Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Configuration to Support Documentation and Editors #204

Open
bhouston opened this issue Jan 1, 2023 · 0 comments
Open

Improved Configuration to Support Documentation and Editors #204

bhouston opened this issue Jan 1, 2023 · 0 comments

Comments

@bhouston
Copy link
Owner

bhouston commented Jan 1, 2023

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');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant