@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.
- package/lib/package.json +2 -2
- package/lib/src/auth/authf.guard.js +12 -4
- package/lib/src/auth/authf.guard.js.map +1 -1
- package/lib/src/context/context.builder.d.ts +3 -3
- package/lib/src/context/context.builder.js +7 -7
- package/lib/src/context/context.builder.js.map +1 -1
- package/lib/src/decorator/index.d.ts +3 -0
- package/lib/src/decorator/index.js +3 -0
- package/lib/src/decorator/index.js.map +1 -1
- package/lib/src/decorator/is-valid-email-type.d.ts +7 -0
- package/lib/src/decorator/is-valid-email-type.js +39 -0
- package/lib/src/decorator/is-valid-email-type.js.map +1 -0
- package/lib/src/decorator/is-valid-phone-type.d.ts +7 -0
- package/lib/src/decorator/is-valid-phone-type.js +39 -0
- package/lib/src/decorator/is-valid-phone-type.js.map +1 -0
- package/lib/src/decorator/is-valid-utc-timezone.d.ts +7 -0
- package/lib/src/decorator/is-valid-utc-timezone.js +80 -0
- package/lib/src/decorator/is-valid-utc-timezone.js.map +1 -0
- package/lib/src/dto/email.dto.d.ts +5 -0
- package/lib/src/dto/email.dto.js +29 -0
- package/lib/src/dto/email.dto.js.map +1 -0
- package/lib/src/dto/index.d.ts +6 -0
- package/lib/src/dto/index.js +23 -0
- package/lib/src/dto/index.js.map +1 -0
- package/lib/src/dto/name.dto.d.ts +7 -0
- package/lib/src/dto/name.dto.js +37 -0
- package/lib/src/dto/name.dto.js.map +1 -0
- package/lib/src/dto/phone.dto.d.ts +5 -0
- package/lib/src/dto/phone.dto.js +29 -0
- package/lib/src/dto/phone.dto.js.map +1 -0
- package/lib/src/dto/photo.dto.d.ts +4 -0
- package/lib/src/dto/photo.dto.js +22 -0
- package/lib/src/dto/photo.dto.js.map +1 -0
- package/lib/src/dto/profile.dto.d.ts +20 -0
- package/lib/src/dto/profile.dto.js +7 -0
- package/lib/src/dto/profile.dto.js.map +1 -0
- package/lib/src/dto/user.dto.d.ts +7 -0
- package/lib/src/dto/user.dto.js +26 -0
- package/lib/src/dto/user.dto.js.map +1 -0
- package/lib/src/index.d.ts +1 -0
- package/lib/src/index.js +1 -0
- package/lib/src/index.js.map +1 -1
- package/lib/src/locales/{eng-US.json → en-US.json} +3 -3
- package/lib/src/locales/index.d.ts +2 -2
- package/lib/src/locales/index.js +3 -3
- package/lib/src/locales/index.js.map +1 -1
- package/lib/src/locales/locales.d.ts +3 -1
- package/lib/src/locales/locales.js +14 -4
- package/lib/src/locales/locales.js.map +1 -1
- package/package.json +2 -2
- package/src/auth/authf.guard.ts +15 -3
- package/src/context/context.builder.ts +5 -5
- package/src/decorator/index.ts +3 -0
- package/src/decorator/is-valid-email-type.ts +34 -0
- package/src/decorator/is-valid-phone-type.ts +34 -0
- package/src/decorator/is-valid-utc-timezone.ts +76 -0
- package/src/dto/email.dto.ts +13 -0
- package/src/dto/index.ts +6 -0
- package/src/dto/name.dto.ts +20 -0
- package/src/dto/phone.dto.ts +13 -0
- package/src/dto/photo.dto.ts +8 -0
- package/src/dto/profile.dto.ts +30 -0
- package/src/dto/user.dto.ts +14 -0
- package/src/index.ts +1 -0
- package/src/locales/en-US.json +7 -2
- package/src/locales/index.ts +2 -2
- package/src/locales/locales.ts +12 -5
- 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"}
|
package/lib/src/index.d.ts
CHANGED
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);
|
package/lib/src/index.js.map
CHANGED
|
@@ -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
|
|
2
|
-
export {
|
|
1
|
+
import * as en_US from "./en-US.json";
|
|
2
|
+
export { en_US };
|
package/lib/src/locales/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
exports.
|
|
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,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/locales/index.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AAE7B,sBAAK"}
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.i18nData = void 0;
|
|
4
|
-
const
|
|
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
|
-
|
|
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":";;;
|
|
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.
|
|
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
|
-
"
|
|
113
|
+
"en-US"
|
|
114
114
|
]
|
|
115
115
|
}
|
|
116
116
|
}
|
package/src/auth/authf.guard.ts
CHANGED
|
@@ -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
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
|
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.
|
|
46
|
+
this.i18nData
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
public
|
|
51
|
-
this.
|
|
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
|
-
|
|
139
|
+
staticCatalog: this.i18nData.getCatalog(),
|
|
140
140
|
defaultLocale: local.i18n,
|
|
141
141
|
});
|
|
142
142
|
|
package/src/decorator/index.ts
CHANGED
|
@@ -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
|
+
}
|
package/src/dto/index.ts
ADDED
|
@@ -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,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
package/src/locales/en-US.json
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"an-error-occurred": "
|
|
3
|
-
"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
|
}
|
package/src/locales/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as en_US from "./en-US.json";
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { en_US };
|
package/src/locales/locales.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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 };
|
package/src/locales/eng-US.json
DELETED