@flowgram.ai/form-materials 0.3.0 → 0.3.1
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.
- package/bin/materials.ts +9 -1
- package/dist/esm/index.js +117 -87
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +94 -87
- package/dist/index.d.ts +94 -87
- package/dist/index.js +191 -164
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/condition-row/constants.ts +4 -0
- package/src/components/constant-input/index.tsx +1 -1
- package/src/components/constant-input/types.ts +1 -1
- package/src/components/display-schema-tag/index.tsx +1 -1
- package/src/components/display-schema-tree/index.tsx +1 -1
- package/src/components/json-schema-editor/config.json +1 -1
- package/src/components/type-selector/index.tsx +1 -1
- package/src/components/variable-selector/use-variable-tree.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/plugins/disable-declaration-plugin/config.json +5 -0
- package/src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts +31 -0
- package/src/plugins/disable-declaration-plugin/index.tsx +6 -0
- package/src/plugins/index.ts +7 -0
- package/src/{shared → plugins}/json-schema-preset/create-type-preset-plugin.tsx +4 -2
- package/src/shared/index.ts +0 -1
- /package/src/{shared → plugins}/json-schema-preset/config.json +0 -0
- /package/src/{shared → plugins}/json-schema-preset/index.tsx +0 -0
- /package/src/{shared → plugins}/json-schema-preset/manager.ts +0 -0
- /package/src/{shared → plugins}/json-schema-preset/type-definition/array.tsx +0 -0
- /package/src/{shared → plugins}/json-schema-preset/type-definition/boolean.tsx +0 -0
- /package/src/{shared → plugins}/json-schema-preset/type-definition/index.tsx +0 -0
- /package/src/{shared → plugins}/json-schema-preset/type-definition/integer.tsx +0 -0
- /package/src/{shared → plugins}/json-schema-preset/type-definition/number.tsx +0 -0
- /package/src/{shared → plugins}/json-schema-preset/type-definition/object.tsx +0 -0
- /package/src/{shared → plugins}/json-schema-preset/type-definition/string.tsx +0 -0
package/dist/index.js
CHANGED
|
@@ -54,6 +54,7 @@ __export(src_exports, {
|
|
|
54
54
|
VariableSelector: () => VariableSelector,
|
|
55
55
|
autoRenameRefEffect: () => autoRenameRefEffect,
|
|
56
56
|
createBatchOutputsFormPlugin: () => createBatchOutputsFormPlugin,
|
|
57
|
+
createDisableDeclarationPlugin: () => createDisableDeclarationPlugin,
|
|
57
58
|
createInferInputsPlugin: () => createInferInputsPlugin,
|
|
58
59
|
createTypePresetPlugin: () => createTypePresetPlugin,
|
|
59
60
|
formatLegacyRefOnInit: () => formatLegacyRefOnInit,
|
|
@@ -85,79 +86,17 @@ var import_semi_icons = require("@douyinfe/semi-icons");
|
|
|
85
86
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
86
87
|
var import_react11 = __toESM(require("react"));
|
|
87
88
|
var import_json_schema4 = require("@flowgram.ai/json-schema");
|
|
88
|
-
var
|
|
89
|
+
var import_editor4 = require("@flowgram.ai/editor");
|
|
89
90
|
var import_semi_ui5 = require("@douyinfe/semi-ui");
|
|
90
91
|
|
|
91
|
-
// src/
|
|
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
|
|
92
|
+
// src/plugins/json-schema-preset/index.tsx
|
|
154
93
|
var import_react10 = __toESM(require("react"));
|
|
155
94
|
var import_json_schema3 = require("@flowgram.ai/json-schema");
|
|
156
95
|
|
|
157
|
-
// src/
|
|
96
|
+
// src/plugins/json-schema-preset/type-definition/index.tsx
|
|
158
97
|
var import_json_schema = require("@flowgram.ai/json-schema");
|
|
159
98
|
|
|
160
|
-
// src/
|
|
99
|
+
// src/plugins/json-schema-preset/type-definition/string.tsx
|
|
161
100
|
var import_react = __toESM(require("react"));
|
|
162
101
|
var import_semi_ui = require("@douyinfe/semi-ui");
|
|
163
102
|
var stringRegistry = {
|
|
@@ -165,7 +104,7 @@ var stringRegistry = {
|
|
|
165
104
|
ConstantRenderer: (props) => /* @__PURE__ */ import_react.default.createElement(import_semi_ui.Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
|
|
166
105
|
};
|
|
167
106
|
|
|
168
|
-
// src/
|
|
107
|
+
// src/plugins/json-schema-preset/type-definition/object.tsx
|
|
169
108
|
var import_react5 = __toESM(require("react"));
|
|
170
109
|
|
|
171
110
|
// src/components/code-editor-mini/index.tsx
|
|
@@ -533,7 +472,7 @@ function CodeEditorMini(props) {
|
|
|
533
472
|
));
|
|
534
473
|
}
|
|
535
474
|
|
|
536
|
-
// src/
|
|
475
|
+
// src/plugins/json-schema-preset/type-definition/object.tsx
|
|
537
476
|
var objectRegistry = {
|
|
538
477
|
type: "object",
|
|
539
478
|
ConstantRenderer: (props) => /* @__PURE__ */ import_react5.default.createElement(
|
|
@@ -548,7 +487,7 @@ var objectRegistry = {
|
|
|
548
487
|
)
|
|
549
488
|
};
|
|
550
489
|
|
|
551
|
-
// src/
|
|
490
|
+
// src/plugins/json-schema-preset/type-definition/number.tsx
|
|
552
491
|
var import_react6 = __toESM(require("react"));
|
|
553
492
|
var import_semi_ui2 = require("@douyinfe/semi-ui");
|
|
554
493
|
var numberRegistry = {
|
|
@@ -565,7 +504,7 @@ var numberRegistry = {
|
|
|
565
504
|
)
|
|
566
505
|
};
|
|
567
506
|
|
|
568
|
-
// src/
|
|
507
|
+
// src/plugins/json-schema-preset/type-definition/integer.tsx
|
|
569
508
|
var import_react7 = __toESM(require("react"));
|
|
570
509
|
var import_semi_ui3 = require("@douyinfe/semi-ui");
|
|
571
510
|
var integerRegistry = {
|
|
@@ -582,7 +521,7 @@ var integerRegistry = {
|
|
|
582
521
|
)
|
|
583
522
|
};
|
|
584
523
|
|
|
585
|
-
// src/
|
|
524
|
+
// src/plugins/json-schema-preset/type-definition/boolean.tsx
|
|
586
525
|
var import_react8 = __toESM(require("react"));
|
|
587
526
|
var import_semi_ui4 = require("@douyinfe/semi-ui");
|
|
588
527
|
var booleanRegistry = {
|
|
@@ -607,7 +546,7 @@ var booleanRegistry = {
|
|
|
607
546
|
}
|
|
608
547
|
};
|
|
609
548
|
|
|
610
|
-
// src/
|
|
549
|
+
// src/plugins/json-schema-preset/type-definition/array.tsx
|
|
611
550
|
var import_react9 = __toESM(require("react"));
|
|
612
551
|
var arrayRegistry = {
|
|
613
552
|
type: "array",
|
|
@@ -623,7 +562,7 @@ var arrayRegistry = {
|
|
|
623
562
|
)
|
|
624
563
|
};
|
|
625
564
|
|
|
626
|
-
// src/
|
|
565
|
+
// src/plugins/json-schema-preset/type-definition/index.tsx
|
|
627
566
|
var jsonSchemaTypePreset = [
|
|
628
567
|
stringRegistry,
|
|
629
568
|
objectRegistry,
|
|
@@ -634,30 +573,51 @@ var jsonSchemaTypePreset = [
|
|
|
634
573
|
];
|
|
635
574
|
jsonSchemaTypePreset.forEach((_type) => import_json_schema.jsonSchemaTypeManager.register(_type));
|
|
636
575
|
|
|
637
|
-
// src/
|
|
576
|
+
// src/plugins/json-schema-preset/create-type-preset-plugin.tsx
|
|
638
577
|
var import_json_schema2 = require("@flowgram.ai/json-schema");
|
|
639
578
|
var import_editor2 = require("@flowgram.ai/editor");
|
|
640
579
|
var createTypePresetPlugin = (0, import_editor2.definePluginCreator)({
|
|
641
580
|
onInit(ctx, opts) {
|
|
642
581
|
const typeManager = ctx.get(import_json_schema2.BaseTypeManager);
|
|
643
582
|
jsonSchemaTypePreset.forEach((_type) => typeManager.register(_type));
|
|
644
|
-
opts.types
|
|
583
|
+
opts.types?.forEach((_type) => typeManager.register(_type));
|
|
584
|
+
opts.unregisterTypes?.forEach((_type) => typeManager.unregister(_type));
|
|
645
585
|
},
|
|
646
586
|
containerModules: [import_json_schema2.jsonSchemaContainerModule]
|
|
647
587
|
});
|
|
648
588
|
|
|
649
|
-
// src/
|
|
589
|
+
// src/plugins/json-schema-preset/index.tsx
|
|
650
590
|
var useTypeManager = () => (0, import_json_schema3.useTypeManager)();
|
|
651
591
|
var JsonSchemaTypePresetProvider = ({
|
|
652
592
|
types = [],
|
|
653
593
|
children
|
|
654
594
|
}) => /* @__PURE__ */ import_react10.default.createElement(import_json_schema3.TypePresetProvider, { types: [...jsonSchemaTypePreset, ...types] }, children);
|
|
655
595
|
|
|
596
|
+
// src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts
|
|
597
|
+
var import_editor3 = require("@flowgram.ai/editor");
|
|
598
|
+
var createDisableDeclarationPlugin = (0, import_editor3.definePluginCreator)({
|
|
599
|
+
onInit(ctx) {
|
|
600
|
+
const variableEngine = ctx.get(import_editor3.VariableEngine);
|
|
601
|
+
const handleEvent = (action) => {
|
|
602
|
+
if (import_editor3.ASTMatch.isVariableDeclaration(action.ast)) {
|
|
603
|
+
if (!action.ast.meta?.disabled) {
|
|
604
|
+
action.ast.updateMeta({
|
|
605
|
+
...action.ast.meta || {},
|
|
606
|
+
disabled: true
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
variableEngine.onGlobalEvent("NewAST", handleEvent);
|
|
612
|
+
variableEngine.onGlobalEvent("UpdateAST", handleEvent);
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
|
|
656
616
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
657
617
|
function useVariableTree(params) {
|
|
658
618
|
const { includeSchema, excludeSchema, customSkip } = params;
|
|
659
619
|
const typeManager = useTypeManager();
|
|
660
|
-
const variables = (0,
|
|
620
|
+
const variables = (0, import_editor4.useAvailableVariables)();
|
|
661
621
|
const getVariableTypeIcon = (0, import_react11.useCallback)((variable) => {
|
|
662
622
|
if (variable.meta?.icon) {
|
|
663
623
|
if (typeof variable.meta.icon === "string") {
|
|
@@ -674,7 +634,7 @@ function useVariableTree(params) {
|
|
|
674
634
|
return null;
|
|
675
635
|
}
|
|
676
636
|
let children;
|
|
677
|
-
if (
|
|
637
|
+
if (import_editor4.ASTMatch.isObject(type)) {
|
|
678
638
|
children = (type.properties || []).map((_property) => renderVariable(_property, [...parentFields, variable])).filter(Boolean);
|
|
679
639
|
}
|
|
680
640
|
const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
|
|
@@ -1102,7 +1062,7 @@ var ConstantInputWrapper = import_styled_components3.default.div`
|
|
|
1102
1062
|
|
|
1103
1063
|
// src/components/json-schema-editor/hooks.tsx
|
|
1104
1064
|
var import_react15 = require("react");
|
|
1105
|
-
var
|
|
1065
|
+
var import_lodash = require("lodash");
|
|
1106
1066
|
var _id = 0;
|
|
1107
1067
|
function genId() {
|
|
1108
1068
|
return _id++;
|
|
@@ -1175,7 +1135,7 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1175
1135
|
if (!_property.name) {
|
|
1176
1136
|
continue;
|
|
1177
1137
|
}
|
|
1178
|
-
nextProperties[_property.name] = (0,
|
|
1138
|
+
nextProperties[_property.name] = (0, import_lodash.omit)(_property, ["key", "name", "isPropertyRequired"]);
|
|
1179
1139
|
if (_property.isPropertyRequired) {
|
|
1180
1140
|
nextRequired.push(_property.name);
|
|
1181
1141
|
}
|
|
@@ -1562,13 +1522,13 @@ function PropertyEdit(props) {
|
|
|
1562
1522
|
|
|
1563
1523
|
// src/components/batch-variable-selector/index.tsx
|
|
1564
1524
|
var import_react20 = __toESM(require("react"));
|
|
1565
|
-
var
|
|
1525
|
+
var import_editor5 = require("@flowgram.ai/editor");
|
|
1566
1526
|
var batchVariableSchema = {
|
|
1567
1527
|
type: "array",
|
|
1568
1528
|
extra: { weak: true }
|
|
1569
1529
|
};
|
|
1570
1530
|
function BatchVariableSelector(props) {
|
|
1571
|
-
return /* @__PURE__ */ import_react20.default.createElement(
|
|
1531
|
+
return /* @__PURE__ */ import_react20.default.createElement(import_editor5.PrivateScopeProvider, null, /* @__PURE__ */ import_react20.default.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
|
|
1572
1532
|
}
|
|
1573
1533
|
|
|
1574
1534
|
// src/components/dynamic-value-input/index.tsx
|
|
@@ -1624,9 +1584,9 @@ var UITrigger = import_styled_components4.default.div`
|
|
|
1624
1584
|
|
|
1625
1585
|
// src/components/dynamic-value-input/hooks.ts
|
|
1626
1586
|
var import_react21 = require("react");
|
|
1627
|
-
var
|
|
1587
|
+
var import_editor6 = require("@flowgram.ai/editor");
|
|
1628
1588
|
function useRefVariable(value) {
|
|
1629
|
-
const available = (0,
|
|
1589
|
+
const available = (0, import_editor6.useScopeAvailable)();
|
|
1630
1590
|
const refVariable = (0, import_react21.useMemo)(() => {
|
|
1631
1591
|
if (value?.type === "ref") {
|
|
1632
1592
|
return available.getByKeyPath(value.content);
|
|
@@ -1779,7 +1739,7 @@ var UIValues = import_styled_components5.default.div`
|
|
|
1779
1739
|
// src/components/condition-row/hooks/useRule.ts
|
|
1780
1740
|
var import_react23 = require("react");
|
|
1781
1741
|
var import_json_schema6 = require("@flowgram.ai/json-schema");
|
|
1782
|
-
var
|
|
1742
|
+
var import_editor7 = require("@flowgram.ai/editor");
|
|
1783
1743
|
|
|
1784
1744
|
// src/components/condition-row/constants.ts
|
|
1785
1745
|
var rules = {
|
|
@@ -1827,7 +1787,11 @@ var rules = {
|
|
|
1827
1787
|
},
|
|
1828
1788
|
array: {
|
|
1829
1789
|
["is_empty" /* IS_EMPTY */]: null,
|
|
1830
|
-
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1790
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null,
|
|
1791
|
+
["contains" /* CONTAINS */]: "array",
|
|
1792
|
+
["not_contains" /* NOT_CONTAINS */]: "array",
|
|
1793
|
+
["eq" /* EQ */]: "array",
|
|
1794
|
+
["neq" /* NEQ */]: "array"
|
|
1831
1795
|
},
|
|
1832
1796
|
map: {
|
|
1833
1797
|
["is_empty" /* IS_EMPTY */]: null,
|
|
@@ -1899,7 +1863,7 @@ var opConfigs = {
|
|
|
1899
1863
|
|
|
1900
1864
|
// src/components/condition-row/hooks/useRule.ts
|
|
1901
1865
|
function useRule(left) {
|
|
1902
|
-
const available = (0,
|
|
1866
|
+
const available = (0, import_editor7.useScopeAvailable)();
|
|
1903
1867
|
const variable = (0, import_react23.useMemo)(() => {
|
|
1904
1868
|
if (!left) return void 0;
|
|
1905
1869
|
return available.getByKeyPath(left.content);
|
|
@@ -1997,7 +1961,7 @@ var import_semi_icons7 = require("@douyinfe/semi-icons");
|
|
|
1997
1961
|
// src/hooks/use-object-list/index.tsx
|
|
1998
1962
|
var import_react26 = require("react");
|
|
1999
1963
|
var import_nanoid = require("nanoid");
|
|
2000
|
-
var
|
|
1964
|
+
var import_lodash2 = require("lodash");
|
|
2001
1965
|
function genId2() {
|
|
2002
1966
|
return (0, import_nanoid.nanoid)();
|
|
2003
1967
|
}
|
|
@@ -2009,9 +1973,9 @@ function useObjectList({
|
|
|
2009
1973
|
const [list, setList] = (0, import_react26.useState)([]);
|
|
2010
1974
|
(0, import_react26.useEffect)(() => {
|
|
2011
1975
|
setList((_prevList) => {
|
|
2012
|
-
const newKeys = Object.entries(value || {}).sort((a, b) => (0,
|
|
1976
|
+
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
1977
|
const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
|
|
2014
|
-
const addKeys = (0,
|
|
1978
|
+
const addKeys = (0, import_lodash2.difference)(newKeys, oldKeys);
|
|
2015
1979
|
return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
|
|
2016
1980
|
id: item.id,
|
|
2017
1981
|
key: item.key,
|
|
@@ -2047,8 +2011,8 @@ function useObjectList({
|
|
|
2047
2011
|
onChange(
|
|
2048
2012
|
Object.fromEntries(
|
|
2049
2013
|
nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
|
|
2050
|
-
if ((0,
|
|
2051
|
-
(0,
|
|
2014
|
+
if ((0, import_lodash2.isObject)(_res[1]) && sortIndexKey) {
|
|
2015
|
+
(0, import_lodash2.set)(_res[1], sortIndexKey, idx);
|
|
2052
2016
|
}
|
|
2053
2017
|
return _res;
|
|
2054
2018
|
})
|
|
@@ -2156,13 +2120,13 @@ var UIContainer4 = import_styled_components7.default.div`
|
|
|
2156
2120
|
// src/components/prompt-editor/extensions/markdown.tsx
|
|
2157
2121
|
var import_react28 = require("react");
|
|
2158
2122
|
var import_react29 = require("@coze-editor/editor/react");
|
|
2159
|
-
var
|
|
2123
|
+
var import_editor8 = require("@coze-editor/editor");
|
|
2160
2124
|
var import_view2 = require("@codemirror/view");
|
|
2161
2125
|
function MarkdownHighlight() {
|
|
2162
2126
|
const injector = (0, import_react29.useInjector)();
|
|
2163
2127
|
(0, import_react28.useLayoutEffect)(
|
|
2164
2128
|
() => injector.inject([
|
|
2165
|
-
|
|
2129
|
+
import_editor8.astDecorator.whole.of((cursor) => {
|
|
2166
2130
|
if (cursor.name.startsWith("ATXHeading")) {
|
|
2167
2131
|
return {
|
|
2168
2132
|
type: "className",
|
|
@@ -2224,13 +2188,13 @@ var language_support_default = LanguageSupport;
|
|
|
2224
2188
|
// src/components/prompt-editor/extensions/jinja.tsx
|
|
2225
2189
|
var import_react32 = require("react");
|
|
2226
2190
|
var import_react33 = require("@coze-editor/editor/react");
|
|
2227
|
-
var
|
|
2191
|
+
var import_editor9 = require("@coze-editor/editor");
|
|
2228
2192
|
var import_view3 = require("@codemirror/view");
|
|
2229
2193
|
function JinjaHighlight() {
|
|
2230
2194
|
const injector = (0, import_react33.useInjector)();
|
|
2231
2195
|
(0, import_react32.useLayoutEffect)(
|
|
2232
2196
|
() => injector.inject([
|
|
2233
|
-
|
|
2197
|
+
import_editor9.astDecorator.whole.of((cursor) => {
|
|
2234
2198
|
if (cursor.name === "JinjaStatementStart" || cursor.name === "JinjaStatementEnd") {
|
|
2235
2199
|
return {
|
|
2236
2200
|
type: "className",
|
|
@@ -2370,8 +2334,8 @@ function VariableTree() {
|
|
|
2370
2334
|
// src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
|
|
2371
2335
|
var import_react_dom = __toESM(require("react-dom"));
|
|
2372
2336
|
var import_react38 = __toESM(require("react"));
|
|
2373
|
-
var
|
|
2374
|
-
var
|
|
2337
|
+
var import_lodash3 = require("lodash");
|
|
2338
|
+
var import_editor10 = require("@flowgram.ai/editor");
|
|
2375
2339
|
var import_semi_ui18 = require("@douyinfe/semi-ui");
|
|
2376
2340
|
var import_semi_icons8 = require("@douyinfe/semi-icons");
|
|
2377
2341
|
var import_react39 = require("@coze-editor/editor/react");
|
|
@@ -2418,7 +2382,7 @@ var UIPopoverContent2 = import_styled_components8.default.div`
|
|
|
2418
2382
|
var VariableTagWidget = class extends import_view4.WidgetType {
|
|
2419
2383
|
constructor({ keyPath, scope }) {
|
|
2420
2384
|
super();
|
|
2421
|
-
this.toDispose = new
|
|
2385
|
+
this.toDispose = new import_editor10.DisposableCollection();
|
|
2422
2386
|
this.renderIcon = (icon) => {
|
|
2423
2387
|
if (typeof icon === "string") {
|
|
2424
2388
|
return /* @__PURE__ */ import_react38.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
@@ -2438,7 +2402,7 @@ var VariableTagWidget = class extends import_view4.WidgetType {
|
|
|
2438
2402
|
);
|
|
2439
2403
|
return;
|
|
2440
2404
|
}
|
|
2441
|
-
const rootField = (0,
|
|
2405
|
+
const rootField = (0, import_lodash3.last)(v.parentFields) || v;
|
|
2442
2406
|
const isRoot = v.parentFields.length === 0;
|
|
2443
2407
|
const rootTitle = /* @__PURE__ */ import_react38.default.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} ${isRoot ? "" : "-"} ` : "");
|
|
2444
2408
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
@@ -2456,7 +2420,7 @@ var VariableTagWidget = class extends import_view4.WidgetType {
|
|
|
2456
2420
|
const dom = document.createElement("span");
|
|
2457
2421
|
this.rootDOM = dom;
|
|
2458
2422
|
this.toDispose.push(
|
|
2459
|
-
|
|
2423
|
+
import_editor10.Disposable.create(() => {
|
|
2460
2424
|
import_react_dom.default.unmountComponentAtNode(this.rootDOM);
|
|
2461
2425
|
})
|
|
2462
2426
|
);
|
|
@@ -2473,7 +2437,7 @@ var VariableTagWidget = class extends import_view4.WidgetType {
|
|
|
2473
2437
|
return dom;
|
|
2474
2438
|
}
|
|
2475
2439
|
eq(other) {
|
|
2476
|
-
return (0,
|
|
2440
|
+
return (0, import_lodash3.isEqual)(this.keyPath, other.keyPath);
|
|
2477
2441
|
}
|
|
2478
2442
|
ignoreEvent() {
|
|
2479
2443
|
return false;
|
|
@@ -2484,7 +2448,7 @@ var VariableTagWidget = class extends import_view4.WidgetType {
|
|
|
2484
2448
|
};
|
|
2485
2449
|
function VariableTagInject() {
|
|
2486
2450
|
const injector = (0, import_react39.useInjector)();
|
|
2487
|
-
const scope = (0,
|
|
2451
|
+
const scope = (0, import_editor10.useCurrentScope)();
|
|
2488
2452
|
(0, import_react38.useLayoutEffect)(() => {
|
|
2489
2453
|
const atMatcher = new import_view4.MatchDecorator({
|
|
2490
2454
|
regexp: /\{\{([^\}]+)\}\}/g,
|
|
@@ -2535,16 +2499,16 @@ var import_react43 = require("@coze-editor/editor/react");
|
|
|
2535
2499
|
|
|
2536
2500
|
// src/components/prompt-editor-with-inputs/inputs-picker.tsx
|
|
2537
2501
|
var import_react41 = __toESM(require("react"));
|
|
2538
|
-
var
|
|
2539
|
-
var
|
|
2502
|
+
var import_lodash4 = require("lodash");
|
|
2503
|
+
var import_editor11 = require("@flowgram.ai/editor");
|
|
2540
2504
|
var import_semi_ui19 = require("@douyinfe/semi-ui");
|
|
2541
2505
|
function InputsPicker({
|
|
2542
2506
|
inputsValues,
|
|
2543
2507
|
onSelect
|
|
2544
2508
|
}) {
|
|
2545
|
-
const available = (0,
|
|
2509
|
+
const available = (0, import_editor11.useScopeAvailable)();
|
|
2546
2510
|
const getArrayDrilldown = (type, depth = 1) => {
|
|
2547
|
-
if (
|
|
2511
|
+
if (import_editor11.ASTMatch.isArray(type.items)) {
|
|
2548
2512
|
return getArrayDrilldown(type.items, depth + 1);
|
|
2549
2513
|
}
|
|
2550
2514
|
return { type: type.items, depth };
|
|
@@ -2552,12 +2516,12 @@ function InputsPicker({
|
|
|
2552
2516
|
const renderVariable = (variable, keyPath) => {
|
|
2553
2517
|
let type = variable?.type;
|
|
2554
2518
|
let children;
|
|
2555
|
-
if (
|
|
2519
|
+
if (import_editor11.ASTMatch.isObject(type)) {
|
|
2556
2520
|
children = (type.properties || []).map((_property) => renderVariable(_property, [...keyPath, _property.key])).filter(Boolean);
|
|
2557
2521
|
}
|
|
2558
|
-
if (
|
|
2522
|
+
if (import_editor11.ASTMatch.isArray(type)) {
|
|
2559
2523
|
const drilldown = getArrayDrilldown(type);
|
|
2560
|
-
if (
|
|
2524
|
+
if (import_editor11.ASTMatch.isObject(drilldown.type)) {
|
|
2561
2525
|
children = (drilldown.type.properties || []).map(
|
|
2562
2526
|
(_property) => renderVariable(_property, [
|
|
2563
2527
|
...keyPath,
|
|
@@ -2570,7 +2534,7 @@ function InputsPicker({
|
|
|
2570
2534
|
const key = keyPath.map((_key, idx) => _key === "[0]" || idx === 0 ? _key : `.${_key}`).join("");
|
|
2571
2535
|
return {
|
|
2572
2536
|
key,
|
|
2573
|
-
label: (0,
|
|
2537
|
+
label: (0, import_lodash4.last)(keyPath),
|
|
2574
2538
|
value: key,
|
|
2575
2539
|
children
|
|
2576
2540
|
};
|
|
@@ -2716,8 +2680,8 @@ function VariableTree2() {
|
|
|
2716
2680
|
// src/components/json-editor-with-variables/extensions/variable-tag.tsx
|
|
2717
2681
|
var import_react47 = __toESM(require("react"));
|
|
2718
2682
|
var import_client = require("react-dom/client");
|
|
2719
|
-
var
|
|
2720
|
-
var
|
|
2683
|
+
var import_lodash5 = require("lodash");
|
|
2684
|
+
var import_editor12 = require("@flowgram.ai/editor");
|
|
2721
2685
|
var import_semi_ui23 = require("@douyinfe/semi-ui");
|
|
2722
2686
|
var import_semi_icons9 = require("@douyinfe/semi-icons");
|
|
2723
2687
|
var import_react48 = require("@coze-editor/editor/react");
|
|
@@ -2764,7 +2728,7 @@ var UIPopoverContent3 = import_styled_components9.default.div`
|
|
|
2764
2728
|
var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
2765
2729
|
constructor({ keyPath, scope }) {
|
|
2766
2730
|
super();
|
|
2767
|
-
this.toDispose = new
|
|
2731
|
+
this.toDispose = new import_editor12.DisposableCollection();
|
|
2768
2732
|
this.renderIcon = (icon) => {
|
|
2769
2733
|
if (typeof icon === "string") {
|
|
2770
2734
|
return /* @__PURE__ */ import_react47.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
@@ -2781,7 +2745,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2781
2745
|
);
|
|
2782
2746
|
return;
|
|
2783
2747
|
}
|
|
2784
|
-
const rootField = (0,
|
|
2748
|
+
const rootField = (0, import_lodash5.last)(v.parentFields);
|
|
2785
2749
|
const rootTitle = /* @__PURE__ */ import_react47.default.createElement(UIRootTitle3, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
|
|
2786
2750
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2787
2751
|
this.root.render(
|
|
@@ -2798,7 +2762,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2798
2762
|
const dom = document.createElement("span");
|
|
2799
2763
|
this.root = (0, import_client.createRoot)(dom);
|
|
2800
2764
|
this.toDispose.push(
|
|
2801
|
-
|
|
2765
|
+
import_editor12.Disposable.create(() => {
|
|
2802
2766
|
this.root.unmount();
|
|
2803
2767
|
})
|
|
2804
2768
|
);
|
|
@@ -2815,7 +2779,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2815
2779
|
return dom;
|
|
2816
2780
|
}
|
|
2817
2781
|
eq(other) {
|
|
2818
|
-
return (0,
|
|
2782
|
+
return (0, import_lodash5.isEqual)(this.keyPath, other.keyPath);
|
|
2819
2783
|
}
|
|
2820
2784
|
ignoreEvent() {
|
|
2821
2785
|
return false;
|
|
@@ -2826,7 +2790,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2826
2790
|
};
|
|
2827
2791
|
function VariableTagInject2() {
|
|
2828
2792
|
const injector = (0, import_react48.useInjector)();
|
|
2829
|
-
const scope = (0,
|
|
2793
|
+
const scope = (0, import_editor12.useCurrentScope)();
|
|
2830
2794
|
(0, import_react47.useLayoutEffect)(() => {
|
|
2831
2795
|
const atMatcher = new import_view5.MatchDecorator({
|
|
2832
2796
|
regexp: /\{\{([^\}]+)\}\}/g,
|
|
@@ -3108,7 +3072,7 @@ function SchemaTree(props) {
|
|
|
3108
3072
|
// src/components/display-outputs/index.tsx
|
|
3109
3073
|
var import_react54 = __toESM(require("react"));
|
|
3110
3074
|
var import_json_schema7 = require("@flowgram.ai/json-schema");
|
|
3111
|
-
var
|
|
3075
|
+
var import_editor13 = require("@flowgram.ai/editor");
|
|
3112
3076
|
|
|
3113
3077
|
// src/components/display-schema-tag/index.tsx
|
|
3114
3078
|
var import_react53 = __toESM(require("react"));
|
|
@@ -3161,8 +3125,8 @@ var DisplayOutputsWrapper = import_styled_components13.default.div`
|
|
|
3161
3125
|
|
|
3162
3126
|
// src/components/display-outputs/index.tsx
|
|
3163
3127
|
function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
3164
|
-
const scope = (0,
|
|
3165
|
-
const refresh = (0,
|
|
3128
|
+
const scope = (0, import_editor13.useCurrentScope)();
|
|
3129
|
+
const refresh = (0, import_editor13.useRefresh)();
|
|
3166
3130
|
(0, import_react54.useEffect)(() => {
|
|
3167
3131
|
if (!displayFromScope) {
|
|
3168
3132
|
return () => null;
|
|
@@ -3188,9 +3152,9 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
|
3188
3152
|
// src/components/display-flow-value/index.tsx
|
|
3189
3153
|
var import_react55 = __toESM(require("react"));
|
|
3190
3154
|
var import_json_schema8 = require("@flowgram.ai/json-schema");
|
|
3191
|
-
var
|
|
3155
|
+
var import_editor14 = require("@flowgram.ai/editor");
|
|
3192
3156
|
function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
3193
|
-
const available = (0,
|
|
3157
|
+
const available = (0, import_editor14.useScopeAvailable)();
|
|
3194
3158
|
const variable = value?.type === "ref" ? available.getByKeyPath(value?.content) : void 0;
|
|
3195
3159
|
const schema = (0, import_react55.useMemo)(() => {
|
|
3196
3160
|
if (value?.type === "ref") {
|
|
@@ -3244,29 +3208,29 @@ function DisplayInputsValues({ value, showIconInTree }) {
|
|
|
3244
3208
|
}
|
|
3245
3209
|
|
|
3246
3210
|
// src/effects/provide-batch-input/index.ts
|
|
3247
|
-
var
|
|
3248
|
-
var provideBatchInputEffect = (0,
|
|
3211
|
+
var import_editor15 = require("@flowgram.ai/editor");
|
|
3212
|
+
var provideBatchInputEffect = (0, import_editor15.createEffectFromVariableProvider)({
|
|
3249
3213
|
private: true,
|
|
3250
3214
|
parse: (value, ctx) => [
|
|
3251
|
-
|
|
3215
|
+
import_editor15.ASTFactory.createVariableDeclaration({
|
|
3252
3216
|
key: `${ctx.node.id}_locals`,
|
|
3253
3217
|
meta: {
|
|
3254
|
-
title: (0,
|
|
3218
|
+
title: (0, import_editor15.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3255
3219
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3256
3220
|
},
|
|
3257
|
-
type:
|
|
3221
|
+
type: import_editor15.ASTFactory.createObject({
|
|
3258
3222
|
properties: [
|
|
3259
|
-
|
|
3223
|
+
import_editor15.ASTFactory.createProperty({
|
|
3260
3224
|
key: "item",
|
|
3261
|
-
initializer:
|
|
3262
|
-
enumerateFor:
|
|
3225
|
+
initializer: import_editor15.ASTFactory.createEnumerateExpression({
|
|
3226
|
+
enumerateFor: import_editor15.ASTFactory.createKeyPathExpression({
|
|
3263
3227
|
keyPath: value.content || []
|
|
3264
3228
|
})
|
|
3265
3229
|
})
|
|
3266
3230
|
}),
|
|
3267
|
-
|
|
3231
|
+
import_editor15.ASTFactory.createProperty({
|
|
3268
3232
|
key: "index",
|
|
3269
|
-
type:
|
|
3233
|
+
type: import_editor15.ASTFactory.createNumber()
|
|
3270
3234
|
})
|
|
3271
3235
|
]
|
|
3272
3236
|
})
|
|
@@ -3275,14 +3239,14 @@ var provideBatchInputEffect = (0, import_editor14.createEffectFromVariableProvid
|
|
|
3275
3239
|
});
|
|
3276
3240
|
|
|
3277
3241
|
// src/effects/auto-rename-ref/index.ts
|
|
3278
|
-
var
|
|
3279
|
-
var
|
|
3242
|
+
var import_lodash6 = require("lodash");
|
|
3243
|
+
var import_editor16 = require("@flowgram.ai/editor");
|
|
3280
3244
|
var autoRenameRefEffect = [
|
|
3281
3245
|
{
|
|
3282
|
-
event:
|
|
3246
|
+
event: import_editor16.DataEvent.onValueInit,
|
|
3283
3247
|
effect: (params) => {
|
|
3284
3248
|
const { context, form, name } = params;
|
|
3285
|
-
const renameService = context.node.getService(
|
|
3249
|
+
const renameService = context.node.getService(import_editor16.VariableFieldKeyRenameService);
|
|
3286
3250
|
const disposable = renameService.onRename(({ before, after }) => {
|
|
3287
3251
|
const beforeKeyPath = [
|
|
3288
3252
|
...before.parentFields.map((_field) => _field.key).reverse(),
|
|
@@ -3331,7 +3295,7 @@ function isKeyPathMatch(keyPath = [], targetKeyPath) {
|
|
|
3331
3295
|
}
|
|
3332
3296
|
function getTemplateKeyPaths(value) {
|
|
3333
3297
|
const keyPathReg = /{{(.*?)}}/g;
|
|
3334
|
-
return (0,
|
|
3298
|
+
return (0, import_lodash6.uniq)(value.content?.match(keyPathReg) || []).map(
|
|
3335
3299
|
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
3336
3300
|
);
|
|
3337
3301
|
}
|
|
@@ -3342,7 +3306,7 @@ function isTemplate(value) {
|
|
|
3342
3306
|
return value?.type === "template" && typeof value?.content === "string";
|
|
3343
3307
|
}
|
|
3344
3308
|
function traverseRef(name, value, cb) {
|
|
3345
|
-
if ((0,
|
|
3309
|
+
if ((0, import_lodash6.isObject)(value)) {
|
|
3346
3310
|
if (isRef(value)) {
|
|
3347
3311
|
cb(name, value);
|
|
3348
3312
|
return;
|
|
@@ -3356,7 +3320,7 @@ function traverseRef(name, value, cb) {
|
|
|
3356
3320
|
});
|
|
3357
3321
|
return;
|
|
3358
3322
|
}
|
|
3359
|
-
if ((0,
|
|
3323
|
+
if ((0, import_lodash6.isArray)(value)) {
|
|
3360
3324
|
value.forEach((_value, idx) => {
|
|
3361
3325
|
traverseRef(`${name}[${idx}]`, _value, cb);
|
|
3362
3326
|
});
|
|
@@ -3367,13 +3331,13 @@ function traverseRef(name, value, cb) {
|
|
|
3367
3331
|
|
|
3368
3332
|
// src/effects/provide-json-schema-outputs/index.ts
|
|
3369
3333
|
var import_json_schema9 = require("@flowgram.ai/json-schema");
|
|
3370
|
-
var
|
|
3371
|
-
var provideJsonSchemaOutputs = (0,
|
|
3334
|
+
var import_editor17 = require("@flowgram.ai/editor");
|
|
3335
|
+
var provideJsonSchemaOutputs = (0, import_editor17.createEffectFromVariableProvider)({
|
|
3372
3336
|
parse: (value, ctx) => [
|
|
3373
|
-
|
|
3337
|
+
import_editor17.ASTFactory.createVariableDeclaration({
|
|
3374
3338
|
key: `${ctx.node.id}`,
|
|
3375
3339
|
meta: {
|
|
3376
|
-
title: (0,
|
|
3340
|
+
title: (0, import_editor17.getNodeForm)(ctx.node)?.getValueIn("title") || ctx.node.id,
|
|
3377
3341
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3378
3342
|
},
|
|
3379
3343
|
type: import_json_schema9.JsonSchemaUtils.schemaToAST(value)
|
|
@@ -3382,12 +3346,12 @@ var provideJsonSchemaOutputs = (0, import_editor16.createEffectFromVariableProvi
|
|
|
3382
3346
|
});
|
|
3383
3347
|
|
|
3384
3348
|
// src/effects/sync-variable-title/index.ts
|
|
3385
|
-
var
|
|
3349
|
+
var import_editor18 = require("@flowgram.ai/editor");
|
|
3386
3350
|
var syncVariableTitle = [
|
|
3387
3351
|
{
|
|
3388
|
-
event:
|
|
3352
|
+
event: import_editor18.DataEvent.onValueChange,
|
|
3389
3353
|
effect: ({ value, context }) => {
|
|
3390
|
-
context.node.getData(
|
|
3354
|
+
context.node.getData(import_editor18.FlowNodeVariableData).allScopes.forEach((_scope) => {
|
|
3391
3355
|
_scope.output.variables.forEach((_var) => {
|
|
3392
3356
|
_var.updateMeta({
|
|
3393
3357
|
..._var.meta || {},
|
|
@@ -3400,22 +3364,84 @@ var syncVariableTitle = [
|
|
|
3400
3364
|
}
|
|
3401
3365
|
];
|
|
3402
3366
|
|
|
3367
|
+
// src/shared/format-legacy-refs/index.ts
|
|
3368
|
+
var import_lodash7 = require("lodash");
|
|
3369
|
+
function formatLegacyRefOnSubmit(value) {
|
|
3370
|
+
if ((0, import_lodash7.isObject)(value)) {
|
|
3371
|
+
if (isLegacyFlowRefValueSchema(value)) {
|
|
3372
|
+
return formatLegacyRefToNewRef(value);
|
|
3373
|
+
}
|
|
3374
|
+
return Object.fromEntries(
|
|
3375
|
+
Object.entries(value).map(([key, value2]) => [
|
|
3376
|
+
key,
|
|
3377
|
+
formatLegacyRefOnSubmit(value2)
|
|
3378
|
+
])
|
|
3379
|
+
);
|
|
3380
|
+
}
|
|
3381
|
+
if (Array.isArray(value)) {
|
|
3382
|
+
return value.map(formatLegacyRefOnSubmit);
|
|
3383
|
+
}
|
|
3384
|
+
return value;
|
|
3385
|
+
}
|
|
3386
|
+
function formatLegacyRefOnInit(value) {
|
|
3387
|
+
if ((0, import_lodash7.isObject)(value)) {
|
|
3388
|
+
if (isNewFlowRefValueSchema(value)) {
|
|
3389
|
+
return formatNewRefToLegacyRef(value);
|
|
3390
|
+
}
|
|
3391
|
+
return Object.fromEntries(
|
|
3392
|
+
Object.entries(value).map(([key, value2]) => [
|
|
3393
|
+
key,
|
|
3394
|
+
formatLegacyRefOnInit(value2)
|
|
3395
|
+
])
|
|
3396
|
+
);
|
|
3397
|
+
}
|
|
3398
|
+
if (Array.isArray(value)) {
|
|
3399
|
+
return value.map(formatLegacyRefOnInit);
|
|
3400
|
+
}
|
|
3401
|
+
return value;
|
|
3402
|
+
}
|
|
3403
|
+
function isLegacyFlowRefValueSchema(value) {
|
|
3404
|
+
return (0, import_lodash7.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
3405
|
+
}
|
|
3406
|
+
function isNewFlowRefValueSchema(value) {
|
|
3407
|
+
return (0, import_lodash7.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
3408
|
+
}
|
|
3409
|
+
function formatLegacyRefToNewRef(value) {
|
|
3410
|
+
const keyPath = value.content.split(".");
|
|
3411
|
+
if (keyPath[1] === "outputs") {
|
|
3412
|
+
return {
|
|
3413
|
+
type: "ref",
|
|
3414
|
+
content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
|
|
3415
|
+
};
|
|
3416
|
+
}
|
|
3417
|
+
return {
|
|
3418
|
+
type: "ref",
|
|
3419
|
+
content: keyPath
|
|
3420
|
+
};
|
|
3421
|
+
}
|
|
3422
|
+
function formatNewRefToLegacyRef(value) {
|
|
3423
|
+
return {
|
|
3424
|
+
type: "ref",
|
|
3425
|
+
content: value.content.join(".")
|
|
3426
|
+
};
|
|
3427
|
+
}
|
|
3428
|
+
|
|
3403
3429
|
// src/form-plugins/batch-outputs-plugin/index.ts
|
|
3404
|
-
var
|
|
3405
|
-
var provideBatchOutputsEffect = (0,
|
|
3430
|
+
var import_editor19 = require("@flowgram.ai/editor");
|
|
3431
|
+
var provideBatchOutputsEffect = (0, import_editor19.createEffectFromVariableProvider)({
|
|
3406
3432
|
parse: (value, ctx) => [
|
|
3407
|
-
|
|
3433
|
+
import_editor19.ASTFactory.createVariableDeclaration({
|
|
3408
3434
|
key: `${ctx.node.id}`,
|
|
3409
3435
|
meta: {
|
|
3410
|
-
title: (0,
|
|
3436
|
+
title: (0, import_editor19.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3411
3437
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3412
3438
|
},
|
|
3413
|
-
type:
|
|
3439
|
+
type: import_editor19.ASTFactory.createObject({
|
|
3414
3440
|
properties: Object.entries(value).map(
|
|
3415
|
-
([_key, value2]) =>
|
|
3441
|
+
([_key, value2]) => import_editor19.ASTFactory.createProperty({
|
|
3416
3442
|
key: _key,
|
|
3417
|
-
initializer:
|
|
3418
|
-
wrapFor:
|
|
3443
|
+
initializer: import_editor19.ASTFactory.createWrapArrayExpression({
|
|
3444
|
+
wrapFor: import_editor19.ASTFactory.createKeyPathExpression({
|
|
3419
3445
|
keyPath: value2?.content || []
|
|
3420
3446
|
})
|
|
3421
3447
|
})
|
|
@@ -3425,7 +3451,7 @@ var provideBatchOutputsEffect = (0, import_editor18.createEffectFromVariableProv
|
|
|
3425
3451
|
})
|
|
3426
3452
|
]
|
|
3427
3453
|
});
|
|
3428
|
-
var createBatchOutputsFormPlugin = (0,
|
|
3454
|
+
var createBatchOutputsFormPlugin = (0, import_editor19.defineFormPluginCreator)({
|
|
3429
3455
|
name: "batch-outputs-plugin",
|
|
3430
3456
|
onSetupFormMeta({ mergeEffect }, { outputKey }) {
|
|
3431
3457
|
mergeEffect({
|
|
@@ -3433,7 +3459,7 @@ var createBatchOutputsFormPlugin = (0, import_editor18.defineFormPluginCreator)(
|
|
|
3433
3459
|
});
|
|
3434
3460
|
},
|
|
3435
3461
|
onInit(ctx, { outputKey }) {
|
|
3436
|
-
const chainTransformService = ctx.node.getService(
|
|
3462
|
+
const chainTransformService = ctx.node.getService(import_editor19.ScopeChainTransformService);
|
|
3437
3463
|
const batchNodeType = ctx.node.flowNodeType;
|
|
3438
3464
|
const transformerId = `${batchNodeType}-outputs`;
|
|
3439
3465
|
if (chainTransformService.hasTransformer(transformerId)) {
|
|
@@ -3443,21 +3469,21 @@ var createBatchOutputsFormPlugin = (0, import_editor18.defineFormPluginCreator)(
|
|
|
3443
3469
|
transformCovers: (covers, ctx2) => {
|
|
3444
3470
|
const node = ctx2.scope.meta?.node;
|
|
3445
3471
|
if (node?.parent?.flowNodeType === batchNodeType) {
|
|
3446
|
-
return [...covers, (0,
|
|
3472
|
+
return [...covers, (0, import_editor19.getNodeScope)(node.parent)];
|
|
3447
3473
|
}
|
|
3448
3474
|
return covers;
|
|
3449
3475
|
},
|
|
3450
3476
|
transformDeps(scopes, ctx2) {
|
|
3451
3477
|
const scopeMeta = ctx2.scope.meta;
|
|
3452
|
-
if (scopeMeta?.type ===
|
|
3478
|
+
if (scopeMeta?.type === import_editor19.FlowNodeScopeType.private) {
|
|
3453
3479
|
return scopes;
|
|
3454
3480
|
}
|
|
3455
3481
|
const node = scopeMeta?.node;
|
|
3456
3482
|
if (node?.flowNodeType === batchNodeType) {
|
|
3457
3483
|
const childBlocks = node.blocks;
|
|
3458
3484
|
return [
|
|
3459
|
-
(0,
|
|
3460
|
-
...childBlocks.map((_childBlock) => (0,
|
|
3485
|
+
(0, import_editor19.getNodePrivateScope)(node),
|
|
3486
|
+
...childBlocks.map((_childBlock) => (0, import_editor19.getNodeScope)(_childBlock))
|
|
3461
3487
|
];
|
|
3462
3488
|
}
|
|
3463
3489
|
return scopes;
|
|
@@ -3469,8 +3495,8 @@ var createBatchOutputsFormPlugin = (0, import_editor18.defineFormPluginCreator)(
|
|
|
3469
3495
|
// src/form-plugins/infer-inputs-plugin/index.ts
|
|
3470
3496
|
var import_lodash8 = require("lodash");
|
|
3471
3497
|
var import_json_schema10 = require("@flowgram.ai/json-schema");
|
|
3472
|
-
var
|
|
3473
|
-
var createInferInputsPlugin = (0,
|
|
3498
|
+
var import_editor20 = require("@flowgram.ai/editor");
|
|
3499
|
+
var createInferInputsPlugin = (0, import_editor20.defineFormPluginCreator)({
|
|
3474
3500
|
onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
|
|
3475
3501
|
if (!sourceKey || !targetKey) {
|
|
3476
3502
|
return;
|
|
@@ -3481,7 +3507,7 @@ var createInferInputsPlugin = (0, import_editor19.defineFormPluginCreator)({
|
|
|
3481
3507
|
targetKey,
|
|
3482
3508
|
infer(
|
|
3483
3509
|
(0, import_lodash8.get)(formData, sourceKey),
|
|
3484
|
-
scope === "private" ? (0,
|
|
3510
|
+
scope === "private" ? (0, import_editor20.getNodePrivateScope)(ctx.node) : (0, import_editor20.getNodeScope)(ctx.node)
|
|
3485
3511
|
)
|
|
3486
3512
|
);
|
|
3487
3513
|
return formData;
|
|
@@ -3567,6 +3593,7 @@ var infer = (values, scope) => {
|
|
|
3567
3593
|
VariableSelector,
|
|
3568
3594
|
autoRenameRefEffect,
|
|
3569
3595
|
createBatchOutputsFormPlugin,
|
|
3596
|
+
createDisableDeclarationPlugin,
|
|
3570
3597
|
createInferInputsPlugin,
|
|
3571
3598
|
createTypePresetPlugin,
|
|
3572
3599
|
formatLegacyRefOnInit,
|