@nocobase/flow-engine 2.1.0-alpha.10 → 2.1.0-alpha.12

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.
Files changed (46) hide show
  1. package/lib/FlowDefinition.d.ts +4 -0
  2. package/lib/FlowSchemaRegistry.d.ts +154 -0
  3. package/lib/FlowSchemaRegistry.js +1427 -0
  4. package/lib/components/subModel/AddSubModelButton.js +11 -0
  5. package/lib/flow-schema-registry/fieldBinding.d.ts +32 -0
  6. package/lib/flow-schema-registry/fieldBinding.js +165 -0
  7. package/lib/flow-schema-registry/modelPatches.d.ts +16 -0
  8. package/lib/flow-schema-registry/modelPatches.js +235 -0
  9. package/lib/flow-schema-registry/schemaInference.d.ts +17 -0
  10. package/lib/flow-schema-registry/schemaInference.js +207 -0
  11. package/lib/flow-schema-registry/utils.d.ts +25 -0
  12. package/lib/flow-schema-registry/utils.js +293 -0
  13. package/lib/flowEngine.js +4 -1
  14. package/lib/index.d.ts +1 -0
  15. package/lib/index.js +3 -1
  16. package/lib/models/DisplayItemModel.d.ts +1 -1
  17. package/lib/models/EditableItemModel.d.ts +1 -1
  18. package/lib/models/FilterableItemModel.d.ts +1 -1
  19. package/lib/runjs-context/setup.js +1 -0
  20. package/lib/server.d.ts +10 -0
  21. package/lib/server.js +32 -0
  22. package/lib/types.d.ts +233 -0
  23. package/package.json +4 -4
  24. package/server.d.ts +1 -0
  25. package/server.js +1 -0
  26. package/src/FlowSchemaRegistry.ts +1799 -0
  27. package/src/__tests__/FlowSchemaRegistry.test.ts +1951 -0
  28. package/src/__tests__/flow-engine.test.ts +48 -0
  29. package/src/__tests__/flowEngine.modelLoaders.test.ts +5 -1
  30. package/src/__tests__/flowEngine.saveModel.test.ts +4 -0
  31. package/src/__tests__/runjsContext.test.ts +3 -0
  32. package/src/__tests__/runjsContextRuntime.test.ts +2 -0
  33. package/src/components/subModel/AddSubModelButton.tsx +15 -1
  34. package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +1 -0
  35. package/src/flow-schema-registry/fieldBinding.ts +171 -0
  36. package/src/flow-schema-registry/modelPatches.ts +260 -0
  37. package/src/flow-schema-registry/schemaInference.ts +210 -0
  38. package/src/flow-schema-registry/utils.ts +268 -0
  39. package/src/flowEngine.ts +7 -1
  40. package/src/index.ts +1 -0
  41. package/src/models/DisplayItemModel.tsx +1 -1
  42. package/src/models/EditableItemModel.tsx +1 -1
  43. package/src/models/FilterableItemModel.tsx +1 -1
  44. package/src/runjs-context/setup.ts +1 -0
  45. package/src/server.ts +11 -0
  46. package/src/types.ts +273 -0
