@nocobase/flow-engine 2.1.0-alpha.11 → 2.1.0-alpha.13

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 (40) hide show
  1. package/lib/FlowDefinition.d.ts +0 -4
  2. package/lib/index.d.ts +0 -1
  3. package/lib/index.js +1 -3
  4. package/lib/models/DisplayItemModel.d.ts +1 -1
  5. package/lib/models/EditableItemModel.d.ts +1 -1
  6. package/lib/models/FilterableItemModel.d.ts +1 -1
  7. package/lib/runjs-context/snippets/index.js +13 -2
  8. package/lib/{server.d.ts → runjs-context/snippets/scene/detail/set-field-style.snippet.d.ts} +3 -2
  9. package/lib/{server.js → runjs-context/snippets/scene/detail/set-field-style.snippet.js} +27 -9
  10. package/{src/server.ts → lib/runjs-context/snippets/scene/table/set-cell-style.snippet.d.ts} +3 -3
  11. package/lib/runjs-context/snippets/scene/table/set-cell-style.snippet.js +54 -0
  12. package/lib/types.d.ts +0 -221
  13. package/package.json +4 -4
  14. package/src/__tests__/runjsSnippets.test.ts +21 -0
  15. package/src/index.ts +0 -1
  16. package/src/models/DisplayItemModel.tsx +1 -1
  17. package/src/models/EditableItemModel.tsx +1 -1
  18. package/src/models/FilterableItemModel.tsx +1 -1
  19. package/src/runjs-context/snippets/index.ts +12 -1
  20. package/src/runjs-context/snippets/scene/detail/set-field-style.snippet.ts +30 -0
  21. package/src/runjs-context/snippets/scene/table/set-cell-style.snippet.ts +34 -0
  22. package/src/types.ts +0 -262
  23. package/lib/FlowSchemaRegistry.d.ts +0 -154
  24. package/lib/FlowSchemaRegistry.js +0 -1427
  25. package/lib/flow-schema-registry/fieldBinding.d.ts +0 -32
  26. package/lib/flow-schema-registry/fieldBinding.js +0 -165
  27. package/lib/flow-schema-registry/modelPatches.d.ts +0 -16
  28. package/lib/flow-schema-registry/modelPatches.js +0 -235
  29. package/lib/flow-schema-registry/schemaInference.d.ts +0 -17
  30. package/lib/flow-schema-registry/schemaInference.js +0 -207
  31. package/lib/flow-schema-registry/utils.d.ts +0 -25
  32. package/lib/flow-schema-registry/utils.js +0 -293
  33. package/server.d.ts +0 -1
  34. package/server.js +0 -1
  35. package/src/FlowSchemaRegistry.ts +0 -1799
  36. package/src/__tests__/FlowSchemaRegistry.test.ts +0 -1951
  37. package/src/flow-schema-registry/fieldBinding.ts +0 -171
  38. package/src/flow-schema-registry/modelPatches.ts +0 -260
  39. package/src/flow-schema-registry/schemaInference.ts +0 -210
  40. package/src/flow-schema-registry/utils.ts +0 -268
@@ -240,8 +240,6 @@ 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;
245
243
  uiMode?: import("./types").StepUIMode | ((ctx: import("./flowContext").FlowRuntimeContext<import(".").FlowModel<import("./types").DefaultStructure>, any>) => import("./types").StepUIMode | Promise<import("./types").StepUIMode>);
246
244
  title?: string;
247
245
  uiSchema?: Record<string, import("@formily/json-schema").Stringify<{
@@ -415,8 +413,6 @@ export declare class FlowStep {
415
413
  }>>>);
416
414
  defaultParams?: Record<string, any> | ((ctx: import("./flowContext").FlowRuntimeContext<import(".").FlowModel<import("./types").DefaultStructure>, any>) => Record<string, any> | Promise<Record<string, any>>);
417
415
  handler?: (ctx: import("./flowContext").FlowRuntimeContext<import(".").FlowModel<import("./types").DefaultStructure>, any>, params: any) => any;
418
- paramsSchema?: import("./types").FlowJsonSchema;
419
- paramsSchemaPatch?: import("./types").FlowJsonSchema;
420
416
  beforeParamsSave?: (ctx: import("./flowContext").FlowSettingsContext<import(".").FlowModel<import("./types").DefaultStructure>>, params: any, previousParams: any) => void | Promise<void>;
