@nattyjs/core 0.0.1-beta.63 → 0.0.1-beta.65
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 +397 -64
- package/dist/index.d.ts +109 -83
- package/dist/index.mjs +388 -66
- package/package.json +2 -2
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 {
|
|
@@ -59,64 +60,6 @@ declare function put(path?: string): (target: any, propertyKey?: string, descrip
|
|
|
59
60
|
|
|
60
61
|
declare function Delete(): (target: any, propertyKey?: string, descriptor?: any) => void;
|
|
61
62
|
|
|
62
|
-
interface RouteConfig {
|
|
63
|
-
controller: Function;
|
|
64
|
-
parameters: Array<{
|
|
65
|
-
name: string;
|
|
66
|
-
type: string;
|
|
67
|
-
}>;
|
|
68
|
-
get: {
|
|
69
|
-
[key: string]: {
|
|
70
|
-
name: string;
|
|
71
|
-
parameters: Array<{
|
|
72
|
-
name: string;
|
|
73
|
-
type: string;
|
|
74
|
-
}>;
|
|
75
|
-
returnType: string;
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
post: {
|
|
79
|
-
[key: string]: {
|
|
80
|
-
name: string;
|
|
81
|
-
parameters: Array<{
|
|
82
|
-
name: string;
|
|
83
|
-
type: string;
|
|
84
|
-
}>;
|
|
85
|
-
returnType: string;
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
put: {
|
|
89
|
-
[key: string]: {
|
|
90
|
-
name: string;
|
|
91
|
-
parameters: Array<{
|
|
92
|
-
name: string;
|
|
93
|
-
type: string;
|
|
94
|
-
}>;
|
|
95
|
-
returnType: string;
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
delete: {
|
|
99
|
-
[key: string]: {
|
|
100
|
-
name: string;
|
|
101
|
-
parameters: Array<{
|
|
102
|
-
name: string;
|
|
103
|
-
type: string;
|
|
104
|
-
}>;
|
|
105
|
-
returnType: string;
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
declare function init(config: NattyConfig, appConfig: {
|
|
111
|
-
routes: {
|
|
112
|
-
[key: string]: RouteConfig;
|
|
113
|
-
};
|
|
114
|
-
envTsDefinition: {
|
|
115
|
-
[key: string]: string;
|
|
116
|
-
};
|
|
117
|
-
resolver: (path: string) => {};
|
|
118
|
-
}): any;
|
|
119
|
-
|
|
120
63
|
interface DecoratorInfo {
|
|
121
64
|
httpMethod: string;
|
|
122
65
|
route: string;
|
|
@@ -126,6 +69,7 @@ interface TypeInfo {
|
|
|
126
69
|
name: string;
|
|
127
70
|
documentation?: string;
|
|
128
71
|
type?: string;
|
|
72
|
+
tokenKey?: string;
|
|
129
73
|
}
|
|
130
74
|
interface MethodInfo extends TypeInfo {
|
|
131
75
|
parameters?: TypeInfo[];
|
|
@@ -250,6 +194,50 @@ interface IHttpResult {
|
|
|
250
194
|
getResponse(): HttpResponseInit;
|
|
251
195
|
}
|
|
252
196
|
|
|
197
|
+
interface RouteConfig {
|
|
198
|
+
controller: Function;
|
|
199
|
+
parameters: TypeInfo$1[];
|
|
200
|
+
get: {
|
|
201
|
+
[key: string]: {
|
|
202
|
+
name: string;
|
|
203
|
+
parameters: TypeInfo$1[];
|
|
204
|
+
returnType: string;
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
post: {
|
|
208
|
+
[key: string]: {
|
|
209
|
+
name: string;
|
|
210
|
+
parameters: TypeInfo$1[];
|
|
211
|
+
returnType: string;
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
put: {
|
|
215
|
+
[key: string]: {
|
|
216
|
+
name: string;
|
|
217
|
+
parameters: TypeInfo$1[];
|
|
218
|
+
returnType: string;
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
delete: {
|
|
222
|
+
[key: string]: {
|
|
223
|
+
name: string;
|
|
224
|
+
parameters: TypeInfo$1[];
|
|
225
|
+
returnType: string;
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
declare function init(config: NattyConfig, appConfig: {
|
|
231
|
+
routes: {
|
|
232
|
+
[key: string]: RouteConfig;
|
|
233
|
+
};
|
|
234
|
+
types?: TypesInfo;
|
|
235
|
+
envTsDefinition: {
|
|
236
|
+
[key: string]: string;
|
|
237
|
+
};
|
|
238
|
+
resolver?: (path: any) => any;
|
|
239
|
+
}): any;
|
|
240
|
+
|
|
253
241
|
declare class HttpRequest {
|
|
254
242
|
private httpRequest;
|
|
255
243
|
constructor(http: HttpRequestInit);
|
|
@@ -317,20 +305,31 @@ type Descriptor<T = any> = {
|
|
|
317
305
|
useFactory?: Factory<T>;
|
|
318
306
|
};
|
|
319
307
|
|
|
308
|
+
type ClearRegistrationsResult = {
|
|
309
|
+
metadataKeys: string[];
|
|
310
|
+
tokens: Token[];
|
|
311
|
+
};
|
|
320
312
|
declare class NattyContainer implements ServiceProvider {
|
|
321
313
|
private readonly regs;
|
|
322
314
|
private readonly singletons;
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
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;
|
|
328
324
|
createScope(): NattyScope;
|
|
329
325
|
set<T>(_token: Token<T>, _value: T): void;
|
|
330
326
|
tryGet<T>(token: Token<T>): T | undefined;
|
|
331
327
|
get<T>(token: Token<T>): T;
|
|
332
328
|
construct<T>(Cls: DIClassType<T>, sp: ServiceProvider): T;
|
|
333
329
|
_getDescriptor<T>(token: Token<T>): Descriptor<T> | undefined;
|
|
330
|
+
trackMetadataKey(sourceFile: string, key: string): void;
|
|
331
|
+
clearRegistrationsFromSource(sourceFile: string): ClearRegistrationsResult;
|
|
332
|
+
private trackTokenSource;
|
|
334
333
|
}
|
|
335
334
|
|
|
336
335
|
declare class NattyScope implements Scope {
|
|
@@ -414,9 +413,9 @@ declare abstract class ParameterTypeConverter extends BaseResponse {
|
|
|
414
413
|
};
|
|
415
414
|
get types(): TypesInfo;
|
|
416
415
|
getObjectTypeInfo(typeName: string): {
|
|
417
|
-
path?:
|
|
418
|
-
props?:
|
|
419
|
-
values?:
|
|
416
|
+
path?: any;
|
|
417
|
+
props?: TypeInfo[];
|
|
418
|
+
values?: any[];
|
|
420
419
|
};
|
|
421
420
|
isArrayType(typeName: string): boolean;
|
|
422
421
|
getTypeName(typeName: string): string;
|
|
@@ -443,10 +442,11 @@ declare class ModelBindingContext extends ParameterTypeConverter {
|
|
|
443
442
|
private type;
|
|
444
443
|
private typeInfo;
|
|
445
444
|
private data;
|
|
445
|
+
private throwOnValidationError;
|
|
446
446
|
root: any;
|
|
447
447
|
parent: any;
|
|
448
448
|
instance: any;
|
|
449
|
-
constructor(type: string, typeInfo: TypeInfo[], data: any);
|
|
449
|
+
constructor(type: string, typeInfo: TypeInfo[], data: any, throwOnValidationError?: boolean);
|
|
450
450
|
private serialize;
|
|
451
451
|
get isValid(): boolean;
|
|
452
452
|
get errors(): {};
|
|
@@ -574,21 +574,21 @@ declare class StatusCodeResult<T = unknown> extends BaseResult implements IHttpR
|
|
|
574
574
|
|
|
575
575
|
declare const Results: {
|
|
576
576
|
readonly ok: <T = unknown>(value?: T, extras?: ResponseExtras) => OkResult<T>;
|
|
577
|
-
readonly created: <
|
|
578
|
-
readonly createdWith: <
|
|
579
|
-
readonly createdAt: <
|
|
580
|
-
readonly accepted: <
|
|
577
|
+
readonly created: <T_1 = unknown>(value?: T_1, extras?: ResponseExtras) => CreatedResult<T_1>;
|
|
578
|
+
readonly createdWith: <T_2 = unknown>(location: string, value?: T_2, extras?: ResponseExtras) => CreatedResult<T_2>;
|
|
579
|
+
readonly createdAt: <T_3 = unknown>(location: string, value?: T_3, extras?: ResponseExtras) => CreatedResult<T_3>;
|
|
580
|
+
readonly accepted: <T_4 = unknown>(value?: T_4, extras?: ResponseExtras) => AcceptedResult<T_4>;
|
|
581
581
|
readonly noContent: (extras?: ResponseExtras) => NoContentResult;
|
|
582
582
|
readonly file: (buffer?: Buffer, extras?: ResponseExtras) => FileResult;
|
|
583
|
-
readonly statusCode: <
|
|
584
|
-
readonly badRequest: <
|
|
583
|
+
readonly statusCode: <T_5 = unknown>(status: number, value?: T_5, extras?: ResponseExtras) => StatusCodeResult<T_5>;
|
|
584
|
+
readonly badRequest: <T_6 = ExceptionTypeInfo>(value?: T_6, extras?: ResponseExtras) => BadRequestResult<T_6>;
|
|
585
585
|
readonly notFound: (extras?: ResponseExtras) => NotFoundResult<any>;
|
|
586
|
-
readonly notFoundWith: <
|
|
587
|
-
readonly unAuthorized: <
|
|
588
|
-
readonly forbid: <
|
|
589
|
-
readonly conflict: <
|
|
590
|
-
readonly unprocessableEntity: <
|
|
591
|
-
readonly tooManyRequests: <
|
|
586
|
+
readonly notFoundWith: <T_7 = unknown>(value?: T_7, extras?: ResponseExtras) => NotFoundResult<T_7>;
|
|
587
|
+
readonly unAuthorized: <T_8 = ExceptionTypeInfo>(value?: T_8, extras?: ResponseExtras) => UnAuthorizedResult<T_8>;
|
|
588
|
+
readonly forbid: <T_9 = ExceptionTypeInfo>(value?: T_9, extras?: ResponseExtras) => ForbiddenAccessInfoResult<unknown>;
|
|
589
|
+
readonly conflict: <T_10 = unknown>(value?: T_10, extras?: ResponseExtras) => ConflictResult<T_10>;
|
|
590
|
+
readonly unprocessableEntity: <T_11 = unknown>(value?: T_11, extras?: ResponseExtras) => UnprocessableEntityResult<T_11>;
|
|
591
|
+
readonly tooManyRequests: <T_12 = unknown>(value?: T_12, retryAfterSeconds?: number, extras?: ResponseExtras) => TooManyRequestsResult<T_12>;
|
|
592
592
|
readonly redirect: (location: string, extras?: ResponseExtras) => RedirectResult;
|
|
593
593
|
readonly redirectPermanent: (location: string, extras?: ResponseExtras) => RedirectResult;
|
|
594
594
|
readonly problem: (p: ProblemDetails, extras?: ResponseExtras) => ProblemResult;
|
|
@@ -655,6 +655,8 @@ declare function anonymous(): (target: any, propertyKey?: string, descriptor?: a
|
|
|
655
655
|
|
|
656
656
|
declare function authenticationOnly(): (target: any, propertyKey?: string, descriptor?: any) => void;
|
|
657
657
|
|
|
658
|
+
declare function onException(exceptionFilter: ClassType<ExceptionFilter>): (target: any, propertyKey?: string, descriptor?: any) => void;
|
|
659
|
+
|
|
658
660
|
declare function setEnvInfo(envTsDefinition: {
|
|
659
661
|
[key: string]: string;
|
|
660
662
|
}, envValueInfo: {
|
|
@@ -690,4 +692,28 @@ declare function transient<T = unknown>(): ClassDecorator;
|
|
|
690
692
|
|
|
691
693
|
declare function singleton<T = unknown>(): ClassDecorator;
|
|
692
694
|
|
|
693
|
-
|
|
695
|
+
interface DiOptions {
|
|
696
|
+
lifetime?: Lifetime;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
declare function di<T = unknown>(token: Token<T> | unknown): ClassDecorator;
|
|
700
|
+
declare function di<T = unknown>(token: Token<T> | unknown, options: DiOptions): ClassDecorator;
|
|
701
|
+
|
|
702
|
+
declare function registerType<T>(): unknown;
|
|
703
|
+
|
|
704
|
+
declare function createServiceScope(): NattyScope;
|
|
705
|
+
|
|
706
|
+
declare function clearHotReloadRegistrations(files: string[]): void;
|
|
707
|
+
|
|
708
|
+
declare function clearHotReloadControllerMetadata(controllerNames: string[]): void;
|
|
709
|
+
|
|
710
|
+
interface RuntimeManifest {
|
|
711
|
+
routes: {
|
|
712
|
+
[key: string]: RouteConfig;
|
|
713
|
+
};
|
|
714
|
+
resolver?: (path: string) => any;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
declare function replaceRoutes(manifest: RuntimeManifest): void;
|
|
718
|
+
|
|
719
|
+
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 };
|