identity-admin 1.25.11 → 1.25.12

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 (141) hide show
  1. package/README.md +126 -126
  2. package/lib/Dashboard.d.ts +14 -14
  3. package/lib/Dashboard.js +95 -95
  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 +41 -41
  19. package/lib/controllers/DashboardController.js +589 -589
  20. package/lib/controllers/ResourceController.d.ts +15 -13
  21. package/lib/controllers/ResourceController.js +132 -124
  22. package/lib/helpers/ActionsGenerator.d.ts +11 -11
  23. package/lib/helpers/ActionsGenerator.js +175 -175
  24. package/lib/helpers/FiltersHelper.d.ts +9 -9
  25. package/lib/helpers/FiltersHelper.js +105 -105
  26. package/lib/helpers/LocalesHelper.d.ts +4 -4
  27. package/lib/helpers/LocalesHelper.js +73 -73
  28. package/lib/helpers/LocalizedStringHelper.d.ts +9 -9
  29. package/lib/helpers/LocalizedStringHelper.js +57 -57
  30. package/lib/helpers/Permissions/PermissionFetcher.d.ts +7 -0
  31. package/lib/helpers/Permissions/PermissionFetcher.js +78 -0
  32. package/lib/helpers/Permissions/PermissionLabel.d.ts +2 -0
  33. package/lib/helpers/Permissions/PermissionLabel.js +42 -0
  34. package/lib/helpers/Permissions/PermissionMapper.d.ts +13 -0
  35. package/lib/helpers/Permissions/PermissionMapper.js +35 -0
  36. package/lib/helpers/Permissions/PermissionResource.d.ts +5 -0
  37. package/lib/helpers/Permissions/PermissionResource.js +31 -0
  38. package/lib/helpers/Permissions/PermissionSavingService.d.ts +13 -0
  39. package/lib/helpers/Permissions/PermissionSavingService.js +32 -0
  40. package/lib/helpers/Permissions/SavePermissionGroup.d.ts +6 -0
  41. package/lib/helpers/Permissions/SavePermissionGroup.js +32 -0
  42. package/lib/helpers/Permissions/UpdatePermissionGroup.d.ts +6 -0
  43. package/lib/helpers/Permissions/UpdatePermissionGroup.js +50 -0
  44. package/lib/helpers/Permissions/types.d.ts +17 -0
  45. package/lib/helpers/Permissions/types.js +2 -0
  46. package/lib/helpers/PopulationHelper.d.ts +12 -12
  47. package/lib/helpers/PopulationHelper.js +50 -50
  48. package/lib/helpers/ResourceGenerator.d.ts +9 -7
  49. package/lib/helpers/ResourceGenerator.js +172 -171
  50. package/lib/helpers/ResourceHelper.d.ts +28 -28
  51. package/lib/helpers/ResourceHelper.js +376 -376
  52. package/lib/helpers/SchemaGenerator.d.ts +5 -5
  53. package/lib/helpers/SchemaGenerator.js +96 -96
  54. package/lib/helpers/SchemaHelper.d.ts +5 -5
  55. package/lib/helpers/SchemaHelper.js +21 -21
  56. package/lib/locales/en.json +53 -53
  57. package/lib/middlewares/isAuth.d.ts +13 -13
  58. package/lib/middlewares/isAuth.js +43 -43
  59. package/lib/models/ModelNames.d.ts +7 -4
  60. package/lib/models/ModelNames.js +10 -7
  61. package/lib/models/adminpermission/AdminPermission.d.ts +6 -0
  62. package/lib/models/adminpermission/AdminPermission.js +23 -0
  63. package/lib/models/adminpermission/IAdminPermission.d.ts +13 -0
  64. package/lib/models/adminpermission/IAdminPermission.js +2 -0
  65. package/lib/models/customPage/CustomPage.d.ts +2 -2
  66. package/lib/models/customPage/CustomPage.js +38 -38
  67. package/lib/models/customPage/ICustomPage.d.ts +17 -17
  68. package/lib/models/customPage/ICustomPage.js +2 -2
  69. package/lib/models/file/File.d.ts +2 -2
  70. package/lib/models/file/File.js +23 -23
  71. package/lib/models/file/IFile.d.ts +15 -15
  72. package/lib/models/file/IFile.js +2 -2
  73. package/lib/models/location/ILocation.d.ts +14 -14
  74. package/lib/models/location/ILocation.js +2 -2
  75. package/lib/models/location/Location.d.ts +2 -2
  76. package/lib/models/location/Location.js +21 -21
  77. package/lib/models/modelConfiguration/IModelConfigurations.d.ts +29 -29
  78. package/lib/models/modelConfiguration/IModelConfigurations.js +2 -2
  79. package/lib/models/modelConfiguration/ModelConfiguration.d.ts +13 -13
  80. package/lib/models/modelConfiguration/ModelConfiguration.js +95 -95
  81. package/lib/models/permission/IPermission.d.ts +14 -0
  82. package/lib/models/permission/IPermission.js +2 -0
  83. package/lib/models/permission/Permission.d.ts +2 -0
  84. package/lib/models/permission/Permission.js +21 -0
  85. package/lib/models/request-log/IRequestLog.d.ts +22 -22
  86. package/lib/models/request-log/IRequestLog.js +2 -2
  87. package/lib/models/request-log/RequestLog.d.ts +3 -3
  88. package/lib/models/request-log/RequestLog.js +51 -51
  89. package/lib/repositories/DashboardRepository.d.ts +5 -5
  90. package/lib/repositories/DashboardRepository.js +12 -12
  91. package/lib/repositories/Repository.d.ts +68 -68
  92. package/lib/repositories/Repository.js +212 -212
  93. package/lib/repositories/RequestLogRepository.d.ts +10 -10
  94. package/lib/repositories/RequestLogRepository.js +54 -54
  95. package/lib/repositories/SaveResult.d.ts +14 -14
  96. package/lib/repositories/SaveResult.js +18 -18
  97. package/lib/router/index.d.ts +8 -8
  98. package/lib/router/index.js +104 -104
  99. package/lib/types/DashbordConfig.d.ts +21 -21
  100. package/lib/types/DashbordConfig.js +2 -2
  101. package/lib/types/IConfigurationFile.d.ts +6 -6
  102. package/lib/types/IConfigurationFile.js +2 -2
  103. package/lib/types/IResourceFile.d.ts +566 -566
  104. package/lib/types/IResourceFile.js +2 -2
  105. package/lib/types/IResourceResponse.d.ts +95 -95
  106. package/lib/types/IResourceResponse.js +2 -2
  107. package/lib/types/helpers.d.ts +60 -60
  108. package/lib/types/helpers.js +70 -70
  109. package/lib/utils/ResourceUtils.d.ts +2 -2
  110. package/lib/utils/ResourceUtils.js +7 -7
  111. package/lib/utils/ResponseUtils.d.ts +11 -11
  112. package/lib/utils/ResponseUtils.js +41 -41
  113. package/lib/utils/StringUtils.d.ts +9 -9
  114. package/lib/utils/StringUtils.js +46 -46
  115. package/lib/view/asset-manifest.json +18 -18
  116. package/lib/view/assets/icons/delete_icon.svg +3 -3
  117. package/lib/view/assets/icons/flags/ic_flag_cn.svg +9 -9
  118. package/lib/view/assets/icons/flags/ic_flag_sa.svg +9 -9
  119. package/lib/view/assets/icons/flags/ic_flag_vn.svg +9 -9
  120. package/lib/view/assets/icons/info_icon.svg +3 -3
  121. package/lib/view/assets/icons/navbar/ic_banking.svg +5 -5
  122. package/lib/view/assets/icons/navbar/ic_invoice.svg +4 -4
  123. package/lib/view/assets/icons/navbar/ic_kanban.svg +7 -7
  124. package/lib/view/assets/icons/navbar/ic_menu_item.svg +8 -8
  125. package/lib/view/assets/icons/small_info_icon.svg +3 -3
  126. package/lib/view/assets/illustrations/Group 16.svg +4 -4
  127. package/lib/view/assets/illustrations/logo.svg +5 -5
  128. package/lib/view/favicon/browserconfig.xml +9 -9
  129. package/lib/view/favicon/safari-pinned-tab.svg +182 -182
  130. package/lib/view/favicon/site.webmanifest +19 -19
  131. package/lib/view/fonts/index.css +18 -18
  132. package/lib/view/index.html +52 -52
  133. package/lib/view/manifest.json +20 -20
  134. package/lib/view/robots.txt +3 -3
  135. package/lib/view/static/css/main.54de06ef.css +1 -1
  136. package/lib/view/static/js/574.778b5963.chunk.js +1 -1
  137. package/lib/view/static/js/678.521704a3.chunk.js +1 -1
  138. package/lib/view/static/js/798.54856416.chunk.js +1 -1
  139. package/lib/view/static/js/main.4687f255.js +2 -2
  140. package/lib/view/static/js/main.4687f255.js.LICENSE.txt +214 -214
  141. package/package.json +51 -51
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.updatePermissionGroup = void 0;
13
+ function updatePermissionGroup(permissionGroupId, permissions, AdminPermission) {
14
+ var _a;
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ const permissionIdsMap = new Map();
17
+ const oldPermissions = yield AdminPermission.find({
18
+ permissionGroupId,
19
+ });
20
+ oldPermissions.forEach((oldPermission) => {
21
+ permissionIdsMap.set(oldPermission.permissionId.toString(), oldPermission);
22
+ });
23
+ const props = [];
24
+ for (const key in permissions) {
25
+ const data = permissions[key];
26
+ for (const permissionId in data) {
27
+ if (permissionId === "all" || permissionId === "opened") {
28
+ continue;
29
+ }
30
+ if (data[permissionId]) {
31
+ if (!permissionIdsMap.get(permissionId)) {
32
+ props.push({
33
+ permissionGroupId,
34
+ permissionId,
35
+ });
36
+ }
37
+ }
38
+ else {
39
+ if (permissionIdsMap.get(permissionId)) {
40
+ yield AdminPermission.remove({
41
+ _id: (_a = permissionIdsMap.get(permissionId)) === null || _a === void 0 ? void 0 : _a._id,
42
+ });
43
+ }
44
+ }
45
+ }
46
+ }
47
+ yield AdminPermission.insertMany(props);
48
+ });
49
+ }
50
+ exports.updatePermissionGroup = updatePermissionGroup;
@@ -0,0 +1,17 @@
1
+ export interface IPermission {
2
+ id: string;
3
+ modelName: string;
4
+ label: string;
5
+ checked: boolean;
6
+ key: string;
7
+ }
8
+ export interface IPermissions {
9
+ modelName: string;
10
+ label: string;
11
+ permissions: IPermission[];
12
+ }
13
+ export interface IPermissionData {
14
+ [modelName: string]: {
15
+ [actionKey: string]: boolean;
16
+ };
17
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,12 +1,12 @@
1
- import { IResourceFile } from "../types/IResourceFile";
2
- export declare enum PopulationType {
3
- LIST = "LIST",
4
- SHOW = "SHOW"
5
- }
6
- export declare class PopulationHelper {
7
- private resource;
8
- private populatedString;
9
- private populationType;
10
- constructor(resource: IResourceFile, populationType: PopulationType, populatedString: any);
11
- get(): Promise<any>;
12
- }
1
+ import { IResourceFile } from "../types/IResourceFile";
2
+ export declare enum PopulationType {
3
+ LIST = "LIST",
4
+ SHOW = "SHOW"
5
+ }
6
+ export declare class PopulationHelper {
7
+ private resource;
8
+ private populatedString;
9
+ private populationType;
10
+ constructor(resource: IResourceFile, populationType: PopulationType, populatedString: any);
11
+ get(): Promise<any>;
12
+ }
@@ -1,50 +1,50 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.PopulationHelper = exports.PopulationType = void 0;
13
- var PopulationType;
14
- (function (PopulationType) {
15
- PopulationType["LIST"] = "LIST";
16
- PopulationType["SHOW"] = "SHOW";
17
- })(PopulationType = exports.PopulationType || (exports.PopulationType = {}));
18
- class PopulationHelper {
19
- constructor(resource, populationType, populatedString) {
20
- this.resource = resource;
21
- this.populatedString = populatedString;
22
- this.populationType = populationType;
23
- }
24
- get() {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- const { populate } = this.resource.properties;
27
- if (!populate) {
28
- return this.populatedString;
29
- }
30
- if (!populate.all && !populate.list && !populate.show) {
31
- return this.populatedString;
32
- }
33
- if (populate.all) {
34
- return yield populate.all(this.populatedString);
35
- }
36
- if (this.populationType === PopulationType.LIST) {
37
- if (populate.list) {
38
- return yield populate.list(this.populatedString);
39
- }
40
- }
41
- else {
42
- if (populate.show) {
43
- return yield populate.show(this.populatedString);
44
- }
45
- }
46
- return this.populatedString;
47
- });
48
- }
49
- }
50
- exports.PopulationHelper = PopulationHelper;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PopulationHelper = exports.PopulationType = void 0;
13
+ var PopulationType;
14
+ (function (PopulationType) {
15
+ PopulationType["LIST"] = "LIST";
16
+ PopulationType["SHOW"] = "SHOW";
17
+ })(PopulationType = exports.PopulationType || (exports.PopulationType = {}));
18
+ class PopulationHelper {
19
+ constructor(resource, populationType, populatedString) {
20
+ this.resource = resource;
21
+ this.populatedString = populatedString;
22
+ this.populationType = populationType;
23
+ }
24
+ get() {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const { populate } = this.resource.properties;
27
+ if (!populate) {
28
+ return this.populatedString;
29
+ }
30
+ if (!populate.all && !populate.list && !populate.show) {
31
+ return this.populatedString;
32
+ }
33
+ if (populate.all) {
34
+ return yield populate.all(this.populatedString);
35
+ }
36
+ if (this.populationType === PopulationType.LIST) {
37
+ if (populate.list) {
38
+ return yield populate.list(this.populatedString);
39
+ }
40
+ }
41
+ else {
42
+ if (populate.show) {
43
+ return yield populate.show(this.populatedString);
44
+ }
45
+ }
46
+ return this.populatedString;
47
+ });
48
+ }
49
+ }
50
+ exports.PopulationHelper = PopulationHelper;
@@ -1,7 +1,9 @@
1
- import { Document } from "mongoose";
2
- import { IResourceFile } from "../types/IResourceFile";
3
- import { IConfiguartionFile } from "../types/IConfigurationFile";
4
- import { IModelConfigurationDocument } from "../models/modelConfiguration/IModelConfigurations";
5
- export default class ResourceGenerator {
6
- static generate(resource: IResourceFile, currentUser: Document, configurations?: IConfiguartionFile, modelConfigurations?: Map<string, IModelConfigurationDocument>): any;
7
- }
1
+ import { Document } from "mongoose";
2
+ import { IResourceFile } from "../types/IResourceFile";
3
+ import { IConfiguartionFile } from "../types/IConfigurationFile";
4
+ import { IModelConfigurationDocument } from "../models/modelConfiguration/IModelConfigurations";
5
+ export default class ResourceGenerator {
6
+ static generate(resource: IResourceFile, currentUser: Document, configurations?: IConfiguartionFile, modelConfigurations?: Map<string, IModelConfigurationDocument>, permissions?: {
7
+ [permissionKey: string]: boolean;
8
+ }): any;
9
+ }
@@ -1,171 +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) {
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 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);
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);
165
- }
166
- const actions = ActionsGenerator_1.default.generateActions(actionsCheck, resource, currentUser, modelConfiguration);
167
- modifiedResource.properties.actions = actions;
168
- return modifiedResource;
169
- }
170
- }
171
- 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;
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);
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);
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[]): 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[]): 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
+ }