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