moost 0.3.11 → 0.3.13
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 +3 -275
- package/dist/index.d.ts +573 -639
- package/dist/index.mjs +3 -275
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,639 +1,573 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { Infact } from '@prostojs/infact';
|
|
4
|
-
|
|
5
|
-
import { TConsoleBase } from '@prostojs/logger';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
* @
|
|
154
|
-
*/
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
*
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
*
|
|
171
|
-
* @
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
*
|
|
179
|
-
* @
|
|
180
|
-
* @param
|
|
181
|
-
* @
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* ##
|
|
201
|
-
* ### @Decorator
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*/
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
*
|
|
232
|
-
* ###
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
*
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
export declare interface TPipeMetas<T extends TObject = TEmpty> {
|
|
575
|
-
classMeta?: TMoostMetadata & T;
|
|
576
|
-
methodMeta?: TMoostMetadata & T;
|
|
577
|
-
propMeta?: TMoostMetadata & T;
|
|
578
|
-
paramMeta?: TMoostParamsMetadata & T;
|
|
579
|
-
targetMeta?: TMoostParamsMetadata & T;
|
|
580
|
-
instance?: TObject;
|
|
581
|
-
type: TFunction;
|
|
582
|
-
index?: number;
|
|
583
|
-
key: string | symbol;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
export declare enum TPipePriority {
|
|
587
|
-
BEFORE_RESOLVE = 0,
|
|
588
|
-
RESOLVE = 1,
|
|
589
|
-
AFTER_RESOLVE = 2,
|
|
590
|
-
BEFORE_TRANSFORM = 3,
|
|
591
|
-
TRANSFORM = 4,
|
|
592
|
-
AFTER_TRANSFORM = 5,
|
|
593
|
-
BEFORE_VALIDATE = 6,
|
|
594
|
-
VALIDATE = 7,
|
|
595
|
-
AFTER_VALIDATE = 8
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
export { TProvideRegistry }
|
|
599
|
-
|
|
600
|
-
export declare function useControllerContext<T extends object>(): {
|
|
601
|
-
instantiate: <T_1>(c: TClassConstructor<T_1>) => Promise<T_1>;
|
|
602
|
-
getController: () => T;
|
|
603
|
-
getMethod: () => keyof T;
|
|
604
|
-
getControllerMeta: () => (TMoostMetadata<TEmpty> & TEmpty & {
|
|
605
|
-
params: (TEmpty & TMateParamMeta)[];
|
|
606
|
-
}) | (TMoostMetadata<TEmpty> & TEmpty & {
|
|
607
|
-
params: (TEmpty & TMateParamMeta)[];
|
|
608
|
-
} & {
|
|
609
|
-
params: (TEmpty & TMateParamMeta)[];
|
|
610
|
-
} & TMateClassMeta<TMateParamMeta & TMoostParamsMetadata & TEmpty> & TMatePropMeta<TMateParamMeta & TMoostParamsMetadata & TEmpty>);
|
|
611
|
-
getMethodMeta: (name?: string) => TMoostMetadata<TEmpty> & TEmpty & {
|
|
612
|
-
params: (TEmpty & TMateParamMeta)[];
|
|
613
|
-
} & {
|
|
614
|
-
params: (TEmpty & TMateParamMeta)[];
|
|
615
|
-
} & TMateClassMeta<TMateParamMeta & TMoostParamsMetadata & TEmpty> & TMatePropMeta<TMateParamMeta & TMoostParamsMetadata & TEmpty>;
|
|
616
|
-
getPropertiesList: () => (string | symbol)[];
|
|
617
|
-
getScope: () => true | TInjectableScope;
|
|
618
|
-
getParamsMeta: () => (TMateParamMeta & TMoostParamsMetadata)[] & (TEmpty & TMateParamMeta)[] & (TMateParamMeta & TMoostParamsMetadata & TEmpty)[];
|
|
619
|
-
getPropMeta: (name: string) => TMoostMetadata<TEmpty> & TEmpty & {
|
|
620
|
-
params: (TEmpty & TMateParamMeta)[];
|
|
621
|
-
} & {
|
|
622
|
-
params: (TEmpty & TMateParamMeta)[];
|
|
623
|
-
} & TMateClassMeta<TMateParamMeta & TMoostParamsMetadata & TEmpty> & TMatePropMeta<TMateParamMeta & TMoostParamsMetadata & TEmpty>;
|
|
624
|
-
};
|
|
625
|
-
|
|
626
|
-
export { useEventContext }
|
|
627
|
-
|
|
628
|
-
export { useEventLogger }
|
|
629
|
-
|
|
630
|
-
/**
|
|
631
|
-
* ## Value
|
|
632
|
-
* ### @Decorator
|
|
633
|
-
* _Common purpose decorator that may be used by various adapters for various purposes_
|
|
634
|
-
*
|
|
635
|
-
* Stores Value metadata
|
|
636
|
-
*/
|
|
637
|
-
export declare function Value(value: unknown): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
638
|
-
|
|
639
|
-
export { }
|
|
1
|
+
import * as _prostojs_mate from '@prostojs/mate';
|
|
2
|
+
import { TMateParamMeta, Mate } from '@prostojs/mate';
|
|
3
|
+
import { TProvideRegistry, Infact, TProvideFn } from '@prostojs/infact';
|
|
4
|
+
export { TProvideRegistry, createProvideRegistry } from '@prostojs/infact';
|
|
5
|
+
import { TConsoleBase } from '@prostojs/logger';
|
|
6
|
+
import { useEventLogger } from '@wooksjs/event-core';
|
|
7
|
+
export { EventLogger, THook, useEventContext, useEventLogger } from '@wooksjs/event-core';
|
|
8
|
+
|
|
9
|
+
type TAny = any;
|
|
10
|
+
type TAnyFn = {
|
|
11
|
+
(...a: TAny[]): unknown;
|
|
12
|
+
};
|
|
13
|
+
type TObject = object;
|
|
14
|
+
type TFunction = Function;
|
|
15
|
+
type TClassConstructor<T = unknown> = new (...args: TAny[]) => T;
|
|
16
|
+
interface TEmpty {
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface TClassFunction<T extends TAnyFn = TAnyFn> {
|
|
20
|
+
handler: T;
|
|
21
|
+
}
|
|
22
|
+
interface TClassFunctionConstructor<T extends TAnyFn = TAnyFn> {
|
|
23
|
+
new (...a: TAny[]): TClassFunction<T>;
|
|
24
|
+
}
|
|
25
|
+
type TCallableClassFunction<T extends TAnyFn = TAnyFn> = T | TClassFunctionConstructor;
|
|
26
|
+
|
|
27
|
+
type TInterceptorBefore = (reply: (response: TAny) => void) => void | Promise<void>;
|
|
28
|
+
type TInterceptorAfter = (response: TAny, reply: (response: TAny) => void) => void | Promise<void>;
|
|
29
|
+
type TInterceptorOnError = (error: Error, reply: (response: TAny) => void) => void | Promise<void>;
|
|
30
|
+
type TInterceptorFn = {
|
|
31
|
+
(before: (fn: TInterceptorBefore) => void, after: (fn: TInterceptorAfter) => void, onError: (fn: TInterceptorOnError) => void): unknown | Promise<unknown>;
|
|
32
|
+
priority?: TInterceptorPriority;
|
|
33
|
+
};
|
|
34
|
+
declare enum TInterceptorPriority {
|
|
35
|
+
BEFORE_ALL = 0,
|
|
36
|
+
BEFORE_GUARD = 1,
|
|
37
|
+
GUARD = 2,
|
|
38
|
+
AFTER_GUARD = 3,
|
|
39
|
+
INTERCEPTOR = 4,
|
|
40
|
+
CATCH_ERROR = 5,
|
|
41
|
+
AFTER_ALL = 6
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* ## Intercept
|
|
45
|
+
* ### @Decorator
|
|
46
|
+
* Set interceptor
|
|
47
|
+
* @param handler interceptor fn (use defineInterceptorFn)
|
|
48
|
+
* @param priority interceptor priority
|
|
49
|
+
* @returns
|
|
50
|
+
*/
|
|
51
|
+
declare function Intercept(handler: TCallableClassFunction<TInterceptorFn>, priority?: TInterceptorPriority): ClassDecorator & MethodDecorator;
|
|
52
|
+
|
|
53
|
+
type TDecoratorLevel = 'CLASS' | 'METHOD' | 'PROP' | 'PARAM';
|
|
54
|
+
|
|
55
|
+
interface TPipeMetas<T extends TObject = TEmpty> {
|
|
56
|
+
classMeta?: TMoostMetadata & T;
|
|
57
|
+
methodMeta?: TMoostMetadata & T;
|
|
58
|
+
propMeta?: TMoostMetadata & T;
|
|
59
|
+
paramMeta?: TMoostParamsMetadata & T;
|
|
60
|
+
targetMeta?: TMoostParamsMetadata & T;
|
|
61
|
+
instance?: TObject;
|
|
62
|
+
type: TFunction;
|
|
63
|
+
index?: number;
|
|
64
|
+
key: string | symbol;
|
|
65
|
+
}
|
|
66
|
+
type TPipeFn<T extends TObject = TEmpty> = {
|
|
67
|
+
(value: unknown, metas: TPipeMetas<T>, level: TDecoratorLevel): unknown | Promise<unknown>;
|
|
68
|
+
priority?: TPipePriority;
|
|
69
|
+
};
|
|
70
|
+
declare enum TPipePriority {
|
|
71
|
+
BEFORE_RESOLVE = 0,
|
|
72
|
+
RESOLVE = 1,
|
|
73
|
+
AFTER_RESOLVE = 2,
|
|
74
|
+
BEFORE_TRANSFORM = 3,
|
|
75
|
+
TRANSFORM = 4,
|
|
76
|
+
AFTER_TRANSFORM = 5,
|
|
77
|
+
BEFORE_VALIDATE = 6,
|
|
78
|
+
VALIDATE = 7,
|
|
79
|
+
AFTER_VALIDATE = 8
|
|
80
|
+
}
|
|
81
|
+
interface TPipeData {
|
|
82
|
+
handler: TPipeFn;
|
|
83
|
+
priority: TPipePriority;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
declare const resolvePipe: TPipeFn<TEmpty>;
|
|
87
|
+
|
|
88
|
+
interface TMoostMetadata<H extends TObject = TEmpty> extends TCommonMetaFields, TCommonMoostMeta {
|
|
89
|
+
requiredProps?: (string | symbol)[];
|
|
90
|
+
controller?: {
|
|
91
|
+
prefix?: string;
|
|
92
|
+
};
|
|
93
|
+
importController?: {
|
|
94
|
+
prefix?: string;
|
|
95
|
+
typeResolver?: TClassConstructor | (() => TClassConstructor | TObject | Promise<TClassConstructor | TObject>);
|
|
96
|
+
provide?: TProvideRegistry;
|
|
97
|
+
}[];
|
|
98
|
+
properties?: (string | symbol)[];
|
|
99
|
+
injectable?: true | TInjectableScope;
|
|
100
|
+
interceptors?: TInterceptorData[];
|
|
101
|
+
handlers?: TMoostHandler<H>[];
|
|
102
|
+
returnType?: TFunction;
|
|
103
|
+
provide?: TProvideRegistry;
|
|
104
|
+
params: (TMateParamMeta & TMoostParamsMetadata)[];
|
|
105
|
+
}
|
|
106
|
+
interface TMoostParamsMetadata extends TCommonMetaFields, TCommonMoostMeta {
|
|
107
|
+
circular?: () => TAny;
|
|
108
|
+
inject?: string | symbol | TClassConstructor;
|
|
109
|
+
nullable?: boolean;
|
|
110
|
+
paramSource?: string;
|
|
111
|
+
paramName?: string;
|
|
112
|
+
}
|
|
113
|
+
type TInjectableScope = 'FOR_EVENT' | 'SINGLETON';
|
|
114
|
+
type TMoostHandler<T> = {
|
|
115
|
+
type: string;
|
|
116
|
+
path?: string;
|
|
117
|
+
} & T;
|
|
118
|
+
interface TInterceptorData {
|
|
119
|
+
handler: TCallableClassFunction<TInterceptorFn>;
|
|
120
|
+
priority: TInterceptorPriority;
|
|
121
|
+
}
|
|
122
|
+
declare function getMoostMate<Class extends TObject = TEmpty, Prop extends TObject = TEmpty, Param extends TObject = TEmpty>(): Mate<TMoostMetadata<TEmpty> & Class & {
|
|
123
|
+
params: (Param & TMateParamMeta)[];
|
|
124
|
+
}, TMoostMetadata<TEmpty> & Prop & {
|
|
125
|
+
params: (Param & TMateParamMeta)[];
|
|
126
|
+
}>;
|
|
127
|
+
interface TCommonMetaFields {
|
|
128
|
+
id?: string;
|
|
129
|
+
label?: string;
|
|
130
|
+
value?: unknown;
|
|
131
|
+
description?: string;
|
|
132
|
+
optional?: boolean;
|
|
133
|
+
required?: boolean;
|
|
134
|
+
}
|
|
135
|
+
interface TCommonMoostMeta {
|
|
136
|
+
inherit?: boolean;
|
|
137
|
+
pipes?: TPipeData[];
|
|
138
|
+
resolver?: (metas: TPipeMetas<TAny>, level: TDecoratorLevel) => unknown;
|
|
139
|
+
type?: TFunction;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
declare function getMoostInfact(): Infact<TMoostMetadata<TEmpty>, TMoostMetadata<TEmpty>, TMoostParamsMetadata, TCustom>;
|
|
143
|
+
interface TCustom {
|
|
144
|
+
pipes?: TPipeData[];
|
|
145
|
+
}
|
|
146
|
+
declare function getNewMoostInfact(): Infact<TMoostMetadata<TEmpty>, TMoostMetadata<TEmpty>, TMoostParamsMetadata, TCustom>;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Hook to the Response Status
|
|
150
|
+
* @decorator
|
|
151
|
+
* @param resolver - resolver function
|
|
152
|
+
* @param label - field label
|
|
153
|
+
* @paramType unknown
|
|
154
|
+
*/
|
|
155
|
+
declare function Resolve<T extends TObject = TEmpty>(resolver: (metas: TPipeMetas<T>, level: TDecoratorLevel) => unknown, label?: string): ParameterDecorator & PropertyDecorator;
|
|
156
|
+
/**
|
|
157
|
+
* Get Param Value from url parh
|
|
158
|
+
* @decorator
|
|
159
|
+
* @param name - param name
|
|
160
|
+
* @paramType string
|
|
161
|
+
*/
|
|
162
|
+
declare function Param(name: string): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
163
|
+
/**
|
|
164
|
+
* Get Parsed Params from url parh
|
|
165
|
+
* @decorator
|
|
166
|
+
* @paramType object
|
|
167
|
+
*/
|
|
168
|
+
declare function Params(): ParameterDecorator & PropertyDecorator;
|
|
169
|
+
/**
|
|
170
|
+
* Provide Const Value
|
|
171
|
+
* @decorator
|
|
172
|
+
* @param value - provided value
|
|
173
|
+
* @param label - label of the field
|
|
174
|
+
* @paramType unknown
|
|
175
|
+
*/
|
|
176
|
+
declare function Const<T>(value: T, label?: string): ParameterDecorator & PropertyDecorator;
|
|
177
|
+
/**
|
|
178
|
+
* Provide Const Value from Factory fn
|
|
179
|
+
* @decorator
|
|
180
|
+
* @param factory - value Factory fn
|
|
181
|
+
* @param label - label of the field
|
|
182
|
+
* @paramType unknown
|
|
183
|
+
*/
|
|
184
|
+
declare function ConstFactory<T>(factory: () => T | Promise<T>, label?: string): ParameterDecorator & PropertyDecorator;
|
|
185
|
+
/**
|
|
186
|
+
* Resolves event logger from event context
|
|
187
|
+
* @param topic
|
|
188
|
+
* @returns Resolver to '@wooksjs/event-core' (EventLogger)
|
|
189
|
+
*/
|
|
190
|
+
declare function InjectEventLogger(topic?: string): ParameterDecorator & PropertyDecorator;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* ## Controller
|
|
194
|
+
* ### @Decorator
|
|
195
|
+
* Set Class as a Controller
|
|
196
|
+
* @param prefix - define the prefix for all the paths of this controller
|
|
197
|
+
*/
|
|
198
|
+
declare function Controller(prefix?: string): ClassDecorator;
|
|
199
|
+
/**
|
|
200
|
+
* ## ImportController
|
|
201
|
+
* ### @Decorator
|
|
202
|
+
* Attach sub-controller
|
|
203
|
+
* @param controller - target controller (instance) to import
|
|
204
|
+
* @param provide - provide registry for the target controller
|
|
205
|
+
*/
|
|
206
|
+
declare function ImportController(controller: TFunction | TObject, provide?: TProvideRegistry): ClassDecorator;
|
|
207
|
+
/**
|
|
208
|
+
* ## ImportController
|
|
209
|
+
* ### @Decorator
|
|
210
|
+
* Attach sub-controller
|
|
211
|
+
* @param prefix - redefine the prefix for all the paths of this controller
|
|
212
|
+
* @param controller - point to a controller (instance) to import
|
|
213
|
+
* @param provide - provide registry for the target controller
|
|
214
|
+
*/
|
|
215
|
+
declare function ImportController(prefix: string, controller: TFunction | TObject, provide?: TProvideRegistry): ClassDecorator;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* ## Injectable
|
|
219
|
+
* ### @Decorator
|
|
220
|
+
* Mark the Class as Injectable to enable it to be used in dependency injection
|
|
221
|
+
* @param scope - Scope for injection ("FOR_EVENT" | "SINGLETON" | true)
|
|
222
|
+
* FOR_EVENT - will create a new instance for each incoming request
|
|
223
|
+
* SINGLETON | true - will create a new instance only once
|
|
224
|
+
* @param label - field label
|
|
225
|
+
*/
|
|
226
|
+
declare function Injectable(scope?: true | TInjectableScope): ClassDecorator;
|
|
227
|
+
|
|
228
|
+
declare function Circular<T = unknown>(resolver: () => TClassConstructor<T>): ParameterDecorator;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* ## Provide
|
|
232
|
+
* ### @Decorator
|
|
233
|
+
* Defines provide registry for class (and all the children)
|
|
234
|
+
* @param type - string or class constructor
|
|
235
|
+
* @param fn - factory function for provided value
|
|
236
|
+
*/
|
|
237
|
+
declare function Provide(type: string | TClassConstructor, fn: TProvideFn): ClassDecorator;
|
|
238
|
+
/**
|
|
239
|
+
* ## Inject
|
|
240
|
+
* ### @Decorator
|
|
241
|
+
* Defines a key from provide registry to inject value
|
|
242
|
+
* (For optional values use with @Optional())
|
|
243
|
+
* @param type - string or class constructor
|
|
244
|
+
*/
|
|
245
|
+
declare function Inject(type: string | TClassConstructor): ParameterDecorator;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* ## Label
|
|
249
|
+
* ### @Decorator
|
|
250
|
+
* _Common purpose decorator that may be used by various adapters for various purposes_
|
|
251
|
+
*
|
|
252
|
+
* Stores Label metadata
|
|
253
|
+
*/
|
|
254
|
+
declare function Label(value: string): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
255
|
+
/**
|
|
256
|
+
* ## Description
|
|
257
|
+
* ### @Decorator
|
|
258
|
+
* _Common purpose decorator that may be used by various adapters for various purposes_
|
|
259
|
+
*
|
|
260
|
+
* Stores Description metadata
|
|
261
|
+
*/
|
|
262
|
+
declare function Description(value: string): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
263
|
+
/**
|
|
264
|
+
* ## Value
|
|
265
|
+
* ### @Decorator
|
|
266
|
+
* _Common purpose decorator that may be used by various adapters for various purposes_
|
|
267
|
+
*
|
|
268
|
+
* Stores Value metadata
|
|
269
|
+
*/
|
|
270
|
+
declare function Value(value: unknown): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
271
|
+
/**
|
|
272
|
+
* ## Id
|
|
273
|
+
* ### @Decorator
|
|
274
|
+
* _Common purpose decorator that may be used by various adapters for various purposes_
|
|
275
|
+
*
|
|
276
|
+
* Stores Id metadata
|
|
277
|
+
*/
|
|
278
|
+
declare function Id(value: string): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
279
|
+
/**
|
|
280
|
+
* ## Optional
|
|
281
|
+
* ### @Decorator
|
|
282
|
+
* _Common purpose decorator that may be used by various adapters for various purposes_
|
|
283
|
+
*
|
|
284
|
+
* Stores Optional metadata
|
|
285
|
+
*/
|
|
286
|
+
declare function Optional(): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
287
|
+
/**
|
|
288
|
+
* ## Required
|
|
289
|
+
* ### @Decorator
|
|
290
|
+
* _Common purpose decorator that may be used by various adapters for various purposes_
|
|
291
|
+
*
|
|
292
|
+
* Stores Required metadata
|
|
293
|
+
*/
|
|
294
|
+
declare function Required(): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* ## Inherit
|
|
298
|
+
* ### @Decorator
|
|
299
|
+
* Inherit metadata from super class
|
|
300
|
+
* @returns
|
|
301
|
+
*/
|
|
302
|
+
declare const Inherit: () => MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* ## Pipe
|
|
306
|
+
* ### @Decorator
|
|
307
|
+
* Attach pipe
|
|
308
|
+
* @param handler pipe handler
|
|
309
|
+
* @param priority pipe priority
|
|
310
|
+
* @returns
|
|
311
|
+
*/
|
|
312
|
+
declare function Pipe(handler: TPipeFn, priority?: TPipePriority): ClassDecorator & MethodDecorator & ParameterDecorator;
|
|
313
|
+
|
|
314
|
+
declare class InterceptorHandler {
|
|
315
|
+
protected handlers: TInterceptorFn[];
|
|
316
|
+
constructor(handlers: TInterceptorFn[]);
|
|
317
|
+
protected before: TInterceptorBefore[];
|
|
318
|
+
protected after: TInterceptorAfter[];
|
|
319
|
+
protected onError: TInterceptorOnError[];
|
|
320
|
+
response?: unknown;
|
|
321
|
+
responseOverwritten: boolean;
|
|
322
|
+
replyFn(reply: unknown): void;
|
|
323
|
+
init(): Promise<{} | null | undefined>;
|
|
324
|
+
fireBefore(response: unknown): Promise<unknown>;
|
|
325
|
+
fireAfter(response: unknown): Promise<unknown>;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
interface TControllerOverview {
|
|
329
|
+
meta: TMoostMetadata;
|
|
330
|
+
computedPrefix: string;
|
|
331
|
+
type: TFunction;
|
|
332
|
+
handlers: THandlerOverview[];
|
|
333
|
+
}
|
|
334
|
+
interface THandlerOverview {
|
|
335
|
+
meta: TMoostMetadata;
|
|
336
|
+
path?: string;
|
|
337
|
+
type: string;
|
|
338
|
+
method: string;
|
|
339
|
+
handler: TMoostHandler<TEmpty>;
|
|
340
|
+
registeredAs: {
|
|
341
|
+
path: string;
|
|
342
|
+
args: string[];
|
|
343
|
+
}[];
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
interface TMoostOptions {
|
|
347
|
+
/**
|
|
348
|
+
* Prefix that is used for each event path
|
|
349
|
+
*/
|
|
350
|
+
globalPrefix?: string;
|
|
351
|
+
logger?: TConsoleBase;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* ## Moost
|
|
355
|
+
* Main moostjs class that serves as a shell for Moost Adapters
|
|
356
|
+
*
|
|
357
|
+
* ### Usage with HTTP Adapter
|
|
358
|
+
* ```ts
|
|
359
|
+
* │ // HTTP server example
|
|
360
|
+
* │ import { MoostHttp, Get } from '@moostjs/event-http'
|
|
361
|
+
* │ import { Moost, Param } from 'moost'
|
|
362
|
+
* │
|
|
363
|
+
* │ class MyServer extends Moost {
|
|
364
|
+
* │ @Get('test/:name')
|
|
365
|
+
* │ test(@Param('name') name: string) {
|
|
366
|
+
* │ return { message: `Hello ${name}!` }
|
|
367
|
+
* │ }
|
|
368
|
+
* │ }
|
|
369
|
+
* │
|
|
370
|
+
* │ const app = new MyServer()
|
|
371
|
+
* │ const http = new MoostHttp()
|
|
372
|
+
* │ app.adapter(http).listen(3000, () => {
|
|
373
|
+
* │ app.getLogger('MyApp').log('Up on port 3000')
|
|
374
|
+
* │ })
|
|
375
|
+
* │ app.init()
|
|
376
|
+
* ```
|
|
377
|
+
* ### Usage with CLI Adapter
|
|
378
|
+
* ```ts
|
|
379
|
+
* │ // CLI example
|
|
380
|
+
* │ import { MoostCli, Cli, CliOption, cliHelpInterceptor } from '@moostjs/event-cli'
|
|
381
|
+
* │ import { Moost, Param } from 'moost'
|
|
382
|
+
* │
|
|
383
|
+
* │ class MyApp extends Moost {
|
|
384
|
+
* │ @Cli('command/:arg')
|
|
385
|
+
* │ command(
|
|
386
|
+
* │ @Param('arg')
|
|
387
|
+
* │ arg: string,
|
|
388
|
+
* │ @CliOption('test', 't')
|
|
389
|
+
* │ test: boolean,
|
|
390
|
+
* │ ) {
|
|
391
|
+
* │ return `command run with flag arg=${ arg }, test=${ test }`
|
|
392
|
+
* │ }
|
|
393
|
+
* │ }
|
|
394
|
+
* │
|
|
395
|
+
* │ const app = new MyApp()
|
|
396
|
+
* │ app.applyGlobalInterceptors(cliHelpInterceptor())
|
|
397
|
+
* │
|
|
398
|
+
* │ const cli = new MoostCli()
|
|
399
|
+
* │ app.adapter(cli)
|
|
400
|
+
* │ app.init()
|
|
401
|
+
* ```
|
|
402
|
+
*/
|
|
403
|
+
declare class Moost {
|
|
404
|
+
protected options?: TMoostOptions | undefined;
|
|
405
|
+
protected logger: TConsoleBase;
|
|
406
|
+
protected pipes: TPipeData[];
|
|
407
|
+
protected interceptors: TInterceptorData[];
|
|
408
|
+
protected adapters: TMoostAdapter<TAny>[];
|
|
409
|
+
protected controllersOverview: TControllerOverview[];
|
|
410
|
+
protected provide: TProvideRegistry;
|
|
411
|
+
protected unregisteredControllers: (TObject | TFunction | [string, TObject | TFunction])[];
|
|
412
|
+
constructor(options?: TMoostOptions | undefined);
|
|
413
|
+
/**
|
|
414
|
+
* ### getLogger
|
|
415
|
+
* Provides application logger
|
|
416
|
+
* ```js
|
|
417
|
+
* // get logger with topic = "App"
|
|
418
|
+
* const logger = app.getLogger('App')
|
|
419
|
+
* logger.log('...')
|
|
420
|
+
* ```
|
|
421
|
+
* @param topic
|
|
422
|
+
* @returns
|
|
423
|
+
*/
|
|
424
|
+
getLogger(topic: string): TConsoleBase;
|
|
425
|
+
adapter<T extends TMoostAdapter<TAny>>(a: T): T;
|
|
426
|
+
getControllersOverview(): TControllerOverview[];
|
|
427
|
+
/**
|
|
428
|
+
* ### init
|
|
429
|
+
* Ititializes adapter. Must be called after adapters are attached.
|
|
430
|
+
*/
|
|
431
|
+
init(): Promise<void>;
|
|
432
|
+
protected bindControllers(): Promise<void>;
|
|
433
|
+
protected bindController(controller: TFunction | TObject, provide: TProvideRegistry, globalPrefix: string, replaceOwnPrefix?: string): Promise<void>;
|
|
434
|
+
applyGlobalPipes(...items: (TPipeFn | TPipeData)[]): this;
|
|
435
|
+
protected globalInterceptorHandler?: () => Promise<InterceptorHandler>;
|
|
436
|
+
/**
|
|
437
|
+
* Provides InterceptorHandler with global interceptors and pipes.
|
|
438
|
+
* Used to process interceptors when event handler was not found.
|
|
439
|
+
*
|
|
440
|
+
* @returns IterceptorHandler
|
|
441
|
+
*/
|
|
442
|
+
getGlobalInterceptorHandler(): Promise<InterceptorHandler>;
|
|
443
|
+
applyGlobalInterceptors(...items: (TInterceptorData['handler'] | TInterceptorData)[]): this;
|
|
444
|
+
/**
|
|
445
|
+
* Register new entried to provide as dependency injections
|
|
446
|
+
* @param provide - Provide Registry (use createProvideRegistry from '\@prostojs/infact')
|
|
447
|
+
* @returns
|
|
448
|
+
*/
|
|
449
|
+
setProvideRegistry(provide: TProvideRegistry): this;
|
|
450
|
+
/**
|
|
451
|
+
* Register controllers (similar to @ImportController decorator)
|
|
452
|
+
* @param controllers - list of target controllers (instances)
|
|
453
|
+
* @returns
|
|
454
|
+
*/
|
|
455
|
+
registerControllers(...controllers: (TObject | TFunction | [string, TObject | TFunction])[]): this;
|
|
456
|
+
}
|
|
457
|
+
interface TMoostAdapterOptions<H, T> {
|
|
458
|
+
prefix: string;
|
|
459
|
+
fakeInstance: T;
|
|
460
|
+
getInstance: () => Promise<T>;
|
|
461
|
+
method: keyof T;
|
|
462
|
+
handlers: TMoostHandler<H>[];
|
|
463
|
+
getIterceptorHandler: () => Promise<InterceptorHandler>;
|
|
464
|
+
resolveArgs: () => Promise<unknown[]>;
|
|
465
|
+
logHandler: (eventName: string) => void;
|
|
466
|
+
register: (handler: TMoostHandler<TEmpty>, path: string, args: string[]) => void;
|
|
467
|
+
}
|
|
468
|
+
interface TMoostAdapter<H> {
|
|
469
|
+
bindHandler<T extends TObject = TObject>(options: TMoostAdapterOptions<H, T>): void | Promise<void>;
|
|
470
|
+
onInit?: (moost: Moost) => void | Promise<void>;
|
|
471
|
+
getProvideRegistry?: () => TProvideRegistry;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
declare function setControllerContext<T>(controller: T, method: keyof T): void;
|
|
475
|
+
declare function useControllerContext<T extends object>(): {
|
|
476
|
+
instantiate: <T_1>(c: TClassConstructor<T_1>) => Promise<T_1>;
|
|
477
|
+
getController: () => T;
|
|
478
|
+
getMethod: () => keyof T;
|
|
479
|
+
getControllerMeta: () => (TMoostMetadata<TEmpty> & TEmpty & {
|
|
480
|
+
params: (TEmpty & _prostojs_mate.TMateParamMeta)[];
|
|
481
|
+
}) | (TMoostMetadata<TEmpty> & TEmpty & {
|
|
482
|
+
params: (TEmpty & _prostojs_mate.TMateParamMeta)[];
|
|
483
|
+
} & {
|
|
484
|
+
params: (TEmpty & _prostojs_mate.TMateParamMeta)[];
|
|
485
|
+
} & _prostojs_mate.TMateClassMeta<_prostojs_mate.TMateParamMeta & TMoostParamsMetadata & TEmpty> & _prostojs_mate.TMatePropMeta<_prostojs_mate.TMateParamMeta & TMoostParamsMetadata & TEmpty>);
|
|
486
|
+
getMethodMeta: (name?: string) => TMoostMetadata<TEmpty> & TEmpty & {
|
|
487
|
+
params: (TEmpty & _prostojs_mate.TMateParamMeta)[];
|
|
488
|
+
} & {
|
|
489
|
+
params: (TEmpty & _prostojs_mate.TMateParamMeta)[];
|
|
490
|
+
} & _prostojs_mate.TMateClassMeta<_prostojs_mate.TMateParamMeta & TMoostParamsMetadata & TEmpty> & _prostojs_mate.TMatePropMeta<_prostojs_mate.TMateParamMeta & TMoostParamsMetadata & TEmpty>;
|
|
491
|
+
getPropertiesList: () => (string | symbol)[];
|
|
492
|
+
getScope: () => true | TInjectableScope;
|
|
493
|
+
getParamsMeta: () => (_prostojs_mate.TMateParamMeta & TMoostParamsMetadata)[] & (TEmpty & _prostojs_mate.TMateParamMeta)[] & (_prostojs_mate.TMateParamMeta & TMoostParamsMetadata & TEmpty)[];
|
|
494
|
+
getPropMeta: (name: string) => TMoostMetadata<TEmpty> & TEmpty & {
|
|
495
|
+
params: (TEmpty & _prostojs_mate.TMateParamMeta)[];
|
|
496
|
+
} & {
|
|
497
|
+
params: (TEmpty & _prostojs_mate.TMateParamMeta)[];
|
|
498
|
+
} & _prostojs_mate.TMateClassMeta<_prostojs_mate.TMateParamMeta & TMoostParamsMetadata & TEmpty> & _prostojs_mate.TMatePropMeta<_prostojs_mate.TMateParamMeta & TMoostParamsMetadata & TEmpty>;
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
interface TMoostEventHandlerHookOptions<T> {
|
|
502
|
+
restoreCtx: () => void;
|
|
503
|
+
scopeId: string;
|
|
504
|
+
logger: ReturnType<typeof useEventLogger>;
|
|
505
|
+
unscope: () => void;
|
|
506
|
+
instance?: T;
|
|
507
|
+
method?: keyof T;
|
|
508
|
+
getResponse: () => unknown;
|
|
509
|
+
reply: (r: unknown) => void;
|
|
510
|
+
}
|
|
511
|
+
interface TMoostEventHandlerOptions<T> {
|
|
512
|
+
contextType?: string | string[];
|
|
513
|
+
loggerTitle: string;
|
|
514
|
+
getIterceptorHandler: () => Promise<InterceptorHandler> | InterceptorHandler | undefined;
|
|
515
|
+
getControllerInstance: () => Promise<T> | T | undefined;
|
|
516
|
+
controllerMethod?: keyof T;
|
|
517
|
+
callControllerMethod?: (args: unknown[]) => unknown;
|
|
518
|
+
resolveArgs?: () => Promise<unknown[]> | unknown[];
|
|
519
|
+
logErrors?: boolean;
|
|
520
|
+
manualUnscope?: boolean;
|
|
521
|
+
hooks?: {
|
|
522
|
+
init?: (opts: TMoostEventHandlerHookOptions<T>) => unknown;
|
|
523
|
+
end?: (opts: TMoostEventHandlerHookOptions<T>) => unknown;
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
declare function registerEventScope(scopeId: string): () => void;
|
|
527
|
+
declare function defineMoostEventHandler<T>(options: TMoostEventHandlerOptions<T>): () => Promise<unknown>;
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* ### Define Interceptor Function
|
|
531
|
+
*
|
|
532
|
+
* ```ts
|
|
533
|
+
* defineInterceptorFn((before, after, onError) => {
|
|
534
|
+
* //init
|
|
535
|
+
* before(() => {
|
|
536
|
+
* // before handler
|
|
537
|
+
* })
|
|
538
|
+
* after((response, reply) => {
|
|
539
|
+
* // after handler
|
|
540
|
+
* })
|
|
541
|
+
* onError((error, reply) => {
|
|
542
|
+
* // when error occured
|
|
543
|
+
* })
|
|
544
|
+
* },
|
|
545
|
+
* TInterceptorPriority.INTERCEPTOR,
|
|
546
|
+
* )
|
|
547
|
+
* ```
|
|
548
|
+
*
|
|
549
|
+
* @param fn interceptor function
|
|
550
|
+
* @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
|
|
551
|
+
* @returns
|
|
552
|
+
*/
|
|
553
|
+
declare function defineInterceptorFn(fn: TInterceptorFn, priority?: TInterceptorPriority): TInterceptorFn;
|
|
554
|
+
type TInterceptorClass = TClassFunction<TInterceptorFn>;
|
|
555
|
+
/**
|
|
556
|
+
* ### Define Pipe Function
|
|
557
|
+
*
|
|
558
|
+
* ```ts
|
|
559
|
+
* // example of a transform pipe
|
|
560
|
+
* const uppercaseTransformPipe = definePipeFn((value, metas, level) => {
|
|
561
|
+
* return typeof value === 'string' ? value.toUpperCase() : value
|
|
562
|
+
* },
|
|
563
|
+
* TPipePriority.TRANSFORM,
|
|
564
|
+
* )
|
|
565
|
+
* ```
|
|
566
|
+
*
|
|
567
|
+
* @param fn interceptor function
|
|
568
|
+
* @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
|
|
569
|
+
* @returns
|
|
570
|
+
*/
|
|
571
|
+
declare function definePipeFn<T extends TObject = TEmpty>(fn: TPipeFn<T>, priority?: TPipePriority): TPipeFn<T>;
|
|
572
|
+
|
|
573
|
+
export { Circular, Const, ConstFactory, Controller, Description, Id, ImportController, Inherit, Inject, InjectEventLogger, Injectable, Intercept, InterceptorHandler, Label, Moost, Optional, Param, Params, Pipe, Provide, Required, Resolve, type TCallableClassFunction, type TClassFunction, type TControllerOverview, type TInjectableScope, type TInterceptorAfter, type TInterceptorBefore, type TInterceptorClass, type TInterceptorData, type TInterceptorFn, type TInterceptorOnError, TInterceptorPriority, type TMoostAdapter, type TMoostAdapterOptions, type TMoostEventHandlerHookOptions, type TMoostEventHandlerOptions, type TMoostHandler, type TMoostMetadata, type TMoostOptions, type TMoostParamsMetadata, type TPipeData, type TPipeFn, type TPipeMetas, TPipePriority, Value, defineInterceptorFn, defineMoostEventHandler, definePipeFn, getMoostInfact, getMoostMate, getNewMoostInfact, registerEventScope, resolvePipe, setControllerContext, useControllerContext };
|