421
417
  afterParamsSave?: (ctx: import("./flowContext").FlowSettingsContext<import(".").FlowModel<import("./types").DefaultStructure>>, params: any, previousParams: any) => void | Promise<void>;
422
418
  useRawParams?: boolean | ((ctx: import("./flowContext").FlowRuntimeContext<import(".").FlowModel<import("./types").DefaultStructure>, any>) => boolean | Promise<boolean>);
package/lib/index.d.ts CHANGED
@@ -34,6 +34,5 @@ export { getSnippetBody, listSnippetsForContext, registerRunJSSnippet } from './
34
34
  export * from './views';
35
35
  export { DATA_SOURCE_DIRTY_EVENT, ENGINE_SCOPE_KEY, getEmitterViewActivatedVersion, VIEW_ACTIVATED_EVENT, VIEW_ACTIVATED_VERSION, VIEW_ENGINE_SCOPE, } from './views/viewEvents';
36
36
  export * from './FlowDefinition';
37
- export * from './FlowSchemaRegistry';
38
37
  export { createViewScopedEngine } from './ViewScopedFlowEngine';
39
38
  export { createBlockScopedEngine } from './BlockScopedFlowEngine';
package/lib/index.js CHANGED
@@ -75,7 +75,6 @@ var import_snippets = require("./runjs-context/snippets");
75
75
  __reExport(src_exports, require("./views"), module.exports);
76
76
  var import_viewEvents = require("./views/viewEvents");
77
77
  __reExport(src_exports, require("./FlowDefinition"), module.exports);
78
- __reExport(src_exports, require("./FlowSchemaRegistry"), module.exports);
79
78
  var import_ViewScopedFlowEngine = require("./ViewScopedFlowEngine");
80
79
  var import_BlockScopedFlowEngine = require("./BlockScopedFlowEngine");
81
80
  // Annotate the CommonJS export names for ESM import in node:
@@ -117,6 +116,5 @@ var import_BlockScopedFlowEngine = require("./BlockScopedFlowEngine");
117
116
  ...require("./FlowContextProvider"),
118
117
  ...require("./JSRunner"),
119
118
  ...require("./views"),
120
- ...require("./FlowDefinition"),
121
- ...require("./FlowSchemaRegistry")
119
+ ...require("./FlowDefinition")
122
120
  });
@@ -6,7 +6,7 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- import { DefaultStructure } from '../types';
9
+ import { DefaultStructure } from '@nocobase/flow-engine';
10
10
  import { CollectionFieldModel } from './CollectionFieldModel';
11
11
  export declare class DisplayItemModel<T extends DefaultStructure = DefaultStructure> extends CollectionFieldModel<T> {
12
12
  }
@@ -6,7 +6,7 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- import { DefaultStructure } from '../types';
9
+ import { DefaultStructure } from '@nocobase/flow-engine';
10
10
  import { CollectionFieldModel } from './CollectionFieldModel';
11
11
  export declare class EditableItemModel<T extends DefaultStructure = DefaultStructure> extends CollectionFieldModel<T> {
12
12
  }
@@ -6,7 +6,7 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- import { DefaultStructure } from '../types';
9
+ import { DefaultStructure } from '@nocobase/flow-engine';
10
10
  import { CollectionFieldModel } from './CollectionFieldModel';
11
11
  export declare class FilterableItemModel<T extends DefaultStructure = DefaultStructure> extends CollectionFieldModel<T> {
12
12
  }
