@elqnt/workflow 2.1.4 → 2.2.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 (45) hide show
  1. package/README.md +6 -0
  2. package/SKILL.md +442 -0
  3. package/dist/api/index.js +3 -4
  4. package/dist/api/index.js.map +1 -1
  5. package/dist/api/index.mjs +1 -2
  6. package/dist/chunk-3GG6KTGJ.js +998 -0
  7. package/dist/chunk-3GG6KTGJ.js.map +1 -0
  8. package/dist/{chunk-UE4ZBFLG.mjs → chunk-4AUWFGQK.mjs} +1 -3
  9. package/dist/{chunk-UE4ZBFLG.mjs.map → chunk-4AUWFGQK.mjs.map} +1 -1
  10. package/dist/{chunk-H24IF5AA.js → chunk-6DV2LPSN.js} +2 -4
  11. package/dist/chunk-6DV2LPSN.js.map +1 -0
  12. package/dist/chunk-AXXQSYT7.mjs +998 -0
  13. package/dist/chunk-AXXQSYT7.mjs.map +1 -0
  14. package/dist/{chunk-YCEGKVXP.mjs → chunk-IY5JCMLA.mjs} +1 -3
  15. package/dist/{chunk-YCEGKVXP.mjs.map → chunk-IY5JCMLA.mjs.map} +1 -1
  16. package/dist/{chunk-JES2EBNO.js → chunk-YCO5IFZK.js} +2 -4
  17. package/dist/chunk-YCO5IFZK.js.map +1 -0
  18. package/dist/components/index.d.mts +245 -0
  19. package/dist/components/index.d.ts +245 -0
  20. package/dist/components/index.js +10 -0
  21. package/dist/components/index.js.map +1 -0
  22. package/dist/components/index.mjs +10 -0
  23. package/dist/components/index.mjs.map +1 -0
  24. package/dist/hooks/index.d.mts +72 -27
  25. package/dist/hooks/index.d.ts +72 -27
  26. package/dist/hooks/index.js +397 -5
  27. package/dist/hooks/index.js.map +1 -1
  28. package/dist/hooks/index.mjs +401 -9
  29. package/dist/hooks/index.mjs.map +1 -1
  30. package/dist/index.d.mts +4 -246
  31. package/dist/index.d.ts +4 -246
  32. package/dist/index.js +8 -1012
  33. package/dist/index.js.map +1 -1
  34. package/dist/index.mjs +5 -1009
  35. package/dist/index.mjs.map +1 -1
  36. package/dist/models/index.js +3 -4
  37. package/dist/models/index.js.map +1 -1
  38. package/dist/models/index.mjs +1 -2
  39. package/package.json +12 -6
  40. package/dist/chunk-H24IF5AA.js.map +0 -1
  41. package/dist/chunk-JES2EBNO.js.map +0 -1
  42. package/dist/chunk-KWWX35B4.js +0 -413
  43. package/dist/chunk-KWWX35B4.js.map +0 -1
  44. package/dist/chunk-WDERYFU3.mjs +0 -413
  45. package/dist/chunk-WDERYFU3.mjs.map +0 -1
