@congruent-stack/congruent-api 0.11.1 → 0.11.3
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 +25 -0
- package/dist/index.d.cts +0 -25
- package/dist/index.d.mts +0 -25
- package/dist/index.mjs +25 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4,14 +4,17 @@ function endpoint(definition) {
|
|
|
4
4
|
return new HttpMethodEndpoint(definition);
|
|
5
5
|
}
|
|
6
6
|
class HttpMethodEndpoint {
|
|
7
|
+
/** @internal */
|
|
7
8
|
_definition;
|
|
8
9
|
get definition() {
|
|
9
10
|
return this._definition;
|
|
10
11
|
}
|
|
12
|
+
/** @internal */
|
|
11
13
|
_pathSegments = [];
|
|
12
14
|
get pathSegments() {
|
|
13
15
|
return this._pathSegments;
|
|
14
16
|
}
|
|
17
|
+
/** @internal */
|
|
15
18
|
_cachedGenericPath = null;
|
|
16
19
|
get genericPath() {
|
|
17
20
|
if (!this._cachedGenericPath) {
|
|
@@ -24,6 +27,7 @@ class HttpMethodEndpoint {
|
|
|
24
27
|
(segment) => segment.startsWith(":") ? pathParams[segment.slice(1)] ?? "?" : segment
|
|
25
28
|
).join("/")}`;
|
|
26
29
|
}
|
|
30
|
+
/** @internal */
|
|
27
31
|
_method = null;
|
|
28
32
|
get method() {
|
|
29
33
|
return this._method;
|
|
@@ -87,6 +91,7 @@ function response(definition) {
|
|
|
87
91
|
return new HttpMethodEndpointResponse(definition);
|
|
88
92
|
}
|
|
89
93
|
class HttpMethodEndpointResponse {
|
|
94
|
+
/** @internal */
|
|
90
95
|
_definition;
|
|
91
96
|
get definition() {
|
|
92
97
|
return this._definition;
|
|
@@ -134,10 +139,12 @@ function isHttpResponseObject(obj) {
|
|
|
134
139
|
}
|
|
135
140
|
|
|
136
141
|
class MethodEndpointHandlerRegistryEntry {
|
|
142
|
+
/** @internal */
|
|
137
143
|
_methodEndpoint;
|
|
138
144
|
get methodEndpoint() {
|
|
139
145
|
return this._methodEndpoint;
|
|
140
146
|
}
|
|
147
|
+
/** @internal */
|
|
141
148
|
_dicontainer;
|
|
142
149
|
get dicontainer() {
|
|
143
150
|
return this._dicontainer;
|
|
@@ -149,6 +156,7 @@ class MethodEndpointHandlerRegistryEntry {
|
|
|
149
156
|
get genericPath() {
|
|
150
157
|
return this._methodEndpoint.genericPath;
|
|
151
158
|
}
|
|
159
|
+
/** @internal */
|
|
152
160
|
_handler = null;
|
|
153
161
|
get handler() {
|
|
154
162
|
return this._handler;
|
|
@@ -160,6 +168,7 @@ class MethodEndpointHandlerRegistryEntry {
|
|
|
160
168
|
}
|
|
161
169
|
return this;
|
|
162
170
|
}
|
|
171
|
+
/** @internal */
|
|
163
172
|
_onHandlerRegisteredCallback = null;
|
|
164
173
|
_onHandlerRegistered(callback) {
|
|
165
174
|
this._onHandlerRegisteredCallback = callback;
|
|
@@ -168,6 +177,7 @@ class MethodEndpointHandlerRegistryEntry {
|
|
|
168
177
|
callback(this);
|
|
169
178
|
return this;
|
|
170
179
|
}
|
|
180
|
+
/** @internal */
|
|
171
181
|
_injection = (_diScope) => ({});
|
|
172
182
|
get injection() {
|
|
173
183
|
return this._injection;
|
|
@@ -176,6 +186,7 @@ class MethodEndpointHandlerRegistryEntry {
|
|
|
176
186
|
this._injection = injection;
|
|
177
187
|
return this;
|
|
178
188
|
}
|
|
189
|
+
/** @internal */
|
|
179
190
|
_decoratorFactories = [];
|
|
180
191
|
get decoratorFactories() {
|
|
181
192
|
return this._decoratorFactories;
|
|
@@ -335,26 +346,32 @@ function middleware(apiReg, path) {
|
|
|
335
346
|
return entry;
|
|
336
347
|
}
|
|
337
348
|
class MiddlewareHandlersRegistryEntryInternal {
|
|
349
|
+
/** @internal */
|
|
338
350
|
_dicontainer;
|
|
339
351
|
get dicontainer() {
|
|
340
352
|
return this._dicontainer;
|
|
341
353
|
}
|
|
354
|
+
/** @internal */
|
|
342
355
|
_middlewareGenericPath;
|
|
343
356
|
get genericPath() {
|
|
344
357
|
return this._middlewareGenericPath;
|
|
345
358
|
}
|
|
359
|
+
/** @internal */
|
|
346
360
|
_middlewarePathSegments;
|
|
347
361
|
get pathSegments() {
|
|
348
362
|
return this._middlewarePathSegments;
|
|
349
363
|
}
|
|
364
|
+
/** @internal */
|
|
350
365
|
_middlewareMethod;
|
|
351
366
|
get method() {
|
|
352
367
|
return this._middlewareMethod;
|
|
353
368
|
}
|
|
369
|
+
/** @internal */
|
|
354
370
|
_middlewareSchemas;
|
|
355
371
|
get middlewareSchemas() {
|
|
356
372
|
return this._middlewareSchemas;
|
|
357
373
|
}
|
|
374
|
+
/** @internal */
|
|
358
375
|
_handler;
|
|
359
376
|
constructor(diContainer, middlewarePath, middlewareSchemas, decoratorFactories, injection, handler) {
|
|
360
377
|
this._dicontainer = diContainer;
|
|
@@ -376,10 +393,12 @@ class MiddlewareHandlersRegistryEntryInternal {
|
|
|
376
393
|
this._middlewareMethod = method;
|
|
377
394
|
this._middlewarePathSegments = pathSegments;
|
|
378
395
|
}
|
|
396
|
+
/** @internal */
|
|
379
397
|
_decoratorFactories = [];
|
|
380
398
|
get decoratorFactories() {
|
|
381
399
|
return this._decoratorFactories;
|
|
382
400
|
}
|
|
401
|
+
/** @internal */
|
|
383
402
|
_injection = (_dicontainer) => ({});
|
|
384
403
|
async trigger(diScope, requestObject, context) {
|
|
385
404
|
return this.triggerNoStaticTypeCheck(diScope, requestObject, context);
|
|
@@ -426,12 +445,15 @@ class MiddlewareHandlersRegistryEntryInternal {
|
|
|
426
445
|
}
|
|
427
446
|
}
|
|
428
447
|
class MiddlewareHandlersRegistryEntry {
|
|
448
|
+
/** @internal */
|
|
429
449
|
_registry;
|
|
450
|
+
/** @internal */
|
|
430
451
|
_path;
|
|
431
452
|
constructor(registry, path) {
|
|
432
453
|
this._registry = registry;
|
|
433
454
|
this._path = path;
|
|
434
455
|
}
|
|
456
|
+
/** @internal */
|
|
435
457
|
_injection = (_diScope) => ({});
|
|
436
458
|
get injection() {
|
|
437
459
|
return this._injection;
|
|
@@ -451,6 +473,7 @@ class MiddlewareHandlersRegistryEntry {
|
|
|
451
473
|
);
|
|
452
474
|
this._registry.register(internalEntry);
|
|
453
475
|
}
|
|
476
|
+
/** @internal */
|
|
454
477
|
_decoratorFactories = [];
|
|
455
478
|
get decoratorFactories() {
|
|
456
479
|
return this._decoratorFactories;
|
|
@@ -503,6 +526,7 @@ class MiddlewareHandlersRegistry {
|
|
|
503
526
|
this.dicontainer = dicontainer;
|
|
504
527
|
this._onHandlerRegisteredCallback = callback;
|
|
505
528
|
}
|
|
529
|
+
/** @internal */
|
|
506
530
|
_list = [];
|
|
507
531
|
get list() {
|
|
508
532
|
return this._list;
|
|
@@ -513,6 +537,7 @@ class MiddlewareHandlersRegistry {
|
|
|
513
537
|
this._onHandlerRegisteredCallback(entry);
|
|
514
538
|
}
|
|
515
539
|
}
|
|
540
|
+
/** @internal */
|
|
516
541
|
_onHandlerRegisteredCallback = null;
|
|
517
542
|
_onHandlerRegistered(callback) {
|
|
518
543
|
this._onHandlerRegisteredCallback = callback;
|
package/dist/index.d.cts
CHANGED
|
@@ -35,7 +35,6 @@ interface IHttpMethodEndpointResponseDefinition<_TStatus extends HttpStatusCode>
|
|
|
35
35
|
body?: z.ZodType;
|
|
36
36
|
}
|
|
37
37
|
declare class HttpMethodEndpointResponse<TStatus extends HttpStatusCode, TDef extends IHttpMethodEndpointResponseDefinition<TStatus>> {
|
|
38
|
-
private _definition;
|
|
39
38
|
get definition(): TDef;
|
|
40
39
|
constructor(definition: TDef);
|
|
41
40
|
}
|
|
@@ -56,14 +55,10 @@ type HttpMethodEndpointResponses = Partial<{
|
|
|
56
55
|
readonly [status in HttpStatusCode]: HttpMethodEndpointResponse<status, any>;
|
|
57
56
|
}>;
|
|
58
57
|
declare class HttpMethodEndpoint<const TDef extends IHttpMethodEndpointDefinition & ValidateHttpMethodEndpointDefinition<TDef>> {
|
|
59
|
-
protected _definition: TDef;
|
|
60
58
|
get definition(): TDef;
|
|
61
|
-
protected _pathSegments: readonly string[];
|
|
62
59
|
get pathSegments(): readonly string[];
|
|
63
|
-
protected _cachedGenericPath: string | null;
|
|
64
60
|
get genericPath(): string;
|
|
65
61
|
createPath(pathParams: Record<string, string>): string;
|
|
66
|
-
protected _method: HttpMethod;
|
|
67
62
|
get method(): HttpMethod;
|
|
68
63
|
get lowerCasedMethod(): LowerCasedHttpMethod;
|
|
69
64
|
constructor(definition: TDef);
|
|
@@ -271,21 +266,13 @@ type MiddlewarePath<TDef, BasePath extends string = ""> = (BasePath extends "" ?
|
|
|
271
266
|
[K in keyof TDef & string]: TDef[K] extends HttpMethodEndpoint<infer _TEndpointDef> ? `${K} ${BasePath}` : TDef[K] extends object ? `${BasePath}/${K}` | MiddlewarePath<TDef[K], `${BasePath}/${K}`> : never;
|
|
272
267
|
}[keyof TDef & string];
|
|
273
268
|
declare class MiddlewareHandlersRegistryEntryInternal<TDIContainer extends DIContainer, TInjected> implements ICanTriggerAsync {
|
|
274
|
-
private readonly _dicontainer;
|
|
275
269
|
get dicontainer(): TDIContainer;
|
|
276
|
-
private readonly _middlewareGenericPath;
|
|
277
270
|
get genericPath(): string;
|
|
278
|
-
private readonly _middlewarePathSegments;
|
|
279
271
|
get pathSegments(): readonly string[];
|
|
280
|
-
private readonly _middlewareMethod;
|
|
281
272
|
get method(): string;
|
|
282
|
-
private readonly _middlewareSchemas;
|
|
283
273
|
get middlewareSchemas(): MiddlewareHandlerSchemas;
|
|
284
|
-
private readonly _handler;
|
|
285
274
|
constructor(diContainer: TDIContainer, middlewarePath: string, middlewareSchemas: MiddlewareHandlerSchemas, decoratorFactories: ((scope: DIScope<any>) => IEndpointHandlerDecorator<any>)[], injection: (dicontainer: TDIContainer) => TInjected, handler: MiddlewareHandlerInternal<TInjected>);
|
|
286
|
-
private readonly _decoratorFactories;
|
|
287
275
|
get decoratorFactories(): ((scope: DIScope<any>) => IEndpointHandlerDecorator<any>)[];
|
|
288
|
-
private _injection;
|
|
289
276
|
trigger<TPathParams extends string, const TMiddlewareSchemas extends MiddlewareHandlerSchemas>(diScope: ReturnType<TDIContainer['createScope']>, requestObject: {
|
|
290
277
|
headers: TMiddlewareSchemas['headers'] extends z$1.ZodType ? z$1.output<TMiddlewareSchemas['headers']> : Record<string, string>;
|
|
291
278
|
pathParams: TypedPathParams<TPathParams>;
|
|
@@ -296,14 +283,10 @@ declare class MiddlewareHandlersRegistryEntryInternal<TDIContainer extends DICon
|
|
|
296
283
|
createPath(pathParams: Record<string, string>): string;
|
|
297
284
|
}
|
|
298
285
|
declare class MiddlewareHandlersRegistryEntry<TApiDef extends IApiContractDefinition & ValidateApiContractDefinition<TApiDef>, TDIContainer extends DIContainer, TPathParams extends string, const TPath extends MiddlewarePath<TApiDef>, TInjected> {
|
|
299
|
-
private readonly _registry;
|
|
300
|
-
private readonly _path;
|
|
301
286
|
constructor(registry: MiddlewareHandlersRegistry<TDIContainer>, path: TPath);
|
|
302
|
-
private _injection;
|
|
303
287
|
get injection(): any;
|
|
304
288
|
inject<TNewInjected>(injection: (diScope: ReturnType<TDIContainer['createScope']>) => TNewInjected & MiddlewareHandlerContextOverlapGuard<TNewInjected>): MiddlewareHandlersRegistryEntry<TApiDef, TDIContainer, TPathParams, TPath, TNewInjected>;
|
|
305
289
|
register<const TMiddlewareSchemas extends MiddlewareHandlerSchemas>(middlewareSchemas: TMiddlewareSchemas, handler: MiddlewareHandler<`${TPathParams}${ExtractConcatenatedParamNamesFromPath<TPath>}`, TMiddlewareSchemas, TInjected>): void;
|
|
306
|
-
private readonly _decoratorFactories;
|
|
307
290
|
get decoratorFactories(): ((scope: DIScope<any>) => IEndpointHandlerDecorator<any>)[];
|
|
308
291
|
/**
|
|
309
292
|
*
|
|
@@ -352,10 +335,8 @@ type OnMiddlewareHandlerRegisteredCallback<TDIContainer extends DIContainer, TIn
|
|
|
352
335
|
declare class MiddlewareHandlersRegistry<TDIContainer extends DIContainer> {
|
|
353
336
|
readonly dicontainer: TDIContainer;
|
|
354
337
|
constructor(dicontainer: TDIContainer, callback: OnMiddlewareHandlerRegisteredCallback<TDIContainer, unknown>);
|
|
355
|
-
private readonly _list;
|
|
356
338
|
get list(): Readonly<MiddlewareHandlersRegistryEntryInternal<TDIContainer, unknown>[]>;
|
|
357
339
|
register<TInjected>(entry: MiddlewareHandlersRegistryEntryInternal<TDIContainer, TInjected>): void;
|
|
358
|
-
private _onHandlerRegisteredCallback;
|
|
359
340
|
_onHandlerRegistered(callback: OnMiddlewareHandlerRegisteredCallback<TDIContainer, unknown>): void;
|
|
360
341
|
}
|
|
361
342
|
|
|
@@ -388,22 +369,16 @@ declare function triggerMiddlewareDecoratorNoStaticTypeCheck(middlewareEntry: Mi
|
|
|
388
369
|
type PrepareRegistryEntryCallback<TDef extends IHttpMethodEndpointDefinition & ValidateHttpMethodEndpointDefinition<TDef>, TDIContainer extends DIContainer, TPathParams extends string> = (entry: MethodEndpointHandlerRegistryEntry<TDef, TDIContainer, TPathParams, any>) => void;
|
|
389
370
|
type OnHandlerRegisteredCallback<TDef extends IHttpMethodEndpointDefinition & ValidateHttpMethodEndpointDefinition<TDef>, TDIContainer extends DIContainer, TPathParams extends string> = (entry: MethodEndpointHandlerRegistryEntry<TDef, TDIContainer, TPathParams, any>) => void;
|
|
390
371
|
declare class MethodEndpointHandlerRegistryEntry<TDef extends IHttpMethodEndpointDefinition & ValidateHttpMethodEndpointDefinition<TDef>, TDIContainer extends DIContainer, TPathParams extends string, TInjected = {}> implements ICanTriggerAsync {
|
|
391
|
-
private _methodEndpoint;
|
|
392
372
|
get methodEndpoint(): HttpMethodEndpoint<TDef>;
|
|
393
|
-
private _dicontainer;
|
|
394
373
|
get dicontainer(): TDIContainer;
|
|
395
374
|
constructor(methodEndpoint: HttpMethodEndpoint<TDef>, dicontainer: TDIContainer);
|
|
396
375
|
get genericPath(): string;
|
|
397
|
-
private _handler;
|
|
398
376
|
get handler(): HttpMethodEndpointHandler<TDef, TPathParams, TInjected> | null;
|
|
399
377
|
register(handler: HttpMethodEndpointHandler<TDef, TPathParams, TInjected>): this;
|
|
400
|
-
private _onHandlerRegisteredCallback;
|
|
401
378
|
_onHandlerRegistered(callback: OnHandlerRegisteredCallback<TDef, TDIContainer, TPathParams>): void;
|
|
402
379
|
prepare(callback: PrepareRegistryEntryCallback<TDef, TDIContainer, TPathParams>): this;
|
|
403
|
-
private _injection;
|
|
404
380
|
get injection(): any;
|
|
405
381
|
inject<TNewInjected>(injection: (diScope: ReturnType<TDIContainer['createScope']>) => TNewInjected & EndpointHandlerContextOverlapGuard<TNewInjected>): MethodEndpointHandlerRegistryEntry<TDef, TDIContainer, TPathParams, TNewInjected>;
|
|
406
|
-
private readonly _decoratorFactories;
|
|
407
382
|
get decoratorFactories(): ((scope: DIScope<any>) => IEndpointHandlerDecorator<any>)[];
|
|
408
383
|
/**
|
|
409
384
|
*
|
package/dist/index.d.mts
CHANGED
|
@@ -35,7 +35,6 @@ interface IHttpMethodEndpointResponseDefinition<_TStatus extends HttpStatusCode>
|
|
|
35
35
|
body?: z.ZodType;
|
|
36
36
|
}
|
|
37
37
|
declare class HttpMethodEndpointResponse<TStatus extends HttpStatusCode, TDef extends IHttpMethodEndpointResponseDefinition<TStatus>> {
|
|
38
|
-
private _definition;
|
|
39
38
|
get definition(): TDef;
|
|
40
39
|
constructor(definition: TDef);
|
|
41
40
|
}
|
|
@@ -56,14 +55,10 @@ type HttpMethodEndpointResponses = Partial<{
|
|
|
56
55
|
readonly [status in HttpStatusCode]: HttpMethodEndpointResponse<status, any>;
|
|
57
56
|
}>;
|
|
58
57
|
declare class HttpMethodEndpoint<const TDef extends IHttpMethodEndpointDefinition & ValidateHttpMethodEndpointDefinition<TDef>> {
|
|
59
|
-
protected _definition: TDef;
|
|
60
58
|
get definition(): TDef;
|
|
61
|
-
protected _pathSegments: readonly string[];
|
|
62
59
|
get pathSegments(): readonly string[];
|
|
63
|
-
protected _cachedGenericPath: string | null;
|
|
64
60
|
get genericPath(): string;
|
|
65
61
|
createPath(pathParams: Record<string, string>): string;
|
|
66
|
-
protected _method: HttpMethod;
|
|
67
62
|
get method(): HttpMethod;
|
|
68
63
|
get lowerCasedMethod(): LowerCasedHttpMethod;
|
|
69
64
|
constructor(definition: TDef);
|
|
@@ -271,21 +266,13 @@ type MiddlewarePath<TDef, BasePath extends string = ""> = (BasePath extends "" ?
|
|
|
271
266
|
[K in keyof TDef & string]: TDef[K] extends HttpMethodEndpoint<infer _TEndpointDef> ? `${K} ${BasePath}` : TDef[K] extends object ? `${BasePath}/${K}` | MiddlewarePath<TDef[K], `${BasePath}/${K}`> : never;
|
|
272
267
|
}[keyof TDef & string];
|
|
273
268
|
declare class MiddlewareHandlersRegistryEntryInternal<TDIContainer extends DIContainer, TInjected> implements ICanTriggerAsync {
|
|
274
|
-
private readonly _dicontainer;
|
|
275
269
|
get dicontainer(): TDIContainer;
|
|
276
|
-
private readonly _middlewareGenericPath;
|
|
277
270
|
get genericPath(): string;
|
|
278
|
-
private readonly _middlewarePathSegments;
|
|
279
271
|
get pathSegments(): readonly string[];
|
|
280
|
-
private readonly _middlewareMethod;
|
|
281
272
|
get method(): string;
|
|
282
|
-
private readonly _middlewareSchemas;
|
|
283
273
|
get middlewareSchemas(): MiddlewareHandlerSchemas;
|
|
284
|
-
private readonly _handler;
|
|
285
274
|
constructor(diContainer: TDIContainer, middlewarePath: string, middlewareSchemas: MiddlewareHandlerSchemas, decoratorFactories: ((scope: DIScope<any>) => IEndpointHandlerDecorator<any>)[], injection: (dicontainer: TDIContainer) => TInjected, handler: MiddlewareHandlerInternal<TInjected>);
|
|
286
|
-
private readonly _decoratorFactories;
|
|
287
275
|
get decoratorFactories(): ((scope: DIScope<any>) => IEndpointHandlerDecorator<any>)[];
|
|
288
|
-
private _injection;
|
|
289
276
|
trigger<TPathParams extends string, const TMiddlewareSchemas extends MiddlewareHandlerSchemas>(diScope: ReturnType<TDIContainer['createScope']>, requestObject: {
|
|
290
277
|
headers: TMiddlewareSchemas['headers'] extends z$1.ZodType ? z$1.output<TMiddlewareSchemas['headers']> : Record<string, string>;
|
|
291
278
|
pathParams: TypedPathParams<TPathParams>;
|
|
@@ -296,14 +283,10 @@ declare class MiddlewareHandlersRegistryEntryInternal<TDIContainer extends DICon
|
|
|
296
283
|
createPath(pathParams: Record<string, string>): string;
|
|
297
284
|
}
|
|
298
285
|
declare class MiddlewareHandlersRegistryEntry<TApiDef extends IApiContractDefinition & ValidateApiContractDefinition<TApiDef>, TDIContainer extends DIContainer, TPathParams extends string, const TPath extends MiddlewarePath<TApiDef>, TInjected> {
|
|
299
|
-
private readonly _registry;
|
|
300
|
-
private readonly _path;
|
|
301
286
|
constructor(registry: MiddlewareHandlersRegistry<TDIContainer>, path: TPath);
|
|
302
|
-
private _injection;
|
|
303
287
|
get injection(): any;
|
|
304
288
|
inject<TNewInjected>(injection: (diScope: ReturnType<TDIContainer['createScope']>) => TNewInjected & MiddlewareHandlerContextOverlapGuard<TNewInjected>): MiddlewareHandlersRegistryEntry<TApiDef, TDIContainer, TPathParams, TPath, TNewInjected>;
|
|
305
289
|
register<const TMiddlewareSchemas extends MiddlewareHandlerSchemas>(middlewareSchemas: TMiddlewareSchemas, handler: MiddlewareHandler<`${TPathParams}${ExtractConcatenatedParamNamesFromPath<TPath>}`, TMiddlewareSchemas, TInjected>): void;
|
|
306
|
-
private readonly _decoratorFactories;
|
|
307
290
|
get decoratorFactories(): ((scope: DIScope<any>) => IEndpointHandlerDecorator<any>)[];
|
|
308
291
|
/**
|
|
309
292
|
*
|
|
@@ -352,10 +335,8 @@ type OnMiddlewareHandlerRegisteredCallback<TDIContainer extends DIContainer, TIn
|
|
|
352
335
|
declare class MiddlewareHandlersRegistry<TDIContainer extends DIContainer> {
|
|
353
336
|
readonly dicontainer: TDIContainer;
|
|
354
337
|
constructor(dicontainer: TDIContainer, callback: OnMiddlewareHandlerRegisteredCallback<TDIContainer, unknown>);
|
|
355
|
-
private readonly _list;
|
|
356
338
|
get list(): Readonly<MiddlewareHandlersRegistryEntryInternal<TDIContainer, unknown>[]>;
|
|
357
339
|
register<TInjected>(entry: MiddlewareHandlersRegistryEntryInternal<TDIContainer, TInjected>): void;
|
|
358
|
-
private _onHandlerRegisteredCallback;
|
|
359
340
|
_onHandlerRegistered(callback: OnMiddlewareHandlerRegisteredCallback<TDIContainer, unknown>): void;
|
|
360
341
|
}
|
|
361
342
|
|
|
@@ -388,22 +369,16 @@ declare function triggerMiddlewareDecoratorNoStaticTypeCheck(middlewareEntry: Mi
|
|
|
388
369
|
type PrepareRegistryEntryCallback<TDef extends IHttpMethodEndpointDefinition & ValidateHttpMethodEndpointDefinition<TDef>, TDIContainer extends DIContainer, TPathParams extends string> = (entry: MethodEndpointHandlerRegistryEntry<TDef, TDIContainer, TPathParams, any>) => void;
|
|
389
370
|
type OnHandlerRegisteredCallback<TDef extends IHttpMethodEndpointDefinition & ValidateHttpMethodEndpointDefinition<TDef>, TDIContainer extends DIContainer, TPathParams extends string> = (entry: MethodEndpointHandlerRegistryEntry<TDef, TDIContainer, TPathParams, any>) => void;
|
|
390
371
|
declare class MethodEndpointHandlerRegistryEntry<TDef extends IHttpMethodEndpointDefinition & ValidateHttpMethodEndpointDefinition<TDef>, TDIContainer extends DIContainer, TPathParams extends string, TInjected = {}> implements ICanTriggerAsync {
|
|
391
|
-
private _methodEndpoint;
|
|
392
372
|
get methodEndpoint(): HttpMethodEndpoint<TDef>;
|
|
393
|
-
private _dicontainer;
|
|
394
373
|
get dicontainer(): TDIContainer;
|
|
395
374
|
constructor(methodEndpoint: HttpMethodEndpoint<TDef>, dicontainer: TDIContainer);
|
|
396
375
|
get genericPath(): string;
|
|
397
|
-
private _handler;
|
|
398
376
|
get handler(): HttpMethodEndpointHandler<TDef, TPathParams, TInjected> | null;
|
|
399
377
|
register(handler: HttpMethodEndpointHandler<TDef, TPathParams, TInjected>): this;
|
|
400
|
-
private _onHandlerRegisteredCallback;
|
|
401
378
|
_onHandlerRegistered(callback: OnHandlerRegisteredCallback<TDef, TDIContainer, TPathParams>): void;
|
|
402
379
|
prepare(callback: PrepareRegistryEntryCallback<TDef, TDIContainer, TPathParams>): this;
|
|
403
|
-
private _injection;
|
|
404
380
|
get injection(): any;
|
|
405
381
|
inject<TNewInjected>(injection: (diScope: ReturnType<TDIContainer['createScope']>) => TNewInjected & EndpointHandlerContextOverlapGuard<TNewInjected>): MethodEndpointHandlerRegistryEntry<TDef, TDIContainer, TPathParams, TNewInjected>;
|
|
406
|
-
private readonly _decoratorFactories;
|
|
407
382
|
get decoratorFactories(): ((scope: DIScope<any>) => IEndpointHandlerDecorator<any>)[];
|
|
408
383
|
/**
|
|
409
384
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -2,14 +2,17 @@ function endpoint(definition) {
|
|
|
2
2
|
return new HttpMethodEndpoint(definition);
|
|
3
3
|
}
|
|
4
4
|
class HttpMethodEndpoint {
|
|
5
|
+
/** @internal */
|
|
5
6
|
_definition;
|
|
6
7
|
get definition() {
|
|
7
8
|
return this._definition;
|
|
8
9
|
}
|
|
10
|
+
/** @internal */
|
|
9
11
|
_pathSegments = [];
|
|
10
12
|
get pathSegments() {
|
|
11
13
|
return this._pathSegments;
|
|
12
14
|
}
|
|
15
|
+
/** @internal */
|
|
13
16
|
_cachedGenericPath = null;
|
|
14
17
|
get genericPath() {
|
|
15
18
|
if (!this._cachedGenericPath) {
|
|
@@ -22,6 +25,7 @@ class HttpMethodEndpoint {
|
|
|
22
25
|
(segment) => segment.startsWith(":") ? pathParams[segment.slice(1)] ?? "?" : segment
|
|
23
26
|
).join("/")}`;
|
|
24
27
|
}
|
|
28
|
+
/** @internal */
|
|
25
29
|
_method = null;
|
|
26
30
|
get method() {
|
|
27
31
|
return this._method;
|
|
@@ -85,6 +89,7 @@ function response(definition) {
|
|
|
85
89
|
return new HttpMethodEndpointResponse(definition);
|
|
86
90
|
}
|
|
87
91
|
class HttpMethodEndpointResponse {
|
|
92
|
+
/** @internal */
|
|
88
93
|
_definition;
|
|
89
94
|
get definition() {
|
|
90
95
|
return this._definition;
|
|
@@ -132,10 +137,12 @@ function isHttpResponseObject(obj) {
|
|
|
132
137
|
}
|
|
133
138
|
|
|
134
139
|
class MethodEndpointHandlerRegistryEntry {
|
|
140
|
+
/** @internal */
|
|
135
141
|
_methodEndpoint;
|
|
136
142
|
get methodEndpoint() {
|
|
137
143
|
return this._methodEndpoint;
|
|
138
144
|
}
|
|
145
|
+
/** @internal */
|
|
139
146
|
_dicontainer;
|
|
140
147
|
get dicontainer() {
|
|
141
148
|
return this._dicontainer;
|
|
@@ -147,6 +154,7 @@ class MethodEndpointHandlerRegistryEntry {
|
|
|
147
154
|
get genericPath() {
|
|
148
155
|
return this._methodEndpoint.genericPath;
|
|
149
156
|
}
|
|
157
|
+
/** @internal */
|
|
150
158
|
_handler = null;
|
|
151
159
|
get handler() {
|
|
152
160
|
return this._handler;
|
|
@@ -158,6 +166,7 @@ class MethodEndpointHandlerRegistryEntry {
|
|
|
158
166
|
}
|
|
159
167
|
return this;
|
|
160
168
|
}
|
|
169
|
+
/** @internal */
|
|
161
170
|
_onHandlerRegisteredCallback = null;
|
|
162
171
|
_onHandlerRegistered(callback) {
|
|
163
172
|
this._onHandlerRegisteredCallback = callback;
|
|
@@ -166,6 +175,7 @@ class MethodEndpointHandlerRegistryEntry {
|
|
|
166
175
|
callback(this);
|
|
167
176
|
return this;
|
|
168
177
|
}
|
|
178
|
+
/** @internal */
|
|
169
179
|
_injection = (_diScope) => ({});
|
|
170
180
|
get injection() {
|
|
171
181
|
return this._injection;
|
|
@@ -174,6 +184,7 @@ class MethodEndpointHandlerRegistryEntry {
|
|
|
174
184
|
this._injection = injection;
|
|
175
185
|
return this;
|
|
176
186
|
}
|
|
187
|
+
/** @internal */
|
|
177
188
|
_decoratorFactories = [];
|
|
178
189
|
get decoratorFactories() {
|
|
179
190
|
return this._decoratorFactories;
|
|
@@ -333,26 +344,32 @@ function middleware(apiReg, path) {
|
|
|
333
344
|
return entry;
|
|
334
345
|
}
|
|
335
346
|
class MiddlewareHandlersRegistryEntryInternal {
|
|
347
|
+
/** @internal */
|
|
336
348
|
_dicontainer;
|
|
337
349
|
get dicontainer() {
|
|
338
350
|
return this._dicontainer;
|
|
339
351
|
}
|
|
352
|
+
/** @internal */
|
|
340
353
|
_middlewareGenericPath;
|
|
341
354
|
get genericPath() {
|
|
342
355
|
return this._middlewareGenericPath;
|
|
343
356
|
}
|
|
357
|
+
/** @internal */
|
|
344
358
|
_middlewarePathSegments;
|
|
345
359
|
get pathSegments() {
|
|
346
360
|
return this._middlewarePathSegments;
|
|
347
361
|
}
|
|
362
|
+
/** @internal */
|
|
348
363
|
_middlewareMethod;
|
|
349
364
|
get method() {
|
|
350
365
|
return this._middlewareMethod;
|
|
351
366
|
}
|
|
367
|
+
/** @internal */
|
|
352
368
|
_middlewareSchemas;
|
|
353
369
|
get middlewareSchemas() {
|
|
354
370
|
return this._middlewareSchemas;
|
|
355
371
|
}
|
|
372
|
+
/** @internal */
|
|
356
373
|
_handler;
|
|
357
374
|
constructor(diContainer, middlewarePath, middlewareSchemas, decoratorFactories, injection, handler) {
|
|
358
375
|
this._dicontainer = diContainer;
|
|
@@ -374,10 +391,12 @@ class MiddlewareHandlersRegistryEntryInternal {
|
|
|
374
391
|
this._middlewareMethod = method;
|
|
375
392
|
this._middlewarePathSegments = pathSegments;
|
|
376
393
|
}
|
|
394
|
+
/** @internal */
|
|
377
395
|
_decoratorFactories = [];
|
|
378
396
|
get decoratorFactories() {
|
|
379
397
|
return this._decoratorFactories;
|
|
380
398
|
}
|
|
399
|
+
/** @internal */
|
|
381
400
|
_injection = (_dicontainer) => ({});
|
|
382
401
|
async trigger(diScope, requestObject, context) {
|
|
383
402
|
return this.triggerNoStaticTypeCheck(diScope, requestObject, context);
|
|
@@ -424,12 +443,15 @@ class MiddlewareHandlersRegistryEntryInternal {
|
|
|
424
443
|
}
|
|
425
444
|
}
|
|
426
445
|
class MiddlewareHandlersRegistryEntry {
|
|
446
|
+
/** @internal */
|
|
427
447
|
_registry;
|
|
448
|
+
/** @internal */
|
|
428
449
|
_path;
|
|
429
450
|
constructor(registry, path) {
|
|
430
451
|
this._registry = registry;
|
|
431
452
|
this._path = path;
|
|
432
453
|
}
|
|
454
|
+
/** @internal */
|
|
433
455
|
_injection = (_diScope) => ({});
|
|
434
456
|
get injection() {
|
|
435
457
|
return this._injection;
|
|
@@ -449,6 +471,7 @@ class MiddlewareHandlersRegistryEntry {
|
|
|
449
471
|
);
|
|
450
472
|
this._registry.register(internalEntry);
|
|
451
473
|
}
|
|
474
|
+
/** @internal */
|
|
452
475
|
_decoratorFactories = [];
|
|
453
476
|
get decoratorFactories() {
|
|
454
477
|
return this._decoratorFactories;
|
|
@@ -501,6 +524,7 @@ class MiddlewareHandlersRegistry {
|
|
|
501
524
|
this.dicontainer = dicontainer;
|
|
502
525
|
this._onHandlerRegisteredCallback = callback;
|
|
503
526
|
}
|
|
527
|
+
/** @internal */
|
|
504
528
|
_list = [];
|
|
505
529
|
get list() {
|
|
506
530
|
return this._list;
|
|
@@ -511,6 +535,7 @@ class MiddlewareHandlersRegistry {
|
|
|
511
535
|
this._onHandlerRegisteredCallback(entry);
|
|
512
536
|
}
|
|
513
537
|
}
|
|
538
|
+
/** @internal */
|
|
514
539
|
_onHandlerRegisteredCallback = null;
|
|
515
540
|
_onHandlerRegistered(callback) {
|
|
516
541
|
this._onHandlerRegisteredCallback = callback;
|