@flowgram.ai/form-materials 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/materials.ts +1 -0
- package/dist/esm/index.js +331 -13
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +125 -6
- package/dist/index.d.ts +125 -6
- package/dist/index.js +360 -51
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/assign-row/components/blur-input.tsx +27 -0
- package/src/components/assign-row/config.json +11 -0
- package/src/components/assign-row/index.tsx +84 -0
- package/src/components/assign-row/types.ts +25 -0
- package/src/components/assign-rows/config.json +11 -0
- package/src/components/assign-rows/index.tsx +59 -0
- package/src/components/constant-input/config.json +1 -1
- package/src/components/display-outputs/index.tsx +7 -1
- package/src/components/display-schema-tree/config.json +1 -1
- package/src/components/index.ts +2 -0
- package/src/components/variable-selector/index.tsx +1 -1
- package/src/effects/index.ts +3 -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/effects/validate-when-variable-sync/config.json +5 -0
- package/src/effects/validate-when-variable-sync/index.ts +35 -0
- package/src/form-plugins/index.ts +1 -0
- package/src/form-plugins/infer-assign-plugin/config.json +7 -0
- package/src/form-plugins/infer-assign-plugin/index.ts +90 -0
- package/src/index.ts +1 -0
- package/src/plugins/json-schema-preset/create-type-preset-plugin.tsx +1 -1
- package/src/plugins/json-schema-preset/index.tsx +2 -0
- package/src/plugins/json-schema-preset/type-definition/array.tsx +2 -1
- package/src/plugins/json-schema-preset/type-definition/object.tsx +2 -1
- package/src/validate/index.tsx +6 -0
- package/src/validate/validate-flow-value/config.json +7 -0
- package/src/validate/validate-flow-value/index.tsx +73 -0
package/dist/index.js
CHANGED
|
@@ -30,6 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
+
AssignRow: () => AssignRow,
|
|
34
|
+
AssignRows: () => AssignRows,
|
|
33
35
|
BatchOutputs: () => BatchOutputs,
|
|
34
36
|
BatchVariableSelector: () => BatchVariableSelector,
|
|
35
37
|
CodeEditor: () => CodeEditor,
|
|
@@ -55,6 +57,7 @@ __export(src_exports, {
|
|
|
55
57
|
autoRenameRefEffect: () => autoRenameRefEffect,
|
|
56
58
|
createBatchOutputsFormPlugin: () => createBatchOutputsFormPlugin,
|
|
57
59
|
createDisableDeclarationPlugin: () => createDisableDeclarationPlugin,
|
|
60
|
+
createInferAssignPlugin: () => createInferAssignPlugin,
|
|
58
61
|
createInferInputsPlugin: () => createInferInputsPlugin,
|
|
59
62
|
createTypePresetPlugin: () => createTypePresetPlugin,
|
|
60
63
|
formatLegacyRefOnInit: () => formatLegacyRefOnInit,
|
|
@@ -64,13 +67,17 @@ __export(src_exports, {
|
|
|
64
67
|
getTypeSelectValue: () => getTypeSelectValue,
|
|
65
68
|
isLegacyFlowRefValueSchema: () => isLegacyFlowRefValueSchema,
|
|
66
69
|
isNewFlowRefValueSchema: () => isNewFlowRefValueSchema,
|
|
70
|
+
listenRefSchemaChange: () => listenRefSchemaChange,
|
|
71
|
+
listenRefValueChange: () => listenRefValueChange,
|
|
67
72
|
parseTypeSelectValue: () => parseTypeSelectValue,
|
|
68
73
|
provideBatchInputEffect: () => provideBatchInputEffect,
|
|
69
74
|
provideBatchOutputsEffect: () => provideBatchOutputsEffect,
|
|
70
75
|
provideJsonSchemaOutputs: () => provideJsonSchemaOutputs,
|
|
71
76
|
syncVariableTitle: () => syncVariableTitle,
|
|
72
77
|
useTypeManager: () => useTypeManager,
|
|
73
|
-
useVariableTree: () => useVariableTree
|
|
78
|
+
useVariableTree: () => useVariableTree,
|
|
79
|
+
validateFlowValue: () => validateFlowValue,
|
|
80
|
+
validateWhenVariableSync: () => validateWhenVariableSync
|
|
74
81
|
});
|
|
75
82
|
module.exports = __toCommonJS(src_exports);
|
|
76
83
|
|
|
@@ -800,7 +807,7 @@ var VariableSelector = ({
|
|
|
800
807
|
showClear: false,
|
|
801
808
|
arrowIcon: /* @__PURE__ */ import_react12.default.createElement(import_semi_icons.IconChevronDownStroked, { size: "small" }),
|
|
802
809
|
triggerRender,
|
|
803
|
-
placeholder: config?.placeholder ?? "Select Variable
|
|
810
|
+
placeholder: config?.placeholder ?? "Select Variable"
|
|
804
811
|
}
|
|
805
812
|
));
|
|
806
813
|
};
|
|
@@ -3146,7 +3153,16 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
|
3146
3153
|
return acm;
|
|
3147
3154
|
}, {}) : value?.properties || {};
|
|
3148
3155
|
const childEntries = Object.entries(properties || {});
|
|
3149
|
-
return /* @__PURE__ */ import_react54.default.createElement(DisplayOutputsWrapper, null, childEntries.map(([key, schema]) => /* @__PURE__ */ import_react54.default.createElement(
|
|
3156
|
+
return /* @__PURE__ */ import_react54.default.createElement(DisplayOutputsWrapper, null, childEntries.map(([key, schema]) => /* @__PURE__ */ import_react54.default.createElement(
|
|
3157
|
+
DisplaySchemaTag,
|
|
3158
|
+
{
|
|
3159
|
+
key,
|
|
3160
|
+
title: key,
|
|
3161
|
+
value: schema,
|
|
3162
|
+
showIconInTree,
|
|
3163
|
+
warning: !schema
|
|
3164
|
+
}
|
|
3165
|
+
)));
|
|
3150
3166
|
}
|
|
3151
3167
|
|
|
3152
3168
|
// src/components/display-flow-value/index.tsx
|
|
@@ -3207,30 +3223,151 @@ function DisplayInputsValues({ value, showIconInTree }) {
|
|
|
3207
3223
|
return /* @__PURE__ */ import_react56.default.createElement(DisplayInputsWrapper, null, childEntries.map(([key, value2]) => /* @__PURE__ */ import_react56.default.createElement(DisplayFlowValue, { key, title: key, value: value2, showIconInTree })));
|
|
3208
3224
|
}
|
|
3209
3225
|
|
|
3210
|
-
// src/
|
|
3226
|
+
// src/components/assign-rows/index.tsx
|
|
3227
|
+
var import_react59 = __toESM(require("react"));
|
|
3211
3228
|
var import_editor15 = require("@flowgram.ai/editor");
|
|
3212
|
-
var
|
|
3229
|
+
var import_semi_ui28 = require("@douyinfe/semi-ui");
|
|
3230
|
+
var import_semi_icons12 = require("@douyinfe/semi-icons");
|
|
3231
|
+
|
|
3232
|
+
// src/components/assign-row/index.tsx
|
|
3233
|
+
var import_react58 = __toESM(require("react"));
|
|
3234
|
+
var import_semi_ui27 = require("@douyinfe/semi-ui");
|
|
3235
|
+
var import_semi_icons11 = require("@douyinfe/semi-icons");
|
|
3236
|
+
|
|
3237
|
+
// src/components/assign-row/components/blur-input.tsx
|
|
3238
|
+
var import_react57 = __toESM(require("react"));
|
|
3239
|
+
var import_input3 = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
|
|
3240
|
+
function BlurInput3(props) {
|
|
3241
|
+
const [value, setValue] = (0, import_react57.useState)("");
|
|
3242
|
+
(0, import_react57.useEffect)(() => {
|
|
3243
|
+
setValue(props.value);
|
|
3244
|
+
}, [props.value]);
|
|
3245
|
+
return /* @__PURE__ */ import_react57.default.createElement(
|
|
3246
|
+
import_input3.default,
|
|
3247
|
+
{
|
|
3248
|
+
...props,
|
|
3249
|
+
value,
|
|
3250
|
+
onChange: (value2) => {
|
|
3251
|
+
setValue(value2);
|
|
3252
|
+
},
|
|
3253
|
+
onBlur: (e) => props.onChange?.(value, e)
|
|
3254
|
+
}
|
|
3255
|
+
);
|
|
3256
|
+
}
|
|
3257
|
+
|
|
3258
|
+
// src/components/assign-row/index.tsx
|
|
3259
|
+
function AssignRow(props) {
|
|
3260
|
+
const {
|
|
3261
|
+
value = {
|
|
3262
|
+
operator: "assign"
|
|
3263
|
+
},
|
|
3264
|
+
onChange,
|
|
3265
|
+
onDelete,
|
|
3266
|
+
readonly
|
|
3267
|
+
} = props;
|
|
3268
|
+
return /* @__PURE__ */ import_react58.default.createElement("div", { style: { display: "flex", alignItems: "center", gap: 5 } }, /* @__PURE__ */ import_react58.default.createElement("div", { style: { width: 150, minWidth: 150, maxWidth: 150 } }, value?.operator === "assign" ? /* @__PURE__ */ import_react58.default.createElement(
|
|
3269
|
+
VariableSelector,
|
|
3270
|
+
{
|
|
3271
|
+
style: { width: "100%", height: 26 },
|
|
3272
|
+
value: value?.left?.content,
|
|
3273
|
+
config: { placeholder: "Select Left" },
|
|
3274
|
+
onChange: (v) => onChange?.({
|
|
3275
|
+
...value,
|
|
3276
|
+
left: { type: "ref", content: v }
|
|
3277
|
+
})
|
|
3278
|
+
}
|
|
3279
|
+
) : /* @__PURE__ */ import_react58.default.createElement(
|
|
3280
|
+
BlurInput3,
|
|
3281
|
+
{
|
|
3282
|
+
style: { height: 26 },
|
|
3283
|
+
size: "small",
|
|
3284
|
+
placeholder: "Input Name",
|
|
3285
|
+
value: value?.left,
|
|
3286
|
+
onChange: (v) => onChange?.({
|
|
3287
|
+
...value,
|
|
3288
|
+
left: v
|
|
3289
|
+
})
|
|
3290
|
+
}
|
|
3291
|
+
)), /* @__PURE__ */ import_react58.default.createElement("div", { style: { flexGrow: 1 } }, /* @__PURE__ */ import_react58.default.createElement(
|
|
3292
|
+
DynamicValueInput,
|
|
3293
|
+
{
|
|
3294
|
+
readonly,
|
|
3295
|
+
value: value?.right,
|
|
3296
|
+
onChange: (v) => onChange?.({
|
|
3297
|
+
...value,
|
|
3298
|
+
right: v
|
|
3299
|
+
})
|
|
3300
|
+
}
|
|
3301
|
+
)), onDelete && /* @__PURE__ */ import_react58.default.createElement("div", null, /* @__PURE__ */ import_react58.default.createElement(
|
|
3302
|
+
import_semi_ui27.IconButton,
|
|
3303
|
+
{
|
|
3304
|
+
size: "small",
|
|
3305
|
+
theme: "borderless",
|
|
3306
|
+
icon: /* @__PURE__ */ import_react58.default.createElement(import_semi_icons11.IconMinus, null),
|
|
3307
|
+
onClick: () => onDelete?.()
|
|
3308
|
+
}
|
|
3309
|
+
)));
|
|
3310
|
+
}
|
|
3311
|
+
|
|
3312
|
+
// src/components/assign-rows/index.tsx
|
|
3313
|
+
function AssignRows(props) {
|
|
3314
|
+
const { name, readonly } = props;
|
|
3315
|
+
return /* @__PURE__ */ import_react59.default.createElement(import_editor15.FieldArray, { name }, ({ field }) => /* @__PURE__ */ import_react59.default.createElement(import_react59.default.Fragment, null, field.map((childField, index) => /* @__PURE__ */ import_react59.default.createElement(
|
|
3316
|
+
AssignRow,
|
|
3317
|
+
{
|
|
3318
|
+
key: childField.key,
|
|
3319
|
+
readonly,
|
|
3320
|
+
value: childField.value,
|
|
3321
|
+
onChange: (value) => {
|
|
3322
|
+
childField.onChange(value);
|
|
3323
|
+
},
|
|
3324
|
+
onDelete: () => field.remove(index)
|
|
3325
|
+
}
|
|
3326
|
+
)), /* @__PURE__ */ import_react59.default.createElement("div", { style: { display: "flex", gap: 5 } }, /* @__PURE__ */ import_react59.default.createElement(
|
|
3327
|
+
import_semi_ui28.Button,
|
|
3328
|
+
{
|
|
3329
|
+
size: "small",
|
|
3330
|
+
theme: "borderless",
|
|
3331
|
+
icon: /* @__PURE__ */ import_react59.default.createElement(import_semi_icons12.IconPlus, null),
|
|
3332
|
+
onClick: () => field.append({ operator: "assign" })
|
|
3333
|
+
},
|
|
3334
|
+
"Assign"
|
|
3335
|
+
), /* @__PURE__ */ import_react59.default.createElement(
|
|
3336
|
+
import_semi_ui28.Button,
|
|
3337
|
+
{
|
|
3338
|
+
size: "small",
|
|
3339
|
+
theme: "borderless",
|
|
3340
|
+
icon: /* @__PURE__ */ import_react59.default.createElement(import_semi_icons12.IconPlus, null),
|
|
3341
|
+
onClick: () => field.append({ operator: "declare" })
|
|
3342
|
+
},
|
|
3343
|
+
"Declaration"
|
|
3344
|
+
))));
|
|
3345
|
+
}
|
|
3346
|
+
|
|
3347
|
+
// src/effects/provide-batch-input/index.ts
|
|
3348
|
+
var import_editor16 = require("@flowgram.ai/editor");
|
|
3349
|
+
var provideBatchInputEffect = (0, import_editor16.createEffectFromVariableProvider)({
|
|
3213
3350
|
private: true,
|
|
3214
3351
|
parse: (value, ctx) => [
|
|
3215
|
-
|
|
3352
|
+
import_editor16.ASTFactory.createVariableDeclaration({
|
|
3216
3353
|
key: `${ctx.node.id}_locals`,
|
|
3217
3354
|
meta: {
|
|
3218
|
-
title: (0,
|
|
3355
|
+
title: (0, import_editor16.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3219
3356
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3220
3357
|
},
|
|
3221
|
-
type:
|
|
3358
|
+
type: import_editor16.ASTFactory.createObject({
|
|
3222
3359
|
properties: [
|
|
3223
|
-
|
|
3360
|
+
import_editor16.ASTFactory.createProperty({
|
|
3224
3361
|
key: "item",
|
|
3225
|
-
initializer:
|
|
3226
|
-
enumerateFor:
|
|
3362
|
+
initializer: import_editor16.ASTFactory.createEnumerateExpression({
|
|
3363
|
+
enumerateFor: import_editor16.ASTFactory.createKeyPathExpression({
|
|
3227
3364
|
keyPath: value.content || []
|
|
3228
3365
|
})
|
|
3229
3366
|
})
|
|
3230
3367
|
}),
|
|
3231
|
-
|
|
3368
|
+
import_editor16.ASTFactory.createProperty({
|
|
3232
3369
|
key: "index",
|
|
3233
|
-
type:
|
|
3370
|
+
type: import_editor16.ASTFactory.createNumber()
|
|
3234
3371
|
})
|
|
3235
3372
|
]
|
|
3236
3373
|
})
|
|
@@ -3240,13 +3377,13 @@ var provideBatchInputEffect = (0, import_editor15.createEffectFromVariableProvid
|
|
|
3240
3377
|
|
|
3241
3378
|
// src/effects/auto-rename-ref/index.ts
|
|
3242
3379
|
var import_lodash6 = require("lodash");
|
|
3243
|
-
var
|
|
3380
|
+
var import_editor17 = require("@flowgram.ai/editor");
|
|
3244
3381
|
var autoRenameRefEffect = [
|
|
3245
3382
|
{
|
|
3246
|
-
event:
|
|
3383
|
+
event: import_editor17.DataEvent.onValueInit,
|
|
3247
3384
|
effect: (params) => {
|
|
3248
3385
|
const { context, form, name } = params;
|
|
3249
|
-
const renameService = context.node.getService(
|
|
3386
|
+
const renameService = context.node.getService(import_editor17.VariableFieldKeyRenameService);
|
|
3250
3387
|
const disposable = renameService.onRename(({ before, after }) => {
|
|
3251
3388
|
const beforeKeyPath = [
|
|
3252
3389
|
...before.parentFields.map((_field) => _field.key).reverse(),
|
|
@@ -3331,13 +3468,13 @@ function traverseRef(name, value, cb) {
|
|
|
3331
3468
|
|
|
3332
3469
|
// src/effects/provide-json-schema-outputs/index.ts
|
|
3333
3470
|
var import_json_schema9 = require("@flowgram.ai/json-schema");
|
|
3334
|
-
var
|
|
3335
|
-
var provideJsonSchemaOutputs = (0,
|
|
3471
|
+
var import_editor18 = require("@flowgram.ai/editor");
|
|
3472
|
+
var provideJsonSchemaOutputs = (0, import_editor18.createEffectFromVariableProvider)({
|
|
3336
3473
|
parse: (value, ctx) => [
|
|
3337
|
-
|
|
3474
|
+
import_editor18.ASTFactory.createVariableDeclaration({
|
|
3338
3475
|
key: `${ctx.node.id}`,
|
|
3339
3476
|
meta: {
|
|
3340
|
-
title: (0,
|
|
3477
|
+
title: (0, import_editor18.getNodeForm)(ctx.node)?.getValueIn("title") || ctx.node.id,
|
|
3341
3478
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3342
3479
|
},
|
|
3343
3480
|
type: import_json_schema9.JsonSchemaUtils.schemaToAST(value)
|
|
@@ -3346,12 +3483,12 @@ var provideJsonSchemaOutputs = (0, import_editor17.createEffectFromVariableProvi
|
|
|
3346
3483
|
});
|
|
3347
3484
|
|
|
3348
3485
|
// src/effects/sync-variable-title/index.ts
|
|
3349
|
-
var
|
|
3486
|
+
var import_editor19 = require("@flowgram.ai/editor");
|
|
3350
3487
|
var syncVariableTitle = [
|
|
3351
3488
|
{
|
|
3352
|
-
event:
|
|
3489
|
+
event: import_editor19.DataEvent.onValueChange,
|
|
3353
3490
|
effect: ({ value, context }) => {
|
|
3354
|
-
context.node.getData(
|
|
3491
|
+
context.node.getData(import_editor19.FlowNodeVariableData).allScopes.forEach((_scope) => {
|
|
3355
3492
|
_scope.output.variables.forEach((_var) => {
|
|
3356
3493
|
_var.updateMeta({
|
|
3357
3494
|
..._var.meta || {},
|
|
@@ -3364,10 +3501,80 @@ var syncVariableTitle = [
|
|
|
3364
3501
|
}
|
|
3365
3502
|
];
|
|
3366
3503
|
|
|
3367
|
-
// src/
|
|
3504
|
+
// src/effects/validate-when-variable-sync/index.ts
|
|
3368
3505
|
var import_lodash7 = require("lodash");
|
|
3506
|
+
var import_editor20 = require("@flowgram.ai/editor");
|
|
3507
|
+
var validateWhenVariableSync = ({
|
|
3508
|
+
scope
|
|
3509
|
+
} = {}) => [
|
|
3510
|
+
{
|
|
3511
|
+
event: import_editor20.DataEvent.onValueInit,
|
|
3512
|
+
effect: ({ context, form }) => {
|
|
3513
|
+
const nodeScope = scope === "private" ? (0, import_editor20.getNodePrivateScope)(context.node) : (0, import_editor20.getNodeScope)(context.node);
|
|
3514
|
+
const disposable = nodeScope.available.onListOrAnyVarChange(() => {
|
|
3515
|
+
if (!(0, import_lodash7.isEmpty)(form.state.errors)) {
|
|
3516
|
+
form.validate();
|
|
3517
|
+
}
|
|
3518
|
+
});
|
|
3519
|
+
return () => disposable.dispose();
|
|
3520
|
+
}
|
|
3521
|
+
}
|
|
3522
|
+
];
|
|
3523
|
+
|
|
3524
|
+
// src/effects/listen-ref-value-change/index.ts
|
|
3525
|
+
var import_editor21 = require("@flowgram.ai/editor");
|
|
3526
|
+
var listenRefValueChange = (cb) => [
|
|
3527
|
+
{
|
|
3528
|
+
event: import_editor21.DataEvent.onValueInitOrChange,
|
|
3529
|
+
effect: (params) => {
|
|
3530
|
+
const { context, value } = params;
|
|
3531
|
+
if (value?.type !== "ref") {
|
|
3532
|
+
return () => null;
|
|
3533
|
+
}
|
|
3534
|
+
const disposable = (0, import_editor21.getNodeScope)(context.node).available.trackByKeyPath(
|
|
3535
|
+
value?.content || [],
|
|
3536
|
+
(v) => {
|
|
3537
|
+
cb({ ...params, variable: v });
|
|
3538
|
+
}
|
|
3539
|
+
);
|
|
3540
|
+
return () => {
|
|
3541
|
+
disposable.dispose();
|
|
3542
|
+
};
|
|
3543
|
+
}
|
|
3544
|
+
}
|
|
3545
|
+
];
|
|
3546
|
+
|
|
3547
|
+
// src/effects/listen-ref-schema-change/index.ts
|
|
3548
|
+
var import_json_schema10 = require("@flowgram.ai/json-schema");
|
|
3549
|
+
var import_editor22 = require("@flowgram.ai/editor");
|
|
3550
|
+
var listenRefSchemaChange = (cb) => [
|
|
3551
|
+
{
|
|
3552
|
+
event: import_editor22.DataEvent.onValueInitOrChange,
|
|
3553
|
+
effect: (params) => {
|
|
3554
|
+
const { context, value } = params;
|
|
3555
|
+
if (value?.type !== "ref") {
|
|
3556
|
+
return () => null;
|
|
3557
|
+
}
|
|
3558
|
+
const disposable = (0, import_editor22.getNodeScope)(context.node).available.trackByKeyPath(
|
|
3559
|
+
value?.content || [],
|
|
3560
|
+
(_type) => {
|
|
3561
|
+
cb({ ...params, schema: import_json_schema10.JsonSchemaUtils.astToSchema(_type) });
|
|
3562
|
+
},
|
|
3563
|
+
{
|
|
3564
|
+
selector: (_v) => _v?.type
|
|
3565
|
+
}
|
|
3566
|
+
);
|
|
3567
|
+
return () => {
|
|
3568
|
+
disposable.dispose();
|
|
3569
|
+
};
|
|
3570
|
+
}
|
|
3571
|
+
}
|
|
3572
|
+
];
|
|
3573
|
+
|
|
3574
|
+
// src/shared/format-legacy-refs/index.ts
|
|
3575
|
+
var import_lodash8 = require("lodash");
|
|
3369
3576
|
function formatLegacyRefOnSubmit(value) {
|
|
3370
|
-
if ((0,
|
|
3577
|
+
if ((0, import_lodash8.isObject)(value)) {
|
|
3371
3578
|
if (isLegacyFlowRefValueSchema(value)) {
|
|
3372
3579
|
return formatLegacyRefToNewRef(value);
|
|
3373
3580
|
}
|
|
@@ -3384,7 +3591,7 @@ function formatLegacyRefOnSubmit(value) {
|
|
|
3384
3591
|
return value;
|
|
3385
3592
|
}
|
|
3386
3593
|
function formatLegacyRefOnInit(value) {
|
|
3387
|
-
if ((0,
|
|
3594
|
+
if ((0, import_lodash8.isObject)(value)) {
|
|
3388
3595
|
if (isNewFlowRefValueSchema(value)) {
|
|
3389
3596
|
return formatNewRefToLegacyRef(value);
|
|
3390
3597
|
}
|
|
@@ -3401,10 +3608,10 @@ function formatLegacyRefOnInit(value) {
|
|
|
3401
3608
|
return value;
|
|
3402
3609
|
}
|
|
3403
3610
|
function isLegacyFlowRefValueSchema(value) {
|
|
3404
|
-
return (0,
|
|
3611
|
+
return (0, import_lodash8.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
3405
3612
|
}
|
|
3406
3613
|
function isNewFlowRefValueSchema(value) {
|
|
3407
|
-
return (0,
|
|
3614
|
+
return (0, import_lodash8.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
3408
3615
|
}
|
|
3409
3616
|
function formatLegacyRefToNewRef(value) {
|
|
3410
3617
|
const keyPath = value.content.split(".");
|
|
@@ -3427,21 +3634,21 @@ function formatNewRefToLegacyRef(value) {
|
|
|
3427
3634
|
}
|
|
3428
3635
|
|
|
3429
3636
|
// src/form-plugins/batch-outputs-plugin/index.ts
|
|
3430
|
-
var
|
|
3431
|
-
var provideBatchOutputsEffect = (0,
|
|
3637
|
+
var import_editor23 = require("@flowgram.ai/editor");
|
|
3638
|
+
var provideBatchOutputsEffect = (0, import_editor23.createEffectFromVariableProvider)({
|
|
3432
3639
|
parse: (value, ctx) => [
|
|
3433
|
-
|
|
3640
|
+
import_editor23.ASTFactory.createVariableDeclaration({
|
|
3434
3641
|
key: `${ctx.node.id}`,
|
|
3435
3642
|
meta: {
|
|
3436
|
-
title: (0,
|
|
3643
|
+
title: (0, import_editor23.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3437
3644
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3438
3645
|
},
|
|
3439
|
-
type:
|
|
3646
|
+
type: import_editor23.ASTFactory.createObject({
|
|
3440
3647
|
properties: Object.entries(value).map(
|
|
3441
|
-
([_key, value2]) =>
|
|
3648
|
+
([_key, value2]) => import_editor23.ASTFactory.createProperty({
|
|
3442
3649
|
key: _key,
|
|
3443
|
-
initializer:
|
|
3444
|
-
wrapFor:
|
|
3650
|
+
initializer: import_editor23.ASTFactory.createWrapArrayExpression({
|
|
3651
|
+
wrapFor: import_editor23.ASTFactory.createKeyPathExpression({
|
|
3445
3652
|
keyPath: value2?.content || []
|
|
3446
3653
|
})
|
|
3447
3654
|
})
|
|
@@ -3451,7 +3658,7 @@ var provideBatchOutputsEffect = (0, import_editor19.createEffectFromVariableProv
|
|
|
3451
3658
|
})
|
|
3452
3659
|
]
|
|
3453
3660
|
});
|
|
3454
|
-
var createBatchOutputsFormPlugin = (0,
|
|
3661
|
+
var createBatchOutputsFormPlugin = (0, import_editor23.defineFormPluginCreator)({
|
|
3455
3662
|
name: "batch-outputs-plugin",
|
|
3456
3663
|
onSetupFormMeta({ mergeEffect }, { outputKey }) {
|
|
3457
3664
|
mergeEffect({
|
|
@@ -3459,7 +3666,7 @@ var createBatchOutputsFormPlugin = (0, import_editor19.defineFormPluginCreator)(
|
|
|
3459
3666
|
});
|
|
3460
3667
|
},
|
|
3461
3668
|
onInit(ctx, { outputKey }) {
|
|
3462
|
-
const chainTransformService = ctx.node.getService(
|
|
3669
|
+
const chainTransformService = ctx.node.getService(import_editor23.ScopeChainTransformService);
|
|
3463
3670
|
const batchNodeType = ctx.node.flowNodeType;
|
|
3464
3671
|
const transformerId = `${batchNodeType}-outputs`;
|
|
3465
3672
|
if (chainTransformService.hasTransformer(transformerId)) {
|
|
@@ -3469,21 +3676,21 @@ var createBatchOutputsFormPlugin = (0, import_editor19.defineFormPluginCreator)(
|
|
|
3469
3676
|
transformCovers: (covers, ctx2) => {
|
|
3470
3677
|
const node = ctx2.scope.meta?.node;
|
|
3471
3678
|
if (node?.parent?.flowNodeType === batchNodeType) {
|
|
3472
|
-
return [...covers, (0,
|
|
3679
|
+
return [...covers, (0, import_editor23.getNodeScope)(node.parent)];
|
|
3473
3680
|
}
|
|
3474
3681
|
return covers;
|
|
3475
3682
|
},
|
|
3476
3683
|
transformDeps(scopes, ctx2) {
|
|
3477
3684
|
const scopeMeta = ctx2.scope.meta;
|
|
3478
|
-
if (scopeMeta?.type ===
|
|
3685
|
+
if (scopeMeta?.type === import_editor23.FlowNodeScopeType.private) {
|
|
3479
3686
|
return scopes;
|
|
3480
3687
|
}
|
|
3481
3688
|
const node = scopeMeta?.node;
|
|
3482
3689
|
if (node?.flowNodeType === batchNodeType) {
|
|
3483
3690
|
const childBlocks = node.blocks;
|
|
3484
3691
|
return [
|
|
3485
|
-
(0,
|
|
3486
|
-
...childBlocks.map((_childBlock) => (0,
|
|
3692
|
+
(0, import_editor23.getNodePrivateScope)(node),
|
|
3693
|
+
...childBlocks.map((_childBlock) => (0, import_editor23.getNodeScope)(_childBlock))
|
|
3487
3694
|
];
|
|
3488
3695
|
}
|
|
3489
3696
|
return scopes;
|
|
@@ -3493,21 +3700,21 @@ var createBatchOutputsFormPlugin = (0, import_editor19.defineFormPluginCreator)(
|
|
|
3493
3700
|
});
|
|
3494
3701
|
|
|
3495
3702
|
// src/form-plugins/infer-inputs-plugin/index.ts
|
|
3496
|
-
var
|
|
3497
|
-
var
|
|
3498
|
-
var
|
|
3499
|
-
var createInferInputsPlugin = (0,
|
|
3703
|
+
var import_lodash9 = require("lodash");
|
|
3704
|
+
var import_json_schema11 = require("@flowgram.ai/json-schema");
|
|
3705
|
+
var import_editor24 = require("@flowgram.ai/editor");
|
|
3706
|
+
var createInferInputsPlugin = (0, import_editor24.defineFormPluginCreator)({
|
|
3500
3707
|
onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
|
|
3501
3708
|
if (!sourceKey || !targetKey) {
|
|
3502
3709
|
return;
|
|
3503
3710
|
}
|
|
3504
3711
|
addFormatOnSubmit((formData, ctx) => {
|
|
3505
|
-
(0,
|
|
3712
|
+
(0, import_lodash9.set)(
|
|
3506
3713
|
formData,
|
|
3507
3714
|
targetKey,
|
|
3508
3715
|
infer(
|
|
3509
|
-
(0,
|
|
3510
|
-
scope === "private" ? (0,
|
|
3716
|
+
(0, import_lodash9.get)(formData, sourceKey),
|
|
3717
|
+
scope === "private" ? (0, import_editor24.getNodePrivateScope)(ctx.node) : (0, import_editor24.getNodeScope)(ctx.node)
|
|
3511
3718
|
)
|
|
3512
3719
|
);
|
|
3513
3720
|
return formData;
|
|
@@ -3547,7 +3754,7 @@ var infer = (values, scope) => {
|
|
|
3547
3754
|
}
|
|
3548
3755
|
if (isRef2(values)) {
|
|
3549
3756
|
const variable = scope.available.getByKeyPath(values?.content);
|
|
3550
|
-
const schema = variable?.type ?
|
|
3757
|
+
const schema = variable?.type ? import_json_schema11.JsonSchemaUtils.astToSchema(variable?.type) : void 0;
|
|
3551
3758
|
return schema;
|
|
3552
3759
|
}
|
|
3553
3760
|
if (isTemplate2(values)) {
|
|
@@ -3567,8 +3774,105 @@ var infer = (values, scope) => {
|
|
|
3567
3774
|
};
|
|
3568
3775
|
}
|
|
3569
3776
|
};
|
|
3777
|
+
|
|
3778
|
+
// src/form-plugins/infer-assign-plugin/index.ts
|
|
3779
|
+
var import_lodash10 = require("lodash");
|
|
3780
|
+
var import_json_schema12 = require("@flowgram.ai/json-schema");
|
|
3781
|
+
var import_editor25 = require("@flowgram.ai/editor");
|
|
3782
|
+
var createInferAssignPlugin = (0, import_editor25.defineFormPluginCreator)({
|
|
3783
|
+
onSetupFormMeta({ addFormatOnSubmit, mergeEffect }, { assignKey, outputKey }) {
|
|
3784
|
+
if (!assignKey || !outputKey) {
|
|
3785
|
+
return;
|
|
3786
|
+
}
|
|
3787
|
+
mergeEffect({
|
|
3788
|
+
[assignKey]: (0, import_editor25.createEffectFromVariableProvider)({
|
|
3789
|
+
parse: (value, ctx) => {
|
|
3790
|
+
const declareRows = (0, import_lodash10.uniqBy)(
|
|
3791
|
+
value.filter((_v) => _v.operator === "declare" && _v.left && _v.right),
|
|
3792
|
+
"left"
|
|
3793
|
+
);
|
|
3794
|
+
return [
|
|
3795
|
+
import_editor25.ASTFactory.createVariableDeclaration({
|
|
3796
|
+
key: `${ctx.node.id}`,
|
|
3797
|
+
meta: {
|
|
3798
|
+
title: (0, import_editor25.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3799
|
+
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3800
|
+
},
|
|
3801
|
+
type: import_editor25.ASTFactory.createObject({
|
|
3802
|
+
properties: declareRows.map(
|
|
3803
|
+
(_v) => import_editor25.ASTFactory.createProperty({
|
|
3804
|
+
key: _v.left,
|
|
3805
|
+
type: _v.right?.type === "constant" ? import_json_schema12.JsonSchemaUtils.schemaToAST(_v.right?.schema || {}) : void 0,
|
|
3806
|
+
initializer: _v.right?.type === "ref" ? import_editor25.ASTFactory.createKeyPathExpression({
|
|
3807
|
+
keyPath: _v.right?.content || []
|
|
3808
|
+
}) : {}
|
|
3809
|
+
})
|
|
3810
|
+
)
|
|
3811
|
+
})
|
|
3812
|
+
})
|
|
3813
|
+
];
|
|
3814
|
+
}
|
|
3815
|
+
})
|
|
3816
|
+
});
|
|
3817
|
+
addFormatOnSubmit((formData, ctx) => {
|
|
3818
|
+
(0, import_lodash10.set)(
|
|
3819
|
+
formData,
|
|
3820
|
+
outputKey,
|
|
3821
|
+
import_json_schema12.JsonSchemaUtils.astToSchema((0, import_editor25.getNodeScope)(ctx.node).output.variables?.[0]?.type)
|
|
3822
|
+
);
|
|
3823
|
+
return formData;
|
|
3824
|
+
});
|
|
3825
|
+
}
|
|
3826
|
+
});
|
|
3827
|
+
|
|
3828
|
+
// src/validate/validate-flow-value/index.tsx
|
|
3829
|
+
var import_lodash11 = require("lodash");
|
|
3830
|
+
var import_editor26 = require("@flowgram.ai/editor");
|
|
3831
|
+
function validateFlowValue(value, ctx) {
|
|
3832
|
+
const { node, required, errorMessages } = ctx;
|
|
3833
|
+
const {
|
|
3834
|
+
required: requiredMessage = "Field is required",
|
|
3835
|
+
unknownVariable: unknownVariableMessage = "Unknown Variable"
|
|
3836
|
+
} = errorMessages || {};
|
|
3837
|
+
if (required && ((0, import_lodash11.isNil)(value) || (0, import_lodash11.isNil)(value?.content) || value?.content === "")) {
|
|
3838
|
+
return {
|
|
3839
|
+
level: import_editor26.FeedbackLevel.Error,
|
|
3840
|
+
message: requiredMessage
|
|
3841
|
+
};
|
|
3842
|
+
}
|
|
3843
|
+
if (value?.type === "ref") {
|
|
3844
|
+
const variable = (0, import_editor26.getNodeScope)(node).available.getByKeyPath(value?.content || []);
|
|
3845
|
+
if (!variable) {
|
|
3846
|
+
return {
|
|
3847
|
+
level: import_editor26.FeedbackLevel.Error,
|
|
3848
|
+
message: unknownVariableMessage
|
|
3849
|
+
};
|
|
3850
|
+
}
|
|
3851
|
+
}
|
|
3852
|
+
if (value?.type === "template") {
|
|
3853
|
+
const allRefs = getTemplateKeyPaths2(value);
|
|
3854
|
+
for (const ref of allRefs) {
|
|
3855
|
+
const variable = (0, import_editor26.getNodeScope)(node).available.getByKeyPath(ref);
|
|
3856
|
+
if (!variable) {
|
|
3857
|
+
return {
|
|
3858
|
+
level: import_editor26.FeedbackLevel.Error,
|
|
3859
|
+
message: unknownVariableMessage
|
|
3860
|
+
};
|
|
3861
|
+
}
|
|
3862
|
+
}
|
|
3863
|
+
}
|
|
3864
|
+
return void 0;
|
|
3865
|
+
}
|
|
3866
|
+
function getTemplateKeyPaths2(value) {
|
|
3867
|
+
const keyPathReg = /{{(.*?)}}/g;
|
|
3868
|
+
return (0, import_lodash11.uniq)(value.content?.match(keyPathReg) || []).map(
|
|
3869
|
+
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
3870
|
+
);
|
|
3871
|
+
}
|
|
3570
3872
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3571
3873
|
0 && (module.exports = {
|
|
3874
|
+
AssignRow,
|
|
3875
|
+
AssignRows,
|
|
3572
3876
|
BatchOutputs,
|
|
3573
3877
|
BatchVariableSelector,
|
|
3574
3878
|
CodeEditor,
|
|
@@ -3594,6 +3898,7 @@ var infer = (values, scope) => {
|
|
|
3594
3898
|
autoRenameRefEffect,
|
|
3595
3899
|
createBatchOutputsFormPlugin,
|
|
3596
3900
|
createDisableDeclarationPlugin,
|
|
3901
|
+
createInferAssignPlugin,
|
|
3597
3902
|
createInferInputsPlugin,
|
|
3598
3903
|
createTypePresetPlugin,
|
|
3599
3904
|
formatLegacyRefOnInit,
|
|
@@ -3603,12 +3908,16 @@ var infer = (values, scope) => {
|
|
|
3603
3908
|
getTypeSelectValue,
|
|
3604
3909
|
isLegacyFlowRefValueSchema,
|
|
3605
3910
|
isNewFlowRefValueSchema,
|
|
3911
|
+
listenRefSchemaChange,
|
|
3912
|
+
listenRefValueChange,
|
|
3606
3913
|
parseTypeSelectValue,
|
|
3607
3914
|
provideBatchInputEffect,
|
|
3608
3915
|
provideBatchOutputsEffect,
|
|
3609
3916
|
provideJsonSchemaOutputs,
|
|
3610
3917
|
syncVariableTitle,
|
|
3611
3918
|
useTypeManager,
|
|
3612
|
-
useVariableTree
|
|
3919
|
+
useVariableTree,
|
|
3920
|
+
validateFlowValue,
|
|
3921
|
+
validateWhenVariableSync
|
|
3613
3922
|
});
|
|
3614
3923
|
//# sourceMappingURL=index.js.map
|