Skip to content

Improved Configuration to Support Documentation and Editors #204

@bhouston

Description

@bhouston

Here is a comment from @aitorllj93 that is important to address: #201 (comment)

@bhouston @oveddan Regarding the dynamic I/O here are the tricks I had to use in order to be able to identify them:

First I had to instantiate every single node with numInputs and numOutputs setted so I can get them from the Node instance, also had to initialize the customEvents and variables properties because otherwise some nodes were crashing:
image
Then I had to compare the Node instance which has the dynamic nodes already setted with the NodeSpec which doesn't have them so I can figure out if that Node has dynamic I/O. This only works for numeric cases
image

That's the reason I think the dynamic I/O specification is incomplete with just the numInputs/numOutputs configuration, I think we should be able to determine before the Node gets instantiated:

  • whether a Node can have dynamic I/O or not (this is currently doable with the configuration definition but only if the Node has a single case for each, ie. it's not possible to define a Node with n text inputs + n flow inputs)
  • which types will those sockets accept
  • and maybe which names do they accept (numeric, text...)

Right now this is a must not only to be able to provide a better logic for docs generation but for the visual editor to be able to recognize them as well

It would be great to have something like this in the NodeSpec:

dynamicInputs:
  flows:
    valueType: "flow"
    keyType: "integer"
    maxAmount: 5
    minAmount: 1
  numbers:
    valueType: "integer"
    keyType: "text"
    maxAmount: 10
dynamicOutputs:
  results:
    valueType: "text"
    keyType: "text"
    minAmount: 1

Or maybe considering the current NodeSpec implementation we can extend the inputs & outputs types to allow it:

inputs: 
  - name: flows
    valueType: flow
    isMultiple: true
    keyType: integer
    minAmount: 1
    maxAmount: 5

And just query by the isMultiple/isDynamic (Idk how to name it) prop

In order to use them inside the Node we could just get the "group" by the name and iterate over them:

const textInputs = readInput<DynamicInput<string, string>[]>('texts');
const inputText = textInputs.find(t => t.name === 'myTextInput').value;

const flowSockets = this.outputSockets.find((s) => s.name === 'flows')?.sockets;
const specificFlowSocket = flowSockets.find(s  => s.name === 'mySwitchCase');

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions