taon 19.0.48 → 19.0.50
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 +304 -198
- package/browser/fesm2022/taon.mjs.map +1 -1
- package/browser/lib/constants.d.ts +2 -1
- package/browser/lib/endpoint-context.d.ts +28 -1
- package/browser/lib/helpers/class-helpers.d.ts +0 -1
- package/browser/lib/models.d.ts +19 -0
- 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/base-classes/base-subscriber.d.ts +4 -0
- package/lib/base-classes/base-subscriber.js +25 -0
- package/lib/base-classes/base-subscriber.js.map +1 -0
- package/lib/build-info._auto-generated_.d.ts +17 -1
- package/lib/build-info._auto-generated_.js +18 -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/create-context.js +15 -0
- package/lib/create-context.js.map +1 -1
- package/lib/endpoint-context.d.ts +28 -1
- package/lib/endpoint-context.js +132 -56
- package/lib/endpoint-context.js.map +1 -1
- package/lib/env.js +5 -1
- package/lib/env.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/models.d.ts +19 -0
- package/lib/models.js +3 -0
- package/lib/models.js.map +1 -1
- package/lib/realtime/realtime-client.js +9 -0
- package/lib/realtime/realtime-client.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 +20 -23
- package/lib/realtime/realtime-server.js.map +1 -1
- package/lib/realtime/realtime-strategy/realtime-abstract-mock.d.ts +10 -0
- package/lib/realtime/realtime-strategy/realtime-abstract-mock.js +214 -0
- package/lib/realtime/realtime-strategy/realtime-abstract-mock.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.d.ts +0 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.js +5 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.d.ts +22 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.js +139 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.d.ts +16 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.js +68 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.d.ts +10 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.js +56 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.d.ts +10 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.js +50 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.d.ts +13 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.js +3 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.d.ts +2 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.js +6 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.d.ts +16 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.js +54 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.d.ts +17 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.js +52 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.d.ts +11 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.js +39 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.d.ts +13 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.js +46 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.d.ts +11 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.js +3 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.js.map +1 -0
- 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 -1
- package/lib/storage.js +5 -1
- package/lib/storage.js.map +1 -1
- package/lib/ui/directives/firedev-inject-html.directive.d.ts +6 -0
- package/lib/ui/directives/firedev-long-press.directive.d.ts +22 -0
- package/lib/ui/directives/index.d.ts +3 -0
- package/lib/ui/directives/index.js +5 -0
- package/lib/ui/directives/index.js.map +1 -0
- package/lib/ui/directives/safe.pipe.d.ts +7 -0
- package/lib/ui/directives/taon-inject-html.directive.d.ts +6 -0
- package/lib/ui/directives/taon-long-press.directive.d.ts +22 -0
- package/lib/ui/directives/view-mode.d.ts +5 -0
- package/lib/ui/directives/view-mode.js +10 -0
- package/lib/ui/directives/view-mode.js.map +1 -0
- package/lib/ui/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.d.ts +2 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.js +5 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.js.map +1 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/taon-admin-edit-mode.component.d.ts +29 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/taon-admin-edit-mode.module.d.ts +2 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.d.ts +1 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.js +5 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.js.map +1 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/taon-db-admin.component.d.ts +8 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.d.ts +2 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.js +5 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.js.map +1 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/taon-file-general-opt.component.d.ts +13 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/taon-file-general-opt.module.d.ts +2 -0
- package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.d.ts +5 -0
- package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.js +3 -0
- package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.js.map +1 -0
- package/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.d.ts +14 -0
- package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +43 -0
- package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.module.d.ts +2 -0
- package/lib/ui/taon-admin-mode-configuration/taon-admin.models.d.ts +5 -0
- package/lib/ui/taon-admin-mode-configuration/taon-admin.models.js +3 -0
- package/lib/ui/taon-admin-mode-configuration/taon-admin.models.js.map +1 -0
- package/lib/ui/taon-full-material.module.d.ts +5 -0
- package/lib/ui/taon-github-fork-me-corner/index.d.ts +2 -0
- package/lib/ui/taon-github-fork-me-corner/index.js +5 -0
- package/lib/ui/taon-github-fork-me-corner/index.js.map +1 -0
- package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.component.d.ts +3 -0
- package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.module.d.ts +2 -0
- package/lib/ui/taon-github-fork-me-ribbon/index.d.ts +2 -0
- package/lib/ui/taon-github-fork-me-ribbon/index.js +5 -0
- package/lib/ui/taon-github-fork-me-ribbon/index.js.map +1 -0
- package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.component.d.ts +3 -0
- package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.module.d.ts +2 -0
- package/lib/ui/taon-notifications/index.d.ts +4 -0
- package/lib/ui/taon-notifications/index.js +24 -0
- package/lib/ui/taon-notifications/index.js.map +1 -0
- package/lib/ui/taon-notifications/taon-notifications.component.d.ts +9 -0
- package/lib/ui/taon-notifications/taon-notifications.models.d.ts +6 -0
- package/lib/ui/taon-notifications/taon-notifications.models.js +5 -0
- package/lib/ui/taon-notifications/taon-notifications.models.js.map +1 -0
- package/lib/ui/taon-notifications/taon-notifications.module.d.ts +2 -0
- package/lib/ui/taon-notifications/taon-notifications.service.d.ts +11 -0
- package/lib/ui/taon-progress-bar/index.d.ts +2 -0
- package/lib/ui/taon-progress-bar/index.js +5 -0
- package/lib/ui/taon-progress-bar/index.js.map +1 -0
- package/lib/ui/taon-progress-bar/taon-progress-bar.component.d.ts +13 -0
- package/lib/ui/taon-progress-bar/taon-progress-bar.module.d.ts +2 -0
- package/lib/ui/taon-session-passcode/index.d.ts +1 -0
- package/lib/ui/taon-session-passcode/index.js +5 -0
- package/lib/ui/taon-session-passcode/index.js.map +1 -0
- package/lib/ui/taon-session-passcode/taon-session-passcode.component.d.ts +35 -0
- package/lib/ui/taon-table/index.d.ts +2 -0
- package/lib/ui/taon-table/index.js +5 -0
- package/lib/ui/taon-table/index.js.map +1 -0
- package/lib/ui/taon-table/taon-table.component.d.ts +34 -0
- package/lib/ui/taon-table/taon-table.module.d.ts +2 -0
- package/lib/ui/taon.models.d.ts +11 -0
- package/lib/ui/taon.models.js +3 -0
- package/lib/ui/taon.models.js.map +1 -0
- package/lib/ui/toan-full-material.module.d.ts +2 -0
- package/package.json +1 -1
- package/tmp-environment.json +43 -0
- package/websql/fesm2022/taon.mjs +335 -230
- package/websql/fesm2022/taon.mjs.map +1 -1
- package/websql/lib/constants.d.ts +2 -1
- package/websql/lib/endpoint-context.d.ts +28 -1
- package/websql/lib/helpers/class-helpers.d.ts +0 -1
- package/websql/lib/models.d.ts +19 -0
- 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
|
/* */
|
|
@@ -1510,6 +1511,15 @@ class RealtimeClient {
|
|
|
1510
1511
|
realtime: this.core.pathFor(Symbols.REALTIME.NAMESPACE(this.core.ctx.contextName)),
|
|
1511
1512
|
};
|
|
1512
1513
|
// console.log('[browser] nspPath', nspPath);
|
|
1514
|
+
if (this.core.ctx.config.frontendHost &&
|
|
1515
|
+
this.core.ctx.config.frontendHost !== '') {
|
|
1516
|
+
console.log(`[${this.core.ctx.contextName}] USING FRONTEND HOST ${this.core.ctx.config.frontendHost}`);
|
|
1517
|
+
nspPath.global = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.global.pathname}`);
|
|
1518
|
+
nspPath.realtime = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.realtime.pathname}`);
|
|
1519
|
+
}
|
|
1520
|
+
else {
|
|
1521
|
+
console.log(`[${this.core.ctx.contextName}] NOT USING FRONTEND HOST`);
|
|
1522
|
+
}
|
|
1513
1523
|
this.core.ctx.logRealtime &&
|
|
1514
1524
|
console.info('[CLIENT] NAMESPACE GLOBAL ', nspPath.global.href + ` host: ${this.core.ctx.host}`);
|
|
1515
1525
|
this.core.ctx.logRealtime &&
|
|
@@ -1659,6 +1669,7 @@ to use socket realtime connection;
|
|
|
1659
1669
|
}
|
|
1660
1670
|
|
|
1661
1671
|
//#region imports
|
|
1672
|
+
/* */
|
|
1662
1673
|
//#endregion
|
|
1663
1674
|
class RealtimeServer {
|
|
1664
1675
|
// private jobs = {};
|
|
@@ -1835,7 +1846,6 @@ class RealtimeServer {
|
|
|
1835
1846
|
/* */
|
|
1836
1847
|
/* */
|
|
1837
1848
|
/* */
|
|
1838
|
-
/* */
|
|
1839
1849
|
}
|
|
1840
1850
|
//#endregion
|
|
1841
1851
|
//#region methods & getters / trigger changes
|
|
@@ -2534,12 +2544,12 @@ class RealtimeStrategyMock extends RealtimeStrategy {
|
|
|
2534
2544
|
//#endregion
|
|
2535
2545
|
//#region server & io
|
|
2536
2546
|
ioServer(url, opt) {
|
|
2537
|
-
const server = MockServer.from(url || this.ctx.
|
|
2547
|
+
const server = MockServer.from(url || this.ctx.uriOrigin);
|
|
2538
2548
|
return server.of(opt?.path || '/');
|
|
2539
2549
|
}
|
|
2540
2550
|
get ioClient() {
|
|
2541
2551
|
const clientIo = (uri, opts) => {
|
|
2542
|
-
return new MockSocket(uri || this.ctx.
|
|
2552
|
+
return new MockSocket(uri || this.ctx.uriOrigin, opts);
|
|
2543
2553
|
};
|
|
2544
2554
|
return clientIo;
|
|
2545
2555
|
}
|
|
@@ -2609,6 +2619,7 @@ class RealtimeCore {
|
|
|
2609
2619
|
//#endregion
|
|
2610
2620
|
//#region methods & getters / resovle staraegy
|
|
2611
2621
|
resolveStrategy() {
|
|
2622
|
+
// console.log(`[taon] resolveStrategy for this.ctx.mode ${this.ctx.mode}`);
|
|
2612
2623
|
if (this.ctx.mode === 'backend-frontend(websql)' ||
|
|
2613
2624
|
this.ctx.mode === 'backend-frontend(websql-electron)') {
|
|
2614
2625
|
// debugger
|
|
@@ -2628,15 +2639,14 @@ class RealtimeCore {
|
|
|
2628
2639
|
//#endregion
|
|
2629
2640
|
//#region path for
|
|
2630
2641
|
pathFor(namespace) {
|
|
2631
|
-
const uri = this.ctx.uri;
|
|
2632
2642
|
let nsp = namespace ? namespace : '';
|
|
2633
2643
|
nsp = nsp === '/' ? '' : nsp;
|
|
2634
|
-
|
|
2635
|
-
let prefix = `taonContext`;
|
|
2644
|
+
let prefix = `${apiPrefix}/${this.ctx.contextName}/udp`;
|
|
2636
2645
|
if (Helpers.isElectron) {
|
|
2637
2646
|
prefix = ``;
|
|
2638
2647
|
}
|
|
2639
|
-
const href = `${
|
|
2648
|
+
const href = `${this.ctx.uriOrigin}${this.ctx.uriPathnameOrNothingIfRoot}` +
|
|
2649
|
+
`/${prefix}${prefix && nsp ? '-' + nsp : nsp}`;
|
|
2640
2650
|
// console.log(`HREF: ${href}, nsp: ${nsp}`)
|
|
2641
2651
|
return new URL(href);
|
|
2642
2652
|
}
|
|
@@ -2692,9 +2702,6 @@ class EndpointContext {
|
|
|
2692
2702
|
}
|
|
2693
2703
|
return this.config?.logs === true;
|
|
2694
2704
|
}
|
|
2695
|
-
//#endregion
|
|
2696
|
-
//#endregion
|
|
2697
|
-
//#region constructor
|
|
2698
2705
|
constructor(originalConfig, configFn) {
|
|
2699
2706
|
this.originalConfig = originalConfig;
|
|
2700
2707
|
this.configFn = configFn;
|
|
@@ -2768,6 +2775,13 @@ class EndpointContext {
|
|
|
2768
2775
|
//#region fields / entities triggers
|
|
2769
2776
|
this.entitiesTriggers = {};
|
|
2770
2777
|
//#endregion
|
|
2778
|
+
//#endregion
|
|
2779
|
+
//#region constructor
|
|
2780
|
+
/**
|
|
2781
|
+
* Inside docker there is not need for https secure server
|
|
2782
|
+
*/
|
|
2783
|
+
this.isRunningInsideDocker = false;
|
|
2784
|
+
//#endregion
|
|
2771
2785
|
//#region methods & getters / clone class
|
|
2772
2786
|
this.cloneClassWithNewMetadata = ({ BaseClass, className, config, ctx, classType, }) => {
|
|
2773
2787
|
// Return a new class that extends the base class
|
|
@@ -2863,6 +2877,7 @@ class EndpointContext {
|
|
|
2863
2877
|
}
|
|
2864
2878
|
return classes;
|
|
2865
2879
|
};
|
|
2880
|
+
this.isRunningInsideDocker = UtilsOs.isRunningInDocker();
|
|
2866
2881
|
}
|
|
2867
2882
|
//#endregion
|
|
2868
2883
|
//#region methods & getters / init
|
|
@@ -2920,6 +2935,10 @@ class EndpointContext {
|
|
|
2920
2935
|
}
|
|
2921
2936
|
this.mode = 'remote-backend(tcp+udp)';
|
|
2922
2937
|
}
|
|
2938
|
+
// console.log(`
|
|
2939
|
+
// useIpcWhenElectron: ${this.config.useIpcWhenElectron}
|
|
2940
|
+
// Helpers.isElectron: ${Helpers.isElectron}
|
|
2941
|
+
// `)
|
|
2923
2942
|
if (this.config.useIpcWhenElectron && Helpers.isElectron) {
|
|
2924
2943
|
if (Helpers.isWebSQL) {
|
|
2925
2944
|
this.mode = 'backend-frontend(websql-electron)';
|
|
@@ -2928,6 +2947,11 @@ class EndpointContext {
|
|
|
2928
2947
|
this.mode = 'backend-frontend(ipc-electron)';
|
|
2929
2948
|
}
|
|
2930
2949
|
}
|
|
2950
|
+
// mode === undefined for BaseContext => ok behavior
|
|
2951
|
+
// console.log(`Mode for BE/FE communication: ${this.mode}`);
|
|
2952
|
+
// if(!this.mode) {
|
|
2953
|
+
// console.log(this.config)
|
|
2954
|
+
// }
|
|
2931
2955
|
if (!this.mode && !this.config.abstract) {
|
|
2932
2956
|
Helpers.error(`[taon] Context "${this.contextName}": You need to provide host or remoteHost or useIpcWhenElectron`, false, true);
|
|
2933
2957
|
/* */
|
|
@@ -3075,6 +3099,14 @@ class EndpointContext {
|
|
|
3075
3099
|
/* */
|
|
3076
3100
|
/* */
|
|
3077
3101
|
/* */
|
|
3102
|
+
/* */
|
|
3103
|
+
/* */
|
|
3104
|
+
/* */
|
|
3105
|
+
/* */
|
|
3106
|
+
/* */
|
|
3107
|
+
/* */
|
|
3108
|
+
/* */
|
|
3109
|
+
/* */
|
|
3078
3110
|
}
|
|
3079
3111
|
//#endregion
|
|
3080
3112
|
//#region prepare realtime
|
|
@@ -3118,7 +3150,7 @@ class EndpointContext {
|
|
|
3118
3150
|
console.log(`
|
|
3119
3151
|
|
|
3120
3152
|
|
|
3121
|
-
IS RUNNING IN DOCKER: ${
|
|
3153
|
+
IS RUNNING IN DOCKER: ${this.isRunningInsideDocker}
|
|
3122
3154
|
|
|
3123
3155
|
`);
|
|
3124
3156
|
/* */
|
|
@@ -3291,6 +3323,10 @@ class EndpointContext {
|
|
|
3291
3323
|
/* */
|
|
3292
3324
|
/* */
|
|
3293
3325
|
/* */
|
|
3326
|
+
/* */
|
|
3327
|
+
/* */
|
|
3328
|
+
/* */
|
|
3329
|
+
/* */
|
|
3294
3330
|
return (void 0);
|
|
3295
3331
|
}
|
|
3296
3332
|
//#endregion
|
|
@@ -3601,6 +3637,13 @@ class EndpointContext {
|
|
|
3601
3637
|
}
|
|
3602
3638
|
//#endregion
|
|
3603
3639
|
//#region methods & getters / uri
|
|
3640
|
+
get frontendHostUri() {
|
|
3641
|
+
const url = this.config?.frontendHost?.startsWith('http')
|
|
3642
|
+
? this.config.frontendHost
|
|
3643
|
+
: `${globalThis?.location?.protocol || 'http:'}//${this.config?.frontendHost}`;
|
|
3644
|
+
const uri = new URL(url.replace(/\/$/, ''));
|
|
3645
|
+
return uri;
|
|
3646
|
+
}
|
|
3604
3647
|
get uri() {
|
|
3605
3648
|
const url = this.host
|
|
3606
3649
|
? new URL(this.host)
|
|
@@ -3610,16 +3653,56 @@ class EndpointContext {
|
|
|
3610
3653
|
return url;
|
|
3611
3654
|
}
|
|
3612
3655
|
//#endregion
|
|
3656
|
+
get uriPort() {
|
|
3657
|
+
if (!this.uri?.origin?.includes('localhost')) {
|
|
3658
|
+
return this.config?.hostPortNumber?.toString();
|
|
3659
|
+
}
|
|
3660
|
+
return this.uri?.port;
|
|
3661
|
+
}
|
|
3662
|
+
get uriProtocol() {
|
|
3663
|
+
return this.uri?.protocol;
|
|
3664
|
+
}
|
|
3665
|
+
/**
|
|
3666
|
+
* Examples
|
|
3667
|
+
* http://localhost:3000
|
|
3668
|
+
* https://localhost (from localhost:80) *
|
|
3669
|
+
*/
|
|
3670
|
+
get uriOrigin() {
|
|
3671
|
+
return this.uri?.origin;
|
|
3672
|
+
}
|
|
3673
|
+
/**
|
|
3674
|
+
* Exampels
|
|
3675
|
+
* http://localhost:3000/path/to/somewhere
|
|
3676
|
+
* https://localhost/path/to/somewhere (from localhost:80)
|
|
3677
|
+
*/
|
|
3678
|
+
// get uriOriginWithPathname(): string | undefined {
|
|
3679
|
+
// return this.uri?.origin
|
|
3680
|
+
// ? this.uri?.origin + this.uriPathnameOrNothingIfRoot.replace(/\/$/, '')
|
|
3681
|
+
// : undefined;
|
|
3682
|
+
// }
|
|
3683
|
+
get uriPathname() {
|
|
3684
|
+
return this.uri?.pathname;
|
|
3685
|
+
}
|
|
3686
|
+
/**
|
|
3687
|
+
* Examples
|
|
3688
|
+
* http://localhost:3000/path/to/somewhere -> '/path/to/somewhere'
|
|
3689
|
+
* http://localhost:3000 -> '' #
|
|
3690
|
+
* https://localhost/path/to/ -> '/path/to/somewhere' # remove last slash
|
|
3691
|
+
*/
|
|
3692
|
+
get uriPathnameOrNothingIfRoot() {
|
|
3693
|
+
const isNonRootProperPathName = this.uri?.pathname && this.uri.pathname !== '/';
|
|
3694
|
+
return isNonRootProperPathName ? this.uri.pathname.replace(/\/$/, '') : '';
|
|
3695
|
+
}
|
|
3613
3696
|
/**
|
|
3614
3697
|
* Port from uri as number
|
|
3615
3698
|
* @returns {Number | undefined}
|
|
3616
3699
|
*/
|
|
3617
3700
|
get port() {
|
|
3618
|
-
return this.uri?.port ? Number(this.
|
|
3701
|
+
return this.uri?.port ? Number(this.uriPort) : undefined;
|
|
3619
3702
|
}
|
|
3620
3703
|
//#region methods & getters / is https server
|
|
3621
3704
|
get isHttpServer() {
|
|
3622
|
-
return this.
|
|
3705
|
+
return this.uriProtocol === 'https:';
|
|
3623
3706
|
}
|
|
3624
3707
|
//#endregion
|
|
3625
3708
|
//#region methods & getters / public assets
|
|
@@ -3630,6 +3713,9 @@ class EndpointContext {
|
|
|
3630
3713
|
return this.config.contextName;
|
|
3631
3714
|
}
|
|
3632
3715
|
//#endregion
|
|
3716
|
+
get activeContext() {
|
|
3717
|
+
return this.config.activeContext || null;
|
|
3718
|
+
}
|
|
3633
3719
|
get appId() {
|
|
3634
3720
|
return this.config.appId;
|
|
3635
3721
|
}
|
|
@@ -3856,7 +3942,7 @@ class EndpointContext {
|
|
|
3856
3942
|
return;
|
|
3857
3943
|
}
|
|
3858
3944
|
const allControllers = this.getClassFunByArr(Models.ClassType.CONTROLLER);
|
|
3859
|
-
// console.log('allControllers', allControllers)
|
|
3945
|
+
// console.log('allControllers', allControllers);
|
|
3860
3946
|
for (const controllerClassFn of allControllers) {
|
|
3861
3947
|
controllerClassFn[Symbols.classMethodsNames] =
|
|
3862
3948
|
ClassHelpers.getMethodsNames(controllerClassFn);
|
|
@@ -3876,15 +3962,17 @@ class EndpointContext {
|
|
|
3876
3962
|
classConfig.calculatedPath = classConfig.path;
|
|
3877
3963
|
}
|
|
3878
3964
|
else {
|
|
3879
|
-
classConfig.calculatedPath =
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3965
|
+
classConfig.calculatedPath = (`${this.uriPathnameOrNothingIfRoot}` +
|
|
3966
|
+
`/${apiPrefix}/${this.contextName}/tcp${parentscalculatedPath}/` +
|
|
3967
|
+
`${ClassHelpers.getName(controllerClassFn)}`)
|
|
3968
|
+
.replace(/\/\//g, '/')
|
|
3969
|
+
.split('/')
|
|
3970
|
+
.reduce((acc, bc) => {
|
|
3971
|
+
return _.last(acc) === bc ? acc : [...acc, bc];
|
|
3972
|
+
}, [])
|
|
3973
|
+
.join('/');
|
|
3887
3974
|
}
|
|
3975
|
+
// console.log('calculatedPath', classConfig.calculatedPath);
|
|
3888
3976
|
_.slice(configs, 1).forEach(bc => {
|
|
3889
3977
|
const alreadyIs = classConfig.methods;
|
|
3890
3978
|
const toMerge = _.cloneDeep(bc.methods);
|
|
@@ -3907,10 +3995,15 @@ class EndpointContext {
|
|
|
3907
3995
|
const methodConfig = classConfig.methods[methodName];
|
|
3908
3996
|
// debugger
|
|
3909
3997
|
const type = methodConfig.type;
|
|
3998
|
+
// this is quick fix - in docker global path should not be used
|
|
3999
|
+
const globalPathPart = this.isRunningInsideDocker ||
|
|
4000
|
+
!this.frontendHostUri?.origin?.includes('localhost') // fe with domain -> is in docker
|
|
4001
|
+
? `${this.uriPathnameOrNothingIfRoot.replace(/\/$/, '')}/${apiPrefix}/${this.contextName}`.replace(/\/\//, '/')
|
|
4002
|
+
: '';
|
|
3910
4003
|
const expressPath = methodConfig.global
|
|
3911
|
-
?
|
|
4004
|
+
? `${globalPathPart}/${methodConfig.path?.replace(/\/$/, '')}`.replace(/\/\//, '/')
|
|
3912
4005
|
: TaonHelpers.getExpressPath(classConfig, methodConfig);
|
|
3913
|
-
// console.log({ expressPath })
|
|
4006
|
+
// console.log({ expressPath });
|
|
3914
4007
|
if (Helpers.isNode || Helpers.isWebSQL) {
|
|
3915
4008
|
/* */
|
|
3916
4009
|
/* */
|
|
@@ -3955,7 +4048,7 @@ class EndpointContext {
|
|
|
3955
4048
|
this.skipWritingServerRoutes) {
|
|
3956
4049
|
return;
|
|
3957
4050
|
}
|
|
3958
|
-
const contexts = [this];
|
|
4051
|
+
// const contexts: EndpointContext[] = [this];
|
|
3959
4052
|
/* */
|
|
3960
4053
|
/* */
|
|
3961
4054
|
/* */
|
|
@@ -4120,7 +4213,7 @@ class EndpointContext {
|
|
|
4120
4213
|
/* */
|
|
4121
4214
|
/* */
|
|
4122
4215
|
/* */
|
|
4123
|
-
const url = this.uri;
|
|
4216
|
+
// const url = this.uri;
|
|
4124
4217
|
//#region get result
|
|
4125
4218
|
const getResult = async (resolvedParams, req, res) => {
|
|
4126
4219
|
const response = methodConfig.descriptor.value.apply(
|
|
@@ -4136,12 +4229,7 @@ class EndpointContext {
|
|
|
4136
4229
|
return result;
|
|
4137
4230
|
};
|
|
4138
4231
|
//#endregion
|
|
4139
|
-
|
|
4140
|
-
expressPath = url.pathname.startsWith('/')
|
|
4141
|
-
? `${url.pathname}${expressPath}`
|
|
4142
|
-
: expressPath;
|
|
4143
|
-
expressPath = expressPath.replace(/\/\//g, '/');
|
|
4144
|
-
// console.log(`BACKEND: expressPath: ${ expressPath } `)
|
|
4232
|
+
// console.log(`BACKEND: expressPath: "${expressPath}" `);
|
|
4145
4233
|
//#endregion
|
|
4146
4234
|
if (Helpers.isElectron) {
|
|
4147
4235
|
/* */
|
|
@@ -4165,6 +4253,9 @@ class EndpointContext {
|
|
|
4165
4253
|
/* */
|
|
4166
4254
|
/* */
|
|
4167
4255
|
/* */
|
|
4256
|
+
/* */
|
|
4257
|
+
/* */
|
|
4258
|
+
/* */
|
|
4168
4259
|
}
|
|
4169
4260
|
if (!this.remoteHost) {
|
|
4170
4261
|
//#region apply dummy websql express routers
|
|
@@ -4391,7 +4482,7 @@ class EndpointContext {
|
|
|
4391
4482
|
/* */
|
|
4392
4483
|
}
|
|
4393
4484
|
return {
|
|
4394
|
-
|
|
4485
|
+
expressPath: expressPath,
|
|
4395
4486
|
method: methodConfig.type,
|
|
4396
4487
|
};
|
|
4397
4488
|
}
|
|
@@ -4429,7 +4520,7 @@ class EndpointContext {
|
|
|
4429
4520
|
body: void 0,
|
|
4430
4521
|
isArray: void 0,
|
|
4431
4522
|
method: methodConfig.type,
|
|
4432
|
-
url: `${ctx.
|
|
4523
|
+
url: `${ctx.uriOrigin}${'' // TODO express path
|
|
4433
4524
|
}${methodConfig.path} `,
|
|
4434
4525
|
}, Helpers.isBlob(body) || _.isString(body)
|
|
4435
4526
|
? body
|
|
@@ -4606,37 +4697,37 @@ class EndpointContext {
|
|
|
4606
4697
|
//#region resolve frontend parameters
|
|
4607
4698
|
if (!storage[Symbols.old.ENDPOINT_META_CONFIG])
|
|
4608
4699
|
storage[Symbols.old.ENDPOINT_META_CONFIG] = {};
|
|
4609
|
-
if (!storage[Symbols.old.ENDPOINT_META_CONFIG][ctx.
|
|
4610
|
-
storage[Symbols.old.ENDPOINT_META_CONFIG][ctx.
|
|
4700
|
+
if (!storage[Symbols.old.ENDPOINT_META_CONFIG][ctx.uriOrigin])
|
|
4701
|
+
storage[Symbols.old.ENDPOINT_META_CONFIG][ctx.uriOrigin] = {};
|
|
4611
4702
|
const endpoints = storage[Symbols.old.ENDPOINT_META_CONFIG];
|
|
4612
4703
|
let rest;
|
|
4613
|
-
if (!endpoints[ctx.
|
|
4704
|
+
if (!endpoints[ctx.uriOrigin][expressPath]) {
|
|
4614
4705
|
let headers = {};
|
|
4615
4706
|
if (methodConfig.contentType && !methodConfig.responseType) {
|
|
4616
|
-
rest = Resource.create(ctx.
|
|
4707
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols.old.MAPPING_CONFIG_HEADER, Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
4617
4708
|
'Content-Type': methodConfig.contentType,
|
|
4618
4709
|
Accept: methodConfig.contentType,
|
|
4619
4710
|
}));
|
|
4620
4711
|
}
|
|
4621
4712
|
else if (methodConfig.contentType && methodConfig.responseType) {
|
|
4622
|
-
rest = Resource.create(ctx.
|
|
4713
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols.old.MAPPING_CONFIG_HEADER, Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
4623
4714
|
'Content-Type': methodConfig.contentType,
|
|
4624
4715
|
Accept: methodConfig.contentType,
|
|
4625
4716
|
responsetypeaxios: methodConfig.responseType,
|
|
4626
4717
|
}));
|
|
4627
4718
|
}
|
|
4628
4719
|
else if (!methodConfig.contentType && methodConfig.responseType) {
|
|
4629
|
-
rest = Resource.create(ctx.
|
|
4720
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols.old.MAPPING_CONFIG_HEADER, Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
4630
4721
|
responsetypeaxios: methodConfig.responseType,
|
|
4631
4722
|
}));
|
|
4632
4723
|
}
|
|
4633
4724
|
else {
|
|
4634
|
-
rest = Resource.create(ctx.
|
|
4725
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols.old.MAPPING_CONFIG_HEADER, Symbols.old.CIRCURAL_OBJECTS_MAP_BODY);
|
|
4635
4726
|
}
|
|
4636
|
-
endpoints[ctx.
|
|
4727
|
+
endpoints[ctx.uriOrigin][expressPath] = rest;
|
|
4637
4728
|
}
|
|
4638
4729
|
else {
|
|
4639
|
-
rest = endpoints[ctx.
|
|
4730
|
+
rest = endpoints[ctx.uriOrigin][expressPath];
|
|
4640
4731
|
}
|
|
4641
4732
|
const method = type.toLowerCase();
|
|
4642
4733
|
const isWithBody = method === 'put' || method === 'post';
|
|
@@ -4811,6 +4902,11 @@ const createContextTemplate = (configFn) => {
|
|
|
4811
4902
|
*/
|
|
4812
4903
|
const createContext = (configFn) => {
|
|
4813
4904
|
let config = configFn({});
|
|
4905
|
+
// console.log(
|
|
4906
|
+
// `
|
|
4907
|
+
// [Taon] Creating context ${config.contextName}...`,
|
|
4908
|
+
// {config},
|
|
4909
|
+
// );
|
|
4814
4910
|
const endpointContextRef = new EndpointContext(config, configFn);
|
|
4815
4911
|
const res = {
|
|
4816
4912
|
//#region types
|
|
@@ -4911,6 +5007,16 @@ const createContext = (configFn) => {
|
|
|
4911
5007
|
return await new Promise(async (resolve, reject) => {
|
|
4912
5008
|
//#region init in set timeout
|
|
4913
5009
|
setTimeout(async () => {
|
|
5010
|
+
if (UtilsOs.isRunningInDocker()) {
|
|
5011
|
+
const activeContext = config?.activeContext || null;
|
|
5012
|
+
if (_.isString(activeContext) &&
|
|
5013
|
+
activeContext !== '' &&
|
|
5014
|
+
activeContext !== config?.contextName) {
|
|
5015
|
+
console.warn(`[taon] Context ${endpointContextRef.contextName} is not active context, skipping initialization.`);
|
|
5016
|
+
resolve(endpointContextRef);
|
|
5017
|
+
return;
|
|
5018
|
+
}
|
|
5019
|
+
}
|
|
4914
5020
|
await endpointContextRef.init({
|
|
4915
5021
|
...overrideOptions,
|
|
4916
5022
|
});
|
|
@@ -6570,5 +6676,5 @@ var Taon;
|
|
|
6570
6676
|
* Generated bundle index. Do not edit.
|
|
6571
6677
|
*/
|
|
6572
6678
|
|
|
6573
|
-
export { BaseContext, BaseController, BaseCustomRepository, BaseEntity, BaseMigration, BaseProvider, BaseRepository, CURRENT_HOST_BACKEND_PORT, ClassHelpers, EndpointContext, Models, TAON_CONTEXT, Taon, TaonAdminService, TaonEntityKeysToOmitArr, createContext, inject };
|
|
6679
|
+
export { BaseContext, BaseController, BaseCustomRepository, BaseEntity, BaseMigration, BaseProvider, BaseRepository, CURRENT_HOST_BACKEND_PORT, ClassHelpers, EndpointContext, Models, TAON_CONTEXT, Taon, TaonAdminService, TaonEntityKeysToOmitArr, apiPrefix, createContext, inject };
|
|
6574
6680
|
//# sourceMappingURL=taon.mjs.map
|