@nocobase/flow-engine 2.0.22 → 2.1.0-alpha.10

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/src/types.ts CHANGED
@@ -388,6 +388,53 @@ export interface CreateModelOptions {
388
388
  delegateToParent?: boolean;
389
389
  [key: string]: any; // 允许额外的自定义选项
390
390
  }
391
+
392
+ /**
393
+ * FlowModel loader result.
394
+ * Supports returning the model constructor directly, a default export, or a module object containing the named export.
395
+ */
396
+ export type FlowModelLoaderResult =
397
+ | ModelConstructor
398
+ | {
399
+ default?: ModelConstructor;
400
+ [key: string]: unknown;
401
+ }
402
+ | Record<string, unknown>;
403
+
404
+ /**
405
+ * FlowModel loader function.
406
+ */
407
+ export type FlowModelLoader = () => Promise<FlowModelLoaderResult>;
408
+
409
+ /**
410
+ * FlowModel loader entry.
411
+ * Future contribution-style fields are intentionally kept as commented placeholders in phase A
412
+ * and are not consumed by current runtime logic.
413
+ */
414
+ export interface FlowModelLoaderEntry {
415
+ loader: FlowModelLoader;
416
+ // extends?: string;
417
+ // meta?: Partial<FlowModelMeta>;
418
+ // scenes?: string[];
419
+ }
420
+
421
+ /**
422
+ * FlowModel loader entry map.
423
+ */
424
+ export type FlowModelLoaderMap = Record<string, FlowModelLoaderEntry>;
425
+
426
+ /**
427
+ * Batch ensure result.
428
+ */
429
+ export interface EnsureBatchResult {
430
+ requested: string[];
431
+ loaded: string[];
432
+ failed: Array<{
433
+ name: string;
434
+ error?: unknown;
435
+ }>;
436
+ }
437
+
391
438
  export interface IFlowModelRepository<T extends FlowModel = FlowModel> {
392
439
  findOne(query: Record<string, any>): Promise<Record<string, any> | null>;
393
440
  save(model: T, options?: { onlyStepParams?: boolean }): Promise<Record<string, any>>;
@@ -553,8 +553,8 @@ function extractUsedCtxLibKeys(code: string): string[] {
553
553
  }
554
554
 
555
555
  function injectEnsureLibsPreamble(code: string): string {
556
- if (!CTX_LIBS_MARKER_RE.test(code)) return code;
557
556
  if (ENSURE_LIBS_MARKER_RE.test(code)) return code;
557
+ if (!CTX_LIBS_MARKER_RE.test(code)) return code;
558
558
  const keys = extractUsedCtxLibKeys(code);
559
559
  if (!keys.length) return code;
560
560
  return `/* __runjs_ensure_libs */\nawait ctx.__ensureLibs(${JSON.stringify(keys)});\n${code}`;