@flowgram.ai/form-materials 0.3.2 → 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/dist/esm/index.js +72 -14
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +46 -3
- package/dist/index.d.ts +46 -3
- package/dist/index.js +90 -36
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/effects/index.ts +2 -0
- package/src/effects/listen-ref-schema-change/config.json +10 -0
- package/src/effects/listen-ref-schema-change/index.ts +56 -0
- package/src/effects/listen-ref-value-change/config.json +9 -0
- package/src/effects/listen-ref-value-change/index.ts +53 -0
- package/src/plugins/json-schema-preset/index.tsx +2 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React$1 from 'react';
|
|
2
2
|
import { IJsonSchema, JsonSchemaTypeRegistry as JsonSchemaTypeRegistry$1, JsonSchemaTypeManager } from '@flowgram.ai/json-schema';
|
|
3
|
-
export { IJsonSchema, JsonSchemaUtils } from '@flowgram.ai/json-schema';
|
|
3
|
+
export { IJsonSchema, JsonSchemaBasicType, JsonSchemaUtils } from '@flowgram.ai/json-schema';
|
|
4
4
|
import { TriggerRenderProps } from '@douyinfe/semi-ui/lib/es/treeSelect';
|
|
5
5
|
import { InferValues } from '@coze-editor/editor/react';
|
|
6
6
|
import preset from '@coze-editor/editor/preset-code';
|
|
7
|
-
import { BaseVariableField, EffectOptions, FormPluginCreator, FeedbackLevel, FlowNodeEntity } from '@flowgram.ai/editor';
|
|
7
|
+
import { BaseVariableField, EffectOptions, EffectFuncProps, FormPluginCreator, FeedbackLevel, FlowNodeEntity } from '@flowgram.ai/editor';
|
|
8
8
|
import * as _flowgram_ai_node from '@flowgram.ai/node';
|
|
9
9
|
import * as _flowgram_ai_core from '@flowgram.ai/core';
|
|
10
10
|
import { TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
|
|
@@ -527,6 +527,49 @@ declare const validateWhenVariableSync: ({ scope, }?: {
|
|
|
527
527
|
scope?: "private" | "public";
|
|
528
528
|
}) => EffectOptions[];
|
|
529
529
|
|
|
530
|
+
/**
|
|
531
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
532
|
+
* SPDX-License-Identifier: MIT
|
|
533
|
+
*/
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Example:
|
|
537
|
+
* const formMeta = {
|
|
538
|
+
* effect: {
|
|
539
|
+
* 'inputsValues.*': listenRefValueChange(({ name, variable, form }) => {
|
|
540
|
+
* const schema = JsonSchemaUtils.astToSchema(variable?.type);
|
|
541
|
+
* form.setValueIn(`${name}.schema`, schema);
|
|
542
|
+
* })
|
|
543
|
+
* }
|
|
544
|
+
* }
|
|
545
|
+
* @param cb
|
|
546
|
+
* @returns
|
|
547
|
+
*/
|
|
548
|
+
declare const listenRefValueChange: (cb: (props: EffectFuncProps<IFlowRefValue> & {
|
|
549
|
+
variable?: BaseVariableField;
|
|
550
|
+
}) => void) => EffectOptions[];
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
554
|
+
* SPDX-License-Identifier: MIT
|
|
555
|
+
*/
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Example:
|
|
559
|
+
* const formMeta = {
|
|
560
|
+
* effect: {
|
|
561
|
+
* 'inputsValues.*': listenRefSchemaChange(({ name, schema, form }) => {
|
|
562
|
+
* form.setValueIn(`${name}.schema`, schema);
|
|
563
|
+
* })
|
|
564
|
+
* }
|
|
565
|
+
* }
|
|
566
|
+
* @param cb
|
|
567
|
+
* @returns
|
|
568
|
+
*/
|
|
569
|
+
declare const listenRefSchemaChange: (cb: (props: EffectFuncProps<IFlowRefValue> & {
|
|
570
|
+
schema?: IJsonSchema;
|
|
571
|
+
}) => void) => EffectOptions[];
|
|
572
|
+
|
|
530
573
|
/**
|
|
531
574
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
532
575
|
* SPDX-License-Identifier: MIT
|
|
@@ -663,4 +706,4 @@ declare function validateFlowValue(value: IFlowValue | undefined, ctx: Context):
|
|
|
663
706
|
message: string;
|
|
664
707
|
} | undefined;
|
|
665
708
|
|
|
666
|
-
export { AssignRow, AssignRows, type AssignValueType, BatchOutputs, BatchVariableSelector, CodeEditor, CodeEditorMini, type CodeEditorPropsType, ConditionRow, type ConditionRowValueType, ConstantInput, type ConstantRendererProps, DisplayFlowValue, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, type IFlowConstantRefValue, type IFlowConstantValue, type IFlowExpressionValue, type IFlowRefValue, type IFlowTemplateValue, type IFlowValue, type IFlowValueExtra, InputsValues, JsonEditorWithVariables, JsonSchemaEditor, JsonSchemaTypePresetProvider, type JsonSchemaTypeRegistry, PromptEditor, type PromptEditorPropsType, PromptEditorWithInputs, PromptEditorWithVariables, TypeSelector, VariableSelector, type VariableSelectorProps, autoRenameRefEffect, createBatchOutputsFormPlugin, createDisableDeclarationPlugin, createInferAssignPlugin, createInferInputsPlugin, createTypePresetPlugin, formatLegacyRefOnInit, formatLegacyRefOnSubmit, formatLegacyRefToNewRef, formatNewRefToLegacyRef, getTypeSelectValue, isLegacyFlowRefValueSchema, isNewFlowRefValueSchema, parseTypeSelectValue, provideBatchInputEffect, provideBatchOutputsEffect, provideJsonSchemaOutputs, syncVariableTitle, useTypeManager, useVariableTree, validateFlowValue, validateWhenVariableSync };
|
|
709
|
+
export { AssignRow, AssignRows, type AssignValueType, BatchOutputs, BatchVariableSelector, CodeEditor, CodeEditorMini, type CodeEditorPropsType, ConditionRow, type ConditionRowValueType, ConstantInput, type ConstantRendererProps, DisplayFlowValue, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, type IFlowConstantRefValue, type IFlowConstantValue, type IFlowExpressionValue, type IFlowRefValue, type IFlowTemplateValue, type IFlowValue, type IFlowValueExtra, InputsValues, JsonEditorWithVariables, JsonSchemaEditor, JsonSchemaTypePresetProvider, type JsonSchemaTypeRegistry, PromptEditor, type PromptEditorPropsType, PromptEditorWithInputs, PromptEditorWithVariables, TypeSelector, VariableSelector, type VariableSelectorProps, autoRenameRefEffect, createBatchOutputsFormPlugin, createDisableDeclarationPlugin, createInferAssignPlugin, createInferInputsPlugin, createTypePresetPlugin, formatLegacyRefOnInit, formatLegacyRefOnSubmit, formatLegacyRefToNewRef, formatNewRefToLegacyRef, getTypeSelectValue, isLegacyFlowRefValueSchema, isNewFlowRefValueSchema, listenRefSchemaChange, listenRefValueChange, parseTypeSelectValue, provideBatchInputEffect, provideBatchOutputsEffect, provideJsonSchemaOutputs, syncVariableTitle, useTypeManager, useVariableTree, validateFlowValue, validateWhenVariableSync };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React$1 from 'react';
|
|
2
2
|
import { IJsonSchema, JsonSchemaTypeRegistry as JsonSchemaTypeRegistry$1, JsonSchemaTypeManager } from '@flowgram.ai/json-schema';
|
|
3
|
-
export { IJsonSchema, JsonSchemaUtils } from '@flowgram.ai/json-schema';
|
|
3
|
+
export { IJsonSchema, JsonSchemaBasicType, JsonSchemaUtils } from '@flowgram.ai/json-schema';
|
|
4
4
|
import { TriggerRenderProps } from '@douyinfe/semi-ui/lib/es/treeSelect';
|
|
5
5
|
import { InferValues } from '@coze-editor/editor/react';
|
|
6
6
|
import preset from '@coze-editor/editor/preset-code';
|
|
7
|
-
import { BaseVariableField, EffectOptions, FormPluginCreator, FeedbackLevel, FlowNodeEntity } from '@flowgram.ai/editor';
|
|
7
|
+
import { BaseVariableField, EffectOptions, EffectFuncProps, FormPluginCreator, FeedbackLevel, FlowNodeEntity } from '@flowgram.ai/editor';
|
|
8
8
|
import * as _flowgram_ai_node from '@flowgram.ai/node';
|
|
9
9
|
import * as _flowgram_ai_core from '@flowgram.ai/core';
|
|
10
10
|
import { TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
|
|
@@ -527,6 +527,49 @@ declare const validateWhenVariableSync: ({ scope, }?: {
|
|
|
527
527
|
scope?: "private" | "public";
|
|
528
528
|
}) => EffectOptions[];
|
|
529
529
|
|
|
530
|
+
/**
|
|
531
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
532
|
+
* SPDX-License-Identifier: MIT
|
|
533
|
+
*/
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Example:
|
|
537
|
+
* const formMeta = {
|
|
538
|
+
* effect: {
|
|
539
|
+
* 'inputsValues.*': listenRefValueChange(({ name, variable, form }) => {
|
|
540
|
+
* const schema = JsonSchemaUtils.astToSchema(variable?.type);
|
|
541
|
+
* form.setValueIn(`${name}.schema`, schema);
|
|
542
|
+
* })
|
|
543
|
+
* }
|
|
544
|
+
* }
|
|
545
|
+
* @param cb
|
|
546
|
+
* @returns
|
|
547
|
+
*/
|
|
548
|
+
declare const listenRefValueChange: (cb: (props: EffectFuncProps<IFlowRefValue> & {
|
|
549
|
+
variable?: BaseVariableField;
|
|
550
|
+
}) => void) => EffectOptions[];
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
554
|
+
* SPDX-License-Identifier: MIT
|
|
555
|
+
*/
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Example:
|
|
559
|
+
* const formMeta = {
|
|
560
|
+
* effect: {
|
|
561
|
+
* 'inputsValues.*': listenRefSchemaChange(({ name, schema, form }) => {
|
|
562
|
+
* form.setValueIn(`${name}.schema`, schema);
|
|
563
|
+
* })
|
|
564
|
+
* }
|
|
565
|
+
* }
|
|
566
|
+
* @param cb
|
|
567
|
+
* @returns
|
|
568
|
+
*/
|
|
569
|
+
declare const listenRefSchemaChange: (cb: (props: EffectFuncProps<IFlowRefValue> & {
|
|
570
|
+
schema?: IJsonSchema;
|
|
571
|
+
}) => void) => EffectOptions[];
|
|
572
|
+
|
|
530
573
|
/**
|
|
531
574
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
532
575
|
* SPDX-License-Identifier: MIT
|
|
@@ -663,4 +706,4 @@ declare function validateFlowValue(value: IFlowValue | undefined, ctx: Context):
|
|
|
663
706
|
message: string;
|
|
664
707
|
} | undefined;
|
|
665
708
|
|
|
666
|
-
export { AssignRow, AssignRows, type AssignValueType, BatchOutputs, BatchVariableSelector, CodeEditor, CodeEditorMini, type CodeEditorPropsType, ConditionRow, type ConditionRowValueType, ConstantInput, type ConstantRendererProps, DisplayFlowValue, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, type IFlowConstantRefValue, type IFlowConstantValue, type IFlowExpressionValue, type IFlowRefValue, type IFlowTemplateValue, type IFlowValue, type IFlowValueExtra, InputsValues, JsonEditorWithVariables, JsonSchemaEditor, JsonSchemaTypePresetProvider, type JsonSchemaTypeRegistry, PromptEditor, type PromptEditorPropsType, PromptEditorWithInputs, PromptEditorWithVariables, TypeSelector, VariableSelector, type VariableSelectorProps, autoRenameRefEffect, createBatchOutputsFormPlugin, createDisableDeclarationPlugin, createInferAssignPlugin, createInferInputsPlugin, createTypePresetPlugin, formatLegacyRefOnInit, formatLegacyRefOnSubmit, formatLegacyRefToNewRef, formatNewRefToLegacyRef, getTypeSelectValue, isLegacyFlowRefValueSchema, isNewFlowRefValueSchema, parseTypeSelectValue, provideBatchInputEffect, provideBatchOutputsEffect, provideJsonSchemaOutputs, syncVariableTitle, useTypeManager, useVariableTree, validateFlowValue, validateWhenVariableSync };
|
|
709
|
+
export { AssignRow, AssignRows, type AssignValueType, BatchOutputs, BatchVariableSelector, CodeEditor, CodeEditorMini, type CodeEditorPropsType, ConditionRow, type ConditionRowValueType, ConstantInput, type ConstantRendererProps, DisplayFlowValue, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, type IFlowConstantRefValue, type IFlowConstantValue, type IFlowExpressionValue, type IFlowRefValue, type IFlowTemplateValue, type IFlowValue, type IFlowValueExtra, InputsValues, JsonEditorWithVariables, JsonSchemaEditor, JsonSchemaTypePresetProvider, type JsonSchemaTypeRegistry, PromptEditor, type PromptEditorPropsType, PromptEditorWithInputs, PromptEditorWithVariables, TypeSelector, VariableSelector, type VariableSelectorProps, autoRenameRefEffect, createBatchOutputsFormPlugin, createDisableDeclarationPlugin, createInferAssignPlugin, createInferInputsPlugin, createTypePresetPlugin, formatLegacyRefOnInit, formatLegacyRefOnSubmit, formatLegacyRefToNewRef, formatNewRefToLegacyRef, getTypeSelectValue, isLegacyFlowRefValueSchema, isNewFlowRefValueSchema, listenRefSchemaChange, listenRefValueChange, parseTypeSelectValue, provideBatchInputEffect, provideBatchOutputsEffect, provideJsonSchemaOutputs, syncVariableTitle, useTypeManager, useVariableTree, validateFlowValue, validateWhenVariableSync };
|
package/dist/index.js
CHANGED
|
@@ -67,6 +67,8 @@ __export(src_exports, {
|
|
|
67
67
|
getTypeSelectValue: () => getTypeSelectValue,
|
|
68
68
|
isLegacyFlowRefValueSchema: () => isLegacyFlowRefValueSchema,
|
|
69
69
|
isNewFlowRefValueSchema: () => isNewFlowRefValueSchema,
|
|
70
|
+
listenRefSchemaChange: () => listenRefSchemaChange,
|
|
71
|
+
listenRefValueChange: () => listenRefValueChange,
|
|
70
72
|
parseTypeSelectValue: () => parseTypeSelectValue,
|
|
71
73
|
provideBatchInputEffect: () => provideBatchInputEffect,
|
|
72
74
|
provideBatchOutputsEffect: () => provideBatchOutputsEffect,
|
|
@@ -3519,6 +3521,56 @@ var validateWhenVariableSync = ({
|
|
|
3519
3521
|
}
|
|
3520
3522
|
];
|
|
3521
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
|
+
|
|
3522
3574
|
// src/shared/format-legacy-refs/index.ts
|
|
3523
3575
|
var import_lodash8 = require("lodash");
|
|
3524
3576
|
function formatLegacyRefOnSubmit(value) {
|
|
@@ -3582,21 +3634,21 @@ function formatNewRefToLegacyRef(value) {
|
|
|
3582
3634
|
}
|
|
3583
3635
|
|
|
3584
3636
|
// src/form-plugins/batch-outputs-plugin/index.ts
|
|
3585
|
-
var
|
|
3586
|
-
var provideBatchOutputsEffect = (0,
|
|
3637
|
+
var import_editor23 = require("@flowgram.ai/editor");
|
|
3638
|
+
var provideBatchOutputsEffect = (0, import_editor23.createEffectFromVariableProvider)({
|
|
3587
3639
|
parse: (value, ctx) => [
|
|
3588
|
-
|
|
3640
|
+
import_editor23.ASTFactory.createVariableDeclaration({
|
|
3589
3641
|
key: `${ctx.node.id}`,
|
|
3590
3642
|
meta: {
|
|
3591
|
-
title: (0,
|
|
3643
|
+
title: (0, import_editor23.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3592
3644
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3593
3645
|
},
|
|
3594
|
-
type:
|
|
3646
|
+
type: import_editor23.ASTFactory.createObject({
|
|
3595
3647
|
properties: Object.entries(value).map(
|
|
3596
|
-
([_key, value2]) =>
|
|
3648
|
+
([_key, value2]) => import_editor23.ASTFactory.createProperty({
|
|
3597
3649
|
key: _key,
|
|
3598
|
-
initializer:
|
|
3599
|
-
wrapFor:
|
|
3650
|
+
initializer: import_editor23.ASTFactory.createWrapArrayExpression({
|
|
3651
|
+
wrapFor: import_editor23.ASTFactory.createKeyPathExpression({
|
|
3600
3652
|
keyPath: value2?.content || []
|
|
3601
3653
|
})
|
|
3602
3654
|
})
|
|
@@ -3606,7 +3658,7 @@ var provideBatchOutputsEffect = (0, import_editor21.createEffectFromVariableProv
|
|
|
3606
3658
|
})
|
|
3607
3659
|
]
|
|
3608
3660
|
});
|
|
3609
|
-
var createBatchOutputsFormPlugin = (0,
|
|
3661
|
+
var createBatchOutputsFormPlugin = (0, import_editor23.defineFormPluginCreator)({
|
|
3610
3662
|
name: "batch-outputs-plugin",
|
|
3611
3663
|
onSetupFormMeta({ mergeEffect }, { outputKey }) {
|
|
3612
3664
|
mergeEffect({
|
|
@@ -3614,7 +3666,7 @@ var createBatchOutputsFormPlugin = (0, import_editor21.defineFormPluginCreator)(
|
|
|
3614
3666
|
});
|
|
3615
3667
|
},
|
|
3616
3668
|
onInit(ctx, { outputKey }) {
|
|
3617
|
-
const chainTransformService = ctx.node.getService(
|
|
3669
|
+
const chainTransformService = ctx.node.getService(import_editor23.ScopeChainTransformService);
|
|
3618
3670
|
const batchNodeType = ctx.node.flowNodeType;
|
|
3619
3671
|
const transformerId = `${batchNodeType}-outputs`;
|
|
3620
3672
|
if (chainTransformService.hasTransformer(transformerId)) {
|
|
@@ -3624,21 +3676,21 @@ var createBatchOutputsFormPlugin = (0, import_editor21.defineFormPluginCreator)(
|
|
|
3624
3676
|
transformCovers: (covers, ctx2) => {
|
|
3625
3677
|
const node = ctx2.scope.meta?.node;
|
|
3626
3678
|
if (node?.parent?.flowNodeType === batchNodeType) {
|
|
3627
|
-
return [...covers, (0,
|
|
3679
|
+
return [...covers, (0, import_editor23.getNodeScope)(node.parent)];
|
|
3628
3680
|
}
|
|
3629
3681
|
return covers;
|
|
3630
3682
|
},
|
|
3631
3683
|
transformDeps(scopes, ctx2) {
|
|
3632
3684
|
const scopeMeta = ctx2.scope.meta;
|
|
3633
|
-
if (scopeMeta?.type ===
|
|
3685
|
+
if (scopeMeta?.type === import_editor23.FlowNodeScopeType.private) {
|
|
3634
3686
|
return scopes;
|
|
3635
3687
|
}
|
|
3636
3688
|
const node = scopeMeta?.node;
|
|
3637
3689
|
if (node?.flowNodeType === batchNodeType) {
|
|
3638
3690
|
const childBlocks = node.blocks;
|
|
3639
3691
|
return [
|
|
3640
|
-
(0,
|
|
3641
|
-
...childBlocks.map((_childBlock) => (0,
|
|
3692
|
+
(0, import_editor23.getNodePrivateScope)(node),
|
|
3693
|
+
...childBlocks.map((_childBlock) => (0, import_editor23.getNodeScope)(_childBlock))
|
|
3642
3694
|
];
|
|
3643
3695
|
}
|
|
3644
3696
|
return scopes;
|
|
@@ -3649,9 +3701,9 @@ var createBatchOutputsFormPlugin = (0, import_editor21.defineFormPluginCreator)(
|
|
|
3649
3701
|
|
|
3650
3702
|
// src/form-plugins/infer-inputs-plugin/index.ts
|
|
3651
3703
|
var import_lodash9 = require("lodash");
|
|
3652
|
-
var
|
|
3653
|
-
var
|
|
3654
|
-
var createInferInputsPlugin = (0,
|
|
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)({
|
|
3655
3707
|
onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
|
|
3656
3708
|
if (!sourceKey || !targetKey) {
|
|
3657
3709
|
return;
|
|
@@ -3662,7 +3714,7 @@ var createInferInputsPlugin = (0, import_editor22.defineFormPluginCreator)({
|
|
|
3662
3714
|
targetKey,
|
|
3663
3715
|
infer(
|
|
3664
3716
|
(0, import_lodash9.get)(formData, sourceKey),
|
|
3665
|
-
scope === "private" ? (0,
|
|
3717
|
+
scope === "private" ? (0, import_editor24.getNodePrivateScope)(ctx.node) : (0, import_editor24.getNodeScope)(ctx.node)
|
|
3666
3718
|
)
|
|
3667
3719
|
);
|
|
3668
3720
|
return formData;
|
|
@@ -3702,7 +3754,7 @@ var infer = (values, scope) => {
|
|
|
3702
3754
|
}
|
|
3703
3755
|
if (isRef2(values)) {
|
|
3704
3756
|
const variable = scope.available.getByKeyPath(values?.content);
|
|
3705
|
-
const schema = variable?.type ?
|
|
3757
|
+
const schema = variable?.type ? import_json_schema11.JsonSchemaUtils.astToSchema(variable?.type) : void 0;
|
|
3706
3758
|
return schema;
|
|
3707
3759
|
}
|
|
3708
3760
|
if (isTemplate2(values)) {
|
|
@@ -3725,33 +3777,33 @@ var infer = (values, scope) => {
|
|
|
3725
3777
|
|
|
3726
3778
|
// src/form-plugins/infer-assign-plugin/index.ts
|
|
3727
3779
|
var import_lodash10 = require("lodash");
|
|
3728
|
-
var
|
|
3729
|
-
var
|
|
3730
|
-
var createInferAssignPlugin = (0,
|
|
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)({
|
|
3731
3783
|
onSetupFormMeta({ addFormatOnSubmit, mergeEffect }, { assignKey, outputKey }) {
|
|
3732
3784
|
if (!assignKey || !outputKey) {
|
|
3733
3785
|
return;
|
|
3734
3786
|
}
|
|
3735
3787
|
mergeEffect({
|
|
3736
|
-
[assignKey]: (0,
|
|
3788
|
+
[assignKey]: (0, import_editor25.createEffectFromVariableProvider)({
|
|
3737
3789
|
parse: (value, ctx) => {
|
|
3738
3790
|
const declareRows = (0, import_lodash10.uniqBy)(
|
|
3739
3791
|
value.filter((_v) => _v.operator === "declare" && _v.left && _v.right),
|
|
3740
3792
|
"left"
|
|
3741
3793
|
);
|
|
3742
3794
|
return [
|
|
3743
|
-
|
|
3795
|
+
import_editor25.ASTFactory.createVariableDeclaration({
|
|
3744
3796
|
key: `${ctx.node.id}`,
|
|
3745
3797
|
meta: {
|
|
3746
|
-
title: (0,
|
|
3798
|
+
title: (0, import_editor25.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3747
3799
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3748
3800
|
},
|
|
3749
|
-
type:
|
|
3801
|
+
type: import_editor25.ASTFactory.createObject({
|
|
3750
3802
|
properties: declareRows.map(
|
|
3751
|
-
(_v) =>
|
|
3803
|
+
(_v) => import_editor25.ASTFactory.createProperty({
|
|
3752
3804
|
key: _v.left,
|
|
3753
|
-
type: _v.right?.type === "constant" ?
|
|
3754
|
-
initializer: _v.right?.type === "ref" ?
|
|
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({
|
|
3755
3807
|
keyPath: _v.right?.content || []
|
|
3756
3808
|
}) : {}
|
|
3757
3809
|
})
|
|
@@ -3766,7 +3818,7 @@ var createInferAssignPlugin = (0, import_editor23.defineFormPluginCreator)({
|
|
|
3766
3818
|
(0, import_lodash10.set)(
|
|
3767
3819
|
formData,
|
|
3768
3820
|
outputKey,
|
|
3769
|
-
|
|
3821
|
+
import_json_schema12.JsonSchemaUtils.astToSchema((0, import_editor25.getNodeScope)(ctx.node).output.variables?.[0]?.type)
|
|
3770
3822
|
);
|
|
3771
3823
|
return formData;
|
|
3772
3824
|
});
|
|
@@ -3775,7 +3827,7 @@ var createInferAssignPlugin = (0, import_editor23.defineFormPluginCreator)({
|
|
|
3775
3827
|
|
|
3776
3828
|
// src/validate/validate-flow-value/index.tsx
|
|
3777
3829
|
var import_lodash11 = require("lodash");
|
|
3778
|
-
var
|
|
3830
|
+
var import_editor26 = require("@flowgram.ai/editor");
|
|
3779
3831
|
function validateFlowValue(value, ctx) {
|
|
3780
3832
|
const { node, required, errorMessages } = ctx;
|
|
3781
3833
|
const {
|
|
@@ -3784,15 +3836,15 @@ function validateFlowValue(value, ctx) {
|
|
|
3784
3836
|
} = errorMessages || {};
|
|
3785
3837
|
if (required && ((0, import_lodash11.isNil)(value) || (0, import_lodash11.isNil)(value?.content) || value?.content === "")) {
|
|
3786
3838
|
return {
|
|
3787
|
-
level:
|
|
3839
|
+
level: import_editor26.FeedbackLevel.Error,
|
|
3788
3840
|
message: requiredMessage
|
|
3789
3841
|
};
|
|
3790
3842
|
}
|
|
3791
3843
|
if (value?.type === "ref") {
|
|
3792
|
-
const variable = (0,
|
|
3844
|
+
const variable = (0, import_editor26.getNodeScope)(node).available.getByKeyPath(value?.content || []);
|
|
3793
3845
|
if (!variable) {
|
|
3794
3846
|
return {
|
|
3795
|
-
level:
|
|
3847
|
+
level: import_editor26.FeedbackLevel.Error,
|
|
3796
3848
|
message: unknownVariableMessage
|
|
3797
3849
|
};
|
|
3798
3850
|
}
|
|
@@ -3800,10 +3852,10 @@ function validateFlowValue(value, ctx) {
|
|
|
3800
3852
|
if (value?.type === "template") {
|
|
3801
3853
|
const allRefs = getTemplateKeyPaths2(value);
|
|
3802
3854
|
for (const ref of allRefs) {
|
|
3803
|
-
const variable = (0,
|
|
3855
|
+
const variable = (0, import_editor26.getNodeScope)(node).available.getByKeyPath(ref);
|
|
3804
3856
|
if (!variable) {
|
|
3805
3857
|
return {
|
|
3806
|
-
level:
|
|
3858
|
+
level: import_editor26.FeedbackLevel.Error,
|
|
3807
3859
|
message: unknownVariableMessage
|
|
3808
3860
|
};
|
|
3809
3861
|
}
|
|
@@ -3856,6 +3908,8 @@ function getTemplateKeyPaths2(value) {
|
|
|
3856
3908
|
getTypeSelectValue,
|
|
3857
3909
|
isLegacyFlowRefValueSchema,
|
|
3858
3910
|
isNewFlowRefValueSchema,
|
|
3911
|
+
listenRefSchemaChange,
|
|
3912
|
+
listenRefValueChange,
|
|
3859
3913
|
parseTypeSelectValue,
|
|
3860
3914
|
provideBatchInputEffect,
|
|
3861
3915
|
provideBatchOutputsEffect,
|