@nocobase/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.
- package/lib/FlowDefinition.d.ts +0 -4
- package/lib/index.d.ts +0 -1
- package/lib/index.js +1 -3
- package/lib/models/DisplayItemModel.d.ts +1 -1
- package/lib/models/EditableItemModel.d.ts +1 -1
- package/lib/models/FilterableItemModel.d.ts +1 -1
- package/lib/runjs-context/snippets/index.js +13 -2
- package/lib/{server.d.ts → runjs-context/snippets/scene/detail/set-field-style.snippet.d.ts} +3 -2
- package/lib/{server.js → runjs-context/snippets/scene/detail/set-field-style.snippet.js} +27 -9
- package/{src/server.ts → lib/runjs-context/snippets/scene/table/set-cell-style.snippet.d.ts} +3 -3
- package/lib/runjs-context/snippets/scene/table/set-cell-style.snippet.js +54 -0
- package/lib/types.d.ts +0 -221
- package/package.json +4 -4
- package/src/__tests__/runjsSnippets.test.ts +21 -0
- package/src/index.ts +0 -1
- package/src/models/DisplayItemModel.tsx +1 -1
- package/src/models/EditableItemModel.tsx +1 -1
- package/src/models/FilterableItemModel.tsx +1 -1
- package/src/runjs-context/snippets/index.ts +12 -1
- package/src/runjs-context/snippets/scene/detail/set-field-style.snippet.ts +30 -0
- package/src/runjs-context/snippets/scene/table/set-cell-style.snippet.ts +34 -0
- package/src/types.ts +0 -262
- package/lib/FlowSchemaRegistry.d.ts +0 -154
- package/lib/FlowSchemaRegistry.js +0 -1427
- package/lib/flow-schema-registry/fieldBinding.d.ts +0 -32
- package/lib/flow-schema-registry/fieldBinding.js +0 -165
- package/lib/flow-schema-registry/modelPatches.d.ts +0 -16
- package/lib/flow-schema-registry/modelPatches.js +0 -235
- package/lib/flow-schema-registry/schemaInference.d.ts +0 -17
- package/lib/flow-schema-registry/schemaInference.js +0 -207
- package/lib/flow-schema-registry/utils.d.ts +0 -25
- package/lib/flow-schema-registry/utils.js +0 -293
- package/server.d.ts +0 -1
- package/server.js +0 -1
- package/src/FlowSchemaRegistry.ts +0 -1799
- package/src/__tests__/FlowSchemaRegistry.test.ts +0 -1951
- package/src/flow-schema-registry/fieldBinding.ts +0 -171
- package/src/flow-schema-registry/modelPatches.ts +0 -260
- package/src/flow-schema-registry/schemaInference.ts +0 -210
- package/src/flow-schema-registry/utils.ts +0 -268
|
@@ -1,25 +0,0 @@
|
|
|
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;
|
|
@@ -1,293 +0,0 @@
|
|
|
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
|
-
var __export = (target, all) => {
|
|
18
|
-
for (var name in all)
|
|
19
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
-
};
|
|
21
|
-
var __copyProps = (to, from, except, desc) => {
|
|
22
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
-
for (let key of __getOwnPropNames(from))
|
|
24
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
-
}
|
|
27
|
-
return to;
|
|
28
|
-
};
|
|
29
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
-
mod
|
|
36
|
-
));
|
|
37
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
-
var utils_exports = {};
|
|
39
|
-
__export(utils_exports, {
|
|
40
|
-
JSON_SCHEMA_DRAFT_07: () => JSON_SCHEMA_DRAFT_07,
|
|
41
|
-
buildSkeletonFromSchema: () => buildSkeletonFromSchema,
|
|
42
|
-
collectAllowedUses: () => collectAllowedUses,
|
|
43
|
-
createFlowHint: () => createFlowHint,
|
|
44
|
-
deepFreezePlainGraph: () => deepFreezePlainGraph,
|
|
45
|
-
deepMergeReplaceArrays: () => deepMergeReplaceArrays,
|
|
46
|
-
hashString: () => hashString,
|
|
47
|
-
mergeSchemas: () => mergeSchemas,
|
|
48
|
-
normalizeSchemaDocs: () => normalizeSchemaDocs,
|
|
49
|
-
normalizeSchemaHints: () => normalizeSchemaHints,
|
|
50
|
-
normalizeStringArray: () => normalizeStringArray,
|
|
51
|
-
stableStringify: () => stableStringify,
|
|
52
|
-
toSchemaTitle: () => toSchemaTitle
|
|
53
|
-
});
|
|
54
|
-
module.exports = __toCommonJS(utils_exports);
|
|
55
|
-
var import_lodash = __toESM(require("lodash"));
|
|
56
|
-
const JSON_SCHEMA_DRAFT_07 = "http://json-schema.org/draft-07/schema#";
|
|
57
|
-
function stableStringify(input) {
|
|
58
|
-
if (Array.isArray(input)) {
|
|
59
|
-
return `[${input.map((item) => stableStringify(item)).join(",")}]`;
|
|
60
|
-
}
|
|
61
|
-
if (import_lodash.default.isPlainObject(input)) {
|
|
62
|
-
const entries = Object.entries(input).sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => `${JSON.stringify(key)}:${stableStringify(value)}`);
|
|
63
|
-
return `{${entries.join(",")}}`;
|
|
64
|
-
}
|
|
65
|
-
return JSON.stringify(input) ?? "null";
|
|
66
|
-
}
|
|
67
|
-
__name(stableStringify, "stableStringify");
|
|
68
|
-
function deepFreezePlainGraph(input, seen = /* @__PURE__ */ new WeakSet()) {
|
|
69
|
-
if (Array.isArray(input)) {
|
|
70
|
-
if (seen.has(input)) {
|
|
71
|
-
return input;
|
|
72
|
-
}
|
|
73
|
-
seen.add(input);
|
|
74
|
-
for (const item of input) {
|
|
75
|
-
deepFreezePlainGraph(item, seen);
|
|
76
|
-
}
|
|
77
|
-
return Object.freeze(input);
|
|
78
|
-
}
|
|
79
|
-
if (!import_lodash.default.isPlainObject(input)) {
|
|
80
|
-
return input;
|
|
81
|
-
}
|
|
82
|
-
const objectValue = input;
|
|
83
|
-
if (seen.has(objectValue)) {
|
|
84
|
-
return input;
|
|
85
|
-
}
|
|
86
|
-
seen.add(objectValue);
|
|
87
|
-
for (const value of Object.values(objectValue)) {
|
|
88
|
-
deepFreezePlainGraph(value, seen);
|
|
89
|
-
}
|
|
90
|
-
return Object.freeze(objectValue);
|
|
91
|
-
}
|
|
92
|
-
__name(deepFreezePlainGraph, "deepFreezePlainGraph");
|
|
93
|
-
function hashString(input) {
|
|
94
|
-
let hash = 0;
|
|
95
|
-
for (let index = 0; index < input.length; index++) {
|
|
96
|
-
hash = hash * 31 + input.charCodeAt(index) >>> 0;
|
|
97
|
-
}
|
|
98
|
-
return hash.toString(16).padStart(8, "0");
|
|
99
|
-
}
|
|
100
|
-
__name(hashString, "hashString");
|
|
101
|
-
function deepMergeReplaceArrays(base, patch) {
|
|
102
|
-
if (typeof patch === "undefined") {
|
|
103
|
-
return import_lodash.default.cloneDeep(base);
|
|
104
|
-
}
|
|
105
|
-
if (typeof base === "undefined") {
|
|
106
|
-
return import_lodash.default.cloneDeep(patch);
|
|
107
|
-
}
|
|
108
|
-
return import_lodash.default.mergeWith({}, import_lodash.default.cloneDeep(base), import_lodash.default.cloneDeep(patch), (_objValue, srcValue) => {
|
|
109
|
-
if (Array.isArray(srcValue)) {
|
|
110
|
-
return import_lodash.default.cloneDeep(srcValue);
|
|
111
|
-
}
|
|
112
|
-
return void 0;
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
__name(deepMergeReplaceArrays, "deepMergeReplaceArrays");
|
|
116
|
-
function mergeSchemas(base, patch) {
|
|
117
|
-
if (!base && !patch) return void 0;
|
|
118
|
-
if (!base) return import_lodash.default.cloneDeep(patch);
|
|
119
|
-
if (!patch) return import_lodash.default.cloneDeep(base);
|
|
120
|
-
return deepMergeReplaceArrays(base, patch);
|
|
121
|
-
}
|
|
122
|
-
__name(mergeSchemas, "mergeSchemas");
|
|
123
|
-
function normalizeFlowHintMetadata(metadata) {
|
|
124
|
-
if (!metadata || typeof metadata !== "object" || Array.isArray(metadata)) {
|
|
125
|
-
return void 0;
|
|
126
|
-
}
|
|
127
|
-
const slotRules = metadata.slotRules && typeof metadata.slotRules === "object" && !Array.isArray(metadata.slotRules) ? import_lodash.default.pickBy(
|
|
128
|
-
{
|
|
129
|
-
slotKey: metadata.slotRules.slotKey,
|
|
130
|
-
type: metadata.slotRules.type,
|
|
131
|
-
allowedUses: Array.isArray(metadata.slotRules.allowedUses) ? metadata.slotRules.allowedUses.filter(Boolean) : metadata.slotRules.allowedUses
|
|
132
|
-
},
|
|
133
|
-
(value) => value !== void 0
|
|
134
|
-
) : void 0;
|
|
135
|
-
const normalized = import_lodash.default.pickBy(
|
|
136
|
-
{
|
|
137
|
-
slotRules: slotRules && Object.keys(slotRules).length > 0 ? slotRules : void 0,
|
|
138
|
-
contextRequirements: Array.isArray(metadata.contextRequirements) ? metadata.contextRequirements.filter(Boolean) : metadata.contextRequirements,
|
|
139
|
-
unresolvedReason: metadata.unresolvedReason,
|
|
140
|
-
recommendedFallback: metadata.recommendedFallback
|
|
141
|
-
},
|
|
142
|
-
(value) => value !== void 0
|
|
143
|
-
);
|
|
144
|
-
return Object.keys(normalized).length > 0 ? normalized : void 0;
|
|
145
|
-
}
|
|
146
|
-
__name(normalizeFlowHintMetadata, "normalizeFlowHintMetadata");
|
|
147
|
-
function normalizeFlowHint(hint) {
|
|
148
|
-
const normalizedHint = { ...hint };
|
|
149
|
-
const flowMetadata = normalizeFlowHintMetadata(hint["x-flow"]);
|
|
150
|
-
if (flowMetadata) {
|
|
151
|
-
normalizedHint["x-flow"] = flowMetadata;
|
|
152
|
-
} else {
|
|
153
|
-
delete normalizedHint["x-flow"];
|
|
154
|
-
}
|
|
155
|
-
return normalizedHint;
|
|
156
|
-
}
|
|
157
|
-
__name(normalizeFlowHint, "normalizeFlowHint");
|
|
158
|
-
function normalizeSchemaHints(hints) {
|
|
159
|
-
return Array.isArray(hints) ? import_lodash.default.uniqBy(
|
|
160
|
-
hints.map((item) => normalizeFlowHint(item)),
|
|
161
|
-
(item) => `${item.kind}:${item.path || ""}:${item.message}`
|
|
162
|
-
) : [];
|
|
163
|
-
}
|
|
164
|
-
__name(normalizeSchemaHints, "normalizeSchemaHints");
|
|
165
|
-
function normalizeSchemaDocs(docs) {
|
|
166
|
-
return {
|
|
167
|
-
description: docs == null ? void 0 : docs.description,
|
|
168
|
-
examples: Array.isArray(docs == null ? void 0 : docs.examples) ? import_lodash.default.cloneDeep(docs.examples) : [],
|
|
169
|
-
minimalExample: (docs == null ? void 0 : docs.minimalExample) === void 0 ? void 0 : import_lodash.default.cloneDeep(docs.minimalExample),
|
|
170
|
-
commonPatterns: Array.isArray(docs == null ? void 0 : docs.commonPatterns) ? import_lodash.default.cloneDeep(docs.commonPatterns) : [],
|
|
171
|
-
antiPatterns: Array.isArray(docs == null ? void 0 : docs.antiPatterns) ? import_lodash.default.cloneDeep(docs.antiPatterns) : [],
|
|
172
|
-
dynamicHints: normalizeSchemaHints(docs == null ? void 0 : docs.dynamicHints)
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
__name(normalizeSchemaDocs, "normalizeSchemaDocs");
|
|
176
|
-
function normalizeStringArray(values) {
|
|
177
|
-
if (!Array.isArray(values)) {
|
|
178
|
-
return [];
|
|
179
|
-
}
|
|
180
|
-
return import_lodash.default.uniq(values.map((item) => String(item || "").trim()).filter(Boolean));
|
|
181
|
-
}
|
|
182
|
-
__name(normalizeStringArray, "normalizeStringArray");
|
|
183
|
-
function createFlowHint(hint, metadata) {
|
|
184
|
-
const result = { ...hint };
|
|
185
|
-
const flowMetadata = normalizeFlowHintMetadata({
|
|
186
|
-
...hint["x-flow"] || {},
|
|
187
|
-
...metadata || {}
|
|
188
|
-
});
|
|
189
|
-
if (flowMetadata) {
|
|
190
|
-
result["x-flow"] = flowMetadata;
|
|
191
|
-
} else {
|
|
192
|
-
delete result["x-flow"];
|
|
193
|
-
}
|
|
194
|
-
return result;
|
|
195
|
-
}
|
|
196
|
-
__name(createFlowHint, "createFlowHint");
|
|
197
|
-
function collectAllowedUses(slot) {
|
|
198
|
-
if (!slot) {
|
|
199
|
-
return [];
|
|
200
|
-
}
|
|
201
|
-
if (Array.isArray(slot.uses)) {
|
|
202
|
-
return slot.uses.filter(Boolean);
|
|
203
|
-
}
|
|
204
|
-
return slot.use ? [slot.use] : [];
|
|
205
|
-
}
|
|
206
|
-
__name(collectAllowedUses, "collectAllowedUses");
|
|
207
|
-
function buildSkeletonFromSchema(schema, options = {}) {
|
|
208
|
-
var _a, _b;
|
|
209
|
-
if (!schema) return void 0;
|
|
210
|
-
if (schema.default !== void 0) return import_lodash.default.cloneDeep(schema.default);
|
|
211
|
-
if (schema.const !== void 0) return import_lodash.default.cloneDeep(schema.const);
|
|
212
|
-
if (Array.isArray(schema.enum) && schema.enum.length > 0) return import_lodash.default.cloneDeep(schema.enum[0]);
|
|
213
|
-
const depth = options.depth || 0;
|
|
214
|
-
if (depth > 4) {
|
|
215
|
-
return void 0;
|
|
216
|
-
}
|
|
217
|
-
const type = Array.isArray(schema.type) ? schema.type[0] : schema.type;
|
|
218
|
-
if (type === "object" || !type && import_lodash.default.isPlainObject(schema.properties)) {
|
|
219
|
-
const result = {};
|
|
220
|
-
const properties = schema.properties || {};
|
|
221
|
-
const required = new Set(schema.required || []);
|
|
222
|
-
for (const [key, value] of Object.entries(properties)) {
|
|
223
|
-
const child = buildSkeletonFromSchema(value, {
|
|
224
|
-
propertyName: key,
|
|
225
|
-
depth: depth + 1
|
|
226
|
-
});
|
|
227
|
-
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));
|
|
228
|
-
if (!includeOptionalTopLevelShell && !required.has(key) && value.default === void 0 && value.const === void 0) {
|
|
229
|
-
continue;
|
|
230
|
-
}
|
|
231
|
-
if (child !== void 0) {
|
|
232
|
-
result[key] = child;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
return result;
|
|
236
|
-
}
|
|
237
|
-
if (type === "array") {
|
|
238
|
-
return [];
|
|
239
|
-
}
|
|
240
|
-
if (type === "boolean") {
|
|
241
|
-
return false;
|
|
242
|
-
}
|
|
243
|
-
if (type === "integer" || type === "number") {
|
|
244
|
-
return 0;
|
|
245
|
-
}
|
|
246
|
-
if (type === "string") {
|
|
247
|
-
const propertyName = options.propertyName || "value";
|
|
248
|
-
if (propertyName === "uid") {
|
|
249
|
-
return "todo-uid";
|
|
250
|
-
}
|
|
251
|
-
return "";
|
|
252
|
-
}
|
|
253
|
-
if ((_a = schema.oneOf) == null ? void 0 : _a.length) {
|
|
254
|
-
return buildSkeletonFromSchema(schema.oneOf[0], {
|
|
255
|
-
propertyName: options.propertyName,
|
|
256
|
-
depth: depth + 1
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
if ((_b = schema.anyOf) == null ? void 0 : _b.length) {
|
|
260
|
-
return buildSkeletonFromSchema(schema.anyOf[0], {
|
|
261
|
-
propertyName: options.propertyName,
|
|
262
|
-
depth: depth + 1
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
return void 0;
|
|
266
|
-
}
|
|
267
|
-
__name(buildSkeletonFromSchema, "buildSkeletonFromSchema");
|
|
268
|
-
function toSchemaTitle(input, fallback) {
|
|
269
|
-
if (typeof input === "string") {
|
|
270
|
-
return input;
|
|
271
|
-
}
|
|
272
|
-
if (typeof input === "number" || typeof input === "boolean") {
|
|
273
|
-
return String(input);
|
|
274
|
-
}
|
|
275
|
-
return fallback;
|
|
276
|
-
}
|
|
277
|
-
__name(toSchemaTitle, "toSchemaTitle");
|
|
278
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
279
|
-
0 && (module.exports = {
|
|
280
|
-
JSON_SCHEMA_DRAFT_07,
|
|
281
|
-
buildSkeletonFromSchema,
|
|
282
|
-
collectAllowedUses,
|
|
283
|
-
createFlowHint,
|
|
284
|
-
deepFreezePlainGraph,
|
|
285
|
-
deepMergeReplaceArrays,
|
|
286
|
-
hashString,
|
|
287
|
-
mergeSchemas,
|
|
288
|
-
normalizeSchemaDocs,
|
|
289
|
-
normalizeSchemaHints,
|
|
290
|
-
normalizeStringArray,
|
|
291
|
-
stableStringify,
|
|
292
|
-
toSchemaTitle
|
|
293
|
-
});
|
package/server.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './src/server';
|
package/server.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = process.env.IS_DEV_CMD || process.env.VITEST ? require('./src/server.ts') : require('./lib/server');
|