@congruent-stack/congruent-api 0.11.2 → 0.11.4
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 +23 -0
- package/dist/index.d.cts +0 -23
- package/dist/index.d.mts +0 -23
- package/dist/index.mjs +23 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -91,6 +91,7 @@ function response(definition) {
|
|
|
91
91
|
return new HttpMethodEndpointResponse(definition);
|
|
92
92
|
}
|
|
93
93
|
class HttpMethodEndpointResponse {
|
|
94
|
+
/** @internal */
|
|
94
95
|
_definition;
|
|
95
96
|
get definition() {
|
|
96
97
|
return this._definition;
|
|
@@ -138,10 +139,12 @@ function isHttpResponseObject(obj) {
|
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
class MethodEndpointHandlerRegistryEntry {
|
|
142
|
+
/** @internal */
|
|
141
143
|
_methodEndpoint;
|
|
142
144
|
get methodEndpoint() {
|
|
143
145
|
return this._methodEndpoint;
|
|
144
146
|
}
|
|
147
|
+
/** @internal */
|
|
145
148
|
_dicontainer;
|
|
146
149
|
get dicontainer() {
|
|
147
150
|
return this._dicontainer;
|
|
@@ -153,6 +156,7 @@ class MethodEndpointHandlerRegistryEntry {
|
|
|
153
156
|
get genericPath() {
|
|
154
157
|
return this._methodEndpoint.genericPath;
|
|
155
158
|
}
|
|
159
|
+
/** @internal */
|
|
156
160
|
_handler = null;
|
|
157
161
|
get handler() {
|
|
158
162
|
return this._handler;
|
|
@@ -164,6 +168,7 @@ class MethodEndpointHandlerRegistryEntry {
|
|
|
164
168
|
}
|
|
165
169
|
return this;
|
|
166
170
|
}
|
|
171
|
+
/** @internal */
|
|
167
172
|
_onHandlerRegisteredCallback = null;
|
|
168
173
|
_onHandlerRegistered(callback) {
|
|
169
174
|
this._onHandlerRegisteredCallback = callback;
|
|
@@ -172,6 +177,7 @@ class MethodEndpointHandlerRegistryEntry {
|
|
|
172
177
|
callback(this);
|
|
173
178
|
return this;
|
|
174
179
|
}
|
|
180
|
+
/** @internal */
|
|
175
181
|
_injection = (_diScope) => ({});
|
|
176
182
|
get injection() {
|
|
177
183
|
return this._injection;
|
|
@@ -180,6 +186,7 @@ class MethodEndpointHandlerRegistryEntry {
|
|
|
180
186
|
this._injection = injection;
|
|
181
187
|
return this;
|
|
182
188
|
}
|
|
189
|
+
/** @internal */
|
|
183
190
|
_decoratorFactories = [];
|
|
184
191
|
get decoratorFactories() {
|
|
185
192
|
return this._decoratorFactories;
|
|
@@ -339,26 +346,32 @@ function middleware(apiReg, path) {
|
|
|
339
346
|
return entry;
|
|
340
347
|
}
|
|
341
348
|
class MiddlewareHandlersRegistryEntryInternal {
|
|
349
|
+
/** @internal */
|
|
342
350
|
_dicontainer;
|
|
343
351
|
get dicontainer() {
|
|
344
352
|
return this._dicontainer;
|
|
345
353
|
}
|
|
354
|
+
/** @internal */
|
|
346
355
|
_middlewareGenericPath;
|
|
347
356
|
get genericPath() {
|
|
348
357
|
return this._middlewareGenericPath;
|
|
349
358
|
}
|
|
359
|
+
/** @internal */
|
|
350
360
|
_middlewarePathSegments;
|
|
351
361
|
get pathSegments() {
|
|
352
362
|
return this._middlewarePathSegments;
|
|
353
363
|
}
|
|
364
|
+
/** @internal */
|
|
354
365
|
_middlewareMethod;
|
|
355
366
|
get method() {
|
|
356
367
|
return this._middlewareMethod;
|
|
357
368
|
}
|
|
369
|
+
/** @internal */
|
|
358
370
|
_middlewareSchemas;
|
|
359
371
|
get middlewareSchemas() {
|
|
360
372
|
return this._middlewareSchemas;
|
|
361
373
|
}
|
|
374
|
+
/** @internal */
|
|
362
375
|
_handler;
|
|
363
376
|
constructor(diContainer, middlewarePath, middlewareSchemas, decoratorFactories, injection, handler) {
|
|
364
377
|
this._dicontainer = diContainer;
|
|
@@ -380,10 +393,12 @@ class MiddlewareHandlersRegistryEntryInternal {
|
|
|
380
393
|
this._middlewareMethod = method;
|
|
381
394
|
this._middlewarePathSegments = pathSegments;
|
|
382
395
|
}
|
|
396
|
+
/** @internal */
|
|
383
397
|
_decoratorFactories = [];
|
|
384
398
|
get decoratorFactories() {
|
|
385
399
|
return this._decoratorFactories;
|
|
386
400
|
}
|
|
401
|
+
/** @internal */
|
|
387
402
|
_injection = (_dicontainer) => ({});
|
|
388
403
|
async trigger(diScope, requestObject, context) {
|
|
389
404
|
return this.triggerNoStaticTypeCheck(diScope, requestObject, context);
|
|
@@ -430,12 +445,15 @@ class MiddlewareHandlersRegistryEntryInternal {
|
|
|
430
445
|
}
|
|
431
446
|
}
|
|
432
447
|
class MiddlewareHandlersRegistryEntry {
|
|
448
|
+
/** @internal */
|
|
433
449
|
_registry;
|
|
450
|
+
/** @internal */
|
|
434
451
|
_path;
|
|
435
452
|
constructor(registry, path) {
|
|
436
453
|
this._registry = registry;
|
|
437
454
|
this._path = path;
|
|
438
455
|
}
|
|
456
|
+
/** @internal */
|
|
439
457
|
_injection = (_diScope) => ({});
|
|
440
458
|
get injection() {
|
|
441
459
|
return this._injection;
|
|
@@ -455,6 +473,7 @@ class MiddlewareHandlersRegistryEntry {
|
|
|
455
473
|
);
|
|
456
474
|
this._registry.register(internalEntry);
|
|
457
475
|
}
|
|
476
|
+
/** @internal */
|
|
458
477
|
_decoratorFactories = [];
|
|
459
478
|
get decoratorFactories() {
|
|
460
479
|
return this._decoratorFactories;
|
|
@@ -507,6 +526,7 @@ class MiddlewareHandlersRegistry {
|
|
|
507
526
|
this.dicontainer = dicontainer;
|
|
508
527
|
this._onHandlerRegisteredCallback = callback;
|
|
509
528
|
}
|
|
529
|
+
/** @internal */
|
|
510
530
|
_list = [];
|
|
511
531
|
get list() {
|
|
512
532
|
return this._list;
|
|
@@ -517,6 +537,7 @@ class MiddlewareHandlersRegistry {
|
|
|
517
537
|
this._onHandlerRegisteredCallback(entry);
|
|
518
538
|
}
|
|
519
539
|
}
|
|
540
|
+
/** @internal */
|
|
520
541
|
_onHandlerRegisteredCallback = null;
|
|
521
542
|
_onHandlerRegistered(callback) {
|
|
522
543
|
this._onHandlerRegisteredCallback = callback;
|
|
@@ -814,7 +835,9 @@ function clientParseRequestDefinitionField(definition, key, requestObject) {
|
|
|
814
835
|
}
|
|
815
836
|
|
|
816
837
|
class DIContainerBase {
|
|
838
|
+
/** @internal */
|
|
817
839
|
_map = /* @__PURE__ */ new Map();
|
|
840
|
+
/** @internal */
|
|
818
841
|
_singletonInstances = /* @__PURE__ */ new Map();
|
|
819
842
|
createScope() {
|
|
820
843
|
const proxy = new Proxy({
|
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
|
}
|
|
@@ -213,8 +212,6 @@ type DIScope<R extends DIRegistry> = {
|
|
|
213
212
|
[K in keyof R as `get${string & K}`]: () => R[K] extends DIRegistryEntry<infer T> ? T : never;
|
|
214
213
|
};
|
|
215
214
|
declare class DIContainerBase<R extends DIRegistry> {
|
|
216
|
-
protected _map: Map<string, DIRegistryEntry<any>>;
|
|
217
|
-
protected _singletonInstances: Map<string, any>;
|
|
218
215
|
createScope(): DIScope<R>;
|
|
219
216
|
}
|
|
220
217
|
declare class DIContainer<R extends DIRegistry = {}> extends DIContainerBase<R> {
|
|
@@ -267,21 +264,13 @@ type MiddlewarePath<TDef, BasePath extends string = ""> = (BasePath extends "" ?
|
|
|
267
264
|
[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;
|
|
268
265
|
}[keyof TDef & string];
|
|
269
266
|
declare class MiddlewareHandlersRegistryEntryInternal<TDIContainer extends DIContainer, TInjected> implements ICanTriggerAsync {
|
|
270
|
-
private readonly _dicontainer;
|
|
271
267
|
get dicontainer(): TDIContainer;
|
|
272
|
-
private readonly _middlewareGenericPath;
|
|
273
268
|
get genericPath(): string;
|
|
274
|
-
private readonly _middlewarePathSegments;
|
|
275
269
|
get pathSegments(): readonly string[];
|
|
276
|
-
private readonly _middlewareMethod;
|
|
277
270
|
get method(): string;
|
|
278
|
-
private readonly _middlewareSchemas;
|
|
279
271
|
get middlewareSchemas(): MiddlewareHandlerSchemas;
|
|
280
|
-
private readonly _handler;
|
|
281
272
|
constructor(diContainer: TDIContainer, middlewarePath: string, middlewareSchemas: MiddlewareHandlerSchemas, decoratorFactories: ((scope: DIScope<any>) => IEndpointHandlerDecorator<any>)[], injection: (dicontainer: TDIContainer) => TInjected, handler: MiddlewareHandlerInternal<TInjected>);
|
|
282
|
-
private readonly _decoratorFactories;
|
|
283
273
|
get decoratorFactories(): ((scope: DIScope<any>) => IEndpointHandlerDecorator<any>)[];
|
|
284
|
-
private _injection;
|
|
285
274
|
trigger<TPathParams extends string, const TMiddlewareSchemas extends MiddlewareHandlerSchemas>(diScope: ReturnType<TDIContainer['createScope']>, requestObject: {
|
|
286
275
|
headers: TMiddlewareSchemas['headers'] extends z$1.ZodType ? z$1.output<TMiddlewareSchemas['headers']> : Record<string, string>;
|
|
287
276
|
pathParams: TypedPathParams<TPathParams>;
|
|
@@ -292,14 +281,10 @@ declare class MiddlewareHandlersRegistryEntryInternal<TDIContainer extends DICon
|
|
|
292
281
|
createPath(pathParams: Record<string, string>): string;
|
|
293
282
|
}
|
|
294
283
|
declare class MiddlewareHandlersRegistryEntry<TApiDef extends IApiContractDefinition & ValidateApiContractDefinition<TApiDef>, TDIContainer extends DIContainer, TPathParams extends string, const TPath extends MiddlewarePath<TApiDef>, TInjected> {
|
|
295
|
-
private readonly _registry;
|
|
296
|
-
private readonly _path;
|
|
297
284
|
constructor(registry: MiddlewareHandlersRegistry<TDIContainer>, path: TPath);
|
|
298
|
-
private _injection;
|
|
299
285
|
get injection(): any;
|
|
300
286
|
inject<TNewInjected>(injection: (diScope: ReturnType<TDIContainer['createScope']>) => TNewInjected & MiddlewareHandlerContextOverlapGuard<TNewInjected>): MiddlewareHandlersRegistryEntry<TApiDef, TDIContainer, TPathParams, TPath, TNewInjected>;
|
|
301
287
|
register<const TMiddlewareSchemas extends MiddlewareHandlerSchemas>(middlewareSchemas: TMiddlewareSchemas, handler: MiddlewareHandler<`${TPathParams}${ExtractConcatenatedParamNamesFromPath<TPath>}`, TMiddlewareSchemas, TInjected>): void;
|
|
302
|
-
private readonly _decoratorFactories;
|
|
303
288
|
get decoratorFactories(): ((scope: DIScope<any>) => IEndpointHandlerDecorator<any>)[];
|
|
304
289
|
/**
|
|
305
290
|
*
|
|
@@ -348,10 +333,8 @@ type OnMiddlewareHandlerRegisteredCallback<TDIContainer extends DIContainer, TIn
|
|
|
348
333
|
declare class MiddlewareHandlersRegistry<TDIContainer extends DIContainer> {
|
|
349
334
|
readonly dicontainer: TDIContainer;
|
|
350
335
|
constructor(dicontainer: TDIContainer, callback: OnMiddlewareHandlerRegisteredCallback<TDIContainer, unknown>);
|
|
351
|
-
private readonly _list;
|
|
352
336
|
get list(): Readonly<MiddlewareHandlersRegistryEntryInternal<TDIContainer, unknown>[]>;
|
|
353
337
|
register<TInjected>(entry: MiddlewareHandlersRegistryEntryInternal<TDIContainer, TInjected>): void;
|
|
354
|
-
private _onHandlerRegisteredCallback;
|
|
355
338
|
_onHandlerRegistered(callback: OnMiddlewareHandlerRegisteredCallback<TDIContainer, unknown>): void;
|
|
356
339
|
}
|
|
357
340
|
|
|
@@ -384,22 +367,16 @@ declare function triggerMiddlewareDecoratorNoStaticTypeCheck(middlewareEntry: Mi
|
|
|
384
367
|
type PrepareRegistryEntryCallback<TDef extends IHttpMethodEndpointDefinition & ValidateHttpMethodEndpointDefinition<TDef>, TDIContainer extends DIContainer, TPathParams extends string> = (entry: MethodEndpointHandlerRegistryEntry<TDef, TDIContainer, TPathParams, any>) => void;
|
|
385
368
|
type OnHandlerRegisteredCallback<TDef extends IHttpMethodEndpointDefinition & ValidateHttpMethodEndpointDefinition<TDef>, TDIContainer extends DIContainer, TPathParams extends string> = (entry: MethodEndpointHandlerRegistryEntry<TDef, TDIContainer, TPathParams, any>) => void;
|
|
386
369
|
declare class MethodEndpointHandlerRegistryEntry<TDef extends IHttpMethodEndpointDefinition & ValidateHttpMethodEndpointDefinition<TDef>, TDIContainer extends DIContainer, TPathParams extends string, TInjected = {}> implements ICanTriggerAsync {
|
|
387
|
-
private _methodEndpoint;
|
|
388
370
|
get methodEndpoint(): HttpMethodEndpoint<TDef>;
|
|
389
|
-
private _dicontainer;
|
|
390
371
|
get dicontainer(): TDIContainer;
|
|
391
372
|
constructor(methodEndpoint: HttpMethodEndpoint<TDef>, dicontainer: TDIContainer);
|
|
392
373
|
get genericPath(): string;
|
|
393
|
-
private _handler;
|
|
394
374
|
get handler(): HttpMethodEndpointHandler<TDef, TPathParams, TInjected> | null;
|
|
395
375
|
register(handler: HttpMethodEndpointHandler<TDef, TPathParams, TInjected>): this;
|
|
396
|
-
private _onHandlerRegisteredCallback;
|
|
397
376
|
_onHandlerRegistered(callback: OnHandlerRegisteredCallback<TDef, TDIContainer, TPathParams>): void;
|
|
398
377
|
prepare(callback: PrepareRegistryEntryCallback<TDef, TDIContainer, TPathParams>): this;
|
|
399
|
-
private _injection;
|
|
400
378
|
get injection(): any;
|
|
401
379
|
inject<TNewInjected>(injection: (diScope: ReturnType<TDIContainer['createScope']>) => TNewInjected & EndpointHandlerContextOverlapGuard<TNewInjected>): MethodEndpointHandlerRegistryEntry<TDef, TDIContainer, TPathParams, TNewInjected>;
|
|
402
|
-
private readonly _decoratorFactories;
|
|
403
380
|
get decoratorFactories(): ((scope: DIScope<any>) => IEndpointHandlerDecorator<any>)[];
|
|
404
381
|
/**
|
|
405
382
|
*
|
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
|
}
|
|
@@ -213,8 +212,6 @@ type DIScope<R extends DIRegistry> = {
|
|
|
213
212
|
[K in keyof R as `get${string & K}`]: () => R[K] extends DIRegistryEntry<infer T> ? T : never;
|
|
214
213
|
};
|
|
215
214
|
declare class DIContainerBase<R extends DIRegistry> {
|
|
216
|
-
protected _map: Map<string, DIRegistryEntry<any>>;
|
|
217
|
-
protected _singletonInstances: Map<string, any>;
|
|
218
215
|
createScope(): DIScope<R>;
|
|
219
216
|
}
|
|
220
217
|
declare class DIContainer<R extends DIRegistry = {}> extends DIContainerBase<R> {
|
|
@@ -267,21 +264,13 @@ type MiddlewarePath<TDef, BasePath extends string = ""> = (BasePath extends "" ?
|
|
|
267
264
|
[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;
|
|
268
265
|
}[keyof TDef & string];
|
|
269
266
|
declare class MiddlewareHandlersRegistryEntryInternal<TDIContainer extends DIContainer, TInjected> implements ICanTriggerAsync {
|
|
270
|
-
private readonly _dicontainer;
|
|
271
267
|
get dicontainer(): TDIContainer;
|
|
272
|
-
private readonly _middlewareGenericPath;
|
|
273
268
|
get genericPath(): string;
|
|
274
|
-
private readonly _middlewarePathSegments;
|
|
275
269
|
get pathSegments(): readonly string[];
|
|
276
|
-
private readonly _middlewareMethod;
|
|
277
270
|
get method(): string;
|
|
278
|
-
private readonly _middlewareSchemas;
|
|
279
271
|
get middlewareSchemas(): MiddlewareHandlerSchemas;
|
|
280
|
-
private readonly _handler;
|
|
281
272
|
constructor(diContainer: TDIContainer, middlewarePath: string, middlewareSchemas: MiddlewareHandlerSchemas, decoratorFactories: ((scope: DIScope<any>) => IEndpointHandlerDecorator<any>)[], injection: (dicontainer: TDIContainer) => TInjected, handler: MiddlewareHandlerInternal<TInjected>);
|
|
282
|
-
private readonly _decoratorFactories;
|
|
283
273
|
get decoratorFactories(): ((scope: DIScope<any>) => IEndpointHandlerDecorator<any>)[];
|
|
284
|
-
private _injection;
|
|
285
274
|
trigger<TPathParams extends string, const TMiddlewareSchemas extends MiddlewareHandlerSchemas>(diScope: ReturnType<TDIContainer['createScope']>, requestObject: {
|
|
286
275
|
headers: TMiddlewareSchemas['headers'] extends z$1.ZodType ? z$1.output<TMiddlewareSchemas['headers']> : Record<string, string>;
|
|
287
276
|
pathParams: TypedPathParams<TPathParams>;
|
|
@@ -292,14 +281,10 @@ declare class MiddlewareHandlersRegistryEntryInternal<TDIContainer extends DICon
|
|
|
292
281
|
createPath(pathParams: Record<string, string>): string;
|
|
293
282
|
}
|
|
294
283
|
declare class MiddlewareHandlersRegistryEntry<TApiDef extends IApiContractDefinition & ValidateApiContractDefinition<TApiDef>, TDIContainer extends DIContainer, TPathParams extends string, const TPath extends MiddlewarePath<TApiDef>, TInjected> {
|
|
295
|
-
private readonly _registry;
|
|
296
|
-
private readonly _path;
|
|
297
284
|
constructor(registry: MiddlewareHandlersRegistry<TDIContainer>, path: TPath);
|
|
298
|
-
private _injection;
|
|
299
285
|
get injection(): any;
|
|
300
286
|
inject<TNewInjected>(injection: (diScope: ReturnType<TDIContainer['createScope']>) => TNewInjected & MiddlewareHandlerContextOverlapGuard<TNewInjected>): MiddlewareHandlersRegistryEntry<TApiDef, TDIContainer, TPathParams, TPath, TNewInjected>;
|
|
301
287
|
register<const TMiddlewareSchemas extends MiddlewareHandlerSchemas>(middlewareSchemas: TMiddlewareSchemas, handler: MiddlewareHandler<`${TPathParams}${ExtractConcatenatedParamNamesFromPath<TPath>}`, TMiddlewareSchemas, TInjected>): void;
|
|
302
|
-
private readonly _decoratorFactories;
|
|
303
288
|
get decoratorFactories(): ((scope: DIScope<any>) => IEndpointHandlerDecorator<any>)[];
|
|
304
289
|
/**
|
|
305
290
|
*
|
|
@@ -348,10 +333,8 @@ type OnMiddlewareHandlerRegisteredCallback<TDIContainer extends DIContainer, TIn
|
|
|
348
333
|
declare class MiddlewareHandlersRegistry<TDIContainer extends DIContainer> {
|
|
349
334
|
readonly dicontainer: TDIContainer;
|
|
350
335
|
constructor(dicontainer: TDIContainer, callback: OnMiddlewareHandlerRegisteredCallback<TDIContainer, unknown>);
|
|
351
|
-
private readonly _list;
|
|
352
336
|
get list(): Readonly<MiddlewareHandlersRegistryEntryInternal<TDIContainer, unknown>[]>;
|
|
353
337
|
register<TInjected>(entry: MiddlewareHandlersRegistryEntryInternal<TDIContainer, TInjected>): void;
|
|
354
|
-
private _onHandlerRegisteredCallback;
|
|
355
338
|
_onHandlerRegistered(callback: OnMiddlewareHandlerRegisteredCallback<TDIContainer, unknown>): void;
|
|
356
339
|
}
|
|
357
340
|
|
|
@@ -384,22 +367,16 @@ declare function triggerMiddlewareDecoratorNoStaticTypeCheck(middlewareEntry: Mi
|
|
|
384
367
|
type PrepareRegistryEntryCallback<TDef extends IHttpMethodEndpointDefinition & ValidateHttpMethodEndpointDefinition<TDef>, TDIContainer extends DIContainer, TPathParams extends string> = (entry: MethodEndpointHandlerRegistryEntry<TDef, TDIContainer, TPathParams, any>) => void;
|
|
385
368
|
type OnHandlerRegisteredCallback<TDef extends IHttpMethodEndpointDefinition & ValidateHttpMethodEndpointDefinition<TDef>, TDIContainer extends DIContainer, TPathParams extends string> = (entry: MethodEndpointHandlerRegistryEntry<TDef, TDIContainer, TPathParams, any>) => void;
|
|
386
369
|
declare class MethodEndpointHandlerRegistryEntry<TDef extends IHttpMethodEndpointDefinition & ValidateHttpMethodEndpointDefinition<TDef>, TDIContainer extends DIContainer, TPathParams extends string, TInjected = {}> implements ICanTriggerAsync {
|
|
387
|
-
private _methodEndpoint;
|
|
388
370
|
get methodEndpoint(): HttpMethodEndpoint<TDef>;
|
|
389
|
-
private _dicontainer;
|
|
390
371
|
get dicontainer(): TDIContainer;
|
|
391
372
|
constructor(methodEndpoint: HttpMethodEndpoint<TDef>, dicontainer: TDIContainer);
|
|
392
373
|
get genericPath(): string;
|
|
393
|
-
private _handler;
|
|
394
374
|
get handler(): HttpMethodEndpointHandler<TDef, TPathParams, TInjected> | null;
|
|
395
375
|
register(handler: HttpMethodEndpointHandler<TDef, TPathParams, TInjected>): this;
|
|
396
|
-
private _onHandlerRegisteredCallback;
|
|
397
376
|
_onHandlerRegistered(callback: OnHandlerRegisteredCallback<TDef, TDIContainer, TPathParams>): void;
|
|
398
377
|
prepare(callback: PrepareRegistryEntryCallback<TDef, TDIContainer, TPathParams>): this;
|
|
399
|
-
private _injection;
|
|
400
378
|
get injection(): any;
|
|
401
379
|
inject<TNewInjected>(injection: (diScope: ReturnType<TDIContainer['createScope']>) => TNewInjected & EndpointHandlerContextOverlapGuard<TNewInjected>): MethodEndpointHandlerRegistryEntry<TDef, TDIContainer, TPathParams, TNewInjected>;
|
|
402
|
-
private readonly _decoratorFactories;
|
|
403
380
|
get decoratorFactories(): ((scope: DIScope<any>) => IEndpointHandlerDecorator<any>)[];
|
|
404
381
|
/**
|
|
405
382
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -89,6 +89,7 @@ function response(definition) {
|
|
|
89
89
|
return new HttpMethodEndpointResponse(definition);
|
|
90
90
|
}
|
|
91
91
|
class HttpMethodEndpointResponse {
|
|
92
|
+
/** @internal */
|
|
92
93
|
_definition;
|
|
93
94
|
get definition() {
|
|
94
95
|
return this._definition;
|
|
@@ -136,10 +137,12 @@ function isHttpResponseObject(obj) {
|
|
|
136
137
|
}
|
|
137
138
|
|
|
138
139
|
class MethodEndpointHandlerRegistryEntry {
|
|
140
|
+
/** @internal */
|
|
139
141
|
_methodEndpoint;
|
|
140
142
|
get methodEndpoint() {
|
|
141
143
|
return this._methodEndpoint;
|
|
142
144
|
}
|
|
145
|
+
/** @internal */
|
|
143
146
|
_dicontainer;
|
|
144
147
|
get dicontainer() {
|
|
145
148
|
return this._dicontainer;
|
|
@@ -151,6 +154,7 @@ class MethodEndpointHandlerRegistryEntry {
|
|
|
151
154
|
get genericPath() {
|
|
152
155
|
return this._methodEndpoint.genericPath;
|
|
153
156
|
}
|
|
157
|
+
/** @internal */
|
|
154
158
|
_handler = null;
|
|
155
159
|
get handler() {
|
|
156
160
|
return this._handler;
|
|
@@ -162,6 +166,7 @@ class MethodEndpointHandlerRegistryEntry {
|
|
|
162
166
|
}
|
|
163
167
|
return this;
|
|
164
168
|
}
|
|
169
|
+
/** @internal */
|
|
165
170
|
_onHandlerRegisteredCallback = null;
|
|
166
171
|
_onHandlerRegistered(callback) {
|
|
167
172
|
this._onHandlerRegisteredCallback = callback;
|
|
@@ -170,6 +175,7 @@ class MethodEndpointHandlerRegistryEntry {
|
|
|
170
175
|
callback(this);
|
|
171
176
|
return this;
|
|
172
177
|
}
|
|
178
|
+
/** @internal */
|
|
173
179
|
_injection = (_diScope) => ({});
|
|
174
180
|
get injection() {
|
|
175
181
|
return this._injection;
|
|
@@ -178,6 +184,7 @@ class MethodEndpointHandlerRegistryEntry {
|
|
|
178
184
|
this._injection = injection;
|
|
179
185
|
return this;
|
|
180
186
|
}
|
|
187
|
+
/** @internal */
|
|
181
188
|
_decoratorFactories = [];
|
|
182
189
|
get decoratorFactories() {
|
|
183
190
|
return this._decoratorFactories;
|
|
@@ -337,26 +344,32 @@ function middleware(apiReg, path) {
|
|
|
337
344
|
return entry;
|
|
338
345
|
}
|
|
339
346
|
class MiddlewareHandlersRegistryEntryInternal {
|
|
347
|
+
/** @internal */
|
|
340
348
|
_dicontainer;
|
|
341
349
|
get dicontainer() {
|
|
342
350
|
return this._dicontainer;
|
|
343
351
|
}
|
|
352
|
+
/** @internal */
|
|
344
353
|
_middlewareGenericPath;
|
|
345
354
|
get genericPath() {
|
|
346
355
|
return this._middlewareGenericPath;
|
|
347
356
|
}
|
|
357
|
+
/** @internal */
|
|
348
358
|
_middlewarePathSegments;
|
|
349
359
|
get pathSegments() {
|
|
350
360
|
return this._middlewarePathSegments;
|
|
351
361
|
}
|
|
362
|
+
/** @internal */
|
|
352
363
|
_middlewareMethod;
|
|
353
364
|
get method() {
|
|
354
365
|
return this._middlewareMethod;
|
|
355
366
|
}
|
|
367
|
+
/** @internal */
|
|
356
368
|
_middlewareSchemas;
|
|
357
369
|
get middlewareSchemas() {
|
|
358
370
|
return this._middlewareSchemas;
|
|
359
371
|
}
|
|
372
|
+
/** @internal */
|
|
360
373
|
_handler;
|
|
361
374
|
constructor(diContainer, middlewarePath, middlewareSchemas, decoratorFactories, injection, handler) {
|
|
362
375
|
this._dicontainer = diContainer;
|
|
@@ -378,10 +391,12 @@ class MiddlewareHandlersRegistryEntryInternal {
|
|
|
378
391
|
this._middlewareMethod = method;
|
|
379
392
|
this._middlewarePathSegments = pathSegments;
|
|
380
393
|
}
|
|
394
|
+
/** @internal */
|
|
381
395
|
_decoratorFactories = [];
|
|
382
396
|
get decoratorFactories() {
|
|
383
397
|
return this._decoratorFactories;
|
|
384
398
|
}
|
|
399
|
+
/** @internal */
|
|
385
400
|
_injection = (_dicontainer) => ({});
|
|
386
401
|
async trigger(diScope, requestObject, context) {
|
|
387
402
|
return this.triggerNoStaticTypeCheck(diScope, requestObject, context);
|
|
@@ -428,12 +443,15 @@ class MiddlewareHandlersRegistryEntryInternal {
|
|
|
428
443
|
}
|
|
429
444
|
}
|
|
430
445
|
class MiddlewareHandlersRegistryEntry {
|
|
446
|
+
/** @internal */
|
|
431
447
|
_registry;
|
|
448
|
+
/** @internal */
|
|
432
449
|
_path;
|
|
433
450
|
constructor(registry, path) {
|
|
434
451
|
this._registry = registry;
|
|
435
452
|
this._path = path;
|
|
436
453
|
}
|
|
454
|
+
/** @internal */
|
|
437
455
|
_injection = (_diScope) => ({});
|
|
438
456
|
get injection() {
|
|
439
457
|
return this._injection;
|
|
@@ -453,6 +471,7 @@ class MiddlewareHandlersRegistryEntry {
|
|
|
453
471
|
);
|
|
454
472
|
this._registry.register(internalEntry);
|
|
455
473
|
}
|
|
474
|
+
/** @internal */
|
|
456
475
|
_decoratorFactories = [];
|
|
457
476
|
get decoratorFactories() {
|
|
458
477
|
return this._decoratorFactories;
|
|
@@ -505,6 +524,7 @@ class MiddlewareHandlersRegistry {
|
|
|
505
524
|
this.dicontainer = dicontainer;
|
|
506
525
|
this._onHandlerRegisteredCallback = callback;
|
|
507
526
|
}
|
|
527
|
+
/** @internal */
|
|
508
528
|
_list = [];
|
|
509
529
|
get list() {
|
|
510
530
|
return this._list;
|
|
@@ -515,6 +535,7 @@ class MiddlewareHandlersRegistry {
|
|
|
515
535
|
this._onHandlerRegisteredCallback(entry);
|
|
516
536
|
}
|
|
517
537
|
}
|
|
538
|
+
/** @internal */
|
|
518
539
|
_onHandlerRegisteredCallback = null;
|
|
519
540
|
_onHandlerRegistered(callback) {
|
|
520
541
|
this._onHandlerRegisteredCallback = callback;
|
|
@@ -812,7 +833,9 @@ function clientParseRequestDefinitionField(definition, key, requestObject) {
|
|
|
812
833
|
}
|
|
813
834
|
|
|
814
835
|
class DIContainerBase {
|
|
836
|
+
/** @internal */
|
|
815
837
|
_map = /* @__PURE__ */ new Map();
|
|
838
|
+
/** @internal */
|
|
816
839
|
_singletonInstances = /* @__PURE__ */ new Map();
|
|
817
840
|
createScope() {
|
|
818
841
|
const proxy = new Proxy({
|