identity-admin 1.5.0 → 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 -337
- 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 -131
- 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,131 +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
|
-
interface
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
interface
|
|
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
}
|