@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.
- 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,1427 +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 FlowSchemaRegistry_exports = {};
|
|
39
|
-
__export(FlowSchemaRegistry_exports, {
|
|
40
|
-
FlowSchemaRegistry: () => FlowSchemaRegistry
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(FlowSchemaRegistry_exports);
|
|
43
|
-
var import_lodash = __toESM(require("lodash"));
|
|
44
|
-
var import_fieldBinding = require("./flow-schema-registry/fieldBinding");
|
|
45
|
-
var import_modelPatches = require("./flow-schema-registry/modelPatches");
|
|
46
|
-
var import_schemaInference = require("./flow-schema-registry/schemaInference");
|
|
47
|
-
var import_utils = require("./flow-schema-registry/utils");
|
|
48
|
-
const _FlowSchemaRegistry = class _FlowSchemaRegistry {
|
|
49
|
-
modelSchemas = /* @__PURE__ */ new Map();
|
|
50
|
-
actionSchemas = /* @__PURE__ */ new Map();
|
|
51
|
-
fieldBindingContexts = /* @__PURE__ */ new Map();
|
|
52
|
-
fieldBindings = /* @__PURE__ */ new Map();
|
|
53
|
-
resolvedModelCache = /* @__PURE__ */ new Map();
|
|
54
|
-
modelSnapshotSchemaCache = /* @__PURE__ */ new Map();
|
|
55
|
-
compactModelSnapshotSchemaCache = /* @__PURE__ */ new Map();
|
|
56
|
-
modelSchemaHashCache = /* @__PURE__ */ new Map();
|
|
57
|
-
compactModelSchemaHashCache = /* @__PURE__ */ new Map();
|
|
58
|
-
modelDocumentCache = /* @__PURE__ */ new Map();
|
|
59
|
-
modelLocalDynamicHintsCache = /* @__PURE__ */ new Map();
|
|
60
|
-
publicModelDocumentCache = /* @__PURE__ */ new Map();
|
|
61
|
-
publicTreeRoots = /* @__PURE__ */ new Set();
|
|
62
|
-
slotUseExpansions = /* @__PURE__ */ new Map();
|
|
63
|
-
invalidateDerivedCaches() {
|
|
64
|
-
this.resolvedModelCache.clear();
|
|
65
|
-
this.modelSnapshotSchemaCache.clear();
|
|
66
|
-
this.compactModelSnapshotSchemaCache.clear();
|
|
67
|
-
this.modelSchemaHashCache.clear();
|
|
68
|
-
this.compactModelSchemaHashCache.clear();
|
|
69
|
-
this.modelDocumentCache.clear();
|
|
70
|
-
this.modelLocalDynamicHintsCache.clear();
|
|
71
|
-
this.publicModelDocumentCache.clear();
|
|
72
|
-
}
|
|
73
|
-
registerAction(action) {
|
|
74
|
-
var _a, _b, _c, _d;
|
|
75
|
-
const name = String((action == null ? void 0 : action.name) || "").trim();
|
|
76
|
-
if (!name) return;
|
|
77
|
-
const previous = this.actionSchemas.get(name);
|
|
78
|
-
const inferred = (0, import_schemaInference.inferParamsSchemaFromUiSchema)(name, action.uiSchema, `actions.${name}`);
|
|
79
|
-
const mergedSchema = (0, import_utils.mergeSchemas)(action.paramsSchema || inferred.schema, action.paramsSchemaPatch);
|
|
80
|
-
const explicit = !!action.paramsSchema || !!action.paramsSchemaPatch;
|
|
81
|
-
const coverageStatus = explicit ? inferred.schema ? "mixed" : "manual" : inferred.coverage;
|
|
82
|
-
const docs = (0, import_utils.normalizeSchemaDocs)({
|
|
83
|
-
...previous == null ? void 0 : previous.docs,
|
|
84
|
-
...action.schemaDocs,
|
|
85
|
-
examples: ((_a = action.schemaDocs) == null ? void 0 : _a.examples) || ((_b = previous == null ? void 0 : previous.docs) == null ? void 0 : _b.examples),
|
|
86
|
-
dynamicHints: [...((_c = previous == null ? void 0 : previous.docs) == null ? void 0 : _c.dynamicHints) || [], ...((_d = action.schemaDocs) == null ? void 0 : _d.dynamicHints) || []]
|
|
87
|
-
});
|
|
88
|
-
this.actionSchemas.set(name, {
|
|
89
|
-
name,
|
|
90
|
-
title: action.title,
|
|
91
|
-
definition: action,
|
|
92
|
-
schema: mergedSchema,
|
|
93
|
-
coverage: {
|
|
94
|
-
status: mergedSchema ? coverageStatus : "unresolved",
|
|
95
|
-
source: (previous == null ? void 0 : previous.coverage.source) || "official",
|
|
96
|
-
strict: previous == null ? void 0 : previous.coverage.strict
|
|
97
|
-
},
|
|
98
|
-
docs,
|
|
99
|
-
dynamicHints: (0, import_utils.normalizeSchemaHints)([
|
|
100
|
-
...(previous == null ? void 0 : previous.dynamicHints) || [],
|
|
101
|
-
...inferred.hints || [],
|
|
102
|
-
...docs.dynamicHints || []
|
|
103
|
-
])
|
|
104
|
-
});
|
|
105
|
-
this.invalidateDerivedCaches();
|
|
106
|
-
}
|
|
107
|
-
registerActions(actions) {
|
|
108
|
-
for (const action of Object.values(actions || {})) {
|
|
109
|
-
this.registerAction(action);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
registerActionContribution(contribution) {
|
|
113
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
114
|
-
const name = String((contribution == null ? void 0 : contribution.name) || "").trim();
|
|
115
|
-
if (!name) return;
|
|
116
|
-
const previous = this.actionSchemas.get(name);
|
|
117
|
-
const docs = (0, import_utils.normalizeSchemaDocs)({
|
|
118
|
-
...previous == null ? void 0 : previous.docs,
|
|
119
|
-
...contribution.docs,
|
|
120
|
-
examples: ((_a = contribution.docs) == null ? void 0 : _a.examples) || ((_b = previous == null ? void 0 : previous.docs) == null ? void 0 : _b.examples),
|
|
121
|
-
dynamicHints: [...((_c = previous == null ? void 0 : previous.docs) == null ? void 0 : _c.dynamicHints) || [], ...((_d = contribution.docs) == null ? void 0 : _d.dynamicHints) || []],
|
|
122
|
-
commonPatterns: ((_e = contribution.docs) == null ? void 0 : _e.commonPatterns) || ((_f = previous == null ? void 0 : previous.docs) == null ? void 0 : _f.commonPatterns),
|
|
123
|
-
antiPatterns: ((_g = contribution.docs) == null ? void 0 : _g.antiPatterns) || ((_h = previous == null ? void 0 : previous.docs) == null ? void 0 : _h.antiPatterns),
|
|
124
|
-
minimalExample: ((_i = contribution.docs) == null ? void 0 : _i.minimalExample) !== void 0 ? contribution.docs.minimalExample : (_j = previous == null ? void 0 : previous.docs) == null ? void 0 : _j.minimalExample
|
|
125
|
-
});
|
|
126
|
-
this.actionSchemas.set(name, {
|
|
127
|
-
name,
|
|
128
|
-
title: contribution.title || (previous == null ? void 0 : previous.title),
|
|
129
|
-
definition: previous == null ? void 0 : previous.definition,
|
|
130
|
-
schema: contribution.paramsSchema ? import_lodash.default.cloneDeep(contribution.paramsSchema) : previous == null ? void 0 : previous.schema,
|
|
131
|
-
docs,
|
|
132
|
-
coverage: {
|
|
133
|
-
status: contribution.paramsSchema ? "manual" : (previous == null ? void 0 : previous.coverage.status) || "unresolved",
|
|
134
|
-
source: contribution.source || (previous == null ? void 0 : previous.coverage.source) || "official",
|
|
135
|
-
strict: contribution.strict ?? (previous == null ? void 0 : previous.coverage.strict)
|
|
136
|
-
},
|
|
137
|
-
dynamicHints: (0, import_utils.normalizeSchemaHints)([...(previous == null ? void 0 : previous.dynamicHints) || [], ...docs.dynamicHints || []])
|
|
138
|
-
});
|
|
139
|
-
this.invalidateDerivedCaches();
|
|
140
|
-
}
|
|
141
|
-
registerActionContributions(contributions) {
|
|
142
|
-
const values = Array.isArray(contributions) ? contributions : Object.values(contributions || {});
|
|
143
|
-
for (const contribution of values) {
|
|
144
|
-
this.registerActionContribution(contribution);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
registerFieldBindingContext(contribution, fallbackName) {
|
|
148
|
-
const normalized = (0, import_fieldBinding.normalizeFieldBindingContextContribution)(contribution, fallbackName);
|
|
149
|
-
if (!normalized) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
const previous = this.fieldBindingContexts.get(normalized.name);
|
|
153
|
-
this.fieldBindingContexts.set(normalized.name, {
|
|
154
|
-
name: normalized.name,
|
|
155
|
-
inherits: import_lodash.default.uniq([...(previous == null ? void 0 : previous.inherits) || [], ...normalized.inherits])
|
|
156
|
-
});
|
|
157
|
-
this.invalidateDerivedCaches();
|
|
158
|
-
}
|
|
159
|
-
registerFieldBindingContexts(contributions) {
|
|
160
|
-
if (!contributions) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
if (Array.isArray(contributions)) {
|
|
164
|
-
for (const contribution of contributions) {
|
|
165
|
-
this.registerFieldBindingContext(contribution);
|
|
166
|
-
}
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
for (const [name, contribution] of Object.entries(contributions)) {
|
|
170
|
-
if (!contribution) {
|
|
171
|
-
continue;
|
|
172
|
-
}
|
|
173
|
-
this.registerFieldBindingContext(contribution, name);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
registerFieldBinding(contribution, source = "official") {
|
|
177
|
-
const normalized = (0, import_fieldBinding.normalizeFieldBindingContribution)(contribution, source);
|
|
178
|
-
if (!normalized) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
const bindings = this.fieldBindings.get(normalized.context) || [];
|
|
182
|
-
bindings.push(normalized);
|
|
183
|
-
this.fieldBindings.set(normalized.context, bindings);
|
|
184
|
-
this.invalidateDerivedCaches();
|
|
185
|
-
}
|
|
186
|
-
registerFieldBindings(contributions, source = "official") {
|
|
187
|
-
if (!contributions) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
if (Array.isArray(contributions)) {
|
|
191
|
-
for (const contribution of contributions) {
|
|
192
|
-
this.registerFieldBinding(contribution, source);
|
|
193
|
-
}
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
for (const [context, contribution] of Object.entries(contributions)) {
|
|
197
|
-
if (!contribution) {
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
const items = Array.isArray(contribution) ? contribution : [contribution];
|
|
201
|
-
for (const item of items) {
|
|
202
|
-
this.registerFieldBinding(
|
|
203
|
-
{
|
|
204
|
-
...item,
|
|
205
|
-
context: item.context || context
|
|
206
|
-
},
|
|
207
|
-
source
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
registerModel(use, options) {
|
|
213
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
214
|
-
const name = String(use || "").trim();
|
|
215
|
-
if (!name) return;
|
|
216
|
-
const previous = this.modelSchemas.get(name);
|
|
217
|
-
this.modelSchemas.set(name, {
|
|
218
|
-
use: name,
|
|
219
|
-
title: options.title || (previous == null ? void 0 : previous.title),
|
|
220
|
-
modelClass: options.modelClass || (previous == null ? void 0 : previous.modelClass),
|
|
221
|
-
stepParamsSchema: options.stepParamsSchema || (previous == null ? void 0 : previous.stepParamsSchema),
|
|
222
|
-
flowRegistrySchema: options.flowRegistrySchema || (previous == null ? void 0 : previous.flowRegistrySchema),
|
|
223
|
-
subModelSlots: (0, import_modelPatches.normalizeSubModelSlots)(options.subModelSlots || (previous == null ? void 0 : previous.subModelSlots)),
|
|
224
|
-
flowRegistrySchemaPatch: options.flowRegistrySchemaPatch || (previous == null ? void 0 : previous.flowRegistrySchemaPatch),
|
|
225
|
-
examples: options.examples || (previous == null ? void 0 : previous.examples) || [],
|
|
226
|
-
docs: (0, import_utils.normalizeSchemaDocs)({
|
|
227
|
-
...previous == null ? void 0 : previous.docs,
|
|
228
|
-
...options.docs,
|
|
229
|
-
examples: ((_a = options.docs) == null ? void 0 : _a.examples) || ((_b = previous == null ? void 0 : previous.docs) == null ? void 0 : _b.examples),
|
|
230
|
-
dynamicHints: [...((_c = previous == null ? void 0 : previous.docs) == null ? void 0 : _c.dynamicHints) || [], ...((_d = options.docs) == null ? void 0 : _d.dynamicHints) || []],
|
|
231
|
-
commonPatterns: ((_e = options.docs) == null ? void 0 : _e.commonPatterns) || ((_f = previous == null ? void 0 : previous.docs) == null ? void 0 : _f.commonPatterns),
|
|
232
|
-
antiPatterns: ((_g = options.docs) == null ? void 0 : _g.antiPatterns) || ((_h = previous == null ? void 0 : previous.docs) == null ? void 0 : _h.antiPatterns),
|
|
233
|
-
minimalExample: ((_i = options.docs) == null ? void 0 : _i.minimalExample) !== void 0 ? options.docs.minimalExample : (_j = previous == null ? void 0 : previous.docs) == null ? void 0 : _j.minimalExample
|
|
234
|
-
}),
|
|
235
|
-
skeleton: options.skeleton !== void 0 ? import_lodash.default.cloneDeep(options.skeleton) : previous == null ? void 0 : previous.skeleton,
|
|
236
|
-
dynamicHints: (0, import_utils.normalizeSchemaHints)([...(previous == null ? void 0 : previous.dynamicHints) || [], ...options.dynamicHints || []]),
|
|
237
|
-
coverage: options.coverage || (previous == null ? void 0 : previous.coverage) || { status: "unresolved", source: "third-party" },
|
|
238
|
-
exposure: options.exposure ?? (previous == null ? void 0 : previous.exposure) ?? "public",
|
|
239
|
-
abstract: options.abstract ?? (previous == null ? void 0 : previous.abstract) ?? false,
|
|
240
|
-
allowDirectUse: options.allowDirectUse ?? (previous == null ? void 0 : previous.allowDirectUse) ?? true,
|
|
241
|
-
suggestedUses: (0, import_utils.normalizeStringArray)(options.suggestedUses || (previous == null ? void 0 : previous.suggestedUses))
|
|
242
|
-
});
|
|
243
|
-
this.invalidateDerivedCaches();
|
|
244
|
-
}
|
|
245
|
-
registerModelContribution(contribution) {
|
|
246
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
247
|
-
const use = String((contribution == null ? void 0 : contribution.use) || "").trim();
|
|
248
|
-
if (!use) return;
|
|
249
|
-
const previous = this.modelSchemas.get(use);
|
|
250
|
-
const hasSchemaContribution = !!contribution.stepParamsSchema || !!contribution.flowRegistrySchema || !!contribution.flowRegistrySchemaPatch || !!contribution.subModelSlots;
|
|
251
|
-
const docs = (0, import_utils.normalizeSchemaDocs)({
|
|
252
|
-
...previous == null ? void 0 : previous.docs,
|
|
253
|
-
...contribution.docs,
|
|
254
|
-
examples: contribution.examples || ((_a = contribution.docs) == null ? void 0 : _a.examples) || ((_b = previous == null ? void 0 : previous.docs) == null ? void 0 : _b.examples),
|
|
255
|
-
dynamicHints: [...((_c = previous == null ? void 0 : previous.docs) == null ? void 0 : _c.dynamicHints) || [], ...((_d = contribution.docs) == null ? void 0 : _d.dynamicHints) || []],
|
|
256
|
-
commonPatterns: ((_e = contribution.docs) == null ? void 0 : _e.commonPatterns) || ((_f = previous == null ? void 0 : previous.docs) == null ? void 0 : _f.commonPatterns),
|
|
257
|
-
antiPatterns: ((_g = contribution.docs) == null ? void 0 : _g.antiPatterns) || ((_h = previous == null ? void 0 : previous.docs) == null ? void 0 : _h.antiPatterns),
|
|
258
|
-
minimalExample: ((_i = contribution.docs) == null ? void 0 : _i.minimalExample) !== void 0 ? contribution.docs.minimalExample : (_j = previous == null ? void 0 : previous.docs) == null ? void 0 : _j.minimalExample
|
|
259
|
-
});
|
|
260
|
-
this.registerModel(use, {
|
|
261
|
-
title: contribution.title,
|
|
262
|
-
stepParamsSchema: contribution.stepParamsSchema ? import_lodash.default.cloneDeep(contribution.stepParamsSchema) : void 0,
|
|
263
|
-
flowRegistrySchema: contribution.flowRegistrySchema ? import_lodash.default.cloneDeep(contribution.flowRegistrySchema) : void 0,
|
|
264
|
-
subModelSlots: contribution.subModelSlots ? (0, import_modelPatches.normalizeSubModelSlots)(contribution.subModelSlots) : void 0,
|
|
265
|
-
flowRegistrySchemaPatch: contribution.flowRegistrySchemaPatch ? import_lodash.default.cloneDeep(contribution.flowRegistrySchemaPatch) : void 0,
|
|
266
|
-
examples: contribution.examples || docs.examples || [],
|
|
267
|
-
docs,
|
|
268
|
-
skeleton: contribution.skeleton,
|
|
269
|
-
dynamicHints: [...contribution.dynamicHints || [], ...docs.dynamicHints || []],
|
|
270
|
-
coverage: hasSchemaContribution ? {
|
|
271
|
-
status: (previous == null ? void 0 : previous.coverage.status) === "auto" ? "mixed" : "manual",
|
|
272
|
-
source: contribution.source || (previous == null ? void 0 : previous.coverage.source) || "official",
|
|
273
|
-
strict: contribution.strict ?? (previous == null ? void 0 : previous.coverage.strict)
|
|
274
|
-
} : (previous == null ? void 0 : previous.coverage) || {
|
|
275
|
-
status: "unresolved",
|
|
276
|
-
source: contribution.source || "official",
|
|
277
|
-
strict: contribution.strict
|
|
278
|
-
},
|
|
279
|
-
exposure: contribution.exposure,
|
|
280
|
-
abstract: contribution.abstract,
|
|
281
|
-
allowDirectUse: contribution.allowDirectUse,
|
|
282
|
-
suggestedUses: contribution.suggestedUses
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
registerModelContributions(contributions) {
|
|
286
|
-
const values = Array.isArray(contributions) ? contributions : Object.values(contributions || {});
|
|
287
|
-
for (const contribution of values) {
|
|
288
|
-
this.registerModelContribution(contribution);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
registerModelClass(use, modelClass) {
|
|
292
|
-
var _a, _b;
|
|
293
|
-
const meta = modelClass.meta || {};
|
|
294
|
-
const schemaMeta = meta.schema || {};
|
|
295
|
-
const inferredSlots = this.inferSubModelSlotsFromModelClass(use, modelClass);
|
|
296
|
-
const inferredHints = this.collectModelDynamicHints(use, modelClass, meta);
|
|
297
|
-
const hasManual = !!schemaMeta.stepParamsSchema || !!schemaMeta.flowRegistrySchema || !!schemaMeta.subModelSlots || !!schemaMeta.flowRegistrySchemaPatch;
|
|
298
|
-
const hasAuto = !!Object.keys(inferredSlots).length;
|
|
299
|
-
this.registerModel(use, {
|
|
300
|
-
modelClass,
|
|
301
|
-
title: (0, import_utils.toSchemaTitle)(meta.label, use),
|
|
302
|
-
stepParamsSchema: schemaMeta.stepParamsSchema,
|
|
303
|
-
flowRegistrySchema: schemaMeta.flowRegistrySchema,
|
|
304
|
-
subModelSlots: Object.keys(schemaMeta.subModelSlots || {}).length ? schemaMeta.subModelSlots : inferredSlots,
|
|
305
|
-
flowRegistrySchemaPatch: schemaMeta.flowRegistrySchemaPatch,
|
|
306
|
-
examples: schemaMeta.examples || ((_a = schemaMeta.docs) == null ? void 0 : _a.examples) || [],
|
|
307
|
-
docs: schemaMeta.docs,
|
|
308
|
-
skeleton: schemaMeta.skeleton,
|
|
309
|
-
dynamicHints: [...schemaMeta.dynamicHints || [], ...((_b = schemaMeta.docs) == null ? void 0 : _b.dynamicHints) || [], ...inferredHints],
|
|
310
|
-
coverage: {
|
|
311
|
-
status: hasManual && hasAuto ? "mixed" : hasManual ? "manual" : hasAuto ? "auto" : "unresolved",
|
|
312
|
-
source: schemaMeta.source || "official",
|
|
313
|
-
strict: schemaMeta.strict
|
|
314
|
-
},
|
|
315
|
-
exposure: schemaMeta.exposure,
|
|
316
|
-
abstract: schemaMeta.abstract,
|
|
317
|
-
allowDirectUse: schemaMeta.allowDirectUse,
|
|
318
|
-
suggestedUses: schemaMeta.suggestedUses
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
registerModels(models) {
|
|
322
|
-
for (const [use, modelClass] of Object.entries(models || {})) {
|
|
323
|
-
if (modelClass) {
|
|
324
|
-
this.registerModelClass(use, modelClass);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
registerInventory(inventory, _source) {
|
|
329
|
-
if (!inventory) {
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
for (const use of (0, import_utils.normalizeStringArray)(inventory.publicTreeRoots)) {
|
|
333
|
-
this.publicTreeRoots.add(use);
|
|
334
|
-
}
|
|
335
|
-
for (const item of inventory.slotUseExpansions || []) {
|
|
336
|
-
const parentUse = String((item == null ? void 0 : item.parentUse) || "").trim();
|
|
337
|
-
const slotKey = String((item == null ? void 0 : item.slotKey) || "").trim();
|
|
338
|
-
const uses = (0, import_utils.normalizeStringArray)(item == null ? void 0 : item.uses);
|
|
339
|
-
if (!parentUse || !slotKey || uses.length === 0) {
|
|
340
|
-
continue;
|
|
341
|
-
}
|
|
342
|
-
const key = this.createSlotUseExpansionKey(parentUse, slotKey);
|
|
343
|
-
this.slotUseExpansions.set(key, import_lodash.default.uniq([...this.slotUseExpansions.get(key) || [], ...uses]));
|
|
344
|
-
}
|
|
345
|
-
this.invalidateDerivedCaches();
|
|
346
|
-
}
|
|
347
|
-
resolveFieldBindingCandidates(context, options = {}) {
|
|
348
|
-
const contextChain = this.resolveFieldBindingContextChain(context);
|
|
349
|
-
const entries = contextChain.flatMap(
|
|
350
|
-
(contextName, contextIndex) => (this.fieldBindings.get(contextName) || []).map((binding, bindingIndex) => ({
|
|
351
|
-
binding,
|
|
352
|
-
contextIndex,
|
|
353
|
-
bindingIndex
|
|
354
|
-
}))
|
|
355
|
-
);
|
|
356
|
-
const candidates = entries.filter(({ binding }) => (0, import_fieldBinding.matchesFieldBinding)(binding, options)).filter(({ binding }) => this.hasQueryableModel(binding.use)).sort((a, b) => {
|
|
357
|
-
if (a.binding.isDefault !== b.binding.isDefault) {
|
|
358
|
-
return a.binding.isDefault ? -1 : 1;
|
|
359
|
-
}
|
|
360
|
-
const aOrder = typeof a.binding.order === "number" ? a.binding.order : Number.MAX_SAFE_INTEGER;
|
|
361
|
-
const bOrder = typeof b.binding.order === "number" ? b.binding.order : Number.MAX_SAFE_INTEGER;
|
|
362
|
-
if (aOrder !== bOrder) {
|
|
363
|
-
return aOrder - bOrder;
|
|
364
|
-
}
|
|
365
|
-
if (a.contextIndex !== b.contextIndex) {
|
|
366
|
-
return a.contextIndex - b.contextIndex;
|
|
367
|
-
}
|
|
368
|
-
return a.bindingIndex - b.bindingIndex;
|
|
369
|
-
}).map(({ binding }) => ({
|
|
370
|
-
use: binding.use,
|
|
371
|
-
defaultProps: binding.defaultProps === void 0 ? void 0 : import_lodash.default.cloneDeep(binding.defaultProps),
|
|
372
|
-
compatibility: (0, import_fieldBinding.buildFieldModelCompatibility)(binding)
|
|
373
|
-
}));
|
|
374
|
-
return import_lodash.default.uniqBy(candidates, (candidate) => `${candidate.use}:${(0, import_utils.stableStringify)(candidate.compatibility)}`);
|
|
375
|
-
}
|
|
376
|
-
getAction(name) {
|
|
377
|
-
return this.actionSchemas.get(name);
|
|
378
|
-
}
|
|
379
|
-
listActionNames() {
|
|
380
|
-
return Array.from(this.actionSchemas.keys()).sort();
|
|
381
|
-
}
|
|
382
|
-
getModel(use) {
|
|
383
|
-
return this.modelSchemas.get(use);
|
|
384
|
-
}
|
|
385
|
-
resolveFieldBindingContextChain(context, visited = /* @__PURE__ */ new Set()) {
|
|
386
|
-
var _a;
|
|
387
|
-
const name = String(context || "").trim();
|
|
388
|
-
if (!name || visited.has(name)) {
|
|
389
|
-
return [];
|
|
390
|
-
}
|
|
391
|
-
visited.add(name);
|
|
392
|
-
const chain = [name];
|
|
393
|
-
const inherits = ((_a = this.fieldBindingContexts.get(name)) == null ? void 0 : _a.inherits) || [];
|
|
394
|
-
for (const inheritedContext of inherits) {
|
|
395
|
-
for (const item of this.resolveFieldBindingContextChain(inheritedContext, visited)) {
|
|
396
|
-
if (!chain.includes(item)) {
|
|
397
|
-
chain.push(item);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
return chain;
|
|
402
|
-
}
|
|
403
|
-
resolveModelSchemaRef(use, contextChain = []) {
|
|
404
|
-
const name = String(use || "").trim();
|
|
405
|
-
const cacheKey = `${name}::${(0, import_utils.stableStringify)(contextChain)}`;
|
|
406
|
-
const cached = this.resolvedModelCache.get(cacheKey);
|
|
407
|
-
if (cached) {
|
|
408
|
-
return cached;
|
|
409
|
-
}
|
|
410
|
-
const registered = this.modelSchemas.get(name);
|
|
411
|
-
const resolved = {
|
|
412
|
-
use: name,
|
|
413
|
-
title: (registered == null ? void 0 : registered.title) || name,
|
|
414
|
-
modelClass: registered == null ? void 0 : registered.modelClass,
|
|
415
|
-
stepParamsSchema: (registered == null ? void 0 : registered.stepParamsSchema) ? import_lodash.default.cloneDeep(registered.stepParamsSchema) : this.buildInferredStepParamsSchema(name),
|
|
416
|
-
flowRegistrySchema: (registered == null ? void 0 : registered.flowRegistrySchema) ? import_lodash.default.cloneDeep(registered.flowRegistrySchema) : this.buildInferredFlowRegistrySchema(name),
|
|
417
|
-
subModelSlots: (0, import_modelPatches.normalizeSubModelSlots)(registered == null ? void 0 : registered.subModelSlots),
|
|
418
|
-
flowRegistrySchemaPatch: (registered == null ? void 0 : registered.flowRegistrySchemaPatch) ? import_lodash.default.cloneDeep(registered.flowRegistrySchemaPatch) : void 0,
|
|
419
|
-
examples: import_lodash.default.cloneDeep((registered == null ? void 0 : registered.examples) || []),
|
|
420
|
-
docs: (0, import_utils.normalizeSchemaDocs)(registered == null ? void 0 : registered.docs),
|
|
421
|
-
skeleton: (registered == null ? void 0 : registered.skeleton) === void 0 ? void 0 : import_lodash.default.cloneDeep(registered.skeleton),
|
|
422
|
-
dynamicHints: (0, import_utils.normalizeSchemaHints)(registered == null ? void 0 : registered.dynamicHints),
|
|
423
|
-
coverage: (registered == null ? void 0 : registered.coverage) || { status: "unresolved", source: "third-party" },
|
|
424
|
-
exposure: (registered == null ? void 0 : registered.exposure) || "public",
|
|
425
|
-
abstract: (registered == null ? void 0 : registered.abstract) ?? false,
|
|
426
|
-
allowDirectUse: (registered == null ? void 0 : registered.allowDirectUse) ?? true,
|
|
427
|
-
suggestedUses: (0, import_utils.normalizeStringArray)(registered == null ? void 0 : registered.suggestedUses)
|
|
428
|
-
};
|
|
429
|
-
for (const contribution of this.collectContextPatches(name, contextChain)) {
|
|
430
|
-
(0, import_modelPatches.applyModelSchemaPatch)(resolved, contribution.patch, contribution.source, contribution.strict);
|
|
431
|
-
}
|
|
432
|
-
const frozen = (0, import_utils.deepFreezePlainGraph)(resolved);
|
|
433
|
-
this.resolvedModelCache.set(cacheKey, frozen);
|
|
434
|
-
return frozen;
|
|
435
|
-
}
|
|
436
|
-
resolveModelSchema(use, contextChain = []) {
|
|
437
|
-
return import_lodash.default.cloneDeep(this.resolveModelSchemaRef(use, contextChain));
|
|
438
|
-
}
|
|
439
|
-
isPublicModel(model) {
|
|
440
|
-
return ((model == null ? void 0 : model.exposure) || "public") === "public";
|
|
441
|
-
}
|
|
442
|
-
isQueryableModel(model) {
|
|
443
|
-
return !!model && model.abstract !== true;
|
|
444
|
-
}
|
|
445
|
-
getSuggestedUses(use) {
|
|
446
|
-
var _a;
|
|
447
|
-
const model = this.modelSchemas.get(String(use || "").trim());
|
|
448
|
-
if ((_a = model == null ? void 0 : model.suggestedUses) == null ? void 0 : _a.length) {
|
|
449
|
-
return (0, import_utils.normalizeStringArray)(model.suggestedUses);
|
|
450
|
-
}
|
|
451
|
-
return this.listModelUses({ directUseOnly: true }).filter((item) => item !== use).slice(0, 20);
|
|
452
|
-
}
|
|
453
|
-
hasQueryableModel(use) {
|
|
454
|
-
const model = this.modelSchemas.get(String(use || "").trim());
|
|
455
|
-
return this.isQueryableModel(model);
|
|
456
|
-
}
|
|
457
|
-
isDirectUseAllowed(use) {
|
|
458
|
-
const model = this.modelSchemas.get(String(use || "").trim());
|
|
459
|
-
return model ? this.isQueryableModel(model) && model.allowDirectUse !== false : true;
|
|
460
|
-
}
|
|
461
|
-
listPublicTreeRoots() {
|
|
462
|
-
return Array.from(this.publicTreeRoots).sort();
|
|
463
|
-
}
|
|
464
|
-
listModelUses(options = {}) {
|
|
465
|
-
const { publicOnly = false, directUseOnly = false, queryableOnly = false } = options;
|
|
466
|
-
return Array.from(this.modelSchemas.values()).filter((model) => !publicOnly || this.isPublicModel(model) && this.isQueryableModel(model)).filter((model) => !queryableOnly || this.isQueryableModel(model)).filter((model) => !directUseOnly || this.isQueryableModel(model) && model.allowDirectUse !== false).map((model) => model.use).sort();
|
|
467
|
-
}
|
|
468
|
-
getSchemaBundle(uses) {
|
|
469
|
-
return {
|
|
470
|
-
items: (Array.isArray(uses) && uses.length > 0 ? uses.filter((use) => this.hasQueryableModel(use)) : []).map(
|
|
471
|
-
(use) => this.buildBundleNode(use, [], /* @__PURE__ */ new Set())
|
|
472
|
-
)
|
|
473
|
-
};
|
|
474
|
-
}
|
|
475
|
-
getModelDocument(use, contextChain = []) {
|
|
476
|
-
return import_lodash.default.cloneDeep(this.getModelDocumentRef(use, contextChain));
|
|
477
|
-
}
|
|
478
|
-
getModelDocumentRef(use, contextChain = []) {
|
|
479
|
-
const cacheKey = this.createContextVisitKey(use, contextChain);
|
|
480
|
-
const cached = this.modelDocumentCache.get(cacheKey);
|
|
481
|
-
if (cached) {
|
|
482
|
-
return cached;
|
|
483
|
-
}
|
|
484
|
-
const document = this.buildModelDocument(use, contextChain, /* @__PURE__ */ new Set());
|
|
485
|
-
const frozen = (0, import_utils.deepFreezePlainGraph)(document);
|
|
486
|
-
this.modelDocumentCache.set(cacheKey, frozen);
|
|
487
|
-
return frozen;
|
|
488
|
-
}
|
|
489
|
-
getPublicModelDocument(use, options = {}) {
|
|
490
|
-
return import_lodash.default.cloneDeep(this.getPublicModelDocumentRef(use, options));
|
|
491
|
-
}
|
|
492
|
-
getPublicModelDocumentRef(use, options = {}) {
|
|
493
|
-
const detail = options.detail === "full" ? "full" : "compact";
|
|
494
|
-
const contextChain = options.contextChain || [];
|
|
495
|
-
const cacheKey = `${detail}::${this.createContextVisitKey(use, contextChain)}`;
|
|
496
|
-
const cached = this.publicModelDocumentCache.get(cacheKey);
|
|
497
|
-
if (cached) {
|
|
498
|
-
return cached;
|
|
499
|
-
}
|
|
500
|
-
const document = detail === "full" ? this.buildFullPublicModelDocument(use, contextChain) : this.buildCompactPublicModelDocument(use, contextChain);
|
|
501
|
-
const frozen = (0, import_utils.deepFreezePlainGraph)(document);
|
|
502
|
-
this.publicModelDocumentCache.set(cacheKey, frozen);
|
|
503
|
-
return frozen;
|
|
504
|
-
}
|
|
505
|
-
buildFullPublicModelDocument(use, contextChain) {
|
|
506
|
-
const document = this.getModelDocumentRef(use, contextChain);
|
|
507
|
-
return {
|
|
508
|
-
use: document.use,
|
|
509
|
-
title: document.title,
|
|
510
|
-
jsonSchema: document.jsonSchema,
|
|
511
|
-
dynamicHints: document.dynamicHints,
|
|
512
|
-
minimalExample: document.minimalExample,
|
|
513
|
-
commonPatterns: document.commonPatterns,
|
|
514
|
-
antiPatterns: document.antiPatterns,
|
|
515
|
-
hash: document.hash,
|
|
516
|
-
source: document.source
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
buildCompactPublicModelDocument(use, contextChain) {
|
|
520
|
-
var _a, _b, _c, _d;
|
|
521
|
-
const resolved = this.resolveModelSchemaRef(use, contextChain);
|
|
522
|
-
const jsonSchema = this.buildCompactModelSnapshotSchemaRef(use, contextChain);
|
|
523
|
-
const minimalExample = import_lodash.default.cloneDeep(
|
|
524
|
-
((_a = resolved == null ? void 0 : resolved.docs) == null ? void 0 : _a.minimalExample) ?? ((_b = resolved == null ? void 0 : resolved.examples) == null ? void 0 : _b[0]) ?? (resolved == null ? void 0 : resolved.skeleton) ?? (0, import_utils.buildSkeletonFromSchema)(jsonSchema)
|
|
525
|
-
);
|
|
526
|
-
return {
|
|
527
|
-
use,
|
|
528
|
-
title: (resolved == null ? void 0 : resolved.title) || use,
|
|
529
|
-
jsonSchema,
|
|
530
|
-
dynamicHints: [...this.getModelLocalDynamicHintsRef(use, contextChain)],
|
|
531
|
-
minimalExample,
|
|
532
|
-
commonPatterns: import_lodash.default.cloneDeep(((_c = resolved == null ? void 0 : resolved.docs) == null ? void 0 : _c.commonPatterns) || []),
|
|
533
|
-
antiPatterns: import_lodash.default.cloneDeep(((_d = resolved == null ? void 0 : resolved.docs) == null ? void 0 : _d.antiPatterns) || []),
|
|
534
|
-
hash: this.getCompactModelSchemaHash(use, contextChain),
|
|
535
|
-
source: ((resolved == null ? void 0 : resolved.coverage) || { source: "third-party" }).source
|
|
536
|
-
};
|
|
537
|
-
}
|
|
538
|
-
getModelLocalDynamicHintsRef(use, contextChain = []) {
|
|
539
|
-
const cacheKey = this.createContextVisitKey(use, contextChain);
|
|
540
|
-
const cached = this.modelLocalDynamicHintsCache.get(cacheKey);
|
|
541
|
-
if (cached) {
|
|
542
|
-
return cached;
|
|
543
|
-
}
|
|
544
|
-
const hints = this.buildModelLocalDynamicHints(use, contextChain);
|
|
545
|
-
const frozen = (0, import_utils.deepFreezePlainGraph)(hints);
|
|
546
|
-
this.modelLocalDynamicHintsCache.set(cacheKey, frozen);
|
|
547
|
-
return frozen;
|
|
548
|
-
}
|
|
549
|
-
buildModelLocalDynamicHints(use, contextChain) {
|
|
550
|
-
const resolved = this.resolveModelSchemaRef(use, contextChain);
|
|
551
|
-
const baseCoverage = resolved.coverage || { status: "unresolved", source: "third-party" };
|
|
552
|
-
const flowDiagnostics = this.collectFlowSchemaDiagnostics(use);
|
|
553
|
-
const slotHints = Object.entries((resolved == null ? void 0 : resolved.subModelSlots) || {}).map(([slotKey, slot]) => {
|
|
554
|
-
const allowedUses = this.resolveSlotAllowedUses(use, slotKey, slot);
|
|
555
|
-
return (0, import_utils.createFlowHint)(
|
|
556
|
-
{
|
|
557
|
-
kind: slot.dynamic || slot.fieldBindingContext ? "dynamic-children" : "manual-schema-required",
|
|
558
|
-
path: `${use}.subModels.${slotKey}`,
|
|
559
|
-
message: slot.description || `${use}.subModels.${slotKey} accepts ${slot.type}${allowedUses.length ? `: ${allowedUses.join(", ")}` : ""}.`
|
|
560
|
-
},
|
|
561
|
-
{
|
|
562
|
-
slotRules: {
|
|
563
|
-
slotKey,
|
|
564
|
-
type: slot.type,
|
|
565
|
-
allowedUses
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
);
|
|
569
|
-
});
|
|
570
|
-
const coverage = this.buildDocumentCoverage(baseCoverage, flowDiagnostics.statuses);
|
|
571
|
-
return (0, import_utils.normalizeSchemaHints)([
|
|
572
|
-
...(resolved == null ? void 0 : resolved.dynamicHints) || [],
|
|
573
|
-
...slotHints,
|
|
574
|
-
...flowDiagnostics.hints,
|
|
575
|
-
...coverage.status === "unresolved" ? [
|
|
576
|
-
(0, import_utils.createFlowHint)(
|
|
577
|
-
{
|
|
578
|
-
kind: "unresolved-model",
|
|
579
|
-
path: use,
|
|
580
|
-
message: `${use} has no registered server-safe schema contribution yet.`
|
|
581
|
-
},
|
|
582
|
-
{
|
|
583
|
-
unresolvedReason: "missing-model-contribution",
|
|
584
|
-
recommendedFallback: { use }
|
|
585
|
-
}
|
|
586
|
-
)
|
|
587
|
-
] : []
|
|
588
|
-
]);
|
|
589
|
-
}
|
|
590
|
-
getModelSchemaHash(use, contextChain = []) {
|
|
591
|
-
const cacheKey = this.createContextVisitKey(use, contextChain);
|
|
592
|
-
const cached = this.modelSchemaHashCache.get(cacheKey);
|
|
593
|
-
if (cached) {
|
|
594
|
-
return cached;
|
|
595
|
-
}
|
|
596
|
-
const hash = (0, import_utils.hashString)((0, import_utils.stableStringify)(this.buildModelSnapshotSchemaRef(use, contextChain)));
|
|
597
|
-
this.modelSchemaHashCache.set(cacheKey, hash);
|
|
598
|
-
return hash;
|
|
599
|
-
}
|
|
600
|
-
getCompactModelSchemaHash(use, contextChain = []) {
|
|
601
|
-
const cacheKey = this.createContextVisitKey(use, contextChain);
|
|
602
|
-
const cached = this.compactModelSchemaHashCache.get(cacheKey);
|
|
603
|
-
if (cached) {
|
|
604
|
-
return cached;
|
|
605
|
-
}
|
|
606
|
-
const hash = (0, import_utils.hashString)((0, import_utils.stableStringify)(this.buildCompactModelSnapshotSchemaRef(use, contextChain)));
|
|
607
|
-
this.compactModelSchemaHashCache.set(cacheKey, hash);
|
|
608
|
-
return hash;
|
|
609
|
-
}
|
|
610
|
-
createSlotUseExpansionKey(parentUse, slotKey) {
|
|
611
|
-
return `${parentUse}::${slotKey}`;
|
|
612
|
-
}
|
|
613
|
-
getSlotUseExpansionUses(parentUse, slotKey) {
|
|
614
|
-
return this.slotUseExpansions.get(this.createSlotUseExpansionKey(parentUse, slotKey)) || [];
|
|
615
|
-
}
|
|
616
|
-
resolveSlotAllowedUses(parentUse, slotKey, slot) {
|
|
617
|
-
if (!slot) {
|
|
618
|
-
return [];
|
|
619
|
-
}
|
|
620
|
-
if (slot.fieldBindingContext) {
|
|
621
|
-
return import_lodash.default.uniq(this.resolveFieldBindingCandidates(slot.fieldBindingContext).map((candidate) => candidate.use));
|
|
622
|
-
}
|
|
623
|
-
return import_lodash.default.uniq([...(0, import_utils.collectAllowedUses)(slot), ...this.getSlotUseExpansionUses(parentUse, slotKey)]);
|
|
624
|
-
}
|
|
625
|
-
buildModelDocument(use, contextChain, visited) {
|
|
626
|
-
var _a, _b, _c, _d;
|
|
627
|
-
const resolved = this.resolveModelSchemaRef(use, contextChain);
|
|
628
|
-
const baseCoverage = resolved.coverage || { status: "unresolved", source: "third-party" };
|
|
629
|
-
const flowDiagnostics = this.collectFlowSchemaDiagnostics(use);
|
|
630
|
-
const coverage = this.buildDocumentCoverage(baseCoverage, flowDiagnostics.statuses);
|
|
631
|
-
const dynamicHints = (0, import_utils.normalizeSchemaHints)([
|
|
632
|
-
...this.getModelLocalDynamicHintsRef(use, contextChain),
|
|
633
|
-
...this.collectNestedDocumentHints(use, contextChain, visited)
|
|
634
|
-
]);
|
|
635
|
-
const jsonSchema = this.buildModelSnapshotSchemaRef(use, contextChain);
|
|
636
|
-
const skeleton = import_lodash.default.cloneDeep((resolved == null ? void 0 : resolved.skeleton) ?? (0, import_utils.buildSkeletonFromSchema)(jsonSchema));
|
|
637
|
-
const minimalExample = import_lodash.default.cloneDeep(((_a = resolved == null ? void 0 : resolved.docs) == null ? void 0 : _a.minimalExample) ?? ((_b = resolved == null ? void 0 : resolved.examples) == null ? void 0 : _b[0]) ?? skeleton);
|
|
638
|
-
const hash = this.getModelSchemaHash(use, contextChain);
|
|
639
|
-
return {
|
|
640
|
-
use,
|
|
641
|
-
title: (resolved == null ? void 0 : resolved.title) || use,
|
|
642
|
-
jsonSchema,
|
|
643
|
-
coverage,
|
|
644
|
-
dynamicHints,
|
|
645
|
-
examples: (resolved == null ? void 0 : resolved.examples) || [],
|
|
646
|
-
minimalExample,
|
|
647
|
-
commonPatterns: import_lodash.default.cloneDeep(((_c = resolved == null ? void 0 : resolved.docs) == null ? void 0 : _c.commonPatterns) || []),
|
|
648
|
-
antiPatterns: import_lodash.default.cloneDeep(((_d = resolved == null ? void 0 : resolved.docs) == null ? void 0 : _d.antiPatterns) || []),
|
|
649
|
-
skeleton,
|
|
650
|
-
hash,
|
|
651
|
-
source: coverage.source
|
|
652
|
-
};
|
|
653
|
-
}
|
|
654
|
-
buildBundleNode(use, contextChain, visited, compatibility) {
|
|
655
|
-
const resolved = this.resolveModelSchemaRef(use, contextChain);
|
|
656
|
-
const visitKey = this.createContextVisitKey(use, contextChain);
|
|
657
|
-
const node = {
|
|
658
|
-
use,
|
|
659
|
-
title: (resolved == null ? void 0 : resolved.title) || use
|
|
660
|
-
};
|
|
661
|
-
if (compatibility) {
|
|
662
|
-
node.compatibility = import_lodash.default.cloneDeep(compatibility);
|
|
663
|
-
}
|
|
664
|
-
if (visited.has(visitKey) || this.isContextCycle(use, contextChain)) {
|
|
665
|
-
return node;
|
|
666
|
-
}
|
|
667
|
-
visited.add(visitKey);
|
|
668
|
-
try {
|
|
669
|
-
const subModelCatalog = this.buildBundleSubModelCatalog(use, resolved == null ? void 0 : resolved.subModelSlots, contextChain, visited);
|
|
670
|
-
if (subModelCatalog && Object.keys(subModelCatalog).length > 0) {
|
|
671
|
-
node.subModelCatalog = subModelCatalog;
|
|
672
|
-
}
|
|
673
|
-
return node;
|
|
674
|
-
} finally {
|
|
675
|
-
visited.delete(visitKey);
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
buildBundleSubModelCatalog(parentUse, slots, contextChain, visited) {
|
|
679
|
-
if (!slots || Object.keys(slots).length === 0) {
|
|
680
|
-
return void 0;
|
|
681
|
-
}
|
|
682
|
-
const entries = Object.entries(slots).map(([slotKey, slot]) => {
|
|
683
|
-
const edgeBase = {
|
|
684
|
-
parentUse,
|
|
685
|
-
slotKey
|
|
686
|
-
};
|
|
687
|
-
const fieldBindingCandidates = slot.fieldBindingContext ? this.resolveFieldBindingCandidates(slot.fieldBindingContext) : [];
|
|
688
|
-
const allowedUses = fieldBindingCandidates.length > 0 ? import_lodash.default.uniq(fieldBindingCandidates.map((item) => item.use)) : this.resolveSlotAllowedUses(parentUse, slotKey, slot);
|
|
689
|
-
const catalog = {
|
|
690
|
-
type: slot.type,
|
|
691
|
-
candidates: fieldBindingCandidates.length > 0 ? fieldBindingCandidates.map(
|
|
692
|
-
(candidate) => this.buildBundleNode(
|
|
693
|
-
candidate.use,
|
|
694
|
-
[
|
|
695
|
-
...contextChain,
|
|
696
|
-
{
|
|
697
|
-
...edgeBase,
|
|
698
|
-
childUse: candidate.use
|
|
699
|
-
}
|
|
700
|
-
],
|
|
701
|
-
visited,
|
|
702
|
-
candidate.compatibility
|
|
703
|
-
)
|
|
704
|
-
) : allowedUses.map(
|
|
705
|
-
(childUse) => this.buildBundleNode(
|
|
706
|
-
childUse,
|
|
707
|
-
[
|
|
708
|
-
...contextChain,
|
|
709
|
-
{
|
|
710
|
-
...edgeBase,
|
|
711
|
-
childUse
|
|
712
|
-
}
|
|
713
|
-
],
|
|
714
|
-
visited
|
|
715
|
-
)
|
|
716
|
-
)
|
|
717
|
-
};
|
|
718
|
-
if (slot.required !== void 0) {
|
|
719
|
-
catalog.required = slot.required;
|
|
720
|
-
}
|
|
721
|
-
if (slot.type === "array" && typeof slot.minItems === "number") {
|
|
722
|
-
catalog.minItems = slot.minItems;
|
|
723
|
-
}
|
|
724
|
-
if (allowedUses.length === 0) {
|
|
725
|
-
catalog.open = true;
|
|
726
|
-
}
|
|
727
|
-
return [slotKey, catalog];
|
|
728
|
-
});
|
|
729
|
-
return entries.length ? Object.fromEntries(entries) : void 0;
|
|
730
|
-
}
|
|
731
|
-
createContextVisitKey(use, contextChain) {
|
|
732
|
-
return `${use}::${(0, import_utils.stableStringify)(contextChain)}`;
|
|
733
|
-
}
|
|
734
|
-
isContextCycle(use, contextChain) {
|
|
735
|
-
if (!contextChain.length) {
|
|
736
|
-
return false;
|
|
737
|
-
}
|
|
738
|
-
const ancestorUses = [contextChain[0].parentUse, ...contextChain.slice(0, -1).map((edge) => edge.childUse)];
|
|
739
|
-
return ancestorUses.includes(use);
|
|
740
|
-
}
|
|
741
|
-
buildModelSnapshotSchema(use, contextChain = []) {
|
|
742
|
-
return import_lodash.default.cloneDeep(this.buildModelSnapshotSchemaRef(use, contextChain));
|
|
743
|
-
}
|
|
744
|
-
buildCompactModelSnapshotSchema(use, contextChain = []) {
|
|
745
|
-
return import_lodash.default.cloneDeep(this.buildCompactModelSnapshotSchemaRef(use, contextChain));
|
|
746
|
-
}
|
|
747
|
-
buildModelSnapshotSchemaRef(use, contextChain = []) {
|
|
748
|
-
const cacheKey = this.createContextVisitKey(use, contextChain);
|
|
749
|
-
const cached = this.modelSnapshotSchemaCache.get(cacheKey);
|
|
750
|
-
if (cached) {
|
|
751
|
-
return cached;
|
|
752
|
-
}
|
|
753
|
-
const schema = this.buildModelSnapshotSchemaInternal(use, contextChain, /* @__PURE__ */ new Set());
|
|
754
|
-
const frozen = (0, import_utils.deepFreezePlainGraph)(schema);
|
|
755
|
-
this.modelSnapshotSchemaCache.set(cacheKey, frozen);
|
|
756
|
-
return frozen;
|
|
757
|
-
}
|
|
758
|
-
buildCompactModelSnapshotSchemaRef(use, contextChain = []) {
|
|
759
|
-
const cacheKey = this.createContextVisitKey(use, contextChain);
|
|
760
|
-
const cached = this.compactModelSnapshotSchemaCache.get(cacheKey);
|
|
761
|
-
if (cached) {
|
|
762
|
-
return cached;
|
|
763
|
-
}
|
|
764
|
-
const schema = this.buildCompactModelSnapshotSchemaInternal(use, contextChain);
|
|
765
|
-
const frozen = (0, import_utils.deepFreezePlainGraph)(schema);
|
|
766
|
-
this.compactModelSnapshotSchemaCache.set(cacheKey, frozen);
|
|
767
|
-
return frozen;
|
|
768
|
-
}
|
|
769
|
-
buildCompactModelSnapshotSchemaInternal(use, contextChain) {
|
|
770
|
-
const resolved = this.resolveModelSchemaRef(use, contextChain);
|
|
771
|
-
const subModelsSchema = this.buildCompactSubModelsSchemaFromSlots(use, resolved == null ? void 0 : resolved.subModelSlots, contextChain);
|
|
772
|
-
return this.buildSnapshotShellSchema(use, resolved, subModelsSchema);
|
|
773
|
-
}
|
|
774
|
-
buildModelSnapshotSchemaInternal(use, contextChain, visited) {
|
|
775
|
-
const resolved = this.resolveModelSchemaRef(use, contextChain);
|
|
776
|
-
const visitKey = this.createContextVisitKey(use, contextChain);
|
|
777
|
-
if (visited.has(visitKey) || this.isContextCycle(use, contextChain)) {
|
|
778
|
-
return this.buildTruncatedSnapshotSchema(use, resolved);
|
|
779
|
-
}
|
|
780
|
-
visited.add(visitKey);
|
|
781
|
-
try {
|
|
782
|
-
return this.buildSnapshotSchemaFromResolved(use, resolved, contextChain, visited);
|
|
783
|
-
} finally {
|
|
784
|
-
visited.delete(visitKey);
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
buildSnapshotSchemaFromResolved(use, resolved, contextChain, visited) {
|
|
788
|
-
const subModelsSchema = this.buildSubModelsSchemaFromSlots(
|
|
789
|
-
use || "",
|
|
790
|
-
resolved == null ? void 0 : resolved.subModelSlots,
|
|
791
|
-
contextChain,
|
|
792
|
-
visited
|
|
793
|
-
);
|
|
794
|
-
return this.buildSnapshotShellSchema(use, resolved, subModelsSchema);
|
|
795
|
-
}
|
|
796
|
-
buildSnapshotShellSchema(use, resolved, subModelsSchema) {
|
|
797
|
-
const flowRegistrySchema = (resolved == null ? void 0 : resolved.flowRegistrySchema) || { type: "object", additionalProperties: true };
|
|
798
|
-
const stepParamsSchema = (resolved == null ? void 0 : resolved.stepParamsSchema) || { type: "object", additionalProperties: true };
|
|
799
|
-
return {
|
|
800
|
-
$schema: import_utils.JSON_SCHEMA_DRAFT_07,
|
|
801
|
-
type: "object",
|
|
802
|
-
properties: {
|
|
803
|
-
uid: { type: "string" },
|
|
804
|
-
use: use ? { const: use } : { type: "string" },
|
|
805
|
-
async: { type: "boolean" },
|
|
806
|
-
parentId: { type: "string" },
|
|
807
|
-
subKey: { type: "string" },
|
|
808
|
-
subType: { type: "string", enum: ["object", "array"] },
|
|
809
|
-
sortIndex: { type: "number" },
|
|
810
|
-
stepParams: stepParamsSchema,
|
|
811
|
-
flowRegistry: (0, import_utils.mergeSchemas)(flowRegistrySchema, resolved == null ? void 0 : resolved.flowRegistrySchemaPatch) || {
|
|
812
|
-
type: "object",
|
|
813
|
-
additionalProperties: true
|
|
814
|
-
},
|
|
815
|
-
subModels: subModelsSchema
|
|
816
|
-
},
|
|
817
|
-
required: ["uid", "use"],
|
|
818
|
-
additionalProperties: true
|
|
819
|
-
};
|
|
820
|
-
}
|
|
821
|
-
buildTruncatedSnapshotSchema(use, resolved) {
|
|
822
|
-
return this.buildSnapshotShellSchema(use, resolved, {
|
|
823
|
-
type: "object",
|
|
824
|
-
additionalProperties: true
|
|
825
|
-
});
|
|
826
|
-
}
|
|
827
|
-
buildStaticFlowRegistrySchema(use, contextChain = []) {
|
|
828
|
-
const resolved = this.resolveModelSchemaRef(use, contextChain);
|
|
829
|
-
const schema = (0, import_utils.mergeSchemas)(resolved == null ? void 0 : resolved.flowRegistrySchema, resolved == null ? void 0 : resolved.flowRegistrySchemaPatch);
|
|
830
|
-
if (schema) {
|
|
831
|
-
return import_lodash.default.cloneDeep(schema);
|
|
832
|
-
}
|
|
833
|
-
return { type: "object", additionalProperties: true };
|
|
834
|
-
}
|
|
835
|
-
buildStaticStepParamsSchema(use, contextChain = []) {
|
|
836
|
-
const resolved = this.resolveModelSchemaRef(use, contextChain);
|
|
837
|
-
if (resolved == null ? void 0 : resolved.stepParamsSchema) {
|
|
838
|
-
return import_lodash.default.cloneDeep(resolved.stepParamsSchema);
|
|
839
|
-
}
|
|
840
|
-
return { type: "object", additionalProperties: true };
|
|
841
|
-
}
|
|
842
|
-
buildSubModelsSchema(use, contextChain = []) {
|
|
843
|
-
const resolved = this.resolveModelSchemaRef(use, contextChain);
|
|
844
|
-
return this.buildSubModelsSchemaFromSlots(use, resolved == null ? void 0 : resolved.subModelSlots, contextChain, /* @__PURE__ */ new Set());
|
|
845
|
-
}
|
|
846
|
-
buildCompactSubModelsSchemaFromSlots(parentUse, slots, contextChain = []) {
|
|
847
|
-
if (!slots || Object.keys(slots).length === 0) {
|
|
848
|
-
return { type: "object", additionalProperties: true };
|
|
849
|
-
}
|
|
850
|
-
const properties = {};
|
|
851
|
-
const required = [];
|
|
852
|
-
for (const [slotKey, slot] of Object.entries(slots)) {
|
|
853
|
-
const itemSchema = this.buildCompactSlotTargetSchema(parentUse, slotKey, slot, contextChain);
|
|
854
|
-
properties[slotKey] = slot.type === "array" ? {
|
|
855
|
-
type: "array",
|
|
856
|
-
...typeof slot.minItems === "number" ? { minItems: slot.minItems } : {},
|
|
857
|
-
items: itemSchema
|
|
858
|
-
} : itemSchema;
|
|
859
|
-
if (slot.required) {
|
|
860
|
-
required.push(slotKey);
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
return {
|
|
864
|
-
type: "object",
|
|
865
|
-
properties,
|
|
866
|
-
...required.length ? { required } : {},
|
|
867
|
-
additionalProperties: true
|
|
868
|
-
};
|
|
869
|
-
}
|
|
870
|
-
buildSubModelsSchemaFromSlots(parentUse, slots, contextChain = [], visited) {
|
|
871
|
-
if (!slots || Object.keys(slots).length === 0) {
|
|
872
|
-
return { type: "object", additionalProperties: true };
|
|
873
|
-
}
|
|
874
|
-
const properties = {};
|
|
875
|
-
const required = [];
|
|
876
|
-
for (const [slotKey, slot] of Object.entries(slots)) {
|
|
877
|
-
const itemSchema = this.buildSlotTargetSchema(parentUse, slotKey, slot, contextChain, visited);
|
|
878
|
-
properties[slotKey] = slot.type === "array" ? {
|
|
879
|
-
type: "array",
|
|
880
|
-
...typeof slot.minItems === "number" ? { minItems: slot.minItems } : {},
|
|
881
|
-
items: itemSchema
|
|
882
|
-
} : itemSchema;
|
|
883
|
-
if (slot.required) {
|
|
884
|
-
required.push(slotKey);
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
return {
|
|
888
|
-
type: "object",
|
|
889
|
-
properties,
|
|
890
|
-
...required.length ? { required } : {},
|
|
891
|
-
additionalProperties: true
|
|
892
|
-
};
|
|
893
|
-
}
|
|
894
|
-
buildInferredFlowRegistrySchema(use) {
|
|
895
|
-
var _a, _b;
|
|
896
|
-
const registered = this.modelSchemas.get(use);
|
|
897
|
-
const modelClass = registered == null ? void 0 : registered.modelClass;
|
|
898
|
-
const flowsMap = (_b = (_a = modelClass == null ? void 0 : modelClass.globalFlowRegistry) == null ? void 0 : _a.getFlows) == null ? void 0 : _b.call(_a);
|
|
899
|
-
if (!(flowsMap == null ? void 0 : flowsMap.size)) {
|
|
900
|
-
return void 0;
|
|
901
|
-
}
|
|
902
|
-
const properties = {};
|
|
903
|
-
for (const [flowKey, flowDef] of flowsMap.entries()) {
|
|
904
|
-
const stepProperties = {};
|
|
905
|
-
const steps = (flowDef == null ? void 0 : flowDef.steps) || {};
|
|
906
|
-
for (const [stepKey, stepDef] of Object.entries(steps)) {
|
|
907
|
-
stepProperties[stepKey] = this.buildStepDefinitionSchema(stepDef);
|
|
908
|
-
}
|
|
909
|
-
properties[flowKey] = {
|
|
910
|
-
type: "object",
|
|
911
|
-
properties: {
|
|
912
|
-
key: { type: "string" },
|
|
913
|
-
title: { type: "string" },
|
|
914
|
-
manual: { type: "boolean" },
|
|
915
|
-
sort: { type: "number" },
|
|
916
|
-
on: this.buildFlowOnSchema(),
|
|
917
|
-
steps: {
|
|
918
|
-
type: "object",
|
|
919
|
-
properties: stepProperties,
|
|
920
|
-
additionalProperties: false
|
|
921
|
-
}
|
|
922
|
-
},
|
|
923
|
-
additionalProperties: true
|
|
924
|
-
};
|
|
925
|
-
}
|
|
926
|
-
return {
|
|
927
|
-
type: "object",
|
|
928
|
-
properties,
|
|
929
|
-
additionalProperties: true
|
|
930
|
-
};
|
|
931
|
-
}
|
|
932
|
-
buildInferredStepParamsSchema(use) {
|
|
933
|
-
var _a, _b;
|
|
934
|
-
const registered = this.modelSchemas.get(use);
|
|
935
|
-
const modelClass = registered == null ? void 0 : registered.modelClass;
|
|
936
|
-
const flowsMap = (_b = (_a = modelClass == null ? void 0 : modelClass.globalFlowRegistry) == null ? void 0 : _a.getFlows) == null ? void 0 : _b.call(_a);
|
|
937
|
-
if (!(flowsMap == null ? void 0 : flowsMap.size)) {
|
|
938
|
-
return void 0;
|
|
939
|
-
}
|
|
940
|
-
const properties = {};
|
|
941
|
-
for (const [flowKey, flowDef] of flowsMap.entries()) {
|
|
942
|
-
const stepProperties = {};
|
|
943
|
-
const steps = (flowDef == null ? void 0 : flowDef.steps) || {};
|
|
944
|
-
for (const [stepKey, stepDef] of Object.entries(steps)) {
|
|
945
|
-
const resolved = this.resolveStepParamsSchema(stepDef, `${use}.${flowKey}.${stepKey}`);
|
|
946
|
-
stepProperties[stepKey] = resolved.schema || { type: "object", additionalProperties: true };
|
|
947
|
-
}
|
|
948
|
-
properties[flowKey] = {
|
|
949
|
-
type: "object",
|
|
950
|
-
properties: stepProperties,
|
|
951
|
-
additionalProperties: false
|
|
952
|
-
};
|
|
953
|
-
}
|
|
954
|
-
return {
|
|
955
|
-
type: "object",
|
|
956
|
-
properties,
|
|
957
|
-
additionalProperties: true
|
|
958
|
-
};
|
|
959
|
-
}
|
|
960
|
-
buildFlowOnSchema() {
|
|
961
|
-
return {
|
|
962
|
-
anyOf: [
|
|
963
|
-
{ type: "string" },
|
|
964
|
-
{
|
|
965
|
-
type: "object",
|
|
966
|
-
properties: {
|
|
967
|
-
eventName: { type: "string" },
|
|
968
|
-
defaultParams: { type: "object", additionalProperties: true },
|
|
969
|
-
phase: {
|
|
970
|
-
type: "string",
|
|
971
|
-
enum: ["beforeAllFlows", "afterAllFlows", "beforeFlow", "afterFlow", "beforeStep", "afterStep"]
|
|
972
|
-
},
|
|
973
|
-
flowKey: { type: "string" },
|
|
974
|
-
stepKey: { type: "string" }
|
|
975
|
-
},
|
|
976
|
-
required: ["eventName"],
|
|
977
|
-
additionalProperties: true
|
|
978
|
-
}
|
|
979
|
-
]
|
|
980
|
-
};
|
|
981
|
-
}
|
|
982
|
-
buildStepDefinitionSchema(step) {
|
|
983
|
-
return {
|
|
984
|
-
type: "object",
|
|
985
|
-
properties: {
|
|
986
|
-
key: { type: "string" },
|
|
987
|
-
flowKey: { type: "string" },
|
|
988
|
-
title: { type: "string" },
|
|
989
|
-
use: { type: "string" },
|
|
990
|
-
sort: { type: "number" },
|
|
991
|
-
preset: { type: "boolean" },
|
|
992
|
-
isAwait: { type: "boolean" },
|
|
993
|
-
manual: { type: "boolean" },
|
|
994
|
-
on: this.buildFlowOnSchema(),
|
|
995
|
-
defaultParams: { type: ["object", "array", "string", "number", "boolean", "null"] },
|
|
996
|
-
paramsSchemaOverride: { type: "object", additionalProperties: true }
|
|
997
|
-
},
|
|
998
|
-
additionalProperties: true
|
|
999
|
-
};
|
|
1000
|
-
}
|
|
1001
|
-
resolveStepParamsSchema(step, path) {
|
|
1002
|
-
var _a, _b, _c, _d;
|
|
1003
|
-
if (step.paramsSchemaOverride) {
|
|
1004
|
-
return {
|
|
1005
|
-
schema: import_lodash.default.cloneDeep(step.paramsSchemaOverride),
|
|
1006
|
-
hints: (0, import_utils.normalizeSchemaHints)((_a = step.schemaDocs) == null ? void 0 : _a.dynamicHints),
|
|
1007
|
-
coverage: "manual"
|
|
1008
|
-
};
|
|
1009
|
-
}
|
|
1010
|
-
if (step.use) {
|
|
1011
|
-
const action = this.getAction(step.use);
|
|
1012
|
-
if (action == null ? void 0 : action.schema) {
|
|
1013
|
-
return {
|
|
1014
|
-
schema: import_lodash.default.cloneDeep(action.schema),
|
|
1015
|
-
hints: (0, import_utils.normalizeSchemaHints)([...action.dynamicHints || [], ...((_b = step.schemaDocs) == null ? void 0 : _b.dynamicHints) || []]),
|
|
1016
|
-
coverage: action.coverage.status === "auto" || action.coverage.status === "manual" ? action.coverage.status : action.coverage.status === "unresolved" ? "unresolved" : "mixed"
|
|
1017
|
-
};
|
|
1018
|
-
}
|
|
1019
|
-
return {
|
|
1020
|
-
schema: { type: "object", additionalProperties: true },
|
|
1021
|
-
hints: [
|
|
1022
|
-
(0, import_utils.createFlowHint)(
|
|
1023
|
-
{
|
|
1024
|
-
kind: "unresolved-action",
|
|
1025
|
-
path,
|
|
1026
|
-
message: `${path} references unresolved action "${step.use}".`
|
|
1027
|
-
},
|
|
1028
|
-
{
|
|
1029
|
-
unresolvedReason: "missing-action-contribution",
|
|
1030
|
-
recommendedFallback: { use: step.use, params: {} }
|
|
1031
|
-
}
|
|
1032
|
-
),
|
|
1033
|
-
...((_c = step.schemaDocs) == null ? void 0 : _c.dynamicHints) || []
|
|
1034
|
-
],
|
|
1035
|
-
coverage: "unresolved"
|
|
1036
|
-
};
|
|
1037
|
-
}
|
|
1038
|
-
const inferred = (0, import_schemaInference.inferParamsSchemaFromUiSchema)(path, step.uiSchema, path);
|
|
1039
|
-
return {
|
|
1040
|
-
schema: (0, import_utils.mergeSchemas)(inferred.schema, step.paramsSchemaPatch),
|
|
1041
|
-
hints: (0, import_utils.normalizeSchemaHints)([...inferred.hints || [], ...((_d = step.schemaDocs) == null ? void 0 : _d.dynamicHints) || []]),
|
|
1042
|
-
coverage: step.paramsSchemaPatch ? "mixed" : inferred.coverage
|
|
1043
|
-
};
|
|
1044
|
-
}
|
|
1045
|
-
buildSlotTargetSchema(parentUse, slotKey, slot, contextChain, visited) {
|
|
1046
|
-
var _a, _b;
|
|
1047
|
-
if (slot.fieldBindingContext) {
|
|
1048
|
-
const candidateUses = import_lodash.default.uniq(
|
|
1049
|
-
this.resolveFieldBindingCandidates(slot.fieldBindingContext).map((item) => item.use)
|
|
1050
|
-
);
|
|
1051
|
-
if (candidateUses.length > 0) {
|
|
1052
|
-
const candidateSchemas = candidateUses.map(
|
|
1053
|
-
(use) => this.buildModelSnapshotSchemaInternal(
|
|
1054
|
-
use,
|
|
1055
|
-
[
|
|
1056
|
-
...contextChain,
|
|
1057
|
-
{
|
|
1058
|
-
parentUse,
|
|
1059
|
-
slotKey,
|
|
1060
|
-
childUse: use
|
|
1061
|
-
}
|
|
1062
|
-
],
|
|
1063
|
-
visited
|
|
1064
|
-
)
|
|
1065
|
-
);
|
|
1066
|
-
if (slot.schema) {
|
|
1067
|
-
return {
|
|
1068
|
-
anyOf: [...candidateSchemas, import_lodash.default.cloneDeep(slot.schema)]
|
|
1069
|
-
};
|
|
1070
|
-
}
|
|
1071
|
-
return candidateSchemas.length === 1 ? candidateSchemas[0] : { oneOf: candidateSchemas };
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
const allowedUses = this.resolveSlotAllowedUses(parentUse, slotKey, slot);
|
|
1075
|
-
if (allowedUses.length > 0) {
|
|
1076
|
-
const knownSchemas = allowedUses.map(
|
|
1077
|
-
(use) => this.buildModelSnapshotSchemaInternal(
|
|
1078
|
-
use,
|
|
1079
|
-
[
|
|
1080
|
-
...contextChain,
|
|
1081
|
-
{
|
|
1082
|
-
parentUse,
|
|
1083
|
-
slotKey,
|
|
1084
|
-
childUse: use
|
|
1085
|
-
}
|
|
1086
|
-
],
|
|
1087
|
-
visited
|
|
1088
|
-
)
|
|
1089
|
-
);
|
|
1090
|
-
if (slot.schema) {
|
|
1091
|
-
return {
|
|
1092
|
-
anyOf: [...knownSchemas, import_lodash.default.cloneDeep(slot.schema)]
|
|
1093
|
-
};
|
|
1094
|
-
}
|
|
1095
|
-
if (knownSchemas.length === 1) {
|
|
1096
|
-
return knownSchemas[0];
|
|
1097
|
-
}
|
|
1098
|
-
return {
|
|
1099
|
-
oneOf: knownSchemas
|
|
1100
|
-
};
|
|
1101
|
-
}
|
|
1102
|
-
if (slot.childSchemaPatch || ((_a = slot.descendantSchemaPatches) == null ? void 0 : _a.length)) {
|
|
1103
|
-
return this.buildAnonymousSlotSnapshotSchema(parentUse, slotKey, slot, contextChain, visited);
|
|
1104
|
-
}
|
|
1105
|
-
if (slot.schema && !slot.childSchemaPatch && !((_b = slot.descendantSchemaPatches) == null ? void 0 : _b.length)) {
|
|
1106
|
-
return import_lodash.default.cloneDeep(slot.schema);
|
|
1107
|
-
}
|
|
1108
|
-
return { type: "object", additionalProperties: true };
|
|
1109
|
-
}
|
|
1110
|
-
buildCompactSlotTargetSchema(parentUse, slotKey, slot, contextChain) {
|
|
1111
|
-
var _a, _b;
|
|
1112
|
-
if (slot.fieldBindingContext) {
|
|
1113
|
-
const candidateUses = import_lodash.default.uniq(
|
|
1114
|
-
this.resolveFieldBindingCandidates(slot.fieldBindingContext).map((item) => item.use)
|
|
1115
|
-
);
|
|
1116
|
-
if (candidateUses.length > 0) {
|
|
1117
|
-
const candidateSchemas = candidateUses.map(
|
|
1118
|
-
(use) => this.buildCompactSlotCandidateSchema(use, [
|
|
1119
|
-
...contextChain,
|
|
1120
|
-
{
|
|
1121
|
-
parentUse,
|
|
1122
|
-
slotKey,
|
|
1123
|
-
childUse: use
|
|
1124
|
-
}
|
|
1125
|
-
])
|
|
1126
|
-
);
|
|
1127
|
-
if (slot.schema) {
|
|
1128
|
-
return {
|
|
1129
|
-
anyOf: [...candidateSchemas, import_lodash.default.cloneDeep(slot.schema)]
|
|
1130
|
-
};
|
|
1131
|
-
}
|
|
1132
|
-
return candidateSchemas.length === 1 ? candidateSchemas[0] : { oneOf: candidateSchemas };
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
const allowedUses = this.resolveSlotAllowedUses(parentUse, slotKey, slot);
|
|
1136
|
-
if (allowedUses.length > 0) {
|
|
1137
|
-
const knownSchemas = allowedUses.map(
|
|
1138
|
-
(use) => this.buildCompactSlotCandidateSchema(use, [
|
|
1139
|
-
...contextChain,
|
|
1140
|
-
{
|
|
1141
|
-
parentUse,
|
|
1142
|
-
slotKey,
|
|
1143
|
-
childUse: use
|
|
1144
|
-
}
|
|
1145
|
-
])
|
|
1146
|
-
);
|
|
1147
|
-
if (slot.schema) {
|
|
1148
|
-
return {
|
|
1149
|
-
anyOf: [...knownSchemas, import_lodash.default.cloneDeep(slot.schema)]
|
|
1150
|
-
};
|
|
1151
|
-
}
|
|
1152
|
-
return knownSchemas.length === 1 ? knownSchemas[0] : { oneOf: knownSchemas };
|
|
1153
|
-
}
|
|
1154
|
-
if (slot.childSchemaPatch || ((_a = slot.descendantSchemaPatches) == null ? void 0 : _a.length)) {
|
|
1155
|
-
return this.buildCompactAnonymousSlotSnapshotSchema(parentUse, slotKey, slot);
|
|
1156
|
-
}
|
|
1157
|
-
if (slot.schema && !slot.childSchemaPatch && !((_b = slot.descendantSchemaPatches) == null ? void 0 : _b.length)) {
|
|
1158
|
-
return import_lodash.default.cloneDeep(slot.schema);
|
|
1159
|
-
}
|
|
1160
|
-
return { type: "object", additionalProperties: true };
|
|
1161
|
-
}
|
|
1162
|
-
buildCompactSlotCandidateSchema(use, contextChain) {
|
|
1163
|
-
const resolved = this.resolveModelSchemaRef(use, contextChain);
|
|
1164
|
-
return this.buildTruncatedSnapshotSchema(use, resolved);
|
|
1165
|
-
}
|
|
1166
|
-
buildCompactAnonymousSlotSnapshotSchema(parentUse, slotKey, slot) {
|
|
1167
|
-
const anonymousResolved = this.createAnonymousResolvedSchema(parentUse, slotKey, slot);
|
|
1168
|
-
return this.buildTruncatedSnapshotSchema(void 0, anonymousResolved);
|
|
1169
|
-
}
|
|
1170
|
-
buildAnonymousSlotSnapshotSchema(parentUse, slotKey, slot, contextChain, visited) {
|
|
1171
|
-
const anonymousResolved = this.createAnonymousResolvedSchema(parentUse, slotKey, slot);
|
|
1172
|
-
return this.buildSnapshotSchemaFromResolved(
|
|
1173
|
-
"",
|
|
1174
|
-
anonymousResolved,
|
|
1175
|
-
[
|
|
1176
|
-
...contextChain,
|
|
1177
|
-
{
|
|
1178
|
-
parentUse,
|
|
1179
|
-
slotKey,
|
|
1180
|
-
childUse: ""
|
|
1181
|
-
}
|
|
1182
|
-
],
|
|
1183
|
-
visited
|
|
1184
|
-
);
|
|
1185
|
-
}
|
|
1186
|
-
createAnonymousResolvedSchema(parentUse, slotKey, slot) {
|
|
1187
|
-
const anonymousResolved = {
|
|
1188
|
-
use: "",
|
|
1189
|
-
title: slot.description || `${parentUse || "AnonymousModel"}.${slotKey}`,
|
|
1190
|
-
examples: [],
|
|
1191
|
-
docs: (0, import_utils.normalizeSchemaDocs)(),
|
|
1192
|
-
dynamicHints: [],
|
|
1193
|
-
coverage: {
|
|
1194
|
-
status: "unresolved",
|
|
1195
|
-
source: "third-party"
|
|
1196
|
-
},
|
|
1197
|
-
exposure: "internal",
|
|
1198
|
-
abstract: false,
|
|
1199
|
-
allowDirectUse: true,
|
|
1200
|
-
suggestedUses: []
|
|
1201
|
-
};
|
|
1202
|
-
const directPatch = (0, import_modelPatches.resolveChildSchemaPatch)(slot, "");
|
|
1203
|
-
if (directPatch) {
|
|
1204
|
-
(0, import_modelPatches.applyModelSchemaPatch)(anonymousResolved, directPatch, "third-party");
|
|
1205
|
-
}
|
|
1206
|
-
return anonymousResolved;
|
|
1207
|
-
}
|
|
1208
|
-
collectNestedDocumentHints(use, contextChain, visited) {
|
|
1209
|
-
const visitKey = this.createContextVisitKey(use, contextChain);
|
|
1210
|
-
if (visited.has(visitKey) || this.isContextCycle(use, contextChain)) {
|
|
1211
|
-
return [];
|
|
1212
|
-
}
|
|
1213
|
-
visited.add(visitKey);
|
|
1214
|
-
try {
|
|
1215
|
-
const resolved = this.resolveModelSchemaRef(use, contextChain);
|
|
1216
|
-
const hints = [];
|
|
1217
|
-
for (const [slotKey, slot] of Object.entries(resolved.subModelSlots || {})) {
|
|
1218
|
-
const childUses = this.resolveSlotAllowedUses(use, slotKey, slot);
|
|
1219
|
-
for (const childUse of childUses) {
|
|
1220
|
-
const childContext = [
|
|
1221
|
-
...contextChain,
|
|
1222
|
-
{
|
|
1223
|
-
parentUse: use,
|
|
1224
|
-
slotKey,
|
|
1225
|
-
childUse
|
|
1226
|
-
}
|
|
1227
|
-
];
|
|
1228
|
-
const childDocument = this.buildModelDocument(childUse, childContext, visited);
|
|
1229
|
-
const basePath = `${use}.subModels.${slotKey}`;
|
|
1230
|
-
hints.push(...childDocument.dynamicHints.map((hint) => this.prefixNestedHint(hint, basePath, childUse)));
|
|
1231
|
-
}
|
|
1232
|
-
}
|
|
1233
|
-
return (0, import_utils.normalizeSchemaHints)(hints);
|
|
1234
|
-
} finally {
|
|
1235
|
-
visited.delete(visitKey);
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
|
-
prefixNestedHint(hint, basePath, childUse) {
|
|
1239
|
-
if (!hint.path) {
|
|
1240
|
-
return {
|
|
1241
|
-
...hint,
|
|
1242
|
-
path: basePath
|
|
1243
|
-
};
|
|
1244
|
-
}
|
|
1245
|
-
if (hint.path === childUse) {
|
|
1246
|
-
return {
|
|
1247
|
-
...hint,
|
|
1248
|
-
path: basePath
|
|
1249
|
-
};
|
|
1250
|
-
}
|
|
1251
|
-
if (hint.path.startsWith(`${childUse}.`)) {
|
|
1252
|
-
return {
|
|
1253
|
-
...hint,
|
|
1254
|
-
path: `${basePath}.${hint.path.slice(childUse.length + 1)}`
|
|
1255
|
-
};
|
|
1256
|
-
}
|
|
1257
|
-
return {
|
|
1258
|
-
...hint,
|
|
1259
|
-
path: `${basePath}.${hint.path}`
|
|
1260
|
-
};
|
|
1261
|
-
}
|
|
1262
|
-
collectContextPatches(use, contextChain) {
|
|
1263
|
-
var _a;
|
|
1264
|
-
if (!contextChain.length) {
|
|
1265
|
-
return [];
|
|
1266
|
-
}
|
|
1267
|
-
const contributions = [];
|
|
1268
|
-
const targetEdgeIndex = contextChain.length - 1;
|
|
1269
|
-
for (let index = 0; index < contextChain.length; index++) {
|
|
1270
|
-
const edge = contextChain[index];
|
|
1271
|
-
const parentContext = contextChain.slice(0, index);
|
|
1272
|
-
const parentResolved = this.resolveModelSchemaRef(edge.parentUse, parentContext);
|
|
1273
|
-
const slot = (_a = parentResolved.subModelSlots) == null ? void 0 : _a[edge.slotKey];
|
|
1274
|
-
if (!slot) {
|
|
1275
|
-
continue;
|
|
1276
|
-
}
|
|
1277
|
-
const remainingEdges = contextChain.slice(index + 1);
|
|
1278
|
-
for (const patch of slot.descendantSchemaPatches || []) {
|
|
1279
|
-
if ((0, import_modelPatches.matchesDescendantSchemaPatch)(patch, remainingEdges)) {
|
|
1280
|
-
contributions.push({
|
|
1281
|
-
patch: patch.patch,
|
|
1282
|
-
source: parentResolved.coverage.source,
|
|
1283
|
-
strict: parentResolved.coverage.strict
|
|
1284
|
-
});
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
if (index === targetEdgeIndex) {
|
|
1288
|
-
const directPatch = (0, import_modelPatches.resolveChildSchemaPatch)(slot, use);
|
|
1289
|
-
if (directPatch) {
|
|
1290
|
-
contributions.push({
|
|
1291
|
-
patch: directPatch,
|
|
1292
|
-
source: parentResolved.coverage.source,
|
|
1293
|
-
strict: parentResolved.coverage.strict
|
|
1294
|
-
});
|
|
1295
|
-
}
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
return contributions;
|
|
1299
|
-
}
|
|
1300
|
-
collectModelDynamicHints(use, modelClass, meta) {
|
|
1301
|
-
const hints = [];
|
|
1302
|
-
if (typeof meta.children === "function") {
|
|
1303
|
-
hints.push(
|
|
1304
|
-
(0, import_utils.createFlowHint)(
|
|
1305
|
-
{
|
|
1306
|
-
kind: "dynamic-children",
|
|
1307
|
-
path: `${use}.meta.children`,
|
|
1308
|
-
message: `${use} uses function-based children and only static slot hints are available.`
|
|
1309
|
-
},
|
|
1310
|
-
{
|
|
1311
|
-
unresolvedReason: "function-children"
|
|
1312
|
-
}
|
|
1313
|
-
)
|
|
1314
|
-
);
|
|
1315
|
-
}
|
|
1316
|
-
if (typeof meta.createModelOptions === "function") {
|
|
1317
|
-
hints.push(
|
|
1318
|
-
(0, import_utils.createFlowHint)(
|
|
1319
|
-
{
|
|
1320
|
-
kind: "dynamic-children",
|
|
1321
|
-
path: `${use}.meta.createModelOptions`,
|
|
1322
|
-
message: `${use} uses function-based createModelOptions and may need manual sub-model slot schema.`
|
|
1323
|
-
},
|
|
1324
|
-
{
|
|
1325
|
-
unresolvedReason: "function-create-model-options"
|
|
1326
|
-
}
|
|
1327
|
-
)
|
|
1328
|
-
);
|
|
1329
|
-
}
|
|
1330
|
-
if (typeof modelClass.defineChildren === "function") {
|
|
1331
|
-
hints.push(
|
|
1332
|
-
(0, import_utils.createFlowHint)(
|
|
1333
|
-
{
|
|
1334
|
-
kind: "dynamic-children",
|
|
1335
|
-
path: `${use}.defineChildren`,
|
|
1336
|
-
message: `${use} defines dynamic children. Schema generation only keeps static baseline.`
|
|
1337
|
-
},
|
|
1338
|
-
{
|
|
1339
|
-
unresolvedReason: "runtime-define-children"
|
|
1340
|
-
}
|
|
1341
|
-
)
|
|
1342
|
-
);
|
|
1343
|
-
}
|
|
1344
|
-
return hints;
|
|
1345
|
-
}
|
|
1346
|
-
collectFlowSchemaDiagnostics(use) {
|
|
1347
|
-
var _a, _b, _c;
|
|
1348
|
-
const registered = this.modelSchemas.get(use);
|
|
1349
|
-
const modelClass = registered == null ? void 0 : registered.modelClass;
|
|
1350
|
-
const flowsMap = (_b = (_a = modelClass == null ? void 0 : modelClass.globalFlowRegistry) == null ? void 0 : _a.getFlows) == null ? void 0 : _b.call(_a);
|
|
1351
|
-
if (!(flowsMap == null ? void 0 : flowsMap.size)) {
|
|
1352
|
-
return {
|
|
1353
|
-
hints: [],
|
|
1354
|
-
statuses: []
|
|
1355
|
-
};
|
|
1356
|
-
}
|
|
1357
|
-
const hints = [];
|
|
1358
|
-
const statuses = [];
|
|
1359
|
-
for (const [flowKey, flowDef] of flowsMap.entries()) {
|
|
1360
|
-
for (const [stepKey, stepDef] of Object.entries((flowDef == null ? void 0 : flowDef.steps) || {})) {
|
|
1361
|
-
const resolved = this.resolveStepParamsSchema(stepDef, `${use}.${flowKey}.${stepKey}`);
|
|
1362
|
-
if ((_c = resolved.hints) == null ? void 0 : _c.length) {
|
|
1363
|
-
hints.push(...resolved.hints);
|
|
1364
|
-
}
|
|
1365
|
-
statuses.push(resolved.coverage);
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1368
|
-
return {
|
|
1369
|
-
hints: (0, import_utils.normalizeSchemaHints)(hints),
|
|
1370
|
-
statuses
|
|
1371
|
-
};
|
|
1372
|
-
}
|
|
1373
|
-
buildDocumentCoverage(base, stepStatuses) {
|
|
1374
|
-
const statuses = new Set([base.status, ...stepStatuses].filter(Boolean));
|
|
1375
|
-
let status = base.status;
|
|
1376
|
-
if (statuses.size > 1) {
|
|
1377
|
-
statuses.delete("unresolved");
|
|
1378
|
-
if (statuses.size === 0) {
|
|
1379
|
-
status = "unresolved";
|
|
1380
|
-
} else {
|
|
1381
|
-
status = "mixed";
|
|
1382
|
-
}
|
|
1383
|
-
} else if (statuses.size === 1) {
|
|
1384
|
-
status = Array.from(statuses)[0] || "unresolved";
|
|
1385
|
-
}
|
|
1386
|
-
return {
|
|
1387
|
-
...base,
|
|
1388
|
-
status
|
|
1389
|
-
};
|
|
1390
|
-
}
|
|
1391
|
-
inferSubModelSlotsFromModelClass(use, modelClass) {
|
|
1392
|
-
const meta = (modelClass.meta || {}).schema;
|
|
1393
|
-
if (meta == null ? void 0 : meta.subModelSlots) {
|
|
1394
|
-
return import_lodash.default.cloneDeep(meta.subModelSlots);
|
|
1395
|
-
}
|
|
1396
|
-
const createModelOptions = (modelClass.meta || {}).createModelOptions;
|
|
1397
|
-
if (!import_lodash.default.isPlainObject(createModelOptions) || !import_lodash.default.isPlainObject(createModelOptions.subModels)) {
|
|
1398
|
-
return {};
|
|
1399
|
-
}
|
|
1400
|
-
const slots = {};
|
|
1401
|
-
for (const [slotKey, slotValue] of Object.entries(createModelOptions.subModels || {})) {
|
|
1402
|
-
if (Array.isArray(slotValue)) {
|
|
1403
|
-
const first = slotValue[0];
|
|
1404
|
-
slots[slotKey] = {
|
|
1405
|
-
type: "array",
|
|
1406
|
-
...typeof (first == null ? void 0 : first.use) === "string" ? { use: first.use } : {}
|
|
1407
|
-
};
|
|
1408
|
-
} else if (import_lodash.default.isPlainObject(slotValue)) {
|
|
1409
|
-
slots[slotKey] = {
|
|
1410
|
-
type: "object",
|
|
1411
|
-
...slotValue.use ? { use: slotValue.use } : {}
|
|
1412
|
-
};
|
|
1413
|
-
} else {
|
|
1414
|
-
slots[slotKey] = {
|
|
1415
|
-
type: "object"
|
|
1416
|
-
};
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
return slots;
|
|
1420
|
-
}
|
|
1421
|
-
};
|
|
1422
|
-
__name(_FlowSchemaRegistry, "FlowSchemaRegistry");
|
|
1423
|
-
let FlowSchemaRegistry = _FlowSchemaRegistry;
|
|
1424
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
1425
|
-
0 && (module.exports = {
|
|
1426
|
-
FlowSchemaRegistry
|
|
1427
|
-
});
|