cloud-ide-lms-model 1.0.53 → 1.0.56

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.
@@ -9,11 +9,14 @@ class MMenu {
9
9
  }
10
10
  Validate() {
11
11
  let errorLogger = {};
12
- if (!this.syme_id) {
13
- errorLogger.syme_id = "System menu ID is Required!";
12
+ if (!this.syme_id && !this.syme_type) {
13
+ errorLogger.syme_id = "System menu ID or menu Type is Required!";
14
14
  }
15
15
  else {
16
- if (this.syme_id == 'module') {
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
+ }
17
20
  }
18
21
  }
19
22
  if (!this.sort) {
@@ -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
- export { errorLoggerRegister, MErrorLoggerHelper, errorLoggerResponse, ErrorLoggerResponseHelper };
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,29 @@ 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
+ var _a;
33
+ let errorLogger = {};
34
+ if (payload.Validate) {
35
+ errorLogger = payload.Validate();
36
+ }
37
+ if (Object.keys(errorLogger).length > 0) {
38
+ return {
39
+ errorLogger: errorLogger,
40
+ first: (_a = Object.keys(errorLogger)) === null || _a === void 0 ? void 0 : _a[0],
41
+ values: Object.values(errorLogger),
42
+ keys: Object.keys(errorLogger),
43
+ keysValues: Object.entries(errorLogger)
44
+ };
45
+ }
46
+ return true;
47
+ };
48
+ 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
- return __awaiter(this, void 0, void 0, function* () {
22
- /*
23
- const placeholders = {
24
- 'status': 'user.status',
25
- 'userName': 'user.name',
26
- 'userFullName': 'user.fullName',
27
- 'entityName': 'entity.name',
28
- 'entityLoginTime': 'entity.data~login',
29
- 'entityAddress': 'entity.address.city',
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
- var _a, e_1, _b, _c, _d, e_2, _e, _f, _g, e_3, _h, _j;
58
- var _k, _l, _m;
59
- let bodyArray = body.split("//");
60
- let replacedBody = [];
61
- try {
62
- for (var _o = true, bodyArray_1 = __asyncValues(bodyArray), bodyArray_1_1; bodyArray_1_1 = yield bodyArray_1.next(), _a = bodyArray_1_1.done, !_a; _o = true) {
63
- _c = bodyArray_1_1.value;
64
- _o = false;
65
- const body_row = _c;
66
- let body_row_init = [body_row];
67
- if (body_row.includes('[')) {
68
- body_row_init = [];
69
- let row_count = 0;
70
- let variable_array = body_row.slice(1, (body_row === null || body_row === void 0 ? void 0 : body_row.indexOf(']')));
71
- if (variable_array === null || variable_array === void 0 ? void 0 : variable_array.includes("-")) {
72
- let spilited_variable_array = variable_array === null || variable_array === void 0 ? void 0 : variable_array.split("-");
73
- if ((spilited_variable_array === null || spilited_variable_array === void 0 ? void 0 : spilited_variable_array.length) == 2) {
74
- row_count = (_k = data[spilited_variable_array[0]][spilited_variable_array[1]]) === null || _k === void 0 ? void 0 : _k.length;
75
- }
76
- }
77
- else {
78
- row_count = (_l = data[variable_array]) === null || _l === void 0 ? void 0 : _l.length;
79
- }
80
- for (let i = 0; i < row_count; i++) {
81
- body_row_init.push("[" + i + "]" + body_row.slice(((body_row === null || body_row === void 0 ? void 0 : body_row.indexOf(']')) + 1)));
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
- try {
85
- 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 = yield body_row_init_1.next(), _d = body_row_init_1_1.done, !_d; _p = true) {
86
- _f = body_row_init_1_1.value;
87
- _p = false;
88
- let body_row_init_row = _f;
89
- let replacedRow = [];
90
- let index = 0;
91
- if (body_row_init_row === null || body_row_init_row === void 0 ? void 0 : body_row_init_row.includes("[")) {
92
- 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)));
93
- 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);
94
- }
95
- let row_array = body_row_init_row.split("\\");
96
- try {
97
- for (var _q = true, row_array_1 = (e_3 = void 0, __asyncValues(row_array)), row_array_1_1; row_array_1_1 = yield row_array_1.next(), _g = row_array_1_1.done, !_g; _q = true) {
98
- _j = row_array_1_1.value;
99
- _q = false;
100
- const row_splited = _j;
101
- let updated_row = row_splited;
102
- if ((updated_row === null || updated_row === void 0 ? void 0 : updated_row.length) > 2) {
103
- let row_data = data;
104
- if (updated_row[0] == "{" && updated_row[(updated_row === null || updated_row === void 0 ? void 0 : updated_row.length) - 1] == "}") {
105
- let variable = variables[updated_row.slice(1, ((updated_row === null || updated_row === void 0 ? void 0 : updated_row.length) - 1))];
106
- if (variable === null || variable === void 0 ? void 0 : variable.includes("~")) {
107
- let variable_array_index = variable === null || variable === void 0 ? void 0 : variable.split("~");
108
- if ((_m = variable_array_index[0]) === null || _m === void 0 ? void 0 : _m.includes("-")) {
109
- let array_data_path = variable_array_index[0].split("-");
110
- if ((array_data_path === null || array_data_path === void 0 ? void 0 : array_data_path.length) == 2) {
111
- row_data = row_data[array_data_path[0]][array_data_path[1]][index];
112
- }
113
- if ((array_data_path === null || array_data_path === void 0 ? void 0 : array_data_path.length) == 3) {
114
- row_data = row_data[array_data_path[0]][array_data_path[1]][array_data_path[2]][index];
115
- }
116
- if ((array_data_path === null || array_data_path === void 0 ? void 0 : array_data_path.length) == 4) {
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
- updated_row = row_data[array_data_path[0]][array_data_path[1]];
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
- updated_row = row_data[array_data_path[0]][array_data_path[1]][array_data_path[2]];
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
- updated_row = row_data[array_data_path[0]][array_data_path[1]][array_data_path[2]][array_data_path[3]];
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
- updated_row = row_data[array_data_path[0]][array_data_path[1]][array_data_path[2]][array_data_path[3]][array_data_path[4]];
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
- updated_row = row_data[variable];
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
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
152
- finally {
153
- try {
154
- if (!_q && !_g && (_h = row_array_1.return)) yield _h.call(row_array_1);
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
- replacedBody.push(replacedRow === null || replacedRow === void 0 ? void 0 : replacedRow.join(""));
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
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
162
- finally {
163
- try {
164
- if (!_p && !_d && (_e = body_row_init_1.return)) yield _e.call(body_row_init_1);
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
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
171
- finally {
172
- try {
173
- if (!_o && !_a && (_b = bodyArray_1.return)) yield _b.call(bodyArray_1);
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
- return replacedBody.join("");
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 = {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "typescript": "^5.4.2"
6
6
  },
7
7
  "name": "cloud-ide-lms-model",
8
- "version": "1.0.53",
8
+ "version": "1.0.56",
9
9
  "description": "Package for Model management of Cloud IDEsys LMS",
10
10
  "main": "lib/index.js",
11
11
  "types": "lib/index.d.ts",