@@ -240,6 +240,8 @@ export declare class FlowStep {
240
240
  use?: string;
241
241
  sort?: number;
242
242
  preset?: boolean;
243
+ paramsSchemaOverride?: import("./types").FlowJsonSchema;
244
+ schemaDocs?: import("./types").FlowSchemaDocs;
243
245
  uiMode?: import("./types").StepUIMode | ((ctx: import("./flowContext").FlowRuntimeContext<import(".").FlowModel<import("./types").DefaultStructure>, any>) => import("./types").StepUIMode | Promise<import("./types").StepUIMode>);
244
246
  title?: string;
245
247
  uiSchema?: Record<string, import("@formily/json-schema").Stringify<{
@@ -413,6 +415,8 @@ export declare class FlowStep {
413
415
  }>>>);
414
416
  defaultParams?: Record<string, any> | ((ctx: import("./flowContext").FlowRuntimeContext<import(".").FlowModel<import("./types").DefaultStructure>, any>) => Record<string, any> | Promise<Record<string, any>>);
415
417
  handler?: (ctx: import("./flowContext").FlowRuntimeContext<import(".").FlowModel<import("./types").DefaultStructure>, any>, params: any) => any;
418
+ paramsSchema?: import("./types").FlowJsonSchema;
419
+ paramsSchemaPatch?: import("./types").FlowJsonSchema;
416
420
  beforeParamsSave?: (ctx: import("./flowContext").FlowSettingsContext<import(".").FlowModel<import("./types").DefaultStructure>>, params: any, previousParams: any) => void | Promise<void>;
417
421
  afterParamsSave?: (ctx: import("./flowContext").FlowSettingsContext<import(".").FlowModel<import("./types").DefaultStructure>>, params: any, previousParams: any) => void | Promise<void>;
418
422
  useRawParams?: boolean | ((ctx: import("./flowContext").FlowRuntimeContext<import(".").FlowModel<import("./types").DefaultStructure>, any>) => boolean | Promise<boolean>);
@@ -0,0 +1,154 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import type { ActionDefinition, FlowActionSchemaContribution, FlowFieldBindingContextContribution, FlowFieldBindingContribution, FlowFieldModelCompatibility, FlowSchemaBundleDocument, FlowSchemaContextEdge, FlowSchemaDocs, FlowDynamicHint, FlowSchemaInventoryContribution, FlowJsonSchema, FlowModelSchemaContribution, FlowSchemaCoverage, FlowSchemaDetail, FlowSchemaDocument, FlowModelSchemaExposure, FlowSchemaPublicDocument, FlowSubModelSlotSchema, ModelConstructor, StepDefinition } from './types';
10
+ import { type StepSchemaResolution } from './flow-schema-registry/schemaInference';
11
+ export type RegisteredActionSchema = {
12
+ name: string;
13
+ title?: string;
14
+ definition?: ActionDefinition;
15
+ schema?: FlowJsonSchema;
16
+ docs: FlowSchemaDocs;
17
+ coverage: FlowSchemaCoverage;
18
+ dynamicHints: FlowDynamicHint[];
19
+ };
20
+ export type RegisteredModelSchema = {
21
+ use: string;
22
+ modelClass?: ModelConstructor;
23
+ stepParamsSchema?: FlowJsonSchema;
24
+ flowRegistrySchema?: FlowJsonSchema;
25
+ subModelSlots?: Record<string, FlowSubModelSlotSchema>;
26
+ flowRegistrySchemaPatch?: FlowJsonSchema;
27
+ title?: string;
28
+ examples: any[];
29
+ docs: FlowSchemaDocs;
30
+ skeleton?: any;
31
+ dynamicHints: FlowDynamicHint[];
32
+ coverage: FlowSchemaCoverage;
33
+ exposure: FlowModelSchemaExposure;
34
+ abstract: boolean;
35
+ allowDirectUse: boolean;
36
+ suggestedUses: string[];
37
+ };
38
+ export declare class FlowSchemaRegistry {
39
+ private readonly modelSchemas;
40
+ private readonly actionSchemas;
41
+ private readonly fieldBindingContexts;
42
+ private readonly fieldBindings;
43
+ private readonly resolvedModelCache;
44
+ private readonly modelSnapshotSchemaCache;
45
+ private readonly compactModelSnapshotSchemaCache;
46
+ private readonly modelSchemaHashCache;
47
+ private readonly compactModelSchemaHashCache;
48
+ private readonly modelDocumentCache;
49
+ private readonly modelLocalDynamicHintsCache;
50
+ private readonly publicModelDocumentCache;
51
+ private readonly publicTreeRoots;
52
+ private readonly slotUseExpansions;
53
+ private invalidateDerivedCaches;
54
+ registerAction(action: ActionDefinition | ({
55
+ name: string;
56
+ } & Partial<ActionDefinition>)): void;
57
+ registerActions(actions: Record<string, ActionDefinition>): void;
58
+ registerActionContribution(contribution: FlowActionSchemaContribution): void;
59
+ registerActionContributions(contributions: FlowActionSchemaContribution[] | Record<string, FlowActionSchemaContribution>): void;
60
+ registerFieldBindingContext(contribution: FlowFieldBindingContextContribution, fallbackName?: string): void;
61
+ registerFieldBindingContexts(contributions: FlowFieldBindingContextContribution[] | Record<string, FlowFieldBindingContextContribution> | undefined): void;
62
+ registerFieldBinding(contribution: FlowFieldBindingContribution, source?: FlowSchemaCoverage['source']): void;
63
+ registerFieldBindings(contributions: FlowFieldBindingContribution[] | Record<string, FlowFieldBindingContribution | FlowFieldBindingContribution[]> | undefined, source?: FlowSchemaCoverage['source']): void;
64
+ registerModel(use: string, options: Partial<RegisteredModelSchema>): void;
65
+ registerModelContribution(contribution: FlowModelSchemaContribution): void;
66
+ registerModelContributions(contributions: FlowModelSchemaContribution[] | Record<string, FlowModelSchemaContribution>): void;
67
+ registerModelClass(use: string, modelClass: ModelConstructor): void;
68
+ registerModels(models: Record<string, ModelConstructor | undefined>): void;
69
+ registerInventory(inventory: FlowSchemaInventoryContribution | undefined, _source: FlowSchemaCoverage['source']): void;
70
+ resolveFieldBindingCandidates(context: string, options?: {
71
+ interface?: string;
72
+ fieldType?: string;
73
+ association?: boolean;
74
+ targetCollectionTemplate?: string;
75
+ }): {
76
+ use: string;
77
+ defaultProps: any;
78
+ compatibility: FlowFieldModelCompatibility;
79
+ }[];
80
+ getAction(name: string): RegisteredActionSchema | undefined;
81
+ listActionNames(): string[];
82
+ getModel(use: string): RegisteredModelSchema | undefined;
83
+ private resolveFieldBindingContextChain;
84
+ private resolveModelSchemaRef;
85
+ resolveModelSchema(use: string, contextChain?: FlowSchemaContextEdge[]): RegisteredModelSchema;
86
+ private isPublicModel;
87
+ private isQueryableModel;
88
+ getSuggestedUses(use: string): string[];
89
+ hasQueryableModel(use: string): boolean;
90
+ isDirectUseAllowed(use: string): boolean;
91
+ listPublicTreeRoots(): string[];
92
+ listModelUses(options?: {
93
+ publicOnly?: boolean;
94
+ directUseOnly?: boolean;
95
+ queryableOnly?: boolean;
96
+ }): string[];
97
+ getSchemaBundle(uses?: string[]): FlowSchemaBundleDocument;
98
+ getModelDocument(use: string, contextChain?: FlowSchemaContextEdge[]): FlowSchemaDocument;
99
+ getModelDocumentRef(use: string, contextChain?: FlowSchemaContextEdge[]): Readonly<FlowSchemaDocument>;
100
+ getPublicModelDocument(use: string, options?: {
101
+ detail?: FlowSchemaDetail;
102
+ contextChain?: FlowSchemaContextEdge[];
103
+ }): FlowSchemaPublicDocument;
104
+ getPublicModelDocumentRef(use: string, options?: {
105
+ detail?: FlowSchemaDetail;
106
+ contextChain?: FlowSchemaContextEdge[];
107
+ }): Readonly<FlowSchemaPublicDocument>;
108
+ private buildFullPublicModelDocument;
109
+ private buildCompactPublicModelDocument;
110
+ private getModelLocalDynamicHintsRef;
111
+ private buildModelLocalDynamicHints;
112
+ getModelSchemaHash(use: string, contextChain?: FlowSchemaContextEdge[]): string;
113
+ getCompactModelSchemaHash(use: string, contextChain?: FlowSchemaContextEdge[]): string;
114
+ private createSlotUseExpansionKey;
115
+ private getSlotUseExpansionUses;
116
+ resolveSlotAllowedUses(parentUse: string, slotKey: string, slot?: FlowSubModelSlotSchema): string[];
117
+ private buildModelDocument;
118
+ private buildBundleNode;
119
+ private buildBundleSubModelCatalog;
120
+ private createContextVisitKey;
121
+ private isContextCycle;
122
+ buildModelSnapshotSchema(use: string, contextChain?: FlowSchemaContextEdge[]): FlowJsonSchema;
123
+ buildCompactModelSnapshotSchema(use: string, contextChain?: FlowSchemaContextEdge[]): FlowJsonSchema;
124
+ private buildModelSnapshotSchemaRef;
125
+ private buildCompactModelSnapshotSchemaRef;
126
+ private buildCompactModelSnapshotSchemaInternal;
127
+ private buildModelSnapshotSchemaInternal;
128
+ private buildSnapshotSchemaFromResolved;
129
+ private buildSnapshotShellSchema;
130
+ private buildTruncatedSnapshotSchema;
131
+ buildStaticFlowRegistrySchema(use: string, contextChain?: FlowSchemaContextEdge[]): FlowJsonSchema;
132
+ buildStaticStepParamsSchema(use: string, contextChain?: FlowSchemaContextEdge[]): FlowJsonSchema;
133
+ buildSubModelsSchema(use: string, contextChain?: FlowSchemaContextEdge[]): FlowJsonSchema;
134
+ private buildCompactSubModelsSchemaFromSlots;
135
+ private buildSubModelsSchemaFromSlots;
136
+ private buildInferredFlowRegistrySchema;
137
+ private buildInferredStepParamsSchema;
138
+ buildFlowOnSchema(): FlowJsonSchema;
139
+ buildStepDefinitionSchema(step: StepDefinition): FlowJsonSchema;
140
+ resolveStepParamsSchema(step: StepDefinition, path: string): StepSchemaResolution;
141
+ private buildSlotTargetSchema;
142
+ private buildCompactSlotTargetSchema;
143
+ private buildCompactSlotCandidateSchema;
144
+ private buildCompactAnonymousSlotSnapshotSchema;
145
+ private buildAnonymousSlotSnapshotSchema;
146
+ private createAnonymousResolvedSchema;
147
+ private collectNestedDocumentHints;
148
+ private prefixNestedHint;
149
+ private collectContextPatches;
150
+ private collectModelDynamicHints;
151
+ private collectFlowSchemaDiagnostics;
152
+ private buildDocumentCoverage;
153
+ private inferSubModelSlotsFromModelClass;
154
+ }