@nattyjs/common 0.0.1-beta.5 → 0.0.1-beta.7

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 CHANGED
@@ -25,6 +25,14 @@ const path__namespace = /*#__PURE__*/_interopNamespaceCompat(path);
25
25
  const commonContainer = new class {
26
26
  constructor() {
27
27
  this.metadataConfig = { services: /* @__PURE__ */ new Map() };
28
+ this.types = {};
29
+ }
30
+ registerType(type) {
31
+ for (const key of Object.keys(type))
32
+ this.types[key] = type[key];
33
+ }
34
+ setupCliConfig(config) {
35
+ this.nattyCliConfig = config;
28
36
  }
29
37
  setupConfig(config) {
30
38
  const modelBinding = {
@@ -286,10 +294,10 @@ function readEnvKey(key) {
286
294
  }
287
295
 
288
296
  class UserIdentity {
289
- constructor(isAuthenticate, id, claim) {
297
+ constructor(isAuthenticate, id, claims) {
290
298
  this.isAuthenticate = isAuthenticate;
291
299
  this.id = id;
292
- this.claim = claim;
300
+ this.claims = claims;
293
301
  }
294
302
  }
295
303
 
@@ -575,6 +583,10 @@ var FrameworkType = /* @__PURE__ */ ((FrameworkType2) => {
575
583
  return FrameworkType2;
576
584
  })(FrameworkType || {});
577
585
 
586
+ function registerType(type) {
587
+ commonContainer.registerType(type);
588
+ }
589
+
578
590
  exports.ALLOW_METHODS = ALLOW_METHODS;
579
591
  exports.ActionFilter = ActionFilter;
580
592
  exports.AuthenticationFilter = AuthenticationFilter;
@@ -612,4 +624,5 @@ exports.isFunction = isFunction;
612
624
  exports.isObject = isObject;
613
625
  exports.readEnv = readEnv;
614
626
  exports.readEnvKey = readEnvKey;
627
+ exports.registerType = registerType;
615
628
  exports.typeContainer = typeContainer;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { RequestRouteInfo, IHttpResult, IModelBindingContext, ProblemDetail, IExceptionContext, HttpResponseInit, NattyTestModule, ModelBinding, BuildOptions, ClassTypeInfo } from '@nattyjs/types';
1
+ import { RequestRouteInfo, IHttpResult, IModelBindingContext, ProblemDetail, IExceptionContext, HttpResponseInit, NattyTestModule, ModelBinding, NattyCliConfig, BuildOptions, TypesInfo, ClassTypeInfo } from '@nattyjs/types';
2
2
 
3
3
  interface ClassType<T> extends Function {
4
4
  new (...args: any[]): T;
@@ -7,8 +7,8 @@ interface ClassType<T> extends Function {
7
7
  declare class UserIdentity<T> {
8
8
  isAuthenticate: boolean;
9
9
  id?: any;
10
- claim?: T;
11
- constructor(isAuthenticate: boolean, id?: any, claim?: T);
10
+ claims?: T;
11
+ constructor(isAuthenticate: boolean, id?: any, claims?: T);
12
12
  }
13
13
 
14
14
  interface IExecutionContext {
@@ -66,8 +66,10 @@ interface NattyConfig {
66
66
 
67
67
  declare const commonContainer: {
68
68
  setupConfig(config?: NattyConfig): void;
69
+ setupCliConfig(config: NattyCliConfig): void;
69
70
  setupBuildOptions(options: BuildOptions): any;
70
71
  get nattyConfig(): NattyConfig;
72
+ get nattyCliConfig(): NattyCliConfig;
71
73
  get buildOptions(): BuildOptions;
72
74
  get envTsDefinition(): {
73
75
  [key: string]: string;
@@ -84,6 +86,7 @@ declare const commonContainer: {
84
86
  setMetadata(key: string, value: any, propName: string): void;
85
87
  getMetadataValue(key: string, propName: string): any;
86
88
  get globalConfig(): GlobalConfig;
89
+ registerType(type: TypesInfo): void;
87
90
  };
88
91
 
89
92
  declare const typeContainer: {
@@ -219,4 +222,6 @@ interface NattyAppConfig extends NattyConfig {
219
222
  framework: FrameworkType;
220
223
  }
221
224
 
222
- export { ALLOW_METHODS, ActionFilter, AuthenticationFilter, AuthorizationFilter, BACK_SLASH_REGEX, BLANK, CONTROLLER, Claim, ClassType, DEFAULT_ACTIONS, DEFAULT_CHILD_PATH, DELETE, ENVIRONMENTS, ExceptionFilter, FrameworkType, GET, GlobalConfig, HTTP_METHOD_ROUTES, IActionExecutedContext, IActionExecutingContext, IExecutionContext, IGNORE_METHODS, List, MetaConfigProps, Middleware, NattyAppConfig, NattyConfig, POST, PUT, RIGHT_SLASH, ROUTE_INSTANCES, ROUTE_METHODS, ROUTE_PATHS, TS_EXTENSION, UserIdentity, commonContainer, createPath, createTestServer, getPath, isConstructor, isEqual, isFunction, isObject, readEnv, readEnvKey, typeContainer };
225
+ declare function registerType(type: TypesInfo): void;
226
+
227
+ export { ALLOW_METHODS, ActionFilter, AuthenticationFilter, AuthorizationFilter, BACK_SLASH_REGEX, BLANK, CONTROLLER, Claim, ClassType, DEFAULT_ACTIONS, DEFAULT_CHILD_PATH, DELETE, ENVIRONMENTS, ExceptionFilter, FrameworkType, GET, GlobalConfig, HTTP_METHOD_ROUTES, IActionExecutedContext, IActionExecutingContext, IExecutionContext, IGNORE_METHODS, List, MetaConfigProps, Middleware, NattyAppConfig, NattyConfig, POST, PUT, RIGHT_SLASH, ROUTE_INSTANCES, ROUTE_METHODS, ROUTE_PATHS, TS_EXTENSION, UserIdentity, commonContainer, createPath, createTestServer, getPath, isConstructor, isEqual, isFunction, isObject, readEnv, readEnvKey, registerType, typeContainer };
package/dist/index.mjs CHANGED
@@ -7,6 +7,14 @@ import * as path from 'path';
7
7
  const commonContainer = new class {
8
8
  constructor() {
9
9
  this.metadataConfig = { services: /* @__PURE__ */ new Map() };
10
+ this.types = {};
11
+ }
12
+ registerType(type) {
13
+ for (const key of Object.keys(type))
14
+ this.types[key] = type[key];
15
+ }
16
+ setupCliConfig(config) {
17
+ this.nattyCliConfig = config;
10
18
  }
11
19
  setupConfig(config) {
12
20
  const modelBinding = {
@@ -268,10 +276,10 @@ function readEnvKey(key) {
268
276
  }
269
277
 
270
278
  class UserIdentity {
271
- constructor(isAuthenticate, id, claim) {
279
+ constructor(isAuthenticate, id, claims) {
272
280
  this.isAuthenticate = isAuthenticate;
273
281
  this.id = id;
274
- this.claim = claim;
282
+ this.claims = claims;
275
283
  }
276
284
  }
277
285
 
@@ -557,4 +565,8 @@ var FrameworkType = /* @__PURE__ */ ((FrameworkType2) => {
557
565
  return FrameworkType2;
558
566
  })(FrameworkType || {});
559
567
 
560
- export { ALLOW_METHODS, ActionFilter, AuthenticationFilter, AuthorizationFilter, BACK_SLASH_REGEX, BLANK, CONTROLLER, DEFAULT_ACTIONS, DEFAULT_CHILD_PATH, DELETE, ENVIRONMENTS, ExceptionFilter, FrameworkType, GET, HTTP_METHOD_ROUTES, IGNORE_METHODS, List, MetaConfigProps, Middleware, POST, PUT, RIGHT_SLASH, ROUTE_INSTANCES, ROUTE_METHODS, ROUTE_PATHS, TS_EXTENSION, UserIdentity, commonContainer, createPath, createTestServer, getPath, isConstructor, isEqual, isFunction, isObject, readEnv, readEnvKey, typeContainer };
568
+ function registerType(type) {
569
+ commonContainer.registerType(type);
570
+ }
571
+
572
+ export { ALLOW_METHODS, ActionFilter, AuthenticationFilter, AuthorizationFilter, BACK_SLASH_REGEX, BLANK, CONTROLLER, DEFAULT_ACTIONS, DEFAULT_CHILD_PATH, DELETE, ENVIRONMENTS, ExceptionFilter, FrameworkType, GET, HTTP_METHOD_ROUTES, IGNORE_METHODS, List, MetaConfigProps, Middleware, POST, PUT, RIGHT_SLASH, ROUTE_INSTANCES, ROUTE_METHODS, ROUTE_PATHS, TS_EXTENSION, UserIdentity, commonContainer, createPath, createTestServer, getPath, isConstructor, isEqual, isFunction, isObject, readEnv, readEnvKey, registerType, typeContainer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nattyjs/common",
3
- "version": "0.0.1-beta.5",
3
+ "version": "0.0.1-beta.7",
4
4
  "description": "Now I’m the model of a modern major general / The venerated Virginian veteran whose men are all / Lining up, to put me up on a pedestal / Writin’ letters to relatives / Embellishin’ my elegance and eloquence / But the elephant is in the room / The truth is in ya face when ya hear the British cannons go / BOOM",
5
5
  "keywords": [],
6
6
  "author": "ajayojha <ojhaajay@outlook.com>",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/node": "20.3.1",
23
- "@nattyjs/types": "0.0.1-beta.5",
23
+ "@nattyjs/types": "0.0.1-beta.7",
24
24
  "unbuild": "1.2.1"
25
25
  }
26
26
  }