taon 19.0.47 → 19.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +160 -160
- package/bin/start.js +279 -279
- package/bin/taon +6 -6
- package/bin/taon-debug +5 -5
- package/bin/taon-debug-brk +5 -5
- package/browser/README.md +24 -24
- package/browser/fesm2022/taon.mjs +259 -192
- package/browser/fesm2022/taon.mjs.map +1 -1
- package/browser/lib/constants.d.ts +2 -1
- package/browser/lib/endpoint-context.d.ts +22 -1
- package/browser/lib/helpers/class-helpers.d.ts +0 -1
- package/browser/lib/realtime/realtime-core.d.ts +2 -2
- package/browser/lib/realtime/realtime-server.d.ts +2 -2
- package/browser/package.json +1 -1
- package/lib/build-info._auto-generated_.d.ts +2 -1
- package/lib/build-info._auto-generated_.js +3 -2
- package/lib/build-info._auto-generated_.js.map +1 -1
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +2 -1
- package/lib/constants.js.map +1 -1
- package/lib/endpoint-context.d.ts +22 -1
- package/lib/endpoint-context.js +108 -49
- package/lib/endpoint-context.js.map +1 -1
- package/lib/env.d.ts +2 -0
- package/lib/env.js +7 -0
- package/lib/env.js.map +1 -0
- package/lib/helpers/class-helpers.d.ts +0 -1
- package/lib/helpers/class-helpers.js +13 -14
- package/lib/helpers/class-helpers.js.map +1 -1
- package/lib/realtime/realtime-core.d.ts +2 -2
- package/lib/realtime/realtime-core.js +6 -5
- package/lib/realtime/realtime-core.js.map +1 -1
- package/lib/realtime/realtime-server.d.ts +2 -2
- package/lib/realtime/realtime-server.js +22 -22
- package/lib/realtime/realtime-server.js.map +1 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock.js +2 -2
- package/lib/realtime/realtime-strategy/realtime-strategy-mock.js.map +1 -1
- package/lib/storage.d.ts +1 -0
- package/lib/storage.js +6 -0
- package/lib/storage.js.map +1 -0
- package/lib/ui/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
- package/package.json +1 -1
- package/websql/README.md +24 -24
- package/websql/fesm2022/taon.mjs +286 -223
- package/websql/fesm2022/taon.mjs.map +1 -1
- package/websql/lib/constants.d.ts +2 -1
- package/websql/lib/endpoint-context.d.ts +22 -1
- package/websql/lib/helpers/class-helpers.d.ts +0 -1
- package/websql/lib/realtime/realtime-core.d.ts +2 -2
- package/websql/lib/realtime/realtime-server.d.ts +2 -2
- package/websql/package.json +1 -1
|
@@ -6,12 +6,12 @@ import { walk } from 'lodash-walk-object/browser';
|
|
|
6
6
|
import { OrignalClassKey, Table } from 'taon-typeorm/browser';
|
|
7
7
|
import { SYMBOL, CLASS } from 'typescript-class-helpers/browser';
|
|
8
8
|
import { Models as Models$1, RestHeaders, Resource, Mapping } from 'ng2-rest/browser';
|
|
9
|
-
import * as JSON5 from 'json5';
|
|
10
9
|
import * as i0 from '@angular/core';
|
|
11
10
|
import { InjectionToken, inject as inject$1, Injectable } from '@angular/core';
|
|
12
11
|
import axios from 'axios';
|
|
13
12
|
import { JSON10 } from 'json10/browser';
|
|
14
13
|
import { Observable, from, Subject } from 'rxjs';
|
|
14
|
+
import * as JSON5 from 'json5';
|
|
15
15
|
import { io } from 'socket.io-client';
|
|
16
16
|
|
|
17
17
|
var Symbols;
|
|
@@ -321,146 +321,6 @@ var Models;
|
|
|
321
321
|
//#endregion
|
|
322
322
|
})(Models || (Models = {}));
|
|
323
323
|
|
|
324
|
-
var TaonHelpers;
|
|
325
|
-
(function (TaonHelpers) {
|
|
326
|
-
//#region fillUpTo string
|
|
327
|
-
TaonHelpers.fillUpTo = (s, nCharacters) => {
|
|
328
|
-
return _.times(nCharacters, n => {
|
|
329
|
-
if (s.charAt(n)) {
|
|
330
|
-
return s.charAt(n);
|
|
331
|
-
}
|
|
332
|
-
return ' ';
|
|
333
|
-
}).join('');
|
|
334
|
-
};
|
|
335
|
-
//#endregion
|
|
336
|
-
//#region is good path
|
|
337
|
-
TaonHelpers.isGoodPath = (p) => {
|
|
338
|
-
return p && typeof p === 'string' && p.trim() !== '';
|
|
339
|
-
};
|
|
340
|
-
//#endregion
|
|
341
|
-
//#region try transform params
|
|
342
|
-
TaonHelpers.tryTransformParam = param => {
|
|
343
|
-
if (typeof param === 'string') {
|
|
344
|
-
let n = Number(param);
|
|
345
|
-
if (!isNaN(n))
|
|
346
|
-
return n;
|
|
347
|
-
const bool = param.trim().toLowerCase();
|
|
348
|
-
if (bool === 'true') {
|
|
349
|
-
return true;
|
|
350
|
-
}
|
|
351
|
-
if (bool === 'false') {
|
|
352
|
-
return false;
|
|
353
|
-
}
|
|
354
|
-
try {
|
|
355
|
-
const t = JSON5.parse(param);
|
|
356
|
-
return t;
|
|
357
|
-
}
|
|
358
|
-
catch (e) {
|
|
359
|
-
return param;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
return param;
|
|
363
|
-
};
|
|
364
|
-
//#endregion
|
|
365
|
-
//#region get expores path
|
|
366
|
-
TaonHelpers.getExpressPath = (c, pathOrClassConfig) => {
|
|
367
|
-
if (typeof pathOrClassConfig === 'string')
|
|
368
|
-
return `${c.calculatedPath}${pathOrClassConfig}`.replace(/\/$/, '');
|
|
369
|
-
return `${c.calculatedPath}${pathOrClassConfig.path}`.replace(/\/$/, '');
|
|
370
|
-
};
|
|
371
|
-
//#endregion
|
|
372
|
-
//#region get default value tyep
|
|
373
|
-
TaonHelpers.defaultType = value => {
|
|
374
|
-
if (typeof value === 'string')
|
|
375
|
-
return '';
|
|
376
|
-
if (typeof value === 'boolean')
|
|
377
|
-
return false;
|
|
378
|
-
if (Array.isArray(value))
|
|
379
|
-
return {};
|
|
380
|
-
if (typeof value === 'object')
|
|
381
|
-
return {};
|
|
382
|
-
};
|
|
383
|
-
//#endregion
|
|
384
|
-
//#region parse json with string jsons
|
|
385
|
-
TaonHelpers.parseJSONwithStringJSONs = (object, waring = false) => {
|
|
386
|
-
// console.log('checking object', object)
|
|
387
|
-
if (!_.isObject(object)) {
|
|
388
|
-
if (waring) {
|
|
389
|
-
console.error(`
|
|
390
|
-
parseJSONwithStringJSONs(...)
|
|
391
|
-
Parameter should be a object, but is ${typeof object}
|
|
392
|
-
`, object);
|
|
393
|
-
}
|
|
394
|
-
return object;
|
|
395
|
-
}
|
|
396
|
-
let res = _.cloneDeep(object);
|
|
397
|
-
Object.keys(res).forEach(key => {
|
|
398
|
-
let isJson = false;
|
|
399
|
-
try {
|
|
400
|
-
const possibleJSON = JSON.parse(res[key]);
|
|
401
|
-
res[key] = possibleJSON;
|
|
402
|
-
isJson = true;
|
|
403
|
-
}
|
|
404
|
-
catch (e) {
|
|
405
|
-
isJson = false;
|
|
406
|
-
}
|
|
407
|
-
// console.log(`key ${key} is json `, isJson)
|
|
408
|
-
if (isJson) {
|
|
409
|
-
res[key] = TaonHelpers.parseJSONwithStringJSONs(res[key], false);
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
return res;
|
|
413
|
-
};
|
|
414
|
-
//#endregion
|
|
415
|
-
//#region is plain file or folder
|
|
416
|
-
TaonHelpers.isPlainFileOrFolder = filePath => {
|
|
417
|
-
return /^([a-zA-Z]|\-|\_|\@|\#|\$|\!|\^|\&|\*|\(|\))+$/.test(filePath);
|
|
418
|
-
};
|
|
419
|
-
//#endregion
|
|
420
|
-
//#region ips key name repsonse
|
|
421
|
-
TaonHelpers.ipcKeyNameResponse = (target, methodConfig, expressPath) => {
|
|
422
|
-
return [
|
|
423
|
-
'response',
|
|
424
|
-
ClassHelpers.getName(target),
|
|
425
|
-
methodConfig.methodName,
|
|
426
|
-
methodConfig.type,
|
|
427
|
-
expressPath,
|
|
428
|
-
].join('--');
|
|
429
|
-
};
|
|
430
|
-
//#endregion
|
|
431
|
-
//#region ipc key name request
|
|
432
|
-
TaonHelpers.ipcKeyNameRequest = (target, methodConfig, expressPath) => {
|
|
433
|
-
return [
|
|
434
|
-
'request',
|
|
435
|
-
ClassHelpers.getName(target),
|
|
436
|
-
methodConfig.methodName,
|
|
437
|
-
methodConfig.type,
|
|
438
|
-
expressPath,
|
|
439
|
-
].join('--');
|
|
440
|
-
};
|
|
441
|
-
//#endregion
|
|
442
|
-
//#region websql mocks
|
|
443
|
-
TaonHelpers.websqlMocks = headers => {
|
|
444
|
-
const response = {
|
|
445
|
-
status(status) {
|
|
446
|
-
// console.log({status})
|
|
447
|
-
return {
|
|
448
|
-
send(send) {
|
|
449
|
-
// console.log({status})
|
|
450
|
-
},
|
|
451
|
-
};
|
|
452
|
-
},
|
|
453
|
-
setHeader(key, value) {
|
|
454
|
-
// console.log('Dummy set header', arguments)
|
|
455
|
-
headers[key] = value;
|
|
456
|
-
},
|
|
457
|
-
};
|
|
458
|
-
const request = {};
|
|
459
|
-
return { request, response };
|
|
460
|
-
};
|
|
461
|
-
//#endregion
|
|
462
|
-
})(TaonHelpers || (TaonHelpers = {}));
|
|
463
|
-
|
|
464
324
|
/* */
|
|
465
325
|
/* */
|
|
466
326
|
var ClassHelpers;
|
|
@@ -651,19 +511,19 @@ var ClassHelpers;
|
|
|
651
511
|
};
|
|
652
512
|
//#endregion
|
|
653
513
|
//#region get path for
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
};
|
|
514
|
+
// export const getCalculatedPathFor = (target: Function) => {
|
|
515
|
+
// const configs = getControllerConfigs(target);
|
|
516
|
+
// const parentscalculatedPath = _.slice(configs, 1)
|
|
517
|
+
// .reverse()
|
|
518
|
+
// .map(bc => {
|
|
519
|
+
// if (TaonHelpers.isGoodPath(bc.path)) {
|
|
520
|
+
// return bc.path;
|
|
521
|
+
// }
|
|
522
|
+
// return bc.className;
|
|
523
|
+
// })
|
|
524
|
+
// .join('/');
|
|
525
|
+
// return `/${parentscalculatedPath}/${ClassHelpers.getName(target)}`;
|
|
526
|
+
// };
|
|
667
527
|
//#endregion
|
|
668
528
|
})(ClassHelpers || (ClassHelpers = {}));
|
|
669
529
|
|
|
@@ -759,6 +619,7 @@ TAON_CONTEXT = new InjectionToken('TAON_CONTEXT');
|
|
|
759
619
|
let CURRENT_HOST_BACKEND_PORT;
|
|
760
620
|
//#region @browser
|
|
761
621
|
CURRENT_HOST_BACKEND_PORT = new InjectionToken('CURRENT_HOST_BACKEND_PORT');
|
|
622
|
+
const apiPrefix = 'api';
|
|
762
623
|
|
|
763
624
|
const inject = (entity) => {
|
|
764
625
|
return new Proxy({}, {
|
|
@@ -1391,6 +1252,146 @@ const getResponseValue = (response, options) => {
|
|
|
1391
1252
|
return (void 0);
|
|
1392
1253
|
};
|
|
1393
1254
|
|
|
1255
|
+
var TaonHelpers;
|
|
1256
|
+
(function (TaonHelpers) {
|
|
1257
|
+
//#region fillUpTo string
|
|
1258
|
+
TaonHelpers.fillUpTo = (s, nCharacters) => {
|
|
1259
|
+
return _.times(nCharacters, n => {
|
|
1260
|
+
if (s.charAt(n)) {
|
|
1261
|
+
return s.charAt(n);
|
|
1262
|
+
}
|
|
1263
|
+
return ' ';
|
|
1264
|
+
}).join('');
|
|
1265
|
+
};
|
|
1266
|
+
//#endregion
|
|
1267
|
+
//#region is good path
|
|
1268
|
+
TaonHelpers.isGoodPath = (p) => {
|
|
1269
|
+
return p && typeof p === 'string' && p.trim() !== '';
|
|
1270
|
+
};
|
|
1271
|
+
//#endregion
|
|
1272
|
+
//#region try transform params
|
|
1273
|
+
TaonHelpers.tryTransformParam = param => {
|
|
1274
|
+
if (typeof param === 'string') {
|
|
1275
|
+
let n = Number(param);
|
|
1276
|
+
if (!isNaN(n))
|
|
1277
|
+
return n;
|
|
1278
|
+
const bool = param.trim().toLowerCase();
|
|
1279
|
+
if (bool === 'true') {
|
|
1280
|
+
return true;
|
|
1281
|
+
}
|
|
1282
|
+
if (bool === 'false') {
|
|
1283
|
+
return false;
|
|
1284
|
+
}
|
|
1285
|
+
try {
|
|
1286
|
+
const t = JSON5.parse(param);
|
|
1287
|
+
return t;
|
|
1288
|
+
}
|
|
1289
|
+
catch (e) {
|
|
1290
|
+
return param;
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
return param;
|
|
1294
|
+
};
|
|
1295
|
+
//#endregion
|
|
1296
|
+
//#region get expores path
|
|
1297
|
+
TaonHelpers.getExpressPath = (c, pathOrClassConfig) => {
|
|
1298
|
+
if (typeof pathOrClassConfig === 'string')
|
|
1299
|
+
return `${c.calculatedPath}${pathOrClassConfig}`.replace(/\/$/, '');
|
|
1300
|
+
return `${c.calculatedPath}${pathOrClassConfig.path}`.replace(/\/$/, '');
|
|
1301
|
+
};
|
|
1302
|
+
//#endregion
|
|
1303
|
+
//#region get default value tyep
|
|
1304
|
+
TaonHelpers.defaultType = value => {
|
|
1305
|
+
if (typeof value === 'string')
|
|
1306
|
+
return '';
|
|
1307
|
+
if (typeof value === 'boolean')
|
|
1308
|
+
return false;
|
|
1309
|
+
if (Array.isArray(value))
|
|
1310
|
+
return {};
|
|
1311
|
+
if (typeof value === 'object')
|
|
1312
|
+
return {};
|
|
1313
|
+
};
|
|
1314
|
+
//#endregion
|
|
1315
|
+
//#region parse json with string jsons
|
|
1316
|
+
TaonHelpers.parseJSONwithStringJSONs = (object, waring = false) => {
|
|
1317
|
+
// console.log('checking object', object)
|
|
1318
|
+
if (!_.isObject(object)) {
|
|
1319
|
+
if (waring) {
|
|
1320
|
+
console.error(`
|
|
1321
|
+
parseJSONwithStringJSONs(...)
|
|
1322
|
+
Parameter should be a object, but is ${typeof object}
|
|
1323
|
+
`, object);
|
|
1324
|
+
}
|
|
1325
|
+
return object;
|
|
1326
|
+
}
|
|
1327
|
+
let res = _.cloneDeep(object);
|
|
1328
|
+
Object.keys(res).forEach(key => {
|
|
1329
|
+
let isJson = false;
|
|
1330
|
+
try {
|
|
1331
|
+
const possibleJSON = JSON.parse(res[key]);
|
|
1332
|
+
res[key] = possibleJSON;
|
|
1333
|
+
isJson = true;
|
|
1334
|
+
}
|
|
1335
|
+
catch (e) {
|
|
1336
|
+
isJson = false;
|
|
1337
|
+
}
|
|
1338
|
+
// console.log(`key ${key} is json `, isJson)
|
|
1339
|
+
if (isJson) {
|
|
1340
|
+
res[key] = TaonHelpers.parseJSONwithStringJSONs(res[key], false);
|
|
1341
|
+
}
|
|
1342
|
+
});
|
|
1343
|
+
return res;
|
|
1344
|
+
};
|
|
1345
|
+
//#endregion
|
|
1346
|
+
//#region is plain file or folder
|
|
1347
|
+
TaonHelpers.isPlainFileOrFolder = filePath => {
|
|
1348
|
+
return /^([a-zA-Z]|\-|\_|\@|\#|\$|\!|\^|\&|\*|\(|\))+$/.test(filePath);
|
|
1349
|
+
};
|
|
1350
|
+
//#endregion
|
|
1351
|
+
//#region ips key name repsonse
|
|
1352
|
+
TaonHelpers.ipcKeyNameResponse = (target, methodConfig, expressPath) => {
|
|
1353
|
+
return [
|
|
1354
|
+
'response',
|
|
1355
|
+
ClassHelpers.getName(target),
|
|
1356
|
+
methodConfig.methodName,
|
|
1357
|
+
methodConfig.type,
|
|
1358
|
+
expressPath,
|
|
1359
|
+
].join('--');
|
|
1360
|
+
};
|
|
1361
|
+
//#endregion
|
|
1362
|
+
//#region ipc key name request
|
|
1363
|
+
TaonHelpers.ipcKeyNameRequest = (target, methodConfig, expressPath) => {
|
|
1364
|
+
return [
|
|
1365
|
+
'request',
|
|
1366
|
+
ClassHelpers.getName(target),
|
|
1367
|
+
methodConfig.methodName,
|
|
1368
|
+
methodConfig.type,
|
|
1369
|
+
expressPath,
|
|
1370
|
+
].join('--');
|
|
1371
|
+
};
|
|
1372
|
+
//#endregion
|
|
1373
|
+
//#region websql mocks
|
|
1374
|
+
TaonHelpers.websqlMocks = headers => {
|
|
1375
|
+
const response = {
|
|
1376
|
+
status(status) {
|
|
1377
|
+
// console.log({status})
|
|
1378
|
+
return {
|
|
1379
|
+
send(send) {
|
|
1380
|
+
// console.log({status})
|
|
1381
|
+
},
|
|
1382
|
+
};
|
|
1383
|
+
},
|
|
1384
|
+
setHeader(key, value) {
|
|
1385
|
+
// console.log('Dummy set header', arguments)
|
|
1386
|
+
headers[key] = value;
|
|
1387
|
+
},
|
|
1388
|
+
};
|
|
1389
|
+
const request = {};
|
|
1390
|
+
return { request, response };
|
|
1391
|
+
};
|
|
1392
|
+
//#endregion
|
|
1393
|
+
})(TaonHelpers || (TaonHelpers = {}));
|
|
1394
|
+
|
|
1394
1395
|
//#region imports
|
|
1395
1396
|
/* */
|
|
1396
1397
|
/* */
|
|
@@ -1659,6 +1660,7 @@ to use socket realtime connection;
|
|
|
1659
1660
|
}
|
|
1660
1661
|
|
|
1661
1662
|
//#region imports
|
|
1663
|
+
/* */
|
|
1662
1664
|
//#endregion
|
|
1663
1665
|
class RealtimeServer {
|
|
1664
1666
|
// private jobs = {};
|
|
@@ -1836,6 +1838,9 @@ class RealtimeServer {
|
|
|
1836
1838
|
/* */
|
|
1837
1839
|
/* */
|
|
1838
1840
|
/* */
|
|
1841
|
+
/* */
|
|
1842
|
+
/* */
|
|
1843
|
+
/* */
|
|
1839
1844
|
}
|
|
1840
1845
|
//#endregion
|
|
1841
1846
|
//#region methods & getters / trigger changes
|
|
@@ -2534,12 +2539,12 @@ class RealtimeStrategyMock extends RealtimeStrategy {
|
|
|
2534
2539
|
//#endregion
|
|
2535
2540
|
//#region server & io
|
|
2536
2541
|
ioServer(url, opt) {
|
|
2537
|
-
const server = MockServer.from(url || this.ctx.
|
|
2542
|
+
const server = MockServer.from(url || this.ctx.uriOrigin);
|
|
2538
2543
|
return server.of(opt?.path || '/');
|
|
2539
2544
|
}
|
|
2540
2545
|
get ioClient() {
|
|
2541
2546
|
const clientIo = (uri, opts) => {
|
|
2542
|
-
return new MockSocket(uri || this.ctx.
|
|
2547
|
+
return new MockSocket(uri || this.ctx.uriOrigin, opts);
|
|
2543
2548
|
};
|
|
2544
2549
|
return clientIo;
|
|
2545
2550
|
}
|
|
@@ -2609,6 +2614,7 @@ class RealtimeCore {
|
|
|
2609
2614
|
//#endregion
|
|
2610
2615
|
//#region methods & getters / resovle staraegy
|
|
2611
2616
|
resolveStrategy() {
|
|
2617
|
+
// console.log(`[taon] resolveStrategy for this.ctx.mode ${this.ctx.mode}`);
|
|
2612
2618
|
if (this.ctx.mode === 'backend-frontend(websql)' ||
|
|
2613
2619
|
this.ctx.mode === 'backend-frontend(websql-electron)') {
|
|
2614
2620
|
// debugger
|
|
@@ -2628,15 +2634,14 @@ class RealtimeCore {
|
|
|
2628
2634
|
//#endregion
|
|
2629
2635
|
//#region path for
|
|
2630
2636
|
pathFor(namespace) {
|
|
2631
|
-
const uri = this.ctx.uri;
|
|
2632
2637
|
let nsp = namespace ? namespace : '';
|
|
2633
2638
|
nsp = nsp === '/' ? '' : nsp;
|
|
2634
|
-
|
|
2635
|
-
let prefix = `taonContext`;
|
|
2639
|
+
let prefix = `${apiPrefix}/${this.ctx.contextName}/udp`;
|
|
2636
2640
|
if (Helpers.isElectron) {
|
|
2637
2641
|
prefix = ``;
|
|
2638
2642
|
}
|
|
2639
|
-
const href = `${
|
|
2643
|
+
const href = `${this.ctx.uriOrigin}${this.ctx.uriPathnameOrNothingIfRoot}` +
|
|
2644
|
+
`/${prefix}${prefix && nsp ? '-' + nsp : nsp}`;
|
|
2640
2645
|
// console.log(`HREF: ${href}, nsp: ${nsp}`)
|
|
2641
2646
|
return new URL(href);
|
|
2642
2647
|
}
|
|
@@ -2920,6 +2925,10 @@ class EndpointContext {
|
|
|
2920
2925
|
}
|
|
2921
2926
|
this.mode = 'remote-backend(tcp+udp)';
|
|
2922
2927
|
}
|
|
2928
|
+
// console.log(`
|
|
2929
|
+
// useIpcWhenElectron: ${this.config.useIpcWhenElectron}
|
|
2930
|
+
// Helpers.isElectron: ${Helpers.isElectron}
|
|
2931
|
+
// `)
|
|
2923
2932
|
if (this.config.useIpcWhenElectron && Helpers.isElectron) {
|
|
2924
2933
|
if (Helpers.isWebSQL) {
|
|
2925
2934
|
this.mode = 'backend-frontend(websql-electron)';
|
|
@@ -2928,6 +2937,11 @@ class EndpointContext {
|
|
|
2928
2937
|
this.mode = 'backend-frontend(ipc-electron)';
|
|
2929
2938
|
}
|
|
2930
2939
|
}
|
|
2940
|
+
// mode === undefined for BaseContext => ok behavior
|
|
2941
|
+
// console.log(`Mode for BE/FE communication: ${this.mode}`);
|
|
2942
|
+
// if(!this.mode) {
|
|
2943
|
+
// console.log(this.config)
|
|
2944
|
+
// }
|
|
2931
2945
|
if (!this.mode && !this.config.abstract) {
|
|
2932
2946
|
Helpers.error(`[taon] Context "${this.contextName}": You need to provide host or remoteHost or useIpcWhenElectron`, false, true);
|
|
2933
2947
|
/* */
|
|
@@ -3279,6 +3293,22 @@ class EndpointContext {
|
|
|
3279
3293
|
/* */
|
|
3280
3294
|
/* */
|
|
3281
3295
|
/* */
|
|
3296
|
+
/* */
|
|
3297
|
+
/* */
|
|
3298
|
+
/* */
|
|
3299
|
+
/* */
|
|
3300
|
+
/* */
|
|
3301
|
+
/* */
|
|
3302
|
+
/* */
|
|
3303
|
+
/* */
|
|
3304
|
+
/* */
|
|
3305
|
+
/* */
|
|
3306
|
+
/* */
|
|
3307
|
+
/* */
|
|
3308
|
+
/* */
|
|
3309
|
+
/* */
|
|
3310
|
+
/* */
|
|
3311
|
+
/* */
|
|
3282
3312
|
return (void 0);
|
|
3283
3313
|
}
|
|
3284
3314
|
//#endregion
|
|
@@ -3598,16 +3628,53 @@ class EndpointContext {
|
|
|
3598
3628
|
return url;
|
|
3599
3629
|
}
|
|
3600
3630
|
//#endregion
|
|
3631
|
+
get uriPort() {
|
|
3632
|
+
return this.uri?.port;
|
|
3633
|
+
}
|
|
3634
|
+
get uriProtocol() {
|
|
3635
|
+
return this.uri?.protocol;
|
|
3636
|
+
}
|
|
3637
|
+
/**
|
|
3638
|
+
* Examples
|
|
3639
|
+
* http://localhost:3000
|
|
3640
|
+
* https://localhost (from localhost:80) *
|
|
3641
|
+
*/
|
|
3642
|
+
get uriOrigin() {
|
|
3643
|
+
return this.uri?.origin;
|
|
3644
|
+
}
|
|
3645
|
+
/**
|
|
3646
|
+
* Exampels
|
|
3647
|
+
* http://localhost:3000/path/to/somewhere
|
|
3648
|
+
* https://localhost/path/to/somewhere (from localhost:80)
|
|
3649
|
+
*/
|
|
3650
|
+
// get uriOriginWithPathname(): string | undefined {
|
|
3651
|
+
// return this.uri?.origin
|
|
3652
|
+
// ? this.uri?.origin + this.uriPathnameOrNothingIfRoot.replace(/\/$/, '')
|
|
3653
|
+
// : undefined;
|
|
3654
|
+
// }
|
|
3655
|
+
get uriPathname() {
|
|
3656
|
+
return this.uri?.pathname;
|
|
3657
|
+
}
|
|
3658
|
+
/**
|
|
3659
|
+
* Examples
|
|
3660
|
+
* http://localhost:3000/path/to/somewhere -> '/path/to/somewhere'
|
|
3661
|
+
* http://localhost:3000 -> '' #
|
|
3662
|
+
* https://localhost/path/to/ -> '/path/to/somewhere' # remove last slash
|
|
3663
|
+
*/
|
|
3664
|
+
get uriPathnameOrNothingIfRoot() {
|
|
3665
|
+
const isNonRootProperPathName = this.uri?.pathname && this.uri.pathname !== '/';
|
|
3666
|
+
return isNonRootProperPathName ? this.uri.pathname.replace(/\/$/, '') : '';
|
|
3667
|
+
}
|
|
3601
3668
|
/**
|
|
3602
3669
|
* Port from uri as number
|
|
3603
3670
|
* @returns {Number | undefined}
|
|
3604
3671
|
*/
|
|
3605
3672
|
get port() {
|
|
3606
|
-
return this.uri?.port ? Number(this.
|
|
3673
|
+
return this.uri?.port ? Number(this.uriPort) : undefined;
|
|
3607
3674
|
}
|
|
3608
3675
|
//#region methods & getters / is https server
|
|
3609
3676
|
get isHttpServer() {
|
|
3610
|
-
return this.
|
|
3677
|
+
return this.uriProtocol === 'https:';
|
|
3611
3678
|
}
|
|
3612
3679
|
//#endregion
|
|
3613
3680
|
//#region methods & getters / public assets
|
|
@@ -3844,7 +3911,7 @@ class EndpointContext {
|
|
|
3844
3911
|
return;
|
|
3845
3912
|
}
|
|
3846
3913
|
const allControllers = this.getClassFunByArr(Models.ClassType.CONTROLLER);
|
|
3847
|
-
// console.log('allControllers', allControllers)
|
|
3914
|
+
// console.log('allControllers', allControllers);
|
|
3848
3915
|
for (const controllerClassFn of allControllers) {
|
|
3849
3916
|
controllerClassFn[Symbols.classMethodsNames] =
|
|
3850
3917
|
ClassHelpers.getMethodsNames(controllerClassFn);
|
|
@@ -3864,15 +3931,17 @@ class EndpointContext {
|
|
|
3864
3931
|
classConfig.calculatedPath = classConfig.path;
|
|
3865
3932
|
}
|
|
3866
3933
|
else {
|
|
3867
|
-
classConfig.calculatedPath =
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3934
|
+
classConfig.calculatedPath = (`${this.uriPathnameOrNothingIfRoot}` +
|
|
3935
|
+
`/${apiPrefix}/${this.contextName}/tcp${parentscalculatedPath}/` +
|
|
3936
|
+
`${ClassHelpers.getName(controllerClassFn)}`)
|
|
3937
|
+
.replace(/\/\//g, '/')
|
|
3938
|
+
.split('/')
|
|
3939
|
+
.reduce((acc, bc) => {
|
|
3940
|
+
return _.last(acc) === bc ? acc : [...acc, bc];
|
|
3941
|
+
}, [])
|
|
3942
|
+
.join('/');
|
|
3875
3943
|
}
|
|
3944
|
+
// console.log('calculatedPath', classConfig.calculatedPath);
|
|
3876
3945
|
_.slice(configs, 1).forEach(bc => {
|
|
3877
3946
|
const alreadyIs = classConfig.methods;
|
|
3878
3947
|
const toMerge = _.cloneDeep(bc.methods);
|
|
@@ -3898,7 +3967,7 @@ class EndpointContext {
|
|
|
3898
3967
|
const expressPath = methodConfig.global
|
|
3899
3968
|
? `/${methodConfig.path?.replace(/\//, '')}`
|
|
3900
3969
|
: TaonHelpers.getExpressPath(classConfig, methodConfig);
|
|
3901
|
-
// console.log({ expressPath })
|
|
3970
|
+
// console.log({ expressPath });
|
|
3902
3971
|
if (Helpers.isNode || Helpers.isWebSQL) {
|
|
3903
3972
|
/* */
|
|
3904
3973
|
/* */
|
|
@@ -3943,7 +4012,7 @@ class EndpointContext {
|
|
|
3943
4012
|
this.skipWritingServerRoutes) {
|
|
3944
4013
|
return;
|
|
3945
4014
|
}
|
|
3946
|
-
const contexts = [this];
|
|
4015
|
+
// const contexts: EndpointContext[] = [this];
|
|
3947
4016
|
/* */
|
|
3948
4017
|
/* */
|
|
3949
4018
|
/* */
|
|
@@ -4108,7 +4177,7 @@ class EndpointContext {
|
|
|
4108
4177
|
/* */
|
|
4109
4178
|
/* */
|
|
4110
4179
|
/* */
|
|
4111
|
-
const url = this.uri;
|
|
4180
|
+
// const url = this.uri;
|
|
4112
4181
|
//#region get result
|
|
4113
4182
|
const getResult = async (resolvedParams, req, res) => {
|
|
4114
4183
|
const response = methodConfig.descriptor.value.apply(
|
|
@@ -4124,12 +4193,7 @@ class EndpointContext {
|
|
|
4124
4193
|
return result;
|
|
4125
4194
|
};
|
|
4126
4195
|
//#endregion
|
|
4127
|
-
|
|
4128
|
-
expressPath = url.pathname.startsWith('/')
|
|
4129
|
-
? `${url.pathname}${expressPath}`
|
|
4130
|
-
: expressPath;
|
|
4131
|
-
expressPath = expressPath.replace(/\/\//g, '/');
|
|
4132
|
-
// console.log(`BACKEND: expressPath: ${ expressPath } `)
|
|
4196
|
+
// console.log(`BACKEND: expressPath: "${expressPath}" `);
|
|
4133
4197
|
//#endregion
|
|
4134
4198
|
if (Helpers.isElectron) {
|
|
4135
4199
|
/* */
|
|
@@ -4153,6 +4217,9 @@ class EndpointContext {
|
|
|
4153
4217
|
/* */
|
|
4154
4218
|
/* */
|
|
4155
4219
|
/* */
|
|
4220
|
+
/* */
|
|
4221
|
+
/* */
|
|
4222
|
+
/* */
|
|
4156
4223
|
}
|
|
4157
4224
|
if (!this.remoteHost) {
|
|
4158
4225
|
//#region apply dummy websql express routers
|
|
@@ -4379,7 +4446,7 @@ class EndpointContext {
|
|
|
4379
4446
|
/* */
|
|
4380
4447
|
}
|
|
4381
4448
|
return {
|
|
4382
|
-
|
|
4449
|
+
expressPath: expressPath,
|
|
4383
4450
|
method: methodConfig.type,
|
|
4384
4451
|
};
|
|
4385
4452
|
}
|
|
@@ -4417,7 +4484,7 @@ class EndpointContext {
|
|
|
4417
4484
|
body: void 0,
|
|
4418
4485
|
isArray: void 0,
|
|
4419
4486
|
method: methodConfig.type,
|
|
4420
|
-
url: `${ctx.
|
|
4487
|
+
url: `${ctx.uriOrigin}${'' // TODO express path
|
|
4421
4488
|
}${methodConfig.path} `,
|
|
4422
4489
|
}, Helpers.isBlob(body) || _.isString(body)
|
|
4423
4490
|
? body
|
|
@@ -4594,37 +4661,37 @@ class EndpointContext {
|
|
|
4594
4661
|
//#region resolve frontend parameters
|
|
4595
4662
|
if (!storage[Symbols.old.ENDPOINT_META_CONFIG])
|
|
4596
4663
|
storage[Symbols.old.ENDPOINT_META_CONFIG] = {};
|
|
4597
|
-
if (!storage[Symbols.old.ENDPOINT_META_CONFIG][ctx.
|
|
4598
|
-
storage[Symbols.old.ENDPOINT_META_CONFIG][ctx.
|
|
4664
|
+
if (!storage[Symbols.old.ENDPOINT_META_CONFIG][ctx.uriOrigin])
|
|
4665
|
+
storage[Symbols.old.ENDPOINT_META_CONFIG][ctx.uriOrigin] = {};
|
|
4599
4666
|
const endpoints = storage[Symbols.old.ENDPOINT_META_CONFIG];
|
|
4600
4667
|
let rest;
|
|
4601
|
-
if (!endpoints[ctx.
|
|
4668
|
+
if (!endpoints[ctx.uriOrigin][expressPath]) {
|
|
4602
4669
|
let headers = {};
|
|
4603
4670
|
if (methodConfig.contentType && !methodConfig.responseType) {
|
|
4604
|
-
rest = Resource.create(ctx.
|
|
4671
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols.old.MAPPING_CONFIG_HEADER, Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
4605
4672
|
'Content-Type': methodConfig.contentType,
|
|
4606
4673
|
Accept: methodConfig.contentType,
|
|
4607
4674
|
}));
|
|
4608
4675
|
}
|
|
4609
4676
|
else if (methodConfig.contentType && methodConfig.responseType) {
|
|
4610
|
-
rest = Resource.create(ctx.
|
|
4677
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols.old.MAPPING_CONFIG_HEADER, Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
4611
4678
|
'Content-Type': methodConfig.contentType,
|
|
4612
4679
|
Accept: methodConfig.contentType,
|
|
4613
4680
|
responsetypeaxios: methodConfig.responseType,
|
|
4614
4681
|
}));
|
|
4615
4682
|
}
|
|
4616
4683
|
else if (!methodConfig.contentType && methodConfig.responseType) {
|
|
4617
|
-
rest = Resource.create(ctx.
|
|
4684
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols.old.MAPPING_CONFIG_HEADER, Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
4618
4685
|
responsetypeaxios: methodConfig.responseType,
|
|
4619
4686
|
}));
|
|
4620
4687
|
}
|
|
4621
4688
|
else {
|
|
4622
|
-
rest = Resource.create(ctx.
|
|
4689
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols.old.MAPPING_CONFIG_HEADER, Symbols.old.CIRCURAL_OBJECTS_MAP_BODY);
|
|
4623
4690
|
}
|
|
4624
|
-
endpoints[ctx.
|
|
4691
|
+
endpoints[ctx.uriOrigin][expressPath] = rest;
|
|
4625
4692
|
}
|
|
4626
4693
|
else {
|
|
4627
|
-
rest = endpoints[ctx.
|
|
4694
|
+
rest = endpoints[ctx.uriOrigin][expressPath];
|
|
4628
4695
|
}
|
|
4629
4696
|
const method = type.toLowerCase();
|
|
4630
4697
|
const isWithBody = method === 'put' || method === 'post';
|
|
@@ -6558,5 +6625,5 @@ var Taon;
|
|
|
6558
6625
|
* Generated bundle index. Do not edit.
|
|
6559
6626
|
*/
|
|
6560
6627
|
|
|
6561
|
-
export { BaseContext, BaseController, BaseCustomRepository, BaseEntity, BaseMigration, BaseProvider, BaseRepository, CURRENT_HOST_BACKEND_PORT, ClassHelpers, EndpointContext, Models, TAON_CONTEXT, Taon, TaonAdminService, TaonEntityKeysToOmitArr, createContext, inject };
|
|
6628
|
+
export { BaseContext, BaseController, BaseCustomRepository, BaseEntity, BaseMigration, BaseProvider, BaseRepository, CURRENT_HOST_BACKEND_PORT, ClassHelpers, EndpointContext, Models, TAON_CONTEXT, Taon, TaonAdminService, TaonEntityKeysToOmitArr, apiPrefix, createContext, inject };
|
|
6562
6629
|
//# sourceMappingURL=taon.mjs.map
|