@nocobase/flow-engine 2.1.0-beta.14 → 2.1.0-beta.16
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/components/FlowModelRenderer.js +10 -6
- package/lib/components/MobilePopup.js +6 -5
- package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.js +13 -5
- package/lib/components/subModel/AddSubModelButton.js +1 -1
- package/lib/components/subModel/utils.js +2 -2
- package/lib/flowEngine.d.ts +132 -1
- package/lib/flowEngine.js +360 -14
- package/lib/flowSettings.d.ts +14 -6
- package/lib/flowSettings.js +34 -6
- package/lib/lazy-helper.d.ts +14 -0
- package/lib/lazy-helper.js +71 -0
- package/lib/models/flowModel.d.ts +2 -1
- package/lib/models/flowModel.js +28 -9
- package/lib/types.d.ts +46 -0
- package/lib/utils/runjsTemplateCompat.js +1 -1
- package/package.json +4 -4
- package/src/__tests__/flow-engine.test.ts +166 -0
- package/src/__tests__/flowEngine.modelLoaders.test.ts +245 -0
- package/src/__tests__/flowSettings.test.ts +94 -15
- package/src/__tests__/renderHiddenInConfig.test.tsx +6 -6
- package/src/__tests__/viewScopedFlowEngine.test.ts +3 -3
- package/src/components/FlowModelRenderer.tsx +9 -5
- package/src/components/MobilePopup.tsx +4 -2
- package/src/components/__tests__/FlowModelRenderer.test.tsx +65 -2
- package/src/components/__tests__/flow-model-render-error-fallback.test.tsx +3 -3
- package/src/components/settings/wrappers/contextual/FlowsFloatContextMenu.tsx +15 -4
- package/src/components/settings/wrappers/contextual/__tests__/FlowsFloatContextMenu.test.tsx +67 -5
- package/src/components/subModel/AddSubModelButton.tsx +1 -1
- package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +93 -33
- package/src/components/subModel/utils.ts +1 -1
- package/src/flowEngine.ts +412 -10
- package/src/flowSettings.ts +40 -6
- package/src/lazy-helper.tsx +57 -0
- package/src/models/flowModel.tsx +31 -10
- package/src/types.ts +59 -0
- package/src/utils/runjsTemplateCompat.ts +1 -1
|
@@ -61,11 +61,12 @@ const FlowModelRendererWithAutoFlows = (0, import_reactive.observer)(
|
|
|
61
61
|
showErrorFallback,
|
|
62
62
|
settingsMenuLevel,
|
|
63
63
|
extraToolbarItems,
|
|
64
|
-
fallback
|
|
64
|
+
fallback,
|
|
65
|
+
useCache
|
|
65
66
|
}) => {
|
|
66
67
|
const { loading: pending, error: autoFlowsError } = (0, import_hooks.useApplyAutoFlows)(model, inputArgs, {
|
|
67
68
|
throwOnError: false,
|
|
68
|
-
useCache
|
|
69
|
+
useCache
|
|
69
70
|
});
|
|
70
71
|
(0, import_utils.setAutoFlowError)(model, autoFlowsError || null);
|
|
71
72
|
if (pending) {
|
|
@@ -195,13 +196,15 @@ const FlowModelRenderer = (0, import_reactive.observer)(
|
|
|
195
196
|
extraToolbarItems,
|
|
196
197
|
useCache
|
|
197
198
|
}) => {
|
|
199
|
+
var _a;
|
|
200
|
+
const resolvedUseCache = typeof useCache === "boolean" ? useCache : (_a = model == null ? void 0 : model.context) == null ? void 0 : _a.useCache;
|
|
198
201
|
(0, import_react.useEffect)(() => {
|
|
199
|
-
if (model == null ? void 0 : model.context) {
|
|
202
|
+
if ((model == null ? void 0 : model.context) && typeof resolvedUseCache !== "undefined") {
|
|
200
203
|
model.context.defineProperty("useCache", {
|
|
201
|
-
value:
|
|
204
|
+
value: resolvedUseCache
|
|
202
205
|
});
|
|
203
206
|
}
|
|
204
|
-
}, [model == null ? void 0 : model.context,
|
|
207
|
+
}, [model == null ? void 0 : model.context, resolvedUseCache]);
|
|
205
208
|
if (!model || typeof model.render !== "function") {
|
|
206
209
|
console.warn("FlowModelRenderer: Invalid model or render method not found.", model);
|
|
207
210
|
return null;
|
|
@@ -218,7 +221,8 @@ const FlowModelRenderer = (0, import_reactive.observer)(
|
|
|
218
221
|
showErrorFallback,
|
|
219
222
|
settingsMenuLevel,
|
|
220
223
|
extraToolbarItems,
|
|
221
|
-
fallback
|
|
224
|
+
fallback,
|
|
225
|
+
useCache: resolvedUseCache
|
|
222
226
|
}
|
|
223
227
|
);
|
|
224
228
|
if (showErrorFallback) {
|
|
@@ -41,11 +41,12 @@ __export(MobilePopup_exports, {
|
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(MobilePopup_exports);
|
|
43
43
|
var import_antd = require("antd");
|
|
44
|
-
var import_antd_mobile = require("antd-mobile");
|
|
45
44
|
var import_react = __toESM(require("react"));
|
|
46
|
-
var import_antd_mobile_icons = require("antd-mobile-icons");
|
|
47
45
|
var import_MobilePopup = require("./MobilePopup.style");
|
|
48
46
|
var import_react_i18next = require("react-i18next");
|
|
47
|
+
var import_lazy_helper = require("../lazy-helper");
|
|
48
|
+
const { Popup } = (0, import_lazy_helper.lazy)(() => import("antd-mobile"), "Popup");
|
|
49
|
+
const { CloseOutline } = (0, import_lazy_helper.lazy)(() => import("antd-mobile-icons"), "CloseOutline");
|
|
49
50
|
const MobilePopup = /* @__PURE__ */ __name((props) => {
|
|
50
51
|
const { title, visible, onClose: closePopup, children, minHeight, className, footer } = props;
|
|
51
52
|
const { t } = (0, import_react_i18next.useTranslation)();
|
|
@@ -67,7 +68,7 @@ const MobilePopup = /* @__PURE__ */ __name((props) => {
|
|
|
67
68
|
};
|
|
68
69
|
}, []);
|
|
69
70
|
return /* @__PURE__ */ import_react.default.createElement(import_antd.ConfigProvider, { theme }, /* @__PURE__ */ import_react.default.createElement(
|
|
70
|
-
|
|
71
|
+
Popup,
|
|
71
72
|
{
|
|
72
73
|
className: `${componentCls} ${hashId} ${className || ""}`,
|
|
73
74
|
visible,
|
|
@@ -81,7 +82,7 @@ const MobilePopup = /* @__PURE__ */ __name((props) => {
|
|
|
81
82
|
style,
|
|
82
83
|
destroyOnClose: true
|
|
83
84
|
},
|
|
84
|
-
/* @__PURE__ */ import_react.default.createElement("div", { className: "nb-mobile-action-drawer-header" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "nb-mobile-action-drawer-placeholder" }, /* @__PURE__ */ import_react.default.createElement(
|
|
85
|
+
/* @__PURE__ */ import_react.default.createElement("div", { className: "nb-mobile-action-drawer-header" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "nb-mobile-action-drawer-placeholder" }, /* @__PURE__ */ import_react.default.createElement(CloseOutline, null)), /* @__PURE__ */ import_react.default.createElement("span", null, title), /* @__PURE__ */ import_react.default.createElement(
|
|
85
86
|
"span",
|
|
86
87
|
{
|
|
87
88
|
className: "nb-mobile-action-drawer-close-icon",
|
|
@@ -90,7 +91,7 @@ const MobilePopup = /* @__PURE__ */ __name((props) => {
|
|
|
90
91
|
tabIndex: 0,
|
|
91
92
|
"aria-label": t("Close")
|
|
92
93
|
},
|
|
93
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
94
|
+
/* @__PURE__ */ import_react.default.createElement(CloseOutline, null)
|
|
94
95
|
)),
|
|
95
96
|
children,
|
|
96
97
|
footer && /* @__PURE__ */ import_react.default.createElement("div", { className: "nb-mobile-action-drawer-footer" }, footer)
|
|
@@ -52,6 +52,13 @@ var import_reactive = require("../../../../reactive");
|
|
|
52
52
|
var import_useFloatToolbarPortal = require("./useFloatToolbarPortal");
|
|
53
53
|
var import_useFloatToolbarVisibility = require("./useFloatToolbarVisibility");
|
|
54
54
|
const TOOLBAR_Z_INDEX = 999;
|
|
55
|
+
const getFloatMenuInstanceId = /* @__PURE__ */ __name((model) => {
|
|
56
|
+
if (!model) {
|
|
57
|
+
return "";
|
|
58
|
+
}
|
|
59
|
+
const forkId = (model == null ? void 0 : model.isFork) ? model == null ? void 0 : model.forkId : void 0;
|
|
60
|
+
return forkId == null || forkId === "" ? String(model.uid || "") : `${String(model.uid || "")}::${String(forkId)}`;
|
|
61
|
+
}, "getFloatMenuInstanceId");
|
|
55
62
|
const hostContainerStyles = import_css.css`
|
|
56
63
|
position: relative;
|
|
57
64
|
|
|
@@ -247,7 +254,7 @@ const detectButtonInDOM = /* @__PURE__ */ __name((container) => {
|
|
|
247
254
|
}
|
|
248
255
|
return false;
|
|
249
256
|
}, "detectButtonInDOM");
|
|
250
|
-
const renderToolbarItems = /* @__PURE__ */ __name((model, showDeleteButton, showCopyUidButton, flowEngine, settingsMenuLevel, extraToolbarItems, onSettingsMenuOpenChange, getPopupContainer) => {
|
|
257
|
+
const renderToolbarItems = /* @__PURE__ */ __name((model, modelInstanceId, showDeleteButton, showCopyUidButton, flowEngine, settingsMenuLevel, extraToolbarItems, onSettingsMenuOpenChange, getPopupContainer) => {
|
|
251
258
|
var _a, _b;
|
|
252
259
|
const toolbarItems = ((_b = (_a = flowEngine == null ? void 0 : flowEngine.flowSettings) == null ? void 0 : _a.getToolbarItems) == null ? void 0 : _b.call(_a)) || [];
|
|
253
260
|
const allToolbarItems = [...toolbarItems, ...extraToolbarItems || []];
|
|
@@ -262,7 +269,7 @@ const renderToolbarItems = /* @__PURE__ */ __name((model, showDeleteButton, show
|
|
|
262
269
|
{
|
|
263
270
|
key: itemConfig.key,
|
|
264
271
|
model,
|
|
265
|
-
id:
|
|
272
|
+
id: modelInstanceId,
|
|
266
273
|
showDeleteButton,
|
|
267
274
|
showCopyUidButton,
|
|
268
275
|
menuLevels: settingsMenuLevel,
|
|
@@ -397,7 +404,7 @@ const FlowsFloatContextMenuWithModel = (0, import_reactive.observer)(
|
|
|
397
404
|
schedulePortalRectUpdate: /* @__PURE__ */ __name(() => {
|
|
398
405
|
}, "schedulePortalRectUpdate")
|
|
399
406
|
});
|
|
400
|
-
const modelUid = (model
|
|
407
|
+
const modelUid = getFloatMenuInstanceId(model);
|
|
401
408
|
const flowEngine = (0, import_provider.useFlowEngine)();
|
|
402
409
|
const updatePortalRectProxy = (0, import_react.useCallback)(() => {
|
|
403
410
|
portalActionsRef.current.updatePortalRect();
|
|
@@ -434,6 +441,7 @@ const FlowsFloatContextMenuWithModel = (0, import_reactive.observer)(
|
|
|
434
441
|
const toolbarItems = (0, import_react.useMemo)(
|
|
435
442
|
() => model ? renderToolbarItems(
|
|
436
443
|
model,
|
|
444
|
+
modelUid,
|
|
437
445
|
showDeleteButton,
|
|
438
446
|
showCopyUidButton,
|
|
439
447
|
flowEngine,
|
|
@@ -495,7 +503,7 @@ const FlowsFloatContextMenuWithModel = (0, import_reactive.observer)(
|
|
|
495
503
|
ref: toolbarContainerRef,
|
|
496
504
|
className: `nb-toolbar-container ${toolbarContainerClassName}`,
|
|
497
505
|
style: toolbarContainerStyle,
|
|
498
|
-
"data-model-uid":
|
|
506
|
+
"data-model-uid": modelUid
|
|
499
507
|
},
|
|
500
508
|
showTitle && (model.title || model.extraTitle) && /* @__PURE__ */ import_react.default.createElement("div", { className: "nb-toolbar-container-title" }, model.title && /* @__PURE__ */ import_react.default.createElement("span", { className: "title-tag" }, model.title), model.extraTitle && /* @__PURE__ */ import_react.default.createElement("span", { className: "title-tag" }, model.extraTitle)),
|
|
501
509
|
/* @__PURE__ */ import_react.default.createElement(
|
|
@@ -528,7 +536,7 @@ const FlowsFloatContextMenuWithModel = (0, import_reactive.observer)(
|
|
|
528
536
|
className: `${hostContainerStyles} ${hasButton ? "has-button-child" : ""} ${className || ""}`,
|
|
529
537
|
style: containerStyle,
|
|
530
538
|
"data-has-float-menu": "true",
|
|
531
|
-
"data-float-menu-model-uid":
|
|
539
|
+
"data-float-menu-model-uid": modelUid,
|
|
532
540
|
onMouseMove: handleChildHover,
|
|
533
541
|
onMouseEnter: handleHostMouseEnter,
|
|
534
542
|
onMouseLeave: handleHostMouseLeave
|
|
@@ -430,7 +430,7 @@ const AddSubModelButtonCore = /* @__PURE__ */ __name(function AddSubModelButton(
|
|
|
430
430
|
}
|
|
431
431
|
let addedModel;
|
|
432
432
|
try {
|
|
433
|
-
addedModel = model.flowEngine.
|
|
433
|
+
addedModel = await model.flowEngine.createModelAsync({
|
|
434
434
|
...import_lodash.default.cloneDeep(createOpts),
|
|
435
435
|
parentId: model.uid,
|
|
436
436
|
subKey: subModelKey,
|
|
@@ -44,7 +44,7 @@ __export(utils_exports, {
|
|
|
44
44
|
buildWrapperFieldChildren: () => buildWrapperFieldChildren
|
|
45
45
|
});
|
|
46
46
|
module.exports = __toCommonJS(utils_exports);
|
|
47
|
-
var
|
|
47
|
+
var import_lodash = __toESM(require("lodash"));
|
|
48
48
|
var import_utils = require("../../utils");
|
|
49
49
|
async function callHideFunction(hide, ctx) {
|
|
50
50
|
if (typeof hide === "function") {
|
|
@@ -107,7 +107,7 @@ function buildSubModelChildren(M, ctx) {
|
|
|
107
107
|
const extraArg = args && args.length > 0 ? args[args.length - 1] : void 0;
|
|
108
108
|
const defaultOpts = await (0, import_utils.resolveCreateModelOptions)(meta == null ? void 0 : meta.createModelOptions, ctx, extraArg);
|
|
109
109
|
const childOpts = await (0, import_utils.resolveCreateModelOptions)(src, ctx, extraArg);
|
|
110
|
-
return
|
|
110
|
+
return import_lodash.default.merge({}, import_lodash.default.cloneDeep(defaultOpts), childOpts);
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
return node;
|
package/lib/flowEngine.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { FlowResource } from './resources';
|
|
|
8
8
|
import { Emitter } from './emitter';
|
|
9
9
|
import ModelOperationScheduler from './scheduler/ModelOperationScheduler';
|
|
10
10
|
import type { ScheduleOptions, ScheduledCancel } from './scheduler/ModelOperationScheduler';
|
|
11
|
-
import type { ActionDefinition, ApplyFlowCacheEntry, CreateModelOptions, EventDefinition, FlowModelOptions, IFlowModelRepository, ModelConstructor, PersistOptions, ResourceType } from './types';
|
|
11
|
+
import type { ActionDefinition, ApplyFlowCacheEntry, CreateModelOptions, EnsureBatchResult, EventDefinition, FlowModelLoaderInputMap, FlowModelOptions, IFlowModelRepository, ModelConstructor, PersistOptions, ResourceType } from './types';
|
|
12
12
|
/**
|
|
13
13
|
* FlowEngine is the core class of the flow engine, responsible for managing flow models, actions, model repository, and more.
|
|
14
14
|
* It provides capabilities for registering, creating, finding, persisting, replacing, and moving models.
|
|
@@ -47,6 +47,28 @@ export declare class FlowEngine {
|
|
|
47
47
|
* @private
|
|
48
48
|
*/
|
|
49
49
|
private _modelClasses;
|
|
50
|
+
/**
|
|
51
|
+
* Registered model entries.
|
|
52
|
+
* Key is the model class name, value is the model loader entry.
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
55
|
+
private _modelLoaders;
|
|
56
|
+
/**
|
|
57
|
+
* In-flight model loading promises.
|
|
58
|
+
* Key is the model class name, value is the loading promise.
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
private _loadingModelPromises;
|
|
62
|
+
/**
|
|
63
|
+
* Whether model-loader preload has completed in this session.
|
|
64
|
+
* @private
|
|
65
|
+
*/
|
|
66
|
+
private _modelLoadersPreloaded;
|
|
67
|
+
/**
|
|
68
|
+
* In-flight model-loader preload promise.
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
private _modelLoadersPreloadPromise?;
|
|
50
72
|
/**
|
|
51
73
|
* Created model instances.
|
|
52
74
|
* Key is the model instance UID, value is the model instance object.
|
|
@@ -226,6 +248,10 @@ export declare class FlowEngine {
|
|
|
226
248
|
* Get all registered global events.
|
|
227
249
|
*/
|
|
228
250
|
getEvents<TModel extends FlowModel = FlowModel>(): Map<string, EventDefinition<TModel>>;
|
|
251
|
+
/**
|
|
252
|
+
* for proxy instance, the #registerModel can't be called.
|
|
253
|
+
*/
|
|
254
|
+
private _registerModel;
|
|
229
255
|
/**
|
|
230
256
|
* Register multiple model classes.
|
|
231
257
|
* @param {Record<string, ModelConstructor>} models Model class map, key is model name, value is model constructor
|
|
@@ -234,6 +260,102 @@ export declare class FlowEngine {
|
|
|
234
260
|
* flowEngine.registerModels({ UserModel, OrderModel });
|
|
235
261
|
*/
|
|
236
262
|
registerModels(models: Record<string, ModelConstructor | typeof FlowModel<any>>): void;
|
|
263
|
+
/**
|
|
264
|
+
* Register multiple model loader entries.
|
|
265
|
+
* The `extends` field declares parent class(es) for async subclass discovery via `getSubclassesOfAsync`.
|
|
266
|
+
* It accepts `string | ModelConstructor | (string | ModelConstructor)[]` and is normalized to `string[]` internally.
|
|
267
|
+
* @param {FlowModelLoaderInputMap} loaders Model loader input map
|
|
268
|
+
* @returns {void}
|
|
269
|
+
* @example
|
|
270
|
+
* flowEngine.registerModelLoaders({
|
|
271
|
+
* DemoModel: {
|
|
272
|
+
* extends: 'BaseModel',
|
|
273
|
+
* loader: () => import('./models/DemoModel'),
|
|
274
|
+
* },
|
|
275
|
+
* });
|
|
276
|
+
*/
|
|
277
|
+
registerModelLoaders(loaders: FlowModelLoaderInputMap): void;
|
|
278
|
+
/**
|
|
279
|
+
* Get a registered model class (constructor) asynchronously.
|
|
280
|
+
* This will first ensure the model loader entry is resolved.
|
|
281
|
+
* @param {string} name Model class name
|
|
282
|
+
* @returns {Promise<ModelConstructor | undefined>} Model constructor, or undefined if not found
|
|
283
|
+
*/
|
|
284
|
+
getModelClassAsync(name: string): Promise<ModelConstructor | undefined>;
|
|
285
|
+
/**
|
|
286
|
+
* Get all registered model classes asynchronously.
|
|
287
|
+
* This will first ensure all registered model loader entries are resolved.
|
|
288
|
+
* @returns {Promise<Map<string, ModelConstructor>>} Model class map
|
|
289
|
+
*/
|
|
290
|
+
getModelClassesAsync(): Promise<Map<string, ModelConstructor>>;
|
|
291
|
+
/**
|
|
292
|
+
* Create and register a model instance asynchronously.
|
|
293
|
+
* This will first ensure all string-based model references in the model tree are resolved.
|
|
294
|
+
* @template T FlowModel subclass type, defaults to FlowModel.
|
|
295
|
+
* @param {CreateModelOptions} options Model creation options
|
|
296
|
+
* @returns {Promise<T>} Created model instance
|
|
297
|
+
*/
|
|
298
|
+
createModelAsync<T extends FlowModel = FlowModel>(options: CreateModelOptions, extra?: {
|
|
299
|
+
delegateToParent?: boolean;
|
|
300
|
+
delegate?: FlowContext;
|
|
301
|
+
}): Promise<T>;
|
|
302
|
+
/**
|
|
303
|
+
* Normalize a loader result into a model constructor.
|
|
304
|
+
* @param {string} name Model class name
|
|
305
|
+
* @param {FlowModelLoaderResult} loaded Loader result
|
|
306
|
+
* @returns {ModelConstructor | null} Normalized model constructor
|
|
307
|
+
* @private
|
|
308
|
+
*/
|
|
309
|
+
private normalizeModelLoaderResult;
|
|
310
|
+
/**
|
|
311
|
+
* Collect string-based model names from a model tree.
|
|
312
|
+
* @param {unknown} data Model tree data
|
|
313
|
+
* @param {Set<string>} names Model name set
|
|
314
|
+
* @private
|
|
315
|
+
*/
|
|
316
|
+
private collectModelNamesFromTree;
|
|
317
|
+
/**
|
|
318
|
+
* Collect additional model names from object-form meta.createModelOptions defaults.
|
|
319
|
+
* @param {ModelConstructor} modelClass Model class constructor
|
|
320
|
+
* @param {Set<string>} names Model name set
|
|
321
|
+
* @private
|
|
322
|
+
*/
|
|
323
|
+
private collectModelNamesFromMetaDefaults;
|
|
324
|
+
/**
|
|
325
|
+
* Ensure a single model class is available.
|
|
326
|
+
* @param {string} name Model class name
|
|
327
|
+
* @returns {Promise<ModelConstructor | null>} Model constructor or null when resolution fails
|
|
328
|
+
* @private
|
|
329
|
+
*/
|
|
330
|
+
private ensureModel;
|
|
331
|
+
/**
|
|
332
|
+
* Ensure multiple model classes are available.
|
|
333
|
+
* @param {string[]} names Model class names
|
|
334
|
+
* @returns {Promise<EnsureBatchResult>} Batch ensure result
|
|
335
|
+
* @private
|
|
336
|
+
*/
|
|
337
|
+
private ensureModels;
|
|
338
|
+
/**
|
|
339
|
+
* Resolve all unresolved string-based model references in a model tree before synchronous creation begins.
|
|
340
|
+
*
|
|
341
|
+
* Use this when you already have a model tree object, such as repository-returned data or resolved
|
|
342
|
+
* `createModelOptions`, and you need to ensure every string `use` in that tree has been loaded and
|
|
343
|
+
* registered into `_modelClasses` before calling `createModel()`.
|
|
344
|
+
*
|
|
345
|
+
* @param {unknown} data Model tree data
|
|
346
|
+
* @returns {Promise<EnsureBatchResult>} Batch ensure result
|
|
347
|
+
*/
|
|
348
|
+
resolveModelTree(data: unknown): Promise<EnsureBatchResult>;
|
|
349
|
+
/**
|
|
350
|
+
* Preload all currently registered unresolved model loaders.
|
|
351
|
+
*
|
|
352
|
+
* This method is intended for flow-settings/discovery style entry points that need registered model
|
|
353
|
+
* classes to exist before UI is rendered, without requiring callers to know which specific models
|
|
354
|
+
* will be touched next.
|
|
355
|
+
*
|
|
356
|
+
* @returns {Promise<EnsureBatchResult>} Batch ensure result
|
|
357
|
+
*/
|
|
358
|
+
preloadModelLoaders(): Promise<EnsureBatchResult>;
|
|
237
359
|
registerResources(resources: Record<string, any>): void;
|
|
238
360
|
createResource<T = FlowResource>(resourceType: ResourceType<T>, options?: {
|
|
239
361
|
context?: FlowContext;
|
|
@@ -262,6 +384,15 @@ export declare class FlowEngine {
|
|
|
262
384
|
* @returns {Map<string, ModelConstructor>} Model classes inherited from base class and passed the filter
|
|
263
385
|
*/
|
|
264
386
|
getSubclassesOf(baseClass: string | ModelConstructor, filter?: (ModelClass: ModelConstructor, className: string) => boolean): Map<string, ModelConstructor>;
|
|
387
|
+
/**
|
|
388
|
+
* Asynchronously get all subclasses of a base class, including those registered via model loaders.
|
|
389
|
+
* Merges results from already-loaded classes (_modelClasses) and async loader entries with matching `extends` declarations.
|
|
390
|
+
* Loader-resolved classes are validated with `isInheritedFrom`; mismatches are warned and excluded.
|
|
391
|
+
* @param {string | ModelConstructor} baseClass Base class name or constructor
|
|
392
|
+
* @param {(ModelClass: ModelConstructor, className: string) => boolean} [filter] Optional filter function
|
|
393
|
+
* @returns {Promise<Map<string, ModelConstructor>>} Model classes that are subclasses of the base class
|
|
394
|
+
*/
|
|
395
|
+
getSubclassesOfAsync(baseClass: string | ModelConstructor, filter?: (ModelClass: ModelConstructor, className: string) => boolean): Promise<Map<string, ModelConstructor>>;
|
|
265
396
|
/**
|
|
266
397
|
* Create and register a model instance.
|
|
267
398
|
* If an instance with the same UID exists, returns the existing instance.
|