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
package/websql/fesm2022/taon.mjs
CHANGED
|
@@ -7,12 +7,12 @@ import { OrignalClassKey, Entity, Table, TableIndex, EventSubscriber, DataSource
|
|
|
7
7
|
import { walk } from 'lodash-walk-object/websql';
|
|
8
8
|
import { SYMBOL, CLASS } from 'typescript-class-helpers/websql';
|
|
9
9
|
import { Models as Models$1, RestHeaders, Resource, Mapping } from 'ng2-rest/websql';
|
|
10
|
-
import * as JSON5 from 'json5';
|
|
11
10
|
import * as i0 from '@angular/core';
|
|
12
11
|
import { InjectionToken, inject as inject$1, Injectable } from '@angular/core';
|
|
13
12
|
import axios from 'axios';
|
|
14
13
|
import { JSON10 } from 'json10/websql';
|
|
15
14
|
import { Observable, Subject, from } from 'rxjs';
|
|
15
|
+
import * as JSON5 from 'json5';
|
|
16
16
|
import { io } from 'socket.io-client';
|
|
17
17
|
import { MySqlQuerySource } from 'taon-type-sql/websql';
|
|
18
18
|
|
|
@@ -424,146 +424,6 @@ var Models;
|
|
|
424
424
|
//#endregion
|
|
425
425
|
})(Models || (Models = {}));
|
|
426
426
|
|
|
427
|
-
var TaonHelpers;
|
|
428
|
-
(function (TaonHelpers) {
|
|
429
|
-
//#region fillUpTo string
|
|
430
|
-
TaonHelpers.fillUpTo = (s, nCharacters) => {
|
|
431
|
-
return _.times(nCharacters, n => {
|
|
432
|
-
if (s.charAt(n)) {
|
|
433
|
-
return s.charAt(n);
|
|
434
|
-
}
|
|
435
|
-
return ' ';
|
|
436
|
-
}).join('');
|
|
437
|
-
};
|
|
438
|
-
//#endregion
|
|
439
|
-
//#region is good path
|
|
440
|
-
TaonHelpers.isGoodPath = (p) => {
|
|
441
|
-
return p && typeof p === 'string' && p.trim() !== '';
|
|
442
|
-
};
|
|
443
|
-
//#endregion
|
|
444
|
-
//#region try transform params
|
|
445
|
-
TaonHelpers.tryTransformParam = param => {
|
|
446
|
-
if (typeof param === 'string') {
|
|
447
|
-
let n = Number(param);
|
|
448
|
-
if (!isNaN(n))
|
|
449
|
-
return n;
|
|
450
|
-
const bool = param.trim().toLowerCase();
|
|
451
|
-
if (bool === 'true') {
|
|
452
|
-
return true;
|
|
453
|
-
}
|
|
454
|
-
if (bool === 'false') {
|
|
455
|
-
return false;
|
|
456
|
-
}
|
|
457
|
-
try {
|
|
458
|
-
const t = JSON5.parse(param);
|
|
459
|
-
return t;
|
|
460
|
-
}
|
|
461
|
-
catch (e) {
|
|
462
|
-
return param;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
return param;
|
|
466
|
-
};
|
|
467
|
-
//#endregion
|
|
468
|
-
//#region get expores path
|
|
469
|
-
TaonHelpers.getExpressPath = (c, pathOrClassConfig) => {
|
|
470
|
-
if (typeof pathOrClassConfig === 'string')
|
|
471
|
-
return `${c.calculatedPath}${pathOrClassConfig}`.replace(/\/$/, '');
|
|
472
|
-
return `${c.calculatedPath}${pathOrClassConfig.path}`.replace(/\/$/, '');
|
|
473
|
-
};
|
|
474
|
-
//#endregion
|
|
475
|
-
//#region get default value tyep
|
|
476
|
-
TaonHelpers.defaultType = value => {
|
|
477
|
-
if (typeof value === 'string')
|
|
478
|
-
return '';
|
|
479
|
-
if (typeof value === 'boolean')
|
|
480
|
-
return false;
|
|
481
|
-
if (Array.isArray(value))
|
|
482
|
-
return {};
|
|
483
|
-
if (typeof value === 'object')
|
|
484
|
-
return {};
|
|
485
|
-
};
|
|
486
|
-
//#endregion
|
|
487
|
-
//#region parse json with string jsons
|
|
488
|
-
TaonHelpers.parseJSONwithStringJSONs = (object, waring = false) => {
|
|
489
|
-
// console.log('checking object', object)
|
|
490
|
-
if (!_.isObject(object)) {
|
|
491
|
-
if (waring) {
|
|
492
|
-
console.error(`
|
|
493
|
-
parseJSONwithStringJSONs(...)
|
|
494
|
-
Parameter should be a object, but is ${typeof object}
|
|
495
|
-
`, object);
|
|
496
|
-
}
|
|
497
|
-
return object;
|
|
498
|
-
}
|
|
499
|
-
let res = _.cloneDeep(object);
|
|
500
|
-
Object.keys(res).forEach(key => {
|
|
501
|
-
let isJson = false;
|
|
502
|
-
try {
|
|
503
|
-
const possibleJSON = JSON.parse(res[key]);
|
|
504
|
-
res[key] = possibleJSON;
|
|
505
|
-
isJson = true;
|
|
506
|
-
}
|
|
507
|
-
catch (e) {
|
|
508
|
-
isJson = false;
|
|
509
|
-
}
|
|
510
|
-
// console.log(`key ${key} is json `, isJson)
|
|
511
|
-
if (isJson) {
|
|
512
|
-
res[key] = TaonHelpers.parseJSONwithStringJSONs(res[key], false);
|
|
513
|
-
}
|
|
514
|
-
});
|
|
515
|
-
return res;
|
|
516
|
-
};
|
|
517
|
-
//#endregion
|
|
518
|
-
//#region is plain file or folder
|
|
519
|
-
TaonHelpers.isPlainFileOrFolder = filePath => {
|
|
520
|
-
return /^([a-zA-Z]|\-|\_|\@|\#|\$|\!|\^|\&|\*|\(|\))+$/.test(filePath);
|
|
521
|
-
};
|
|
522
|
-
//#endregion
|
|
523
|
-
//#region ips key name repsonse
|
|
524
|
-
TaonHelpers.ipcKeyNameResponse = (target, methodConfig, expressPath) => {
|
|
525
|
-
return [
|
|
526
|
-
'response',
|
|
527
|
-
ClassHelpers.getName(target),
|
|
528
|
-
methodConfig.methodName,
|
|
529
|
-
methodConfig.type,
|
|
530
|
-
expressPath,
|
|
531
|
-
].join('--');
|
|
532
|
-
};
|
|
533
|
-
//#endregion
|
|
534
|
-
//#region ipc key name request
|
|
535
|
-
TaonHelpers.ipcKeyNameRequest = (target, methodConfig, expressPath) => {
|
|
536
|
-
return [
|
|
537
|
-
'request',
|
|
538
|
-
ClassHelpers.getName(target),
|
|
539
|
-
methodConfig.methodName,
|
|
540
|
-
methodConfig.type,
|
|
541
|
-
expressPath,
|
|
542
|
-
].join('--');
|
|
543
|
-
};
|
|
544
|
-
//#endregion
|
|
545
|
-
//#region websql mocks
|
|
546
|
-
TaonHelpers.websqlMocks = headers => {
|
|
547
|
-
const response = {
|
|
548
|
-
status(status) {
|
|
549
|
-
// console.log({status})
|
|
550
|
-
return {
|
|
551
|
-
send(send) {
|
|
552
|
-
// console.log({status})
|
|
553
|
-
},
|
|
554
|
-
};
|
|
555
|
-
},
|
|
556
|
-
setHeader(key, value) {
|
|
557
|
-
// console.log('Dummy set header', arguments)
|
|
558
|
-
headers[key] = value;
|
|
559
|
-
},
|
|
560
|
-
};
|
|
561
|
-
const request = {};
|
|
562
|
-
return { request, response };
|
|
563
|
-
};
|
|
564
|
-
//#endregion
|
|
565
|
-
})(TaonHelpers || (TaonHelpers = {}));
|
|
566
|
-
|
|
567
427
|
/* */
|
|
568
428
|
/* */
|
|
569
429
|
var ClassHelpers;
|
|
@@ -754,19 +614,19 @@ var ClassHelpers;
|
|
|
754
614
|
};
|
|
755
615
|
//#endregion
|
|
756
616
|
//#region get path for
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
};
|
|
617
|
+
// export const getCalculatedPathFor = (target: Function) => {
|
|
618
|
+
// const configs = getControllerConfigs(target);
|
|
619
|
+
// const parentscalculatedPath = _.slice(configs, 1)
|
|
620
|
+
// .reverse()
|
|
621
|
+
// .map(bc => {
|
|
622
|
+
// if (TaonHelpers.isGoodPath(bc.path)) {
|
|
623
|
+
// return bc.path;
|
|
624
|
+
// }
|
|
625
|
+
// return bc.className;
|
|
626
|
+
// })
|
|
627
|
+
// .join('/');
|
|
628
|
+
// return `/${parentscalculatedPath}/${ClassHelpers.getName(target)}`;
|
|
629
|
+
// };
|
|
770
630
|
//#endregion
|
|
771
631
|
})(ClassHelpers || (ClassHelpers = {}));
|
|
772
632
|
|
|
@@ -874,6 +734,7 @@ TAON_CONTEXT = new InjectionToken('TAON_CONTEXT');
|
|
|
874
734
|
let CURRENT_HOST_BACKEND_PORT;
|
|
875
735
|
//#region @browser
|
|
876
736
|
CURRENT_HOST_BACKEND_PORT = new InjectionToken('CURRENT_HOST_BACKEND_PORT');
|
|
737
|
+
const apiPrefix = 'api';
|
|
877
738
|
|
|
878
739
|
const inject = (entity) => {
|
|
879
740
|
return new Proxy({}, {
|
|
@@ -1399,6 +1260,146 @@ const getResponseValue = (response, options) => {
|
|
|
1399
1260
|
//#endregion
|
|
1400
1261
|
};
|
|
1401
1262
|
|
|
1263
|
+
var TaonHelpers;
|
|
1264
|
+
(function (TaonHelpers) {
|
|
1265
|
+
//#region fillUpTo string
|
|
1266
|
+
TaonHelpers.fillUpTo = (s, nCharacters) => {
|
|
1267
|
+
return _.times(nCharacters, n => {
|
|
1268
|
+
if (s.charAt(n)) {
|
|
1269
|
+
return s.charAt(n);
|
|
1270
|
+
}
|
|
1271
|
+
return ' ';
|
|
1272
|
+
}).join('');
|
|
1273
|
+
};
|
|
1274
|
+
//#endregion
|
|
1275
|
+
//#region is good path
|
|
1276
|
+
TaonHelpers.isGoodPath = (p) => {
|
|
1277
|
+
return p && typeof p === 'string' && p.trim() !== '';
|
|
1278
|
+
};
|
|
1279
|
+
//#endregion
|
|
1280
|
+
//#region try transform params
|
|
1281
|
+
TaonHelpers.tryTransformParam = param => {
|
|
1282
|
+
if (typeof param === 'string') {
|
|
1283
|
+
let n = Number(param);
|
|
1284
|
+
if (!isNaN(n))
|
|
1285
|
+
return n;
|
|
1286
|
+
const bool = param.trim().toLowerCase();
|
|
1287
|
+
if (bool === 'true') {
|
|
1288
|
+
return true;
|
|
1289
|
+
}
|
|
1290
|
+
if (bool === 'false') {
|
|
1291
|
+
return false;
|
|
1292
|
+
}
|
|
1293
|
+
try {
|
|
1294
|
+
const t = JSON5.parse(param);
|
|
1295
|
+
return t;
|
|
1296
|
+
}
|
|
1297
|
+
catch (e) {
|
|
1298
|
+
return param;
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
return param;
|
|
1302
|
+
};
|
|
1303
|
+
//#endregion
|
|
1304
|
+
//#region get expores path
|
|
1305
|
+
TaonHelpers.getExpressPath = (c, pathOrClassConfig) => {
|
|
1306
|
+
if (typeof pathOrClassConfig === 'string')
|
|
1307
|
+
return `${c.calculatedPath}${pathOrClassConfig}`.replace(/\/$/, '');
|
|
1308
|
+
return `${c.calculatedPath}${pathOrClassConfig.path}`.replace(/\/$/, '');
|
|
1309
|
+
};
|
|
1310
|
+
//#endregion
|
|
1311
|
+
//#region get default value tyep
|
|
1312
|
+
TaonHelpers.defaultType = value => {
|
|
1313
|
+
if (typeof value === 'string')
|
|
1314
|
+
return '';
|
|
1315
|
+
if (typeof value === 'boolean')
|
|
1316
|
+
return false;
|
|
1317
|
+
if (Array.isArray(value))
|
|
1318
|
+
return {};
|
|
1319
|
+
if (typeof value === 'object')
|
|
1320
|
+
return {};
|
|
1321
|
+
};
|
|
1322
|
+
//#endregion
|
|
1323
|
+
//#region parse json with string jsons
|
|
1324
|
+
TaonHelpers.parseJSONwithStringJSONs = (object, waring = false) => {
|
|
1325
|
+
// console.log('checking object', object)
|
|
1326
|
+
if (!_.isObject(object)) {
|
|
1327
|
+
if (waring) {
|
|
1328
|
+
console.error(`
|
|
1329
|
+
parseJSONwithStringJSONs(...)
|
|
1330
|
+
Parameter should be a object, but is ${typeof object}
|
|
1331
|
+
`, object);
|
|
1332
|
+
}
|
|
1333
|
+
return object;
|
|
1334
|
+
}
|
|
1335
|
+
let res = _.cloneDeep(object);
|
|
1336
|
+
Object.keys(res).forEach(key => {
|
|
1337
|
+
let isJson = false;
|
|
1338
|
+
try {
|
|
1339
|
+
const possibleJSON = JSON.parse(res[key]);
|
|
1340
|
+
res[key] = possibleJSON;
|
|
1341
|
+
isJson = true;
|
|
1342
|
+
}
|
|
1343
|
+
catch (e) {
|
|
1344
|
+
isJson = false;
|
|
1345
|
+
}
|
|
1346
|
+
// console.log(`key ${key} is json `, isJson)
|
|
1347
|
+
if (isJson) {
|
|
1348
|
+
res[key] = TaonHelpers.parseJSONwithStringJSONs(res[key], false);
|
|
1349
|
+
}
|
|
1350
|
+
});
|
|
1351
|
+
return res;
|
|
1352
|
+
};
|
|
1353
|
+
//#endregion
|
|
1354
|
+
//#region is plain file or folder
|
|
1355
|
+
TaonHelpers.isPlainFileOrFolder = filePath => {
|
|
1356
|
+
return /^([a-zA-Z]|\-|\_|\@|\#|\$|\!|\^|\&|\*|\(|\))+$/.test(filePath);
|
|
1357
|
+
};
|
|
1358
|
+
//#endregion
|
|
1359
|
+
//#region ips key name repsonse
|
|
1360
|
+
TaonHelpers.ipcKeyNameResponse = (target, methodConfig, expressPath) => {
|
|
1361
|
+
return [
|
|
1362
|
+
'response',
|
|
1363
|
+
ClassHelpers.getName(target),
|
|
1364
|
+
methodConfig.methodName,
|
|
1365
|
+
methodConfig.type,
|
|
1366
|
+
expressPath,
|
|
1367
|
+
].join('--');
|
|
1368
|
+
};
|
|
1369
|
+
//#endregion
|
|
1370
|
+
//#region ipc key name request
|
|
1371
|
+
TaonHelpers.ipcKeyNameRequest = (target, methodConfig, expressPath) => {
|
|
1372
|
+
return [
|
|
1373
|
+
'request',
|
|
1374
|
+
ClassHelpers.getName(target),
|
|
1375
|
+
methodConfig.methodName,
|
|
1376
|
+
methodConfig.type,
|
|
1377
|
+
expressPath,
|
|
1378
|
+
].join('--');
|
|
1379
|
+
};
|
|
1380
|
+
//#endregion
|
|
1381
|
+
//#region websql mocks
|
|
1382
|
+
TaonHelpers.websqlMocks = headers => {
|
|
1383
|
+
const response = {
|
|
1384
|
+
status(status) {
|
|
1385
|
+
// console.log({status})
|
|
1386
|
+
return {
|
|
1387
|
+
send(send) {
|
|
1388
|
+
// console.log({status})
|
|
1389
|
+
},
|
|
1390
|
+
};
|
|
1391
|
+
},
|
|
1392
|
+
setHeader(key, value) {
|
|
1393
|
+
// console.log('Dummy set header', arguments)
|
|
1394
|
+
headers[key] = value;
|
|
1395
|
+
},
|
|
1396
|
+
};
|
|
1397
|
+
const request = {};
|
|
1398
|
+
return { request, response };
|
|
1399
|
+
};
|
|
1400
|
+
//#endregion
|
|
1401
|
+
})(TaonHelpers || (TaonHelpers = {}));
|
|
1402
|
+
|
|
1402
1403
|
//#region imports
|
|
1403
1404
|
/* */
|
|
1404
1405
|
/* */
|
|
@@ -1667,6 +1668,7 @@ to use socket realtime connection;
|
|
|
1667
1668
|
}
|
|
1668
1669
|
|
|
1669
1670
|
//#region imports
|
|
1671
|
+
/* */
|
|
1670
1672
|
//#endregion
|
|
1671
1673
|
class RealtimeServer {
|
|
1672
1674
|
// private jobs = {};
|
|
@@ -1693,45 +1695,44 @@ class RealtimeServer {
|
|
|
1693
1695
|
`);
|
|
1694
1696
|
}
|
|
1695
1697
|
//#region prepare namespaces pathes
|
|
1696
|
-
const
|
|
1697
|
-
|
|
1698
|
-
realtime: this.core.pathFor(Symbols.REALTIME.NAMESPACE(this.core.ctx.contextName)),
|
|
1699
|
-
};
|
|
1698
|
+
const nspPathGlobal = this.core.pathFor();
|
|
1699
|
+
const nspPathRealtime = this.core.pathFor(Symbols.REALTIME.NAMESPACE(this.core.ctx.contextName));
|
|
1700
1700
|
//#endregion
|
|
1701
1701
|
// console.log('[backend] nspPath', nspPath);
|
|
1702
|
+
const fronendURL = new URL(this.core.ctx.config.frontendHost.replace(/\/$/, ''));
|
|
1703
|
+
const cors = {
|
|
1704
|
+
origin: fronendURL.origin, // only origin needs to be set - pathname not needed
|
|
1705
|
+
methods: this.core.allHttpMethods,
|
|
1706
|
+
};
|
|
1707
|
+
// console.log('frontendHost', this.core.ctx.config.frontendHost);
|
|
1708
|
+
// console.log('cors', cors);
|
|
1702
1709
|
//#region prepare global BE socket
|
|
1703
|
-
this.core.connectSocketBE = this.core.strategy.ioServer(Helpers.isWebSQL ? this.core.ctx.
|
|
1704
|
-
path:
|
|
1705
|
-
cors
|
|
1706
|
-
origin: this.core.ctx.config.frontendHost,
|
|
1707
|
-
methods: this.core.allHttpMethods,
|
|
1708
|
-
},
|
|
1710
|
+
this.core.connectSocketBE = this.core.strategy.ioServer(Helpers.isWebSQL ? this.core.ctx.uriOrigin : this.core.ctx.serverTcpUdp, {
|
|
1711
|
+
path: nspPathGlobal.pathname,
|
|
1712
|
+
cors,
|
|
1709
1713
|
}, // @ts-ignore
|
|
1710
1714
|
this.core.ctx);
|
|
1711
1715
|
this.core.ctx.logRealtime &&
|
|
1712
1716
|
console.info(`[backend] CREATE GLOBAL NAMESPACE: '${this.core.connectSocketBE.path()}'` +
|
|
1713
|
-
` , path: '${
|
|
1717
|
+
` , path: '${nspPathGlobal.pathname}'`);
|
|
1714
1718
|
this.core.connectSocketBE.on('connection', clientSocket => {
|
|
1715
|
-
console.info(`[backend] client connected to namespace "${
|
|
1719
|
+
console.info(`[backend] client connected to namespace "${nspPathGlobal.pathname}", ` +
|
|
1716
1720
|
` host: ${this.core.ctx.host}`);
|
|
1717
1721
|
});
|
|
1718
1722
|
//#endregion
|
|
1719
1723
|
//#region prepare realtime BE socket
|
|
1720
1724
|
this.core.socketBE = this.core.strategy.ioServer(Helpers.isWebSQL || Helpers.isElectron
|
|
1721
|
-
? this.core.ctx.
|
|
1725
|
+
? this.core.ctx.uriOrigin
|
|
1722
1726
|
: this.core.ctx.serverTcpUdp, {
|
|
1723
|
-
path:
|
|
1724
|
-
cors
|
|
1725
|
-
origin: this.core.ctx.config.frontendHost,
|
|
1726
|
-
methods: this.core.allHttpMethods,
|
|
1727
|
-
},
|
|
1727
|
+
path: nspPathRealtime.pathname,
|
|
1728
|
+
cors,
|
|
1728
1729
|
}, // @ts-ignore
|
|
1729
1730
|
this.core.ctx);
|
|
1730
1731
|
this.core.ctx.logRealtime &&
|
|
1731
1732
|
console.info(`[backend] CREATE REALTIME NAMESPACE: '${this.core.socketBE.path()}'` +
|
|
1732
|
-
` , path: '${
|
|
1733
|
+
` , path: '${nspPathRealtime.pathname}' `);
|
|
1733
1734
|
this.core.socketBE.on('connection', backendSocketForClient => {
|
|
1734
|
-
console.info(`[backend] client connected to namespace "${
|
|
1735
|
+
console.info(`[backend] client connected to namespace "${nspPathRealtime.pathname}", ` +
|
|
1735
1736
|
` host: ${this.core.ctx.host}`);
|
|
1736
1737
|
backendSocketForClient.on(Symbols.REALTIME.ROOM_SUBSCRIBE_CUSTOM(this.core.ctx.contextName), roomName => {
|
|
1737
1738
|
this.core.ctx.logRealtime &&
|
|
@@ -2440,12 +2441,12 @@ class RealtimeStrategyMock extends RealtimeStrategy {
|
|
|
2440
2441
|
//#endregion
|
|
2441
2442
|
//#region server & io
|
|
2442
2443
|
ioServer(url, opt) {
|
|
2443
|
-
const server = MockServer.from(url || this.ctx.
|
|
2444
|
+
const server = MockServer.from(url || this.ctx.uriOrigin);
|
|
2444
2445
|
return server.of(opt?.path || '/');
|
|
2445
2446
|
}
|
|
2446
2447
|
get ioClient() {
|
|
2447
2448
|
const clientIo = (uri, opts) => {
|
|
2448
|
-
return new MockSocket(uri || this.ctx.
|
|
2449
|
+
return new MockSocket(uri || this.ctx.uriOrigin, opts);
|
|
2449
2450
|
};
|
|
2450
2451
|
return clientIo;
|
|
2451
2452
|
}
|
|
@@ -2515,6 +2516,7 @@ class RealtimeCore {
|
|
|
2515
2516
|
//#endregion
|
|
2516
2517
|
//#region methods & getters / resovle staraegy
|
|
2517
2518
|
resolveStrategy() {
|
|
2519
|
+
// console.log(`[taon] resolveStrategy for this.ctx.mode ${this.ctx.mode}`);
|
|
2518
2520
|
if (this.ctx.mode === 'backend-frontend(websql)' ||
|
|
2519
2521
|
this.ctx.mode === 'backend-frontend(websql-electron)') {
|
|
2520
2522
|
// debugger
|
|
@@ -2534,15 +2536,14 @@ class RealtimeCore {
|
|
|
2534
2536
|
//#endregion
|
|
2535
2537
|
//#region path for
|
|
2536
2538
|
pathFor(namespace) {
|
|
2537
|
-
const uri = this.ctx.uri;
|
|
2538
2539
|
let nsp = namespace ? namespace : '';
|
|
2539
2540
|
nsp = nsp === '/' ? '' : nsp;
|
|
2540
|
-
|
|
2541
|
-
let prefix = `taonContext`;
|
|
2541
|
+
let prefix = `${apiPrefix}/${this.ctx.contextName}/udp`;
|
|
2542
2542
|
if (Helpers.isElectron) {
|
|
2543
2543
|
prefix = ``;
|
|
2544
2544
|
}
|
|
2545
|
-
const href = `${
|
|
2545
|
+
const href = `${this.ctx.uriOrigin}${this.ctx.uriPathnameOrNothingIfRoot}` +
|
|
2546
|
+
`/${prefix}${prefix && nsp ? '-' + nsp : nsp}`;
|
|
2546
2547
|
// console.log(`HREF: ${href}, nsp: ${nsp}`)
|
|
2547
2548
|
return new URL(href);
|
|
2548
2549
|
}
|
|
@@ -2874,6 +2875,10 @@ class EndpointContext {
|
|
|
2874
2875
|
}
|
|
2875
2876
|
this.mode = 'remote-backend(tcp+udp)';
|
|
2876
2877
|
}
|
|
2878
|
+
// console.log(`
|
|
2879
|
+
// useIpcWhenElectron: ${this.config.useIpcWhenElectron}
|
|
2880
|
+
// Helpers.isElectron: ${Helpers.isElectron}
|
|
2881
|
+
// `)
|
|
2877
2882
|
if (this.config.useIpcWhenElectron && Helpers.isElectron) {
|
|
2878
2883
|
if (Helpers.isWebSQL) {
|
|
2879
2884
|
this.mode = 'backend-frontend(websql-electron)';
|
|
@@ -2882,6 +2887,11 @@ class EndpointContext {
|
|
|
2882
2887
|
this.mode = 'backend-frontend(ipc-electron)';
|
|
2883
2888
|
}
|
|
2884
2889
|
}
|
|
2890
|
+
// mode === undefined for BaseContext => ok behavior
|
|
2891
|
+
// console.log(`Mode for BE/FE communication: ${this.mode}`);
|
|
2892
|
+
// if(!this.mode) {
|
|
2893
|
+
// console.log(this.config)
|
|
2894
|
+
// }
|
|
2885
2895
|
if (!this.mode && !this.config.abstract) {
|
|
2886
2896
|
Helpers.error(`[taon] Context "${this.contextName}": You need to provide host or remoteHost or useIpcWhenElectron`, false, true);
|
|
2887
2897
|
/* */
|
|
@@ -3223,6 +3233,22 @@ class EndpointContext {
|
|
|
3223
3233
|
/* */
|
|
3224
3234
|
/* */
|
|
3225
3235
|
/* */
|
|
3236
|
+
/* */
|
|
3237
|
+
/* */
|
|
3238
|
+
/* */
|
|
3239
|
+
/* */
|
|
3240
|
+
/* */
|
|
3241
|
+
/* */
|
|
3242
|
+
/* */
|
|
3243
|
+
/* */
|
|
3244
|
+
/* */
|
|
3245
|
+
/* */
|
|
3246
|
+
/* */
|
|
3247
|
+
/* */
|
|
3248
|
+
/* */
|
|
3249
|
+
/* */
|
|
3250
|
+
/* */
|
|
3251
|
+
/* */
|
|
3226
3252
|
return (void 0);
|
|
3227
3253
|
}
|
|
3228
3254
|
//#endregion
|
|
@@ -3539,16 +3565,53 @@ class EndpointContext {
|
|
|
3539
3565
|
return url;
|
|
3540
3566
|
}
|
|
3541
3567
|
//#endregion
|
|
3568
|
+
get uriPort() {
|
|
3569
|
+
return this.uri?.port;
|
|
3570
|
+
}
|
|
3571
|
+
get uriProtocol() {
|
|
3572
|
+
return this.uri?.protocol;
|
|
3573
|
+
}
|
|
3574
|
+
/**
|
|
3575
|
+
* Examples
|
|
3576
|
+
* http://localhost:3000
|
|
3577
|
+
* https://localhost (from localhost:80) *
|
|
3578
|
+
*/
|
|
3579
|
+
get uriOrigin() {
|
|
3580
|
+
return this.uri?.origin;
|
|
3581
|
+
}
|
|
3582
|
+
/**
|
|
3583
|
+
* Exampels
|
|
3584
|
+
* http://localhost:3000/path/to/somewhere
|
|
3585
|
+
* https://localhost/path/to/somewhere (from localhost:80)
|
|
3586
|
+
*/
|
|
3587
|
+
// get uriOriginWithPathname(): string | undefined {
|
|
3588
|
+
// return this.uri?.origin
|
|
3589
|
+
// ? this.uri?.origin + this.uriPathnameOrNothingIfRoot.replace(/\/$/, '')
|
|
3590
|
+
// : undefined;
|
|
3591
|
+
// }
|
|
3592
|
+
get uriPathname() {
|
|
3593
|
+
return this.uri?.pathname;
|
|
3594
|
+
}
|
|
3595
|
+
/**
|
|
3596
|
+
* Examples
|
|
3597
|
+
* http://localhost:3000/path/to/somewhere -> '/path/to/somewhere'
|
|
3598
|
+
* http://localhost:3000 -> '' #
|
|
3599
|
+
* https://localhost/path/to/ -> '/path/to/somewhere' # remove last slash
|
|
3600
|
+
*/
|
|
3601
|
+
get uriPathnameOrNothingIfRoot() {
|
|
3602
|
+
const isNonRootProperPathName = this.uri?.pathname && this.uri.pathname !== '/';
|
|
3603
|
+
return isNonRootProperPathName ? this.uri.pathname.replace(/\/$/, '') : '';
|
|
3604
|
+
}
|
|
3542
3605
|
/**
|
|
3543
3606
|
* Port from uri as number
|
|
3544
3607
|
* @returns {Number | undefined}
|
|
3545
3608
|
*/
|
|
3546
3609
|
get port() {
|
|
3547
|
-
return this.uri?.port ? Number(this.
|
|
3610
|
+
return this.uri?.port ? Number(this.uriPort) : undefined;
|
|
3548
3611
|
}
|
|
3549
3612
|
//#region methods & getters / is https server
|
|
3550
3613
|
get isHttpServer() {
|
|
3551
|
-
return this.
|
|
3614
|
+
return this.uriProtocol === 'https:';
|
|
3552
3615
|
}
|
|
3553
3616
|
//#endregion
|
|
3554
3617
|
//#region methods & getters / public assets
|
|
@@ -3750,7 +3813,7 @@ class EndpointContext {
|
|
|
3750
3813
|
return;
|
|
3751
3814
|
}
|
|
3752
3815
|
const allControllers = this.getClassFunByArr(Models.ClassType.CONTROLLER);
|
|
3753
|
-
// console.log('allControllers', allControllers)
|
|
3816
|
+
// console.log('allControllers', allControllers);
|
|
3754
3817
|
for (const controllerClassFn of allControllers) {
|
|
3755
3818
|
controllerClassFn[Symbols.classMethodsNames] =
|
|
3756
3819
|
ClassHelpers.getMethodsNames(controllerClassFn);
|
|
@@ -3770,15 +3833,17 @@ class EndpointContext {
|
|
|
3770
3833
|
classConfig.calculatedPath = classConfig.path;
|
|
3771
3834
|
}
|
|
3772
3835
|
else {
|
|
3773
|
-
classConfig.calculatedPath =
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3836
|
+
classConfig.calculatedPath = (`${this.uriPathnameOrNothingIfRoot}` +
|
|
3837
|
+
`/${apiPrefix}/${this.contextName}/tcp${parentscalculatedPath}/` +
|
|
3838
|
+
`${ClassHelpers.getName(controllerClassFn)}`)
|
|
3839
|
+
.replace(/\/\//g, '/')
|
|
3840
|
+
.split('/')
|
|
3841
|
+
.reduce((acc, bc) => {
|
|
3842
|
+
return _.last(acc) === bc ? acc : [...acc, bc];
|
|
3843
|
+
}, [])
|
|
3844
|
+
.join('/');
|
|
3781
3845
|
}
|
|
3846
|
+
// console.log('calculatedPath', classConfig.calculatedPath);
|
|
3782
3847
|
_.slice(configs, 1).forEach(bc => {
|
|
3783
3848
|
const alreadyIs = classConfig.methods;
|
|
3784
3849
|
const toMerge = _.cloneDeep(bc.methods);
|
|
@@ -3804,13 +3869,13 @@ class EndpointContext {
|
|
|
3804
3869
|
const expressPath = methodConfig.global
|
|
3805
3870
|
? `/${methodConfig.path?.replace(/\//, '')}`
|
|
3806
3871
|
: TaonHelpers.getExpressPath(classConfig, methodConfig);
|
|
3807
|
-
// console.log({ expressPath })
|
|
3872
|
+
// console.log({ expressPath });
|
|
3808
3873
|
if (Helpers.isNode || Helpers.isWebSQL) {
|
|
3809
3874
|
//#region @websql
|
|
3810
|
-
const
|
|
3875
|
+
const route = this.initServer(type, methodConfig, classConfig, expressPath, controllerClassFn);
|
|
3811
3876
|
this.activeRoutes.push({
|
|
3812
|
-
|
|
3813
|
-
method,
|
|
3877
|
+
expressPath: route.expressPath,
|
|
3878
|
+
method: route.method,
|
|
3814
3879
|
});
|
|
3815
3880
|
//#endregion
|
|
3816
3881
|
}
|
|
@@ -3842,21 +3907,21 @@ class EndpointContext {
|
|
|
3842
3907
|
this.skipWritingServerRoutes) {
|
|
3843
3908
|
return;
|
|
3844
3909
|
}
|
|
3845
|
-
const contexts = [this];
|
|
3910
|
+
// const contexts: EndpointContext[] = [this];
|
|
3846
3911
|
//#region @websql
|
|
3847
3912
|
const troutes = Utils.uniqArray(this.activeRoutes.map(f => {
|
|
3848
|
-
return `${f.method} ${f.
|
|
3913
|
+
return `${f.method} ${f.expressPath}`;
|
|
3849
3914
|
})).map(f => {
|
|
3850
|
-
const [method,
|
|
3851
|
-
return (`\n### ${_.startCase(_.last(
|
|
3915
|
+
const [method, expressPath] = f.split(' ');
|
|
3916
|
+
return (`\n### ${_.startCase(_.last(expressPath.split('/')))}\n` +
|
|
3852
3917
|
TaonHelpers.fillUpTo(method.toUpperCase() + ' ', 10) +
|
|
3853
|
-
this.
|
|
3854
|
-
|
|
3918
|
+
this.uriOrigin +
|
|
3919
|
+
expressPath);
|
|
3855
3920
|
// return `${TaonHelpers.string(method.toUpperCase() + ':')
|
|
3856
|
-
// .fillUpTo(10)}${context.
|
|
3921
|
+
// .fillUpTo(10)}${context.uriHref.replace(/\/$/, '')}${expressPath}`
|
|
3857
3922
|
});
|
|
3858
3923
|
const routes = [
|
|
3859
|
-
...['', `# ROUTES FOR HOST ${this.
|
|
3924
|
+
...['', `# ROUTES FOR HOST ${this.uriOrigin} `],
|
|
3860
3925
|
...troutes,
|
|
3861
3926
|
].join('\n');
|
|
3862
3927
|
const fileName = crossPlatformPath([
|
|
@@ -3999,7 +4064,7 @@ class EndpointContext {
|
|
|
3999
4064
|
next();
|
|
4000
4065
|
};
|
|
4001
4066
|
//#endregion
|
|
4002
|
-
const url = this.uri;
|
|
4067
|
+
// const url = this.uri;
|
|
4003
4068
|
//#region get result
|
|
4004
4069
|
const getResult = async (resolvedParams, req, res) => {
|
|
4005
4070
|
const response = methodConfig.descriptor.value.apply(
|
|
@@ -4015,12 +4080,7 @@ class EndpointContext {
|
|
|
4015
4080
|
return result;
|
|
4016
4081
|
};
|
|
4017
4082
|
//#endregion
|
|
4018
|
-
|
|
4019
|
-
expressPath = url.pathname.startsWith('/')
|
|
4020
|
-
? `${url.pathname}${expressPath}`
|
|
4021
|
-
: expressPath;
|
|
4022
|
-
expressPath = expressPath.replace(/\/\//g, '/');
|
|
4023
|
-
// console.log(`BACKEND: expressPath: ${ expressPath } `)
|
|
4083
|
+
// console.log(`BACKEND: expressPath: "${expressPath}" `);
|
|
4024
4084
|
//#endregion
|
|
4025
4085
|
if (Helpers.isElectron) {
|
|
4026
4086
|
/* */
|
|
@@ -4044,6 +4104,9 @@ class EndpointContext {
|
|
|
4044
4104
|
/* */
|
|
4045
4105
|
/* */
|
|
4046
4106
|
/* */
|
|
4107
|
+
/* */
|
|
4108
|
+
/* */
|
|
4109
|
+
/* */
|
|
4047
4110
|
}
|
|
4048
4111
|
if (!this.remoteHost) {
|
|
4049
4112
|
//#region apply dummy websql express routers
|
|
@@ -4271,7 +4334,7 @@ class EndpointContext {
|
|
|
4271
4334
|
/* */
|
|
4272
4335
|
}
|
|
4273
4336
|
return {
|
|
4274
|
-
|
|
4337
|
+
expressPath: expressPath,
|
|
4275
4338
|
method: methodConfig.type,
|
|
4276
4339
|
};
|
|
4277
4340
|
}
|
|
@@ -4309,7 +4372,7 @@ class EndpointContext {
|
|
|
4309
4372
|
body: void 0,
|
|
4310
4373
|
isArray: void 0,
|
|
4311
4374
|
method: methodConfig.type,
|
|
4312
|
-
url: `${ctx.
|
|
4375
|
+
url: `${ctx.uriOrigin}${'' // TODO express path
|
|
4313
4376
|
}${methodConfig.path} `,
|
|
4314
4377
|
}, Helpers.isBlob(body) || _.isString(body)
|
|
4315
4378
|
? body
|
|
@@ -4422,7 +4485,7 @@ class EndpointContext {
|
|
|
4422
4485
|
body: void 0,
|
|
4423
4486
|
isArray: void 0,
|
|
4424
4487
|
method: methodConfig.type,
|
|
4425
|
-
url: `${ctx.
|
|
4488
|
+
url: `${ctx.uriOrigin}${'' // TODO express path
|
|
4426
4489
|
}${methodConfig.path} `,
|
|
4427
4490
|
}, Helpers.isBlob(body) || _.isString(body)
|
|
4428
4491
|
? body
|
|
@@ -4462,37 +4525,37 @@ class EndpointContext {
|
|
|
4462
4525
|
//#region resolve frontend parameters
|
|
4463
4526
|
if (!storage[Symbols.old.ENDPOINT_META_CONFIG])
|
|
4464
4527
|
storage[Symbols.old.ENDPOINT_META_CONFIG] = {};
|
|
4465
|
-
if (!storage[Symbols.old.ENDPOINT_META_CONFIG][ctx.
|
|
4466
|
-
storage[Symbols.old.ENDPOINT_META_CONFIG][ctx.
|
|
4528
|
+
if (!storage[Symbols.old.ENDPOINT_META_CONFIG][ctx.uriOrigin])
|
|
4529
|
+
storage[Symbols.old.ENDPOINT_META_CONFIG][ctx.uriOrigin] = {};
|
|
4467
4530
|
const endpoints = storage[Symbols.old.ENDPOINT_META_CONFIG];
|
|
4468
4531
|
let rest;
|
|
4469
|
-
if (!endpoints[ctx.
|
|
4532
|
+
if (!endpoints[ctx.uriOrigin][expressPath]) {
|
|
4470
4533
|
let headers = {};
|
|
4471
4534
|
if (methodConfig.contentType && !methodConfig.responseType) {
|
|
4472
|
-
rest = Resource.create(ctx.
|
|
4535
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols.old.MAPPING_CONFIG_HEADER, Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
4473
4536
|
'Content-Type': methodConfig.contentType,
|
|
4474
4537
|
Accept: methodConfig.contentType,
|
|
4475
4538
|
}));
|
|
4476
4539
|
}
|
|
4477
4540
|
else if (methodConfig.contentType && methodConfig.responseType) {
|
|
4478
|
-
rest = Resource.create(ctx.
|
|
4541
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols.old.MAPPING_CONFIG_HEADER, Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
4479
4542
|
'Content-Type': methodConfig.contentType,
|
|
4480
4543
|
Accept: methodConfig.contentType,
|
|
4481
4544
|
responsetypeaxios: methodConfig.responseType,
|
|
4482
4545
|
}));
|
|
4483
4546
|
}
|
|
4484
4547
|
else if (!methodConfig.contentType && methodConfig.responseType) {
|
|
4485
|
-
rest = Resource.create(ctx.
|
|
4548
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols.old.MAPPING_CONFIG_HEADER, Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
4486
4549
|
responsetypeaxios: methodConfig.responseType,
|
|
4487
4550
|
}));
|
|
4488
4551
|
}
|
|
4489
4552
|
else {
|
|
4490
|
-
rest = Resource.create(ctx.
|
|
4553
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols.old.MAPPING_CONFIG_HEADER, Symbols.old.CIRCURAL_OBJECTS_MAP_BODY);
|
|
4491
4554
|
}
|
|
4492
|
-
endpoints[ctx.
|
|
4555
|
+
endpoints[ctx.uriOrigin][expressPath] = rest;
|
|
4493
4556
|
}
|
|
4494
4557
|
else {
|
|
4495
|
-
rest = endpoints[ctx.
|
|
4558
|
+
rest = endpoints[ctx.uriOrigin][expressPath];
|
|
4496
4559
|
}
|
|
4497
4560
|
const method = type.toLowerCase();
|
|
4498
4561
|
const isWithBody = method === 'put' || method === 'post';
|
|
@@ -6348,5 +6411,5 @@ var Taon;
|
|
|
6348
6411
|
* Generated bundle index. Do not edit.
|
|
6349
6412
|
*/
|
|
6350
6413
|
|
|
6351
|
-
export { BaseContext, BaseController, BaseCustomRepository, BaseEntity, BaseMigration, BaseProvider, BaseRepository, CURRENT_HOST_BACKEND_PORT, ClassHelpers, EndpointContext, Models, TAON_CONTEXT, Taon, TaonAdminService, TaonEntityKeysToOmitArr, createContext, inject };
|
|
6414
|
+
export { BaseContext, BaseController, BaseCustomRepository, BaseEntity, BaseMigration, BaseProvider, BaseRepository, CURRENT_HOST_BACKEND_PORT, ClassHelpers, EndpointContext, Models, TAON_CONTEXT, Taon, TaonAdminService, TaonEntityKeysToOmitArr, apiPrefix, createContext, inject };
|
|
6352
6415
|
//# sourceMappingURL=taon.mjs.map
|