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,73 +1,73 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
// import { AdminParent, SetupParent } from "@pbb/materialUi/parents";
|
|
7
|
-
const StringUtils_1 = __importDefault(require("../utils/StringUtils"));
|
|
8
|
-
const ResourceHelper_1 = __importDefault(require("./ResourceHelper"));
|
|
9
|
-
var pluralize = require('pluralize');
|
|
10
|
-
class LocalesHelper {
|
|
11
|
-
static localizeResource(resource) {
|
|
12
|
-
var _a, _b, _c, _d, _e;
|
|
13
|
-
const modelName = resource.resource.modelName;
|
|
14
|
-
const modifiedResource = JSON.parse(JSON.stringify(resource));
|
|
15
|
-
const title = ResourceHelper_1.default.getSchemaTitle(modelName, resource);
|
|
16
|
-
const schema = resource.resource.schema.paths;
|
|
17
|
-
const recordFields = ResourceHelper_1.default.manageFields(schema, title, resource.properties.hiddenProperties);
|
|
18
|
-
const modelCheck = resource.properties.model ? JSON.parse(JSON.stringify(resource.properties.model)) : undefined;
|
|
19
|
-
const actionsCheck = resource.properties.actions;
|
|
20
|
-
const modelAndPopulatedString = ResourceHelper_1.default.setModelSchema(schema, modelCheck, modelName);
|
|
21
|
-
modifiedResource.properties.model = modelAndPopulatedString[0];
|
|
22
|
-
modifiedResource.properties.populatedString = modelAndPopulatedString[1];
|
|
23
|
-
const modifiedProperties = ResourceHelper_1.default.addVirtualFields(JSON.parse(JSON.stringify(recordFields)), modelCheck);
|
|
24
|
-
modifiedResource.properties.path = ResourceHelper_1.default.getModelPath(modelName);
|
|
25
|
-
const modifiedListProperties = modifiedProperties[0];
|
|
26
|
-
const modifiedShowProperties = modifiedProperties[1];
|
|
27
|
-
const modifiedFormProperties = modifiedProperties[2];
|
|
28
|
-
if (!resource.properties.parent) {
|
|
29
|
-
//modifiedResource.properties.parent = SetupParent
|
|
30
|
-
}
|
|
31
|
-
if (!resource.properties.name) {
|
|
32
|
-
modifiedResource.properties.name = StringUtils_1.default.convertCamelCaseToWord(modelName);
|
|
33
|
-
}
|
|
34
|
-
if (!resource.showProperties) {
|
|
35
|
-
modifiedResource.showProperties = modifiedShowProperties;
|
|
36
|
-
}
|
|
37
|
-
if (!resource.listProperties) {
|
|
38
|
-
modifiedResource.listProperties = ResourceHelper_1.default.exchangeFirstFieldWithTitle(JSON.parse(JSON.stringify(modifiedListProperties)), title);
|
|
39
|
-
}
|
|
40
|
-
if (!resource.formProperties) {
|
|
41
|
-
modifiedResource.formProperties = ResourceHelper_1.default.removeUnWantedFieldsFromCreateOrUpdate(JSON.parse(JSON.stringify(modifiedFormProperties)));
|
|
42
|
-
}
|
|
43
|
-
modifiedResource.properties.title = title;
|
|
44
|
-
if (!resource.properties.defaultOrderBy) {
|
|
45
|
-
modifiedResource.properties.defaultOrderBy = title;
|
|
46
|
-
}
|
|
47
|
-
if (!resource.properties.defaultOrder) {
|
|
48
|
-
modifiedResource.properties.defaultOrder = 'asc';
|
|
49
|
-
}
|
|
50
|
-
if (!resource.properties.defaultrowsPerPage) {
|
|
51
|
-
modifiedResource.properties.defaultrowsPerPage = 10;
|
|
52
|
-
}
|
|
53
|
-
modifiedResource.listProperties = ResourceHelper_1.default.prepareProperties(resource.listProperties ? resource.listProperties : modifiedResource.listProperties, modelName, modifiedResource.properties.model);
|
|
54
|
-
modifiedResource.showProperties = ResourceHelper_1.default.prepareProperties(resource.showProperties ? resource.showProperties : modifiedResource.showProperties, modelName, modifiedResource.properties.model);
|
|
55
|
-
modifiedResource.properties.filters = ResourceHelper_1.default.getFilters(resource.properties.filters ? JSON.parse(JSON.stringify(resource.properties.filters)) : undefined);
|
|
56
|
-
if (modifiedResource.properties.filters.scopes.isAccessible) {
|
|
57
|
-
const options = (_c = (_b = (_a = resource === null || resource === void 0 ? void 0 : resource.properties) === null || _a === void 0 ? void 0 : _a.filters) === null || _b === void 0 ? void 0 : _b.scopes) === null || _c === void 0 ? void 0 : _c.options;
|
|
58
|
-
modifiedResource.properties.filters.scopes.options = ResourceHelper_1.default.setScopeFilterOptions(modelName, options);
|
|
59
|
-
}
|
|
60
|
-
const actions = ResourceHelper_1.default.getActions(actionsCheck ? JSON.parse(JSON.stringify(resource.properties.actions)) : undefined); //resource.properties.actions? ResourcesHelper.getActions(JSON.parse(JSON.stringify(resource.properties.actions))): ResourcesHelper.getActions(undefined)
|
|
61
|
-
for (const key in actions) {
|
|
62
|
-
if (key === 'extras') {
|
|
63
|
-
actions.extras = actions.extras ? ResourceHelper_1.default.addExtraActions(JSON.parse(JSON.stringify((_e = (_d = resource === null || resource === void 0 ? void 0 : resource.properties) === null || _d === void 0 ? void 0 : _d.actions) === null || _e === void 0 ? void 0 : _e.extras))) : actions.extras;
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
const translation = ResourceHelper_1.default.checkActionTranslation(modelName, key);
|
|
67
|
-
actions[key] = ResourceHelper_1.default.appendActionValues(key, actions[key], translation);
|
|
68
|
-
}
|
|
69
|
-
modifiedResource.properties.actions = actions;
|
|
70
|
-
return modifiedResource;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
exports.default = LocalesHelper;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
// import { AdminParent, SetupParent } from "@pbb/materialUi/parents";
|
|
7
|
+
const StringUtils_1 = __importDefault(require("../utils/StringUtils"));
|
|
8
|
+
const ResourceHelper_1 = __importDefault(require("./ResourceHelper"));
|
|
9
|
+
var pluralize = require('pluralize');
|
|
10
|
+
class LocalesHelper {
|
|
11
|
+
static localizeResource(resource) {
|
|
12
|
+
var _a, _b, _c, _d, _e;
|
|
13
|
+
const modelName = resource.resource.modelName;
|
|
14
|
+
const modifiedResource = JSON.parse(JSON.stringify(resource));
|
|
15
|
+
const title = ResourceHelper_1.default.getSchemaTitle(modelName, resource);
|
|
16
|
+
const schema = resource.resource.schema.paths;
|
|
17
|
+
const recordFields = ResourceHelper_1.default.manageFields(schema, title, resource.properties.hiddenProperties);
|
|
18
|
+
const modelCheck = resource.properties.model ? JSON.parse(JSON.stringify(resource.properties.model)) : undefined;
|
|
19
|
+
const actionsCheck = resource.properties.actions;
|
|
20
|
+
const modelAndPopulatedString = ResourceHelper_1.default.setModelSchema(schema, modelCheck, modelName);
|
|
21
|
+
modifiedResource.properties.model = modelAndPopulatedString[0];
|
|
22
|
+
modifiedResource.properties.populatedString = modelAndPopulatedString[1];
|
|
23
|
+
const modifiedProperties = ResourceHelper_1.default.addVirtualFields(JSON.parse(JSON.stringify(recordFields)), modelCheck);
|
|
24
|
+
modifiedResource.properties.path = ResourceHelper_1.default.getModelPath(modelName);
|
|
25
|
+
const modifiedListProperties = modifiedProperties[0];
|
|
26
|
+
const modifiedShowProperties = modifiedProperties[1];
|
|
27
|
+
const modifiedFormProperties = modifiedProperties[2];
|
|
28
|
+
if (!resource.properties.parent) {
|
|
29
|
+
//modifiedResource.properties.parent = SetupParent
|
|
30
|
+
}
|
|
31
|
+
if (!resource.properties.name) {
|
|
32
|
+
modifiedResource.properties.name = StringUtils_1.default.convertCamelCaseToWord(modelName);
|
|
33
|
+
}
|
|
34
|
+
if (!resource.showProperties) {
|
|
35
|
+
modifiedResource.showProperties = modifiedShowProperties;
|
|
36
|
+
}
|
|
37
|
+
if (!resource.listProperties) {
|
|
38
|
+
modifiedResource.listProperties = ResourceHelper_1.default.exchangeFirstFieldWithTitle(JSON.parse(JSON.stringify(modifiedListProperties)), title);
|
|
39
|
+
}
|
|
40
|
+
if (!resource.formProperties) {
|
|
41
|
+
modifiedResource.formProperties = ResourceHelper_1.default.removeUnWantedFieldsFromCreateOrUpdate(JSON.parse(JSON.stringify(modifiedFormProperties)));
|
|
42
|
+
}
|
|
43
|
+
modifiedResource.properties.title = title;
|
|
44
|
+
if (!resource.properties.defaultOrderBy) {
|
|
45
|
+
modifiedResource.properties.defaultOrderBy = title;
|
|
46
|
+
}
|
|
47
|
+
if (!resource.properties.defaultOrder) {
|
|
48
|
+
modifiedResource.properties.defaultOrder = 'asc';
|
|
49
|
+
}
|
|
50
|
+
if (!resource.properties.defaultrowsPerPage) {
|
|
51
|
+
modifiedResource.properties.defaultrowsPerPage = 10;
|
|
52
|
+
}
|
|
53
|
+
modifiedResource.listProperties = ResourceHelper_1.default.prepareProperties(resource.listProperties ? resource.listProperties : modifiedResource.listProperties, modelName, modifiedResource.properties.model);
|
|
54
|
+
modifiedResource.showProperties = ResourceHelper_1.default.prepareProperties(resource.showProperties ? resource.showProperties : modifiedResource.showProperties, modelName, modifiedResource.properties.model);
|
|
55
|
+
modifiedResource.properties.filters = ResourceHelper_1.default.getFilters(resource.properties.filters ? JSON.parse(JSON.stringify(resource.properties.filters)) : undefined);
|
|
56
|
+
if (modifiedResource.properties.filters.scopes.isAccessible) {
|
|
57
|
+
const options = (_c = (_b = (_a = resource === null || resource === void 0 ? void 0 : resource.properties) === null || _a === void 0 ? void 0 : _a.filters) === null || _b === void 0 ? void 0 : _b.scopes) === null || _c === void 0 ? void 0 : _c.options;
|
|
58
|
+
modifiedResource.properties.filters.scopes.options = ResourceHelper_1.default.setScopeFilterOptions(modelName, options);
|
|
59
|
+
}
|
|
60
|
+
const actions = ResourceHelper_1.default.getActions(actionsCheck ? JSON.parse(JSON.stringify(resource.properties.actions)) : undefined); //resource.properties.actions? ResourcesHelper.getActions(JSON.parse(JSON.stringify(resource.properties.actions))): ResourcesHelper.getActions(undefined)
|
|
61
|
+
for (const key in actions) {
|
|
62
|
+
if (key === 'extras') {
|
|
63
|
+
actions.extras = actions.extras ? ResourceHelper_1.default.addExtraActions(JSON.parse(JSON.stringify((_e = (_d = resource === null || resource === void 0 ? void 0 : resource.properties) === null || _d === void 0 ? void 0 : _d.actions) === null || _e === void 0 ? void 0 : _e.extras))) : actions.extras;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const translation = ResourceHelper_1.default.checkActionTranslation(modelName, key);
|
|
67
|
+
actions[key] = ResourceHelper_1.default.appendActionValues(key, actions[key], translation);
|
|
68
|
+
}
|
|
69
|
+
modifiedResource.properties.actions = actions;
|
|
70
|
+
return modifiedResource;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.default = LocalesHelper;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IResourceFile } from "../types/IResourceFile";
|
|
2
|
+
export default class LocalizedStringHelper {
|
|
3
|
+
static mapLocalizableString(recordParams: any, resource: IResourceFile): any;
|
|
4
|
+
private static getArrayOfLanguages;
|
|
5
|
+
static checkLocalizedStringType(resource: IResourceFile, fieldName: string): boolean;
|
|
6
|
+
static getFilterObject(searchBy: string, index: string, value: any): {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const helpers_1 = require("../types/helpers");
|
|
4
|
+
class LocalizedStringHelper {
|
|
5
|
+
static mapLocalizableString(recordParams, resource) {
|
|
6
|
+
const modelObject = resource.properties.model;
|
|
7
|
+
if (!modelObject) {
|
|
8
|
+
return recordParams;
|
|
9
|
+
}
|
|
10
|
+
for (const key in modelObject) {
|
|
11
|
+
if (!modelObject.hasOwnProperty(key) || key === 'virtuals') {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
const castedModelObject = modelObject;
|
|
15
|
+
if (castedModelObject[key].type && castedModelObject[key].type === helpers_1.FieldTypes.LOCALIZEDSTRING && recordParams[key]) {
|
|
16
|
+
recordParams[key] = this.getArrayOfLanguages(recordParams[key]);
|
|
17
|
+
}
|
|
18
|
+
else if (castedModelObject[key].arrayType && castedModelObject[key].arrayType === helpers_1.FieldTypes.LOCALIZEDSTRING && recordParams[key] && recordParams[key].length !== 0) {
|
|
19
|
+
for (var j = 0; j < recordParams[key].length; j++) {
|
|
20
|
+
recordParams[key][j] = this.getArrayOfLanguages(recordParams[key][j]);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return recordParams;
|
|
25
|
+
}
|
|
26
|
+
static getArrayOfLanguages(record) {
|
|
27
|
+
var localizedArray = [];
|
|
28
|
+
for (const language in record) {
|
|
29
|
+
if (!record.hasOwnProperty(language)) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const languageObject = {
|
|
33
|
+
key: language,
|
|
34
|
+
value: record[language] ? record[language] : undefined
|
|
35
|
+
};
|
|
36
|
+
localizedArray.push(languageObject);
|
|
37
|
+
}
|
|
38
|
+
return localizedArray;
|
|
39
|
+
}
|
|
40
|
+
static checkLocalizedStringType(resource, fieldName) {
|
|
41
|
+
const modelObject = resource.properties.model;
|
|
42
|
+
if (!modelObject || !modelObject.hasOwnProperty(fieldName)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
const castedModelObject = modelObject;
|
|
46
|
+
if (castedModelObject[fieldName].type && castedModelObject[fieldName].type === helpers_1.FieldTypes.LOCALIZEDSTRING) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
static getFilterObject(searchBy, index, value) {
|
|
52
|
+
const filterObject = {};
|
|
53
|
+
filterObject[`${searchBy}.${index}.value`] = value;
|
|
54
|
+
return filterObject;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.default = LocalizedStringHelper;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IResourceFile } from "../types/IResourceFile";
|
|
2
|
-
export default class ResourceGenerator {
|
|
3
|
-
static generate(resource: IResourceFile): any;
|
|
4
|
-
}
|
|
1
|
+
import { IResourceFile } from "../types/IResourceFile";
|
|
2
|
+
export default class ResourceGenerator {
|
|
3
|
+
static generate(resource: IResourceFile): any;
|
|
4
|
+
}
|
|
@@ -1,68 +1,110 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
modifiedResource.
|
|
57
|
-
|
|
58
|
-
modifiedResource.properties.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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) {
|
|
41
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
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 modifiedResource = JSON.parse(JSON.stringify(resource));
|
|
49
|
+
const schema = resource.properties.resource.schema.paths;
|
|
50
|
+
const title = ResourceHelper_1.default.getSchemaTitle(schema, resource);
|
|
51
|
+
const recordFields = ResourceHelper_1.default.manageFields(schema, title, resource.properties.hiddenProperties);
|
|
52
|
+
const modelCheck = resource.properties.model ? JSON.parse(JSON.stringify(resource.properties.model)) : undefined;
|
|
53
|
+
const actionsCheck = resource.properties.actions;
|
|
54
|
+
const modelAndPopulatedString = SchemaGenerator_1.default.generateSchema(schema, modelCheck, modelName, resource);
|
|
55
|
+
modifiedResource.properties.model = modelAndPopulatedString[0];
|
|
56
|
+
modifiedResource.properties.populatedString = modelAndPopulatedString[1];
|
|
57
|
+
const modifiedProperties = ResourceHelper_1.default.addVirtualFields(JSON.parse(JSON.stringify(recordFields)), modelCheck);
|
|
58
|
+
modifiedResource.properties.path = ResourceHelper_1.default.getModelPath(modelName);
|
|
59
|
+
const modifiedListProperties = modifiedProperties[0];
|
|
60
|
+
const modifiedShowProperties = modifiedProperties[1];
|
|
61
|
+
const modifiedFormProperties = modifiedProperties[2];
|
|
62
|
+
if (!resource.properties.parent) {
|
|
63
|
+
modifiedResource.properties.parent = SetupParent;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
modifiedResource.properties.parent = {
|
|
67
|
+
name: resource.properties.parent.name,
|
|
68
|
+
icon: resource.properties.parent.icon,
|
|
69
|
+
value: (0, i18n_1.__)({ phrase: resource.properties.parent.name, locale: i18n_1.default.getLocale() })
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (!resource.properties.name) {
|
|
73
|
+
modifiedResource.properties.name = (0, i18n_1.__)({ phrase: StringUtils_1.default.convertCamelCaseToWord(modelName), locale: i18n_1.default.getLocale() });
|
|
74
|
+
}
|
|
75
|
+
if (!resource.showProperties) {
|
|
76
|
+
modifiedResource.showProperties = modifiedShowProperties;
|
|
77
|
+
}
|
|
78
|
+
if (!resource.filterProperties) {
|
|
79
|
+
modifiedResource.filterProperties = recordFields;
|
|
80
|
+
}
|
|
81
|
+
if (!resource.listProperties) {
|
|
82
|
+
modifiedResource.listProperties = ResourceHelper_1.default.exchangeFirstFieldWithTitle(JSON.parse(JSON.stringify(modifiedListProperties)), title);
|
|
83
|
+
}
|
|
84
|
+
if (!resource.formProperties) {
|
|
85
|
+
modifiedResource.formProperties = ResourceHelper_1.default.removeUnWantedFieldsFromCreateOrUpdate(JSON.parse(JSON.stringify(modifiedFormProperties)));
|
|
86
|
+
}
|
|
87
|
+
modifiedResource.properties.title = title;
|
|
88
|
+
if (!resource.properties.defaultOrderBy) {
|
|
89
|
+
modifiedResource.properties.defaultOrderBy = title;
|
|
90
|
+
}
|
|
91
|
+
if (!resource.properties.defaultOrder) {
|
|
92
|
+
modifiedResource.properties.defaultOrder = 'asc';
|
|
93
|
+
}
|
|
94
|
+
if (!resource.properties.defaultrowsPerPage) {
|
|
95
|
+
modifiedResource.properties.defaultrowsPerPage = 10;
|
|
96
|
+
}
|
|
97
|
+
modifiedResource.listProperties = ResourceHelper_1.default.prepareProperties(resource.listProperties ? resource.listProperties : modifiedResource.listProperties, modelName, modifiedResource.properties.model, resource);
|
|
98
|
+
modifiedResource.showProperties = ResourceHelper_1.default.prepareProperties(resource.showProperties ? resource.showProperties : modifiedResource.showProperties, modelName, modifiedResource.properties.model, resource);
|
|
99
|
+
modifiedResource.filterProperties = ResourceHelper_1.default.prepareFilterProperties(modifiedResource.filterProperties, modifiedResource.properties.model);
|
|
100
|
+
modifiedResource.properties.filters = ResourceHelper_1.default.getFilters(resource.properties.filters ? JSON.parse(JSON.stringify(resource.properties.filters)) : undefined);
|
|
101
|
+
if (modifiedResource.properties.filters && modifiedResource.properties.filters.scopes && modifiedResource.properties.filters.scopes.isAccessible) {
|
|
102
|
+
const options = ((_b = (_a = resource.properties.filters) === null || _a === void 0 ? void 0 : _a.scopes) === null || _b === void 0 ? void 0 : _b.auto) ? (_d = (_c = resource.properties.filters) === null || _c === void 0 ? void 0 : _c.scopes) === null || _d === void 0 ? void 0 : _d.auto.options : (_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;
|
|
103
|
+
modifiedResource.properties.filters.scopes.options = ResourceHelper_1.default.setScopeFilterOptions(modelName, options);
|
|
104
|
+
}
|
|
105
|
+
const actions = ActionsGenerator_1.default.generateActions(actionsCheck, resource);
|
|
106
|
+
modifiedResource.properties.actions = actions;
|
|
107
|
+
return modifiedResource;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.default = ResourceGenerator;
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import { IResourceFile } from "../types/IResourceFile";
|
|
2
|
-
export default class ResourcesHelper {
|
|
3
|
-
static getSchemaTitle(schema: any, resource: any): any;
|
|
4
|
-
static prepareProperties(properties: string[], modelName: string, model: any, resource: IResourceFile): {}[];
|
|
5
|
-
static getFieldType(schemaField: any): any;
|
|
6
|
-
static
|
|
7
|
-
static
|
|
8
|
-
static
|
|
9
|
-
static
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
static
|
|
15
|
-
static
|
|
16
|
-
static
|
|
17
|
-
static
|
|
18
|
-
static
|
|
19
|
-
static
|
|
20
|
-
static
|
|
21
|
-
static
|
|
22
|
-
|
|
1
|
+
import { IResourceFile } from "../types/IResourceFile";
|
|
2
|
+
export default class ResourcesHelper {
|
|
3
|
+
static getSchemaTitle(schema: any, resource: any): any;
|
|
4
|
+
static prepareProperties(properties: string[], modelName: string, model: any, resource: IResourceFile): {}[];
|
|
5
|
+
static getFieldType(schemaField: any): any;
|
|
6
|
+
static prepareFilterProperties(properties: string[], schema: any): string[];
|
|
7
|
+
static checkResourceTranslation(resource: IResourceFile, key: string): string | undefined;
|
|
8
|
+
static checkActionTranslation(resource: IResourceFile, action: string): string | undefined;
|
|
9
|
+
static setScopeFilterOptions(modelName: string, options: string[]): any;
|
|
10
|
+
static getFilters(filters: any): {
|
|
11
|
+
scopes: {};
|
|
12
|
+
searchBar: {};
|
|
13
|
+
};
|
|
14
|
+
static addExtraFields(showProperties: any, model: any, record: any, filterBy: string, resource: IResourceFile): Promise<any>;
|
|
15
|
+
static getTitle(schema: any): "title" | "name" | "_id" | "email";
|
|
16
|
+
static exchangeFirstFieldWithTitle(arrayOfFields: any, title: string): any;
|
|
17
|
+
static addVirtualFields(arrayOfFields: string[], model: any): any[];
|
|
18
|
+
static manageFields(schema: any, title: string, hiddenProperties: any): any[];
|
|
19
|
+
static checkUnwantedFields(fieldKey: string, title: string): boolean;
|
|
20
|
+
static getModelPath(modelName: string): any;
|
|
21
|
+
static removeUnWantedFieldsFromCreateOrUpdate(arrayOfFields: string[]): string[];
|
|
22
|
+
static checkCreateBeforeHandler(resource: any): boolean;
|
|
23
|
+
}
|