moost 0.5.29 → 0.5.31
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 +371 -122
- package/dist/index.d.ts +364 -13
- package/dist/index.mjs +353 -106
- package/package.json +8 -8
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,16 +69,28 @@ 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
|
-
|
|
73
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Get Infact instance (used for Dependency Injections)
|
|
92
|
+
*/ function getNewMoostInfact() {
|
|
93
|
+
const infactInstance = new Infact({
|
|
74
94
|
describeClass(classConstructor) {
|
|
75
95
|
const meta = getMoostMate().read(classConstructor);
|
|
76
96
|
return {
|
|
@@ -79,25 +99,26 @@ 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
|
-
resolveParam({ paramMeta, customData, classConstructor, index, scopeId }) {
|
|
86
|
-
if (paramMeta && customData?.pipes) return runPipes(customData.pipes,
|
|
105
|
+
resolveParam({ paramMeta, customData, classConstructor, index, scopeId, instantiate }) {
|
|
106
|
+
if (paramMeta && customData?.pipes) return runPipes(customData.pipes, void 0, {
|
|
87
107
|
paramMeta,
|
|
88
108
|
type: classConstructor,
|
|
89
109
|
key: "constructor",
|
|
90
110
|
scopeId,
|
|
91
111
|
classMeta: getMoostMate().read(classConstructor),
|
|
92
112
|
index,
|
|
93
|
-
targetMeta: paramMeta
|
|
113
|
+
targetMeta: paramMeta,
|
|
114
|
+
instantiate
|
|
94
115
|
}, "PARAM");
|
|
95
116
|
},
|
|
96
117
|
describeProp(classConstructor, key) {
|
|
97
118
|
const meta = getMoostMate().read(classConstructor, key);
|
|
98
119
|
return meta;
|
|
99
120
|
},
|
|
100
|
-
resolveProp({ instance, key, initialValue, propMeta, scopeId, classMeta, customData, classConstructor }) {
|
|
121
|
+
resolveProp({ instance, key, initialValue, propMeta, scopeId, classMeta, customData, classConstructor, instantiate }) {
|
|
101
122
|
if (propMeta && customData?.pipes) return runPipes(customData.pipes, initialValue, {
|
|
102
123
|
instance,
|
|
103
124
|
type: classConstructor,
|
|
@@ -105,7 +126,8 @@ function getNewMoostInfact() {
|
|
|
105
126
|
scopeId,
|
|
106
127
|
propMeta,
|
|
107
128
|
targetMeta: propMeta,
|
|
108
|
-
classMeta
|
|
129
|
+
classMeta,
|
|
130
|
+
instantiate
|
|
109
131
|
}, "PROP");
|
|
110
132
|
},
|
|
111
133
|
storeProvideRegByInstance: true,
|
|
@@ -124,39 +146,40 @@ function getNewMoostInfact() {
|
|
|
124
146
|
if (!loggingOptions.error) return;
|
|
125
147
|
break;
|
|
126
148
|
}
|
|
149
|
+
default:
|
|
127
150
|
}
|
|
128
151
|
let logger;
|
|
129
152
|
try {
|
|
130
|
-
logger = event === "error" ? getDefaultLogger(INFACT_BANNER) : useEventLogger(INFACT_BANNER);
|
|
153
|
+
logger = event === "error" ? getDefaultLogger(INFACT_BANNER) : useEventLogger$1(INFACT_BANNER);
|
|
131
154
|
} catch (error) {
|
|
132
155
|
logger = getDefaultLogger(INFACT_BANNER);
|
|
133
156
|
}
|
|
134
|
-
const instance =
|
|
157
|
+
const instance = `[4m${targetClass.name}[24m`;
|
|
135
158
|
switch (event) {
|
|
136
159
|
case "new-instance": {
|
|
137
160
|
const params = args?.map((a) => {
|
|
138
161
|
switch (typeof a) {
|
|
139
162
|
case "number":
|
|
140
|
-
case "boolean": return
|
|
141
|
-
case "string": return
|
|
163
|
+
case "boolean": return `[33m${a}[2m[34m`;
|
|
164
|
+
case "string": return `[92m"${a.slice(0, 1)}..."[2m[34m`;
|
|
142
165
|
case "object": {
|
|
143
166
|
if (Array.isArray(a)) return `[${a.length}]`;
|
|
144
|
-
if (getConstructor(a)) return getConstructor(a).name;
|
|
167
|
+
if (getConstructor$1(a)) return getConstructor$1(a).name;
|
|
145
168
|
return "{}";
|
|
146
169
|
}
|
|
147
170
|
default: return "*";
|
|
148
171
|
}
|
|
149
|
-
}).map((a) =>
|
|
150
|
-
logger.info(`new ${instance}
|
|
172
|
+
}).map((a) => `[2m[1m${a}[22m[2m`).join(", ") || "";
|
|
173
|
+
logger.info(`new ${instance}[2m[34m(${params})`);
|
|
151
174
|
break;
|
|
152
175
|
}
|
|
153
176
|
case "warn": {
|
|
154
|
-
const hier =
|
|
177
|
+
const hier = `[2m[34m⋱ ${args?.map(String).join(" → ") || ""}`;
|
|
155
178
|
logger.warn(`${instance} - ${message} ${hier}`);
|
|
156
179
|
break;
|
|
157
180
|
}
|
|
158
181
|
case "error": {
|
|
159
|
-
const hier =
|
|
182
|
+
const hier = `[2m[34m⋱ ${args?.map(String).join(" → ") || ""}`;
|
|
160
183
|
logger.error(`Failed to instantiate ${instance}. ${message} ${hier}`);
|
|
161
184
|
break;
|
|
162
185
|
}
|
|
@@ -164,19 +187,20 @@ function getNewMoostInfact() {
|
|
|
164
187
|
}
|
|
165
188
|
}
|
|
166
189
|
});
|
|
190
|
+
return infactInstance;
|
|
167
191
|
}
|
|
168
192
|
|
|
169
193
|
//#endregion
|
|
170
194
|
//#region packages/moost/src/composables/controller.composable.ts
|
|
171
195
|
function setControllerContext(controller, method, route) {
|
|
172
|
-
const { store } = useAsyncEventContext();
|
|
196
|
+
const { store } = useAsyncEventContext$1();
|
|
173
197
|
const { set } = store("controller");
|
|
174
198
|
set("instance", controller);
|
|
175
199
|
set("method", method);
|
|
176
200
|
set("route", route);
|
|
177
201
|
}
|
|
178
202
|
function useControllerContext() {
|
|
179
|
-
const { store } = useAsyncEventContext();
|
|
203
|
+
const { store } = useAsyncEventContext$1();
|
|
180
204
|
const { get } = store("controller");
|
|
181
205
|
const getController = () => get("instance");
|
|
182
206
|
const getMethod = () => get("method");
|
|
@@ -210,10 +234,10 @@ function registerEventScope(scopeId) {
|
|
|
210
234
|
};
|
|
211
235
|
}
|
|
212
236
|
function defineMoostEventHandler(options) {
|
|
213
|
-
const ci = getContextInjector();
|
|
237
|
+
const ci = getContextInjector$1();
|
|
214
238
|
return async () => {
|
|
215
239
|
const scopeId = useEventId().getId();
|
|
216
|
-
const logger = useEventLogger(options.loggerTitle);
|
|
240
|
+
const logger = useEventLogger$1(options.loggerTitle);
|
|
217
241
|
const unscope = registerEventScope(scopeId);
|
|
218
242
|
let response;
|
|
219
243
|
const hookOptions = {
|
|
@@ -233,7 +257,7 @@ function defineMoostEventHandler(options) {
|
|
|
233
257
|
const interceptorHandler = await options.getIterceptorHandler();
|
|
234
258
|
if (interceptorHandler?.count) try {
|
|
235
259
|
response = await ci.with("Interceptors:init", () => interceptorHandler.init());
|
|
236
|
-
if (response !==
|
|
260
|
+
if (response !== void 0) return await endWithResponse();
|
|
237
261
|
} catch (error) {
|
|
238
262
|
options.logErrors && logger.error(error);
|
|
239
263
|
response = error;
|
|
@@ -249,7 +273,7 @@ function defineMoostEventHandler(options) {
|
|
|
249
273
|
}
|
|
250
274
|
if (interceptorHandler?.countBefore) {
|
|
251
275
|
response = await ci.with("Interceptors:before", () => interceptorHandler.fireBefore(response));
|
|
252
|
-
if (response !==
|
|
276
|
+
if (response !== void 0) return endWithResponse();
|
|
253
277
|
}
|
|
254
278
|
const callControllerMethod = () => {
|
|
255
279
|
if (options.callControllerMethod) return options.callControllerMethod(args);
|
|
@@ -258,7 +282,7 @@ function defineMoostEventHandler(options) {
|
|
|
258
282
|
try {
|
|
259
283
|
response = await ci.with(`Handler:${options.targetPath}`, {
|
|
260
284
|
"moost.handler": options.controllerMethod || "",
|
|
261
|
-
"moost.controller": getConstructor(instance).name
|
|
285
|
+
"moost.controller": getConstructor$1(instance).name
|
|
262
286
|
}, () => callControllerMethod());
|
|
263
287
|
} catch (error) {
|
|
264
288
|
options.logErrors && logger.error(error);
|
|
@@ -287,7 +311,7 @@ function defineMoostEventHandler(options) {
|
|
|
287
311
|
function getInstanceOwnMethods(instance) {
|
|
288
312
|
const proto = Object.getPrototypeOf(instance);
|
|
289
313
|
return [
|
|
290
|
-
...getParentProps(getConstructor(instance)),
|
|
314
|
+
...getParentProps(getConstructor$1(instance)),
|
|
291
315
|
...Object.getOwnPropertyNames(proto),
|
|
292
316
|
...Object.getOwnPropertyNames(instance)
|
|
293
317
|
].filter((m) => typeof instance[m] === "function");
|
|
@@ -295,7 +319,7 @@ function getInstanceOwnMethods(instance) {
|
|
|
295
319
|
function getInstanceOwnProps(instance) {
|
|
296
320
|
const proto = Object.getPrototypeOf(instance);
|
|
297
321
|
return [
|
|
298
|
-
...getParentProps(getConstructor(instance)),
|
|
322
|
+
...getParentProps(getConstructor$1(instance)),
|
|
299
323
|
...Object.getOwnPropertyNames(proto),
|
|
300
324
|
...Object.getOwnPropertyNames(instance)
|
|
301
325
|
].filter((m) => typeof instance[m] !== "function");
|
|
@@ -318,7 +342,7 @@ async function getCallableFn(targetInstance, fn, pipes, logger) {
|
|
|
318
342
|
return (...args) => instance.handler(...args);
|
|
319
343
|
}
|
|
320
344
|
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`);
|
|
345
|
+
const e = /* @__PURE__ */ new Error(`getCallableFn failed for "${getConstructor$1(targetInstance).name}" because the passed arg is not a Function nor TClassFunction`);
|
|
322
346
|
logger.error(e);
|
|
323
347
|
throw e;
|
|
324
348
|
}
|
|
@@ -353,7 +377,7 @@ var InterceptorHandler = class {
|
|
|
353
377
|
this.responseOverwritten = true;
|
|
354
378
|
}
|
|
355
379
|
async init() {
|
|
356
|
-
const ci = getContextInjector();
|
|
380
|
+
const ci = getContextInjector$1();
|
|
357
381
|
for (const { handler, name } of this.handlers) {
|
|
358
382
|
const response = await ci.with(`Interceptor:${name}`, { "moost.interceptor.stage": "init" }, () => handler((fn) => {
|
|
359
383
|
this.before.push({
|
|
@@ -371,11 +395,11 @@ var InterceptorHandler = class {
|
|
|
371
395
|
fn
|
|
372
396
|
});
|
|
373
397
|
}));
|
|
374
|
-
if (response !==
|
|
398
|
+
if (response !== void 0) return response;
|
|
375
399
|
}
|
|
376
400
|
}
|
|
377
401
|
async fireBefore(response) {
|
|
378
|
-
const ci = getContextInjector();
|
|
402
|
+
const ci = getContextInjector$1();
|
|
379
403
|
this.response = response;
|
|
380
404
|
for (const { name, fn } of this.before) {
|
|
381
405
|
await ci.with(`Interceptor:${name}`, { "moost.interceptor.stage": "before" }, () => fn(this.replyFn.bind(this)));
|
|
@@ -384,7 +408,7 @@ var InterceptorHandler = class {
|
|
|
384
408
|
return this.response;
|
|
385
409
|
}
|
|
386
410
|
async fireAfter(response) {
|
|
387
|
-
const ci = getContextInjector();
|
|
411
|
+
const ci = getContextInjector$1();
|
|
388
412
|
this.response = response;
|
|
389
413
|
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
414
|
else for (const { name, fn } of this.after) await ci.with(`Interceptor:${name}`, { "moost.interceptor.stage": "onError" }, () => fn(response, this.replyFn.bind(this)));
|
|
@@ -467,18 +491,19 @@ async function bindControllerMethods(options) {
|
|
|
467
491
|
});
|
|
468
492
|
const resolveArgs = async () => {
|
|
469
493
|
const args = [];
|
|
470
|
-
for (const [i, { pipes: pipes$1, meta: paramMeta }] of argsPipes.entries()) args[i] = await runPipes(pipes$1,
|
|
494
|
+
for (const [i, { pipes: pipes$1, meta: paramMeta }] of argsPipes.entries()) args[i] = await runPipes(pipes$1, void 0, {
|
|
471
495
|
classMeta: meta,
|
|
472
496
|
methodMeta,
|
|
473
497
|
paramMeta,
|
|
474
498
|
type: classConstructor,
|
|
475
499
|
key: method,
|
|
476
500
|
index: i,
|
|
477
|
-
targetMeta: paramMeta
|
|
501
|
+
targetMeta: paramMeta,
|
|
502
|
+
instantiate: (t) => useControllerContext().instantiate(t)
|
|
478
503
|
}, "PARAM");
|
|
479
504
|
return args;
|
|
480
505
|
};
|
|
481
|
-
const wm = new WeakMap();
|
|
506
|
+
const wm = /* @__PURE__ */ new WeakMap();
|
|
482
507
|
controllerOverview.handlers.push(...methodMeta.handlers.map((h) => {
|
|
483
508
|
const data = {
|
|
484
509
|
meta: methodMeta,
|
|
@@ -522,22 +547,67 @@ function Circular(resolver) {
|
|
|
522
547
|
|
|
523
548
|
//#endregion
|
|
524
549
|
//#region packages/moost/src/decorators/common.decorator.ts
|
|
525
|
-
|
|
550
|
+
/**
|
|
551
|
+
* Apply Multiple Decorators
|
|
552
|
+
*
|
|
553
|
+
* @param decorators - array of decorators
|
|
554
|
+
* @returns
|
|
555
|
+
*/ function ApplyDecorators(...decorators) {
|
|
556
|
+
const mate$1 = getMoostMate();
|
|
557
|
+
return mate$1.apply(...decorators);
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* ## Label
|
|
561
|
+
* ### @Decorator
|
|
562
|
+
* _Common purpose decorator that may be used by various adapters for various purposes_
|
|
563
|
+
*
|
|
564
|
+
* Stores Label metadata
|
|
565
|
+
*/ function Label(value) {
|
|
526
566
|
return getMoostMate().decorate("label", value);
|
|
527
567
|
}
|
|
528
|
-
|
|
568
|
+
/**
|
|
569
|
+
* ## Description
|
|
570
|
+
* ### @Decorator
|
|
571
|
+
* _Common purpose decorator that may be used by various adapters for various purposes_
|
|
572
|
+
*
|
|
573
|
+
* Stores Description metadata
|
|
574
|
+
*/ function Description(value) {
|
|
529
575
|
return getMoostMate().decorate("description", value);
|
|
530
576
|
}
|
|
531
|
-
|
|
577
|
+
/**
|
|
578
|
+
* ## Value
|
|
579
|
+
* ### @Decorator
|
|
580
|
+
* _Common purpose decorator that may be used by various adapters for various purposes_
|
|
581
|
+
*
|
|
582
|
+
* Stores Value metadata
|
|
583
|
+
*/ function Value(value) {
|
|
532
584
|
return getMoostMate().decorate("value", value);
|
|
533
585
|
}
|
|
534
|
-
|
|
586
|
+
/**
|
|
587
|
+
* ## Id
|
|
588
|
+
* ### @Decorator
|
|
589
|
+
* _Common purpose decorator that may be used by various adapters for various purposes_
|
|
590
|
+
*
|
|
591
|
+
* Stores Id metadata
|
|
592
|
+
*/ function Id(value) {
|
|
535
593
|
return getMoostMate().decorate("id", value);
|
|
536
594
|
}
|
|
537
|
-
|
|
595
|
+
/**
|
|
596
|
+
* ## Optional
|
|
597
|
+
* ### @Decorator
|
|
598
|
+
* _Common purpose decorator that may be used by various adapters for various purposes_
|
|
599
|
+
*
|
|
600
|
+
* Stores Optional metadata
|
|
601
|
+
*/ function Optional() {
|
|
538
602
|
return getMoostMate().decorate("optional", true);
|
|
539
603
|
}
|
|
540
|
-
|
|
604
|
+
/**
|
|
605
|
+
* ## Required
|
|
606
|
+
* ### @Decorator
|
|
607
|
+
* _Common purpose decorator that may be used by various adapters for various purposes_
|
|
608
|
+
*
|
|
609
|
+
* Stores Required metadata
|
|
610
|
+
*/ function Required() {
|
|
541
611
|
const mate$1 = getMoostMate();
|
|
542
612
|
return mate$1.apply(mate$1.decorate("required", true), mate$1.decorateClass((meta, level, key, index) => {
|
|
543
613
|
if (typeof index !== "number" && meta && ["string", "symbol"].includes(typeof key)) {
|
|
@@ -550,7 +620,15 @@ function Required() {
|
|
|
550
620
|
|
|
551
621
|
//#endregion
|
|
552
622
|
//#region packages/moost/src/decorators/injectable.decorator.ts
|
|
553
|
-
|
|
623
|
+
/**
|
|
624
|
+
* ## Injectable
|
|
625
|
+
* ### @Decorator
|
|
626
|
+
* Mark the Class as Injectable to enable it to be used in dependency injection
|
|
627
|
+
* @param scope - Scope for injection ("FOR_EVENT" | "SINGLETON" | true)
|
|
628
|
+
* FOR_EVENT - will create a new instance for each incoming request
|
|
629
|
+
* SINGLETON | true - will create a new instance only once
|
|
630
|
+
* @param label - field label
|
|
631
|
+
*/ function Injectable(scope = true) {
|
|
554
632
|
return getMoostMate().decorate("injectable", scope);
|
|
555
633
|
}
|
|
556
634
|
const insureInjectable = getMoostMate().decorate((meta) => {
|
|
@@ -560,25 +638,35 @@ const insureInjectable = getMoostMate().decorate((meta) => {
|
|
|
560
638
|
|
|
561
639
|
//#endregion
|
|
562
640
|
//#region packages/moost/src/decorators/controller.decorator.ts
|
|
563
|
-
|
|
641
|
+
/**
|
|
642
|
+
* ## Controller
|
|
643
|
+
* ### @Decorator
|
|
644
|
+
* Set Class as a Controller
|
|
645
|
+
* @param prefix - define the prefix for all the paths of this controller
|
|
646
|
+
*/ function Controller(prefix) {
|
|
564
647
|
const mate$1 = getMoostMate();
|
|
565
648
|
return mate$1.apply(insureInjectable, mate$1.decorate("controller", { prefix: prefix || "" }));
|
|
566
649
|
}
|
|
567
650
|
function ImportController(prefix, controller, provide) {
|
|
568
651
|
return getMoostMate().decorate("importController", {
|
|
569
|
-
prefix: typeof prefix === "string" ? prefix :
|
|
652
|
+
prefix: typeof prefix === "string" ? prefix : void 0,
|
|
570
653
|
typeResolver: typeof prefix === "string" ? controller : prefix,
|
|
571
|
-
provide: typeof prefix === "string" ? provide ||
|
|
654
|
+
provide: typeof prefix === "string" ? provide || void 0 : controller || void 0
|
|
572
655
|
}, true);
|
|
573
656
|
}
|
|
574
657
|
|
|
575
658
|
//#endregion
|
|
576
659
|
//#region packages/moost/src/decorators/inherit.decorator.ts
|
|
577
|
-
|
|
660
|
+
/**
|
|
661
|
+
* ## Inherit
|
|
662
|
+
* ### @Decorator
|
|
663
|
+
* Inherit metadata from super class
|
|
664
|
+
* @returns
|
|
665
|
+
*/ const Inherit = () => getMoostMate().decorate("inherit", true);
|
|
578
666
|
|
|
579
667
|
//#endregion
|
|
580
668
|
//#region packages/moost/src/decorators/intercept.decorator.ts
|
|
581
|
-
var TInterceptorPriority =
|
|
669
|
+
var TInterceptorPriority = /* @__PURE__ */ function(TInterceptorPriority$1) {
|
|
582
670
|
TInterceptorPriority$1[TInterceptorPriority$1["BEFORE_ALL"] = 0] = "BEFORE_ALL";
|
|
583
671
|
TInterceptorPriority$1[TInterceptorPriority$1["BEFORE_GUARD"] = 1] = "BEFORE_GUARD";
|
|
584
672
|
TInterceptorPriority$1[TInterceptorPriority$1["GUARD"] = 2] = "GUARD";
|
|
@@ -588,7 +676,14 @@ var TInterceptorPriority = /*#__PURE__*/ function(TInterceptorPriority$1) {
|
|
|
588
676
|
TInterceptorPriority$1[TInterceptorPriority$1["AFTER_ALL"] = 6] = "AFTER_ALL";
|
|
589
677
|
return TInterceptorPriority$1;
|
|
590
678
|
}({});
|
|
591
|
-
|
|
679
|
+
/**
|
|
680
|
+
* ## Intercept
|
|
681
|
+
* ### @Decorator
|
|
682
|
+
* Set interceptor
|
|
683
|
+
* @param handler interceptor fn (use defineInterceptorFn)
|
|
684
|
+
* @param priority interceptor priority
|
|
685
|
+
* @returns
|
|
686
|
+
*/ function Intercept(handler, priority, name) {
|
|
592
687
|
return getMoostMate().decorate("interceptors", {
|
|
593
688
|
handler,
|
|
594
689
|
priority: priority || handler.priority || 4,
|
|
@@ -598,9 +693,15 @@ function Intercept(handler, priority, name) {
|
|
|
598
693
|
|
|
599
694
|
//#endregion
|
|
600
695
|
//#region packages/moost/src/decorators/resolve.decorator.ts
|
|
601
|
-
|
|
696
|
+
/**
|
|
697
|
+
* Hook to the Response Status
|
|
698
|
+
* @decorator
|
|
699
|
+
* @param resolver - resolver function
|
|
700
|
+
* @param label - field label
|
|
701
|
+
* @paramType unknown
|
|
702
|
+
*/ function Resolve(resolver, label) {
|
|
602
703
|
return (target, key, index) => {
|
|
603
|
-
const i = typeof index === "number" ? index :
|
|
704
|
+
const i = typeof index === "number" ? index : void 0;
|
|
604
705
|
getMoostMate().decorate("resolver", (metas, level) => {
|
|
605
706
|
let newLabel = label;
|
|
606
707
|
if (!newLabel && level === "PROP" && typeof metas.key === "string") newLabel = metas.key;
|
|
@@ -609,16 +710,37 @@ function Resolve(resolver, label) {
|
|
|
609
710
|
})(target, key, i);
|
|
610
711
|
};
|
|
611
712
|
}
|
|
612
|
-
|
|
713
|
+
/**
|
|
714
|
+
* Get Param Value from url parh
|
|
715
|
+
* @decorator
|
|
716
|
+
* @param name - param name
|
|
717
|
+
* @paramType string
|
|
718
|
+
*/ function Param(name) {
|
|
613
719
|
return getMoostMate().apply(getMoostMate().decorate("paramSource", "ROUTE"), getMoostMate().decorate("paramName", name), Resolve(() => useRouteParams().get(name), name));
|
|
614
720
|
}
|
|
615
|
-
|
|
721
|
+
/**
|
|
722
|
+
* Get Parsed Params from url parh
|
|
723
|
+
* @decorator
|
|
724
|
+
* @paramType object
|
|
725
|
+
*/ function Params() {
|
|
616
726
|
return Resolve(() => useRouteParams().params, "params");
|
|
617
727
|
}
|
|
618
|
-
|
|
728
|
+
/**
|
|
729
|
+
* Provide Const Value
|
|
730
|
+
* @decorator
|
|
731
|
+
* @param value - provided value
|
|
732
|
+
* @param label - label of the field
|
|
733
|
+
* @paramType unknown
|
|
734
|
+
*/ function Const(value, label) {
|
|
619
735
|
return Resolve(() => value, label);
|
|
620
736
|
}
|
|
621
|
-
|
|
737
|
+
/**
|
|
738
|
+
* Provide Const Value from Factory fn
|
|
739
|
+
* @decorator
|
|
740
|
+
* @param factory - value Factory fn
|
|
741
|
+
* @param label - label of the field
|
|
742
|
+
* @paramType unknown
|
|
743
|
+
*/ function ConstFactory(factory, label) {
|
|
622
744
|
return Resolve(async () => factory(), label);
|
|
623
745
|
}
|
|
624
746
|
function fillLabel(target, key, index, name) {
|
|
@@ -632,10 +754,18 @@ function fillLabel(target, key, index, name) {
|
|
|
632
754
|
|
|
633
755
|
//#endregion
|
|
634
756
|
//#region packages/moost/src/decorators/logger.decorator.ts
|
|
635
|
-
|
|
636
|
-
|
|
757
|
+
/**
|
|
758
|
+
* Resolves event logger from event context
|
|
759
|
+
* @param topic
|
|
760
|
+
* @returns Resolver to '@wooksjs/event-core' (EventLogger)
|
|
761
|
+
*/ function InjectEventLogger(topic) {
|
|
762
|
+
return Resolve(() => useEventLogger$1(topic));
|
|
637
763
|
}
|
|
638
|
-
|
|
764
|
+
/**
|
|
765
|
+
* Resolves app-level logger
|
|
766
|
+
* @param topic - logger topic (can be overrided by @LoggerTopic)
|
|
767
|
+
* @returns
|
|
768
|
+
*/ function InjectMoostLogger(topic) {
|
|
639
769
|
return Resolve(async (metas) => {
|
|
640
770
|
const { instantiate, getController } = useControllerContext();
|
|
641
771
|
const controller = getController();
|
|
@@ -644,13 +774,17 @@ function InjectMoostLogger(topic) {
|
|
|
644
774
|
return moostApp.getLogger(meta?.loggerTopic || topic || meta?.id);
|
|
645
775
|
});
|
|
646
776
|
}
|
|
647
|
-
|
|
777
|
+
/**
|
|
778
|
+
* Sets logger topic (used in @InjectMoostLogger)
|
|
779
|
+
* @param topic - logger topic (banner)
|
|
780
|
+
* @returns
|
|
781
|
+
*/ function LoggerTopic(topic) {
|
|
648
782
|
return getMoostMate().decorate("loggerTopic", topic);
|
|
649
783
|
}
|
|
650
784
|
|
|
651
785
|
//#endregion
|
|
652
786
|
//#region packages/moost/src/pipes/types.ts
|
|
653
|
-
var TPipePriority =
|
|
787
|
+
var TPipePriority = /* @__PURE__ */ function(TPipePriority$1) {
|
|
654
788
|
TPipePriority$1[TPipePriority$1["BEFORE_RESOLVE"] = 0] = "BEFORE_RESOLVE";
|
|
655
789
|
TPipePriority$1[TPipePriority$1["RESOLVE"] = 1] = "RESOLVE";
|
|
656
790
|
TPipePriority$1[TPipePriority$1["AFTER_RESOLVE"] = 2] = "AFTER_RESOLVE";
|
|
@@ -665,7 +799,14 @@ var TPipePriority = /*#__PURE__*/ function(TPipePriority$1) {
|
|
|
665
799
|
|
|
666
800
|
//#endregion
|
|
667
801
|
//#region packages/moost/src/decorators/pipe.decorator.ts
|
|
668
|
-
|
|
802
|
+
/**
|
|
803
|
+
* ## Pipe
|
|
804
|
+
* ### @Decorator
|
|
805
|
+
* Attach pipe
|
|
806
|
+
* @param handler pipe handler
|
|
807
|
+
* @param priority pipe priority
|
|
808
|
+
* @returns
|
|
809
|
+
*/ function Pipe(handler, priority) {
|
|
669
810
|
if (typeof priority !== "number") priority = typeof handler.priority === "number" ? handler.priority : TPipePriority.TRANSFORM;
|
|
670
811
|
return getMoostMate().decorate("pipes", {
|
|
671
812
|
handler,
|
|
@@ -675,40 +816,104 @@ function Pipe(handler, priority) {
|
|
|
675
816
|
|
|
676
817
|
//#endregion
|
|
677
818
|
//#region packages/moost/src/decorators/provide.decorator.ts
|
|
678
|
-
|
|
819
|
+
/**
|
|
820
|
+
* ## Provide
|
|
821
|
+
* ### @Decorator
|
|
822
|
+
* Defines provide registry for class (and all the children)
|
|
823
|
+
* @param type - string or class constructor
|
|
824
|
+
* @param fn - factory function for provided value
|
|
825
|
+
*/ function Provide(type, fn) {
|
|
679
826
|
return getMoostMate().decorate((meta) => {
|
|
680
827
|
meta.provide = meta.provide || {};
|
|
681
|
-
Object.assign(meta.provide, createProvideRegistry([type, fn]));
|
|
828
|
+
Object.assign(meta.provide, createProvideRegistry$1([type, fn]));
|
|
682
829
|
return meta;
|
|
683
830
|
});
|
|
684
831
|
}
|
|
685
|
-
|
|
832
|
+
/**
|
|
833
|
+
* ## Replace
|
|
834
|
+
* ### @Decorator
|
|
835
|
+
* Defines class to replace in DI
|
|
836
|
+
* @param type - class to replace
|
|
837
|
+
* @param newType - new class
|
|
838
|
+
*/ function Replace(type, newType) {
|
|
686
839
|
return getMoostMate().decorate((meta) => {
|
|
687
840
|
meta.replace = meta.replace || {};
|
|
688
|
-
Object.assign(meta.replace, createReplaceRegistry([type, newType]));
|
|
841
|
+
Object.assign(meta.replace, createReplaceRegistry$1([type, newType]));
|
|
689
842
|
return meta;
|
|
690
843
|
});
|
|
691
844
|
}
|
|
692
|
-
|
|
845
|
+
/**
|
|
846
|
+
* ## Inject
|
|
847
|
+
* ### @Decorator
|
|
848
|
+
* Defines a key from provide registry to inject value
|
|
849
|
+
* (For optional values use with @Optional())
|
|
850
|
+
* @param type - string or class constructor
|
|
851
|
+
*/ function Inject(type) {
|
|
693
852
|
return getMoostMate().decorate("inject", type);
|
|
694
853
|
}
|
|
695
|
-
|
|
854
|
+
/**
|
|
855
|
+
* Injects instance from scope
|
|
856
|
+
*
|
|
857
|
+
* (scope must be defined by `defineInfactScope` fn)
|
|
858
|
+
* @param name scope name
|
|
859
|
+
*/ function InjectFromScope(name) {
|
|
696
860
|
return getMoostMate().decorate("fromScope", name);
|
|
697
861
|
}
|
|
698
|
-
|
|
862
|
+
/**
|
|
863
|
+
* Inject vars from scope for instances
|
|
864
|
+
* instantiated with `@InjectFromScope` decorator
|
|
865
|
+
*/ function InjectScopeVars(name) {
|
|
699
866
|
return Resolve(({ scopeId }) => {
|
|
700
867
|
if (scopeId) return name ? getInfactScopeVars(scopeId)?.[name] : getInfactScopeVars(scopeId);
|
|
701
|
-
return
|
|
868
|
+
return void 0;
|
|
702
869
|
});
|
|
703
870
|
}
|
|
704
871
|
|
|
705
872
|
//#endregion
|
|
706
873
|
//#region packages/moost/src/define.ts
|
|
707
|
-
|
|
874
|
+
/**
|
|
875
|
+
* ### Define Interceptor Function
|
|
876
|
+
*
|
|
877
|
+
* ```ts
|
|
878
|
+
* defineInterceptorFn((before, after, onError) => {
|
|
879
|
+
* //init
|
|
880
|
+
* before(() => {
|
|
881
|
+
* // before handler
|
|
882
|
+
* })
|
|
883
|
+
* after((response, reply) => {
|
|
884
|
+
* // after handler
|
|
885
|
+
* })
|
|
886
|
+
* onError((error, reply) => {
|
|
887
|
+
* // when error occured
|
|
888
|
+
* })
|
|
889
|
+
* },
|
|
890
|
+
* TInterceptorPriority.INTERCEPTOR,
|
|
891
|
+
* )
|
|
892
|
+
* ```
|
|
893
|
+
*
|
|
894
|
+
* @param fn interceptor function
|
|
895
|
+
* @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
|
|
896
|
+
* @returns
|
|
897
|
+
*/ function defineInterceptorFn(fn, priority = TInterceptorPriority.INTERCEPTOR) {
|
|
708
898
|
fn.priority = priority;
|
|
709
899
|
return fn;
|
|
710
900
|
}
|
|
711
|
-
|
|
901
|
+
/**
|
|
902
|
+
* ### Define Pipe Function
|
|
903
|
+
*
|
|
904
|
+
* ```ts
|
|
905
|
+
* // example of a transform pipe
|
|
906
|
+
* const uppercaseTransformPipe = definePipeFn((value, metas, level) => {
|
|
907
|
+
* return typeof value === 'string' ? value.toUpperCase() : value
|
|
908
|
+
* },
|
|
909
|
+
* TPipePriority.TRANSFORM,
|
|
910
|
+
* )
|
|
911
|
+
* ```
|
|
912
|
+
*
|
|
913
|
+
* @param fn interceptor function
|
|
914
|
+
* @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
|
|
915
|
+
* @returns
|
|
916
|
+
*/ function definePipeFn(fn, priority = TPipePriority.TRANSFORM) {
|
|
712
917
|
fn.priority = priority;
|
|
713
918
|
return fn;
|
|
714
919
|
}
|
|
@@ -718,7 +923,7 @@ function definePipeFn(fn, priority = TPipePriority.TRANSFORM) {
|
|
|
718
923
|
const resolvePipe = definePipeFn((_value, metas, level) => {
|
|
719
924
|
const resolver = metas.targetMeta?.resolver;
|
|
720
925
|
if (resolver) return resolver(metas, level);
|
|
721
|
-
return
|
|
926
|
+
return void 0;
|
|
722
927
|
}, TPipePriority.RESOLVE);
|
|
723
928
|
|
|
724
929
|
//#endregion
|
|
@@ -740,7 +945,56 @@ function _define_property(obj, key, value) {
|
|
|
740
945
|
else obj[key] = value;
|
|
741
946
|
return obj;
|
|
742
947
|
}
|
|
743
|
-
|
|
948
|
+
/**
|
|
949
|
+
* ## Moost
|
|
950
|
+
* Main moostjs class that serves as a shell for Moost Adapters
|
|
951
|
+
*
|
|
952
|
+
* ### Usage with HTTP Adapter
|
|
953
|
+
* ```ts
|
|
954
|
+
* │ // HTTP server example
|
|
955
|
+
* │ import { MoostHttp, Get } from '@moostjs/event-http'
|
|
956
|
+
* │ import { Moost, Param } from 'moost'
|
|
957
|
+
* │
|
|
958
|
+
* │ class MyServer extends Moost {
|
|
959
|
+
* │ @Get('test/:name')
|
|
960
|
+
* │ test(@Param('name') name: string) {
|
|
961
|
+
* │ return { message: `Hello ${name}!` }
|
|
962
|
+
* │ }
|
|
963
|
+
* │ }
|
|
964
|
+
* │
|
|
965
|
+
* │ const app = new MyServer()
|
|
966
|
+
* │ const http = new MoostHttp()
|
|
967
|
+
* │ app.adapter(http).listen(3000, () => {
|
|
968
|
+
* │ app.getLogger('MyApp').log('Up on port 3000')
|
|
969
|
+
* │ })
|
|
970
|
+
* │ app.init()
|
|
971
|
+
* ```
|
|
972
|
+
* ### Usage with CLI Adapter
|
|
973
|
+
* ```ts
|
|
974
|
+
* │ // CLI example
|
|
975
|
+
* │ import { MoostCli, Cli, CliOption, cliHelpInterceptor } from '@moostjs/event-cli'
|
|
976
|
+
* │ import { Moost, Param } from 'moost'
|
|
977
|
+
* │
|
|
978
|
+
* │ class MyApp extends Moost {
|
|
979
|
+
* │ @Cli('command/:arg')
|
|
980
|
+
* │ command(
|
|
981
|
+
* │ @Param('arg')
|
|
982
|
+
* │ arg: string,
|
|
983
|
+
* │ @CliOption('test', 't')
|
|
984
|
+
* │ test: boolean,
|
|
985
|
+
* │ ) {
|
|
986
|
+
* │ return `command run with flag arg=${ arg }, test=${ test }`
|
|
987
|
+
* │ }
|
|
988
|
+
* │ }
|
|
989
|
+
* │
|
|
990
|
+
* │ const app = new MyApp()
|
|
991
|
+
* │ app.applyGlobalInterceptors(cliHelpInterceptor())
|
|
992
|
+
* │
|
|
993
|
+
* │ const cli = new MoostCli()
|
|
994
|
+
* │ app.adapter(cli)
|
|
995
|
+
* │ app.init()
|
|
996
|
+
* ```
|
|
997
|
+
*/ var Moost = class Moost extends Hookable {
|
|
744
998
|
_fireEventStart(source) {
|
|
745
999
|
this.callHook("event-start", source);
|
|
746
1000
|
}
|
|
@@ -758,7 +1012,7 @@ var Moost = class Moost extends Hookable {
|
|
|
758
1012
|
* @param topic
|
|
759
1013
|
* @returns
|
|
760
1014
|
*/ getLogger(topic) {
|
|
761
|
-
if (topic && this.logger instanceof ProstoLogger) return this.logger.createTopic(topic);
|
|
1015
|
+
if (topic && this.logger instanceof ProstoLogger$1) return this.logger.createTopic(topic);
|
|
762
1016
|
return this.logger;
|
|
763
1017
|
}
|
|
764
1018
|
adapter(a) {
|
|
@@ -772,10 +1026,10 @@ var Moost = class Moost extends Hookable {
|
|
|
772
1026
|
* ### init
|
|
773
1027
|
* Ititializes adapter. Must be called after adapters are attached.
|
|
774
1028
|
*/ async init() {
|
|
775
|
-
this.setProvideRegistry(createProvideRegistry([Moost, () => this], [ProstoLogger, () => this.logger], ["MOOST_LOGGER", () => this.logger]));
|
|
1029
|
+
this.setProvideRegistry(createProvideRegistry$1([Moost, () => this], [ProstoLogger$1, () => this.logger], ["MOOST_LOGGER", () => this.logger]));
|
|
776
1030
|
for (const a of this.adapters) {
|
|
777
|
-
const constructor = getConstructor(a);
|
|
778
|
-
if (constructor) this.setProvideRegistry(createProvideRegistry([constructor, () => a]));
|
|
1031
|
+
const constructor = getConstructor$1(a);
|
|
1032
|
+
if (constructor) this.setProvideRegistry(createProvideRegistry$1([constructor, () => a]));
|
|
779
1033
|
if (typeof a.getProvideRegistry === "function") this.setProvideRegistry(a.getProvideRegistry());
|
|
780
1034
|
}
|
|
781
1035
|
this.unregisteredControllers.unshift(this);
|
|
@@ -808,7 +1062,7 @@ var Moost = class Moost extends Hookable {
|
|
|
808
1062
|
const mate$1 = getMoostMate();
|
|
809
1063
|
const classMeta = mate$1.read(controller);
|
|
810
1064
|
const infact$1 = getMoostInfact();
|
|
811
|
-
const isControllerConsructor = isConstructor(controller);
|
|
1065
|
+
const isControllerConsructor = isConstructor$1(controller);
|
|
812
1066
|
const pipes = [...this.pipes, ...classMeta?.pipes || []].sort((a, b) => a.priority - b.priority);
|
|
813
1067
|
let instance;
|
|
814
1068
|
const infactOpts = {
|
|
@@ -828,7 +1082,7 @@ var Moost = class Moost extends Hookable {
|
|
|
828
1082
|
infact$1.setInstanceRegistries(instance, provide, replace, { pipes });
|
|
829
1083
|
}
|
|
830
1084
|
const getInstance = instance ? () => Promise.resolve(instance) : async () => await infact$1.get(controller, { ...infactOpts });
|
|
831
|
-
const classConstructor = isConstructor(controller) ? controller : getConstructor(controller);
|
|
1085
|
+
const classConstructor = isConstructor$1(controller) ? controller : getConstructor$1(controller);
|
|
832
1086
|
this.controllersOverview.push(await bindControllerMethods({
|
|
833
1087
|
getInstance,
|
|
834
1088
|
classConstructor,
|
|
@@ -853,19 +1107,12 @@ var Moost = class Moost extends Hookable {
|
|
|
853
1107
|
...classMeta.replace
|
|
854
1108
|
};
|
|
855
1109
|
for (const ic of classMeta.importController) if (ic.typeResolver) {
|
|
856
|
-
const isConstr = isConstructor(ic.typeResolver);
|
|
1110
|
+
const isConstr = isConstructor$1(ic.typeResolver);
|
|
857
1111
|
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
|
-
);
|
|
1112
|
+
await this.bindController(isConstr ? ic.typeResolver : isFunc ? await ic.typeResolver() : ic.typeResolver, ic.provide ? {
|
|
1113
|
+
...mergedProvide,
|
|
1114
|
+
...ic.provide
|
|
1115
|
+
} : mergedProvide, mergedReplace, `${globalPrefix}/${prefix || ""}`, ic.prefix);
|
|
869
1116
|
}
|
|
870
1117
|
}
|
|
871
1118
|
}
|
|
@@ -878,7 +1125,7 @@ var Moost = class Moost extends Hookable {
|
|
|
878
1125
|
handler: item.handler,
|
|
879
1126
|
priority: item.priority
|
|
880
1127
|
});
|
|
881
|
-
this.globalInterceptorHandler =
|
|
1128
|
+
this.globalInterceptorHandler = void 0;
|
|
882
1129
|
return this;
|
|
883
1130
|
}
|
|
884
1131
|
/**
|
|
@@ -907,7 +1154,7 @@ var Moost = class Moost extends Hookable {
|
|
|
907
1154
|
priority: item.priority,
|
|
908
1155
|
name: item.name || item.handler._name || item.handler.name || "<anonymous>"
|
|
909
1156
|
});
|
|
910
|
-
this.globalInterceptorHandler =
|
|
1157
|
+
this.globalInterceptorHandler = void 0;
|
|
911
1158
|
return this;
|
|
912
1159
|
}
|
|
913
1160
|
/**
|
|
@@ -943,11 +1190,11 @@ var Moost = class Moost extends Hookable {
|
|
|
943
1190
|
logMappedHandler(eventName, classConstructor, method, stroke, prefix) {
|
|
944
1191
|
const c = stroke ? "\x1B[9m" : "";
|
|
945
1192
|
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}
|
|
1193
|
+
this.logger.info(`${prefix || ""}${c}${eventName} ${"\x1B[0m\x1B[2m\x1B[32m" + c}→ ${classConstructor.name}.${"\x1B[36m" + c}${method}[32m()${coff}`);
|
|
947
1194
|
}
|
|
948
1195
|
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(
|
|
1196
|
+
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 = [];
|
|
1197
|
+
this.logger = options?.logger || getDefaultLogger(`[2m[35mmoost`);
|
|
951
1198
|
setDefaultLogger(this.logger);
|
|
952
1199
|
const mate$1 = getMoostMate();
|
|
953
1200
|
Object.assign(mate$1, { logger: this.getLogger("mate") });
|
|
@@ -955,4 +1202,4 @@ var Moost = class Moost extends Hookable {
|
|
|
955
1202
|
};
|
|
956
1203
|
|
|
957
1204
|
//#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 };
|
|
1205
|
+
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 };
|