@flowdrop/flowdrop 2.8.0 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/CHANGELOG.md +227 -0
  2. package/dist/commands/executor.js +52 -8
  3. package/dist/commands/types.d.ts +3 -0
  4. package/dist/components/App.svelte +8 -0
  5. package/dist/components/App.svelte.d.ts +6 -0
  6. package/dist/components/CanvasContextMenu.stories.svelte +63 -0
  7. package/dist/components/CanvasContextMenu.stories.svelte.d.ts +19 -0
  8. package/dist/components/CanvasContextMenu.svelte +259 -0
  9. package/dist/components/CanvasContextMenu.svelte.d.ts +16 -0
  10. package/dist/components/CanvasController.svelte +23 -1
  11. package/dist/components/CanvasController.svelte.d.ts +16 -0
  12. package/dist/components/UniversalNode.svelte +12 -13
  13. package/dist/components/WorkflowEditor.svelte +364 -27
  14. package/dist/components/WorkflowEditor.svelte.d.ts +7 -0
  15. package/dist/components/WorkflowInterfaceEditor.svelte +28 -3
  16. package/dist/components/WorkflowInterfaceEntryCard.svelte +112 -2
  17. package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +3 -1
  18. package/dist/components/form/FieldFactory.svelte +478 -0
  19. package/dist/components/form/FieldFactory.svelte.d.ts +14 -0
  20. package/dist/components/form/FormField.svelte +19 -404
  21. package/dist/components/form/FormField.svelte.d.ts +2 -27
  22. package/dist/components/form/FormFieldLight.svelte +11 -424
  23. package/dist/components/form/FormFieldLight.svelte.d.ts +2 -28
  24. package/dist/components/form/FormMarkdownEditor.svelte +11 -4
  25. package/dist/components/form/FormTemplateEditor.svelte +12 -5
  26. package/dist/components/form/resolveFieldType.d.ts +18 -15
  27. package/dist/components/form/resolveFieldType.js +33 -12
  28. package/dist/components/form/types.d.ts +14 -2
  29. package/dist/components/nodes/CaptionNode.stories.svelte +65 -0
  30. package/dist/components/nodes/CaptionNode.stories.svelte.d.ts +18 -0
  31. package/dist/components/nodes/CaptionNode.svelte +313 -0
  32. package/dist/components/nodes/CaptionNode.svelte.d.ts +16 -0
  33. package/dist/components/nodes/NotesNode.svelte +6 -0
  34. package/dist/components/playground/ChatBubble.svelte +2 -0
  35. package/dist/components/playground/ChatInput.svelte +18 -34
  36. package/dist/components/playground/ChatInput.svelte.d.ts +7 -0
  37. package/dist/components/playground/ControlPanel.svelte +27 -0
  38. package/dist/components/playground/ControlPanel.svelte.d.ts +12 -0
  39. package/dist/components/playground/ExecutionLogs.svelte +11 -8
  40. package/dist/components/playground/InterfaceInputForm.svelte +74 -0
  41. package/dist/components/playground/InterfaceInputForm.svelte.d.ts +14 -0
  42. package/dist/components/playground/LogRow.svelte +2 -0
  43. package/dist/components/playground/MessageCard.svelte +15 -3
  44. package/dist/components/playground/MessageNotice.svelte +2 -0
  45. package/dist/components/playground/MessageStream.svelte +87 -23
  46. package/dist/components/playground/OriginBadge.svelte +48 -0
  47. package/dist/components/playground/OriginBadge.svelte.d.ts +7 -0
  48. package/dist/components/playground/Playground.svelte +155 -38
  49. package/dist/components/playground/messageDisplay.d.ts +23 -1
  50. package/dist/components/playground/messageDisplay.js +49 -0
  51. package/dist/config/endpoints.d.ts +65 -0
  52. package/dist/config/endpoints.js +39 -0
  53. package/dist/core/index.d.ts +6 -3
  54. package/dist/core/index.js +2 -1
  55. package/dist/editor/contextMenu.d.ts +107 -0
  56. package/dist/editor/contextMenu.js +134 -0
  57. package/dist/editor/index.d.ts +2 -0
  58. package/dist/editor/index.js +1 -0
  59. package/dist/index.d.ts +1 -1
  60. package/dist/index.js +1 -1
  61. package/dist/messages/defaults.d.ts +63 -0
  62. package/dist/messages/defaults.js +59 -0
  63. package/dist/openapi/v1/openapi.yaml +356 -7
  64. package/dist/playground/commands/registry.js +4 -2
  65. package/dist/playground/index.d.ts +3 -2
  66. package/dist/playground/index.js +2 -1
  67. package/dist/registry/builtinNodeTypes.d.ts +1 -1
  68. package/dist/registry/builtinNodeTypes.js +1 -0
  69. package/dist/registry/builtinNodes.js +13 -0
  70. package/dist/registry/nodeComponentRegistry.d.ts +18 -0
  71. package/dist/registry/nodeComponentRegistry.js +14 -2
  72. package/dist/schemas/v1/workflow.schema.json +22 -1
  73. package/dist/services/historyService.d.ts +1 -1
  74. package/dist/services/historyService.js +2 -2
  75. package/dist/services/playgroundService.d.ts +35 -1
  76. package/dist/services/playgroundService.js +82 -36
  77. package/dist/stores/inlineEditStore.svelte.d.ts +35 -0
  78. package/dist/stores/inlineEditStore.svelte.js +63 -0
  79. package/dist/stores/instanceContainer.svelte.d.ts +6 -0
  80. package/dist/stores/instanceContainer.svelte.js +2 -0
  81. package/dist/stores/playgroundStore.svelte.d.ts +59 -2
  82. package/dist/stores/playgroundStore.svelte.js +128 -2
  83. package/dist/styles/base.css +8 -0
  84. package/dist/styles/tokens.css +8 -0
  85. package/dist/svelte-app.d.ts +15 -0
  86. package/dist/svelte-app.js +6 -4
  87. package/dist/types/index.d.ts +34 -1
  88. package/dist/types/index.js +11 -0
  89. package/dist/types/playground.d.ts +90 -9
  90. package/dist/types/playground.js +12 -4
  91. package/dist/utils/captionText.d.ts +43 -0
  92. package/dist/utils/captionText.js +49 -0
  93. package/dist/utils/focus.d.ts +16 -0
  94. package/dist/utils/focus.js +40 -0
  95. package/dist/utils/nodeTypes.js +1 -0
  96. package/dist/utils/nodeWrapper.js +2 -0
  97. package/dist/utils/workflowInterface.d.ts +83 -1
  98. package/dist/utils/workflowInterface.js +192 -1
  99. package/package.json +1 -1
