@nocobase/plugin-flow-engine 2.1.0-alpha.12 → 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 (152) hide show
  1. package/dist/externalVersion.js +12 -11
  2. package/dist/node_modules/ajv/package.json +1 -1
  3. package/dist/node_modules/ses/package.json +1 -1
  4. package/dist/node_modules/zod/package.json +1 -1
  5. package/dist/server/flow-models/schema-contribution-collector.d.ts +2 -1
  6. package/dist/server/flow-models/schema-contribution-collector.js +26 -5
  7. package/dist/server/flow-schema-contributions/actions/aclCheck.d.ts +1 -1
  8. package/dist/server/flow-schema-contributions/actions/aclCheckRefresh.d.ts +1 -1
  9. package/dist/server/flow-schema-contributions/actions/actionLinkageRules.d.ts +1 -1
  10. package/dist/server/flow-schema-contributions/actions/confirm.d.ts +1 -1
  11. package/dist/server/flow-schema-contributions/actions/customVariable.d.ts +1 -1
  12. package/dist/server/flow-schema-contributions/actions/dataScope.d.ts +1 -1
  13. package/dist/server/flow-schema-contributions/actions/detailsFieldLinkageRules.d.ts +1 -1
  14. package/dist/server/flow-schema-contributions/actions/fieldLinkageRules.d.ts +1 -1
  15. package/dist/server/flow-schema-contributions/actions/filterFormDefaultValues.d.ts +1 -1
  16. package/dist/server/flow-schema-contributions/actions/formAssignRules.d.ts +1 -1
  17. package/dist/server/flow-schema-contributions/actions/index.d.ts +1 -1
  18. package/dist/server/flow-schema-contributions/actions/layout.d.ts +1 -1
  19. package/dist/server/flow-schema-contributions/actions/linkageRulesRefresh.d.ts +1 -1
  20. package/dist/server/flow-schema-contributions/actions/navigateToURL.d.ts +1 -1
  21. package/dist/server/flow-schema-contributions/actions/openView.d.ts +1 -1
  22. package/dist/server/flow-schema-contributions/actions/refreshTargetBlocks.d.ts +1 -1
  23. package/dist/server/flow-schema-contributions/actions/runjs.d.ts +1 -1
  24. package/dist/server/flow-schema-contributions/actions/setTargetDataScope.d.ts +1 -1
  25. package/dist/server/flow-schema-contributions/actions/showMessage.d.ts +1 -1
  26. package/dist/server/flow-schema-contributions/actions/showNotification.d.ts +1 -1
  27. package/dist/server/flow-schema-contributions/actions/sortingRule.d.ts +1 -1
  28. package/dist/server/flow-schema-contributions/field-models.d.ts +1 -1
  29. package/dist/server/flow-schema-contributions/index.d.ts +1 -1
  30. package/dist/server/flow-schema-contributions/models/ActionBulkEditModel.d.ts +10 -0
  31. package/dist/server/flow-schema-contributions/models/ActionBulkEditModel.js +382 -0
  32. package/dist/server/flow-schema-contributions/models/ActionBulkUpdateModel.d.ts +10 -0
  33. package/dist/server/flow-schema-contributions/models/ActionBulkUpdateModel.js +169 -0
  34. package/dist/server/flow-schema-contributions/models/ActionCustomRequestModel.d.ts +11 -0
  35. package/dist/server/flow-schema-contributions/models/ActionCustomRequestModel.js +115 -0
  36. package/dist/server/flow-schema-contributions/models/ActionDuplicateModel.d.ts +10 -0
  37. package/dist/server/flow-schema-contributions/models/ActionDuplicateModel.js +169 -0
  38. package/dist/server/flow-schema-contributions/models/ActionExportModel.d.ts +10 -0
  39. package/dist/server/flow-schema-contributions/models/ActionExportModel.js +141 -0
  40. package/dist/server/flow-schema-contributions/models/ActionImportModel.d.ts +10 -0
  41. package/dist/server/flow-schema-contributions/models/ActionImportModel.js +122 -0
  42. package/dist/server/flow-schema-contributions/models/ActionModel.d.ts +1 -1
  43. package/dist/server/flow-schema-contributions/models/AddChildActionModel.d.ts +1 -1
  44. package/dist/server/flow-schema-contributions/models/AddNewActionModel.d.ts +1 -1
  45. package/dist/server/flow-schema-contributions/models/AssignFormGridModel.d.ts +1 -1
  46. package/dist/server/flow-schema-contributions/models/AssignFormItemModel.d.ts +1 -1
  47. package/dist/server/flow-schema-contributions/models/AssignFormModel.d.ts +1 -1
  48. package/dist/server/flow-schema-contributions/models/BasePageTabModel.d.ts +1 -1
  49. package/dist/server/flow-schema-contributions/models/BlockGridCardModel.d.ts +10 -0
  50. package/dist/server/flow-schema-contributions/models/BlockGridCardModel.js +449 -0
  51. package/dist/server/flow-schema-contributions/models/BlockGridModel.d.ts +1 -1
  52. package/dist/server/flow-schema-contributions/models/BlockIframeModel.d.ts +10 -0
  53. package/dist/server/flow-schema-contributions/models/BlockIframeModel.js +143 -0
  54. package/dist/server/flow-schema-contributions/models/BlockListModel.d.ts +10 -0
  55. package/dist/server/flow-schema-contributions/models/BlockListModel.js +435 -0
  56. package/dist/server/flow-schema-contributions/models/BlockMarkdownModel.d.ts +10 -0
  57. package/dist/server/flow-schema-contributions/models/BlockMarkdownModel.js +108 -0
  58. package/dist/server/flow-schema-contributions/models/BlockWorkbenchModel.d.ts +10 -0
  59. package/dist/server/flow-schema-contributions/models/BlockWorkbenchModel.js +173 -0
  60. package/dist/server/flow-schema-contributions/models/BulkDeleteActionModel.d.ts +1 -1
  61. package/dist/server/flow-schema-contributions/models/ChildPageModel.d.ts +1 -1
  62. package/dist/server/flow-schema-contributions/models/ChildPageTabModel.d.ts +1 -1
  63. package/dist/server/flow-schema-contributions/models/CommentsModel.d.ts +10 -0
  64. package/dist/server/flow-schema-contributions/models/CommentsModel.js +255 -0
  65. package/dist/server/flow-schema-contributions/models/CreateFormModel.d.ts +1 -1
  66. package/dist/server/flow-schema-contributions/models/DataVisualizationModel.d.ts +10 -0
  67. package/dist/server/flow-schema-contributions/models/DataVisualizationModel.js +240 -0
  68. package/dist/server/flow-schema-contributions/models/DeleteActionModel.d.ts +1 -1
  69. package/dist/server/flow-schema-contributions/models/DetailsBlockModel.d.ts +1 -1
  70. package/dist/server/flow-schema-contributions/models/DetailsGridModel.d.ts +1 -1
  71. package/dist/server/flow-schema-contributions/models/DetailsItemModel.d.ts +1 -1
  72. package/dist/server/flow-schema-contributions/models/EditActionModel.d.ts +1 -1
  73. package/dist/server/flow-schema-contributions/models/EditFormModel.d.ts +1 -1
  74. package/dist/server/flow-schema-contributions/models/ExpandCollapseActionModel.d.ts +1 -1
  75. package/dist/server/flow-schema-contributions/models/FieldAttachmentUrlModel.d.ts +10 -0
  76. package/dist/server/flow-schema-contributions/models/FieldAttachmentUrlModel.js +87 -0
  77. package/dist/server/flow-schema-contributions/models/FieldCodeModel.d.ts +10 -0
  78. package/dist/server/flow-schema-contributions/models/FieldCodeModel.js +99 -0
  79. package/dist/server/flow-schema-contributions/models/FieldFormulaModel.d.ts +10 -0
  80. package/dist/server/flow-schema-contributions/models/FieldFormulaModel.js +152 -0
  81. package/dist/server/flow-schema-contributions/models/FieldMarkdownVditorModel.d.ts +10 -0
  82. package/dist/server/flow-schema-contributions/models/FieldMarkdownVditorModel.js +92 -0
  83. package/dist/server/flow-schema-contributions/models/FieldSequenceModel.d.ts +10 -0
  84. package/dist/server/flow-schema-contributions/models/FieldSequenceModel.js +60 -0
  85. package/dist/server/flow-schema-contributions/models/FieldSortModel.d.ts +10 -0
  86. package/dist/server/flow-schema-contributions/models/FieldSortModel.js +87 -0
  87. package/dist/server/flow-schema-contributions/models/FileManagerModel.d.ts +10 -0
  88. package/dist/server/flow-schema-contributions/models/FileManagerModel.js +115 -0
  89. package/dist/server/flow-schema-contributions/models/FilterActionModel.d.ts +1 -1
  90. package/dist/server/flow-schema-contributions/models/FilterFormBlockModel.d.ts +1 -1
  91. package/dist/server/flow-schema-contributions/models/FilterFormCollapseActionModel.d.ts +1 -1
  92. package/dist/server/flow-schema-contributions/models/FilterFormCustomFieldModel.d.ts +1 -1
  93. package/dist/server/flow-schema-contributions/models/FilterFormGridModel.d.ts +1 -1
  94. package/dist/server/flow-schema-contributions/models/FilterFormItemModel.d.ts +1 -1
  95. package/dist/server/flow-schema-contributions/models/FilterFormJSActionModel.d.ts +1 -1
  96. package/dist/server/flow-schema-contributions/models/FilterFormResetActionModel.d.ts +1 -1
  97. package/dist/server/flow-schema-contributions/models/FilterFormSubmitActionModel.d.ts +1 -1
  98. package/dist/server/flow-schema-contributions/models/FormAssociationItemModel.d.ts +1 -1
  99. package/dist/server/flow-schema-contributions/models/FormBlockModel.d.ts +1 -1
  100. package/dist/server/flow-schema-contributions/models/FormGridModel.d.ts +1 -1
  101. package/dist/server/flow-schema-contributions/models/FormItemModel.d.ts +1 -1
  102. package/dist/server/flow-schema-contributions/models/FormSubmitActionModel.d.ts +1 -1
  103. package/dist/server/flow-schema-contributions/models/JSActionModel.d.ts +1 -1
  104. package/dist/server/flow-schema-contributions/models/JSBlockModel.d.ts +1 -1
  105. package/dist/server/flow-schema-contributions/models/JSCollectionActionModel.d.ts +1 -1
  106. package/dist/server/flow-schema-contributions/models/JSColumnModel.d.ts +1 -1
  107. package/dist/server/flow-schema-contributions/models/JSFormActionModel.d.ts +1 -1
  108. package/dist/server/flow-schema-contributions/models/JSItemModel.d.ts +1 -1
  109. package/dist/server/flow-schema-contributions/models/JSRecordActionModel.d.ts +1 -1
  110. package/dist/server/flow-schema-contributions/models/LinkActionModel.d.ts +1 -1
  111. package/dist/server/flow-schema-contributions/models/MapModel.d.ts +10 -0
  112. package/dist/server/flow-schema-contributions/models/MapModel.js +427 -0
  113. package/dist/server/flow-schema-contributions/models/PageModel.d.ts +1 -1
  114. package/dist/server/flow-schema-contributions/models/PageTabModel.d.ts +1 -1
  115. package/dist/server/flow-schema-contributions/models/PopupActionModel.d.ts +1 -1
  116. package/dist/server/flow-schema-contributions/models/PopupCollectionActionModel.d.ts +1 -1
  117. package/dist/server/flow-schema-contributions/models/RefreshActionModel.d.ts +1 -1
  118. package/dist/server/flow-schema-contributions/models/RootPageModel.d.ts +1 -1
  119. package/dist/server/flow-schema-contributions/models/RootPageTabModel.d.ts +1 -1
  120. package/dist/server/flow-schema-contributions/models/RouteModel.d.ts +1 -1
  121. package/dist/server/flow-schema-contributions/models/TableActionsColumnModel.d.ts +1 -1
  122. package/dist/server/flow-schema-contributions/models/TableBlockModel.d.ts +1 -1
  123. package/dist/server/flow-schema-contributions/models/TableColumnModel.d.ts +1 -1
  124. package/dist/server/flow-schema-contributions/models/TableCustomColumnModel.d.ts +1 -1
  125. package/dist/server/flow-schema-contributions/models/UiTemplatesModel.d.ts +10 -0
  126. package/dist/server/flow-schema-contributions/models/UiTemplatesModel.js +130 -0
  127. package/dist/server/flow-schema-contributions/models/UpdateRecordActionModel.d.ts +1 -1
  128. package/dist/server/flow-schema-contributions/models/ViewActionModel.d.ts +1 -1
  129. package/dist/server/flow-schema-contributions/models/index.d.ts +6 -1
  130. package/dist/server/flow-schema-contributions/models/index.js +114 -0
  131. package/dist/server/flow-schema-contributions/shared.d.ts +1 -1
  132. package/dist/server/flow-schema-registry/FlowSchemaRegistry.d.ts +154 -0
  133. package/dist/server/flow-schema-registry/FlowSchemaRegistry.js +1424 -0
  134. package/dist/server/flow-schema-registry/flow-schema-registry/fieldBinding.d.ts +32 -0
  135. package/dist/server/flow-schema-registry/flow-schema-registry/fieldBinding.js +159 -0
  136. package/dist/server/flow-schema-registry/flow-schema-registry/modelPatches.d.ts +16 -0
  137. package/dist/server/flow-schema-registry/flow-schema-registry/modelPatches.js +226 -0
  138. package/dist/server/flow-schema-registry/flow-schema-registry/schemaInference.d.ts +17 -0
  139. package/dist/server/flow-schema-registry/flow-schema-registry/schemaInference.js +204 -0
  140. package/dist/server/flow-schema-registry/flow-schema-registry/utils.d.ts +25 -0
  141. package/dist/server/flow-schema-registry/flow-schema-registry/utils.js +278 -0
  142. package/dist/server/flow-schema-registry/index.d.ts +10 -0
  143. package/dist/server/flow-schema-registry/index.js +32 -0
  144. package/dist/server/flow-schema-registry/types.d.ts +244 -0
  145. package/dist/server/flow-schema-registry/types.js +24 -0
  146. package/dist/server/flow-schema-service.d.ts +1 -1
  147. package/dist/server/flow-schema-service.js +2 -2
  148. package/dist/server/plugin.d.ts +1 -1
  149. package/dist/server/repository.d.ts +1 -0
  150. package/dist/server/repository.js +3 -5
  151. package/dist/server/server.js +1 -1
  152. package/package.json +2 -2
