moost 0.5.28 → 0.5.30
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 +360 -116
- package/dist/index.d.ts +363 -13
- package/dist/index.mjs +342 -100
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Mate, getConstructor, isConstructor } from "@prostojs/mate";
|
|
2
|
-
import { ContextInjector, EventLogger, createAsyncEventContext, getContextInjector, replaceContextInjector, useAsyncEventContext, useEventId, useEventLogger, useRouteParams } from "@wooksjs/event-core";
|
|
3
|
-
import { Infact, createProvideRegistry, createReplaceRegistry } from "@prostojs/infact";
|
|
4
|
-
import { ProstoLogger, coloredConsole, createConsoleTransort } from "@prostojs/logger";
|
|
1
|
+
import { Mate, getConstructor, getConstructor as getConstructor$1, isConstructor, isConstructor as isConstructor$1 } from "@prostojs/mate";
|
|
2
|
+
import { ContextInjector, EventLogger, createAsyncEventContext, getContextInjector, getContextInjector as getContextInjector$1, replaceContextInjector, useAsyncEventContext, useAsyncEventContext as useAsyncEventContext$1, useEventId, useEventLogger, useEventLogger as useEventLogger$1, useRouteParams } from "@wooksjs/event-core";
|
|
3
|
+
import { Infact, createProvideRegistry, createProvideRegistry as createProvideRegistry$1, createReplaceRegistry, createReplaceRegistry as createReplaceRegistry$1 } from "@prostojs/infact";
|
|
4
|
+
import { ProstoLogger, ProstoLogger as ProstoLogger$1, coloredConsole, createConsoleTransort } from "@prostojs/logger";
|
|
5
5
|
import { Hookable } from "hookable";
|
|
6
6
|
import { clearGlobalWooks, getGlobalWooks } from "wooks";
|
|
7
7
|
|
|
@@ -11,12 +11,20 @@ function setDefaultLogger(logger) {
|
|
|
11
11
|
defaultLogger = logger;
|
|
12
12
|
}
|
|
13
13
|
function getDefaultLogger(topic) {
|
|
14
|
-
if (!defaultLogger) defaultLogger = new ProstoLogger({
|
|
14
|
+
if (!defaultLogger) defaultLogger = new ProstoLogger$1({
|
|
15
15
|
level: 4,
|
|
16
|
-
transports: [
|
|
16
|
+
transports: [loggerConsoleTransport]
|
|
17
17
|
});
|
|
18
|
-
return topic && defaultLogger instanceof ProstoLogger ? defaultLogger.createTopic(topic) : defaultLogger;
|
|
18
|
+
return topic && defaultLogger instanceof ProstoLogger$1 ? defaultLogger.createTopic(topic) : defaultLogger;
|
|
19
19
|
}
|
|
20
|
+
function createLogger(opts) {
|
|
21
|
+
return new ProstoLogger$1({
|
|
22
|
+
...opts,
|
|
23
|
+
level: opts?.level ?? 4,
|
|
24
|
+
transports: opts?.transports ?? [loggerConsoleTransport]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const loggerConsoleTransport = createConsoleTransort({ format: coloredConsole });
|
|
20
28
|
|
|
21
29
|
//#endregion
|
|
22
30
|
//#region packages/moost/src/pipes/run-pipes.ts
|
|
@@ -46,7 +54,7 @@ function getMoostMate() {
|
|
|
46
54
|
//#endregion
|
|
47
55
|
//#region packages/moost/src/metadata/infact.ts
|
|
48
56
|
const sharedMoostInfact = getNewMoostInfact();
|
|
49
|
-
const INFACT_BANNER =
|
|
57
|
+
const INFACT_BANNER = `[2m[35minfact`;
|
|
50
58
|
let loggingOptions = {
|
|
51
59
|
newInstance: "SINGLETON",
|
|
52
60
|
warn: true,
|
|
@@ -61,15 +69,27 @@ function setInfactLoggingOptions(options) {
|
|
|
61
69
|
function getMoostInfact() {
|
|
62
70
|
return sharedMoostInfact;
|
|
63
71
|
}
|
|
64
|
-
const scopeVarsMap = new Map();
|
|
65
|
-
|
|
72
|
+
const scopeVarsMap = /* @__PURE__ */ new Map();
|
|
73
|
+
/**
|
|
74
|
+
* Define global scope name to be used with `@InjectFromScope` and `@InjectScopeVars` decorators
|
|
75
|
+
*
|
|
76
|
+
* You can read scoped vars with `getInfactScopeVars`
|
|
77
|
+
* @param name scope name
|
|
78
|
+
* @param scopeVars key-value object as scoped vars
|
|
79
|
+
*/ function defineInfactScope(name, scopeVars) {
|
|
66
80
|
scopeVarsMap.set(name, scopeVars);
|
|
67
81
|
getMoostInfact().registerScope(name);
|
|
68
82
|
}
|
|
69
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Read scoped vars defined with `defineInfactScope`
|
|
85
|
+
* @param name scope name
|
|
86
|
+
* @returns key-value object as scoped vars
|
|
87
|
+
*/ function getInfactScopeVars(name) {
|
|
70
88
|
return scopeVarsMap.get(name);
|
|
71
89
|
}
|
|
72
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Get Infact instance (used for Dependency Injections)
|
|
92
|
+
*/ function getNewMoostInfact() {
|
|
73
93
|
return new Infact({
|
|
74
94
|
describeClass(classConstructor) {
|
|
75
95
|
const meta = getMoostMate().read(classConstructor);
|
|
@@ -79,11 +99,11 @@ function getNewMoostInfact() {
|
|
|
79
99
|
constructorParams: meta?.params || [],
|
|
80
100
|
provide: meta?.provide,
|
|
81
101
|
properties: meta?.properties || [],
|
|
82
|
-
scopeId: meta?.injectable === "FOR_EVENT" ? useEventId().getId() :
|
|
102
|
+
scopeId: meta?.injectable === "FOR_EVENT" ? useEventId().getId() : void 0
|
|
83
103
|
};
|
|
84
104
|
},
|
|
85
105
|
resolveParam({ paramMeta, customData, classConstructor, index, scopeId }) {
|
|
86
|
-
if (paramMeta && customData?.pipes) return runPipes(customData.pipes,
|
|
106
|
+
if (paramMeta && customData?.pipes) return runPipes(customData.pipes, void 0, {
|
|
87
107
|
paramMeta,
|
|
88
108
|
type: classConstructor,
|
|
89
109
|
key: "constructor",
|
|
@@ -127,36 +147,36 @@ function getNewMoostInfact() {
|
|
|
127
147
|
}
|
|
128
148
|
let logger;
|
|
129
149
|
try {
|
|
130
|
-
logger = event === "error" ? getDefaultLogger(INFACT_BANNER) : useEventLogger(INFACT_BANNER);
|
|
150
|
+
logger = event === "error" ? getDefaultLogger(INFACT_BANNER) : useEventLogger$1(INFACT_BANNER);
|
|
131
151
|
} catch (error) {
|
|
132
152
|
logger = getDefaultLogger(INFACT_BANNER);
|
|
133
153
|
}
|
|
134
|
-
const instance =
|
|
154
|
+
const instance = `[4m${targetClass.name}[24m`;
|
|
135
155
|
switch (event) {
|
|
136
156
|
case "new-instance": {
|
|
137
157
|
const params = args?.map((a) => {
|
|
138
158
|
switch (typeof a) {
|
|
139
159
|
case "number":
|
|
140
|
-
case "boolean": return
|
|
141
|
-
case "string": return
|
|
160
|
+
case "boolean": return `[33m${a}[2m[34m`;
|
|
161
|
+
case "string": return `[92m"${a.slice(0, 1)}..."[2m[34m`;
|
|
142
162
|
case "object": {
|
|
143
163
|
if (Array.isArray(a)) return `[${a.length}]`;
|
|
144
|
-
if (getConstructor(a)) return getConstructor(a).name;
|
|
164
|
+
if (getConstructor$1(a)) return getConstructor$1(a).name;
|
|
145
165
|
return "{}";
|
|
146
166
|
}
|
|
147
167
|
default: return "*";
|
|
148
168
|
}
|
|
149
|
-
}).map((a) =>
|
|
150
|
-
logger.info(`new ${instance}
|
|
169
|
+
}).map((a) => `[2m[1m${a}[22m[2m`).join(", ") || "";
|
|
170
|
+
logger.info(`new ${instance}[2m[34m(${params})`);
|
|
151
171
|
break;
|
|
152
172
|
}
|
|
153
173
|
case "warn": {
|
|
154
|
-
const hier =
|
|
174
|
+
const hier = `[2m[34m⋱ ${args?.map(String).join(" → ") || ""}`;
|
|
155
175
|
logger.warn(`${instance} - ${message} ${hier}`);
|
|
156
176
|
break;
|
|
157
177
|
}
|
|
158
178
|
case "error": {
|
|
159
|
-
const hier =
|
|
179
|
+
const hier = `[2m[34m⋱ ${args?.map(String).join(" → ") || ""}`;
|
|
160
180
|
logger.error(`Failed to instantiate ${instance}. ${message} ${hier}`);
|
|
161
181
|
break;
|
|
162
182
|
}
|
|
@@ -169,14 +189,14 @@ function getNewMoostInfact() {
|
|
|
169
189
|
//#endregion
|
|
170
190
|
//#region packages/moost/src/composables/controller.composable.ts
|
|
171
191
|
function setControllerContext(controller, method, route) {
|
|
172
|
-
const { store } = useAsyncEventContext();
|
|
192
|
+
const { store } = useAsyncEventContext$1();
|
|
173
193
|
const { set } = store("controller");
|
|
174
194
|
set("instance", controller);
|
|
175
195
|
set("method", method);
|
|
176
196
|
set("route", route);
|
|
177
197
|
}
|
|
178
198
|
function useControllerContext() {
|
|
179
|
-
const { store } = useAsyncEventContext();
|
|
199
|
+
const { store } = useAsyncEventContext$1();
|
|
180
200
|
const { get } = store("controller");
|
|
181
201
|
const getController = () => get("instance");
|
|
182
202
|
const getMethod = () => get("method");
|
|
@@ -210,10 +230,10 @@ function registerEventScope(scopeId) {
|
|
|
210
230
|
};
|
|
211
231
|
}
|
|
212
232
|
function defineMoostEventHandler(options) {
|
|
213
|
-
const ci = getContextInjector();
|
|
233
|
+
const ci = getContextInjector$1();
|
|
214
234
|
return async () => {
|
|
215
235
|
const scopeId = useEventId().getId();
|
|
216
|
-
const logger = useEventLogger(options.loggerTitle);
|
|
236
|
+
const logger = useEventLogger$1(options.loggerTitle);
|
|
217
237
|
const unscope = registerEventScope(scopeId);
|
|
218
238
|
let response;
|
|
219
239
|
const hookOptions = {
|
|
@@ -233,7 +253,7 @@ function defineMoostEventHandler(options) {
|
|
|
233
253
|
const interceptorHandler = await options.getIterceptorHandler();
|
|
234
254
|
if (interceptorHandler?.count) try {
|
|
235
255
|
response = await ci.with("Interceptors:init", () => interceptorHandler.init());
|
|
236
|
-
if (response !==
|
|
256
|
+
if (response !== void 0) return await endWithResponse();
|
|
237
257
|
} catch (error) {
|
|
238
258
|
options.logErrors && logger.error(error);
|
|
239
259
|
response = error;
|
|
@@ -249,7 +269,7 @@ function defineMoostEventHandler(options) {
|
|
|
249
269
|
}
|
|
250
270
|
if (interceptorHandler?.countBefore) {
|
|
251
271
|
response = await ci.with("Interceptors:before", () => interceptorHandler.fireBefore(response));
|
|
252
|
-
if (response !==
|
|
272
|
+
if (response !== void 0) return endWithResponse();
|
|
253
273
|
}
|
|
254
274
|
const callControllerMethod = () => {
|
|
255
275
|
if (options.callControllerMethod) return options.callControllerMethod(args);
|
|
@@ -258,7 +278,7 @@ function defineMoostEventHandler(options) {
|
|
|
258
278
|
try {
|
|
259
279
|
response = await ci.with(`Handler:${options.targetPath}`, {
|
|
260
280
|
"moost.handler": options.controllerMethod || "",
|
|
261
|
-
"moost.controller": getConstructor(instance).name
|
|
281
|
+
"moost.controller": getConstructor$1(instance).name
|
|
262
282
|
}, () => callControllerMethod());
|
|
263
283
|
} catch (error) {
|
|
264
284
|
options.logErrors && logger.error(error);
|
|
@@ -287,7 +307,7 @@ function defineMoostEventHandler(options) {
|
|
|
287
307
|
function getInstanceOwnMethods(instance) {
|
|
288
308
|
const proto = Object.getPrototypeOf(instance);
|
|
289
309
|
return [
|
|
290
|
-
...getParentProps(getConstructor(instance)),
|
|
310
|
+
...getParentProps(getConstructor$1(instance)),
|
|
291
311
|
...Object.getOwnPropertyNames(proto),
|
|
292
312
|
...Object.getOwnPropertyNames(instance)
|
|
293
313
|
].filter((m) => typeof instance[m] === "function");
|
|
@@ -295,7 +315,7 @@ function getInstanceOwnMethods(instance) {
|
|
|
295
315
|
function getInstanceOwnProps(instance) {
|
|
296
316
|
const proto = Object.getPrototypeOf(instance);
|
|
297
317
|
return [
|
|
298
|
-
...getParentProps(getConstructor(instance)),
|
|
318
|
+
...getParentProps(getConstructor$1(instance)),
|
|
299
319
|
...Object.getOwnPropertyNames(proto),
|
|
300
320
|
...Object.getOwnPropertyNames(instance)
|
|
301
321
|
].filter((m) => typeof instance[m] !== "function");
|
|
@@ -318,7 +338,7 @@ async function getCallableFn(targetInstance, fn, pipes, logger) {
|
|
|
318
338
|
return (...args) => instance.handler(...args);
|
|
319
339
|
}
|
|
320
340
|
if (typeof fn === "function") return fn;
|
|
321
|
-
const e = new Error(`getCallableFn failed for "${getConstructor(targetInstance).name}" because the passed arg is not a Function nor TClassFunction`);
|
|
341
|
+
const e = /* @__PURE__ */ new Error(`getCallableFn failed for "${getConstructor$1(targetInstance).name}" because the passed arg is not a Function nor TClassFunction`);
|
|
322
342
|
logger.error(e);
|
|
323
343
|
throw e;
|
|
324
344
|
}
|
|
@@ -353,7 +373,7 @@ var InterceptorHandler = class {
|
|
|
353
373
|
this.responseOverwritten = true;
|
|
354
374
|
}
|
|
355
375
|
async init() {
|
|
356
|
-
const ci = getContextInjector();
|
|
376
|
+
const ci = getContextInjector$1();
|
|
357
377
|
for (const { handler, name } of this.handlers) {
|
|
358
378
|
const response = await ci.with(`Interceptor:${name}`, { "moost.interceptor.stage": "init" }, () => handler((fn) => {
|
|
359
379
|
this.before.push({
|
|
@@ -371,11 +391,11 @@ var InterceptorHandler = class {
|
|
|
371
391
|
fn
|
|
372
392
|
});
|
|
373
393
|
}));
|
|
374
|
-
if (response !==
|
|
394
|
+
if (response !== void 0) return response;
|
|
375
395
|
}
|
|
376
396
|
}
|
|
377
397
|
async fireBefore(response) {
|
|
378
|
-
const ci = getContextInjector();
|
|
398
|
+
const ci = getContextInjector$1();
|
|
379
399
|
this.response = response;
|
|
380
400
|
for (const { name, fn } of this.before) {
|
|
381
401
|
await ci.with(`Interceptor:${name}`, { "moost.interceptor.stage": "before" }, () => fn(this.replyFn.bind(this)));
|
|
@@ -384,7 +404,7 @@ var InterceptorHandler = class {
|
|
|
384
404
|
return this.response;
|
|
385
405
|
}
|
|
386
406
|
async fireAfter(response) {
|
|
387
|
-
const ci = getContextInjector();
|
|
407
|
+
const ci = getContextInjector$1();
|
|
388
408
|
this.response = response;
|
|
389
409
|
if (response instanceof Error) for (const { name, fn } of this.onError) await ci.with(`Interceptor:${name}`, { "moost.interceptor.stage": "after" }, () => fn(response, this.replyFn.bind(this)));
|
|
390
410
|
else for (const { name, fn } of this.after) await ci.with(`Interceptor:${name}`, { "moost.interceptor.stage": "onError" }, () => fn(response, this.replyFn.bind(this)));
|
|
@@ -467,7 +487,7 @@ async function bindControllerMethods(options) {
|
|
|
467
487
|
});
|
|
468
488
|
const resolveArgs = async () => {
|
|
469
489
|
const args = [];
|
|
470
|
-
for (const [i, { pipes: pipes$1, meta: paramMeta }] of argsPipes.entries()) args[i] = await runPipes(pipes$1,
|
|
490
|
+
for (const [i, { pipes: pipes$1, meta: paramMeta }] of argsPipes.entries()) args[i] = await runPipes(pipes$1, void 0, {
|
|
471
491
|
classMeta: meta,
|
|
472
492
|
methodMeta,
|
|
473
493
|
paramMeta,
|
|
@@ -478,7 +498,7 @@ async function bindControllerMethods(options) {
|
|
|
478
498
|
}, "PARAM");
|
|
479
499
|
return args;
|
|
480
500
|
};
|
|
481
|
-
const wm = new WeakMap();
|
|
501
|
+
const wm = /* @__PURE__ */ new WeakMap();
|
|
482
502
|
controllerOverview.handlers.push(...methodMeta.handlers.map((h) => {
|
|
483
503
|
const data = {
|
|
484
504
|
meta: methodMeta,
|
|
@@ -522,22 +542,67 @@ function Circular(resolver) {
|
|
|
522
542
|
|
|
523
543
|
//#endregion
|
|
524
544
|
//#region packages/moost/src/decorators/common.decorator.ts
|
|
525
|
-
|
|
545
|
+
/**
|
|
546
|
+
* Apply Multiple Decorators
|
|
547
|
+
*
|
|
548
|
+
* @param decorators - array of decorators
|
|
549
|
+
* @returns
|
|
550
|
+
*/ function ApplyDecorators(...decorators) {
|
|
551
|
+
const mate$1 = getMoostMate();
|
|
552
|
+
return mate$1.apply(...decorators);
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* ## Label
|
|
556
|
+
* ### @Decorator
|
|
557
|
+
* _Common purpose decorator that may be used by various adapters for various purposes_
|
|
558
|
+
*
|
|
559
|
+
* Stores Label metadata
|
|
560
|
+
*/ function Label(value) {
|
|
526
561
|
return getMoostMate().decorate("label", value);
|
|
527
562
|
}
|
|
528
|
-
|
|
563
|
+
/**
|
|
564
|
+
* ## Description
|
|
565
|
+
* ### @Decorator
|
|
566
|
+
* _Common purpose decorator that may be used by various adapters for various purposes_
|
|
567
|
+
*
|
|
568
|
+
* Stores Description metadata
|
|
569
|
+
*/ function Description(value) {
|
|
529
570
|
return getMoostMate().decorate("description", value);
|
|
530
571
|
}
|
|
531
|
-
|
|
572
|
+
/**
|
|
573
|
+
* ## Value
|
|
574
|
+
* ### @Decorator
|
|
575
|
+
* _Common purpose decorator that may be used by various adapters for various purposes_
|
|
576
|
+
*
|
|
577
|
+
* Stores Value metadata
|
|
578
|
+
*/ function Value(value) {
|
|
532
579
|
return getMoostMate().decorate("value", value);
|
|
533
580
|
}
|
|
534
|
-
|
|
581
|
+
/**
|
|
582
|
+
* ## Id
|
|
583
|
+
* ### @Decorator
|
|
584
|
+
* _Common purpose decorator that may be used by various adapters for various purposes_
|
|
585
|
+
*
|
|
586
|
+
* Stores Id metadata
|
|
587
|
+
*/ function Id(value) {
|
|
535
588
|
return getMoostMate().decorate("id", value);
|
|
536
589
|
}
|
|
537
|
-
|
|
590
|
+
/**
|
|
591
|
+
* ## Optional
|
|
592
|
+
* ### @Decorator
|
|
593
|
+
* _Common purpose decorator that may be used by various adapters for various purposes_
|
|
594
|
+
*
|
|
595
|
+
* Stores Optional metadata
|
|
596
|
+
*/ function Optional() {
|
|
538
597
|
return getMoostMate().decorate("optional", true);
|
|
539
598
|
}
|
|
540
|
-
|
|
599
|
+
/**
|
|
600
|
+
* ## Required
|
|
601
|
+
* ### @Decorator
|
|
602
|
+
* _Common purpose decorator that may be used by various adapters for various purposes_
|
|
603
|
+
*
|
|
604
|
+
* Stores Required metadata
|
|
605
|
+
*/ function Required() {
|
|
541
606
|
const mate$1 = getMoostMate();
|
|
542
607
|
return mate$1.apply(mate$1.decorate("required", true), mate$1.decorateClass((meta, level, key, index) => {
|
|
543
608
|
if (typeof index !== "number" && meta && ["string", "symbol"].includes(typeof key)) {
|
|
@@ -550,7 +615,15 @@ function Required() {
|
|
|
550
615
|
|
|
551
616
|
//#endregion
|
|
552
617
|
//#region packages/moost/src/decorators/injectable.decorator.ts
|
|
553
|
-
|
|
618
|
+
/**
|
|
619
|
+
* ## Injectable
|
|
620
|
+
* ### @Decorator
|
|
621
|
+
* Mark the Class as Injectable to enable it to be used in dependency injection
|
|
622
|
+
* @param scope - Scope for injection ("FOR_EVENT" | "SINGLETON" | true)
|
|
623
|
+
* FOR_EVENT - will create a new instance for each incoming request
|
|
624
|
+
* SINGLETON | true - will create a new instance only once
|
|
625
|
+
* @param label - field label
|
|
626
|
+
*/ function Injectable(scope = true) {
|
|
554
627
|
return getMoostMate().decorate("injectable", scope);
|
|
555
628
|
}
|
|
556
629
|
const insureInjectable = getMoostMate().decorate((meta) => {
|
|
@@ -560,25 +633,35 @@ const insureInjectable = getMoostMate().decorate((meta) => {
|
|
|
560
633
|
|
|
561
634
|
//#endregion
|
|
562
635
|
//#region packages/moost/src/decorators/controller.decorator.ts
|
|
563
|
-
|
|
636
|
+
/**
|
|
637
|
+
* ## Controller
|
|
638
|
+
* ### @Decorator
|
|
639
|
+
* Set Class as a Controller
|
|
640
|
+
* @param prefix - define the prefix for all the paths of this controller
|
|
641
|
+
*/ function Controller(prefix) {
|
|
564
642
|
const mate$1 = getMoostMate();
|
|
565
643
|
return mate$1.apply(insureInjectable, mate$1.decorate("controller", { prefix: prefix || "" }));
|
|
566
644
|
}
|
|
567
645
|
function ImportController(prefix, controller, provide) {
|
|
568
646
|
return getMoostMate().decorate("importController", {
|
|
569
|
-
prefix: typeof prefix === "string" ? prefix :
|
|
647
|
+
prefix: typeof prefix === "string" ? prefix : void 0,
|
|
570
648
|
typeResolver: typeof prefix === "string" ? controller : prefix,
|
|
571
|
-
provide: typeof prefix === "string" ? provide ||
|
|
649
|
+
provide: typeof prefix === "string" ? provide || void 0 : controller || void 0
|
|
572
650
|
}, true);
|
|
573
651
|
}
|
|
574
652
|
|
|
575
653
|
//#endregion
|
|
576
654
|
//#region packages/moost/src/decorators/inherit.decorator.ts
|
|
577
|
-
|
|
655
|
+
/**
|
|
656
|
+
* ## Inherit
|
|
657
|
+
* ### @Decorator
|
|
658
|
+
* Inherit metadata from super class
|
|
659
|
+
* @returns
|
|
660
|
+
*/ const Inherit = () => getMoostMate().decorate("inherit", true);
|
|
578
661
|
|
|
579
662
|
//#endregion
|
|
580
663
|
//#region packages/moost/src/decorators/intercept.decorator.ts
|
|
581
|
-
var TInterceptorPriority =
|
|
664
|
+
var TInterceptorPriority = /* @__PURE__ */ function(TInterceptorPriority$1) {
|
|
582
665
|
TInterceptorPriority$1[TInterceptorPriority$1["BEFORE_ALL"] = 0] = "BEFORE_ALL";
|
|
583
666
|
TInterceptorPriority$1[TInterceptorPriority$1["BEFORE_GUARD"] = 1] = "BEFORE_GUARD";
|
|
584
667
|
TInterceptorPriority$1[TInterceptorPriority$1["GUARD"] = 2] = "GUARD";
|
|
@@ -588,7 +671,14 @@ var TInterceptorPriority = /*#__PURE__*/ function(TInterceptorPriority$1) {
|
|
|
588
671
|
TInterceptorPriority$1[TInterceptorPriority$1["AFTER_ALL"] = 6] = "AFTER_ALL";
|
|
589
672
|
return TInterceptorPriority$1;
|
|
590
673
|
}({});
|
|
591
|
-
|
|
674
|
+
/**
|
|
675
|
+
* ## Intercept
|
|
676
|
+
* ### @Decorator
|
|
677
|
+
* Set interceptor
|
|
678
|
+
* @param handler interceptor fn (use defineInterceptorFn)
|
|
679
|
+
* @param priority interceptor priority
|
|
680
|
+
* @returns
|
|
681
|
+
*/ function Intercept(handler, priority, name) {
|
|
592
682
|
return getMoostMate().decorate("interceptors", {
|
|
593
683
|
handler,
|
|
594
684
|
priority: priority || handler.priority || 4,
|
|
@@ -598,9 +688,15 @@ function Intercept(handler, priority, name) {
|
|
|
598
688
|
|
|
599
689
|
//#endregion
|
|
600
690
|
//#region packages/moost/src/decorators/resolve.decorator.ts
|
|
601
|
-
|
|
691
|
+
/**
|
|
692
|
+
* Hook to the Response Status
|
|
693
|
+
* @decorator
|
|
694
|
+
* @param resolver - resolver function
|
|
695
|
+
* @param label - field label
|
|
696
|
+
* @paramType unknown
|
|
697
|
+
*/ function Resolve(resolver, label) {
|
|
602
698
|
return (target, key, index) => {
|
|
603
|
-
const i = typeof index === "number" ? index :
|
|
699
|
+
const i = typeof index === "number" ? index : void 0;
|
|
604
700
|
getMoostMate().decorate("resolver", (metas, level) => {
|
|
605
701
|
let newLabel = label;
|
|
606
702
|
if (!newLabel && level === "PROP" && typeof metas.key === "string") newLabel = metas.key;
|
|
@@ -609,16 +705,37 @@ function Resolve(resolver, label) {
|
|
|
609
705
|
})(target, key, i);
|
|
610
706
|
};
|
|
611
707
|
}
|
|
612
|
-
|
|
708
|
+
/**
|
|
709
|
+
* Get Param Value from url parh
|
|
710
|
+
* @decorator
|
|
711
|
+
* @param name - param name
|
|
712
|
+
* @paramType string
|
|
713
|
+
*/ function Param(name) {
|
|
613
714
|
return getMoostMate().apply(getMoostMate().decorate("paramSource", "ROUTE"), getMoostMate().decorate("paramName", name), Resolve(() => useRouteParams().get(name), name));
|
|
614
715
|
}
|
|
615
|
-
|
|
716
|
+
/**
|
|
717
|
+
* Get Parsed Params from url parh
|
|
718
|
+
* @decorator
|
|
719
|
+
* @paramType object
|
|
720
|
+
*/ function Params() {
|
|
616
721
|
return Resolve(() => useRouteParams().params, "params");
|
|
617
722
|
}
|
|
618
|
-
|
|
723
|
+
/**
|
|
724
|
+
* Provide Const Value
|
|
725
|
+
* @decorator
|
|
726
|
+
* @param value - provided value
|
|
727
|
+
* @param label - label of the field
|
|
728
|
+
* @paramType unknown
|
|
729
|
+
*/ function Const(value, label) {
|
|
619
730
|
return Resolve(() => value, label);
|
|
620
731
|
}
|
|
621
|
-
|
|
732
|
+
/**
|
|
733
|
+
* Provide Const Value from Factory fn
|
|
734
|
+
* @decorator
|
|
735
|
+
* @param factory - value Factory fn
|
|
736
|
+
* @param label - label of the field
|
|
737
|
+
* @paramType unknown
|
|
738
|
+
*/ function ConstFactory(factory, label) {
|
|
622
739
|
return Resolve(async () => factory(), label);
|
|
623
740
|
}
|
|
624
741
|
function fillLabel(target, key, index, name) {
|
|
@@ -632,10 +749,18 @@ function fillLabel(target, key, index, name) {
|
|
|
632
749
|
|
|
633
750
|
//#endregion
|
|
634
751
|
//#region packages/moost/src/decorators/logger.decorator.ts
|
|
635
|
-
|
|
636
|
-
|
|
752
|
+
/**
|
|
753
|
+
* Resolves event logger from event context
|
|
754
|
+
* @param topic
|
|
755
|
+
* @returns Resolver to '@wooksjs/event-core' (EventLogger)
|
|
756
|
+
*/ function InjectEventLogger(topic) {
|
|
757
|
+
return Resolve(() => useEventLogger$1(topic));
|
|
637
758
|
}
|
|
638
|
-
|
|
759
|
+
/**
|
|
760
|
+
* Resolves app-level logger
|
|
761
|
+
* @param topic - logger topic (can be overrided by @LoggerTopic)
|
|
762
|
+
* @returns
|
|
763
|
+
*/ function InjectMoostLogger(topic) {
|
|
639
764
|
return Resolve(async (metas) => {
|
|
640
765
|
const { instantiate, getController } = useControllerContext();
|
|
641
766
|
const controller = getController();
|
|
@@ -644,13 +769,17 @@ function InjectMoostLogger(topic) {
|
|
|
644
769
|
return moostApp.getLogger(meta?.loggerTopic || topic || meta?.id);
|
|
645
770
|
});
|
|
646
771
|
}
|
|
647
|
-
|
|
772
|
+
/**
|
|
773
|
+
* Sets logger topic (used in @InjectMoostLogger)
|
|
774
|
+
* @param topic - logger topic (banner)
|
|
775
|
+
* @returns
|
|
776
|
+
*/ function LoggerTopic(topic) {
|
|
648
777
|
return getMoostMate().decorate("loggerTopic", topic);
|
|
649
778
|
}
|
|
650
779
|
|
|
651
780
|
//#endregion
|
|
652
781
|
//#region packages/moost/src/pipes/types.ts
|
|
653
|
-
var TPipePriority =
|
|
782
|
+
var TPipePriority = /* @__PURE__ */ function(TPipePriority$1) {
|
|
654
783
|
TPipePriority$1[TPipePriority$1["BEFORE_RESOLVE"] = 0] = "BEFORE_RESOLVE";
|
|
655
784
|
TPipePriority$1[TPipePriority$1["RESOLVE"] = 1] = "RESOLVE";
|
|
656
785
|
TPipePriority$1[TPipePriority$1["AFTER_RESOLVE"] = 2] = "AFTER_RESOLVE";
|
|
@@ -665,7 +794,14 @@ var TPipePriority = /*#__PURE__*/ function(TPipePriority$1) {
|
|
|
665
794
|
|
|
666
795
|
//#endregion
|
|
667
796
|
//#region packages/moost/src/decorators/pipe.decorator.ts
|
|
668
|
-
|
|
797
|
+
/**
|
|
798
|
+
* ## Pipe
|
|
799
|
+
* ### @Decorator
|
|
800
|
+
* Attach pipe
|
|
801
|
+
* @param handler pipe handler
|
|
802
|
+
* @param priority pipe priority
|
|
803
|
+
* @returns
|
|
804
|
+
*/ function Pipe(handler, priority) {
|
|
669
805
|
if (typeof priority !== "number") priority = typeof handler.priority === "number" ? handler.priority : TPipePriority.TRANSFORM;
|
|
670
806
|
return getMoostMate().decorate("pipes", {
|
|
671
807
|
handler,
|
|
@@ -675,40 +811,104 @@ function Pipe(handler, priority) {
|
|
|
675
811
|
|
|
676
812
|
//#endregion
|
|
677
813
|
//#region packages/moost/src/decorators/provide.decorator.ts
|
|
678
|
-
|
|
814
|
+
/**
|
|
815
|
+
* ## Provide
|
|
816
|
+
* ### @Decorator
|
|
817
|
+
* Defines provide registry for class (and all the children)
|
|
818
|
+
* @param type - string or class constructor
|
|
819
|
+
* @param fn - factory function for provided value
|
|
820
|
+
*/ function Provide(type, fn) {
|
|
679
821
|
return getMoostMate().decorate((meta) => {
|
|
680
822
|
meta.provide = meta.provide || {};
|
|
681
|
-
Object.assign(meta.provide, createProvideRegistry([type, fn]));
|
|
823
|
+
Object.assign(meta.provide, createProvideRegistry$1([type, fn]));
|
|
682
824
|
return meta;
|
|
683
825
|
});
|
|
684
826
|
}
|
|
685
|
-
|
|
827
|
+
/**
|
|
828
|
+
* ## Replace
|
|
829
|
+
* ### @Decorator
|
|
830
|
+
* Defines class to replace in DI
|
|
831
|
+
* @param type - class to replace
|
|
832
|
+
* @param newType - new class
|
|
833
|
+
*/ function Replace(type, newType) {
|
|
686
834
|
return getMoostMate().decorate((meta) => {
|
|
687
835
|
meta.replace = meta.replace || {};
|
|
688
|
-
Object.assign(meta.replace, createReplaceRegistry([type, newType]));
|
|
836
|
+
Object.assign(meta.replace, createReplaceRegistry$1([type, newType]));
|
|
689
837
|
return meta;
|
|
690
838
|
});
|
|
691
839
|
}
|
|
692
|
-
|
|
840
|
+
/**
|
|
841
|
+
* ## Inject
|
|
842
|
+
* ### @Decorator
|
|
843
|
+
* Defines a key from provide registry to inject value
|
|
844
|
+
* (For optional values use with @Optional())
|
|
845
|
+
* @param type - string or class constructor
|
|
846
|
+
*/ function Inject(type) {
|
|
693
847
|
return getMoostMate().decorate("inject", type);
|
|
694
848
|
}
|
|
695
|
-
|
|
849
|
+
/**
|
|
850
|
+
* Injects instance from scope
|
|
851
|
+
*
|
|
852
|
+
* (scope must be defined by `defineInfactScope` fn)
|
|
853
|
+
* @param name scope name
|
|
854
|
+
*/ function InjectFromScope(name) {
|
|
696
855
|
return getMoostMate().decorate("fromScope", name);
|
|
697
856
|
}
|
|
698
|
-
|
|
857
|
+
/**
|
|
858
|
+
* Inject vars from scope for instances
|
|
859
|
+
* instantiated with `@InjectFromScope` decorator
|
|
860
|
+
*/ function InjectScopeVars(name) {
|
|
699
861
|
return Resolve(({ scopeId }) => {
|
|
700
862
|
if (scopeId) return name ? getInfactScopeVars(scopeId)?.[name] : getInfactScopeVars(scopeId);
|
|
701
|
-
return
|
|
863
|
+
return void 0;
|
|
702
864
|
});
|
|
703
865
|
}
|
|
704
866
|
|
|
705
867
|
//#endregion
|
|
706
868
|
//#region packages/moost/src/define.ts
|
|
707
|
-
|
|
869
|
+
/**
|
|
870
|
+
* ### Define Interceptor Function
|
|
871
|
+
*
|
|
872
|
+
* ```ts
|
|
873
|
+
* defineInterceptorFn((before, after, onError) => {
|
|
874
|
+
* //init
|
|
875
|
+
* before(() => {
|
|
876
|
+
* // before handler
|
|
877
|
+
* })
|
|
878
|
+
* after((response, reply) => {
|
|
879
|
+
* // after handler
|
|
880
|
+
* })
|
|
881
|
+
* onError((error, reply) => {
|
|
882
|
+
* // when error occured
|
|
883
|
+
* })
|
|
884
|
+
* },
|
|
885
|
+
* TInterceptorPriority.INTERCEPTOR,
|
|
886
|
+
* )
|
|
887
|
+
* ```
|
|
888
|
+
*
|
|
889
|
+
* @param fn interceptor function
|
|
890
|
+
* @param priority priority of the interceptor where BEFORE_ALL = 0, BEFORE_GUARD = 1, GUARD = 2, AFTER_GUARD = 3, INTERCEPTOR = 4, CATCH_ERROR = 5, AFTER_ALL = 6
|
|
891
|
+
* @returns
|
|
892
|
+
*/ function defineInterceptorFn(fn, priority = TInterceptorPriority.INTERCEPTOR) {
|
|
708
893
|
fn.priority = priority;
|
|
709
894
|
return fn;
|
|
710
895
|
}
|
|
711
|
-
|
|
896
|
+
/**
|
|
897
|
+
* ### Define Pipe Function
|
|
898
|
+
*
|
|
899
|
+
* ```ts
|
|
900
|
+
* // example of a transform pipe
|
|
901
|
+
* const uppercaseTransformPipe = definePipeFn((value, metas, level) => {
|
|
902
|
+
* return typeof value === 'string' ? value.toUpperCase() : value
|
|
903
|
+
* },
|
|
904
|
+
* TPipePriority.TRANSFORM,
|
|
905
|
+
* )
|
|
906
|
+
* ```
|
|
907
|
+
*
|
|
908
|
+
* @param fn interceptor function
|
|
909
|
+
* @param priority priority of the pipe where BEFORE_RESOLVE = 0, RESOLVE = 1, AFTER_RESOLVE = 2, BEFORE_TRANSFORM = 3, TRANSFORM = 4, AFTER_TRANSFORM = 5, BEFORE_VALIDATE = 6, VALIDATE = 7, AFTER_VALIDATE = 8
|
|
910
|
+
* @returns
|
|
911
|
+
*/ function definePipeFn(fn, priority = TPipePriority.TRANSFORM) {
|
|
712
912
|
fn.priority = priority;
|
|
713
913
|
return fn;
|
|
714
914
|
}
|
|
@@ -718,7 +918,7 @@ function definePipeFn(fn, priority = TPipePriority.TRANSFORM) {
|
|
|
718
918
|
const resolvePipe = definePipeFn((_value, metas, level) => {
|
|
719
919
|
const resolver = metas.targetMeta?.resolver;
|
|
720
920
|
if (resolver) return resolver(metas, level);
|
|
721
|
-
return
|
|
921
|
+
return void 0;
|
|
722
922
|
}, TPipePriority.RESOLVE);
|
|
723
923
|
|
|
724
924
|
//#endregion
|
|
@@ -740,7 +940,56 @@ function _define_property(obj, key, value) {
|
|
|
740
940
|
else obj[key] = value;
|
|
741
941
|
return obj;
|
|
742
942
|
}
|
|
743
|
-
|
|
943
|
+
/**
|
|
944
|
+
* ## Moost
|
|
945
|
+
* Main moostjs class that serves as a shell for Moost Adapters
|
|
946
|
+
*
|
|
947
|
+
* ### Usage with HTTP Adapter
|
|
948
|
+
* ```ts
|
|
949
|
+
* │ // HTTP server example
|
|
950
|
+
* │ import { MoostHttp, Get } from '@moostjs/event-http'
|
|
951
|
+
* │ import { Moost, Param } from 'moost'
|
|
952
|
+
* │
|
|
953
|
+
* │ class MyServer extends Moost {
|
|
954
|
+
* │ @Get('test/:name')
|
|
955
|
+
* │ test(@Param('name') name: string) {
|
|
956
|
+
* │ return { message: `Hello ${name}!` }
|
|
957
|
+
* │ }
|
|
958
|
+
* │ }
|
|
959
|
+
* │
|
|
960
|
+
* │ const app = new MyServer()
|
|
961
|
+
* │ const http = new MoostHttp()
|
|
962
|
+
* │ app.adapter(http).listen(3000, () => {
|
|
963
|
+
* │ app.getLogger('MyApp').log('Up on port 3000')
|
|
964
|
+
* │ })
|
|
965
|
+
* │ app.init()
|
|
966
|
+
* ```
|
|
967
|
+
* ### Usage with CLI Adapter
|
|
968
|
+
* ```ts
|
|
969
|
+
* │ // CLI example
|
|
970
|
+
* │ import { MoostCli, Cli, CliOption, cliHelpInterceptor } from '@moostjs/event-cli'
|
|
971
|
+
* │ import { Moost, Param } from 'moost'
|
|
972
|
+
* │
|
|
973
|
+
* │ class MyApp extends Moost {
|
|
974
|
+
* │ @Cli('command/:arg')
|
|
975
|
+
* │ command(
|
|
976
|
+
* │ @Param('arg')
|
|
977
|
+
* │ arg: string,
|
|
978
|
+
* │ @CliOption('test', 't')
|
|
979
|
+
* │ test: boolean,
|
|
980
|
+
* │ ) {
|
|
981
|
+
* │ return `command run with flag arg=${ arg }, test=${ test }`
|
|
982
|
+
* │ }
|
|
983
|
+
* │ }
|
|
984
|
+
* │
|
|
985
|
+
* │ const app = new MyApp()
|
|
986
|
+
* │ app.applyGlobalInterceptors(cliHelpInterceptor())
|
|
987
|
+
* │
|
|
988
|
+
* │ const cli = new MoostCli()
|
|
989
|
+
* │ app.adapter(cli)
|
|
990
|
+
* │ app.init()
|
|
991
|
+
* ```
|
|
992
|
+
*/ var Moost = class Moost extends Hookable {
|
|
744
993
|
_fireEventStart(source) {
|
|
745
994
|
this.callHook("event-start", source);
|
|
746
995
|
}
|
|
@@ -758,7 +1007,7 @@ var Moost = class Moost extends Hookable {
|
|
|
758
1007
|
* @param topic
|
|
759
1008
|
* @returns
|
|
760
1009
|
*/ getLogger(topic) {
|
|
761
|
-
if (topic && this.logger instanceof ProstoLogger) return this.logger.createTopic(topic);
|
|
1010
|
+
if (topic && this.logger instanceof ProstoLogger$1) return this.logger.createTopic(topic);
|
|
762
1011
|
return this.logger;
|
|
763
1012
|
}
|
|
764
1013
|
adapter(a) {
|
|
@@ -772,10 +1021,10 @@ var Moost = class Moost extends Hookable {
|
|
|
772
1021
|
* ### init
|
|
773
1022
|
* Ititializes adapter. Must be called after adapters are attached.
|
|
774
1023
|
*/ async init() {
|
|
775
|
-
this.setProvideRegistry(createProvideRegistry([Moost, () => this], [ProstoLogger, () => this.logger], ["MOOST_LOGGER", () => this.logger]));
|
|
1024
|
+
this.setProvideRegistry(createProvideRegistry$1([Moost, () => this], [ProstoLogger$1, () => this.logger], ["MOOST_LOGGER", () => this.logger]));
|
|
776
1025
|
for (const a of this.adapters) {
|
|
777
|
-
const constructor = getConstructor(a);
|
|
778
|
-
if (constructor) this.setProvideRegistry(createProvideRegistry([constructor, () => a]));
|
|
1026
|
+
const constructor = getConstructor$1(a);
|
|
1027
|
+
if (constructor) this.setProvideRegistry(createProvideRegistry$1([constructor, () => a]));
|
|
779
1028
|
if (typeof a.getProvideRegistry === "function") this.setProvideRegistry(a.getProvideRegistry());
|
|
780
1029
|
}
|
|
781
1030
|
this.unregisteredControllers.unshift(this);
|
|
@@ -808,7 +1057,7 @@ var Moost = class Moost extends Hookable {
|
|
|
808
1057
|
const mate$1 = getMoostMate();
|
|
809
1058
|
const classMeta = mate$1.read(controller);
|
|
810
1059
|
const infact$1 = getMoostInfact();
|
|
811
|
-
const isControllerConsructor = isConstructor(controller);
|
|
1060
|
+
const isControllerConsructor = isConstructor$1(controller);
|
|
812
1061
|
const pipes = [...this.pipes, ...classMeta?.pipes || []].sort((a, b) => a.priority - b.priority);
|
|
813
1062
|
let instance;
|
|
814
1063
|
const infactOpts = {
|
|
@@ -828,7 +1077,7 @@ var Moost = class Moost extends Hookable {
|
|
|
828
1077
|
infact$1.setInstanceRegistries(instance, provide, replace, { pipes });
|
|
829
1078
|
}
|
|
830
1079
|
const getInstance = instance ? () => Promise.resolve(instance) : async () => await infact$1.get(controller, { ...infactOpts });
|
|
831
|
-
const classConstructor = isConstructor(controller) ? controller : getConstructor(controller);
|
|
1080
|
+
const classConstructor = isConstructor$1(controller) ? controller : getConstructor$1(controller);
|
|
832
1081
|
this.controllersOverview.push(await bindControllerMethods({
|
|
833
1082
|
getInstance,
|
|
834
1083
|
classConstructor,
|
|
@@ -853,19 +1102,12 @@ var Moost = class Moost extends Hookable {
|
|
|
853
1102
|
...classMeta.replace
|
|
854
1103
|
};
|
|
855
1104
|
for (const ic of classMeta.importController) if (ic.typeResolver) {
|
|
856
|
-
const isConstr = isConstructor(ic.typeResolver);
|
|
1105
|
+
const isConstr = isConstructor$1(ic.typeResolver);
|
|
857
1106
|
const isFunc = typeof ic.typeResolver === "function";
|
|
858
|
-
await this.bindController(
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
...mergedProvide,
|
|
863
|
-
...ic.provide
|
|
864
|
-
} : mergedProvide,
|
|
865
|
-
mergedReplace,
|
|
866
|
-
`${globalPrefix}/${prefix || ""}`,
|
|
867
|
-
ic.prefix
|
|
868
|
-
);
|
|
1107
|
+
await this.bindController(isConstr ? ic.typeResolver : isFunc ? await ic.typeResolver() : ic.typeResolver, ic.provide ? {
|
|
1108
|
+
...mergedProvide,
|
|
1109
|
+
...ic.provide
|
|
1110
|
+
} : mergedProvide, mergedReplace, `${globalPrefix}/${prefix || ""}`, ic.prefix);
|
|
869
1111
|
}
|
|
870
1112
|
}
|
|
871
1113
|
}
|
|
@@ -878,7 +1120,7 @@ var Moost = class Moost extends Hookable {
|
|
|
878
1120
|
handler: item.handler,
|
|
879
1121
|
priority: item.priority
|
|
880
1122
|
});
|
|
881
|
-
this.globalInterceptorHandler =
|
|
1123
|
+
this.globalInterceptorHandler = void 0;
|
|
882
1124
|
return this;
|
|
883
1125
|
}
|
|
884
1126
|
/**
|
|
@@ -907,7 +1149,7 @@ var Moost = class Moost extends Hookable {
|
|
|
907
1149
|
priority: item.priority,
|
|
908
1150
|
name: item.name || item.handler._name || item.handler.name || "<anonymous>"
|
|
909
1151
|
});
|
|
910
|
-
this.globalInterceptorHandler =
|
|
1152
|
+
this.globalInterceptorHandler = void 0;
|
|
911
1153
|
return this;
|
|
912
1154
|
}
|
|
913
1155
|
/**
|
|
@@ -943,11 +1185,11 @@ var Moost = class Moost extends Hookable {
|
|
|
943
1185
|
logMappedHandler(eventName, classConstructor, method, stroke, prefix) {
|
|
944
1186
|
const c = stroke ? "\x1B[9m" : "";
|
|
945
1187
|
const coff = stroke ? "\x1B[29m" : "";
|
|
946
|
-
this.logger.info(`${prefix || ""}${c}${eventName} ${"\x1B[0m\x1B[2m\x1B[32m" + c}→ ${classConstructor.name}.${"\x1B[36m" + c}${method}
|
|
1188
|
+
this.logger.info(`${prefix || ""}${c}${eventName} ${"\x1B[0m\x1B[2m\x1B[32m" + c}→ ${classConstructor.name}.${"\x1B[36m" + c}${method}[32m()${coff}`);
|
|
947
1189
|
}
|
|
948
1190
|
constructor(options) {
|
|
949
|
-
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([Infact, getMoostInfact], [Mate, getMoostMate]), this.replace = {}, this.unregisteredControllers = [];
|
|
950
|
-
this.logger = options?.logger || getDefaultLogger(
|
|
1191
|
+
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 = [];
|
|
1192
|
+
this.logger = options?.logger || getDefaultLogger(`[2m[35mmoost`);
|
|
951
1193
|
setDefaultLogger(this.logger);
|
|
952
1194
|
const mate$1 = getMoostMate();
|
|
953
1195
|
Object.assign(mate$1, { logger: this.getLogger("mate") });
|
|
@@ -955,4 +1197,4 @@ var Moost = class Moost extends Hookable {
|
|
|
955
1197
|
};
|
|
956
1198
|
|
|
957
1199
|
//#endregion
|
|
958
|
-
export { Circular, Const, ConstFactory, ContextInjector, Controller, Description, EventLogger, Id, ImportController, Inherit, Inject, InjectEventLogger, InjectFromScope, InjectMoostLogger, InjectScopeVars, Injectable, Intercept, InterceptorHandler, Label, LoggerTopic, Moost, Optional, Param, Params, Pipe, ProstoLogger, Provide, Replace, Required, Resolve, TInterceptorPriority, TPipePriority, Value, clearGlobalWooks, createProvideRegistry, createReplaceRegistry, defineInfactScope, defineInterceptorFn, defineMoostEventHandler, definePipeFn, getConstructor, getContextInjector, getGlobalWooks, getInfactScopeVars, getInstanceOwnMethods, getInstanceOwnProps, getMoostInfact, getMoostMate, getNewMoostInfact, isConstructor, registerEventScope, replaceContextInjector, resolvePipe, setControllerContext, setInfactLoggingOptions, useAsyncEventContext, useControllerContext, useEventLogger };
|
|
1200
|
+
export { ApplyDecorators, Circular, Const, ConstFactory, ContextInjector, Controller, Description, EventLogger, Id, ImportController, Inherit, Inject, InjectEventLogger, InjectFromScope, InjectMoostLogger, InjectScopeVars, Injectable, Intercept, InterceptorHandler, Label, LoggerTopic, Moost, Optional, Param, Params, Pipe, ProstoLogger, Provide, Replace, Required, Resolve, TInterceptorPriority, TPipePriority, Value, clearGlobalWooks, createLogger, createProvideRegistry, createReplaceRegistry, defineInfactScope, defineInterceptorFn, defineMoostEventHandler, definePipeFn, getConstructor, getContextInjector, getGlobalWooks, getInfactScopeVars, getInstanceOwnMethods, getInstanceOwnProps, getMoostInfact, getMoostMate, getNewMoostInfact, isConstructor, loggerConsoleTransport, registerEventScope, replaceContextInjector, resolvePipe, setControllerContext, setInfactLoggingOptions, useAsyncEventContext, useControllerContext, useEventLogger };
|