resurgence-data 1.0.17 → 1.0.19
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/authentication/authentication.data.d.ts +1 -1
- 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 +1 -4
- 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 +131 -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,13 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "resurgence-data",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.19",
|
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",
|
@@ -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,131 @@
|
|
1
|
+
// {
|
2
|
+
// "compilerOptions": {
|
3
|
+
// /* Visit https://aka.ms/tsconfig to read more about this file */
|
4
|
+
|
5
|
+
// /* Projects */
|
6
|
+
// // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
7
|
+
// // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
8
|
+
// // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
9
|
+
// // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
10
|
+
// // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
11
|
+
// // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
12
|
+
|
13
|
+
// /* Language and Environment */
|
14
|
+
// "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
15
|
+
// // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
16
|
+
// // "jsx": "preserve", /* Specify what JSX code is generated. */
|
17
|
+
// "experimentalDecorators": true /* Enable experimental support for legacy experimental decorators. */,
|
18
|
+
// "emitDecoratorMetadata": true /* Emit design-type metadata for decorated declarations in source files. */,
|
19
|
+
// // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
20
|
+
// // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
21
|
+
// // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
22
|
+
// // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
23
|
+
// // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
24
|
+
// // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
25
|
+
// // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
26
|
+
|
27
|
+
// /* Modules */
|
28
|
+
// "module": "commonjs" /* Specify what module code is generated. */,
|
29
|
+
// // "rootDir": "./", /* Specify the root folder within your source files. */
|
30
|
+
// // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
31
|
+
// // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
32
|
+
// // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
33
|
+
// // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
34
|
+
// // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
35
|
+
// // "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
36
|
+
// // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
37
|
+
// // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
38
|
+
// // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
39
|
+
// // "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
|
40
|
+
// // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
41
|
+
// // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
42
|
+
// // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
43
|
+
// // "noUncheckedSideEffectImports": true, /* Check side effect imports. */
|
44
|
+
// // "resolveJsonModule": true, /* Enable importing .json files. */
|
45
|
+
// // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
46
|
+
// // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
47
|
+
|
48
|
+
// /* JavaScript Support */
|
49
|
+
// // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
50
|
+
// // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
51
|
+
// // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
52
|
+
|
53
|
+
// /* Emit */
|
54
|
+
// // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
55
|
+
// // "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
56
|
+
// // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
57
|
+
// // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
58
|
+
// // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
59
|
+
// // "noEmit": true, /* Disable emitting files from a compilation. */
|
60
|
+
// // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
61
|
+
// "outDir": "./dist" /* Specify an output folder for all emitted files. */,
|
62
|
+
// // "removeComments": true, /* Disable emitting comments. */
|
63
|
+
// // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
64
|
+
// // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
65
|
+
// // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
66
|
+
// // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
67
|
+
// // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
68
|
+
// // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
69
|
+
// // "newLine": "crlf", /* Set the newline character for emitting files. */
|
70
|
+
// // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
71
|
+
// // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
72
|
+
// // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
73
|
+
// // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
74
|
+
// // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
75
|
+
|
76
|
+
// /* Interop Constraints */
|
77
|
+
// // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
78
|
+
// // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
79
|
+
// // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
|
80
|
+
// // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
81
|
+
// "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
82
|
+
// // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
83
|
+
// "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
84
|
+
|
85
|
+
// /* Type Checking */
|
86
|
+
// "strict": true /* Enable all strict type-checking options. */,
|
87
|
+
// // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
88
|
+
// // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
89
|
+
// // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
90
|
+
// // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
91
|
+
// "strictPropertyInitialization": false /* Check for class properties that are declared but not set in the constructor. */,
|
92
|
+
// // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
|
93
|
+
// // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
94
|
+
// // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
95
|
+
// // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
96
|
+
// // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
97
|
+
// // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
98
|
+
// // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
99
|
+
// // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
100
|
+
// // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
101
|
+
// // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
102
|
+
// // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
103
|
+
// // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
104
|
+
// // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
105
|
+
// // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
106
|
+
|
107
|
+
// /* Completeness */
|
108
|
+
// // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
109
|
+
// "skipLibCheck": true /* Skip type checking all .d.ts files. */
|
110
|
+
// },
|
111
|
+
// "include": ["src/**/*"],
|
112
|
+
// "exclude": ["node_modules", "**/*.test.ts"]
|
113
|
+
// }
|
114
|
+
|
115
|
+
{
|
116
|
+
"compilerOptions": {
|
117
|
+
"target": "ES6",
|
118
|
+
"module": "CommonJS",
|
119
|
+
"declaration": true,
|
120
|
+
"outDir": "./dist",
|
121
|
+
"strict": true,
|
122
|
+
"moduleResolution": "node",
|
123
|
+
"strictPropertyInitialization": false,
|
124
|
+
"forceConsistentCasingInFileNames": true,
|
125
|
+
"experimentalDecorators": true /* Enable experimental support for legacy experimental decorators. */,
|
126
|
+
"emitDecoratorMetadata": true,
|
127
|
+
"esModuleInterop": true
|
128
|
+
},
|
129
|
+
"include": ["src/**/*"],
|
130
|
+
"exclude": ["node_modules", "**/*.test.ts"]
|
131
|
+
}
|