@@ -0,0 +1,25 @@
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 { FlowDynamicHint, FlowJsonSchema, FlowSchemaDocs, FlowSubModelSlotSchema } from '../types';
10
+ export declare const JSON_SCHEMA_DRAFT_07 = "http://json-schema.org/draft-07/schema#";
11
+ export declare function stableStringify(input: any): string;
12
+ export declare function deepFreezePlainGraph<T>(input: T, seen?: WeakSet<object>): T;
13
+ export declare function hashString(input: string): string;
14
+ export declare function deepMergeReplaceArrays<T>(base: T, patch: any): T;
15
+ export declare function mergeSchemas(base?: FlowJsonSchema, patch?: FlowJsonSchema): FlowJsonSchema | undefined;
16
+ export declare function normalizeSchemaHints(hints?: FlowDynamicHint[]): FlowDynamicHint[];
17
+ export declare function normalizeSchemaDocs(docs?: FlowSchemaDocs): FlowSchemaDocs;
18
+ export declare function normalizeStringArray(values?: string[]): string[];
19
+ export declare function createFlowHint(hint: FlowDynamicHint, metadata?: FlowDynamicHint['x-flow']): FlowDynamicHint;
20
+ export declare function collectAllowedUses(slot?: FlowSubModelSlotSchema): string[];
21
+ export declare function buildSkeletonFromSchema(schema?: FlowJsonSchema, options?: {
22
+ propertyName?: string;
23
+ depth?: number;
24
+ }): any;
25
+ export declare function toSchemaTitle(input: any, fallback: string): string;
@@ -0,0 +1,278 @@
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 __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
+ var utils_exports = {};
38
+ __export(utils_exports, {
39
+ JSON_SCHEMA_DRAFT_07: () => JSON_SCHEMA_DRAFT_07,
40
+ buildSkeletonFromSchema: () => buildSkeletonFromSchema,
41
+ collectAllowedUses: () => collectAllowedUses,
42
+ createFlowHint: () => createFlowHint,
43
+ deepFreezePlainGraph: () => deepFreezePlainGraph,
44
+ deepMergeReplaceArrays: () => deepMergeReplaceArrays,
45
+ hashString: () => hashString,
46
+ mergeSchemas: () => mergeSchemas,
47
+ normalizeSchemaDocs: () => normalizeSchemaDocs,
48
+ normalizeSchemaHints: () => normalizeSchemaHints,
49
+ normalizeStringArray: () => normalizeStringArray,
50
+ stableStringify: () => stableStringify,
51
+ toSchemaTitle: () => toSchemaTitle
52
+ });
53
+ module.exports = __toCommonJS(utils_exports);
54
+ var import_lodash = __toESM(require("lodash"));
55
+ const JSON_SCHEMA_DRAFT_07 = "http://json-schema.org/draft-07/schema#";
56
+ function stableStringify(input) {
57
+ if (Array.isArray(input)) {
58
+ return `[${input.map((item) => stableStringify(item)).join(",")}]`;
59
+ }
60
+ if (import_lodash.default.isPlainObject(input)) {
61
+ const entries = Object.entries(input).sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => `${JSON.stringify(key)}:${stableStringify(value)}`);
62
+ return `{${entries.join(",")}}`;
63
+ }
64
+ return JSON.stringify(input) ?? "null";
65
+ }
66
+ function deepFreezePlainGraph(input, seen = /* @__PURE__ */ new WeakSet()) {
67
+ if (Array.isArray(input)) {
68
+ if (seen.has(input)) {
69
+ return input;
70
+ }
71
+ seen.add(input);
72
+ for (const item of input) {
73
+ deepFreezePlainGraph(item, seen);
74
+ }
75
+ return Object.freeze(input);
76
+ }
77
+ if (!import_lodash.default.isPlainObject(input)) {
78
+ return input;
79
+ }
80
+ const objectValue = input;
81
+ if (seen.has(objectValue)) {
82
+ return input;
83
+ }
84
+ seen.add(objectValue);
85
+ for (const value of Object.values(objectValue)) {
86
+ deepFreezePlainGraph(value, seen);
87
+ }
88
+ return Object.freeze(objectValue);
89
+ }
90
+ function hashString(input) {
91
+ let hash = 0;
92
+ for (let index = 0; index < input.length; index++) {
93
+ hash = hash * 31 + input.charCodeAt(index) >>> 0;
94
+ }
95
+ return hash.toString(16).padStart(8, "0");
96
+ }
97
+ function deepMergeReplaceArrays(base, patch) {
98
+ if (typeof patch === "undefined") {
99
+ return import_lodash.default.cloneDeep(base);
100
+ }
101
+ if (typeof base === "undefined") {
102
+ return import_lodash.default.cloneDeep(patch);
103
+ }
104
+ return import_lodash.default.mergeWith({}, import_lodash.default.cloneDeep(base), import_lodash.default.cloneDeep(patch), (_objValue, srcValue) => {
105
+ if (Array.isArray(srcValue)) {
106
+ return import_lodash.default.cloneDeep(srcValue);
107
+ }
108
+ return void 0;
109
+ });
110
+ }
111
+ function mergeSchemas(base, patch) {
112
+ if (!base && !patch) return void 0;
113
+ if (!base) return import_lodash.default.cloneDeep(patch);
114
+ if (!patch) return import_lodash.default.cloneDeep(base);
115
+ return deepMergeReplaceArrays(base, patch);
116
+ }
117
+ function normalizeFlowHintMetadata(metadata) {
118
+ if (!metadata || typeof metadata !== "object" || Array.isArray(metadata)) {
119
+ return void 0;
120
+ }
121
+ const slotRules = metadata.slotRules && typeof metadata.slotRules === "object" && !Array.isArray(metadata.slotRules) ? import_lodash.default.pickBy(
122
+ {
123
+ slotKey: metadata.slotRules.slotKey,
124
+ type: metadata.slotRules.type,
125
+ allowedUses: Array.isArray(metadata.slotRules.allowedUses) ? metadata.slotRules.allowedUses.filter(Boolean) : metadata.slotRules.allowedUses
126
+ },
127
+ (value) => value !== void 0
128
+ ) : void 0;
129
+ const normalized = import_lodash.default.pickBy(
130
+ {
131
+ slotRules: slotRules && Object.keys(slotRules).length > 0 ? slotRules : void 0,
132
+ contextRequirements: Array.isArray(metadata.contextRequirements) ? metadata.contextRequirements.filter(Boolean) : metadata.contextRequirements,
133
+ unresolvedReason: metadata.unresolvedReason,
134
+ recommendedFallback: metadata.recommendedFallback
135
+ },
136
+ (value) => value !== void 0
137
+ );
138
+ return Object.keys(normalized).length > 0 ? normalized : void 0;
139
+ }
140
+ function normalizeFlowHint(hint) {
141
+ const normalizedHint = { ...hint };
142
+ const flowMetadata = normalizeFlowHintMetadata(hint["x-flow"]);
143
+ if (flowMetadata) {
144
+ normalizedHint["x-flow"] = flowMetadata;
145
+ } else {
146
+ delete normalizedHint["x-flow"];
147
+ }
148
+ return normalizedHint;
149
+ }
150
+ function normalizeSchemaHints(hints) {
151
+ return Array.isArray(hints) ? import_lodash.default.uniqBy(
152
+ hints.map((item) => normalizeFlowHint(item)),
153
+ (item) => `${item.kind}:${item.path || ""}:${item.message}`
154
+ ) : [];
155
+ }
156
+ function normalizeSchemaDocs(docs) {
157
+ return {
158
+ description: docs == null ? void 0 : docs.description,
159
+ examples: Array.isArray(docs == null ? void 0 : docs.examples) ? import_lodash.default.cloneDeep(docs.examples) : [],
160
+ minimalExample: (docs == null ? void 0 : docs.minimalExample) === void 0 ? void 0 : import_lodash.default.cloneDeep(docs.minimalExample),
161
+ commonPatterns: Array.isArray(docs == null ? void 0 : docs.commonPatterns) ? import_lodash.default.cloneDeep(docs.commonPatterns) : [],
162
+ antiPatterns: Array.isArray(docs == null ? void 0 : docs.antiPatterns) ? import_lodash.default.cloneDeep(docs.antiPatterns) : [],
163
+ dynamicHints: normalizeSchemaHints(docs == null ? void 0 : docs.dynamicHints)
164
+ };
165
+ }
166
+ function normalizeStringArray(values) {
167
+ if (!Array.isArray(values)) {
168
+ return [];
169
+ }
170
+ return import_lodash.default.uniq(values.map((item) => String(item || "").trim()).filter(Boolean));
171
+ }
172
+ function createFlowHint(hint, metadata) {
173
+ const result = { ...hint };
174
+ const flowMetadata = normalizeFlowHintMetadata({
175
+ ...hint["x-flow"] || {},
176
+ ...metadata || {}
177
+ });
178
+ if (flowMetadata) {
179
+ result["x-flow"] = flowMetadata;
180
+ } else {
181
+ delete result["x-flow"];
182
+ }
183
+ return result;
184
+ }
185
+ function collectAllowedUses(slot) {
186
+ if (!slot) {
187
+ return [];
188
+ }
189
+ if (Array.isArray(slot.uses)) {
190
+ return slot.uses.filter(Boolean);
191
+ }
192
+ return slot.use ? [slot.use] : [];
193
+ }
194
+ function buildSkeletonFromSchema(schema, options = {}) {
195
+ var _a, _b;
196
+ if (!schema) return void 0;
197
+ if (schema.default !== void 0) return import_lodash.default.cloneDeep(schema.default);
198
+ if (schema.const !== void 0) return import_lodash.default.cloneDeep(schema.const);
199
+ if (Array.isArray(schema.enum) && schema.enum.length > 0) return import_lodash.default.cloneDeep(schema.enum[0]);
200
+ const depth = options.depth || 0;
201
+ if (depth > 4) {
202
+ return void 0;
203
+ }
204
+ const type = Array.isArray(schema.type) ? schema.type[0] : schema.type;
205
+ if (type === "object" || !type && import_lodash.default.isPlainObject(schema.properties)) {
206
+ const result = {};
207
+ const properties = schema.properties || {};
208
+ const required = new Set(schema.required || []);
209
+ for (const [key, value] of Object.entries(properties)) {
210
+ const child = buildSkeletonFromSchema(value, {
211
+ propertyName: key,
212
+ depth: depth + 1
213
+ });
214
+ const includeOptionalTopLevelShell = depth === 0 && ["stepParams", "subModels", "flowRegistry"].includes(key) && child !== void 0 && (import_lodash.default.isPlainObject(child) && Object.keys(child).length > 0 || Array.isArray(child));
215
+ if (!includeOptionalTopLevelShell && !required.has(key) && value.default === void 0 && value.const === void 0) {
216
+ continue;
217
+ }
218
+ if (child !== void 0) {
219
+ result[key] = child;
220
+ }
221
+ }
222
+ return result;
223
+ }
224
+ if (type === "array") {
225
+ return [];
226
+ }
227
+ if (type === "boolean") {
228
+ return false;
229
+ }
230
+ if (type === "integer" || type === "number") {
231
+ return 0;
232
+ }
233
+ if (type === "string") {
234
+ const propertyName = options.propertyName || "value";
235
+ if (propertyName === "uid") {
236
+ return "todo-uid";
237
+ }
238
+ return "";
239
+ }
240
+ if ((_a = schema.oneOf) == null ? void 0 : _a.length) {
241
+ return buildSkeletonFromSchema(schema.oneOf[0], {
242
+ propertyName: options.propertyName,
243
+ depth: depth + 1
244
+ });
245
+ }
246
+ if ((_b = schema.anyOf) == null ? void 0 : _b.length) {
247
+ return buildSkeletonFromSchema(schema.anyOf[0], {
248
+ propertyName: options.propertyName,
249
+ depth: depth + 1
250
+ });
251
+ }
252
+ return void 0;
253
+ }
254
+ function toSchemaTitle(input, fallback) {
255
+ if (typeof input === "string") {
256
+ return input;
257
+ }
258
+ if (typeof input === "number" || typeof input === "boolean") {
259
+ return String(input);
260
+ }
261
+ return fallback;
262
+ }
263
+ // Annotate the CommonJS export names for ESM import in node:
264
+ 0 && (module.exports = {
265
+ JSON_SCHEMA_DRAFT_07,
266
+ buildSkeletonFromSchema,
267
+ collectAllowedUses,
268
+ createFlowHint,
269
+ deepFreezePlainGraph,
270
+ deepMergeReplaceArrays,
271
+ hashString,
272
+ mergeSchemas,
273
+ normalizeSchemaDocs,
274
+ normalizeSchemaHints,
275
+ normalizeStringArray,
276
+ stableStringify,
277
+ toSchemaTitle
278
+ });
@@ -0,0 +1,10 @@
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
+ export * from './types';
10
+ export * from './FlowSchemaRegistry';
@@ -0,0 +1,32 @@
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 __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var flow_schema_registry_exports = {};
25
+ module.exports = __toCommonJS(flow_schema_registry_exports);
26
+ __reExport(flow_schema_registry_exports, require("./types"), module.exports);
27
+ __reExport(flow_schema_registry_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")
32
+ });
@@ -0,0 +1,244 @@
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 as BaseActionDefinition, FlowContext, FlowModel, FlowModelMeta as BaseFlowModelMeta, ModelConstructor as BaseModelConstructor, StepDefinition as BaseStepDefinition } from '@nocobase/flow-engine';
10
+ export type FlowJsonSchema = Record<string, any> & {
11
+ $schema?: string;
12
+ $id?: string;
13
+ };
14
+ export interface FlowDynamicHintMetadata {
15
+ slotRules?: {
16
+ slotKey?: string;
17
+ type?: 'object' | 'array';
18
+ allowedUses?: string[];
19
+ };
20
+ contextRequirements?: string[];
21
+ unresolvedReason?: string;
22
+ recommendedFallback?: any;
23
+ }
24
+ export interface FlowDynamicHint {
25
+ kind: 'dynamic-ui-schema' | 'dynamic-children' | 'custom-component' | 'x-reactions' | 'unresolved-action' | 'manual-schema-required' | 'unresolved-model';
26
+ path?: string;
27
+ message: string;
28
+ 'x-flow'?: FlowDynamicHintMetadata;
29
+ }
30
+ export interface FlowSchemaCoverage {
31
+ status: 'auto' | 'manual' | 'mixed' | 'unresolved';
32
+ source: 'official' | 'plugin' | 'third-party';
33
+ strict?: boolean;
34
+ issues?: string[];
35
+ }
36
+ export type FlowModelSchemaExposure = 'public' | 'internal';
37
+ export interface FlowSchemaPattern {
38
+ title: string;
39
+ description?: string;
40
+ snippet?: any;
41
+ }
42
+ export interface FlowSchemaDocs {
43
+ description?: string;
44
+ examples?: any[];
45
+ minimalExample?: any;
46
+ commonPatterns?: FlowSchemaPattern[];
47
+ antiPatterns?: FlowSchemaPattern[];
48
+ dynamicHints?: FlowDynamicHint[];
49
+ }
50
+ export interface FlowFieldBindingConditions {
51
+ association?: boolean;
52
+ fieldTypes?: string[];
53
+ targetCollectionTemplateIn?: string[];
54
+ targetCollectionTemplateNotIn?: string[];
55
+ }
56
+ export interface FlowFieldBindingContextContribution {
57
+ name: string;
58
+ inherits?: string[];
59
+ }
60
+ export interface FlowFieldBindingContribution {
61
+ context: string;
62
+ use: string;
63
+ interfaces: string[];
64
+ isDefault?: boolean;
65
+ order?: number;
66
+ conditions?: FlowFieldBindingConditions;
67
+ defaultProps?: any;
68
+ }
69
+ export interface FlowFieldModelCompatibility {
70
+ context: string;
71
+ interfaces: string[];
72
+ isDefault?: boolean;
73
+ order?: number;
74
+ association?: boolean;
75
+ fieldTypes?: string[];
76
+ targetCollectionTemplateIn?: string[];
77
+ targetCollectionTemplateNotIn?: string[];
78
+ inheritParentFieldBinding?: boolean;
79
+ }
80
+ export interface FlowSchemaBundleSlotCatalog {
81
+ type: 'object' | 'array';
82
+ required?: boolean;
83
+ minItems?: number;
84
+ open?: boolean;
85
+ candidates: FlowSchemaBundleNode[];
86
+ }
87
+ export interface FlowSchemaBundleNode {
88
+ use: string;
89
+ title?: string;
90
+ compatibility?: FlowFieldModelCompatibility;
91
+ subModelCatalog?: Record<string, FlowSchemaBundleSlotCatalog>;
92
+ }
93
+ export type FlowSchemaBundleItem = FlowSchemaBundleNode;
94
+ export interface FlowSchemaBundleDocument {
95
+ items: FlowSchemaBundleNode[];
96
+ }
97
+ export interface FlowSchemaContextEdge {
98
+ parentUse: string;
99
+ slotKey: string;
100
+ childUse: string;
101
+ }
102
+ export interface FlowSubModelContextPathStep {
103
+ slotKey: string;
104
+ use?: string | string[];
105
+ }
106
+ export interface FlowModelSchemaPatch {
107
+ stepParamsSchema?: FlowJsonSchema;
108
+ flowRegistrySchema?: FlowJsonSchema;
109
+ subModelSlots?: Record<string, FlowSubModelSlotSchema>;
110
+ flowRegistrySchemaPatch?: FlowJsonSchema;
111
+ docs?: FlowSchemaDocs;
112
+ examples?: any[];
113
+ skeleton?: any;
114
+ dynamicHints?: FlowDynamicHint[];
115
+ }
116
+ export interface FlowDescendantSchemaPatch {
117
+ path: FlowSubModelContextPathStep[];
118
+ patch: FlowModelSchemaPatch;
119
+ }
120
+ export interface FlowSubModelSlotSchema {
121
+ type: 'object' | 'array';
122
+ use?: string;
123
+ uses?: string[];
124
+ required?: boolean;
125
+ minItems?: number;
126
+ dynamic?: boolean;
127
+ schema?: FlowJsonSchema;
128
+ fieldBindingContext?: string;
129
+ childSchemaPatch?: FlowModelSchemaPatch | Record<string, FlowModelSchemaPatch>;
130
+ descendantSchemaPatches?: FlowDescendantSchemaPatch[];
131
+ description?: string;
132
+ }
133
+ export interface FlowModelSchemaMeta {
134
+ stepParamsSchema?: FlowJsonSchema;
135
+ flowRegistrySchema?: FlowJsonSchema;
136
+ subModelSlots?: Record<string, FlowSubModelSlotSchema>;
137
+ flowRegistrySchemaPatch?: FlowJsonSchema;
138
+ docs?: FlowSchemaDocs;
139
+ examples?: any[];
140
+ skeleton?: any;
141
+ dynamicHints?: FlowDynamicHint[];
142
+ source?: FlowSchemaCoverage['source'];
143
+ strict?: boolean;
144
+ exposure?: FlowModelSchemaExposure;
145
+ abstract?: boolean;
146
+ allowDirectUse?: boolean;
147
+ suggestedUses?: string[];
148
+ }
149
+ export type FlowModelMeta = BaseFlowModelMeta & {
150
+ schema?: FlowModelSchemaMeta;
151
+ };
152
+ export type ModelConstructor<T extends FlowModel<any> = FlowModel<any>> = BaseModelConstructor<T> & {
153
+ meta?: FlowModelMeta;
154
+ };
155
+ export type ActionDefinition<TModel extends FlowModel = FlowModel, TCtx extends FlowContext = FlowContext> = BaseActionDefinition<TModel, TCtx> & {
156
+ paramsSchema?: FlowJsonSchema;
157
+ paramsSchemaPatch?: FlowJsonSchema;
158
+ schemaDocs?: FlowSchemaDocs;
159
+ };
160
+ export type StepDefinition<TModel extends FlowModel = FlowModel> = BaseStepDefinition<TModel> & {
161
+ paramsSchemaPatch?: FlowJsonSchema;
162
+ paramsSchemaOverride?: FlowJsonSchema;
163
+ schemaDocs?: FlowSchemaDocs;
164
+ };
165
+ export interface FlowActionSchemaContribution {
166
+ name: string;
167
+ title?: string;
168
+ paramsSchema?: FlowJsonSchema;
169
+ docs?: FlowSchemaDocs;
170
+ source?: FlowSchemaCoverage['source'];
171
+ strict?: boolean;
172
+ }
173
+ export interface FlowModelSchemaContribution {
174
+ use: string;
175
+ title?: string;
176
+ stepParamsSchema?: FlowJsonSchema;
177
+ flowRegistrySchema?: FlowJsonSchema;
178
+ subModelSlots?: Record<string, FlowSubModelSlotSchema>;
179
+ flowRegistrySchemaPatch?: FlowJsonSchema;
180
+ docs?: FlowSchemaDocs;
181
+ examples?: any[];
182
+ skeleton?: any;
183
+ dynamicHints?: FlowDynamicHint[];
184
+ source?: FlowSchemaCoverage['source'];
185
+ strict?: boolean;
186
+ exposure?: FlowModelSchemaExposure;
187
+ abstract?: boolean;
188
+ allowDirectUse?: boolean;
189
+ suggestedUses?: string[];
190
+ }
191
+ export interface FlowSchemaContributionDefaults {
192
+ source?: FlowSchemaCoverage['source'];
193
+ strict?: boolean;
194
+ }
195
+ export interface FlowSchemaSlotUseExpansion {
196
+ parentUse: string;
197
+ slotKey: string;
198
+ uses: string[];
199
+ }
200
+ export interface FlowSchemaInventoryContribution {
201
+ publicTreeRoots?: string[];
202
+ slotUseExpansions?: FlowSchemaSlotUseExpansion[];
203
+ }
204
+ export interface FlowSchemaContribution {
205
+ models?: FlowModelSchemaContribution[] | Record<string, FlowModelSchemaContribution>;
206
+ actions?: FlowActionSchemaContribution[] | Record<string, FlowActionSchemaContribution>;
207
+ fieldBindingContexts?: FlowFieldBindingContextContribution[] | Record<string, FlowFieldBindingContextContribution>;
208
+ fieldBindings?: FlowFieldBindingContribution[] | Record<string, FlowFieldBindingContribution | FlowFieldBindingContribution[]>;
209
+ inventory?: FlowSchemaInventoryContribution;
210
+ defaults?: FlowSchemaContributionDefaults;
211
+ }
212
+ export interface FlowSchemaContributionProvider {
213
+ getFlowSchemaContributions(): FlowSchemaContribution | undefined | Promise<FlowSchemaContribution | undefined>;
214
+ }
215
+ export interface FlowSchemaDocument {
216
+ use: string;
217
+ title?: string;
218
+ jsonSchema: FlowJsonSchema;
219
+ coverage: FlowSchemaCoverage;
220
+ dynamicHints: FlowDynamicHint[];
221
+ examples: any[];
222
+ minimalExample?: any;
223
+ commonPatterns: FlowSchemaPattern[];
224
+ antiPatterns: FlowSchemaPattern[];
225
+ skeleton: any;
226
+ hash: string;
227
+ source: FlowSchemaCoverage['source'];
228
+ }
229
+ export type FlowSchemaDetail = 'compact' | 'full';
230
+ export interface FlowSchemaPublicDocument {
231
+ use: string;
232
+ title?: string;
233
+ jsonSchema: FlowJsonSchema;
234
+ dynamicHints: FlowDynamicHint[];
235
+ minimalExample?: any;
236
+ commonPatterns: FlowSchemaPattern[];
237
+ antiPatterns: FlowSchemaPattern[];
238
+ hash: string;
239
+ source: FlowSchemaCoverage['source'];
240
+ }
241
+ export type FlowSchemaActionDefinition<TModel extends FlowModel = FlowModel, TCtx extends FlowContext = FlowContext> = ActionDefinition<TModel, TCtx>;
242
+ export type FlowSchemaStepDefinition<TModel extends FlowModel = FlowModel> = StepDefinition<TModel>;
243
+ export type FlowSchemaModelMeta = FlowModelMeta;
244
+ export type FlowSchemaModelConstructor<T extends FlowModel<any> = FlowModel<any>> = ModelConstructor<T>;
@@ -0,0 +1,24 @@
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 __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
+ var types_exports = {};
24
+ module.exports = __toCommonJS(types_exports);
@@ -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 { FlowSchemaRegistry, type ActionDefinition, type FlowActionSchemaContribution, type FlowFieldBindingContextContribution, type FlowFieldBindingContribution, type FlowSchemaInventoryContribution, type FlowModelSchemaContribution, type FlowSchemaBundleDocument, type FlowSchemaContextEdge, type FlowSchemaDocument, type FlowSchemaDetail, type FlowSchemaPublicDocument, type ModelConstructor } from '@nocobase/flow-engine/server';
9
+ import { FlowSchemaRegistry, type ActionDefinition, type FlowActionSchemaContribution, type FlowFieldBindingContextContribution, type FlowFieldBindingContribution, type FlowSchemaInventoryContribution, type FlowModelSchemaContribution, type FlowSchemaBundleDocument, type FlowSchemaContextEdge, type FlowSchemaDocument, type FlowSchemaDetail, type FlowSchemaPublicDocument, type ModelConstructor } from './flow-schema-registry';
10
10
  export interface FlowSchemaValidationIssue {
11
11
  level: 'error' | 'warning';
12
12
  jsonPointer: string;
@@ -41,7 +41,7 @@ __export(flow_schema_service_exports, {
41
41
  module.exports = __toCommonJS(flow_schema_service_exports);
42
42
  var import_ajv = __toESM(require("ajv"));
43
43
  var import_utils = require("@nocobase/utils");
44
- var import_server = require("@nocobase/flow-engine/server");
44
+ var import_flow_schema_registry = require("./flow-schema-registry");
45
45
  const MODEL_SHELL_SCHEMA = {
46
46
  $schema: "http://json-schema.org/draft-07/schema#",
47
47
  type: "object",
@@ -130,7 +130,7 @@ function readFieldBindingUse(value) {
130
130
  return String(((_b = (_a = value == null ? void 0 : value.stepParams) == null ? void 0 : _a.fieldBinding) == null ? void 0 : _b.use) || "").trim();
131
131
  }
132
132
  class FlowSchemaService {
133
- registry = new import_server.FlowSchemaRegistry();
133
+ registry = new import_flow_schema_registry.FlowSchemaRegistry();
134
134
  ajv = new import_ajv.default({
135
135
  allErrors: true
136
136
  });
@@ -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 type { FlowSchemaContribution } from '@nocobase/flow-engine';
9
+ import type { FlowSchemaContribution } from './flow-schema-registry';
10
10
  import PluginUISchemaStorageServer from './server';
11
11
  export declare class PluginFlowEngineServer extends PluginUISchemaStorageServer {
12
12
  private globalContext;
@@ -48,6 +48,7 @@ interface InsertAdjacentOptions extends removeParentOptions {
48
48
  export declare function transaction(transactionAbleArgPosition?: number): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
49
49
  export declare class FlowModelRepository extends Repository {
50
50
  cache: Cache;
51
+ emitTransactionRollback(transaction?: Transaction): Promise<void>;
51
52
  get flowModelsTableName(): any;
52
53
  get flowModelTreePathTableName(): any;
53
54
  static schemaToSingleNodes(schema: any, carry?: SchemaNode[], childOptions?: ChildOptions): SchemaNode[];