@xuda.io/runtime-bundle 1.0.560 → 1.0.562
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/js/modules/xuda-db-adapter-module.min.mjs +1 -1
- package/js/modules/xuda-db-adapter-module.mjs +155 -333
- package/js/xuda-runtime-bundle.js +380 -703
- package/js/xuda-runtime-bundle.min.js +1 -1
- package/js/xuda-runtime-slim.js +380 -703
- package/js/xuda-runtime-slim.min.es.js +380 -703
- package/js/xuda-runtime-slim.min.js +1 -1
- package/js/xuda-server-bundle.min.mjs +1 -1
- package/js/xuda-server-bundle.mjs +380 -703
- package/js/xuda-worker-bundle.js +380 -703
- package/js/xuda-worker-bundle.min.js +1 -1
- package/js/xuda_common-bundle.js +382 -705
- package/js/xuda_common-bundle.min.js +1 -1
- package/package.json +1 -1
package/js/xuda-worker-bundle.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
if (
|
|
4
|
-
typeof IS_DOCKER === "undefined" ||
|
|
5
|
-
typeof IS_PROCESS_SERVER === "undefined"
|
|
6
|
-
) {
|
|
3
|
+
if (typeof IS_DOCKER === 'undefined' || typeof IS_PROCESS_SERVER === 'undefined') {
|
|
7
4
|
var SESSION_OBJ = {};
|
|
8
5
|
var DOCS_OBJ = {};
|
|
9
6
|
}
|
|
@@ -20,17 +17,7 @@ var PROJECT_OBJ = {};
|
|
|
20
17
|
var APP_OBJ = {};
|
|
21
18
|
var SESSION_ID = null;
|
|
22
19
|
|
|
23
|
-
glb.PROTECTED_VARS = [
|
|
24
|
-
"_NULL",
|
|
25
|
-
"_THIS",
|
|
26
|
-
"_FOR_KEY",
|
|
27
|
-
"_FOR_VAL",
|
|
28
|
-
"_ROWNO",
|
|
29
|
-
"_ROWID",
|
|
30
|
-
"_ROWDOC",
|
|
31
|
-
"_KEY",
|
|
32
|
-
"_VAL",
|
|
33
|
-
];
|
|
20
|
+
glb.PROTECTED_VARS = ['_NULL', '_THIS', '_FOR_KEY', '_FOR_VAL', '_ROWNO', '_ROWID', '_ROWDOC', '_KEY', '_VAL'];
|
|
34
21
|
|
|
35
22
|
// glb.newRecord = 999999;
|
|
36
23
|
|
|
@@ -47,7 +34,7 @@ func.common.find_item_by_key_root = function (arr, key, val) {
|
|
|
47
34
|
};
|
|
48
35
|
func.common.find_ROWID_idx = function (_ds, rowId) {
|
|
49
36
|
if (!_ds?.data_feed?.rows) {
|
|
50
|
-
throw new Error(
|
|
37
|
+
throw new Error('data_feed not found');
|
|
51
38
|
}
|
|
52
39
|
|
|
53
40
|
// Find the index of the object with the given _ROWID
|
|
@@ -61,129 +48,55 @@ func.common.find_ROWID_idx = function (_ds, rowId) {
|
|
|
61
48
|
// Return the found index
|
|
62
49
|
return index;
|
|
63
50
|
};
|
|
64
|
-
func.common.input_mask = async function (
|
|
65
|
-
|
|
66
|
-
valP,
|
|
67
|
-
typeP,
|
|
68
|
-
maskP,
|
|
69
|
-
elemP,
|
|
70
|
-
grid_objP,
|
|
71
|
-
grid_row_idP,
|
|
72
|
-
grid_col_idP,
|
|
73
|
-
dsSessionP
|
|
74
|
-
) {
|
|
75
|
-
const module = await func.common.get_module(
|
|
76
|
-
SESSION_ID,
|
|
77
|
-
"xuda-input-musk-utils-module.mjs"
|
|
78
|
-
);
|
|
51
|
+
func.common.input_mask = async function (actionP, valP, typeP, maskP, elemP, grid_objP, grid_row_idP, grid_col_idP, dsSessionP) {
|
|
52
|
+
const module = await func.common.get_module(SESSION_ID, 'xuda-input-musk-utils-module.mjs');
|
|
79
53
|
|
|
80
|
-
module.input_mask(
|
|
81
|
-
actionP,
|
|
82
|
-
valP,
|
|
83
|
-
typeP,
|
|
84
|
-
maskP,
|
|
85
|
-
elemP,
|
|
86
|
-
grid_objP,
|
|
87
|
-
grid_row_idP,
|
|
88
|
-
grid_col_idP,
|
|
89
|
-
dsSessionP
|
|
90
|
-
);
|
|
54
|
+
module.input_mask(actionP, valP, typeP, maskP, elemP, grid_objP, grid_row_idP, grid_col_idP, dsSessionP);
|
|
91
55
|
};
|
|
92
56
|
|
|
93
|
-
glb.MAIN_WINDOW_TYPES_ARR = [
|
|
94
|
-
glb.FUNCTION_NODES_ARR = [
|
|
95
|
-
"batch",
|
|
96
|
-
"get_data",
|
|
97
|
-
"set_data",
|
|
98
|
-
"Alert_error",
|
|
99
|
-
"Alert_warning",
|
|
100
|
-
"Alert_info",
|
|
101
|
-
"Alert_ok",
|
|
102
|
-
"javascript",
|
|
103
|
-
"SQL",
|
|
104
|
-
];
|
|
57
|
+
glb.MAIN_WINDOW_TYPES_ARR = ['screen', 'program'];
|
|
58
|
+
glb.FUNCTION_NODES_ARR = ['batch', 'get_data', 'set_data', 'Alert_error', 'Alert_warning', 'Alert_info', 'Alert_ok', 'javascript', 'SQL'];
|
|
105
59
|
glb.emailRegex = /^[\w\.-]+@[a-zA-Z\d\.-]+\.[a-zA-Z]{2,}$/;
|
|
106
60
|
|
|
107
|
-
const FIREBASE_AUTH_PROPERTIES_ARR = [
|
|
108
|
-
"provider",
|
|
109
|
-
"token",
|
|
110
|
-
"first_name",
|
|
111
|
-
"last_name",
|
|
112
|
-
"email",
|
|
113
|
-
"user_id",
|
|
114
|
-
"picture",
|
|
115
|
-
"verified_email",
|
|
116
|
-
"locale",
|
|
117
|
-
"error_code",
|
|
118
|
-
"error_msg",
|
|
119
|
-
];
|
|
61
|
+
const FIREBASE_AUTH_PROPERTIES_ARR = ['provider', 'token', 'first_name', 'last_name', 'email', 'user_id', 'picture', 'verified_email', 'locale', 'error_code', 'error_msg'];
|
|
120
62
|
|
|
121
63
|
const CLIENT_INFO_PROPERTIES_ARR = [
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
64
|
+
'fingerprint',
|
|
65
|
+
'device',
|
|
66
|
+
'user_agent',
|
|
67
|
+
'browser_version',
|
|
68
|
+
'browser_name',
|
|
69
|
+
'engine_version',
|
|
70
|
+
'engine_name',
|
|
71
|
+
'client_ip',
|
|
72
|
+
'os_name',
|
|
73
|
+
'os_version',
|
|
74
|
+
'device_model',
|
|
75
|
+
'device_vendor',
|
|
76
|
+
'device_type',
|
|
77
|
+
'screen_current_resolution_x',
|
|
78
|
+
'screen_current_resolution_y',
|
|
79
|
+
'screen_available_resolution_x',
|
|
80
|
+
'screen_available_resolution_y',
|
|
81
|
+
'language',
|
|
82
|
+
'time_zone',
|
|
83
|
+
'cpu_architecture',
|
|
84
|
+
'uuid',
|
|
85
|
+
'cursor_pos_x',
|
|
86
|
+
'cursor_pos_y',
|
|
145
87
|
];
|
|
146
88
|
|
|
147
|
-
const APP_PROPERTIES_ARR = [
|
|
148
|
-
|
|
149
|
-
const DATASOURCE_PROPERTIES_ARR = [
|
|
150
|
-
"rows",
|
|
151
|
-
"type",
|
|
152
|
-
"first_row_id",
|
|
153
|
-
"last_row_id",
|
|
154
|
-
"query_from_segments_json",
|
|
155
|
-
"query_to_segments_json",
|
|
156
|
-
"locate_query_from_segments_json",
|
|
157
|
-
"locate_query_to_segments_json",
|
|
158
|
-
"first_row_segments_json",
|
|
159
|
-
"last_row_segments_json",
|
|
160
|
-
"rowid_snapshot",
|
|
161
|
-
"rowid",
|
|
162
|
-
];
|
|
89
|
+
const APP_PROPERTIES_ARR = ['build', 'author', 'date', 'name'];
|
|
163
90
|
|
|
164
|
-
|
|
165
|
-
"component",
|
|
166
|
-
"web_app",
|
|
167
|
-
"ios_app",
|
|
168
|
-
"android_app",
|
|
169
|
-
"electron_app",
|
|
170
|
-
"osx_app",
|
|
171
|
-
"windows_app",
|
|
172
|
-
];
|
|
91
|
+
const DATASOURCE_PROPERTIES_ARR = ['rows', 'type', 'first_row_id', 'last_row_id', 'query_from_segments_json', 'query_to_segments_json', 'locate_query_from_segments_json', 'locate_query_to_segments_json', 'first_row_segments_json', 'last_row_segments_json', 'rowid_snapshot', 'rowid'];
|
|
173
92
|
|
|
174
|
-
glb.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
"SYS_DATE_VALUE",
|
|
178
|
-
"SYS_DATE_WEEK_YEAR",
|
|
179
|
-
"SYS_DATE_MONTH_YEAR",
|
|
180
|
-
"SYS_TIME_SHORT",
|
|
181
|
-
"SYS_TIME",
|
|
182
|
-
];
|
|
93
|
+
glb.MOBILE_ARR = ['component', 'web_app', 'ios_app', 'android_app', 'electron_app', 'osx_app', 'windows_app'];
|
|
94
|
+
|
|
95
|
+
glb.SYS_DATE_ARR = ['SYS_DATE', 'SYS_DATE_TIME', 'SYS_DATE_VALUE', 'SYS_DATE_WEEK_YEAR', 'SYS_DATE_MONTH_YEAR', 'SYS_TIME_SHORT', 'SYS_TIME'];
|
|
183
96
|
|
|
184
|
-
glb.API_OUTPUT_ARR = [
|
|
97
|
+
glb.API_OUTPUT_ARR = ['json', 'html', 'xml', 'text', 'css', 'javascript'];
|
|
185
98
|
|
|
186
|
-
const PROTECTED_NAMES_ARR = [
|
|
99
|
+
const PROTECTED_NAMES_ARR = ['THIS', 'ROWID']; //tbd
|
|
187
100
|
|
|
188
101
|
// func.common.get_custom_icon = async function (
|
|
189
102
|
// SESSION_ID,
|
|
@@ -226,19 +139,13 @@ const PROTECTED_NAMES_ARR = ["THIS", "ROWID"]; //tbd
|
|
|
226
139
|
// } else return ret;
|
|
227
140
|
// };
|
|
228
141
|
|
|
229
|
-
func.common.db = async function (
|
|
230
|
-
SESSION_ID,
|
|
231
|
-
serviceP,
|
|
232
|
-
dataP,
|
|
233
|
-
opt = {},
|
|
234
|
-
dsSession
|
|
235
|
-
) {
|
|
142
|
+
func.common.db = async function (SESSION_ID, serviceP, dataP, opt = {}, dsSession) {
|
|
236
143
|
return new Promise(async function (resolve, reject) {
|
|
237
144
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
238
145
|
const app_id = _session.app_id;
|
|
239
146
|
|
|
240
|
-
if (_session.engine_mode ===
|
|
241
|
-
console.log(
|
|
147
|
+
if (_session.engine_mode === 'live_preview') {
|
|
148
|
+
console.log('request', dataP);
|
|
242
149
|
}
|
|
243
150
|
|
|
244
151
|
var data = {
|
|
@@ -250,18 +157,15 @@ func.common.db = async function (
|
|
|
250
157
|
app_token: _session.app_token,
|
|
251
158
|
res_token: _session.res_token,
|
|
252
159
|
engine_mode: _session.engine_mode,
|
|
253
|
-
req_id:
|
|
160
|
+
req_id: 'rt_req_' + crypto.randomUUID(),
|
|
254
161
|
app_replicate: APP_OBJ[app_id].app_replicate,
|
|
255
162
|
};
|
|
256
163
|
|
|
257
164
|
try {
|
|
258
|
-
if (
|
|
259
|
-
typeof firebase !== "undefined" &&
|
|
260
|
-
firebase?.auth()?.currentUser?.displayName
|
|
261
|
-
) {
|
|
165
|
+
if (typeof firebase !== 'undefined' && firebase?.auth()?.currentUser?.displayName) {
|
|
262
166
|
data.device_name = firebase.auth().currentUser.displayName;
|
|
263
167
|
}
|
|
264
|
-
} catch (error) {
|
|
168
|
+
} catch (error) {}
|
|
265
169
|
|
|
266
170
|
for (const [key, val] of Object.entries(dataP)) {
|
|
267
171
|
data[key] = val;
|
|
@@ -269,20 +173,14 @@ func.common.db = async function (
|
|
|
269
173
|
|
|
270
174
|
const success_callback = function (ret) {
|
|
271
175
|
if (dataP.table_id && DOCS_OBJ[app_id][dataP.table_id]) {
|
|
272
|
-
func.utils.debug.watch(
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
DOCS_OBJ[app_id][dataP.table_id].properties.menuName,
|
|
277
|
-
{
|
|
278
|
-
req: data,
|
|
279
|
-
res: ret,
|
|
280
|
-
}
|
|
281
|
-
);
|
|
176
|
+
func.utils.debug.watch(SESSION_ID, dataP.table_id, 'table', DOCS_OBJ[app_id][dataP.table_id].properties.menuName, {
|
|
177
|
+
req: data,
|
|
178
|
+
res: ret,
|
|
179
|
+
});
|
|
282
180
|
}
|
|
283
181
|
|
|
284
|
-
if (_session.engine_mode ===
|
|
285
|
-
console.log(
|
|
182
|
+
if (_session.engine_mode === 'live_preview') {
|
|
183
|
+
console.log('response', ret);
|
|
286
184
|
}
|
|
287
185
|
resolve(ret, true);
|
|
288
186
|
};
|
|
@@ -293,31 +191,14 @@ func.common.db = async function (
|
|
|
293
191
|
function cleanString(json) {
|
|
294
192
|
let str = JSON.stringify(json);
|
|
295
193
|
// Replace all non-alphanumeric characters with an empty string
|
|
296
|
-
return str.replace(/[^a-zA-Z0-9]/g,
|
|
194
|
+
return str.replace(/[^a-zA-Z0-9]/g, '');
|
|
297
195
|
}
|
|
298
196
|
const get_rep_id = function () {
|
|
299
197
|
let _data = {};
|
|
300
|
-
const fields_to_skip = [
|
|
301
|
-
"fields",
|
|
302
|
-
"viewSourceDesc",
|
|
303
|
-
"skip",
|
|
304
|
-
"limit",
|
|
305
|
-
"count",
|
|
306
|
-
"reduce",
|
|
307
|
-
"prog_id",
|
|
308
|
-
"sortModel",
|
|
309
|
-
"filterModelMongo",
|
|
310
|
-
"filterModelSql",
|
|
311
|
-
"filterModelUserMongo",
|
|
312
|
-
"filterModelUserSql",
|
|
313
|
-
];
|
|
198
|
+
const fields_to_skip = ['fields', 'viewSourceDesc', 'skip', 'limit', 'count', 'reduce', 'prog_id', 'sortModel', 'filterModelMongo', 'filterModelSql', 'filterModelUserMongo', 'filterModelUserSql'];
|
|
314
199
|
|
|
315
200
|
for (let [key, val] of Object.entries(dataP)) {
|
|
316
|
-
if (
|
|
317
|
-
typeof val !== "undefined" &&
|
|
318
|
-
val !== null &&
|
|
319
|
-
!fields_to_skip.includes(key)
|
|
320
|
-
) {
|
|
201
|
+
if (typeof val !== 'undefined' && val !== null && !fields_to_skip.includes(key)) {
|
|
321
202
|
_data[key] = val;
|
|
322
203
|
}
|
|
323
204
|
}
|
|
@@ -335,13 +216,13 @@ func.common.db = async function (
|
|
|
335
216
|
|
|
336
217
|
let ret = await db.find({
|
|
337
218
|
selector: {
|
|
338
|
-
docType:
|
|
219
|
+
docType: 'rep_request',
|
|
339
220
|
table_id: data.table_id,
|
|
340
221
|
},
|
|
341
222
|
});
|
|
342
223
|
|
|
343
224
|
if (doc.stat < 3) {
|
|
344
|
-
throw
|
|
225
|
+
throw 'not ready';
|
|
345
226
|
}
|
|
346
227
|
|
|
347
228
|
/// delete table refunded requests
|
|
@@ -356,10 +237,7 @@ func.common.db = async function (
|
|
|
356
237
|
};
|
|
357
238
|
|
|
358
239
|
const read_dbs_pouch = async function (db) {
|
|
359
|
-
if (
|
|
360
|
-
_session?.DS_GLB?.[dsSession]?.refreshed &&
|
|
361
|
-
(dataP.filterModelMongo || dataP.filterModelSql)
|
|
362
|
-
) {
|
|
240
|
+
if (_session?.DS_GLB?.[dsSession]?.refreshed && (dataP.filterModelMongo || dataP.filterModelSql)) {
|
|
363
241
|
return {
|
|
364
242
|
code: 1,
|
|
365
243
|
data: await func.db.pouch[serviceP](SESSION_ID, data),
|
|
@@ -368,8 +246,7 @@ func.common.db = async function (
|
|
|
368
246
|
|
|
369
247
|
const rep_id = get_rep_id();
|
|
370
248
|
|
|
371
|
-
const { code: table_req_code, data: table_req_id } =
|
|
372
|
-
await validate_existence_of_whole_table_request(db);
|
|
249
|
+
const { code: table_req_code, data: table_req_id } = await validate_existence_of_whole_table_request(db);
|
|
373
250
|
if (table_req_code > 0) {
|
|
374
251
|
return {
|
|
375
252
|
code: 1,
|
|
@@ -379,7 +256,7 @@ func.common.db = async function (
|
|
|
379
256
|
|
|
380
257
|
try {
|
|
381
258
|
const doc = await db.get(rep_id);
|
|
382
|
-
if (doc.stat < 3) throw
|
|
259
|
+
if (doc.stat < 3) throw 'replication not ready';
|
|
383
260
|
const json = {
|
|
384
261
|
code: 1,
|
|
385
262
|
data: await func.db.pouch[serviceP](SESSION_ID, data),
|
|
@@ -387,12 +264,7 @@ func.common.db = async function (
|
|
|
387
264
|
|
|
388
265
|
return json;
|
|
389
266
|
} catch (err) {
|
|
390
|
-
const json = await func.common.perform_rpi_request(
|
|
391
|
-
SESSION_ID,
|
|
392
|
-
serviceP,
|
|
393
|
-
opt,
|
|
394
|
-
data
|
|
395
|
-
);
|
|
267
|
+
const json = await func.common.perform_rpi_request(SESSION_ID, serviceP, opt, data);
|
|
396
268
|
if (json.data.opt) {
|
|
397
269
|
try {
|
|
398
270
|
try {
|
|
@@ -403,16 +275,16 @@ func.common.db = async function (
|
|
|
403
275
|
selector: json.data.opt.selector,
|
|
404
276
|
stat: 1,
|
|
405
277
|
ts: Date.now(),
|
|
406
|
-
docType:
|
|
278
|
+
docType: 'rep_request',
|
|
407
279
|
table_id: dataP.table_id,
|
|
408
280
|
prog_id: dataP.prog_id,
|
|
409
281
|
entire_table: table_req_id === rep_id,
|
|
410
|
-
source:
|
|
282
|
+
source: 'runtime',
|
|
411
283
|
e: data,
|
|
412
284
|
});
|
|
413
285
|
}
|
|
414
286
|
func.db.pouch.set_db_replication_from_server(SESSION_ID);
|
|
415
|
-
} catch (err) {
|
|
287
|
+
} catch (err) {}
|
|
416
288
|
}
|
|
417
289
|
return json;
|
|
418
290
|
}
|
|
@@ -423,8 +295,7 @@ func.common.db = async function (
|
|
|
423
295
|
// throw "online";
|
|
424
296
|
// }
|
|
425
297
|
|
|
426
|
-
const { code: table_req_code, data: table_req_id } =
|
|
427
|
-
await validate_existence_of_whole_table_request(db);
|
|
298
|
+
const { code: table_req_code, data: table_req_id } = await validate_existence_of_whole_table_request(db);
|
|
428
299
|
|
|
429
300
|
if (table_req_code > 0) {
|
|
430
301
|
data.full_table_downloaded = true;
|
|
@@ -433,37 +304,25 @@ func.common.db = async function (
|
|
|
433
304
|
await db.get(dataP.row_id);
|
|
434
305
|
return await func.db.pouch[serviceP](SESSION_ID, data);
|
|
435
306
|
} catch (err) {
|
|
436
|
-
return await func.common.perform_rpi_request(
|
|
437
|
-
SESSION_ID,
|
|
438
|
-
serviceP,
|
|
439
|
-
opt,
|
|
440
|
-
data
|
|
441
|
-
);
|
|
307
|
+
return await func.common.perform_rpi_request(SESSION_ID, serviceP, opt, data);
|
|
442
308
|
}
|
|
443
309
|
};
|
|
444
310
|
const create_dbs_pouch = async function (db) {
|
|
445
311
|
try {
|
|
446
|
-
const { code: table_req_code, data: table_req_id } =
|
|
447
|
-
await validate_existence_of_whole_table_request(db);
|
|
312
|
+
const { code: table_req_code, data: table_req_id } = await validate_existence_of_whole_table_request(db);
|
|
448
313
|
|
|
449
314
|
if (table_req_code > 0) {
|
|
450
315
|
data.full_table_downloaded = true;
|
|
451
316
|
}
|
|
452
317
|
return await func.db.pouch[serviceP](SESSION_ID, data);
|
|
453
318
|
} catch (err) {
|
|
454
|
-
return await func.common.perform_rpi_request(
|
|
455
|
-
SESSION_ID,
|
|
456
|
-
serviceP,
|
|
457
|
-
opt,
|
|
458
|
-
data
|
|
459
|
-
);
|
|
319
|
+
return await func.common.perform_rpi_request(SESSION_ID, serviceP, opt, data);
|
|
460
320
|
}
|
|
461
321
|
};
|
|
462
322
|
const delete_dbs_pouch = async function (db) {
|
|
463
|
-
for await (let row_id of dataP.ids) {
|
|
323
|
+
for await (let row_id of dataP.ids || []) {
|
|
464
324
|
try {
|
|
465
|
-
const { code: table_req_code, data: table_req_id } =
|
|
466
|
-
await validate_existence_of_whole_table_request(db);
|
|
325
|
+
const { code: table_req_code, data: table_req_id } = await validate_existence_of_whole_table_request(db);
|
|
467
326
|
|
|
468
327
|
if (table_req_code > 0) {
|
|
469
328
|
data.full_table_downloaded = true;
|
|
@@ -472,41 +331,32 @@ func.common.db = async function (
|
|
|
472
331
|
await db.get(row_id);
|
|
473
332
|
let _data = _.cloneDeep(dataP);
|
|
474
333
|
_data.ids = [row_id];
|
|
475
|
-
return await func.db.pouch[
|
|
334
|
+
return await func.db.pouch['dbs_delete'](SESSION_ID, _data);
|
|
476
335
|
} catch (err) {
|
|
477
|
-
return await func.common.perform_rpi_request(
|
|
478
|
-
SESSION_ID,
|
|
479
|
-
serviceP,
|
|
480
|
-
opt,
|
|
481
|
-
data
|
|
482
|
-
);
|
|
336
|
+
return await func.common.perform_rpi_request(SESSION_ID, serviceP, opt, data);
|
|
483
337
|
}
|
|
484
338
|
}
|
|
485
339
|
};
|
|
486
|
-
if (
|
|
487
|
-
typeof IS_DOCKER === "undefined" &&
|
|
488
|
-
typeof IS_PROCESS_SERVER === "undefined"
|
|
489
|
-
) {
|
|
340
|
+
if (typeof IS_DOCKER === 'undefined' && typeof IS_PROCESS_SERVER === 'undefined') {
|
|
490
341
|
try {
|
|
491
342
|
if (!SESSION_OBJ?.[SESSION_ID]?.rpi_http_methods?.includes(serviceP)) {
|
|
492
|
-
throw
|
|
343
|
+
throw '';
|
|
493
344
|
}
|
|
494
|
-
if (!(await func?.db?.pouch?.get_replication_stat(SESSION_ID)))
|
|
495
|
-
throw "";
|
|
345
|
+
if (!(await func?.db?.pouch?.get_replication_stat(SESSION_ID))) throw '';
|
|
496
346
|
const db = await func.utils.connect_pouchdb(SESSION_ID);
|
|
497
347
|
switch (serviceP) {
|
|
498
|
-
case
|
|
348
|
+
case 'dbs_read': {
|
|
499
349
|
try {
|
|
500
350
|
return success_callback(await read_dbs_pouch(db));
|
|
501
351
|
} catch (err) {
|
|
502
|
-
if (err ===
|
|
503
|
-
throw
|
|
352
|
+
if (err === 'creating index in progress') {
|
|
353
|
+
throw '';
|
|
504
354
|
}
|
|
505
355
|
return error_callback(err);
|
|
506
356
|
}
|
|
507
357
|
break;
|
|
508
358
|
}
|
|
509
|
-
case
|
|
359
|
+
case 'dbs_update': {
|
|
510
360
|
try {
|
|
511
361
|
const ret = {
|
|
512
362
|
code: 1,
|
|
@@ -518,7 +368,7 @@ func.common.db = async function (
|
|
|
518
368
|
}
|
|
519
369
|
break;
|
|
520
370
|
}
|
|
521
|
-
case
|
|
371
|
+
case 'dbs_create': {
|
|
522
372
|
try {
|
|
523
373
|
const ret = {
|
|
524
374
|
code: 1,
|
|
@@ -530,7 +380,7 @@ func.common.db = async function (
|
|
|
530
380
|
}
|
|
531
381
|
break;
|
|
532
382
|
}
|
|
533
|
-
case
|
|
383
|
+
case 'dbs_delete': {
|
|
534
384
|
try {
|
|
535
385
|
const ret = {
|
|
536
386
|
code: 1,
|
|
@@ -544,17 +394,12 @@ func.common.db = async function (
|
|
|
544
394
|
}
|
|
545
395
|
|
|
546
396
|
default:
|
|
547
|
-
throw
|
|
397
|
+
throw '';
|
|
548
398
|
break;
|
|
549
399
|
}
|
|
550
400
|
} catch (err) {
|
|
551
401
|
try {
|
|
552
|
-
const json = await func.common.perform_rpi_request(
|
|
553
|
-
SESSION_ID,
|
|
554
|
-
serviceP,
|
|
555
|
-
opt,
|
|
556
|
-
data
|
|
557
|
-
);
|
|
402
|
+
const json = await func.common.perform_rpi_request(SESSION_ID, serviceP, opt, data);
|
|
558
403
|
return success_callback(json, true);
|
|
559
404
|
} catch (err) {
|
|
560
405
|
return error_callback(err);
|
|
@@ -575,14 +420,14 @@ func.common.db = async function (
|
|
|
575
420
|
var e = {};
|
|
576
421
|
_.forEach(data, function (val, key) {
|
|
577
422
|
if (!val) {
|
|
578
|
-
if (typeof val ===
|
|
579
|
-
e[key] =
|
|
423
|
+
if (typeof val === 'boolean') {
|
|
424
|
+
e[key] = 'false';
|
|
580
425
|
} else {
|
|
581
|
-
e[key] =
|
|
426
|
+
e[key] = '';
|
|
582
427
|
}
|
|
583
428
|
} else {
|
|
584
|
-
if (typeof val ===
|
|
585
|
-
e[key] =
|
|
429
|
+
if (typeof val === 'boolean') {
|
|
430
|
+
e[key] = 'true';
|
|
586
431
|
} else {
|
|
587
432
|
e[key] = val;
|
|
588
433
|
}
|
|
@@ -590,7 +435,7 @@ func.common.db = async function (
|
|
|
590
435
|
});
|
|
591
436
|
|
|
592
437
|
if (data.fields && !data.fields.length) {
|
|
593
|
-
e.fields =
|
|
438
|
+
e.fields = '';
|
|
594
439
|
}
|
|
595
440
|
|
|
596
441
|
return e;
|
|
@@ -600,13 +445,8 @@ func.common.db = async function (
|
|
|
600
445
|
await func.utils.FILES_OBJ.get(SESSION_ID, dataP.table_id);
|
|
601
446
|
await func.utils.TREE_OBJ.get(SESSION_ID, dataP.table_id);
|
|
602
447
|
}
|
|
603
|
-
data.db_driver =
|
|
604
|
-
__.rpi.http_calls(
|
|
605
|
-
serviceP,
|
|
606
|
-
{ body: get_white_spaced_data(data) },
|
|
607
|
-
null,
|
|
608
|
-
response
|
|
609
|
-
);
|
|
448
|
+
data.db_driver = 'xuda';
|
|
449
|
+
__.rpi.http_calls(serviceP, { body: get_white_spaced_data(data) }, null, response);
|
|
610
450
|
});
|
|
611
451
|
};
|
|
612
452
|
|
|
@@ -626,11 +466,7 @@ func.common.getParametersFromUrl = function () {
|
|
|
626
466
|
return parameters;
|
|
627
467
|
};
|
|
628
468
|
|
|
629
|
-
func.common.getObjectFromUrl = function (
|
|
630
|
-
url,
|
|
631
|
-
element_attributes_obj,
|
|
632
|
-
embed_params_obj
|
|
633
|
-
) {
|
|
469
|
+
func.common.getObjectFromUrl = function (url, element_attributes_obj, embed_params_obj) {
|
|
634
470
|
var result = {};
|
|
635
471
|
if (element_attributes_obj) {
|
|
636
472
|
for (let [key, val] of Object.entries(element_attributes_obj)) {
|
|
@@ -643,33 +479,26 @@ func.common.getObjectFromUrl = function (
|
|
|
643
479
|
}
|
|
644
480
|
}
|
|
645
481
|
|
|
646
|
-
if (
|
|
647
|
-
!url &&
|
|
648
|
-
typeof IS_DOCKER === "undefined" &&
|
|
649
|
-
typeof IS_PROCESS_SERVER === "undefined"
|
|
650
|
-
) {
|
|
482
|
+
if (!url && typeof IS_DOCKER === 'undefined' && typeof IS_PROCESS_SERVER === 'undefined') {
|
|
651
483
|
url = location.href;
|
|
652
484
|
}
|
|
653
|
-
var question = url.indexOf(
|
|
654
|
-
var hash = url.indexOf(
|
|
485
|
+
var question = url.indexOf('?');
|
|
486
|
+
var hash = url.indexOf('#');
|
|
655
487
|
if (hash == -1 && question == -1) return result;
|
|
656
488
|
if (hash == -1) hash = url.length;
|
|
657
|
-
var query =
|
|
658
|
-
question == -1 || hash == question + 1
|
|
659
|
-
? url.substring(hash)
|
|
660
|
-
: url.substring(question + 1, hash);
|
|
489
|
+
var query = question == -1 || hash == question + 1 ? url.substring(hash) : url.substring(question + 1, hash);
|
|
661
490
|
// var result = {};
|
|
662
|
-
query.split(
|
|
491
|
+
query.split('&').forEach(function (part) {
|
|
663
492
|
if (!part) return;
|
|
664
|
-
part = part.split(
|
|
665
|
-
var eq = part.indexOf(
|
|
493
|
+
part = part.split('+').join(' '); // replace every + with space, regexp-free version
|
|
494
|
+
var eq = part.indexOf('=');
|
|
666
495
|
var key = eq > -1 ? part.substr(0, eq) : part;
|
|
667
|
-
var val = eq > -1 ? decodeURIComponent(part.substr(eq + 1)) :
|
|
668
|
-
var from = key.indexOf(
|
|
496
|
+
var val = eq > -1 ? decodeURIComponent(part.substr(eq + 1)) : '';
|
|
497
|
+
var from = key.indexOf('[');
|
|
669
498
|
if (from == -1) {
|
|
670
499
|
result[decodeURIComponent(key)] = val;
|
|
671
500
|
} else {
|
|
672
|
-
var to = key.indexOf(
|
|
501
|
+
var to = key.indexOf(']', from);
|
|
673
502
|
var index = decodeURIComponent(key.substring(from + 1, to));
|
|
674
503
|
key = decodeURIComponent(key.substring(0, from));
|
|
675
504
|
if (!result[key]) result[key] = [];
|
|
@@ -684,159 +513,158 @@ func.common.getObjectFromUrl = function (
|
|
|
684
513
|
func.common.getContrast_color = function (hexcolor) {
|
|
685
514
|
function colourNameToHex(colour) {
|
|
686
515
|
var colours = {
|
|
687
|
-
aliceblue:
|
|
688
|
-
antiquewhite:
|
|
689
|
-
aqua:
|
|
690
|
-
aquamarine:
|
|
691
|
-
azure:
|
|
692
|
-
beige:
|
|
693
|
-
bisque:
|
|
694
|
-
black:
|
|
695
|
-
blanchedalmond:
|
|
696
|
-
blue:
|
|
697
|
-
blueviolet:
|
|
698
|
-
brown:
|
|
699
|
-
burlywood:
|
|
700
|
-
cadetblue:
|
|
701
|
-
chartreuse:
|
|
702
|
-
chocolate:
|
|
703
|
-
coral:
|
|
704
|
-
cornflowerblue:
|
|
705
|
-
cornsilk:
|
|
706
|
-
crimson:
|
|
707
|
-
cyan:
|
|
708
|
-
darkblue:
|
|
709
|
-
darkcyan:
|
|
710
|
-
darkgoldenrod:
|
|
711
|
-
darkgray:
|
|
712
|
-
darkgreen:
|
|
713
|
-
darkkhaki:
|
|
714
|
-
darkmagenta:
|
|
715
|
-
darkolivegreen:
|
|
716
|
-
darkorange:
|
|
717
|
-
darkorchid:
|
|
718
|
-
darkred:
|
|
719
|
-
darksalmon:
|
|
720
|
-
darkseagreen:
|
|
721
|
-
darkslateblue:
|
|
722
|
-
darkslategray:
|
|
723
|
-
darkturquoise:
|
|
724
|
-
darkviolet:
|
|
725
|
-
deeppink:
|
|
726
|
-
deepskyblue:
|
|
727
|
-
dimgray:
|
|
728
|
-
dodgerblue:
|
|
729
|
-
firebrick:
|
|
730
|
-
floralwhite:
|
|
731
|
-
forestgreen:
|
|
732
|
-
fuchsia:
|
|
733
|
-
gainsboro:
|
|
734
|
-
ghostwhite:
|
|
735
|
-
gold:
|
|
736
|
-
goldenrod:
|
|
737
|
-
gray:
|
|
738
|
-
green:
|
|
739
|
-
greenyellow:
|
|
740
|
-
honeydew:
|
|
741
|
-
hotpink:
|
|
742
|
-
|
|
743
|
-
indigo:
|
|
744
|
-
ivory:
|
|
745
|
-
khaki:
|
|
746
|
-
lavender:
|
|
747
|
-
lavenderblush:
|
|
748
|
-
lawngreen:
|
|
749
|
-
lemonchiffon:
|
|
750
|
-
lightblue:
|
|
751
|
-
lightcoral:
|
|
752
|
-
lightcyan:
|
|
753
|
-
lightgoldenrodyellow:
|
|
754
|
-
lightgrey:
|
|
755
|
-
lightgreen:
|
|
756
|
-
lightpink:
|
|
757
|
-
lightsalmon:
|
|
758
|
-
lightseagreen:
|
|
759
|
-
lightskyblue:
|
|
760
|
-
lightslategray:
|
|
761
|
-
lightsteelblue:
|
|
762
|
-
lightyellow:
|
|
763
|
-
lime:
|
|
764
|
-
limegreen:
|
|
765
|
-
linen:
|
|
766
|
-
magenta:
|
|
767
|
-
maroon:
|
|
768
|
-
mediumaquamarine:
|
|
769
|
-
mediumblue:
|
|
770
|
-
mediumorchid:
|
|
771
|
-
mediumpurple:
|
|
772
|
-
mediumseagreen:
|
|
773
|
-
mediumslateblue:
|
|
774
|
-
mediumspringgreen:
|
|
775
|
-
mediumturquoise:
|
|
776
|
-
mediumvioletred:
|
|
777
|
-
midnightblue:
|
|
778
|
-
mintcream:
|
|
779
|
-
mistyrose:
|
|
780
|
-
moccasin:
|
|
781
|
-
navajowhite:
|
|
782
|
-
navy:
|
|
783
|
-
oldlace:
|
|
784
|
-
olive:
|
|
785
|
-
olivedrab:
|
|
786
|
-
orange:
|
|
787
|
-
orangered:
|
|
788
|
-
orchid:
|
|
789
|
-
palegoldenrod:
|
|
790
|
-
palegreen:
|
|
791
|
-
paleturquoise:
|
|
792
|
-
palevioletred:
|
|
793
|
-
papayawhip:
|
|
794
|
-
peachpuff:
|
|
795
|
-
peru:
|
|
796
|
-
pink:
|
|
797
|
-
plum:
|
|
798
|
-
powderblue:
|
|
799
|
-
purple:
|
|
800
|
-
rebeccapurple:
|
|
801
|
-
red:
|
|
802
|
-
rosybrown:
|
|
803
|
-
royalblue:
|
|
804
|
-
saddlebrown:
|
|
805
|
-
salmon:
|
|
806
|
-
sandybrown:
|
|
807
|
-
seagreen:
|
|
808
|
-
seashell:
|
|
809
|
-
sienna:
|
|
810
|
-
silver:
|
|
811
|
-
skyblue:
|
|
812
|
-
slateblue:
|
|
813
|
-
slategray:
|
|
814
|
-
snow:
|
|
815
|
-
springgreen:
|
|
816
|
-
steelblue:
|
|
817
|
-
tan:
|
|
818
|
-
teal:
|
|
819
|
-
thistle:
|
|
820
|
-
tomato:
|
|
821
|
-
turquoise:
|
|
822
|
-
violet:
|
|
823
|
-
wheat:
|
|
824
|
-
white:
|
|
825
|
-
whitesmoke:
|
|
826
|
-
yellow:
|
|
827
|
-
yellowgreen:
|
|
516
|
+
aliceblue: '#f0f8ff',
|
|
517
|
+
antiquewhite: '#faebd7',
|
|
518
|
+
aqua: '#00ffff',
|
|
519
|
+
aquamarine: '#7fffd4',
|
|
520
|
+
azure: '#f0ffff',
|
|
521
|
+
beige: '#f5f5dc',
|
|
522
|
+
bisque: '#ffe4c4',
|
|
523
|
+
black: '#000000',
|
|
524
|
+
blanchedalmond: '#ffebcd',
|
|
525
|
+
blue: '#0000ff',
|
|
526
|
+
blueviolet: '#8a2be2',
|
|
527
|
+
brown: '#a52a2a',
|
|
528
|
+
burlywood: '#deb887',
|
|
529
|
+
cadetblue: '#5f9ea0',
|
|
530
|
+
chartreuse: '#7fff00',
|
|
531
|
+
chocolate: '#d2691e',
|
|
532
|
+
coral: '#ff7f50',
|
|
533
|
+
cornflowerblue: '#6495ed',
|
|
534
|
+
cornsilk: '#fff8dc',
|
|
535
|
+
crimson: '#dc143c',
|
|
536
|
+
cyan: '#00ffff',
|
|
537
|
+
darkblue: '#00008b',
|
|
538
|
+
darkcyan: '#008b8b',
|
|
539
|
+
darkgoldenrod: '#b8860b',
|
|
540
|
+
darkgray: '#a9a9a9',
|
|
541
|
+
darkgreen: '#006400',
|
|
542
|
+
darkkhaki: '#bdb76b',
|
|
543
|
+
darkmagenta: '#8b008b',
|
|
544
|
+
darkolivegreen: '#556b2f',
|
|
545
|
+
darkorange: '#ff8c00',
|
|
546
|
+
darkorchid: '#9932cc',
|
|
547
|
+
darkred: '#8b0000',
|
|
548
|
+
darksalmon: '#e9967a',
|
|
549
|
+
darkseagreen: '#8fbc8f',
|
|
550
|
+
darkslateblue: '#483d8b',
|
|
551
|
+
darkslategray: '#2f4f4f',
|
|
552
|
+
darkturquoise: '#00ced1',
|
|
553
|
+
darkviolet: '#9400d3',
|
|
554
|
+
deeppink: '#ff1493',
|
|
555
|
+
deepskyblue: '#00bfff',
|
|
556
|
+
dimgray: '#696969',
|
|
557
|
+
dodgerblue: '#1e90ff',
|
|
558
|
+
firebrick: '#b22222',
|
|
559
|
+
floralwhite: '#fffaf0',
|
|
560
|
+
forestgreen: '#228b22',
|
|
561
|
+
fuchsia: '#ff00ff',
|
|
562
|
+
gainsboro: '#dcdcdc',
|
|
563
|
+
ghostwhite: '#f8f8ff',
|
|
564
|
+
gold: '#ffd700',
|
|
565
|
+
goldenrod: '#daa520',
|
|
566
|
+
gray: '#808080',
|
|
567
|
+
green: '#008000',
|
|
568
|
+
greenyellow: '#adff2f',
|
|
569
|
+
honeydew: '#f0fff0',
|
|
570
|
+
hotpink: '#ff69b4',
|
|
571
|
+
'indianred ': '#cd5c5c',
|
|
572
|
+
indigo: '#4b0082',
|
|
573
|
+
ivory: '#fffff0',
|
|
574
|
+
khaki: '#f0e68c',
|
|
575
|
+
lavender: '#e6e6fa',
|
|
576
|
+
lavenderblush: '#fff0f5',
|
|
577
|
+
lawngreen: '#7cfc00',
|
|
578
|
+
lemonchiffon: '#fffacd',
|
|
579
|
+
lightblue: '#add8e6',
|
|
580
|
+
lightcoral: '#f08080',
|
|
581
|
+
lightcyan: '#e0ffff',
|
|
582
|
+
lightgoldenrodyellow: '#fafad2',
|
|
583
|
+
lightgrey: '#d3d3d3',
|
|
584
|
+
lightgreen: '#90ee90',
|
|
585
|
+
lightpink: '#ffb6c1',
|
|
586
|
+
lightsalmon: '#ffa07a',
|
|
587
|
+
lightseagreen: '#20b2aa',
|
|
588
|
+
lightskyblue: '#87cefa',
|
|
589
|
+
lightslategray: '#778899',
|
|
590
|
+
lightsteelblue: '#b0c4de',
|
|
591
|
+
lightyellow: '#ffffe0',
|
|
592
|
+
lime: '#00ff00',
|
|
593
|
+
limegreen: '#32cd32',
|
|
594
|
+
linen: '#faf0e6',
|
|
595
|
+
magenta: '#ff00ff',
|
|
596
|
+
maroon: '#800000',
|
|
597
|
+
mediumaquamarine: '#66cdaa',
|
|
598
|
+
mediumblue: '#0000cd',
|
|
599
|
+
mediumorchid: '#ba55d3',
|
|
600
|
+
mediumpurple: '#9370d8',
|
|
601
|
+
mediumseagreen: '#3cb371',
|
|
602
|
+
mediumslateblue: '#7b68ee',
|
|
603
|
+
mediumspringgreen: '#00fa9a',
|
|
604
|
+
mediumturquoise: '#48d1cc',
|
|
605
|
+
mediumvioletred: '#c71585',
|
|
606
|
+
midnightblue: '#191970',
|
|
607
|
+
mintcream: '#f5fffa',
|
|
608
|
+
mistyrose: '#ffe4e1',
|
|
609
|
+
moccasin: '#ffe4b5',
|
|
610
|
+
navajowhite: '#ffdead',
|
|
611
|
+
navy: '#000080',
|
|
612
|
+
oldlace: '#fdf5e6',
|
|
613
|
+
olive: '#808000',
|
|
614
|
+
olivedrab: '#6b8e23',
|
|
615
|
+
orange: '#ffa500',
|
|
616
|
+
orangered: '#ff4500',
|
|
617
|
+
orchid: '#da70d6',
|
|
618
|
+
palegoldenrod: '#eee8aa',
|
|
619
|
+
palegreen: '#98fb98',
|
|
620
|
+
paleturquoise: '#afeeee',
|
|
621
|
+
palevioletred: '#d87093',
|
|
622
|
+
papayawhip: '#ffefd5',
|
|
623
|
+
peachpuff: '#ffdab9',
|
|
624
|
+
peru: '#cd853f',
|
|
625
|
+
pink: '#ffc0cb',
|
|
626
|
+
plum: '#dda0dd',
|
|
627
|
+
powderblue: '#b0e0e6',
|
|
628
|
+
purple: '#800080',
|
|
629
|
+
rebeccapurple: '#663399',
|
|
630
|
+
red: '#ff0000',
|
|
631
|
+
rosybrown: '#bc8f8f',
|
|
632
|
+
royalblue: '#4169e1',
|
|
633
|
+
saddlebrown: '#8b4513',
|
|
634
|
+
salmon: '#fa8072',
|
|
635
|
+
sandybrown: '#f4a460',
|
|
636
|
+
seagreen: '#2e8b57',
|
|
637
|
+
seashell: '#fff5ee',
|
|
638
|
+
sienna: '#a0522d',
|
|
639
|
+
silver: '#c0c0c0',
|
|
640
|
+
skyblue: '#87ceeb',
|
|
641
|
+
slateblue: '#6a5acd',
|
|
642
|
+
slategray: '#708090',
|
|
643
|
+
snow: '#fffafa',
|
|
644
|
+
springgreen: '#00ff7f',
|
|
645
|
+
steelblue: '#4682b4',
|
|
646
|
+
tan: '#d2b48c',
|
|
647
|
+
teal: '#008080',
|
|
648
|
+
thistle: '#d8bfd8',
|
|
649
|
+
tomato: '#ff6347',
|
|
650
|
+
turquoise: '#40e0d0',
|
|
651
|
+
violet: '#ee82ee',
|
|
652
|
+
wheat: '#f5deb3',
|
|
653
|
+
white: '#ffffff',
|
|
654
|
+
whitesmoke: '#f5f5f5',
|
|
655
|
+
yellow: '#ffff00',
|
|
656
|
+
yellowgreen: '#9acd32',
|
|
828
657
|
};
|
|
829
658
|
|
|
830
|
-
if (typeof colours[colour.toLowerCase()] !=
|
|
831
|
-
return colours[colour.toLowerCase()];
|
|
659
|
+
if (typeof colours[colour.toLowerCase()] != 'undefined') return colours[colour.toLowerCase()];
|
|
832
660
|
|
|
833
661
|
return false;
|
|
834
662
|
}
|
|
835
|
-
if (!hexcolor.includes(
|
|
663
|
+
if (!hexcolor.includes('#')) {
|
|
836
664
|
hexcolor = colourNameToHex(hexcolor);
|
|
837
665
|
}
|
|
838
666
|
// If a leading # is provided, remove it
|
|
839
|
-
if (hexcolor.slice(0, 1) ===
|
|
667
|
+
if (hexcolor.slice(0, 1) === '#') {
|
|
840
668
|
hexcolor = hexcolor.slice(1);
|
|
841
669
|
}
|
|
842
670
|
|
|
@@ -849,51 +677,30 @@ func.common.getContrast_color = function (hexcolor) {
|
|
|
849
677
|
var yiq = (r * 299 + g * 587 + b * 114) / 1000;
|
|
850
678
|
|
|
851
679
|
// Check contrast
|
|
852
|
-
return yiq >= 128 ?
|
|
680
|
+
return yiq >= 128 ? 'black' : 'white';
|
|
853
681
|
};
|
|
854
682
|
|
|
855
683
|
func.common.get_url = function (SESSION_ID, method, path) {
|
|
856
|
-
return `https://${SESSION_OBJ[SESSION_ID].domain}/${method}${path ?
|
|
857
|
-
}`;
|
|
684
|
+
return `https://${SESSION_OBJ[SESSION_ID].domain}/${method}${path ? '/' + path : '/'}`;
|
|
858
685
|
};
|
|
859
686
|
|
|
860
687
|
var UI_FRAMEWORK_INSTALLED = null;
|
|
861
688
|
var UI_FRAMEWORK_PLUGIN = {};
|
|
862
689
|
|
|
863
|
-
func.common.get_cast_val = async function (
|
|
864
|
-
SESSION_ID,
|
|
865
|
-
source,
|
|
866
|
-
attributeP,
|
|
867
|
-
typeP,
|
|
868
|
-
valP,
|
|
869
|
-
errorP
|
|
870
|
-
) {
|
|
690
|
+
func.common.get_cast_val = async function (SESSION_ID, source, attributeP, typeP, valP, errorP) {
|
|
871
691
|
const report_conversion_error = function (res) {
|
|
872
692
|
if (errorP) {
|
|
873
|
-
return func.utils.debug_report(
|
|
874
|
-
SESSION_ID,
|
|
875
|
-
_.capitalize(source),
|
|
876
|
-
errorP,
|
|
877
|
-
"W"
|
|
878
|
-
);
|
|
693
|
+
return func.utils.debug_report(SESSION_ID, _.capitalize(source), errorP, 'W');
|
|
879
694
|
}
|
|
880
695
|
var msg = `error converting ${attributeP} from ${valP} to ${typeP}`;
|
|
881
|
-
func.utils.debug_report(SESSION_ID, _.capitalize(source), msg,
|
|
696
|
+
func.utils.debug_report(SESSION_ID, _.capitalize(source), msg, 'E');
|
|
882
697
|
};
|
|
883
698
|
const report_conversion_warn = function (msg) {
|
|
884
699
|
var msg = `type mismatch auto conversion made to ${attributeP} from value ${valP} to ${typeP}`;
|
|
885
|
-
func.utils.debug_report(SESSION_ID, _.capitalize(source), msg,
|
|
700
|
+
func.utils.debug_report(SESSION_ID, _.capitalize(source), msg, 'W');
|
|
886
701
|
};
|
|
887
|
-
const module = await func.common.get_module(
|
|
888
|
-
|
|
889
|
-
`xuda-get-cast-util-module.mjs`
|
|
890
|
-
);
|
|
891
|
-
return module.cast(
|
|
892
|
-
typeP,
|
|
893
|
-
valP,
|
|
894
|
-
report_conversion_error,
|
|
895
|
-
report_conversion_warn
|
|
896
|
-
);
|
|
702
|
+
const module = await func.common.get_module(SESSION_ID, `xuda-get-cast-util-module.mjs`);
|
|
703
|
+
return module.cast(typeP, valP, report_conversion_error, report_conversion_warn);
|
|
897
704
|
};
|
|
898
705
|
var WEB_WORKER = {};
|
|
899
706
|
var WEB_WORKER_CALLBACK_QUEUE = {};
|
|
@@ -915,9 +722,7 @@ func.common.get_module = async function (SESSION_ID, module, paramsP = {}) {
|
|
|
915
722
|
const module_ret = await import(src);
|
|
916
723
|
var params = get_params();
|
|
917
724
|
|
|
918
|
-
const ret = module_ret.XudaModule
|
|
919
|
-
? new module_ret.XudaModule(params)
|
|
920
|
-
: await invoke_init_module(module_ret, params);
|
|
725
|
+
const ret = module_ret.XudaModule ? new module_ret.XudaModule(params) : await invoke_init_module(module_ret, params);
|
|
921
726
|
|
|
922
727
|
return ret;
|
|
923
728
|
};
|
|
@@ -934,13 +739,11 @@ func.common.get_module = async function (SESSION_ID, module, paramsP = {}) {
|
|
|
934
739
|
_,
|
|
935
740
|
...paramsP,
|
|
936
741
|
};
|
|
937
|
-
if (typeof IS_PROCESS_SERVER !==
|
|
938
|
-
params.IS_PROCESS_SERVER = IS_PROCESS_SERVER;
|
|
742
|
+
if (typeof IS_PROCESS_SERVER !== 'undefined') params.IS_PROCESS_SERVER = IS_PROCESS_SERVER;
|
|
939
743
|
|
|
940
|
-
if (typeof IS_API_SERVER !==
|
|
941
|
-
params.IS_API_SERVER = IS_API_SERVER;
|
|
744
|
+
if (typeof IS_API_SERVER !== 'undefined') params.IS_API_SERVER = IS_API_SERVER;
|
|
942
745
|
|
|
943
|
-
if (typeof IS_DOCKER !==
|
|
746
|
+
if (typeof IS_DOCKER !== 'undefined') params.IS_DOCKER = IS_DOCKER;
|
|
944
747
|
|
|
945
748
|
return params;
|
|
946
749
|
};
|
|
@@ -951,73 +754,29 @@ func.common.get_module = async function (SESSION_ID, module, paramsP = {}) {
|
|
|
951
754
|
return module_ret;
|
|
952
755
|
};
|
|
953
756
|
const _session = SESSION_OBJ[SESSION_ID];
|
|
954
|
-
if (_session.worker_type ===
|
|
955
|
-
ret = await get_ret(
|
|
757
|
+
if (_session.worker_type === 'Dev') {
|
|
758
|
+
ret = await get_ret('./modules/' + module);
|
|
956
759
|
|
|
957
760
|
return ret;
|
|
958
761
|
}
|
|
959
|
-
if (_session.worker_type ===
|
|
960
|
-
if (
|
|
961
|
-
|
|
962
|
-
typeof IS_PROCESS_SERVER !== "undefined"
|
|
963
|
-
) {
|
|
964
|
-
ret = await get_ret(
|
|
965
|
-
func.utils.get_resource_filename(
|
|
966
|
-
SESSION_OBJ[SESSION_ID].engine_mode === "live_preview"
|
|
967
|
-
? ""
|
|
968
|
-
: SESSION_OBJ[SESSION_ID]?.opt?.app_build_id,
|
|
969
|
-
`${_conf.xuda_home}root/dist/runtime/js/modules/` + module
|
|
970
|
-
)
|
|
971
|
-
);
|
|
762
|
+
if (_session.worker_type === 'Debug') {
|
|
763
|
+
if (typeof IS_DOCKER !== 'undefined' || typeof IS_PROCESS_SERVER !== 'undefined') {
|
|
764
|
+
ret = await get_ret(func.utils.get_resource_filename(SESSION_OBJ[SESSION_ID].engine_mode === 'live_preview' ? '' : SESSION_OBJ[SESSION_ID]?.opt?.app_build_id, `${_conf.xuda_home}root/dist/runtime/js/modules/` + module));
|
|
972
765
|
} else {
|
|
973
|
-
ret = await get_ret(
|
|
974
|
-
func.common.get_url(
|
|
975
|
-
SESSION_ID,
|
|
976
|
-
"dist",
|
|
977
|
-
func.utils.get_resource_filename(
|
|
978
|
-
SESSION_OBJ[SESSION_ID].engine_mode === "live_preview"
|
|
979
|
-
? ""
|
|
980
|
-
: SESSION_OBJ[SESSION_ID]?.opt?.app_build_id,
|
|
981
|
-
"runtime/js/modules/" + module
|
|
982
|
-
)
|
|
983
|
-
)
|
|
984
|
-
);
|
|
766
|
+
ret = await get_ret(func.common.get_url(SESSION_ID, 'dist', func.utils.get_resource_filename(SESSION_OBJ[SESSION_ID].engine_mode === 'live_preview' ? '' : SESSION_OBJ[SESSION_ID]?.opt?.app_build_id, 'runtime/js/modules/' + module)));
|
|
985
767
|
}
|
|
986
768
|
|
|
987
769
|
return ret;
|
|
988
770
|
}
|
|
989
771
|
|
|
990
772
|
const rep = function () {
|
|
991
|
-
return _.endsWith(module,
|
|
992
|
-
? module.replace(".js", ".min.js")
|
|
993
|
-
: module.replace(".mjs", ".min.mjs");
|
|
773
|
+
return _.endsWith(module, '.js') ? module.replace('.js', '.min.js') : module.replace('.mjs', '.min.mjs');
|
|
994
774
|
};
|
|
995
775
|
|
|
996
|
-
if (
|
|
997
|
-
|
|
998
|
-
typeof IS_PROCESS_SERVER !== "undefined"
|
|
999
|
-
) {
|
|
1000
|
-
ret = await get_ret(
|
|
1001
|
-
func.utils.get_resource_filename(
|
|
1002
|
-
SESSION_OBJ[SESSION_ID].engine_mode === "live_preview"
|
|
1003
|
-
? ""
|
|
1004
|
-
: SESSION_OBJ[SESSION_ID]?.opt?.app_build_id,
|
|
1005
|
-
`${_conf.xuda_home}root/dist/runtime/js/modules/` + rep()
|
|
1006
|
-
)
|
|
1007
|
-
);
|
|
776
|
+
if (typeof IS_DOCKER !== 'undefined' || typeof IS_PROCESS_SERVER !== 'undefined') {
|
|
777
|
+
ret = await get_ret(func.utils.get_resource_filename(SESSION_OBJ[SESSION_ID].engine_mode === 'live_preview' ? '' : SESSION_OBJ[SESSION_ID]?.opt?.app_build_id, `${_conf.xuda_home}root/dist/runtime/js/modules/` + rep()));
|
|
1008
778
|
} else {
|
|
1009
|
-
ret = await get_ret(
|
|
1010
|
-
func.common.get_url(
|
|
1011
|
-
SESSION_ID,
|
|
1012
|
-
"dist",
|
|
1013
|
-
func.utils.get_resource_filename(
|
|
1014
|
-
SESSION_OBJ[SESSION_ID].engine_mode === "live_preview"
|
|
1015
|
-
? ""
|
|
1016
|
-
: SESSION_OBJ[SESSION_ID]?.opt?.app_build_id,
|
|
1017
|
-
"runtime/js/modules/" + rep()
|
|
1018
|
-
)
|
|
1019
|
-
)
|
|
1020
|
-
);
|
|
779
|
+
ret = await get_ret(func.common.get_url(SESSION_ID, 'dist', func.utils.get_resource_filename(SESSION_OBJ[SESSION_ID].engine_mode === 'live_preview' ? '' : SESSION_OBJ[SESSION_ID]?.opt?.app_build_id, 'runtime/js/modules/' + rep())));
|
|
1021
780
|
}
|
|
1022
781
|
|
|
1023
782
|
return ret;
|
|
@@ -1026,209 +785,160 @@ func.common.get_module = async function (SESSION_ID, module, paramsP = {}) {
|
|
|
1026
785
|
func.api = {};
|
|
1027
786
|
func.api.set_field_value = async function (field_id, value, avoid_refresh) {
|
|
1028
787
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
1029
|
-
const api_utils = await func.common.get_module(
|
|
788
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
789
|
+
func,
|
|
790
|
+
glb,
|
|
791
|
+
SESSION_OBJ,
|
|
1030
792
|
SESSION_ID,
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
glb,
|
|
1035
|
-
SESSION_OBJ,
|
|
1036
|
-
SESSION_ID,
|
|
1037
|
-
APP_OBJ,
|
|
1038
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
1039
|
-
}
|
|
1040
|
-
);
|
|
793
|
+
APP_OBJ,
|
|
794
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
795
|
+
});
|
|
1041
796
|
|
|
1042
797
|
return await api_utils.set_field_value(field_id, value, avoid_refresh);
|
|
1043
798
|
};
|
|
1044
799
|
func.api.get_field_value = async function (field_id) {
|
|
1045
800
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
1046
|
-
const api_utils = await func.common.get_module(
|
|
801
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
802
|
+
func,
|
|
803
|
+
glb,
|
|
804
|
+
SESSION_OBJ,
|
|
1047
805
|
SESSION_ID,
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
glb,
|
|
1052
|
-
SESSION_OBJ,
|
|
1053
|
-
SESSION_ID,
|
|
1054
|
-
APP_OBJ,
|
|
1055
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
1056
|
-
}
|
|
1057
|
-
);
|
|
806
|
+
APP_OBJ,
|
|
807
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
808
|
+
});
|
|
1058
809
|
|
|
1059
810
|
return await api_utils.get_field_value(field_id);
|
|
1060
811
|
};
|
|
1061
812
|
func.api.invoke_event = async function (event_id) {
|
|
1062
813
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
1063
|
-
const api_utils = await func.common.get_module(
|
|
814
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
815
|
+
func,
|
|
816
|
+
glb,
|
|
817
|
+
SESSION_OBJ,
|
|
1064
818
|
SESSION_ID,
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
glb,
|
|
1069
|
-
SESSION_OBJ,
|
|
1070
|
-
SESSION_ID,
|
|
1071
|
-
APP_OBJ,
|
|
1072
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
1073
|
-
}
|
|
1074
|
-
);
|
|
819
|
+
APP_OBJ,
|
|
820
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
821
|
+
});
|
|
1075
822
|
|
|
1076
823
|
return await api_utils.invoke_event(event_id);
|
|
1077
824
|
};
|
|
1078
825
|
func.api.call_project_api = async function (prog_id, params) {
|
|
1079
826
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
1080
|
-
const api_utils = await func.common.get_module(
|
|
827
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
828
|
+
func,
|
|
829
|
+
glb,
|
|
830
|
+
SESSION_OBJ,
|
|
1081
831
|
SESSION_ID,
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
glb,
|
|
1086
|
-
SESSION_OBJ,
|
|
1087
|
-
SESSION_ID,
|
|
1088
|
-
APP_OBJ,
|
|
1089
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
1090
|
-
}
|
|
1091
|
-
);
|
|
832
|
+
APP_OBJ,
|
|
833
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
834
|
+
});
|
|
1092
835
|
|
|
1093
836
|
return await api_utils.call_project_api(prog_id, params, null);
|
|
1094
837
|
};
|
|
1095
838
|
func.api.call_system_api = async function (api_method, payload) {
|
|
1096
839
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
1097
|
-
const api_utils = await func.common.get_module(
|
|
840
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
841
|
+
func,
|
|
842
|
+
glb,
|
|
843
|
+
SESSION_OBJ,
|
|
1098
844
|
SESSION_ID,
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
glb,
|
|
1103
|
-
SESSION_OBJ,
|
|
1104
|
-
SESSION_ID,
|
|
1105
|
-
APP_OBJ,
|
|
1106
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
1107
|
-
}
|
|
1108
|
-
);
|
|
845
|
+
APP_OBJ,
|
|
846
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
847
|
+
});
|
|
1109
848
|
|
|
1110
849
|
return await api_utils.call_system_api(api_method, payload, null);
|
|
1111
850
|
};
|
|
1112
851
|
|
|
1113
852
|
func.api.dbs_create = async function (table_id, data, cb) {
|
|
1114
853
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
1115
|
-
const api_utils = await func.common.get_module(
|
|
854
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
855
|
+
func,
|
|
856
|
+
glb,
|
|
857
|
+
SESSION_OBJ,
|
|
1116
858
|
SESSION_ID,
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
glb,
|
|
1121
|
-
SESSION_OBJ,
|
|
1122
|
-
SESSION_ID,
|
|
1123
|
-
APP_OBJ,
|
|
1124
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
1125
|
-
}
|
|
1126
|
-
);
|
|
859
|
+
APP_OBJ,
|
|
860
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
861
|
+
});
|
|
1127
862
|
|
|
1128
863
|
return await api_utils.dbs_create(table_id, row_id, data, cb);
|
|
1129
864
|
};
|
|
1130
865
|
func.api.dbs_read = async function (table_id, selector, fields, sort, limit, skip, cb) {
|
|
1131
866
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
1132
|
-
const api_utils = await func.common.get_module(
|
|
867
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
868
|
+
func,
|
|
869
|
+
glb,
|
|
870
|
+
SESSION_OBJ,
|
|
1133
871
|
SESSION_ID,
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
glb,
|
|
1138
|
-
SESSION_OBJ,
|
|
1139
|
-
SESSION_ID,
|
|
1140
|
-
APP_OBJ,
|
|
1141
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
1142
|
-
}
|
|
1143
|
-
);
|
|
872
|
+
APP_OBJ,
|
|
873
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
874
|
+
});
|
|
1144
875
|
|
|
1145
876
|
return await api_utils.dbs_read(table_id, selector, fields, sort, limit, skip, cb);
|
|
1146
877
|
};
|
|
1147
878
|
func.api.dbs_update = async function (table_id, row_id, data) {
|
|
1148
879
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
1149
|
-
const api_utils = await func.common.get_module(
|
|
880
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
881
|
+
func,
|
|
882
|
+
glb,
|
|
883
|
+
SESSION_OBJ,
|
|
1150
884
|
SESSION_ID,
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
glb,
|
|
1155
|
-
SESSION_OBJ,
|
|
1156
|
-
SESSION_ID,
|
|
1157
|
-
APP_OBJ,
|
|
1158
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
1159
|
-
}
|
|
1160
|
-
);
|
|
885
|
+
APP_OBJ,
|
|
886
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
887
|
+
});
|
|
1161
888
|
|
|
1162
889
|
return await api_utils.dbs_update(table_id, row_id, data, cb);
|
|
1163
890
|
};
|
|
1164
891
|
func.api.dbs_delete = async function (table_id, row_id, cb) {
|
|
1165
892
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
1166
|
-
const api_utils = await func.common.get_module(
|
|
893
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
894
|
+
func,
|
|
895
|
+
glb,
|
|
896
|
+
SESSION_OBJ,
|
|
1167
897
|
SESSION_ID,
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
glb,
|
|
1172
|
-
SESSION_OBJ,
|
|
1173
|
-
SESSION_ID,
|
|
1174
|
-
APP_OBJ,
|
|
1175
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
1176
|
-
}
|
|
1177
|
-
);
|
|
898
|
+
APP_OBJ,
|
|
899
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
900
|
+
});
|
|
1178
901
|
|
|
1179
902
|
return await api_utils.dbs_delete(table_id, row_id, cb);
|
|
1180
903
|
};
|
|
1181
904
|
|
|
1182
905
|
func.api.call_javascript = async function (prog_id, params, evaluate) {
|
|
1183
906
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
1184
|
-
const api_utils = await func.common.get_module(
|
|
907
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
908
|
+
func,
|
|
909
|
+
glb,
|
|
910
|
+
SESSION_OBJ,
|
|
1185
911
|
SESSION_ID,
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
glb,
|
|
1190
|
-
SESSION_OBJ,
|
|
1191
|
-
SESSION_ID,
|
|
1192
|
-
APP_OBJ,
|
|
1193
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
1194
|
-
}
|
|
1195
|
-
);
|
|
912
|
+
APP_OBJ,
|
|
913
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
914
|
+
});
|
|
1196
915
|
|
|
1197
916
|
return await api_utils.call_javascript(prog_id, params, evaluate);
|
|
1198
917
|
};
|
|
1199
918
|
|
|
1200
919
|
func.api.call_javascript = async function (prog_id, params, evaluate) {
|
|
1201
920
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
1202
|
-
const api_utils = await func.common.get_module(
|
|
921
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
922
|
+
func,
|
|
923
|
+
glb,
|
|
924
|
+
SESSION_OBJ,
|
|
1203
925
|
SESSION_ID,
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
glb,
|
|
1208
|
-
SESSION_OBJ,
|
|
1209
|
-
SESSION_ID,
|
|
1210
|
-
APP_OBJ,
|
|
1211
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
1212
|
-
}
|
|
1213
|
-
);
|
|
926
|
+
APP_OBJ,
|
|
927
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
928
|
+
});
|
|
1214
929
|
|
|
1215
930
|
return await api_utils.call_javascript(prog_id, params, evaluate);
|
|
1216
931
|
};
|
|
1217
932
|
|
|
1218
933
|
glb.rpi_request_queue_num = 0;
|
|
1219
|
-
func.common.perform_rpi_request = async function (
|
|
1220
|
-
SESSION_ID,
|
|
1221
|
-
serviceP,
|
|
1222
|
-
opt = {},
|
|
1223
|
-
data
|
|
1224
|
-
) {
|
|
934
|
+
func.common.perform_rpi_request = async function (SESSION_ID, serviceP, opt = {}, data) {
|
|
1225
935
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
1226
936
|
var _data_system = _session?.DS_GLB?.[0]?.data_system;
|
|
1227
937
|
|
|
1228
938
|
const set_ajax = async function (stat) {
|
|
1229
939
|
var datasource_changes = {
|
|
1230
940
|
[0]: {
|
|
1231
|
-
[
|
|
941
|
+
['data_system']: { SYS_GLOBAL_BOL_AJAX_BUSY: stat },
|
|
1232
942
|
},
|
|
1233
943
|
};
|
|
1234
944
|
await func.datasource.update(SESSION_ID, datasource_changes);
|
|
@@ -1237,12 +947,7 @@ func.common.perform_rpi_request = async function (
|
|
|
1237
947
|
// _data_system.SYS_GLOBAL_BOL_AJAX_BUSY = 1;
|
|
1238
948
|
await set_ajax(1);
|
|
1239
949
|
if (!_data_system.SYS_GLOBAL_BOL_CONNECTED) {
|
|
1240
|
-
func.utils.alerts.toast(
|
|
1241
|
-
SESSION_ID,
|
|
1242
|
-
"Server connection error",
|
|
1243
|
-
"You are not connected to the server, so your request cannot be processed.",
|
|
1244
|
-
"error"
|
|
1245
|
-
);
|
|
950
|
+
func.utils.alerts.toast(SESSION_ID, 'Server connection error', 'You are not connected to the server, so your request cannot be processed.', 'error');
|
|
1246
951
|
return { code: 88, data: {} };
|
|
1247
952
|
}
|
|
1248
953
|
}
|
|
@@ -1256,8 +961,8 @@ func.common.perform_rpi_request = async function (
|
|
|
1256
961
|
const timeoutPromise = new Promise((_, reject) =>
|
|
1257
962
|
setTimeout(() => {
|
|
1258
963
|
controller.abort();
|
|
1259
|
-
reject(new Error(
|
|
1260
|
-
}, timeout)
|
|
964
|
+
reject(new Error('Request timed out'));
|
|
965
|
+
}, timeout),
|
|
1261
966
|
);
|
|
1262
967
|
|
|
1263
968
|
const fetchPromise = fetch(url, { ...options, signal });
|
|
@@ -1265,27 +970,24 @@ func.common.perform_rpi_request = async function (
|
|
|
1265
970
|
return Promise.race([fetchPromise, timeoutPromise]);
|
|
1266
971
|
};
|
|
1267
972
|
|
|
1268
|
-
var url = func.common.get_url(SESSION_ID,
|
|
973
|
+
var url = func.common.get_url(SESSION_ID, 'rpi', '');
|
|
1269
974
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
1270
975
|
const app_id = _session.app_id;
|
|
1271
976
|
|
|
1272
|
-
if (
|
|
1273
|
-
|
|
1274
|
-
_session.rpi_http_methods?.includes(serviceP)
|
|
1275
|
-
) {
|
|
1276
|
-
url = "https://" + _session.host + "/rpi/";
|
|
977
|
+
if (APP_OBJ[app_id].is_deployment && _session.rpi_http_methods?.includes(serviceP)) {
|
|
978
|
+
url = 'https://' + _session.host + '/rpi/';
|
|
1277
979
|
}
|
|
1278
980
|
|
|
1279
981
|
url += serviceP;
|
|
1280
982
|
|
|
1281
983
|
try {
|
|
1282
984
|
const response = await fetchWithTimeout(url, {
|
|
1283
|
-
method: opt.type ? opt.type :
|
|
985
|
+
method: opt.type ? opt.type : 'POST',
|
|
1284
986
|
headers: {
|
|
1285
|
-
Accept:
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
987
|
+
Accept: 'application/json',
|
|
988
|
+
'Content-Type': 'application/json',
|
|
989
|
+
'xu-gtp-token': _session.gtp_token,
|
|
990
|
+
'xu-app-token': _session.app_token,
|
|
1289
991
|
},
|
|
1290
992
|
body: JSON.stringify(data),
|
|
1291
993
|
});
|
|
@@ -1298,10 +1000,7 @@ func.common.perform_rpi_request = async function (
|
|
|
1298
1000
|
} catch (err) {
|
|
1299
1001
|
console.error(err);
|
|
1300
1002
|
if (err === 503) {
|
|
1301
|
-
_this.func.UI.utils.progressScreen.show(
|
|
1302
|
-
SESSION_ID,
|
|
1303
|
-
`Error code ${err}, reloading in 5 sec`
|
|
1304
|
-
);
|
|
1003
|
+
_this.func.UI.utils.progressScreen.show(SESSION_ID, `Error code ${err}, reloading in 5 sec`);
|
|
1305
1004
|
setTimeout(async () => {
|
|
1306
1005
|
await func.index.delete_pouch(SESSION_ID);
|
|
1307
1006
|
location.reload();
|
|
@@ -1312,23 +1011,19 @@ func.common.perform_rpi_request = async function (
|
|
|
1312
1011
|
};
|
|
1313
1012
|
|
|
1314
1013
|
try {
|
|
1315
|
-
if (_session.engine_mode ===
|
|
1316
|
-
throw new Error(
|
|
1014
|
+
if (_session.engine_mode === 'live_preview') {
|
|
1015
|
+
throw new Error('live_preview');
|
|
1317
1016
|
}
|
|
1318
1017
|
|
|
1319
1018
|
if (SESSION_OBJ?.[SESSION_ID]?.rpi_http_methods?.includes(serviceP)) {
|
|
1320
|
-
const ret = await func.common.get_data_from_websocket(
|
|
1321
|
-
SESSION_ID,
|
|
1322
|
-
serviceP,
|
|
1323
|
-
data
|
|
1324
|
-
);
|
|
1019
|
+
const ret = await func.common.get_data_from_websocket(SESSION_ID, serviceP, data);
|
|
1325
1020
|
if (_data_system) {
|
|
1326
1021
|
// _data_system.SYS_GLOBAL_BOL_AJAX_BUSY = 0;
|
|
1327
1022
|
await set_ajax(0);
|
|
1328
1023
|
}
|
|
1329
1024
|
return ret;
|
|
1330
1025
|
} else {
|
|
1331
|
-
throw new Error(
|
|
1026
|
+
throw new Error('method not found in rpi_http_methods');
|
|
1332
1027
|
}
|
|
1333
1028
|
} catch (err) {
|
|
1334
1029
|
const ret = await http();
|
|
@@ -1340,11 +1035,7 @@ func.common.perform_rpi_request = async function (
|
|
|
1340
1035
|
}
|
|
1341
1036
|
};
|
|
1342
1037
|
|
|
1343
|
-
func.common.get_data_from_websocket = async function (
|
|
1344
|
-
SESSION_ID,
|
|
1345
|
-
serviceP,
|
|
1346
|
-
data
|
|
1347
|
-
) {
|
|
1038
|
+
func.common.get_data_from_websocket = async function (SESSION_ID, serviceP, data) {
|
|
1348
1039
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
1349
1040
|
return new Promise(function (resolve, reject) {
|
|
1350
1041
|
const dbs_calls = function () {
|
|
@@ -1355,60 +1046,46 @@ func.common.get_data_from_websocket = async function (
|
|
|
1355
1046
|
websocket_queue_num: glb.websocket_queue_num,
|
|
1356
1047
|
};
|
|
1357
1048
|
if (glb.IS_WORKER) {
|
|
1358
|
-
func.utils.post_back_to_client(
|
|
1359
|
-
SESSION_ID,
|
|
1360
|
-
"get_dbs_data_from_websocket",
|
|
1361
|
-
_session.worker_id,
|
|
1362
|
-
obj
|
|
1363
|
-
);
|
|
1049
|
+
func.utils.post_back_to_client(SESSION_ID, 'get_dbs_data_from_websocket', _session.worker_id, obj);
|
|
1364
1050
|
|
|
1365
|
-
self.addEventListener(
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
resolve(event.detail.data);
|
|
1369
|
-
}
|
|
1370
|
-
);
|
|
1051
|
+
self.addEventListener('get_ws_data_worker_' + glb.websocket_queue_num, (event) => {
|
|
1052
|
+
resolve(event.detail.data);
|
|
1053
|
+
});
|
|
1371
1054
|
// throw new Error("not ready yet");
|
|
1372
1055
|
} else {
|
|
1373
1056
|
if (RUNTIME_SERVER_WEBSOCKET && RUNTIME_SERVER_WEBSOCKET_CONNECTED) {
|
|
1374
|
-
RUNTIME_SERVER_WEBSOCKET.emit(
|
|
1375
|
-
$(
|
|
1376
|
-
|
|
1377
|
-
(
|
|
1378
|
-
|
|
1379
|
-
$("body").off(
|
|
1380
|
-
"get_ws_data_response_" + data.e.websocket_queue_num
|
|
1381
|
-
);
|
|
1382
|
-
}
|
|
1383
|
-
);
|
|
1057
|
+
RUNTIME_SERVER_WEBSOCKET.emit('message', obj);
|
|
1058
|
+
$('body').on('get_ws_data_response_' + glb.websocket_queue_num, (e, data) => {
|
|
1059
|
+
resolve(data.data);
|
|
1060
|
+
$('body').off('get_ws_data_response_' + data.e.websocket_queue_num);
|
|
1061
|
+
});
|
|
1384
1062
|
} else {
|
|
1385
|
-
throw new Error(
|
|
1063
|
+
throw new Error('fail to fetch from ws websocket inactive');
|
|
1386
1064
|
}
|
|
1387
1065
|
}
|
|
1388
1066
|
};
|
|
1389
1067
|
const heartbeat = function () {
|
|
1390
1068
|
const obj = {
|
|
1391
|
-
service:
|
|
1069
|
+
service: 'heartbeat',
|
|
1392
1070
|
data,
|
|
1393
1071
|
};
|
|
1394
1072
|
|
|
1395
1073
|
if (RUNTIME_SERVER_WEBSOCKET && RUNTIME_SERVER_WEBSOCKET_CONNECTED) {
|
|
1396
|
-
RUNTIME_SERVER_WEBSOCKET.emit(
|
|
1397
|
-
$(
|
|
1074
|
+
RUNTIME_SERVER_WEBSOCKET.emit('message', obj);
|
|
1075
|
+
$('body').on('heartbeat_response', (e, data) => {
|
|
1398
1076
|
resolve(data.data);
|
|
1399
|
-
$(
|
|
1077
|
+
$('body').off('heartbeat_response');
|
|
1400
1078
|
});
|
|
1401
1079
|
} else {
|
|
1402
|
-
throw new Error(
|
|
1080
|
+
throw new Error('fail to fetch from ws websocket inactive');
|
|
1403
1081
|
}
|
|
1404
1082
|
};
|
|
1405
|
-
if (serviceP ===
|
|
1083
|
+
if (serviceP === 'heartbeat') {
|
|
1406
1084
|
return heartbeat();
|
|
1407
1085
|
}
|
|
1408
1086
|
dbs_calls();
|
|
1409
1087
|
});
|
|
1410
1088
|
};
|
|
1411
|
-
|
|
1412
1089
|
glb.DEBUG_INFO_OBJ = {};
|
|
1413
1090
|
// var CONNECTION_ATTEMPTS = 0;
|
|
1414
1091
|
glb.APP_INFO = {};
|