identity-admin 1.4.4 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/README.md +126 -126
  2. package/lib/Dashboard.d.ts +14 -14
  3. package/lib/Dashboard.js +95 -88
  4. package/lib/container/helpers/HelperInversify.d.ts +6 -6
  5. package/lib/container/helpers/HelperInversify.js +10 -10
  6. package/lib/container/helpers/HelperTypes.d.ts +5 -5
  7. package/lib/container/helpers/HelperTypes.js +7 -7
  8. package/lib/container/index.d.ts +1 -1
  9. package/lib/container/index.js +14 -14
  10. package/lib/container/repositories/RepositoryInversify.d.ts +4 -4
  11. package/lib/container/repositories/RepositoryInversify.js +13 -13
  12. package/lib/container/repositories/RepositoryTypes.d.ts +4 -4
  13. package/lib/container/repositories/RepositoryTypes.js +6 -6
  14. package/lib/container/types.d.ts +8 -8
  15. package/lib/container/types.js +9 -9
  16. package/lib/controllers/ActionController.d.ts +8 -8
  17. package/lib/controllers/ActionController.js +79 -79
  18. package/lib/controllers/DashboardController.d.ts +36 -36
  19. package/lib/controllers/DashboardController.js +349 -335
  20. package/lib/controllers/ResourceController.d.ts +11 -9
  21. package/lib/controllers/ResourceController.js +109 -104
  22. package/lib/helpers/ActionsGenerator.d.ts +9 -9
  23. package/lib/helpers/ActionsGenerator.js +101 -77
  24. package/lib/helpers/FiltersHelper.d.ts +7 -0
  25. package/lib/helpers/FiltersHelper.js +64 -0
  26. package/lib/helpers/LocalesHelper.d.ts +4 -4
  27. package/lib/helpers/LocalesHelper.js +73 -73
  28. package/lib/helpers/ResourceGenerator.d.ts +4 -4
  29. package/lib/helpers/ResourceGenerator.js +110 -68
  30. package/lib/helpers/ResourceHelper.d.ts +23 -22
  31. package/lib/helpers/ResourceHelper.js +305 -286
  32. package/lib/helpers/SchemaGenerator.d.ts +5 -5
  33. package/lib/helpers/SchemaGenerator.js +92 -87
  34. package/lib/helpers/SchemaHelper.d.ts +5 -5
  35. package/lib/helpers/SchemaHelper.js +21 -21
  36. package/lib/locales/ar.json +1 -0
  37. package/lib/locales/en.json +50 -10
  38. package/lib/middlewares/isAuth.d.ts +13 -13
  39. package/lib/middlewares/isAuth.js +43 -43
  40. package/lib/models/ModelNames.d.ts +4 -4
  41. package/lib/models/ModelNames.js +7 -7
  42. package/lib/models/request-log/IRequestLog.d.ts +22 -22
  43. package/lib/models/request-log/IRequestLog.js +2 -2
  44. package/lib/models/request-log/RequestLog.d.ts +3 -3
  45. package/lib/models/request-log/RequestLog.js +51 -51
  46. package/lib/repositories/DashboardRepository.d.ts +5 -5
  47. package/lib/repositories/DashboardRepository.js +12 -12
  48. package/lib/repositories/Repository.d.ts +68 -68
  49. package/lib/repositories/Repository.js +212 -212
  50. package/lib/repositories/RequestLogRepository.d.ts +10 -10
  51. package/lib/repositories/RequestLogRepository.js +54 -54
  52. package/lib/repositories/SaveResult.d.ts +14 -14
  53. package/lib/repositories/SaveResult.js +18 -18
  54. package/lib/router/index.d.ts +8 -8
  55. package/lib/router/index.js +97 -97
  56. package/lib/types/DashbordConfig.d.ts +21 -19
  57. package/lib/types/DashbordConfig.js +2 -2
  58. package/lib/types/IConfigurationFile.d.ts +5 -0
  59. package/lib/types/IConfigurationFile.js +2 -0
  60. package/lib/types/IResourceFile.d.ts +145 -125
  61. package/lib/types/IResourceFile.js +2 -2
  62. package/lib/types/helpers.d.ts +28 -15
  63. package/lib/types/helpers.js +35 -21
  64. package/lib/utils/ResourceUtils.d.ts +2 -2
  65. package/lib/utils/ResourceUtils.js +7 -7
  66. package/lib/utils/ResponseUtils.d.ts +10 -10
  67. package/lib/utils/ResponseUtils.js +38 -38
  68. package/lib/utils/StringUtils.d.ts +9 -9
  69. package/lib/utils/StringUtils.js +46 -46
  70. package/lib/view/asset-manifest.json +13 -13
  71. package/lib/view/assets/icons/delete_icon.svg +3 -3
  72. package/lib/view/assets/icons/flags/ic_flag_cn.svg +9 -9
  73. package/lib/view/assets/icons/flags/ic_flag_sa.svg +9 -9
  74. package/lib/view/assets/icons/flags/ic_flag_vn.svg +9 -9
  75. package/lib/view/assets/icons/info_icon.svg +3 -3
  76. package/lib/view/assets/icons/navbar/ic_banking.svg +5 -5
  77. package/lib/view/assets/icons/navbar/ic_invoice.svg +4 -4
  78. package/lib/view/assets/icons/navbar/ic_kanban.svg +7 -7
  79. package/lib/view/assets/icons/navbar/ic_menu_item.svg +8 -8
  80. package/lib/view/assets/icons/small_info_icon.svg +3 -3
  81. package/lib/view/assets/illustrations/Group 16.svg +4 -4
  82. package/lib/view/assets/illustrations/logo.svg +5 -5
  83. package/lib/view/favicon/browserconfig.xml +9 -9
  84. package/lib/view/favicon/safari-pinned-tab.svg +182 -182
  85. package/lib/view/favicon/site.webmanifest +19 -19
  86. package/lib/view/fonts/index.css +18 -18
  87. package/lib/view/index.html +1 -1
  88. package/lib/view/manifest.json +20 -20
  89. package/lib/view/robots.txt +3 -3
  90. package/lib/view/static/js/{148.b6f24fc9.chunk.js → 148.b05fe2c8.chunk.js} +1 -1
  91. package/lib/view/static/js/{705.b2b55cc3.chunk.js → 705.f86db82e.chunk.js} +1 -1
  92. package/lib/view/static/js/802.3f287a2c.chunk.js +1 -0
  93. package/lib/view/static/js/main.da8f09ec.js +2 -0
  94. package/lib/view/static/js/{main.bc5ec798.js.LICENSE.txt → main.da8f09ec.js.LICENSE.txt} +225 -223
  95. package/package.json +51 -51
  96. package/lib/view/static/js/939.f35326c5.chunk.js +0 -1
  97. 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;