@@ -1,416 +1,31 @@
1
1
  <!--
2
- FormField Component
3
- Factory component that renders the appropriate field based on schema type
4
-
5
- Features:
6
- - Automatically selects the correct field component based on schema
7
- - Wraps fields with FormFieldWrapper for consistent layout
8
- - Supports all current field types (string, number, boolean, checkbox group, range, json, markdown, template, autocomplete)
9
- - Uses standard JSON Schema patterns (enum, oneOf) for select fields
10
- - Extensible architecture for future complex types (array, object)
11
-
12
- Type Resolution Order:
13
- 1. format: 'hidden' -> skip rendering (return nothing)
14
- 2. format: 'autocomplete' with autocomplete.url -> FormAutocomplete
15
- 3. format: 'json' or 'code' -> FormCodeEditor (CodeMirror JSON editor)
16
- 4. format: 'markdown' -> FormMarkdownEditor (SimpleMDE Markdown editor)
17
- 5. format: 'template' -> FormTemplateEditor (CodeMirror with Twig/Liquid syntax)
18
- 6. enum with multiple: true -> FormCheckboxGroup
19
- 7. enum -> FormSelect (simple values without labels)
20
- 8. oneOf with const/title (labeled options) -> FormSelect
21
- 9. format: 'multiline' -> FormTextarea
22
- 10. format: 'range' (number/integer) -> FormRangeField
23
- 11. type: 'string' -> FormTextField
24
- 12. type: 'number' or 'integer' -> FormNumberField
25
- 13. type: 'boolean' -> FormToggle
26
- 14. type: 'object' (without format) -> FormCodeEditor (for JSON objects)
27
- 15. fallback -> FormTextField
2
+ FormField Component (exported as `FormFieldFull` from "@flowdrop/flowdrop/form/full")
3
+
4
+ The field factory with every heavy editor statically bundled, so code,
5
+ markdown and template fields work without registering anything. All field
6
+ resolution lives in FieldFactory; this file only hands it the editors. A component
7
+ registered on the instance's field registry still wins over these.
8
+
9
+ It used to be a second, parallel factory. The two drifted: the light one lost
10
+ the built-in autocomplete and readOnly handling, and since the config panel
11
+ renders the light one, those bugs were the ones users saw.
28
12
  -->