package/dist/index.mjs CHANGED
@@ -1,12 +1,7 @@
1
- "use client";
2
1
  import {
3
- useApiAsync,
4
- useAsync,
5
- useOptionsRef,
6
- useWorkflowInstances,
7
- useWorkflowTemplates,
8
- useWorkflows
9
- } from "./chunk-WDERYFU3.mjs";
2
+ DynamicSchemaForm,
3
+ SchemaBuilder
4
+ } from "./chunk-AXXQSYT7.mjs";
10
5
  import {
11
6
  createWorkflowApi,
12
7
  createWorkflowInstanceApi,
@@ -23,7 +18,7 @@ import {
23
18
  retryWorkflowNodeApi,
24
19
  updateWorkflowApi,
25
20
  updateWorkflowInstanceStatusApi
26
- } from "./chunk-UE4ZBFLG.mjs";
21
+ } from "./chunk-4AUWFGQK.mjs";
27
22
  import {
28
23
  EdgeStatusCompleted,
29
24
  EdgeStatusPending,
@@ -174,1000 +169,7 @@ import {
174
169
  WorkflowTypeDocument,
175
170
  WorkflowTypeEntity,
176
171
  WorkflowTypeProductivity
177
- } from "./chunk-YCEGKVXP.mjs";
178
-
179
- // components/dynamic-schema-form.tsx
180
- import { useState } from "react";
181
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
182
- function DynamicSchemaForm({
183
- schema,
184
- value = {},
185
- onChange,
186
- disabled = false,
187
- path = [],
188
- components,
189
- variables = [],
190
- showVariablePicker = false
191
- }) {
192
- const [collapsedSections, setCollapsedSections] = useState(
193
- /* @__PURE__ */ new Set()
194
- );
195
- const [openVariablePickers, setOpenVariablePickers] = useState(
196
- /* @__PURE__ */ new Set()
197
- );
198
- const [openRichTextDialogs, setOpenRichTextDialogs] = useState(
199
- /* @__PURE__ */ new Set()
200
- );
201
- const [richTextDraftValues, setRichTextDraftValues] = useState({});
202
- const {
203
- Input,
204
- Label,
205
- Textarea,
206
- Checkbox,
207
- Select,
208
- SelectTrigger,
209
- SelectValue,
210
- SelectContent,
211
- SelectItem,
212
- Button,
213
- Card,
214
- PlusIcon,
215
- TrashIcon,
216
- ChevronDownIcon,
217
- ChevronRightIcon,
218
- VariableIcon,
219
- CheckIcon,
220
- EditIcon,
221
- Popover,
222
- PopoverTrigger,
223
- PopoverContent,
224
- Dialog,
225
- DialogContent,
226
- DialogHeader,
227
- DialogTitle,
228
- DialogFooter,
229
- ScrollArea,
230
- MarkdownEditor,
231
- cn
232
- } = components;
233
- const isVariableReference = (val) => {
234
- return typeof val === "string" && val.startsWith("{{") && val.endsWith("}}");
235
- };
236
- const getMatchingVariables = (fieldType) => {
237
- if (!fieldType) return variables;
238
- const compatibleTypes = {
239
- string: ["string"],
240
- number: ["number", "integer"],
241
- integer: ["number", "integer"],
242
- boolean: ["boolean"],
243
- object: ["object"],
244
- array: ["array"]
245
- };
246
- const compatible = compatibleTypes[fieldType] || [fieldType];
247
- return variables.filter((v) => compatible.includes(v.type));
248
- };
249
- const toggleVariablePicker = (fieldPath) => {
250
- setOpenVariablePickers((prev) => {
251
- const next = new Set(prev);
252
- if (next.has(fieldPath)) {
253
- next.delete(fieldPath);
254
- } else {
255
- next.add(fieldPath);
256
- }
257
- return next;
258
- });
259
- };
260
- const renderVariablePicker = (fieldName, fieldType, fieldPath, onSelect) => {
261
- if (!showVariablePicker) {
262
- return null;
263
- }
264
- if (!VariableIcon || !Popover || !PopoverTrigger || !PopoverContent) {
265
- return null;
266
- }
267
- const matchingVars = getMatchingVariables(fieldType);
268
- const isOpen = openVariablePickers.has(fieldPath);
269
- const currentValue = value[fieldName];
270
- const isVariable = isVariableReference(currentValue);
271
- return /* @__PURE__ */ jsxs(
272
- Popover,
273
- {
274
- open: isOpen,
275
- onOpenChange: (open) => {
276
- if (open) {
277
- setOpenVariablePickers((prev) => new Set(prev).add(fieldPath));
278
- } else {
279
- setOpenVariablePickers((prev) => {
280
- const next = new Set(prev);
281
- next.delete(fieldPath);
282
- return next;
283
- });
284
- }
285
- },
286
- children: [
287
- /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
288
- Button,
289
- {
290
- type: "button",
291
- variant: "outline",
292
- size: "sm",
293
- className: cn(
294
- "h-8 px-2 shrink-0",
295
- isVariable && "border-primary text-primary"
296
- ),
297
- disabled,
298
- children: /* @__PURE__ */ jsx(VariableIcon, { className: "h-3.5 w-3.5" })
299
- }
300
- ) }),
301
- /* @__PURE__ */ jsxs(PopoverContent, { className: "w-56 p-1", align: "end", children: [
302
- /* @__PURE__ */ jsxs("div", { className: "text-xs font-medium text-muted-foreground px-2 py-1.5", children: [
303
- "Select Variable (",
304
- fieldType || "any",
305
- ")"
306
- ] }),
307
- /* @__PURE__ */ jsx("div", { className: "max-h-48 overflow-y-auto", children: matchingVars.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "px-2 py-3 text-xs text-muted-foreground text-center", children: [
308
- "No variables available.",
309
- /* @__PURE__ */ jsx("br", {}),
310
- /* @__PURE__ */ jsx("span", { className: "text-[10px]", children: "Add variables in Workflow Settings \u2192 Variables" })
311
- ] }) : matchingVars.map((variable) => {
312
- const varRef = `{{${variable.path}}}`;
313
- const isSelected = currentValue === varRef;
314
- return /* @__PURE__ */ jsxs(
315
- "button",
316
- {
317
- type: "button",
318
- className: cn(
319
- "w-full text-left px-2 py-1.5 text-xs rounded hover:bg-accent flex items-center justify-between",
320
- isSelected && "bg-accent"
321
- ),
322
- onClick: () => {
323
- onSelect(varRef);
324
- setOpenVariablePickers((prev) => {
325
- const next = new Set(prev);
326
- next.delete(fieldPath);
327
- return next;
328
- });
329
- },
330
- children: [
331
- /* @__PURE__ */ jsxs("div", { children: [
332
- /* @__PURE__ */ jsx("div", { className: "font-medium", children: variable.title || variable.name }),
333
- /* @__PURE__ */ jsx("div", { className: "text-[10px] text-muted-foreground font-mono", children: variable.path })
334
- ] }),
335
- isSelected && CheckIcon && /* @__PURE__ */ jsx(CheckIcon, { className: "h-3 w-3" })
336
- ]
337
- },
338
- variable.path
339
- );
340
- }) })
341
- ] })
342
- ]
343
- }
344
- );
345
- };
346
- const toggleSection = (key) => {
347
- setCollapsedSections((prev) => {
348
- const next = new Set(prev);
349
- if (next.has(key)) {
350
- next.delete(key);
351
- } else {
352
- next.add(key);
353
- }
354
- return next;
355
- });
356
- };
357
- const handleFieldChange = (fieldName, fieldValue) => {
358
- onChange({
359
- ...value,
360
- [fieldName]: fieldValue
361
- });
362
- };
363
- const renderField = (fieldSchema, fieldName, fieldValue) => {
364
- const fieldPath = [...path, fieldName].join(".");
365
- const isRequired = schema.required?.includes(fieldName);
366
- if (fieldSchema.enum) {
367
- const labels = fieldSchema["x-enumLabels"] || fieldSchema.enum;
368
- return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
369
- /* @__PURE__ */ jsxs(Label, { className: "text-xs font-medium", children: [
370
- fieldSchema.title || fieldName,
371
- isRequired && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
372
- ] }),
373
- /* @__PURE__ */ jsxs(
374
- Select,
375
- {
376
- value: fieldValue || "",
377
- onValueChange: (v) => handleFieldChange(fieldName, v),
378
- disabled,
379
- children: [
380
- /* @__PURE__ */ jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsx(
381
- SelectValue,
382
- {
383
- placeholder: `Select ${fieldSchema.title || fieldName}`
384
- }
385
- ) }),
386
- /* @__PURE__ */ jsx(SelectContent, { children: fieldSchema.enum.map((option, idx) => /* @__PURE__ */ jsx(SelectItem, { value: option, className: "text-xs", children: labels[idx] || option }, option)) })
387
- ]
388
- }
389
- ),
390
- fieldSchema.description && /* @__PURE__ */ jsx("p", { className: "text-[10px] text-muted-foreground", children: fieldSchema.description })
391
- ] }, fieldPath);
392
- }
393
- if (fieldSchema.type === "object" && fieldSchema.properties) {
394
- const isCollapsed = collapsedSections.has(fieldPath);
395
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
396
- /* @__PURE__ */ jsxs(
397
- "button",
398
- {
399
- type: "button",
400
- onClick: () => toggleSection(fieldPath),
401
- className: "flex items-center gap-1 text-xs font-medium text-gray-700 hover:text-gray-900",
402
- children: [
403
- isCollapsed ? /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-3 w-3" }),
404
- fieldSchema.title || fieldName
405
- ]
406
- }
407
- ),
408
- !isCollapsed && /* @__PURE__ */ jsx(Card, { className: "p-3 bg-gray-50/50", children: /* @__PURE__ */ jsx(
409
- DynamicSchemaForm,
410
- {
411
- schema: fieldSchema,
412
- value: fieldValue || {},
413
- onChange: (v) => handleFieldChange(fieldName, v),
414
- disabled,
415
- path: [...path, fieldName],
416
- components,
417
- variables,
418
- showVariablePicker
419
- }
420
- ) })
421
- ] }, fieldPath);
422
- }
423
- if (fieldSchema.type === "array" && fieldSchema.items) {
424
- const arrayValue = Array.isArray(fieldValue) ? fieldValue : [];
425
- const itemSchema = fieldSchema.items;
426
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
427
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
428
- /* @__PURE__ */ jsxs(Label, { className: "text-xs font-medium", children: [
429
- fieldSchema.title || fieldName,
430
- isRequired && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
431
- ] }),
432
- /* @__PURE__ */ jsxs(
433
- Button,
434
- {
435
- type: "button",
436
- variant: "outline",
437
- size: "sm",
438
- className: "h-6 text-xs px-2",
439
- onClick: () => {
440
- const newItem = itemSchema.type === "object" ? {} : "";
441
- handleFieldChange(fieldName, [...arrayValue, newItem]);
442
- },
443
- disabled,
444
- children: [
445
- /* @__PURE__ */ jsx(PlusIcon, { className: "h-3 w-3 mr-1" }),
446
- "Add"
447
- ]
448
- }
449
- )
450
- ] }),
451
- fieldSchema.description && /* @__PURE__ */ jsx("p", { className: "text-[10px] text-muted-foreground", children: fieldSchema.description }),
452
- /* @__PURE__ */ jsx("div", { className: "space-y-2", children: arrayValue.map((item, index) => /* @__PURE__ */ jsxs("div", { className: "flex gap-2 items-start", children: [
453
- /* @__PURE__ */ jsx("div", { className: "flex-1", children: itemSchema.type === "object" ? /* @__PURE__ */ jsx(Card, { className: "p-2 bg-gray-50/50", children: /* @__PURE__ */ jsx(
454
- DynamicSchemaForm,
455
- {
456
- schema: itemSchema,
457
- value: item,
458
- onChange: (v) => {
459
- const newArray = [...arrayValue];
460
- newArray[index] = v;
461
- handleFieldChange(fieldName, newArray);
462
- },
463
- disabled,
464
- path: [...path, fieldName, String(index)],
465
- components,
466
- variables,
467
- showVariablePicker
468
- }
469
- ) }) : /* @__PURE__ */ jsx(
470
- Input,
471
- {
472
- value: item || "",
473
- onChange: (e) => {
474
- const newArray = [...arrayValue];
475
- newArray[index] = e.target.value;
476
- handleFieldChange(fieldName, newArray);
477
- },
478
- disabled,
479
- className: "h-8 text-xs"
480
- }
481
- ) }),
482
- /* @__PURE__ */ jsx(
483
- Button,
484
- {
485
- type: "button",
486
- variant: "ghost",
487
- size: "sm",
488
- className: "h-8 w-8 p-0 text-red-500 hover:text-red-700",
489
- onClick: () => {
490
- const newArray = arrayValue.filter(
491
- (_, i) => i !== index
492
- );
493
- handleFieldChange(fieldName, newArray);
494
- },
495
- disabled,
496
- children: /* @__PURE__ */ jsx(TrashIcon, { className: "h-3 w-3" })
497
- }
498
- )
499
- ] }, index)) })
500
- ] }, fieldPath);
501
- }
502
- if (fieldSchema.type === "boolean") {
503
- return /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
504
- /* @__PURE__ */ jsx(
505
- Checkbox,
506
- {
507
- id: fieldPath,
508
- checked: !!fieldValue,
509
- onCheckedChange: (checked) => handleFieldChange(fieldName, checked),
510
- disabled
511
- }
512
- ),
513
- /* @__PURE__ */ jsxs(Label, { htmlFor: fieldPath, className: "text-xs font-normal", children: [
514
- fieldSchema.title || fieldName,
515
- isRequired && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
516
- ] }),
517
- fieldSchema.description && /* @__PURE__ */ jsxs("span", { className: "text-[10px] text-muted-foreground ml-2", children: [
518
- "(",
519
- fieldSchema.description,
520
- ")"
521
- ] })
522
- ] }, fieldPath);
523
- }
524
- if (fieldSchema.type === "number" || fieldSchema.type === "integer") {
525
- const isVarValue = isVariableReference(fieldValue);
526
- return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
527
- /* @__PURE__ */ jsxs(Label, { className: "text-xs font-medium", children: [
528
- fieldSchema.title || fieldName,
529
- isRequired && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
530
- ] }),
531
- /* @__PURE__ */ jsxs("div", { className: "flex gap-1.5", children: [
532
- /* @__PURE__ */ jsx(
533
- Input,
534
- {
535
- type: isVarValue ? "text" : "number",
536
- value: fieldValue ?? "",
537
- onChange: (e) => {
538
- if (isVariableReference(e.target.value)) {
539
- handleFieldChange(fieldName, e.target.value);
540
- } else {
541
- const val = e.target.value === "" ? void 0 : Number(e.target.value);
542
- handleFieldChange(fieldName, val);
543
- }
544
- },
545
- min: fieldSchema.minimum,
546
- max: fieldSchema.maximum,
547
- step: fieldSchema.type === "integer" ? 1 : "any",
548
- disabled,
549
- className: cn("h-8 text-xs flex-1", isVarValue && "font-mono text-primary")
550
- }
551
- ),
552
- renderVariablePicker(
553
- fieldName,
554
- fieldSchema.type,
555
- fieldPath,
556
- (varPath) => handleFieldChange(fieldName, varPath)
557
- )
558
- ] }),
559
- fieldSchema.description && /* @__PURE__ */ jsx("p", { className: "text-[10px] text-muted-foreground", children: fieldSchema.description })
560
- ] }, fieldPath);
561
- }
562
- if (fieldSchema.type === "string") {
563
- if (fieldSchema.format === "richtext") {
564
- const isDialogOpen = openRichTextDialogs.has(fieldPath);
565
- const draftValue = richTextDraftValues[fieldPath] ?? fieldValue ?? "";
566
- const previewText = (fieldValue || "").replace(/<[^>]*>/g, "").slice(0, 50);
567
- const matchingVars = getMatchingVariables("string");
568
- if (!Dialog || !DialogContent || !DialogHeader || !DialogTitle || !DialogFooter) {
569
- return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
570
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
571
- /* @__PURE__ */ jsxs(Label, { className: "text-xs font-medium", children: [
572
- fieldSchema.title || fieldName,
573
- isRequired && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
574
- ] }),
575
- renderVariablePicker(
576
- fieldName,
577
- "string",
578
- fieldPath,
579
- (varPath) => handleFieldChange(fieldName, (fieldValue || "") + varPath)
580
- )
581
- ] }),
582
- /* @__PURE__ */ jsx(
583
- Textarea,
584
- {
585
- value: fieldValue || "",
586
- onChange: (e) => handleFieldChange(fieldName, e.target.value),
587
- disabled,
588
- rows: 3,
589
- className: "text-xs",
590
- placeholder: fieldSchema.description
591
- }
592
- )
593
- ] }, fieldPath);
594
- }
595
- return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
596
- /* @__PURE__ */ jsxs(Label, { className: "text-xs font-medium", children: [
597
- fieldSchema.title || fieldName,
598
- isRequired && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
599
- ] }),
600
- /* @__PURE__ */ jsxs("div", { className: "flex gap-1.5", children: [
601
- /* @__PURE__ */ jsx("div", { className: "flex-1 min-w-0 px-2 py-1.5 bg-muted/50 rounded text-xs text-muted-foreground truncate border", children: previewText || /* @__PURE__ */ jsx("span", { className: "italic", children: "Click edit to add content..." }) }),
602
- /* @__PURE__ */ jsx(
603
- Button,
604
- {
605
- type: "button",
606
- variant: "outline",
607
- size: "sm",
608
- className: "h-8 px-2 shrink-0",
609
- onClick: () => {
610
- setRichTextDraftValues((prev) => ({ ...prev, [fieldPath]: fieldValue || "" }));
611
- setOpenRichTextDialogs((prev) => new Set(prev).add(fieldPath));
612
- },
613
- disabled,
614
- children: EditIcon ? /* @__PURE__ */ jsx(EditIcon, { className: "h-3.5 w-3.5" }) : "Edit"
615
- }
616
- )
617
- ] }),
618
- /* @__PURE__ */ jsx(
619
- Dialog,
620
- {
621
- open: isDialogOpen,
622
- onOpenChange: (open) => {
623
- if (!open) {
624
- setOpenRichTextDialogs((prev) => {
625
- const next = new Set(prev);
626
- next.delete(fieldPath);
627
- return next;
628
- });
629
- }
630
- },
631
- children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-3xl max-h-[85vh] flex flex-col", children: [
632
- /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { children: [
633
- "Edit ",
634
- fieldSchema.title || fieldName
635
- ] }) }),
636
- /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-hidden flex flex-col min-h-0", children: MarkdownEditor ? /* @__PURE__ */ jsx(
637
- MarkdownEditor,
638
- {
639
- content: draftValue,
640
- onChange: (value2) => {
641
- setRichTextDraftValues((prev) => ({ ...prev, [fieldPath]: value2 }));
642
- },
643
- placeholder: "Enter content... Use {{variables.name}} for dynamic values",
644
- minHeight: "300px",
645
- variables: showVariablePicker ? matchingVars : []
646
- }
647
- ) : /* @__PURE__ */ jsxs(Fragment, { children: [
648
- /* @__PURE__ */ jsx(
649
- Textarea,
650
- {
651
- value: draftValue,
652
- onChange: (e) => {
653
- setRichTextDraftValues((prev) => ({ ...prev, [fieldPath]: e.target.value }));
654
- },
655
- rows: 12,
656
- className: "flex-1 text-sm font-mono resize-none",
657
- placeholder: "Enter content... Use {{variables.name}} for dynamic values"
658
- }
659
- ),
660
- showVariablePicker && matchingVars.length > 0 && /* @__PURE__ */ jsxs("div", { className: "border rounded-md p-2 bg-muted/30 mt-3", children: [
661
- /* @__PURE__ */ jsx("p", { className: "text-xs font-medium mb-2", children: "Insert Variable:" }),
662
- /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: matchingVars.map((variable) => /* @__PURE__ */ jsx(
663
- Button,
664
- {
665
- type: "button",
666
- variant: "outline",
667
- size: "sm",
668
- className: "h-6 text-xs px-2",
669
- onClick: () => {
670
- const varRef = `{{${variable.path}}}`;
671
- setRichTextDraftValues((prev) => ({
672
- ...prev,
673
- [fieldPath]: (prev[fieldPath] || "") + varRef
674
- }));
675
- },
676
- children: variable.title || variable.name
677
- },
678
- variable.path
679
- )) })
680
- ] })
681
- ] }) }),
682
- /* @__PURE__ */ jsxs(DialogFooter, { children: [
683
- /* @__PURE__ */ jsx(
684
- Button,
685
- {
686
- type: "button",
687
- variant: "outline",
688
- onClick: () => {
689
- setOpenRichTextDialogs((prev) => {
690
- const next = new Set(prev);
691
- next.delete(fieldPath);
692
- return next;
693
- });
694
- },
695
- children: "Cancel"
696
- }
697
- ),
698
- /* @__PURE__ */ jsx(
699
- Button,
700
- {
701
- type: "button",
702
- onClick: () => {
703
- handleFieldChange(fieldName, draftValue);
704
- setOpenRichTextDialogs((prev) => {
705
- const next = new Set(prev);
706
- next.delete(fieldPath);
707
- return next;
708
- });
709
- },
710
- children: "Save"
711
- }
712
- )
713
- ] })
714
- ] })
715
- }
716
- )
717
- ] }, fieldPath);
718
- }
719
- if (fieldSchema.format === "multiline" || fieldSchema.format === "textarea") {
720
- const isVarValue2 = isVariableReference(fieldValue);
721
- return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
722
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
723
- /* @__PURE__ */ jsxs(Label, { className: "text-xs font-medium", children: [
724
- fieldSchema.title || fieldName,
725
- isRequired && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
726
- ] }),
727
- renderVariablePicker(
728
- fieldName,
729
- "string",
730
- fieldPath,
731
- (varPath) => handleFieldChange(fieldName, (fieldValue || "") + varPath)
732
- )
733
- ] }),
734
- /* @__PURE__ */ jsx(
735
- Textarea,
736
- {
737
- value: fieldValue || "",
738
- onChange: (e) => handleFieldChange(fieldName, e.target.value),
739
- disabled,
740
- rows: 3,
741
- className: cn("text-xs", isVarValue2 && "font-mono text-primary"),
742
- placeholder: fieldSchema.description
743
- }
744
- ),
745
- fieldSchema.description && /* @__PURE__ */ jsx("p", { className: "text-[10px] text-muted-foreground", children: fieldSchema.description })
746
- ] }, fieldPath);
747
- }
748
- const inputType = fieldSchema.format === "email" ? "email" : fieldSchema.format === "uri" || fieldSchema.format === "url" ? "url" : fieldSchema.format === "password" ? "password" : "text";
749
- const isVarValue = isVariableReference(fieldValue);
750
- return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
751
- /* @__PURE__ */ jsxs(Label, { className: "text-xs font-medium", children: [
752
- fieldSchema.title || fieldName,
753
- isRequired && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
754
- ] }),
755
- /* @__PURE__ */ jsxs("div", { className: "flex gap-1.5", children: [
756
- /* @__PURE__ */ jsx(
757
- Input,
758
- {
759
- type: inputType,
760
- value: fieldValue || "",
761
- onChange: (e) => handleFieldChange(fieldName, e.target.value),
762
- disabled,
763
- className: cn("h-8 text-xs flex-1", isVarValue && "font-mono text-primary"),
764
- placeholder: fieldSchema.description
765
- }
766
- ),
767
- renderVariablePicker(
768
- fieldName,
769
- "string",
770
- fieldPath,
771
- (varPath) => handleFieldChange(fieldName, (fieldValue || "") + varPath)
772
- )
773
- ] }),
774
- fieldSchema.description && /* @__PURE__ */ jsx("p", { className: "text-[10px] text-muted-foreground", children: fieldSchema.description })
775
- ] }, fieldPath);
776
- }
777
- return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
778
- /* @__PURE__ */ jsxs(Label, { className: "text-xs font-medium", children: [
779
- fieldSchema.title || fieldName,
780
- isRequired && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
781
- ] }),
782
- /* @__PURE__ */ jsx(
783
- Input,
784
- {
785
- value: typeof fieldValue === "object" ? JSON.stringify(fieldValue) : fieldValue || "",
786
- onChange: (e) => {
787
- try {
788
- const parsed = JSON.parse(e.target.value);
789
- handleFieldChange(fieldName, parsed);
790
- } catch {
791
- handleFieldChange(fieldName, e.target.value);
792
- }
793
- },
794
- disabled,
795
- className: "h-8 text-xs font-mono"
796
- }
797
- ),
798
- /* @__PURE__ */ jsxs("p", { className: "text-[10px] text-muted-foreground", children: [
799
- "Type: ",
800
- fieldSchema.type || "unknown"
801
- ] })
802
- ] }, fieldPath);
803
- };
804
- if (schema.type === "object" && schema.properties) {
805
- const sortedProperties = Object.entries(schema.properties).sort(
806
- ([, a], [, b]) => {
807
- const orderA = a["x-displayOrder"] ?? 999;
808
- const orderB = b["x-displayOrder"] ?? 999;
809
- return orderA - orderB;
810
- }
811
- );
812
- return /* @__PURE__ */ jsx("div", { className: "space-y-3", children: sortedProperties.map(
813
- ([fieldName, fieldSchema]) => renderField(fieldSchema, fieldName, value[fieldName])
814
- ) });
815
- }
816
- return /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground text-center py-4", children: "No configuration required for this node." });
817
- }
818
-
819
- // components/schema-builder.tsx
820
- import { useState as useState2 } from "react";
821
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
822
- var FIELD_TYPES = [
823
- { value: "string", label: "Text" },
824
- { value: "number", label: "Number" },
825
- { value: "integer", label: "Integer" },
826
- { value: "boolean", label: "Boolean" },
827
- { value: "array", label: "Array" },
828
- { value: "object", label: "Object" }
829
- ];
830
- var STRING_FORMATS = [
831
- { value: "plain", label: "Plain Text" },
832
- { value: "email", label: "Email" },
833
- { value: "uri", label: "URL" },
834
- { value: "date", label: "Date" },
835
- { value: "date-time", label: "Date & Time" },
836
- { value: "multiline", label: "Multiline Text" }
837
- ];
838
- function SchemaBuilder({
839
- schema,
840
- onChange,
841
- disabled = false,
842
- components
843
- }) {
844
- const [expandedFields, setExpandedFields] = useState2(/* @__PURE__ */ new Set());
845
- const {
846
- Input,
847
- Label,
848
- Checkbox,
849
- Select,
850
- SelectTrigger,
851
- SelectValue,
852
- SelectContent,
853
- SelectItem,
854
- Button,
855
- Card,
856
- PlusIcon,
857
- TrashIcon,
858
- GripVerticalIcon,
859
- ChevronDownIcon,
860
- ChevronRightIcon
861
- } = components;
862
- const getFieldsFromSchema = () => {
863
- if (!schema?.properties) return [];
864
- return Object.entries(schema.properties).map(([name, prop]) => {
865
- const fieldSchema = prop;
866
- return {
867
- name,
868
- type: fieldSchema.type || "string",
869
- title: fieldSchema.title || name,
870
- description: fieldSchema.description || "",
871
- required: schema.required?.includes(name) || false,
872
- format: fieldSchema.format,
873
- enum: fieldSchema.enum,
874
- items: fieldSchema.items
875
- };
876
- });
877
- };
878
- const fields = getFieldsFromSchema();
879
- const updateSchema = (newFields) => {
880
- const properties = {};
881
- const required = [];
882
- newFields.forEach((field) => {
883
- if (!field.name) return;
884
- const fieldSchema = {
885
- type: field.type,
886
- title: field.title || field.name
887
- };
888
- if (field.description) {
889
- fieldSchema.description = field.description;
890
- }
891
- if (field.format && field.format !== "plain") {
892
- fieldSchema.format = field.format;
893
- }
894
- if (field.enum && field.enum.length > 0) {
895
- fieldSchema.enum = field.enum;
896
- }
897
- if (field.type === "array" && field.items) {
898
- fieldSchema.items = field.items;
899
- }
900
- properties[field.name] = fieldSchema;
901
- if (field.required) {
902
- required.push(field.name);
903
- }
904
- });
905
- onChange({
906
- type: "object",
907
- properties,
908
- required: required.length > 0 ? required : void 0
909
- });
910
- };
911
- const addField = () => {
912
- const newFieldName = `field_${fields.length + 1}`;
913
- const newFields = [
914
- ...fields,
915
- {
916
- name: newFieldName,
917
- type: "string",
918
- title: "",
919
- description: "",
920
- required: false
921
- }
922
- ];
923
- updateSchema(newFields);
924
- setExpandedFields((prev) => /* @__PURE__ */ new Set([...prev, newFieldName]));
925
- };
926
- const updateField = (index, updates) => {
927
- const newFields = [...fields];
928
- newFields[index] = { ...newFields[index], ...updates };
929
- updateSchema(newFields);
930
- };
931
- const removeField = (index) => {
932
- const newFields = fields.filter((_, i) => i !== index);
933
- updateSchema(newFields);
934
- };
935
- const toggleExpand = (name) => {
936
- setExpandedFields((prev) => {
937
- const next = new Set(prev);
938
- if (next.has(name)) {
939
- next.delete(name);
940
- } else {
941
- next.add(name);
942
- }
943
- return next;
944
- });
945
- };
946
- return /* @__PURE__ */ jsxs2("div", { className: "space-y-2", children: [
947
- fields.length === 0 ? /* @__PURE__ */ jsx2("p", { className: "text-xs text-muted-foreground italic py-3", children: 'No fields defined. Click "Add Field" to create one.' }) : /* @__PURE__ */ jsx2("div", { className: "space-y-3", children: fields.map((field, index) => {
948
- const isExpanded = expandedFields.has(field.name);
949
- return /* @__PURE__ */ jsxs2(Card, { className: "p-3 bg-gray-50/50", children: [
950
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2 mb-2", children: [
951
- /* @__PURE__ */ jsx2(GripVerticalIcon, { className: "h-4 w-4 text-gray-300 flex-shrink-0 cursor-grab" }),
952
- /* @__PURE__ */ jsx2(
953
- "button",
954
- {
955
- type: "button",
956
- onClick: () => toggleExpand(field.name),
957
- className: "flex-shrink-0 p-1 hover:bg-gray-200 rounded",
958
- children: isExpanded ? /* @__PURE__ */ jsx2(ChevronDownIcon, { className: "h-4 w-4 text-gray-500" }) : /* @__PURE__ */ jsx2(ChevronRightIcon, { className: "h-4 w-4 text-gray-500" })
959
- }
960
- ),
961
- /* @__PURE__ */ jsx2("div", { className: "flex-1", children: /* @__PURE__ */ jsx2(
962
- Input,
963
- {
964
- value: field.name,
965
- onChange: (e) => {
966
- const oldName = field.name;
967
- const newName = e.target.value.toLowerCase().replace(/\s+/g, "_").replace(/[^a-z0-9_]/g, "");
968
- updateField(index, { name: newName });
969
- if (expandedFields.has(oldName)) {
970
- setExpandedFields((prev) => {
971
- const next = new Set(prev);
972
- next.delete(oldName);
973
- next.add(newName);
974
- return next;
975
- });
976
- }
977
- },
978
- placeholder: "field_name",
979
- className: "h-9 text-sm font-mono",
980
- disabled
981
- }
982
- ) }),
983
- /* @__PURE__ */ jsx2(
984
- Button,
985
- {
986
- type: "button",
987
- variant: "ghost",
988
- size: "sm",
989
- className: "h-9 w-9 p-0 text-red-500 hover:text-red-700 hover:bg-red-50 flex-shrink-0",
990
- onClick: () => removeField(index),
991
- disabled,
992
- children: /* @__PURE__ */ jsx2(TrashIcon, { className: "h-4 w-4" })
993
- }
994
- )
995
- ] }),
996
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-3 pl-10", children: [
997
- /* @__PURE__ */ jsx2("div", { className: "flex-1", children: /* @__PURE__ */ jsxs2(
998
- Select,
999
- {
1000
- value: field.type,
1001
- onValueChange: (v) => updateField(index, { type: v }),
1002
- disabled,
1003
- children: [
1004
- /* @__PURE__ */ jsx2(SelectTrigger, { className: "h-9 text-sm", children: /* @__PURE__ */ jsx2(SelectValue, {}) }),
1005
- /* @__PURE__ */ jsx2(SelectContent, { children: FIELD_TYPES.map((type) => /* @__PURE__ */ jsx2(SelectItem, { value: type.value, children: type.label }, type.value)) })
1006
- ]
1007
- }
1008
- ) }),
1009
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2 flex-shrink-0", children: [
1010
- /* @__PURE__ */ jsx2(
1011
- Checkbox,
1012
- {
1013
- id: `required-${index}`,
1014
- checked: field.required,
1015
- onCheckedChange: (checked) => updateField(index, { required: !!checked }),
1016
- disabled
1017
- }
1018
- ),
1019
- /* @__PURE__ */ jsx2(
1020
- Label,
1021
- {
1022
- htmlFor: `required-${index}`,
1023
- className: "text-sm text-muted-foreground",
1024
- children: "Required"
1025
- }
1026
- )
1027
- ] })
1028
- ] }),
1029
- isExpanded && /* @__PURE__ */ jsxs2("div", { className: "mt-3 pt-3 border-t space-y-3 pl-10", children: [
1030
- /* @__PURE__ */ jsxs2("div", { className: "space-y-1", children: [
1031
- /* @__PURE__ */ jsx2(Label, { className: "text-xs text-muted-foreground", children: "Display Title" }),
1032
- /* @__PURE__ */ jsx2(
1033
- Input,
1034
- {
1035
- value: field.title,
1036
- onChange: (e) => updateField(index, { title: e.target.value }),
1037
- placeholder: "Human readable title",
1038
- className: "h-9 text-sm",
1039
- disabled
1040
- }
1041
- )
1042
- ] }),
1043
- /* @__PURE__ */ jsxs2("div", { className: "space-y-1", children: [
1044
- /* @__PURE__ */ jsx2(Label, { className: "text-xs text-muted-foreground", children: "Description" }),
1045
- /* @__PURE__ */ jsx2(
1046
- Input,
1047
- {
1048
- value: field.description,
1049
- onChange: (e) => updateField(index, { description: e.target.value }),
1050
- placeholder: "Help text for this field",
1051
- className: "h-9 text-sm",
1052
- disabled
1053
- }
1054
- )
1055
- ] }),
1056
- field.type === "string" && /* @__PURE__ */ jsxs2("div", { className: "space-y-1", children: [
1057
- /* @__PURE__ */ jsx2(Label, { className: "text-xs text-muted-foreground", children: "Format" }),
1058
- /* @__PURE__ */ jsxs2(
1059
- Select,
1060
- {
1061
- value: field.format || "plain",
1062
- onValueChange: (v) => updateField(index, { format: v }),
1063
- disabled,
1064
- children: [
1065
- /* @__PURE__ */ jsx2(SelectTrigger, { className: "h-9 text-sm", children: /* @__PURE__ */ jsx2(SelectValue, {}) }),
1066
- /* @__PURE__ */ jsx2(SelectContent, { children: STRING_FORMATS.map((format) => /* @__PURE__ */ jsx2(SelectItem, { value: format.value, children: format.label }, format.value)) })
1067
- ]
1068
- }
1069
- )
1070
- ] }),
1071
- field.type === "array" && /* @__PURE__ */ jsxs2("div", { className: "space-y-1", children: [
1072
- /* @__PURE__ */ jsx2(Label, { className: "text-xs text-muted-foreground", children: "Item Type" }),
1073
- /* @__PURE__ */ jsxs2(
1074
- Select,
1075
- {
1076
- value: field.items?.type || "string",
1077
- onValueChange: (v) => updateField(index, { items: { type: v } }),
1078
- disabled,
1079
- children: [
1080
- /* @__PURE__ */ jsx2(SelectTrigger, { className: "h-9 text-sm", children: /* @__PURE__ */ jsx2(SelectValue, {}) }),
1081
- /* @__PURE__ */ jsx2(SelectContent, { children: FIELD_TYPES.filter((t) => t.value !== "array").map(
1082
- (type) => /* @__PURE__ */ jsx2(SelectItem, { value: type.value, children: type.label }, type.value)
1083
- ) })
1084
- ]
1085
- }
1086
- )
1087
- ] }),
1088
- field.type === "string" && /* @__PURE__ */ jsxs2("div", { className: "space-y-2", children: [
1089
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between", children: [
1090
- /* @__PURE__ */ jsx2(Label, { className: "text-xs text-muted-foreground", children: "Dropdown Options (optional)" }),
1091
- /* @__PURE__ */ jsxs2(
1092
- Button,
1093
- {
1094
- type: "button",
1095
- variant: "outline",
1096
- size: "sm",
1097
- className: "h-7 text-xs",
1098
- onClick: () => {
1099
- const currentEnum = field.enum || [];
1100
- updateField(index, {
1101
- enum: [
1102
- ...currentEnum,
1103
- `option_${currentEnum.length + 1}`
1104
- ]
1105
- });
1106
- },
1107
- disabled,
1108
- children: [
1109
- /* @__PURE__ */ jsx2(PlusIcon, { className: "h-3 w-3 mr-1" }),
1110
- "Add Option"
1111
- ]
1112
- }
1113
- )
1114
- ] }),
1115
- field.enum && field.enum.length > 0 && /* @__PURE__ */ jsx2("div", { className: "space-y-2", children: field.enum.map((option, optIdx) => /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2", children: [
1116
- /* @__PURE__ */ jsx2(
1117
- Input,
1118
- {
1119
- value: option,
1120
- onChange: (e) => {
1121
- const newEnum = [...field.enum || []];
1122
- newEnum[optIdx] = e.target.value;
1123
- updateField(index, { enum: newEnum });
1124
- },
1125
- placeholder: `Option ${optIdx + 1}`,
1126
- className: "h-8 text-sm flex-1",
1127
- disabled
1128
- }
1129
- ),
1130
- /* @__PURE__ */ jsx2(
1131
- Button,
1132
- {
1133
- type: "button",
1134
- variant: "ghost",
1135
- size: "sm",
1136
- className: "h-8 w-8 p-0 text-red-400 hover:text-red-600",
1137
- onClick: () => {
1138
- const newEnum = (field.enum || []).filter(
1139
- (_, i) => i !== optIdx
1140
- );
1141
- updateField(index, {
1142
- enum: newEnum.length > 0 ? newEnum : void 0
1143
- });
1144
- },
1145
- disabled,
1146
- children: /* @__PURE__ */ jsx2(TrashIcon, { className: "h-3 w-3" })
1147
- }
1148
- )
1149
- ] }, optIdx)) })
1150
- ] })
1151
- ] })
1152
- ] }, index);
1153
- }) }),
1154
- /* @__PURE__ */ jsxs2(
1155
- Button,
1156
- {
1157
- type: "button",
1158
- variant: "outline",
1159
- size: "sm",
1160
- className: "w-full h-9 text-sm",
1161
- onClick: addField,
1162
- disabled,
1163
- children: [
1164
- /* @__PURE__ */ jsx2(PlusIcon, { className: "h-4 w-4 mr-2" }),
1165
- "Add Field"
1166
- ]
1167
- }
1168
- )
1169
- ] });
1170
- }
172
+ } from "./chunk-IY5JCMLA.mjs";
1171
173
 
1172
174
  // store/workflow-definition-slice.ts
1173
175
  import { createSlice } from "@reduxjs/toolkit";
@@ -4380,12 +3382,6 @@ export {
4380
3382
  retryWorkflowNodeApi,
4381
3383
  updateWorkflowApi,
4382
3384
  updateWorkflowInstanceStatusApi,
4383
- useApiAsync,
4384
- useAsync,
4385
- useOptionsRef,
4386
- useWorkflowInstances,
4387
- useWorkflowTemplates,
4388
- useWorkflows,
4389
3385
  workflowDefinitionReducer,
4390
3386
  workflowInstanceReducer
4391
3387
  };