identity-admin 1.28.2 → 1.28.5
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 +294 -294
- package/lib/Dashboard.d.ts +14 -14
- package/lib/Dashboard.js +95 -95
- 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 +96 -96
- package/lib/controllers/AdminNotificationController.d.ts +8 -8
- package/lib/controllers/AdminNotificationController.js +69 -69
- package/lib/controllers/DashboardController.d.ts +44 -44
- package/lib/controllers/DashboardController.js +787 -787
- package/lib/controllers/ResourceController.d.ts +15 -15
- package/lib/controllers/ResourceController.js +135 -135
- package/lib/helpers/ActionsGenerator.d.ts +11 -11
- package/lib/helpers/ActionsGenerator.js +179 -179
- package/lib/helpers/AdminNotifications/AdminNotificationCreation.d.ts +49 -49
- package/lib/helpers/AdminNotifications/AdminNotificationCreation.js +66 -66
- package/lib/helpers/AdminNotifications/AdminNotificationFetcher.d.ts +51 -51
- package/lib/helpers/AdminNotifications/AdminNotificationFetcher.js +39 -39
- package/lib/helpers/FilterQueryHelper.d.ts +9 -9
- package/lib/helpers/FilterQueryHelper.js +83 -83
- package/lib/helpers/FiltersHelper.d.ts +9 -9
- package/lib/helpers/FiltersHelper.js +126 -126
- package/lib/helpers/LocalesHelper.d.ts +4 -4
- package/lib/helpers/LocalesHelper.js +73 -73
- package/lib/helpers/LocalizedStringHelper.d.ts +11 -11
- package/lib/helpers/LocalizedStringHelper.js +74 -74
- package/lib/helpers/Permissions/PermissionFetcher.d.ts +8 -8
- package/lib/helpers/Permissions/PermissionFetcher.js +95 -95
- package/lib/helpers/Permissions/PermissionLabel.d.ts +2 -2
- package/lib/helpers/Permissions/PermissionLabel.js +42 -42
- package/lib/helpers/Permissions/PermissionMapper.d.ts +13 -13
- package/lib/helpers/Permissions/PermissionMapper.js +35 -35
- package/lib/helpers/Permissions/PermissionResource.d.ts +6 -6
- package/lib/helpers/Permissions/PermissionResource.js +62 -62
- package/lib/helpers/Permissions/PermissionSavingService.d.ts +13 -13
- package/lib/helpers/Permissions/PermissionSavingService.js +32 -32
- package/lib/helpers/Permissions/SavePermissionGroup.d.ts +6 -6
- package/lib/helpers/Permissions/SavePermissionGroup.js +32 -32
- package/lib/helpers/Permissions/UpdatePermissionGroup.d.ts +6 -6
- package/lib/helpers/Permissions/UpdatePermissionGroup.js +50 -50
- package/lib/helpers/Permissions/types.d.ts +17 -17
- package/lib/helpers/Permissions/types.js +2 -2
- package/lib/helpers/PopulationHelper.d.ts +12 -12
- package/lib/helpers/PopulationHelper.js +50 -50
- package/lib/helpers/RecordsCounter.d.ts +10 -10
- package/lib/helpers/RecordsCounter.js +33 -33
- package/lib/helpers/ReportsGenerator.d.ts +26 -26
- package/lib/helpers/ReportsGenerator.js +162 -162
- package/lib/helpers/ResourceGenerator.d.ts +9 -9
- package/lib/helpers/ResourceGenerator.js +172 -172
- package/lib/helpers/ResourceHelper.d.ts +28 -28
- package/lib/helpers/ResourceHelper.js +395 -395
- package/lib/helpers/RportsGenerator.d.ts +10 -10
- package/lib/helpers/RportsGenerator.js +21 -21
- package/lib/helpers/SchemaGenerator.d.ts +7 -7
- package/lib/helpers/SchemaGenerator.js +130 -130
- package/lib/helpers/SchemaHelper.d.ts +5 -5
- package/lib/helpers/SchemaHelper.js +21 -21
- package/lib/helpers/UserActionsLog/UserActionsLogHelper.d.ts +2 -2
- package/lib/helpers/UserActionsLog/UserActionsLogHelper.js +49 -49
- package/lib/locales/en.json +53 -53
- package/lib/middlewares/cache/decorator.d.ts +3 -3
- package/lib/middlewares/cache/decorator.js +60 -60
- package/lib/middlewares/cache/deletionMethods.d.ts +3 -3
- package/lib/middlewares/cache/deletionMethods.js +23 -23
- package/lib/middlewares/isAuth.d.ts +13 -13
- package/lib/middlewares/isAuth.js +43 -43
- package/lib/models/ModelNames.d.ts +9 -9
- package/lib/models/ModelNames.js +12 -12
- package/lib/models/adminNotification/AdminNotification.d.ts +5 -5
- package/lib/models/adminNotification/AdminNotification.js +53 -53
- package/lib/models/adminNotification/IAdminNotification.d.ts +30 -30
- package/lib/models/adminNotification/IAdminNotification.js +15 -15
- package/lib/models/adminpermission/AdminPermission.d.ts +11 -11
- package/lib/models/adminpermission/AdminPermission.js +23 -23
- package/lib/models/adminpermission/IAdminPermission.d.ts +13 -13
- package/lib/models/adminpermission/IAdminPermission.js +2 -2
- package/lib/models/customPage/CustomPage.d.ts +2 -2
- package/lib/models/customPage/CustomPage.js +38 -38
- package/lib/models/customPage/ICustomPage.d.ts +17 -17
- package/lib/models/customPage/ICustomPage.js +2 -2
- package/lib/models/file/File.d.ts +2 -2
- package/lib/models/file/File.js +23 -23
- package/lib/models/file/IFile.d.ts +15 -15
- package/lib/models/file/IFile.js +2 -2
- package/lib/models/location/ILocation.d.ts +14 -14
- package/lib/models/location/ILocation.js +2 -2
- package/lib/models/location/Location.d.ts +2 -2
- package/lib/models/location/Location.js +21 -21
- package/lib/models/modelConfiguration/IModelConfigurations.d.ts +29 -29
- package/lib/models/modelConfiguration/IModelConfigurations.js +2 -2
- package/lib/models/modelConfiguration/ModelConfiguration.d.ts +13 -13
- package/lib/models/modelConfiguration/ModelConfiguration.js +95 -95
- package/lib/models/permission/IPermission.d.ts +14 -14
- package/lib/models/permission/IPermission.js +2 -2
- package/lib/models/permission/Permission.d.ts +2 -2
- package/lib/models/permission/Permission.js +21 -21
- 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/models/userActionsLog/IUserActionsLog.d.ts +26 -26
- package/lib/models/userActionsLog/IUserActionsLog.js +11 -11
- package/lib/models/userActionsLog/UserActionsLog.d.ts +3 -3
- package/lib/models/userActionsLog/UserActionsLog.js +41 -41
- package/lib/pdf/ReportTemplate.d.ts +71 -71
- package/lib/pdf/ReportTemplate.js +94 -94
- package/lib/repositories/AdminNotificationRepository.d.ts +7 -7
- package/lib/repositories/AdminNotificationRepository.js +23 -23
- 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 +215 -215
- 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/resources/AdminNotificationsResource.d.ts +3 -3
- package/lib/resources/AdminNotificationsResource.js +23 -23
- package/lib/resources/parents.d.ts +4 -4
- package/lib/resources/parents.js +7 -7
- package/lib/router/index.d.ts +8 -8
- package/lib/router/index.js +104 -104
- package/lib/types/DashbordConfig.d.ts +21 -21
- package/lib/types/DashbordConfig.js +2 -2
- package/lib/types/IConfigurationFile.d.ts +11 -11
- package/lib/types/IConfigurationFile.js +2 -2
- package/lib/types/IResourceFile.d.ts +710 -701
- package/lib/types/IResourceFile.js +2 -2
- package/lib/types/IResourceResponse.d.ts +95 -95
- package/lib/types/IResourceResponse.js +2 -2
- package/lib/types/helpers.d.ts +66 -66
- package/lib/types/helpers.js +77 -77
- package/lib/utils/DateUtils.d.ts +7 -7
- package/lib/utils/DateUtils.js +45 -45
- package/lib/utils/ResourceUtils.d.ts +2 -2
- package/lib/utils/ResourceUtils.js +7 -7
- package/lib/utils/ResponseUtils.d.ts +11 -11
- package/lib/utils/ResponseUtils.js +41 -41
- package/lib/utils/StringUtils.d.ts +9 -9
- package/lib/utils/StringUtils.js +46 -46
- package/lib/view/asset-manifest.json +18 -18
- 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 +52 -52
- package/lib/view/manifest.json +20 -20
- package/lib/view/robots.txt +3 -3
- package/lib/view/static/css/main.54de06ef.css +1 -1
- package/lib/view/static/js/574.778b5963.chunk.js +1 -1
- package/lib/view/static/js/678.521704a3.chunk.js +1 -1
- package/lib/view/static/js/798.54856416.chunk.js +1 -1
- package/lib/view/static/js/main.4687f255.js +2 -2
- package/lib/view/static/js/main.4687f255.js.LICENSE.txt +214 -214
- package/package.json +63 -63
|
@@ -1,172 +1,172 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const StringUtils_1 = __importDefault(require("../utils/StringUtils"));
|
|
30
|
-
const i18n_1 = __importStar(require("i18n"));
|
|
31
|
-
const SchemaGenerator_1 = __importDefault(require("./SchemaGenerator"));
|
|
32
|
-
const ResourceHelper_1 = __importDefault(require("./ResourceHelper"));
|
|
33
|
-
const ActionsGenerator_1 = __importDefault(require("./ActionsGenerator"));
|
|
34
|
-
const SetupParent = {
|
|
35
|
-
name: "Setup",
|
|
36
|
-
icon: "PermDataSetting",
|
|
37
|
-
//value: __({phrase: "Setup", locale: i18n.getLocale()})
|
|
38
|
-
};
|
|
39
|
-
class ResourceGenerator {
|
|
40
|
-
static generate(resource, currentUser, configurations, modelConfigurations, permissions) {
|
|
41
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
42
|
-
const SetupParent = {
|
|
43
|
-
name: "Setup",
|
|
44
|
-
icon: "PermDataSetting",
|
|
45
|
-
value: (0, i18n_1.__)({ phrase: "Setup", locale: i18n_1.default.getLocale() }),
|
|
46
|
-
};
|
|
47
|
-
const modelName = resource.properties.modelName;
|
|
48
|
-
const modelConfiguration = modelConfigurations === null || modelConfigurations === void 0 ? void 0 : modelConfigurations.get(modelName);
|
|
49
|
-
const modifiedResource = JSON.parse(JSON.stringify(resource));
|
|
50
|
-
const schema = resource.properties.resource.schema.paths;
|
|
51
|
-
const title = ResourceHelper_1.default.getSchemaTitle(schema, resource, modelConfiguration);
|
|
52
|
-
const recordFields = ResourceHelper_1.default.manageFields(schema, title, resource.properties.hiddenProperties);
|
|
53
|
-
const modelCheck = resource.properties.model
|
|
54
|
-
? JSON.parse(JSON.stringify(resource.properties.model))
|
|
55
|
-
: undefined;
|
|
56
|
-
const actionsCheck = resource.properties.actions;
|
|
57
|
-
const modelAndPopulatedString = SchemaGenerator_1.default.generateSchema(schema, modelCheck, modelName, resource, configurations);
|
|
58
|
-
modifiedResource.properties.model = modelAndPopulatedString[0];
|
|
59
|
-
modifiedResource.properties.populatedString = modelAndPopulatedString[1];
|
|
60
|
-
const modifiedProperties = ResourceHelper_1.default.addVirtualFields(JSON.parse(JSON.stringify(recordFields)), modelCheck);
|
|
61
|
-
modifiedResource.properties.path = ResourceHelper_1.default.getModelPath(modelName);
|
|
62
|
-
const modifiedListProperties = modifiedProperties[0];
|
|
63
|
-
const modifiedShowProperties = modifiedProperties[1];
|
|
64
|
-
const modifiedFormProperties = modifiedProperties[2];
|
|
65
|
-
const modifiedFilterProperties = modifiedProperties[3];
|
|
66
|
-
if (!resource.properties.parent) {
|
|
67
|
-
modifiedResource.properties.parent = SetupParent;
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
modifiedResource.properties.parent = {
|
|
71
|
-
name: resource.properties.parent.name,
|
|
72
|
-
icon: resource.properties.parent.icon,
|
|
73
|
-
value: (0, i18n_1.__)({
|
|
74
|
-
phrase: resource.properties.parent.name,
|
|
75
|
-
locale: i18n_1.default.getLocale(),
|
|
76
|
-
}),
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
if (!resource.properties.name) {
|
|
80
|
-
modifiedResource.properties.name = (0, i18n_1.__)({
|
|
81
|
-
phrase: StringUtils_1.default.convertCamelCaseToWord(modelName),
|
|
82
|
-
locale: i18n_1.default.getLocale(),
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
modifiedResource.properties.name = (0, i18n_1.__)({
|
|
87
|
-
phrase: resource.properties.name,
|
|
88
|
-
locale: i18n_1.default.getLocale(),
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
if (!resource.showProperties) {
|
|
92
|
-
modifiedResource.showProperties =
|
|
93
|
-
modelConfiguration &&
|
|
94
|
-
modelConfiguration.showProperties &&
|
|
95
|
-
modelConfiguration.showProperties.length !== 0
|
|
96
|
-
? modelConfiguration.showProperties
|
|
97
|
-
: modifiedShowProperties;
|
|
98
|
-
}
|
|
99
|
-
if (!resource.filterProperties) {
|
|
100
|
-
modifiedResource.filterProperties =
|
|
101
|
-
modelConfiguration && modelConfiguration.filterProperties &&
|
|
102
|
-
modelConfiguration.filterProperties.length !== 0
|
|
103
|
-
? modelConfiguration.filterProperties
|
|
104
|
-
: modifiedFilterProperties;
|
|
105
|
-
}
|
|
106
|
-
if (!resource.quickFilterProperties) {
|
|
107
|
-
modifiedResource.quickFilterProperties =
|
|
108
|
-
modelConfiguration && modelConfiguration.quickFilterProperties &&
|
|
109
|
-
modelConfiguration.quickFilterProperties.length !== 0
|
|
110
|
-
? modelConfiguration.quickFilterProperties
|
|
111
|
-
: [];
|
|
112
|
-
}
|
|
113
|
-
if (!resource.listProperties) {
|
|
114
|
-
modifiedResource.listProperties =
|
|
115
|
-
modelConfiguration && modelConfiguration.listProperties &&
|
|
116
|
-
modelConfiguration.listProperties.length !== 0
|
|
117
|
-
? modelConfiguration.listProperties
|
|
118
|
-
: ResourceHelper_1.default.exchangeFirstFieldWithTitle(JSON.parse(JSON.stringify(modifiedListProperties)), title);
|
|
119
|
-
}
|
|
120
|
-
if (!resource.formProperties) {
|
|
121
|
-
modifiedResource.formProperties =
|
|
122
|
-
ResourceHelper_1.default.removeUnWantedFieldsFromCreateOrUpdate(JSON.parse(JSON.stringify(modifiedFormProperties)));
|
|
123
|
-
}
|
|
124
|
-
modifiedResource.properties.title = title;
|
|
125
|
-
if (!resource.properties.defaultOrderBy) {
|
|
126
|
-
modifiedResource.properties.defaultOrderBy =
|
|
127
|
-
modelConfiguration && modelConfiguration.defaultOrderBy
|
|
128
|
-
? modelConfiguration.defaultOrderBy
|
|
129
|
-
: title;
|
|
130
|
-
}
|
|
131
|
-
if (!resource.properties.defaultOrder) {
|
|
132
|
-
modifiedResource.properties.defaultOrder =
|
|
133
|
-
modelConfiguration && modelConfiguration.defaultOrder
|
|
134
|
-
? modelConfiguration.defaultOrder
|
|
135
|
-
: "asc";
|
|
136
|
-
}
|
|
137
|
-
if (!resource.properties.defaultrowsPerPage) {
|
|
138
|
-
modifiedResource.properties.defaultrowsPerPage =
|
|
139
|
-
modelConfiguration && modelConfiguration.defaultrowsPerPage
|
|
140
|
-
? +modelConfiguration.defaultrowsPerPage
|
|
141
|
-
: configurations && configurations.defaultRowsPerPage
|
|
142
|
-
? configurations.defaultRowsPerPage
|
|
143
|
-
: 10;
|
|
144
|
-
}
|
|
145
|
-
modifiedResource.listProperties = ResourceHelper_1.default.prepareProperties(resource.listProperties
|
|
146
|
-
? resource.listProperties
|
|
147
|
-
: modifiedResource.listProperties, modelName, modifiedResource.properties.model, resource);
|
|
148
|
-
modifiedResource.showProperties = ResourceHelper_1.default.prepareProperties(resource.showProperties
|
|
149
|
-
? resource.showProperties
|
|
150
|
-
: modifiedResource.showProperties, modelName, modifiedResource.properties.model, resource);
|
|
151
|
-
modifiedResource.filterProperties = ResourceHelper_1.default.prepareFilterProperties(modifiedResource.filterProperties, modifiedResource.properties.model);
|
|
152
|
-
modifiedResource.quickFilterProperties =
|
|
153
|
-
ResourceHelper_1.default.prepareFilterProperties(modifiedResource.quickFilterProperties, modifiedResource.properties.model);
|
|
154
|
-
modifiedResource.properties.filters = ResourceHelper_1.default.getFilters(resource.properties.filters
|
|
155
|
-
? JSON.parse(JSON.stringify(resource.properties.filters))
|
|
156
|
-
: undefined);
|
|
157
|
-
if (modifiedResource.properties.filters &&
|
|
158
|
-
modifiedResource.properties.filters.scopes &&
|
|
159
|
-
modifiedResource.properties.filters.scopes.isAccessible) {
|
|
160
|
-
const options = ((_b = (_a = resource.properties.filters) === null || _a === void 0 ? void 0 : _a.scopes) === null || _b === void 0 ? void 0 : _b.auto)
|
|
161
|
-
? (_d = (_c = resource.properties.filters) === null || _c === void 0 ? void 0 : _c.scopes) === null || _d === void 0 ? void 0 : _d.auto.options
|
|
162
|
-
: (_g = (_f = (_e = resource.properties.filters) === null || _e === void 0 ? void 0 : _e.scopes) === null || _f === void 0 ? void 0 : _f.manual) === null || _g === void 0 ? void 0 : _g.options;
|
|
163
|
-
modifiedResource.properties.filters.scopes.options =
|
|
164
|
-
ResourceHelper_1.default.setScopeFilterOptions(modelName, options, ((_j = (_h = resource.properties.filters) === null || _h === void 0 ? void 0 : _h.scopes) === null || _j === void 0 ? void 0 : _j.showAll) === undefined ? true : (_l = (_k = resource.properties.filters) === null || _k === void 0 ? void 0 : _k.scopes) === null || _l === void 0 ? void 0 : _l.showAll);
|
|
165
|
-
}
|
|
166
|
-
const actions = ActionsGenerator_1.default.generateActions(actionsCheck, resource, currentUser, modelConfiguration);
|
|
167
|
-
modifiedResource.properties.actions = actions;
|
|
168
|
-
modifiedResource.permissions = permissions;
|
|
169
|
-
return modifiedResource;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
exports.default = ResourceGenerator;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const StringUtils_1 = __importDefault(require("../utils/StringUtils"));
|
|
30
|
+
const i18n_1 = __importStar(require("i18n"));
|
|
31
|
+
const SchemaGenerator_1 = __importDefault(require("./SchemaGenerator"));
|
|
32
|
+
const ResourceHelper_1 = __importDefault(require("./ResourceHelper"));
|
|
33
|
+
const ActionsGenerator_1 = __importDefault(require("./ActionsGenerator"));
|
|
34
|
+
const SetupParent = {
|
|
35
|
+
name: "Setup",
|
|
36
|
+
icon: "PermDataSetting",
|
|
37
|
+
//value: __({phrase: "Setup", locale: i18n.getLocale()})
|
|
38
|
+
};
|
|
39
|
+
class ResourceGenerator {
|
|
40
|
+
static generate(resource, currentUser, configurations, modelConfigurations, permissions) {
|
|
41
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
42
|
+
const SetupParent = {
|
|
43
|
+
name: "Setup",
|
|
44
|
+
icon: "PermDataSetting",
|
|
45
|
+
value: (0, i18n_1.__)({ phrase: "Setup", locale: i18n_1.default.getLocale() }),
|
|
46
|
+
};
|
|
47
|
+
const modelName = resource.properties.modelName;
|
|
48
|
+
const modelConfiguration = modelConfigurations === null || modelConfigurations === void 0 ? void 0 : modelConfigurations.get(modelName);
|
|
49
|
+
const modifiedResource = JSON.parse(JSON.stringify(resource));
|
|
50
|
+
const schema = resource.properties.resource.schema.paths;
|
|
51
|
+
const title = ResourceHelper_1.default.getSchemaTitle(schema, resource, modelConfiguration);
|
|
52
|
+
const recordFields = ResourceHelper_1.default.manageFields(schema, title, resource.properties.hiddenProperties);
|
|
53
|
+
const modelCheck = resource.properties.model
|
|
54
|
+
? JSON.parse(JSON.stringify(resource.properties.model))
|
|
55
|
+
: undefined;
|
|
56
|
+
const actionsCheck = resource.properties.actions;
|
|
57
|
+
const modelAndPopulatedString = SchemaGenerator_1.default.generateSchema(schema, modelCheck, modelName, resource, configurations);
|
|
58
|
+
modifiedResource.properties.model = modelAndPopulatedString[0];
|
|
59
|
+
modifiedResource.properties.populatedString = modelAndPopulatedString[1];
|
|
60
|
+
const modifiedProperties = ResourceHelper_1.default.addVirtualFields(JSON.parse(JSON.stringify(recordFields)), modelCheck);
|
|
61
|
+
modifiedResource.properties.path = ResourceHelper_1.default.getModelPath(modelName);
|
|
62
|
+
const modifiedListProperties = modifiedProperties[0];
|
|
63
|
+
const modifiedShowProperties = modifiedProperties[1];
|
|
64
|
+
const modifiedFormProperties = modifiedProperties[2];
|
|
65
|
+
const modifiedFilterProperties = modifiedProperties[3];
|
|
66
|
+
if (!resource.properties.parent) {
|
|
67
|
+
modifiedResource.properties.parent = SetupParent;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
modifiedResource.properties.parent = {
|
|
71
|
+
name: resource.properties.parent.name,
|
|
72
|
+
icon: resource.properties.parent.icon,
|
|
73
|
+
value: (0, i18n_1.__)({
|
|
74
|
+
phrase: resource.properties.parent.name,
|
|
75
|
+
locale: i18n_1.default.getLocale(),
|
|
76
|
+
}),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (!resource.properties.name) {
|
|
80
|
+
modifiedResource.properties.name = (0, i18n_1.__)({
|
|
81
|
+
phrase: StringUtils_1.default.convertCamelCaseToWord(modelName),
|
|
82
|
+
locale: i18n_1.default.getLocale(),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
modifiedResource.properties.name = (0, i18n_1.__)({
|
|
87
|
+
phrase: resource.properties.name,
|
|
88
|
+
locale: i18n_1.default.getLocale(),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (!resource.showProperties) {
|
|
92
|
+
modifiedResource.showProperties =
|
|
93
|
+
modelConfiguration &&
|
|
94
|
+
modelConfiguration.showProperties &&
|
|
95
|
+
modelConfiguration.showProperties.length !== 0
|
|
96
|
+
? modelConfiguration.showProperties
|
|
97
|
+
: modifiedShowProperties;
|
|
98
|
+
}
|
|
99
|
+
if (!resource.filterProperties) {
|
|
100
|
+
modifiedResource.filterProperties =
|
|
101
|
+
modelConfiguration && modelConfiguration.filterProperties &&
|
|
102
|
+
modelConfiguration.filterProperties.length !== 0
|
|
103
|
+
? modelConfiguration.filterProperties
|
|
104
|
+
: modifiedFilterProperties;
|
|
105
|
+
}
|
|
106
|
+
if (!resource.quickFilterProperties) {
|
|
107
|
+
modifiedResource.quickFilterProperties =
|
|
108
|
+
modelConfiguration && modelConfiguration.quickFilterProperties &&
|
|
109
|
+
modelConfiguration.quickFilterProperties.length !== 0
|
|
110
|
+
? modelConfiguration.quickFilterProperties
|
|
111
|
+
: [];
|
|
112
|
+
}
|
|
113
|
+
if (!resource.listProperties) {
|
|
114
|
+
modifiedResource.listProperties =
|
|
115
|
+
modelConfiguration && modelConfiguration.listProperties &&
|
|
116
|
+
modelConfiguration.listProperties.length !== 0
|
|
117
|
+
? modelConfiguration.listProperties
|
|
118
|
+
: ResourceHelper_1.default.exchangeFirstFieldWithTitle(JSON.parse(JSON.stringify(modifiedListProperties)), title);
|
|
119
|
+
}
|
|
120
|
+
if (!resource.formProperties) {
|
|
121
|
+
modifiedResource.formProperties =
|
|
122
|
+
ResourceHelper_1.default.removeUnWantedFieldsFromCreateOrUpdate(JSON.parse(JSON.stringify(modifiedFormProperties)));
|
|
123
|
+
}
|
|
124
|
+
modifiedResource.properties.title = title;
|
|
125
|
+
if (!resource.properties.defaultOrderBy) {
|
|
126
|
+
modifiedResource.properties.defaultOrderBy =
|
|
127
|
+
modelConfiguration && modelConfiguration.defaultOrderBy
|
|
128
|
+
? modelConfiguration.defaultOrderBy
|
|
129
|
+
: title;
|
|
130
|
+
}
|
|
131
|
+
if (!resource.properties.defaultOrder) {
|
|
132
|
+
modifiedResource.properties.defaultOrder =
|
|
133
|
+
modelConfiguration && modelConfiguration.defaultOrder
|
|
134
|
+
? modelConfiguration.defaultOrder
|
|
135
|
+
: "asc";
|
|
136
|
+
}
|
|
137
|
+
if (!resource.properties.defaultrowsPerPage) {
|
|
138
|
+
modifiedResource.properties.defaultrowsPerPage =
|
|
139
|
+
modelConfiguration && modelConfiguration.defaultrowsPerPage
|
|
140
|
+
? +modelConfiguration.defaultrowsPerPage
|
|
141
|
+
: configurations && configurations.defaultRowsPerPage
|
|
142
|
+
? configurations.defaultRowsPerPage
|
|
143
|
+
: 10;
|
|
144
|
+
}
|
|
145
|
+
modifiedResource.listProperties = ResourceHelper_1.default.prepareProperties(resource.listProperties
|
|
146
|
+
? resource.listProperties
|
|
147
|
+
: modifiedResource.listProperties, modelName, modifiedResource.properties.model, resource);
|
|
148
|
+
modifiedResource.showProperties = ResourceHelper_1.default.prepareProperties(resource.showProperties
|
|
149
|
+
? resource.showProperties
|
|
150
|
+
: modifiedResource.showProperties, modelName, modifiedResource.properties.model, resource);
|
|
151
|
+
modifiedResource.filterProperties = ResourceHelper_1.default.prepareFilterProperties(modifiedResource.filterProperties, modifiedResource.properties.model);
|
|
152
|
+
modifiedResource.quickFilterProperties =
|
|
153
|
+
ResourceHelper_1.default.prepareFilterProperties(modifiedResource.quickFilterProperties, modifiedResource.properties.model);
|
|
154
|
+
modifiedResource.properties.filters = ResourceHelper_1.default.getFilters(resource.properties.filters
|
|
155
|
+
? JSON.parse(JSON.stringify(resource.properties.filters))
|
|
156
|
+
: undefined);
|
|
157
|
+
if (modifiedResource.properties.filters &&
|
|
158
|
+
modifiedResource.properties.filters.scopes &&
|
|
159
|
+
modifiedResource.properties.filters.scopes.isAccessible) {
|
|
160
|
+
const options = ((_b = (_a = resource.properties.filters) === null || _a === void 0 ? void 0 : _a.scopes) === null || _b === void 0 ? void 0 : _b.auto)
|
|
161
|
+
? (_d = (_c = resource.properties.filters) === null || _c === void 0 ? void 0 : _c.scopes) === null || _d === void 0 ? void 0 : _d.auto.options
|
|
162
|
+
: (_g = (_f = (_e = resource.properties.filters) === null || _e === void 0 ? void 0 : _e.scopes) === null || _f === void 0 ? void 0 : _f.manual) === null || _g === void 0 ? void 0 : _g.options;
|
|
163
|
+
modifiedResource.properties.filters.scopes.options =
|
|
164
|
+
ResourceHelper_1.default.setScopeFilterOptions(modelName, options, ((_j = (_h = resource.properties.filters) === null || _h === void 0 ? void 0 : _h.scopes) === null || _j === void 0 ? void 0 : _j.showAll) === undefined ? true : (_l = (_k = resource.properties.filters) === null || _k === void 0 ? void 0 : _k.scopes) === null || _l === void 0 ? void 0 : _l.showAll);
|
|
165
|
+
}
|
|
166
|
+
const actions = ActionsGenerator_1.default.generateActions(actionsCheck, resource, currentUser, modelConfiguration);
|
|
167
|
+
modifiedResource.properties.actions = actions;
|
|
168
|
+
modifiedResource.permissions = permissions;
|
|
169
|
+
return modifiedResource;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
exports.default = ResourceGenerator;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { IResourceFile } from '../types/IResourceFile';
|
|
2
|
-
import { IModelConfigurationDocument } from '../models/modelConfiguration/IModelConfigurations';
|
|
3
|
-
export default class ResourcesHelper {
|
|
4
|
-
static getSchemaTitle(schema: any, resource: any, modelConfiguration: IModelConfigurationDocument | undefined): any;
|
|
5
|
-
static prepareProperties(properties: string[], modelName: string, model: any, resource: IResourceFile): {}[];
|
|
6
|
-
private static getPropertyObject;
|
|
7
|
-
private static getRawName;
|
|
8
|
-
static getFieldType(schemaField: any): any;
|
|
9
|
-
static prepareFilterProperties(properties: string[], schema: any): string[];
|
|
10
|
-
static checkResourceTranslation(resource: IResourceFile, key: string): string | undefined;
|
|
11
|
-
static checkActionTranslation(resource: IResourceFile, action: string): string | undefined;
|
|
12
|
-
static setScopeFilterOptions(modelName: string, options: string[], showAll: boolean): any;
|
|
13
|
-
static getFilters(filters: any): {
|
|
14
|
-
scopes: {};
|
|
15
|
-
searchBar: {};
|
|
16
|
-
};
|
|
17
|
-
static addExtraFields(showProperties: any, model: any, record: any, filterBy: string, resource: IResourceFile): Promise<any>;
|
|
18
|
-
static getTitle(schema: any): "title" | "name" | "_id" | "email";
|
|
19
|
-
static exchangeFirstFieldWithTitle(arrayOfFields: any, title: string): any;
|
|
20
|
-
static addVirtualFields(arrayOfFields: string[], model: any): any[];
|
|
21
|
-
static manageFields(schema: any, title: string, hiddenProperties: any): any[];
|
|
22
|
-
static checkUnwantedFields(fieldKey: string, title: string): boolean;
|
|
23
|
-
static getModelPath(modelName: string): any;
|
|
24
|
-
static removeUnWantedFieldsFromCreateOrUpdate(arrayOfFields: string[]): string[];
|
|
25
|
-
static checkCreateBeforeHandler(resource: any): boolean;
|
|
26
|
-
private static checkNestedField;
|
|
27
|
-
private static getSchemaOfNestedProperty;
|
|
28
|
-
}
|
|
1
|
+
import { IResourceFile } from '../types/IResourceFile';
|
|
2
|
+
import { IModelConfigurationDocument } from '../models/modelConfiguration/IModelConfigurations';
|
|
3
|
+
export default class ResourcesHelper {
|
|
4
|
+
static getSchemaTitle(schema: any, resource: any, modelConfiguration: IModelConfigurationDocument | undefined): any;
|
|
5
|
+
static prepareProperties(properties: string[], modelName: string, model: any, resource: IResourceFile): {}[];
|
|
6
|
+
private static getPropertyObject;
|
|
7
|
+
private static getRawName;
|
|
8
|
+
static getFieldType(schemaField: any): any;
|
|
9
|
+
static prepareFilterProperties(properties: string[], schema: any): string[];
|
|
10
|
+
static checkResourceTranslation(resource: IResourceFile, key: string): string | undefined;
|
|
11
|
+
static checkActionTranslation(resource: IResourceFile, action: string): string | undefined;
|
|
12
|
+
static setScopeFilterOptions(modelName: string, options: string[], showAll: boolean): any;
|
|
13
|
+
static getFilters(filters: any): {
|
|
14
|
+
scopes: {};
|
|
15
|
+
searchBar: {};
|
|
16
|
+
};
|
|
17
|
+
static addExtraFields(showProperties: any, model: any, record: any, filterBy: string, resource: IResourceFile): Promise<any>;
|
|
18
|
+
static getTitle(schema: any): "title" | "name" | "_id" | "email";
|
|
19
|
+
static exchangeFirstFieldWithTitle(arrayOfFields: any, title: string): any;
|
|
20
|
+
static addVirtualFields(arrayOfFields: string[], model: any): any[];
|
|
21
|
+
static manageFields(schema: any, title: string, hiddenProperties: any): any[];
|
|
22
|
+
static checkUnwantedFields(fieldKey: string, title: string): boolean;
|
|
23
|
+
static getModelPath(modelName: string): any;
|
|
24
|
+
static removeUnWantedFieldsFromCreateOrUpdate(arrayOfFields: string[]): string[];
|
|
25
|
+
static checkCreateBeforeHandler(resource: any): boolean;
|
|
26
|
+
private static checkNestedField;
|
|
27
|
+
private static getSchemaOfNestedProperty;
|
|
28
|
+
}
|