resurgence-data 1.0.18 → 1.0.20
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/exception/authentication.exception.d.ts +4 -4
- package/dist/exception/authentication.exception.js +3 -3
- package/dist/exception/authorization.exception.d.ts +3 -3
- package/dist/exception/authorization.exception.js +2 -2
- package/dist/exception/data.exception.d.ts +2 -2
- package/dist/exception/data.exception.js +1 -1
- package/dist/exception/database.exception.d.ts +2 -2
- package/dist/exception/database.exception.js +1 -1
- package/dist/exception/exception.d.ts +3 -1
- package/dist/exception/exception.js +9 -3
- package/dist/exception/integration.exception.d.ts +3 -3
- package/dist/exception/integration.exception.js +2 -2
- package/dist/exception/process.exception.d.ts +2 -2
- package/dist/exception/process.exception.js +1 -1
- package/dist/exception/resource.exception.d.ts +5 -5
- package/dist/exception/resource.exception.js +4 -4
- package/dist/types/error.type.d.ts +1 -0
- package/jest.config.js +7 -0
- package/package.json +3 -5
- package/src/authentication/authentication.data.ts +33 -0
- package/src/authentication/authentication.dto.ts +108 -0
- package/src/authentication/index.ts +4 -0
- package/src/authentication/invite.data.ts +14 -0
- package/src/authentication/invite.dto.ts +30 -0
- package/src/exception/authentication.exception.ts +7 -0
- package/src/exception/authorization.exception.ts +5 -0
- package/src/exception/data.exception.ts +3 -0
- package/src/exception/database.exception.ts +3 -0
- package/src/exception/exception.ts +24 -0
- package/src/exception/index.ts +7 -0
- package/src/exception/integration.exception.ts +5 -0
- package/src/exception/process.exception.ts +3 -0
- package/src/exception/resource.exception.ts +9 -0
- package/src/index.ts +5 -0
- package/src/messaging/index.ts +1 -0
- package/src/messaging/message.dto.ts +5 -0
- package/src/response/index.ts +1 -0
- package/src/response/response.dto.ts +7 -0
- package/src/types/account.type.ts +3 -0
- package/src/types/error.type.ts +7 -0
- package/src/user/index.ts +1 -0
- package/src/user/user.ts +32 -0
- package/src/validation/custom-validation.ts +20 -0
- package/tsconfig.json +17 -0
@@ -1,7 +1,7 @@
|
|
1
|
-
import {
|
2
|
-
export declare class InvalidCredentialsException extends
|
1
|
+
import { ResurgenceException } from "./exception";
|
2
|
+
export declare class InvalidCredentialsException extends ResurgenceException {
|
3
3
|
}
|
4
|
-
export declare class InvalidUserException extends
|
4
|
+
export declare class InvalidUserException extends ResurgenceException {
|
5
5
|
}
|
6
|
-
export declare class InactiveUserException extends
|
6
|
+
export declare class InactiveUserException extends ResurgenceException {
|
7
7
|
}
|
@@ -2,12 +2,12 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.InactiveUserException = exports.InvalidUserException = exports.InvalidCredentialsException = void 0;
|
4
4
|
const exception_1 = require("./exception");
|
5
|
-
class InvalidCredentialsException extends exception_1.
|
5
|
+
class InvalidCredentialsException extends exception_1.ResurgenceException {
|
6
6
|
}
|
7
7
|
exports.InvalidCredentialsException = InvalidCredentialsException;
|
8
|
-
class InvalidUserException extends exception_1.
|
8
|
+
class InvalidUserException extends exception_1.ResurgenceException {
|
9
9
|
}
|
10
10
|
exports.InvalidUserException = InvalidUserException;
|
11
|
-
class InactiveUserException extends exception_1.
|
11
|
+
class InactiveUserException extends exception_1.ResurgenceException {
|
12
12
|
}
|
13
13
|
exports.InactiveUserException = InactiveUserException;
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import {
|
2
|
-
export declare class InvalidAuthorizationException extends
|
1
|
+
import { ResurgenceException } from "./exception";
|
2
|
+
export declare class InvalidAuthorizationException extends ResurgenceException {
|
3
3
|
}
|
4
|
-
export declare class ExpiredAuthorizationException extends
|
4
|
+
export declare class ExpiredAuthorizationException extends ResurgenceException {
|
5
5
|
}
|
@@ -2,9 +2,9 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.ExpiredAuthorizationException = exports.InvalidAuthorizationException = void 0;
|
4
4
|
const exception_1 = require("./exception");
|
5
|
-
class InvalidAuthorizationException extends exception_1.
|
5
|
+
class InvalidAuthorizationException extends exception_1.ResurgenceException {
|
6
6
|
}
|
7
7
|
exports.InvalidAuthorizationException = InvalidAuthorizationException;
|
8
|
-
class ExpiredAuthorizationException extends exception_1.
|
8
|
+
class ExpiredAuthorizationException extends exception_1.ResurgenceException {
|
9
9
|
}
|
10
10
|
exports.ExpiredAuthorizationException = ExpiredAuthorizationException;
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import {
|
2
|
-
export declare class InvalidPayloadException extends
|
1
|
+
import { ResurgenceException } from "./exception";
|
2
|
+
export declare class InvalidPayloadException extends ResurgenceException {
|
3
3
|
}
|
@@ -2,6 +2,6 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.InvalidPayloadException = void 0;
|
4
4
|
const exception_1 = require("./exception");
|
5
|
-
class InvalidPayloadException extends exception_1.
|
5
|
+
class InvalidPayloadException extends exception_1.ResurgenceException {
|
6
6
|
}
|
7
7
|
exports.InvalidPayloadException = InvalidPayloadException;
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import {
|
2
|
-
export declare class DatabaseProcessException extends
|
1
|
+
import { ResurgenceException } from "./exception";
|
2
|
+
export declare class DatabaseProcessException extends ResurgenceException {
|
3
3
|
}
|
@@ -2,6 +2,6 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.DatabaseProcessException = void 0;
|
4
4
|
const exception_1 = require("./exception");
|
5
|
-
class DatabaseProcessException extends exception_1.
|
5
|
+
class DatabaseProcessException extends exception_1.ResurgenceException {
|
6
6
|
}
|
7
7
|
exports.DatabaseProcessException = DatabaseProcessException;
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { ErrorContent } from "../types/error.type";
|
2
|
-
export declare class
|
2
|
+
export declare class ResurgenceException extends Error {
|
3
3
|
description?: string;
|
4
4
|
status: number | 500;
|
5
|
+
context: string;
|
6
|
+
data: any;
|
5
7
|
constructor(errorContent?: ErrorContent);
|
6
8
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
4
|
-
class
|
3
|
+
exports.ResurgenceException = void 0;
|
4
|
+
class ResurgenceException extends Error {
|
5
5
|
constructor(errorContent) {
|
6
6
|
super();
|
7
7
|
if (errorContent) {
|
@@ -10,7 +10,13 @@ class Exception extends Error {
|
|
10
10
|
if (errorContent.status) {
|
11
11
|
this.status = errorContent.status;
|
12
12
|
}
|
13
|
+
if (errorContent.context) {
|
14
|
+
this.context = errorContent.context;
|
15
|
+
}
|
16
|
+
if (errorContent.data) {
|
17
|
+
this.data = errorContent.data;
|
18
|
+
}
|
13
19
|
}
|
14
20
|
}
|
15
21
|
}
|
16
|
-
exports.
|
22
|
+
exports.ResurgenceException = ResurgenceException;
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import {
|
2
|
-
export declare class MessagingException extends
|
1
|
+
import { ResurgenceException } from "./exception";
|
2
|
+
export declare class MessagingException extends ResurgenceException {
|
3
3
|
}
|
4
|
-
export declare class ThirdPartyIntegrationException extends
|
4
|
+
export declare class ThirdPartyIntegrationException extends ResurgenceException {
|
5
5
|
}
|
@@ -2,9 +2,9 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.ThirdPartyIntegrationException = exports.MessagingException = void 0;
|
4
4
|
const exception_1 = require("./exception");
|
5
|
-
class MessagingException extends exception_1.
|
5
|
+
class MessagingException extends exception_1.ResurgenceException {
|
6
6
|
}
|
7
7
|
exports.MessagingException = MessagingException;
|
8
|
-
class ThirdPartyIntegrationException extends exception_1.
|
8
|
+
class ThirdPartyIntegrationException extends exception_1.ResurgenceException {
|
9
9
|
}
|
10
10
|
exports.ThirdPartyIntegrationException = ThirdPartyIntegrationException;
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import {
|
2
|
-
export declare class IncompleteProcessException extends
|
1
|
+
import { ResurgenceException } from "./exception";
|
2
|
+
export declare class IncompleteProcessException extends ResurgenceException {
|
3
3
|
}
|
@@ -2,6 +2,6 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.IncompleteProcessException = void 0;
|
4
4
|
const exception_1 = require("./exception");
|
5
|
-
class IncompleteProcessException extends exception_1.
|
5
|
+
class IncompleteProcessException extends exception_1.ResurgenceException {
|
6
6
|
}
|
7
7
|
exports.IncompleteProcessException = IncompleteProcessException;
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import {
|
2
|
-
export declare class ResourceNotFoundException extends
|
1
|
+
import { ResurgenceException } from "./exception";
|
2
|
+
export declare class ResourceNotFoundException extends ResurgenceException {
|
3
3
|
}
|
4
|
-
export declare class ResourceExistsException extends
|
4
|
+
export declare class ResourceExistsException extends ResurgenceException {
|
5
5
|
}
|
6
|
-
export declare class UnauthorizedResourceActionException extends
|
6
|
+
export declare class UnauthorizedResourceActionException extends ResurgenceException {
|
7
7
|
}
|
8
|
-
export declare class ExpiredResourceException extends
|
8
|
+
export declare class ExpiredResourceException extends ResurgenceException {
|
9
9
|
}
|
@@ -2,15 +2,15 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.ExpiredResourceException = exports.UnauthorizedResourceActionException = exports.ResourceExistsException = exports.ResourceNotFoundException = void 0;
|
4
4
|
const exception_1 = require("./exception");
|
5
|
-
class ResourceNotFoundException extends exception_1.
|
5
|
+
class ResourceNotFoundException extends exception_1.ResurgenceException {
|
6
6
|
}
|
7
7
|
exports.ResourceNotFoundException = ResourceNotFoundException;
|
8
|
-
class ResourceExistsException extends exception_1.
|
8
|
+
class ResourceExistsException extends exception_1.ResurgenceException {
|
9
9
|
}
|
10
10
|
exports.ResourceExistsException = ResourceExistsException;
|
11
|
-
class UnauthorizedResourceActionException extends exception_1.
|
11
|
+
class UnauthorizedResourceActionException extends exception_1.ResurgenceException {
|
12
12
|
}
|
13
13
|
exports.UnauthorizedResourceActionException = UnauthorizedResourceActionException;
|
14
|
-
class ExpiredResourceException extends exception_1.
|
14
|
+
class ExpiredResourceException extends exception_1.ResurgenceException {
|
15
15
|
}
|
16
16
|
exports.ExpiredResourceException = ExpiredResourceException;
|
package/jest.config.js
ADDED
package/package.json
CHANGED
@@ -1,17 +1,15 @@
|
|
1
1
|
{
|
2
2
|
"name": "resurgence-data",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.20",
|
4
4
|
"description": "DTOs and shareable resources",
|
5
5
|
"module": "dist/index.js",
|
6
6
|
"main": "dist/index.js",
|
7
7
|
"types": "dist/index.d.ts",
|
8
|
-
"files": [
|
9
|
-
"dist"
|
10
|
-
],
|
11
8
|
"exports": {
|
12
9
|
".": {
|
13
10
|
"import": "./dist/index.js",
|
14
|
-
"require": "./dist/index.js"
|
11
|
+
"require": "./dist/index.js",
|
12
|
+
"types": "./dist/index.d.ts"
|
15
13
|
}
|
16
14
|
},
|
17
15
|
"scripts": {
|
@@ -0,0 +1,33 @@
|
|
1
|
+
export interface AuthenticationBillerRole {
|
2
|
+
authenticationId: string;
|
3
|
+
billerId: string;
|
4
|
+
role: string;
|
5
|
+
}
|
6
|
+
|
7
|
+
export interface LoggedInUser {
|
8
|
+
id: string;
|
9
|
+
firstName: string;
|
10
|
+
lastName: string;
|
11
|
+
emailAddress: string;
|
12
|
+
phoneNumber: string;
|
13
|
+
merchantRoles: AuthenticationBillerRole[];
|
14
|
+
}
|
15
|
+
|
16
|
+
export interface ResetPasswordEmailRequest {
|
17
|
+
firstName: string;
|
18
|
+
emailAddress: string;
|
19
|
+
actionUrl: string;
|
20
|
+
}
|
21
|
+
|
22
|
+
export interface NewUserEmailRequest extends ResetPasswordEmailRequest {}
|
23
|
+
|
24
|
+
export interface UpdateAuthenticationModel {
|
25
|
+
id: string;
|
26
|
+
userId?: string;
|
27
|
+
password?: string | null;
|
28
|
+
token?: string | null;
|
29
|
+
tokenExpiry?: Date | null;
|
30
|
+
active?: boolean;
|
31
|
+
twoFactorEnabled?: boolean;
|
32
|
+
role?: string;
|
33
|
+
}
|
@@ -0,0 +1,108 @@
|
|
1
|
+
import { IsBoolean, IsEmail, IsIn, IsOptional, IsString, IsUUID, Length } from "class-validator";
|
2
|
+
import { accountTypes } from "../types/account.type";
|
3
|
+
import { isSameAs } from "../validation/custom-validation";
|
4
|
+
|
5
|
+
export class SignUpDTO {
|
6
|
+
firstName: string;
|
7
|
+
lastName: string;
|
8
|
+
emailAddress: string;
|
9
|
+
phoneNumber: string;
|
10
|
+
}
|
11
|
+
|
12
|
+
export class LoginRequestDTO {
|
13
|
+
@IsString({ message: "Please enter your username / email address" })
|
14
|
+
emailAddress: string;
|
15
|
+
@IsString({ message: "Please enter your password" })
|
16
|
+
password: string;
|
17
|
+
}
|
18
|
+
|
19
|
+
export class RecoverAccountDTO {
|
20
|
+
@IsString({ message: "Please enter your email address." })
|
21
|
+
emailAddress: string;
|
22
|
+
}
|
23
|
+
|
24
|
+
export class SendInviteDTO {
|
25
|
+
@IsUUID(4, { message: "Please provide a valid merchant / biller identifier" })
|
26
|
+
billerId: string;
|
27
|
+
@IsString({ message: "Please enter the email address of your invitee" })
|
28
|
+
@IsEmail(undefined, { message: "Please enter a valid email address" })
|
29
|
+
emailAddress: string;
|
30
|
+
@IsString({ message: "Please enter a valid data type" })
|
31
|
+
@IsIn(accountTypes, { message: "Please select a valid role type" })
|
32
|
+
role: string;
|
33
|
+
}
|
34
|
+
|
35
|
+
export class ActivationRequestDTO {
|
36
|
+
@IsString({ message: "Please provide your activation code" })
|
37
|
+
token: string;
|
38
|
+
@IsString({ message: "Please provide your password" })
|
39
|
+
password: string;
|
40
|
+
@IsOptional()
|
41
|
+
@IsString({ message: "Please confirm your password" })
|
42
|
+
@isSameAs("password", { message: "Your passwords to not match. Please check" })
|
43
|
+
passwordConfirm?: string;
|
44
|
+
}
|
45
|
+
|
46
|
+
export class UpdateAuthenticationDTO {
|
47
|
+
@IsUUID()
|
48
|
+
userId: string;
|
49
|
+
@IsOptional()
|
50
|
+
@IsBoolean()
|
51
|
+
active?: boolean;
|
52
|
+
@IsOptional()
|
53
|
+
@IsString({ message: "Please enter a valid data type" })
|
54
|
+
@IsIn(accountTypes, { message: "Please select a valid role type" })
|
55
|
+
role?: string;
|
56
|
+
}
|
57
|
+
|
58
|
+
export class TwoFactorAuthRequestDTO {
|
59
|
+
@IsEmail(undefined, { message: "Please enter a valid email address" })
|
60
|
+
@IsString({ message: "Please enter the email address of your invitee" })
|
61
|
+
emailAddress: string;
|
62
|
+
@IsString({ message: "Please provide the 6 character code" })
|
63
|
+
@Length(6, 6, { message: "Please enter a 6 character code" })
|
64
|
+
token: string;
|
65
|
+
}
|
66
|
+
|
67
|
+
export class TwoFactorCreateDTO {
|
68
|
+
emailAddress: string;
|
69
|
+
token: string;
|
70
|
+
authenticationId: string;
|
71
|
+
tokenExpiry?: Date;
|
72
|
+
}
|
73
|
+
|
74
|
+
export class LoginResponseDTO {
|
75
|
+
twoFactorEnabled: boolean;
|
76
|
+
message?: string;
|
77
|
+
token?: string;
|
78
|
+
}
|
79
|
+
|
80
|
+
export interface UserAuthenticationBillerRole {
|
81
|
+
id: string;
|
82
|
+
firstName?: string;
|
83
|
+
lastName?: string;
|
84
|
+
emailAddress: string;
|
85
|
+
phoneNumber?: string | null;
|
86
|
+
createdAt?: Date;
|
87
|
+
updatedAt?: Date;
|
88
|
+
authentication: {
|
89
|
+
id: string;
|
90
|
+
userId?: string;
|
91
|
+
password?: string | null;
|
92
|
+
token?: string | null;
|
93
|
+
tokenExpiry?: Date | null;
|
94
|
+
active: boolean;
|
95
|
+
twoFactorEnabled: boolean;
|
96
|
+
role: string;
|
97
|
+
createdAt?: Date;
|
98
|
+
updatedAt?: Date;
|
99
|
+
authenticationBillerRole: {
|
100
|
+
id: string;
|
101
|
+
billerId: string;
|
102
|
+
authenticationId: string;
|
103
|
+
role: string;
|
104
|
+
createdAt?: Date;
|
105
|
+
updatedAt?: Date;
|
106
|
+
}[];
|
107
|
+
};
|
108
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
export interface InviteCreateModel {
|
2
|
+
userId: string;
|
3
|
+
emailAddress: string;
|
4
|
+
firstName: string;
|
5
|
+
lastName: string;
|
6
|
+
billerId: string;
|
7
|
+
token: string;
|
8
|
+
status?: string;
|
9
|
+
role: string;
|
10
|
+
tokenExpiry?: Date;
|
11
|
+
}
|
12
|
+
export interface InviteUpdateModel extends InviteCreateModel {
|
13
|
+
id: string;
|
14
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { IsEmail, IsIn, IsString, IsUUID } from "class-validator";
|
2
|
+
import { accountTypes } from "../types/account.type";
|
3
|
+
|
4
|
+
export class InviteRequestDTO {
|
5
|
+
@IsString({ message: "Please enter your invitees first name" })
|
6
|
+
firstName: string;
|
7
|
+
@IsString({ message: "Please enter your invitees first name" })
|
8
|
+
lastName: string;
|
9
|
+
@IsEmail(undefined, { message: "Please enter a valid email address" })
|
10
|
+
@IsString({ message: "Please enter your invitees first name" })
|
11
|
+
emailAddress: string;
|
12
|
+
@IsIn(accountTypes, { message: "Please select a valid role tyoe" })
|
13
|
+
role: string;
|
14
|
+
@IsUUID(4, { message: "Please enter a valid merchant identifier" })
|
15
|
+
billerId: string;
|
16
|
+
@IsUUID(4, { message: "Please enter a valid user identifier" })
|
17
|
+
userId: string;
|
18
|
+
}
|
19
|
+
|
20
|
+
export class AcceptInviteInviteDTO {
|
21
|
+
@IsString({ message: "Please enter the valid invite token" })
|
22
|
+
token: string;
|
23
|
+
@IsString({ message: "Please enter a valid password" })
|
24
|
+
password: string;
|
25
|
+
}
|
26
|
+
|
27
|
+
export class RevokeInviteDTO {
|
28
|
+
@IsUUID(4, { message: "Please select a valid invite" })
|
29
|
+
id: string;
|
30
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { ErrorContent } from "../types/error.type";
|
2
|
+
|
3
|
+
export class ResurgenceException extends Error {
|
4
|
+
description?: string;
|
5
|
+
status!: number | 500;
|
6
|
+
context!: string;
|
7
|
+
data!: any;
|
8
|
+
constructor(errorContent?: ErrorContent) {
|
9
|
+
super();
|
10
|
+
if (errorContent) {
|
11
|
+
this.message = errorContent.message;
|
12
|
+
this.description = errorContent.description;
|
13
|
+
if (errorContent.status) {
|
14
|
+
this.status = errorContent.status;
|
15
|
+
}
|
16
|
+
if (errorContent.context) {
|
17
|
+
this.context = errorContent.context;
|
18
|
+
}
|
19
|
+
if (errorContent.data) {
|
20
|
+
this.data = errorContent.data;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
export * from "./resource.exception";
|
2
|
+
export * from "./exception";
|
3
|
+
export * from "./authentication.exception";
|
4
|
+
export * from "./authorization.exception";
|
5
|
+
export * from "./database.exception";
|
6
|
+
export * from "./integration.exception";
|
7
|
+
export * from "./process.exception";
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { ResurgenceException } from "./exception";
|
2
|
+
|
3
|
+
export class ResourceNotFoundException extends ResurgenceException {}
|
4
|
+
|
5
|
+
export class ResourceExistsException extends ResurgenceException {}
|
6
|
+
|
7
|
+
export class UnauthorizedResourceActionException extends ResurgenceException {}
|
8
|
+
|
9
|
+
export class ExpiredResourceException extends ResurgenceException {}
|
package/src/index.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./message.dto";
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./response.dto";
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./user";
|
package/src/user/user.ts
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
import { IsBoolean, IsEmail, IsOptional, IsString, IsUUID } from "class-validator";
|
2
|
+
|
3
|
+
export class CreateUserDTO {
|
4
|
+
@IsString({ message: "Please enter your first name." })
|
5
|
+
firstName: string;
|
6
|
+
|
7
|
+
@IsString({ message: "Please enter your last name." })
|
8
|
+
lastName: string;
|
9
|
+
|
10
|
+
@IsEmail(undefined, { message: "Please enter a valid email address" })
|
11
|
+
@IsString({ message: "Please enter a valid email address." })
|
12
|
+
emailAddress: string;
|
13
|
+
|
14
|
+
@IsString({ message: "Please enter your phone number." })
|
15
|
+
phoneNumber: string;
|
16
|
+
@IsString({ message: "Please enter your business name." })
|
17
|
+
businessName: string;
|
18
|
+
@IsOptional() // Allows the property to be optional
|
19
|
+
@IsString({ message: "Please provide a valid avatar URL." })
|
20
|
+
avatarUrl?: string;
|
21
|
+
@IsOptional()
|
22
|
+
@IsBoolean({ message: "Corporate must be a boolean value." })
|
23
|
+
corporate?: boolean;
|
24
|
+
|
25
|
+
@IsString({ message: "Please specify the account type." })
|
26
|
+
accountType: string;
|
27
|
+
}
|
28
|
+
|
29
|
+
export class UpdateUserDTO extends CreateUserDTO {
|
30
|
+
@IsUUID(4, { message: "Please enter a valid user id format" })
|
31
|
+
id: string;
|
32
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { registerDecorator, ValidationArguments, ValidationOptions } from "class-validator";
|
2
|
+
|
3
|
+
export function isSameAs(property: string, validationOptions: ValidationOptions) {
|
4
|
+
return function (object: Object, propertyName: string) {
|
5
|
+
registerDecorator({
|
6
|
+
name: "isSameAs",
|
7
|
+
target: object.constructor,
|
8
|
+
propertyName: propertyName,
|
9
|
+
constraints: [property],
|
10
|
+
options: validationOptions,
|
11
|
+
validator: {
|
12
|
+
validate(value: any, args: ValidationArguments) {
|
13
|
+
const [relatedPropertyName] = args.constraints;
|
14
|
+
const relatedValue = (args.object as any)[relatedPropertyName];
|
15
|
+
return value === relatedValue;
|
16
|
+
},
|
17
|
+
},
|
18
|
+
});
|
19
|
+
};
|
20
|
+
}
|
package/tsconfig.json
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"target": "ES6",
|
4
|
+
"module": "CommonJS",
|
5
|
+
"declaration": true,
|
6
|
+
"outDir": "./dist",
|
7
|
+
"strict": true,
|
8
|
+
"moduleResolution": "node",
|
9
|
+
"strictPropertyInitialization": false,
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
11
|
+
"experimentalDecorators": true /* Enable experimental support for legacy experimental decorators. */,
|
12
|
+
"emitDecoratorMetadata": true,
|
13
|
+
"esModuleInterop": true
|
14
|
+
},
|
15
|
+
"include": ["src/**/*"],
|
16
|
+
"exclude": ["node_modules", "**/*.test.ts"]
|
17
|
+
}
|