@flowgram.ai/form-materials 0.4.1 → 0.4.3
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/dist/esm/index.js +198 -87
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +29 -4
- package/dist/index.d.ts +29 -4
- package/dist/index.js +249 -139
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/display-flow-value/index.tsx +2 -12
- package/src/components/display-inputs-values/index.tsx +44 -6
- package/src/components/dynamic-value-input/hooks.ts +23 -2
- package/src/components/dynamic-value-input/index.tsx +21 -12
- package/src/components/inputs-values/index.tsx +12 -1
- package/src/components/inputs-values-tree/hooks/use-child-list.tsx +8 -3
- package/src/components/inputs-values-tree/index.tsx +7 -1
- package/src/components/inputs-values-tree/row.tsx +23 -9
- package/src/components/json-editor-with-variables/extensions/variable-tag.tsx +1 -1
- package/src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx +11 -0
- package/src/components/prompt-editor-with-inputs/index.tsx +1 -2
- package/src/components/prompt-editor-with-inputs/inputs-picker.tsx +34 -17
- package/src/components/prompt-editor-with-variables/extensions/variable-tag.tsx +1 -1
- package/src/components/prompt-editor-with-variables/extensions/variable-tree.tsx +13 -1
- package/src/components/type-selector/index.tsx +12 -2
- package/src/index.ts +1 -0
- package/src/shared/flow-value/schema.ts +1 -1
- package/src/shared/flow-value/utils.ts +1 -1
- package/src/typings/flow-value/index.ts +1 -1
- package/src/validate/validate-flow-value/index.tsx +4 -16
package/dist/index.js
CHANGED
|
@@ -40,6 +40,7 @@ __export(src_exports, {
|
|
|
40
40
|
ConditionRow: () => ConditionRow,
|
|
41
41
|
ConstantInput: () => ConstantInput,
|
|
42
42
|
DisplayFlowValue: () => DisplayFlowValue,
|
|
43
|
+
DisplayInputsValueAllInTag: () => DisplayInputsValueAllInTag,
|
|
43
44
|
DisplayInputsValues: () => DisplayInputsValues,
|
|
44
45
|
DisplayOutputs: () => DisplayOutputs,
|
|
45
46
|
DisplaySchemaTag: () => DisplaySchemaTag,
|
|
@@ -81,6 +82,7 @@ __export(src_exports, {
|
|
|
81
82
|
provideBatchOutputsEffect: () => provideBatchOutputsEffect,
|
|
82
83
|
provideJsonSchemaOutputs: () => provideJsonSchemaOutputs,
|
|
83
84
|
syncVariableTitle: () => syncVariableTitle,
|
|
85
|
+
useObjectList: () => useObjectList,
|
|
84
86
|
useTypeManager: () => useTypeManager,
|
|
85
87
|
useVariableTree: () => useVariableTree,
|
|
86
88
|
validateFlowValue: () => validateFlowValue,
|
|
@@ -193,7 +195,7 @@ var extraSchema = import_zod.default.object({
|
|
|
193
195
|
}).optional();
|
|
194
196
|
var constantSchema = import_zod.default.object({
|
|
195
197
|
type: import_zod.default.literal("constant"),
|
|
196
|
-
content: import_zod.default.
|
|
198
|
+
content: import_zod.default.any().optional(),
|
|
197
199
|
schema: import_zod.default.any().optional(),
|
|
198
200
|
extra: extraSchema
|
|
199
201
|
});
|
|
@@ -273,13 +275,13 @@ var FlowValueUtils;
|
|
|
273
275
|
return;
|
|
274
276
|
}
|
|
275
277
|
FlowValueUtils2.traverse = traverse;
|
|
276
|
-
function
|
|
277
|
-
const keyPathReg =
|
|
278
|
+
function getTemplateKeyPaths(value) {
|
|
279
|
+
const keyPathReg = /\{\{([^\}\{]+)\}\}/g;
|
|
278
280
|
return (0, import_lodash2.uniq)(value.content?.match(keyPathReg) || []).map(
|
|
279
281
|
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
280
282
|
);
|
|
281
283
|
}
|
|
282
|
-
FlowValueUtils2.getTemplateKeyPaths =
|
|
284
|
+
FlowValueUtils2.getTemplateKeyPaths = getTemplateKeyPaths;
|
|
283
285
|
function inferConstantJsonSchema(value) {
|
|
284
286
|
if (value?.schema) {
|
|
285
287
|
return value.schema;
|
|
@@ -1127,12 +1129,24 @@ function TypeSelector(props) {
|
|
|
1127
1129
|
}),
|
|
1128
1130
|
[]
|
|
1129
1131
|
);
|
|
1132
|
+
const isDisabled = readonly || disabled;
|
|
1130
1133
|
return /* @__PURE__ */ import_react14.default.createElement(
|
|
1131
1134
|
import_semi_ui8.Cascader,
|
|
1132
1135
|
{
|
|
1133
|
-
disabled:
|
|
1136
|
+
disabled: isDisabled,
|
|
1134
1137
|
size: "small",
|
|
1135
|
-
triggerRender: () => /* @__PURE__ */ import_react14.default.createElement(
|
|
1138
|
+
triggerRender: () => /* @__PURE__ */ import_react14.default.createElement(
|
|
1139
|
+
import_semi_ui8.IconButton,
|
|
1140
|
+
{
|
|
1141
|
+
size: "small",
|
|
1142
|
+
style: {
|
|
1143
|
+
...isDisabled ? { pointerEvents: "none" } : {},
|
|
1144
|
+
...style || {}
|
|
1145
|
+
},
|
|
1146
|
+
disabled: isDisabled,
|
|
1147
|
+
icon
|
|
1148
|
+
}
|
|
1149
|
+
),
|
|
1136
1150
|
treeData: options,
|
|
1137
1151
|
value: selectValue,
|
|
1138
1152
|
leafOnly: true,
|
|
@@ -1685,8 +1699,25 @@ function useSelectSchema(schemaFromProps, constantProps, value) {
|
|
|
1685
1699
|
if (value?.type === "constant") {
|
|
1686
1700
|
defaultSelectSchema = value?.schema || defaultSelectSchema;
|
|
1687
1701
|
}
|
|
1702
|
+
const changeVersion = (0, import_react22.useRef)(0);
|
|
1703
|
+
const effectVersion = (0, import_react22.useRef)(0);
|
|
1688
1704
|
const [selectSchema, setSelectSchema] = (0, import_react22.useState)(defaultSelectSchema);
|
|
1689
|
-
|
|
1705
|
+
(0, import_react22.useEffect)(() => {
|
|
1706
|
+
effectVersion.current += 1;
|
|
1707
|
+
if (changeVersion.current === effectVersion.current) {
|
|
1708
|
+
return;
|
|
1709
|
+
}
|
|
1710
|
+
effectVersion.current = changeVersion.current;
|
|
1711
|
+
if (value?.type === "constant" && value?.schema) {
|
|
1712
|
+
setSelectSchema(value?.schema);
|
|
1713
|
+
return;
|
|
1714
|
+
}
|
|
1715
|
+
}, [value]);
|
|
1716
|
+
const setSelectSchemaWithVersionUpdate = (schema) => {
|
|
1717
|
+
setSelectSchema(schema);
|
|
1718
|
+
changeVersion.current += 1;
|
|
1719
|
+
};
|
|
1720
|
+
return [selectSchema, setSelectSchemaWithVersionUpdate];
|
|
1690
1721
|
}
|
|
1691
1722
|
function useIncludeSchema(schemaFromProps) {
|
|
1692
1723
|
const includeSchema = (0, import_react22.useMemo)(() => {
|
|
@@ -1702,6 +1733,11 @@ function useIncludeSchema(schemaFromProps) {
|
|
|
1702
1733
|
}
|
|
1703
1734
|
|
|
1704
1735
|
// src/components/dynamic-value-input/index.tsx
|
|
1736
|
+
var DEFAULT_VALUE = {
|
|
1737
|
+
type: "constant",
|
|
1738
|
+
content: "",
|
|
1739
|
+
schema: { type: "string" }
|
|
1740
|
+
};
|
|
1705
1741
|
function DynamicValueInput({
|
|
1706
1742
|
value,
|
|
1707
1743
|
onChange,
|
|
@@ -1713,6 +1749,7 @@ function DynamicValueInput({
|
|
|
1713
1749
|
const refVariable = useRefVariable(value);
|
|
1714
1750
|
const [selectSchema, setSelectSchema] = useSelectSchema(schemaFromProps, constantProps, value);
|
|
1715
1751
|
const includeSchema = useIncludeSchema(schemaFromProps);
|
|
1752
|
+
const typeManager = (0, import_json_schema7.useTypeManager)();
|
|
1716
1753
|
const renderTypeSelector = () => {
|
|
1717
1754
|
if (schemaFromProps) {
|
|
1718
1755
|
return /* @__PURE__ */ import_react23.default.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
|
|
@@ -1727,20 +1764,18 @@ function DynamicValueInput({
|
|
|
1727
1764
|
value: selectSchema,
|
|
1728
1765
|
onChange: (_v) => {
|
|
1729
1766
|
setSelectSchema(_v || { type: "string" });
|
|
1730
|
-
|
|
1767
|
+
const schema = _v || { type: "string" };
|
|
1768
|
+
let content = typeManager.getDefaultValue(schema);
|
|
1731
1769
|
if (_v?.type === "object") {
|
|
1732
1770
|
content = "{}";
|
|
1733
1771
|
}
|
|
1734
1772
|
if (_v?.type === "array") {
|
|
1735
1773
|
content = "[]";
|
|
1736
1774
|
}
|
|
1737
|
-
if (_v?.type === "boolean") {
|
|
1738
|
-
content = false;
|
|
1739
|
-
}
|
|
1740
1775
|
onChange({
|
|
1741
1776
|
type: "constant",
|
|
1742
1777
|
content,
|
|
1743
|
-
schema
|
|
1778
|
+
schema
|
|
1744
1779
|
});
|
|
1745
1780
|
},
|
|
1746
1781
|
readonly
|
|
@@ -1754,7 +1789,7 @@ function DynamicValueInput({
|
|
|
1754
1789
|
{
|
|
1755
1790
|
style: { width: "100%" },
|
|
1756
1791
|
value: value?.content,
|
|
1757
|
-
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } :
|
|
1792
|
+
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : DEFAULT_VALUE),
|
|
1758
1793
|
includeSchema,
|
|
1759
1794
|
readonly
|
|
1760
1795
|
}
|
|
@@ -1768,17 +1803,17 @@ function DynamicValueInput({
|
|
|
1768
1803
|
onChange: (_v) => onChange({ type: "constant", content: _v, schema: constantSchema2 }),
|
|
1769
1804
|
schema: constantSchema2 || { type: "string" },
|
|
1770
1805
|
readonly,
|
|
1771
|
-
strategies: [...constantProps?.strategies || []],
|
|
1772
1806
|
fallbackRenderer: () => /* @__PURE__ */ import_react23.default.createElement(
|
|
1773
1807
|
InjectVariableSelector,
|
|
1774
1808
|
{
|
|
1775
1809
|
style: { width: "100%" },
|
|
1776
|
-
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } :
|
|
1810
|
+
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : DEFAULT_VALUE),
|
|
1777
1811
|
includeSchema,
|
|
1778
1812
|
readonly
|
|
1779
1813
|
}
|
|
1780
1814
|
),
|
|
1781
|
-
...constantProps
|
|
1815
|
+
...constantProps,
|
|
1816
|
+
strategies: [...constantProps?.strategies || []]
|
|
1782
1817
|
}
|
|
1783
1818
|
);
|
|
1784
1819
|
};
|
|
@@ -2413,8 +2448,16 @@ function VariableTree() {
|
|
|
2413
2448
|
if (!range) {
|
|
2414
2449
|
return;
|
|
2415
2450
|
}
|
|
2451
|
+
let { from, to } = range;
|
|
2452
|
+
while (editor.$view.state.doc.sliceString(from - 1, from) === "{") {
|
|
2453
|
+
from--;
|
|
2454
|
+
}
|
|
2455
|
+
while (editor.$view.state.doc.sliceString(to, to + 1) === "}") {
|
|
2456
|
+
to++;
|
|
2457
|
+
}
|
|
2416
2458
|
editor.replaceText({
|
|
2417
|
-
|
|
2459
|
+
from,
|
|
2460
|
+
to,
|
|
2418
2461
|
text: "{{" + variablePath + "}}"
|
|
2419
2462
|
});
|
|
2420
2463
|
setVisible(false);
|
|
@@ -2576,7 +2619,7 @@ function VariableTagInject() {
|
|
|
2576
2619
|
const scope = (0, import_editor23.useCurrentScope)();
|
|
2577
2620
|
(0, import_react39.useLayoutEffect)(() => {
|
|
2578
2621
|
const atMatcher = new import_view4.MatchDecorator({
|
|
2579
|
-
regexp: /\{\{([^\}]+)\}\}/g,
|
|
2622
|
+
regexp: /\{\{([^\}\{]+)\}\}/g,
|
|
2580
2623
|
decoration: (match) => import_view4.Decoration.replace({
|
|
2581
2624
|
widget: new VariableTagWidget({
|
|
2582
2625
|
keyPath: match[1]?.split(".") ?? [],
|
|
@@ -2664,20 +2707,32 @@ function InputsPicker({
|
|
|
2664
2707
|
children
|
|
2665
2708
|
};
|
|
2666
2709
|
};
|
|
2667
|
-
const
|
|
2668
|
-
|
|
2669
|
-
|
|
2710
|
+
const getTreeData = (value, keyPath) => {
|
|
2711
|
+
const currKey = keyPath.join(".");
|
|
2712
|
+
if (FlowValueUtils.isFlowValue(value)) {
|
|
2713
|
+
if (FlowValueUtils.isRef(value)) {
|
|
2670
2714
|
const variable = available.getByKeyPath(value.content || []);
|
|
2671
2715
|
if (variable) {
|
|
2672
|
-
return renderVariable(variable,
|
|
2716
|
+
return renderVariable(variable, keyPath);
|
|
2673
2717
|
}
|
|
2674
2718
|
}
|
|
2675
2719
|
return {
|
|
2676
|
-
key,
|
|
2677
|
-
value:
|
|
2678
|
-
label:
|
|
2720
|
+
key: currKey,
|
|
2721
|
+
value: currKey,
|
|
2722
|
+
label: (0, import_lodash6.last)(keyPath)
|
|
2679
2723
|
};
|
|
2680
|
-
}
|
|
2724
|
+
}
|
|
2725
|
+
if ((0, import_lodash6.isPlainObject)(value)) {
|
|
2726
|
+
return {
|
|
2727
|
+
key: currKey,
|
|
2728
|
+
value: currKey,
|
|
2729
|
+
label: (0, import_lodash6.last)(keyPath),
|
|
2730
|
+
children: Object.entries(value).map(([key, value2]) => getTreeData(value2, [...keyPath, key])).filter(Boolean)
|
|
2731
|
+
};
|
|
2732
|
+
}
|
|
2733
|
+
};
|
|
2734
|
+
const treeData = (0, import_react42.useMemo)(
|
|
2735
|
+
() => Object.entries(inputsValues).map(([key, value]) => getTreeData(value, [key])).filter(Boolean),
|
|
2681
2736
|
[]
|
|
2682
2737
|
);
|
|
2683
2738
|
return /* @__PURE__ */ import_react42.default.createElement(import_semi_ui18.Tree, { treeData, onSelect: (v) => onSelect(v) });
|
|
@@ -2694,6 +2749,13 @@ function InputsTree({ inputsValues }) {
|
|
|
2694
2749
|
if (!range) {
|
|
2695
2750
|
return;
|
|
2696
2751
|
}
|
|
2752
|
+
let { from, to } = range;
|
|
2753
|
+
while (editor.$view.state.doc.sliceString(from - 1, from) === "{") {
|
|
2754
|
+
from--;
|
|
2755
|
+
}
|
|
2756
|
+
while (editor.$view.state.doc.sliceString(to, to + 1) === "}") {
|
|
2757
|
+
to++;
|
|
2758
|
+
}
|
|
2697
2759
|
editor.replaceText({
|
|
2698
2760
|
...range,
|
|
2699
2761
|
text: "{{" + variablePath + "}}"
|
|
@@ -2918,7 +2980,7 @@ function VariableTagInject2() {
|
|
|
2918
2980
|
const scope = (0, import_editor25.useCurrentScope)();
|
|
2919
2981
|
(0, import_react48.useLayoutEffect)(() => {
|
|
2920
2982
|
const atMatcher = new import_view5.MatchDecorator({
|
|
2921
|
-
regexp: /\{\{([^\}]+)\}\}/g,
|
|
2983
|
+
regexp: /\{\{([^\}\{]+)\}\}/g,
|
|
2922
2984
|
decoration: (match) => import_view5.Decoration.replace({
|
|
2923
2985
|
widget: new VariableTagWidget2({
|
|
2924
2986
|
keyPath: match[1]?.split(".") ?? [],
|
|
@@ -3065,7 +3127,20 @@ function InputsValues({
|
|
|
3065
3127
|
size: "small",
|
|
3066
3128
|
onClick: () => remove(item.id)
|
|
3067
3129
|
}
|
|
3068
|
-
)))), /* @__PURE__ */ import_react51.default.createElement(
|
|
3130
|
+
)))), /* @__PURE__ */ import_react51.default.createElement(
|
|
3131
|
+
import_semi_ui23.Button,
|
|
3132
|
+
{
|
|
3133
|
+
disabled: readonly,
|
|
3134
|
+
icon: /* @__PURE__ */ import_react51.default.createElement(import_semi_icons9.IconPlus, null),
|
|
3135
|
+
size: "small",
|
|
3136
|
+
onClick: () => add({
|
|
3137
|
+
type: "constant",
|
|
3138
|
+
content: "",
|
|
3139
|
+
schema: { type: "string" }
|
|
3140
|
+
})
|
|
3141
|
+
},
|
|
3142
|
+
import_editor26.I18n.t("Add")
|
|
3143
|
+
));
|
|
3069
3144
|
}
|
|
3070
3145
|
|
|
3071
3146
|
// src/components/display-schema-tree/index.tsx
|
|
@@ -3278,18 +3353,7 @@ function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
|
3278
3353
|
return { type: "string" };
|
|
3279
3354
|
}
|
|
3280
3355
|
if (value?.type === "constant") {
|
|
3281
|
-
|
|
3282
|
-
return value?.schema;
|
|
3283
|
-
}
|
|
3284
|
-
if (typeof value?.content === "string") {
|
|
3285
|
-
return { type: "string" };
|
|
3286
|
-
}
|
|
3287
|
-
if (typeof value?.content === "number") {
|
|
3288
|
-
return { type: "number" };
|
|
3289
|
-
}
|
|
3290
|
-
if (typeof value?.content === "boolean") {
|
|
3291
|
-
return { type: "boolean" };
|
|
3292
|
-
}
|
|
3356
|
+
return FlowValueUtils.inferConstantJsonSchema(value);
|
|
3293
3357
|
}
|
|
3294
3358
|
return { type: "unknown" };
|
|
3295
3359
|
}, [value, variable?.hash]);
|
|
@@ -3306,6 +3370,8 @@ function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
|
3306
3370
|
|
|
3307
3371
|
// src/components/display-inputs-values/index.tsx
|
|
3308
3372
|
var import_react56 = __toESM(require("react"));
|
|
3373
|
+
var import_lodash8 = require("lodash");
|
|
3374
|
+
var import_editor29 = require("@flowgram.ai/editor");
|
|
3309
3375
|
|
|
3310
3376
|
// src/components/display-inputs-values/styles.ts
|
|
3311
3377
|
var import_styled_components14 = __toESM(require("styled-components"));
|
|
@@ -3318,12 +3384,40 @@ var DisplayInputsWrapper = import_styled_components14.default.div`
|
|
|
3318
3384
|
// src/components/display-inputs-values/index.tsx
|
|
3319
3385
|
function DisplayInputsValues({ value, showIconInTree }) {
|
|
3320
3386
|
const childEntries = Object.entries(value || {});
|
|
3321
|
-
return /* @__PURE__ */ import_react56.default.createElement(DisplayInputsWrapper, null, childEntries.map(([key, value2]) =>
|
|
3387
|
+
return /* @__PURE__ */ import_react56.default.createElement(DisplayInputsWrapper, null, childEntries.map(([key, value2]) => {
|
|
3388
|
+
if (FlowValueUtils.isFlowValue(value2)) {
|
|
3389
|
+
return /* @__PURE__ */ import_react56.default.createElement(DisplayFlowValue, { key, title: key, value: value2, showIconInTree });
|
|
3390
|
+
}
|
|
3391
|
+
if ((0, import_lodash8.isPlainObject)(value2)) {
|
|
3392
|
+
return /* @__PURE__ */ import_react56.default.createElement(
|
|
3393
|
+
DisplayInputsValueAllInTag,
|
|
3394
|
+
{
|
|
3395
|
+
key,
|
|
3396
|
+
title: key,
|
|
3397
|
+
value: value2,
|
|
3398
|
+
showIconInTree
|
|
3399
|
+
}
|
|
3400
|
+
);
|
|
3401
|
+
}
|
|
3402
|
+
return null;
|
|
3403
|
+
}));
|
|
3404
|
+
}
|
|
3405
|
+
function DisplayInputsValueAllInTag({
|
|
3406
|
+
value,
|
|
3407
|
+
title,
|
|
3408
|
+
showIconInTree
|
|
3409
|
+
}) {
|
|
3410
|
+
const available = (0, import_editor29.useScopeAvailable)();
|
|
3411
|
+
const schema = (0, import_react56.useMemo)(
|
|
3412
|
+
() => FlowValueUtils.inferJsonSchema(value, available.scope),
|
|
3413
|
+
[available.version, value]
|
|
3414
|
+
);
|
|
3415
|
+
return /* @__PURE__ */ import_react56.default.createElement(DisplaySchemaTag, { title, value: schema, showIconInTree });
|
|
3322
3416
|
}
|
|
3323
3417
|
|
|
3324
3418
|
// src/components/assign-rows/index.tsx
|
|
3325
3419
|
var import_react59 = __toESM(require("react"));
|
|
3326
|
-
var
|
|
3420
|
+
var import_editor30 = require("@flowgram.ai/editor");
|
|
3327
3421
|
var import_semi_ui27 = require("@douyinfe/semi-ui");
|
|
3328
3422
|
var import_semi_icons11 = require("@douyinfe/semi-icons");
|
|
3329
3423
|
|
|
@@ -3410,7 +3504,7 @@ function AssignRow(props) {
|
|
|
3410
3504
|
// src/components/assign-rows/index.tsx
|
|
3411
3505
|
function AssignRows(props) {
|
|
3412
3506
|
const { name, readonly } = props;
|
|
3413
|
-
return /* @__PURE__ */ import_react59.default.createElement(
|
|
3507
|
+
return /* @__PURE__ */ import_react59.default.createElement(import_editor30.FieldArray, { name }, ({ field }) => /* @__PURE__ */ import_react59.default.createElement(import_react59.default.Fragment, null, field.map((childField, index) => /* @__PURE__ */ import_react59.default.createElement(
|
|
3414
3508
|
AssignRow,
|
|
3415
3509
|
{
|
|
3416
3510
|
key: childField.key,
|
|
@@ -3444,7 +3538,7 @@ function AssignRows(props) {
|
|
|
3444
3538
|
|
|
3445
3539
|
// src/components/inputs-values-tree/index.tsx
|
|
3446
3540
|
var import_react63 = __toESM(require("react"));
|
|
3447
|
-
var
|
|
3541
|
+
var import_editor32 = require("@flowgram.ai/editor");
|
|
3448
3542
|
var import_semi_ui29 = require("@douyinfe/semi-ui");
|
|
3449
3543
|
var import_semi_icons14 = require("@douyinfe/semi-icons");
|
|
3450
3544
|
|
|
@@ -3554,16 +3648,16 @@ var IconAddChildren2 = () => /* @__PURE__ */ import_react60.default.createElemen
|
|
|
3554
3648
|
|
|
3555
3649
|
// src/components/inputs-values-tree/row.tsx
|
|
3556
3650
|
var import_react62 = __toESM(require("react"));
|
|
3557
|
-
var
|
|
3651
|
+
var import_editor31 = require("@flowgram.ai/editor");
|
|
3558
3652
|
var import_semi_ui28 = require("@douyinfe/semi-ui");
|
|
3559
3653
|
var import_semi_icons13 = require("@douyinfe/semi-icons");
|
|
3560
3654
|
|
|
3561
3655
|
// src/components/inputs-values-tree/hooks/use-child-list.tsx
|
|
3562
3656
|
var import_react61 = require("react");
|
|
3563
|
-
var
|
|
3657
|
+
var import_lodash9 = require("lodash");
|
|
3564
3658
|
function useChildList(value, onChange) {
|
|
3565
3659
|
const canAddField = (0, import_react61.useMemo)(() => {
|
|
3566
|
-
if (!(0,
|
|
3660
|
+
if (!(0, import_lodash9.isPlainObject)(value)) {
|
|
3567
3661
|
return false;
|
|
3568
3662
|
}
|
|
3569
3663
|
if (FlowValueUtils.isFlowValue(value)) {
|
|
@@ -3572,7 +3666,7 @@ function useChildList(value, onChange) {
|
|
|
3572
3666
|
return true;
|
|
3573
3667
|
}, [value]);
|
|
3574
3668
|
const objectListValue = (0, import_react61.useMemo)(() => {
|
|
3575
|
-
if ((0,
|
|
3669
|
+
if ((0, import_lodash9.isPlainObject)(value)) {
|
|
3576
3670
|
if (FlowValueUtils.isFlowValue(value)) {
|
|
3577
3671
|
return void 0;
|
|
3578
3672
|
}
|
|
@@ -3580,7 +3674,6 @@ function useChildList(value, onChange) {
|
|
|
3580
3674
|
}
|
|
3581
3675
|
return void 0;
|
|
3582
3676
|
}, [value]);
|
|
3583
|
-
console.log("debugger objectListValue", objectListValue);
|
|
3584
3677
|
const { list, add, updateKey, updateValue, remove } = useObjectList({
|
|
3585
3678
|
value: objectListValue,
|
|
3586
3679
|
onChange: (value2) => {
|
|
@@ -3588,8 +3681,13 @@ function useChildList(value, onChange) {
|
|
|
3588
3681
|
},
|
|
3589
3682
|
sortIndexKey: (value2) => FlowValueUtils.isFlowValue(value2) ? "extra.index" : ""
|
|
3590
3683
|
});
|
|
3684
|
+
const hasChildren = (0, import_react61.useMemo)(
|
|
3685
|
+
() => canAddField && (list.length > 0 || Object.keys(objectListValue || {}).length > 0),
|
|
3686
|
+
[canAddField, list.length, Object.keys(objectListValue || {}).length]
|
|
3687
|
+
);
|
|
3591
3688
|
return {
|
|
3592
3689
|
canAddField,
|
|
3690
|
+
hasChildren,
|
|
3593
3691
|
list,
|
|
3594
3692
|
add,
|
|
3595
3693
|
updateKey,
|
|
@@ -3607,7 +3705,7 @@ var AddObjectChildStrategy = {
|
|
|
3607
3705
|
size: "small",
|
|
3608
3706
|
disabled: true,
|
|
3609
3707
|
style: { pointerEvents: "none" },
|
|
3610
|
-
value:
|
|
3708
|
+
value: import_editor31.I18n.t("Configure via child fields")
|
|
3611
3709
|
}
|
|
3612
3710
|
)
|
|
3613
3711
|
};
|
|
@@ -3625,12 +3723,21 @@ function InputValueRow(props) {
|
|
|
3625
3723
|
readonly
|
|
3626
3724
|
} = props;
|
|
3627
3725
|
const [collapse, setCollapse] = (0, import_react62.useState)(false);
|
|
3628
|
-
const { canAddField, list, add, updateKey, updateValue, remove } = useChildList(
|
|
3726
|
+
const { canAddField, hasChildren, list, add, updateKey, updateValue, remove } = useChildList(
|
|
3629
3727
|
value,
|
|
3630
3728
|
onUpdateValue
|
|
3631
3729
|
);
|
|
3632
|
-
const
|
|
3633
|
-
|
|
3730
|
+
const strategies = (0, import_react62.useMemo)(
|
|
3731
|
+
() => [...hasChildren ? [AddObjectChildStrategy] : [], ...constantProps?.strategies || []],
|
|
3732
|
+
[hasChildren, constantProps?.strategies]
|
|
3733
|
+
);
|
|
3734
|
+
const flowDisplayValue = (0, import_react62.useMemo)(
|
|
3735
|
+
() => hasChildren ? {
|
|
3736
|
+
type: "constant",
|
|
3737
|
+
schema: { type: "object" }
|
|
3738
|
+
} : value,
|
|
3739
|
+
[hasChildren, value]
|
|
3740
|
+
);
|
|
3634
3741
|
return /* @__PURE__ */ import_react62.default.createElement(import_react62.default.Fragment, null, /* @__PURE__ */ import_react62.default.createElement(UITreeItemLeft2, { $isLast, $showLine: $level > 0, $showCollapse: hasChildren }, hasChildren && /* @__PURE__ */ import_react62.default.createElement(UICollapseTrigger2, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ import_react62.default.createElement(import_semi_icons13.IconChevronDown, { size: "small" }) : /* @__PURE__ */ import_react62.default.createElement(import_semi_icons13.IconChevronRight, { size: "small" }))), /* @__PURE__ */ import_react62.default.createElement(UITreeItemRight2, null, /* @__PURE__ */ import_react62.default.createElement(UITreeItemMain2, null, /* @__PURE__ */ import_react62.default.createElement(UIRow4, null, /* @__PURE__ */ import_react62.default.createElement(
|
|
3635
3742
|
BlurInput,
|
|
3636
3743
|
{
|
|
@@ -3639,7 +3746,7 @@ function InputValueRow(props) {
|
|
|
3639
3746
|
size: "small",
|
|
3640
3747
|
value: keyName,
|
|
3641
3748
|
onChange: (v) => onUpdateKey?.(v),
|
|
3642
|
-
placeholder:
|
|
3749
|
+
placeholder: import_editor31.I18n.t("Input Key")
|
|
3643
3750
|
}
|
|
3644
3751
|
), /* @__PURE__ */ import_react62.default.createElement(
|
|
3645
3752
|
InjectDynamicValueInput,
|
|
@@ -3651,10 +3758,7 @@ function InputValueRow(props) {
|
|
|
3651
3758
|
hasError,
|
|
3652
3759
|
constantProps: {
|
|
3653
3760
|
...constantProps,
|
|
3654
|
-
strategies
|
|
3655
|
-
...hasChildren ? [AddObjectChildStrategy] : [],
|
|
3656
|
-
...constantProps?.strategies || []
|
|
3657
|
-
]
|
|
3761
|
+
strategies
|
|
3658
3762
|
}
|
|
3659
3763
|
}
|
|
3660
3764
|
), /* @__PURE__ */ import_react62.default.createElement(UIActions2, null, canAddField && /* @__PURE__ */ import_react62.default.createElement(
|
|
@@ -3665,7 +3769,11 @@ function InputValueRow(props) {
|
|
|
3665
3769
|
theme: "borderless",
|
|
3666
3770
|
icon: /* @__PURE__ */ import_react62.default.createElement(IconAddChildren2, null),
|
|
3667
3771
|
onClick: () => {
|
|
3668
|
-
add(
|
|
3772
|
+
add({
|
|
3773
|
+
type: "constant",
|
|
3774
|
+
content: "",
|
|
3775
|
+
schema: { type: "string" }
|
|
3776
|
+
});
|
|
3669
3777
|
setCollapse(true);
|
|
3670
3778
|
}
|
|
3671
3779
|
}
|
|
@@ -3730,36 +3838,42 @@ function InputsValuesTree(props) {
|
|
|
3730
3838
|
disabled: readonly,
|
|
3731
3839
|
icon: /* @__PURE__ */ import_react63.default.createElement(import_semi_icons14.IconPlus, null),
|
|
3732
3840
|
size: "small",
|
|
3733
|
-
onClick:
|
|
3841
|
+
onClick: () => {
|
|
3842
|
+
add({
|
|
3843
|
+
type: "constant",
|
|
3844
|
+
content: "",
|
|
3845
|
+
schema: { type: "string" }
|
|
3846
|
+
});
|
|
3847
|
+
}
|
|
3734
3848
|
},
|
|
3735
|
-
|
|
3849
|
+
import_editor32.I18n.t("Add")
|
|
3736
3850
|
));
|
|
3737
3851
|
}
|
|
3738
3852
|
|
|
3739
3853
|
// src/effects/provide-batch-input/index.ts
|
|
3740
|
-
var
|
|
3741
|
-
var provideBatchInputEffect = (0,
|
|
3854
|
+
var import_editor33 = require("@flowgram.ai/editor");
|
|
3855
|
+
var provideBatchInputEffect = (0, import_editor33.createEffectFromVariableProvider)({
|
|
3742
3856
|
private: true,
|
|
3743
3857
|
parse: (value, ctx) => [
|
|
3744
|
-
|
|
3858
|
+
import_editor33.ASTFactory.createVariableDeclaration({
|
|
3745
3859
|
key: `${ctx.node.id}_locals`,
|
|
3746
3860
|
meta: {
|
|
3747
|
-
title: (0,
|
|
3861
|
+
title: (0, import_editor33.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3748
3862
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3749
3863
|
},
|
|
3750
|
-
type:
|
|
3864
|
+
type: import_editor33.ASTFactory.createObject({
|
|
3751
3865
|
properties: [
|
|
3752
|
-
|
|
3866
|
+
import_editor33.ASTFactory.createProperty({
|
|
3753
3867
|
key: "item",
|
|
3754
|
-
initializer:
|
|
3755
|
-
enumerateFor:
|
|
3868
|
+
initializer: import_editor33.ASTFactory.createEnumerateExpression({
|
|
3869
|
+
enumerateFor: import_editor33.ASTFactory.createKeyPathExpression({
|
|
3756
3870
|
keyPath: value.content || []
|
|
3757
3871
|
})
|
|
3758
3872
|
})
|
|
3759
3873
|
}),
|
|
3760
|
-
|
|
3874
|
+
import_editor33.ASTFactory.createProperty({
|
|
3761
3875
|
key: "index",
|
|
3762
|
-
type:
|
|
3876
|
+
type: import_editor33.ASTFactory.createNumber()
|
|
3763
3877
|
})
|
|
3764
3878
|
]
|
|
3765
3879
|
})
|
|
@@ -3768,13 +3882,13 @@ var provideBatchInputEffect = (0, import_editor32.createEffectFromVariableProvid
|
|
|
3768
3882
|
});
|
|
3769
3883
|
|
|
3770
3884
|
// src/effects/auto-rename-ref/index.ts
|
|
3771
|
-
var
|
|
3885
|
+
var import_editor34 = require("@flowgram.ai/editor");
|
|
3772
3886
|
var autoRenameRefEffect = [
|
|
3773
3887
|
{
|
|
3774
|
-
event:
|
|
3888
|
+
event: import_editor34.DataEvent.onValueInit,
|
|
3775
3889
|
effect: (params) => {
|
|
3776
3890
|
const { context, form, name } = params;
|
|
3777
|
-
const renameService = context.node.getService(
|
|
3891
|
+
const renameService = context.node.getService(import_editor34.VariableFieldKeyRenameService);
|
|
3778
3892
|
const disposable = renameService.onRename(({ before, after }) => {
|
|
3779
3893
|
const beforeKeyPath = [
|
|
3780
3894
|
...before.parentFields.map((_field) => _field.key).reverse(),
|
|
@@ -3832,13 +3946,13 @@ function traverseRef(name, value, cb) {
|
|
|
3832
3946
|
|
|
3833
3947
|
// src/effects/provide-json-schema-outputs/index.ts
|
|
3834
3948
|
var import_json_schema11 = require("@flowgram.ai/json-schema");
|
|
3835
|
-
var
|
|
3836
|
-
var provideJsonSchemaOutputs = (0,
|
|
3949
|
+
var import_editor35 = require("@flowgram.ai/editor");
|
|
3950
|
+
var provideJsonSchemaOutputs = (0, import_editor35.createEffectFromVariableProvider)({
|
|
3837
3951
|
parse: (value, ctx) => [
|
|
3838
|
-
|
|
3952
|
+
import_editor35.ASTFactory.createVariableDeclaration({
|
|
3839
3953
|
key: `${ctx.node.id}`,
|
|
3840
3954
|
meta: {
|
|
3841
|
-
title: (0,
|
|
3955
|
+
title: (0, import_editor35.getNodeForm)(ctx.node)?.getValueIn("title") || ctx.node.id,
|
|
3842
3956
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3843
3957
|
},
|
|
3844
3958
|
type: import_json_schema11.JsonSchemaUtils.schemaToAST(value)
|
|
@@ -3847,12 +3961,12 @@ var provideJsonSchemaOutputs = (0, import_editor34.createEffectFromVariableProvi
|
|
|
3847
3961
|
});
|
|
3848
3962
|
|
|
3849
3963
|
// src/effects/sync-variable-title/index.ts
|
|
3850
|
-
var
|
|
3964
|
+
var import_editor36 = require("@flowgram.ai/editor");
|
|
3851
3965
|
var syncVariableTitle = [
|
|
3852
3966
|
{
|
|
3853
|
-
event:
|
|
3967
|
+
event: import_editor36.DataEvent.onValueChange,
|
|
3854
3968
|
effect: ({ value, context }) => {
|
|
3855
|
-
context.node.getData(
|
|
3969
|
+
context.node.getData(import_editor36.FlowNodeVariableData).allScopes.forEach((_scope) => {
|
|
3856
3970
|
_scope.output.variables.forEach((_var) => {
|
|
3857
3971
|
_var.updateMeta({
|
|
3858
3972
|
..._var.meta || {},
|
|
@@ -3866,17 +3980,17 @@ var syncVariableTitle = [
|
|
|
3866
3980
|
];
|
|
3867
3981
|
|
|
3868
3982
|
// src/effects/validate-when-variable-sync/index.ts
|
|
3869
|
-
var
|
|
3870
|
-
var
|
|
3983
|
+
var import_lodash10 = require("lodash");
|
|
3984
|
+
var import_editor37 = require("@flowgram.ai/editor");
|
|
3871
3985
|
var validateWhenVariableSync = ({
|
|
3872
3986
|
scope
|
|
3873
3987
|
} = {}) => [
|
|
3874
3988
|
{
|
|
3875
|
-
event:
|
|
3989
|
+
event: import_editor37.DataEvent.onValueInit,
|
|
3876
3990
|
effect: ({ context, form }) => {
|
|
3877
|
-
const nodeScope = scope === "private" ? (0,
|
|
3991
|
+
const nodeScope = scope === "private" ? (0, import_editor37.getNodePrivateScope)(context.node) : (0, import_editor37.getNodeScope)(context.node);
|
|
3878
3992
|
const disposable = nodeScope.available.onListOrAnyVarChange(() => {
|
|
3879
|
-
if (!(0,
|
|
3993
|
+
if (!(0, import_lodash10.isEmpty)(form.state.errors)) {
|
|
3880
3994
|
form.validate();
|
|
3881
3995
|
}
|
|
3882
3996
|
});
|
|
@@ -3886,16 +4000,16 @@ var validateWhenVariableSync = ({
|
|
|
3886
4000
|
];
|
|
3887
4001
|
|
|
3888
4002
|
// src/effects/listen-ref-value-change/index.ts
|
|
3889
|
-
var
|
|
4003
|
+
var import_editor38 = require("@flowgram.ai/editor");
|
|
3890
4004
|
var listenRefValueChange = (cb) => [
|
|
3891
4005
|
{
|
|
3892
|
-
event:
|
|
4006
|
+
event: import_editor38.DataEvent.onValueInitOrChange,
|
|
3893
4007
|
effect: (params) => {
|
|
3894
4008
|
const { context, value } = params;
|
|
3895
4009
|
if (value?.type !== "ref") {
|
|
3896
4010
|
return () => null;
|
|
3897
4011
|
}
|
|
3898
|
-
const disposable = (0,
|
|
4012
|
+
const disposable = (0, import_editor38.getNodeScope)(context.node).available.trackByKeyPath(
|
|
3899
4013
|
value?.content || [],
|
|
3900
4014
|
(v) => {
|
|
3901
4015
|
cb({ ...params, variable: v });
|
|
@@ -3910,16 +4024,16 @@ var listenRefValueChange = (cb) => [
|
|
|
3910
4024
|
|
|
3911
4025
|
// src/effects/listen-ref-schema-change/index.ts
|
|
3912
4026
|
var import_json_schema12 = require("@flowgram.ai/json-schema");
|
|
3913
|
-
var
|
|
4027
|
+
var import_editor39 = require("@flowgram.ai/editor");
|
|
3914
4028
|
var listenRefSchemaChange = (cb) => [
|
|
3915
4029
|
{
|
|
3916
|
-
event:
|
|
4030
|
+
event: import_editor39.DataEvent.onValueInitOrChange,
|
|
3917
4031
|
effect: (params) => {
|
|
3918
4032
|
const { context, value } = params;
|
|
3919
4033
|
if (value?.type !== "ref") {
|
|
3920
4034
|
return () => null;
|
|
3921
4035
|
}
|
|
3922
|
-
const disposable = (0,
|
|
4036
|
+
const disposable = (0, import_editor39.getNodeScope)(context.node).available.trackByKeyPath(
|
|
3923
4037
|
value?.content || [],
|
|
3924
4038
|
(_type) => {
|
|
3925
4039
|
cb({ ...params, schema: import_json_schema12.JsonSchemaUtils.astToSchema(_type) });
|
|
@@ -3936,21 +4050,21 @@ var listenRefSchemaChange = (cb) => [
|
|
|
3936
4050
|
];
|
|
3937
4051
|
|
|
3938
4052
|
// src/form-plugins/batch-outputs-plugin/index.ts
|
|
3939
|
-
var
|
|
3940
|
-
var provideBatchOutputsEffect = (0,
|
|
4053
|
+
var import_editor40 = require("@flowgram.ai/editor");
|
|
4054
|
+
var provideBatchOutputsEffect = (0, import_editor40.createEffectFromVariableProvider)({
|
|
3941
4055
|
parse: (value, ctx) => [
|
|
3942
|
-
|
|
4056
|
+
import_editor40.ASTFactory.createVariableDeclaration({
|
|
3943
4057
|
key: `${ctx.node.id}`,
|
|
3944
4058
|
meta: {
|
|
3945
|
-
title: (0,
|
|
4059
|
+
title: (0, import_editor40.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3946
4060
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3947
4061
|
},
|
|
3948
|
-
type:
|
|
4062
|
+
type: import_editor40.ASTFactory.createObject({
|
|
3949
4063
|
properties: Object.entries(value).map(
|
|
3950
|
-
([_key, value2]) =>
|
|
4064
|
+
([_key, value2]) => import_editor40.ASTFactory.createProperty({
|
|
3951
4065
|
key: _key,
|
|
3952
|
-
initializer:
|
|
3953
|
-
wrapFor:
|
|
4066
|
+
initializer: import_editor40.ASTFactory.createWrapArrayExpression({
|
|
4067
|
+
wrapFor: import_editor40.ASTFactory.createKeyPathExpression({
|
|
3954
4068
|
keyPath: value2?.content || []
|
|
3955
4069
|
})
|
|
3956
4070
|
})
|
|
@@ -3960,7 +4074,7 @@ var provideBatchOutputsEffect = (0, import_editor39.createEffectFromVariableProv
|
|
|
3960
4074
|
})
|
|
3961
4075
|
]
|
|
3962
4076
|
});
|
|
3963
|
-
var createBatchOutputsFormPlugin = (0,
|
|
4077
|
+
var createBatchOutputsFormPlugin = (0, import_editor40.defineFormPluginCreator)({
|
|
3964
4078
|
name: "batch-outputs-plugin",
|
|
3965
4079
|
onSetupFormMeta({ mergeEffect }, { outputKey }) {
|
|
3966
4080
|
mergeEffect({
|
|
@@ -3968,7 +4082,7 @@ var createBatchOutputsFormPlugin = (0, import_editor39.defineFormPluginCreator)(
|
|
|
3968
4082
|
});
|
|
3969
4083
|
},
|
|
3970
4084
|
onInit(ctx, { outputKey }) {
|
|
3971
|
-
const chainTransformService = ctx.node.getService(
|
|
4085
|
+
const chainTransformService = ctx.node.getService(import_editor40.ScopeChainTransformService);
|
|
3972
4086
|
const batchNodeType = ctx.node.flowNodeType;
|
|
3973
4087
|
const transformerId = `${batchNodeType}-outputs`;
|
|
3974
4088
|
if (chainTransformService.hasTransformer(transformerId)) {
|
|
@@ -3978,21 +4092,21 @@ var createBatchOutputsFormPlugin = (0, import_editor39.defineFormPluginCreator)(
|
|
|
3978
4092
|
transformCovers: (covers, ctx2) => {
|
|
3979
4093
|
const node = ctx2.scope.meta?.node;
|
|
3980
4094
|
if (node?.parent?.flowNodeType === batchNodeType) {
|
|
3981
|
-
return [...covers, (0,
|
|
4095
|
+
return [...covers, (0, import_editor40.getNodeScope)(node.parent)];
|
|
3982
4096
|
}
|
|
3983
4097
|
return covers;
|
|
3984
4098
|
},
|
|
3985
4099
|
transformDeps(scopes, ctx2) {
|
|
3986
4100
|
const scopeMeta = ctx2.scope.meta;
|
|
3987
|
-
if (scopeMeta?.type ===
|
|
4101
|
+
if (scopeMeta?.type === import_editor40.FlowNodeScopeType.private) {
|
|
3988
4102
|
return scopes;
|
|
3989
4103
|
}
|
|
3990
4104
|
const node = scopeMeta?.node;
|
|
3991
4105
|
if (node?.flowNodeType === batchNodeType) {
|
|
3992
4106
|
const childBlocks = node.blocks;
|
|
3993
4107
|
return [
|
|
3994
|
-
(0,
|
|
3995
|
-
...childBlocks.map((_childBlock) => (0,
|
|
4108
|
+
(0, import_editor40.getNodePrivateScope)(node),
|
|
4109
|
+
...childBlocks.map((_childBlock) => (0, import_editor40.getNodeScope)(_childBlock))
|
|
3996
4110
|
];
|
|
3997
4111
|
}
|
|
3998
4112
|
return scopes;
|
|
@@ -4002,20 +4116,20 @@ var createBatchOutputsFormPlugin = (0, import_editor39.defineFormPluginCreator)(
|
|
|
4002
4116
|
});
|
|
4003
4117
|
|
|
4004
4118
|
// src/form-plugins/infer-inputs-plugin/index.ts
|
|
4005
|
-
var
|
|
4006
|
-
var
|
|
4007
|
-
var createInferInputsPlugin = (0,
|
|
4119
|
+
var import_lodash11 = require("lodash");
|
|
4120
|
+
var import_editor41 = require("@flowgram.ai/editor");
|
|
4121
|
+
var createInferInputsPlugin = (0, import_editor41.defineFormPluginCreator)({
|
|
4008
4122
|
onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
|
|
4009
4123
|
if (!sourceKey || !targetKey) {
|
|
4010
4124
|
return;
|
|
4011
4125
|
}
|
|
4012
4126
|
addFormatOnSubmit((formData, ctx) => {
|
|
4013
|
-
(0,
|
|
4127
|
+
(0, import_lodash11.set)(
|
|
4014
4128
|
formData,
|
|
4015
4129
|
targetKey,
|
|
4016
4130
|
FlowValueUtils.inferJsonSchema(
|
|
4017
|
-
(0,
|
|
4018
|
-
scope === "private" ? (0,
|
|
4131
|
+
(0, import_lodash11.get)(formData, sourceKey),
|
|
4132
|
+
scope === "private" ? (0, import_editor41.getNodePrivateScope)(ctx.node) : (0, import_editor41.getNodeScope)(ctx.node)
|
|
4019
4133
|
)
|
|
4020
4134
|
);
|
|
4021
4135
|
return formData;
|
|
@@ -4024,34 +4138,34 @@ var createInferInputsPlugin = (0, import_editor40.defineFormPluginCreator)({
|
|
|
4024
4138
|
});
|
|
4025
4139
|
|
|
4026
4140
|
// src/form-plugins/infer-assign-plugin/index.ts
|
|
4027
|
-
var
|
|
4141
|
+
var import_lodash12 = require("lodash");
|
|
4028
4142
|
var import_json_schema13 = require("@flowgram.ai/json-schema");
|
|
4029
|
-
var
|
|
4030
|
-
var createInferAssignPlugin = (0,
|
|
4143
|
+
var import_editor42 = require("@flowgram.ai/editor");
|
|
4144
|
+
var createInferAssignPlugin = (0, import_editor42.defineFormPluginCreator)({
|
|
4031
4145
|
onSetupFormMeta({ addFormatOnSubmit, mergeEffect }, { assignKey, outputKey }) {
|
|
4032
4146
|
if (!assignKey || !outputKey) {
|
|
4033
4147
|
return;
|
|
4034
4148
|
}
|
|
4035
4149
|
mergeEffect({
|
|
4036
|
-
[assignKey]: (0,
|
|
4150
|
+
[assignKey]: (0, import_editor42.createEffectFromVariableProvider)({
|
|
4037
4151
|
parse: (value, ctx) => {
|
|
4038
|
-
const declareRows = (0,
|
|
4152
|
+
const declareRows = (0, import_lodash12.uniqBy)(
|
|
4039
4153
|
value.filter((_v) => _v.operator === "declare" && _v.left && _v.right),
|
|
4040
4154
|
"left"
|
|
4041
4155
|
);
|
|
4042
4156
|
return [
|
|
4043
|
-
|
|
4157
|
+
import_editor42.ASTFactory.createVariableDeclaration({
|
|
4044
4158
|
key: `${ctx.node.id}`,
|
|
4045
4159
|
meta: {
|
|
4046
|
-
title: (0,
|
|
4160
|
+
title: (0, import_editor42.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
4047
4161
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
4048
4162
|
},
|
|
4049
|
-
type:
|
|
4163
|
+
type: import_editor42.ASTFactory.createObject({
|
|
4050
4164
|
properties: declareRows.map(
|
|
4051
|
-
(_v) =>
|
|
4165
|
+
(_v) => import_editor42.ASTFactory.createProperty({
|
|
4052
4166
|
key: _v.left,
|
|
4053
4167
|
type: _v.right?.type === "constant" ? import_json_schema13.JsonSchemaUtils.schemaToAST(_v.right?.schema || {}) : void 0,
|
|
4054
|
-
initializer: _v.right?.type === "ref" ?
|
|
4168
|
+
initializer: _v.right?.type === "ref" ? import_editor42.ASTFactory.createKeyPathExpression({
|
|
4055
4169
|
keyPath: _v.right?.content || []
|
|
4056
4170
|
}) : {}
|
|
4057
4171
|
})
|
|
@@ -4063,10 +4177,10 @@ var createInferAssignPlugin = (0, import_editor41.defineFormPluginCreator)({
|
|
|
4063
4177
|
})
|
|
4064
4178
|
});
|
|
4065
4179
|
addFormatOnSubmit((formData, ctx) => {
|
|
4066
|
-
(0,
|
|
4180
|
+
(0, import_lodash12.set)(
|
|
4067
4181
|
formData,
|
|
4068
4182
|
outputKey,
|
|
4069
|
-
import_json_schema13.JsonSchemaUtils.astToSchema((0,
|
|
4183
|
+
import_json_schema13.JsonSchemaUtils.astToSchema((0, import_editor42.getNodeScope)(ctx.node).output.variables?.[0]?.type)
|
|
4070
4184
|
);
|
|
4071
4185
|
return formData;
|
|
4072
4186
|
});
|
|
@@ -4074,36 +4188,36 @@ var createInferAssignPlugin = (0, import_editor41.defineFormPluginCreator)({
|
|
|
4074
4188
|
});
|
|
4075
4189
|
|
|
4076
4190
|
// src/validate/validate-flow-value/index.tsx
|
|
4077
|
-
var
|
|
4078
|
-
var
|
|
4191
|
+
var import_lodash13 = require("lodash");
|
|
4192
|
+
var import_editor43 = require("@flowgram.ai/editor");
|
|
4079
4193
|
function validateFlowValue(value, ctx) {
|
|
4080
4194
|
const { node, required, errorMessages } = ctx;
|
|
4081
4195
|
const {
|
|
4082
4196
|
required: requiredMessage = "Field is required",
|
|
4083
4197
|
unknownVariable: unknownVariableMessage = "Unknown Variable"
|
|
4084
4198
|
} = errorMessages || {};
|
|
4085
|
-
if (required && ((0,
|
|
4199
|
+
if (required && ((0, import_lodash13.isNil)(value) || (0, import_lodash13.isNil)(value?.content) || value?.content === "")) {
|
|
4086
4200
|
return {
|
|
4087
|
-
level:
|
|
4201
|
+
level: import_editor43.FeedbackLevel.Error,
|
|
4088
4202
|
message: requiredMessage
|
|
4089
4203
|
};
|
|
4090
4204
|
}
|
|
4091
4205
|
if (value?.type === "ref") {
|
|
4092
|
-
const variable = (0,
|
|
4206
|
+
const variable = (0, import_editor43.getNodeScope)(node).available.getByKeyPath(value?.content || []);
|
|
4093
4207
|
if (!variable) {
|
|
4094
4208
|
return {
|
|
4095
|
-
level:
|
|
4209
|
+
level: import_editor43.FeedbackLevel.Error,
|
|
4096
4210
|
message: unknownVariableMessage
|
|
4097
4211
|
};
|
|
4098
4212
|
}
|
|
4099
4213
|
}
|
|
4100
4214
|
if (value?.type === "template") {
|
|
4101
|
-
const allRefs = getTemplateKeyPaths(value);
|
|
4215
|
+
const allRefs = FlowValueUtils.getTemplateKeyPaths(value);
|
|
4102
4216
|
for (const ref of allRefs) {
|
|
4103
|
-
const variable = (0,
|
|
4217
|
+
const variable = (0, import_editor43.getNodeScope)(node).available.getByKeyPath(ref);
|
|
4104
4218
|
if (!variable) {
|
|
4105
4219
|
return {
|
|
4106
|
-
level:
|
|
4220
|
+
level: import_editor43.FeedbackLevel.Error,
|
|
4107
4221
|
message: unknownVariableMessage
|
|
4108
4222
|
};
|
|
4109
4223
|
}
|
|
@@ -4111,12 +4225,6 @@ function validateFlowValue(value, ctx) {
|
|
|
4111
4225
|
}
|
|
4112
4226
|
return void 0;
|
|
4113
4227
|
}
|
|
4114
|
-
function getTemplateKeyPaths(value) {
|
|
4115
|
-
const keyPathReg = /{{(.*?)}}/g;
|
|
4116
|
-
return (0, import_lodash12.uniq)(value.content?.match(keyPathReg) || []).map(
|
|
4117
|
-
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
4118
|
-
);
|
|
4119
|
-
}
|
|
4120
4228
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4121
4229
|
0 && (module.exports = {
|
|
4122
4230
|
AssignRow,
|
|
@@ -4129,6 +4237,7 @@ function getTemplateKeyPaths(value) {
|
|
|
4129
4237
|
ConditionRow,
|
|
4130
4238
|
ConstantInput,
|
|
4131
4239
|
DisplayFlowValue,
|
|
4240
|
+
DisplayInputsValueAllInTag,
|
|
4132
4241
|
DisplayInputsValues,
|
|
4133
4242
|
DisplayOutputs,
|
|
4134
4243
|
DisplaySchemaTag,
|
|
@@ -4170,6 +4279,7 @@ function getTemplateKeyPaths(value) {
|
|
|
4170
4279
|
provideBatchOutputsEffect,
|
|
4171
4280
|
provideJsonSchemaOutputs,
|
|
4172
4281
|
syncVariableTitle,
|
|
4282
|
+
useObjectList,
|
|
4173
4283
|
useTypeManager,
|
|
4174
4284
|
useVariableTree,
|
|
4175
4285
|
validateFlowValue,
|