@@ -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 __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const StringUtils_1 = __importDefault(require("../utils/StringUtils"));
7
- const SchemaGenerator_1 = __importDefault(require("./SchemaGenerator"));
8
- const ResourceHelper_1 = __importDefault(require("./ResourceHelper"));
9
- const ActionsGenerator_1 = __importDefault(require("./ActionsGenerator"));
10
- const SetupParent = {
11
- name: 'Setup',
12
- icon: 'PermDataSetting'
13
- };
14
- class ResourceGenerator {
15
- static generate(resource) {
16
- const modelName = resource.properties.modelName;
17
- const modifiedResource = JSON.parse(JSON.stringify(resource));
18
- const schema = resource.properties.resource.schema.paths;
19
- const title = ResourceHelper_1.default.getSchemaTitle(schema, resource);
20
- const recordFields = ResourceHelper_1.default.manageFields(schema, title, resource.properties.hiddenProperties);
21
- const modelCheck = resource.properties.model ? JSON.parse(JSON.stringify(resource.properties.model)) : undefined;
22
- const actionsCheck = resource.properties.actions;
23
- const modelAndPopulatedString = SchemaGenerator_1.default.generateSchema(schema, modelCheck, modelName, resource);
24
- modifiedResource.properties.model = modelAndPopulatedString[0];
25
- modifiedResource.properties.populatedString = modelAndPopulatedString[1];
26
- const modifiedProperties = ResourceHelper_1.default.addVirtualFields(JSON.parse(JSON.stringify(recordFields)), modelCheck);
27
- modifiedResource.properties.path = ResourceHelper_1.default.getModelPath(modelName);
28
- const modifiedListProperties = modifiedProperties[0];
29
- const modifiedShowProperties = modifiedProperties[1];
30
- const modifiedFormProperties = modifiedProperties[2];
31
- if (!resource.properties.parent) {
32
- modifiedResource.properties.parent = SetupParent;
33
- }
34
- if (!resource.properties.name) {
35
- modifiedResource.properties.name = StringUtils_1.default.convertCamelCaseToWord(modelName);
36
- }
37
- if (!resource.showProperties) {
38
- modifiedResource.showProperties = modifiedShowProperties;
39
- }
40
- if (!resource.listProperties) {
41
- modifiedResource.listProperties = ResourceHelper_1.default.exchangeFirstFieldWithTitle(JSON.parse(JSON.stringify(modifiedListProperties)), title);
42
- }
43
- if (!resource.formProperties) {
44
- modifiedResource.formProperties = ResourceHelper_1.default.removeUnWantedFieldsFromCreateOrUpdate(JSON.parse(JSON.stringify(modifiedFormProperties)));
45
- }
46
- modifiedResource.properties.title = title;
47
- if (!resource.properties.defaultOrderBy) {
48
- modifiedResource.properties.defaultOrderBy = title;
49
- }
50
- if (!resource.properties.defaultOrder) {
51
- modifiedResource.properties.defaultOrder = 'asc';
52
- }
53
- if (!resource.properties.defaultrowsPerPage) {
54
- modifiedResource.properties.defaultrowsPerPage = 10;
55
- }
56
- modifiedResource.listProperties = ResourceHelper_1.default.prepareProperties(resource.listProperties ? resource.listProperties : modifiedResource.listProperties, modelName, modifiedResource.properties.model, resource);
57
- modifiedResource.showProperties = ResourceHelper_1.default.prepareProperties(resource.showProperties ? resource.showProperties : modifiedResource.showProperties, modelName, modifiedResource.properties.model, resource);
58
- modifiedResource.properties.filters = ResourceHelper_1.default.getFilters(resource.properties.filters ? JSON.parse(JSON.stringify(resource.properties.filters)) : undefined);
59
- if (modifiedResource.properties.filters && modifiedResource.properties.filters.scopes && modifiedResource.properties.filters.scopes.isAccessible) {
60
- const options = resource.properties.filters.scopes.options;
61
- modifiedResource.properties.filters.scopes.options = ResourceHelper_1.default.setScopeFilterOptions(modelName, options);
62
- }
63
- const actions = ActionsGenerator_1.default.generateActions(actionsCheck, resource);
64
- modifiedResource.properties.actions = actions;
65
- return modifiedResource;
66
- }
67
- }
68
- 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) {
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 checkResourceTranslation(resource: IResourceFile, key: string): string | undefined;
7
- static checkActionTranslation(resource: IResourceFile, action: string): string | undefined;
8
- static setScopeFilterOptions(modelName: string, options: string[]): any;
9
- static getFilters(filters: any): {
10
- scopes: {};
11
- searchBar: {};
12
- };
13
- static addExtraFields(showProperties: any, model: any, record: any, filterBy: string, resource: IResourceFile): Promise<any>;
14
- static getTitle(schema: any): "title" | "name" | "_id" | "email";
15
- static exchangeFirstFieldWithTitle(arrayOfFields: any, title: string): any;
16
- static addVirtualFields(arrayOfFields: string[], model: any): any[];
17
- static manageFields(schema: any, title: string, hiddenProperties: any): any[];
18
- static checkUnwantedFields(fieldKey: string, title: string): boolean;
19
- static getModelPath(modelName: string): any;
20
- static removeUnWantedFieldsFromCreateOrUpdate(arrayOfFields: string[]): string[];
21
- static checkCreateBeforeHandler(resource: any): boolean;
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
+ }