go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/projects/nodes/static/_nextjs/src/store/apiEffect.ts (about)

     1  /**
     2   * Copyright (c) 2024 - Present. Will Charczuk. All rights reserved.
     3   * Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository.
     4   */
     5  import { Viewport, XYPosition } from "reactflow";
     6  import * as api from '../api/nodes';
     7  
     8  export interface ApiEffectAddNode {
     9    type: 'add-node',
    10    node: Omit<api.Node, 'id'>;
    11    value?: any;
    12  }
    13  
    14  export interface ApiEffectDuplicateNode {
    15    type: 'duplicate-node',
    16    node: api.Node;
    17  }
    18  
    19  export interface ApiEffectSetStale {
    20    type: 'set-stale',
    21    node_id: string;
    22  }
    23  
    24  export interface ApiEffectUnlinkNodes {
    25    type: 'unlink-nodes',
    26    parent_id: string;
    27    child_id: string;
    28    child_input_name: string | null;
    29  }
    30  
    31  export interface ApiEffectLinkNodes {
    32    type: 'link-nodes',
    33    parent_id: string;
    34    child_id: string;
    35    child_input_name: string | null;
    36  }
    37  
    38  export interface ApiEffectRemoveNode {
    39    type: 'remove-node',
    40    node_id: string;
    41  }
    42  
    43  export interface ApiEffectUpdateLabel {
    44    type: 'update-label',
    45    node_id: string;
    46    label: string;
    47  }
    48  
    49  export interface ApiEffectUpdateExpression {
    50    type: 'update-expression',
    51    node_id: string;
    52    expression: string;
    53  }
    54  
    55  export interface ApiEffectUpdateValue {
    56    type: 'update-value',
    57    node_id: string;
    58    value: any;
    59  }
    60  
    61  export interface ApiEffectUpdatePosition {
    62    type: 'update-position',
    63    node_id: string;
    64    position: XYPosition;
    65  }
    66  
    67  export interface ApiEffectUpdateSize {
    68    type: 'update-size',
    69    node_id: string;
    70    height: number;
    71    width: number;
    72  }
    73  
    74  export interface ApiEffectUpdateCollapsedAll {
    75    type: 'update-collapsed-all',
    76    collapsed: boolean;
    77  }
    78  
    79  export interface ApiEffectUpdateGroupCollapsed {
    80    type: 'update-group-collapsed',
    81    node_group_id: string;
    82    collapsed: boolean;
    83  }
    84  
    85  export interface ApiEffectUpdateCollapsed {
    86    type: 'update-collapsed',
    87    node_id: string;
    88    collapsed: boolean;
    89  }
    90  
    91  export interface ApiEffectUpdateWatched {
    92    type: 'update-watched',
    93    node_id: string;
    94    watched: boolean;
    95  }
    96  
    97  export interface ApiEffectUpdateWatchedCollapsed {
    98    type: 'update-watched-collapsed',
    99    node_id: string;
   100    watched_collapsed: boolean;
   101  }
   102  
   103  export interface ApiEffectUpdateGraphViewport {
   104    type: 'update-graph-viewport',
   105    graph_id: string;
   106    viewport: Viewport,
   107  }
   108  
   109  export interface ApiEffectUpdateGraphLabel {
   110    type: 'update-graph-label',
   111    graph_id: string;
   112    label: string,
   113  }
   114  
   115  export interface ApiEffectDeleteGraph {
   116    type: 'delete-graph',
   117    graph_id: string;
   118  }
   119  
   120  export type ApiEffect = ApiEffectUpdateGraphViewport | ApiEffectUpdateGraphLabel | ApiEffectDeleteGraph | ApiEffectUpdateCollapsed | ApiEffectUpdateGroupCollapsed | ApiEffectUpdateCollapsedAll |
   121    ApiEffectUpdatePosition | ApiEffectUpdateSize | ApiEffectUpdateValue | ApiEffectUpdateExpression | ApiEffectUpdateLabel | ApiEffectUpdateWatched | ApiEffectUpdateWatchedCollapsed |
   122    ApiEffectAddNode | ApiEffectDuplicateNode | ApiEffectRemoveNode | ApiEffectLinkNodes | ApiEffectUnlinkNodes |
   123    ApiEffectSetStale | ApiEffectAddNode;