identity-admin 1.28.21 → 1.28.23

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.
@@ -1,9 +1,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
- import { IModelConfigurationDocument } from "../models/modelConfiguration/IModelConfigurations";
6
- import { Model } from "mongoose";
1
+ import { Response } from 'express';
2
+ import { IResourceFile } from '../types/IResourceFile';
3
+ import { IRequest } from '../middlewares/isAuth';
4
+ import { IConfiguartionFile } from '../types/IConfigurationFile';
5
+ import { IModelConfigurationDocument } from '../models/modelConfiguration/IModelConfigurations';
6
+ import { Model } from 'mongoose';
7
7
  export default class ResourceController {
8
8
  protected resourceFiles: IResourceFile[];
9
9
  protected configurations: IConfiguartionFile | undefined;
@@ -68,35 +68,26 @@ let ResourceController = class ResourceController {
68
68
  modifiedResource.appConfigurations.showMainActions = (_a = modifiedResource.appConfigurations.showMainActions) !== null && _a !== void 0 ? _a : true;
69
69
  modifiedResource.appConfigurations.adminNotifications = (_b = modifiedResource.appConfigurations.adminNotifications) !== null && _b !== void 0 ? _b : false;
70
70
  }
71
+ const permissions = this.PermissionModel && currentUser.permissionGroupId ? yield PermissionResource_1.PermissionResource.get(currentUser.permissionGroupId, this.PermissionModel) : undefined;
71
72
  for (var i = 0; i < this.resourceFiles.length; i++) {
72
73
  const resource = this.resourceFiles[i];
73
- const isAllowed = resource.properties.isAllowed
74
- ? yield resource.properties.isAllowed(currentUser)
75
- : true;
76
- const isVisibile = resource.properties.isVisible
77
- ? yield resource.properties.isVisible(currentUser)
78
- : true;
74
+ const isAllowed = resource.properties.isAllowed ? yield resource.properties.isAllowed(currentUser) : true;
75
+ const isVisibile = resource.properties.isVisible ? yield resource.properties.isVisible(currentUser) : true;
79
76
  if (isAllowed) {
80
- const permissions = this.PermissionModel && currentUser.permissionGroupId
81
- ? yield PermissionResource_1.PermissionResource.get(currentUser.permissionGroupId, this.PermissionModel)
82
- : undefined;
83
- const adaptedResource = ResourceGenerator_1.default.generate(resource, currentUser, this.configurations, this.modelConfigurations, permissions ? permissions[resource.properties.modelName] : undefined);
77
+ const adaptedResource = ResourceGenerator_1.default.generate(resource, currentUser, this.configurations, this.modelConfigurations, permissions === null || permissions === void 0 ? void 0 : permissions[resource.properties.modelName]);
84
78
  const modelName = StringUtils_1.default.lowerCaseFirstLetter(adaptedResource.properties.modelName);
85
79
  modifiedResource[modelName] = adaptedResource;
86
- if (isVisibile &&
87
- (!permissions ||
88
- permissions[adaptedResource.properties.modelName][`${modelName}_view`])) {
80
+ if (isVisibile && (!permissions || permissions[adaptedResource.properties.modelName][`${modelName}_view`])) {
89
81
  if (modifiedResource.modelParents[adaptedResource.properties.parent.name]) {
90
82
  modifiedResource.modelParents[adaptedResource.properties.parent.name].push(modelName);
91
83
  }
92
84
  else {
93
- modifiedResource.modelParents[adaptedResource.properties.parent.name] = [];
94
- modifiedResource.modelParents[adaptedResource.properties.parent.name].push(modelName);
85
+ modifiedResource.modelParents[adaptedResource.properties.parent.name] = [modelName];
95
86
  }
96
87
  }
97
88
  }
98
89
  }
99
- return ResponseUtils_1.default.send(res, 200, "OK", {
90
+ return ResponseUtils_1.default.send(res, 200, 'OK', {
100
91
  resources: modifiedResource,
101
92
  });
102
93
  });
@@ -104,24 +95,24 @@ let ResourceController = class ResourceController {
104
95
  getOne(req, res) {
105
96
  return __awaiter(this, void 0, void 0, function* () {
106
97
  const modelName = req.params.modelName;
107
- const resourceName = modelName + "Resource";
108
- const resourceFilePath = "@pbb/materialUi/" + resourceName;
98
+ const resourceName = modelName + 'Resource';
99
+ const resourceFilePath = '@pbb/materialUi/' + resourceName;
109
100
  const resource = yield Promise.resolve().then(() => __importStar(require(resourceFilePath)));
110
101
  const currentUser = req.user;
111
- console.log("Single Resource", this.modelConfigurations);
112
- return ResponseUtils_1.default.send(res, 200, "OK", {
102
+ console.log('Single Resource', this.modelConfigurations);
103
+ return ResponseUtils_1.default.send(res, 200, 'OK', {
113
104
  options: ResourceGenerator_1.default.generate(resource[resourceName], currentUser, this.configurations, this.modelConfigurations),
114
105
  });
115
106
  });
116
107
  }
117
108
  };
118
109
  __decorate([
119
- (0, inversify_express_utils_1.httpGet)("/"),
110
+ (0, inversify_express_utils_1.httpGet)('/'),
120
111
  __param(0, (0, inversify_express_utils_1.request)()),
121
112
  __param(1, (0, inversify_express_utils_1.response)())
122
113
  ], ResourceController.prototype, "index", null);
123
114
  __decorate([
124
- (0, inversify_express_utils_1.httpGet)("/:modelName"),
115
+ (0, inversify_express_utils_1.httpGet)('/:modelName'),
125
116
  __param(0, (0, inversify_express_utils_1.request)()),
126
117
  __param(1, (0, inversify_express_utils_1.response)())
127
118
  ], ResourceController.prototype, "getOne", null);
@@ -60,7 +60,7 @@ class ActionsGenerator {
60
60
  return extraActionsObject;
61
61
  }
62
62
  static getActions(actions, currentUser, configuration) {
63
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
63
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
64
64
  var actionObject = {
65
65
  show: {
66
66
  isAccessible: ((_a = configuration === null || configuration === void 0 ? void 0 : configuration.actions) === null || _a === void 0 ? void 0 : _a.show) === false ? false : true,
@@ -70,20 +70,20 @@ class ActionsGenerator {
70
70
  isAccessible: ((_b = configuration === null || configuration === void 0 ? void 0 : configuration.actions) === null || _b === void 0 ? void 0 : _b.new) === false ? false : true,
71
71
  },
72
72
  duplicate: {
73
- isAccessible: ((_c = configuration === null || configuration === void 0 ? void 0 : configuration.actions) === null || _c === void 0 ? void 0 : _c.new) === false ? false : true,
73
+ isAccessible: ((_c = configuration === null || configuration === void 0 ? void 0 : configuration.actions) === null || _c === void 0 ? void 0 : _c.new) === false ? false : ((_d = configuration === null || configuration === void 0 ? void 0 : configuration.actions) === null || _d === void 0 ? void 0 : _d.duplicate) === false ? false : true,
74
74
  },
75
75
  edit: {
76
- isAccessible: ((_d = configuration === null || configuration === void 0 ? void 0 : configuration.actions) === null || _d === void 0 ? void 0 : _d.edit) === false ? false : true,
76
+ isAccessible: ((_e = configuration === null || configuration === void 0 ? void 0 : configuration.actions) === null || _e === void 0 ? void 0 : _e.edit) === false ? false : true,
77
77
  isMainAction: true,
78
78
  },
79
79
  delete: {
80
- isAccessible: ((_e = configuration === null || configuration === void 0 ? void 0 : configuration.actions) === null || _e === void 0 ? void 0 : _e.delete) === false ? false : true,
80
+ isAccessible: ((_f = configuration === null || configuration === void 0 ? void 0 : configuration.actions) === null || _f === void 0 ? void 0 : _f.delete) === false ? false : true,
81
81
  },
82
82
  import: {
83
- isAccessible: ((_f = configuration === null || configuration === void 0 ? void 0 : configuration.actions) === null || _f === void 0 ? void 0 : _f.import) === true ? true : false,
83
+ isAccessible: ((_g = configuration === null || configuration === void 0 ? void 0 : configuration.actions) === null || _g === void 0 ? void 0 : _g.import) === true ? true : false,
84
84
  },
85
85
  bulkDelete: {
86
- isAccessible: ((_g = configuration === null || configuration === void 0 ? void 0 : configuration.actions) === null || _g === void 0 ? void 0 : _g.bulkDelete) === true ? true : false,
86
+ isAccessible: ((_h = configuration === null || configuration === void 0 ? void 0 : configuration.actions) === null || _h === void 0 ? void 0 : _h.bulkDelete) === true ? true : false,
87
87
  },
88
88
  };
89
89
  if (!actions || Object.keys(actions).length === 0) {
@@ -101,8 +101,8 @@ class ActionsGenerator {
101
101
  else if (key === 'extras') {
102
102
  actionObject[key] = actions[key];
103
103
  }
104
- actionObject[key].reloadAfterAction = (_h = actions[key]) === null || _h === void 0 ? void 0 : _h.reloadAfterAction;
105
- actionObject[key].isMainAction = (_j = actions[key].isMainAction) !== null && _j !== void 0 ? _j : (key === 'edit' || key === 'show');
104
+ actionObject[key].reloadAfterAction = (_j = actions[key]) === null || _j === void 0 ? void 0 : _j.reloadAfterAction;
105
+ actionObject[key].isMainAction = (_k = actions[key].isMainAction) !== null && _k !== void 0 ? _k : (key === 'edit' || key === 'show');
106
106
  }
107
107
  return actionObject;
108
108
  }
@@ -7,6 +7,7 @@ export interface IModelConfigurationActions {
7
7
  delete?: boolean;
8
8
  bulkDelete?: boolean;
9
9
  import?: boolean;
10
+ duplicate?: boolean;
10
11
  }
11
12
  export interface IModelConfigurationProps {
12
13
  _id?: Types.ObjectId;
@@ -1,4 +1,4 @@
1
- import { Schema, SchemaOptions } from "mongoose";
1
+ import { Schema, SchemaOptions } from 'mongoose';
2
2
  export declare enum RowArrangeType {
3
3
  ASCENDING = "asc",
4
4
  DESCENDING = "desc"
@@ -40,6 +40,10 @@ const ActionSchema = new mongoose_1.Schema({
40
40
  type: Boolean,
41
41
  required: false,
42
42
  },
43
+ duplicate: {
44
+ type: Boolean,
45
+ required: false,
46
+ },
43
47
  }, { _id: false });
44
48
  function getModelConfiguartionSchema(schemaOptions) {
45
49
  return new mongoose_1.Schema({
@@ -68,7 +72,7 @@ function getModelConfiguartionSchema(schemaOptions) {
68
72
  },
69
73
  actions: {
70
74
  type: ActionSchema,
71
- required: false
75
+ required: false,
72
76
  },
73
77
  listProperties: [
74
78
  {
@@ -8,5 +8,6 @@ export interface IConfiguartionFile {
8
8
  adminNotifications?: boolean;
9
9
  baseApiUrl?: string;
10
10
  enableLocalization?: boolean;
11
+ disableDuplicateAction?: boolean;
11
12
  }
12
13
  export {};
@@ -451,6 +451,7 @@ interface ActionOptions {
451
451
  delete?: Action;
452
452
  import?: Action;
453
453
  bulkDelete?: Action;
454
+ duplicate?: Action;
454
455
  /**
455
456
  * Any extra action to be added.
456
457
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "identity-admin",
3
- "version": "1.28.21",
3
+ "version": "1.28.23",
4
4
  "description": "",
5
5
  "main": "lib/Dashboard.js",
6
6
  "types": "lib/Dashbord.d.ts",