taon 19.0.48 → 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/browser/fesm2022/taon.mjs +247 -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 +96 -50
- package/lib/endpoint-context.js.map +1 -1
- 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/ui/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
- package/package.json +1 -1
- package/websql/fesm2022/taon.mjs +274 -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
|
/* */
|
|
@@ -3291,6 +3305,10 @@ class EndpointContext {
|
|
|
3291
3305
|
/* */
|
|
3292
3306
|
/* */
|
|
3293
3307
|
/* */
|
|
3308
|
+
/* */
|
|
3309
|
+
/* */
|
|
3310
|
+
/* */
|
|
3311
|
+
/* */
|
|
3294
3312
|
return (void 0);
|
|
3295
3313
|
}
|
|
3296
3314
|
//#endregion
|
|
@@ -3610,16 +3628,53 @@ class EndpointContext {
|
|
|
3610
3628
|
return url;
|
|
3611
3629
|
}
|
|
3612
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
|
+
}
|
|
3613
3668
|
/**
|
|
3614
3669
|
* Port from uri as number
|
|
3615
3670
|
* @returns {Number | undefined}
|
|
3616
3671
|
*/
|
|
3617
3672
|
get port() {
|
|
3618
|
-
return this.uri?.port ? Number(this.
|
|
3673
|
+
return this.uri?.port ? Number(this.uriPort) : undefined;
|
|
3619
3674
|
}
|
|
3620
3675
|
//#region methods & getters / is https server
|
|
3621
3676
|
get isHttpServer() {
|
|
3622
|
-
return this.
|
|
3677
|
+
return this.uriProtocol === 'https:';
|
|
3623
3678
|
}
|
|
3624
3679
|
//#endregion
|
|
3625
3680
|
//#region methods & getters / public assets
|
|
@@ -3856,7 +3911,7 @@ class EndpointContext {
|
|
|
3856
3911
|
return;
|
|
3857
3912
|
}
|
|
3858
3913
|
const allControllers = this.getClassFunByArr(Models.ClassType.CONTROLLER);
|
|
3859
|
-
// console.log('allControllers', allControllers)
|
|
3914
|
+
// console.log('allControllers', allControllers);
|
|
3860
3915
|
for (const controllerClassFn of allControllers) {
|
|
3861
3916
|
controllerClassFn[Symbols.classMethodsNames] =
|
|
3862
3917
|
ClassHelpers.getMethodsNames(controllerClassFn);
|
|
@@ -3876,15 +3931,17 @@ class EndpointContext {
|
|
|
3876
3931
|
classConfig.calculatedPath = classConfig.path;
|
|
3877
3932
|
}
|
|
3878
3933
|
else {
|
|
3879
|
-
classConfig.calculatedPath =
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
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('/');
|
|
3887
3943
|
}
|
|
3944
|
+
// console.log('calculatedPath', classConfig.calculatedPath);
|
|
3888
3945
|
_.slice(configs, 1).forEach(bc => {
|
|
3889
3946
|
const alreadyIs = classConfig.methods;
|
|
3890
3947
|
const toMerge = _.cloneDeep(bc.methods);
|
|
@@ -3910,7 +3967,7 @@ class EndpointContext {
|
|
|
3910
3967
|
const expressPath = methodConfig.global
|
|
3911
3968
|
? `/${methodConfig.path?.replace(/\//, '')}`
|
|
3912
3969
|
: TaonHelpers.getExpressPath(classConfig, methodConfig);
|
|
3913
|
-
// console.log({ expressPath })
|
|
3970
|
+
// console.log({ expressPath });
|
|
3914
3971
|
if (Helpers.isNode || Helpers.isWebSQL) {
|
|
3915
3972
|
/* */
|
|
3916
3973
|
/* */
|
|
@@ -3955,7 +4012,7 @@ class EndpointContext {
|
|
|
3955
4012
|
this.skipWritingServerRoutes) {
|
|
3956
4013
|
return;
|
|
3957
4014
|
}
|
|
3958
|
-
const contexts = [this];
|
|
4015
|
+
// const contexts: EndpointContext[] = [this];
|
|
3959
4016
|
/* */
|
|
3960
4017
|
/* */
|
|
3961
4018
|
/* */
|
|
@@ -4120,7 +4177,7 @@ class EndpointContext {
|
|
|
4120
4177
|
/* */
|
|
4121
4178
|
/* */
|
|
4122
4179
|
/* */
|
|
4123
|
-
const url = this.uri;
|
|
4180
|
+
// const url = this.uri;
|
|
4124
4181
|
//#region get result
|
|
4125
4182
|
const getResult = async (resolvedParams, req, res) => {
|
|
4126
4183
|
const response = methodConfig.descriptor.value.apply(
|
|
@@ -4136,12 +4193,7 @@ class EndpointContext {
|
|
|
4136
4193
|
return result;
|
|
4137
4194
|
};
|
|
4138
4195
|
//#endregion
|
|
4139
|
-
|
|
4140
|
-
expressPath = url.pathname.startsWith('/')
|
|
4141
|
-
? `${url.pathname}${expressPath}`
|
|
4142
|
-
: expressPath;
|
|
4143
|
-
expressPath = expressPath.replace(/\/\//g, '/');
|
|
4144
|
-
// console.log(`BACKEND: expressPath: ${ expressPath } `)
|
|
4196
|
+
// console.log(`BACKEND: expressPath: "${expressPath}" `);
|
|
4145
4197
|
//#endregion
|
|
4146
4198
|
if (Helpers.isElectron) {
|
|
4147
4199
|
/* */
|
|
@@ -4165,6 +4217,9 @@ class EndpointContext {
|
|
|
4165
4217
|
/* */
|
|
4166
4218
|
/* */
|
|
4167
4219
|
/* */
|
|
4220
|
+
/* */
|
|
4221
|
+
/* */
|
|
4222
|
+
/* */
|
|
4168
4223
|
}
|
|
4169
4224
|
if (!this.remoteHost) {
|
|
4170
4225
|
//#region apply dummy websql express routers
|
|
@@ -4391,7 +4446,7 @@ class EndpointContext {
|
|
|
4391
4446
|
/* */
|
|
4392
4447
|
}
|
|
4393
4448
|
return {
|
|
4394
|
-
|
|
4449
|
+
expressPath: expressPath,
|
|
4395
4450
|
method: methodConfig.type,
|
|
4396
4451
|
};
|
|
4397
4452
|
}
|
|
@@ -4429,7 +4484,7 @@ class EndpointContext {
|
|
|
4429
4484
|
body: void 0,
|
|
4430
4485
|
isArray: void 0,
|
|
4431
4486
|
method: methodConfig.type,
|
|
4432
|
-
url: `${ctx.
|
|
4487
|
+
url: `${ctx.uriOrigin}${'' // TODO express path
|
|
4433
4488
|
}${methodConfig.path} `,
|
|
4434
4489
|
}, Helpers.isBlob(body) || _.isString(body)
|
|
4435
4490
|
? body
|
|
@@ -4606,37 +4661,37 @@ class EndpointContext {
|
|
|
4606
4661
|
//#region resolve frontend parameters
|
|
4607
4662
|
if (!storage[Symbols.old.ENDPOINT_META_CONFIG])
|
|
4608
4663
|
storage[Symbols.old.ENDPOINT_META_CONFIG] = {};
|
|
4609
|
-
if (!storage[Symbols.old.ENDPOINT_META_CONFIG][ctx.
|
|
4610
|
-
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] = {};
|
|
4611
4666
|
const endpoints = storage[Symbols.old.ENDPOINT_META_CONFIG];
|
|
4612
4667
|
let rest;
|
|
4613
|
-
if (!endpoints[ctx.
|
|
4668
|
+
if (!endpoints[ctx.uriOrigin][expressPath]) {
|
|
4614
4669
|
let headers = {};
|
|
4615
4670
|
if (methodConfig.contentType && !methodConfig.responseType) {
|
|
4616
|
-
rest = Resource.create(ctx.
|
|
4671
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols.old.MAPPING_CONFIG_HEADER, Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
4617
4672
|
'Content-Type': methodConfig.contentType,
|
|
4618
4673
|
Accept: methodConfig.contentType,
|
|
4619
4674
|
}));
|
|
4620
4675
|
}
|
|
4621
4676
|
else if (methodConfig.contentType && methodConfig.responseType) {
|
|
4622
|
-
rest = Resource.create(ctx.
|
|
4677
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols.old.MAPPING_CONFIG_HEADER, Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
4623
4678
|
'Content-Type': methodConfig.contentType,
|
|
4624
4679
|
Accept: methodConfig.contentType,
|
|
4625
4680
|
responsetypeaxios: methodConfig.responseType,
|
|
4626
4681
|
}));
|
|
4627
4682
|
}
|
|
4628
4683
|
else if (!methodConfig.contentType && methodConfig.responseType) {
|
|
4629
|
-
rest = Resource.create(ctx.
|
|
4684
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols.old.MAPPING_CONFIG_HEADER, Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
4630
4685
|
responsetypeaxios: methodConfig.responseType,
|
|
4631
4686
|
}));
|
|
4632
4687
|
}
|
|
4633
4688
|
else {
|
|
4634
|
-
rest = Resource.create(ctx.
|
|
4689
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols.old.MAPPING_CONFIG_HEADER, Symbols.old.CIRCURAL_OBJECTS_MAP_BODY);
|
|
4635
4690
|
}
|
|
4636
|
-
endpoints[ctx.
|
|
4691
|
+
endpoints[ctx.uriOrigin][expressPath] = rest;
|
|
4637
4692
|
}
|
|
4638
4693
|
else {
|
|
4639
|
-
rest = endpoints[ctx.
|
|
4694
|
+
rest = endpoints[ctx.uriOrigin][expressPath];
|
|
4640
4695
|
}
|
|
4641
4696
|
const method = type.toLowerCase();
|
|
4642
4697
|
const isWithBody = method === 'put' || method === 'post';
|
|
@@ -6570,5 +6625,5 @@ var Taon;
|
|
|
6570
6625
|
* Generated bundle index. Do not edit.
|
|
6571
6626
|
*/
|
|
6572
6627
|
|
|
6573
|
-
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 };
|
|
6574
6629
|
//# sourceMappingURL=taon.mjs.map
|