identity-admin 1.9.1 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/controllers/DashboardController.d.ts +1 -1
- package/lib/controllers/DashboardController.js +20 -6
- package/lib/helpers/ResourceHelper.d.ts +4 -0
- package/lib/helpers/ResourceHelper.js +75 -12
- package/lib/locales/en.json +2 -1
- package/lib/router/index.js +3 -0
- package/lib/types/IResourceFile.d.ts +268 -80
- package/lib/types/IResourceResponse.d.ts +99 -0
- package/lib/types/IResourceResponse.js +2 -0
- package/lib/types/helpers.d.ts +12 -0
- package/lib/types/helpers.js +14 -1
- package/lib/view/asset-manifest.json +13 -8
- package/lib/view/index.html +52 -1
- package/lib/view/static/css/main.54de06ef.css +2 -0
- package/lib/view/static/css/main.54de06ef.css.map +1 -0
- package/lib/view/static/js/{148.b05fe2c8.chunk.js → 574.778b5963.chunk.js} +2 -1
- package/lib/view/static/js/574.778b5963.chunk.js.map +1 -0
- package/lib/view/static/js/678.521704a3.chunk.js +2 -0
- package/lib/view/static/js/678.521704a3.chunk.js.map +1 -0
- package/lib/view/static/js/798.54856416.chunk.js +2 -0
- package/lib/view/static/js/798.54856416.chunk.js.map +1 -0
- package/lib/view/static/js/admin.js +1 -0
- package/lib/view/static/js/main.4687f255.js +3 -0
- package/lib/view/static/js/{main.da8f09ec.js.LICENSE.txt → main.4687f255.js.LICENSE.txt} +4 -15
- package/lib/view/static/js/main.4687f255.js.map +1 -0
- package/package.json +1 -1
- package/lib/view/static/css/main.18dca458.css +0 -1
- package/lib/view/static/js/705.f86db82e.chunk.js +0 -1
- package/lib/view/static/js/802.3f287a2c.chunk.js +0 -1
- package/lib/view/static/js/main.da8f09ec.js +0 -2
|
@@ -27,7 +27,7 @@ export default class DashboardController {
|
|
|
27
27
|
}, scope: string): {
|
|
28
28
|
[key: string]: any;
|
|
29
29
|
};
|
|
30
|
-
protected getVisibileExtrsActions(currentUser: Document, record: any, resource:
|
|
30
|
+
protected getVisibileExtrsActions(currentUser: Document, record: any, resource: IResourceFile, repository: any, modelName: string): Promise<string[] | undefined>;
|
|
31
31
|
index(req: IRequest, res: Response): Promise<void | Response<any, Record<string, any>>>;
|
|
32
32
|
create(req: IRequest, res: Response): Promise<void>;
|
|
33
33
|
update(req: IRequest, res: Response): Promise<void | Response<any, Record<string, any>>>;
|
|
@@ -102,7 +102,7 @@ let DashboardController = DashboardController_1 = class DashboardController {
|
|
|
102
102
|
if (!extraAction.isVisible) {
|
|
103
103
|
break;
|
|
104
104
|
}
|
|
105
|
-
const isVisible = extraAction.isVisible(data);
|
|
105
|
+
const isVisible = yield extraAction.isVisible(data);
|
|
106
106
|
if (isVisible) {
|
|
107
107
|
extraActionsArray.push(extraAction.key);
|
|
108
108
|
}
|
|
@@ -140,7 +140,7 @@ let DashboardController = DashboardController_1 = class DashboardController {
|
|
|
140
140
|
var filter = {};
|
|
141
141
|
if (scope && resource.properties.filters && resource.properties.filters.scopes && resource.properties.filters.scopes.isAccessible) {
|
|
142
142
|
if (resource.properties.filters.scopes.manual) {
|
|
143
|
-
filter = resource.properties.filters.scopes.manual.handler(filter, scope);
|
|
143
|
+
filter = yield resource.properties.filters.scopes.manual.handler(filter, scope);
|
|
144
144
|
}
|
|
145
145
|
else if (resource.properties.filters.scopes.auto) {
|
|
146
146
|
const key = resource.properties.filters.scopes.auto.key;
|
|
@@ -154,8 +154,8 @@ let DashboardController = DashboardController_1 = class DashboardController {
|
|
|
154
154
|
}
|
|
155
155
|
filter = FiltersHelper_1.default.appendFilters(filter, filters);
|
|
156
156
|
const crudOperations = resource.properties.crudOperations;
|
|
157
|
-
if (crudOperations && crudOperations.index) {
|
|
158
|
-
filter = crudOperations.index.before(req, filter, currentUser);
|
|
157
|
+
if (crudOperations && crudOperations.index && crudOperations.index.before) {
|
|
158
|
+
filter = yield crudOperations.index.before(req, filter, currentUser);
|
|
159
159
|
}
|
|
160
160
|
var records = [];
|
|
161
161
|
var pageInfo = undefined;
|
|
@@ -189,6 +189,9 @@ let DashboardController = DashboardController_1 = class DashboardController {
|
|
|
189
189
|
documents.push(record);
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
+
if (crudOperations && crudOperations.index && crudOperations.index.after) {
|
|
193
|
+
documents = yield crudOperations.index.after(req, documents, currentUser);
|
|
194
|
+
}
|
|
192
195
|
return ResponseUtils_1.default.send(res, 200, 'OK', {
|
|
193
196
|
records: documents,
|
|
194
197
|
pageInfo,
|
|
@@ -213,8 +216,8 @@ let DashboardController = DashboardController_1 = class DashboardController {
|
|
|
213
216
|
const currentUser = req.user;
|
|
214
217
|
recordParams = LocalizedStringHelper_1.default.mapLocalizableString(recordParams, resource);
|
|
215
218
|
const crudOperations = resource.properties.crudOperations;
|
|
216
|
-
if (crudOperations && crudOperations.create) {
|
|
217
|
-
recordParams = crudOperations.create.before(req, recordParams, currentUser);
|
|
219
|
+
if (crudOperations && crudOperations.create && crudOperations.create.before) {
|
|
220
|
+
recordParams = yield crudOperations.create.before(req, recordParams, currentUser);
|
|
218
221
|
}
|
|
219
222
|
var record;
|
|
220
223
|
if (recordParams.password) {
|
|
@@ -228,6 +231,9 @@ let DashboardController = DashboardController_1 = class DashboardController {
|
|
|
228
231
|
if (!record.isValid() || !record.document) {
|
|
229
232
|
return ResponseUtils_1.default.unprocessable(res, 'Invalid Data', record.getErrors());
|
|
230
233
|
}
|
|
234
|
+
if (crudOperations && crudOperations.create && crudOperations.create.after) {
|
|
235
|
+
record = yield crudOperations.create.after(req, record, currentUser);
|
|
236
|
+
}
|
|
231
237
|
return ResponseUtils_1.default.created(res, {
|
|
232
238
|
record
|
|
233
239
|
});
|
|
@@ -247,10 +253,15 @@ let DashboardController = DashboardController_1 = class DashboardController {
|
|
|
247
253
|
const repository = (_c = this.repository) !== null && _c !== void 0 ? _c : new Repository_1.default(resource.properties.resource);
|
|
248
254
|
const recordId = req.params.id;
|
|
249
255
|
var recordParams = req.body;
|
|
256
|
+
const currentUser = req.user;
|
|
250
257
|
var record = yield repository.findById(recordId);
|
|
251
258
|
if (!record) {
|
|
252
259
|
return ResponseUtils_1.default.send(res, 404, 'record Not Found');
|
|
253
260
|
}
|
|
261
|
+
const crudOperations = resource.properties.crudOperations;
|
|
262
|
+
if (crudOperations && crudOperations.update && crudOperations.update.before) {
|
|
263
|
+
recordParams = yield crudOperations.update.before(req, recordParams, currentUser);
|
|
264
|
+
}
|
|
254
265
|
const recordSaveResult = yield repository.update(record, recordParams);
|
|
255
266
|
if (!recordSaveResult.isValid()) {
|
|
256
267
|
return ResponseUtils_1.default.unprocessable(res, 'Invalid Data', recordSaveResult.getErrors());
|
|
@@ -258,6 +269,9 @@ let DashboardController = DashboardController_1 = class DashboardController {
|
|
|
258
269
|
// if (resource.properties.modelName === ModelNames.Settings) {
|
|
259
270
|
// await AppSettings.run()
|
|
260
271
|
// }
|
|
272
|
+
// if (crudOperations && crudOperations.update && crudOperations.update.after) {
|
|
273
|
+
// recordSaveResult = await crudOperations.update.after(req, recordSaveResult, currentUser)
|
|
274
|
+
// }
|
|
261
275
|
return ResponseUtils_1.default.ok(res, {
|
|
262
276
|
record: recordSaveResult
|
|
263
277
|
});
|
|
@@ -2,6 +2,8 @@ import { IResourceFile } from "../types/IResourceFile";
|
|
|
2
2
|
export default class ResourcesHelper {
|
|
3
3
|
static getSchemaTitle(schema: any, resource: any): any;
|
|
4
4
|
static prepareProperties(properties: string[], modelName: string, model: any, resource: IResourceFile): {}[];
|
|
5
|
+
private static getPropertyObject;
|
|
6
|
+
private static getRawName;
|
|
5
7
|
static getFieldType(schemaField: any): any;
|
|
6
8
|
static prepareFilterProperties(properties: string[], schema: any): string[];
|
|
7
9
|
static checkResourceTranslation(resource: IResourceFile, key: string): string | undefined;
|
|
@@ -20,4 +22,6 @@ export default class ResourcesHelper {
|
|
|
20
22
|
static getModelPath(modelName: string): any;
|
|
21
23
|
static removeUnWantedFieldsFromCreateOrUpdate(arrayOfFields: string[]): string[];
|
|
22
24
|
static checkCreateBeforeHandler(resource: any): boolean;
|
|
25
|
+
private static checkNestedField;
|
|
26
|
+
private static getSchemaOfNestedProperty;
|
|
23
27
|
}
|
|
@@ -51,22 +51,49 @@ class ResourcesHelper {
|
|
|
51
51
|
var preparedProperties = [];
|
|
52
52
|
properties.forEach(key => {
|
|
53
53
|
if (model[key]) {
|
|
54
|
-
const refCheck = model[key].type ===
|
|
55
|
-
var path = undefined
|
|
56
|
-
if (refCheck) {
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
const translation = this.checkResourceTranslation(resource, key)
|
|
60
|
-
const propertyObject = {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
preparedProperties.push(
|
|
54
|
+
// const refCheck = model[key].type === FieldTypes.REFERENCE
|
|
55
|
+
// var path = undefined
|
|
56
|
+
// if (refCheck) {
|
|
57
|
+
// path = model[key].path
|
|
58
|
+
// }
|
|
59
|
+
// const translation = this.checkResourceTranslation(resource, key)
|
|
60
|
+
// const propertyObject = {
|
|
61
|
+
// key,
|
|
62
|
+
// value: translation? translation: StringUtils.checkRefId(key)? StringUtils.convertCamelCaseToWord(key.slice(0, -2)): StringUtils.convertCamelCaseToWord(key),
|
|
63
|
+
// path: path
|
|
64
|
+
// }
|
|
65
|
+
preparedProperties.push(this.getPropertyObject(key, model[key], resource));
|
|
66
|
+
}
|
|
67
|
+
else if (key.includes('.') && this.checkNestedField(key, model)) {
|
|
68
|
+
const nestedModel = this.getSchemaOfNestedProperty(key, model);
|
|
69
|
+
preparedProperties.push(this.getPropertyObject(key, nestedModel, resource));
|
|
66
70
|
}
|
|
67
71
|
});
|
|
68
72
|
return preparedProperties;
|
|
69
73
|
}
|
|
74
|
+
static getPropertyObject(key, model, resource) {
|
|
75
|
+
const refCheck = model.type === helpers_1.FieldTypes.REFERENCE;
|
|
76
|
+
var path = undefined;
|
|
77
|
+
if (refCheck) {
|
|
78
|
+
path = model.path;
|
|
79
|
+
}
|
|
80
|
+
const translation = this.checkResourceTranslation(resource, key);
|
|
81
|
+
var rawKey = this.getRawName(key);
|
|
82
|
+
const translatedKey = rawKey ? rawKey : key;
|
|
83
|
+
const propertyObject = {
|
|
84
|
+
key,
|
|
85
|
+
value: translation ? translation : model.value ? model.value : StringUtils_1.default.checkRefId(translatedKey) ? StringUtils_1.default.convertCamelCaseToWord(translatedKey.slice(0, -2)) : StringUtils_1.default.convertCamelCaseToWord(translatedKey),
|
|
86
|
+
path: path
|
|
87
|
+
};
|
|
88
|
+
return propertyObject;
|
|
89
|
+
}
|
|
90
|
+
static getRawName(key) {
|
|
91
|
+
if (key.includes('.')) {
|
|
92
|
+
const nestedProperties = key.split('.');
|
|
93
|
+
return (nestedProperties[nestedProperties.length - 1]);
|
|
94
|
+
}
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
70
97
|
static getFieldType(schemaField) {
|
|
71
98
|
if (schemaField.instance === 'Embedded') {
|
|
72
99
|
return helpers_1.FieldTypes.NESTEDSCHEMA;
|
|
@@ -301,5 +328,41 @@ class ResourcesHelper {
|
|
|
301
328
|
}
|
|
302
329
|
return false;
|
|
303
330
|
}
|
|
331
|
+
static checkNestedField(nestedProperty, model) {
|
|
332
|
+
const nestedProperties = nestedProperty.split('.');
|
|
333
|
+
if (nestedProperties.length === 0) {
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
const parentProperty = nestedProperties[0];
|
|
337
|
+
if (!model[parentProperty] || (!model[parentProperty].schema && nestedProperties.length > 1)) {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
if (nestedProperties.length === 1) {
|
|
341
|
+
return true;
|
|
342
|
+
}
|
|
343
|
+
var nextProperty = '';
|
|
344
|
+
for (var i = 1; i < nestedProperties.length; i++) {
|
|
345
|
+
nextProperty = nextProperty + nestedProperties[i];
|
|
346
|
+
if (i !== nestedProperties.length - 1) {
|
|
347
|
+
nextProperty = nextProperty + '.';
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return this.checkNestedField(nextProperty, model[parentProperty].schema);
|
|
351
|
+
}
|
|
352
|
+
static getSchemaOfNestedProperty(nestedProperty, model) {
|
|
353
|
+
const nestedProperties = nestedProperty.split('.');
|
|
354
|
+
const parentProperty = nestedProperties[0];
|
|
355
|
+
if (nestedProperties.length === 1) {
|
|
356
|
+
return model[parentProperty];
|
|
357
|
+
}
|
|
358
|
+
var nextProperty = '';
|
|
359
|
+
for (var i = 1; i < nestedProperties.length; i++) {
|
|
360
|
+
nextProperty = nextProperty + nestedProperties[i];
|
|
361
|
+
if (i !== nestedProperties.length - 1) {
|
|
362
|
+
nextProperty = nextProperty + '.';
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return this.getSchemaOfNestedProperty(nextProperty, model[parentProperty].schema);
|
|
366
|
+
}
|
|
304
367
|
}
|
|
305
368
|
exports.default = ResourcesHelper;
|
package/lib/locales/en.json
CHANGED
package/lib/router/index.js
CHANGED
|
@@ -47,6 +47,9 @@ const createMainRouter = (router, controller) => {
|
|
|
47
47
|
.route(`/api/:resource`)
|
|
48
48
|
.get((req, res) => controller.index(req, res))
|
|
49
49
|
.post((req, res) => controller.create(req, res));
|
|
50
|
+
router
|
|
51
|
+
.route('/api/all')
|
|
52
|
+
.delete((req, res) => controller.deleteAll(req, res));
|
|
50
53
|
router
|
|
51
54
|
.route("/api/:resource/:id")
|
|
52
55
|
.get((req, res) => controller.show(req, res))
|