identity-admin 1.5.0 → 1.7.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 +37 -36
- package/lib/controllers/DashboardController.js +388 -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 +71 -0
- package/lib/helpers/LocalesHelper.d.ts +4 -4
- package/lib/helpers/LocalesHelper.js +73 -73
- package/lib/helpers/LocalizedStringHelper.d.ts +9 -0
- package/lib/helpers/LocalizedStringHelper.js +57 -0
- 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 +182 -131
- package/lib/types/IResourceFile.js +2 -2
- package/lib/types/helpers.d.ts +32 -15
- package/lib/types/helpers.js +39 -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,182 @@
|
|
|
1
|
-
import { Request } from "express";
|
|
2
|
-
import { Document, Model } from "mongoose";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
declare type
|
|
6
|
-
declare type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
1
|
+
import { Request } from "express";
|
|
2
|
+
import { Document, Model } from "mongoose";
|
|
3
|
+
import { IRequest } from "../middlewares/isAuth";
|
|
4
|
+
import { ActionTypes, FieldTypes, Virtuals } from "./helpers";
|
|
5
|
+
declare type orderTypes = 'asc' | 'desc';
|
|
6
|
+
declare type VirtualFieldTypes = 'password' | 'ref' | 'Array';
|
|
7
|
+
declare type Severity = 'success' | 'info' | 'warning' | 'error';
|
|
8
|
+
interface IAutoScope {
|
|
9
|
+
/**
|
|
10
|
+
* Key of property as specified in the database
|
|
11
|
+
*/
|
|
12
|
+
key: string;
|
|
13
|
+
/**
|
|
14
|
+
* Array of values that this key can have
|
|
15
|
+
*/
|
|
16
|
+
options: string[];
|
|
17
|
+
}
|
|
18
|
+
interface IManualScope {
|
|
19
|
+
/**
|
|
20
|
+
* Array of values that will be appeared in the scope
|
|
21
|
+
*/
|
|
22
|
+
options: string[];
|
|
23
|
+
/**
|
|
24
|
+
* A handler that will be called when scope filter is used. This handler should perform a switch case on the specified options values, each case set the filter on its way.
|
|
25
|
+
*/
|
|
26
|
+
handler: (filter: {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
}, scope: string) => {
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
interface Parent {
|
|
33
|
+
/**
|
|
34
|
+
* Name of the parent
|
|
35
|
+
*/
|
|
36
|
+
name: string;
|
|
37
|
+
/**
|
|
38
|
+
* Icon of the parent. You can get the icons from
|
|
39
|
+
* @link https://mui.com/material-ui/material-icons/
|
|
40
|
+
*/
|
|
41
|
+
icon: string;
|
|
42
|
+
}
|
|
43
|
+
interface Action {
|
|
44
|
+
/**
|
|
45
|
+
* Specify if this action is accessible or not.
|
|
46
|
+
* @default True is the default for show, edit, delete, and new while false for bulk delete. You can ovveride any of these values here.
|
|
47
|
+
*/
|
|
48
|
+
isAccessible?: boolean;
|
|
49
|
+
}
|
|
50
|
+
interface ICrudOperations {
|
|
51
|
+
index?: {
|
|
52
|
+
/**
|
|
53
|
+
* Before handler that gives you the access to the filter object. You can add to the filter object any key and value that will be used in the filter query before getting the records for list. You should return the filter object
|
|
54
|
+
*/
|
|
55
|
+
before: (req: IRequest, filter: {
|
|
56
|
+
[key: string]: any;
|
|
57
|
+
}, currentUser: Document) => {
|
|
58
|
+
[key: string]: any;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
create?: {
|
|
62
|
+
/**
|
|
63
|
+
* Before handler that is called before creating a new record. This function gives you the access to the record params before saving it, you can perform any update to the params before saving it. This function should return the params
|
|
64
|
+
*/
|
|
65
|
+
before: (req: IRequest, params: any, currentUser: Document) => any;
|
|
66
|
+
};
|
|
67
|
+
show?: {
|
|
68
|
+
after: (req: IRequest, record: Document) => Promise<{
|
|
69
|
+
record: Document;
|
|
70
|
+
[key: string]: any;
|
|
71
|
+
}>;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export interface ActionData {
|
|
75
|
+
record: any;
|
|
76
|
+
currentUser: Document;
|
|
77
|
+
resource: {
|
|
78
|
+
name: string;
|
|
79
|
+
path: string;
|
|
80
|
+
repository: any;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
interface IFilters {
|
|
84
|
+
scopes?: {
|
|
85
|
+
isAccessible: boolean;
|
|
86
|
+
auto?: IAutoScope;
|
|
87
|
+
manual?: IManualScope;
|
|
88
|
+
};
|
|
89
|
+
searchBar?: {
|
|
90
|
+
isAccessible: boolean;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export interface IFieldValue {
|
|
94
|
+
required?: boolean;
|
|
95
|
+
isEditable?: boolean;
|
|
96
|
+
type?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Specify the allowed country codes. Only mandatory if the type is phone number
|
|
99
|
+
* Alert message appear after executing this action.
|
|
100
|
+
* ex: ["sa", "eg", ...]
|
|
101
|
+
*/
|
|
102
|
+
countryCodes?: string[];
|
|
103
|
+
arrayType?: FieldTypes;
|
|
104
|
+
mediaUploader?: boolean;
|
|
105
|
+
}
|
|
106
|
+
export interface IVirtualValue {
|
|
107
|
+
type: VirtualFieldTypes;
|
|
108
|
+
arrayType?: string;
|
|
109
|
+
showIn: Virtuals;
|
|
110
|
+
required: boolean;
|
|
111
|
+
resource?: Model<any, any>;
|
|
112
|
+
}
|
|
113
|
+
interface IModel {
|
|
114
|
+
virtuals?: {
|
|
115
|
+
[key: string]: IVirtualValue;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
interface ActionOptions {
|
|
119
|
+
show?: Action;
|
|
120
|
+
new?: Action;
|
|
121
|
+
edit?: Action;
|
|
122
|
+
delete?: Action;
|
|
123
|
+
bulkDelete?: Action;
|
|
124
|
+
extras?: ExtraAction[];
|
|
125
|
+
}
|
|
126
|
+
interface ExtraAction {
|
|
127
|
+
key: string;
|
|
128
|
+
name: string;
|
|
129
|
+
/**
|
|
130
|
+
* Icon of this action.
|
|
131
|
+
* @reference 'https://mui.com/material-ui/material-icons/'
|
|
132
|
+
*/
|
|
133
|
+
icon: string;
|
|
134
|
+
actionType: ActionTypes;
|
|
135
|
+
/**
|
|
136
|
+
* Guard message that appears before executing the action to confirm execution.
|
|
137
|
+
* @default 'No guard message'
|
|
138
|
+
*/
|
|
139
|
+
guard?: string;
|
|
140
|
+
/**
|
|
141
|
+
* Alert message appear after executing this action.
|
|
142
|
+
* @default 'Action was executed successfully'
|
|
143
|
+
*/
|
|
144
|
+
message?: string;
|
|
145
|
+
/**
|
|
146
|
+
* The severity of the alert. This defines the color and icon used.
|
|
147
|
+
* @default 'success'
|
|
148
|
+
*/
|
|
149
|
+
severity?: Severity;
|
|
150
|
+
isVisible?: (data: ActionData) => boolean;
|
|
151
|
+
handler: (req: Request, res: any, data: ActionData) => Promise<any>;
|
|
152
|
+
}
|
|
153
|
+
export interface IResourceFile {
|
|
154
|
+
properties: {
|
|
155
|
+
resource: Model<any, any>;
|
|
156
|
+
modelName: string;
|
|
157
|
+
name?: string;
|
|
158
|
+
title?: string;
|
|
159
|
+
defaultOrderBy?: string;
|
|
160
|
+
defaultrowsPerPage?: number;
|
|
161
|
+
defaultOrder?: orderTypes;
|
|
162
|
+
parent?: Parent;
|
|
163
|
+
hiddenProperties?: string[];
|
|
164
|
+
actions?: ActionOptions;
|
|
165
|
+
filters?: IFilters;
|
|
166
|
+
crudOperations?: ICrudOperations;
|
|
167
|
+
keysTranslations?: {
|
|
168
|
+
[key: string]: any;
|
|
169
|
+
};
|
|
170
|
+
actionsTranslations?: {
|
|
171
|
+
[key: string]: any;
|
|
172
|
+
};
|
|
173
|
+
model?: {
|
|
174
|
+
[key: string]: IFieldValue;
|
|
175
|
+
} | IModel;
|
|
176
|
+
};
|
|
177
|
+
listProperties?: string[];
|
|
178
|
+
showProperties?: string[];
|
|
179
|
+
formProperties?: string[];
|
|
180
|
+
filterProperties?: string[];
|
|
181
|
+
}
|
|
182
|
+
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,32 @@
|
|
|
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
|
+
LOCALIZEDSTRING = "localizedString",
|
|
29
|
+
PHONENUMBER = "phoneNumber",
|
|
30
|
+
COLOR = "color",
|
|
31
|
+
TIMEPICKER = "timePicker"
|
|
32
|
+
}
|
package/lib/types/helpers.js
CHANGED
|
@@ -1,21 +1,39 @@
|
|
|
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["LOCALIZEDSTRING"] = "localizedString";
|
|
36
|
+
FieldTypes["PHONENUMBER"] = "phoneNumber";
|
|
37
|
+
FieldTypes["COLOR"] = "color";
|
|
38
|
+
FieldTypes["TIMEPICKER"] = "timePicker";
|
|
39
|
+
})(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;
|