@flowgram.ai/form-materials 0.3.0 → 0.3.2

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 (53) hide show
  1. package/bin/materials.ts +10 -1
  2. package/dist/esm/index.js +388 -98
  3. package/dist/esm/index.js.map +1 -1
  4. package/dist/index.d.mts +173 -90
  5. package/dist/index.d.ts +173 -90
  6. package/dist/index.js +453 -171
  7. package/dist/index.js.map +1 -1
  8. package/package.json +5 -5
  9. package/src/components/assign-row/components/blur-input.tsx +27 -0
  10. package/src/components/assign-row/config.json +11 -0
  11. package/src/components/assign-row/index.tsx +84 -0
  12. package/src/components/assign-row/types.ts +25 -0
  13. package/src/components/assign-rows/config.json +11 -0
  14. package/src/components/assign-rows/index.tsx +59 -0
  15. package/src/components/condition-row/constants.ts +4 -0
  16. package/src/components/constant-input/config.json +1 -1
  17. package/src/components/constant-input/index.tsx +1 -1
  18. package/src/components/constant-input/types.ts +1 -1
  19. package/src/components/display-outputs/index.tsx +7 -1
  20. package/src/components/display-schema-tag/index.tsx +1 -1
  21. package/src/components/display-schema-tree/config.json +1 -1
  22. package/src/components/display-schema-tree/index.tsx +1 -1
  23. package/src/components/index.ts +2 -0
  24. package/src/components/json-schema-editor/config.json +1 -1
  25. package/src/components/type-selector/index.tsx +1 -1
  26. package/src/components/variable-selector/index.tsx +1 -1
  27. package/src/components/variable-selector/use-variable-tree.tsx +1 -1
  28. package/src/effects/index.ts +1 -0
  29. package/src/effects/validate-when-variable-sync/config.json +5 -0
  30. package/src/effects/validate-when-variable-sync/index.ts +35 -0
  31. package/src/form-plugins/index.ts +1 -0
  32. package/src/form-plugins/infer-assign-plugin/config.json +7 -0
  33. package/src/form-plugins/infer-assign-plugin/index.ts +90 -0
  34. package/src/index.ts +2 -0
  35. package/src/plugins/disable-declaration-plugin/config.json +5 -0
  36. package/src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts +31 -0
  37. package/src/plugins/disable-declaration-plugin/index.tsx +6 -0
  38. package/src/plugins/index.ts +7 -0
  39. package/src/{shared → plugins}/json-schema-preset/create-type-preset-plugin.tsx +4 -2
  40. package/src/{shared → plugins}/json-schema-preset/type-definition/array.tsx +2 -1
  41. package/src/{shared → plugins}/json-schema-preset/type-definition/object.tsx +2 -1
  42. package/src/shared/index.ts +0 -1
  43. package/src/validate/index.tsx +6 -0
  44. package/src/validate/validate-flow-value/config.json +7 -0
  45. package/src/validate/validate-flow-value/index.tsx +73 -0
  46. /package/src/{shared → plugins}/json-schema-preset/config.json +0 -0
  47. /package/src/{shared → plugins}/json-schema-preset/index.tsx +0 -0
  48. /package/src/{shared → plugins}/json-schema-preset/manager.ts +0 -0
  49. /package/src/{shared → plugins}/json-schema-preset/type-definition/boolean.tsx +0 -0
  50. /package/src/{shared → plugins}/json-schema-preset/type-definition/index.tsx +0 -0
  51. /package/src/{shared → plugins}/json-schema-preset/type-definition/integer.tsx +0 -0
  52. /package/src/{shared → plugins}/json-schema-preset/type-definition/number.tsx +0 -0
  53. /package/src/{shared → plugins}/json-schema-preset/type-definition/string.tsx +0 -0
package/dist/index.js CHANGED
@@ -30,6 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
+ AssignRow: () => AssignRow,
34
+ AssignRows: () => AssignRows,
33
35
  BatchOutputs: () => BatchOutputs,
34
36
  BatchVariableSelector: () => BatchVariableSelector,
35
37
  CodeEditor: () => CodeEditor,
