identity-admin 1.25.24 → 1.26.1
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/README.md +126 -126
- package/lib/Dashboard.d.ts +14 -14
- package/lib/Dashboard.js +95 -95
- package/lib/container/helpers/HelperInversify.d.ts +6 -6
- package/lib/container/helpers/HelperInversify.js +10 -10
- package/lib/container/helpers/HelperTypes.d.ts +5 -5
- package/lib/container/helpers/HelperTypes.js +7 -7
- package/lib/container/index.d.ts +1 -1
- package/lib/container/index.js +14 -14
- package/lib/container/repositories/RepositoryInversify.d.ts +4 -4
- package/lib/container/repositories/RepositoryInversify.js +13 -13
- package/lib/container/repositories/RepositoryTypes.d.ts +4 -4
- package/lib/container/repositories/RepositoryTypes.js +6 -6
- package/lib/container/types.d.ts +8 -8
- package/lib/container/types.js +9 -9
- package/lib/controllers/ActionController.d.ts +8 -8
- package/lib/controllers/ActionController.js +79 -79
- package/lib/controllers/DashboardController.d.ts +43 -43
- package/lib/controllers/DashboardController.js +695 -695
- package/lib/controllers/ResourceController.d.ts +15 -15
- package/lib/controllers/ResourceController.js +134 -134
- package/lib/helpers/ActionsGenerator.d.ts +11 -11
- package/lib/helpers/ActionsGenerator.js +179 -179
- package/lib/helpers/FiltersHelper.d.ts +9 -9
- package/lib/helpers/FiltersHelper.js +113 -105
- package/lib/helpers/LocalesHelper.d.ts +4 -4
- package/lib/helpers/LocalesHelper.js +73 -73
- package/lib/helpers/LocalizedStringHelper.d.ts +9 -9
- package/lib/helpers/LocalizedStringHelper.js +57 -57
- package/lib/helpers/Permissions/PermissionFetcher.d.ts +7 -7
- package/lib/helpers/Permissions/PermissionFetcher.js +78 -78
- package/lib/helpers/Permissions/PermissionLabel.d.ts +2 -2
- package/lib/helpers/Permissions/PermissionLabel.js +42 -42
- package/lib/helpers/Permissions/PermissionMapper.d.ts +13 -13
- package/lib/helpers/Permissions/PermissionMapper.js +35 -35
- package/lib/helpers/Permissions/PermissionResource.d.ts +5 -5
- package/lib/helpers/Permissions/PermissionResource.js +31 -31
- package/lib/helpers/Permissions/PermissionSavingService.d.ts +13 -13
- package/lib/helpers/Permissions/PermissionSavingService.js +32 -32
- package/lib/helpers/Permissions/SavePermissionGroup.d.ts +6 -6
- package/lib/helpers/Permissions/SavePermissionGroup.js +32 -32
- package/lib/helpers/Permissions/UpdatePermissionGroup.d.ts +6 -6
- package/lib/helpers/Permissions/UpdatePermissionGroup.js +50 -50
- package/lib/helpers/Permissions/types.d.ts +17 -17
- package/lib/helpers/Permissions/types.js +2 -2
- package/lib/helpers/PopulationHelper.d.ts +12 -12
- package/lib/helpers/PopulationHelper.js +50 -50
- package/lib/helpers/ReportsGenerator.d.ts +11 -11
- package/lib/helpers/ReportsGenerator.js +57 -57
- package/lib/helpers/ResourceGenerator.d.ts +9 -9
- package/lib/helpers/ResourceGenerator.js +172 -172
- package/lib/helpers/ResourceHelper.d.ts +28 -28
- package/lib/helpers/ResourceHelper.js +393 -376
- package/lib/helpers/RportsGenerator.d.ts +10 -10
- package/lib/helpers/RportsGenerator.js +21 -21
- package/lib/helpers/SchemaGenerator.d.ts +5 -5
- package/lib/helpers/SchemaGenerator.js +97 -97
- package/lib/helpers/SchemaHelper.d.ts +5 -5
- package/lib/helpers/SchemaHelper.js +21 -21
- package/lib/locales/en.json +53 -53
- package/lib/middlewares/isAuth.d.ts +13 -13
- package/lib/middlewares/isAuth.js +43 -43
- package/lib/models/ModelNames.d.ts +7 -7
- package/lib/models/ModelNames.js +10 -10
- package/lib/models/adminpermission/AdminPermission.d.ts +6 -6
- package/lib/models/adminpermission/AdminPermission.js +23 -23
- package/lib/models/adminpermission/IAdminPermission.d.ts +13 -13
- package/lib/models/adminpermission/IAdminPermission.js +2 -2
- package/lib/models/customPage/CustomPage.d.ts +2 -2
- package/lib/models/customPage/CustomPage.js +38 -38
- package/lib/models/customPage/ICustomPage.d.ts +17 -17
- package/lib/models/customPage/ICustomPage.js +2 -2
- package/lib/models/file/File.d.ts +2 -2
- package/lib/models/file/File.js +23 -23
- package/lib/models/file/IFile.d.ts +15 -15
- package/lib/models/file/IFile.js +2 -2
- package/lib/models/location/ILocation.d.ts +14 -14
- package/lib/models/location/ILocation.js +2 -2
- package/lib/models/location/Location.d.ts +2 -2
- package/lib/models/location/Location.js +21 -21
- package/lib/models/modelConfiguration/IModelConfigurations.d.ts +29 -29
- package/lib/models/modelConfiguration/IModelConfigurations.js +2 -2
- package/lib/models/modelConfiguration/ModelConfiguration.d.ts +13 -13
- package/lib/models/modelConfiguration/ModelConfiguration.js +95 -95
- package/lib/models/permission/IPermission.d.ts +14 -14
- package/lib/models/permission/IPermission.js +2 -2
- package/lib/models/permission/Permission.d.ts +2 -2
- package/lib/models/permission/Permission.js +21 -21
- package/lib/models/request-log/IRequestLog.d.ts +22 -22
- package/lib/models/request-log/IRequestLog.js +2 -2
- package/lib/models/request-log/RequestLog.d.ts +3 -3
- package/lib/models/request-log/RequestLog.js +51 -51
- package/lib/pdf/ReportTemplate.d.ts +71 -71
- package/lib/pdf/ReportTemplate.js +94 -94
- package/lib/repositories/DashboardRepository.d.ts +5 -5
- package/lib/repositories/DashboardRepository.js +12 -12
- package/lib/repositories/Repository.d.ts +68 -68
- package/lib/repositories/Repository.js +212 -212
- package/lib/repositories/RequestLogRepository.d.ts +10 -10
- package/lib/repositories/RequestLogRepository.js +54 -54
- package/lib/repositories/SaveResult.d.ts +14 -14
- package/lib/repositories/SaveResult.js +18 -18
- package/lib/router/index.d.ts +8 -8
- package/lib/router/index.js +104 -104
- package/lib/types/DashbordConfig.d.ts +21 -21
- package/lib/types/DashbordConfig.js +2 -2
- package/lib/types/IConfigurationFile.d.ts +9 -9
- package/lib/types/IConfigurationFile.js +2 -2
- package/lib/types/IResourceFile.d.ts +633 -624
- package/lib/types/IResourceFile.js +2 -2
- package/lib/types/IResourceResponse.d.ts +95 -95
- package/lib/types/IResourceResponse.js +2 -2
- package/lib/types/helpers.d.ts +61 -61
- package/lib/types/helpers.js +71 -71
- package/lib/utils/ResourceUtils.d.ts +2 -2
- package/lib/utils/ResourceUtils.js +7 -7
- package/lib/utils/ResponseUtils.d.ts +11 -11
- package/lib/utils/ResponseUtils.js +41 -41
- package/lib/utils/StringUtils.d.ts +9 -9
- package/lib/utils/StringUtils.js +46 -46
- package/lib/view/asset-manifest.json +18 -18
- package/lib/view/assets/icons/delete_icon.svg +3 -3
- package/lib/view/assets/icons/flags/ic_flag_cn.svg +9 -9
- package/lib/view/assets/icons/flags/ic_flag_sa.svg +9 -9
- package/lib/view/assets/icons/flags/ic_flag_vn.svg +9 -9
- package/lib/view/assets/icons/info_icon.svg +3 -3
- package/lib/view/assets/icons/navbar/ic_banking.svg +5 -5
- package/lib/view/assets/icons/navbar/ic_invoice.svg +4 -4
- package/lib/view/assets/icons/navbar/ic_kanban.svg +7 -7
- package/lib/view/assets/icons/navbar/ic_menu_item.svg +8 -8
- package/lib/view/assets/icons/small_info_icon.svg +3 -3
- package/lib/view/assets/illustrations/Group 16.svg +4 -4
- package/lib/view/assets/illustrations/logo.svg +5 -5
- package/lib/view/favicon/browserconfig.xml +9 -9
- package/lib/view/favicon/safari-pinned-tab.svg +182 -182
- package/lib/view/favicon/site.webmanifest +19 -19
- package/lib/view/fonts/index.css +18 -18
- package/lib/view/index.html +52 -52
- package/lib/view/manifest.json +20 -20
- package/lib/view/robots.txt +3 -3
- package/lib/view/static/css/main.54de06ef.css +1 -1
- package/lib/view/static/js/574.778b5963.chunk.js +1 -1
- package/lib/view/static/js/678.521704a3.chunk.js +1 -1
- package/lib/view/static/js/798.54856416.chunk.js +1 -1
- package/lib/view/static/js/main.4687f255.js +2 -2
- package/lib/view/static/js/main.4687f255.js.LICENSE.txt +214 -214
- package/package.json +58 -58
|
@@ -1,57 +1,57 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const node_xlsx_1 = __importDefault(require("node-xlsx"));
|
|
16
|
-
const lodash_1 = require("lodash");
|
|
17
|
-
const helpers_1 = require("../types/helpers");
|
|
18
|
-
const pdfjs_1 = __importDefault(require("pdfjs"));
|
|
19
|
-
class ReportsGenerator {
|
|
20
|
-
static CreateXlsxFile(columns, data, name) {
|
|
21
|
-
const header = columns.map((field) => field.label);
|
|
22
|
-
const rows = data.map((row) => columns.map((field) => { var _a, _b; return (field.type === helpers_1.FieldTypes.OBJECTID ? (_b = (_a = (0, lodash_1.get)(row, field.value)) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '' : (0, lodash_1.get)(row, field.value)); }));
|
|
23
|
-
const sheets = [
|
|
24
|
-
{
|
|
25
|
-
name,
|
|
26
|
-
data: [header, ...rows],
|
|
27
|
-
options: {},
|
|
28
|
-
},
|
|
29
|
-
];
|
|
30
|
-
const buffer = node_xlsx_1.default.build(sheets);
|
|
31
|
-
return buffer;
|
|
32
|
-
}
|
|
33
|
-
static CreatePdfFile(columns, data, name) {
|
|
34
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const rows = data.map((row) => columns.map((field) => { var _a, _b; return (field.type === helpers_1.FieldTypes.OBJECTID ? (_b = (_a = (0, lodash_1.get)(row, field.value)) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '' : (0, lodash_1.get)(row, field.value)); }));
|
|
36
|
-
const doc = new pdfjs_1.default.Document({
|
|
37
|
-
width: 861.12,
|
|
38
|
-
font: require('pdfjs/font/Helvetica'),
|
|
39
|
-
});
|
|
40
|
-
const table = doc.table({
|
|
41
|
-
widths: columns.map(column => '*'),
|
|
42
|
-
borderWidth: 1,
|
|
43
|
-
});
|
|
44
|
-
const header = table.header({
|
|
45
|
-
backgroundColor: 0x000,
|
|
46
|
-
color: 0xffffff,
|
|
47
|
-
});
|
|
48
|
-
columns.map((field) => header.cell(field.label));
|
|
49
|
-
rows.forEach(row => {
|
|
50
|
-
const tableRow = table.row();
|
|
51
|
-
row.map(cell => tableRow.cell(`${cell !== null && cell !== void 0 ? cell : '---'}`));
|
|
52
|
-
});
|
|
53
|
-
return yield doc.asBuffer();
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.default = ReportsGenerator;
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const node_xlsx_1 = __importDefault(require("node-xlsx"));
|
|
16
|
+
const lodash_1 = require("lodash");
|
|
17
|
+
const helpers_1 = require("../types/helpers");
|
|
18
|
+
const pdfjs_1 = __importDefault(require("pdfjs"));
|
|
19
|
+
class ReportsGenerator {
|
|
20
|
+
static CreateXlsxFile(columns, data, name) {
|
|
21
|
+
const header = columns.map((field) => field.label);
|
|
22
|
+
const rows = data.map((row) => columns.map((field) => { var _a, _b; return (field.type === helpers_1.FieldTypes.OBJECTID ? (_b = (_a = (0, lodash_1.get)(row, field.value)) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '' : (0, lodash_1.get)(row, field.value)); }));
|
|
23
|
+
const sheets = [
|
|
24
|
+
{
|
|
25
|
+
name,
|
|
26
|
+
data: [header, ...rows],
|
|
27
|
+
options: {},
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
const buffer = node_xlsx_1.default.build(sheets);
|
|
31
|
+
return buffer;
|
|
32
|
+
}
|
|
33
|
+
static CreatePdfFile(columns, data, name) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const rows = data.map((row) => columns.map((field) => { var _a, _b; return (field.type === helpers_1.FieldTypes.OBJECTID ? (_b = (_a = (0, lodash_1.get)(row, field.value)) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '' : (0, lodash_1.get)(row, field.value)); }));
|
|
36
|
+
const doc = new pdfjs_1.default.Document({
|
|
37
|
+
width: 861.12,
|
|
38
|
+
font: require('pdfjs/font/Helvetica'),
|
|
39
|
+
});
|
|
40
|
+
const table = doc.table({
|
|
41
|
+
widths: columns.map(column => '*'),
|
|
42
|
+
borderWidth: 1,
|
|
43
|
+
});
|
|
44
|
+
const header = table.header({
|
|
45
|
+
backgroundColor: 0x000,
|
|
46
|
+
color: 0xffffff,
|
|
47
|
+
});
|
|
48
|
+
columns.map((field) => header.cell(field.label));
|
|
49
|
+
rows.forEach(row => {
|
|
50
|
+
const tableRow = table.row();
|
|
51
|
+
row.map(cell => tableRow.cell(`${cell !== null && cell !== void 0 ? cell : '---'}`));
|
|
52
|
+
});
|
|
53
|
+
return yield doc.asBuffer();
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.default = ReportsGenerator;
|
|
@@ -1,9 +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>, permissions?: {
|
|
7
|
-
[permissionKey: string]: boolean;
|
|
8
|
-
}): any;
|
|
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>, permissions?: {
|
|
7
|
+
[permissionKey: string]: boolean;
|
|
8
|
+
}): any;
|
|
9
|
+
}
|
|
@@ -1,172 +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, 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
|
+
"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
|
|
2
|
-
import { IModelConfigurationDocument } from
|
|
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
|
+
}
|