@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/esm/index.js
CHANGED
|
@@ -3512,6 +3512,62 @@ var validateWhenVariableSync = ({
|
|
|
3512
3512
|
}
|
|
3513
3513
|
];
|
|
3514
3514
|
|
|
3515
|
+
// src/effects/listen-ref-value-change/index.ts
|
|
3516
|
+
import {
|
|
3517
|
+
DataEvent as DataEvent4,
|
|
3518
|
+
getNodeScope as getNodeScope2
|
|
3519
|
+
} from "@flowgram.ai/editor";
|
|
3520
|
+
var listenRefValueChange = (cb) => [
|
|
3521
|
+
{
|
|
3522
|
+
event: DataEvent4.onValueInitOrChange,
|
|
3523
|
+
effect: (params) => {
|
|
3524
|
+
const { context, value } = params;
|
|
3525
|
+
if (value?.type !== "ref") {
|
|
3526
|
+
return () => null;
|
|
3527
|
+
}
|
|
3528
|
+
const disposable = getNodeScope2(context.node).available.trackByKeyPath(
|
|
3529
|
+
value?.content || [],
|
|
3530
|
+
(v) => {
|
|
3531
|
+
cb({ ...params, variable: v });
|
|
3532
|
+
}
|
|
3533
|
+
);
|
|
3534
|
+
return () => {
|
|
3535
|
+
disposable.dispose();
|
|
3536
|
+
};
|
|
3537
|
+
}
|
|
3538
|
+
}
|
|
3539
|
+
];
|
|
3540
|
+
|
|
3541
|
+
// src/effects/listen-ref-schema-change/index.ts
|
|
3542
|
+
import { JsonSchemaUtils as JsonSchemaUtils8 } from "@flowgram.ai/json-schema";
|
|
3543
|
+
import {
|
|
3544
|
+
DataEvent as DataEvent5,
|
|
3545
|
+
getNodeScope as getNodeScope3
|
|
3546
|
+
} from "@flowgram.ai/editor";
|
|
3547
|
+
var listenRefSchemaChange = (cb) => [
|
|
3548
|
+
{
|
|
3549
|
+
event: DataEvent5.onValueInitOrChange,
|
|
3550
|
+
effect: (params) => {
|
|
3551
|
+
const { context, value } = params;
|
|
3552
|
+
if (value?.type !== "ref") {
|
|
3553
|
+
return () => null;
|
|
3554
|
+
}
|
|
3555
|
+
const disposable = getNodeScope3(context.node).available.trackByKeyPath(
|
|
3556
|
+
value?.content || [],
|
|
3557
|
+
(_type) => {
|
|
3558
|
+
cb({ ...params, schema: JsonSchemaUtils8.astToSchema(_type) });
|
|
3559
|
+
},
|
|
3560
|
+
{
|
|
3561
|
+
selector: (_v) => _v?.type
|
|
3562
|
+
}
|
|
3563
|
+
);
|
|
3564
|
+
return () => {
|
|
3565
|
+
disposable.dispose();
|
|
3566
|
+
};
|
|
3567
|
+
}
|
|
3568
|
+
}
|
|
3569
|
+
];
|
|
3570
|
+
|
|
3515
3571
|
// src/shared/format-legacy-refs/index.ts
|
|
3516
3572
|
import { isObject as isObject3 } from "lodash";
|
|
3517
3573
|
function formatLegacyRefOnSubmit(value) {
|
|
@@ -3581,7 +3637,7 @@ import {
|
|
|
3581
3637
|
defineFormPluginCreator,
|
|
3582
3638
|
getNodeForm as getNodeForm3,
|
|
3583
3639
|
getNodePrivateScope as getNodePrivateScope2,
|
|
3584
|
-
getNodeScope as
|
|
3640
|
+
getNodeScope as getNodeScope4,
|
|
3585
3641
|
ScopeChainTransformService,
|
|
3586
3642
|
FlowNodeScopeType
|
|
3587
3643
|
} from "@flowgram.ai/editor";
|
|
@@ -3626,7 +3682,7 @@ var createBatchOutputsFormPlugin = defineFormPluginCreator({
|
|
|
3626
3682
|
transformCovers: (covers, ctx2) => {
|
|
3627
3683
|
const node = ctx2.scope.meta?.node;
|
|
3628
3684
|
if (node?.parent?.flowNodeType === batchNodeType) {
|
|
3629
|
-
return [...covers,
|
|
3685
|
+
return [...covers, getNodeScope4(node.parent)];
|
|
3630
3686
|
}
|
|
3631
3687
|
return covers;
|
|
3632
3688
|
},
|
|
@@ -3640,7 +3696,7 @@ var createBatchOutputsFormPlugin = defineFormPluginCreator({
|
|
|
3640
3696
|
const childBlocks = node.blocks;
|
|
3641
3697
|
return [
|
|
3642
3698
|
getNodePrivateScope2(node),
|
|
3643
|
-
...childBlocks.map((_childBlock) =>
|
|
3699
|
+
...childBlocks.map((_childBlock) => getNodeScope4(_childBlock))
|
|
3644
3700
|
];
|
|
3645
3701
|
}
|
|
3646
3702
|
return scopes;
|
|
@@ -3651,11 +3707,11 @@ var createBatchOutputsFormPlugin = defineFormPluginCreator({
|
|
|
3651
3707
|
|
|
3652
3708
|
// src/form-plugins/infer-inputs-plugin/index.ts
|
|
3653
3709
|
import { get as get2, set as set2 } from "lodash";
|
|
3654
|
-
import { JsonSchemaUtils as
|
|
3710
|
+
import { JsonSchemaUtils as JsonSchemaUtils9 } from "@flowgram.ai/json-schema";
|
|
3655
3711
|
import {
|
|
3656
3712
|
defineFormPluginCreator as defineFormPluginCreator2,
|
|
3657
3713
|
getNodePrivateScope as getNodePrivateScope3,
|
|
3658
|
-
getNodeScope as
|
|
3714
|
+
getNodeScope as getNodeScope5
|
|
3659
3715
|
} from "@flowgram.ai/editor";
|
|
3660
3716
|
var createInferInputsPlugin = defineFormPluginCreator2({
|
|
3661
3717
|
onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
|
|
@@ -3668,7 +3724,7 @@ var createInferInputsPlugin = defineFormPluginCreator2({
|
|
|
3668
3724
|
targetKey,
|
|
3669
3725
|
infer(
|
|
3670
3726
|
get2(formData, sourceKey),
|
|
3671
|
-
scope === "private" ? getNodePrivateScope3(ctx.node) :
|
|
3727
|
+
scope === "private" ? getNodePrivateScope3(ctx.node) : getNodeScope5(ctx.node)
|
|
3672
3728
|
)
|
|
3673
3729
|
);
|
|
3674
3730
|
return formData;
|
|
@@ -3708,7 +3764,7 @@ var infer = (values, scope) => {
|
|
|
3708
3764
|
}
|
|
3709
3765
|
if (isRef2(values)) {
|
|
3710
3766
|
const variable = scope.available.getByKeyPath(values?.content);
|
|
3711
|
-
const schema = variable?.type ?
|
|
3767
|
+
const schema = variable?.type ? JsonSchemaUtils9.astToSchema(variable?.type) : void 0;
|
|
3712
3768
|
return schema;
|
|
3713
3769
|
}
|
|
3714
3770
|
if (isTemplate2(values)) {
|
|
@@ -3731,13 +3787,13 @@ var infer = (values, scope) => {
|
|
|
3731
3787
|
|
|
3732
3788
|
// src/form-plugins/infer-assign-plugin/index.ts
|
|
3733
3789
|
import { set as set3, uniqBy } from "lodash";
|
|
3734
|
-
import { JsonSchemaUtils as
|
|
3790
|
+
import { JsonSchemaUtils as JsonSchemaUtils10 } from "@flowgram.ai/json-schema";
|
|
3735
3791
|
import {
|
|
3736
3792
|
ASTFactory as ASTFactory4,
|
|
3737
3793
|
createEffectFromVariableProvider as createEffectFromVariableProvider4,
|
|
3738
3794
|
defineFormPluginCreator as defineFormPluginCreator3,
|
|
3739
3795
|
getNodeForm as getNodeForm4,
|
|
3740
|
-
getNodeScope as
|
|
3796
|
+
getNodeScope as getNodeScope6
|
|
3741
3797
|
} from "@flowgram.ai/editor";
|
|
3742
3798
|
var createInferAssignPlugin = defineFormPluginCreator3({
|
|
3743
3799
|
onSetupFormMeta({ addFormatOnSubmit, mergeEffect }, { assignKey, outputKey }) {
|
|
@@ -3762,7 +3818,7 @@ var createInferAssignPlugin = defineFormPluginCreator3({
|
|
|
3762
3818
|
properties: declareRows.map(
|
|
3763
3819
|
(_v) => ASTFactory4.createProperty({
|
|
3764
3820
|
key: _v.left,
|
|
3765
|
-
type: _v.right?.type === "constant" ?
|
|
3821
|
+
type: _v.right?.type === "constant" ? JsonSchemaUtils10.schemaToAST(_v.right?.schema || {}) : void 0,
|
|
3766
3822
|
initializer: _v.right?.type === "ref" ? ASTFactory4.createKeyPathExpression({
|
|
3767
3823
|
keyPath: _v.right?.content || []
|
|
3768
3824
|
}) : {}
|
|
@@ -3778,7 +3834,7 @@ var createInferAssignPlugin = defineFormPluginCreator3({
|
|
|
3778
3834
|
set3(
|
|
3779
3835
|
formData,
|
|
3780
3836
|
outputKey,
|
|
3781
|
-
|
|
3837
|
+
JsonSchemaUtils10.astToSchema(getNodeScope6(ctx.node).output.variables?.[0]?.type)
|
|
3782
3838
|
);
|
|
3783
3839
|
return formData;
|
|
3784
3840
|
});
|
|
@@ -3787,7 +3843,7 @@ var createInferAssignPlugin = defineFormPluginCreator3({
|
|
|
3787
3843
|
|
|
3788
3844
|
// src/validate/validate-flow-value/index.tsx
|
|
3789
3845
|
import { isNil, uniq as uniq2 } from "lodash";
|
|
3790
|
-
import { FeedbackLevel, getNodeScope as
|
|
3846
|
+
import { FeedbackLevel, getNodeScope as getNodeScope7 } from "@flowgram.ai/editor";
|
|
3791
3847
|
function validateFlowValue(value, ctx) {
|
|
3792
3848
|
const { node, required, errorMessages } = ctx;
|
|
3793
3849
|
const {
|
|
@@ -3801,7 +3857,7 @@ function validateFlowValue(value, ctx) {
|
|
|
3801
3857
|
};
|
|
3802
3858
|
}
|
|
3803
3859
|
if (value?.type === "ref") {
|
|
3804
|
-
const variable =
|
|
3860
|
+
const variable = getNodeScope7(node).available.getByKeyPath(value?.content || []);
|
|
3805
3861
|
if (!variable) {
|
|
3806
3862
|
return {
|
|
3807
3863
|
level: FeedbackLevel.Error,
|
|
@@ -3812,7 +3868,7 @@ function validateFlowValue(value, ctx) {
|
|
|
3812
3868
|
if (value?.type === "template") {
|
|
3813
3869
|
const allRefs = getTemplateKeyPaths2(value);
|
|
3814
3870
|
for (const ref of allRefs) {
|
|
3815
|
-
const variable =
|
|
3871
|
+
const variable = getNodeScope7(node).available.getByKeyPath(ref);
|
|
3816
3872
|
if (!variable) {
|
|
3817
3873
|
return {
|
|
3818
3874
|
level: FeedbackLevel.Error,
|
|
@@ -3867,6 +3923,8 @@ export {
|
|
|
3867
3923
|
getTypeSelectValue,
|
|
3868
3924
|
isLegacyFlowRefValueSchema,
|
|
3869
3925
|
isNewFlowRefValueSchema,
|
|
3926
|
+
listenRefSchemaChange,
|
|
3927
|
+
listenRefValueChange,
|
|
3870
3928
|
parseTypeSelectValue,
|
|
3871
3929
|
provideBatchInputEffect,
|
|
3872
3930
|
provideBatchOutputsEffect,
|