@flowgram.ai/form-materials 0.2.0 → 0.2.1
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 -20
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +80 -34
- package/dist/index.d.ts +80 -34
- package/dist/index.js +146 -32
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/batch-variable-selector/index.tsx +3 -2
- package/src/components/constant-input/config.json +1 -1
- package/src/components/constant-input/types.ts +3 -3
- package/src/components/dynamic-value-input/index.tsx +2 -2
- package/src/components/json-schema-editor/config.json +1 -1
- package/src/components/json-schema-editor/hooks.tsx +2 -2
- package/src/components/json-schema-editor/index.tsx +3 -3
- package/src/components/json-schema-editor/types.ts +3 -3
- package/src/components/type-selector/config.json +1 -1
- package/src/components/type-selector/constants.tsx +2 -2
- package/src/components/type-selector/index.tsx +6 -6
- package/src/components/variable-selector/config.json +1 -1
- package/src/components/variable-selector/index.tsx +3 -3
- package/src/components/variable-selector/use-variable-tree.tsx +11 -5
- package/src/typings/index.ts +1 -0
- package/src/typings/json-schema/config.json +5 -0
- package/src/typings/json-schema/index.ts +31 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/json-schema/config.json +5 -0
- package/src/utils/json-schema/index.ts +154 -0
- package/src/components/type-selector/types.ts +0 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import React$1 from 'react';
|
|
2
|
-
import { VarJSONSchema, EffectOptions } from '@flowgram.ai/editor';
|
|
3
2
|
import { TriggerRenderProps } from '@douyinfe/semi-ui/lib/es/treeSelect';
|
|
3
|
+
import { EffectOptions, ASTNodeJSON, ASTNode, BaseType } from '@flowgram.ai/editor';
|
|
4
|
+
|
|
5
|
+
type JsonSchemaBasicType = 'boolean' | 'string' | 'integer' | 'number' | 'object' | 'array' | 'map';
|
|
6
|
+
interface IJsonSchema<T = string> {
|
|
7
|
+
type?: T;
|
|
8
|
+
default?: any;
|
|
9
|
+
title?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
enum?: (string | number)[];
|
|
12
|
+
properties?: Record<string, IJsonSchema<T>>;
|
|
13
|
+
additionalProperties?: IJsonSchema<T>;
|
|
14
|
+
items?: IJsonSchema<T>;
|
|
15
|
+
required?: string[];
|
|
16
|
+
$ref?: string;
|
|
17
|
+
extra?: {
|
|
18
|
+
index?: number;
|
|
19
|
+
weak?: boolean;
|
|
20
|
+
formComponent?: string;
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
type IBasicJsonSchema = IJsonSchema<JsonSchemaBasicType>;
|
|
4
25
|
|
|
5
26
|
interface PropTypes$1 {
|
|
6
27
|
value?: string[];
|
|
@@ -9,8 +30,8 @@ interface PropTypes$1 {
|
|
|
9
30
|
notFoundContent?: string;
|
|
10
31
|
};
|
|
11
32
|
onChange: (value?: string[]) => void;
|
|
12
|
-
includeSchema?:
|
|
13
|
-
excludeSchema?:
|
|
33
|
+
includeSchema?: IJsonSchema | IJsonSchema[];
|
|
34
|
+
excludeSchema?: IJsonSchema | IJsonSchema[];
|
|
14
35
|
readonly?: boolean;
|
|
15
36
|
hasError?: boolean;
|
|
16
37
|
style?: React$1.CSSProperties;
|
|
@@ -19,7 +40,24 @@ interface PropTypes$1 {
|
|
|
19
40
|
type VariableSelectorProps = PropTypes$1;
|
|
20
41
|
declare const VariableSelector: ({ value, config, onChange, style, readonly, includeSchema, excludeSchema, hasError, triggerRender, }: PropTypes$1) => React$1.JSX.Element;
|
|
21
42
|
|
|
22
|
-
|
|
43
|
+
interface IFlowConstantValue {
|
|
44
|
+
type: 'constant';
|
|
45
|
+
content?: string | number | boolean;
|
|
46
|
+
}
|
|
47
|
+
interface IFlowRefValue {
|
|
48
|
+
type: 'ref';
|
|
49
|
+
content?: string[];
|
|
50
|
+
}
|
|
51
|
+
interface IFlowExpressionValue {
|
|
52
|
+
type: 'expression';
|
|
53
|
+
content?: string;
|
|
54
|
+
}
|
|
55
|
+
interface IFlowTemplateValue {
|
|
56
|
+
type: 'template';
|
|
57
|
+
content?: string;
|
|
58
|
+
}
|
|
59
|
+
type IFlowValue = IFlowConstantValue | IFlowRefValue | IFlowExpressionValue | IFlowTemplateValue;
|
|
60
|
+
type IFlowConstantRefValue = IFlowConstantValue | IFlowRefValue;
|
|
23
61
|
|
|
24
62
|
declare const VariableTypeIcons: {
|
|
25
63
|
[key: string]: React$1.ReactNode;
|
|
@@ -27,16 +65,16 @@ declare const VariableTypeIcons: {
|
|
|
27
65
|
declare const ArrayIcons: {
|
|
28
66
|
[key: string]: React$1.ReactNode;
|
|
29
67
|
};
|
|
30
|
-
declare const getSchemaIcon: (value?: Partial<
|
|
68
|
+
declare const getSchemaIcon: (value?: Partial<IJsonSchema>) => React$1.ReactNode;
|
|
31
69
|
|
|
32
70
|
interface PropTypes {
|
|
33
|
-
value?: Partial<
|
|
34
|
-
onChange: (value?: Partial<
|
|
71
|
+
value?: Partial<IJsonSchema>;
|
|
72
|
+
onChange: (value?: Partial<IJsonSchema>) => void;
|
|
35
73
|
disabled?: boolean;
|
|
36
74
|
style?: React$1.CSSProperties;
|
|
37
75
|
}
|
|
38
|
-
declare const getTypeSelectValue: (value?: Partial<
|
|
39
|
-
declare const parseTypeSelectValue: (value?: string[]) => Partial<
|
|
76
|
+
declare const getTypeSelectValue: (value?: Partial<IJsonSchema>) => string[] | undefined;
|
|
77
|
+
declare const parseTypeSelectValue: (value?: string[]) => Partial<IJsonSchema> | undefined;
|
|
40
78
|
declare function TypeSelector(props: PropTypes): React$1.JSX.Element;
|
|
41
79
|
|
|
42
80
|
interface ConfigType {
|
|
@@ -47,15 +85,15 @@ interface ConfigType {
|
|
|
47
85
|
}
|
|
48
86
|
|
|
49
87
|
declare function JsonSchemaEditor(props: {
|
|
50
|
-
value?:
|
|
51
|
-
onChange?: (value:
|
|
88
|
+
value?: IJsonSchema;
|
|
89
|
+
onChange?: (value: IJsonSchema) => void;
|
|
52
90
|
config?: ConfigType;
|
|
53
91
|
}): React$1.JSX.Element;
|
|
54
92
|
|
|
55
93
|
declare function BatchVariableSelector(props: VariableSelectorProps): React$1.JSX.Element;
|
|
56
94
|
|
|
57
95
|
interface Strategy<Value = any> {
|
|
58
|
-
hit: (schema:
|
|
96
|
+
hit: (schema: IJsonSchema) => boolean;
|
|
59
97
|
Renderer: React.FC<RendererProps<Value>>;
|
|
60
98
|
}
|
|
61
99
|
interface RendererProps<Value = any> {
|
|
@@ -64,39 +102,20 @@ interface RendererProps<Value = any> {
|
|
|
64
102
|
readonly?: boolean;
|
|
65
103
|
}
|
|
66
104
|
interface PropsType$1 extends RendererProps {
|
|
67
|
-
schema:
|
|
105
|
+
schema: IJsonSchema;
|
|
68
106
|
strategies?: Strategy[];
|
|
69
107
|
[key: string]: any;
|
|
70
108
|
}
|
|
71
109
|
|
|
72
110
|
declare function ConstantInput(props: PropsType$1): React$1.JSX.Element;
|
|
73
111
|
|
|
74
|
-
interface IFlowConstantValue {
|
|
75
|
-
type: 'constant';
|
|
76
|
-
content?: string | number | boolean;
|
|
77
|
-
}
|
|
78
|
-
interface IFlowRefValue {
|
|
79
|
-
type: 'ref';
|
|
80
|
-
content?: string[];
|
|
81
|
-
}
|
|
82
|
-
interface IFlowExpressionValue {
|
|
83
|
-
type: 'expression';
|
|
84
|
-
content?: string;
|
|
85
|
-
}
|
|
86
|
-
interface IFlowTemplateValue {
|
|
87
|
-
type: 'template';
|
|
88
|
-
content?: string;
|
|
89
|
-
}
|
|
90
|
-
type IFlowValue = IFlowConstantValue | IFlowRefValue | IFlowExpressionValue | IFlowTemplateValue;
|
|
91
|
-
type IFlowConstantRefValue = IFlowConstantValue | IFlowRefValue;
|
|
92
|
-
|
|
93
112
|
interface PropsType {
|
|
94
113
|
value?: IFlowConstantRefValue;
|
|
95
114
|
onChange: (value?: IFlowConstantRefValue) => void;
|
|
96
115
|
readonly?: boolean;
|
|
97
116
|
hasError?: boolean;
|
|
98
117
|
style?: React$1.CSSProperties;
|
|
99
|
-
schema?:
|
|
118
|
+
schema?: IJsonSchema;
|
|
100
119
|
constantProps?: {
|
|
101
120
|
strategies?: Strategy[];
|
|
102
121
|
[key: string]: any;
|
|
@@ -188,4 +207,31 @@ declare function formatNewRefToLegacyRef(value: NewFlowRefValueSchema): {
|
|
|
188
207
|
content: string;
|
|
189
208
|
};
|
|
190
209
|
|
|
191
|
-
|
|
210
|
+
declare namespace JsonSchemaUtils {
|
|
211
|
+
/**
|
|
212
|
+
* Converts a JSON schema to an Abstract Syntax Tree (AST) representation.
|
|
213
|
+
* This function recursively processes the JSON schema and creates corresponding AST nodes.
|
|
214
|
+
*
|
|
215
|
+
* For more information on JSON Schema, refer to the official documentation:
|
|
216
|
+
* https://json-schema.org/
|
|
217
|
+
*
|
|
218
|
+
* @param jsonSchema - The JSON schema to convert.
|
|
219
|
+
* @returns An AST node representing the JSON schema, or undefined if the schema type is not recognized.
|
|
220
|
+
*/
|
|
221
|
+
function schemaToAST(jsonSchema: IJsonSchema): ASTNodeJSON | undefined;
|
|
222
|
+
/**
|
|
223
|
+
* Convert AST To JSON Schema
|
|
224
|
+
* @param typeAST
|
|
225
|
+
* @returns
|
|
226
|
+
*/
|
|
227
|
+
function astToSchema(typeAST: ASTNode): IJsonSchema | undefined;
|
|
228
|
+
/**
|
|
229
|
+
* Check if the AST type is match the JSON Schema
|
|
230
|
+
* @param typeAST
|
|
231
|
+
* @param schema
|
|
232
|
+
* @returns
|
|
233
|
+
*/
|
|
234
|
+
function isASTMatchSchema(typeAST: BaseType, schema: IJsonSchema | IJsonSchema[]): boolean;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export { ArrayIcons, BatchVariableSelector, ConstantInput, DynamicValueInput, type IBasicJsonSchema, type IFlowConstantRefValue, type IFlowConstantValue, type IFlowExpressionValue, type IFlowRefValue, type IFlowTemplateValue, type IFlowValue, type IJsonSchema, type JsonSchemaBasicType, JsonSchemaEditor, JsonSchemaUtils, TypeSelector, VariableSelector, type VariableSelectorProps, VariableTypeIcons, formatLegacyRefOnInit, formatLegacyRefOnSubmit, formatLegacyRefToNewRef, formatNewRefToLegacyRef, getSchemaIcon, getTypeSelectValue, isLegacyFlowRefValueSchema, isNewFlowRefValueSchema, parseTypeSelectValue, provideBatchInputEffect, provideBatchOutputsEffect };
|
package/dist/index.js
CHANGED
|
@@ -35,6 +35,7 @@ __export(src_exports, {
|
|
|
35
35
|
ConstantInput: () => ConstantInput,
|
|
36
36
|
DynamicValueInput: () => DynamicValueInput,
|
|
37
37
|
JsonSchemaEditor: () => JsonSchemaEditor,
|
|
38
|
+
JsonSchemaUtils: () => JsonSchemaUtils,
|
|
38
39
|
TypeSelector: () => TypeSelector,
|
|
39
40
|
VariableSelector: () => VariableSelector,
|
|
40
41
|
VariableTypeIcons: () => VariableTypeIcons,
|
|
@@ -58,7 +59,7 @@ var import_semi_icons2 = require("@douyinfe/semi-icons");
|
|
|
58
59
|
|
|
59
60
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
60
61
|
var import_react2 = __toESM(require("react"));
|
|
61
|
-
var
|
|
62
|
+
var import_editor2 = require("@flowgram.ai/editor");
|
|
62
63
|
var import_semi_ui = require("@douyinfe/semi-ui");
|
|
63
64
|
|
|
64
65
|
// src/components/type-selector/constants.tsx
|
|
@@ -450,10 +451,122 @@ var options = [
|
|
|
450
451
|
}
|
|
451
452
|
];
|
|
452
453
|
|
|
454
|
+
// src/utils/json-schema/index.ts
|
|
455
|
+
var import_lodash = require("lodash");
|
|
456
|
+
var import_editor = require("@flowgram.ai/editor");
|
|
457
|
+
var JsonSchemaUtils;
|
|
458
|
+
((JsonSchemaUtils2) => {
|
|
459
|
+
function schemaToAST(jsonSchema) {
|
|
460
|
+
const { type, extra } = jsonSchema || {};
|
|
461
|
+
const { weak = false } = extra || {};
|
|
462
|
+
if (!type) {
|
|
463
|
+
return void 0;
|
|
464
|
+
}
|
|
465
|
+
switch (type) {
|
|
466
|
+
case "object":
|
|
467
|
+
if (weak) {
|
|
468
|
+
return { kind: import_editor.ASTKind.Object, weak: true };
|
|
469
|
+
}
|
|
470
|
+
return import_editor.ASTFactory.createObject({
|
|
471
|
+
properties: Object.entries(jsonSchema.properties || {}).sort((a, b) => ((0, import_lodash.get)(a?.[1], "extra.index") || 0) - ((0, import_lodash.get)(b?.[1], "extra.index") || 0)).map(([key, _property]) => ({
|
|
472
|
+
key,
|
|
473
|
+
type: schemaToAST(_property),
|
|
474
|
+
meta: { description: _property.description }
|
|
475
|
+
}))
|
|
476
|
+
});
|
|
477
|
+
case "array":
|
|
478
|
+
if (weak) {
|
|
479
|
+
return { kind: import_editor.ASTKind.Array, weak: true };
|
|
480
|
+
}
|
|
481
|
+
return import_editor.ASTFactory.createArray({
|
|
482
|
+
items: schemaToAST(jsonSchema.items)
|
|
483
|
+
});
|
|
484
|
+
case "map":
|
|
485
|
+
if (weak) {
|
|
486
|
+
return { kind: import_editor.ASTKind.Map, weak: true };
|
|
487
|
+
}
|
|
488
|
+
return import_editor.ASTFactory.createMap({
|
|
489
|
+
valueType: schemaToAST(jsonSchema.additionalProperties)
|
|
490
|
+
});
|
|
491
|
+
case "string":
|
|
492
|
+
return import_editor.ASTFactory.createString();
|
|
493
|
+
case "number":
|
|
494
|
+
return import_editor.ASTFactory.createNumber();
|
|
495
|
+
case "boolean":
|
|
496
|
+
return import_editor.ASTFactory.createBoolean();
|
|
497
|
+
case "integer":
|
|
498
|
+
return import_editor.ASTFactory.createInteger();
|
|
499
|
+
default:
|
|
500
|
+
return import_editor.ASTFactory.createCustomType({ typeName: type });
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
JsonSchemaUtils2.schemaToAST = schemaToAST;
|
|
504
|
+
function astToSchema(typeAST) {
|
|
505
|
+
if (import_editor.ASTMatch.isString(typeAST)) {
|
|
506
|
+
return {
|
|
507
|
+
type: "string"
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
if (import_editor.ASTMatch.isBoolean(typeAST)) {
|
|
511
|
+
return {
|
|
512
|
+
type: "boolean"
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
if (import_editor.ASTMatch.isNumber(typeAST)) {
|
|
516
|
+
return {
|
|
517
|
+
type: "number"
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
if (import_editor.ASTMatch.isInteger(typeAST)) {
|
|
521
|
+
return {
|
|
522
|
+
type: "integer"
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
if (import_editor.ASTMatch.isObject(typeAST)) {
|
|
526
|
+
return {
|
|
527
|
+
type: "object",
|
|
528
|
+
properties: Object.fromEntries(
|
|
529
|
+
Object.entries(typeAST.properties).map(([key, value]) => [key, astToSchema(value)])
|
|
530
|
+
)
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
if (import_editor.ASTMatch.isArray(typeAST)) {
|
|
534
|
+
return {
|
|
535
|
+
type: "array",
|
|
536
|
+
items: astToSchema(typeAST.items)
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
if (import_editor.ASTMatch.isMap(typeAST)) {
|
|
540
|
+
return {
|
|
541
|
+
type: "map",
|
|
542
|
+
items: astToSchema(typeAST.valueType)
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
if (import_editor.ASTMatch.isCustomType(typeAST)) {
|
|
546
|
+
return {
|
|
547
|
+
type: typeAST.typeName
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
return void 0;
|
|
551
|
+
}
|
|
552
|
+
JsonSchemaUtils2.astToSchema = astToSchema;
|
|
553
|
+
function isASTMatchSchema(typeAST, schema) {
|
|
554
|
+
if (Array.isArray(schema)) {
|
|
555
|
+
return typeAST.isTypeEqual(
|
|
556
|
+
import_editor.ASTFactory.createUnion({
|
|
557
|
+
types: schema.map((_schema) => schemaToAST(_schema)).filter(Boolean)
|
|
558
|
+
})
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
return typeAST.isTypeEqual(schemaToAST(schema));
|
|
562
|
+
}
|
|
563
|
+
JsonSchemaUtils2.isASTMatchSchema = isASTMatchSchema;
|
|
564
|
+
})(JsonSchemaUtils || (JsonSchemaUtils = {}));
|
|
565
|
+
|
|
453
566
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
454
567
|
function useVariableTree(params) {
|
|
455
568
|
const { includeSchema, excludeSchema } = params;
|
|
456
|
-
const available = (0,
|
|
569
|
+
const available = (0, import_editor2.useScopeAvailable)();
|
|
457
570
|
const getVariableTypeIcon = (0, import_react2.useCallback)((variable) => {
|
|
458
571
|
if (variable.meta?.icon) {
|
|
459
572
|
if (typeof variable.meta.icon === "string") {
|
|
@@ -462,7 +575,7 @@ function useVariableTree(params) {
|
|
|
462
575
|
return variable.meta.icon;
|
|
463
576
|
}
|
|
464
577
|
const _type = variable.type;
|
|
465
|
-
if (
|
|
578
|
+
if (import_editor2.ASTMatch.isArray(_type)) {
|
|
466
579
|
return /* @__PURE__ */ import_react2.default.createElement(
|
|
467
580
|
import_semi_ui.Icon,
|
|
468
581
|
{
|
|
@@ -471,7 +584,7 @@ function useVariableTree(params) {
|
|
|
471
584
|
}
|
|
472
585
|
);
|
|
473
586
|
}
|
|
474
|
-
if (
|
|
587
|
+
if (import_editor2.ASTMatch.isCustomType(_type)) {
|
|
475
588
|
return /* @__PURE__ */ import_react2.default.createElement(import_semi_ui.Icon, { size: "small", svg: VariableTypeIcons[_type.typeName.toLowerCase()] });
|
|
476
589
|
}
|
|
477
590
|
return /* @__PURE__ */ import_react2.default.createElement(import_semi_ui.Icon, { size: "small", svg: VariableTypeIcons[variable.type?.kind.toLowerCase()] });
|
|
@@ -482,7 +595,7 @@ function useVariableTree(params) {
|
|
|
482
595
|
return null;
|
|
483
596
|
}
|
|
484
597
|
let children;
|
|
485
|
-
if (
|
|
598
|
+
if (import_editor2.ASTMatch.isObject(type)) {
|
|
486
599
|
children = (type.properties || []).map((_property) => renderVariable(_property, [...parentFields, variable])).filter(Boolean);
|
|
487
600
|
if (!children?.length) {
|
|
488
601
|
return null;
|
|
@@ -490,8 +603,8 @@ function useVariableTree(params) {
|
|
|
490
603
|
}
|
|
491
604
|
const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
|
|
492
605
|
const key = keyPath.join(".");
|
|
493
|
-
const isSchemaInclude = includeSchema ?
|
|
494
|
-
const isSchemaExclude = excludeSchema ?
|
|
606
|
+
const isSchemaInclude = includeSchema ? JsonSchemaUtils.isASTMatchSchema(type, includeSchema) : true;
|
|
607
|
+
const isSchemaExclude = excludeSchema ? JsonSchemaUtils.isASTMatchSchema(type, excludeSchema) : false;
|
|
495
608
|
const isSchemaMatch = isSchemaInclude && !isSchemaExclude;
|
|
496
609
|
if (!isSchemaMatch && !children?.length) {
|
|
497
610
|
return null;
|
|
@@ -1026,13 +1139,13 @@ function PropertyEdit(props) {
|
|
|
1026
1139
|
|
|
1027
1140
|
// src/components/batch-variable-selector/index.tsx
|
|
1028
1141
|
var import_react8 = __toESM(require("react"));
|
|
1029
|
-
var
|
|
1142
|
+
var import_editor3 = require("@flowgram.ai/editor");
|
|
1030
1143
|
var batchVariableSchema = {
|
|
1031
1144
|
type: "array",
|
|
1032
1145
|
extra: { weak: true }
|
|
1033
1146
|
};
|
|
1034
1147
|
function BatchVariableSelector(props) {
|
|
1035
|
-
return /* @__PURE__ */ import_react8.default.createElement(
|
|
1148
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_editor3.PrivateScopeProvider, null, /* @__PURE__ */ import_react8.default.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
|
|
1036
1149
|
}
|
|
1037
1150
|
|
|
1038
1151
|
// src/components/constant-input/index.tsx
|
|
@@ -1178,29 +1291,29 @@ function DynamicValueInput({
|
|
|
1178
1291
|
}
|
|
1179
1292
|
|
|
1180
1293
|
// src/effects/provide-batch-input/index.ts
|
|
1181
|
-
var
|
|
1182
|
-
var provideBatchInputEffect = (0,
|
|
1294
|
+
var import_editor4 = require("@flowgram.ai/editor");
|
|
1295
|
+
var provideBatchInputEffect = (0, import_editor4.createEffectFromVariableProvider)({
|
|
1183
1296
|
private: true,
|
|
1184
1297
|
parse: (value, ctx) => [
|
|
1185
|
-
|
|
1298
|
+
import_editor4.ASTFactory.createVariableDeclaration({
|
|
1186
1299
|
key: `${ctx.node.id}_locals`,
|
|
1187
1300
|
meta: {
|
|
1188
|
-
title: (0,
|
|
1301
|
+
title: (0, import_editor4.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
1189
1302
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
1190
1303
|
},
|
|
1191
|
-
type:
|
|
1304
|
+
type: import_editor4.ASTFactory.createObject({
|
|
1192
1305
|
properties: [
|
|
1193
|
-
|
|
1306
|
+
import_editor4.ASTFactory.createProperty({
|
|
1194
1307
|
key: "item",
|
|
1195
|
-
initializer:
|
|
1196
|
-
enumerateFor:
|
|
1308
|
+
initializer: import_editor4.ASTFactory.createEnumerateExpression({
|
|
1309
|
+
enumerateFor: import_editor4.ASTFactory.createKeyPathExpression({
|
|
1197
1310
|
keyPath: value.content || []
|
|
1198
1311
|
})
|
|
1199
1312
|
})
|
|
1200
1313
|
}),
|
|
1201
|
-
|
|
1314
|
+
import_editor4.ASTFactory.createProperty({
|
|
1202
1315
|
key: "index",
|
|
1203
|
-
type:
|
|
1316
|
+
type: import_editor4.ASTFactory.createNumber()
|
|
1204
1317
|
})
|
|
1205
1318
|
]
|
|
1206
1319
|
})
|
|
@@ -1209,22 +1322,22 @@ var provideBatchInputEffect = (0, import_editor3.createEffectFromVariableProvide
|
|
|
1209
1322
|
});
|
|
1210
1323
|
|
|
1211
1324
|
// src/effects/provide-batch-outputs/index.ts
|
|
1212
|
-
var
|
|
1213
|
-
var provideBatchOutputsEffect = (0,
|
|
1325
|
+
var import_editor5 = require("@flowgram.ai/editor");
|
|
1326
|
+
var provideBatchOutputsEffect = (0, import_editor5.createEffectFromVariableProvider)({
|
|
1214
1327
|
private: true,
|
|
1215
1328
|
parse: (value, ctx) => [
|
|
1216
|
-
|
|
1329
|
+
import_editor5.ASTFactory.createVariableDeclaration({
|
|
1217
1330
|
key: `${ctx.node.id}`,
|
|
1218
1331
|
meta: {
|
|
1219
|
-
title: (0,
|
|
1332
|
+
title: (0, import_editor5.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
1220
1333
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
1221
1334
|
},
|
|
1222
|
-
type:
|
|
1335
|
+
type: import_editor5.ASTFactory.createObject({
|
|
1223
1336
|
properties: Object.entries(value).map(
|
|
1224
|
-
([_key, value2]) =>
|
|
1337
|
+
([_key, value2]) => import_editor5.ASTFactory.createProperty({
|
|
1225
1338
|
key: _key,
|
|
1226
|
-
initializer:
|
|
1227
|
-
wrapFor:
|
|
1339
|
+
initializer: import_editor5.ASTFactory.createWrapArrayExpression({
|
|
1340
|
+
wrapFor: import_editor5.ASTFactory.createKeyPathExpression({
|
|
1228
1341
|
keyPath: value2.content || []
|
|
1229
1342
|
})
|
|
1230
1343
|
})
|
|
@@ -1236,9 +1349,9 @@ var provideBatchOutputsEffect = (0, import_editor4.createEffectFromVariableProvi
|
|
|
1236
1349
|
});
|
|
1237
1350
|
|
|
1238
1351
|
// src/utils/format-legacy-refs/index.ts
|
|
1239
|
-
var
|
|
1352
|
+
var import_lodash2 = require("lodash");
|
|
1240
1353
|
function formatLegacyRefOnSubmit(value) {
|
|
1241
|
-
if ((0,
|
|
1354
|
+
if ((0, import_lodash2.isObject)(value)) {
|
|
1242
1355
|
if (isLegacyFlowRefValueSchema(value)) {
|
|
1243
1356
|
return formatLegacyRefToNewRef(value);
|
|
1244
1357
|
}
|
|
@@ -1255,7 +1368,7 @@ function formatLegacyRefOnSubmit(value) {
|
|
|
1255
1368
|
return value;
|
|
1256
1369
|
}
|
|
1257
1370
|
function formatLegacyRefOnInit(value) {
|
|
1258
|
-
if ((0,
|
|
1371
|
+
if ((0, import_lodash2.isObject)(value)) {
|
|
1259
1372
|
if (isNewFlowRefValueSchema(value)) {
|
|
1260
1373
|
return formatNewRefToLegacyRef(value);
|
|
1261
1374
|
}
|
|
@@ -1272,10 +1385,10 @@ function formatLegacyRefOnInit(value) {
|
|
|
1272
1385
|
return value;
|
|
1273
1386
|
}
|
|
1274
1387
|
function isLegacyFlowRefValueSchema(value) {
|
|
1275
|
-
return (0,
|
|
1388
|
+
return (0, import_lodash2.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
1276
1389
|
}
|
|
1277
1390
|
function isNewFlowRefValueSchema(value) {
|
|
1278
|
-
return (0,
|
|
1391
|
+
return (0, import_lodash2.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
1279
1392
|
}
|
|
1280
1393
|
function formatLegacyRefToNewRef(value) {
|
|
1281
1394
|
const keyPath = value.content.split(".");
|
|
@@ -1303,6 +1416,7 @@ function formatNewRefToLegacyRef(value) {
|
|
|
1303
1416
|
ConstantInput,
|
|
1304
1417
|
DynamicValueInput,
|
|
1305
1418
|
JsonSchemaEditor,
|
|
1419
|
+
JsonSchemaUtils,
|
|
1306
1420
|
TypeSelector,
|
|
1307
1421
|
VariableSelector,
|
|
1308
1422
|
VariableTypeIcons,
|