29
13
 
30
14
  <script lang="ts">
31
- import FormFieldWrapper from './FormFieldWrapper.svelte';
32
- import FormTextField from './FormTextField.svelte';
33
- import FormTextarea from './FormTextarea.svelte';
34
- import FormNumberField from './FormNumberField.svelte';
35
- import FormRangeField from './FormRangeField.svelte';
36
- import FormToggle from './FormToggle.svelte';
37
- import FormSelect from './FormSelect.svelte';
38
- import FormCheckboxGroup from './FormCheckboxGroup.svelte';
39
- import FormArray from './FormArray.svelte';
40
- import FormPorts from './FormPorts.svelte';
15
+ import FieldFactory from './FieldFactory.svelte';
41
16
  import FormCodeEditor from './FormCodeEditor.svelte';
42
17
  import FormMarkdownEditor from './FormMarkdownEditor.svelte';
43
18
  import FormTemplateEditor from './FormTemplateEditor.svelte';
44
- import FormAutocomplete from './FormAutocomplete.svelte';
45
- import type { FieldSchema } from './types.js';
46
- import { getSchemaOptions } from './types.js';
47
- import { resolveBaseFieldType } from './resolveFieldType.js';
48
- import type { WorkflowNode, WorkflowEdge, AuthProvider } from '../../types/index.js';
49
- import { getResolvedTheme } from '../../stores/settingsStore.svelte.js';
50
- import { getInstance } from '../../stores/getInstance.svelte.js';
51
-
52
- const fd = getInstance();
53
-
54
- interface Props {
55
- /** Unique key/id for the field */
56
- fieldKey: string;
57
- /** Field schema definition */
58
- schema: FieldSchema;
59
- /** Current field value */
60
- value: unknown;
61
- /** Whether the field is required */
62
- required?: boolean;
63
- /** Animation delay index for staggered animations */
64
- animationIndex?: number;
65
- /** Callback when the field value changes */
66
- onChange: (value: unknown) => void;
67
- /** Current workflow node (optional, used for template variable API mode) */
68
- node?: WorkflowNode;
69
- /** All workflow nodes (optional, used for port-derived variables) */
70
- nodes?: WorkflowNode[];
71
- /** All workflow edges (optional, used for port-derived variables) */
72
- edges?: WorkflowEdge[];
73
- /** Workflow ID (optional, used for template variable API mode) */
74
- workflowId?: string;
75
- /** Auth provider (optional, used for API requests) */
76
- authProvider?: AuthProvider;
77
- }
78
-
79
- let {
80
- fieldKey,
81
- schema,
82
- value,
83
- required = false,
84
- animationIndex = 0,
85
- onChange,
86
- node,
87
- nodes,
88
- edges,
89
- workflowId,
90
- authProvider
91
- }: Props = $props();
92
-
93
- /**
94
- * When schema.readOnly is true, disable all inputs (no editing).
95
- */
96
- const isReadOnly = $derived(schema.readOnly === true);
97
-
98
- /**
99
- * Computed description ID for ARIA association
100
- */
101
- const descriptionId = $derived(
102
- schema.description && schema.title ? `${fieldKey}-description` : undefined
103
- );
104
-
105
- /**
106
- * Animation delay based on index
107
- */
108
- const animationDelay = $derived(animationIndex * 30);
109
-
110
- /**
111
- * Field label - prefer title, fall back to description, then key
112
- */
113
- const fieldLabel = $derived(String(schema.title ?? schema.description ?? fieldKey));
114
-
115
- /**
116
- * Determine the field type to render
117
- */
118
- const fieldType = $derived.by(() => {
119
- // Hidden fields should not be rendered
120
- if (schema.format === 'hidden') {
121
- return 'hidden';
122
- }
123
-
124
- // Autocomplete field for format: "autocomplete" with autocomplete.url
125
- if (schema.format === 'autocomplete' && schema.autocomplete?.url) {
126
- return 'autocomplete';
127
- }
128
19
 
129
- // JSON/code editor for format: "json" or "code"
130
- if (schema.format === 'json' || schema.format === 'code') {
131
- return 'code-editor';
132
- }
20
+ const editors = {
21
+ 'code-editor': FormCodeEditor,
22
+ 'markdown-editor': FormMarkdownEditor,
23
+ 'template-editor': FormTemplateEditor
24
+ };
133
25
 
134
- // Markdown editor for format: "markdown"
135
- if (schema.format === 'markdown') {
136
- return 'markdown-editor';
137
- }
26
+ import type { FormFieldFactoryProps } from './types.js';
138
27
 
139
- // Template editor for format: "template" (Twig/Liquid syntax)
140
- if (schema.format === 'template') {
141
- return 'template-editor';
142
- }
143
-
144
- // Injected port order + exposure widget (the `ports` reserved config prop).
145
- if (schema.format === 'ports') {
146
- return 'ports';
147
- }
148
-
149
- // Shared basic field resolution (enum/oneOf/primitive types).
150
- const base = resolveBaseFieldType(schema);
151
- if (base) {
152
- return base;
153
- }
154
-
155
- // Object type without specific format -> CodeMirror JSON editor
156
- if (schema.type === 'object') {
157
- return 'code-editor';
158
- }
159
-
160
- // Fallback to text
161
- return 'text';
162
- });
163
-
164
- /**
165
- * Get enum options as string array for select/checkbox components
166
- */
167
- const enumOptions = $derived.by((): string[] => {
168
- if (!schema.enum) return [];
169
- return schema.enum.map((opt) => String(opt));
170
- });
171
-
172
- /**
173
- * Get select options for select-options type
174
- * Handles both oneOf (standard) and options (legacy) patterns
175
- */
176
- const selectOptions = $derived(getSchemaOptions(schema));
177
-
178
- /**
179
- * Get current value as the appropriate type
180
- */
181
- const stringValue = $derived(String(value ?? ''));
182
- const numberValue = $derived(value as number | string);
183
- const booleanValue = $derived(Boolean(value ?? schema.default ?? false));
184
- const arrayValue = $derived.by((): string[] => {
185
- if (Array.isArray(value)) {
186
- return value.map((v) => String(v));
187
- }
188
- return [];
189
- });
190
- const arrayItems = $derived.by((): unknown[] => {
191
- if (Array.isArray(value)) {
192
- return value;
193
- }
194
- return [];
195
- });
196
-
197
- const registeredAutocompleteComponent = $derived(
198
- fieldType === 'autocomplete' ? fd.fields.resolveFieldComponent(schema) : null
199
- );
200
-
201
- /**
202
- * Get autocomplete value - can be string or string[] based on multiple setting
203
- */
204
- const autocompleteValue = $derived.by((): string | string[] => {
205
- if (schema.autocomplete?.multiple) {
206
- if (Array.isArray(value)) {
207
- return value.map((v) => String(v));
208
- }
209
- return value ? [String(value)] : [];
210
- }
211
- return String(value ?? '');
212
- });
28
+ let props: FormFieldFactoryProps = $props();
213
29
  </script>
