@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/index.js
CHANGED
|
@@ -67,6 +67,8 @@ __export(src_exports, {
|
|
|
67
67
|
getTypeSelectValue: () => getTypeSelectValue,
|
|
68
68
|
isLegacyFlowRefValueSchema: () => isLegacyFlowRefValueSchema,
|
|
69
69
|
isNewFlowRefValueSchema: () => isNewFlowRefValueSchema,
|
|
70
|
+
listenRefSchemaChange: () => listenRefSchemaChange,
|
|
71
|
+
listenRefValueChange: () => listenRefValueChange,
|
|
70
72
|
parseTypeSelectValue: () => parseTypeSelectValue,
|
|
71
73
|
provideBatchInputEffect: () => provideBatchInputEffect,
|
|
72
74
|
provideBatchOutputsEffect: () => provideBatchOutputsEffect,
|
|
@@ -85,13 +87,14 @@ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
|
85
87
|
|
|
86
88
|
// src/components/variable-selector/index.tsx
|
|
87
89
|
var import_react12 = __toESM(require("react"));
|
|
90
|
+
var import_editor11 = require("@flowgram.ai/editor");
|
|
88
91
|
var import_semi_ui7 = require("@douyinfe/semi-ui");
|
|
89
92
|
var import_semi_icons = require("@douyinfe/semi-icons");
|
|
90
93
|
|
|
91
94
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
92
95
|
var import_react11 = __toESM(require("react"));
|
|
93
96
|
var import_json_schema4 = require("@flowgram.ai/json-schema");
|
|
94
|
-
var
|
|
97
|
+
var import_editor10 = require("@flowgram.ai/editor");
|
|
95
98
|
var import_semi_ui5 = require("@douyinfe/semi-ui");
|
|
96
99
|
|
|
97
100
|
// src/plugins/json-schema-preset/index.tsx
|
|
@@ -103,14 +106,24 @@ var import_json_schema = require("@flowgram.ai/json-schema");
|
|
|
103
106
|
|
|
104
107
|
// src/plugins/json-schema-preset/type-definition/string.tsx
|
|
105
108
|
var import_react = __toESM(require("react"));
|
|
109
|
+
var import_editor = require("@flowgram.ai/editor");
|
|
106
110
|
var import_semi_ui = require("@douyinfe/semi-ui");
|
|
107
111
|
var stringRegistry = {
|
|
108
112
|
type: "string",
|
|
109
|
-
ConstantRenderer: (props) => /* @__PURE__ */ import_react.default.createElement(
|
|
113
|
+
ConstantRenderer: (props) => /* @__PURE__ */ import_react.default.createElement(
|
|
114
|
+
import_semi_ui.Input,
|
|
115
|
+
{
|
|
116
|
+
placeholder: import_editor.I18n.t("Please Input String"),
|
|
117
|
+
size: "small",
|
|
118
|
+
disabled: props.readonly,
|
|
119
|
+
...props
|
|
120
|
+
}
|
|
121
|
+
)
|
|
110
122
|
};
|
|
111
123
|
|
|
112
124
|
// src/plugins/json-schema-preset/type-definition/object.tsx
|
|
113
125
|
var import_react5 = __toESM(require("react"));
|
|
126
|
+
var import_editor3 = require("@flowgram.ai/editor");
|
|
114
127
|
|
|
115
128
|
// src/components/code-editor-mini/index.tsx
|
|
116
129
|
var import_react4 = __toESM(require("react"));
|
|
@@ -145,13 +158,13 @@ var import_language_typescript = require("@coze-editor/editor/language-typescrip
|
|
|
145
158
|
var import_language_shell = require("@coze-editor/editor/language-shell");
|
|
146
159
|
var import_language_python = require("@coze-editor/editor/language-python");
|
|
147
160
|
var import_language_json = require("@coze-editor/editor/language-json");
|
|
148
|
-
var
|
|
161
|
+
var import_editor2 = require("@coze-editor/editor");
|
|
149
162
|
import_preset_code.languages.register("python", import_language_python.python);
|
|
150
163
|
import_preset_code.languages.register("shell", import_language_shell.shell);
|
|
151
164
|
import_preset_code.languages.register("typescript", import_language_typescript.typescript);
|
|
152
165
|
import_preset_code.languages.register("json", {
|
|
153
166
|
// mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
|
|
154
|
-
language: (0,
|
|
167
|
+
language: (0, import_editor2.mixLanguages)({
|
|
155
168
|
outerLanguage: import_language_json.json.language
|
|
156
169
|
}),
|
|
157
170
|
languageService: import_language_json.json.languageService
|
|
@@ -486,7 +499,7 @@ var objectRegistry = {
|
|
|
486
499
|
value: props.value,
|
|
487
500
|
onChange: (v) => props.onChange?.(v),
|
|
488
501
|
languageId: "json",
|
|
489
|
-
placeholder: "Please Input Object",
|
|
502
|
+
placeholder: import_editor3.I18n.t("Please Input Object"),
|
|
490
503
|
readonly: props.readonly
|
|
491
504
|
}
|
|
492
505
|
)
|
|
@@ -494,13 +507,14 @@ var objectRegistry = {
|
|
|
494
507
|
|
|
495
508
|
// src/plugins/json-schema-preset/type-definition/number.tsx
|
|
496
509
|
var import_react6 = __toESM(require("react"));
|
|
510
|
+
var import_editor4 = require("@flowgram.ai/editor");
|
|
497
511
|
var import_semi_ui2 = require("@douyinfe/semi-ui");
|
|
498
512
|
var numberRegistry = {
|
|
499
513
|
type: "number",
|
|
500
514
|
ConstantRenderer: (props) => /* @__PURE__ */ import_react6.default.createElement(
|
|
501
515
|
import_semi_ui2.InputNumber,
|
|
502
516
|
{
|
|
503
|
-
placeholder: "Please Input Number",
|
|
517
|
+
placeholder: import_editor4.I18n.t("Please Input Number"),
|
|
504
518
|
size: "small",
|
|
505
519
|
disabled: props.readonly,
|
|
506
520
|
hideButtons: true,
|
|
@@ -511,13 +525,14 @@ var numberRegistry = {
|
|
|
511
525
|
|
|
512
526
|
// src/plugins/json-schema-preset/type-definition/integer.tsx
|
|
513
527
|
var import_react7 = __toESM(require("react"));
|
|
528
|
+
var import_editor5 = require("@flowgram.ai/editor");
|
|
514
529
|
var import_semi_ui3 = require("@douyinfe/semi-ui");
|
|
515
530
|
var integerRegistry = {
|
|
516
531
|
type: "integer",
|
|
517
532
|
ConstantRenderer: (props) => /* @__PURE__ */ import_react7.default.createElement(
|
|
518
533
|
import_semi_ui3.InputNumber,
|
|
519
534
|
{
|
|
520
|
-
placeholder: "Please Input Integer",
|
|
535
|
+
placeholder: import_editor5.I18n.t("Please Input Integer"),
|
|
521
536
|
size: "small",
|
|
522
537
|
disabled: props.readonly,
|
|
523
538
|
precision: 0,
|
|
@@ -528,6 +543,7 @@ var integerRegistry = {
|
|
|
528
543
|
|
|
529
544
|
// src/plugins/json-schema-preset/type-definition/boolean.tsx
|
|
530
545
|
var import_react8 = __toESM(require("react"));
|
|
546
|
+
var import_editor6 = require("@flowgram.ai/editor");
|
|
531
547
|
var import_semi_ui4 = require("@douyinfe/semi-ui");
|
|
532
548
|
var booleanRegistry = {
|
|
533
549
|
type: "boolean",
|
|
@@ -536,12 +552,12 @@ var booleanRegistry = {
|
|
|
536
552
|
return /* @__PURE__ */ import_react8.default.createElement(
|
|
537
553
|
import_semi_ui4.Select,
|
|
538
554
|
{
|
|
539
|
-
placeholder: "Please Select Boolean",
|
|
555
|
+
placeholder: import_editor6.I18n.t("Please Select Boolean"),
|
|
540
556
|
size: "small",
|
|
541
557
|
disabled: props.readonly,
|
|
542
558
|
optionList: [
|
|
543
|
-
{ label: "True", value: 1 },
|
|
544
|
-
{ label: "False", value: 0 }
|
|
559
|
+
{ label: import_editor6.I18n.t("True"), value: 1 },
|
|
560
|
+
{ label: import_editor6.I18n.t("False"), value: 0 }
|
|
545
561
|
],
|
|
546
562
|
value: value ? 1 : 0,
|
|
547
563
|
onChange: (value2) => onChange?.(!!value2),
|
|
@@ -553,6 +569,7 @@ var booleanRegistry = {
|
|
|
553
569
|
|
|
554
570
|
// src/plugins/json-schema-preset/type-definition/array.tsx
|
|
555
571
|
var import_react9 = __toESM(require("react"));
|
|
572
|
+
var import_editor7 = require("@flowgram.ai/editor");
|
|
556
573
|
var arrayRegistry = {
|
|
557
574
|
type: "array",
|
|
558
575
|
ConstantRenderer: (props) => /* @__PURE__ */ import_react9.default.createElement(
|
|
@@ -561,7 +578,7 @@ var arrayRegistry = {
|
|
|
561
578
|
value: props.value,
|
|
562
579
|
languageId: "json",
|
|
563
580
|
onChange: (v) => props.onChange?.(v),
|
|
564
|
-
placeholder: "Please Input Array",
|
|
581
|
+
placeholder: import_editor7.I18n.t("Please Input Array"),
|
|
565
582
|
readonly: props.readonly
|
|
566
583
|
}
|
|
567
584
|
)
|
|
@@ -580,8 +597,8 @@ jsonSchemaTypePreset.forEach((_type) => import_json_schema.jsonSchemaTypeManager
|
|
|
580
597
|
|
|
581
598
|
// src/plugins/json-schema-preset/create-type-preset-plugin.tsx
|
|
582
599
|
var import_json_schema2 = require("@flowgram.ai/json-schema");
|
|
583
|
-
var
|
|
584
|
-
var createTypePresetPlugin = (0,
|
|
600
|
+
var import_editor8 = require("@flowgram.ai/editor");
|
|
601
|
+
var createTypePresetPlugin = (0, import_editor8.definePluginCreator)({
|
|
585
602
|
onInit(ctx, opts) {
|
|
586
603
|
const typeManager = ctx.get(import_json_schema2.BaseTypeManager);
|
|
587
604
|
jsonSchemaTypePreset.forEach((_type) => typeManager.register(_type));
|
|
@@ -599,12 +616,12 @@ var JsonSchemaTypePresetProvider = ({
|
|
|
599
616
|
}) => /* @__PURE__ */ import_react10.default.createElement(import_json_schema3.TypePresetProvider, { types: [...jsonSchemaTypePreset, ...types] }, children);
|
|
600
617
|
|
|
601
618
|
// src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts
|
|
602
|
-
var
|
|
603
|
-
var createDisableDeclarationPlugin = (0,
|
|
619
|
+
var import_editor9 = require("@flowgram.ai/editor");
|
|
620
|
+
var createDisableDeclarationPlugin = (0, import_editor9.definePluginCreator)({
|
|
604
621
|
onInit(ctx) {
|
|
605
|
-
const variableEngine = ctx.get(
|
|
622
|
+
const variableEngine = ctx.get(import_editor9.VariableEngine);
|
|
606
623
|
const handleEvent = (action) => {
|
|
607
|
-
if (
|
|
624
|
+
if (import_editor9.ASTMatch.isVariableDeclaration(action.ast)) {
|
|
608
625
|
if (!action.ast.meta?.disabled) {
|
|
609
626
|
action.ast.updateMeta({
|
|
610
627
|
...action.ast.meta || {},
|
|
@@ -622,7 +639,7 @@ var createDisableDeclarationPlugin = (0, import_editor3.definePluginCreator)({
|
|
|
622
639
|
function useVariableTree(params) {
|
|
623
640
|
const { includeSchema, excludeSchema, customSkip } = params;
|
|
624
641
|
const typeManager = useTypeManager();
|
|
625
|
-
const variables = (0,
|
|
642
|
+
const variables = (0, import_editor10.useAvailableVariables)();
|
|
626
643
|
const getVariableTypeIcon = (0, import_react11.useCallback)((variable) => {
|
|
627
644
|
if (variable.meta?.icon) {
|
|
628
645
|
if (typeof variable.meta.icon === "string") {
|
|
@@ -639,7 +656,7 @@ function useVariableTree(params) {
|
|
|
639
656
|
return null;
|
|
640
657
|
}
|
|
641
658
|
let children;
|
|
642
|
-
if (
|
|
659
|
+
if (import_editor10.ASTMatch.isObject(type)) {
|
|
643
660
|
children = (type.properties || []).map((_property) => renderVariable(_property, [...parentFields, variable])).filter(Boolean);
|
|
644
661
|
}
|
|
645
662
|
const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
|
|
@@ -805,7 +822,7 @@ var VariableSelector = ({
|
|
|
805
822
|
showClear: false,
|
|
806
823
|
arrowIcon: /* @__PURE__ */ import_react12.default.createElement(import_semi_icons.IconChevronDownStroked, { size: "small" }),
|
|
807
824
|
triggerRender,
|
|
808
|
-
placeholder: config?.placeholder ?? "Select Variable"
|
|
825
|
+
placeholder: config?.placeholder ?? import_editor11.I18n.t("Select Variable")
|
|
809
826
|
}
|
|
810
827
|
));
|
|
811
828
|
};
|
|
@@ -814,7 +831,6 @@ var VariableSelector = ({
|
|
|
814
831
|
var import_react13 = __toESM(require("react"));
|
|
815
832
|
var import_semi_ui8 = require("@douyinfe/semi-ui");
|
|
816
833
|
var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
|
|
817
|
-
var firstUppercase = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
818
834
|
var getTypeSelectValue = (value) => {
|
|
819
835
|
if (value?.type === "array" && value?.items) {
|
|
820
836
|
return [value.type, ...getTypeSelectValue(value.items) || []];
|
|
@@ -837,7 +853,7 @@ function TypeSelector(props) {
|
|
|
837
853
|
() => typeManager.getTypeRegistriesWithParentType().map((_type) => {
|
|
838
854
|
const isArray2 = _type.type === "array";
|
|
839
855
|
return {
|
|
840
|
-
label: /* @__PURE__ */ import_react13.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react13.default.createElement(import_semi_ui8.Icon, { size: "small", svg: _type.icon }),
|
|
856
|
+
label: /* @__PURE__ */ import_react13.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react13.default.createElement(import_semi_ui8.Icon, { size: "small", svg: _type.icon }), typeManager.getTypeBySchema(_type)?.label || _type.type),
|
|
841
857
|
value: _type.type,
|
|
842
858
|
children: isArray2 ? typeManager.getTypeRegistriesWithParentType("array").map((_type2) => ({
|
|
843
859
|
label: /* @__PURE__ */ import_react13.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react13.default.createElement(
|
|
@@ -849,7 +865,7 @@ function TypeSelector(props) {
|
|
|
849
865
|
items: { type: _type2.type }
|
|
850
866
|
})
|
|
851
867
|
}
|
|
852
|
-
),
|
|
868
|
+
), typeManager.getTypeBySchema(_type2)?.label || _type2.type),
|
|
853
869
|
value: _type2.type
|
|
854
870
|
})) : []
|
|
855
871
|
};
|
|
@@ -874,6 +890,7 @@ function TypeSelector(props) {
|
|
|
874
890
|
|
|
875
891
|
// src/components/json-schema-editor/index.tsx
|
|
876
892
|
var import_react19 = __toESM(require("react"));
|
|
893
|
+
var import_editor12 = require("@flowgram.ai/editor");
|
|
877
894
|
var import_semi_ui11 = require("@douyinfe/semi-ui");
|
|
878
895
|
var import_semi_icons4 = require("@douyinfe/semi-icons");
|
|
879
896
|
|
|
@@ -1481,22 +1498,22 @@ function PropertyEdit(props) {
|
|
|
1481
1498
|
onClick: onRemove
|
|
1482
1499
|
}
|
|
1483
1500
|
))),
|
|
1484
|
-
expand && /* @__PURE__ */ import_react19.default.createElement(UIExpandDetail, null, /* @__PURE__ */ import_react19.default.createElement(UILabel, null, config?.descTitle ?? "Description"), /* @__PURE__ */ import_react19.default.createElement(
|
|
1501
|
+
expand && /* @__PURE__ */ import_react19.default.createElement(UIExpandDetail, null, /* @__PURE__ */ import_react19.default.createElement(UILabel, null, config?.descTitle ?? import_editor12.I18n.t("Description")), /* @__PURE__ */ import_react19.default.createElement(
|
|
1485
1502
|
BlurInput,
|
|
1486
1503
|
{
|
|
1487
1504
|
disabled: readonly,
|
|
1488
1505
|
size: "small",
|
|
1489
1506
|
value: description,
|
|
1490
1507
|
onChange: (value2) => onChange("description", value2),
|
|
1491
|
-
placeholder: config?.descPlaceholder ?? "Help LLM to understand the property"
|
|
1508
|
+
placeholder: config?.descPlaceholder ?? import_editor12.I18n.t("Help LLM to understand the property")
|
|
1492
1509
|
}
|
|
1493
|
-
), $level === 0 && type && type !== "array" && /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, /* @__PURE__ */ import_react19.default.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? "Default Value"), /* @__PURE__ */ import_react19.default.createElement(DefaultValueWrapper, null, /* @__PURE__ */ import_react19.default.createElement(
|
|
1510
|
+
), $level === 0 && type && type !== "array" && /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, /* @__PURE__ */ import_react19.default.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? import_editor12.I18n.t("Default Value")), /* @__PURE__ */ import_react19.default.createElement(DefaultValueWrapper, null, /* @__PURE__ */ import_react19.default.createElement(
|
|
1494
1511
|
DefaultValue,
|
|
1495
1512
|
{
|
|
1496
1513
|
value: defaultValue,
|
|
1497
1514
|
schema: value,
|
|
1498
1515
|
type,
|
|
1499
|
-
placeholder: config?.defaultValuePlaceholder,
|
|
1516
|
+
placeholder: config?.defaultValuePlaceholder ?? import_editor12.I18n.t("Default Value"),
|
|
1500
1517
|
jsonFormatText: config?.jsonFormatText,
|
|
1501
1518
|
onChange: (value2) => onChange("default", value2)
|
|
1502
1519
|
}
|
|
@@ -1527,13 +1544,13 @@ function PropertyEdit(props) {
|
|
|
1527
1544
|
|
|
1528
1545
|
// src/components/batch-variable-selector/index.tsx
|
|
1529
1546
|
var import_react20 = __toESM(require("react"));
|
|
1530
|
-
var
|
|
1547
|
+
var import_editor13 = require("@flowgram.ai/editor");
|
|
1531
1548
|
var batchVariableSchema = {
|
|
1532
1549
|
type: "array",
|
|
1533
1550
|
extra: { weak: true }
|
|
1534
1551
|
};
|
|
1535
1552
|
function BatchVariableSelector(props) {
|
|
1536
|
-
return /* @__PURE__ */ import_react20.default.createElement(
|
|
1553
|
+
return /* @__PURE__ */ import_react20.default.createElement(import_editor13.PrivateScopeProvider, null, /* @__PURE__ */ import_react20.default.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
|
|
1537
1554
|
}
|
|
1538
1555
|
|
|
1539
1556
|
// src/components/dynamic-value-input/index.tsx
|
|
@@ -1589,9 +1606,9 @@ var UITrigger = import_styled_components4.default.div`
|
|
|
1589
1606
|
|
|
1590
1607
|
// src/components/dynamic-value-input/hooks.ts
|
|
1591
1608
|
var import_react21 = require("react");
|
|
1592
|
-
var
|
|
1609
|
+
var import_editor14 = require("@flowgram.ai/editor");
|
|
1593
1610
|
function useRefVariable(value) {
|
|
1594
|
-
const available = (0,
|
|
1611
|
+
const available = (0, import_editor14.useScopeAvailable)();
|
|
1595
1612
|
const refVariable = (0, import_react21.useMemo)(() => {
|
|
1596
1613
|
if (value?.type === "ref") {
|
|
1597
1614
|
return available.getByKeyPath(value.content);
|
|
@@ -1717,6 +1734,7 @@ function DynamicValueInput({
|
|
|
1717
1734
|
|
|
1718
1735
|
// src/components/condition-row/index.tsx
|
|
1719
1736
|
var import_react25 = __toESM(require("react"));
|
|
1737
|
+
var import_editor17 = require("@flowgram.ai/editor");
|
|
1720
1738
|
var import_semi_ui14 = require("@douyinfe/semi-ui");
|
|
1721
1739
|
|
|
1722
1740
|
// src/components/condition-row/styles.tsx
|
|
@@ -1744,10 +1762,10 @@ var UIValues = import_styled_components5.default.div`
|
|
|
1744
1762
|
// src/components/condition-row/hooks/useRule.ts
|
|
1745
1763
|
var import_react23 = require("react");
|
|
1746
1764
|
var import_json_schema6 = require("@flowgram.ai/json-schema");
|
|
1747
|
-
var
|
|
1765
|
+
var import_editor15 = require("@flowgram.ai/editor");
|
|
1748
1766
|
|
|
1749
1767
|
// src/components/condition-row/constants.ts
|
|
1750
|
-
var
|
|
1768
|
+
var defaultRules = {
|
|
1751
1769
|
string: {
|
|
1752
1770
|
["eq" /* EQ */]: "string",
|
|
1753
1771
|
["neq" /* NEQ */]: "string",
|
|
@@ -1803,7 +1821,7 @@ var rules = {
|
|
|
1803
1821
|
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1804
1822
|
}
|
|
1805
1823
|
};
|
|
1806
|
-
var
|
|
1824
|
+
var defaultOpConfigs = {
|
|
1807
1825
|
["eq" /* EQ */]: {
|
|
1808
1826
|
label: "Equal",
|
|
1809
1827
|
abbreviation: "="
|
|
@@ -1867,8 +1885,9 @@ var opConfigs = {
|
|
|
1867
1885
|
};
|
|
1868
1886
|
|
|
1869
1887
|
// src/components/condition-row/hooks/useRule.ts
|
|
1870
|
-
function useRule(left) {
|
|
1871
|
-
const available = (0,
|
|
1888
|
+
function useRule(left, userRules) {
|
|
1889
|
+
const available = (0, import_editor15.useScopeAvailable)();
|
|
1890
|
+
const rules = (0, import_react23.useMemo)(() => ({ ...defaultRules, ...userRules || {} }), [userRules]);
|
|
1872
1891
|
const variable = (0, import_react23.useMemo)(() => {
|
|
1873
1892
|
if (!left) return void 0;
|
|
1874
1893
|
return available.getByKeyPath(left.content);
|
|
@@ -1877,23 +1896,26 @@ function useRule(left) {
|
|
|
1877
1896
|
if (!variable) return void 0;
|
|
1878
1897
|
const schema = import_json_schema6.JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
|
|
1879
1898
|
return rules[schema?.type];
|
|
1880
|
-
}, [variable?.type]);
|
|
1899
|
+
}, [variable?.type, rules]);
|
|
1881
1900
|
return { rule };
|
|
1882
1901
|
}
|
|
1883
1902
|
|
|
1884
1903
|
// src/components/condition-row/hooks/useOp.tsx
|
|
1885
1904
|
var import_react24 = __toESM(require("react"));
|
|
1905
|
+
var import_editor16 = require("@flowgram.ai/editor");
|
|
1886
1906
|
var import_semi_ui13 = require("@douyinfe/semi-ui");
|
|
1887
1907
|
var import_semi_icons6 = require("@douyinfe/semi-icons");
|
|
1888
|
-
function useOp({ rule, op, onChange, readonly }) {
|
|
1908
|
+
function useOp({ rule, op, onChange, readonly, userOps }) {
|
|
1889
1909
|
const options = (0, import_react24.useMemo)(
|
|
1890
1910
|
() => Object.keys(rule || {}).map((_op) => ({
|
|
1891
|
-
...
|
|
1892
|
-
|
|
1911
|
+
...defaultOpConfigs[_op] || {},
|
|
1912
|
+
...userOps?.[_op] || {},
|
|
1913
|
+
value: _op,
|
|
1914
|
+
label: import_editor16.I18n.t(userOps?.[_op]?.label || defaultOpConfigs[_op]?.label)
|
|
1893
1915
|
})),
|
|
1894
|
-
[rule]
|
|
1916
|
+
[rule, userOps]
|
|
1895
1917
|
);
|
|
1896
|
-
const opConfig = (0, import_react24.useMemo)(() =>
|
|
1918
|
+
const opConfig = (0, import_react24.useMemo)(() => defaultOpConfigs[op], [op]);
|
|
1897
1919
|
const renderOpSelect = () => /* @__PURE__ */ import_react24.default.createElement(
|
|
1898
1920
|
import_semi_ui13.Select,
|
|
1899
1921
|
{
|
|
@@ -1912,17 +1934,28 @@ function useOp({ rule, op, onChange, readonly }) {
|
|
|
1912
1934
|
}
|
|
1913
1935
|
|
|
1914
1936
|
// src/components/condition-row/index.tsx
|
|
1915
|
-
|
|
1937
|
+
var defaultRuleConfig = {
|
|
1938
|
+
ops: {},
|
|
1939
|
+
rules: {}
|
|
1940
|
+
};
|
|
1941
|
+
function ConditionRow({
|
|
1942
|
+
style,
|
|
1943
|
+
value,
|
|
1944
|
+
onChange,
|
|
1945
|
+
readonly,
|
|
1946
|
+
ruleConfig = defaultRuleConfig
|
|
1947
|
+
}) {
|
|
1916
1948
|
const { left, operator, right } = value || {};
|
|
1917
|
-
const { rule } = useRule(left);
|
|
1949
|
+
const { rule } = useRule(left, ruleConfig.rules);
|
|
1918
1950
|
const { renderOpSelect, opConfig } = useOp({
|
|
1919
1951
|
rule,
|
|
1920
1952
|
op: operator,
|
|
1921
1953
|
onChange: (v) => onChange({ ...value, operator: v }),
|
|
1922
|
-
readonly
|
|
1954
|
+
readonly,
|
|
1955
|
+
userOps: ruleConfig.ops
|
|
1923
1956
|
});
|
|
1924
1957
|
const targetSchema = (0, import_react25.useMemo)(() => {
|
|
1925
|
-
const targetType = rule?.[operator] || null;
|
|
1958
|
+
const targetType = rule?.[operator || ""] || null;
|
|
1926
1959
|
return targetType ? { type: targetType, extra: { weak: true } } : null;
|
|
1927
1960
|
}, [rule, opConfig]);
|
|
1928
1961
|
return /* @__PURE__ */ import_react25.default.createElement(UIContainer3, { style }, /* @__PURE__ */ import_react25.default.createElement(UIOperator, null, renderOpSelect()), /* @__PURE__ */ import_react25.default.createElement(UIValues, null, /* @__PURE__ */ import_react25.default.createElement(UILeft, null, /* @__PURE__ */ import_react25.default.createElement(
|
|
@@ -1953,7 +1986,7 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1953
1986
|
size: "small",
|
|
1954
1987
|
disabled: true,
|
|
1955
1988
|
style: { pointerEvents: "none" },
|
|
1956
|
-
value: opConfig?.rightDisplay || "Empty"
|
|
1989
|
+
value: opConfig?.rightDisplay || import_editor17.I18n.t("Empty")
|
|
1957
1990
|
}
|
|
1958
1991
|
))));
|
|
1959
1992
|
}
|
|
@@ -2125,13 +2158,13 @@ var UIContainer4 = import_styled_components7.default.div`
|
|
|
2125
2158
|
// src/components/prompt-editor/extensions/markdown.tsx
|
|
2126
2159
|
var import_react28 = require("react");
|
|
2127
2160
|
var import_react29 = require("@coze-editor/editor/react");
|
|
2128
|
-
var
|
|
2161
|
+
var import_editor18 = require("@coze-editor/editor");
|
|
2129
2162
|
var import_view2 = require("@codemirror/view");
|
|
2130
2163
|
function MarkdownHighlight() {
|
|
2131
2164
|
const injector = (0, import_react29.useInjector)();
|
|
2132
2165
|
(0, import_react28.useLayoutEffect)(
|
|
2133
2166
|
() => injector.inject([
|
|
2134
|
-
|
|
2167
|
+
import_editor18.astDecorator.whole.of((cursor) => {
|
|
2135
2168
|
if (cursor.name.startsWith("ATXHeading")) {
|
|
2136
2169
|
return {
|
|
2137
2170
|
type: "className",
|
|
@@ -2193,13 +2226,13 @@ var language_support_default = LanguageSupport;
|
|
|
2193
2226
|
// src/components/prompt-editor/extensions/jinja.tsx
|
|
2194
2227
|
var import_react32 = require("react");
|
|
2195
2228
|
var import_react33 = require("@coze-editor/editor/react");
|
|
2196
|
-
var
|
|
2229
|
+
var import_editor19 = require("@coze-editor/editor");
|
|
2197
2230
|
var import_view3 = require("@codemirror/view");
|
|
2198
2231
|
function JinjaHighlight() {
|
|
2199
2232
|
const injector = (0, import_react33.useInjector)();
|
|
2200
2233
|
(0, import_react32.useLayoutEffect)(
|
|
2201
2234
|
() => injector.inject([
|
|
2202
|
-
|
|
2235
|
+
import_editor19.astDecorator.whole.of((cursor) => {
|
|
2203
2236
|
if (cursor.name === "JinjaStatementStart" || cursor.name === "JinjaStatementEnd") {
|
|
2204
2237
|
return {
|
|
2205
2238
|
type: "className",
|
|
@@ -2340,7 +2373,7 @@ function VariableTree() {
|
|
|
2340
2373
|
var import_react_dom = __toESM(require("react-dom"));
|
|
2341
2374
|
var import_react38 = __toESM(require("react"));
|
|
2342
2375
|
var import_lodash3 = require("lodash");
|
|
2343
|
-
var
|
|
2376
|
+
var import_editor20 = require("@flowgram.ai/editor");
|
|
2344
2377
|
var import_semi_ui18 = require("@douyinfe/semi-ui");
|
|
2345
2378
|
var import_semi_icons8 = require("@douyinfe/semi-icons");
|
|
2346
2379
|
var import_react39 = require("@coze-editor/editor/react");
|
|
@@ -2387,7 +2420,7 @@ var UIPopoverContent2 = import_styled_components8.default.div`
|
|
|
2387
2420
|
var VariableTagWidget = class extends import_view4.WidgetType {
|
|
2388
2421
|
constructor({ keyPath, scope }) {
|
|
2389
2422
|
super();
|
|
2390
|
-
this.toDispose = new
|
|
2423
|
+
this.toDispose = new import_editor20.DisposableCollection();
|
|
2391
2424
|
this.renderIcon = (icon) => {
|
|
2392
2425
|
if (typeof icon === "string") {
|
|
2393
2426
|
return /* @__PURE__ */ import_react38.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
@@ -2425,7 +2458,7 @@ var VariableTagWidget = class extends import_view4.WidgetType {
|
|
|
2425
2458
|
const dom = document.createElement("span");
|
|
2426
2459
|
this.rootDOM = dom;
|
|
2427
2460
|
this.toDispose.push(
|
|
2428
|
-
|
|
2461
|
+
import_editor20.Disposable.create(() => {
|
|
2429
2462
|
import_react_dom.default.unmountComponentAtNode(this.rootDOM);
|
|
2430
2463
|
})
|
|
2431
2464
|
);
|
|
@@ -2453,7 +2486,7 @@ var VariableTagWidget = class extends import_view4.WidgetType {
|
|
|
2453
2486
|
};
|
|
2454
2487
|
function VariableTagInject() {
|
|
2455
2488
|
const injector = (0, import_react39.useInjector)();
|
|
2456
|
-
const scope = (0,
|
|
2489
|
+
const scope = (0, import_editor20.useCurrentScope)();
|
|
2457
2490
|
(0, import_react38.useLayoutEffect)(() => {
|
|
2458
2491
|
const atMatcher = new import_view4.MatchDecorator({
|
|
2459
2492
|
regexp: /\{\{([^\}]+)\}\}/g,
|
|
@@ -2505,15 +2538,15 @@ var import_react43 = require("@coze-editor/editor/react");
|
|
|
2505
2538
|
// src/components/prompt-editor-with-inputs/inputs-picker.tsx
|
|
2506
2539
|
var import_react41 = __toESM(require("react"));
|
|
2507
2540
|
var import_lodash4 = require("lodash");
|
|
2508
|
-
var
|
|
2541
|
+
var import_editor21 = require("@flowgram.ai/editor");
|
|
2509
2542
|
var import_semi_ui19 = require("@douyinfe/semi-ui");
|
|
2510
2543
|
function InputsPicker({
|
|
2511
2544
|
inputsValues,
|
|
2512
2545
|
onSelect
|
|
2513
2546
|
}) {
|
|
2514
|
-
const available = (0,
|
|
2547
|
+
const available = (0, import_editor21.useScopeAvailable)();
|
|
2515
2548
|
const getArrayDrilldown = (type, depth = 1) => {
|
|
2516
|
-
if (
|
|
2549
|
+
if (import_editor21.ASTMatch.isArray(type.items)) {
|
|
2517
2550
|
return getArrayDrilldown(type.items, depth + 1);
|
|
2518
2551
|
}
|
|
2519
2552
|
return { type: type.items, depth };
|
|
@@ -2521,12 +2554,12 @@ function InputsPicker({
|
|
|
2521
2554
|
const renderVariable = (variable, keyPath) => {
|
|
2522
2555
|
let type = variable?.type;
|
|
2523
2556
|
let children;
|
|
2524
|
-
if (
|
|
2557
|
+
if (import_editor21.ASTMatch.isObject(type)) {
|
|
2525
2558
|
children = (type.properties || []).map((_property) => renderVariable(_property, [...keyPath, _property.key])).filter(Boolean);
|
|
2526
2559
|
}
|
|
2527
|
-
if (
|
|
2560
|
+
if (import_editor21.ASTMatch.isArray(type)) {
|
|
2528
2561
|
const drilldown = getArrayDrilldown(type);
|
|
2529
|
-
if (
|
|
2562
|
+
if (import_editor21.ASTMatch.isObject(drilldown.type)) {
|
|
2530
2563
|
children = (drilldown.type.properties || []).map(
|
|
2531
2564
|
(_property) => renderVariable(_property, [
|
|
2532
2565
|
...keyPath,
|
|
@@ -2686,7 +2719,7 @@ function VariableTree2() {
|
|
|
2686
2719
|
var import_react47 = __toESM(require("react"));
|
|
2687
2720
|
var import_client = require("react-dom/client");
|
|
2688
2721
|
var import_lodash5 = require("lodash");
|
|
2689
|
-
var
|
|
2722
|
+
var import_editor22 = require("@flowgram.ai/editor");
|
|
2690
2723
|
var import_semi_ui23 = require("@douyinfe/semi-ui");
|
|
2691
2724
|
var import_semi_icons9 = require("@douyinfe/semi-icons");
|
|
2692
2725
|
var import_react48 = require("@coze-editor/editor/react");
|
|
@@ -2733,7 +2766,7 @@ var UIPopoverContent3 = import_styled_components9.default.div`
|
|
|
2733
2766
|
var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
2734
2767
|
constructor({ keyPath, scope }) {
|
|
2735
2768
|
super();
|
|
2736
|
-
this.toDispose = new
|
|
2769
|
+
this.toDispose = new import_editor22.DisposableCollection();
|
|
2737
2770
|
this.renderIcon = (icon) => {
|
|
2738
2771
|
if (typeof icon === "string") {
|
|
2739
2772
|
return /* @__PURE__ */ import_react47.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
@@ -2767,7 +2800,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2767
2800
|
const dom = document.createElement("span");
|
|
2768
2801
|
this.root = (0, import_client.createRoot)(dom);
|
|
2769
2802
|
this.toDispose.push(
|
|
2770
|
-
|
|
2803
|
+
import_editor22.Disposable.create(() => {
|
|
2771
2804
|
this.root.unmount();
|
|
2772
2805
|
})
|
|
2773
2806
|
);
|
|
@@ -2795,7 +2828,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2795
2828
|
};
|
|
2796
2829
|
function VariableTagInject2() {
|
|
2797
2830
|
const injector = (0, import_react48.useInjector)();
|
|
2798
|
-
const scope = (0,
|
|
2831
|
+
const scope = (0, import_editor22.useCurrentScope)();
|
|
2799
2832
|
(0, import_react47.useLayoutEffect)(() => {
|
|
2800
2833
|
const atMatcher = new import_view5.MatchDecorator({
|
|
2801
2834
|
regexp: /\{\{([^\}]+)\}\}/g,
|
|
@@ -3077,7 +3110,7 @@ function SchemaTree(props) {
|
|
|
3077
3110
|
// src/components/display-outputs/index.tsx
|
|
3078
3111
|
var import_react54 = __toESM(require("react"));
|
|
3079
3112
|
var import_json_schema7 = require("@flowgram.ai/json-schema");
|
|
3080
|
-
var
|
|
3113
|
+
var import_editor23 = require("@flowgram.ai/editor");
|
|
3081
3114
|
|
|
3082
3115
|
// src/components/display-schema-tag/index.tsx
|
|
3083
3116
|
var import_react53 = __toESM(require("react"));
|
|
@@ -3130,8 +3163,8 @@ var DisplayOutputsWrapper = import_styled_components13.default.div`
|
|
|
3130
3163
|
|
|
3131
3164
|
// src/components/display-outputs/index.tsx
|
|
3132
3165
|
function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
3133
|
-
const scope = (0,
|
|
3134
|
-
const refresh = (0,
|
|
3166
|
+
const scope = (0, import_editor23.useCurrentScope)();
|
|
3167
|
+
const refresh = (0, import_editor23.useRefresh)();
|
|
3135
3168
|
(0, import_react54.useEffect)(() => {
|
|
3136
3169
|
if (!displayFromScope) {
|
|
3137
3170
|
return () => null;
|
|
@@ -3166,9 +3199,9 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
|
3166
3199
|
// src/components/display-flow-value/index.tsx
|
|
3167
3200
|
var import_react55 = __toESM(require("react"));
|
|
3168
3201
|
var import_json_schema8 = require("@flowgram.ai/json-schema");
|
|
3169
|
-
var
|
|
3202
|
+
var import_editor24 = require("@flowgram.ai/editor");
|
|
3170
3203
|
function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
3171
|
-
const available = (0,
|
|
3204
|
+
const available = (0, import_editor24.useScopeAvailable)();
|
|
3172
3205
|
const variable = value?.type === "ref" ? available.getByKeyPath(value?.content) : void 0;
|
|
3173
3206
|
const schema = (0, import_react55.useMemo)(() => {
|
|
3174
3207
|
if (value?.type === "ref") {
|
|
@@ -3223,7 +3256,7 @@ function DisplayInputsValues({ value, showIconInTree }) {
|
|
|
3223
3256
|
|
|
3224
3257
|
// src/components/assign-rows/index.tsx
|
|
3225
3258
|
var import_react59 = __toESM(require("react"));
|
|
3226
|
-
var
|
|
3259
|
+
var import_editor25 = require("@flowgram.ai/editor");
|
|
3227
3260
|
var import_semi_ui28 = require("@douyinfe/semi-ui");
|
|
3228
3261
|
var import_semi_icons12 = require("@douyinfe/semi-icons");
|
|
3229
3262
|
|
|
@@ -3310,7 +3343,7 @@ function AssignRow(props) {
|
|
|
3310
3343
|
// src/components/assign-rows/index.tsx
|
|
3311
3344
|
function AssignRows(props) {
|
|
3312
3345
|
const { name, readonly } = props;
|
|
3313
|
-
return /* @__PURE__ */ import_react59.default.createElement(
|
|
3346
|
+
return /* @__PURE__ */ import_react59.default.createElement(import_editor25.FieldArray, { name }, ({ field }) => /* @__PURE__ */ import_react59.default.createElement(import_react59.default.Fragment, null, field.map((childField, index) => /* @__PURE__ */ import_react59.default.createElement(
|
|
3314
3347
|
AssignRow,
|
|
3315
3348
|
{
|
|
3316
3349
|
key: childField.key,
|
|
@@ -3343,29 +3376,29 @@ function AssignRows(props) {
|
|
|
3343
3376
|
}
|
|
3344
3377
|
|
|
3345
3378
|
// src/effects/provide-batch-input/index.ts
|
|
3346
|
-
var
|
|
3347
|
-
var provideBatchInputEffect = (0,
|
|
3379
|
+
var import_editor26 = require("@flowgram.ai/editor");
|
|
3380
|
+
var provideBatchInputEffect = (0, import_editor26.createEffectFromVariableProvider)({
|
|
3348
3381
|
private: true,
|
|
3349
3382
|
parse: (value, ctx) => [
|
|
3350
|
-
|
|
3383
|
+
import_editor26.ASTFactory.createVariableDeclaration({
|
|
3351
3384
|
key: `${ctx.node.id}_locals`,
|
|
3352
3385
|
meta: {
|
|
3353
|
-
title: (0,
|
|
3386
|
+
title: (0, import_editor26.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3354
3387
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3355
3388
|
},
|
|
3356
|
-
type:
|
|
3389
|
+
type: import_editor26.ASTFactory.createObject({
|
|
3357
3390
|
properties: [
|
|
3358
|
-
|
|
3391
|
+
import_editor26.ASTFactory.createProperty({
|
|
3359
3392
|
key: "item",
|
|
3360
|
-
initializer:
|
|
3361
|
-
enumerateFor:
|
|
3393
|
+
initializer: import_editor26.ASTFactory.createEnumerateExpression({
|
|
3394
|
+
enumerateFor: import_editor26.ASTFactory.createKeyPathExpression({
|
|
3362
3395
|
keyPath: value.content || []
|
|
3363
3396
|
})
|
|
3364
3397
|
})
|
|
3365
3398
|
}),
|
|
3366
|
-
|
|
3399
|
+
import_editor26.ASTFactory.createProperty({
|
|
3367
3400
|
key: "index",
|
|
3368
|
-
type:
|
|
3401
|
+
type: import_editor26.ASTFactory.createNumber()
|
|
3369
3402
|
})
|
|
3370
3403
|
]
|
|
3371
3404
|
})
|
|
@@ -3375,13 +3408,13 @@ var provideBatchInputEffect = (0, import_editor16.createEffectFromVariableProvid
|
|
|
3375
3408
|
|
|
3376
3409
|
// src/effects/auto-rename-ref/index.ts
|
|
3377
3410
|
var import_lodash6 = require("lodash");
|
|
3378
|
-
var
|
|
3411
|
+
var import_editor27 = require("@flowgram.ai/editor");
|
|
3379
3412
|
var autoRenameRefEffect = [
|
|
3380
3413
|
{
|
|
3381
|
-
event:
|
|
3414
|
+
event: import_editor27.DataEvent.onValueInit,
|
|
3382
3415
|
effect: (params) => {
|
|
3383
3416
|
const { context, form, name } = params;
|
|
3384
|
-
const renameService = context.node.getService(
|
|
3417
|
+
const renameService = context.node.getService(import_editor27.VariableFieldKeyRenameService);
|
|
3385
3418
|
const disposable = renameService.onRename(({ before, after }) => {
|
|
3386
3419
|
const beforeKeyPath = [
|
|
3387
3420
|
...before.parentFields.map((_field) => _field.key).reverse(),
|
|
@@ -3466,13 +3499,13 @@ function traverseRef(name, value, cb) {
|
|
|
3466
3499
|
|
|
3467
3500
|
// src/effects/provide-json-schema-outputs/index.ts
|
|
3468
3501
|
var import_json_schema9 = require("@flowgram.ai/json-schema");
|
|
3469
|
-
var
|
|
3470
|
-
var provideJsonSchemaOutputs = (0,
|
|
3502
|
+
var import_editor28 = require("@flowgram.ai/editor");
|
|
3503
|
+
var provideJsonSchemaOutputs = (0, import_editor28.createEffectFromVariableProvider)({
|
|
3471
3504
|
parse: (value, ctx) => [
|
|
3472
|
-
|
|
3505
|
+
import_editor28.ASTFactory.createVariableDeclaration({
|
|
3473
3506
|
key: `${ctx.node.id}`,
|
|
3474
3507
|
meta: {
|
|
3475
|
-
title: (0,
|
|
3508
|
+
title: (0, import_editor28.getNodeForm)(ctx.node)?.getValueIn("title") || ctx.node.id,
|
|
3476
3509
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3477
3510
|
},
|
|
3478
3511
|
type: import_json_schema9.JsonSchemaUtils.schemaToAST(value)
|
|
@@ -3481,12 +3514,12 @@ var provideJsonSchemaOutputs = (0, import_editor18.createEffectFromVariableProvi
|
|
|
3481
3514
|
});
|
|
3482
3515
|
|
|
3483
3516
|
// src/effects/sync-variable-title/index.ts
|
|
3484
|
-
var
|
|
3517
|
+
var import_editor29 = require("@flowgram.ai/editor");
|
|
3485
3518
|
var syncVariableTitle = [
|
|
3486
3519
|
{
|
|
3487
|
-
event:
|
|
3520
|
+
event: import_editor29.DataEvent.onValueChange,
|
|
3488
3521
|
effect: ({ value, context }) => {
|
|
3489
|
-
context.node.getData(
|
|
3522
|
+
context.node.getData(import_editor29.FlowNodeVariableData).allScopes.forEach((_scope) => {
|
|
3490
3523
|
_scope.output.variables.forEach((_var) => {
|
|
3491
3524
|
_var.updateMeta({
|
|
3492
3525
|
..._var.meta || {},
|
|
@@ -3501,14 +3534,14 @@ var syncVariableTitle = [
|
|
|
3501
3534
|
|
|
3502
3535
|
// src/effects/validate-when-variable-sync/index.ts
|
|
3503
3536
|
var import_lodash7 = require("lodash");
|
|
3504
|
-
var
|
|
3537
|
+
var import_editor30 = require("@flowgram.ai/editor");
|
|
3505
3538
|
var validateWhenVariableSync = ({
|
|
3506
3539
|
scope
|
|
3507
3540
|
} = {}) => [
|
|
3508
3541
|
{
|
|
3509
|
-
event:
|
|
3542
|
+
event: import_editor30.DataEvent.onValueInit,
|
|
3510
3543
|
effect: ({ context, form }) => {
|
|
3511
|
-
const nodeScope = scope === "private" ? (0,
|
|
3544
|
+
const nodeScope = scope === "private" ? (0, import_editor30.getNodePrivateScope)(context.node) : (0, import_editor30.getNodeScope)(context.node);
|
|
3512
3545
|
const disposable = nodeScope.available.onListOrAnyVarChange(() => {
|
|
3513
3546
|
if (!(0, import_lodash7.isEmpty)(form.state.errors)) {
|
|
3514
3547
|
form.validate();
|
|
@@ -3519,6 +3552,56 @@ var validateWhenVariableSync = ({
|
|
|
3519
3552
|
}
|
|
3520
3553
|
];
|
|
3521
3554
|
|
|
3555
|
+
// src/effects/listen-ref-value-change/index.ts
|
|
3556
|
+
var import_editor31 = require("@flowgram.ai/editor");
|
|
3557
|
+
var listenRefValueChange = (cb) => [
|
|
3558
|
+
{
|
|
3559
|
+
event: import_editor31.DataEvent.onValueInitOrChange,
|
|
3560
|
+
effect: (params) => {
|
|
3561
|
+
const { context, value } = params;
|
|
3562
|
+
if (value?.type !== "ref") {
|
|
3563
|
+
return () => null;
|
|
3564
|
+
}
|
|
3565
|
+
const disposable = (0, import_editor31.getNodeScope)(context.node).available.trackByKeyPath(
|
|
3566
|
+
value?.content || [],
|
|
3567
|
+
(v) => {
|
|
3568
|
+
cb({ ...params, variable: v });
|
|
3569
|
+
}
|
|
3570
|
+
);
|
|
3571
|
+
return () => {
|
|
3572
|
+
disposable.dispose();
|
|
3573
|
+
};
|
|
3574
|
+
}
|
|
3575
|
+
}
|
|
3576
|
+
];
|
|
3577
|
+
|
|
3578
|
+
// src/effects/listen-ref-schema-change/index.ts
|
|
3579
|
+
var import_json_schema10 = require("@flowgram.ai/json-schema");
|
|
3580
|
+
var import_editor32 = require("@flowgram.ai/editor");
|
|
3581
|
+
var listenRefSchemaChange = (cb) => [
|
|
3582
|
+
{
|
|
3583
|
+
event: import_editor32.DataEvent.onValueInitOrChange,
|
|
3584
|
+
effect: (params) => {
|
|
3585
|
+
const { context, value } = params;
|
|
3586
|
+
if (value?.type !== "ref") {
|
|
3587
|
+
return () => null;
|
|
3588
|
+
}
|
|
3589
|
+
const disposable = (0, import_editor32.getNodeScope)(context.node).available.trackByKeyPath(
|
|
3590
|
+
value?.content || [],
|
|
3591
|
+
(_type) => {
|
|
3592
|
+
cb({ ...params, schema: import_json_schema10.JsonSchemaUtils.astToSchema(_type) });
|
|
3593
|
+
},
|
|
3594
|
+
{
|
|
3595
|
+
selector: (_v) => _v?.type
|
|
3596
|
+
}
|
|
3597
|
+
);
|
|
3598
|
+
return () => {
|
|
3599
|
+
disposable.dispose();
|
|
3600
|
+
};
|
|
3601
|
+
}
|
|
3602
|
+
}
|
|
3603
|
+
];
|
|
3604
|
+
|
|
3522
3605
|
// src/shared/format-legacy-refs/index.ts
|
|
3523
3606
|
var import_lodash8 = require("lodash");
|
|
3524
3607
|
function formatLegacyRefOnSubmit(value) {
|
|
@@ -3582,21 +3665,21 @@ function formatNewRefToLegacyRef(value) {
|
|
|
3582
3665
|
}
|
|
3583
3666
|
|
|
3584
3667
|
// src/form-plugins/batch-outputs-plugin/index.ts
|
|
3585
|
-
var
|
|
3586
|
-
var provideBatchOutputsEffect = (0,
|
|
3668
|
+
var import_editor33 = require("@flowgram.ai/editor");
|
|
3669
|
+
var provideBatchOutputsEffect = (0, import_editor33.createEffectFromVariableProvider)({
|
|
3587
3670
|
parse: (value, ctx) => [
|
|
3588
|
-
|
|
3671
|
+
import_editor33.ASTFactory.createVariableDeclaration({
|
|
3589
3672
|
key: `${ctx.node.id}`,
|
|
3590
3673
|
meta: {
|
|
3591
|
-
title: (0,
|
|
3674
|
+
title: (0, import_editor33.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3592
3675
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3593
3676
|
},
|
|
3594
|
-
type:
|
|
3677
|
+
type: import_editor33.ASTFactory.createObject({
|
|
3595
3678
|
properties: Object.entries(value).map(
|
|
3596
|
-
([_key, value2]) =>
|
|
3679
|
+
([_key, value2]) => import_editor33.ASTFactory.createProperty({
|
|
3597
3680
|
key: _key,
|
|
3598
|
-
initializer:
|
|
3599
|
-
wrapFor:
|
|
3681
|
+
initializer: import_editor33.ASTFactory.createWrapArrayExpression({
|
|
3682
|
+
wrapFor: import_editor33.ASTFactory.createKeyPathExpression({
|
|
3600
3683
|
keyPath: value2?.content || []
|
|
3601
3684
|
})
|
|
3602
3685
|
})
|
|
@@ -3606,7 +3689,7 @@ var provideBatchOutputsEffect = (0, import_editor21.createEffectFromVariableProv
|
|
|
3606
3689
|
})
|
|
3607
3690
|
]
|
|
3608
3691
|
});
|
|
3609
|
-
var createBatchOutputsFormPlugin = (0,
|
|
3692
|
+
var createBatchOutputsFormPlugin = (0, import_editor33.defineFormPluginCreator)({
|
|
3610
3693
|
name: "batch-outputs-plugin",
|
|
3611
3694
|
onSetupFormMeta({ mergeEffect }, { outputKey }) {
|
|
3612
3695
|
mergeEffect({
|
|
@@ -3614,7 +3697,7 @@ var createBatchOutputsFormPlugin = (0, import_editor21.defineFormPluginCreator)(
|
|
|
3614
3697
|
});
|
|
3615
3698
|
},
|
|
3616
3699
|
onInit(ctx, { outputKey }) {
|
|
3617
|
-
const chainTransformService = ctx.node.getService(
|
|
3700
|
+
const chainTransformService = ctx.node.getService(import_editor33.ScopeChainTransformService);
|
|
3618
3701
|
const batchNodeType = ctx.node.flowNodeType;
|
|
3619
3702
|
const transformerId = `${batchNodeType}-outputs`;
|
|
3620
3703
|
if (chainTransformService.hasTransformer(transformerId)) {
|
|
@@ -3624,21 +3707,21 @@ var createBatchOutputsFormPlugin = (0, import_editor21.defineFormPluginCreator)(
|
|
|
3624
3707
|
transformCovers: (covers, ctx2) => {
|
|
3625
3708
|
const node = ctx2.scope.meta?.node;
|
|
3626
3709
|
if (node?.parent?.flowNodeType === batchNodeType) {
|
|
3627
|
-
return [...covers, (0,
|
|
3710
|
+
return [...covers, (0, import_editor33.getNodeScope)(node.parent)];
|
|
3628
3711
|
}
|
|
3629
3712
|
return covers;
|
|
3630
3713
|
},
|
|
3631
3714
|
transformDeps(scopes, ctx2) {
|
|
3632
3715
|
const scopeMeta = ctx2.scope.meta;
|
|
3633
|
-
if (scopeMeta?.type ===
|
|
3716
|
+
if (scopeMeta?.type === import_editor33.FlowNodeScopeType.private) {
|
|
3634
3717
|
return scopes;
|
|
3635
3718
|
}
|
|
3636
3719
|
const node = scopeMeta?.node;
|
|
3637
3720
|
if (node?.flowNodeType === batchNodeType) {
|
|
3638
3721
|
const childBlocks = node.blocks;
|
|
3639
3722
|
return [
|
|
3640
|
-
(0,
|
|
3641
|
-
...childBlocks.map((_childBlock) => (0,
|
|
3723
|
+
(0, import_editor33.getNodePrivateScope)(node),
|
|
3724
|
+
...childBlocks.map((_childBlock) => (0, import_editor33.getNodeScope)(_childBlock))
|
|
3642
3725
|
];
|
|
3643
3726
|
}
|
|
3644
3727
|
return scopes;
|
|
@@ -3649,9 +3732,9 @@ var createBatchOutputsFormPlugin = (0, import_editor21.defineFormPluginCreator)(
|
|
|
3649
3732
|
|
|
3650
3733
|
// src/form-plugins/infer-inputs-plugin/index.ts
|
|
3651
3734
|
var import_lodash9 = require("lodash");
|
|
3652
|
-
var
|
|
3653
|
-
var
|
|
3654
|
-
var createInferInputsPlugin = (0,
|
|
3735
|
+
var import_json_schema11 = require("@flowgram.ai/json-schema");
|
|
3736
|
+
var import_editor34 = require("@flowgram.ai/editor");
|
|
3737
|
+
var createInferInputsPlugin = (0, import_editor34.defineFormPluginCreator)({
|
|
3655
3738
|
onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
|
|
3656
3739
|
if (!sourceKey || !targetKey) {
|
|
3657
3740
|
return;
|
|
@@ -3662,7 +3745,7 @@ var createInferInputsPlugin = (0, import_editor22.defineFormPluginCreator)({
|
|
|
3662
3745
|
targetKey,
|
|
3663
3746
|
infer(
|
|
3664
3747
|
(0, import_lodash9.get)(formData, sourceKey),
|
|
3665
|
-
scope === "private" ? (0,
|
|
3748
|
+
scope === "private" ? (0, import_editor34.getNodePrivateScope)(ctx.node) : (0, import_editor34.getNodeScope)(ctx.node)
|
|
3666
3749
|
)
|
|
3667
3750
|
);
|
|
3668
3751
|
return formData;
|
|
@@ -3702,7 +3785,7 @@ var infer = (values, scope) => {
|
|
|
3702
3785
|
}
|
|
3703
3786
|
if (isRef2(values)) {
|
|
3704
3787
|
const variable = scope.available.getByKeyPath(values?.content);
|
|
3705
|
-
const schema = variable?.type ?
|
|
3788
|
+
const schema = variable?.type ? import_json_schema11.JsonSchemaUtils.astToSchema(variable?.type) : void 0;
|
|
3706
3789
|
return schema;
|
|
3707
3790
|
}
|
|
3708
3791
|
if (isTemplate2(values)) {
|
|
@@ -3725,33 +3808,33 @@ var infer = (values, scope) => {
|
|
|
3725
3808
|
|
|
3726
3809
|
// src/form-plugins/infer-assign-plugin/index.ts
|
|
3727
3810
|
var import_lodash10 = require("lodash");
|
|
3728
|
-
var
|
|
3729
|
-
var
|
|
3730
|
-
var createInferAssignPlugin = (0,
|
|
3811
|
+
var import_json_schema12 = require("@flowgram.ai/json-schema");
|
|
3812
|
+
var import_editor35 = require("@flowgram.ai/editor");
|
|
3813
|
+
var createInferAssignPlugin = (0, import_editor35.defineFormPluginCreator)({
|
|
3731
3814
|
onSetupFormMeta({ addFormatOnSubmit, mergeEffect }, { assignKey, outputKey }) {
|
|
3732
3815
|
if (!assignKey || !outputKey) {
|
|
3733
3816
|
return;
|
|
3734
3817
|
}
|
|
3735
3818
|
mergeEffect({
|
|
3736
|
-
[assignKey]: (0,
|
|
3819
|
+
[assignKey]: (0, import_editor35.createEffectFromVariableProvider)({
|
|
3737
3820
|
parse: (value, ctx) => {
|
|
3738
3821
|
const declareRows = (0, import_lodash10.uniqBy)(
|
|
3739
3822
|
value.filter((_v) => _v.operator === "declare" && _v.left && _v.right),
|
|
3740
3823
|
"left"
|
|
3741
3824
|
);
|
|
3742
3825
|
return [
|
|
3743
|
-
|
|
3826
|
+
import_editor35.ASTFactory.createVariableDeclaration({
|
|
3744
3827
|
key: `${ctx.node.id}`,
|
|
3745
3828
|
meta: {
|
|
3746
|
-
title: (0,
|
|
3829
|
+
title: (0, import_editor35.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3747
3830
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3748
3831
|
},
|
|
3749
|
-
type:
|
|
3832
|
+
type: import_editor35.ASTFactory.createObject({
|
|
3750
3833
|
properties: declareRows.map(
|
|
3751
|
-
(_v) =>
|
|
3834
|
+
(_v) => import_editor35.ASTFactory.createProperty({
|
|
3752
3835
|
key: _v.left,
|
|
3753
|
-
type: _v.right?.type === "constant" ?
|
|
3754
|
-
initializer: _v.right?.type === "ref" ?
|
|
3836
|
+
type: _v.right?.type === "constant" ? import_json_schema12.JsonSchemaUtils.schemaToAST(_v.right?.schema || {}) : void 0,
|
|
3837
|
+
initializer: _v.right?.type === "ref" ? import_editor35.ASTFactory.createKeyPathExpression({
|
|
3755
3838
|
keyPath: _v.right?.content || []
|
|
3756
3839
|
}) : {}
|
|
3757
3840
|
})
|
|
@@ -3766,7 +3849,7 @@ var createInferAssignPlugin = (0, import_editor23.defineFormPluginCreator)({
|
|
|
3766
3849
|
(0, import_lodash10.set)(
|
|
3767
3850
|
formData,
|
|
3768
3851
|
outputKey,
|
|
3769
|
-
|
|
3852
|
+
import_json_schema12.JsonSchemaUtils.astToSchema((0, import_editor35.getNodeScope)(ctx.node).output.variables?.[0]?.type)
|
|
3770
3853
|
);
|
|
3771
3854
|
return formData;
|
|
3772
3855
|
});
|
|
@@ -3775,7 +3858,7 @@ var createInferAssignPlugin = (0, import_editor23.defineFormPluginCreator)({
|
|
|
3775
3858
|
|
|
3776
3859
|
// src/validate/validate-flow-value/index.tsx
|
|
3777
3860
|
var import_lodash11 = require("lodash");
|
|
3778
|
-
var
|
|
3861
|
+
var import_editor36 = require("@flowgram.ai/editor");
|
|
3779
3862
|
function validateFlowValue(value, ctx) {
|
|
3780
3863
|
const { node, required, errorMessages } = ctx;
|
|
3781
3864
|
const {
|
|
@@ -3784,15 +3867,15 @@ function validateFlowValue(value, ctx) {
|
|
|
3784
3867
|
} = errorMessages || {};
|
|
3785
3868
|
if (required && ((0, import_lodash11.isNil)(value) || (0, import_lodash11.isNil)(value?.content) || value?.content === "")) {
|
|
3786
3869
|
return {
|
|
3787
|
-
level:
|
|
3870
|
+
level: import_editor36.FeedbackLevel.Error,
|
|
3788
3871
|
message: requiredMessage
|
|
3789
3872
|
};
|
|
3790
3873
|
}
|
|
3791
3874
|
if (value?.type === "ref") {
|
|
3792
|
-
const variable = (0,
|
|
3875
|
+
const variable = (0, import_editor36.getNodeScope)(node).available.getByKeyPath(value?.content || []);
|
|
3793
3876
|
if (!variable) {
|
|
3794
3877
|
return {
|
|
3795
|
-
level:
|
|
3878
|
+
level: import_editor36.FeedbackLevel.Error,
|
|
3796
3879
|
message: unknownVariableMessage
|
|
3797
3880
|
};
|
|
3798
3881
|
}
|
|
@@ -3800,10 +3883,10 @@ function validateFlowValue(value, ctx) {
|
|
|
3800
3883
|
if (value?.type === "template") {
|
|
3801
3884
|
const allRefs = getTemplateKeyPaths2(value);
|
|
3802
3885
|
for (const ref of allRefs) {
|
|
3803
|
-
const variable = (0,
|
|
3886
|
+
const variable = (0, import_editor36.getNodeScope)(node).available.getByKeyPath(ref);
|
|
3804
3887
|
if (!variable) {
|
|
3805
3888
|
return {
|
|
3806
|
-
level:
|
|
3889
|
+
level: import_editor36.FeedbackLevel.Error,
|
|
3807
3890
|
message: unknownVariableMessage
|
|
3808
3891
|
};
|
|
3809
3892
|
}
|
|
@@ -3856,6 +3939,8 @@ function getTemplateKeyPaths2(value) {
|
|
|
3856
3939
|
getTypeSelectValue,
|
|
3857
3940
|
isLegacyFlowRefValueSchema,
|
|
3858
3941
|
isNewFlowRefValueSchema,
|
|
3942
|
+
listenRefSchemaChange,
|
|
3943
|
+
listenRefValueChange,
|
|
3859
3944
|
parseTypeSelectValue,
|
|
3860
3945
|
provideBatchInputEffect,
|
|
3861
3946
|
provideBatchOutputsEffect,
|