identity-admin 1.4.4 → 1.6.0
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/README.md +126 -126
- package/lib/Dashboard.d.ts +14 -14
- package/lib/Dashboard.js +95 -88
- package/lib/container/helpers/HelperInversify.d.ts +6 -6
- package/lib/container/helpers/HelperInversify.js +10 -10
- package/lib/container/helpers/HelperTypes.d.ts +5 -5
- package/lib/container/helpers/HelperTypes.js +7 -7
- package/lib/container/index.d.ts +1 -1
- package/lib/container/index.js +14 -14
- package/lib/container/repositories/RepositoryInversify.d.ts +4 -4
- package/lib/container/repositories/RepositoryInversify.js +13 -13
- package/lib/container/repositories/RepositoryTypes.d.ts +4 -4
- package/lib/container/repositories/RepositoryTypes.js +6 -6
- package/lib/container/types.d.ts +8 -8
- package/lib/container/types.js +9 -9
- package/lib/controllers/ActionController.d.ts +8 -8
- package/lib/controllers/ActionController.js +79 -79
- package/lib/controllers/DashboardController.d.ts +36 -36
- package/lib/controllers/DashboardController.js +349 -335
- package/lib/controllers/ResourceController.d.ts +11 -9
- package/lib/controllers/ResourceController.js +109 -104
- package/lib/helpers/ActionsGenerator.d.ts +9 -9
- package/lib/helpers/ActionsGenerator.js +101 -77
- package/lib/helpers/FiltersHelper.d.ts +7 -0
- package/lib/helpers/FiltersHelper.js +64 -0
- package/lib/helpers/LocalesHelper.d.ts +4 -4
- package/lib/helpers/LocalesHelper.js +73 -73
- package/lib/helpers/ResourceGenerator.d.ts +4 -4
- package/lib/helpers/ResourceGenerator.js +110 -68
- package/lib/helpers/ResourceHelper.d.ts +23 -22
- package/lib/helpers/ResourceHelper.js +305 -286
- package/lib/helpers/SchemaGenerator.d.ts +5 -5
- package/lib/helpers/SchemaGenerator.js +92 -87
- package/lib/helpers/SchemaHelper.d.ts +5 -5
- package/lib/helpers/SchemaHelper.js +21 -21
- package/lib/locales/ar.json +1 -0
- package/lib/locales/en.json +50 -10
- package/lib/middlewares/isAuth.d.ts +13 -13
- package/lib/middlewares/isAuth.js +43 -43
- package/lib/models/ModelNames.d.ts +4 -4
- package/lib/models/ModelNames.js +7 -7
- package/lib/models/request-log/IRequestLog.d.ts +22 -22
- package/lib/models/request-log/IRequestLog.js +2 -2
- package/lib/models/request-log/RequestLog.d.ts +3 -3
- package/lib/models/request-log/RequestLog.js +51 -51
- package/lib/repositories/DashboardRepository.d.ts +5 -5
- package/lib/repositories/DashboardRepository.js +12 -12
- package/lib/repositories/Repository.d.ts +68 -68
- package/lib/repositories/Repository.js +212 -212
- package/lib/repositories/RequestLogRepository.d.ts +10 -10
- package/lib/repositories/RequestLogRepository.js +54 -54
- package/lib/repositories/SaveResult.d.ts +14 -14
- package/lib/repositories/SaveResult.js +18 -18
- package/lib/router/index.d.ts +8 -8
- package/lib/router/index.js +97 -97
- package/lib/types/DashbordConfig.d.ts +21 -19
- package/lib/types/DashbordConfig.js +2 -2
- package/lib/types/IConfigurationFile.d.ts +5 -0
- package/lib/types/IConfigurationFile.js +2 -0
- package/lib/types/IResourceFile.d.ts +145 -125
- package/lib/types/IResourceFile.js +2 -2
- package/lib/types/helpers.d.ts +28 -15
- package/lib/types/helpers.js +35 -21
- package/lib/utils/ResourceUtils.d.ts +2 -2
- package/lib/utils/ResourceUtils.js +7 -7
- package/lib/utils/ResponseUtils.d.ts +10 -10
- package/lib/utils/ResponseUtils.js +38 -38
- package/lib/utils/StringUtils.d.ts +9 -9
- package/lib/utils/StringUtils.js +46 -46
- package/lib/view/asset-manifest.json +13 -13
- package/lib/view/assets/icons/delete_icon.svg +3 -3
- package/lib/view/assets/icons/flags/ic_flag_cn.svg +9 -9
- package/lib/view/assets/icons/flags/ic_flag_sa.svg +9 -9
- package/lib/view/assets/icons/flags/ic_flag_vn.svg +9 -9
- package/lib/view/assets/icons/info_icon.svg +3 -3
- package/lib/view/assets/icons/navbar/ic_banking.svg +5 -5
- package/lib/view/assets/icons/navbar/ic_invoice.svg +4 -4
- package/lib/view/assets/icons/navbar/ic_kanban.svg +7 -7
- package/lib/view/assets/icons/navbar/ic_menu_item.svg +8 -8
- package/lib/view/assets/icons/small_info_icon.svg +3 -3
- package/lib/view/assets/illustrations/Group 16.svg +4 -4
- package/lib/view/assets/illustrations/logo.svg +5 -5
- package/lib/view/favicon/browserconfig.xml +9 -9
- package/lib/view/favicon/safari-pinned-tab.svg +182 -182
- package/lib/view/favicon/site.webmanifest +19 -19
- package/lib/view/fonts/index.css +18 -18
- package/lib/view/index.html +1 -1
- package/lib/view/manifest.json +20 -20
- package/lib/view/robots.txt +3 -3
- package/lib/view/static/js/{148.b6f24fc9.chunk.js → 148.b05fe2c8.chunk.js} +1 -1
- package/lib/view/static/js/{705.b2b55cc3.chunk.js → 705.f86db82e.chunk.js} +1 -1
- package/lib/view/static/js/802.3f287a2c.chunk.js +1 -0
- package/lib/view/static/js/main.da8f09ec.js +2 -0
- package/lib/view/static/js/{main.bc5ec798.js.LICENSE.txt → main.da8f09ec.js.LICENSE.txt} +225 -223
- package/package.json +51 -51
- package/lib/view/static/js/939.f35326c5.chunk.js +0 -1
- package/lib/view/static/js/main.bc5ec798.js +0 -2
|
@@ -1,125 +1,145 @@
|
|
|
1
|
-
import { Request } from "express";
|
|
2
|
-
import { Document, Model } from "mongoose";
|
|
3
|
-
import { ActionTypes, Virtuals } from "./helpers";
|
|
4
|
-
declare type orderTypes = 'asc' | 'desc';
|
|
5
|
-
declare type VirtualFieldTypes = 'password' | 'ref' | 'Array';
|
|
6
|
-
declare type Severity = 'success' | 'info' | 'warning' | 'error';
|
|
7
|
-
interface
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
interface
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
1
|
+
import { Request } from "express";
|
|
2
|
+
import { Document, Model } from "mongoose";
|
|
3
|
+
import { ActionTypes, Virtuals } from "./helpers";
|
|
4
|
+
declare type orderTypes = 'asc' | 'desc';
|
|
5
|
+
declare type VirtualFieldTypes = 'password' | 'ref' | 'Array';
|
|
6
|
+
declare type Severity = 'success' | 'info' | 'warning' | 'error';
|
|
7
|
+
interface IAutoScope {
|
|
8
|
+
key: string;
|
|
9
|
+
options: string[];
|
|
10
|
+
}
|
|
11
|
+
interface IManualScope {
|
|
12
|
+
options: string[];
|
|
13
|
+
handler: (filter: {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}, scope: string) => {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
interface Parent {
|
|
20
|
+
name: string;
|
|
21
|
+
icon: string;
|
|
22
|
+
}
|
|
23
|
+
interface Action {
|
|
24
|
+
isAccessible?: boolean;
|
|
25
|
+
}
|
|
26
|
+
interface ICrudOperations {
|
|
27
|
+
index?: {
|
|
28
|
+
before: (filter: {
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
}, currentUser: Document) => {
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
create?: {
|
|
35
|
+
before: (params: any, currentUser: Document) => any;
|
|
36
|
+
};
|
|
37
|
+
show?: {
|
|
38
|
+
after: (record: Document) => Promise<{
|
|
39
|
+
record: Document;
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
}>;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export interface ActionData {
|
|
45
|
+
record: any;
|
|
46
|
+
currentUser: Document;
|
|
47
|
+
resource: {
|
|
48
|
+
name: string;
|
|
49
|
+
path: string;
|
|
50
|
+
repository: any;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
interface IFilters {
|
|
54
|
+
scopes?: {
|
|
55
|
+
isAccessible: boolean;
|
|
56
|
+
auto?: IAutoScope;
|
|
57
|
+
manual?: IManualScope;
|
|
58
|
+
};
|
|
59
|
+
searchBar?: {
|
|
60
|
+
isAccessible: boolean;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export interface IFieldValue {
|
|
64
|
+
required?: boolean;
|
|
65
|
+
isEditable?: boolean;
|
|
66
|
+
type?: string;
|
|
67
|
+
mediaUploader?: boolean;
|
|
68
|
+
}
|
|
69
|
+
export interface IVirtualValue {
|
|
70
|
+
type: VirtualFieldTypes;
|
|
71
|
+
arrayType?: string;
|
|
72
|
+
showIn: Virtuals;
|
|
73
|
+
required: boolean;
|
|
74
|
+
resource?: Model<any, any>;
|
|
75
|
+
}
|
|
76
|
+
interface IModel {
|
|
77
|
+
virtuals?: {
|
|
78
|
+
[key: string]: IVirtualValue;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
interface ActionOptions {
|
|
82
|
+
show?: Action;
|
|
83
|
+
new?: Action;
|
|
84
|
+
edit?: Action;
|
|
85
|
+
delete?: Action;
|
|
86
|
+
bulkDelete?: Action;
|
|
87
|
+
extras?: ExtraAction[];
|
|
88
|
+
}
|
|
89
|
+
interface ExtraAction {
|
|
90
|
+
key: string;
|
|
91
|
+
name: string;
|
|
92
|
+
/**
|
|
93
|
+
* Icon of this action.
|
|
94
|
+
* @reference 'https://mui.com/material-ui/material-icons/'
|
|
95
|
+
*/
|
|
96
|
+
icon: string;
|
|
97
|
+
actionType: ActionTypes;
|
|
98
|
+
/**
|
|
99
|
+
* Guard message that appears before executing the action to confirm execution.
|
|
100
|
+
* @default 'No guard message'
|
|
101
|
+
*/
|
|
102
|
+
guard?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Alert message appear after executing this action.
|
|
105
|
+
* @default 'Action was executed successfully'
|
|
106
|
+
*/
|
|
107
|
+
message?: string;
|
|
108
|
+
/**
|
|
109
|
+
* The severity of the alert. This defines the color and icon used.
|
|
110
|
+
* @default 'success'
|
|
111
|
+
*/
|
|
112
|
+
severity?: Severity;
|
|
113
|
+
isVisible?: (data: ActionData) => boolean;
|
|
114
|
+
handler: (req: Request, res: any, data: ActionData) => Promise<any>;
|
|
115
|
+
}
|
|
116
|
+
export interface IResourceFile {
|
|
117
|
+
properties: {
|
|
118
|
+
resource: Model<any, any>;
|
|
119
|
+
modelName: string;
|
|
120
|
+
name?: string;
|
|
121
|
+
title?: string;
|
|
122
|
+
defaultOrderBy?: string;
|
|
123
|
+
defaultrowsPerPage?: number;
|
|
124
|
+
defaultOrder?: orderTypes;
|
|
125
|
+
parent?: Parent;
|
|
126
|
+
hiddenProperties?: string[];
|
|
127
|
+
actions?: ActionOptions;
|
|
128
|
+
filters?: IFilters;
|
|
129
|
+
crudOperations?: ICrudOperations;
|
|
130
|
+
keysTranslations?: {
|
|
131
|
+
[key: string]: any;
|
|
132
|
+
};
|
|
133
|
+
actionsTranslations?: {
|
|
134
|
+
[key: string]: any;
|
|
135
|
+
};
|
|
136
|
+
model?: {
|
|
137
|
+
[key: string]: IFieldValue;
|
|
138
|
+
} | IModel;
|
|
139
|
+
};
|
|
140
|
+
listProperties?: string[];
|
|
141
|
+
showProperties?: string[];
|
|
142
|
+
formProperties?: string[];
|
|
143
|
+
filterProperties?: string[];
|
|
144
|
+
}
|
|
145
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/lib/types/helpers.d.ts
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
|
-
export declare enum Virtuals {
|
|
2
|
-
SHOW = "SHOW",
|
|
3
|
-
LIST = "LIST",
|
|
4
|
-
FORM = "FORM"
|
|
5
|
-
}
|
|
6
|
-
export declare enum ActionNames {
|
|
7
|
-
SHOW = "SHOW",
|
|
8
|
-
LIST = "LIST",
|
|
9
|
-
NEW = "NEW",
|
|
10
|
-
EDIT = "EDIT"
|
|
11
|
-
}
|
|
12
|
-
export declare enum ActionTypes {
|
|
13
|
-
RECORD = "record",
|
|
14
|
-
Resource = "resource"
|
|
15
|
-
}
|
|
1
|
+
export declare enum Virtuals {
|
|
2
|
+
SHOW = "SHOW",
|
|
3
|
+
LIST = "LIST",
|
|
4
|
+
FORM = "FORM"
|
|
5
|
+
}
|
|
6
|
+
export declare enum ActionNames {
|
|
7
|
+
SHOW = "SHOW",
|
|
8
|
+
LIST = "LIST",
|
|
9
|
+
NEW = "NEW",
|
|
10
|
+
EDIT = "EDIT"
|
|
11
|
+
}
|
|
12
|
+
export declare enum ActionTypes {
|
|
13
|
+
RECORD = "record",
|
|
14
|
+
Resource = "resource"
|
|
15
|
+
}
|
|
16
|
+
export declare enum FieldTypes {
|
|
17
|
+
STRING = "String",
|
|
18
|
+
NUMBER = "Number",
|
|
19
|
+
ENUM = "enum",
|
|
20
|
+
REFERENCE = "ref",
|
|
21
|
+
DATE = "Date",
|
|
22
|
+
PASSWORD = "password",
|
|
23
|
+
BOOLEAN = "Boolean",
|
|
24
|
+
OBJECTID = "ObjectID",
|
|
25
|
+
NESTEDSCHEMA = "nestedSchema",
|
|
26
|
+
ARRAY = "Array",
|
|
27
|
+
IMAGE = "image"
|
|
28
|
+
}
|
package/lib/types/helpers.js
CHANGED
|
@@ -1,21 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ActionTypes = exports.ActionNames = exports.Virtuals = void 0;
|
|
4
|
-
var Virtuals;
|
|
5
|
-
(function (Virtuals) {
|
|
6
|
-
Virtuals["SHOW"] = "SHOW";
|
|
7
|
-
Virtuals["LIST"] = "LIST";
|
|
8
|
-
Virtuals["FORM"] = "FORM";
|
|
9
|
-
})(Virtuals = exports.Virtuals || (exports.Virtuals = {}));
|
|
10
|
-
var ActionNames;
|
|
11
|
-
(function (ActionNames) {
|
|
12
|
-
ActionNames["SHOW"] = "SHOW";
|
|
13
|
-
ActionNames["LIST"] = "LIST";
|
|
14
|
-
ActionNames["NEW"] = "NEW";
|
|
15
|
-
ActionNames["EDIT"] = "EDIT";
|
|
16
|
-
})(ActionNames = exports.ActionNames || (exports.ActionNames = {}));
|
|
17
|
-
var ActionTypes;
|
|
18
|
-
(function (ActionTypes) {
|
|
19
|
-
ActionTypes["RECORD"] = "record";
|
|
20
|
-
ActionTypes["Resource"] = "resource";
|
|
21
|
-
})(ActionTypes = exports.ActionTypes || (exports.ActionTypes = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FieldTypes = exports.ActionTypes = exports.ActionNames = exports.Virtuals = void 0;
|
|
4
|
+
var Virtuals;
|
|
5
|
+
(function (Virtuals) {
|
|
6
|
+
Virtuals["SHOW"] = "SHOW";
|
|
7
|
+
Virtuals["LIST"] = "LIST";
|
|
8
|
+
Virtuals["FORM"] = "FORM";
|
|
9
|
+
})(Virtuals = exports.Virtuals || (exports.Virtuals = {}));
|
|
10
|
+
var ActionNames;
|
|
11
|
+
(function (ActionNames) {
|
|
12
|
+
ActionNames["SHOW"] = "SHOW";
|
|
13
|
+
ActionNames["LIST"] = "LIST";
|
|
14
|
+
ActionNames["NEW"] = "NEW";
|
|
15
|
+
ActionNames["EDIT"] = "EDIT";
|
|
16
|
+
})(ActionNames = exports.ActionNames || (exports.ActionNames = {}));
|
|
17
|
+
var ActionTypes;
|
|
18
|
+
(function (ActionTypes) {
|
|
19
|
+
ActionTypes["RECORD"] = "record";
|
|
20
|
+
ActionTypes["Resource"] = "resource";
|
|
21
|
+
})(ActionTypes = exports.ActionTypes || (exports.ActionTypes = {}));
|
|
22
|
+
var FieldTypes;
|
|
23
|
+
(function (FieldTypes) {
|
|
24
|
+
FieldTypes["STRING"] = "String";
|
|
25
|
+
FieldTypes["NUMBER"] = "Number";
|
|
26
|
+
FieldTypes["ENUM"] = "enum";
|
|
27
|
+
FieldTypes["REFERENCE"] = "ref";
|
|
28
|
+
FieldTypes["DATE"] = "Date";
|
|
29
|
+
FieldTypes["PASSWORD"] = "password";
|
|
30
|
+
FieldTypes["BOOLEAN"] = "Boolean";
|
|
31
|
+
FieldTypes["OBJECTID"] = "ObjectID";
|
|
32
|
+
FieldTypes["NESTEDSCHEMA"] = "nestedSchema";
|
|
33
|
+
FieldTypes["ARRAY"] = "Array";
|
|
34
|
+
FieldTypes["IMAGE"] = "image";
|
|
35
|
+
})(FieldTypes = exports.FieldTypes || (exports.FieldTypes = {}));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { IResourceFile } from "../types/IResourceFile";
|
|
2
|
-
export declare const getResource: (modelName: string, resources: IResourceFile[]) => IResourceFile | undefined;
|
|
1
|
+
import { IResourceFile } from "../types/IResourceFile";
|
|
2
|
+
export declare const getResource: (modelName: string, resources: IResourceFile[]) => IResourceFile | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getResource = void 0;
|
|
4
|
-
const getResource = (modelName, resources) => {
|
|
5
|
-
return resources.find(resource => resource.properties.modelName === modelName);
|
|
6
|
-
};
|
|
7
|
-
exports.getResource = getResource;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getResource = void 0;
|
|
4
|
+
const getResource = (modelName, resources) => {
|
|
5
|
+
return resources.find(resource => resource.properties.modelName === modelName);
|
|
6
|
+
};
|
|
7
|
+
exports.getResource = getResource;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ISaveError } from '../repositories/SaveResult';
|
|
2
|
-
import { Response } from 'express';
|
|
3
|
-
export default class ResponseUtils {
|
|
4
|
-
static send(res: Response, status: number, message: string, data?: object, errors?: ISaveError[]): Response<any, Record<string, any>>;
|
|
5
|
-
static created(res: Response, data: object): void;
|
|
6
|
-
static ok(res: Response, data: object): void;
|
|
7
|
-
static unauthorized(res: Response): void;
|
|
8
|
-
static unprocessable(res: Response, message: string, errors: ISaveError[]): void;
|
|
9
|
-
static notFound(res: Response, message: string, errors: ISaveError[]): void;
|
|
10
|
-
}
|
|
1
|
+
import { ISaveError } from '../repositories/SaveResult';
|
|
2
|
+
import { Response } from 'express';
|
|
3
|
+
export default class ResponseUtils {
|
|
4
|
+
static send(res: Response, status: number, message: string, data?: object, errors?: ISaveError[]): Response<any, Record<string, any>>;
|
|
5
|
+
static created(res: Response, data: object): void;
|
|
6
|
+
static ok(res: Response, data: object): void;
|
|
7
|
+
static unauthorized(res: Response): void;
|
|
8
|
+
static unprocessable(res: Response, message: string, errors: ISaveError[]): void;
|
|
9
|
+
static notFound(res: Response, message: string, errors: ISaveError[]): void;
|
|
10
|
+
}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class ResponseUtils {
|
|
4
|
-
static send(res, status, message, data, errors) {
|
|
5
|
-
const splittedMessage = message.split(', ');
|
|
6
|
-
return res.format({
|
|
7
|
-
json: () => {
|
|
8
|
-
res.status(status).json({
|
|
9
|
-
meta: {
|
|
10
|
-
status,
|
|
11
|
-
message: res.__(splittedMessage[0], { attribute: splittedMessage[1] })
|
|
12
|
-
},
|
|
13
|
-
data,
|
|
14
|
-
errors
|
|
15
|
-
});
|
|
16
|
-
},
|
|
17
|
-
default: () => {
|
|
18
|
-
res.status(406).send();
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
static created(res, data) {
|
|
23
|
-
this.send(res, 201, 'Created', data);
|
|
24
|
-
}
|
|
25
|
-
static ok(res, data) {
|
|
26
|
-
this.send(res, 200, 'Ok', data);
|
|
27
|
-
}
|
|
28
|
-
static unauthorized(res) {
|
|
29
|
-
this.send(res, 401, 'Unauthenticated');
|
|
30
|
-
}
|
|
31
|
-
static unprocessable(res, message, errors) {
|
|
32
|
-
this.send(res, 422, message, {}, errors);
|
|
33
|
-
}
|
|
34
|
-
static notFound(res, message, errors) {
|
|
35
|
-
this.send(res, 404, message, {}, errors);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.default = ResponseUtils;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class ResponseUtils {
|
|
4
|
+
static send(res, status, message, data, errors) {
|
|
5
|
+
const splittedMessage = message.split(', ');
|
|
6
|
+
return res.format({
|
|
7
|
+
json: () => {
|
|
8
|
+
res.status(status).json({
|
|
9
|
+
meta: {
|
|
10
|
+
status,
|
|
11
|
+
message: res.__(splittedMessage[0], { attribute: splittedMessage[1] })
|
|
12
|
+
},
|
|
13
|
+
data,
|
|
14
|
+
errors
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
default: () => {
|
|
18
|
+
res.status(406).send();
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
static created(res, data) {
|
|
23
|
+
this.send(res, 201, 'Created', data);
|
|
24
|
+
}
|
|
25
|
+
static ok(res, data) {
|
|
26
|
+
this.send(res, 200, 'Ok', data);
|
|
27
|
+
}
|
|
28
|
+
static unauthorized(res) {
|
|
29
|
+
this.send(res, 401, 'Unauthenticated');
|
|
30
|
+
}
|
|
31
|
+
static unprocessable(res, message, errors) {
|
|
32
|
+
this.send(res, 422, message, {}, errors);
|
|
33
|
+
}
|
|
34
|
+
static notFound(res, message, errors) {
|
|
35
|
+
this.send(res, 404, message, {}, errors);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.default = ResponseUtils;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export default class StringUtils {
|
|
2
|
-
static convertCamelCaseToWord(camelCaseWord: string): string;
|
|
3
|
-
static checkRefId(word: string): boolean;
|
|
4
|
-
static lowerCaseFirstLetter(word: string): string;
|
|
5
|
-
static upperCaseFirstLetter(word: string): string;
|
|
6
|
-
static removeResourceWord(word: string): string;
|
|
7
|
-
static getRefPath(word: string): string;
|
|
8
|
-
static getPopulatedString(populatedString: string, addedString: string): string;
|
|
9
|
-
}
|
|
1
|
+
export default class StringUtils {
|
|
2
|
+
static convertCamelCaseToWord(camelCaseWord: string): string;
|
|
3
|
+
static checkRefId(word: string): boolean;
|
|
4
|
+
static lowerCaseFirstLetter(word: string): string;
|
|
5
|
+
static upperCaseFirstLetter(word: string): string;
|
|
6
|
+
static removeResourceWord(word: string): string;
|
|
7
|
+
static getRefPath(word: string): string;
|
|
8
|
+
static getPopulatedString(populatedString: string, addedString: string): string;
|
|
9
|
+
}
|
package/lib/utils/StringUtils.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var pluralize = require('pluralize');
|
|
4
|
-
class StringUtils {
|
|
5
|
-
static convertCamelCaseToWord(camelCaseWord) {
|
|
6
|
-
if (camelCaseWord === '_id') {
|
|
7
|
-
return 'Id';
|
|
8
|
-
}
|
|
9
|
-
var result = camelCaseWord.replace(/([A-Z])/g, " $1");
|
|
10
|
-
var word = result.charAt(0).toUpperCase() + result.slice(1);
|
|
11
|
-
if (word.charAt(0) === ' ') {
|
|
12
|
-
word = word.substring(1);
|
|
13
|
-
}
|
|
14
|
-
return word;
|
|
15
|
-
}
|
|
16
|
-
static checkRefId(word) {
|
|
17
|
-
const check = word.slice(-2) === 'Id';
|
|
18
|
-
return check;
|
|
19
|
-
}
|
|
20
|
-
static lowerCaseFirstLetter(word) {
|
|
21
|
-
return word.charAt(0).toLocaleLowerCase() + word.slice(1);
|
|
22
|
-
}
|
|
23
|
-
static upperCaseFirstLetter(word) {
|
|
24
|
-
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
25
|
-
}
|
|
26
|
-
static removeResourceWord(word) {
|
|
27
|
-
return this.lowerCaseFirstLetter(word.split('Resource')[0]);
|
|
28
|
-
}
|
|
29
|
-
static getRefPath(word) {
|
|
30
|
-
const check = word.slice(-2) === 'Id';
|
|
31
|
-
if (check) {
|
|
32
|
-
return word.slice(0, -2);
|
|
33
|
-
}
|
|
34
|
-
return this.lowerCaseFirstLetter(pluralize.singular(word));
|
|
35
|
-
}
|
|
36
|
-
static getPopulatedString(populatedString, addedString) {
|
|
37
|
-
if (populatedString.length === 0) {
|
|
38
|
-
populatedString = populatedString + addedString;
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
populatedString = populatedString + ' ' + addedString;
|
|
42
|
-
}
|
|
43
|
-
return populatedString;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.default = StringUtils;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var pluralize = require('pluralize');
|
|
4
|
+
class StringUtils {
|
|
5
|
+
static convertCamelCaseToWord(camelCaseWord) {
|
|
6
|
+
if (camelCaseWord === '_id') {
|
|
7
|
+
return 'Id';
|
|
8
|
+
}
|
|
9
|
+
var result = camelCaseWord.replace(/([A-Z])/g, " $1");
|
|
10
|
+
var word = result.charAt(0).toUpperCase() + result.slice(1);
|
|
11
|
+
if (word.charAt(0) === ' ') {
|
|
12
|
+
word = word.substring(1);
|
|
13
|
+
}
|
|
14
|
+
return word;
|
|
15
|
+
}
|
|
16
|
+
static checkRefId(word) {
|
|
17
|
+
const check = word.slice(-2) === 'Id';
|
|
18
|
+
return check;
|
|
19
|
+
}
|
|
20
|
+
static lowerCaseFirstLetter(word) {
|
|
21
|
+
return word.charAt(0).toLocaleLowerCase() + word.slice(1);
|
|
22
|
+
}
|
|
23
|
+
static upperCaseFirstLetter(word) {
|
|
24
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
25
|
+
}
|
|
26
|
+
static removeResourceWord(word) {
|
|
27
|
+
return this.lowerCaseFirstLetter(word.split('Resource')[0]);
|
|
28
|
+
}
|
|
29
|
+
static getRefPath(word) {
|
|
30
|
+
const check = word.slice(-2) === 'Id';
|
|
31
|
+
if (check) {
|
|
32
|
+
return word.slice(0, -2);
|
|
33
|
+
}
|
|
34
|
+
return this.lowerCaseFirstLetter(pluralize.singular(word));
|
|
35
|
+
}
|
|
36
|
+
static getPopulatedString(populatedString, addedString) {
|
|
37
|
+
if (populatedString.length === 0) {
|
|
38
|
+
populatedString = populatedString + addedString;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
populatedString = populatedString + ' ' + addedString;
|
|
42
|
+
}
|
|
43
|
+
return populatedString;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.default = StringUtils;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
{
|
|
2
|
-
"files": {
|
|
3
|
-
"main.css": "/static/css/main.18dca458.css",
|
|
4
|
-
"main.js": "/static/js/main.
|
|
5
|
-
"static/js/148.
|
|
6
|
-
"static/js/705.
|
|
7
|
-
"static/js/
|
|
8
|
-
"index.html": "/index.html"
|
|
9
|
-
},
|
|
10
|
-
"entrypoints": [
|
|
11
|
-
"static/css/main.18dca458.css",
|
|
12
|
-
"static/js/main.
|
|
13
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"files": {
|
|
3
|
+
"main.css": "/static/css/main.18dca458.css",
|
|
4
|
+
"main.js": "/static/js/main.da8f09ec.js",
|
|
5
|
+
"static/js/148.b05fe2c8.chunk.js": "/static/js/148.b05fe2c8.chunk.js",
|
|
6
|
+
"static/js/705.f86db82e.chunk.js": "/static/js/705.f86db82e.chunk.js",
|
|
7
|
+
"static/js/802.3f287a2c.chunk.js": "/static/js/802.3f287a2c.chunk.js",
|
|
8
|
+
"index.html": "/index.html"
|
|
9
|
+
},
|
|
10
|
+
"entrypoints": [
|
|
11
|
+
"static/css/main.18dca458.css",
|
|
12
|
+
"static/js/main.da8f09ec.js"
|
|
13
|
+
]
|
|
14
14
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M21 5.99991H16V4.32991C15.9765 3.68973 15.7002 3.08497 15.2316 2.64821C14.7629 2.21144 14.1402 1.97831 13.5 1.99991H10.5C9.85975 1.97831 9.23706 2.21144 8.76843 2.64821C8.2998 3.08497 8.02346 3.68973 8 4.32991V5.99991H3C2.73478 5.99991 2.48043 6.10527 2.29289 6.29281C2.10536 6.48034 2 6.7347 2 6.99991C2 7.26513 2.10536 7.51948 2.29289 7.70702C2.48043 7.89456 2.73478 7.99991 3 7.99991H4V18.9999C4 19.7956 4.31607 20.5586 4.87868 21.1212C5.44129 21.6838 6.20435 21.9999 7 21.9999H17C17.7956 21.9999 18.5587 21.6838 19.1213 21.1212C19.6839 20.5586 20 19.7956 20 18.9999V7.99991H21C21.2652 7.99991 21.5196 7.89456 21.7071 7.70702C21.8946 7.51948 22 7.26513 22 6.99991C22 6.7347 21.8946 6.48034 21.7071 6.29281C21.5196 6.10527 21.2652 5.99991 21 5.99991ZM10 4.32991C10 4.16991 10.21 3.99991 10.5 3.99991H13.5C13.79 3.99991 14 4.16991 14 4.32991V5.99991H10V4.32991ZM18 18.9999C18 19.2651 17.8946 19.5195 17.7071 19.707C17.5196 19.8946 17.2652 19.9999 17 19.9999H7C6.73478 19.9999 6.48043 19.8946 6.29289 19.707C6.10536 19.5195 6 19.2651 6 18.9999V7.99991H18V18.9999ZM9 16.9999C9.26522 16.9999 9.51957 16.8946 9.70711 16.707C9.89464 16.5195 10 16.2651 10 15.9999V11.9999C10 11.7347 9.89464 11.4803 9.70711 11.2928C9.51957 11.1053 9.26522 10.9999 9 10.9999C8.73478 10.9999 8.48043 11.1053 8.29289 11.2928C8.10536 11.4803 8 11.7347 8 11.9999V15.9999C8 16.2651 8.10536 16.5195 8.29289 16.707C8.48043 16.8946 8.73478 16.9999 9 16.9999ZM15.7071 16.707C15.5196 16.8946 15.2652 16.9999 15 16.9999C14.7348 16.9999 14.4804 16.8946 14.2929 16.707C14.1054 16.5195 14 16.2651 14 15.9999V11.9999C14 11.7347 14.1054 11.4803 14.2929 11.2928C14.4804 11.1053 14.7348 10.9999 15 10.9999C15.2652 10.9999 15.5196 11.1053 15.7071 11.2928C15.8946 11.4803 16 11.7347 16 11.9999V15.9999C16 16.2651 15.8946 16.5195 15.7071 16.707Z" fill="#BE1E2D"/>
|
|
3
|
-
</svg>
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M21 5.99991H16V4.32991C15.9765 3.68973 15.7002 3.08497 15.2316 2.64821C14.7629 2.21144 14.1402 1.97831 13.5 1.99991H10.5C9.85975 1.97831 9.23706 2.21144 8.76843 2.64821C8.2998 3.08497 8.02346 3.68973 8 4.32991V5.99991H3C2.73478 5.99991 2.48043 6.10527 2.29289 6.29281C2.10536 6.48034 2 6.7347 2 6.99991C2 7.26513 2.10536 7.51948 2.29289 7.70702C2.48043 7.89456 2.73478 7.99991 3 7.99991H4V18.9999C4 19.7956 4.31607 20.5586 4.87868 21.1212C5.44129 21.6838 6.20435 21.9999 7 21.9999H17C17.7956 21.9999 18.5587 21.6838 19.1213 21.1212C19.6839 20.5586 20 19.7956 20 18.9999V7.99991H21C21.2652 7.99991 21.5196 7.89456 21.7071 7.70702C21.8946 7.51948 22 7.26513 22 6.99991C22 6.7347 21.8946 6.48034 21.7071 6.29281C21.5196 6.10527 21.2652 5.99991 21 5.99991ZM10 4.32991C10 4.16991 10.21 3.99991 10.5 3.99991H13.5C13.79 3.99991 14 4.16991 14 4.32991V5.99991H10V4.32991ZM18 18.9999C18 19.2651 17.8946 19.5195 17.7071 19.707C17.5196 19.8946 17.2652 19.9999 17 19.9999H7C6.73478 19.9999 6.48043 19.8946 6.29289 19.707C6.10536 19.5195 6 19.2651 6 18.9999V7.99991H18V18.9999ZM9 16.9999C9.26522 16.9999 9.51957 16.8946 9.70711 16.707C9.89464 16.5195 10 16.2651 10 15.9999V11.9999C10 11.7347 9.89464 11.4803 9.70711 11.2928C9.51957 11.1053 9.26522 10.9999 9 10.9999C8.73478 10.9999 8.48043 11.1053 8.29289 11.2928C8.10536 11.4803 8 11.7347 8 11.9999V15.9999C8 16.2651 8.10536 16.5195 8.29289 16.707C8.48043 16.8946 8.73478 16.9999 9 16.9999ZM15.7071 16.707C15.5196 16.8946 15.2652 16.9999 15 16.9999C14.7348 16.9999 14.4804 16.8946 14.2929 16.707C14.1054 16.5195 14 16.2651 14 15.9999V11.9999C14 11.7347 14.1054 11.4803 14.2929 11.2928C14.4804 11.1053 14.7348 10.9999 15 10.9999C15.2652 10.9999 15.5196 11.1053 15.7071 11.2928C15.8946 11.4803 16 11.7347 16 11.9999V15.9999C16 16.2651 15.8946 16.5195 15.7071 16.707Z" fill="#BE1E2D"/>
|
|
3
|
+
</svg>
|