moost 0.6.9 → 0.6.12
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 +135 -175
- package/dist/index.mjs +71 -89
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -1,32 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key$3; i < n; i++) {
|
|
10
|
-
key$3 = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key$3) && key$3 !== except) __defProp(to, key$3, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key$3),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key$3)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
const __wooksjs_event_core = __toESM(require("@wooksjs/event-core"));
|
|
25
|
-
const __prostojs_infact = __toESM(require("@prostojs/infact"));
|
|
26
|
-
const __prostojs_mate = __toESM(require("@prostojs/mate"));
|
|
27
|
-
const __prostojs_logger = __toESM(require("@prostojs/logger"));
|
|
28
|
-
const hookable = __toESM(require("hookable"));
|
|
29
|
-
const wooks = __toESM(require("wooks"));
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _wooksjs_event_core = require("@wooksjs/event-core");
|
|
3
|
+
let _prostojs_infact = require("@prostojs/infact");
|
|
4
|
+
let _prostojs_mate = require("@prostojs/mate");
|
|
5
|
+
let _prostojs_logger = require("@prostojs/logger");
|
|
6
|
+
let hookable = require("hookable");
|
|
7
|
+
let wooks = require("wooks");
|
|
30
8
|
|
|
31
9
|
//#region packages/moost/src/logger.ts
|
|
32
10
|
let defaultLogger;
|
|
@@ -34,20 +12,20 @@ function setDefaultLogger(logger) {
|
|
|
34
12
|
defaultLogger = logger;
|
|
35
13
|
}
|
|
36
14
|
function getDefaultLogger(topic) {
|
|
37
|
-
if (!defaultLogger) defaultLogger = new
|
|
15
|
+
if (!defaultLogger) defaultLogger = new _prostojs_logger.ProstoLogger({
|
|
38
16
|
level: 4,
|
|
39
17
|
transports: [loggerConsoleTransport]
|
|
40
18
|
});
|
|
41
|
-
return topic && defaultLogger instanceof
|
|
19
|
+
return topic && defaultLogger instanceof _prostojs_logger.ProstoLogger ? defaultLogger.createTopic(topic) : defaultLogger;
|
|
42
20
|
}
|
|
43
21
|
/** Creates a new `ProstoLogger` instance with sensible defaults (level 4, colored console). */ function createLogger(opts) {
|
|
44
|
-
return new
|
|
22
|
+
return new _prostojs_logger.ProstoLogger({
|
|
45
23
|
...opts,
|
|
46
24
|
level: opts?.level ?? 4,
|
|
47
25
|
transports: opts?.transports ?? [loggerConsoleTransport]
|
|
48
26
|
});
|
|
49
27
|
}
|
|
50
|
-
/** Default colored console transport used by Moost loggers. */ const loggerConsoleTransport = (0,
|
|
28
|
+
/** Default colored console transport used by Moost loggers. */ const loggerConsoleTransport = (0, _prostojs_logger.createConsoleTransort)({ format: _prostojs_logger.coloredConsole });
|
|
51
29
|
|
|
52
30
|
//#endregion
|
|
53
31
|
//#region packages/moost/src/shared-utils.ts
|
|
@@ -87,8 +65,7 @@ function runPipes(pipes, initialValue, metas, level) {
|
|
|
87
65
|
|
|
88
66
|
//#endregion
|
|
89
67
|
//#region packages/moost/src/metadata/moost-metadata.ts
|
|
90
|
-
const
|
|
91
|
-
const moostMate = new __prostojs_mate.Mate(METADATA_WORKSPACE, {
|
|
68
|
+
const moostMate = new _prostojs_mate.Mate("moost", {
|
|
92
69
|
readType: true,
|
|
93
70
|
readReturnType: true,
|
|
94
71
|
collectPropKeys: true,
|
|
@@ -141,7 +118,7 @@ const scopeVarsMap = /* @__PURE__ */ new Map();
|
|
|
141
118
|
/**
|
|
142
119
|
* Get Infact instance (used for Dependency Injections)
|
|
143
120
|
*/ function getNewMoostInfact() {
|
|
144
|
-
|
|
121
|
+
return new _prostojs_infact.Infact({
|
|
145
122
|
describeClass(classConstructor) {
|
|
146
123
|
const meta = getMoostMate().read(classConstructor);
|
|
147
124
|
return {
|
|
@@ -165,15 +142,14 @@ const scopeVarsMap = /* @__PURE__ */ new Map();
|
|
|
165
142
|
instantiate
|
|
166
143
|
}, "PARAM");
|
|
167
144
|
},
|
|
168
|
-
describeProp(classConstructor, key
|
|
169
|
-
|
|
170
|
-
return meta;
|
|
145
|
+
describeProp(classConstructor, key) {
|
|
146
|
+
return getMoostMate().read(classConstructor, key);
|
|
171
147
|
},
|
|
172
|
-
resolveProp({ instance, key
|
|
148
|
+
resolveProp({ instance, key, initialValue, propMeta, scopeId, classMeta, customData, classConstructor, instantiate }) {
|
|
173
149
|
if (propMeta && customData?.pipes) return runPipes(customData.pipes, initialValue, {
|
|
174
150
|
instance,
|
|
175
151
|
type: classConstructor,
|
|
176
|
-
key
|
|
152
|
+
key,
|
|
177
153
|
scopeId,
|
|
178
154
|
propMeta,
|
|
179
155
|
targetMeta: propMeta,
|
|
@@ -189,19 +165,17 @@ const scopeVarsMap = /* @__PURE__ */ new Map();
|
|
|
189
165
|
if (loggingOptions.newInstance === false || !(loggingOptions.newInstance === scope || loggingOptions.newInstance === "SINGLETON" && scope === true)) return;
|
|
190
166
|
break;
|
|
191
167
|
}
|
|
192
|
-
case "warn":
|
|
168
|
+
case "warn":
|
|
193
169
|
if (!loggingOptions.warn) return;
|
|
194
170
|
break;
|
|
195
|
-
|
|
196
|
-
case "error": {
|
|
171
|
+
case "error":
|
|
197
172
|
if (!loggingOptions.error) return;
|
|
198
173
|
break;
|
|
199
|
-
}
|
|
200
174
|
default:
|
|
201
175
|
}
|
|
202
176
|
let logger;
|
|
203
177
|
try {
|
|
204
|
-
const ctxLogger = event === "error" ? getDefaultLogger(INFACT_BANNER) : (0,
|
|
178
|
+
const ctxLogger = event === "error" ? getDefaultLogger(INFACT_BANNER) : (0, _wooksjs_event_core.useLogger)();
|
|
205
179
|
const withTopic = ctxLogger;
|
|
206
180
|
logger = typeof withTopic.topic === "function" ? withTopic.topic(INFACT_BANNER) : ctxLogger;
|
|
207
181
|
} catch (error) {
|
|
@@ -215,11 +189,10 @@ const scopeVarsMap = /* @__PURE__ */ new Map();
|
|
|
215
189
|
case "number":
|
|
216
190
|
case "boolean": return `[33m${a}[2m[34m`;
|
|
217
191
|
case "string": return `[92m"${a.slice(0, 1)}..."[2m[34m`;
|
|
218
|
-
case "object":
|
|
192
|
+
case "object":
|
|
219
193
|
if (Array.isArray(a)) return `[${a.length}]`;
|
|
220
|
-
if ((0,
|
|
194
|
+
if ((0, _prostojs_mate.getConstructor)(a)) return (0, _prostojs_mate.getConstructor)(a).name;
|
|
221
195
|
return "{}";
|
|
222
|
-
}
|
|
223
196
|
default: return "*";
|
|
224
197
|
}
|
|
225
198
|
}).map((a) => `[2m[1m${a}[22m[2m`).join(", ") || "";
|
|
@@ -240,20 +213,19 @@ const scopeVarsMap = /* @__PURE__ */ new Map();
|
|
|
240
213
|
}
|
|
241
214
|
}
|
|
242
215
|
});
|
|
243
|
-
return infactInstance;
|
|
244
216
|
}
|
|
245
217
|
|
|
246
218
|
//#endregion
|
|
247
219
|
//#region packages/moost/src/composables/controller.composable.ts
|
|
248
|
-
const controllerInstanceKey = (0,
|
|
249
|
-
const controllerMethodKey = (0,
|
|
250
|
-
const controllerRouteKey = (0,
|
|
251
|
-
const controllerPrefixKey = (0,
|
|
220
|
+
const controllerInstanceKey = (0, _wooksjs_event_core.key)("controller.instance");
|
|
221
|
+
const controllerMethodKey = (0, _wooksjs_event_core.key)("controller.method");
|
|
222
|
+
const controllerRouteKey = (0, _wooksjs_event_core.key)("controller.route");
|
|
223
|
+
const controllerPrefixKey = (0, _wooksjs_event_core.key)("controller.prefix");
|
|
252
224
|
/**
|
|
253
225
|
* Sets the controller context for the current event scope.
|
|
254
226
|
* Called internally by adapters when dispatching events to handlers.
|
|
255
227
|
*/ function setControllerContext(controller, method, route, opts) {
|
|
256
|
-
const _ctx = opts?.ctx || (0,
|
|
228
|
+
const _ctx = opts?.ctx || (0, _wooksjs_event_core.current)();
|
|
257
229
|
_ctx.set(controllerInstanceKey, controller);
|
|
258
230
|
_ctx.set(controllerMethodKey, method);
|
|
259
231
|
_ctx.set(controllerRouteKey, route);
|
|
@@ -263,7 +235,7 @@ const controllerPrefixKey = (0, __wooksjs_event_core.key)("controller.prefix");
|
|
|
263
235
|
* Provides access to the current controller context within an event handler.
|
|
264
236
|
* Returns utilities for accessing the controller instance, method metadata, and DI.
|
|
265
237
|
*/ function useControllerContext(ctx) {
|
|
266
|
-
const _ctx = ctx || (0,
|
|
238
|
+
const _ctx = ctx || (0, _wooksjs_event_core.current)();
|
|
267
239
|
const getController = () => _ctx.get(controllerInstanceKey);
|
|
268
240
|
const getMethod = () => _ctx.get(controllerMethodKey);
|
|
269
241
|
const getRoute = () => _ctx.get(controllerRouteKey);
|
|
@@ -292,19 +264,19 @@ const controllerPrefixKey = (0, __wooksjs_event_core.key)("controller.prefix");
|
|
|
292
264
|
//#region packages/moost/src/composables/interceptor.composable.ts
|
|
293
265
|
var _g, _g1;
|
|
294
266
|
const g = globalThis;
|
|
295
|
-
const overtakeKey = (_g = g).__moost_overtakeKey ?? (_g.__moost_overtakeKey = (0,
|
|
296
|
-
const interceptResultKey = (_g1 = g).__moost_interceptResultKey ?? (_g1.__moost_interceptResultKey = (0,
|
|
267
|
+
const overtakeKey = (_g = g).__moost_overtakeKey ?? (_g.__moost_overtakeKey = (0, _wooksjs_event_core.key)("interceptor.overtake"));
|
|
268
|
+
const interceptResultKey = (_g1 = g).__moost_interceptResultKey ?? (_g1.__moost_interceptResultKey = (0, _wooksjs_event_core.key)("interceptor.result"));
|
|
297
269
|
/** Stores the overtake (reply) function in the current event context. */ function setOvertake(fn, ctx) {
|
|
298
|
-
(ctx || (0,
|
|
270
|
+
(ctx || (0, _wooksjs_event_core.current)()).set(overtakeKey, fn);
|
|
299
271
|
}
|
|
300
272
|
/** Retrieves the overtake (reply) function from the current event context. */ function useOvertake(ctx) {
|
|
301
|
-
return (ctx || (0,
|
|
273
|
+
return (ctx || (0, _wooksjs_event_core.current)()).get(overtakeKey);
|
|
302
274
|
}
|
|
303
275
|
/** Stores the interceptor result value in the current event context. */ function setInterceptResult(value, ctx) {
|
|
304
|
-
(ctx || (0,
|
|
276
|
+
(ctx || (0, _wooksjs_event_core.current)()).set(interceptResultKey, value);
|
|
305
277
|
}
|
|
306
278
|
/** Retrieves the interceptor result value from the current event context. */ function useInterceptResult(ctx) {
|
|
307
|
-
return (ctx || (0,
|
|
279
|
+
return (ctx || (0, _wooksjs_event_core.current)()).get(interceptResultKey);
|
|
308
280
|
}
|
|
309
281
|
|
|
310
282
|
//#endregion
|
|
@@ -318,7 +290,7 @@ function nextScopeId() {
|
|
|
318
290
|
}
|
|
319
291
|
return `__moost_${_scopeChar}_${++_scopeNum}`;
|
|
320
292
|
}
|
|
321
|
-
/** Composable returning the moost scope ID for the current event. Generates on first call, caches for subsequent calls. */ const useScopeId = (0,
|
|
293
|
+
/** Composable returning the moost scope ID for the current event. Generates on first call, caches for subsequent calls. */ const useScopeId = (0, _wooksjs_event_core.defineWook)(() => nextScopeId());
|
|
322
294
|
/** Registers a DI scope for the given ID and returns an unscope function. */ function registerEventScope(scopeId) {
|
|
323
295
|
const infact = getMoostInfact();
|
|
324
296
|
infact.registerScope(scopeId);
|
|
@@ -331,16 +303,16 @@ function nextScopeId() {
|
|
|
331
303
|
* Handles scope registration, controller resolution, interceptors, argument resolution,
|
|
332
304
|
* handler invocation, and cleanup — optimised for sync-first execution.
|
|
333
305
|
*/ function defineMoostEventHandler(options) {
|
|
334
|
-
const ci = (0,
|
|
306
|
+
const ci = (0, _wooksjs_event_core.getContextInjector)();
|
|
335
307
|
const handlerSpanName = `Handler:${options.targetPath}`;
|
|
336
308
|
const handlerAttrs = {
|
|
337
309
|
"moost.handler": options.controllerMethod || "",
|
|
338
310
|
"moost.controller": options.controllerName || ""
|
|
339
311
|
};
|
|
340
312
|
return () => {
|
|
341
|
-
const ctx = (0,
|
|
313
|
+
const ctx = (0, _wooksjs_event_core.current)();
|
|
342
314
|
const scopeId = useScopeId(ctx);
|
|
343
|
-
const ctxLogger = (0,
|
|
315
|
+
const ctxLogger = (0, _wooksjs_event_core.useLogger)(ctx);
|
|
344
316
|
const logger = typeof ctxLogger.topic === "function" ? ctxLogger.topic(options.loggerTitle) : ctxLogger;
|
|
345
317
|
const unscope = registerEventScope(scopeId);
|
|
346
318
|
let response;
|
|
@@ -474,7 +446,7 @@ function nextScopeId() {
|
|
|
474
446
|
/** Returns the own method names of an instance, including inherited methods from parent classes. */ function getInstanceOwnMethods(instance) {
|
|
475
447
|
const proto = Object.getPrototypeOf(instance);
|
|
476
448
|
return [...new Set([
|
|
477
|
-
...getParentProps((0,
|
|
449
|
+
...getParentProps((0, _prostojs_mate.getConstructor)(instance)),
|
|
478
450
|
...Object.getOwnPropertyNames(proto),
|
|
479
451
|
...Object.getOwnPropertyNames(instance)
|
|
480
452
|
])].filter((m) => typeof instance[m] === "function");
|
|
@@ -482,7 +454,7 @@ function nextScopeId() {
|
|
|
482
454
|
/** Returns the own non-method property names of an instance, including inherited properties. */ function getInstanceOwnProps(instance) {
|
|
483
455
|
const proto = Object.getPrototypeOf(instance);
|
|
484
456
|
return [...new Set([
|
|
485
|
-
...getParentProps((0,
|
|
457
|
+
...getParentProps((0, _prostojs_mate.getConstructor)(instance)),
|
|
486
458
|
...Object.getOwnPropertyNames(proto),
|
|
487
459
|
...Object.getOwnPropertyNames(instance)
|
|
488
460
|
])].filter((m) => typeof instance[m] !== "function");
|
|
@@ -503,7 +475,7 @@ function getParentProps(constructor) {
|
|
|
503
475
|
* The returned function runs pipes for each parameter and returns
|
|
504
476
|
* `unknown[]` synchronously when possible, or `Promise<unknown[]>` otherwise.
|
|
505
477
|
*/ function resolveArguments(argsPipes, context) {
|
|
506
|
-
if (argsPipes.length === 0) return
|
|
478
|
+
if (argsPipes.length === 0) return;
|
|
507
479
|
return () => {
|
|
508
480
|
const args = [];
|
|
509
481
|
let hasAsync = false;
|
|
@@ -528,14 +500,14 @@ function getParentProps(constructor) {
|
|
|
528
500
|
|
|
529
501
|
//#endregion
|
|
530
502
|
//#region packages/moost/src/interceptor-handler.ts
|
|
531
|
-
function _define_property$1(obj, key
|
|
532
|
-
if (key
|
|
503
|
+
function _define_property$1(obj, key, value) {
|
|
504
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
533
505
|
value,
|
|
534
506
|
enumerable: true,
|
|
535
507
|
configurable: true,
|
|
536
508
|
writable: true
|
|
537
509
|
});
|
|
538
|
-
else obj[key
|
|
510
|
+
else obj[key] = value;
|
|
539
511
|
return obj;
|
|
540
512
|
}
|
|
541
513
|
/**
|
|
@@ -574,10 +546,9 @@ function _define_property$1(obj, key$3, value) {
|
|
|
574
546
|
const result = ci ? ci.with(spanName, { "moost.interceptor.stage": "before" }, () => def.before?.(this.getReplyFn())) : def.before(this.getReplyFn());
|
|
575
547
|
if (isThenable(result)) return result;
|
|
576
548
|
}
|
|
577
|
-
return void 0;
|
|
578
549
|
}
|
|
579
550
|
before() {
|
|
580
|
-
const ci = (0,
|
|
551
|
+
const ci = (0, _wooksjs_event_core.getContextInjector)();
|
|
581
552
|
for (let i = 0; i < this.handlers.length; i++) {
|
|
582
553
|
const entry = this.handlers[i];
|
|
583
554
|
const { handler } = entry;
|
|
@@ -624,7 +595,7 @@ function _define_property$1(obj, key$3, value) {
|
|
|
624
595
|
const isError = response instanceof Error;
|
|
625
596
|
const handlers = isError ? this.onError : this.after;
|
|
626
597
|
if (!handlers) return this.response;
|
|
627
|
-
const ci = (0,
|
|
598
|
+
const ci = (0, _wooksjs_event_core.getContextInjector)();
|
|
628
599
|
const stage = isError ? "onError" : "after";
|
|
629
600
|
for (let i = 0; i < handlers.length; i++) {
|
|
630
601
|
const { name, fn } = handlers[i];
|
|
@@ -668,8 +639,7 @@ function findInterceptorMethods(handler) {
|
|
|
668
639
|
const methods = getInstanceOwnMethods(fakeInstance);
|
|
669
640
|
const result = {};
|
|
670
641
|
for (const method of methods) {
|
|
671
|
-
const
|
|
672
|
-
const hook = methodMeta?.interceptorHook;
|
|
642
|
+
const hook = mate.read(fakeInstance, method)?.interceptorHook;
|
|
673
643
|
if (hook === "before" || hook === "after" || hook === "error") result[hook] = method;
|
|
674
644
|
}
|
|
675
645
|
return result;
|
|
@@ -682,7 +652,7 @@ function buildMethodResolver(opts) {
|
|
|
682
652
|
meta: p,
|
|
683
653
|
pipes: mergeSorted(opts.pipes, p.pipes)
|
|
684
654
|
});
|
|
685
|
-
if (argsPipes.length === 0) return
|
|
655
|
+
if (argsPipes.length === 0) return;
|
|
686
656
|
return resolveArguments(argsPipes, {
|
|
687
657
|
classMeta: opts.classMeta,
|
|
688
658
|
methodMeta,
|
|
@@ -691,7 +661,7 @@ function buildMethodResolver(opts) {
|
|
|
691
661
|
});
|
|
692
662
|
}
|
|
693
663
|
function callWithArgs(instance, methodName, resolveArgs) {
|
|
694
|
-
const ci = (0,
|
|
664
|
+
const ci = (0, _wooksjs_event_core.getContextInjector)();
|
|
695
665
|
const args = ci ? ci.with("Arguments:resolve", resolveArgs) : resolveArgs();
|
|
696
666
|
if (isThenable(args)) return args.then((a) => instance[methodName](...a));
|
|
697
667
|
return instance[methodName](...args);
|
|
@@ -798,8 +768,7 @@ async function bindControllerMethods(options) {
|
|
|
798
768
|
opts.provide = opts.provide || {};
|
|
799
769
|
const fakeInstance = Object.create(classConstructor.prototype);
|
|
800
770
|
const methods = getInstanceOwnMethods(fakeInstance);
|
|
801
|
-
const
|
|
802
|
-
const meta = mate$1.read(classConstructor) || {};
|
|
771
|
+
const meta = getMoostMate().read(classConstructor) || {};
|
|
803
772
|
const ownPrefix = typeof opts.replaceOwnPrefix === "string" ? opts.replaceOwnPrefix : meta.controller?.prefix || "";
|
|
804
773
|
const prefix = `${opts.globalPrefix}/${ownPrefix}`;
|
|
805
774
|
const controllerOverview = {
|
|
@@ -812,8 +781,7 @@ async function bindControllerMethods(options) {
|
|
|
812
781
|
const methodMeta = getMoostMate().read(fakeInstance, method) || {};
|
|
813
782
|
if (!methodMeta.handlers?.length) continue;
|
|
814
783
|
const pipes = mergeSorted(opts.pipes, methodMeta.pipes);
|
|
815
|
-
const
|
|
816
|
-
const getIterceptorHandler = getIterceptorHandlerFactory(interceptors, getInstance, pipes);
|
|
784
|
+
const getIterceptorHandler = getIterceptorHandlerFactory(mergeSorted(opts.interceptors, meta.interceptors, methodMeta.interceptors), getInstance, pipes);
|
|
817
785
|
const argsPipes = [];
|
|
818
786
|
for (const p of methodMeta.params || []) argsPipes.push({
|
|
819
787
|
meta: p,
|
|
@@ -888,8 +856,7 @@ async function bindControllerMethods(options) {
|
|
|
888
856
|
* @param decorators - array of decorators
|
|
889
857
|
* @returns
|
|
890
858
|
*/ function ApplyDecorators(...decorators) {
|
|
891
|
-
|
|
892
|
-
return mate$1.apply(...decorators);
|
|
859
|
+
return getMoostMate().apply(...decorators);
|
|
893
860
|
}
|
|
894
861
|
/**
|
|
895
862
|
* ## Label
|
|
@@ -943,11 +910,11 @@ async function bindControllerMethods(options) {
|
|
|
943
910
|
*
|
|
944
911
|
* Stores Required metadata
|
|
945
912
|
*/ function Required() {
|
|
946
|
-
const mate
|
|
947
|
-
return mate
|
|
948
|
-
if (typeof index !== "number" && meta && ["string", "symbol"].includes(typeof key
|
|
913
|
+
const mate = getMoostMate();
|
|
914
|
+
return mate.apply(mate.decorate("required", true), mate.decorateClass((meta, level, key, index) => {
|
|
915
|
+
if (typeof index !== "number" && meta && ["string", "symbol"].includes(typeof key)) {
|
|
949
916
|
meta.requiredProps = meta.requiredProps || [];
|
|
950
|
-
meta.requiredProps.push(key
|
|
917
|
+
meta.requiredProps.push(key);
|
|
951
918
|
}
|
|
952
919
|
return meta;
|
|
953
920
|
}));
|
|
@@ -979,8 +946,8 @@ const insureInjectable = getMoostMate().decorate((meta) => {
|
|
|
979
946
|
* Set Class as a Controller
|
|
980
947
|
* @param prefix - define the prefix for all the paths of this controller
|
|
981
948
|
*/ function Controller(prefix) {
|
|
982
|
-
const mate
|
|
983
|
-
return mate
|
|
949
|
+
const mate = getMoostMate();
|
|
950
|
+
return mate.apply(insureInjectable, mate.decorate("controller", { prefix: prefix || "" }));
|
|
984
951
|
}
|
|
985
952
|
function ImportController(prefix, controller, provide) {
|
|
986
953
|
return getMoostMate().decorate("importController", {
|
|
@@ -1001,15 +968,15 @@ function ImportController(prefix, controller, provide) {
|
|
|
1001
968
|
|
|
1002
969
|
//#endregion
|
|
1003
970
|
//#region packages/moost/src/decorators/intercept.decorator.ts
|
|
1004
|
-
var TInterceptorPriority = /* @__PURE__ */ function(TInterceptorPriority
|
|
1005
|
-
TInterceptorPriority
|
|
1006
|
-
TInterceptorPriority
|
|
1007
|
-
TInterceptorPriority
|
|
1008
|
-
TInterceptorPriority
|
|
1009
|
-
TInterceptorPriority
|
|
1010
|
-
TInterceptorPriority
|
|
1011
|
-
TInterceptorPriority
|
|
1012
|
-
return TInterceptorPriority
|
|
971
|
+
var TInterceptorPriority = /* @__PURE__ */ function(TInterceptorPriority) {
|
|
972
|
+
TInterceptorPriority[TInterceptorPriority["BEFORE_ALL"] = 0] = "BEFORE_ALL";
|
|
973
|
+
TInterceptorPriority[TInterceptorPriority["BEFORE_GUARD"] = 1] = "BEFORE_GUARD";
|
|
974
|
+
TInterceptorPriority[TInterceptorPriority["GUARD"] = 2] = "GUARD";
|
|
975
|
+
TInterceptorPriority[TInterceptorPriority["AFTER_GUARD"] = 3] = "AFTER_GUARD";
|
|
976
|
+
TInterceptorPriority[TInterceptorPriority["INTERCEPTOR"] = 4] = "INTERCEPTOR";
|
|
977
|
+
TInterceptorPriority[TInterceptorPriority["CATCH_ERROR"] = 5] = "CATCH_ERROR";
|
|
978
|
+
TInterceptorPriority[TInterceptorPriority["AFTER_ALL"] = 6] = "AFTER_ALL";
|
|
979
|
+
return TInterceptorPriority;
|
|
1013
980
|
}({});
|
|
1014
981
|
/**
|
|
1015
982
|
* ## Intercept
|
|
@@ -1019,16 +986,16 @@ var TInterceptorPriority = /* @__PURE__ */ function(TInterceptorPriority$1) {
|
|
|
1019
986
|
* @param priority — interceptor priority (overrides handler's own priority)
|
|
1020
987
|
* @param name — interceptor name for tracing
|
|
1021
988
|
*/ function Intercept(handler, priority, name) {
|
|
1022
|
-
const mate
|
|
989
|
+
const mate = getMoostMate();
|
|
1023
990
|
if (typeof handler === "function") {
|
|
1024
|
-
const interceptorMeta = mate
|
|
1025
|
-
return mate
|
|
991
|
+
const interceptorMeta = mate.read(handler);
|
|
992
|
+
return mate.decorate("interceptors", {
|
|
1026
993
|
handler,
|
|
1027
994
|
priority: priority ?? interceptorMeta?.interceptor?.priority ?? 4,
|
|
1028
995
|
name: name || handler.name || "<anonymous>"
|
|
1029
996
|
}, true);
|
|
1030
997
|
}
|
|
1031
|
-
return mate
|
|
998
|
+
return mate.decorate("interceptors", {
|
|
1032
999
|
handler,
|
|
1033
1000
|
priority: priority ?? handler.priority ?? 4,
|
|
1034
1001
|
name: name || handler._name || "<anonymous>"
|
|
@@ -1044,14 +1011,14 @@ var TInterceptorPriority = /* @__PURE__ */ function(TInterceptorPriority$1) {
|
|
|
1044
1011
|
* @param label - field label
|
|
1045
1012
|
* @paramType unknown
|
|
1046
1013
|
*/ function Resolve(resolver, label) {
|
|
1047
|
-
return (target, key
|
|
1014
|
+
return (target, key, index) => {
|
|
1048
1015
|
const i = typeof index === "number" ? index : void 0;
|
|
1049
1016
|
getMoostMate().decorate("resolver", (metas, level) => {
|
|
1050
1017
|
let newLabel = label;
|
|
1051
1018
|
if (!newLabel && level === "PROP" && typeof metas.key === "string") newLabel = metas.key;
|
|
1052
|
-
fillLabel(target, key
|
|
1019
|
+
fillLabel(target, key || "", i, newLabel);
|
|
1053
1020
|
return resolver(metas, level);
|
|
1054
|
-
})(target, key
|
|
1021
|
+
})(target, key, i);
|
|
1055
1022
|
};
|
|
1056
1023
|
}
|
|
1057
1024
|
/**
|
|
@@ -1060,14 +1027,14 @@ var TInterceptorPriority = /* @__PURE__ */ function(TInterceptorPriority$1) {
|
|
|
1060
1027
|
* @param name - param name
|
|
1061
1028
|
* @paramType string
|
|
1062
1029
|
*/ function Param(name) {
|
|
1063
|
-
return getMoostMate().apply(getMoostMate().decorate("paramSource", "ROUTE"), getMoostMate().decorate("paramName", name), Resolve(() => (0,
|
|
1030
|
+
return getMoostMate().apply(getMoostMate().decorate("paramSource", "ROUTE"), getMoostMate().decorate("paramName", name), Resolve(() => (0, _wooksjs_event_core.useRouteParams)().get(name), name));
|
|
1064
1031
|
}
|
|
1065
1032
|
/**
|
|
1066
1033
|
* Get Parsed Params from url parh
|
|
1067
1034
|
* @decorator
|
|
1068
1035
|
* @paramType object
|
|
1069
1036
|
*/ function Params() {
|
|
1070
|
-
return Resolve(() => (0,
|
|
1037
|
+
return Resolve(() => (0, _wooksjs_event_core.useRouteParams)().params, "params");
|
|
1071
1038
|
}
|
|
1072
1039
|
/**
|
|
1073
1040
|
* Provide Const Value
|
|
@@ -1087,12 +1054,12 @@ var TInterceptorPriority = /* @__PURE__ */ function(TInterceptorPriority$1) {
|
|
|
1087
1054
|
*/ function ConstFactory(factory, label) {
|
|
1088
1055
|
return Resolve(async () => factory(), label);
|
|
1089
1056
|
}
|
|
1090
|
-
function fillLabel(target, key
|
|
1057
|
+
function fillLabel(target, key, index, name) {
|
|
1091
1058
|
if (name) {
|
|
1092
|
-
const meta = getMoostMate().read(target, key
|
|
1059
|
+
const meta = getMoostMate().read(target, key);
|
|
1093
1060
|
if (typeof index === "number") {
|
|
1094
|
-
if (!meta?.params?.[index]?.label) Label(name)(target, key
|
|
1095
|
-
} else if (!meta?.label) Label(name)(target, key
|
|
1061
|
+
if (!meta?.params?.[index]?.label) Label(name)(target, key, index);
|
|
1062
|
+
} else if (!meta?.label) Label(name)(target, key);
|
|
1096
1063
|
}
|
|
1097
1064
|
}
|
|
1098
1065
|
|
|
@@ -1110,10 +1077,10 @@ function fillLabel(target, key$3, index, name) {
|
|
|
1110
1077
|
* @param priority — interceptor priority (default: INTERCEPTOR)
|
|
1111
1078
|
* @param scope — DI scope ('FOR_EVENT' | 'SINGLETON' | true)
|
|
1112
1079
|
*/ function Interceptor(priority, scope) {
|
|
1113
|
-
const mate
|
|
1114
|
-
const decorators = [insureInjectable, mate
|
|
1115
|
-
if (scope) decorators.push(mate
|
|
1116
|
-
return mate
|
|
1080
|
+
const mate = getMoostMate();
|
|
1081
|
+
const decorators = [insureInjectable, mate.decorate("interceptor", { priority: priority ?? TInterceptorPriority.INTERCEPTOR })];
|
|
1082
|
+
if (scope) decorators.push(mate.decorate("injectable", scope));
|
|
1083
|
+
return mate.apply(...decorators);
|
|
1117
1084
|
}
|
|
1118
1085
|
/**
|
|
1119
1086
|
* ## @Before
|
|
@@ -1168,7 +1135,7 @@ function fillLabel(target, key$3, index, name) {
|
|
|
1168
1135
|
* @returns Resolver to '@wooksjs/event-core' (Logger)
|
|
1169
1136
|
*/ function InjectEventLogger(topic) {
|
|
1170
1137
|
return Resolve(() => {
|
|
1171
|
-
const l = (0,
|
|
1138
|
+
const l = (0, _wooksjs_event_core.useLogger)();
|
|
1172
1139
|
return topic && typeof l.topic === "function" ? l.topic(topic) : l;
|
|
1173
1140
|
});
|
|
1174
1141
|
}
|
|
@@ -1195,17 +1162,17 @@ function fillLabel(target, key$3, index, name) {
|
|
|
1195
1162
|
|
|
1196
1163
|
//#endregion
|
|
1197
1164
|
//#region packages/moost/src/pipes/types.ts
|
|
1198
|
-
/** Execution priority for pipes. Lower values run first. */ var TPipePriority = /* @__PURE__ */ function(TPipePriority
|
|
1199
|
-
TPipePriority
|
|
1200
|
-
TPipePriority
|
|
1201
|
-
TPipePriority
|
|
1202
|
-
TPipePriority
|
|
1203
|
-
TPipePriority
|
|
1204
|
-
TPipePriority
|
|
1205
|
-
TPipePriority
|
|
1206
|
-
TPipePriority
|
|
1207
|
-
TPipePriority
|
|
1208
|
-
return TPipePriority
|
|
1165
|
+
/** Execution priority for pipes. Lower values run first. */ var TPipePriority = /* @__PURE__ */ function(TPipePriority) {
|
|
1166
|
+
TPipePriority[TPipePriority["BEFORE_RESOLVE"] = 0] = "BEFORE_RESOLVE";
|
|
1167
|
+
TPipePriority[TPipePriority["RESOLVE"] = 1] = "RESOLVE";
|
|
1168
|
+
TPipePriority[TPipePriority["AFTER_RESOLVE"] = 2] = "AFTER_RESOLVE";
|
|
1169
|
+
TPipePriority[TPipePriority["BEFORE_TRANSFORM"] = 3] = "BEFORE_TRANSFORM";
|
|
1170
|
+
TPipePriority[TPipePriority["TRANSFORM"] = 4] = "TRANSFORM";
|
|
1171
|
+
TPipePriority[TPipePriority["AFTER_TRANSFORM"] = 5] = "AFTER_TRANSFORM";
|
|
1172
|
+
TPipePriority[TPipePriority["BEFORE_VALIDATE"] = 6] = "BEFORE_VALIDATE";
|
|
1173
|
+
TPipePriority[TPipePriority["VALIDATE"] = 7] = "VALIDATE";
|
|
1174
|
+
TPipePriority[TPipePriority["AFTER_VALIDATE"] = 8] = "AFTER_VALIDATE";
|
|
1175
|
+
return TPipePriority;
|
|
1209
1176
|
}({});
|
|
1210
1177
|
|
|
1211
1178
|
//#endregion
|
|
@@ -1236,7 +1203,7 @@ function fillLabel(target, key$3, index, name) {
|
|
|
1236
1203
|
*/ function Provide(type, fn) {
|
|
1237
1204
|
return getMoostMate().decorate((meta) => {
|
|
1238
1205
|
meta.provide = meta.provide || {};
|
|
1239
|
-
Object.assign(meta.provide, (0,
|
|
1206
|
+
Object.assign(meta.provide, (0, _prostojs_infact.createProvideRegistry)([type, fn]));
|
|
1240
1207
|
return meta;
|
|
1241
1208
|
});
|
|
1242
1209
|
}
|
|
@@ -1249,7 +1216,7 @@ function fillLabel(target, key$3, index, name) {
|
|
|
1249
1216
|
*/ function Replace(type, newType) {
|
|
1250
1217
|
return getMoostMate().decorate((meta) => {
|
|
1251
1218
|
meta.replace = meta.replace || {};
|
|
1252
|
-
Object.assign(meta.replace, (0,
|
|
1219
|
+
Object.assign(meta.replace, (0, _prostojs_infact.createReplaceRegistry)([type, newType]));
|
|
1253
1220
|
return meta;
|
|
1254
1221
|
});
|
|
1255
1222
|
}
|
|
@@ -1276,7 +1243,6 @@ function fillLabel(target, key$3, index, name) {
|
|
|
1276
1243
|
*/ function InjectScopeVars(name) {
|
|
1277
1244
|
return Resolve(({ scopeId }) => {
|
|
1278
1245
|
if (scopeId) return name ? getInfactScopeVars(scopeId)?.[name] : getInfactScopeVars(scopeId);
|
|
1279
|
-
return void 0;
|
|
1280
1246
|
});
|
|
1281
1247
|
}
|
|
1282
1248
|
|
|
@@ -1376,7 +1342,6 @@ function fillLabel(target, key$3, index, name) {
|
|
|
1376
1342
|
const resolvePipe = definePipeFn((_value, metas, level) => {
|
|
1377
1343
|
const resolver = metas.targetMeta?.resolver;
|
|
1378
1344
|
if (resolver) return resolver(metas, level);
|
|
1379
|
-
return void 0;
|
|
1380
1345
|
}, TPipePriority.RESOLVE);
|
|
1381
1346
|
|
|
1382
1347
|
//#endregion
|
|
@@ -1388,14 +1353,14 @@ const sharedPipes = [{
|
|
|
1388
1353
|
|
|
1389
1354
|
//#endregion
|
|
1390
1355
|
//#region packages/moost/src/moost.ts
|
|
1391
|
-
function _define_property(obj, key
|
|
1392
|
-
if (key
|
|
1356
|
+
function _define_property(obj, key, value) {
|
|
1357
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
1393
1358
|
value,
|
|
1394
1359
|
enumerable: true,
|
|
1395
1360
|
configurable: true,
|
|
1396
1361
|
writable: true
|
|
1397
1362
|
});
|
|
1398
|
-
else obj[key
|
|
1363
|
+
else obj[key] = value;
|
|
1399
1364
|
return obj;
|
|
1400
1365
|
}
|
|
1401
1366
|
/**
|
|
@@ -1465,7 +1430,7 @@ function _define_property(obj, key$3, value) {
|
|
|
1465
1430
|
* @param topic
|
|
1466
1431
|
* @returns
|
|
1467
1432
|
*/ getLogger(topic) {
|
|
1468
|
-
if (topic && this.logger instanceof
|
|
1433
|
+
if (topic && this.logger instanceof _prostojs_logger.ProstoLogger) return this.logger.createTopic(topic);
|
|
1469
1434
|
return this.logger;
|
|
1470
1435
|
}
|
|
1471
1436
|
adapter(a) {
|
|
@@ -1479,10 +1444,10 @@ function _define_property(obj, key$3, value) {
|
|
|
1479
1444
|
* ### init
|
|
1480
1445
|
* Ititializes adapter. Must be called after adapters are attached.
|
|
1481
1446
|
*/ async init() {
|
|
1482
|
-
this.setProvideRegistry((0,
|
|
1447
|
+
this.setProvideRegistry((0, _prostojs_infact.createProvideRegistry)([Moost, () => this], [_prostojs_logger.ProstoLogger, () => this.logger], ["MOOST_LOGGER", () => this.logger]));
|
|
1483
1448
|
for (const a of this.adapters) {
|
|
1484
|
-
const constructor = (0,
|
|
1485
|
-
if (constructor) this.setProvideRegistry((0,
|
|
1449
|
+
const constructor = (0, _prostojs_mate.getConstructor)(a);
|
|
1450
|
+
if (constructor) this.setProvideRegistry((0, _prostojs_infact.createProvideRegistry)([constructor, () => a]));
|
|
1486
1451
|
if (typeof a.getProvideRegistry === "function") this.setProvideRegistry(a.getProvideRegistry());
|
|
1487
1452
|
}
|
|
1488
1453
|
this.unregisteredControllers.unshift(this);
|
|
@@ -1490,8 +1455,7 @@ function _define_property(obj, key$3, value) {
|
|
|
1490
1455
|
for (const a of this.adapters) await (a.onInit && a.onInit(this));
|
|
1491
1456
|
}
|
|
1492
1457
|
async bindControllers() {
|
|
1493
|
-
const
|
|
1494
|
-
const thisMeta = meta.read(this);
|
|
1458
|
+
const thisMeta = getMoostMate().read(this);
|
|
1495
1459
|
const provide = {
|
|
1496
1460
|
...thisMeta?.provide,
|
|
1497
1461
|
...this.provide
|
|
@@ -1512,12 +1476,10 @@ function _define_property(obj, key$3, value) {
|
|
|
1512
1476
|
this.unregisteredControllers = [];
|
|
1513
1477
|
}
|
|
1514
1478
|
async bindController(controller, provide, replace, globalPrefix, replaceOwnPrefix) {
|
|
1515
|
-
const
|
|
1516
|
-
const classMeta = mate$1.read(controller);
|
|
1479
|
+
const classMeta = getMoostMate().read(controller);
|
|
1517
1480
|
const infact = getMoostInfact();
|
|
1518
|
-
const isControllerConsructor = (0,
|
|
1519
|
-
const
|
|
1520
|
-
const computedPrefix = `${globalPrefix}/${ownPrefix}`;
|
|
1481
|
+
const isControllerConsructor = (0, _prostojs_mate.isConstructor)(controller);
|
|
1482
|
+
const computedPrefix = `${globalPrefix}/${typeof replaceOwnPrefix === "string" ? replaceOwnPrefix : classMeta?.controller?.prefix || ""}`;
|
|
1521
1483
|
const pipes = mergeSorted(this.pipes, classMeta?.pipes);
|
|
1522
1484
|
let instance;
|
|
1523
1485
|
const infactOpts = {
|
|
@@ -1525,7 +1487,7 @@ function _define_property(obj, key$3, value) {
|
|
|
1525
1487
|
replace,
|
|
1526
1488
|
customData: { pipes }
|
|
1527
1489
|
};
|
|
1528
|
-
if (isControllerConsructor && (classMeta?.injectable === "SINGLETON" || classMeta?.injectable === true)) await (0,
|
|
1490
|
+
if (isControllerConsructor && (classMeta?.injectable === "SINGLETON" || classMeta?.injectable === true)) await (0, _wooksjs_event_core.createEventContext)({ logger: this.logger }, async () => {
|
|
1529
1491
|
setControllerContext(this, "bindController", "", { prefix: computedPrefix });
|
|
1530
1492
|
instance = await infact.get(controller, infactOpts);
|
|
1531
1493
|
});
|
|
@@ -1534,7 +1496,7 @@ function _define_property(obj, key$3, value) {
|
|
|
1534
1496
|
infact.setInstanceRegistries(instance, provide, replace, { pipes });
|
|
1535
1497
|
}
|
|
1536
1498
|
const getInstance = instance ? () => instance : async () => await infact.get(controller, { ...infactOpts });
|
|
1537
|
-
const classConstructor = (0,
|
|
1499
|
+
const classConstructor = (0, _prostojs_mate.isConstructor)(controller) ? controller : (0, _prostojs_mate.getConstructor)(controller);
|
|
1538
1500
|
this.controllersOverview.push(await bindControllerMethods({
|
|
1539
1501
|
getInstance,
|
|
1540
1502
|
classConstructor,
|
|
@@ -1559,7 +1521,7 @@ function _define_property(obj, key$3, value) {
|
|
|
1559
1521
|
...classMeta.replace
|
|
1560
1522
|
};
|
|
1561
1523
|
for (const ic of classMeta.importController) if (ic.typeResolver) {
|
|
1562
|
-
const isConstr = (0,
|
|
1524
|
+
const isConstr = (0, _prostojs_mate.isConstructor)(ic.typeResolver);
|
|
1563
1525
|
const isFunc = typeof ic.typeResolver === "function";
|
|
1564
1526
|
await this.bindController(isConstr ? ic.typeResolver : isFunc ? await ic.typeResolver() : ic.typeResolver, ic.provide ? {
|
|
1565
1527
|
...mergedProvide,
|
|
@@ -1587,18 +1549,16 @@ function _define_property(obj, key$3, value) {
|
|
|
1587
1549
|
* @returns IterceptorHandler
|
|
1588
1550
|
*/ getGlobalInterceptorHandler() {
|
|
1589
1551
|
if (!this.globalInterceptorHandler) {
|
|
1590
|
-
const
|
|
1591
|
-
const thisMeta = mate$1.read(this);
|
|
1552
|
+
const thisMeta = getMoostMate().read(this);
|
|
1592
1553
|
const pipes = mergeSorted(this.pipes, thisMeta?.pipes);
|
|
1593
|
-
|
|
1594
|
-
this.globalInterceptorHandler = getIterceptorHandlerFactory(interceptors, () => this, pipes);
|
|
1554
|
+
this.globalInterceptorHandler = getIterceptorHandlerFactory(mergeSorted(this.interceptors, thisMeta?.interceptors), () => this, pipes);
|
|
1595
1555
|
}
|
|
1596
1556
|
return this.globalInterceptorHandler();
|
|
1597
1557
|
}
|
|
1598
1558
|
applyGlobalInterceptors(...items) {
|
|
1599
|
-
const mate
|
|
1559
|
+
const mate = getMoostMate();
|
|
1600
1560
|
for (const item of items) if (typeof item === "function") {
|
|
1601
|
-
const meta = mate
|
|
1561
|
+
const meta = mate.read(item);
|
|
1602
1562
|
this.interceptors.push({
|
|
1603
1563
|
handler: item,
|
|
1604
1564
|
priority: meta?.interceptor?.priority ?? TInterceptorPriority.INTERCEPTOR,
|
|
@@ -1649,11 +1609,11 @@ function _define_property(obj, key$3, value) {
|
|
|
1649
1609
|
this.logger.info(`${prefix || ""}${c}${eventName} ${"\x1B[0m\x1B[2m\x1B[32m" + c}→ ${classConstructor.name}.${"\x1B[36m" + c}${method}[32m()${coff}`);
|
|
1650
1610
|
}
|
|
1651
1611
|
constructor(options) {
|
|
1652
|
-
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, "provide", void 0), _define_property(this, "replace", void 0), _define_property(this, "unregisteredControllers", void 0), _define_property(this, "globalInterceptorHandler", void 0), this.options = options, this.pipes = Array.from(sharedPipes), this.interceptors = [], this.adapters = [], this.controllersOverview = [], this.provide = (0,
|
|
1612
|
+
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, "provide", void 0), _define_property(this, "replace", void 0), _define_property(this, "unregisteredControllers", void 0), _define_property(this, "globalInterceptorHandler", void 0), this.options = options, this.pipes = Array.from(sharedPipes), this.interceptors = [], this.adapters = [], this.controllersOverview = [], this.provide = (0, _prostojs_infact.createProvideRegistry)([_prostojs_infact.Infact, getMoostInfact], [_prostojs_mate.Mate, getMoostMate]), this.replace = {}, this.unregisteredControllers = [];
|
|
1653
1613
|
this.logger = options?.logger || getDefaultLogger(`[2m[35mmoost`);
|
|
1654
1614
|
setDefaultLogger(this.logger);
|
|
1655
|
-
const mate
|
|
1656
|
-
Object.assign(mate
|
|
1615
|
+
const mate = getMoostMate();
|
|
1616
|
+
Object.assign(mate, { logger: this.getLogger("mate") });
|
|
1657
1617
|
}
|
|
1658
1618
|
};
|
|
1659
1619
|
|
|
@@ -1667,7 +1627,7 @@ exports.ConstFactory = ConstFactory;
|
|
|
1667
1627
|
Object.defineProperty(exports, 'ContextInjector', {
|
|
1668
1628
|
enumerable: true,
|
|
1669
1629
|
get: function () {
|
|
1670
|
-
return
|
|
1630
|
+
return _wooksjs_event_core.ContextInjector;
|
|
1671
1631
|
}
|
|
1672
1632
|
});
|
|
1673
1633
|
exports.Controller = Controller;
|
|
@@ -1696,7 +1656,7 @@ exports.Pipe = Pipe;
|
|
|
1696
1656
|
Object.defineProperty(exports, 'ProstoLogger', {
|
|
1697
1657
|
enumerable: true,
|
|
1698
1658
|
get: function () {
|
|
1699
|
-
return
|
|
1659
|
+
return _prostojs_logger.ProstoLogger;
|
|
1700
1660
|
}
|
|
1701
1661
|
});
|
|
1702
1662
|
exports.Provide = Provide;
|
|
@@ -1710,7 +1670,7 @@ exports.Value = Value;
|
|
|
1710
1670
|
Object.defineProperty(exports, 'cached', {
|
|
1711
1671
|
enumerable: true,
|
|
1712
1672
|
get: function () {
|
|
1713
|
-
return
|
|
1673
|
+
return _wooksjs_event_core.cached;
|
|
1714
1674
|
}
|
|
1715
1675
|
});
|
|
1716
1676
|
Object.defineProperty(exports, 'clearGlobalWooks', {
|
|
@@ -1722,26 +1682,26 @@ Object.defineProperty(exports, 'clearGlobalWooks', {
|
|
|
1722
1682
|
Object.defineProperty(exports, 'createEventContext', {
|
|
1723
1683
|
enumerable: true,
|
|
1724
1684
|
get: function () {
|
|
1725
|
-
return
|
|
1685
|
+
return _wooksjs_event_core.createEventContext;
|
|
1726
1686
|
}
|
|
1727
1687
|
});
|
|
1728
1688
|
exports.createLogger = createLogger;
|
|
1729
1689
|
Object.defineProperty(exports, 'createProvideRegistry', {
|
|
1730
1690
|
enumerable: true,
|
|
1731
1691
|
get: function () {
|
|
1732
|
-
return
|
|
1692
|
+
return _prostojs_infact.createProvideRegistry;
|
|
1733
1693
|
}
|
|
1734
1694
|
});
|
|
1735
1695
|
Object.defineProperty(exports, 'createReplaceRegistry', {
|
|
1736
1696
|
enumerable: true,
|
|
1737
1697
|
get: function () {
|
|
1738
|
-
return
|
|
1698
|
+
return _prostojs_infact.createReplaceRegistry;
|
|
1739
1699
|
}
|
|
1740
1700
|
});
|
|
1741
1701
|
Object.defineProperty(exports, 'current', {
|
|
1742
1702
|
enumerable: true,
|
|
1743
1703
|
get: function () {
|
|
1744
|
-
return
|
|
1704
|
+
return _wooksjs_event_core.current;
|
|
1745
1705
|
}
|
|
1746
1706
|
});
|
|
1747
1707
|
exports.defineAfterInterceptor = defineAfterInterceptor;
|
|
@@ -1754,19 +1714,19 @@ exports.definePipeFn = definePipeFn;
|
|
|
1754
1714
|
Object.defineProperty(exports, 'eventTypeKey', {
|
|
1755
1715
|
enumerable: true,
|
|
1756
1716
|
get: function () {
|
|
1757
|
-
return
|
|
1717
|
+
return _wooksjs_event_core.eventTypeKey;
|
|
1758
1718
|
}
|
|
1759
1719
|
});
|
|
1760
1720
|
Object.defineProperty(exports, 'getConstructor', {
|
|
1761
1721
|
enumerable: true,
|
|
1762
1722
|
get: function () {
|
|
1763
|
-
return
|
|
1723
|
+
return _prostojs_mate.getConstructor;
|
|
1764
1724
|
}
|
|
1765
1725
|
});
|
|
1766
1726
|
Object.defineProperty(exports, 'getContextInjector', {
|
|
1767
1727
|
enumerable: true,
|
|
1768
1728
|
get: function () {
|
|
1769
|
-
return
|
|
1729
|
+
return _wooksjs_event_core.getContextInjector;
|
|
1770
1730
|
}
|
|
1771
1731
|
});
|
|
1772
1732
|
Object.defineProperty(exports, 'getGlobalWooks', {
|
|
@@ -1784,14 +1744,14 @@ exports.getNewMoostInfact = getNewMoostInfact;
|
|
|
1784
1744
|
Object.defineProperty(exports, 'isConstructor', {
|
|
1785
1745
|
enumerable: true,
|
|
1786
1746
|
get: function () {
|
|
1787
|
-
return
|
|
1747
|
+
return _prostojs_mate.isConstructor;
|
|
1788
1748
|
}
|
|
1789
1749
|
});
|
|
1790
1750
|
exports.isThenable = isThenable;
|
|
1791
1751
|
Object.defineProperty(exports, 'key', {
|
|
1792
1752
|
enumerable: true,
|
|
1793
1753
|
get: function () {
|
|
1794
|
-
return
|
|
1754
|
+
return _wooksjs_event_core.key;
|
|
1795
1755
|
}
|
|
1796
1756
|
});
|
|
1797
1757
|
exports.loggerConsoleTransport = loggerConsoleTransport;
|
|
@@ -1800,20 +1760,20 @@ exports.registerEventScope = registerEventScope;
|
|
|
1800
1760
|
Object.defineProperty(exports, 'replaceContextInjector', {
|
|
1801
1761
|
enumerable: true,
|
|
1802
1762
|
get: function () {
|
|
1803
|
-
return
|
|
1763
|
+
return _wooksjs_event_core.replaceContextInjector;
|
|
1804
1764
|
}
|
|
1805
1765
|
});
|
|
1806
1766
|
Object.defineProperty(exports, 'resetContextInjector', {
|
|
1807
1767
|
enumerable: true,
|
|
1808
1768
|
get: function () {
|
|
1809
|
-
return
|
|
1769
|
+
return _wooksjs_event_core.resetContextInjector;
|
|
1810
1770
|
}
|
|
1811
1771
|
});
|
|
1812
1772
|
exports.resolvePipe = resolvePipe;
|
|
1813
1773
|
Object.defineProperty(exports, 'run', {
|
|
1814
1774
|
enumerable: true,
|
|
1815
1775
|
get: function () {
|
|
1816
|
-
return
|
|
1776
|
+
return _wooksjs_event_core.run;
|
|
1817
1777
|
}
|
|
1818
1778
|
});
|
|
1819
1779
|
exports.setControllerContext = setControllerContext;
|
|
@@ -1825,7 +1785,7 @@ exports.useInterceptResult = useInterceptResult;
|
|
|
1825
1785
|
Object.defineProperty(exports, 'useLogger', {
|
|
1826
1786
|
enumerable: true,
|
|
1827
1787
|
get: function () {
|
|
1828
|
-
return
|
|
1788
|
+
return _wooksjs_event_core.useLogger;
|
|
1829
1789
|
}
|
|
1830
1790
|
});
|
|
1831
1791
|
exports.useOvertake = useOvertake;
|
package/dist/index.mjs
CHANGED
|
@@ -64,8 +64,7 @@ function runPipes(pipes, initialValue, metas, level) {
|
|
|
64
64
|
|
|
65
65
|
//#endregion
|
|
66
66
|
//#region packages/moost/src/metadata/moost-metadata.ts
|
|
67
|
-
const
|
|
68
|
-
const moostMate = new Mate(METADATA_WORKSPACE, {
|
|
67
|
+
const moostMate = new Mate("moost", {
|
|
69
68
|
readType: true,
|
|
70
69
|
readReturnType: true,
|
|
71
70
|
collectPropKeys: true,
|
|
@@ -118,7 +117,7 @@ const scopeVarsMap = /* @__PURE__ */ new Map();
|
|
|
118
117
|
/**
|
|
119
118
|
* Get Infact instance (used for Dependency Injections)
|
|
120
119
|
*/ function getNewMoostInfact() {
|
|
121
|
-
|
|
120
|
+
return new Infact({
|
|
122
121
|
describeClass(classConstructor) {
|
|
123
122
|
const meta = getMoostMate().read(classConstructor);
|
|
124
123
|
return {
|
|
@@ -142,15 +141,14 @@ const scopeVarsMap = /* @__PURE__ */ new Map();
|
|
|
142
141
|
instantiate
|
|
143
142
|
}, "PARAM");
|
|
144
143
|
},
|
|
145
|
-
describeProp(classConstructor, key
|
|
146
|
-
|
|
147
|
-
return meta;
|
|
144
|
+
describeProp(classConstructor, key) {
|
|
145
|
+
return getMoostMate().read(classConstructor, key);
|
|
148
146
|
},
|
|
149
|
-
resolveProp({ instance, key
|
|
147
|
+
resolveProp({ instance, key, initialValue, propMeta, scopeId, classMeta, customData, classConstructor, instantiate }) {
|
|
150
148
|
if (propMeta && customData?.pipes) return runPipes(customData.pipes, initialValue, {
|
|
151
149
|
instance,
|
|
152
150
|
type: classConstructor,
|
|
153
|
-
key
|
|
151
|
+
key,
|
|
154
152
|
scopeId,
|
|
155
153
|
propMeta,
|
|
156
154
|
targetMeta: propMeta,
|
|
@@ -166,14 +164,12 @@ const scopeVarsMap = /* @__PURE__ */ new Map();
|
|
|
166
164
|
if (loggingOptions.newInstance === false || !(loggingOptions.newInstance === scope || loggingOptions.newInstance === "SINGLETON" && scope === true)) return;
|
|
167
165
|
break;
|
|
168
166
|
}
|
|
169
|
-
case "warn":
|
|
167
|
+
case "warn":
|
|
170
168
|
if (!loggingOptions.warn) return;
|
|
171
169
|
break;
|
|
172
|
-
|
|
173
|
-
case "error": {
|
|
170
|
+
case "error":
|
|
174
171
|
if (!loggingOptions.error) return;
|
|
175
172
|
break;
|
|
176
|
-
}
|
|
177
173
|
default:
|
|
178
174
|
}
|
|
179
175
|
let logger;
|
|
@@ -192,11 +188,10 @@ const scopeVarsMap = /* @__PURE__ */ new Map();
|
|
|
192
188
|
case "number":
|
|
193
189
|
case "boolean": return `[33m${a}[2m[34m`;
|
|
194
190
|
case "string": return `[92m"${a.slice(0, 1)}..."[2m[34m`;
|
|
195
|
-
case "object":
|
|
191
|
+
case "object":
|
|
196
192
|
if (Array.isArray(a)) return `[${a.length}]`;
|
|
197
193
|
if (getConstructor$1(a)) return getConstructor$1(a).name;
|
|
198
194
|
return "{}";
|
|
199
|
-
}
|
|
200
195
|
default: return "*";
|
|
201
196
|
}
|
|
202
197
|
}).map((a) => `[2m[1m${a}[22m[2m`).join(", ") || "";
|
|
@@ -217,7 +212,6 @@ const scopeVarsMap = /* @__PURE__ */ new Map();
|
|
|
217
212
|
}
|
|
218
213
|
}
|
|
219
214
|
});
|
|
220
|
-
return infactInstance;
|
|
221
215
|
}
|
|
222
216
|
|
|
223
217
|
//#endregion
|
|
@@ -480,7 +474,7 @@ function getParentProps(constructor) {
|
|
|
480
474
|
* The returned function runs pipes for each parameter and returns
|
|
481
475
|
* `unknown[]` synchronously when possible, or `Promise<unknown[]>` otherwise.
|
|
482
476
|
*/ function resolveArguments(argsPipes, context) {
|
|
483
|
-
if (argsPipes.length === 0) return
|
|
477
|
+
if (argsPipes.length === 0) return;
|
|
484
478
|
return () => {
|
|
485
479
|
const args = [];
|
|
486
480
|
let hasAsync = false;
|
|
@@ -505,14 +499,14 @@ function getParentProps(constructor) {
|
|
|
505
499
|
|
|
506
500
|
//#endregion
|
|
507
501
|
//#region packages/moost/src/interceptor-handler.ts
|
|
508
|
-
function _define_property$1(obj, key
|
|
509
|
-
if (key
|
|
502
|
+
function _define_property$1(obj, key, value) {
|
|
503
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
510
504
|
value,
|
|
511
505
|
enumerable: true,
|
|
512
506
|
configurable: true,
|
|
513
507
|
writable: true
|
|
514
508
|
});
|
|
515
|
-
else obj[key
|
|
509
|
+
else obj[key] = value;
|
|
516
510
|
return obj;
|
|
517
511
|
}
|
|
518
512
|
/**
|
|
@@ -551,7 +545,6 @@ function _define_property$1(obj, key$2, value) {
|
|
|
551
545
|
const result = ci ? ci.with(spanName, { "moost.interceptor.stage": "before" }, () => def.before?.(this.getReplyFn())) : def.before(this.getReplyFn());
|
|
552
546
|
if (isThenable(result)) return result;
|
|
553
547
|
}
|
|
554
|
-
return void 0;
|
|
555
548
|
}
|
|
556
549
|
before() {
|
|
557
550
|
const ci = getContextInjector$1();
|
|
@@ -645,8 +638,7 @@ function findInterceptorMethods(handler) {
|
|
|
645
638
|
const methods = getInstanceOwnMethods(fakeInstance);
|
|
646
639
|
const result = {};
|
|
647
640
|
for (const method of methods) {
|
|
648
|
-
const
|
|
649
|
-
const hook = methodMeta?.interceptorHook;
|
|
641
|
+
const hook = mate.read(fakeInstance, method)?.interceptorHook;
|
|
650
642
|
if (hook === "before" || hook === "after" || hook === "error") result[hook] = method;
|
|
651
643
|
}
|
|
652
644
|
return result;
|
|
@@ -659,7 +651,7 @@ function buildMethodResolver(opts) {
|
|
|
659
651
|
meta: p,
|
|
660
652
|
pipes: mergeSorted(opts.pipes, p.pipes)
|
|
661
653
|
});
|
|
662
|
-
if (argsPipes.length === 0) return
|
|
654
|
+
if (argsPipes.length === 0) return;
|
|
663
655
|
return resolveArguments(argsPipes, {
|
|
664
656
|
classMeta: opts.classMeta,
|
|
665
657
|
methodMeta,
|
|
@@ -775,8 +767,7 @@ async function bindControllerMethods(options) {
|
|
|
775
767
|
opts.provide = opts.provide || {};
|
|
776
768
|
const fakeInstance = Object.create(classConstructor.prototype);
|
|
777
769
|
const methods = getInstanceOwnMethods(fakeInstance);
|
|
778
|
-
const
|
|
779
|
-
const meta = mate$1.read(classConstructor) || {};
|
|
770
|
+
const meta = getMoostMate().read(classConstructor) || {};
|
|
780
771
|
const ownPrefix = typeof opts.replaceOwnPrefix === "string" ? opts.replaceOwnPrefix : meta.controller?.prefix || "";
|
|
781
772
|
const prefix = `${opts.globalPrefix}/${ownPrefix}`;
|
|
782
773
|
const controllerOverview = {
|
|
@@ -789,8 +780,7 @@ async function bindControllerMethods(options) {
|
|
|
789
780
|
const methodMeta = getMoostMate().read(fakeInstance, method) || {};
|
|
790
781
|
if (!methodMeta.handlers?.length) continue;
|
|
791
782
|
const pipes = mergeSorted(opts.pipes, methodMeta.pipes);
|
|
792
|
-
const
|
|
793
|
-
const getIterceptorHandler = getIterceptorHandlerFactory(interceptors, getInstance, pipes);
|
|
783
|
+
const getIterceptorHandler = getIterceptorHandlerFactory(mergeSorted(opts.interceptors, meta.interceptors, methodMeta.interceptors), getInstance, pipes);
|
|
794
784
|
const argsPipes = [];
|
|
795
785
|
for (const p of methodMeta.params || []) argsPipes.push({
|
|
796
786
|
meta: p,
|
|
@@ -865,8 +855,7 @@ async function bindControllerMethods(options) {
|
|
|
865
855
|
* @param decorators - array of decorators
|
|
866
856
|
* @returns
|
|
867
857
|
*/ function ApplyDecorators(...decorators) {
|
|
868
|
-
|
|
869
|
-
return mate$1.apply(...decorators);
|
|
858
|
+
return getMoostMate().apply(...decorators);
|
|
870
859
|
}
|
|
871
860
|
/**
|
|
872
861
|
* ## Label
|
|
@@ -920,11 +909,11 @@ async function bindControllerMethods(options) {
|
|
|
920
909
|
*
|
|
921
910
|
* Stores Required metadata
|
|
922
911
|
*/ function Required() {
|
|
923
|
-
const mate
|
|
924
|
-
return mate
|
|
925
|
-
if (typeof index !== "number" && meta && ["string", "symbol"].includes(typeof key
|
|
912
|
+
const mate = getMoostMate();
|
|
913
|
+
return mate.apply(mate.decorate("required", true), mate.decorateClass((meta, level, key, index) => {
|
|
914
|
+
if (typeof index !== "number" && meta && ["string", "symbol"].includes(typeof key)) {
|
|
926
915
|
meta.requiredProps = meta.requiredProps || [];
|
|
927
|
-
meta.requiredProps.push(key
|
|
916
|
+
meta.requiredProps.push(key);
|
|
928
917
|
}
|
|
929
918
|
return meta;
|
|
930
919
|
}));
|
|
@@ -956,8 +945,8 @@ const insureInjectable = getMoostMate().decorate((meta) => {
|
|
|
956
945
|
* Set Class as a Controller
|
|
957
946
|
* @param prefix - define the prefix for all the paths of this controller
|
|
958
947
|
*/ function Controller(prefix) {
|
|
959
|
-
const mate
|
|
960
|
-
return mate
|
|
948
|
+
const mate = getMoostMate();
|
|
949
|
+
return mate.apply(insureInjectable, mate.decorate("controller", { prefix: prefix || "" }));
|
|
961
950
|
}
|
|
962
951
|
function ImportController(prefix, controller, provide) {
|
|
963
952
|
return getMoostMate().decorate("importController", {
|
|
@@ -978,15 +967,15 @@ function ImportController(prefix, controller, provide) {
|
|
|
978
967
|
|
|
979
968
|
//#endregion
|
|
980
969
|
//#region packages/moost/src/decorators/intercept.decorator.ts
|
|
981
|
-
var TInterceptorPriority = /* @__PURE__ */ function(TInterceptorPriority
|
|
982
|
-
TInterceptorPriority
|
|
983
|
-
TInterceptorPriority
|
|
984
|
-
TInterceptorPriority
|
|
985
|
-
TInterceptorPriority
|
|
986
|
-
TInterceptorPriority
|
|
987
|
-
TInterceptorPriority
|
|
988
|
-
TInterceptorPriority
|
|
989
|
-
return TInterceptorPriority
|
|
970
|
+
var TInterceptorPriority = /* @__PURE__ */ function(TInterceptorPriority) {
|
|
971
|
+
TInterceptorPriority[TInterceptorPriority["BEFORE_ALL"] = 0] = "BEFORE_ALL";
|
|
972
|
+
TInterceptorPriority[TInterceptorPriority["BEFORE_GUARD"] = 1] = "BEFORE_GUARD";
|
|
973
|
+
TInterceptorPriority[TInterceptorPriority["GUARD"] = 2] = "GUARD";
|
|
974
|
+
TInterceptorPriority[TInterceptorPriority["AFTER_GUARD"] = 3] = "AFTER_GUARD";
|
|
975
|
+
TInterceptorPriority[TInterceptorPriority["INTERCEPTOR"] = 4] = "INTERCEPTOR";
|
|
976
|
+
TInterceptorPriority[TInterceptorPriority["CATCH_ERROR"] = 5] = "CATCH_ERROR";
|
|
977
|
+
TInterceptorPriority[TInterceptorPriority["AFTER_ALL"] = 6] = "AFTER_ALL";
|
|
978
|
+
return TInterceptorPriority;
|
|
990
979
|
}({});
|
|
991
980
|
/**
|
|
992
981
|
* ## Intercept
|
|
@@ -996,16 +985,16 @@ var TInterceptorPriority = /* @__PURE__ */ function(TInterceptorPriority$1) {
|
|
|
996
985
|
* @param priority — interceptor priority (overrides handler's own priority)
|
|
997
986
|
* @param name — interceptor name for tracing
|
|
998
987
|
*/ function Intercept(handler, priority, name) {
|
|
999
|
-
const mate
|
|
988
|
+
const mate = getMoostMate();
|
|
1000
989
|
if (typeof handler === "function") {
|
|
1001
|
-
const interceptorMeta = mate
|
|
1002
|
-
return mate
|
|
990
|
+
const interceptorMeta = mate.read(handler);
|
|
991
|
+
return mate.decorate("interceptors", {
|
|
1003
992
|
handler,
|
|
1004
993
|
priority: priority ?? interceptorMeta?.interceptor?.priority ?? 4,
|
|
1005
994
|
name: name || handler.name || "<anonymous>"
|
|
1006
995
|
}, true);
|
|
1007
996
|
}
|
|
1008
|
-
return mate
|
|
997
|
+
return mate.decorate("interceptors", {
|
|
1009
998
|
handler,
|
|
1010
999
|
priority: priority ?? handler.priority ?? 4,
|
|
1011
1000
|
name: name || handler._name || "<anonymous>"
|
|
@@ -1021,14 +1010,14 @@ var TInterceptorPriority = /* @__PURE__ */ function(TInterceptorPriority$1) {
|
|
|
1021
1010
|
* @param label - field label
|
|
1022
1011
|
* @paramType unknown
|
|
1023
1012
|
*/ function Resolve(resolver, label) {
|
|
1024
|
-
return (target, key
|
|
1013
|
+
return (target, key, index) => {
|
|
1025
1014
|
const i = typeof index === "number" ? index : void 0;
|
|
1026
1015
|
getMoostMate().decorate("resolver", (metas, level) => {
|
|
1027
1016
|
let newLabel = label;
|
|
1028
1017
|
if (!newLabel && level === "PROP" && typeof metas.key === "string") newLabel = metas.key;
|
|
1029
|
-
fillLabel(target, key
|
|
1018
|
+
fillLabel(target, key || "", i, newLabel);
|
|
1030
1019
|
return resolver(metas, level);
|
|
1031
|
-
})(target, key
|
|
1020
|
+
})(target, key, i);
|
|
1032
1021
|
};
|
|
1033
1022
|
}
|
|
1034
1023
|
/**
|
|
@@ -1064,12 +1053,12 @@ var TInterceptorPriority = /* @__PURE__ */ function(TInterceptorPriority$1) {
|
|
|
1064
1053
|
*/ function ConstFactory(factory, label) {
|
|
1065
1054
|
return Resolve(async () => factory(), label);
|
|
1066
1055
|
}
|
|
1067
|
-
function fillLabel(target, key
|
|
1056
|
+
function fillLabel(target, key, index, name) {
|
|
1068
1057
|
if (name) {
|
|
1069
|
-
const meta = getMoostMate().read(target, key
|
|
1058
|
+
const meta = getMoostMate().read(target, key);
|
|
1070
1059
|
if (typeof index === "number") {
|
|
1071
|
-
if (!meta?.params?.[index]?.label) Label(name)(target, key
|
|
1072
|
-
} else if (!meta?.label) Label(name)(target, key
|
|
1060
|
+
if (!meta?.params?.[index]?.label) Label(name)(target, key, index);
|
|
1061
|
+
} else if (!meta?.label) Label(name)(target, key);
|
|
1073
1062
|
}
|
|
1074
1063
|
}
|
|
1075
1064
|
|
|
@@ -1087,10 +1076,10 @@ function fillLabel(target, key$2, index, name) {
|
|
|
1087
1076
|
* @param priority — interceptor priority (default: INTERCEPTOR)
|
|
1088
1077
|
* @param scope — DI scope ('FOR_EVENT' | 'SINGLETON' | true)
|
|
1089
1078
|
*/ function Interceptor(priority, scope) {
|
|
1090
|
-
const mate
|
|
1091
|
-
const decorators = [insureInjectable, mate
|
|
1092
|
-
if (scope) decorators.push(mate
|
|
1093
|
-
return mate
|
|
1079
|
+
const mate = getMoostMate();
|
|
1080
|
+
const decorators = [insureInjectable, mate.decorate("interceptor", { priority: priority ?? TInterceptorPriority.INTERCEPTOR })];
|
|
1081
|
+
if (scope) decorators.push(mate.decorate("injectable", scope));
|
|
1082
|
+
return mate.apply(...decorators);
|
|
1094
1083
|
}
|
|
1095
1084
|
/**
|
|
1096
1085
|
* ## @Before
|
|
@@ -1172,17 +1161,17 @@ function fillLabel(target, key$2, index, name) {
|
|
|
1172
1161
|
|
|
1173
1162
|
//#endregion
|
|
1174
1163
|
//#region packages/moost/src/pipes/types.ts
|
|
1175
|
-
/** Execution priority for pipes. Lower values run first. */ var TPipePriority = /* @__PURE__ */ function(TPipePriority
|
|
1176
|
-
TPipePriority
|
|
1177
|
-
TPipePriority
|
|
1178
|
-
TPipePriority
|
|
1179
|
-
TPipePriority
|
|
1180
|
-
TPipePriority
|
|
1181
|
-
TPipePriority
|
|
1182
|
-
TPipePriority
|
|
1183
|
-
TPipePriority
|
|
1184
|
-
TPipePriority
|
|
1185
|
-
return TPipePriority
|
|
1164
|
+
/** Execution priority for pipes. Lower values run first. */ var TPipePriority = /* @__PURE__ */ function(TPipePriority) {
|
|
1165
|
+
TPipePriority[TPipePriority["BEFORE_RESOLVE"] = 0] = "BEFORE_RESOLVE";
|
|
1166
|
+
TPipePriority[TPipePriority["RESOLVE"] = 1] = "RESOLVE";
|
|
1167
|
+
TPipePriority[TPipePriority["AFTER_RESOLVE"] = 2] = "AFTER_RESOLVE";
|
|
1168
|
+
TPipePriority[TPipePriority["BEFORE_TRANSFORM"] = 3] = "BEFORE_TRANSFORM";
|
|
1169
|
+
TPipePriority[TPipePriority["TRANSFORM"] = 4] = "TRANSFORM";
|
|
1170
|
+
TPipePriority[TPipePriority["AFTER_TRANSFORM"] = 5] = "AFTER_TRANSFORM";
|
|
1171
|
+
TPipePriority[TPipePriority["BEFORE_VALIDATE"] = 6] = "BEFORE_VALIDATE";
|
|
1172
|
+
TPipePriority[TPipePriority["VALIDATE"] = 7] = "VALIDATE";
|
|
1173
|
+
TPipePriority[TPipePriority["AFTER_VALIDATE"] = 8] = "AFTER_VALIDATE";
|
|
1174
|
+
return TPipePriority;
|
|
1186
1175
|
}({});
|
|
1187
1176
|
|
|
1188
1177
|
//#endregion
|
|
@@ -1253,7 +1242,6 @@ function fillLabel(target, key$2, index, name) {
|
|
|
1253
1242
|
*/ function InjectScopeVars(name) {
|
|
1254
1243
|
return Resolve(({ scopeId }) => {
|
|
1255
1244
|
if (scopeId) return name ? getInfactScopeVars(scopeId)?.[name] : getInfactScopeVars(scopeId);
|
|
1256
|
-
return void 0;
|
|
1257
1245
|
});
|
|
1258
1246
|
}
|
|
1259
1247
|
|
|
@@ -1353,7 +1341,6 @@ function fillLabel(target, key$2, index, name) {
|
|
|
1353
1341
|
const resolvePipe = definePipeFn((_value, metas, level) => {
|
|
1354
1342
|
const resolver = metas.targetMeta?.resolver;
|
|
1355
1343
|
if (resolver) return resolver(metas, level);
|
|
1356
|
-
return void 0;
|
|
1357
1344
|
}, TPipePriority.RESOLVE);
|
|
1358
1345
|
|
|
1359
1346
|
//#endregion
|
|
@@ -1365,14 +1352,14 @@ const sharedPipes = [{
|
|
|
1365
1352
|
|
|
1366
1353
|
//#endregion
|
|
1367
1354
|
//#region packages/moost/src/moost.ts
|
|
1368
|
-
function _define_property(obj, key
|
|
1369
|
-
if (key
|
|
1355
|
+
function _define_property(obj, key, value) {
|
|
1356
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
1370
1357
|
value,
|
|
1371
1358
|
enumerable: true,
|
|
1372
1359
|
configurable: true,
|
|
1373
1360
|
writable: true
|
|
1374
1361
|
});
|
|
1375
|
-
else obj[key
|
|
1362
|
+
else obj[key] = value;
|
|
1376
1363
|
return obj;
|
|
1377
1364
|
}
|
|
1378
1365
|
/**
|
|
@@ -1467,8 +1454,7 @@ function _define_property(obj, key$2, value) {
|
|
|
1467
1454
|
for (const a of this.adapters) await (a.onInit && a.onInit(this));
|
|
1468
1455
|
}
|
|
1469
1456
|
async bindControllers() {
|
|
1470
|
-
const
|
|
1471
|
-
const thisMeta = meta.read(this);
|
|
1457
|
+
const thisMeta = getMoostMate().read(this);
|
|
1472
1458
|
const provide = {
|
|
1473
1459
|
...thisMeta?.provide,
|
|
1474
1460
|
...this.provide
|
|
@@ -1489,12 +1475,10 @@ function _define_property(obj, key$2, value) {
|
|
|
1489
1475
|
this.unregisteredControllers = [];
|
|
1490
1476
|
}
|
|
1491
1477
|
async bindController(controller, provide, replace, globalPrefix, replaceOwnPrefix) {
|
|
1492
|
-
const
|
|
1493
|
-
const classMeta = mate$1.read(controller);
|
|
1478
|
+
const classMeta = getMoostMate().read(controller);
|
|
1494
1479
|
const infact = getMoostInfact();
|
|
1495
1480
|
const isControllerConsructor = isConstructor$1(controller);
|
|
1496
|
-
const
|
|
1497
|
-
const computedPrefix = `${globalPrefix}/${ownPrefix}`;
|
|
1481
|
+
const computedPrefix = `${globalPrefix}/${typeof replaceOwnPrefix === "string" ? replaceOwnPrefix : classMeta?.controller?.prefix || ""}`;
|
|
1498
1482
|
const pipes = mergeSorted(this.pipes, classMeta?.pipes);
|
|
1499
1483
|
let instance;
|
|
1500
1484
|
const infactOpts = {
|
|
@@ -1564,18 +1548,16 @@ function _define_property(obj, key$2, value) {
|
|
|
1564
1548
|
* @returns IterceptorHandler
|
|
1565
1549
|
*/ getGlobalInterceptorHandler() {
|
|
1566
1550
|
if (!this.globalInterceptorHandler) {
|
|
1567
|
-
const
|
|
1568
|
-
const thisMeta = mate$1.read(this);
|
|
1551
|
+
const thisMeta = getMoostMate().read(this);
|
|
1569
1552
|
const pipes = mergeSorted(this.pipes, thisMeta?.pipes);
|
|
1570
|
-
|
|
1571
|
-
this.globalInterceptorHandler = getIterceptorHandlerFactory(interceptors, () => this, pipes);
|
|
1553
|
+
this.globalInterceptorHandler = getIterceptorHandlerFactory(mergeSorted(this.interceptors, thisMeta?.interceptors), () => this, pipes);
|
|
1572
1554
|
}
|
|
1573
1555
|
return this.globalInterceptorHandler();
|
|
1574
1556
|
}
|
|
1575
1557
|
applyGlobalInterceptors(...items) {
|
|
1576
|
-
const mate
|
|
1558
|
+
const mate = getMoostMate();
|
|
1577
1559
|
for (const item of items) if (typeof item === "function") {
|
|
1578
|
-
const meta = mate
|
|
1560
|
+
const meta = mate.read(item);
|
|
1579
1561
|
this.interceptors.push({
|
|
1580
1562
|
handler: item,
|
|
1581
1563
|
priority: meta?.interceptor?.priority ?? TInterceptorPriority.INTERCEPTOR,
|
|
@@ -1629,8 +1611,8 @@ function _define_property(obj, key$2, value) {
|
|
|
1629
1611
|
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, "provide", void 0), _define_property(this, "replace", void 0), _define_property(this, "unregisteredControllers", void 0), _define_property(this, "globalInterceptorHandler", void 0), this.options = options, this.pipes = Array.from(sharedPipes), this.interceptors = [], this.adapters = [], this.controllersOverview = [], this.provide = createProvideRegistry$1([Infact, getMoostInfact], [Mate, getMoostMate]), this.replace = {}, this.unregisteredControllers = [];
|
|
1630
1612
|
this.logger = options?.logger || getDefaultLogger(`[2m[35mmoost`);
|
|
1631
1613
|
setDefaultLogger(this.logger);
|
|
1632
|
-
const mate
|
|
1633
|
-
Object.assign(mate
|
|
1614
|
+
const mate = getMoostMate();
|
|
1615
|
+
Object.assign(mate, { logger: this.getLogger("mate") });
|
|
1634
1616
|
}
|
|
1635
1617
|
};
|
|
1636
1618
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moost",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.12",
|
|
4
4
|
"description": "moost",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"composables",
|
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
"@prostojs/infact": "^0.4.1",
|
|
42
42
|
"@prostojs/logger": "^0.4.3",
|
|
43
43
|
"@prostojs/mate": "^0.4.0",
|
|
44
|
-
"@wooksjs/event-core": "^0.7.
|
|
44
|
+
"@wooksjs/event-core": "^0.7.12",
|
|
45
45
|
"hookable": "^5.5.3",
|
|
46
|
-
"wooks": "^0.7.
|
|
46
|
+
"wooks": "^0.7.12"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@wooksjs/event-http": "^0.7.
|
|
50
|
-
"@wooksjs/http-body": "^0.7.
|
|
49
|
+
"@wooksjs/event-http": "^0.7.12",
|
|
50
|
+
"@wooksjs/http-body": "^0.7.12",
|
|
51
51
|
"vitest": "3.2.4",
|
|
52
|
-
"@moostjs/event-http": "^0.6.
|
|
52
|
+
"@moostjs/event-http": "^0.6.12"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"pub": "pnpm publish --access public",
|