214
30
 
215
- {#if fieldType !== 'hidden'}
216
- <FormFieldWrapper
217
- id={fieldKey}
218
- label={fieldLabel}
219
- {required}
220
- description={schema.title ? schema.description : undefined}
221
- {animationDelay}
222
- >
223
- {#if fieldType === 'checkbox-group'}
224
- <FormCheckboxGroup
225
- id={fieldKey}
226
- value={arrayValue}
227
- options={enumOptions}
228
- ariaDescribedBy={descriptionId}
229
- disabled={isReadOnly}
230
- onChange={(val) => onChange(val)}
231
- />
232
- {:else if fieldType === 'select-enum'}
233
- <FormSelect
234
- id={fieldKey}
235
- value={stringValue}
236
- options={enumOptions}
237
- {required}
238
- ariaDescribedBy={descriptionId}
239
- disabled={isReadOnly}
240
- onChange={(val) => onChange(val)}
241
- />
242
- {:else if fieldType === 'textarea'}
243
- <FormTextarea
244
- id={fieldKey}
245
- value={stringValue}
246
- placeholder={schema.placeholder ?? ''}
247
- {required}
248
- ariaDescribedBy={descriptionId}
249
- disabled={isReadOnly}
250
- onChange={(val) => onChange(val)}
251
- />
252
- {:else if fieldType === 'text'}
253
- <FormTextField
254
- id={fieldKey}
255
- value={stringValue}
256
- placeholder={schema.placeholder ?? ''}
257
- {required}
258
- ariaDescribedBy={descriptionId}
259
- disabled={isReadOnly}
260
- onChange={(val) => onChange(val)}
261
- />
262
- {:else if fieldType === 'number'}
263
- <FormNumberField
264
- id={fieldKey}
265
- value={numberValue}
266
- placeholder={schema.placeholder ?? ''}
267
- min={schema.minimum}
268
- max={schema.maximum}
269
- step={schema.step}
270
- {required}
271
- ariaDescribedBy={descriptionId}
272
- disabled={isReadOnly}
273
- onChange={(val) => onChange(val)}
274
- />
275
- {:else if fieldType === 'range'}
276
- <FormRangeField
277
- id={fieldKey}
278
- value={numberValue}
279
- min={schema.minimum}
280
- max={schema.maximum}
281
- step={schema.step}
282
- {required}
283
- ariaDescribedBy={descriptionId}
284
- disabled={isReadOnly}
285
- onChange={(val) => onChange(val)}
286
- />
287
- {:else if fieldType === 'toggle'}
288
- <FormToggle
289
- id={fieldKey}
290
- value={booleanValue}
291
- ariaDescribedBy={descriptionId}
292
- disabled={isReadOnly}
293
- onChange={(val) => onChange(val)}
294
- />
295
- {:else if fieldType === 'select-options'}
296
- <FormSelect
297
- id={fieldKey}
298
- value={stringValue}
299
- options={selectOptions}
300
- {required}
301
- ariaDescribedBy={descriptionId}
302
- disabled={isReadOnly}
303
- onChange={(val) => onChange(val)}
304
- />
305
- {:else if fieldType === 'array' && schema.items}
306
- <FormArray
307
- id={fieldKey}
308
- value={arrayItems}
309
- itemSchema={schema.items}
310
- minItems={schema.minItems}
311
- maxItems={schema.maxItems}
312
- addLabel={`Add ${schema.items.title ?? 'Item'}`}
313
- disabled={isReadOnly}
314
- onChange={(val) => onChange(val)}
315
- />
316
- {:else if fieldType === 'ports'}
317
- <FormPorts
318
- id={fieldKey}
319
- {value}
320
- ariaDescribedBy={descriptionId}
321
- disabled={isReadOnly}
322
- {node}
323
- onChange={(val) => onChange(val)}
324
- />
325
- {:else if fieldType === 'code-editor'}
326
- <FormCodeEditor
327
- id={fieldKey}
328
- {value}
329
- placeholder={schema.placeholder ?? '{}'}
330
- {required}
331
- height={(schema.height as string | undefined) ?? '200px'}
332
- darkTheme={(schema.darkTheme as boolean | undefined) ?? getResolvedTheme() === 'dark'}
333
- autoFormat={(schema.autoFormat as boolean | undefined) ?? true}
334
- ariaDescribedBy={descriptionId}
335
- disabled={isReadOnly}
336
- onChange={(val) => onChange(val)}
337
- />
338
- {:else if fieldType === 'markdown-editor'}
339
- <FormMarkdownEditor
340
- id={fieldKey}
341
- value={stringValue}
342
- placeholder={schema.placeholder ?? 'Write your markdown here...'}
343
- {required}
344
- height={(schema.height as string | undefined) ?? '300px'}
345
- showToolbar={(schema.showToolbar as boolean | undefined) ?? true}
346
- showStatusBar={(schema.showStatusBar as boolean | undefined) ?? true}
347
- spellChecker={(schema.spellChecker as boolean | undefined) ?? false}
348
- ariaDescribedBy={descriptionId}
349
- disabled={isReadOnly}
350
- onChange={(val) => onChange(val)}
351
- />
352
- {:else if fieldType === 'template-editor'}
353
- <FormTemplateEditor
354
- id={fieldKey}
355
- value={stringValue}
356
- placeholder={schema.placeholder ??
357
- 'Enter your template here...\nUse {{ variable }} for dynamic values.'}
358
- {required}
359
- height={(schema.height as string | undefined) ?? '250px'}
360
- darkTheme={(schema.darkTheme as boolean | undefined) ?? getResolvedTheme() === 'dark'}
361
- variables={schema.variables}
362
- placeholderExample={(schema.placeholderExample as string | undefined) ??
363
- 'Hello {{ name }}, your order #{{ order_id }} is ready!'}
364
- ariaDescribedBy={descriptionId}
365
- disabled={isReadOnly}
366
- {node}
367
- {nodes}
368
- {edges}
369
- {workflowId}
370
- {authProvider}
371
- onChange={(val) => onChange(val)}
372
- />
373
- {:else if fieldType === 'autocomplete' && schema.autocomplete && registeredAutocompleteComponent}
374
- <registeredAutocompleteComponent.component
375
- id={fieldKey}
376
- value={autocompleteValue}
377
- placeholder={schema.placeholder ?? ''}
378
- {required}
379
- {schema}
380
- ariaDescribedBy={descriptionId}
381
- disabled={isReadOnly}
382
- {node}
383
- {nodes}
384
- {edges}
385
- {workflowId}
386
- {authProvider}
387
- onChange={(val: unknown) => onChange(val)}
388
- />
389
- {:else if fieldType === 'autocomplete' && schema.autocomplete}
390
- <FormAutocomplete
391
- id={fieldKey}
392
- value={autocompleteValue}
393
- autocomplete={schema.autocomplete}
394
- placeholder={schema.placeholder ?? ''}
395
- {required}
396
- ariaDescribedBy={descriptionId}
397
- disabled={isReadOnly}
398
- onChange={(val) => onChange(val)}
399
- />
400
- {:else}
401
- <!-- Fallback to text input -->
402
- <FormTextField
403
- id={fieldKey}
404
- value={stringValue}
405
- placeholder={schema.placeholder ?? ''}
406
- ariaDescribedBy={descriptionId}
407
- disabled={isReadOnly}
408
- onChange={(val) => onChange(val)}
409
- />
410
- {/if}
411
- </FormFieldWrapper>
412
- {/if}
413
-
414
- <style>
415
- /* Styles moved to individual form components */
416
- </style>
31
+ <FieldFactory {...props} {editors} />
@@ -1,29 +1,4 @@
1
- import type { FieldSchema } from './types.js';
2
- import type { WorkflowNode, WorkflowEdge, AuthProvider } from '../../types/index.js';
3
- interface Props {
4
- /** Unique key/id for the field */
5
- fieldKey: string;
6
- /** Field schema definition */
7
- schema: FieldSchema;
8
- /** Current field value */
9
- value: unknown;
10
- /** Whether the field is required */
11
- required?: boolean;
12
- /** Animation delay index for staggered animations */
13
- animationIndex?: number;
14
- /** Callback when the field value changes */
15
- onChange: (value: unknown) => void;
16
- /** Current workflow node (optional, used for template variable API mode) */
17
- node?: WorkflowNode;
18
- /** All workflow nodes (optional, used for port-derived variables) */
19
- nodes?: WorkflowNode[];
20
- /** All workflow edges (optional, used for port-derived variables) */
21
- edges?: WorkflowEdge[];
22
- /** Workflow ID (optional, used for template variable API mode) */
23
- workflowId?: string;
24
- /** Auth provider (optional, used for API requests) */
25
- authProvider?: AuthProvider;
26
- }
27
- declare const FormField: import("svelte").Component<Props, {}, "">;
1
+ import type { FormFieldFactoryProps } from './types.js';
2
+ declare const FormField: import("svelte").Component<FormFieldFactoryProps, {}, "">;
28
3
  type FormField = ReturnType<typeof FormField>;
29
4
  export default FormField;