@nattyjs/core 0.0.1-beta.7 → 0.0.1-beta.70
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 +1204 -209
- package/dist/index.d.ts +307 -53
- package/dist/index.mjs +1156 -211
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NattyConfig, UserIdentity } from '@nattyjs/common';
|
|
1
|
+
import { NattyConfig, UserIdentity, ClassType, ExceptionFilter } from '@nattyjs/common';
|
|
2
2
|
import { GlobalConfig } from '@nattyjs/common/interfaces/global-config';
|
|
3
3
|
|
|
4
4
|
interface DecoratorInfo$1 {
|
|
@@ -8,8 +8,9 @@ interface DecoratorInfo$1 {
|
|
|
8
8
|
|
|
9
9
|
interface TypeInfo$1 {
|
|
10
10
|
name: string;
|
|
11
|
-
documentation
|
|
12
|
-
type
|
|
11
|
+
documentation?: string;
|
|
12
|
+
type?: string;
|
|
13
|
+
tokenKey?: string;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
interface ParameterInfo {
|
|
@@ -53,9 +54,9 @@ declare function route(path: string): (target: any, propertyKey?: string, parame
|
|
|
53
54
|
|
|
54
55
|
declare function get(path: string): (target: any, propertyKey?: string, descriptor?: any) => void;
|
|
55
56
|
|
|
56
|
-
declare function post(path
|
|
57
|
+
declare function post(path?: string): (target: any, propertyKey?: string, descriptor?: any) => void;
|
|
57
58
|
|
|
58
|
-
declare function put(path
|
|
59
|
+
declare function put(path?: string): (target: any, propertyKey?: string, descriptor?: any) => void;
|
|
59
60
|
|
|
60
61
|
declare function Delete(): (target: any, propertyKey?: string, descriptor?: any) => void;
|
|
61
62
|
|
|
@@ -68,6 +69,7 @@ interface TypeInfo {
|
|
|
68
69
|
name: string;
|
|
69
70
|
documentation?: string;
|
|
70
71
|
type?: string;
|
|
72
|
+
tokenKey?: string;
|
|
71
73
|
}
|
|
72
74
|
interface MethodInfo extends TypeInfo {
|
|
73
75
|
parameters?: TypeInfo[];
|
|
@@ -81,6 +83,7 @@ type HttpRequestBodyInfo = {
|
|
|
81
83
|
number?: number | number[];
|
|
82
84
|
boolean?: boolean | boolean[];
|
|
83
85
|
FormData?: FormData;
|
|
86
|
+
buffer?: any;
|
|
84
87
|
ArrayBuffer?: ArrayBuffer;
|
|
85
88
|
Blob?: Blob;
|
|
86
89
|
json?: {
|
|
@@ -120,6 +123,7 @@ interface HttpResponseInit {
|
|
|
120
123
|
headers?: HeadersInit;
|
|
121
124
|
cookies?: Cookie[];
|
|
122
125
|
enableContentNegotiation?: boolean;
|
|
126
|
+
isBuffer?: boolean;
|
|
123
127
|
}
|
|
124
128
|
|
|
125
129
|
interface ProblemDetail {
|
|
@@ -192,47 +196,32 @@ interface IHttpResult {
|
|
|
192
196
|
|
|
193
197
|
interface RouteConfig {
|
|
194
198
|
controller: Function;
|
|
195
|
-
parameters:
|
|
196
|
-
name: string;
|
|
197
|
-
type: string;
|
|
198
|
-
}>;
|
|
199
|
+
parameters: TypeInfo$1[];
|
|
199
200
|
get: {
|
|
200
201
|
[key: string]: {
|
|
201
202
|
name: string;
|
|
202
|
-
parameters:
|
|
203
|
-
name: string;
|
|
204
|
-
type: string;
|
|
205
|
-
}>;
|
|
203
|
+
parameters: TypeInfo$1[];
|
|
206
204
|
returnType: string;
|
|
207
205
|
};
|
|
208
206
|
};
|
|
209
207
|
post: {
|
|
210
208
|
[key: string]: {
|
|
211
209
|
name: string;
|
|
212
|
-
parameters:
|
|
213
|
-
name: string;
|
|
214
|
-
type: string;
|
|
215
|
-
}>;
|
|
210
|
+
parameters: TypeInfo$1[];
|
|
216
211
|
returnType: string;
|
|
217
212
|
};
|
|
218
213
|
};
|
|
219
214
|
put: {
|
|
220
215
|
[key: string]: {
|
|
221
216
|
name: string;
|
|
222
|
-
parameters:
|
|
223
|
-
name: string;
|
|
224
|
-
type: string;
|
|
225
|
-
}>;
|
|
217
|
+
parameters: TypeInfo$1[];
|
|
226
218
|
returnType: string;
|
|
227
219
|
};
|
|
228
220
|
};
|
|
229
221
|
delete: {
|
|
230
222
|
[key: string]: {
|
|
231
223
|
name: string;
|
|
232
|
-
parameters:
|
|
233
|
-
name: string;
|
|
234
|
-
type: string;
|
|
235
|
-
}>;
|
|
224
|
+
parameters: TypeInfo$1[];
|
|
236
225
|
returnType: string;
|
|
237
226
|
};
|
|
238
227
|
};
|
|
@@ -242,10 +231,11 @@ declare function init(config: NattyConfig, appConfig: {
|
|
|
242
231
|
routes: {
|
|
243
232
|
[key: string]: RouteConfig;
|
|
244
233
|
};
|
|
234
|
+
types?: TypesInfo;
|
|
245
235
|
envTsDefinition: {
|
|
246
236
|
[key: string]: string;
|
|
247
237
|
};
|
|
248
|
-
|
|
238
|
+
resolver?: (path: any) => any;
|
|
249
239
|
}): any;
|
|
250
240
|
|
|
251
241
|
declare class HttpRequest {
|
|
@@ -264,6 +254,7 @@ declare class HttpResponse {
|
|
|
264
254
|
private _headers;
|
|
265
255
|
private _body;
|
|
266
256
|
private _status;
|
|
257
|
+
private _isBuffer;
|
|
267
258
|
constructor(response?: HttpResponseInit);
|
|
268
259
|
private setValues;
|
|
269
260
|
addCookie(cookie: Cookie): void;
|
|
@@ -276,6 +267,83 @@ declare class HttpResponse {
|
|
|
276
267
|
write(responseInit: HttpResponseInit): void;
|
|
277
268
|
}
|
|
278
269
|
|
|
270
|
+
type DIClassType<T = any> = new (...args: any[]) => T;
|
|
271
|
+
|
|
272
|
+
type Token<T = any> = DIClassType<T> | symbol | string;
|
|
273
|
+
|
|
274
|
+
interface ServiceProvider {
|
|
275
|
+
get<T>(token: Token<T>): T;
|
|
276
|
+
tryGet<T>(token: Token<T>): T | undefined;
|
|
277
|
+
set<T>(token: Token<T>, value: T): void;
|
|
278
|
+
createScope(): Scope;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
interface Scope extends ServiceProvider {
|
|
282
|
+
dispose(): Promise<void> | void;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
type Factory<T = any> = (sp: ServiceProvider) => T;
|
|
286
|
+
|
|
287
|
+
declare enum Lifetime {
|
|
288
|
+
Singleton = "singleton",
|
|
289
|
+
Scoped = "scoped",
|
|
290
|
+
Transient = "transient"
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
type Descriptor<T = any> = {
|
|
294
|
+
lifetime: Lifetime.Singleton;
|
|
295
|
+
useValue?: T;
|
|
296
|
+
useClass?: DIClassType<T>;
|
|
297
|
+
useFactory?: Factory<T>;
|
|
298
|
+
} | {
|
|
299
|
+
lifetime: Lifetime.Scoped;
|
|
300
|
+
useClass?: DIClassType<T>;
|
|
301
|
+
useFactory?: Factory<T>;
|
|
302
|
+
} | {
|
|
303
|
+
lifetime: Lifetime.Transient;
|
|
304
|
+
useClass?: DIClassType<T>;
|
|
305
|
+
useFactory?: Factory<T>;
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
type ClearRegistrationsResult = {
|
|
309
|
+
metadataKeys: string[];
|
|
310
|
+
tokens: Token[];
|
|
311
|
+
};
|
|
312
|
+
declare class NattyContainer implements ServiceProvider {
|
|
313
|
+
private readonly regs;
|
|
314
|
+
private readonly singletons;
|
|
315
|
+
private readonly tokenSources;
|
|
316
|
+
private readonly sourceTokens;
|
|
317
|
+
private readonly metadataKeySources;
|
|
318
|
+
private readonly sourceMetadataKeys;
|
|
319
|
+
register<T>(token: Token<T>, desc: Descriptor<T>, sourceFile?: string): void;
|
|
320
|
+
addTransient<T>(token: Token<T>, useClass?: DIClassType<T>, useFactory?: Factory<T>, sourceFile?: string): void;
|
|
321
|
+
addScoped<T>(token: Token<T>, useClass?: DIClassType<T>, useFactory?: Factory<T>, sourceFile?: string): void;
|
|
322
|
+
addSingleton<T>(token: Token<T>, useClass?: DIClassType<T>, useFactory?: Factory<T>, sourceFile?: string): void;
|
|
323
|
+
addInstance<T>(token: Token<T>, value: T, sourceFile?: string): void;
|
|
324
|
+
createScope(): NattyScope;
|
|
325
|
+
set<T>(_token: Token<T>, _value: T): void;
|
|
326
|
+
tryGet<T>(token: Token<T>): T | undefined;
|
|
327
|
+
get<T>(token: Token<T>): T;
|
|
328
|
+
construct<T>(Cls: DIClassType<T>, sp: ServiceProvider): T;
|
|
329
|
+
_getDescriptor<T>(token: Token<T>): Descriptor<T> | undefined;
|
|
330
|
+
trackMetadataKey(sourceFile: string, key: string): void;
|
|
331
|
+
clearRegistrationsFromSource(sourceFile: string): ClearRegistrationsResult;
|
|
332
|
+
private trackTokenSource;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
declare class NattyScope implements Scope {
|
|
336
|
+
private readonly root;
|
|
337
|
+
private readonly scoped;
|
|
338
|
+
private readonly disposables;
|
|
339
|
+
constructor(root: NattyContainer);
|
|
340
|
+
createScope(): NattyScope;
|
|
341
|
+
set<T>(token: Token<T>, value: T): void;
|
|
342
|
+
tryGet<T>(token: Token<T>): T | undefined;
|
|
343
|
+
get<T>(token: Token<T>): T;
|
|
344
|
+
dispose(): Promise<void>;
|
|
345
|
+
}
|
|
346
|
+
|
|
279
347
|
declare class HttpContext {
|
|
280
348
|
constructor(request: HttpRequestInit, context: any);
|
|
281
349
|
request: HttpRequest;
|
|
@@ -286,6 +354,7 @@ declare class HttpContext {
|
|
|
286
354
|
[key: string]: RouteConfig;
|
|
287
355
|
};
|
|
288
356
|
user: UserIdentity<any>;
|
|
357
|
+
services: NattyScope;
|
|
289
358
|
}
|
|
290
359
|
|
|
291
360
|
declare class HttpHandler {
|
|
@@ -297,8 +366,11 @@ interface HttpModule {
|
|
|
297
366
|
init: (config: NattyConfig) => void;
|
|
298
367
|
}
|
|
299
368
|
|
|
300
|
-
declare function injectable<T = unknown>():
|
|
301
|
-
declare function injectable<T = unknown>(options:
|
|
369
|
+
declare function injectable<T = unknown>(): ClassDecorator;
|
|
370
|
+
declare function injectable<T = unknown>(options: {
|
|
371
|
+
lifetime?: Lifetime;
|
|
372
|
+
token?: Token<T>;
|
|
373
|
+
}): ClassDecorator;
|
|
302
374
|
|
|
303
375
|
declare function $request(request: HttpRequestInit): Promise<HttpResponse>;
|
|
304
376
|
|
|
@@ -330,6 +402,7 @@ declare abstract class BaseResponse {
|
|
|
330
402
|
badRequest(): void;
|
|
331
403
|
success(body: any): HttpResponse;
|
|
332
404
|
notFound(): void;
|
|
405
|
+
protected normalizeHttpResponse(result: any): any;
|
|
333
406
|
}
|
|
334
407
|
|
|
335
408
|
declare abstract class ParameterTypeConverter extends BaseResponse {
|
|
@@ -370,10 +443,11 @@ declare class ModelBindingContext extends ParameterTypeConverter {
|
|
|
370
443
|
private type;
|
|
371
444
|
private typeInfo;
|
|
372
445
|
private data;
|
|
446
|
+
private throwOnValidationError;
|
|
373
447
|
root: any;
|
|
374
448
|
parent: any;
|
|
375
449
|
instance: any;
|
|
376
|
-
constructor(type: string, typeInfo: TypeInfo[], data: any);
|
|
450
|
+
constructor(type: string, typeInfo: TypeInfo[], data: any, throwOnValidationError?: boolean);
|
|
377
451
|
private serialize;
|
|
378
452
|
get isValid(): boolean;
|
|
379
453
|
get errors(): {};
|
|
@@ -397,47 +471,134 @@ declare abstract class BaseController {
|
|
|
397
471
|
httpContext: HttpContext;
|
|
398
472
|
}
|
|
399
473
|
|
|
474
|
+
type ResponseExtras = Pick<HttpResponseInit, "headers" | "cookies">;
|
|
400
475
|
declare abstract class BaseResult {
|
|
401
|
-
|
|
402
|
-
constructor(response: HttpResponseInit,
|
|
476
|
+
protected response: HttpResponseInit;
|
|
477
|
+
constructor(response: HttpResponseInit, extras?: ResponseExtras);
|
|
403
478
|
getResponse(): HttpResponseInit;
|
|
404
479
|
}
|
|
405
480
|
|
|
406
|
-
declare class OkResult extends BaseResult {
|
|
407
|
-
value
|
|
408
|
-
|
|
481
|
+
declare class OkResult<T = unknown> extends BaseResult implements IHttpResult {
|
|
482
|
+
constructor(value?: T, extras?: ResponseExtras);
|
|
483
|
+
}
|
|
484
|
+
declare function ok<T = unknown>(value?: T, extras?: ResponseExtras): OkResult<T>;
|
|
485
|
+
|
|
486
|
+
declare class CreatedResult<T = unknown> extends BaseResult implements IHttpResult {
|
|
487
|
+
constructor(value?: T, extras?: ResponseExtras);
|
|
409
488
|
}
|
|
410
|
-
declare function
|
|
489
|
+
declare function created<T = unknown>(value?: T, extras?: ResponseExtras): CreatedResult<T>;
|
|
490
|
+
declare function createdWith<T = unknown>(location: string, value?: T, extras?: ResponseExtras): CreatedResult<T>;
|
|
491
|
+
declare function createdAt<T = unknown>(location: string, value?: T, extras?: ResponseExtras): CreatedResult<T>;
|
|
411
492
|
|
|
412
|
-
declare class
|
|
413
|
-
|
|
493
|
+
declare class AcceptedResult<T = unknown> extends BaseResult implements IHttpResult {
|
|
494
|
+
value?: T;
|
|
495
|
+
constructor(value?: T, extras?: ResponseExtras);
|
|
414
496
|
}
|
|
415
|
-
declare function
|
|
497
|
+
declare function accepted<T = unknown>(value?: T, extras?: ResponseExtras): AcceptedResult<T>;
|
|
416
498
|
|
|
417
499
|
declare class NoContentResult extends BaseResult implements IHttpResult {
|
|
418
|
-
constructor(
|
|
500
|
+
constructor(extras?: ResponseExtras);
|
|
501
|
+
}
|
|
502
|
+
declare function noContent(extras?: ResponseExtras): NoContentResult;
|
|
503
|
+
|
|
504
|
+
declare class BadRequestResult<T = ExceptionTypeInfo> extends BaseResult implements IHttpResult {
|
|
505
|
+
value?: T;
|
|
506
|
+
constructor(value?: T, extras?: ResponseExtras);
|
|
507
|
+
}
|
|
508
|
+
declare function badRequest<T = ExceptionTypeInfo>(value?: T, extras?: ResponseExtras): BadRequestResult<T>;
|
|
509
|
+
|
|
510
|
+
declare class UnAuthorizedResult<T = ExceptionTypeInfo> extends BaseResult implements IHttpResult {
|
|
511
|
+
value?: T;
|
|
512
|
+
constructor(value?: T, extras?: ResponseExtras);
|
|
513
|
+
}
|
|
514
|
+
declare function unAuthorized<T = ExceptionTypeInfo>(value?: T, extras?: ResponseExtras): UnAuthorizedResult<T>;
|
|
515
|
+
|
|
516
|
+
declare class ForbiddenAccessInfoResult<T = unknown> extends BaseResult implements IHttpResult {
|
|
517
|
+
constructor(value?: ExceptionTypeInfo, extras?: ResponseExtras);
|
|
518
|
+
}
|
|
519
|
+
declare function forbiddenAccessInfo(value?: ExceptionTypeInfo, extras?: ResponseExtras): ForbiddenAccessInfoResult<unknown>;
|
|
520
|
+
declare function forbiddenAccess<T = unknown>(value?: ExceptionTypeInfo, extras?: ResponseExtras): ForbiddenAccessInfoResult<unknown>;
|
|
521
|
+
|
|
522
|
+
declare class NotFoundResult<T = unknown> extends BaseResult implements IHttpResult {
|
|
523
|
+
constructor(value?: T, extras?: ResponseExtras);
|
|
524
|
+
}
|
|
525
|
+
declare function notFound(extras?: ResponseExtras): NotFoundResult<any>;
|
|
526
|
+
declare function notFoundWith<T = unknown>(value?: T, extras?: ResponseExtras): NotFoundResult<T>;
|
|
527
|
+
|
|
528
|
+
declare class ConflictResult<T = unknown> extends BaseResult implements IHttpResult {
|
|
529
|
+
value?: T;
|
|
530
|
+
constructor(value?: T, extras?: ResponseExtras);
|
|
419
531
|
}
|
|
420
|
-
declare function
|
|
532
|
+
declare function conflict<T = unknown>(value?: T, extras?: ResponseExtras): ConflictResult<T>;
|
|
421
533
|
|
|
422
|
-
declare class
|
|
423
|
-
|
|
534
|
+
declare class UnprocessableEntityResult<T = unknown> extends BaseResult implements IHttpResult {
|
|
535
|
+
value?: T;
|
|
536
|
+
constructor(value?: T, extras?: ResponseExtras);
|
|
424
537
|
}
|
|
425
|
-
declare function
|
|
538
|
+
declare function unprocessableEntity<T = unknown>(value?: T, extras?: ResponseExtras): UnprocessableEntityResult<T>;
|
|
426
539
|
|
|
427
|
-
declare class
|
|
428
|
-
|
|
540
|
+
declare class TooManyRequestsResult<T = unknown> extends BaseResult implements IHttpResult {
|
|
541
|
+
value?: T;
|
|
542
|
+
constructor(value?: T, retryAfterSeconds?: number, extras?: ResponseExtras);
|
|
429
543
|
}
|
|
430
|
-
declare function
|
|
544
|
+
declare function tooManyRequests<T = unknown>(value?: T, retryAfterSeconds?: number, extras?: ResponseExtras): TooManyRequestsResult<T>;
|
|
431
545
|
|
|
432
|
-
declare class
|
|
433
|
-
|
|
434
|
-
constructor(value: ExceptionTypeInfo, response?: Pick<HttpResponseInit, "headers" | "cookies">);
|
|
546
|
+
declare class RedirectResult extends BaseResult implements IHttpResult {
|
|
547
|
+
constructor(location: string, permanent?: boolean, extras?: ResponseExtras);
|
|
435
548
|
}
|
|
436
|
-
declare function
|
|
549
|
+
declare function redirect(location: string, extras?: ResponseExtras): RedirectResult;
|
|
550
|
+
declare function redirectPermanent(location: string, extras?: ResponseExtras): RedirectResult;
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* RFC7807 problem details.
|
|
554
|
+
*/
|
|
555
|
+
type ProblemDetails = ProblemDetail & {
|
|
556
|
+
status?: number;
|
|
557
|
+
errors?: Record<string, string[]>;
|
|
558
|
+
[key: string]: any;
|
|
559
|
+
};
|
|
560
|
+
|
|
561
|
+
declare class ProblemResult extends BaseResult implements IHttpResult {
|
|
562
|
+
constructor(problem: ProblemDetails, extras?: ResponseExtras);
|
|
563
|
+
}
|
|
564
|
+
declare function problem(problem: ProblemDetails, extras?: ResponseExtras): ProblemResult;
|
|
565
|
+
declare function validationProblem(errors: Record<string, string[]>, detail?: string, extras?: ResponseExtras): ProblemResult;
|
|
566
|
+
|
|
567
|
+
declare class FileResult extends BaseResult implements IHttpResult {
|
|
568
|
+
constructor(buffer?: Buffer, extras?: ResponseExtras);
|
|
569
|
+
}
|
|
570
|
+
declare function file(buffer?: Buffer, extras?: ResponseExtras): FileResult;
|
|
571
|
+
|
|
572
|
+
declare class StatusCodeResult<T = unknown> extends BaseResult implements IHttpResult {
|
|
573
|
+
constructor(status: number, value?: T, extras?: ResponseExtras);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
declare const Results: {
|
|
577
|
+
readonly ok: <T = unknown>(value?: T, extras?: ResponseExtras) => OkResult<T>;
|
|
578
|
+
readonly created: <T_1 = unknown>(value?: T_1, extras?: ResponseExtras) => CreatedResult<T_1>;
|
|
579
|
+
readonly createdWith: <T_2 = unknown>(location: string, value?: T_2, extras?: ResponseExtras) => CreatedResult<T_2>;
|
|
580
|
+
readonly createdAt: <T_3 = unknown>(location: string, value?: T_3, extras?: ResponseExtras) => CreatedResult<T_3>;
|
|
581
|
+
readonly accepted: <T_4 = unknown>(value?: T_4, extras?: ResponseExtras) => AcceptedResult<T_4>;
|
|
582
|
+
readonly noContent: (extras?: ResponseExtras) => NoContentResult;
|
|
583
|
+
readonly file: (buffer?: Buffer, extras?: ResponseExtras) => FileResult;
|
|
584
|
+
readonly statusCode: <T_5 = unknown>(status: number, value?: T_5, extras?: ResponseExtras) => StatusCodeResult<T_5>;
|
|
585
|
+
readonly badRequest: <T_6 = ExceptionTypeInfo>(value?: T_6, extras?: ResponseExtras) => BadRequestResult<T_6>;
|
|
586
|
+
readonly notFound: (extras?: ResponseExtras) => NotFoundResult<any>;
|
|
587
|
+
readonly notFoundWith: <T_7 = unknown>(value?: T_7, extras?: ResponseExtras) => NotFoundResult<T_7>;
|
|
588
|
+
readonly unAuthorized: <T_8 = ExceptionTypeInfo>(value?: T_8, extras?: ResponseExtras) => UnAuthorizedResult<T_8>;
|
|
589
|
+
readonly forbid: <T_9 = ExceptionTypeInfo>(value?: T_9, extras?: ResponseExtras) => ForbiddenAccessInfoResult<unknown>;
|
|
590
|
+
readonly conflict: <T_10 = unknown>(value?: T_10, extras?: ResponseExtras) => ConflictResult<T_10>;
|
|
591
|
+
readonly unprocessableEntity: <T_11 = unknown>(value?: T_11, extras?: ResponseExtras) => UnprocessableEntityResult<T_11>;
|
|
592
|
+
readonly tooManyRequests: <T_12 = unknown>(value?: T_12, retryAfterSeconds?: number, extras?: ResponseExtras) => TooManyRequestsResult<T_12>;
|
|
593
|
+
readonly redirect: (location: string, extras?: ResponseExtras) => RedirectResult;
|
|
594
|
+
readonly redirectPermanent: (location: string, extras?: ResponseExtras) => RedirectResult;
|
|
595
|
+
readonly problem: (p: ProblemDetails, extras?: ResponseExtras) => ProblemResult;
|
|
596
|
+
readonly validationProblem: (errors: Record<string, string[]>, detail?: string, extras?: ResponseExtras) => ProblemResult;
|
|
597
|
+
};
|
|
437
598
|
|
|
438
|
-
declare class HttpException {
|
|
599
|
+
declare class HttpException extends Error {
|
|
439
600
|
private httpResponse;
|
|
440
|
-
constructor(response: HttpResponseInit);
|
|
601
|
+
constructor(response: HttpResponseInit, message?: string);
|
|
441
602
|
getResponse(): HttpResponse;
|
|
442
603
|
}
|
|
443
604
|
|
|
@@ -457,10 +618,103 @@ declare class UnauthorizedAccessException extends HttpException {
|
|
|
457
618
|
constructor(data?: ExceptionTypeInfo);
|
|
458
619
|
}
|
|
459
620
|
|
|
621
|
+
declare class AcceptedException extends HttpException {
|
|
622
|
+
constructor(data?: ExceptionTypeInfo);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
declare class HttpConflictException extends HttpException {
|
|
626
|
+
constructor(data?: ExceptionTypeInfo);
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
declare class HttpUnprocessableEntityException extends HttpException {
|
|
630
|
+
constructor(data?: ExceptionTypeInfo);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
type RetryAfter = number | string | Date;
|
|
634
|
+
declare class TooManyRequestsException extends HttpException {
|
|
635
|
+
constructor(data?: ExceptionTypeInfo, retryAfter?: RetryAfter);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
declare class RedirectException extends HttpException {
|
|
639
|
+
constructor(location: string, data?: ExceptionTypeInfo);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
declare class RedirectPermanentException extends HttpException {
|
|
643
|
+
constructor(location: string, data?: ExceptionTypeInfo);
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
declare class ProblemDetailsException extends HttpException {
|
|
647
|
+
constructor(problem: ProblemDetails, status?: number, headers?: Record<string, string>);
|
|
648
|
+
}
|
|
649
|
+
declare class ValidationProblemDetailsException extends ProblemDetailsException {
|
|
650
|
+
constructor(errors: Record<string, string[]>, detail?: string, status?: number);
|
|
651
|
+
}
|
|
652
|
+
|
|
460
653
|
declare function useFilter(config: GlobalConfig): (target: any, propertyKey?: string, descriptor?: any) => void;
|
|
461
654
|
|
|
462
655
|
declare function anonymous(): (target: any, propertyKey?: string, descriptor?: any) => void;
|
|
463
656
|
|
|
464
657
|
declare function authenticationOnly(): (target: any, propertyKey?: string, descriptor?: any) => void;
|
|
465
658
|
|
|
466
|
-
|
|
659
|
+
declare function onException(exceptionFilter: ClassType<ExceptionFilter>): (target: any, propertyKey?: string, descriptor?: any) => void;
|
|
660
|
+
|
|
661
|
+
declare function setEnvInfo(envTsDefinition: {
|
|
662
|
+
[key: string]: string;
|
|
663
|
+
}, envValueInfo: {
|
|
664
|
+
[key: string]: any;
|
|
665
|
+
}): void;
|
|
666
|
+
|
|
667
|
+
declare enum HttpStatusCode {
|
|
668
|
+
success = 200,
|
|
669
|
+
created = 201,
|
|
670
|
+
accepted = 202,
|
|
671
|
+
noContent = 204,
|
|
672
|
+
movedPermanently = 301,
|
|
673
|
+
found = 302,
|
|
674
|
+
badRequest = 400,
|
|
675
|
+
unAuthorized = 401,
|
|
676
|
+
forbiddenAccess = 403,
|
|
677
|
+
notFound = 404,
|
|
678
|
+
conflict = 409,
|
|
679
|
+
unprocessableEntity = 422,
|
|
680
|
+
tooManyRequests = 429,
|
|
681
|
+
serverError = 500
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
declare function authorize(permission: {
|
|
685
|
+
[key: string]: any;
|
|
686
|
+
}): (target: any, propertyKey?: string, descriptor?: any) => void;
|
|
687
|
+
|
|
688
|
+
declare function CreateProblemDetail(modelName: string, detail: any): ProblemDetail;
|
|
689
|
+
|
|
690
|
+
declare function scoped<T = unknown>(): ClassDecorator;
|
|
691
|
+
|
|
692
|
+
declare function transient<T = unknown>(): ClassDecorator;
|
|
693
|
+
|
|
694
|
+
declare function singleton<T = unknown>(): ClassDecorator;
|
|
695
|
+
|
|
696
|
+
interface DiOptions {
|
|
697
|
+
lifetime?: Lifetime;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
declare function di<T = unknown>(token: Token<T> | unknown): ClassDecorator;
|
|
701
|
+
declare function di<T = unknown>(token: Token<T> | unknown, options: DiOptions): ClassDecorator;
|
|
702
|
+
|
|
703
|
+
declare function registerType<T>(): unknown;
|
|
704
|
+
|
|
705
|
+
declare function createServiceScope(): NattyScope;
|
|
706
|
+
|
|
707
|
+
declare function clearHotReloadRegistrations(files: string[]): void;
|
|
708
|
+
|
|
709
|
+
declare function clearHotReloadControllerMetadata(controllerNames: string[]): void;
|
|
710
|
+
|
|
711
|
+
interface RuntimeManifest {
|
|
712
|
+
routes: {
|
|
713
|
+
[key: string]: RouteConfig;
|
|
714
|
+
};
|
|
715
|
+
resolver?: (path: string) => any;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
declare function replaceRoutes(manifest: RuntimeManifest): void;
|
|
719
|
+
|
|
720
|
+
export { $request, AbstractModelState, AcceptedException, AcceptedResult, BadRequestResult, BaseController, BaseResult, BuildOptions, ClassTypeInfo, ConflictResult, CreateProblemDetail, CreatedResult, Delete, DiOptions, FileResult, ForbiddenAccessException, ForbiddenAccessInfoResult, HttpBadRequestException, HttpConflictException, HttpContext, HttpException, HttpHandler, HttpModule, HttpNotFoundException, HttpResponse, HttpStatusCode, HttpUnprocessableEntityException, Lifetime, MethodInfo$1 as MethodInfo, ModelBindingContext, NoContentResult, NotFoundResult, OkResult, ParameterInfo, ProblemDetailsException, ProblemResult, RedirectException, RedirectPermanentException, RedirectResult, ResponseExtras, Results, RetryAfter, RunOn, RuntimeManifest, TooManyRequestsException, TooManyRequestsResult, TypeInfo$1 as TypeInfo, UnAuthorizedResult, UnauthorizedAccessException, UnprocessableEntityResult, ValidationProblemDetailsException, accepted, anonymous, authenticationOnly, authorize, badRequest, clearHotReloadControllerMetadata, clearHotReloadRegistrations, conflict, createServiceScope, created, createdAt, createdWith, defineNattyConfig, di, entityContainer, file, filter, forbiddenAccess, forbiddenAccessInfo, get, init, injectable, noContent, notFound, notFoundWith, ok, onException, post, problem, put, redirect, redirectPermanent, registerDecorator, registerType, replaceRoutes, route, scoped, setEnvInfo, singleton, tooManyRequests, transient, unAuthorized, unprocessableEntity, useFilter, validationProblem };
|