itrm-tools 1.3.16-beta.9 → 1.3.17
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/api/alegra/AlegraConnectionManager.d.ts +30 -30
- package/dist/api/request/crud/CrudManager.d.ts +11 -11
- package/dist/api/request/crud/CrudServiceManager.d.ts +28 -28
- package/dist/api/request/crud/CrudServiceManager.js +98 -98
- package/dist/api/request/crud/CrudServiceManager.js.map +1 -1
- package/dist/api/request/crud/common/ActivityHistoryManager.d.ts +38 -38
- package/dist/api/request/crud/common/ActivityHistoryManager.js +68 -68
- package/dist/api/request/crud/common/ApplicationManager.d.ts +37 -37
- package/dist/api/request/crud/common/ApplicationManager.js +56 -56
- package/dist/api/request/crud/common/AvailablePlatformManager.d.ts +38 -38
- package/dist/api/request/crud/common/AvailablePlatformManager.js +68 -68
- package/dist/api/request/crud/common/ComponentManager.d.ts +48 -51
- package/dist/api/request/crud/common/ComponentManager.js +62 -62
- package/dist/api/request/crud/common/ComponentManager.js.map +1 -1
- package/dist/api/request/crud/common/KeyManager.d.ts +41 -41
- package/dist/api/request/crud/common/KeyManager.js +69 -69
- package/dist/api/request/crud/common/PlatformManager.d.ts +41 -44
- package/dist/api/request/crud/common/PlatformManager.js +59 -59
- package/dist/api/request/crud/common/PlatformManager.js.map +1 -1
- package/dist/api/request/crud/common/RoleManager.d.ts +40 -41
- package/dist/api/request/crud/common/RoleManager.js +56 -56
- package/dist/api/request/crud/common/RoleManager.js.map +1 -1
- package/dist/api/request/crud/common/StatusManager.d.ts +32 -32
- package/dist/api/request/crud/common/StatusManager.js +56 -56
- package/dist/api/request/crud/common/TypeManager.d.ts +32 -32
- package/dist/api/request/crud/common/TypeManager.js +56 -56
- package/dist/api/request/crud/common/UserCredentialsManager.d.ts +37 -37
- package/dist/api/request/crud/common/UserCredentialsManager.js +66 -66
- package/dist/api/request/crud/common/UserManager.d.ts +38 -38
- package/dist/api/request/crud/common/UserManager.js +62 -62
- package/dist/api/utils/Response.d.ts +25 -25
- package/dist/api/utils/Response.js +85 -85
- package/dist/cryptography/jwt/JwtUtils.d.ts +18 -18
- package/dist/cryptography/jwt/JwtUtils.js +36 -36
- package/dist/cryptography/password/PasswordUtils.d.ts +6 -6
- package/dist/cryptography/password/PasswordUtils.js +34 -34
- package/dist/index.d.ts +62 -63
- package/dist/index.js +126 -128
- package/dist/index.js.map +1 -1
- package/dist/types/api.d.ts +21 -21
- package/dist/types/api.js +2 -2
- package/package.json +1 -1
- package/dist/api/request/crud/common/ServiceSessionManager.d.ts +0 -24
- package/dist/api/request/crud/common/ServiceSessionManager.js +0 -109
- package/dist/api/request/crud/common/ServiceSessionManager.js.map +0 -1
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UserCredentialsManager = void 0;
|
|
4
|
-
const CrudServiceManager_1 = require("../CrudServiceManager");
|
|
5
|
-
class UserCredentialsManager extends CrudServiceManager_1.CrudServiceManager {
|
|
6
|
-
url;
|
|
7
|
-
constructor(url) {
|
|
8
|
-
super();
|
|
9
|
-
this.url = url;
|
|
10
|
-
}
|
|
11
|
-
find(details) {
|
|
12
|
-
return this.sendFinding(`${this.url}/userCredentials?email=${details.email}`, details.config);
|
|
13
|
-
}
|
|
14
|
-
findById(details) {
|
|
15
|
-
return this.sendFinding(`${this.url}/userCredentials?id=${details.id}`, details.config);
|
|
16
|
-
}
|
|
17
|
-
async count(details) {
|
|
18
|
-
let url = this.buildRequestUrl(`${this.url}/userCredentials`, details);
|
|
19
|
-
return (await this.sendCounting(url, details.config)) ?? 0;
|
|
20
|
-
}
|
|
21
|
-
async findAll(details) {
|
|
22
|
-
let users = [];
|
|
23
|
-
let url = this.buildRequestUrl(`${this.url}/userCredentials`, details);
|
|
24
|
-
if (details.limit) {
|
|
25
|
-
users = (await this.sendAllFinding(`${url}${url.indexOf('?') !== -1 ? '&' : '?'}limit=${details.limit}&offset=${details.offset}`, details.config)) ?? [];
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
let limit = 5000, offset = 0, isEmpty = false;
|
|
29
|
-
do {
|
|
30
|
-
let values = await this.sendAllFinding(`${url}${url.indexOf('?') !== -1 ? '&' : '?'}limit=${limit}&offset=${offset}`, details.config);
|
|
31
|
-
if (values)
|
|
32
|
-
users = users.concat(values);
|
|
33
|
-
isEmpty = values == undefined || values.length == 0;
|
|
34
|
-
offset += limit;
|
|
35
|
-
} while (!isEmpty);
|
|
36
|
-
}
|
|
37
|
-
return users;
|
|
38
|
-
}
|
|
39
|
-
buildRequestUrl(url, details) {
|
|
40
|
-
let suffix = `${details.id ? `&id=${details.id}` : ""}${details.email ? `&email=${details.email}` : ""}`;
|
|
41
|
-
return `${url}?${suffix.substring(1)}`;
|
|
42
|
-
}
|
|
43
|
-
create(details) {
|
|
44
|
-
return this.sendCreation(`${this.url}/userCredentials`, {
|
|
45
|
-
userName: details.userName,
|
|
46
|
-
password: details.password,
|
|
47
|
-
email: details.email,
|
|
48
|
-
metadata: details.metadata
|
|
49
|
-
}, details.config);
|
|
50
|
-
}
|
|
51
|
-
createMany(details) {
|
|
52
|
-
return this.sendCreationMany(`${this.url}/userCredentials`, details.values ?? [], details.config);
|
|
53
|
-
}
|
|
54
|
-
modify(user) {
|
|
55
|
-
return this.sendModification(`${this.url}/userCredentials/${user.userCredentialId}`, {
|
|
56
|
-
userName: user.userName,
|
|
57
|
-
password: user.password,
|
|
58
|
-
email: user.email,
|
|
59
|
-
metadata: user.metadata
|
|
60
|
-
}, user.config);
|
|
61
|
-
}
|
|
62
|
-
destroy(user) {
|
|
63
|
-
return this.sendDestruction(`${this.url}/userCredentials/${user.userCredentialId}`, user.config);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.UserCredentialsManager = UserCredentialsManager;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserCredentialsManager = void 0;
|
|
4
|
+
const CrudServiceManager_1 = require("../CrudServiceManager");
|
|
5
|
+
class UserCredentialsManager extends CrudServiceManager_1.CrudServiceManager {
|
|
6
|
+
url;
|
|
7
|
+
constructor(url) {
|
|
8
|
+
super();
|
|
9
|
+
this.url = url;
|
|
10
|
+
}
|
|
11
|
+
find(details) {
|
|
12
|
+
return this.sendFinding(`${this.url}/userCredentials?email=${details.email}`, details.config);
|
|
13
|
+
}
|
|
14
|
+
findById(details) {
|
|
15
|
+
return this.sendFinding(`${this.url}/userCredentials?id=${details.id}`, details.config);
|
|
16
|
+
}
|
|
17
|
+
async count(details) {
|
|
18
|
+
let url = this.buildRequestUrl(`${this.url}/userCredentials`, details);
|
|
19
|
+
return (await this.sendCounting(url, details.config)) ?? 0;
|
|
20
|
+
}
|
|
21
|
+
async findAll(details) {
|
|
22
|
+
let users = [];
|
|
23
|
+
let url = this.buildRequestUrl(`${this.url}/userCredentials`, details);
|
|
24
|
+
if (details.limit) {
|
|
25
|
+
users = (await this.sendAllFinding(`${url}${url.indexOf('?') !== -1 ? '&' : '?'}limit=${details.limit}&offset=${details.offset}`, details.config)) ?? [];
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
let limit = 5000, offset = 0, isEmpty = false;
|
|
29
|
+
do {
|
|
30
|
+
let values = await this.sendAllFinding(`${url}${url.indexOf('?') !== -1 ? '&' : '?'}limit=${limit}&offset=${offset}`, details.config);
|
|
31
|
+
if (values)
|
|
32
|
+
users = users.concat(values);
|
|
33
|
+
isEmpty = values == undefined || values.length == 0;
|
|
34
|
+
offset += limit;
|
|
35
|
+
} while (!isEmpty);
|
|
36
|
+
}
|
|
37
|
+
return users;
|
|
38
|
+
}
|
|
39
|
+
buildRequestUrl(url, details) {
|
|
40
|
+
let suffix = `${details.id ? `&id=${details.id}` : ""}${details.email ? `&email=${details.email}` : ""}`;
|
|
41
|
+
return `${url}?${suffix.substring(1)}`;
|
|
42
|
+
}
|
|
43
|
+
create(details) {
|
|
44
|
+
return this.sendCreation(`${this.url}/userCredentials`, {
|
|
45
|
+
userName: details.userName,
|
|
46
|
+
password: details.password,
|
|
47
|
+
email: details.email,
|
|
48
|
+
metadata: details.metadata
|
|
49
|
+
}, details.config);
|
|
50
|
+
}
|
|
51
|
+
createMany(details) {
|
|
52
|
+
return this.sendCreationMany(`${this.url}/userCredentials`, details.values ?? [], details.config);
|
|
53
|
+
}
|
|
54
|
+
modify(user) {
|
|
55
|
+
return this.sendModification(`${this.url}/userCredentials/${user.userCredentialId}`, {
|
|
56
|
+
userName: user.userName,
|
|
57
|
+
password: user.password,
|
|
58
|
+
email: user.email,
|
|
59
|
+
metadata: user.metadata
|
|
60
|
+
}, user.config);
|
|
61
|
+
}
|
|
62
|
+
destroy(user) {
|
|
63
|
+
return this.sendDestruction(`${this.url}/userCredentials/${user.userCredentialId}`, user.config);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.UserCredentialsManager = UserCredentialsManager;
|
|
67
67
|
//# sourceMappingURL=UserCredentialsManager.js.map
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { AxiosRequestConfig } from "axios";
|
|
2
|
-
import { CrudServiceManager, StandardIdRequestDefinition } from "../CrudServiceManager";
|
|
3
|
-
import { IStatus } from "./StatusManager";
|
|
4
|
-
import { IUserCredentials } from "./UserCredentialsManager";
|
|
5
|
-
export interface IUser {
|
|
6
|
-
userId?: string;
|
|
7
|
-
statusId?: number;
|
|
8
|
-
credentialsId?: number;
|
|
9
|
-
updatedAt?: string;
|
|
10
|
-
createdAt?: string;
|
|
11
|
-
status?: IStatus;
|
|
12
|
-
userCredentials?: IUserCredentials;
|
|
13
|
-
config?: AxiosRequestConfig;
|
|
14
|
-
}
|
|
15
|
-
export interface IUserSearchDetails {
|
|
16
|
-
id?: string;
|
|
17
|
-
credentials?: boolean;
|
|
18
|
-
userId?: string;
|
|
19
|
-
statusId?: number;
|
|
20
|
-
credentialsId?: number;
|
|
21
|
-
values?: IUser[];
|
|
22
|
-
limit?: number;
|
|
23
|
-
offset?: number;
|
|
24
|
-
config?: AxiosRequestConfig;
|
|
25
|
-
}
|
|
26
|
-
export declare class UserManager extends CrudServiceManager<IUserSearchDetails, IUser> {
|
|
27
|
-
private readonly url;
|
|
28
|
-
constructor(url: string);
|
|
29
|
-
find(details: IUserSearchDetails): Promise<IUser | undefined>;
|
|
30
|
-
findById(details: StandardIdRequestDefinition): Promise<IUser | undefined>;
|
|
31
|
-
count(details: IUserSearchDetails): Promise<number>;
|
|
32
|
-
findAll(details: IUserSearchDetails): Promise<IUser[] | undefined>;
|
|
33
|
-
private buildRequestUrl;
|
|
34
|
-
create(details: IUserSearchDetails): Promise<IUser | undefined>;
|
|
35
|
-
createMany(details: IUserSearchDetails): Promise<IUser[] | undefined>;
|
|
36
|
-
modify(user: IUser): Promise<IUser | undefined>;
|
|
37
|
-
destroy(user: IUser): Promise<number | void>;
|
|
38
|
-
}
|
|
1
|
+
import { AxiosRequestConfig } from "axios";
|
|
2
|
+
import { CrudServiceManager, StandardIdRequestDefinition } from "../CrudServiceManager";
|
|
3
|
+
import { IStatus } from "./StatusManager";
|
|
4
|
+
import { IUserCredentials } from "./UserCredentialsManager";
|
|
5
|
+
export interface IUser {
|
|
6
|
+
userId?: string;
|
|
7
|
+
statusId?: number;
|
|
8
|
+
credentialsId?: number;
|
|
9
|
+
updatedAt?: string;
|
|
10
|
+
createdAt?: string;
|
|
11
|
+
status?: IStatus;
|
|
12
|
+
userCredentials?: IUserCredentials;
|
|
13
|
+
config?: AxiosRequestConfig;
|
|
14
|
+
}
|
|
15
|
+
export interface IUserSearchDetails {
|
|
16
|
+
id?: string;
|
|
17
|
+
credentials?: boolean;
|
|
18
|
+
userId?: string;
|
|
19
|
+
statusId?: number;
|
|
20
|
+
credentialsId?: number;
|
|
21
|
+
values?: IUser[];
|
|
22
|
+
limit?: number;
|
|
23
|
+
offset?: number;
|
|
24
|
+
config?: AxiosRequestConfig;
|
|
25
|
+
}
|
|
26
|
+
export declare class UserManager extends CrudServiceManager<IUserSearchDetails, IUser> {
|
|
27
|
+
private readonly url;
|
|
28
|
+
constructor(url: string);
|
|
29
|
+
find(details: IUserSearchDetails): Promise<IUser | undefined>;
|
|
30
|
+
findById(details: StandardIdRequestDefinition): Promise<IUser | undefined>;
|
|
31
|
+
count(details: IUserSearchDetails): Promise<number>;
|
|
32
|
+
findAll(details: IUserSearchDetails): Promise<IUser[] | undefined>;
|
|
33
|
+
private buildRequestUrl;
|
|
34
|
+
create(details: IUserSearchDetails): Promise<IUser | undefined>;
|
|
35
|
+
createMany(details: IUserSearchDetails): Promise<IUser[] | undefined>;
|
|
36
|
+
modify(user: IUser): Promise<IUser | undefined>;
|
|
37
|
+
destroy(user: IUser): Promise<number | void>;
|
|
38
|
+
}
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UserManager = void 0;
|
|
4
|
-
const CrudServiceManager_1 = require("../CrudServiceManager");
|
|
5
|
-
class UserManager extends CrudServiceManager_1.CrudServiceManager {
|
|
6
|
-
url;
|
|
7
|
-
constructor(url) {
|
|
8
|
-
super();
|
|
9
|
-
this.url = url;
|
|
10
|
-
}
|
|
11
|
-
find(details) {
|
|
12
|
-
return this.sendFinding(`${this.url}/users?credentialsId=${details.credentialsId}`, details.config);
|
|
13
|
-
}
|
|
14
|
-
findById(details) {
|
|
15
|
-
return this.sendFinding(`${this.url}/users?id=${details.id}`, details.config);
|
|
16
|
-
}
|
|
17
|
-
async count(details) {
|
|
18
|
-
let url = this.buildRequestUrl(`${this.url}/users`, details);
|
|
19
|
-
return (await this.sendCounting(url, details.config)) ?? 0;
|
|
20
|
-
}
|
|
21
|
-
async findAll(details) {
|
|
22
|
-
let users = [];
|
|
23
|
-
let url = this.buildRequestUrl(`${this.url}/users`, details);
|
|
24
|
-
if (details.limit) {
|
|
25
|
-
users = (await this.sendAllFinding(`${url}${url.indexOf('?') !== -1 ? '&' : '?'}limit=${details.limit}&offset=${details.offset}`, details.config)) ?? [];
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
let limit = 5000, offset = 0, isEmpty = false;
|
|
29
|
-
do {
|
|
30
|
-
let values = await this.sendAllFinding(`${url}${url.indexOf('?') !== -1 ? '&' : '?'}limit=${limit}&offset=${offset}`, details.config);
|
|
31
|
-
if (values)
|
|
32
|
-
users = users.concat(values);
|
|
33
|
-
isEmpty = values == undefined || values.length == 0;
|
|
34
|
-
offset += limit;
|
|
35
|
-
} while (!isEmpty);
|
|
36
|
-
}
|
|
37
|
-
return users;
|
|
38
|
-
}
|
|
39
|
-
buildRequestUrl(url, details) {
|
|
40
|
-
let suffix = `${details.id ? `&id=${details.id}` : ""}${details.credentials ? `&credentials=${details.credentials}` : ""}${details.credentialsId ? `&credentialsId=${details.credentialsId}` : ""}`;
|
|
41
|
-
return `${url}?${suffix.substring(1)}`;
|
|
42
|
-
}
|
|
43
|
-
create(details) {
|
|
44
|
-
return this.sendCreation(`${this.url}/users`, {
|
|
45
|
-
statusId: details.statusId,
|
|
46
|
-
credentialsId: details.credentialsId
|
|
47
|
-
}, details.config);
|
|
48
|
-
}
|
|
49
|
-
createMany(details) {
|
|
50
|
-
return this.sendCreationMany(`${this.url}/users`, details.values ?? [], details.config);
|
|
51
|
-
}
|
|
52
|
-
modify(user) {
|
|
53
|
-
return this.sendModification(`${this.url}/users/${user.userId}`, {
|
|
54
|
-
statusId: user.statusId,
|
|
55
|
-
credentialsId: user.credentialsId
|
|
56
|
-
}, user.config);
|
|
57
|
-
}
|
|
58
|
-
destroy(user) {
|
|
59
|
-
return this.sendDestruction(`${this.url}/users/${user.userId}`, user.config);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
exports.UserManager = UserManager;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserManager = void 0;
|
|
4
|
+
const CrudServiceManager_1 = require("../CrudServiceManager");
|
|
5
|
+
class UserManager extends CrudServiceManager_1.CrudServiceManager {
|
|
6
|
+
url;
|
|
7
|
+
constructor(url) {
|
|
8
|
+
super();
|
|
9
|
+
this.url = url;
|
|
10
|
+
}
|
|
11
|
+
find(details) {
|
|
12
|
+
return this.sendFinding(`${this.url}/users?credentialsId=${details.credentialsId}`, details.config);
|
|
13
|
+
}
|
|
14
|
+
findById(details) {
|
|
15
|
+
return this.sendFinding(`${this.url}/users?id=${details.id}`, details.config);
|
|
16
|
+
}
|
|
17
|
+
async count(details) {
|
|
18
|
+
let url = this.buildRequestUrl(`${this.url}/users`, details);
|
|
19
|
+
return (await this.sendCounting(url, details.config)) ?? 0;
|
|
20
|
+
}
|
|
21
|
+
async findAll(details) {
|
|
22
|
+
let users = [];
|
|
23
|
+
let url = this.buildRequestUrl(`${this.url}/users`, details);
|
|
24
|
+
if (details.limit) {
|
|
25
|
+
users = (await this.sendAllFinding(`${url}${url.indexOf('?') !== -1 ? '&' : '?'}limit=${details.limit}&offset=${details.offset}`, details.config)) ?? [];
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
let limit = 5000, offset = 0, isEmpty = false;
|
|
29
|
+
do {
|
|
30
|
+
let values = await this.sendAllFinding(`${url}${url.indexOf('?') !== -1 ? '&' : '?'}limit=${limit}&offset=${offset}`, details.config);
|
|
31
|
+
if (values)
|
|
32
|
+
users = users.concat(values);
|
|
33
|
+
isEmpty = values == undefined || values.length == 0;
|
|
34
|
+
offset += limit;
|
|
35
|
+
} while (!isEmpty);
|
|
36
|
+
}
|
|
37
|
+
return users;
|
|
38
|
+
}
|
|
39
|
+
buildRequestUrl(url, details) {
|
|
40
|
+
let suffix = `${details.id ? `&id=${details.id}` : ""}${details.credentials ? `&credentials=${details.credentials}` : ""}${details.credentialsId ? `&credentialsId=${details.credentialsId}` : ""}`;
|
|
41
|
+
return `${url}?${suffix.substring(1)}`;
|
|
42
|
+
}
|
|
43
|
+
create(details) {
|
|
44
|
+
return this.sendCreation(`${this.url}/users`, {
|
|
45
|
+
statusId: details.statusId,
|
|
46
|
+
credentialsId: details.credentialsId
|
|
47
|
+
}, details.config);
|
|
48
|
+
}
|
|
49
|
+
createMany(details) {
|
|
50
|
+
return this.sendCreationMany(`${this.url}/users`, details.values ?? [], details.config);
|
|
51
|
+
}
|
|
52
|
+
modify(user) {
|
|
53
|
+
return this.sendModification(`${this.url}/users/${user.userId}`, {
|
|
54
|
+
statusId: user.statusId,
|
|
55
|
+
credentialsId: user.credentialsId
|
|
56
|
+
}, user.config);
|
|
57
|
+
}
|
|
58
|
+
destroy(user) {
|
|
59
|
+
return this.sendDestruction(`${this.url}/users/${user.userId}`, user.config);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.UserManager = UserManager;
|
|
63
63
|
//# sourceMappingURL=UserManager.js.map
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { ApiResponse, PaginationMeta } from "../../types/api";
|
|
2
|
-
export declare class ApiServiceError extends Error {
|
|
3
|
-
readonly httpStatus: number;
|
|
4
|
-
readonly code: string;
|
|
5
|
-
readonly details?: any | undefined;
|
|
6
|
-
constructor(httpStatus: number, code: string, message: string, details?: any | undefined);
|
|
7
|
-
}
|
|
8
|
-
export declare class ResponseUtils {
|
|
9
|
-
static success<T = null>(payload: T, message?: string, meta?: Partial<ApiResponse['meta']>): ApiResponse<T>;
|
|
10
|
-
static error(apiError: ApiServiceError, meta?: Partial<ApiResponse['meta']>): ApiResponse<null>;
|
|
11
|
-
static paginated<T>(payload: T[], pagination: PaginationMeta, message?: string): ApiResponse<T[]>;
|
|
12
|
-
}
|
|
13
|
-
export declare function mapErrorCodeToHttpStatus(code: string): number;
|
|
14
|
-
export declare enum HttpCode {
|
|
15
|
-
OK = 200,
|
|
16
|
-
CREATED = 201,
|
|
17
|
-
NO_CONTENT = 204,
|
|
18
|
-
BAD_REQUEST = 400,
|
|
19
|
-
UNAUTHORIZED = 401,
|
|
20
|
-
FORBIDDEN = 403,
|
|
21
|
-
NOT_FOUND = 404,
|
|
22
|
-
CONFLICT = 409,
|
|
23
|
-
INTERNAL_SERVER_ERROR = 500,
|
|
24
|
-
SERVICE_UNAVAILABLE = 503
|
|
25
|
-
}
|
|
1
|
+
import { ApiResponse, PaginationMeta } from "../../types/api";
|
|
2
|
+
export declare class ApiServiceError extends Error {
|
|
3
|
+
readonly httpStatus: number;
|
|
4
|
+
readonly code: string;
|
|
5
|
+
readonly details?: any | undefined;
|
|
6
|
+
constructor(httpStatus: number, code: string, message: string, details?: any | undefined);
|
|
7
|
+
}
|
|
8
|
+
export declare class ResponseUtils {
|
|
9
|
+
static success<T = null>(payload: T, message?: string, meta?: Partial<ApiResponse['meta']>): ApiResponse<T>;
|
|
10
|
+
static error(apiError: ApiServiceError, meta?: Partial<ApiResponse['meta']>): ApiResponse<null>;
|
|
11
|
+
static paginated<T>(payload: T[], pagination: PaginationMeta, message?: string): ApiResponse<T[]>;
|
|
12
|
+
}
|
|
13
|
+
export declare function mapErrorCodeToHttpStatus(code: string): number;
|
|
14
|
+
export declare enum HttpCode {
|
|
15
|
+
OK = 200,
|
|
16
|
+
CREATED = 201,
|
|
17
|
+
NO_CONTENT = 204,
|
|
18
|
+
BAD_REQUEST = 400,
|
|
19
|
+
UNAUTHORIZED = 401,
|
|
20
|
+
FORBIDDEN = 403,
|
|
21
|
+
NOT_FOUND = 404,
|
|
22
|
+
CONFLICT = 409,
|
|
23
|
+
INTERNAL_SERVER_ERROR = 500,
|
|
24
|
+
SERVICE_UNAVAILABLE = 503
|
|
25
|
+
}
|
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpCode = exports.ResponseUtils = exports.ApiServiceError = void 0;
|
|
4
|
-
exports.mapErrorCodeToHttpStatus = mapErrorCodeToHttpStatus;
|
|
5
|
-
class ApiServiceError extends Error {
|
|
6
|
-
httpStatus;
|
|
7
|
-
code;
|
|
8
|
-
details;
|
|
9
|
-
constructor(httpStatus, code, message, details) {
|
|
10
|
-
super(message);
|
|
11
|
-
this.httpStatus = httpStatus;
|
|
12
|
-
this.code = code;
|
|
13
|
-
this.details = details;
|
|
14
|
-
// Maintains proper stack trace
|
|
15
|
-
Object.setPrototypeOf(this, ApiServiceError.prototype);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.ApiServiceError = ApiServiceError;
|
|
19
|
-
class ResponseUtils {
|
|
20
|
-
static success(payload, message, meta) {
|
|
21
|
-
return {
|
|
22
|
-
success: true,
|
|
23
|
-
payload,
|
|
24
|
-
message,
|
|
25
|
-
meta: {
|
|
26
|
-
timestamp: new Date().toISOString(),
|
|
27
|
-
...meta,
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
static error(apiError, meta) {
|
|
32
|
-
return {
|
|
33
|
-
success: false,
|
|
34
|
-
payload: null,
|
|
35
|
-
error: {
|
|
36
|
-
code: apiError.code,
|
|
37
|
-
message: apiError.message,
|
|
38
|
-
details: apiError.details,
|
|
39
|
-
},
|
|
40
|
-
meta: {
|
|
41
|
-
timestamp: new Date().toISOString(),
|
|
42
|
-
...meta,
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
static paginated(payload, pagination, message) {
|
|
47
|
-
return {
|
|
48
|
-
success: true,
|
|
49
|
-
payload,
|
|
50
|
-
message,
|
|
51
|
-
meta: {
|
|
52
|
-
timestamp: new Date().toISOString(),
|
|
53
|
-
pagination,
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.ResponseUtils = ResponseUtils;
|
|
59
|
-
function mapErrorCodeToHttpStatus(code) {
|
|
60
|
-
switch (code) {
|
|
61
|
-
case 'NOT_FOUND':
|
|
62
|
-
return HttpCode.NOT_FOUND;
|
|
63
|
-
case 'UNAUTHORIZED':
|
|
64
|
-
return HttpCode.UNAUTHORIZED;
|
|
65
|
-
case 'INTERNAL_SERVER_ERROR':
|
|
66
|
-
return HttpCode.INTERNAL_SERVER_ERROR;
|
|
67
|
-
case 'FORBIDDEN':
|
|
68
|
-
return HttpCode.FORBIDDEN;
|
|
69
|
-
default:
|
|
70
|
-
return HttpCode.BAD_REQUEST;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
var HttpCode;
|
|
74
|
-
(function (HttpCode) {
|
|
75
|
-
HttpCode[HttpCode["OK"] = 200] = "OK";
|
|
76
|
-
HttpCode[HttpCode["CREATED"] = 201] = "CREATED";
|
|
77
|
-
HttpCode[HttpCode["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
78
|
-
HttpCode[HttpCode["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
79
|
-
HttpCode[HttpCode["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
80
|
-
HttpCode[HttpCode["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
81
|
-
HttpCode[HttpCode["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
82
|
-
HttpCode[HttpCode["CONFLICT"] = 409] = "CONFLICT";
|
|
83
|
-
HttpCode[HttpCode["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
84
|
-
HttpCode[HttpCode["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
85
|
-
})(HttpCode || (exports.HttpCode = HttpCode = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpCode = exports.ResponseUtils = exports.ApiServiceError = void 0;
|
|
4
|
+
exports.mapErrorCodeToHttpStatus = mapErrorCodeToHttpStatus;
|
|
5
|
+
class ApiServiceError extends Error {
|
|
6
|
+
httpStatus;
|
|
7
|
+
code;
|
|
8
|
+
details;
|
|
9
|
+
constructor(httpStatus, code, message, details) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.httpStatus = httpStatus;
|
|
12
|
+
this.code = code;
|
|
13
|
+
this.details = details;
|
|
14
|
+
// Maintains proper stack trace
|
|
15
|
+
Object.setPrototypeOf(this, ApiServiceError.prototype);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.ApiServiceError = ApiServiceError;
|
|
19
|
+
class ResponseUtils {
|
|
20
|
+
static success(payload, message, meta) {
|
|
21
|
+
return {
|
|
22
|
+
success: true,
|
|
23
|
+
payload,
|
|
24
|
+
message,
|
|
25
|
+
meta: {
|
|
26
|
+
timestamp: new Date().toISOString(),
|
|
27
|
+
...meta,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
static error(apiError, meta) {
|
|
32
|
+
return {
|
|
33
|
+
success: false,
|
|
34
|
+
payload: null,
|
|
35
|
+
error: {
|
|
36
|
+
code: apiError.code,
|
|
37
|
+
message: apiError.message,
|
|
38
|
+
details: apiError.details,
|
|
39
|
+
},
|
|
40
|
+
meta: {
|
|
41
|
+
timestamp: new Date().toISOString(),
|
|
42
|
+
...meta,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
static paginated(payload, pagination, message) {
|
|
47
|
+
return {
|
|
48
|
+
success: true,
|
|
49
|
+
payload,
|
|
50
|
+
message,
|
|
51
|
+
meta: {
|
|
52
|
+
timestamp: new Date().toISOString(),
|
|
53
|
+
pagination,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.ResponseUtils = ResponseUtils;
|
|
59
|
+
function mapErrorCodeToHttpStatus(code) {
|
|
60
|
+
switch (code) {
|
|
61
|
+
case 'NOT_FOUND':
|
|
62
|
+
return HttpCode.NOT_FOUND;
|
|
63
|
+
case 'UNAUTHORIZED':
|
|
64
|
+
return HttpCode.UNAUTHORIZED;
|
|
65
|
+
case 'INTERNAL_SERVER_ERROR':
|
|
66
|
+
return HttpCode.INTERNAL_SERVER_ERROR;
|
|
67
|
+
case 'FORBIDDEN':
|
|
68
|
+
return HttpCode.FORBIDDEN;
|
|
69
|
+
default:
|
|
70
|
+
return HttpCode.BAD_REQUEST;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
var HttpCode;
|
|
74
|
+
(function (HttpCode) {
|
|
75
|
+
HttpCode[HttpCode["OK"] = 200] = "OK";
|
|
76
|
+
HttpCode[HttpCode["CREATED"] = 201] = "CREATED";
|
|
77
|
+
HttpCode[HttpCode["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
78
|
+
HttpCode[HttpCode["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
79
|
+
HttpCode[HttpCode["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
80
|
+
HttpCode[HttpCode["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
81
|
+
HttpCode[HttpCode["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
82
|
+
HttpCode[HttpCode["CONFLICT"] = 409] = "CONFLICT";
|
|
83
|
+
HttpCode[HttpCode["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
84
|
+
HttpCode[HttpCode["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
85
|
+
})(HttpCode || (exports.HttpCode = HttpCode = {}));
|
|
86
86
|
//# sourceMappingURL=Response.js.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { JWTPayload } from 'jose';
|
|
2
|
-
export interface CustomJWTPayload extends JWTPayload {
|
|
3
|
-
userId: string;
|
|
4
|
-
rolesByPlatform: Record<string, string>;
|
|
5
|
-
status: string;
|
|
6
|
-
application: string;
|
|
7
|
-
metadata?: Record<string, boolean>;
|
|
8
|
-
}
|
|
9
|
-
export interface JwtConfig {
|
|
10
|
-
algorithm?: string;
|
|
11
|
-
expirationTime?: number;
|
|
12
|
-
}
|
|
13
|
-
export declare class JwtUtils {
|
|
14
|
-
private readonly config;
|
|
15
|
-
constructor(config: JwtConfig);
|
|
16
|
-
sign(payload: CustomJWTPayload, secretKey: string): Promise<string | undefined>;
|
|
17
|
-
verify(token: string, secretKey: string): Promise<CustomJWTPayload | undefined>;
|
|
18
|
-
}
|
|
1
|
+
import { JWTPayload } from 'jose';
|
|
2
|
+
export interface CustomJWTPayload extends JWTPayload {
|
|
3
|
+
userId: string;
|
|
4
|
+
rolesByPlatform: Record<string, string>;
|
|
5
|
+
status: string;
|
|
6
|
+
application: string;
|
|
7
|
+
metadata?: Record<string, boolean>;
|
|
8
|
+
}
|
|
9
|
+
export interface JwtConfig {
|
|
10
|
+
algorithm?: string;
|
|
11
|
+
expirationTime?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class JwtUtils {
|
|
14
|
+
private readonly config;
|
|
15
|
+
constructor(config: JwtConfig);
|
|
16
|
+
sign(payload: CustomJWTPayload, secretKey: string): Promise<string | undefined>;
|
|
17
|
+
verify(token: string, secretKey: string): Promise<CustomJWTPayload | undefined>;
|
|
18
|
+
}
|