@@ -54,6 +56,8 @@ __export(src_exports, {
54
56
  VariableSelector: () => VariableSelector,
55
57
  autoRenameRefEffect: () => autoRenameRefEffect,
56
58
  createBatchOutputsFormPlugin: () => createBatchOutputsFormPlugin,
59
+ createDisableDeclarationPlugin: () => createDisableDeclarationPlugin,
60
+ createInferAssignPlugin: () => createInferAssignPlugin,
57
61
  createInferInputsPlugin: () => createInferInputsPlugin,
58
62
  createTypePresetPlugin: () => createTypePresetPlugin,
59
63
  formatLegacyRefOnInit: () => formatLegacyRefOnInit,
@@ -69,7 +73,9 @@ __export(src_exports, {
69
73
  provideJsonSchemaOutputs: () => provideJsonSchemaOutputs,
70
74
  syncVariableTitle: () => syncVariableTitle,
71
75
  useTypeManager: () => useTypeManager,
72
- useVariableTree: () => useVariableTree
76
+ useVariableTree: () => useVariableTree,
77
+ validateFlowValue: () => validateFlowValue,
78
+ validateWhenVariableSync: () => validateWhenVariableSync
73
79
  });
74
80
  module.exports = __toCommonJS(src_exports);
75
81
 
@@ -85,79 +91,17 @@ var import_semi_icons = require("@douyinfe/semi-icons");
85
91
  // src/components/variable-selector/use-variable-tree.tsx
86
92
  var import_react11 = __toESM(require("react"));
87
93
  var import_json_schema4 = require("@flowgram.ai/json-schema");
88
- var import_editor3 = require("@flowgram.ai/editor");
94
+ var import_editor4 = require("@flowgram.ai/editor");
89
95
  var import_semi_ui5 = require("@douyinfe/semi-ui");
90
96
 
91
- // src/shared/format-legacy-refs/index.ts
92
- var import_lodash = require("lodash");
93
- function formatLegacyRefOnSubmit(value) {
94
- if ((0, import_lodash.isObject)(value)) {
95
- if (isLegacyFlowRefValueSchema(value)) {
96
- return formatLegacyRefToNewRef(value);
97
- }
98
- return Object.fromEntries(
99
- Object.entries(value).map(([key, value2]) => [
100
- key,
101
- formatLegacyRefOnSubmit(value2)
102
- ])
103
- );
104
- }
105
- if (Array.isArray(value)) {
106
- return value.map(formatLegacyRefOnSubmit);
107
- }
108
- return value;
109
- }
110
- function formatLegacyRefOnInit(value) {
111
- if ((0, import_lodash.isObject)(value)) {
112
- if (isNewFlowRefValueSchema(value)) {
113
- return formatNewRefToLegacyRef(value);
114
- }
115
- return Object.fromEntries(
116
- Object.entries(value).map(([key, value2]) => [
117
- key,
118
- formatLegacyRefOnInit(value2)
119
- ])
120
- );
121
- }
122
- if (Array.isArray(value)) {
123
- return value.map(formatLegacyRefOnInit);
124
- }
125
- return value;
126
- }
127
- function isLegacyFlowRefValueSchema(value) {
128
- return (0, import_lodash.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
129
- }
130
- function isNewFlowRefValueSchema(value) {
131
- return (0, import_lodash.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
132
- }
133
- function formatLegacyRefToNewRef(value) {
134
- const keyPath = value.content.split(".");
135
- if (keyPath[1] === "outputs") {
136
- return {
137
- type: "ref",
138
- content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
139
- };
140
- }
141
- return {
142
- type: "ref",
143
- content: keyPath
144
- };
145
- }
146
- function formatNewRefToLegacyRef(value) {
147
- return {
148
- type: "ref",
149
- content: value.content.join(".")
150
- };
151
- }
152
-
153
- // src/shared/json-schema-preset/index.tsx
97
+ // src/plugins/json-schema-preset/index.tsx
154
98
  var import_react10 = __toESM(require("react"));
155
99
  var import_json_schema3 = require("@flowgram.ai/json-schema");
156
100
 
157
- // src/shared/json-schema-preset/type-definition/index.tsx
101
+ // src/plugins/json-schema-preset/type-definition/index.tsx
158
102
  var import_json_schema = require("@flowgram.ai/json-schema");
159
103
 
160
- // src/shared/json-schema-preset/type-definition/string.tsx
104
+ // src/plugins/json-schema-preset/type-definition/string.tsx
161
105
  var import_react = __toESM(require("react"));
162
106
  var import_semi_ui = require("@douyinfe/semi-ui");
163
107
  var stringRegistry = {
@@ -165,7 +109,7 @@ var stringRegistry = {
165
109
  ConstantRenderer: (props) => /* @__PURE__ */ import_react.default.createElement(import_semi_ui.Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
166
110
  };
167
111
 
168
- // src/shared/json-schema-preset/type-definition/object.tsx
112
+ // src/plugins/json-schema-preset/type-definition/object.tsx
169
113
  var import_react5 = __toESM(require("react"));
170
114
 
171
115
  // src/components/code-editor-mini/index.tsx
@@ -533,7 +477,7 @@ function CodeEditorMini(props) {
533
477
  ));
534
478
  }
535
479
 
536
- // src/shared/json-schema-preset/type-definition/object.tsx
480
+ // src/plugins/json-schema-preset/type-definition/object.tsx
537
481
  var objectRegistry = {
538
482
  type: "object",
539
483
  ConstantRenderer: (props) => /* @__PURE__ */ import_react5.default.createElement(
@@ -548,7 +492,7 @@ var objectRegistry = {
548
492
  )
549
493
  };
550
494
 
551
- // src/shared/json-schema-preset/type-definition/number.tsx
495
+ // src/plugins/json-schema-preset/type-definition/number.tsx
552
496
  var import_react6 = __toESM(require("react"));
553
497
  var import_semi_ui2 = require("@douyinfe/semi-ui");
554
498
  var numberRegistry = {
@@ -565,7 +509,7 @@ var numberRegistry = {
565
509
  )
566
510
  };
567
511
 
568
- // src/shared/json-schema-preset/type-definition/integer.tsx
512
+ // src/plugins/json-schema-preset/type-definition/integer.tsx
569
513
  var import_react7 = __toESM(require("react"));
570
514
  var import_semi_ui3 = require("@douyinfe/semi-ui");
571
515
  var integerRegistry = {
@@ -582,7 +526,7 @@ var integerRegistry = {
582
526
  )
583
527
  };
584
528
 
585
- // src/shared/json-schema-preset/type-definition/boolean.tsx
529
+ // src/plugins/json-schema-preset/type-definition/boolean.tsx
586
530
  var import_react8 = __toESM(require("react"));
587
531
  var import_semi_ui4 = require("@douyinfe/semi-ui");
588
532
  var booleanRegistry = {
@@ -607,7 +551,7 @@ var booleanRegistry = {
607
551
  }
608
552
  };
609
553
 
610
- // src/shared/json-schema-preset/type-definition/array.tsx
554
+ // src/plugins/json-schema-preset/type-definition/array.tsx
611
555
  var import_react9 = __toESM(require("react"));
612
556
  var arrayRegistry = {
613
557
  type: "array",
@@ -623,7 +567,7 @@ var arrayRegistry = {
623
567
  )
624
568
  };
625
569
 
626
- // src/shared/json-schema-preset/type-definition/index.tsx
570
+ // src/plugins/json-schema-preset/type-definition/index.tsx
627
571
  var jsonSchemaTypePreset = [
628
572
  stringRegistry,
629
573
  objectRegistry,
@@ -634,30 +578,51 @@ var jsonSchemaTypePreset = [
634
578
  ];
635
579
  jsonSchemaTypePreset.forEach((_type) => import_json_schema.jsonSchemaTypeManager.register(_type));
636
580
 
637
- // src/shared/json-schema-preset/create-type-preset-plugin.tsx
581
+ // src/plugins/json-schema-preset/create-type-preset-plugin.tsx
638
582
  var import_json_schema2 = require("@flowgram.ai/json-schema");
639
583
  var import_editor2 = require("@flowgram.ai/editor");
640
584
  var createTypePresetPlugin = (0, import_editor2.definePluginCreator)({
641
585
  onInit(ctx, opts) {
642
586
  const typeManager = ctx.get(import_json_schema2.BaseTypeManager);
643
587
  jsonSchemaTypePreset.forEach((_type) => typeManager.register(_type));
644
- opts.types.forEach((_type) => typeManager.register(_type));
588
+ opts.types?.forEach((_type) => typeManager.register(_type));
589
+ opts.unregisterTypes?.forEach((_type) => typeManager.unregister(_type));
645
590
  },
646
591
  containerModules: [import_json_schema2.jsonSchemaContainerModule]
647
592
  });
648
593
 
649
- // src/shared/json-schema-preset/index.tsx
594
+ // src/plugins/json-schema-preset/index.tsx
650
595
  var useTypeManager = () => (0, import_json_schema3.useTypeManager)();
651
596
  var JsonSchemaTypePresetProvider = ({
652
597
  types = [],
653
598
  children
654
599
  }) => /* @__PURE__ */ import_react10.default.createElement(import_json_schema3.TypePresetProvider, { types: [...jsonSchemaTypePreset, ...types] }, children);
655
600
 
601
+ // src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts
602
+ var import_editor3 = require("@flowgram.ai/editor");
603
+ var createDisableDeclarationPlugin = (0, import_editor3.definePluginCreator)({
604
+ onInit(ctx) {
605
+ const variableEngine = ctx.get(import_editor3.VariableEngine);
606
+ const handleEvent = (action) => {
607
+ if (import_editor3.ASTMatch.isVariableDeclaration(action.ast)) {
608
+ if (!action.ast.meta?.disabled) {
609
+ action.ast.updateMeta({
610
+ ...action.ast.meta || {},
611
+ disabled: true
612
+ });
613
+ }
614
+ }
615
+ };
616
+ variableEngine.onGlobalEvent("NewAST", handleEvent);
617
+ variableEngine.onGlobalEvent("UpdateAST", handleEvent);
618
+ }
619
+ });
620
+
656
621
  // src/components/variable-selector/use-variable-tree.tsx
657
622
  function useVariableTree(params) {
658
623
  const { includeSchema, excludeSchema, customSkip } = params;
659
624
  const typeManager = useTypeManager();
660
- const variables = (0, import_editor3.useAvailableVariables)();
625
+ const variables = (0, import_editor4.useAvailableVariables)();
661
626
  const getVariableTypeIcon = (0, import_react11.useCallback)((variable) => {
662
627
  if (variable.meta?.icon) {
663
628
  if (typeof variable.meta.icon === "string") {
@@ -674,7 +639,7 @@ function useVariableTree(params) {
674
639
  return null;
675
640
  }
676
641
  let children;
677
- if (import_editor3.ASTMatch.isObject(type)) {
642
+ if (import_editor4.ASTMatch.isObject(type)) {
678
643
  children = (type.properties || []).map((_property) => renderVariable(_property, [...parentFields, variable])).filter(Boolean);
679
644
  }
680
645
  const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
@@ -840,7 +805,7 @@ var VariableSelector = ({
840
805
  showClear: false,
841
806
  arrowIcon: /* @__PURE__ */ import_react12.default.createElement(import_semi_icons.IconChevronDownStroked, { size: "small" }),
842
807
  triggerRender,
843
- placeholder: config?.placeholder ?? "Select Variable..."
808
+ placeholder: config?.placeholder ?? "Select Variable"
844
809
  }
845
810
  ));
846
811
  };
@@ -1102,7 +1067,7 @@ var ConstantInputWrapper = import_styled_components3.default.div`
1102
1067
 
1103
1068
  // src/components/json-schema-editor/hooks.tsx
1104
1069
  var import_react15 = require("react");
1105
- var import_lodash2 = require("lodash");
1070
+ var import_lodash = require("lodash");
1106
1071
  var _id = 0;
1107
1072
  function genId() {
1108
1073
  return _id++;
@@ -1175,7 +1140,7 @@ function usePropertiesEdit(value, onChange) {
1175
1140
  if (!_property.name) {
1176
1141
  continue;
1177
1142
  }
1178
- nextProperties[_property.name] = (0, import_lodash2.omit)(_property, ["key", "name", "isPropertyRequired"]);
1143
+ nextProperties[_property.name] = (0, import_lodash.omit)(_property, ["key", "name", "isPropertyRequired"]);
1179
1144
  if (_property.isPropertyRequired) {
1180
1145
  nextRequired.push(_property.name);
1181
1146
  }
@@ -1562,13 +1527,13 @@ function PropertyEdit(props) {
1562
1527
 
1563
1528
  // src/components/batch-variable-selector/index.tsx
1564
1529
  var import_react20 = __toESM(require("react"));
1565
- var import_editor4 = require("@flowgram.ai/editor");
1530
+ var import_editor5 = require("@flowgram.ai/editor");
1566
1531
  var batchVariableSchema = {
1567
1532
  type: "array",
1568
1533
  extra: { weak: true }
1569
1534
  };
1570
1535
  function BatchVariableSelector(props) {
1571
- return /* @__PURE__ */ import_react20.default.createElement(import_editor4.PrivateScopeProvider, null, /* @__PURE__ */ import_react20.default.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
1536
+ return /* @__PURE__ */ import_react20.default.createElement(import_editor5.PrivateScopeProvider, null, /* @__PURE__ */ import_react20.default.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
1572
1537
  }
1573
1538
 
1574
1539
  // src/components/dynamic-value-input/index.tsx
@@ -1624,9 +1589,9 @@ var UITrigger = import_styled_components4.default.div`
1624
1589
 
1625
1590
  // src/components/dynamic-value-input/hooks.ts
1626
1591
  var import_react21 = require("react");
1627
- var import_editor5 = require("@flowgram.ai/editor");
1592
+ var import_editor6 = require("@flowgram.ai/editor");
1628
1593
  function useRefVariable(value) {
1629
- const available = (0, import_editor5.useScopeAvailable)();
1594
+ const available = (0, import_editor6.useScopeAvailable)();
1630
1595
  const refVariable = (0, import_react21.useMemo)(() => {
1631
1596
  if (value?.type === "ref") {
1632
1597
  return available.getByKeyPath(value.content);
@@ -1779,7 +1744,7 @@ var UIValues = import_styled_components5.default.div`
1779
1744
  // src/components/condition-row/hooks/useRule.ts
1780
1745
  var import_react23 = require("react");
1781
1746
  var import_json_schema6 = require("@flowgram.ai/json-schema");
1782
- var import_editor6 = require("@flowgram.ai/editor");
1747
+ var import_editor7 = require("@flowgram.ai/editor");
1783
1748
 
1784
1749
  // src/components/condition-row/constants.ts
1785
1750
  var rules = {
@@ -1827,7 +1792,11 @@ var rules = {
1827
1792
  },
1828
1793
  array: {
1829
1794
  ["is_empty" /* IS_EMPTY */]: null,
1830
- ["is_not_empty" /* IS_NOT_EMPTY */]: null
1795
+ ["is_not_empty" /* IS_NOT_EMPTY */]: null,
1796
+ ["contains" /* CONTAINS */]: "array",
1797
+ ["not_contains" /* NOT_CONTAINS */]: "array",
1798
+ ["eq" /* EQ */]: "array",
1799
+ ["neq" /* NEQ */]: "array"
1831
1800
  },
1832
1801
  map: {
1833
1802
  ["is_empty" /* IS_EMPTY */]: null,
@@ -1899,7 +1868,7 @@ var opConfigs = {
1899
1868
 
1900
1869
  // src/components/condition-row/hooks/useRule.ts
1901
1870
  function useRule(left) {
1902
- const available = (0, import_editor6.useScopeAvailable)();
1871
+ const available = (0, import_editor7.useScopeAvailable)();
1903
1872
  const variable = (0, import_react23.useMemo)(() => {
1904
1873
  if (!left) return void 0;
1905
1874
  return available.getByKeyPath(left.content);
@@ -1997,7 +1966,7 @@ var import_semi_icons7 = require("@douyinfe/semi-icons");
1997
1966
  // src/hooks/use-object-list/index.tsx
1998
1967
  var import_react26 = require("react");
1999
1968
  var import_nanoid = require("nanoid");
2000
- var import_lodash3 = require("lodash");
1969
+ var import_lodash2 = require("lodash");
2001
1970
  function genId2() {
2002
1971
  return (0, import_nanoid.nanoid)();
2003
1972
  }
@@ -2009,9 +1978,9 @@ function useObjectList({
2009
1978
  const [list, setList] = (0, import_react26.useState)([]);
2010
1979
  (0, import_react26.useEffect)(() => {
2011
1980
  setList((_prevList) => {
2012
- const newKeys = Object.entries(value || {}).sort((a, b) => (0, import_lodash3.get)(a[1], sortIndexKey || 0) - (0, import_lodash3.get)(b[1], sortIndexKey || 0)).map(([key]) => key);
1981
+ const newKeys = Object.entries(value || {}).sort((a, b) => (0, import_lodash2.get)(a[1], sortIndexKey || 0) - (0, import_lodash2.get)(b[1], sortIndexKey || 0)).map(([key]) => key);
2013
1982
  const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
2014
- const addKeys = (0, import_lodash3.difference)(newKeys, oldKeys);
1983
+ const addKeys = (0, import_lodash2.difference)(newKeys, oldKeys);
2015
1984
  return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
2016
1985
  id: item.id,
2017
1986
  key: item.key,
@@ -2047,8 +2016,8 @@ function useObjectList({
2047
2016
  onChange(
2048
2017
  Object.fromEntries(
2049
2018
  nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
2050
- if ((0, import_lodash3.isObject)(_res[1]) && sortIndexKey) {
2051
- (0, import_lodash3.set)(_res[1], sortIndexKey, idx);
2019
+ if ((0, import_lodash2.isObject)(_res[1]) && sortIndexKey) {
2020
+ (0, import_lodash2.set)(_res[1], sortIndexKey, idx);
2052
2021
  }
2053
2022
  return _res;
2054
2023
  })
@@ -2156,13 +2125,13 @@ var UIContainer4 = import_styled_components7.default.div`
2156
2125
  // src/components/prompt-editor/extensions/markdown.tsx
2157
2126
  var import_react28 = require("react");
2158
2127
  var import_react29 = require("@coze-editor/editor/react");
2159
- var import_editor7 = require("@coze-editor/editor");
2128
+ var import_editor8 = require("@coze-editor/editor");
2160
2129
  var import_view2 = require("@codemirror/view");
2161
2130
  function MarkdownHighlight() {
2162
2131
  const injector = (0, import_react29.useInjector)();
2163
2132
  (0, import_react28.useLayoutEffect)(
2164
2133
  () => injector.inject([
2165
- import_editor7.astDecorator.whole.of((cursor) => {
2134
+ import_editor8.astDecorator.whole.of((cursor) => {
2166
2135
  if (cursor.name.startsWith("ATXHeading")) {
2167
2136
  return {
2168
2137
  type: "className",
@@ -2224,13 +2193,13 @@ var language_support_default = LanguageSupport;
2224
2193
  // src/components/prompt-editor/extensions/jinja.tsx
2225
2194
  var import_react32 = require("react");
2226
2195
  var import_react33 = require("@coze-editor/editor/react");
2227
- var import_editor8 = require("@coze-editor/editor");
2196
+ var import_editor9 = require("@coze-editor/editor");
2228
2197
  var import_view3 = require("@codemirror/view");
2229
2198
  function JinjaHighlight() {
2230
2199
  const injector = (0, import_react33.useInjector)();
2231
2200
  (0, import_react32.useLayoutEffect)(
2232
2201
  () => injector.inject([
2233
- import_editor8.astDecorator.whole.of((cursor) => {
2202
+ import_editor9.astDecorator.whole.of((cursor) => {
2234
2203
  if (cursor.name === "JinjaStatementStart" || cursor.name === "JinjaStatementEnd") {
2235
2204
  return {
2236
2205
  type: "className",
@@ -2370,8 +2339,8 @@ function VariableTree() {
2370
2339
  // src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
2371
2340
  var import_react_dom = __toESM(require("react-dom"));
2372
2341
  var import_react38 = __toESM(require("react"));
2373
- var import_lodash4 = require("lodash");
2374
- var import_editor9 = require("@flowgram.ai/editor");
2342
+ var import_lodash3 = require("lodash");
2343
+ var import_editor10 = require("@flowgram.ai/editor");
2375
2344
  var import_semi_ui18 = require("@douyinfe/semi-ui");
2376
2345
  var import_semi_icons8 = require("@douyinfe/semi-icons");
2377
2346
  var import_react39 = require("@coze-editor/editor/react");
@@ -2418,7 +2387,7 @@ var UIPopoverContent2 = import_styled_components8.default.div`
2418
2387
  var VariableTagWidget = class extends import_view4.WidgetType {
2419
2388
  constructor({ keyPath, scope }) {
2420
2389
  super();
2421
- this.toDispose = new import_editor9.DisposableCollection();
2390
+ this.toDispose = new import_editor10.DisposableCollection();
2422
2391
  this.renderIcon = (icon) => {
2423
2392
  if (typeof icon === "string") {
2424
2393
  return /* @__PURE__ */ import_react38.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
@@ -2438,7 +2407,7 @@ var VariableTagWidget = class extends import_view4.WidgetType {
2438
2407
  );
2439
2408
  return;
2440
2409
  }
2441
- const rootField = (0, import_lodash4.last)(v.parentFields) || v;
2410
+ const rootField = (0, import_lodash3.last)(v.parentFields) || v;
2442
2411
  const isRoot = v.parentFields.length === 0;
2443
2412
  const rootTitle = /* @__PURE__ */ import_react38.default.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} ${isRoot ? "" : "-"} ` : "");
2444
2413
  const rootIcon = this.renderIcon(rootField?.meta.icon);
@@ -2456,7 +2425,7 @@ var VariableTagWidget = class extends import_view4.WidgetType {
2456
2425
  const dom = document.createElement("span");
2457
2426
  this.rootDOM = dom;
2458
2427
  this.toDispose.push(
2459
- import_editor9.Disposable.create(() => {
2428
+ import_editor10.Disposable.create(() => {
2460
2429
  import_react_dom.default.unmountComponentAtNode(this.rootDOM);
2461
2430
  })
2462
2431
  );
@@ -2473,7 +2442,7 @@ var VariableTagWidget = class extends import_view4.WidgetType {
2473
2442
  return dom;
2474
2443
  }
2475
2444
  eq(other) {
2476
- return (0, import_lodash4.isEqual)(this.keyPath, other.keyPath);
2445
+ return (0, import_lodash3.isEqual)(this.keyPath, other.keyPath);
2477
2446
  }
2478
2447
  ignoreEvent() {
2479
2448
  return false;
@@ -2484,7 +2453,7 @@ var VariableTagWidget = class extends import_view4.WidgetType {
2484
2453
  };
2485
2454
  function VariableTagInject() {
2486
2455
  const injector = (0, import_react39.useInjector)();
2487
- const scope = (0, import_editor9.useCurrentScope)();
2456
+ const scope = (0, import_editor10.useCurrentScope)();
2488
2457
  (0, import_react38.useLayoutEffect)(() => {
2489
2458
  const atMatcher = new import_view4.MatchDecorator({
2490
2459
  regexp: /\{\{([^\}]+)\}\}/g,
@@ -2535,16 +2504,16 @@ var import_react43 = require("@coze-editor/editor/react");
2535
2504
 
2536
2505
  // src/components/prompt-editor-with-inputs/inputs-picker.tsx
2537
2506
  var import_react41 = __toESM(require("react"));
2538
- var import_lodash5 = require("lodash");
2539
- var import_editor10 = require("@flowgram.ai/editor");
2507
+ var import_lodash4 = require("lodash");
2508
+ var import_editor11 = require("@flowgram.ai/editor");
2540
2509
  var import_semi_ui19 = require("@douyinfe/semi-ui");
2541
2510
  function InputsPicker({
2542
2511
  inputsValues,
2543
2512
  onSelect
2544
2513
  }) {
2545
- const available = (0, import_editor10.useScopeAvailable)();
2514
+ const available = (0, import_editor11.useScopeAvailable)();
2546
2515
  const getArrayDrilldown = (type, depth = 1) => {
2547
- if (import_editor10.ASTMatch.isArray(type.items)) {
2516
+ if (import_editor11.ASTMatch.isArray(type.items)) {
2548
2517
  return getArrayDrilldown(type.items, depth + 1);
2549
2518
  }
2550
2519
  return { type: type.items, depth };
@@ -2552,12 +2521,12 @@ function InputsPicker({
2552
2521
  const renderVariable = (variable, keyPath) => {
2553
2522
  let type = variable?.type;
2554
2523
  let children;
2555
- if (import_editor10.ASTMatch.isObject(type)) {
2524
+ if (import_editor11.ASTMatch.isObject(type)) {
2556
2525
  children = (type.properties || []).map((_property) => renderVariable(_property, [...keyPath, _property.key])).filter(Boolean);
2557
2526
  }
2558
- if (import_editor10.ASTMatch.isArray(type)) {
2527
+ if (import_editor11.ASTMatch.isArray(type)) {
2559
2528
  const drilldown = getArrayDrilldown(type);
2560
- if (import_editor10.ASTMatch.isObject(drilldown.type)) {
2529
+ if (import_editor11.ASTMatch.isObject(drilldown.type)) {
2561
2530
  children = (drilldown.type.properties || []).map(
2562
2531
  (_property) => renderVariable(_property, [
2563
2532
  ...keyPath,
@@ -2570,7 +2539,7 @@ function InputsPicker({
2570
2539
  const key = keyPath.map((_key, idx) => _key === "[0]" || idx === 0 ? _key : `.${_key}`).join("");
2571
2540
  return {
2572
2541
  key,
2573
- label: (0, import_lodash5.last)(keyPath),
2542
+ label: (0, import_lodash4.last)(keyPath),
2574
2543
  value: key,
2575
2544
  children
2576
2545
  };
@@ -2716,8 +2685,8 @@ function VariableTree2() {
2716
2685
  // src/components/json-editor-with-variables/extensions/variable-tag.tsx
2717
2686
  var import_react47 = __toESM(require("react"));
2718
2687
  var import_client = require("react-dom/client");
2719
- var import_lodash6 = require("lodash");
2720
- var import_editor11 = require("@flowgram.ai/editor");
2688
+ var import_lodash5 = require("lodash");
2689
+ var import_editor12 = require("@flowgram.ai/editor");
2721
2690
  var import_semi_ui23 = require("@douyinfe/semi-ui");
2722
2691
  var import_semi_icons9 = require("@douyinfe/semi-icons");
2723
2692
  var import_react48 = require("@coze-editor/editor/react");
@@ -2764,7 +2733,7 @@ var UIPopoverContent3 = import_styled_components9.default.div`
2764
2733
  var VariableTagWidget2 = class extends import_view5.WidgetType {
2765
2734
  constructor({ keyPath, scope }) {
2766
2735
  super();
2767
- this.toDispose = new import_editor11.DisposableCollection();
2736
+ this.toDispose = new import_editor12.DisposableCollection();
2768
2737
  this.renderIcon = (icon) => {
2769
2738
  if (typeof icon === "string") {
2770
2739
  return /* @__PURE__ */ import_react47.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
@@ -2781,7 +2750,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
2781
2750
  );
2782
2751
  return;
2783
2752
  }
2784
- const rootField = (0, import_lodash6.last)(v.parentFields);
2753
+ const rootField = (0, import_lodash5.last)(v.parentFields);
2785
2754
  const rootTitle = /* @__PURE__ */ import_react47.default.createElement(UIRootTitle3, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
2786
2755
  const rootIcon = this.renderIcon(rootField?.meta.icon);
2787
2756
  this.root.render(
@@ -2798,7 +2767,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
2798
2767
  const dom = document.createElement("span");
2799
2768
  this.root = (0, import_client.createRoot)(dom);
2800
2769
  this.toDispose.push(
2801
- import_editor11.Disposable.create(() => {
2770
+ import_editor12.Disposable.create(() => {
2802
2771
  this.root.unmount();
2803
2772
  })
2804
2773
  );
@@ -2815,7 +2784,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
2815
2784
  return dom;
2816
2785
  }
2817
2786
  eq(other) {
2818
- return (0, import_lodash6.isEqual)(this.keyPath, other.keyPath);
2787
+ return (0, import_lodash5.isEqual)(this.keyPath, other.keyPath);
2819
2788
  }
2820
2789
  ignoreEvent() {
2821
2790
  return false;
@@ -2826,7 +2795,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
2826
2795
  };
2827
2796
  function VariableTagInject2() {
2828
2797
  const injector = (0, import_react48.useInjector)();
2829
- const scope = (0, import_editor11.useCurrentScope)();
2798
+ const scope = (0, import_editor12.useCurrentScope)();
2830
2799
  (0, import_react47.useLayoutEffect)(() => {
2831
2800
  const atMatcher = new import_view5.MatchDecorator({
2832
2801
  regexp: /\{\{([^\}]+)\}\}/g,
@@ -3108,7 +3077,7 @@ function SchemaTree(props) {
3108
3077
  // src/components/display-outputs/index.tsx
3109
3078
  var import_react54 = __toESM(require("react"));
3110
3079
  var import_json_schema7 = require("@flowgram.ai/json-schema");
3111
- var import_editor12 = require("@flowgram.ai/editor");
3080
+ var import_editor13 = require("@flowgram.ai/editor");
3112
3081
 
3113
3082
  // src/components/display-schema-tag/index.tsx
3114
3083
  var import_react53 = __toESM(require("react"));
@@ -3161,8 +3130,8 @@ var DisplayOutputsWrapper = import_styled_components13.default.div`
3161
3130
 
3162
3131
  // src/components/display-outputs/index.tsx
3163
3132
  function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
3164
- const scope = (0, import_editor12.useCurrentScope)();
3165
- const refresh = (0, import_editor12.useRefresh)();
3133
+ const scope = (0, import_editor13.useCurrentScope)();
3134
+ const refresh = (0, import_editor13.useRefresh)();
3166
3135
  (0, import_react54.useEffect)(() => {
3167
3136
  if (!displayFromScope) {
3168
3137
  return () => null;
@@ -3182,15 +3151,24 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
3182
3151
  return acm;
3183
3152
  }, {}) : value?.properties || {};
3184
3153
  const childEntries = Object.entries(properties || {});
3185
- return /* @__PURE__ */ import_react54.default.createElement(DisplayOutputsWrapper, null, childEntries.map(([key, schema]) => /* @__PURE__ */ import_react54.default.createElement(DisplaySchemaTag, { key, title: key, value: schema, showIconInTree })));
3154
+ return /* @__PURE__ */ import_react54.default.createElement(DisplayOutputsWrapper, null, childEntries.map(([key, schema]) => /* @__PURE__ */ import_react54.default.createElement(
3155
+ DisplaySchemaTag,
3156
+ {
3157
+ key,
3158
+ title: key,
3159
+ value: schema,
3160
+ showIconInTree,
3161
+ warning: !schema
3162
+ }
3163
+ )));
3186
3164
  }
3187
3165
 
3188
3166
  // src/components/display-flow-value/index.tsx
3189
3167
  var import_react55 = __toESM(require("react"));
3190
3168
  var import_json_schema8 = require("@flowgram.ai/json-schema");
3191
- var import_editor13 = require("@flowgram.ai/editor");
3169
+ var import_editor14 = require("@flowgram.ai/editor");
3192
3170
  function DisplayFlowValue({ value, title, showIconInTree }) {
3193
- const available = (0, import_editor13.useScopeAvailable)();
3171
+ const available = (0, import_editor14.useScopeAvailable)();
3194
3172
  const variable = value?.type === "ref" ? available.getByKeyPath(value?.content) : void 0;
3195
3173
  const schema = (0, import_react55.useMemo)(() => {
3196
3174
  if (value?.type === "ref") {
@@ -3243,30 +3221,151 @@ function DisplayInputsValues({ value, showIconInTree }) {
3243
3221
  return /* @__PURE__ */ import_react56.default.createElement(DisplayInputsWrapper, null, childEntries.map(([key, value2]) => /* @__PURE__ */ import_react56.default.createElement(DisplayFlowValue, { key, title: key, value: value2, showIconInTree })));
3244
3222
  }
3245
3223
 
3224
+ // src/components/assign-rows/index.tsx
3225
+ var import_react59 = __toESM(require("react"));
3226
+ var import_editor15 = require("@flowgram.ai/editor");
3227
+ var import_semi_ui28 = require("@douyinfe/semi-ui");
3228
+ var import_semi_icons12 = require("@douyinfe/semi-icons");
3229
+
3230
+ // src/components/assign-row/index.tsx
3231
+ var import_react58 = __toESM(require("react"));
3232
+ var import_semi_ui27 = require("@douyinfe/semi-ui");
3233
+ var import_semi_icons11 = require("@douyinfe/semi-icons");
3234
+
3235
+ // src/components/assign-row/components/blur-input.tsx
3236
+ var import_react57 = __toESM(require("react"));
3237
+ var import_input3 = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
3238
+ function BlurInput3(props) {
3239
+ const [value, setValue] = (0, import_react57.useState)("");
3240
+ (0, import_react57.useEffect)(() => {
3241
+ setValue(props.value);
3242
+ }, [props.value]);
3243
+ return /* @__PURE__ */ import_react57.default.createElement(
3244
+ import_input3.default,
3245
+ {
3246
+ ...props,
3247
+ value,
3248
+ onChange: (value2) => {
3249
+ setValue(value2);
3250
+ },
3251
+ onBlur: (e) => props.onChange?.(value, e)
3252
+ }
3253
+ );
3254
+ }
3255
+
3256
+ // src/components/assign-row/index.tsx
3257
+ function AssignRow(props) {
3258
+ const {
3259
+ value = {
3260
+ operator: "assign"
3261
+ },
3262
+ onChange,
3263
+ onDelete,
3264
+ readonly
3265
+ } = props;
3266
+ return /* @__PURE__ */ import_react58.default.createElement("div", { style: { display: "flex", alignItems: "center", gap: 5 } }, /* @__PURE__ */ import_react58.default.createElement("div", { style: { width: 150, minWidth: 150, maxWidth: 150 } }, value?.operator === "assign" ? /* @__PURE__ */ import_react58.default.createElement(
3267
+ VariableSelector,
3268
+ {
3269
+ style: { width: "100%", height: 26 },
3270
+ value: value?.left?.content,
3271
+ config: { placeholder: "Select Left" },
3272
+ onChange: (v) => onChange?.({
3273
+ ...value,
3274
+ left: { type: "ref", content: v }
3275
+ })
3276
+ }
3277
+ ) : /* @__PURE__ */ import_react58.default.createElement(
3278
+ BlurInput3,
3279
+ {
3280
+ style: { height: 26 },
3281
+ size: "small",
3282
+ placeholder: "Input Name",
3283
+ value: value?.left,
3284
+ onChange: (v) => onChange?.({
3285
+ ...value,
3286
+ left: v
3287
+ })
3288
+ }
3289
+ )), /* @__PURE__ */ import_react58.default.createElement("div", { style: { flexGrow: 1 } }, /* @__PURE__ */ import_react58.default.createElement(
3290
+ DynamicValueInput,
3291
+ {
3292
+ readonly,
3293
+ value: value?.right,
3294
+ onChange: (v) => onChange?.({
3295
+ ...value,
3296
+ right: v
3297
+ })
3298
+ }
3299
+ )), onDelete && /* @__PURE__ */ import_react58.default.createElement("div", null, /* @__PURE__ */ import_react58.default.createElement(
3300
+ import_semi_ui27.IconButton,
3301
+ {
3302
+ size: "small",
3303
+ theme: "borderless",
3304
+ icon: /* @__PURE__ */ import_react58.default.createElement(import_semi_icons11.IconMinus, null),
3305
+ onClick: () => onDelete?.()
3306
+ }
3307
+ )));
3308
+ }
3309
+
3310
+ // src/components/assign-rows/index.tsx
3311
+ function AssignRows(props) {
3312
+ const { name, readonly } = props;
3313
+ return /* @__PURE__ */ import_react59.default.createElement(import_editor15.FieldArray, { name }, ({ field }) => /* @__PURE__ */ import_react59.default.createElement(import_react59.default.Fragment, null, field.map((childField, index) => /* @__PURE__ */ import_react59.default.createElement(
3314
+ AssignRow,
3315
+ {
3316
+ key: childField.key,
3317
+ readonly,
3318
+ value: childField.value,
3319
+ onChange: (value) => {
3320
+ childField.onChange(value);
3321
+ },
3322
+ onDelete: () => field.remove(index)
3323
+ }
3324
+ )), /* @__PURE__ */ import_react59.default.createElement("div", { style: { display: "flex", gap: 5 } }, /* @__PURE__ */ import_react59.default.createElement(
3325
+ import_semi_ui28.Button,
3326
+ {
3327
+ size: "small",
3328
+ theme: "borderless",
3329
+ icon: /* @__PURE__ */ import_react59.default.createElement(import_semi_icons12.IconPlus, null),
3330
+ onClick: () => field.append({ operator: "assign" })
3331
+ },
3332
+ "Assign"
3333
+ ), /* @__PURE__ */ import_react59.default.createElement(
3334
+ import_semi_ui28.Button,
3335
+ {
3336
+ size: "small",
3337
+ theme: "borderless",
3338
+ icon: /* @__PURE__ */ import_react59.default.createElement(import_semi_icons12.IconPlus, null),
3339
+ onClick: () => field.append({ operator: "declare" })
3340
+ },
3341
+ "Declaration"
3342
+ ))));
3343
+ }
3344
+
3246
3345
  // src/effects/provide-batch-input/index.ts
3247
- var import_editor14 = require("@flowgram.ai/editor");
3248
- var provideBatchInputEffect = (0, import_editor14.createEffectFromVariableProvider)({
3346
+ var import_editor16 = require("@flowgram.ai/editor");
3347
+ var provideBatchInputEffect = (0, import_editor16.createEffectFromVariableProvider)({
3249
3348
  private: true,
3250
3349
  parse: (value, ctx) => [
3251
- import_editor14.ASTFactory.createVariableDeclaration({
3350
+ import_editor16.ASTFactory.createVariableDeclaration({
3252
3351
  key: `${ctx.node.id}_locals`,
3253
3352
  meta: {
3254
- title: (0, import_editor14.getNodeForm)(ctx.node)?.getValueIn("title"),
3353
+ title: (0, import_editor16.getNodeForm)(ctx.node)?.getValueIn("title"),
3255
3354
  icon: ctx.node.getNodeRegistry().info?.icon
3256
3355
  },
3257
- type: import_editor14.ASTFactory.createObject({
3356
+ type: import_editor16.ASTFactory.createObject({
3258
3357
  properties: [
3259
- import_editor14.ASTFactory.createProperty({
3358
+ import_editor16.ASTFactory.createProperty({
3260
3359
  key: "item",
3261
- initializer: import_editor14.ASTFactory.createEnumerateExpression({
3262
- enumerateFor: import_editor14.ASTFactory.createKeyPathExpression({
3360
+ initializer: import_editor16.ASTFactory.createEnumerateExpression({
3361
+ enumerateFor: import_editor16.ASTFactory.createKeyPathExpression({
3263
3362
  keyPath: value.content || []
3264
3363
  })
3265
3364
  })
3266
3365
  }),
3267
- import_editor14.ASTFactory.createProperty({
3366
+ import_editor16.ASTFactory.createProperty({
3268
3367
  key: "index",
3269
- type: import_editor14.ASTFactory.createNumber()
3368
+ type: import_editor16.ASTFactory.createNumber()
3270
3369
  })
3271
3370
  ]
3272
3371
  })
@@ -3275,14 +3374,14 @@ var provideBatchInputEffect = (0, import_editor14.createEffectFromVariableProvid
3275
3374
  });
3276
3375
 
3277
3376
  // src/effects/auto-rename-ref/index.ts
3278
- var import_lodash7 = require("lodash");
3279
- var import_editor15 = require("@flowgram.ai/editor");
3377
+ var import_lodash6 = require("lodash");
3378
+ var import_editor17 = require("@flowgram.ai/editor");
3280
3379
  var autoRenameRefEffect = [
3281
3380
  {
3282
- event: import_editor15.DataEvent.onValueInit,
3381
+ event: import_editor17.DataEvent.onValueInit,
3283
3382
  effect: (params) => {
3284
3383
  const { context, form, name } = params;
3285
- const renameService = context.node.getService(import_editor15.VariableFieldKeyRenameService);
3384
+ const renameService = context.node.getService(import_editor17.VariableFieldKeyRenameService);
3286
3385
  const disposable = renameService.onRename(({ before, after }) => {
3287
3386
  const beforeKeyPath = [
3288
3387
  ...before.parentFields.map((_field) => _field.key).reverse(),
@@ -3331,7 +3430,7 @@ function isKeyPathMatch(keyPath = [], targetKeyPath) {
3331
3430
  }
3332
3431
  function getTemplateKeyPaths(value) {
3333
3432
  const keyPathReg = /{{(.*?)}}/g;
3334
- return (0, import_lodash7.uniq)(value.content?.match(keyPathReg) || []).map(
3433
+ return (0, import_lodash6.uniq)(value.content?.match(keyPathReg) || []).map(
3335
3434
  (_keyPath) => _keyPath.slice(2, -2).split(".")
3336
3435
  );
3337
3436
  }
@@ -3342,7 +3441,7 @@ function isTemplate(value) {
3342
3441
  return value?.type === "template" && typeof value?.content === "string";
3343
3442
  }
3344
3443
  function traverseRef(name, value, cb) {
3345
- if ((0, import_lodash7.isObject)(value)) {
3444
+ if ((0, import_lodash6.isObject)(value)) {
3346
3445
  if (isRef(value)) {
3347
3446
  cb(name, value);
3348
3447
  return;
@@ -3356,7 +3455,7 @@ function traverseRef(name, value, cb) {
3356
3455
  });
3357
3456
  return;
3358
3457
  }
3359
- if ((0, import_lodash7.isArray)(value)) {
3458
+ if ((0, import_lodash6.isArray)(value)) {
3360
3459
  value.forEach((_value, idx) => {
3361
3460
  traverseRef(`${name}[${idx}]`, _value, cb);
3362
3461
  });
@@ -3367,13 +3466,13 @@ function traverseRef(name, value, cb) {
3367
3466
 
3368
3467
  // src/effects/provide-json-schema-outputs/index.ts
3369
3468
  var import_json_schema9 = require("@flowgram.ai/json-schema");
3370
- var import_editor16 = require("@flowgram.ai/editor");
3371
- var provideJsonSchemaOutputs = (0, import_editor16.createEffectFromVariableProvider)({
3469
+ var import_editor18 = require("@flowgram.ai/editor");
3470
+ var provideJsonSchemaOutputs = (0, import_editor18.createEffectFromVariableProvider)({
3372
3471
  parse: (value, ctx) => [
3373
- import_editor16.ASTFactory.createVariableDeclaration({
3472
+ import_editor18.ASTFactory.createVariableDeclaration({
3374
3473
  key: `${ctx.node.id}`,
3375
3474
  meta: {
3376
- title: (0, import_editor16.getNodeForm)(ctx.node)?.getValueIn("title") || ctx.node.id,
3475
+ title: (0, import_editor18.getNodeForm)(ctx.node)?.getValueIn("title") || ctx.node.id,
3377
3476
  icon: ctx.node.getNodeRegistry().info?.icon
3378
3477
  },
3379
3478
  type: import_json_schema9.JsonSchemaUtils.schemaToAST(value)
@@ -3382,12 +3481,12 @@ var provideJsonSchemaOutputs = (0, import_editor16.createEffectFromVariableProvi
3382
3481
  });
3383
3482
 
3384
3483
  // src/effects/sync-variable-title/index.ts
3385
- var import_editor17 = require("@flowgram.ai/editor");
3484
+ var import_editor19 = require("@flowgram.ai/editor");
3386
3485
  var syncVariableTitle = [
3387
3486
  {
3388
- event: import_editor17.DataEvent.onValueChange,
3487
+ event: import_editor19.DataEvent.onValueChange,
3389
3488
  effect: ({ value, context }) => {
3390
- context.node.getData(import_editor17.FlowNodeVariableData).allScopes.forEach((_scope) => {
3489
+ context.node.getData(import_editor19.FlowNodeVariableData).allScopes.forEach((_scope) => {
3391
3490
  _scope.output.variables.forEach((_var) => {
3392
3491
  _var.updateMeta({
3393
3492
  ..._var.meta || {},
@@ -3400,22 +3499,104 @@ var syncVariableTitle = [
3400
3499
  }
3401
3500
  ];
3402
3501
 
3502
+ // src/effects/validate-when-variable-sync/index.ts
3503
+ var import_lodash7 = require("lodash");
3504
+ var import_editor20 = require("@flowgram.ai/editor");
3505
+ var validateWhenVariableSync = ({
3506
+ scope
3507
+ } = {}) => [
3508
+ {
3509
+ event: import_editor20.DataEvent.onValueInit,
3510
+ effect: ({ context, form }) => {
3511
+ const nodeScope = scope === "private" ? (0, import_editor20.getNodePrivateScope)(context.node) : (0, import_editor20.getNodeScope)(context.node);
3512
+ const disposable = nodeScope.available.onListOrAnyVarChange(() => {
3513
+ if (!(0, import_lodash7.isEmpty)(form.state.errors)) {
3514
+ form.validate();
3515
+ }
3516
+ });
3517
+ return () => disposable.dispose();
3518
+ }
3519
+ }
3520
+ ];
3521
+
3522
+ // src/shared/format-legacy-refs/index.ts
3523
+ var import_lodash8 = require("lodash");
3524
+ function formatLegacyRefOnSubmit(value) {
3525
+ if ((0, import_lodash8.isObject)(value)) {
3526
+ if (isLegacyFlowRefValueSchema(value)) {
3527
+ return formatLegacyRefToNewRef(value);
3528
+ }
3529
+ return Object.fromEntries(
3530
+ Object.entries(value).map(([key, value2]) => [
3531
+ key,
3532
+ formatLegacyRefOnSubmit(value2)
3533
+ ])
3534
+ );
3535
+ }
3536
+ if (Array.isArray(value)) {
3537
+ return value.map(formatLegacyRefOnSubmit);
3538
+ }
3539
+ return value;
3540
+ }
3541
+ function formatLegacyRefOnInit(value) {
3542
+ if ((0, import_lodash8.isObject)(value)) {
3543
+ if (isNewFlowRefValueSchema(value)) {
3544
+ return formatNewRefToLegacyRef(value);
3545
+ }
3546
+ return Object.fromEntries(
3547
+ Object.entries(value).map(([key, value2]) => [
3548
+ key,
3549
+ formatLegacyRefOnInit(value2)
3550
+ ])
3551
+ );
3552
+ }
3553
+ if (Array.isArray(value)) {
3554
+ return value.map(formatLegacyRefOnInit);
3555
+ }
3556
+ return value;
3557
+ }
3558
+ function isLegacyFlowRefValueSchema(value) {
3559
+ return (0, import_lodash8.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
3560
+ }
3561
+ function isNewFlowRefValueSchema(value) {
3562
+ return (0, import_lodash8.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
3563
+ }
3564
+ function formatLegacyRefToNewRef(value) {
3565
+ const keyPath = value.content.split(".");
3566
+ if (keyPath[1] === "outputs") {
3567
+ return {
3568
+ type: "ref",
3569
+ content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
3570
+ };
3571
+ }
3572
+ return {
3573
+ type: "ref",
3574
+ content: keyPath
3575
+ };
3576
+ }
3577
+ function formatNewRefToLegacyRef(value) {
3578
+ return {
3579
+ type: "ref",
3580
+ content: value.content.join(".")
3581
+ };
3582
+ }
3583
+
3403
3584
  // src/form-plugins/batch-outputs-plugin/index.ts
3404
- var import_editor18 = require("@flowgram.ai/editor");
3405
- var provideBatchOutputsEffect = (0, import_editor18.createEffectFromVariableProvider)({
3585
+ var import_editor21 = require("@flowgram.ai/editor");
3586
+ var provideBatchOutputsEffect = (0, import_editor21.createEffectFromVariableProvider)({
3406
3587
  parse: (value, ctx) => [
3407
- import_editor18.ASTFactory.createVariableDeclaration({
3588
+ import_editor21.ASTFactory.createVariableDeclaration({
3408
3589
  key: `${ctx.node.id}`,
3409
3590
  meta: {
3410
- title: (0, import_editor18.getNodeForm)(ctx.node)?.getValueIn("title"),
3591
+ title: (0, import_editor21.getNodeForm)(ctx.node)?.getValueIn("title"),
3411
3592
  icon: ctx.node.getNodeRegistry().info?.icon
3412
3593
  },
3413
- type: import_editor18.ASTFactory.createObject({
3594
+ type: import_editor21.ASTFactory.createObject({
3414
3595
  properties: Object.entries(value).map(
3415
- ([_key, value2]) => import_editor18.ASTFactory.createProperty({
3596
+ ([_key, value2]) => import_editor21.ASTFactory.createProperty({
3416
3597
  key: _key,
3417
- initializer: import_editor18.ASTFactory.createWrapArrayExpression({
3418
- wrapFor: import_editor18.ASTFactory.createKeyPathExpression({
3598
+ initializer: import_editor21.ASTFactory.createWrapArrayExpression({
3599
+ wrapFor: import_editor21.ASTFactory.createKeyPathExpression({
3419
3600
  keyPath: value2?.content || []
3420
3601
  })
3421
3602
  })
@@ -3425,7 +3606,7 @@ var provideBatchOutputsEffect = (0, import_editor18.createEffectFromVariableProv
3425
3606
  })
3426
3607
  ]
3427
3608
  });
3428
- var createBatchOutputsFormPlugin = (0, import_editor18.defineFormPluginCreator)({
3609
+ var createBatchOutputsFormPlugin = (0, import_editor21.defineFormPluginCreator)({
3429
3610
  name: "batch-outputs-plugin",
3430
3611
  onSetupFormMeta({ mergeEffect }, { outputKey }) {
3431
3612
  mergeEffect({
@@ -3433,7 +3614,7 @@ var createBatchOutputsFormPlugin = (0, import_editor18.defineFormPluginCreator)(
3433
3614
  });
3434
3615
  },
3435
3616
  onInit(ctx, { outputKey }) {
3436
- const chainTransformService = ctx.node.getService(import_editor18.ScopeChainTransformService);
3617
+ const chainTransformService = ctx.node.getService(import_editor21.ScopeChainTransformService);
3437
3618
  const batchNodeType = ctx.node.flowNodeType;
3438
3619
  const transformerId = `${batchNodeType}-outputs`;
3439
3620
  if (chainTransformService.hasTransformer(transformerId)) {
@@ -3443,21 +3624,21 @@ var createBatchOutputsFormPlugin = (0, import_editor18.defineFormPluginCreator)(
3443
3624
  transformCovers: (covers, ctx2) => {
3444
3625
  const node = ctx2.scope.meta?.node;
3445
3626
  if (node?.parent?.flowNodeType === batchNodeType) {
3446
- return [...covers, (0, import_editor18.getNodeScope)(node.parent)];
3627
+ return [...covers, (0, import_editor21.getNodeScope)(node.parent)];
3447
3628
  }
3448
3629
  return covers;
3449
3630
  },
3450
3631
  transformDeps(scopes, ctx2) {
3451
3632
  const scopeMeta = ctx2.scope.meta;
3452
- if (scopeMeta?.type === import_editor18.FlowNodeScopeType.private) {
3633
+ if (scopeMeta?.type === import_editor21.FlowNodeScopeType.private) {
3453
3634
  return scopes;
3454
3635
  }
3455
3636
  const node = scopeMeta?.node;
3456
3637
  if (node?.flowNodeType === batchNodeType) {
3457
3638
  const childBlocks = node.blocks;
3458
3639
  return [
3459
- (0, import_editor18.getNodePrivateScope)(node),
3460
- ...childBlocks.map((_childBlock) => (0, import_editor18.getNodeScope)(_childBlock))
3640
+ (0, import_editor21.getNodePrivateScope)(node),
3641
+ ...childBlocks.map((_childBlock) => (0, import_editor21.getNodeScope)(_childBlock))
3461
3642
  ];
3462
3643
  }
3463
3644
  return scopes;
@@ -3467,21 +3648,21 @@ var createBatchOutputsFormPlugin = (0, import_editor18.defineFormPluginCreator)(
3467
3648
  });
3468
3649
 
3469
3650
  // src/form-plugins/infer-inputs-plugin/index.ts
3470
- var import_lodash8 = require("lodash");
3651
+ var import_lodash9 = require("lodash");
3471
3652
  var import_json_schema10 = require("@flowgram.ai/json-schema");
3472
- var import_editor19 = require("@flowgram.ai/editor");
3473
- var createInferInputsPlugin = (0, import_editor19.defineFormPluginCreator)({
3653
+ var import_editor22 = require("@flowgram.ai/editor");
3654
+ var createInferInputsPlugin = (0, import_editor22.defineFormPluginCreator)({
3474
3655
  onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
3475
3656
  if (!sourceKey || !targetKey) {
3476
3657
  return;
3477
3658
  }
3478
3659
  addFormatOnSubmit((formData, ctx) => {
3479
- (0, import_lodash8.set)(
3660
+ (0, import_lodash9.set)(
3480
3661
  formData,
3481
3662
  targetKey,
3482
3663
  infer(
3483
- (0, import_lodash8.get)(formData, sourceKey),
3484
- scope === "private" ? (0, import_editor19.getNodePrivateScope)(ctx.node) : (0, import_editor19.getNodeScope)(ctx.node)
3664
+ (0, import_lodash9.get)(formData, sourceKey),
3665
+ scope === "private" ? (0, import_editor22.getNodePrivateScope)(ctx.node) : (0, import_editor22.getNodeScope)(ctx.node)
3485
3666
  )
3486
3667
  );
3487
3668
  return formData;
@@ -3541,8 +3722,105 @@ var infer = (values, scope) => {
3541
3722
  };
3542
3723
  }
3543
3724
  };
3725
+
3726
+ // src/form-plugins/infer-assign-plugin/index.ts
3727
+ var import_lodash10 = require("lodash");
3728
+ var import_json_schema11 = require("@flowgram.ai/json-schema");
3729
+ var import_editor23 = require("@flowgram.ai/editor");
3730
+ var createInferAssignPlugin = (0, import_editor23.defineFormPluginCreator)({
3731
+ onSetupFormMeta({ addFormatOnSubmit, mergeEffect }, { assignKey, outputKey }) {
3732
+ if (!assignKey || !outputKey) {
3733
+ return;
3734
+ }
3735
+ mergeEffect({
3736
+ [assignKey]: (0, import_editor23.createEffectFromVariableProvider)({
3737
+ parse: (value, ctx) => {
3738
+ const declareRows = (0, import_lodash10.uniqBy)(
3739
+ value.filter((_v) => _v.operator === "declare" && _v.left && _v.right),
3740
+ "left"
3741
+ );
3742
+ return [
3743
+ import_editor23.ASTFactory.createVariableDeclaration({
3744
+ key: `${ctx.node.id}`,
3745
+ meta: {
3746
+ title: (0, import_editor23.getNodeForm)(ctx.node)?.getValueIn("title"),
3747
+ icon: ctx.node.getNodeRegistry().info?.icon
3748
+ },
3749
+ type: import_editor23.ASTFactory.createObject({
3750
+ properties: declareRows.map(
3751
+ (_v) => import_editor23.ASTFactory.createProperty({
3752
+ key: _v.left,
3753
+ type: _v.right?.type === "constant" ? import_json_schema11.JsonSchemaUtils.schemaToAST(_v.right?.schema || {}) : void 0,
3754
+ initializer: _v.right?.type === "ref" ? import_editor23.ASTFactory.createKeyPathExpression({
3755
+ keyPath: _v.right?.content || []
3756
+ }) : {}
3757
+ })
3758
+ )
3759
+ })
3760
+ })
3761
+ ];
3762
+ }
3763
+ })
3764
+ });
3765
+ addFormatOnSubmit((formData, ctx) => {
3766
+ (0, import_lodash10.set)(
3767
+ formData,
3768
+ outputKey,
3769
+ import_json_schema11.JsonSchemaUtils.astToSchema((0, import_editor23.getNodeScope)(ctx.node).output.variables?.[0]?.type)
3770
+ );
3771
+ return formData;
3772
+ });
3773
+ }
3774
+ });
3775
+
3776
+ // src/validate/validate-flow-value/index.tsx
3777
+ var import_lodash11 = require("lodash");
3778
+ var import_editor24 = require("@flowgram.ai/editor");
3779
+ function validateFlowValue(value, ctx) {
3780
+ const { node, required, errorMessages } = ctx;
3781
+ const {
3782
+ required: requiredMessage = "Field is required",
3783
+ unknownVariable: unknownVariableMessage = "Unknown Variable"
3784
+ } = errorMessages || {};
3785
+ if (required && ((0, import_lodash11.isNil)(value) || (0, import_lodash11.isNil)(value?.content) || value?.content === "")) {
3786
+ return {
3787
+ level: import_editor24.FeedbackLevel.Error,
3788
+ message: requiredMessage
3789
+ };
3790
+ }
3791
+ if (value?.type === "ref") {
3792
+ const variable = (0, import_editor24.getNodeScope)(node).available.getByKeyPath(value?.content || []);
3793
+ if (!variable) {
3794
+ return {
3795
+ level: import_editor24.FeedbackLevel.Error,
3796
+ message: unknownVariableMessage
3797
+ };
3798
+ }
3799
+ }
3800
+ if (value?.type === "template") {
3801
+ const allRefs = getTemplateKeyPaths2(value);
3802
+ for (const ref of allRefs) {
3803
+ const variable = (0, import_editor24.getNodeScope)(node).available.getByKeyPath(ref);
3804
+ if (!variable) {
3805
+ return {
3806
+ level: import_editor24.FeedbackLevel.Error,
3807
+ message: unknownVariableMessage
3808
+ };
3809
+ }
3810
+ }
3811
+ }
3812
+ return void 0;
3813
+ }
3814
+ function getTemplateKeyPaths2(value) {
3815
+ const keyPathReg = /{{(.*?)}}/g;
3816
+ return (0, import_lodash11.uniq)(value.content?.match(keyPathReg) || []).map(
3817
+ (_keyPath) => _keyPath.slice(2, -2).split(".")
3818
+ );
3819
+ }
3544
3820
  // Annotate the CommonJS export names for ESM import in node:
3545
3821
  0 && (module.exports = {
3822
+ AssignRow,
3823
+ AssignRows,
3546
3824
  BatchOutputs,
3547
3825
  BatchVariableSelector,
3548
3826
  CodeEditor,
@@ -3567,6 +3845,8 @@ var infer = (values, scope) => {
3567
3845
  VariableSelector,
3568
3846
  autoRenameRefEffect,
3569
3847
  createBatchOutputsFormPlugin,
3848
+ createDisableDeclarationPlugin,
3849
+ createInferAssignPlugin,
3570
3850
  createInferInputsPlugin,
3571
3851
  createTypePresetPlugin,
3572
3852
  formatLegacyRefOnInit,
@@ -3582,6 +3862,8 @@ var infer = (values, scope) => {
3582
3862
  provideJsonSchemaOutputs,
3583
3863
  syncVariableTitle,
3584
3864
  useTypeManager,
3585
- useVariableTree
3865
+ useVariableTree,
3866
+ validateFlowValue,
3867
+ validateWhenVariableSync
3586
3868
  });
3587
3869
  //# sourceMappingURL=index.js.map