@@ -81,6 +81,7 @@ const snippets = {
81
81
  "scene/detail/status-tag": /* @__PURE__ */ __name(() => import("./scene/detail/status-tag.snippet"), "scene/detail/status-tag"),
82
82
  "scene/detail/relative-time": /* @__PURE__ */ __name(() => import("./scene/detail/relative-time.snippet"), "scene/detail/relative-time"),
83
83
  "scene/detail/percentage-bar": /* @__PURE__ */ __name(() => import("./scene/detail/percentage-bar.snippet"), "scene/detail/percentage-bar"),
84
+ "scene/detail/set-field-style": /* @__PURE__ */ __name(() => import("./scene/detail/set-field-style.snippet"), "scene/detail/set-field-style"),
84
85
  // scene/form
85
86
  "scene/form/render-basic": /* @__PURE__ */ __name(() => import("./scene/form/render-basic.snippet"), "scene/form/render-basic"),
86
87
  "scene/form/set-field-value": /* @__PURE__ */ __name(() => import("./scene/form/set-field-value.snippet"), "scene/form/set-field-value"),
@@ -98,7 +99,8 @@ const snippets = {
98
99
  "scene/table/collection-selected-count": /* @__PURE__ */ __name(() => import("./scene/table/collection-selected-count.snippet"), "scene/table/collection-selected-count"),
99
100
  "scene/table/iterate-selected-rows": /* @__PURE__ */ __name(() => import("./scene/table/iterate-selected-rows.snippet"), "scene/table/iterate-selected-rows"),
100
101
  "scene/table/destroy-selected": /* @__PURE__ */ __name(() => import("./scene/table/destroy-selected.snippet"), "scene/table/destroy-selected"),
101
- "scene/table/export-selected-json": /* @__PURE__ */ __name(() => import("./scene/table/export-selected-json.snippet"), "scene/table/export-selected-json")
102
+ "scene/table/export-selected-json": /* @__PURE__ */ __name(() => import("./scene/table/export-selected-json.snippet"), "scene/table/export-selected-json"),
103
+ "scene/table/set-cell-style": /* @__PURE__ */ __name(() => import("./scene/table/set-cell-style.snippet"), "scene/table/set-cell-style")
102
104
  };
103
105
  var snippets_default = snippets;
104
106
  function registerRunJSSnippet(ref, loader, options) {
@@ -131,10 +133,19 @@ function normalizeScenes(def, key) {
131
133
  return [];
132
134
  }
133
135
  __name(normalizeScenes, "normalizeScenes");
136
+ function normalizeSceneGroup(scene) {
137
+ const mapping = {
138
+ detailFieldEvent: "detail",
139
+ tableFieldEvent: "table",
140
+ formFieldEvent: "form"
141
+ };
142
+ return mapping[scene] || scene;
143
+ }
144
+ __name(normalizeSceneGroup, "normalizeSceneGroup");
134
145
  function computeGroups(def, key) {
135
146
  const scenes = normalizeScenes(def, key);
136
147
  if (scenes.length) {
137
- return scenes.map((scene) => `scene/${scene}`);
148
+ return Array.from(new Set(scenes.map((scene) => `scene/${normalizeSceneGroup(scene)}`)));
138
149
  }
139
150
  const parts = key.split("/");
140
151
  if (!parts.length) return [];
@@ -6,5 +6,6 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- export * from './types';
10
- export * from './FlowSchemaRegistry';
9
+ import type { SnippetModule } from '../../types';
10
+ declare const snippet: SnippetModule;
11
+ export default snippet;
@@ -11,6 +11,10 @@ var __defProp = Object.defineProperty;
11
11
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
12
  var __getOwnPropNames = Object.getOwnPropertyNames;
13
13
  var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
14
18
  var __copyProps = (to, from, except, desc) => {
15
19
  if (from && typeof from === "object" || typeof from === "function") {
16
20
  for (let key of __getOwnPropNames(from))
@@ -19,14 +23,28 @@ var __copyProps = (to, from, except, desc) => {
19
23
  }
20
24
  return to;
21
25
  };
22
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
23
26
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
- var server_exports = {};
25
- module.exports = __toCommonJS(server_exports);
26
- __reExport(server_exports, require("./types"), module.exports);
27
- __reExport(server_exports, require("./FlowSchemaRegistry"), module.exports);
28
- // Annotate the CommonJS export names for ESM import in node:
29
- 0 && (module.exports = {
30
- ...require("./types"),
31
- ...require("./FlowSchemaRegistry")
27
+ var set_field_style_snippet_exports = {};
28
+ __export(set_field_style_snippet_exports, {
29
+ default: () => set_field_style_snippet_default
32
30
  });
31
+ module.exports = __toCommonJS(set_field_style_snippet_exports);
32
+ const snippet = {
33
+ contexts: ["*"],
34
+ scenes: ["detailFieldEvent", "formFieldEvent"],
35
+ prefix: "sn-field-style",
36
+ label: "Set field style",
37
+ description: "Customize form and detail field styles",
38
+ locales: {
39
+ "zh-CN": {
40
+ label: "\u8868\u5355\u3001\u8BE6\u60C5\u5B57\u6BB5\u6837\u5F0F\u8BBE\u7F6E",
41
+ description: "\u81EA\u5B9A\u4E49\u8868\u5355\u5B57\u6BB5\u548C\u8BE6\u60C5\u5B57\u6BB5\u7684\u6837\u5F0F"
42
+ }
43
+ },
44
+ content: `
45
+ ctx.model.subModels.field.props.style = {
46
+ fontWeight: 900,
47
+ };
48
+ `
49
+ };
50
+ var set_field_style_snippet_default = snippet;
@@ -6,6 +6,6 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
-
10
- export * from './types';
11
- export * from './FlowSchemaRegistry';
9
+ import type { SnippetModule } from '../../types';
10
+ declare const snippet: SnippetModule;
11
+ export default snippet;
@@ -0,0 +1,54 @@
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
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var set_cell_style_snippet_exports = {};
28
+ __export(set_cell_style_snippet_exports, {
29
+ default: () => set_cell_style_snippet_default
30
+ });
31
+ module.exports = __toCommonJS(set_cell_style_snippet_exports);
32
+ const snippet = {
33
+ contexts: ["*"],
34
+ scenes: ["tableFieldEvent"],
35
+ prefix: "sn-table-cell-style",
36
+ label: "Set table cell style",
37
+ description: "Customize table field cell styles with onCell",
38
+ locales: {
39
+ "zh-CN": {
40
+ label: "\u8868\u683C\u5B57\u6BB5\u6837\u5F0F\u8BBE\u7F6E",
41
+ description: "\u901A\u8FC7 onCell \u81EA\u5B9A\u4E49\u8868\u683C\u5B57\u6BB5\u5355\u5143\u683C\u6837\u5F0F"
42
+ }
43
+ },
44
+ content: `
45
+ ctx.model.props.onCell = (record, rowIndex) => {
46
+ return {
47
+ style: {
48
+ fontWeight: 900,
49
+ },
50
+ };
51
+ };
52
+ `
53
+ };
54
+ var set_cell_style_snippet_default = snippet;
package/lib/types.d.ts CHANGED
@@ -30,221 +30,6 @@ export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
30
30
  export type DeepPartial<T> = {
31
31
  [P in keyof T]?: T[P] extends (infer U)[] ? DeepPartial<U>[] : T[P] extends Record<string, any> ? DeepPartial<T[P]> : T[P] extends object ? DeepPartial<T[P]> : T[P];
32
32
  };
33
- export type FlowJsonSchema = Record<string, any> & {
34
- $schema?: string;
35
- $id?: string;
36
- };
37
- export interface FlowDynamicHintMetadata {
38
- slotRules?: {
39
- slotKey?: string;
40
- type?: 'object' | 'array';
41
- allowedUses?: string[];
42
- };
43
- contextRequirements?: string[];
44
- unresolvedReason?: string;
45
- recommendedFallback?: any;
46
- }
47
- export interface FlowDynamicHint {
48
- kind: 'dynamic-ui-schema' | 'dynamic-children' | 'custom-component' | 'x-reactions' | 'unresolved-action' | 'manual-schema-required' | 'unresolved-model';
49
- path?: string;
50
- message: string;
51
- 'x-flow'?: FlowDynamicHintMetadata;
52
- }
53
- export interface FlowSchemaCoverage {
54
- status: 'auto' | 'manual' | 'mixed' | 'unresolved';
55
- source: 'official' | 'plugin' | 'third-party';
56
- strict?: boolean;
57
- issues?: string[];
58
- }
59
- export type FlowModelSchemaExposure = 'public' | 'internal';
60
- export interface FlowSchemaPattern {
61
- title: string;
62
- description?: string;
63
- snippet?: any;
64
- }
65
- export interface FlowSchemaDocument {
66
- use: string;
67
- title?: string;
68
- jsonSchema: FlowJsonSchema;
69
- coverage: FlowSchemaCoverage;
70
- dynamicHints: FlowDynamicHint[];
71
- examples: any[];
72
- minimalExample?: any;
73
- commonPatterns: FlowSchemaPattern[];
74
- antiPatterns: FlowSchemaPattern[];
75
- skeleton: any;
76
- hash: string;
77
- source: FlowSchemaCoverage['source'];
78
- }
79
- export type FlowSchemaDetail = 'compact' | 'full';
80
- export interface FlowSchemaPublicDocument {
81
- use: string;
82
- title?: string;
83
- jsonSchema: FlowJsonSchema;
84
- dynamicHints: FlowDynamicHint[];
85
- minimalExample?: any;
86
- commonPatterns: FlowSchemaPattern[];
87
- antiPatterns: FlowSchemaPattern[];
88
- hash: string;
89
- source: FlowSchemaCoverage['source'];
90
- }
91
- export interface FlowSchemaDocs {
92
- description?: string;
93
- examples?: any[];
94
- minimalExample?: any;
95
- commonPatterns?: FlowSchemaPattern[];
96
- antiPatterns?: FlowSchemaPattern[];
97
- dynamicHints?: FlowDynamicHint[];
98
- }
99
- export interface FlowSchemaBundleSlotCatalog {
100
- type: 'object' | 'array';
101
- required?: boolean;
102
- minItems?: number;
103
- open?: boolean;
104
- candidates: FlowSchemaBundleNode[];
105
- }
106
- export interface FlowSchemaBundleNode {
107
- use: string;
108
- title?: string;
109
- compatibility?: FlowFieldModelCompatibility;
110
- subModelCatalog?: Record<string, FlowSchemaBundleSlotCatalog>;
111
- }
112
- export type FlowSchemaBundleItem = FlowSchemaBundleNode;
113
- export interface FlowSchemaBundleDocument {
114
- items: FlowSchemaBundleNode[];
115
- }
116
- export interface FlowSchemaContextEdge {
117
- parentUse: string;
118
- slotKey: string;
119
- childUse: string;
120
- }
121
- export interface FlowSubModelContextPathStep {
122
- slotKey: string;
123
- use?: string | string[];
124
- }
125
- export interface FlowModelSchemaPatch {
126
- stepParamsSchema?: FlowJsonSchema;
127
- flowRegistrySchema?: FlowJsonSchema;
128
- subModelSlots?: Record<string, FlowSubModelSlotSchema>;
129
- flowRegistrySchemaPatch?: FlowJsonSchema;
130
- docs?: FlowSchemaDocs;
131
- examples?: any[];
132
- skeleton?: any;
133
- dynamicHints?: FlowDynamicHint[];
134
- }
135
- export interface FlowDescendantSchemaPatch {
136
- path: FlowSubModelContextPathStep[];
137
- patch: FlowModelSchemaPatch;
138
- }
139
- export interface FlowSubModelSlotSchema {
140
- type: 'object' | 'array';
141
- use?: string;
142
- uses?: string[];
143
- required?: boolean;
144
- minItems?: number;
145
- dynamic?: boolean;
146
- schema?: FlowJsonSchema;
147
- fieldBindingContext?: string;
148
- childSchemaPatch?: FlowModelSchemaPatch | Record<string, FlowModelSchemaPatch>;
149
- descendantSchemaPatches?: FlowDescendantSchemaPatch[];
150
- description?: string;
151
- }
152
- export interface FlowModelSchemaMeta {
153
- stepParamsSchema?: FlowJsonSchema;
154
- flowRegistrySchema?: FlowJsonSchema;
155
- subModelSlots?: Record<string, FlowSubModelSlotSchema>;
156
- flowRegistrySchemaPatch?: FlowJsonSchema;
157
- docs?: FlowSchemaDocs;
158
- examples?: any[];
159
- skeleton?: any;
160
- dynamicHints?: FlowDynamicHint[];
161
- source?: FlowSchemaCoverage['source'];
162
- strict?: boolean;
163
- exposure?: FlowModelSchemaExposure;
164
- abstract?: boolean;
165
- allowDirectUse?: boolean;
166
- suggestedUses?: string[];
167
- }
168
- export interface FlowActionSchemaContribution {
169
- name: string;
170
- title?: string;
171
- paramsSchema?: FlowJsonSchema;
172
- docs?: FlowSchemaDocs;
173
- source?: FlowSchemaCoverage['source'];
174
- strict?: boolean;
175
- }
176
- export interface FlowModelSchemaContribution {
177
- use: string;
178
- title?: string;
179
- stepParamsSchema?: FlowJsonSchema;
180
- flowRegistrySchema?: FlowJsonSchema;
181
- subModelSlots?: Record<string, FlowSubModelSlotSchema>;
182
- flowRegistrySchemaPatch?: FlowJsonSchema;
183
- docs?: FlowSchemaDocs;
184
- examples?: any[];
185
- skeleton?: any;
186
- dynamicHints?: FlowDynamicHint[];
187
- source?: FlowSchemaCoverage['source'];
188
- strict?: boolean;
189
- exposure?: FlowModelSchemaExposure;
190
- abstract?: boolean;
191
- allowDirectUse?: boolean;
192
- suggestedUses?: string[];
193
- }
194
- export interface FlowSchemaContributionDefaults {
195
- source?: FlowSchemaCoverage['source'];
196
- strict?: boolean;
197
- }
198
- export interface FlowSchemaSlotUseExpansion {
199
- parentUse: string;
200
- slotKey: string;
201
- uses: string[];
202
- }
203
- export interface FlowSchemaInventoryContribution {
204
- publicTreeRoots?: string[];
205
- slotUseExpansions?: FlowSchemaSlotUseExpansion[];
206
- }
207
- export interface FlowFieldBindingConditions {
208
- association?: boolean;
209
- fieldTypes?: string[];
210
- targetCollectionTemplateIn?: string[];
211
- targetCollectionTemplateNotIn?: string[];
212
- }
213
- export interface FlowFieldBindingContextContribution {
214
- name: string;
215
- inherits?: string[];
216
- }
217
- export interface FlowFieldBindingContribution {
218
- context: string;
219
- use: string;
220
- interfaces: string[];
221
- isDefault?: boolean;
222
- order?: number;
223
- conditions?: FlowFieldBindingConditions;
224
- defaultProps?: any;
225
- }
226
- export interface FlowFieldModelCompatibility {
227
- context: string;
228
- interfaces: string[];
229
- isDefault?: boolean;
230
- order?: number;
231
- association?: boolean;
232
- fieldTypes?: string[];
233
- targetCollectionTemplateIn?: string[];
234
- targetCollectionTemplateNotIn?: string[];
235
- inheritParentFieldBinding?: boolean;
236
- }
237
- export interface FlowSchemaContribution {
238
- models?: FlowModelSchemaContribution[] | Record<string, FlowModelSchemaContribution>;
239
- actions?: FlowActionSchemaContribution[] | Record<string, FlowActionSchemaContribution>;
240
- fieldBindingContexts?: FlowFieldBindingContextContribution[] | Record<string, FlowFieldBindingContextContribution>;
241
- fieldBindings?: FlowFieldBindingContribution[] | Record<string, FlowFieldBindingContribution | FlowFieldBindingContribution[]>;
242
- inventory?: FlowSchemaInventoryContribution;
243
- defaults?: FlowSchemaContributionDefaults;
244
- }
245
- export interface FlowSchemaContributionProvider {
246
- getFlowSchemaContributions(): FlowSchemaContribution | undefined | Promise<FlowSchemaContribution | undefined>;
247
- }
248
33
  /**
249
34
  * Defines a flow with generic model type support.
250
35
  */
@@ -345,9 +130,6 @@ export interface ActionDefinition<TModel extends FlowModel = FlowModel, TCtx ext
345
130
  title?: string;
346
131
  handler: (ctx: TCtx, params: any) => Promise<any> | any;
347
132
  uiSchema?: Record<string, ISchema> | ((ctx: TCtx) => Record<string, ISchema> | Promise<Record<string, ISchema>>);
348
- paramsSchema?: FlowJsonSchema;
349
- paramsSchemaPatch?: FlowJsonSchema;
350
- schemaDocs?: FlowSchemaDocs;
351
133
  defaultParams?: Record<string, any> | ((ctx: TCtx) => Record<string, any> | Promise<Record<string, any>>);
352
134
  beforeParamsSave?: (ctx: FlowSettingsContext<TModel>, params: any, previousParams: any) => void | Promise<void>;
353
135
  afterParamsSave?: (ctx: FlowSettingsContext<TModel>, params: any, previousParams: any) => void | Promise<void>;
@@ -446,8 +228,6 @@ export interface StepDefinition<TModel extends FlowModel = FlowModel> extends Pa
446
228
  use?: string;
447
229
  sort?: number;
448
230
  preset?: boolean;
449
- paramsSchemaOverride?: FlowJsonSchema;
450
- schemaDocs?: FlowSchemaDocs;
451
231
  uiMode?: StepUIMode | ((ctx: FlowRuntimeContext<TModel>) => StepUIMode | Promise<StepUIMode>);
452
232
  }
453
233
  /**
@@ -684,7 +464,6 @@ export type FlowModelMeta = Pick<SubModelItem, 'key' | 'label' | 'icon' | 'child
684
464
  label: string;
685
465
  value: string;
686
466
  }[];
687
- schema?: FlowModelSchemaMeta;
688
467
  };
689
468
  /**
690
469
  * 字段 FlowModel 的专用元数据接口
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/flow-engine",
3
- "version": "2.1.0-alpha.11",
3
+ "version": "2.1.0-alpha.13",
4
4
  "private": false,
5
5
  "description": "A standalone flow engine for NocoBase, managing workflows, models, and actions.",
6
6
  "main": "lib/index.js",
@@ -8,8 +8,8 @@
8
8
  "dependencies": {
9
9
  "@formily/antd-v5": "1.x",
10
10
  "@formily/reactive": "2.x",
11
- "@nocobase/sdk": "2.1.0-alpha.11",
12
- "@nocobase/shared": "2.1.0-alpha.11",
11
+ "@nocobase/sdk": "2.1.0-alpha.13",
12
+ "@nocobase/shared": "2.1.0-alpha.13",
13
13
  "ahooks": "^3.7.2",
14
14
  "dayjs": "^1.11.9",
15
15
  "dompurify": "^3.0.2",
@@ -36,5 +36,5 @@
36
36
  ],
37
37
  "author": "NocoBase Team",
38
38
  "license": "Apache-2.0",
39
- "gitHead": "bb96d633a6371afb586072ff516bd0613c757db0"
39
+ "gitHead": "2807a8948412d9c235115a31a81a66f7c82dd173"
40
40
  }
@@ -112,6 +112,27 @@ describe('RunJS Snippets', () => {
112
112
  expect(multiScene?.scenes).toEqual(expect.arrayContaining(['detail', 'table']));
113
113
  expect(multiScene?.groups).toEqual(expect.arrayContaining(['scene/detail', 'scene/table']));
114
114
  });
115
+
116
+ it('should expose new style snippets for matching contexts', async () => {
117
+ const tableSnippets = await listSnippetsForContext('JSColumnRunJSContext', 'v1', 'zh-CN');
118
+ const fieldSnippets = await listSnippetsForContext('FormJSFieldItemRunJSContext', 'v1', 'zh-CN');
119
+ const detailEventSnippets = await listSnippetsForContext('DetailsItemModel', 'v1', 'zh-CN');
120
+ const tableEventSnippets = await listSnippetsForContext('TableColumnModel', 'v1', 'zh-CN');
121
+
122
+ const tableStyle = tableSnippets.find((s) => s.ref === 'scene/table/set-cell-style');
123
+ expect(tableStyle?.name).toBe('表格字段样式设置');
124
+ expect(tableStyle?.body).toContain('ctx.model.props.onCell');
125
+ expect(tableStyle?.scenes).toEqual(['tableFieldEvent']);
126
+
127
+ const fieldStyle = fieldSnippets.find((s) => s.ref === 'scene/detail/set-field-style');
128
+ expect(fieldStyle?.name).toBe('表单、详情字段样式设置');
129
+ expect(fieldStyle?.body).toContain('ctx.model.subModels.field.props.style');
130
+ expect(fieldStyle?.scenes).toEqual(expect.arrayContaining(['detailFieldEvent', 'formFieldEvent']));
131
+ expect(fieldStyle?.groups).toEqual(expect.arrayContaining(['scene/detail', 'scene/form']));
132
+
133
+ expect(detailEventSnippets.some((s) => s.ref === 'scene/detail/set-field-style')).toBe(true);
134
+ expect(tableEventSnippets.some((s) => s.ref === 'scene/table/set-cell-style')).toBe(true);
135
+ });
115
136
  });
116
137
 
117
138
  describe('New snippets', () => {
package/src/index.ts CHANGED
@@ -57,6 +57,5 @@ export {
57
57
  } from './views/viewEvents';
58
58
 
59
59
  export * from './FlowDefinition';
60
- export * from './FlowSchemaRegistry';
61
60
  export { createViewScopedEngine } from './ViewScopedFlowEngine';
62
61
  export { createBlockScopedEngine } from './BlockScopedFlowEngine';
@@ -7,7 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- import { DefaultStructure } from '../types';
10
+ import { DefaultStructure } from '@nocobase/flow-engine';
11
11
  import { CollectionFieldModel } from './CollectionFieldModel';
12
12
 
13
13
  export class DisplayItemModel<T extends DefaultStructure = DefaultStructure> extends CollectionFieldModel<T> {}
@@ -7,7 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- import { DefaultStructure } from '../types';
10
+ import { DefaultStructure } from '@nocobase/flow-engine';
11
11
  import { CollectionFieldModel } from './CollectionFieldModel';
12
12
 
13
13
  export class EditableItemModel<T extends DefaultStructure = DefaultStructure> extends CollectionFieldModel<T> {}
@@ -7,7 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- import { DefaultStructure } from '../types';
10
+ import { DefaultStructure } from '@nocobase/flow-engine';
11
11
  import { CollectionFieldModel } from './CollectionFieldModel';
12
12
 
13
13
  export class FilterableItemModel<T extends DefaultStructure = DefaultStructure> extends CollectionFieldModel<T> {}
@@ -49,6 +49,7 @@ const snippets: Record<string, RunJSSnippetLoader | undefined> = {
49
49
  'scene/detail/status-tag': () => import('./scene/detail/status-tag.snippet'),
50
50
  'scene/detail/relative-time': () => import('./scene/detail/relative-time.snippet'),
51
51
  'scene/detail/percentage-bar': () => import('./scene/detail/percentage-bar.snippet'),
52
+ 'scene/detail/set-field-style': () => import('./scene/detail/set-field-style.snippet'),
52
53
  // scene/form
53
54
  'scene/form/render-basic': () => import('./scene/form/render-basic.snippet'),
54
55
  'scene/form/set-field-value': () => import('./scene/form/set-field-value.snippet'),
@@ -67,6 +68,7 @@ const snippets: Record<string, RunJSSnippetLoader | undefined> = {
67
68
  'scene/table/iterate-selected-rows': () => import('./scene/table/iterate-selected-rows.snippet'),
68
69
  'scene/table/destroy-selected': () => import('./scene/table/destroy-selected.snippet'),
69
70
  'scene/table/export-selected-json': () => import('./scene/table/export-selected-json.snippet'),
71
+ 'scene/table/set-cell-style': () => import('./scene/table/set-cell-style.snippet'),
70
72
  };
71
73
 
72
74
  export default snippets;
@@ -125,10 +127,19 @@ function normalizeScenes(def: any, key: string): string[] {
125
127
  return [];
126
128
  }
127
129
 
130
+ function normalizeSceneGroup(scene: string): string {
131
+ const mapping: Record<string, string> = {
132
+ detailFieldEvent: 'detail',
133
+ tableFieldEvent: 'table',
134
+ formFieldEvent: 'form',
135
+ };
136
+ return mapping[scene] || scene;
137
+ }
138
+
128
139
  function computeGroups(def: any, key: string): string[] {
129
140
  const scenes = normalizeScenes(def, key);
130
141
  if (scenes.length) {
131
- return scenes.map((scene) => `scene/${scene}`);
142
+ return Array.from(new Set(scenes.map((scene) => `scene/${normalizeSceneGroup(scene)}`)));
132
143
  }
133
144
  const parts = key.split('/');
134
145
  if (!parts.length) return [];
@@ -0,0 +1,30 @@
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
+
10
+ import type { SnippetModule } from '../../types';
11
+ const snippet: SnippetModule = {
12
+ contexts: ['*'],
13
+ scenes: ['detailFieldEvent', 'formFieldEvent'],
14
+ prefix: 'sn-field-style',
15
+ label: 'Set field style',
16
+ description: 'Customize form and detail field styles',
17
+ locales: {
18
+ 'zh-CN': {
19
+ label: '表单、详情字段样式设置',
20
+ description: '自定义表单字段和详情字段的样式',
21
+ },
22
+ },
23
+ content: `
24
+ ctx.model.subModels.field.props.style = {
25
+ fontWeight: 900,
26
+ };
27
+ `,
28
+ };
29
+
30
+ export default snippet;