@flowgram.ai/form-materials 0.1.0-alpha.15 → 0.1.0-alpha.16
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/run.sh +3 -2
- package/dist/cjs/components/blur-input/index.js +2 -12
- package/dist/cjs/components/code-editor/editor-all.js +52 -0
- package/dist/cjs/components/code-editor/editor-json.js +71 -0
- package/dist/cjs/components/code-editor/editor-python.js +63 -0
- package/dist/cjs/components/code-editor/editor-shell.js +63 -0
- package/dist/cjs/components/code-editor/editor-sql.js +71 -0
- package/dist/cjs/components/code-editor/editor-ts.js +80 -0
- package/dist/cjs/components/code-editor/editor.js +45 -57
- package/dist/cjs/components/code-editor/factory.js +96 -0
- package/dist/cjs/components/code-editor/index.js +31 -28
- package/dist/cjs/components/code-editor/theme/dark.js +120 -50
- package/dist/cjs/components/code-editor/theme/light.js +110 -61
- package/dist/cjs/components/code-editor/utils.js +1 -0
- package/dist/cjs/components/condition-context/context.js +59 -0
- package/dist/cjs/components/condition-context/hooks/use-condition.js +97 -0
- package/dist/cjs/components/condition-context/index.js +47 -0
- package/dist/cjs/components/condition-context/op.js +117 -0
- package/dist/cjs/components/condition-row/index.js +43 -26
- package/dist/cjs/components/condition-row/types.js +1 -35
- package/dist/cjs/components/{prompt-editor-with-inputs/inputs-picker.js → coze-editor-extensions/extensions/inputs-tree.js} +70 -2
- package/dist/cjs/components/{prompt-editor-with-variables → coze-editor-extensions}/extensions/variable-tag.js +4 -3
- package/dist/cjs/components/{prompt-editor-with-variables → coze-editor-extensions}/extensions/variable-tree.js +13 -7
- package/dist/cjs/components/coze-editor-extensions/index.js +86 -0
- package/dist/cjs/components/db-condition-row/index.js +59 -34
- package/dist/cjs/components/display-schema-tree/index.js +2 -2
- package/dist/cjs/components/index.js +49 -4
- package/dist/cjs/components/json-editor-with-variables/editor.js +10 -7
- package/dist/cjs/components/prompt-editor-with-inputs/editor.js +2 -2
- package/dist/cjs/components/prompt-editor-with-variables/editor.js +3 -4
- package/dist/cjs/components/{condition-row/hooks/useRule.js → sql-editor-with-variables/editor.js} +19 -34
- package/dist/cjs/components/sql-editor-with-variables/index.js +57 -0
- package/dist/cjs/components/type-selector/index.js +2 -2
- package/dist/cjs/components/variable-selector/use-variable-tree.js +1 -2
- package/dist/cjs/effects/provide-batch-input/index.js +1 -1
- package/dist/cjs/effects/provide-json-schema-outputs/index.js +1 -1
- package/dist/cjs/form-plugins/batch-outputs-plugin/index.js +9 -2
- package/dist/cjs/form-plugins/infer-assign-plugin/index.js +1 -1
- package/dist/cjs/form-plugins/infer-inputs-plugin/index.js +30 -3
- package/dist/cjs/index.js +44 -2
- package/dist/cjs/plugins/json-schema-preset/create-type-preset-plugin.js +1 -0
- package/dist/cjs/plugins/json-schema-preset/index.js +3 -13
- package/dist/cjs/{components/code-editor/init-worker.js → plugins/json-schema-preset/react.js} +18 -23
- package/dist/cjs/plugins/json-schema-preset/type-definition/array.js +33 -4
- package/dist/cjs/plugins/json-schema-preset/type-definition/boolean.js +23 -0
- package/dist/cjs/plugins/json-schema-preset/type-definition/date-time.js +31 -2
- package/dist/cjs/plugins/json-schema-preset/type-definition/index.js +9 -1
- package/dist/cjs/plugins/json-schema-preset/type-definition/integer.js +34 -1
- package/dist/cjs/plugins/json-schema-preset/type-definition/map.js +54 -0
- package/dist/cjs/plugins/json-schema-preset/type-definition/number.js +34 -1
- package/dist/cjs/plugins/json-schema-preset/type-definition/object.js +9 -4
- package/dist/cjs/plugins/json-schema-preset/type-definition/string.js +30 -1
- package/dist/cjs/plugins/json-schema-preset/types.js +18 -0
- package/dist/cjs/shared/flow-value/utils.js +22 -8
- package/dist/cjs/shared/inject-material/index.js +2 -1
- package/dist/esm/components/blur-input/index.mjs +2 -2
- package/dist/esm/components/code-editor/editor-all.mjs +18 -0
- package/dist/esm/components/code-editor/editor-json.mjs +16 -0
- package/dist/esm/components/code-editor/editor-python.mjs +8 -0
- package/dist/esm/components/code-editor/editor-shell.mjs +8 -0
- package/dist/esm/components/code-editor/editor-sql.mjs +16 -0
- package/dist/esm/components/code-editor/editor-ts.mjs +22 -0
- package/dist/esm/components/code-editor/editor.mjs +38 -33
- package/dist/esm/components/code-editor/factory.mjs +36 -0
- package/dist/esm/components/code-editor/index.mjs +8 -5
- package/dist/esm/components/code-editor/theme/dark.mjs +117 -50
- package/dist/esm/components/code-editor/theme/light.mjs +108 -62
- package/dist/esm/components/code-editor/utils.mjs +1 -0
- package/dist/esm/components/condition-context/context.mjs +19 -0
- package/dist/esm/components/condition-context/hooks/use-condition.mjs +63 -0
- package/dist/esm/components/condition-context/index.mjs +4 -0
- package/dist/esm/components/condition-context/op.mjs +80 -0
- package/dist/esm/components/condition-row/index.mjs +45 -28
- package/dist/esm/components/condition-row/types.mjs +0 -18
- package/dist/esm/components/coze-editor-extensions/extensions/inputs-tree.mjs +135 -0
- package/dist/esm/components/{json-editor-with-variables → coze-editor-extensions}/extensions/variable-tag.mjs +4 -3
- package/dist/esm/components/{prompt-editor-with-variables → coze-editor-extensions}/extensions/variable-tree.mjs +13 -7
- package/dist/esm/components/coze-editor-extensions/index.mjs +18 -0
- package/dist/esm/components/db-condition-row/index.mjs +59 -34
- package/dist/esm/components/display-schema-tree/index.mjs +1 -1
- package/dist/esm/components/index.mjs +5 -2
- package/dist/esm/components/json-editor-with-variables/editor.mjs +10 -7
- package/dist/esm/components/prompt-editor-with-inputs/editor.mjs +2 -2
- package/dist/esm/components/prompt-editor-with-variables/editor.mjs +3 -4
- package/dist/esm/components/sql-editor-with-variables/editor.mjs +19 -0
- package/dist/esm/components/sql-editor-with-variables/index.mjs +5 -0
- package/dist/esm/components/type-selector/index.mjs +1 -1
- package/dist/esm/components/variable-selector/use-variable-tree.mjs +1 -2
- package/dist/esm/effects/provide-batch-input/index.mjs +2 -2
- package/dist/esm/effects/provide-json-schema-outputs/index.mjs +2 -2
- package/dist/esm/form-plugins/batch-outputs-plugin/index.mjs +10 -3
- package/dist/esm/form-plugins/infer-assign-plugin/index.mjs +2 -2
- package/dist/esm/form-plugins/infer-inputs-plugin/index.mjs +31 -4
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/plugins/json-schema-preset/create-type-preset-plugin.mjs +2 -1
- package/dist/esm/plugins/json-schema-preset/index.mjs +3 -13
- package/dist/esm/plugins/json-schema-preset/react.mjs +14 -0
- package/dist/esm/plugins/json-schema-preset/type-definition/array.mjs +33 -4
- package/dist/esm/plugins/json-schema-preset/type-definition/boolean.mjs +23 -0
- package/dist/esm/plugins/json-schema-preset/type-definition/date-time.mjs +31 -2
- package/dist/esm/plugins/json-schema-preset/type-definition/index.mjs +7 -2
- package/dist/esm/plugins/json-schema-preset/type-definition/integer.mjs +34 -1
- package/dist/esm/plugins/json-schema-preset/type-definition/map.mjs +20 -0
- package/dist/esm/plugins/json-schema-preset/type-definition/number.mjs +34 -1
- package/dist/esm/plugins/json-schema-preset/type-definition/object.mjs +9 -4
- package/dist/esm/plugins/json-schema-preset/type-definition/string.mjs +30 -1
- package/dist/esm/plugins/json-schema-preset/types.mjs +0 -0
- package/dist/esm/shared/flow-value/utils.mjs +22 -8
- package/dist/esm/shared/inject-material/index.mjs +2 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/components/blur-input/index.d.ts +7 -1
- package/dist/types/components/code-editor/editor-all.d.ts +8 -0
- package/dist/types/components/code-editor/editor-json.d.ts +6 -0
- package/dist/types/components/code-editor/editor-python.d.ts +6 -0
- package/dist/types/components/code-editor/editor-shell.d.ts +6 -0
- package/dist/types/components/code-editor/editor-sql.d.ts +6 -0
- package/dist/types/components/code-editor/editor-ts.d.ts +6 -0
- package/dist/types/components/code-editor/editor.d.ts +3 -4
- package/dist/types/components/code-editor/factory.d.ts +13 -0
- package/dist/types/components/code-editor/index.d.ts +7 -2
- package/dist/types/components/code-editor/theme/dark.d.ts +29 -0
- package/dist/types/components/code-editor/theme/light.d.ts +24 -0
- package/dist/types/components/code-editor/utils.d.ts +1 -1
- package/dist/types/components/code-editor-mini/index.d.ts +3 -0
- package/dist/types/components/condition-context/context.d.ts +14 -0
- package/dist/types/components/condition-context/hooks/use-condition.d.ts +29 -0
- package/dist/types/components/condition-context/index.d.ts +8 -0
- package/dist/types/components/condition-context/op.d.ts +22 -0
- package/dist/types/components/condition-context/types.d.ts +14 -0
- package/dist/types/components/condition-row/index.d.ts +4 -7
- package/dist/types/components/condition-row/types.d.ts +0 -24
- package/dist/types/components/{prompt-editor-with-inputs/inputs-picker.d.ts → coze-editor-extensions/extensions/inputs-tree.d.ts} +5 -0
- package/dist/types/components/{json-editor-with-variables → coze-editor-extensions}/extensions/variable-tree.d.ts +3 -1
- package/dist/types/components/coze-editor-extensions/index.d.ts +18 -0
- package/dist/types/components/db-condition-row/index.d.ts +4 -3
- package/dist/types/components/db-condition-row/types.d.ts +0 -8
- package/dist/types/components/display-schema-tree/index.d.ts +1 -1
- package/dist/types/components/dynamic-value-input/index.d.ts +3 -1
- package/dist/types/components/index.d.ts +4 -1
- package/dist/types/components/sql-editor-with-variables/editor.d.ts +9 -0
- package/dist/types/components/sql-editor-with-variables/index.d.ts +6 -0
- package/dist/types/components/type-selector/index.d.ts +3 -1
- package/dist/types/components/variable-selector/index.d.ts +4 -2
- package/dist/types/form-plugins/batch-outputs-plugin/index.d.ts +4 -0
- package/dist/types/form-plugins/infer-inputs-plugin/index.d.ts +4 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/create-type-preset-plugin.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/index.d.ts +3 -7
- package/dist/types/plugins/json-schema-preset/react.d.ts +11 -0
- package/dist/types/plugins/json-schema-preset/type-definition/array.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/boolean.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/date-time.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/index.d.ts +3 -1
- package/dist/types/plugins/json-schema-preset/type-definition/integer.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/map.d.ts +6 -0
- package/dist/types/plugins/json-schema-preset/type-definition/number.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/object.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/string.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/{manager.d.ts → types.d.ts} +5 -0
- package/dist/types/shared/flow-value/utils.d.ts +3 -1
- package/dist/types/shared/inject-material/index.d.ts +6 -4
- package/dist/types/validate/validate-flow-value/index.d.ts +1 -1
- package/package.json +56 -17
- package/src/components/blur-input/index.tsx +9 -1
- package/src/components/code-editor/editor-all.tsx +30 -0
- package/src/components/code-editor/editor-json.tsx +25 -0
- package/src/components/code-editor/editor-python.tsx +18 -0
- package/src/components/code-editor/editor-shell.tsx +18 -0
- package/src/components/code-editor/editor-sql.tsx +24 -0
- package/src/components/code-editor/editor-ts.tsx +31 -0
- package/src/components/code-editor/editor.tsx +45 -36
- package/src/components/code-editor/factory.tsx +61 -0
- package/src/components/code-editor/index.tsx +7 -7
- package/src/components/code-editor/theme/dark.ts +62 -77
- package/src/components/code-editor/theme/light.ts +60 -91
- package/src/components/code-editor/utils.ts +4 -0
- package/src/components/code-editor-mini/index.tsx +3 -0
- package/src/components/condition-context/context.tsx +28 -0
- package/src/components/condition-context/hooks/use-condition.tsx +99 -0
- package/src/components/condition-context/index.tsx +14 -0
- package/src/components/condition-context/op.ts +86 -0
- package/src/components/condition-context/types.ts +22 -0
- package/src/components/condition-row/index.tsx +44 -22
- package/src/components/condition-row/types.ts +0 -30
- package/src/components/{prompt-editor-with-inputs/inputs-picker.tsx → coze-editor-extensions/extensions/inputs-tree.tsx} +95 -5
- package/src/components/{prompt-editor-with-variables → coze-editor-extensions}/extensions/variable-tag.tsx +6 -3
- package/src/components/{prompt-editor-with-variables → coze-editor-extensions}/extensions/variable-tree.tsx +12 -3
- package/src/components/coze-editor-extensions/index.tsx +33 -0
- package/src/components/db-condition-row/index.tsx +76 -24
- package/src/components/db-condition-row/types.ts +0 -13
- package/src/components/display-schema-tree/index.tsx +6 -4
- package/src/components/index.ts +29 -1
- package/src/components/json-editor-with-variables/editor.tsx +7 -8
- package/src/components/prompt-editor-with-inputs/editor.tsx +2 -3
- package/src/components/prompt-editor-with-variables/editor.tsx +3 -5
- package/src/components/sql-editor-with-variables/editor.tsx +28 -0
- package/src/components/sql-editor-with-variables/index.tsx +12 -0
- package/src/components/type-selector/index.tsx +2 -3
- package/src/components/variable-selector/index.tsx +2 -2
- package/src/components/variable-selector/use-variable-tree.tsx +7 -4
- package/src/effects/provide-batch-input/index.ts +1 -2
- package/src/effects/provide-json-schema-outputs/index.ts +1 -2
- package/src/form-plugins/batch-outputs-plugin/index.ts +64 -46
- package/src/form-plugins/infer-assign-plugin/index.ts +1 -2
- package/src/form-plugins/infer-inputs-plugin/index.ts +62 -14
- package/src/index.ts +19 -0
- package/src/plugins/json-schema-preset/create-type-preset-plugin.tsx +4 -2
- package/src/plugins/json-schema-preset/index.tsx +4 -20
- package/src/plugins/json-schema-preset/react.tsx +31 -0
- package/src/plugins/json-schema-preset/type-definition/array.tsx +13 -4
- package/src/plugins/json-schema-preset/type-definition/boolean.tsx +17 -1
- package/src/plugins/json-schema-preset/type-definition/date-time.tsx +21 -2
- package/src/plugins/json-schema-preset/type-definition/index.tsx +10 -1
- package/src/plugins/json-schema-preset/type-definition/integer.tsx +19 -1
- package/src/plugins/json-schema-preset/type-definition/map.tsx +31 -0
- package/src/plugins/json-schema-preset/type-definition/number.tsx +19 -1
- package/src/plugins/json-schema-preset/type-definition/object.tsx +9 -4
- package/src/plugins/json-schema-preset/type-definition/string.tsx +19 -1
- package/src/plugins/json-schema-preset/{manager.ts → types.ts} +7 -0
- package/src/shared/flow-value/utils.ts +22 -9
- package/src/shared/inject-material/index.tsx +10 -6
- package/src/validate/validate-flow-value/index.tsx +1 -2
- package/dist/cjs/components/code-editor/language-features.js +0 -21
- package/dist/cjs/components/condition-row/constants.js +0 -165
- package/dist/cjs/components/condition-row/hooks/useOp.js +0 -78
- package/dist/cjs/components/db-condition-row/hooks/use-left.js +0 -86
- package/dist/cjs/components/db-condition-row/hooks/use-op.js +0 -79
- package/dist/cjs/components/json-editor-with-variables/extensions/variable-tag.js +0 -151
- package/dist/cjs/components/json-editor-with-variables/extensions/variable-tree.js +0 -97
- package/dist/cjs/components/prompt-editor-with-inputs/extensions/inputs-tree.js +0 -101
- package/dist/cjs/components/prompt-editor-with-variables/styles.js +0 -89
- package/dist/esm/components/code-editor/init-worker.mjs +0 -19
- package/dist/esm/components/code-editor/language-features.mjs +0 -15
- package/dist/esm/components/condition-row/constants.mjs +0 -128
- package/dist/esm/components/condition-row/hooks/useOp.mjs +0 -44
- package/dist/esm/components/condition-row/hooks/useRule.mjs +0 -34
- package/dist/esm/components/db-condition-row/hooks/use-left.mjs +0 -52
- package/dist/esm/components/db-condition-row/hooks/use-op.mjs +0 -45
- package/dist/esm/components/json-editor-with-variables/extensions/variable-tree.mjs +0 -63
- package/dist/esm/components/prompt-editor-with-inputs/extensions/inputs-tree.mjs +0 -67
- package/dist/esm/components/prompt-editor-with-inputs/inputs-picker.mjs +0 -70
- package/dist/esm/components/prompt-editor-with-variables/extensions/variable-tag.mjs +0 -117
- package/dist/esm/components/prompt-editor-with-variables/styles.mjs +0 -36
- package/dist/types/components/code-editor/init-worker.d.ts +0 -5
- package/dist/types/components/code-editor/language-features.d.ts +0 -5
- package/dist/types/components/condition-row/constants.d.ts +0 -7
- package/dist/types/components/condition-row/hooks/useOp.d.ts +0 -18
- package/dist/types/components/condition-row/hooks/useRule.d.ts +0 -9
- package/dist/types/components/db-condition-row/hooks/use-left.d.ts +0 -18
- package/dist/types/components/db-condition-row/hooks/use-op.d.ts +0 -18
- package/dist/types/components/prompt-editor-with-inputs/extensions/inputs-tree.d.ts +0 -9
- package/dist/types/components/prompt-editor-with-variables/extensions/variable-tag.d.ts +0 -5
- package/dist/types/components/prompt-editor-with-variables/extensions/variable-tree.d.ts +0 -6
- package/dist/types/components/prompt-editor-with-variables/styles.d.ts +0 -9
- package/src/components/code-editor/init-worker.ts +0 -27
- package/src/components/code-editor/language-features.ts +0 -23
- package/src/components/condition-row/constants.ts +0 -134
- package/src/components/condition-row/hooks/useOp.tsx +0 -56
- package/src/components/condition-row/hooks/useRule.ts +0 -35
- package/src/components/db-condition-row/hooks/use-left.tsx +0 -66
- package/src/components/db-condition-row/hooks/use-op.tsx +0 -59
- package/src/components/json-editor-with-variables/extensions/variable-tag.tsx +0 -174
- package/src/components/json-editor-with-variables/extensions/variable-tree.tsx +0 -83
- package/src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx +0 -94
- package/src/components/prompt-editor-with-variables/styles.tsx +0 -44
- /package/dist/cjs/{plugins/json-schema-preset/manager.js → components/condition-context/types.js} +0 -0
- /package/dist/cjs/components/{json-editor-with-variables → coze-editor-extensions}/styles.js +0 -0
- /package/dist/esm/{plugins/json-schema-preset/manager.mjs → components/condition-context/types.mjs} +0 -0
- /package/dist/esm/components/{json-editor-with-variables → coze-editor-extensions}/styles.mjs +0 -0
- /package/dist/types/components/{json-editor-with-variables → coze-editor-extensions}/extensions/variable-tag.d.ts +0 -0
- /package/dist/types/components/{json-editor-with-variables → coze-editor-extensions}/styles.d.ts +0 -0
- /package/src/components/{json-editor-with-variables → coze-editor-extensions}/styles.tsx +0 -0
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { set } from 'lodash-es';
|
|
7
|
+
import { JsonSchemaUtils } from '@flowgram.ai/json-schema';
|
|
6
8
|
import {
|
|
7
9
|
ASTFactory,
|
|
8
10
|
createEffectFromVariableProvider,
|
|
9
11
|
defineFormPluginCreator,
|
|
10
12
|
FlowNodeRegistry,
|
|
11
|
-
getNodeForm,
|
|
12
13
|
getNodePrivateScope,
|
|
13
14
|
getNodeScope,
|
|
14
15
|
ScopeChainTransformService,
|
|
@@ -24,7 +25,7 @@ export const provideBatchOutputsEffect: EffectOptions[] = createEffectFromVariab
|
|
|
24
25
|
ASTFactory.createVariableDeclaration({
|
|
25
26
|
key: `${ctx.node.id}`,
|
|
26
27
|
meta: {
|
|
27
|
-
title:
|
|
28
|
+
title: ctx.node.form?.getValueIn('title'),
|
|
28
29
|
icon: ctx.node.getNodeRegistry<FlowNodeRegistry>().info?.icon,
|
|
29
30
|
},
|
|
30
31
|
type: ASTFactory.createObject({
|
|
@@ -46,59 +47,76 @@ export const provideBatchOutputsEffect: EffectOptions[] = createEffectFromVariab
|
|
|
46
47
|
/**
|
|
47
48
|
* Free Layout only right now
|
|
48
49
|
*/
|
|
49
|
-
export const createBatchOutputsFormPlugin: FormPluginCreator<{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
export const createBatchOutputsFormPlugin: FormPluginCreator<{
|
|
51
|
+
outputKey: string;
|
|
52
|
+
/**
|
|
53
|
+
* if set, infer json schema to inferTargetKey when submit
|
|
54
|
+
*/
|
|
55
|
+
inferTargetKey?: string;
|
|
56
|
+
}> = defineFormPluginCreator({
|
|
57
|
+
name: 'batch-outputs-plugin',
|
|
58
|
+
onSetupFormMeta({ mergeEffect, addFormatOnSubmit }, { outputKey, inferTargetKey }) {
|
|
59
|
+
mergeEffect({
|
|
60
|
+
[outputKey]: provideBatchOutputsEffect,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
if (inferTargetKey) {
|
|
64
|
+
addFormatOnSubmit((formData, ctx) => {
|
|
65
|
+
const outputVariable = getNodeScope(ctx.node).output.variables?.[0];
|
|
66
|
+
|
|
67
|
+
if (outputVariable?.type) {
|
|
68
|
+
set(formData, inferTargetKey, JsonSchemaUtils.astToSchema(outputVariable?.type));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return formData;
|
|
55
72
|
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
onInit(ctx, { outputKey }) {
|
|
76
|
+
const chainTransformService = ctx.node.getService(ScopeChainTransformService);
|
|
59
77
|
|
|
60
|
-
|
|
78
|
+
const batchNodeType = ctx.node.flowNodeType;
|
|
61
79
|
|
|
62
|
-
|
|
80
|
+
const transformerId = `${batchNodeType}-outputs`;
|
|
63
81
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
82
|
+
if (chainTransformService.hasTransformer(transformerId)) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
67
85
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
86
|
+
chainTransformService.registerTransformer(transformerId, {
|
|
87
|
+
transformCovers: (covers, ctx) => {
|
|
88
|
+
const node = ctx.scope.meta?.node;
|
|
71
89
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
90
|
+
// Child Node's variable can cover parent
|
|
91
|
+
if (node?.parent?.flowNodeType === batchNodeType) {
|
|
92
|
+
return [...covers, getNodeScope(node.parent)];
|
|
93
|
+
}
|
|
76
94
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
95
|
+
return covers;
|
|
96
|
+
},
|
|
97
|
+
transformDeps(scopes, ctx) {
|
|
98
|
+
const scopeMeta = ctx.scope.meta;
|
|
81
99
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
100
|
+
if (scopeMeta?.type === FlowNodeScopeType.private) {
|
|
101
|
+
return scopes;
|
|
102
|
+
}
|
|
85
103
|
|
|
86
|
-
|
|
104
|
+
const node = scopeMeta?.node;
|
|
87
105
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
106
|
+
// Public of Loop Node depends on child Node
|
|
107
|
+
if (node?.flowNodeType === batchNodeType) {
|
|
108
|
+
// Get all child blocks
|
|
109
|
+
const childBlocks = node.blocks;
|
|
92
110
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
111
|
+
// public scope of all child blocks
|
|
112
|
+
return [
|
|
113
|
+
getNodePrivateScope(node),
|
|
114
|
+
...childBlocks.map((_childBlock) => getNodeScope(_childBlock)),
|
|
115
|
+
];
|
|
116
|
+
}
|
|
99
117
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
118
|
+
return scopes;
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
},
|
|
122
|
+
});
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
createEffectFromVariableProvider,
|
|
11
11
|
defineFormPluginCreator,
|
|
12
12
|
FlowNodeRegistry,
|
|
13
|
-
getNodeForm,
|
|
14
13
|
getNodeScope,
|
|
15
14
|
} from '@flowgram.ai/editor';
|
|
16
15
|
|
|
@@ -51,7 +50,7 @@ export const createInferAssignPlugin = defineFormPluginCreator<InputConfig>({
|
|
|
51
50
|
ASTFactory.createVariableDeclaration({
|
|
52
51
|
key: `${ctx.node.id}`,
|
|
53
52
|
meta: {
|
|
54
|
-
title:
|
|
53
|
+
title: ctx.node.form?.getValueIn('title'),
|
|
55
54
|
icon: ctx.node.getNodeRegistry<FlowNodeRegistry>().info?.icon,
|
|
56
55
|
},
|
|
57
56
|
type: ASTFactory.createObject({
|
|
@@ -3,34 +3,82 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { get, set } from 'lodash-es';
|
|
6
|
+
import { get, omit, set } from 'lodash-es';
|
|
7
|
+
import { Immer } from 'immer';
|
|
7
8
|
import { defineFormPluginCreator, getNodePrivateScope, getNodeScope } from '@flowgram.ai/editor';
|
|
8
9
|
|
|
9
10
|
import { FlowValueUtils } from '@/shared';
|
|
10
11
|
|
|
12
|
+
const { produce } = new Immer({ autoFreeze: false });
|
|
13
|
+
|
|
11
14
|
interface InputConfig {
|
|
12
15
|
sourceKey: string;
|
|
13
16
|
targetKey: string;
|
|
14
17
|
scope?: 'private' | 'public';
|
|
18
|
+
/**
|
|
19
|
+
* For backend runtime, constant schema is redundant, so we can choose to ignore it
|
|
20
|
+
*/
|
|
21
|
+
ignoreConstantSchema?: boolean;
|
|
15
22
|
}
|
|
16
23
|
|
|
17
24
|
export const createInferInputsPlugin = defineFormPluginCreator<InputConfig>({
|
|
18
|
-
onSetupFormMeta(
|
|
25
|
+
onSetupFormMeta(
|
|
26
|
+
{ addFormatOnSubmit, addFormatOnInit },
|
|
27
|
+
{ sourceKey, targetKey, scope, ignoreConstantSchema }
|
|
28
|
+
) {
|
|
19
29
|
if (!sourceKey || !targetKey) {
|
|
20
30
|
return;
|
|
21
31
|
}
|
|
22
32
|
|
|
23
|
-
addFormatOnSubmit((formData, ctx) =>
|
|
24
|
-
|
|
25
|
-
formData,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
addFormatOnSubmit((formData, ctx) =>
|
|
34
|
+
produce(formData, (draft: any) => {
|
|
35
|
+
const sourceData = get(formData, sourceKey);
|
|
36
|
+
|
|
37
|
+
set(
|
|
38
|
+
draft,
|
|
39
|
+
targetKey,
|
|
40
|
+
FlowValueUtils.inferJsonSchema(
|
|
41
|
+
sourceData,
|
|
42
|
+
scope === 'private' ? getNodePrivateScope(ctx.node) : getNodeScope(ctx.node)
|
|
43
|
+
)
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
if (ignoreConstantSchema) {
|
|
47
|
+
for (const { value, path } of FlowValueUtils.traverse(sourceData, {
|
|
48
|
+
includeTypes: ['constant'],
|
|
49
|
+
})) {
|
|
50
|
+
if (FlowValueUtils.isConstant(value) && value?.schema) {
|
|
51
|
+
set(formData, `${sourceKey}.${path}`, omit(value, ['schema']));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
if (ignoreConstantSchema) {
|
|
59
|
+
// Revert Schema in frontend
|
|
60
|
+
addFormatOnInit((formData, ctx) => {
|
|
61
|
+
const targetSchema = get(formData, targetKey);
|
|
62
|
+
|
|
63
|
+
if (!targetSchema) {
|
|
64
|
+
return formData;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// For backend data, it's not necessary to use immer
|
|
68
|
+
for (const { value, pathArr } of FlowValueUtils.traverse(get(formData, sourceKey), {
|
|
69
|
+
includeTypes: ['constant'],
|
|
70
|
+
})) {
|
|
71
|
+
if (FlowValueUtils.isConstant(value) && !value?.schema) {
|
|
72
|
+
const schemaPath = pathArr.map((_item) => `properties.${_item}`).join('.');
|
|
73
|
+
const schema = get(targetSchema, schemaPath);
|
|
74
|
+
if (schema) {
|
|
75
|
+
set(value, 'schema', schema);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return formData;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
35
83
|
},
|
|
36
84
|
});
|
package/src/index.ts
CHANGED
|
@@ -6,11 +6,14 @@
|
|
|
6
6
|
export {
|
|
7
7
|
AssignRow,
|
|
8
8
|
AssignRows,
|
|
9
|
+
BaseCodeEditor,
|
|
9
10
|
BatchOutputs,
|
|
10
11
|
BatchVariableSelector,
|
|
11
12
|
BlurInput,
|
|
12
13
|
CodeEditor,
|
|
13
14
|
CodeEditorMini,
|
|
15
|
+
ConditionPresetOp,
|
|
16
|
+
ConditionProvider,
|
|
14
17
|
ConditionRow,
|
|
15
18
|
ConstantInput,
|
|
16
19
|
DBConditionRow,
|
|
@@ -21,16 +24,25 @@ export {
|
|
|
21
24
|
DisplaySchemaTag,
|
|
22
25
|
DisplaySchemaTree,
|
|
23
26
|
DynamicValueInput,
|
|
27
|
+
EditorInputsTree,
|
|
28
|
+
EditorVariableTagInject,
|
|
29
|
+
EditorVariableTree,
|
|
24
30
|
InjectDynamicValueInput,
|
|
25
31
|
InjectTypeSelector,
|
|
26
32
|
InjectVariableSelector,
|
|
27
33
|
InputsValues,
|
|
28
34
|
InputsValuesTree,
|
|
35
|
+
JsonCodeEditor,
|
|
29
36
|
JsonEditorWithVariables,
|
|
30
37
|
JsonSchemaEditor,
|
|
31
38
|
PromptEditor,
|
|
32
39
|
PromptEditorWithInputs,
|
|
33
40
|
PromptEditorWithVariables,
|
|
41
|
+
PythonCodeEditor,
|
|
42
|
+
SQLCodeEditor,
|
|
43
|
+
SQLEditorWithVariables,
|
|
44
|
+
ShellCodeEditor,
|
|
45
|
+
TypeScriptCodeEditor,
|
|
34
46
|
TypeSelector,
|
|
35
47
|
VariableSelector,
|
|
36
48
|
VariableSelectorProvider,
|
|
@@ -38,16 +50,23 @@ export {
|
|
|
38
50
|
parseTypeSelectValue,
|
|
39
51
|
type AssignValueType,
|
|
40
52
|
type CodeEditorPropsType,
|
|
53
|
+
type ConditionOpConfig,
|
|
54
|
+
type ConditionOpConfigs,
|
|
41
55
|
type ConditionRowValueType,
|
|
42
56
|
type ConstantInputStrategy,
|
|
43
57
|
type DBConditionOptionType,
|
|
44
58
|
type DBConditionRowValueType,
|
|
59
|
+
type IConditionRule,
|
|
60
|
+
type IConditionRuleFactory,
|
|
45
61
|
type JsonEditorWithVariablesProps,
|
|
46
62
|
type PromptEditorPropsType,
|
|
47
63
|
type PromptEditorWithInputsProps,
|
|
48
64
|
type PromptEditorWithVariablesProps,
|
|
65
|
+
type SQLEditorWithVariablesProps,
|
|
49
66
|
type TypeSelectorProps,
|
|
50
67
|
type VariableSelectorProps,
|
|
68
|
+
useCondition,
|
|
69
|
+
useConditionContext,
|
|
51
70
|
useVariableTree,
|
|
52
71
|
} from './components';
|
|
53
72
|
export {
|
|
@@ -10,8 +10,10 @@ import {
|
|
|
10
10
|
} from '@flowgram.ai/json-schema';
|
|
11
11
|
import { definePluginCreator } from '@flowgram.ai/editor';
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
13
|
+
import { JsonSchemaTypeRegistry } from './types';
|
|
14
|
+
import { initRegistries, jsonSchemaTypePreset } from './type-definition';
|
|
15
|
+
|
|
16
|
+
initRegistries();
|
|
15
17
|
|
|
16
18
|
export const createTypePresetPlugin = definePluginCreator<{
|
|
17
19
|
types?: Partial<JsonSchemaTypeRegistry> & Pick<JsonSchemaTypeRegistry, 'type'>[];
|
|
@@ -2,33 +2,17 @@
|
|
|
2
2
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
|
-
import React from 'react';
|
|
6
5
|
|
|
7
6
|
import {
|
|
8
|
-
type IJsonSchema,
|
|
9
|
-
JsonSchemaUtils,
|
|
10
|
-
useTypeManager as useOriginTypeManager,
|
|
11
|
-
TypePresetProvider as OriginTypePresetProvider,
|
|
12
|
-
JsonSchemaTypeManager,
|
|
13
7
|
type JsonSchemaBasicType,
|
|
8
|
+
JsonSchemaUtils,
|
|
9
|
+
type IJsonSchema,
|
|
14
10
|
} from '@flowgram.ai/json-schema';
|
|
15
11
|
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
12
|
+
import { type ConstantRendererProps, type JsonSchemaTypeRegistry } from './types';
|
|
13
|
+
import { useTypeManager, JsonSchemaTypePresetProvider } from './react';
|
|
18
14
|
import { createTypePresetPlugin } from './create-type-preset-plugin';
|
|
19
15
|
|
|
20
|
-
const useTypeManager = () =>
|
|
21
|
-
useOriginTypeManager() as JsonSchemaTypeManager<IJsonSchema, JsonSchemaTypeRegistry>;
|
|
22
|
-
|
|
23
|
-
const JsonSchemaTypePresetProvider = ({
|
|
24
|
-
types = [],
|
|
25
|
-
children,
|
|
26
|
-
}: React.PropsWithChildren<{ types: JsonSchemaTypeRegistry[] }>) => (
|
|
27
|
-
<OriginTypePresetProvider types={[...jsonSchemaTypePreset, ...types]}>
|
|
28
|
-
{children}
|
|
29
|
-
</OriginTypePresetProvider>
|
|
30
|
-
);
|
|
31
|
-
|
|
32
16
|
export {
|
|
33
17
|
createTypePresetPlugin,
|
|
34
18
|
useTypeManager,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
type IJsonSchema,
|
|
10
|
+
useTypeManager as useOriginTypeManager,
|
|
11
|
+
TypePresetProvider as OriginTypePresetProvider,
|
|
12
|
+
JsonSchemaTypeManager,
|
|
13
|
+
} from '@flowgram.ai/json-schema';
|
|
14
|
+
|
|
15
|
+
import { type JsonSchemaTypeRegistry } from './types';
|
|
16
|
+
import { initRegistries, jsonSchemaTypePreset } from './type-definition';
|
|
17
|
+
|
|
18
|
+
// If you want to use new type Manager, init registries
|
|
19
|
+
initRegistries();
|
|
20
|
+
|
|
21
|
+
export const useTypeManager = () =>
|
|
22
|
+
useOriginTypeManager() as JsonSchemaTypeManager<IJsonSchema, JsonSchemaTypeRegistry>;
|
|
23
|
+
|
|
24
|
+
export const JsonSchemaTypePresetProvider = ({
|
|
25
|
+
types = [],
|
|
26
|
+
children,
|
|
27
|
+
}: React.PropsWithChildren<{ types: JsonSchemaTypeRegistry[] }>) => (
|
|
28
|
+
<OriginTypePresetProvider types={[...jsonSchemaTypePreset, ...types]}>
|
|
29
|
+
{children}
|
|
30
|
+
</OriginTypePresetProvider>
|
|
31
|
+
);
|
|
@@ -8,19 +8,28 @@ import React from 'react';
|
|
|
8
8
|
|
|
9
9
|
import { I18n } from '@flowgram.ai/editor';
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { ConditionPresetOp } from '@/components/condition-context/op';
|
|
12
|
+
import { JsonCodeEditor } from '@/components/code-editor';
|
|
12
13
|
|
|
13
|
-
import { type JsonSchemaTypeRegistry } from '../
|
|
14
|
+
import { type JsonSchemaTypeRegistry } from '../types';
|
|
14
15
|
|
|
15
16
|
export const arrayRegistry: Partial<JsonSchemaTypeRegistry> = {
|
|
16
17
|
type: 'array',
|
|
17
18
|
ConstantRenderer: (props) => (
|
|
18
|
-
<
|
|
19
|
+
<JsonCodeEditor
|
|
20
|
+
mini
|
|
19
21
|
value={props.value}
|
|
20
|
-
languageId="json"
|
|
21
22
|
onChange={(v) => props.onChange?.(v)}
|
|
22
23
|
placeholder={I18n.t('Please Input Array')}
|
|
23
24
|
readonly={props.readonly}
|
|
24
25
|
/>
|
|
25
26
|
),
|
|
27
|
+
conditionRule: {
|
|
28
|
+
[ConditionPresetOp.IS_EMPTY]: null,
|
|
29
|
+
[ConditionPresetOp.IS_NOT_EMPTY]: null,
|
|
30
|
+
[ConditionPresetOp.CONTAINS]: { type: 'array', extra: { weak: true } },
|
|
31
|
+
[ConditionPresetOp.NOT_CONTAINS]: { type: 'array', extra: { weak: true } },
|
|
32
|
+
[ConditionPresetOp.EQ]: { type: 'array', extra: { weak: true } },
|
|
33
|
+
[ConditionPresetOp.NEQ]: { type: 'array', extra: { weak: true } },
|
|
34
|
+
},
|
|
26
35
|
};
|
|
@@ -9,7 +9,9 @@ import React from 'react';
|
|
|
9
9
|
import { I18n } from '@flowgram.ai/editor';
|
|
10
10
|
import { Select } from '@douyinfe/semi-ui';
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { ConditionPresetOp } from '@/components/condition-context/op';
|
|
13
|
+
|
|
14
|
+
import { type JsonSchemaTypeRegistry } from '../types';
|
|
13
15
|
|
|
14
16
|
export const booleanRegistry: Partial<JsonSchemaTypeRegistry> = {
|
|
15
17
|
type: 'boolean',
|
|
@@ -30,4 +32,18 @@ export const booleanRegistry: Partial<JsonSchemaTypeRegistry> = {
|
|
|
30
32
|
/>
|
|
31
33
|
);
|
|
32
34
|
},
|
|
35
|
+
conditionRule: {
|
|
36
|
+
[ConditionPresetOp.EQ]: { type: 'boolean' },
|
|
37
|
+
[ConditionPresetOp.NEQ]: { type: 'boolean' },
|
|
38
|
+
[ConditionPresetOp.IS_TRUE]: null,
|
|
39
|
+
[ConditionPresetOp.IS_FALSE]: null,
|
|
40
|
+
[ConditionPresetOp.IN]: {
|
|
41
|
+
type: 'array',
|
|
42
|
+
items: { type: 'boolean' },
|
|
43
|
+
},
|
|
44
|
+
[ConditionPresetOp.NIN]: {
|
|
45
|
+
type: 'array',
|
|
46
|
+
items: { type: 'boolean' },
|
|
47
|
+
},
|
|
48
|
+
},
|
|
33
49
|
};
|
|
@@ -6,20 +6,39 @@
|
|
|
6
6
|
/* eslint-disable react/prop-types */
|
|
7
7
|
import React from 'react';
|
|
8
8
|
|
|
9
|
+
import { format } from 'date-fns';
|
|
10
|
+
import { type DatePickerProps } from '@douyinfe/semi-ui/lib/es/datePicker';
|
|
9
11
|
import { DatePicker } from '@douyinfe/semi-ui';
|
|
10
12
|
|
|
11
|
-
import {
|
|
13
|
+
import { ConditionPresetOp } from '@/components/condition-context/op';
|
|
14
|
+
|
|
15
|
+
import { type JsonSchemaTypeRegistry } from '../types';
|
|
12
16
|
|
|
13
17
|
export const dateTimeRegistry: Partial<JsonSchemaTypeRegistry> = {
|
|
14
18
|
type: 'date-time',
|
|
15
|
-
ConstantRenderer: (props) => (
|
|
19
|
+
ConstantRenderer: (props: DatePickerProps & { readonly?: boolean }) => (
|
|
16
20
|
<DatePicker
|
|
17
21
|
size="small"
|
|
18
22
|
type="dateTime"
|
|
19
23
|
density="compact"
|
|
24
|
+
defaultValue={Date.now()}
|
|
20
25
|
style={{ width: '100%', ...(props.style || {}) }}
|
|
21
26
|
disabled={props.readonly}
|
|
22
27
|
{...props}
|
|
28
|
+
onChange={(date) => {
|
|
29
|
+
props.onChange?.(format(date as Date, "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"));
|
|
30
|
+
}}
|
|
31
|
+
value={props.value}
|
|
23
32
|
/>
|
|
24
33
|
),
|
|
34
|
+
conditionRule: {
|
|
35
|
+
[ConditionPresetOp.EQ]: { type: 'date-time' },
|
|
36
|
+
[ConditionPresetOp.NEQ]: { type: 'date-time' },
|
|
37
|
+
[ConditionPresetOp.GT]: { type: 'date-time' },
|
|
38
|
+
[ConditionPresetOp.GTE]: { type: 'date-time' },
|
|
39
|
+
[ConditionPresetOp.LT]: { type: 'date-time' },
|
|
40
|
+
[ConditionPresetOp.LTE]: { type: 'date-time' },
|
|
41
|
+
[ConditionPresetOp.IS_EMPTY]: null,
|
|
42
|
+
[ConditionPresetOp.IS_NOT_EMPTY]: null,
|
|
43
|
+
},
|
|
25
44
|
};
|
|
@@ -8,10 +8,12 @@ import { jsonSchemaTypeManager } from '@flowgram.ai/json-schema';
|
|
|
8
8
|
import { stringRegistry } from './string';
|
|
9
9
|
import { objectRegistry } from './object';
|
|
10
10
|
import { numberRegistry } from './number';
|
|
11
|
+
import { mapRegistry } from './map';
|
|
11
12
|
import { integerRegistry } from './integer';
|
|
12
13
|
import { dateTimeRegistry } from './date-time';
|
|
13
14
|
import { booleanRegistry } from './boolean';
|
|
14
15
|
import { arrayRegistry } from './array';
|
|
16
|
+
import { type JsonSchemaTypeRegistry } from '../types';
|
|
15
17
|
|
|
16
18
|
export const jsonSchemaTypePreset = [
|
|
17
19
|
stringRegistry,
|
|
@@ -20,7 +22,14 @@ export const jsonSchemaTypePreset = [
|
|
|
20
22
|
integerRegistry,
|
|
21
23
|
booleanRegistry,
|
|
22
24
|
arrayRegistry,
|
|
25
|
+
mapRegistry,
|
|
23
26
|
dateTimeRegistry,
|
|
24
27
|
];
|
|
25
28
|
|
|
26
|
-
|
|
29
|
+
export const initRegistries = () => {
|
|
30
|
+
if ((jsonSchemaTypeManager.getTypeByName('string') as JsonSchemaTypeRegistry)?.ConstantRenderer) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
jsonSchemaTypePreset.forEach((_type) => jsonSchemaTypeManager.register(_type));
|
|
35
|
+
};
|
|
@@ -9,7 +9,9 @@ import React from 'react';
|
|
|
9
9
|
import { I18n } from '@flowgram.ai/editor';
|
|
10
10
|
import { InputNumber } from '@douyinfe/semi-ui';
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { ConditionPresetOp } from '@/components/condition-context/op';
|
|
13
|
+
|
|
14
|
+
import { type JsonSchemaTypeRegistry } from '../types';
|
|
13
15
|
|
|
14
16
|
export const integerRegistry: Partial<JsonSchemaTypeRegistry> = {
|
|
15
17
|
type: 'integer',
|
|
@@ -22,4 +24,20 @@ export const integerRegistry: Partial<JsonSchemaTypeRegistry> = {
|
|
|
22
24
|
{...props}
|
|
23
25
|
/>
|
|
24
26
|
),
|
|
27
|
+
conditionRule: {
|
|
28
|
+
[ConditionPresetOp.EQ]: { type: 'number' },
|
|
29
|
+
[ConditionPresetOp.NEQ]: { type: 'number' },
|
|
30
|
+
[ConditionPresetOp.GT]: { type: 'number' },
|
|
31
|
+
[ConditionPresetOp.GTE]: { type: 'number' },
|
|
32
|
+
[ConditionPresetOp.LT]: { type: 'number' },
|
|
33
|
+
[ConditionPresetOp.LTE]: { type: 'number' },
|
|
34
|
+
[ConditionPresetOp.IN]: {
|
|
35
|
+
type: 'array',
|
|
36
|
+
extra: { weak: true },
|
|
37
|
+
},
|
|
38
|
+
[ConditionPresetOp.NIN]: {
|
|
39
|
+
type: 'array',
|
|
40
|
+
extra: { weak: true },
|
|
41
|
+
},
|
|
42
|
+
},
|
|
25
43
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* eslint-disable react/prop-types */
|
|
7
|
+
import React from 'react';
|
|
8
|
+
|
|
9
|
+
import { I18n } from '@flowgram.ai/editor';
|
|
10
|
+
|
|
11
|
+
import { ConditionPresetOp } from '@/components/condition-context/op';
|
|
12
|
+
import { JsonCodeEditor } from '@/components/code-editor';
|
|
13
|
+
|
|
14
|
+
import { type JsonSchemaTypeRegistry } from '../types';
|
|
15
|
+
|
|
16
|
+
export const mapRegistry: Partial<JsonSchemaTypeRegistry> = {
|
|
17
|
+
type: 'map',
|
|
18
|
+
ConstantRenderer: (props) => (
|
|
19
|
+
<JsonCodeEditor
|
|
20
|
+
mini
|
|
21
|
+
value={props.value}
|
|
22
|
+
onChange={(v) => props.onChange?.(v)}
|
|
23
|
+
placeholder={I18n.t('Please Input Map')}
|
|
24
|
+
readonly={props.readonly}
|
|
25
|
+
/>
|
|
26
|
+
),
|
|
27
|
+
conditionRule: {
|
|
28
|
+
[ConditionPresetOp.IS_EMPTY]: null,
|
|
29
|
+
[ConditionPresetOp.IS_NOT_EMPTY]: null,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
@@ -9,7 +9,9 @@ import React from 'react';
|
|
|
9
9
|
import { I18n } from '@flowgram.ai/editor';
|
|
10
10
|
import { InputNumber } from '@douyinfe/semi-ui';
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { ConditionPresetOp } from '@/components/condition-context/op';
|
|
13
|
+
|
|
14
|
+
import { type JsonSchemaTypeRegistry } from '../types';
|
|
13
15
|
|
|
14
16
|
export const numberRegistry: Partial<JsonSchemaTypeRegistry> = {
|
|
15
17
|
type: 'number',
|
|
@@ -22,4 +24,20 @@ export const numberRegistry: Partial<JsonSchemaTypeRegistry> = {
|
|
|
22
24
|
{...props}
|
|
23
25
|
/>
|
|
24
26
|
),
|
|
27
|
+
conditionRule: {
|
|
28
|
+
[ConditionPresetOp.EQ]: { type: 'number' },
|
|
29
|
+
[ConditionPresetOp.NEQ]: { type: 'number' },
|
|
30
|
+
[ConditionPresetOp.GT]: { type: 'number' },
|
|
31
|
+
[ConditionPresetOp.GTE]: { type: 'number' },
|
|
32
|
+
[ConditionPresetOp.LT]: { type: 'number' },
|
|
33
|
+
[ConditionPresetOp.LTE]: { type: 'number' },
|
|
34
|
+
[ConditionPresetOp.IN]: {
|
|
35
|
+
type: 'array',
|
|
36
|
+
extra: { weak: true },
|
|
37
|
+
},
|
|
38
|
+
[ConditionPresetOp.NIN]: {
|
|
39
|
+
type: 'array',
|
|
40
|
+
extra: { weak: true },
|
|
41
|
+
},
|
|
42
|
+
},
|
|
25
43
|
};
|
|
@@ -8,19 +8,24 @@ import React from 'react';
|
|
|
8
8
|
|
|
9
9
|
import { I18n } from '@flowgram.ai/editor';
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { ConditionPresetOp } from '@/components/condition-context/op';
|
|
12
|
+
import { JsonCodeEditor } from '@/components/code-editor';
|
|
12
13
|
|
|
13
|
-
import { type JsonSchemaTypeRegistry } from '../
|
|
14
|
+
import { type JsonSchemaTypeRegistry } from '../types';
|
|
14
15
|
|
|
15
16
|
export const objectRegistry: Partial<JsonSchemaTypeRegistry> = {
|
|
16
17
|
type: 'object',
|
|
17
18
|
ConstantRenderer: (props) => (
|
|
18
|
-
<
|
|
19
|
+
<JsonCodeEditor
|
|
20
|
+
mini
|
|
19
21
|
value={props.value}
|
|
20
22
|
onChange={(v) => props.onChange?.(v)}
|
|
21
|
-
languageId="json"
|
|
22
23
|
placeholder={I18n.t('Please Input Object')}
|
|
23
24
|
readonly={props.readonly}
|
|
24
25
|
/>
|
|
25
26
|
),
|
|
27
|
+
conditionRule: {
|
|
28
|
+
[ConditionPresetOp.IS_EMPTY]: null,
|
|
29
|
+
[ConditionPresetOp.IS_NOT_EMPTY]: null,
|
|
30
|
+
},
|
|
26
31
|
};
|