@flowgram.ai/form-materials 0.3.2 → 0.3.4
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 +133 -44
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +59 -20
- package/dist/index.d.ts +59 -20
- package/dist/index.js +216 -131
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/condition-row/constants.ts +2 -2
- package/src/components/condition-row/hooks/useOp.tsx +13 -9
- package/src/components/condition-row/hooks/useRule.ts +6 -3
- package/src/components/condition-row/index.tsx +22 -6
- package/src/components/condition-row/types.ts +4 -6
- package/src/components/json-schema-editor/index.tsx +7 -4
- package/src/components/type-selector/index.tsx +2 -4
- package/src/components/variable-selector/index.tsx +2 -1
- package/src/effects/index.ts +2 -0
- package/src/effects/listen-ref-schema-change/config.json +10 -0
- package/src/effects/listen-ref-schema-change/index.ts +56 -0
- package/src/effects/listen-ref-value-change/config.json +9 -0
- package/src/effects/listen-ref-value-change/index.ts +53 -0
- package/src/plugins/json-schema-preset/index.tsx +2 -0
- package/src/plugins/json-schema-preset/type-definition/array.tsx +3 -1
- package/src/plugins/json-schema-preset/type-definition/boolean.tsx +4 -3
- package/src/plugins/json-schema-preset/type-definition/integer.tsx +2 -1
- package/src/plugins/json-schema-preset/type-definition/number.tsx +2 -1
- package/src/plugins/json-schema-preset/type-definition/object.tsx +3 -1
- package/src/plugins/json-schema-preset/type-definition/string.tsx +7 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/components/variable-selector/index.tsx
|
|
2
2
|
import React11, { useMemo } from "react";
|
|
3
|
+
import { I18n as I18n7 } from "@flowgram.ai/editor";
|
|
3
4
|
import { Popover } from "@douyinfe/semi-ui";
|
|
4
5
|
import { IconChevronDownStroked, IconIssueStroked } from "@douyinfe/semi-icons";
|
|
5
6
|
|
|
@@ -22,14 +23,24 @@ import { jsonSchemaTypeManager } from "@flowgram.ai/json-schema";
|
|
|
22
23
|
|
|
23
24
|
// src/plugins/json-schema-preset/type-definition/string.tsx
|
|
24
25
|
import React from "react";
|
|
26
|
+
import { I18n } from "@flowgram.ai/editor";
|
|
25
27
|
import { Input } from "@douyinfe/semi-ui";
|
|
26
28
|
var stringRegistry = {
|
|
27
29
|
type: "string",
|
|
28
|
-
ConstantRenderer: (props) => /* @__PURE__ */ React.createElement(
|
|
30
|
+
ConstantRenderer: (props) => /* @__PURE__ */ React.createElement(
|
|
31
|
+
Input,
|
|
32
|
+
{
|
|
33
|
+
placeholder: I18n.t("Please Input String"),
|
|
34
|
+
size: "small",
|
|
35
|
+
disabled: props.readonly,
|
|
36
|
+
...props
|
|
37
|
+
}
|
|
38
|
+
)
|
|
29
39
|
};
|
|
30
40
|
|
|
31
41
|
// src/plugins/json-schema-preset/type-definition/object.tsx
|
|
32
42
|
import React4 from "react";
|
|
43
|
+
import { I18n as I18n2 } from "@flowgram.ai/editor";
|
|
33
44
|
|
|
34
45
|
// src/components/code-editor-mini/index.tsx
|
|
35
46
|
import React3 from "react";
|
|
@@ -409,7 +420,7 @@ var objectRegistry = {
|
|
|
409
420
|
value: props.value,
|
|
410
421
|
onChange: (v) => props.onChange?.(v),
|
|
411
422
|
languageId: "json",
|
|
412
|
-
placeholder: "Please Input Object",
|
|
423
|
+
placeholder: I18n2.t("Please Input Object"),
|
|
413
424
|
readonly: props.readonly
|
|
414
425
|
}
|
|
415
426
|
)
|
|
@@ -417,13 +428,14 @@ var objectRegistry = {
|
|
|
417
428
|
|
|
418
429
|
// src/plugins/json-schema-preset/type-definition/number.tsx
|
|
419
430
|
import React5 from "react";
|
|
431
|
+
import { I18n as I18n3 } from "@flowgram.ai/editor";
|
|
420
432
|
import { InputNumber } from "@douyinfe/semi-ui";
|
|
421
433
|
var numberRegistry = {
|
|
422
434
|
type: "number",
|
|
423
435
|
ConstantRenderer: (props) => /* @__PURE__ */ React5.createElement(
|
|
424
436
|
InputNumber,
|
|
425
437
|
{
|
|
426
|
-
placeholder: "Please Input Number",
|
|
438
|
+
placeholder: I18n3.t("Please Input Number"),
|
|
427
439
|
size: "small",
|
|
428
440
|
disabled: props.readonly,
|
|
429
441
|
hideButtons: true,
|
|
@@ -434,13 +446,14 @@ var numberRegistry = {
|
|
|
434
446
|
|
|
435
447
|
// src/plugins/json-schema-preset/type-definition/integer.tsx
|
|
436
448
|
import React6 from "react";
|
|
449
|
+
import { I18n as I18n4 } from "@flowgram.ai/editor";
|
|
437
450
|
import { InputNumber as InputNumber2 } from "@douyinfe/semi-ui";
|
|
438
451
|
var integerRegistry = {
|
|
439
452
|
type: "integer",
|
|
440
453
|
ConstantRenderer: (props) => /* @__PURE__ */ React6.createElement(
|
|
441
454
|
InputNumber2,
|
|
442
455
|
{
|
|
443
|
-
placeholder: "Please Input Integer",
|
|
456
|
+
placeholder: I18n4.t("Please Input Integer"),
|
|
444
457
|
size: "small",
|
|
445
458
|
disabled: props.readonly,
|
|
446
459
|
precision: 0,
|
|
@@ -451,6 +464,7 @@ var integerRegistry = {
|
|
|
451
464
|
|
|
452
465
|
// src/plugins/json-schema-preset/type-definition/boolean.tsx
|
|
453
466
|
import React7 from "react";
|
|
467
|
+
import { I18n as I18n5 } from "@flowgram.ai/editor";
|
|
454
468
|
import { Select } from "@douyinfe/semi-ui";
|
|
455
469
|
var booleanRegistry = {
|
|
456
470
|
type: "boolean",
|
|
@@ -459,12 +473,12 @@ var booleanRegistry = {
|
|
|
459
473
|
return /* @__PURE__ */ React7.createElement(
|
|
460
474
|
Select,
|
|
461
475
|
{
|
|
462
|
-
placeholder: "Please Select Boolean",
|
|
476
|
+
placeholder: I18n5.t("Please Select Boolean"),
|
|
463
477
|
size: "small",
|
|
464
478
|
disabled: props.readonly,
|
|
465
479
|
optionList: [
|
|
466
|
-
{ label: "True", value: 1 },
|
|
467
|
-
{ label: "False", value: 0 }
|
|
480
|
+
{ label: I18n5.t("True"), value: 1 },
|
|
481
|
+
{ label: I18n5.t("False"), value: 0 }
|
|
468
482
|
],
|
|
469
483
|
value: value ? 1 : 0,
|
|
470
484
|
onChange: (value2) => onChange?.(!!value2),
|
|
@@ -476,6 +490,7 @@ var booleanRegistry = {
|
|
|
476
490
|
|
|
477
491
|
// src/plugins/json-schema-preset/type-definition/array.tsx
|
|
478
492
|
import React8 from "react";
|
|
493
|
+
import { I18n as I18n6 } from "@flowgram.ai/editor";
|
|
479
494
|
var arrayRegistry = {
|
|
480
495
|
type: "array",
|
|
481
496
|
ConstantRenderer: (props) => /* @__PURE__ */ React8.createElement(
|
|
@@ -484,7 +499,7 @@ var arrayRegistry = {
|
|
|
484
499
|
value: props.value,
|
|
485
500
|
languageId: "json",
|
|
486
501
|
onChange: (v) => props.onChange?.(v),
|
|
487
|
-
placeholder: "Please Input Array",
|
|
502
|
+
placeholder: I18n6.t("Please Input Array"),
|
|
488
503
|
readonly: props.readonly
|
|
489
504
|
}
|
|
490
505
|
)
|
|
@@ -735,7 +750,7 @@ var VariableSelector = ({
|
|
|
735
750
|
showClear: false,
|
|
736
751
|
arrowIcon: /* @__PURE__ */ React11.createElement(IconChevronDownStroked, { size: "small" }),
|
|
737
752
|
triggerRender,
|
|
738
|
-
placeholder: config?.placeholder ?? "Select Variable"
|
|
753
|
+
placeholder: config?.placeholder ?? I18n7.t("Select Variable")
|
|
739
754
|
}
|
|
740
755
|
));
|
|
741
756
|
};
|
|
@@ -744,7 +759,6 @@ var VariableSelector = ({
|
|
|
744
759
|
import React12, { useMemo as useMemo2 } from "react";
|
|
745
760
|
import { Cascader, Icon as Icon2, IconButton } from "@douyinfe/semi-ui";
|
|
746
761
|
var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
|
|
747
|
-
var firstUppercase = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
748
762
|
var getTypeSelectValue = (value) => {
|
|
749
763
|
if (value?.type === "array" && value?.items) {
|
|
750
764
|
return [value.type, ...getTypeSelectValue(value.items) || []];
|
|
@@ -767,7 +781,7 @@ function TypeSelector(props) {
|
|
|
767
781
|
() => typeManager.getTypeRegistriesWithParentType().map((_type) => {
|
|
768
782
|
const isArray2 = _type.type === "array";
|
|
769
783
|
return {
|
|
770
|
-
label: /* @__PURE__ */ React12.createElement("div", { style: labelStyle }, /* @__PURE__ */ React12.createElement(Icon2, { size: "small", svg: _type.icon }),
|
|
784
|
+
label: /* @__PURE__ */ React12.createElement("div", { style: labelStyle }, /* @__PURE__ */ React12.createElement(Icon2, { size: "small", svg: _type.icon }), typeManager.getTypeBySchema(_type)?.label || _type.type),
|
|
771
785
|
value: _type.type,
|
|
772
786
|
children: isArray2 ? typeManager.getTypeRegistriesWithParentType("array").map((_type2) => ({
|
|
773
787
|
label: /* @__PURE__ */ React12.createElement("div", { style: labelStyle }, /* @__PURE__ */ React12.createElement(
|
|
@@ -779,7 +793,7 @@ function TypeSelector(props) {
|
|
|
779
793
|
items: { type: _type2.type }
|
|
780
794
|
})
|
|
781
795
|
}
|
|
782
|
-
),
|
|
796
|
+
), typeManager.getTypeBySchema(_type2)?.label || _type2.type),
|
|
783
797
|
value: _type2.type
|
|
784
798
|
})) : []
|
|
785
799
|
};
|
|
@@ -804,6 +818,7 @@ function TypeSelector(props) {
|
|
|
804
818
|
|
|
805
819
|
// src/components/json-schema-editor/index.tsx
|
|
806
820
|
import React17, { useMemo as useMemo5, useState as useState4 } from "react";
|
|
821
|
+
import { I18n as I18n8 } from "@flowgram.ai/editor";
|
|
807
822
|
import { Button, Checkbox, IconButton as IconButton3 } from "@douyinfe/semi-ui";
|
|
808
823
|
import {
|
|
809
824
|
IconExpand,
|
|
@@ -1418,22 +1433,22 @@ function PropertyEdit(props) {
|
|
|
1418
1433
|
onClick: onRemove
|
|
1419
1434
|
}
|
|
1420
1435
|
))),
|
|
1421
|
-
expand && /* @__PURE__ */ React17.createElement(UIExpandDetail, null, /* @__PURE__ */ React17.createElement(UILabel, null, config?.descTitle ?? "Description"), /* @__PURE__ */ React17.createElement(
|
|
1436
|
+
expand && /* @__PURE__ */ React17.createElement(UIExpandDetail, null, /* @__PURE__ */ React17.createElement(UILabel, null, config?.descTitle ?? I18n8.t("Description")), /* @__PURE__ */ React17.createElement(
|
|
1422
1437
|
BlurInput,
|
|
1423
1438
|
{
|
|
1424
1439
|
disabled: readonly,
|
|
1425
1440
|
size: "small",
|
|
1426
1441
|
value: description,
|
|
1427
1442
|
onChange: (value2) => onChange("description", value2),
|
|
1428
|
-
placeholder: config?.descPlaceholder ?? "Help LLM to understand the property"
|
|
1443
|
+
placeholder: config?.descPlaceholder ?? I18n8.t("Help LLM to understand the property")
|
|
1429
1444
|
}
|
|
1430
|
-
), $level === 0 && type && type !== "array" && /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? "Default Value"), /* @__PURE__ */ React17.createElement(DefaultValueWrapper, null, /* @__PURE__ */ React17.createElement(
|
|
1445
|
+
), $level === 0 && type && type !== "array" && /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? I18n8.t("Default Value")), /* @__PURE__ */ React17.createElement(DefaultValueWrapper, null, /* @__PURE__ */ React17.createElement(
|
|
1431
1446
|
DefaultValue,
|
|
1432
1447
|
{
|
|
1433
1448
|
value: defaultValue,
|
|
1434
1449
|
schema: value,
|
|
1435
1450
|
type,
|
|
1436
|
-
placeholder: config?.defaultValuePlaceholder,
|
|
1451
|
+
placeholder: config?.defaultValuePlaceholder ?? I18n8.t("Default Value"),
|
|
1437
1452
|
jsonFormatText: config?.jsonFormatText,
|
|
1438
1453
|
onChange: (value2) => onChange("default", value2)
|
|
1439
1454
|
}
|
|
@@ -1654,6 +1669,7 @@ function DynamicValueInput({
|
|
|
1654
1669
|
|
|
1655
1670
|
// src/components/condition-row/index.tsx
|
|
1656
1671
|
import React21, { useMemo as useMemo9 } from "react";
|
|
1672
|
+
import { I18n as I18n10 } from "@flowgram.ai/editor";
|
|
1657
1673
|
import { Input as Input4 } from "@douyinfe/semi-ui";
|
|
1658
1674
|
|
|
1659
1675
|
// src/components/condition-row/styles.tsx
|
|
@@ -1684,7 +1700,7 @@ import { JsonSchemaUtils as JsonSchemaUtils4 } from "@flowgram.ai/json-schema";
|
|
|
1684
1700
|
import { useScopeAvailable as useScopeAvailable2 } from "@flowgram.ai/editor";
|
|
1685
1701
|
|
|
1686
1702
|
// src/components/condition-row/constants.ts
|
|
1687
|
-
var
|
|
1703
|
+
var defaultRules = {
|
|
1688
1704
|
string: {
|
|
1689
1705
|
["eq" /* EQ */]: "string",
|
|
1690
1706
|
["neq" /* NEQ */]: "string",
|
|
@@ -1740,7 +1756,7 @@ var rules = {
|
|
|
1740
1756
|
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1741
1757
|
}
|
|
1742
1758
|
};
|
|
1743
|
-
var
|
|
1759
|
+
var defaultOpConfigs = {
|
|
1744
1760
|
["eq" /* EQ */]: {
|
|
1745
1761
|
label: "Equal",
|
|
1746
1762
|
abbreviation: "="
|
|
@@ -1804,8 +1820,9 @@ var opConfigs = {
|
|
|
1804
1820
|
};
|
|
1805
1821
|
|
|
1806
1822
|
// src/components/condition-row/hooks/useRule.ts
|
|
1807
|
-
function useRule(left) {
|
|
1823
|
+
function useRule(left, userRules) {
|
|
1808
1824
|
const available = useScopeAvailable2();
|
|
1825
|
+
const rules = useMemo7(() => ({ ...defaultRules, ...userRules || {} }), [userRules]);
|
|
1809
1826
|
const variable = useMemo7(() => {
|
|
1810
1827
|
if (!left) return void 0;
|
|
1811
1828
|
return available.getByKeyPath(left.content);
|
|
@@ -1814,23 +1831,26 @@ function useRule(left) {
|
|
|
1814
1831
|
if (!variable) return void 0;
|
|
1815
1832
|
const schema = JsonSchemaUtils4.astToSchema(variable.type, { drilldown: false });
|
|
1816
1833
|
return rules[schema?.type];
|
|
1817
|
-
}, [variable?.type]);
|
|
1834
|
+
}, [variable?.type, rules]);
|
|
1818
1835
|
return { rule };
|
|
1819
1836
|
}
|
|
1820
1837
|
|
|
1821
1838
|
// src/components/condition-row/hooks/useOp.tsx
|
|
1822
1839
|
import React20, { useMemo as useMemo8 } from "react";
|
|
1840
|
+
import { I18n as I18n9 } from "@flowgram.ai/editor";
|
|
1823
1841
|
import { Button as Button2, Select as Select2 } from "@douyinfe/semi-ui";
|
|
1824
1842
|
import { IconChevronDownStroked as IconChevronDownStroked2 } from "@douyinfe/semi-icons";
|
|
1825
|
-
function useOp({ rule, op, onChange, readonly }) {
|
|
1843
|
+
function useOp({ rule, op, onChange, readonly, userOps }) {
|
|
1826
1844
|
const options = useMemo8(
|
|
1827
1845
|
() => Object.keys(rule || {}).map((_op) => ({
|
|
1828
|
-
...
|
|
1829
|
-
|
|
1846
|
+
...defaultOpConfigs[_op] || {},
|
|
1847
|
+
...userOps?.[_op] || {},
|
|
1848
|
+
value: _op,
|
|
1849
|
+
label: I18n9.t(userOps?.[_op]?.label || defaultOpConfigs[_op]?.label)
|
|
1830
1850
|
})),
|
|
1831
|
-
[rule]
|
|
1851
|
+
[rule, userOps]
|
|
1832
1852
|
);
|
|
1833
|
-
const opConfig = useMemo8(() =>
|
|
1853
|
+
const opConfig = useMemo8(() => defaultOpConfigs[op], [op]);
|
|
1834
1854
|
const renderOpSelect = () => /* @__PURE__ */ React20.createElement(
|
|
1835
1855
|
Select2,
|
|
1836
1856
|
{
|
|
@@ -1849,17 +1869,28 @@ function useOp({ rule, op, onChange, readonly }) {
|
|
|
1849
1869
|
}
|
|
1850
1870
|
|
|
1851
1871
|
// src/components/condition-row/index.tsx
|
|
1852
|
-
|
|
1872
|
+
var defaultRuleConfig = {
|
|
1873
|
+
ops: {},
|
|
1874
|
+
rules: {}
|
|
1875
|
+
};
|
|
1876
|
+
function ConditionRow({
|
|
1877
|
+
style,
|
|
1878
|
+
value,
|
|
1879
|
+
onChange,
|
|
1880
|
+
readonly,
|
|
1881
|
+
ruleConfig = defaultRuleConfig
|
|
1882
|
+
}) {
|
|
1853
1883
|
const { left, operator, right } = value || {};
|
|
1854
|
-
const { rule } = useRule(left);
|
|
1884
|
+
const { rule } = useRule(left, ruleConfig.rules);
|
|
1855
1885
|
const { renderOpSelect, opConfig } = useOp({
|
|
1856
1886
|
rule,
|
|
1857
1887
|
op: operator,
|
|
1858
1888
|
onChange: (v) => onChange({ ...value, operator: v }),
|
|
1859
|
-
readonly
|
|
1889
|
+
readonly,
|
|
1890
|
+
userOps: ruleConfig.ops
|
|
1860
1891
|
});
|
|
1861
1892
|
const targetSchema = useMemo9(() => {
|
|
1862
|
-
const targetType = rule?.[operator] || null;
|
|
1893
|
+
const targetType = rule?.[operator || ""] || null;
|
|
1863
1894
|
return targetType ? { type: targetType, extra: { weak: true } } : null;
|
|
1864
1895
|
}, [rule, opConfig]);
|
|
1865
1896
|
return /* @__PURE__ */ React21.createElement(UIContainer3, { style }, /* @__PURE__ */ React21.createElement(UIOperator, null, renderOpSelect()), /* @__PURE__ */ React21.createElement(UIValues, null, /* @__PURE__ */ React21.createElement(UILeft, null, /* @__PURE__ */ React21.createElement(
|
|
@@ -1890,7 +1921,7 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1890
1921
|
size: "small",
|
|
1891
1922
|
disabled: true,
|
|
1892
1923
|
style: { pointerEvents: "none" },
|
|
1893
|
-
value: opConfig?.rightDisplay || "Empty"
|
|
1924
|
+
value: opConfig?.rightDisplay || I18n10.t("Empty")
|
|
1894
1925
|
}
|
|
1895
1926
|
))));
|
|
1896
1927
|
}
|
|
@@ -3512,6 +3543,62 @@ var validateWhenVariableSync = ({
|
|
|
3512
3543
|
}
|
|
3513
3544
|
];
|
|
3514
3545
|
|
|
3546
|
+
// src/effects/listen-ref-value-change/index.ts
|
|
3547
|
+
import {
|
|
3548
|
+
DataEvent as DataEvent4,
|
|
3549
|
+
getNodeScope as getNodeScope2
|
|
3550
|
+
} from "@flowgram.ai/editor";
|
|
3551
|
+
var listenRefValueChange = (cb) => [
|
|
3552
|
+
{
|
|
3553
|
+
event: DataEvent4.onValueInitOrChange,
|
|
3554
|
+
effect: (params) => {
|
|
3555
|
+
const { context, value } = params;
|
|
3556
|
+
if (value?.type !== "ref") {
|
|
3557
|
+
return () => null;
|
|
3558
|
+
}
|
|
3559
|
+
const disposable = getNodeScope2(context.node).available.trackByKeyPath(
|
|
3560
|
+
value?.content || [],
|
|
3561
|
+
(v) => {
|
|
3562
|
+
cb({ ...params, variable: v });
|
|
3563
|
+
}
|
|
3564
|
+
);
|
|
3565
|
+
return () => {
|
|
3566
|
+
disposable.dispose();
|
|
3567
|
+
};
|
|
3568
|
+
}
|
|
3569
|
+
}
|
|
3570
|
+
];
|
|
3571
|
+
|
|
3572
|
+
// src/effects/listen-ref-schema-change/index.ts
|
|
3573
|
+
import { JsonSchemaUtils as JsonSchemaUtils8 } from "@flowgram.ai/json-schema";
|
|
3574
|
+
import {
|
|
3575
|
+
DataEvent as DataEvent5,
|
|
3576
|
+
getNodeScope as getNodeScope3
|
|
3577
|
+
} from "@flowgram.ai/editor";
|
|
3578
|
+
var listenRefSchemaChange = (cb) => [
|
|
3579
|
+
{
|
|
3580
|
+
event: DataEvent5.onValueInitOrChange,
|
|
3581
|
+
effect: (params) => {
|
|
3582
|
+
const { context, value } = params;
|
|
3583
|
+
if (value?.type !== "ref") {
|
|
3584
|
+
return () => null;
|
|
3585
|
+
}
|
|
3586
|
+
const disposable = getNodeScope3(context.node).available.trackByKeyPath(
|
|
3587
|
+
value?.content || [],
|
|
3588
|
+
(_type) => {
|
|
3589
|
+
cb({ ...params, schema: JsonSchemaUtils8.astToSchema(_type) });
|
|
3590
|
+
},
|
|
3591
|
+
{
|
|
3592
|
+
selector: (_v) => _v?.type
|
|
3593
|
+
}
|
|
3594
|
+
);
|
|
3595
|
+
return () => {
|
|
3596
|
+
disposable.dispose();
|
|
3597
|
+
};
|
|
3598
|
+
}
|
|
3599
|
+
}
|
|
3600
|
+
];
|
|
3601
|
+
|
|
3515
3602
|
// src/shared/format-legacy-refs/index.ts
|
|
3516
3603
|
import { isObject as isObject3 } from "lodash";
|
|
3517
3604
|
function formatLegacyRefOnSubmit(value) {
|
|
@@ -3581,7 +3668,7 @@ import {
|
|
|
3581
3668
|
defineFormPluginCreator,
|
|
3582
3669
|
getNodeForm as getNodeForm3,
|
|
3583
3670
|
getNodePrivateScope as getNodePrivateScope2,
|
|
3584
|
-
getNodeScope as
|
|
3671
|
+
getNodeScope as getNodeScope4,
|
|
3585
3672
|
ScopeChainTransformService,
|
|
3586
3673
|
FlowNodeScopeType
|
|
3587
3674
|
} from "@flowgram.ai/editor";
|
|
@@ -3626,7 +3713,7 @@ var createBatchOutputsFormPlugin = defineFormPluginCreator({
|
|
|
3626
3713
|
transformCovers: (covers, ctx2) => {
|
|
3627
3714
|
const node = ctx2.scope.meta?.node;
|
|
3628
3715
|
if (node?.parent?.flowNodeType === batchNodeType) {
|
|
3629
|
-
return [...covers,
|
|
3716
|
+
return [...covers, getNodeScope4(node.parent)];
|
|
3630
3717
|
}
|
|
3631
3718
|
return covers;
|
|
3632
3719
|
},
|
|
@@ -3640,7 +3727,7 @@ var createBatchOutputsFormPlugin = defineFormPluginCreator({
|
|
|
3640
3727
|
const childBlocks = node.blocks;
|
|
3641
3728
|
return [
|
|
3642
3729
|
getNodePrivateScope2(node),
|
|
3643
|
-
...childBlocks.map((_childBlock) =>
|
|
3730
|
+
...childBlocks.map((_childBlock) => getNodeScope4(_childBlock))
|
|
3644
3731
|
];
|
|
3645
3732
|
}
|
|
3646
3733
|
return scopes;
|
|
@@ -3651,11 +3738,11 @@ var createBatchOutputsFormPlugin = defineFormPluginCreator({
|
|
|
3651
3738
|
|
|
3652
3739
|
// src/form-plugins/infer-inputs-plugin/index.ts
|
|
3653
3740
|
import { get as get2, set as set2 } from "lodash";
|
|
3654
|
-
import { JsonSchemaUtils as
|
|
3741
|
+
import { JsonSchemaUtils as JsonSchemaUtils9 } from "@flowgram.ai/json-schema";
|
|
3655
3742
|
import {
|
|
3656
3743
|
defineFormPluginCreator as defineFormPluginCreator2,
|
|
3657
3744
|
getNodePrivateScope as getNodePrivateScope3,
|
|
3658
|
-
getNodeScope as
|
|
3745
|
+
getNodeScope as getNodeScope5
|
|
3659
3746
|
} from "@flowgram.ai/editor";
|
|
3660
3747
|
var createInferInputsPlugin = defineFormPluginCreator2({
|
|
3661
3748
|
onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
|
|
@@ -3668,7 +3755,7 @@ var createInferInputsPlugin = defineFormPluginCreator2({
|
|
|
3668
3755
|
targetKey,
|
|
3669
3756
|
infer(
|
|
3670
3757
|
get2(formData, sourceKey),
|
|
3671
|
-
scope === "private" ? getNodePrivateScope3(ctx.node) :
|
|
3758
|
+
scope === "private" ? getNodePrivateScope3(ctx.node) : getNodeScope5(ctx.node)
|
|
3672
3759
|
)
|
|
3673
3760
|
);
|
|
3674
3761
|
return formData;
|
|
@@ -3708,7 +3795,7 @@ var infer = (values, scope) => {
|
|
|
3708
3795
|
}
|
|
3709
3796
|
if (isRef2(values)) {
|
|
3710
3797
|
const variable = scope.available.getByKeyPath(values?.content);
|
|
3711
|
-
const schema = variable?.type ?
|
|
3798
|
+
const schema = variable?.type ? JsonSchemaUtils9.astToSchema(variable?.type) : void 0;
|
|
3712
3799
|
return schema;
|
|
3713
3800
|
}
|
|
3714
3801
|
if (isTemplate2(values)) {
|
|
@@ -3731,13 +3818,13 @@ var infer = (values, scope) => {
|
|
|
3731
3818
|
|
|
3732
3819
|
// src/form-plugins/infer-assign-plugin/index.ts
|
|
3733
3820
|
import { set as set3, uniqBy } from "lodash";
|
|
3734
|
-
import { JsonSchemaUtils as
|
|
3821
|
+
import { JsonSchemaUtils as JsonSchemaUtils10 } from "@flowgram.ai/json-schema";
|
|
3735
3822
|
import {
|
|
3736
3823
|
ASTFactory as ASTFactory4,
|
|
3737
3824
|
createEffectFromVariableProvider as createEffectFromVariableProvider4,
|
|
3738
3825
|
defineFormPluginCreator as defineFormPluginCreator3,
|
|
3739
3826
|
getNodeForm as getNodeForm4,
|
|
3740
|
-
getNodeScope as
|
|
3827
|
+
getNodeScope as getNodeScope6
|
|
3741
3828
|
} from "@flowgram.ai/editor";
|
|
3742
3829
|
var createInferAssignPlugin = defineFormPluginCreator3({
|
|
3743
3830
|
onSetupFormMeta({ addFormatOnSubmit, mergeEffect }, { assignKey, outputKey }) {
|
|
@@ -3762,7 +3849,7 @@ var createInferAssignPlugin = defineFormPluginCreator3({
|
|
|
3762
3849
|
properties: declareRows.map(
|
|
3763
3850
|
(_v) => ASTFactory4.createProperty({
|
|
3764
3851
|
key: _v.left,
|
|
3765
|
-
type: _v.right?.type === "constant" ?
|
|
3852
|
+
type: _v.right?.type === "constant" ? JsonSchemaUtils10.schemaToAST(_v.right?.schema || {}) : void 0,
|
|
3766
3853
|
initializer: _v.right?.type === "ref" ? ASTFactory4.createKeyPathExpression({
|
|
3767
3854
|
keyPath: _v.right?.content || []
|
|
3768
3855
|
}) : {}
|
|
@@ -3778,7 +3865,7 @@ var createInferAssignPlugin = defineFormPluginCreator3({
|
|
|
3778
3865
|
set3(
|
|
3779
3866
|
formData,
|
|
3780
3867
|
outputKey,
|
|
3781
|
-
|
|
3868
|
+
JsonSchemaUtils10.astToSchema(getNodeScope6(ctx.node).output.variables?.[0]?.type)
|
|
3782
3869
|
);
|
|
3783
3870
|
return formData;
|
|
3784
3871
|
});
|
|
@@ -3787,7 +3874,7 @@ var createInferAssignPlugin = defineFormPluginCreator3({
|
|
|
3787
3874
|
|
|
3788
3875
|
// src/validate/validate-flow-value/index.tsx
|
|
3789
3876
|
import { isNil, uniq as uniq2 } from "lodash";
|
|
3790
|
-
import { FeedbackLevel, getNodeScope as
|
|
3877
|
+
import { FeedbackLevel, getNodeScope as getNodeScope7 } from "@flowgram.ai/editor";
|
|
3791
3878
|
function validateFlowValue(value, ctx) {
|
|
3792
3879
|
const { node, required, errorMessages } = ctx;
|
|
3793
3880
|
const {
|
|
@@ -3801,7 +3888,7 @@ function validateFlowValue(value, ctx) {
|
|
|
3801
3888
|
};
|
|
3802
3889
|
}
|
|
3803
3890
|
if (value?.type === "ref") {
|
|
3804
|
-
const variable =
|
|
3891
|
+
const variable = getNodeScope7(node).available.getByKeyPath(value?.content || []);
|
|
3805
3892
|
if (!variable) {
|
|
3806
3893
|
return {
|
|
3807
3894
|
level: FeedbackLevel.Error,
|
|
@@ -3812,7 +3899,7 @@ function validateFlowValue(value, ctx) {
|
|
|
3812
3899
|
if (value?.type === "template") {
|
|
3813
3900
|
const allRefs = getTemplateKeyPaths2(value);
|
|
3814
3901
|
for (const ref of allRefs) {
|
|
3815
|
-
const variable =
|
|
3902
|
+
const variable = getNodeScope7(node).available.getByKeyPath(ref);
|
|
3816
3903
|
if (!variable) {
|
|
3817
3904
|
return {
|
|
3818
3905
|
level: FeedbackLevel.Error,
|
|
@@ -3867,6 +3954,8 @@ export {
|
|
|
3867
3954
|
getTypeSelectValue,
|
|
3868
3955
|
isLegacyFlowRefValueSchema,
|
|
3869
3956
|
isNewFlowRefValueSchema,
|
|
3957
|
+
listenRefSchemaChange,
|
|
3958
|
+
listenRefValueChange,
|
|
3870
3959
|
parseTypeSelectValue,
|
|
3871
3960
|
provideBatchInputEffect,
|
|
3872
3961
|
provideBatchOutputsEffect,
|