moost 0.6.44 → 0.6.45
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/dist/index.cjs +61 -16
- package/dist/index.d.ts +47 -3
- package/dist/index.mjs +61 -16
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -48,7 +48,7 @@ let stamped = false;
|
|
|
48
48
|
if (stamped) return;
|
|
49
49
|
stamped = true;
|
|
50
50
|
stampModuleIdentity({
|
|
51
|
-
version: "0.6.
|
|
51
|
+
version: "0.6.45",
|
|
52
52
|
path: typeof __filename === "string" ? __filename : require("url").pathToFileURL(__filename).href
|
|
53
53
|
});
|
|
54
54
|
}
|
|
@@ -2457,15 +2457,8 @@ function _define_property(obj, key, value) {
|
|
|
2457
2457
|
if (fatal.length > 0 && this.paramAuditMode === "error") return formatParamAuditError(fatal);
|
|
2458
2458
|
}
|
|
2459
2459
|
async bindControllers() {
|
|
2460
|
-
const
|
|
2461
|
-
const
|
|
2462
|
-
...thisMeta?.provide,
|
|
2463
|
-
...this.provide
|
|
2464
|
-
};
|
|
2465
|
-
const replace = {
|
|
2466
|
-
...thisMeta?.replace,
|
|
2467
|
-
...this.replace
|
|
2468
|
-
};
|
|
2460
|
+
const provide = this.appProvideRegistry();
|
|
2461
|
+
const replace = this.appReplaceRegistry();
|
|
2469
2462
|
const globalPrefix = this.options?.globalPrefix || "";
|
|
2470
2463
|
for (const { controller, prependPrefix, replaceOwnPrefix } of this.unregisteredControllers) await this.bindController(controller, provide, replace, prependPrefix ? `${globalPrefix}/${prependPrefix}` : globalPrefix, replaceOwnPrefix);
|
|
2471
2464
|
this.unregisteredControllers = [];
|
|
@@ -2523,7 +2516,7 @@ function _define_property(obj, key, value) {
|
|
|
2523
2516
|
...classMeta.provide
|
|
2524
2517
|
};
|
|
2525
2518
|
const mergedReplace = {
|
|
2526
|
-
...this.
|
|
2519
|
+
...this.appReplaceRegistry(),
|
|
2527
2520
|
...classMeta.replace
|
|
2528
2521
|
};
|
|
2529
2522
|
for (const ic of classMeta.importController) if (ic.typeResolver) {
|
|
@@ -2590,10 +2583,17 @@ function _define_property(obj, key, value) {
|
|
|
2590
2583
|
* controller — it flows parent → child through `@ImportController`, never
|
|
2591
2584
|
* to siblings.
|
|
2592
2585
|
* @param provide - Provide Registry (use createProvideRegistry from '\@prostojs/infact')
|
|
2586
|
+
* @param opts - `{ override: false }` registers a default: used only when neither `@Provide`
|
|
2587
|
+
* on the app subclass nor a normal `setProvideRegistry` entry exists for the token,
|
|
2588
|
+
* regardless of call order. @since 0.6.45
|
|
2593
2589
|
* @returns
|
|
2594
|
-
*/ setProvideRegistry(provide) {
|
|
2590
|
+
*/ setProvideRegistry(provide, opts) {
|
|
2595
2591
|
if (this.initialized) this.logger.warn("[moost] setProvideRegistry() called after init() — already-bound controllers will not see these providers. Register providers before init(), or provide them via @Provide on a parent controller.");
|
|
2596
|
-
this.
|
|
2592
|
+
if (opts?.override === false) this.defaultProvide = {
|
|
2593
|
+
...this.defaultProvide,
|
|
2594
|
+
...provide
|
|
2595
|
+
};
|
|
2596
|
+
else this.provide = {
|
|
2597
2597
|
...this.provide,
|
|
2598
2598
|
...provide
|
|
2599
2599
|
};
|
|
@@ -2606,16 +2606,61 @@ function _define_property(obj, key, value) {
|
|
|
2606
2606
|
* replace registry once when binding controllers, so replacements added
|
|
2607
2607
|
* later are never seen by already-bound controllers.
|
|
2608
2608
|
* @param replace - Replace Registry (use createReplaceRegistry from '\@prostojs/infact')
|
|
2609
|
+
* @param opts - `{ override: false }` registers a default: used only when neither `@Replace`
|
|
2610
|
+
* on the app subclass nor a normal `setReplaceRegistry` entry exists for the class,
|
|
2611
|
+
* regardless of call order. @since 0.6.45
|
|
2609
2612
|
* @returns
|
|
2610
|
-
*/ setReplaceRegistry(replace) {
|
|
2613
|
+
*/ setReplaceRegistry(replace, opts) {
|
|
2611
2614
|
if (this.initialized) this.logger.warn("[moost] setReplaceRegistry() called after init() — already-bound controllers will not see these replacements. Register replacements before init().");
|
|
2612
|
-
this.
|
|
2615
|
+
if (opts?.override === false) this.defaultReplace = {
|
|
2616
|
+
...this.defaultReplace,
|
|
2617
|
+
...replace
|
|
2618
|
+
};
|
|
2619
|
+
else this.replace = {
|
|
2613
2620
|
...this.replace,
|
|
2614
2621
|
...replace
|
|
2615
2622
|
};
|
|
2616
2623
|
return this;
|
|
2617
2624
|
}
|
|
2618
2625
|
/**
|
|
2626
|
+
* Effective app-level replace registry, lowest to highest precedence: defaults
|
|
2627
|
+
* (`override: false`), `@Replace` on the app subclass, `setReplaceRegistry()` entries.
|
|
2628
|
+
* A controller's own `@Replace` is NOT app-level (it only reaches that controller's direct imports).
|
|
2629
|
+
*/ appReplaceRegistry() {
|
|
2630
|
+
return {
|
|
2631
|
+
...this.defaultReplace,
|
|
2632
|
+
...getMoostMate().read(this)?.replace,
|
|
2633
|
+
...this.replace
|
|
2634
|
+
};
|
|
2635
|
+
}
|
|
2636
|
+
/** Effective app-level provide registry (same layering as `appReplaceRegistry`). */ appProvideRegistry() {
|
|
2637
|
+
return {
|
|
2638
|
+
...this.defaultProvide,
|
|
2639
|
+
...getMoostMate().read(this)?.provide,
|
|
2640
|
+
...this.provide
|
|
2641
|
+
};
|
|
2642
|
+
}
|
|
2643
|
+
/**
|
|
2644
|
+
* The class `type` is replaced with app-wide (one hop, like the DI container), or `undefined`.
|
|
2645
|
+
* Works before and after `init()`; never warns. Per-controller `@Replace` is not reported.
|
|
2646
|
+
* @since 0.6.45
|
|
2647
|
+
*/ getReplacement(type) {
|
|
2648
|
+
return this.appReplaceRegistry()[(0, _prostojs_infact.getClassKey)(type)];
|
|
2649
|
+
}
|
|
2650
|
+
/**
|
|
2651
|
+
* `getReplacement(type) !== undefined`.
|
|
2652
|
+
* @since 0.6.45
|
|
2653
|
+
*/ hasReplacement(type) {
|
|
2654
|
+
return this.getReplacement(type) !== void 0;
|
|
2655
|
+
}
|
|
2656
|
+
/**
|
|
2657
|
+
* Frozen shallow copy of the effective app-level replace registry
|
|
2658
|
+
* (keys are `getClassKey(Class)` symbols). Mutating it never affects the app.
|
|
2659
|
+
* @since 0.6.45
|
|
2660
|
+
*/ getReplaceRegistry() {
|
|
2661
|
+
return Object.freeze(this.appReplaceRegistry());
|
|
2662
|
+
}
|
|
2663
|
+
/**
|
|
2619
2664
|
* Register controllers with the app (similar to the `@ImportController` decorator).
|
|
2620
2665
|
*
|
|
2621
2666
|
* Accepted forms (mixable in one call):
|
|
@@ -2666,7 +2711,7 @@ function _define_property(obj, key, value) {
|
|
|
2666
2711
|
this.logger.info(`${prefix || ""}${c}${eventName} ${"\x1B[0m\x1B[2m\x1B[32m" + c}→ ${classConstructor.name}.${"\x1B[36m" + c}${method}[32m()${coff}`);
|
|
2667
2712
|
}
|
|
2668
2713
|
constructor(options) {
|
|
2669
|
-
super(), _define_property(this, "options", void 0), _define_property(this, "logger", void 0), _define_property(this, "pipes", void 0), _define_property(this, "interceptors", void 0), _define_property(this, "adapters", void 0), _define_property(this, "controllersOverview", void 0), _define_property(this, "handlerOverviewIndex", void 0), _define_property(this, "initHooks", void 0), _define_property(this, "provide", void 0), _define_property(this, "replace", void 0), _define_property(this, "unregisteredControllers", void 0), _define_property(this, "paramAuditFindings", void 0), _define_property(this, "paramAuditMode", void 0), _define_property(this, "inheritanceAuditMode", void 0), _define_property(this, "initialized", void 0), _define_property(this, "singletonInstances", void 0), _define_property(this, "disposePromise", void 0), _define_property(this, "globalInterceptorHandler", void 0), this.options = options, this.pipes = Array.from(sharedPipes), this.interceptors = [], this.adapters = [], this.controllersOverview = [], this.initHooks = [], this.provide = (0, _prostojs_infact.createProvideRegistry)([_prostojs_infact.Infact, getMoostInfact], [_prostojs_mate.Mate, getMoostMate]), this.replace = {}, this.unregisteredControllers = [], this.paramAuditFindings = [], this.initialized = false, this.singletonInstances = /* @__PURE__ */ new Set();
|
|
2714
|
+
super(), _define_property(this, "options", void 0), _define_property(this, "logger", void 0), _define_property(this, "pipes", void 0), _define_property(this, "interceptors", void 0), _define_property(this, "adapters", void 0), _define_property(this, "controllersOverview", void 0), _define_property(this, "handlerOverviewIndex", void 0), _define_property(this, "initHooks", void 0), _define_property(this, "provide", void 0), _define_property(this, "replace", void 0), _define_property(this, "defaultProvide", void 0), _define_property(this, "defaultReplace", void 0), _define_property(this, "unregisteredControllers", void 0), _define_property(this, "paramAuditFindings", void 0), _define_property(this, "paramAuditMode", void 0), _define_property(this, "inheritanceAuditMode", void 0), _define_property(this, "initialized", void 0), _define_property(this, "singletonInstances", void 0), _define_property(this, "disposePromise", void 0), _define_property(this, "globalInterceptorHandler", void 0), this.options = options, this.pipes = Array.from(sharedPipes), this.interceptors = [], this.adapters = [], this.controllersOverview = [], this.initHooks = [], this.provide = (0, _prostojs_infact.createProvideRegistry)([_prostojs_infact.Infact, getMoostInfact], [_prostojs_mate.Mate, getMoostMate]), this.replace = {}, this.defaultProvide = {}, this.defaultReplace = {}, this.unregisteredControllers = [], this.paramAuditFindings = [], this.initialized = false, this.singletonInstances = /* @__PURE__ */ new Set();
|
|
2670
2715
|
this.paramAuditMode = resolveParamAuditMode(options?.diagnostics?.paramTypes);
|
|
2671
2716
|
this.inheritanceAuditMode = options?.diagnostics?.inheritance || "warn";
|
|
2672
2717
|
this.logger = options?.logger || getDefaultLogger(`[2m[35mmoost`);
|
package/dist/index.d.ts
CHANGED
|
@@ -623,6 +623,16 @@ interface TControllerRegistration {
|
|
|
623
623
|
*/
|
|
624
624
|
prependPrefix?: string;
|
|
625
625
|
}
|
|
626
|
+
/** Options of `setProvideRegistry` / `setReplaceRegistry`. @since 0.6.45 */
|
|
627
|
+
interface TRegistryMergeOptions {
|
|
628
|
+
/**
|
|
629
|
+
* `true` (default): entries replace existing ones for the same token.
|
|
630
|
+
* `false`: register a lowest-precedence default, used only when neither the app subclass's
|
|
631
|
+
* class-level decorator nor a normal `set*Registry()` entry exists for the token — regardless
|
|
632
|
+
* of call order.
|
|
633
|
+
*/
|
|
634
|
+
override?: boolean;
|
|
635
|
+
}
|
|
626
636
|
/**
|
|
627
637
|
* ## Moost
|
|
628
638
|
* Main moostjs class that serves as a shell for Moost Adapters
|
|
@@ -684,6 +694,9 @@ declare class Moost extends Hookable {
|
|
|
684
694
|
protected initHooks: TInitHook[];
|
|
685
695
|
protected provide: TProvideRegistry;
|
|
686
696
|
protected replace: TReplaceRegistry;
|
|
697
|
+
/** Lowest-precedence layers, filled by `set*Registry(reg, { override: false })`. */
|
|
698
|
+
protected defaultProvide: TProvideRegistry;
|
|
699
|
+
protected defaultReplace: TReplaceRegistry;
|
|
687
700
|
protected unregisteredControllers: TControllerRegistration[];
|
|
688
701
|
/** D1 param-audit findings collected while binding controllers, flushed by `init()`. */
|
|
689
702
|
protected paramAuditFindings: TParamAuditFinding[];
|
|
@@ -833,9 +846,12 @@ declare class Moost extends Hookable {
|
|
|
833
846
|
* controller — it flows parent → child through `@ImportController`, never
|
|
834
847
|
* to siblings.
|
|
835
848
|
* @param provide - Provide Registry (use createProvideRegistry from '\@prostojs/infact')
|
|
849
|
+
* @param opts - `{ override: false }` registers a default: used only when neither `@Provide`
|
|
850
|
+
* on the app subclass nor a normal `setProvideRegistry` entry exists for the token,
|
|
851
|
+
* regardless of call order. @since 0.6.45
|
|
836
852
|
* @returns
|
|
837
853
|
*/
|
|
838
|
-
setProvideRegistry(provide: TProvideRegistry): this;
|
|
854
|
+
setProvideRegistry(provide: TProvideRegistry, opts?: TRegistryMergeOptions): this;
|
|
839
855
|
/**
|
|
840
856
|
* Register replace classes to provide as dependency injections
|
|
841
857
|
*
|
|
@@ -843,9 +859,37 @@ declare class Moost extends Hookable {
|
|
|
843
859
|
* replace registry once when binding controllers, so replacements added
|
|
844
860
|
* later are never seen by already-bound controllers.
|
|
845
861
|
* @param replace - Replace Registry (use createReplaceRegistry from '\@prostojs/infact')
|
|
862
|
+
* @param opts - `{ override: false }` registers a default: used only when neither `@Replace`
|
|
863
|
+
* on the app subclass nor a normal `setReplaceRegistry` entry exists for the class,
|
|
864
|
+
* regardless of call order. @since 0.6.45
|
|
846
865
|
* @returns
|
|
847
866
|
*/
|
|
848
|
-
setReplaceRegistry(replace: TReplaceRegistry): this;
|
|
867
|
+
setReplaceRegistry(replace: TReplaceRegistry, opts?: TRegistryMergeOptions): this;
|
|
868
|
+
/**
|
|
869
|
+
* Effective app-level replace registry, lowest to highest precedence: defaults
|
|
870
|
+
* (`override: false`), `@Replace` on the app subclass, `setReplaceRegistry()` entries.
|
|
871
|
+
* A controller's own `@Replace` is NOT app-level (it only reaches that controller's direct imports).
|
|
872
|
+
*/
|
|
873
|
+
protected appReplaceRegistry(): TReplaceRegistry;
|
|
874
|
+
/** Effective app-level provide registry (same layering as `appReplaceRegistry`). */
|
|
875
|
+
protected appProvideRegistry(): TProvideRegistry;
|
|
876
|
+
/**
|
|
877
|
+
* The class `type` is replaced with app-wide (one hop, like the DI container), or `undefined`.
|
|
878
|
+
* Works before and after `init()`; never warns. Per-controller `@Replace` is not reported.
|
|
879
|
+
* @since 0.6.45
|
|
880
|
+
*/
|
|
881
|
+
getReplacement<T>(type: TClassConstructor<T>): TClassConstructor<T> | undefined;
|
|
882
|
+
/**
|
|
883
|
+
* `getReplacement(type) !== undefined`.
|
|
884
|
+
* @since 0.6.45
|
|
885
|
+
*/
|
|
886
|
+
hasReplacement(type: TClassConstructor): boolean;
|
|
887
|
+
/**
|
|
888
|
+
* Frozen shallow copy of the effective app-level replace registry
|
|
889
|
+
* (keys are `getClassKey(Class)` symbols). Mutating it never affects the app.
|
|
890
|
+
* @since 0.6.45
|
|
891
|
+
*/
|
|
892
|
+
getReplaceRegistry(): Readonly<TReplaceRegistry>;
|
|
849
893
|
/**
|
|
850
894
|
* Register controllers with the app (similar to the `@ImportController` decorator).
|
|
851
895
|
*
|
|
@@ -1541,4 +1585,4 @@ declare function createLogger(opts?: Partial<TProstoLoggerOptions>): ProstoLogge
|
|
|
1541
1585
|
declare const loggerConsoleTransport: _prostojs_logger.TProstoLoggerTransportFn<any>;
|
|
1542
1586
|
|
|
1543
1587
|
export { After, ApplyDecorators, Before, Circular, Const, ConstFactory, Controller, Description, HandlerPaths, Id, ImportController, Inherit, Inject, InjectEventLogger, InjectFromScope, InjectMoost, InjectMoostLogger, InjectScopeVars, Injectable, Intercept, Interceptor, InterceptorHandler, Label, LoggerTopic, MOOST_ADAPTER_BRAND, MOOST_MODULE_IDENTITY_KEY, Moost, MoostDispose, MoostInit, OnError, Optional, Overtake, Param, Params, Pipe, Provide, Replace, Required, Resolve, Response, TInterceptorPriority, TPipePriority, Value, createLogger, defineAfterInterceptor, defineBeforeInterceptor, defineErrorInterceptor, defineInfactScope, defineInterceptor, defineMoostEventHandler, definePipeFn, disposeInstances, forkEventContext, getHandlerPaths, getInfactScopeVars, getInfactSingletonInstances, getInstanceOwnMethods, getInstanceOwnProps, getMoostInfact, getMoostMate, getNewMoostInfact, globalKey, isThenable, loggerConsoleTransport, mergeSorted, registerEventScope, resolvePipe, setControllerContext, setInfactLoggingOptions, setInterceptResult, setOvertake, stampModuleIdentity, stampOnce, useControllerContext, useHandlerPaths, useInterceptResult, useOvertake, useScopeId, withControllerContext };
|
|
1544
|
-
export type { TAny, TAnyFn, TClassConstructor, TContextInjectorHook, TControllerOverview, TControllerRegistration, TControllersGroup, TDisposeError, TDisposeOptions, TDisposeResult, TEmpty, TForkEventContextOptions, TFunction, TGetHandlerPathsOptions, TInjectableScope, TInterceptorAfterFn, TInterceptorBeforeFn, TInterceptorData, TInterceptorDef, TInterceptorDefFactory, TInterceptorEntry, TInterceptorErrorFn, TIsolatedSlot, TLogger, TMoostAdapter, TMoostAdapterOptions, TMoostEventHandlerHookOptions, TMoostEventHandlerOptions, TMoostHandler, TMoostMetadata, TMoostModuleIdentity, TMoostOptions, TMoostParamsMetadata, TObject, TOvertakeFn, TPipeData, TPipeFn, TPipeMetas, TPrimitives, TWithControllerContextOptions };
|
|
1588
|
+
export type { TAny, TAnyFn, TClassConstructor, TContextInjectorHook, TControllerOverview, TControllerRegistration, TControllersGroup, TDisposeError, TDisposeOptions, TDisposeResult, TEmpty, TForkEventContextOptions, TFunction, TGetHandlerPathsOptions, TInjectableScope, TInterceptorAfterFn, TInterceptorBeforeFn, TInterceptorData, TInterceptorDef, TInterceptorDefFactory, TInterceptorEntry, TInterceptorErrorFn, TIsolatedSlot, TLogger, TMoostAdapter, TMoostAdapterOptions, TMoostEventHandlerHookOptions, TMoostEventHandlerOptions, TMoostHandler, TMoostMetadata, TMoostModuleIdentity, TMoostOptions, TMoostParamsMetadata, TObject, TOvertakeFn, TPipeData, TPipeFn, TPipeMetas, TPrimitives, TRegistryMergeOptions, TWithControllerContextOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -47,7 +47,7 @@ let stamped = false;
|
|
|
47
47
|
if (stamped) return;
|
|
48
48
|
stamped = true;
|
|
49
49
|
stampModuleIdentity({
|
|
50
|
-
version: "0.6.
|
|
50
|
+
version: "0.6.45",
|
|
51
51
|
path: typeof __filename === "string" ? __filename : import.meta.url
|
|
52
52
|
});
|
|
53
53
|
}
|
|
@@ -2456,15 +2456,8 @@ function _define_property(obj, key, value) {
|
|
|
2456
2456
|
if (fatal.length > 0 && this.paramAuditMode === "error") return formatParamAuditError(fatal);
|
|
2457
2457
|
}
|
|
2458
2458
|
async bindControllers() {
|
|
2459
|
-
const
|
|
2460
|
-
const
|
|
2461
|
-
...thisMeta?.provide,
|
|
2462
|
-
...this.provide
|
|
2463
|
-
};
|
|
2464
|
-
const replace = {
|
|
2465
|
-
...thisMeta?.replace,
|
|
2466
|
-
...this.replace
|
|
2467
|
-
};
|
|
2459
|
+
const provide = this.appProvideRegistry();
|
|
2460
|
+
const replace = this.appReplaceRegistry();
|
|
2468
2461
|
const globalPrefix = this.options?.globalPrefix || "";
|
|
2469
2462
|
for (const { controller, prependPrefix, replaceOwnPrefix } of this.unregisteredControllers) await this.bindController(controller, provide, replace, prependPrefix ? `${globalPrefix}/${prependPrefix}` : globalPrefix, replaceOwnPrefix);
|
|
2470
2463
|
this.unregisteredControllers = [];
|
|
@@ -2522,7 +2515,7 @@ function _define_property(obj, key, value) {
|
|
|
2522
2515
|
...classMeta.provide
|
|
2523
2516
|
};
|
|
2524
2517
|
const mergedReplace = {
|
|
2525
|
-
...this.
|
|
2518
|
+
...this.appReplaceRegistry(),
|
|
2526
2519
|
...classMeta.replace
|
|
2527
2520
|
};
|
|
2528
2521
|
for (const ic of classMeta.importController) if (ic.typeResolver) {
|
|
@@ -2589,10 +2582,17 @@ function _define_property(obj, key, value) {
|
|
|
2589
2582
|
* controller — it flows parent → child through `@ImportController`, never
|
|
2590
2583
|
* to siblings.
|
|
2591
2584
|
* @param provide - Provide Registry (use createProvideRegistry from '\@prostojs/infact')
|
|
2585
|
+
* @param opts - `{ override: false }` registers a default: used only when neither `@Provide`
|
|
2586
|
+
* on the app subclass nor a normal `setProvideRegistry` entry exists for the token,
|
|
2587
|
+
* regardless of call order. @since 0.6.45
|
|
2592
2588
|
* @returns
|
|
2593
|
-
*/ setProvideRegistry(provide) {
|
|
2589
|
+
*/ setProvideRegistry(provide, opts) {
|
|
2594
2590
|
if (this.initialized) this.logger.warn("[moost] setProvideRegistry() called after init() — already-bound controllers will not see these providers. Register providers before init(), or provide them via @Provide on a parent controller.");
|
|
2595
|
-
this.
|
|
2591
|
+
if (opts?.override === false) this.defaultProvide = {
|
|
2592
|
+
...this.defaultProvide,
|
|
2593
|
+
...provide
|
|
2594
|
+
};
|
|
2595
|
+
else this.provide = {
|
|
2596
2596
|
...this.provide,
|
|
2597
2597
|
...provide
|
|
2598
2598
|
};
|
|
@@ -2605,16 +2605,61 @@ function _define_property(obj, key, value) {
|
|
|
2605
2605
|
* replace registry once when binding controllers, so replacements added
|
|
2606
2606
|
* later are never seen by already-bound controllers.
|
|
2607
2607
|
* @param replace - Replace Registry (use createReplaceRegistry from '\@prostojs/infact')
|
|
2608
|
+
* @param opts - `{ override: false }` registers a default: used only when neither `@Replace`
|
|
2609
|
+
* on the app subclass nor a normal `setReplaceRegistry` entry exists for the class,
|
|
2610
|
+
* regardless of call order. @since 0.6.45
|
|
2608
2611
|
* @returns
|
|
2609
|
-
*/ setReplaceRegistry(replace) {
|
|
2612
|
+
*/ setReplaceRegistry(replace, opts) {
|
|
2610
2613
|
if (this.initialized) this.logger.warn("[moost] setReplaceRegistry() called after init() — already-bound controllers will not see these replacements. Register replacements before init().");
|
|
2611
|
-
this.
|
|
2614
|
+
if (opts?.override === false) this.defaultReplace = {
|
|
2615
|
+
...this.defaultReplace,
|
|
2616
|
+
...replace
|
|
2617
|
+
};
|
|
2618
|
+
else this.replace = {
|
|
2612
2619
|
...this.replace,
|
|
2613
2620
|
...replace
|
|
2614
2621
|
};
|
|
2615
2622
|
return this;
|
|
2616
2623
|
}
|
|
2617
2624
|
/**
|
|
2625
|
+
* Effective app-level replace registry, lowest to highest precedence: defaults
|
|
2626
|
+
* (`override: false`), `@Replace` on the app subclass, `setReplaceRegistry()` entries.
|
|
2627
|
+
* A controller's own `@Replace` is NOT app-level (it only reaches that controller's direct imports).
|
|
2628
|
+
*/ appReplaceRegistry() {
|
|
2629
|
+
return {
|
|
2630
|
+
...this.defaultReplace,
|
|
2631
|
+
...getMoostMate().read(this)?.replace,
|
|
2632
|
+
...this.replace
|
|
2633
|
+
};
|
|
2634
|
+
}
|
|
2635
|
+
/** Effective app-level provide registry (same layering as `appReplaceRegistry`). */ appProvideRegistry() {
|
|
2636
|
+
return {
|
|
2637
|
+
...this.defaultProvide,
|
|
2638
|
+
...getMoostMate().read(this)?.provide,
|
|
2639
|
+
...this.provide
|
|
2640
|
+
};
|
|
2641
|
+
}
|
|
2642
|
+
/**
|
|
2643
|
+
* The class `type` is replaced with app-wide (one hop, like the DI container), or `undefined`.
|
|
2644
|
+
* Works before and after `init()`; never warns. Per-controller `@Replace` is not reported.
|
|
2645
|
+
* @since 0.6.45
|
|
2646
|
+
*/ getReplacement(type) {
|
|
2647
|
+
return this.appReplaceRegistry()[getClassKey$1(type)];
|
|
2648
|
+
}
|
|
2649
|
+
/**
|
|
2650
|
+
* `getReplacement(type) !== undefined`.
|
|
2651
|
+
* @since 0.6.45
|
|
2652
|
+
*/ hasReplacement(type) {
|
|
2653
|
+
return this.getReplacement(type) !== void 0;
|
|
2654
|
+
}
|
|
2655
|
+
/**
|
|
2656
|
+
* Frozen shallow copy of the effective app-level replace registry
|
|
2657
|
+
* (keys are `getClassKey(Class)` symbols). Mutating it never affects the app.
|
|
2658
|
+
* @since 0.6.45
|
|
2659
|
+
*/ getReplaceRegistry() {
|
|
2660
|
+
return Object.freeze(this.appReplaceRegistry());
|
|
2661
|
+
}
|
|
2662
|
+
/**
|
|
2618
2663
|
* Register controllers with the app (similar to the `@ImportController` decorator).
|
|
2619
2664
|
*
|
|
2620
2665
|
* Accepted forms (mixable in one call):
|
|
@@ -2665,7 +2710,7 @@ function _define_property(obj, key, value) {
|
|
|
2665
2710
|
this.logger.info(`${prefix || ""}${c}${eventName} ${"\x1B[0m\x1B[2m\x1B[32m" + c}→ ${classConstructor.name}.${"\x1B[36m" + c}${method}[32m()${coff}`);
|
|
2666
2711
|
}
|
|
2667
2712
|
constructor(options) {
|
|
2668
|
-
super(), _define_property(this, "options", void 0), _define_property(this, "logger", void 0), _define_property(this, "pipes", void 0), _define_property(this, "interceptors", void 0), _define_property(this, "adapters", void 0), _define_property(this, "controllersOverview", void 0), _define_property(this, "handlerOverviewIndex", void 0), _define_property(this, "initHooks", void 0), _define_property(this, "provide", void 0), _define_property(this, "replace", void 0), _define_property(this, "unregisteredControllers", void 0), _define_property(this, "paramAuditFindings", void 0), _define_property(this, "paramAuditMode", void 0), _define_property(this, "inheritanceAuditMode", void 0), _define_property(this, "initialized", void 0), _define_property(this, "singletonInstances", void 0), _define_property(this, "disposePromise", void 0), _define_property(this, "globalInterceptorHandler", void 0), this.options = options, this.pipes = Array.from(sharedPipes), this.interceptors = [], this.adapters = [], this.controllersOverview = [], this.initHooks = [], this.provide = createProvideRegistry$1([Infact, getMoostInfact], [Mate, getMoostMate]), this.replace = {}, this.unregisteredControllers = [], this.paramAuditFindings = [], this.initialized = false, this.singletonInstances = /* @__PURE__ */ new Set();
|
|
2713
|
+
super(), _define_property(this, "options", void 0), _define_property(this, "logger", void 0), _define_property(this, "pipes", void 0), _define_property(this, "interceptors", void 0), _define_property(this, "adapters", void 0), _define_property(this, "controllersOverview", void 0), _define_property(this, "handlerOverviewIndex", void 0), _define_property(this, "initHooks", void 0), _define_property(this, "provide", void 0), _define_property(this, "replace", void 0), _define_property(this, "defaultProvide", void 0), _define_property(this, "defaultReplace", void 0), _define_property(this, "unregisteredControllers", void 0), _define_property(this, "paramAuditFindings", void 0), _define_property(this, "paramAuditMode", void 0), _define_property(this, "inheritanceAuditMode", void 0), _define_property(this, "initialized", void 0), _define_property(this, "singletonInstances", void 0), _define_property(this, "disposePromise", void 0), _define_property(this, "globalInterceptorHandler", void 0), this.options = options, this.pipes = Array.from(sharedPipes), this.interceptors = [], this.adapters = [], this.controllersOverview = [], this.initHooks = [], this.provide = createProvideRegistry$1([Infact, getMoostInfact], [Mate, getMoostMate]), this.replace = {}, this.defaultProvide = {}, this.defaultReplace = {}, this.unregisteredControllers = [], this.paramAuditFindings = [], this.initialized = false, this.singletonInstances = /* @__PURE__ */ new Set();
|
|
2669
2714
|
this.paramAuditMode = resolveParamAuditMode(options?.diagnostics?.paramTypes);
|
|
2670
2715
|
this.inheritanceAuditMode = options?.diagnostics?.inheritance || "warn";
|
|
2671
2716
|
this.logger = options?.logger || getDefaultLogger(`[2m[35mmoost`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moost",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.45",
|
|
4
4
|
"description": "moost",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"composables",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@wooksjs/event-http": "^0.7.26",
|
|
50
50
|
"@wooksjs/http-body": "^0.7.26",
|
|
51
51
|
"vitest": "3.2.7",
|
|
52
|
-
"@moostjs/event-http": "^0.6.
|
|
52
|
+
"@moostjs/event-http": "^0.6.45"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"pub": "pnpm publish --access public",
|