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,9 +1,11 @@
1
- import { Response } from 'express';
2
- import { IResourceFile } from '../types/IResourceFile';
3
- import { IRequest } from '../middlewares/isAuth';
4
- export default class ResourceController {
5
- private resourceFiles;
6
- constructor(resourceFiles: IResourceFile[]);
7
- index(req: IRequest, res: Response): Promise<Response<any, Record<string, any>>>;
8
- getOne(req: IRequest, res: Response): Promise<Response<any, Record<string, any>>>;
9
- }
1
+ import { Response } from 'express';
2
+ import { IResourceFile } from '../types/IResourceFile';
3
+ import { IRequest } from '../middlewares/isAuth';
4
+ import { IConfiguartionFile } from '../types/IConfigurationFile';
5
+ export default class ResourceController {
6
+ private resourceFiles;
7
+ private configurations;
8
+ constructor(resourceFiles: IResourceFile[], configurations: IConfiguartionFile | undefined);
9
+ index(req: IRequest, res: Response): Promise<Response<any, Record<string, any>>>;
10
+ getOne(req: IRequest, res: Response): Promise<Response<any, Record<string, any>>>;
11
+ }
@@ -1,104 +1,109 @@
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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
- return c > 3 && r && Object.defineProperty(target, key, r), r;
23
- };
24
- var __importStar = (this && this.__importStar) || function (mod) {
25
- if (mod && mod.__esModule) return mod;
26
- var result = {};
27
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
- __setModuleDefault(result, mod);
29
- return result;
30
- };
31
- var __param = (this && this.__param) || function (paramIndex, decorator) {
32
- return function (target, key) { decorator(target, key, paramIndex); }
33
- };
34
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
35
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
36
- return new (P || (P = Promise))(function (resolve, reject) {
37
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
38
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
39
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
40
- step((generator = generator.apply(thisArg, _arguments || [])).next());
41
- });
42
- };
43
- var __importDefault = (this && this.__importDefault) || function (mod) {
44
- return (mod && mod.__esModule) ? mod : { "default": mod };
45
- };
46
- Object.defineProperty(exports, "__esModule", { value: true });
47
- const inversify_express_utils_1 = require("inversify-express-utils");
48
- const ResponseUtils_1 = __importDefault(require("../utils/ResponseUtils"));
49
- const StringUtils_1 = __importDefault(require("../utils/StringUtils"));
50
- const ResourceGenerator_1 = __importDefault(require("../helpers/ResourceGenerator"));
51
- const inversify_1 = require("inversify");
52
- let ResourceController = class ResourceController {
53
- constructor(resourceFiles) {
54
- this.resourceFiles = resourceFiles;
55
- }
56
- index(req, res) {
57
- return __awaiter(this, void 0, void 0, function* () {
58
- var modifiedResource = {};
59
- modifiedResource.modelParents = {};
60
- for (var i = 0; i < this.resourceFiles.length; i++) {
61
- const resource = this.resourceFiles[i];
62
- const adaptedResource = ResourceGenerator_1.default.generate(resource);
63
- const modelName = StringUtils_1.default.lowerCaseFirstLetter(adaptedResource.properties.modelName);
64
- modifiedResource[modelName] = adaptedResource;
65
- if (modifiedResource.modelParents[adaptedResource.properties.parent.name]) {
66
- modifiedResource.modelParents[adaptedResource.properties.parent.name].push(modelName);
67
- }
68
- else {
69
- modifiedResource.modelParents[adaptedResource.properties.parent.name] = [];
70
- modifiedResource.modelParents[adaptedResource.properties.parent.name].push(modelName);
71
- }
72
- }
73
- return ResponseUtils_1.default.send(res, 200, 'OK', {
74
- resources: modifiedResource
75
- });
76
- });
77
- }
78
- getOne(req, res) {
79
- return __awaiter(this, void 0, void 0, function* () {
80
- const modelName = req.params.modelName;
81
- const resourceName = modelName + 'Resource';
82
- const resourceFilePath = '@pbb/materialUi/' + resourceName;
83
- const resource = yield Promise.resolve().then(() => __importStar(require(resourceFilePath)));
84
- return ResponseUtils_1.default.send(res, 200, 'OK', {
85
- options: ResourceGenerator_1.default.generate(resource[resourceName])
86
- });
87
- });
88
- }
89
- };
90
- __decorate([
91
- (0, inversify_express_utils_1.httpGet)('/'),
92
- __param(0, (0, inversify_express_utils_1.request)()),
93
- __param(1, (0, inversify_express_utils_1.response)())
94
- ], ResourceController.prototype, "index", null);
95
- __decorate([
96
- (0, inversify_express_utils_1.httpGet)('/:modelName'),
97
- __param(0, (0, inversify_express_utils_1.request)()),
98
- __param(1, (0, inversify_express_utils_1.response)())
99
- ], ResourceController.prototype, "getOne", null);
100
- ResourceController = __decorate([
101
- (0, inversify_1.injectable)(),
102
- __param(0, (0, inversify_1.unmanaged)())
103
- ], ResourceController);
104
- exports.default = ResourceController;
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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || function (mod) {
25
+ if (mod && mod.__esModule) return mod;
26
+ var result = {};
27
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
+ __setModuleDefault(result, mod);
29
+ return result;
30
+ };
31
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
32
+ return function (target, key) { decorator(target, key, paramIndex); }
33
+ };
34
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
35
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
36
+ return new (P || (P = Promise))(function (resolve, reject) {
37
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
38
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
39
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
40
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
41
+ });
42
+ };
43
+ var __importDefault = (this && this.__importDefault) || function (mod) {
44
+ return (mod && mod.__esModule) ? mod : { "default": mod };
45
+ };
46
+ Object.defineProperty(exports, "__esModule", { value: true });
47
+ const inversify_express_utils_1 = require("inversify-express-utils");
48
+ const ResponseUtils_1 = __importDefault(require("../utils/ResponseUtils"));
49
+ const StringUtils_1 = __importDefault(require("../utils/StringUtils"));
50
+ const ResourceGenerator_1 = __importDefault(require("../helpers/ResourceGenerator"));
51
+ const inversify_1 = require("inversify");
52
+ let ResourceController = class ResourceController {
53
+ constructor(resourceFiles, configurations) {
54
+ this.resourceFiles = resourceFiles;
55
+ this.configurations = configurations;
56
+ }
57
+ index(req, res) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ var modifiedResource = {};
60
+ modifiedResource.modelParents = {};
61
+ if (this.configurations) {
62
+ modifiedResource.appConfigurations = this.configurations;
63
+ }
64
+ for (var i = 0; i < this.resourceFiles.length; i++) {
65
+ const resource = this.resourceFiles[i];
66
+ const adaptedResource = ResourceGenerator_1.default.generate(resource);
67
+ const modelName = StringUtils_1.default.lowerCaseFirstLetter(adaptedResource.properties.modelName);
68
+ modifiedResource[modelName] = adaptedResource;
69
+ if (modifiedResource.modelParents[adaptedResource.properties.parent.name]) {
70
+ modifiedResource.modelParents[adaptedResource.properties.parent.name].push(modelName);
71
+ }
72
+ else {
73
+ modifiedResource.modelParents[adaptedResource.properties.parent.name] = [];
74
+ modifiedResource.modelParents[adaptedResource.properties.parent.name].push(modelName);
75
+ }
76
+ }
77
+ return ResponseUtils_1.default.send(res, 200, 'OK', {
78
+ resources: modifiedResource
79
+ });
80
+ });
81
+ }
82
+ getOne(req, res) {
83
+ return __awaiter(this, void 0, void 0, function* () {
84
+ const modelName = req.params.modelName;
85
+ const resourceName = modelName + 'Resource';
86
+ const resourceFilePath = '@pbb/materialUi/' + resourceName;
87
+ const resource = yield Promise.resolve().then(() => __importStar(require(resourceFilePath)));
88
+ return ResponseUtils_1.default.send(res, 200, 'OK', {
89
+ options: ResourceGenerator_1.default.generate(resource[resourceName])
90
+ });
91
+ });
92
+ }
93
+ };
94
+ __decorate([
95
+ (0, inversify_express_utils_1.httpGet)('/'),
96
+ __param(0, (0, inversify_express_utils_1.request)()),
97
+ __param(1, (0, inversify_express_utils_1.response)())
98
+ ], ResourceController.prototype, "index", null);
99
+ __decorate([
100
+ (0, inversify_express_utils_1.httpGet)('/:modelName'),
101
+ __param(0, (0, inversify_express_utils_1.request)()),
102
+ __param(1, (0, inversify_express_utils_1.response)())
103
+ ], ResourceController.prototype, "getOne", null);
104
+ ResourceController = __decorate([
105
+ (0, inversify_1.injectable)(),
106
+ __param(0, (0, inversify_1.unmanaged)()),
107
+ __param(1, (0, inversify_1.unmanaged)())
108
+ ], ResourceController);
109
+ exports.default = ResourceController;
@@ -1,9 +1,9 @@
1
- import { IResourceFile } from "../types/IResourceFile";
2
- export default class ActionsGenerator {
3
- static generateActions(actionsCheck: any, resource: IResourceFile): {
4
- [key: string]: any;
5
- };
6
- private static addExtraActions;
7
- private static getActions;
8
- private static appendActionValues;
9
- }
1
+ import { IResourceFile } from "../types/IResourceFile";
2
+ export default class ActionsGenerator {
3
+ static generateActions(actionsCheck: any, resource: IResourceFile): {
4
+ [key: string]: any;
5
+ };
6
+ private static addExtraActions;
7
+ private static getActions;
8
+ private static appendActionValues;
9
+ }
@@ -1,77 +1,101 @@
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 i18n_1 = require("i18n");
7
- const ResourceHelper_1 = __importDefault(require("./ResourceHelper"));
8
- var pluralize = require('pluralize');
9
- class ActionsGenerator {
10
- static generateActions(actionsCheck, resource) {
11
- const actions = this.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)
12
- for (const key in actions) {
13
- if (key === 'extras') {
14
- actions.extras = actions.extras ? this.addExtraActions(JSON.parse(JSON.stringify(resource.properties.actions.extras))) : actions.extras;
15
- continue;
16
- }
17
- const translation = ResourceHelper_1.default.checkActionTranslation(resource, key);
18
- actions[key] = this.appendActionValues(key, actions[key], translation);
19
- }
20
- return actions;
21
- }
22
- static addExtraActions(extraActions) {
23
- var extraActionsObject = {
24
- record: {},
25
- resource: {}
26
- };
27
- extraActions.forEach((action) => {
28
- action.keys = action.isVisible ? Object.keys(action.isVisible) : [];
29
- action.actionType ? extraActionsObject[action.actionType][action.key] = action : '';
30
- });
31
- return extraActionsObject;
32
- }
33
- static getActions(actions) {
34
- var actionObject = {
35
- show: { isAccessible: true },
36
- new: { isAccessible: true },
37
- edit: { isAccessible: true },
38
- delete: { isAccessible: true },
39
- bulkDelete: { isAccessible: false },
40
- };
41
- if (!actions || Object.keys(actions).length === 0) {
42
- return actionObject;
43
- }
44
- for (const key in actions) {
45
- if (actions[key].hasOwnProperty('isAccessible') || key === 'extras') {
46
- actionObject[key] = actions[key];
47
- }
48
- }
49
- return actionObject;
50
- }
51
- static appendActionValues(action, actionObject, translation) {
52
- switch (action) {
53
- case 'new':
54
- actionObject.value = translation ? translation : (0, i18n_1.__)("actions_new");
55
- break;
56
- case 'edit':
57
- actionObject.value = translation ? translation : (0, i18n_1.__)("actions_edit");
58
- break;
59
- case 'delete':
60
- actionObject.value = translation ? translation : (0, i18n_1.__)("actions_delete");
61
- actionObject.confirmationMessageTitle = (0, i18n_1.__)("actions_delete_confirmMessage_title");
62
- actionObject.confirmationMessageBody = (0, i18n_1.__)("actions_delete_confirmMessage_body");
63
- actionObject.confirmDeleteOption = (0, i18n_1.__)("actions_delete_options_yes");
64
- actionObject.cancelDeleteOption = (0, i18n_1.__)("actions_delete_options_no");
65
- break;
66
- case 'bulkDelete':
67
- actionObject.value = translation ? translation : (0, i18n_1.__)("actions_delete");
68
- actionObject.confirmationMessageTitle = (0, i18n_1.__)("actions_bulkDelete_confirmMessage_title");
69
- actionObject.confirmationMessageBody = (0, i18n_1.__)("actions_bulkDelete_confirmMessage_body");
70
- actionObject.confirmDeleteOption = (0, i18n_1.__)("actions_delete_options_yes");
71
- actionObject.cancelDeleteOption = (0, i18n_1.__)("actions_delete_options_no");
72
- break;
73
- }
74
- return actionObject;
75
- }
76
- }
77
- exports.default = ActionsGenerator;
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 i18n_1 = __importStar(require("i18n"));
30
+ const ResourceHelper_1 = __importDefault(require("./ResourceHelper"));
31
+ var pluralize = require('pluralize');
32
+ class ActionsGenerator {
33
+ static generateActions(actionsCheck, resource) {
34
+ const actions = this.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)
35
+ for (const key in actions) {
36
+ if (key === 'extras') {
37
+ actions.extras = actions.extras ? this.addExtraActions(JSON.parse(JSON.stringify(resource.properties.actions.extras))) : actions.extras;
38
+ continue;
39
+ }
40
+ const translation = ResourceHelper_1.default.checkActionTranslation(resource, key);
41
+ actions[key] = this.appendActionValues(key, actions[key], translation);
42
+ }
43
+ return actions;
44
+ }
45
+ static addExtraActions(extraActions) {
46
+ var extraActionsObject = {
47
+ record: {},
48
+ resource: {}
49
+ };
50
+ extraActions.forEach((action) => {
51
+ action.keys = action.isVisible ? Object.keys(action.isVisible) : [];
52
+ action.name = (0, i18n_1.__)({ phrase: action.name, locale: i18n_1.default.getLocale() });
53
+ action.actionType ? extraActionsObject[action.actionType][action.key] = action : '';
54
+ });
55
+ return extraActionsObject;
56
+ }
57
+ static getActions(actions) {
58
+ var actionObject = {
59
+ show: { isAccessible: true },
60
+ new: { isAccessible: true },
61
+ edit: { isAccessible: true },
62
+ delete: { isAccessible: true },
63
+ bulkDelete: { isAccessible: false },
64
+ };
65
+ if (!actions || Object.keys(actions).length === 0) {
66
+ return actionObject;
67
+ }
68
+ for (const key in actions) {
69
+ if (actions[key].hasOwnProperty('isAccessible') || key === 'extras') {
70
+ actionObject[key] = actions[key];
71
+ }
72
+ }
73
+ return actionObject;
74
+ }
75
+ static appendActionValues(action, actionObject, translation) {
76
+ switch (action) {
77
+ case 'new':
78
+ actionObject.value = translation ? translation : (0, i18n_1.__)({ phrase: "actions_new", locale: i18n_1.default.getLocale() });
79
+ break;
80
+ case 'edit':
81
+ actionObject.value = translation ? translation : (0, i18n_1.__)({ phrase: "actions_edit", locale: i18n_1.default.getLocale() });
82
+ break;
83
+ case 'delete':
84
+ actionObject.value = translation ? translation : (0, i18n_1.__)({ phrase: "actions_delete", locale: i18n_1.default.getLocale() });
85
+ actionObject.confirmationMessageTitle = (0, i18n_1.__)({ phrase: "actions_delete_confirmMessage_title", locale: i18n_1.default.getLocale() });
86
+ actionObject.confirmationMessageBody = (0, i18n_1.__)({ phrase: "actions_delete_confirmMessage_body", locale: i18n_1.default.getLocale() });
87
+ actionObject.confirmDeleteOption = (0, i18n_1.__)({ phrase: "actions_delete_options_yes", locale: i18n_1.default.getLocale() });
88
+ actionObject.cancelDeleteOption = (0, i18n_1.__)({ phrase: "actions_delete_options_no", locale: i18n_1.default.getLocale() });
89
+ break;
90
+ case 'bulkDelete':
91
+ actionObject.value = translation ? translation : (0, i18n_1.__)({ phrase: "actions_delete", locale: i18n_1.default.getLocale() });
92
+ actionObject.confirmationMessageTitle = (0, i18n_1.__)({ phrase: "actions_bulkDelete_confirmMessage_title", locale: i18n_1.default.getLocale() });
93
+ actionObject.confirmationMessageBody = (0, i18n_1.__)({ phrase: "actions_bulkDelete_confirmMessage_body", locale: i18n_1.default.getLocale() });
94
+ actionObject.confirmDeleteOption = (0, i18n_1.__)({ phrase: "actions_delete_options_yes", locale: i18n_1.default.getLocale() });
95
+ actionObject.cancelDeleteOption = (0, i18n_1.__)({ phrase: "actions_delete_options_no", locale: i18n_1.default.getLocale() });
96
+ break;
97
+ }
98
+ return actionObject;
99
+ }
100
+ }
101
+ exports.default = ActionsGenerator;
@@ -0,0 +1,7 @@
1
+ export default class FilterHelper {
2
+ static appendFilters(filterQuery: {
3
+ [key: string]: any;
4
+ }, filters: string[] | undefined): {
5
+ [key: string]: any;
6
+ };
7
+ }
@@ -0,0 +1,64 @@
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 mongoose_1 = __importDefault(require("mongoose"));
7
+ const helpers_1 = require("../types/helpers");
8
+ var pluralize = require('pluralize');
9
+ class FilterHelper {
10
+ static appendFilters(filterQuery, filters) {
11
+ if (!filters) {
12
+ return filterQuery;
13
+ }
14
+ for (var i = 0; i < filters.length; i++) {
15
+ const filter = filters[i];
16
+ if (!filter || filter === '' || !filter.includes(';;')) {
17
+ continue;
18
+ }
19
+ const filterQueryString = filter.split(';;');
20
+ const fieldType = filterQueryString[1];
21
+ if (fieldType === helpers_1.FieldTypes.NUMBER || fieldType === helpers_1.FieldTypes.DATE) {
22
+ const rangeObject = filterQueryString[0].split(':');
23
+ const fieldName = rangeObject[0];
24
+ const fromToObject = rangeObject[1].split(',');
25
+ const from = fromToObject[0].split('=')[1];
26
+ const to = fromToObject[1].split('=')[1];
27
+ var filterRange = {};
28
+ if (from && from !== '' && from !== 'null') {
29
+ filterRange.$gte = from;
30
+ }
31
+ if (to && to !== '' && to !== 'null') {
32
+ filterRange.$lte = to;
33
+ }
34
+ if (filterRange.$lte || filterRange.$gte) {
35
+ filterQuery[fieldName] = filterRange;
36
+ }
37
+ continue;
38
+ }
39
+ if (!filterQueryString[0] || !fieldType || !filterQueryString[0].includes('=')) {
40
+ continue;
41
+ }
42
+ const splittedQueryString = filterQueryString[0].split('=');
43
+ const key = splittedQueryString[0];
44
+ const value = splittedQueryString[1].includes('%20') ? splittedQueryString[1].replace(/%20/g, ' ') : splittedQueryString[1];
45
+ switch (fieldType) {
46
+ case helpers_1.FieldTypes.OBJECTID:
47
+ if (!mongoose_1.default.isValidObjectId(value)) {
48
+ break;
49
+ }
50
+ filterQuery[key] = value;
51
+ break;
52
+ case helpers_1.FieldTypes.STRING:
53
+ filterQuery[key] = new RegExp(value, 'i');
54
+ break;
55
+ default:
56
+ if (value !== 'null' && value !== 'undefined') {
57
+ filterQuery[key] = value;
58
+ }
59
+ }
60
+ }
61
+ return filterQuery;
62
+ }
63
+ }
64
+ exports.default = FilterHelper;
@@ -1,4 +1,4 @@
1
- import { IResourceFile } from "../types/IResourceFile";
2
- export default class LocalesHelper {
3
- static localizeResource(resource: IResourceFile): any;
4
- }
1
+ import { IResourceFile } from "../types/IResourceFile";
2
+ export default class LocalesHelper {
3
+ static localizeResource(resource: IResourceFile): any;
4
+ }