@cryptexlabs/codex-nodejs-common 0.11.3 → 0.12.1

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.
Files changed (68) hide show
  1. package/lib/package.json +2 -2
  2. package/lib/src/auth/authf.guard.js +12 -4
  3. package/lib/src/auth/authf.guard.js.map +1 -1
  4. package/lib/src/context/context.builder.d.ts +3 -3
  5. package/lib/src/context/context.builder.js +7 -7
  6. package/lib/src/context/context.builder.js.map +1 -1
  7. package/lib/src/decorator/index.d.ts +3 -0
  8. package/lib/src/decorator/index.js +3 -0
  9. package/lib/src/decorator/index.js.map +1 -1
  10. package/lib/src/decorator/is-valid-email-type.d.ts +7 -0
  11. package/lib/src/decorator/is-valid-email-type.js +39 -0
  12. package/lib/src/decorator/is-valid-email-type.js.map +1 -0
  13. package/lib/src/decorator/is-valid-phone-type.d.ts +7 -0
  14. package/lib/src/decorator/is-valid-phone-type.js +39 -0
  15. package/lib/src/decorator/is-valid-phone-type.js.map +1 -0
  16. package/lib/src/decorator/is-valid-utc-timezone.d.ts +7 -0
  17. package/lib/src/decorator/is-valid-utc-timezone.js +80 -0
  18. package/lib/src/decorator/is-valid-utc-timezone.js.map +1 -0
  19. package/lib/src/dto/email.dto.d.ts +5 -0
  20. package/lib/src/dto/email.dto.js +29 -0
  21. package/lib/src/dto/email.dto.js.map +1 -0
  22. package/lib/src/dto/index.d.ts +6 -0
  23. package/lib/src/dto/index.js +23 -0
  24. package/lib/src/dto/index.js.map +1 -0
  25. package/lib/src/dto/name.dto.d.ts +7 -0
  26. package/lib/src/dto/name.dto.js +37 -0
  27. package/lib/src/dto/name.dto.js.map +1 -0
  28. package/lib/src/dto/phone.dto.d.ts +5 -0
  29. package/lib/src/dto/phone.dto.js +29 -0
  30. package/lib/src/dto/phone.dto.js.map +1 -0
  31. package/lib/src/dto/photo.dto.d.ts +4 -0
  32. package/lib/src/dto/photo.dto.js +22 -0
  33. package/lib/src/dto/photo.dto.js.map +1 -0
  34. package/lib/src/dto/profile.dto.d.ts +20 -0
  35. package/lib/src/dto/profile.dto.js +7 -0
  36. package/lib/src/dto/profile.dto.js.map +1 -0
  37. package/lib/src/dto/user.dto.d.ts +7 -0
  38. package/lib/src/dto/user.dto.js +26 -0
  39. package/lib/src/dto/user.dto.js.map +1 -0
  40. package/lib/src/index.d.ts +1 -0
  41. package/lib/src/index.js +1 -0
  42. package/lib/src/index.js.map +1 -1
  43. package/lib/src/locales/{eng-US.json → en-US.json} +3 -3
  44. package/lib/src/locales/index.d.ts +2 -2
  45. package/lib/src/locales/index.js +3 -3
  46. package/lib/src/locales/index.js.map +1 -1
  47. package/lib/src/locales/locales.d.ts +3 -1
  48. package/lib/src/locales/locales.js +14 -4
  49. package/lib/src/locales/locales.js.map +1 -1
  50. package/package.json +2 -2
  51. package/src/auth/authf.guard.ts +15 -3
  52. package/src/context/context.builder.ts +5 -5
  53. package/src/decorator/index.ts +3 -0
  54. package/src/decorator/is-valid-email-type.ts +34 -0
  55. package/src/decorator/is-valid-phone-type.ts +34 -0
  56. package/src/decorator/is-valid-utc-timezone.ts +76 -0
  57. package/src/dto/email.dto.ts +13 -0
  58. package/src/dto/index.ts +6 -0
  59. package/src/dto/name.dto.ts +20 -0
  60. package/src/dto/phone.dto.ts +13 -0
  61. package/src/dto/photo.dto.ts +8 -0
  62. package/src/dto/profile.dto.ts +30 -0
  63. package/src/dto/user.dto.ts +14 -0
  64. package/src/index.ts +1 -0
  65. package/src/locales/en-US.json +7 -2
  66. package/src/locales/index.ts +2 -2
  67. package/src/locales/locales.ts +12 -5
  68. package/src/locales/eng-US.json +0 -9
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.UserDto = void 0;
13
+ const class_validator_1 = require("class-validator");
14
+ const decorator_1 = require("../decorator");
15
+ class UserDto {
16
+ }
17
+ exports.UserDto = UserDto;
18
+ __decorate([
19
+ (0, class_validator_1.IsString)(),
20
+ __metadata("design:type", String)
21
+ ], UserDto.prototype, "username", void 0);
22
+ __decorate([
23
+ (0, decorator_1.IsValidUtcTimezone)(),
24
+ __metadata("design:type", String)
25
+ ], UserDto.prototype, "timezone", void 0);
26
+ //# sourceMappingURL=user.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.dto.js","sourceRoot":"","sources":["../../../src/dto/user.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qDAA2C;AAE3C,4CAAkD;AAElD,MAAa,OAAO;CAQnB;AARD,0BAQC;AANC;IADC,IAAA,0BAAQ,GAAE;;yCACM;AAKjB;IADC,IAAA,8BAAkB,GAAE;;yCACC"}
@@ -3,6 +3,7 @@ export * from "./client";
3
3
  export * from "./config";
