cloud-ide-lms-model 1.0.54 → 1.0.57
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/model/core/menu.js
CHANGED
|
@@ -12,6 +12,13 @@ class MMenu {
|
|
|
12
12
|
if (!this.syme_id && !this.syme_type) {
|
|
13
13
|
errorLogger.syme_id = "System menu ID or menu Type is Required!";
|
|
14
14
|
}
|
|
15
|
+
else {
|
|
16
|
+
if (this.syme_type === 'module') {
|
|
17
|
+
if (typeof (this === null || this === void 0 ? void 0 : this.syme_title) === 'undefined') {
|
|
18
|
+
errorLogger.syme_title = "System menu title is Required!";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
15
22
|
if (!this.sort) {
|
|
16
23
|
errorLogger.sort = "sort order is Required!";
|
|
17
24
|
}
|
|
@@ -1,9 +1,26 @@
|
|
|
1
|
+
import { MRequestMiddelware } from "../../common-types";
|
|
1
2
|
declare abstract class MErrorLoggerHelper {
|
|
2
3
|
[key: string]: string;
|
|
3
4
|
}
|
|
4
5
|
declare class ErrorLoggerResponseHelper {
|
|
5
6
|
errorLogged: MErrorLoggerHelper;
|
|
6
7
|
}
|
|
8
|
+
interface IValidateRequestModalResponse {
|
|
9
|
+
errorLogger: MErrorLoggerHelper | true;
|
|
10
|
+
first: string | undefined;
|
|
11
|
+
values: string[];
|
|
12
|
+
keys: string[];
|
|
13
|
+
keysValues: string[][];
|
|
14
|
+
}
|
|
7
15
|
declare function errorLoggerRegister(errorLoggerRegister: MErrorLoggerHelper): void;
|
|
8
16
|
declare function errorLoggerResponse(errorLoggerResponse: ErrorLoggerResponseHelper): MErrorLoggerHelper | true;
|
|
9
|
-
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param payload - payload of the request to be validated
|
|
20
|
+
* @returns - true if the request is valid, otherwise returns an object with error messages
|
|
21
|
+
* @description - this function is used to validate the request payload. if the payload has a Validate function, it will be called and the response will be returned. if the response has any error messages, it will be returned as an object with error messages. if there are no error messages, true will be returned.
|
|
22
|
+
* @example - validateRequestModal({ Validate: () => { return { name: "Name is required" } } }) // returns { name: "Name is required" }
|
|
23
|
+
* @example - validateRequestModal({ Validate: () => { return {} } }) // returns true
|
|
24
|
+
*/
|
|
25
|
+
declare const validateRequestModal: (payload: MRequestMiddelware) => IValidateRequestModalResponse | true;
|
|
26
|
+
export { errorLoggerRegister, MErrorLoggerHelper, errorLoggerResponse, ErrorLoggerResponseHelper, validateRequestModal };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ErrorLoggerResponseHelper = exports.errorLoggerResponse = exports.MErrorLoggerHelper = exports.errorLoggerRegister = void 0;
|
|
3
|
+
exports.validateRequestModal = exports.ErrorLoggerResponseHelper = exports.errorLoggerResponse = exports.MErrorLoggerHelper = exports.errorLoggerRegister = void 0;
|
|
4
4
|
class MErrorLoggerHelper {
|
|
5
5
|
}
|
|
6
6
|
exports.MErrorLoggerHelper = MErrorLoggerHelper;
|
|
@@ -20,3 +20,28 @@ function errorLoggerResponse(errorLoggerResponse) {
|
|
|
20
20
|
return true;
|
|
21
21
|
}
|
|
22
22
|
exports.errorLoggerResponse = errorLoggerResponse;
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param payload - payload of the request to be validated
|
|
26
|
+
* @returns - true if the request is valid, otherwise returns an object with error messages
|
|
27
|
+
* @description - this function is used to validate the request payload. if the payload has a Validate function, it will be called and the response will be returned. if the response has any error messages, it will be returned as an object with error messages. if there are no error messages, true will be returned.
|
|
28
|
+
* @example - validateRequestModal({ Validate: () => { return { name: "Name is required" } } }) // returns { name: "Name is required" }
|
|
29
|
+
* @example - validateRequestModal({ Validate: () => { return {} } }) // returns true
|
|
30
|
+
*/
|
|
31
|
+
const validateRequestModal = (payload) => {
|
|
32
|
+
let errorLogger = {};
|
|
33
|
+
if (payload.Validate) {
|
|
34
|
+
errorLogger = payload.Validate();
|
|
35
|
+
}
|
|
36
|
+
if (Object.keys(errorLogger).length > 0) {
|
|
37
|
+
return {
|
|
38
|
+
errorLogger: errorLogger,
|
|
39
|
+
first: Object.keys(errorLogger)[0],
|
|
40
|
+
values: Object.values(errorLogger),
|
|
41
|
+
keys: Object.keys(errorLogger),
|
|
42
|
+
keysValues: Object.entries(errorLogger)
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
};
|
|
47
|
+
exports.validateRequestModal = validateRequestModal;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
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
2
|
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
3
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
4
|
var m = o[Symbol.asyncIterator], i;
|
|
@@ -17,165 +8,163 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
|
17
8
|
};
|
|
18
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
10
|
exports.cidePath = exports.stringInterpolation = void 0;
|
|
20
|
-
function stringInterpolation(variables, body, data) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const data = {
|
|
34
|
-
user: {
|
|
35
|
-
status: 'active',
|
|
36
|
-
name: 'John Doe',
|
|
37
|
-
fullName: 'John Doe Jr.',
|
|
38
|
-
},
|
|
39
|
-
entity: {
|
|
40
|
-
name: 'Acme Corp',
|
|
41
|
-
data: [
|
|
42
|
-
{ login: '2 days ago' },
|
|
43
|
-
{ login: '3 days ago' },
|
|
44
|
-
],
|
|
45
|
-
address: {
|
|
46
|
-
city: 'Metropolis',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const template = 'Hello, {userName}! Your status is {status}. Full name is {userFullName}.' +
|
|
53
|
-
'[entity-data] This is the row for login time: {entityLoginTime}. [/entity-data]' +
|
|
54
|
-
'Your entity is {entityName}. The city is {entityAddress}.';
|
|
11
|
+
async function stringInterpolation(variables, body, data) {
|
|
12
|
+
/*
|
|
13
|
+
const placeholders = {
|
|
14
|
+
'status': 'user.status',
|
|
15
|
+
'userName': 'user.name',
|
|
16
|
+
'userFullName': 'user.fullName',
|
|
17
|
+
'entityName': 'entity.name',
|
|
18
|
+
'entityLoginTime': 'entity.data~login',
|
|
19
|
+
'entityAddress': 'entity.address.city',
|
|
20
|
+
};
|
|
55
21
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
22
|
+
|
|
23
|
+
const data = {
|
|
24
|
+
user: {
|
|
25
|
+
status: 'active',
|
|
26
|
+
name: 'John Doe',
|
|
27
|
+
fullName: 'John Doe Jr.',
|
|
28
|
+
},
|
|
29
|
+
entity: {
|
|
30
|
+
name: 'Acme Corp',
|
|
31
|
+
data: [
|
|
32
|
+
{ login: '2 days ago' },
|
|
33
|
+
{ login: '3 days ago' },
|
|
34
|
+
],
|
|
35
|
+
address: {
|
|
36
|
+
city: 'Metropolis',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
const template = 'Hello, {userName}! Your status is {status}. Full name is {userFullName}.' +
|
|
43
|
+
'[entity-data] This is the row for login time: {entityLoginTime}. [/entity-data]' +
|
|
44
|
+
'Your entity is {entityName}. The city is {entityAddress}.';
|
|
45
|
+
|
|
46
|
+
*/
|
|
47
|
+
var _a, e_1, _b, _c, _d, e_2, _e, _f, _g, e_3, _h, _j;
|
|
48
|
+
var _k, _l, _m;
|
|
49
|
+
let bodyArray = body.split("//");
|
|
50
|
+
let replacedBody = [];
|
|
51
|
+
try {
|
|
52
|
+
for (var _o = true, bodyArray_1 = __asyncValues(bodyArray), bodyArray_1_1; bodyArray_1_1 = await bodyArray_1.next(), _a = bodyArray_1_1.done, !_a; _o = true) {
|
|
53
|
+
_c = bodyArray_1_1.value;
|
|
54
|
+
_o = false;
|
|
55
|
+
const body_row = _c;
|
|
56
|
+
let body_row_init = [body_row];
|
|
57
|
+
if (body_row.includes('[')) {
|
|
58
|
+
body_row_init = [];
|
|
59
|
+
let row_count = 0;
|
|
60
|
+
let variable_array = body_row.slice(1, (body_row === null || body_row === void 0 ? void 0 : body_row.indexOf(']')));
|
|
61
|
+
if (variable_array === null || variable_array === void 0 ? void 0 : variable_array.includes("-")) {
|
|
62
|
+
let spilited_variable_array = variable_array === null || variable_array === void 0 ? void 0 : variable_array.split("-");
|
|
63
|
+
if ((spilited_variable_array === null || spilited_variable_array === void 0 ? void 0 : spilited_variable_array.length) == 2) {
|
|
64
|
+
row_count = (_k = data[spilited_variable_array[0]][spilited_variable_array[1]]) === null || _k === void 0 ? void 0 : _k.length;
|
|
82
65
|
}
|
|
83
66
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
row_data = row_data[array_data_path[0]][array_data_path[1]][array_data_path[2]][array_data_path[3]][index];
|
|
118
|
-
}
|
|
119
|
-
if ((array_data_path === null || array_data_path === void 0 ? void 0 : array_data_path.length) == 5) {
|
|
120
|
-
row_data = row_data[array_data_path[0]][array_data_path[1]][array_data_path[2]][array_data_path[3]][array_data_path[4]][index];
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
row_data = row_data[variable];
|
|
125
|
-
}
|
|
126
|
-
variable = variable_array_index[1];
|
|
127
|
-
}
|
|
128
|
-
if (variable === null || variable === void 0 ? void 0 : variable.includes("-")) {
|
|
129
|
-
let array_data_path = variable.split("-");
|
|
67
|
+
else {
|
|
68
|
+
row_count = (_l = data[variable_array]) === null || _l === void 0 ? void 0 : _l.length;
|
|
69
|
+
}
|
|
70
|
+
for (let i = 0; i < row_count; i++) {
|
|
71
|
+
body_row_init.push("[" + i + "]" + body_row.slice(((body_row === null || body_row === void 0 ? void 0 : body_row.indexOf(']')) + 1)));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
for (var _p = true, body_row_init_1 = (e_2 = void 0, __asyncValues(body_row_init)), body_row_init_1_1; body_row_init_1_1 = await body_row_init_1.next(), _d = body_row_init_1_1.done, !_d; _p = true) {
|
|
76
|
+
_f = body_row_init_1_1.value;
|
|
77
|
+
_p = false;
|
|
78
|
+
let body_row_init_row = _f;
|
|
79
|
+
let replacedRow = [];
|
|
80
|
+
let index = 0;
|
|
81
|
+
if (body_row_init_row === null || body_row_init_row === void 0 ? void 0 : body_row_init_row.includes("[")) {
|
|
82
|
+
index = parseInt(body_row_init_row === null || body_row_init_row === void 0 ? void 0 : body_row_init_row.slice(1, ((body_row_init_row === null || body_row_init_row === void 0 ? void 0 : body_row_init_row.indexOf(']')) + 1)));
|
|
83
|
+
body_row_init_row = body_row_init_row === null || body_row_init_row === void 0 ? void 0 : body_row_init_row.slice((body_row_init_row === null || body_row_init_row === void 0 ? void 0 : body_row_init_row.indexOf(']')) + 1);
|
|
84
|
+
}
|
|
85
|
+
let row_array = body_row_init_row.split("\\");
|
|
86
|
+
try {
|
|
87
|
+
for (var _q = true, row_array_1 = (e_3 = void 0, __asyncValues(row_array)), row_array_1_1; row_array_1_1 = await row_array_1.next(), _g = row_array_1_1.done, !_g; _q = true) {
|
|
88
|
+
_j = row_array_1_1.value;
|
|
89
|
+
_q = false;
|
|
90
|
+
const row_splited = _j;
|
|
91
|
+
let updated_row = row_splited;
|
|
92
|
+
if ((updated_row === null || updated_row === void 0 ? void 0 : updated_row.length) > 2) {
|
|
93
|
+
let row_data = data;
|
|
94
|
+
if (updated_row[0] == "{" && updated_row[(updated_row === null || updated_row === void 0 ? void 0 : updated_row.length) - 1] == "}") {
|
|
95
|
+
let variable = variables[updated_row.slice(1, ((updated_row === null || updated_row === void 0 ? void 0 : updated_row.length) - 1))];
|
|
96
|
+
if (variable === null || variable === void 0 ? void 0 : variable.includes("~")) {
|
|
97
|
+
let variable_array_index = variable === null || variable === void 0 ? void 0 : variable.split("~");
|
|
98
|
+
if ((_m = variable_array_index[0]) === null || _m === void 0 ? void 0 : _m.includes("-")) {
|
|
99
|
+
let array_data_path = variable_array_index[0].split("-");
|
|
130
100
|
if ((array_data_path === null || array_data_path === void 0 ? void 0 : array_data_path.length) == 2) {
|
|
131
|
-
|
|
101
|
+
row_data = row_data[array_data_path[0]][array_data_path[1]][index];
|
|
132
102
|
}
|
|
133
103
|
if ((array_data_path === null || array_data_path === void 0 ? void 0 : array_data_path.length) == 3) {
|
|
134
|
-
|
|
104
|
+
row_data = row_data[array_data_path[0]][array_data_path[1]][array_data_path[2]][index];
|
|
135
105
|
}
|
|
136
106
|
if ((array_data_path === null || array_data_path === void 0 ? void 0 : array_data_path.length) == 4) {
|
|
137
|
-
|
|
107
|
+
row_data = row_data[array_data_path[0]][array_data_path[1]][array_data_path[2]][array_data_path[3]][index];
|
|
138
108
|
}
|
|
139
109
|
if ((array_data_path === null || array_data_path === void 0 ? void 0 : array_data_path.length) == 5) {
|
|
140
|
-
|
|
110
|
+
row_data = row_data[array_data_path[0]][array_data_path[1]][array_data_path[2]][array_data_path[3]][array_data_path[4]][index];
|
|
141
111
|
}
|
|
142
112
|
}
|
|
143
113
|
else {
|
|
144
|
-
|
|
114
|
+
row_data = row_data[variable];
|
|
145
115
|
}
|
|
116
|
+
variable = variable_array_index[1];
|
|
117
|
+
}
|
|
118
|
+
if (variable === null || variable === void 0 ? void 0 : variable.includes("-")) {
|
|
119
|
+
let array_data_path = variable.split("-");
|
|
120
|
+
if ((array_data_path === null || array_data_path === void 0 ? void 0 : array_data_path.length) == 2) {
|
|
121
|
+
updated_row = row_data[array_data_path[0]][array_data_path[1]];
|
|
122
|
+
}
|
|
123
|
+
if ((array_data_path === null || array_data_path === void 0 ? void 0 : array_data_path.length) == 3) {
|
|
124
|
+
updated_row = row_data[array_data_path[0]][array_data_path[1]][array_data_path[2]];
|
|
125
|
+
}
|
|
126
|
+
if ((array_data_path === null || array_data_path === void 0 ? void 0 : array_data_path.length) == 4) {
|
|
127
|
+
updated_row = row_data[array_data_path[0]][array_data_path[1]][array_data_path[2]][array_data_path[3]];
|
|
128
|
+
}
|
|
129
|
+
if ((array_data_path === null || array_data_path === void 0 ? void 0 : array_data_path.length) == 5) {
|
|
130
|
+
updated_row = row_data[array_data_path[0]][array_data_path[1]][array_data_path[2]][array_data_path[3]][array_data_path[4]];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
updated_row = row_data[variable];
|
|
146
135
|
}
|
|
147
136
|
}
|
|
148
|
-
replacedRow.push(updated_row);
|
|
149
137
|
}
|
|
138
|
+
replacedRow.push(updated_row);
|
|
150
139
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
finally { if (e_3) throw e_3.error; }
|
|
140
|
+
}
|
|
141
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
142
|
+
finally {
|
|
143
|
+
try {
|
|
144
|
+
if (!_q && !_g && (_h = row_array_1.return)) await _h.call(row_array_1);
|
|
157
145
|
}
|
|
158
|
-
|
|
146
|
+
finally { if (e_3) throw e_3.error; }
|
|
159
147
|
}
|
|
148
|
+
replacedBody.push(replacedRow === null || replacedRow === void 0 ? void 0 : replacedRow.join(""));
|
|
160
149
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
finally { if (e_2) throw e_2.error; }
|
|
150
|
+
}
|
|
151
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
152
|
+
finally {
|
|
153
|
+
try {
|
|
154
|
+
if (!_p && !_d && (_e = body_row_init_1.return)) await _e.call(body_row_init_1);
|
|
167
155
|
}
|
|
156
|
+
finally { if (e_2) throw e_2.error; }
|
|
168
157
|
}
|
|
169
158
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
finally { if (e_1) throw e_1.error; }
|
|
159
|
+
}
|
|
160
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
161
|
+
finally {
|
|
162
|
+
try {
|
|
163
|
+
if (!_o && !_a && (_b = bodyArray_1.return)) await _b.call(bodyArray_1);
|
|
176
164
|
}
|
|
177
|
-
|
|
178
|
-
}
|
|
165
|
+
finally { if (e_1) throw e_1.error; }
|
|
166
|
+
}
|
|
167
|
+
return replacedBody.join("");
|
|
179
168
|
}
|
|
180
169
|
exports.stringInterpolation = stringInterpolation;
|
|
181
170
|
exports.cidePath = {
|