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