4
4
  export * from "./context";
5
5
  export * from "./decorator";
6
+ export * from "./dto";
6
7
  export * from "./event";
7
8
  export * from "./filter";
8
9
  export * from "./logger";
package/lib/src/index.js CHANGED
@@ -19,6 +19,7 @@ __exportStar(require("./client"), exports);
19
19
  __exportStar(require("./config"), exports);
20
20
  __exportStar(require("./context"), exports);
21
21
  __exportStar(require("./decorator"), exports);
22
+ __exportStar(require("./dto"), exports);
22
23
  __exportStar(require("./event"), exports);
23
24
  __exportStar(require("./filter"), exports);
24
25
  __exportStar(require("./logger"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,2CAAyB;AACzB,2CAAyB;AACzB,4CAA0B;AAC1B,8CAA4B;AAC5B,0CAAwB;AACxB,2CAAyB;AACzB,2CAAyB;AACzB,4CAA0B;AAC1B,yCAAuB;AACvB,6CAA2B;AAC3B,2CAAyB;AACzB,8CAA4B;AAC5B,4CAA0B;AAC1B,4CAA0B;AAC1B,yCAAuB;AACvB,+CAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,2CAAyB;AACzB,2CAAyB;AACzB,4CAA0B;AAC1B,8CAA4B;AAC5B,wCAAsB;AACtB,0CAAwB;AACxB,2CAAyB;AACzB,2CAAyB;AACzB,4CAA0B;AAC1B,yCAAuB;AACvB,6CAA2B;AAC3B,2CAAyB;AACzB,8CAA4B;AAC5B,4CAA0B;AAC1B,4CAA0B;AAC1B,yCAAuB;AACvB,+CAA6B"}
@@ -1,9 +1,9 @@
1
1
  {
2
+ "an-error-occurred": "An error occurred",
3
+ "language-not-supported": "Language not supported",
2
4
  "unknown-error": "Unknown Error",
3
5
  "i-am-healthy": "I'm healthy",
4
6
  "invalid-request": "Invalid request",
5
7
  "success": "Success",
6
- "pong": "Pong",
7
- "an-error-occurred": "An error occurred",
8
- "language-not-supported": "Your language is not supported"
8
+ "pong": "Pong"
9
9
  }
@@ -1,2 +1,2 @@
1
- import * as eng_US from "./eng-US.json";
2
- export { eng_US };
1
+ import * as en_US from "./en-US.json";
2
+ export { en_US };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.eng_US = void 0;
4
- const eng_US = require("./eng-US.json");
5
- exports.eng_US = eng_US;
3
+ exports.en_US = void 0;
4
+ const en_US = require("./en-US.json");
5
+ exports.en_US = en_US;
6
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/locales/index.ts"],"names":[],"mappings":";;;AAAA,wCAAwC;AAE/B,wBAAM"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/locales/index.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AAE7B,sBAAK"}
@@ -1,2 +1,4 @@
1
+ import { I18n } from "i18n";
1
2
  declare const i18nData: i18nAPI;
2
- export { i18nData };
3
+ declare const i18nInstance: I18n;
4
+ export { i18nData, i18nInstance as i18n };
@@ -1,14 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.i18nData = void 0;
4
- const { I18n } = require("i18n");
3
+ exports.i18n = exports.i18nData = void 0;
4
+ const i18n_1 = require("i18n");
5
5
  const packageJSON = require("../../package.json");
6
+ const index_1 = require("./index");
6
7
  const i18nData = {};
7
8
  exports.i18nData = i18nData;
8
- const i18nInstance = new I18n();
9
+ const i18nInstance = new i18n_1.I18n();
10
+ exports.i18n = i18nInstance;
9
11
  i18nInstance.configure({
10
12
  locales: packageJSON.i18n.languages,
11
- directory: __dirname,
13
+ defaultLocale: "en-US",
12
14
  register: i18nData,
15
+ updateFiles: false,
16
+ objectNotation: true,
17
+ autoReload: false,
18
+ syncFiles: false,
19
+ extension: ".json",
20
+ staticCatalog: {
21
+ "en-US": index_1.en_US,
22
+ },
13
23
  });
14
24
  //# sourceMappingURL=locales.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"locales.js","sourceRoot":"","sources":["../../../src/locales/locales.ts"],"names":[],"mappings":";;;AAEA,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AACjC,kDAAkD;AAElD,MAAM,QAAQ,GAAG,EAAa,CAAC;AAUtB,4BAAQ;AARjB,MAAM,YAAY,GAAG,IAAI,IAAI,EAAE,CAAC;AAEhC,YAAY,CAAC,SAAS,CAAC;IACrB,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC,SAAS;IACnC,SAAS,EAAE,SAAS;IACpB,QAAQ,EAAE,QAAQ;CACnB,CAAC,CAAC"}
1
+ {"version":3,"file":"locales.js","sourceRoot":"","sources":["../../../src/locales/locales.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAC5B,kDAAkD;AAClD,mCAAgC;AAEhC,MAAM,QAAQ,GAAG,EAAa,CAAC;AAkBtB,4BAAQ;AAhBjB,MAAM,YAAY,GAAG,IAAI,WAAI,EAAE,CAAC;AAgBG,4BAAI;AAdvC,YAAY,CAAC,SAAS,CAAC;IACrB,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC,SAAS;IACnC,aAAa,EAAE,OAAO;IACtB,QAAQ,EAAE,QAAQ;IAClB,WAAW,EAAE,KAAK;IAClB,cAAc,EAAE,IAAI;IACpB,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,OAAO;IAClB,aAAa,EAAE;QACb,OAAO,EAAE,aAAK;KACf;CACF,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cryptexlabs/codex-nodejs-common",
3
- "version": "0.11.3",
3
+ "version": "0.12.1",
4
4
  "description": "Common code for Codex framework",
5
5
  "main": "lib/src/index.js",
6
6
  "type": "commonjs",
@@ -110,7 +110,7 @@
110
110
  },
111
111
  "i18n": {
112
112
  "languages": [
113
- "eng-US"
113
+ "en-US"
114
114
  ]
115
115
  }
116
116
  }
@@ -119,6 +119,7 @@ export class AuthfGuard implements CanActivate {
119
119
  private async _updateBlacklist(context: Context) {
120
120
  const headers = this._getApiHeaders(context);
121
121
 
122
+ context.logger.verbose(`Fetching blacklist`);
122
123
  const subjectBlacklistResponse = await axios.get(
123
124
  `/api/v1/blacklisted-subjects`,
124
125
  {
@@ -126,15 +127,26 @@ export class AuthfGuard implements CanActivate {
126
127
  headers,
127
128
  }
128
129
  );
130
+ context.logger.verbose(`Blacklist response`, subjectBlacklistResponse.data);
129
131
 
130
132
  if (
131
133
  subjectBlacklistResponse.data?.data !== undefined &&
132
134
  Array.isArray(subjectBlacklistResponse.data?.data)
133
135
  ) {
134
- this._blacklistedSubjects = subjectBlacklistResponse.data?.data;
135
- if (this._blacklistedSubjects.length > 0) {
136
- context.logger.verbose(`Got blacklist`, this._blacklistedSubjects);
136
+ if (
137
+ this._blacklistedSubjects.length !== subjectBlacklistResponse.data?.data
138
+ ) {
139
+ context.logger.debug(`Got change in blacklist`, {
140
+ old: this._blacklistedSubjects,
141
+ new: subjectBlacklistResponse.data?.data,
142
+ });
143
+ } else if (this._blacklistedSubjects.length > 0) {
144
+ context.logger.verbose(
145
+ `Got blacklist`,
146
+ subjectBlacklistResponse.data?.data
147
+ );
137
148
  }
149
+ this._blacklistedSubjects = subjectBlacklistResponse.data?.data;
138
150
  }
139
151
  }
140
152
  }
@@ -26,7 +26,7 @@ export class ContextBuilder {
26
26
  private readonly config: DefaultConfig,
27
27
  public client: ClientInterface,
28
28
  private readonly messageContext: MessageContextInterface,
29
- private i18nDir?: string
29
+ private i18nData?: i18nAPI
30
30
  ) {}
31
31
 
32
32
  public build() {
@@ -43,12 +43,12 @@ export class ContextBuilder {
43
43
  category: this.messageContext.category,
44
44
  id: this.messageContext.id,
45
45
  },
46
- this.i18nDir
46
+ this.i18nData
47
47
  );
48
48
  }
49
49
 
50
- public setI18nDir(i18nDir: string) {
51
- this.i18nDir = i18nDir;
50
+ public setI18nData(i18nData: i18nAPI) {
51
+ this.i18nData = i18nData;
52
52
  return this;
53
53
  }
54
54
 
@@ -136,7 +136,7 @@ export class ContextBuilder {
136
136
  const local = this._getLocale();
137
137
  i18nInstance.configure({
138
138
  locales: [local.i18n],
139
- directory: this.i18nDir,
139
+ staticCatalog: this.i18nData.getCatalog(),
140
140
  defaultLocale: local.i18n,
141
141
  });
142
142
 
@@ -1,3 +1,6 @@
1
1
  export * from "./api-meta-headers";
2
2
  export * from "./api-pagination";
3
3
  export * from "./api-query-options";
4
+ export * from "./is-valid-email-type";
5
+ export * from "./is-valid-phone-type";
6
+ export * from "./is-valid-utc-timezone";
@@ -0,0 +1,34 @@
1
+ import {
2
+ ValidatorConstraint,
3
+ ValidatorConstraintInterface,
4
+ ValidationArguments,
5
+ registerDecorator,
6
+ ValidationOptions,
7
+ } from "class-validator";
8
+ import { EmailTypeEnum } from "@cryptexlabs/authf-data-model";
9
+
10
+ @ValidatorConstraint({ name: "IsValidEmailType", async: false })
11
+ export class IsValidEmailTypeConstraint
12
+ implements ValidatorConstraintInterface {
13
+ private readonly EMAIL_TYPES: string[] = Object.values(EmailTypeEnum);
14
+
15
+ validate(timezone: any, args: ValidationArguments): boolean {
16
+ return this.EMAIL_TYPES.includes(timezone);
17
+ }
18
+
19
+ defaultMessage(args: ValidationArguments): string {
20
+ return `"${args.value}" is not a valid UTC timezone. Choose one of the allowed timezones.`;
21
+ }
22
+ }
23
+
24
+ export function IsValidEmailType(validationOptions?: ValidationOptions) {
25
+ return (object: any, propertyName: string) => {
26
+ registerDecorator({
27
+ target: object.constructor,
28
+ propertyName,
29
+ options: validationOptions,
30
+ constraints: [],
31
+ validator: IsValidEmailTypeConstraint,
32
+ });
33
+ };
34
+ }
@@ -0,0 +1,34 @@
1
+ import {
2
+ ValidatorConstraint,
3
+ ValidatorConstraintInterface,
4
+ ValidationArguments,
5
+ registerDecorator,
6
+ ValidationOptions,
7
+ } from "class-validator";
8
+ import { EmailTypeEnum, PhoneTypeEnum } from "@cryptexlabs/authf-data-model";
9
+
10
+ @ValidatorConstraint({ name: "IsValidPhoneType", async: false })
11
+ export class IsValidPhoneTypeConstraint
12
+ implements ValidatorConstraintInterface {
13
+ private readonly PHONE_TYPES: string[] = Object.values(PhoneTypeEnum);
14
+
15
+ validate(timezone: any, args: ValidationArguments): boolean {
16
+ return this.PHONE_TYPES.includes(timezone);
17
+ }
18
+
19
+ defaultMessage(args: ValidationArguments): string {
20
+ return `"${args.value}" is not a valid UTC timezone. Choose one of the allowed timezones.`;
21
+ }
22
+ }
23
+
24
+ export function IsValidPhoneType(validationOptions?: ValidationOptions) {
25
+ return (object: any, propertyName: string) => {
26
+ registerDecorator({
27
+ target: object.constructor,
28
+ propertyName,
29
+ options: validationOptions,
30
+ constraints: [],
31
+ validator: IsValidPhoneTypeConstraint,
32
+ });
33
+ };
34
+ }
@@ -0,0 +1,76 @@
1
+ import {
2
+ ValidatorConstraint,
3
+ ValidatorConstraintInterface,
4
+ ValidationArguments,
5
+ registerDecorator,
6
+ ValidationOptions,
7
+ } from "class-validator";
8
+
9
+ // Step 1: Define the custom validator
10
+ @ValidatorConstraint({ name: "IsValidUtcTimezone", async: false })
11
+ export class IsValidUtcTimezoneConstraint
12
+ implements ValidatorConstraintInterface {
13
+ private readonly TIMEZONES: string[] = [
14
+ "-12:00",
15
+ "-11:00",
16
+ "-10:30",
17
+ "-10:00",
18
+ "-09:30",
19
+ "-09:00",
20
+ "-08:00",
21
+ "-07:00",
22
+ "-06:00",
23
+ "-05:00",
24
+ "-04:00",
25
+ "-04:30",
26
+ "-03:30",
27
+ "-03:00",
28
+ "-02:00",
29
+ "-01:00",
30
+ "-00:00",
31
+ "+00:00",
32
+ "+01:00",
33
+ "+02:00",
34
+ "+03:00",
35
+ "+03:30",
36
+ "+04:00",
37
+ "+04:30",
38
+ "+05:00",
39
+ "+05:30",
40
+ "+05:45",
41
+ "+06:00",
42
+ "+06:30",
43
+ "+07:00",
44
+ "+08:00",
45
+ "+08:45",
46
+ "+09:00",
47
+ "+09:30",
48
+ "+10:00",
49
+ "+10:30",
50
+ "+11:00",
51
+ "+12:00",
52
+ "+12:45",
53
+ "+13:00",
54
+ "+14:00",
55
+ ];
56
+
57
+ validate(timezone: any, args: ValidationArguments): boolean {
58
+ return this.TIMEZONES.includes(timezone);
59
+ }
60
+
61
+ defaultMessage(args: ValidationArguments): string {
62
+ return `"${args.value}" is not a valid UTC timezone. Choose one of the allowed timezones.`;
63
+ }
64
+ }
65
+
66
+ export function IsValidUtcTimezone(validationOptions?: ValidationOptions) {
67
+ return (object: any, propertyName: string) => {
68
+ registerDecorator({
69
+ target: object.constructor,
70
+ propertyName,
71
+ options: validationOptions,
72
+ constraints: [],
73
+ validator: IsValidUtcTimezoneConstraint,
74
+ });
75
+ };
76
+ }
@@ -0,0 +1,13 @@
1
+ import { EmailInterface, EmailTypeEnum } from "@cryptexlabs/authf-data-model";
2
+ import { IsEmail, IsOptional } from "class-validator";
3
+ import { IsValidEmailType } from "../decorator";
4
+
5
+ export class EmailDto implements EmailInterface {
6
+ @IsOptional()
7
+ @IsEmail()
8
+ value: string | null;
9
+
10
+ @IsOptional()
11
+ @IsValidEmailType()
12
+ type: EmailTypeEnum;
13
+ }
@@ -0,0 +1,6 @@
1
+ export * from "./email.dto";
2
+ export * from "./name.dto";
3
+ export * from "./phone.dto";
4
+ export * from "./photo.dto";
5
+ export * from "./profile.dto";
6
+ export * from "./user.dto";
@@ -0,0 +1,20 @@
1
+ import { NameInterface } from "@cryptexlabs/authf-data-model";
2
+ import { IsOptional, IsString } from "class-validator";
3
+
4
+ export class NameDto implements NameInterface {
5
+ @IsOptional()
6
+ @IsString()
7
+ first: string;
8
+
9
+ @IsOptional()
10
+ @IsString()
11
+ middle: string;
12
+
13
+ @IsOptional()
14
+ @IsString()
15
+ last: string;
16
+
17
+ @IsOptional()
18
+ @IsString()
19
+ display: string;
20
+ }
@@ -0,0 +1,13 @@
1
+ import { PhoneInterface, PhoneTypeEnum } from "@cryptexlabs/authf-data-model";
2
+ import { IsOptional, IsString } from "class-validator";
3
+ import { IsValidPhoneType } from "../decorator";
4
+
5
+ export class PhoneDto implements PhoneInterface {
6
+ @IsOptional()
7
+ @IsString()
8
+ value: string;
9
+
10
+ @IsOptional()
11
+ @IsValidPhoneType()
12
+ type: PhoneTypeEnum;
13
+ }
@@ -0,0 +1,8 @@
1
+ import { PhotoInterface } from "@cryptexlabs/authf-data-model";
2
+ import { IsOptional, IsUrl } from "class-validator";
3
+
4
+ export class PhotoDto implements PhotoInterface {
5
+ @IsOptional()
6
+ @IsUrl()
7
+ url: string;
8
+ }
@@ -0,0 +1,30 @@
1
+ import {
2
+ EmailInterface,
3
+ NameInterface,
4
+ PhoneInterface,
5
+ PhotoInterface,
6
+ ProfileInterface,
7
+ } from "@cryptexlabs/authf-data-model";
8
+ import { EmailDto } from "./email.dto";
9
+ import { PhoneDto } from "./phone.dto";
10
+ import { PhotoDto } from "./photo.dto";
11
+ import { NameDto } from "./name.dto";
12
+
13
+ export class ProfileDto implements ProfileInterface {
14
+ email: {
15
+ primary: EmailDto | null;
16
+ other: EmailDto[];
17
+ };
18
+
19
+ phone: {
20
+ primary: PhoneDto | null;
21
+ other: PhoneDto[];
22
+ };
23
+
24
+ photo: {
25
+ primary: PhotoDto | null;
26
+ other: PhotoDto[];
27
+ };
28
+
29
+ name: NameDto;
30
+ }
@@ -0,0 +1,14 @@
1
+ import { UserInterface, UtcTimezone } from "@cryptexlabs/authf-data-model";
2
+ import { IsString } from "class-validator";
3
+ import { ProfileDto } from "./profile.dto";
4
+ import { IsValidUtcTimezone } from "../decorator";
5
+
6
+ export class UserDto implements UserInterface {
7
+ @IsString()
8
+ username: string;
9
+
10
+ profile: ProfileDto;
11
+
12
+ @IsValidUtcTimezone()
13
+ timezone: UtcTimezone;
14
+ }
package/src/index.ts CHANGED
@@ -3,6 +3,7 @@ export * from "./client";
3
3
  export * from "./config";
4
4
  export * from "./context";
5
5
  export * from "./decorator";
6
+ export * from "./dto";
6
7
  export * from "./event";
7
8
  export * from "./filter";
8
9
  export * from "./logger";
@@ -1,4 +1,9 @@
1
1
  {
2
- "an-error-occurred": "an-error-occurred",
3
- "language-not-supported": "language-not-supported"
2
+ "an-error-occurred": "An error occurred",
3
+ "language-not-supported": "Language not supported",
4
+ "unknown-error": "Unknown Error",
5
+ "i-am-healthy": "I'm healthy",
6
+ "invalid-request": "Invalid request",
7
+ "success": "Success",
8
+ "pong": "Pong"
4
9
  }
@@ -1,3 +1,3 @@
1
- import * as eng_US from "./eng-US.json";
1
+ import * as en_US from "./en-US.json";
2
2
 
3
- export { eng_US };
3
+ export { en_US };
@@ -1,7 +1,6 @@
1
- // TODO remove https://github.com/DefinitelyTyped/DefinitelyTyped/issues/46871
2
- // tslint:disable-next-line:no-var-requires
3
- const { I18n } = require("i18n");
1
+ import { I18n } from "i18n";
4
2
  import * as packageJSON from "../../package.json";
3
+ import { en_US } from "./index";
5
4
 
6
5
  const i18nData = {} as i18nAPI;
7
6
 
@@ -9,8 +8,16 @@ const i18nInstance = new I18n();
9
8
 
10
9
  i18nInstance.configure({
11
10
  locales: packageJSON.i18n.languages,
12
- directory: __dirname,
11
+ defaultLocale: "en-US",
13
12
  register: i18nData,
13
+ updateFiles: false,
14
+ objectNotation: true,
15
+ autoReload: false,
16
+ syncFiles: false,
17
+ extension: ".json",
18
+ staticCatalog: {
19
+ "en-US": en_US,
20
+ },
14
21
  });
15
22
 
16
- export { i18nData };
23
+ export { i18nData, i18nInstance as i18n };
@@ -1,9 +0,0 @@
1
- {
2
- "unknown-error": "Unknown Error",
3
- "i-am-healthy": "I'm healthy",
4
- "invalid-request": "Invalid request",
5
- "success": "Success",
6
- "pong": "Pong",
7
- "an-error-occurred": "An error occurred",
8
- "language-not-supported": "Your language is not supported"
9
- }