taon 19.0.62 → 19.0.64
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 +181 -78
- package/browser/fesm2022/taon.mjs.map +1 -1
- package/browser/lib/base-classes/base-context.d.ts +6 -0
- package/browser/lib/base-classes/base-controller.d.ts +3 -3
- package/browser/lib/base-classes/base.d.ts +6 -0
- package/browser/lib/create-context.d.ts +12 -4
- package/browser/lib/endpoint-context-storage.d.ts +12 -0
- package/browser/lib/endpoint-context.d.ts +28 -8
- package/browser/lib/index.d.ts +19 -0
- package/browser/lib/models.d.ts +7 -8
- package/browser/package.json +1 -1
- package/lib/base-classes/base-context.d.ts +6 -0
- package/lib/base-classes/base-controller.d.ts +3 -3
- package/lib/base-classes/base-controller.js +2 -2
- package/lib/base-classes/base-controller.js.map +1 -1
- package/lib/base-classes/base.d.ts +6 -0
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/context-db-migrations.js +5 -5
- package/lib/context-db-migrations.js.map +1 -1
- package/lib/create-context.d.ts +12 -4
- package/lib/create-context.js +35 -5
- package/lib/create-context.js.map +1 -1
- package/lib/decorators/classes/controller-config.d.ts +11 -0
- package/lib/decorators/classes/controller-config.js +10 -0
- package/lib/decorators/classes/controller-config.js.map +1 -1
- package/lib/decorators/classes/controller-options.d.ts +5 -0
- package/lib/decorators/classes/controller-options.js +4 -0
- package/lib/decorators/classes/controller-options.js.map +1 -1
- package/lib/endpoint-context-storage.d.ts +11 -0
- package/lib/endpoint-context-storage.js +38 -0
- package/lib/endpoint-context-storage.js.map +1 -0
- package/lib/endpoint-context.d.ts +28 -8
- package/lib/endpoint-context.js +96 -55
- package/lib/endpoint-context.js.map +1 -1
- package/lib/index.d.ts +19 -0
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/models.d.ts +7 -8
- package/lib/models.js.map +1 -1
- package/lib/realtime/realtime-client.js +12 -11
- package/lib/realtime/realtime-client.js.map +1 -1
- package/lib/realtime/realtime-core.js +6 -3
- package/lib/realtime/realtime-core.js.map +1 -1
- package/lib/realtime/realtime-server.js +6 -5
- package/lib/realtime/realtime-server.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 +188 -85
- package/websql/fesm2022/taon.mjs.map +1 -1
- package/websql/lib/base-classes/base-context.d.ts +6 -0
- package/websql/lib/base-classes/base-controller.d.ts +3 -3
- package/websql/lib/base-classes/base.d.ts +6 -0
- package/websql/lib/create-context.d.ts +12 -4
- package/websql/lib/endpoint-context-storage.d.ts +12 -0
- package/websql/lib/endpoint-context.d.ts +28 -8
- package/websql/lib/index.d.ts +19 -0
- package/websql/lib/models.d.ts +7 -8
- package/websql/package.json +1 -1
- package/lib/env.d.ts +0 -2
- package/lib/env.js +0 -7
- package/lib/env.js.map +0 -1
- package/lib/storage.d.ts +0 -1
- package/lib/storage.js +0 -6
- package/lib/storage.js.map +0 -1
- package/lib/ui/directives/index.d.ts +0 -3
- package/lib/ui/directives/index.js +0 -5
- package/lib/ui/directives/index.js.map +0 -1
- package/lib/ui/directives/safe.pipe.d.ts +0 -7
- package/lib/ui/directives/taon-inject-html.directive.d.ts +0 -6
- package/lib/ui/directives/taon-long-press.directive.d.ts +0 -22
- package/lib/ui/directives/view-mode.d.ts +0 -5
- package/lib/ui/directives/view-mode.js +0 -10
- package/lib/ui/directives/view-mode.js.map +0 -1
- package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +0 -43
- package/lib/ui/taon-admin-mode-configuration/taon-admin.models.d.ts +0 -5
- package/lib/ui/taon-admin-mode-configuration/taon-admin.models.js +0 -3
- package/lib/ui/taon-admin-mode-configuration/taon-admin.models.js.map +0 -1
- package/lib/ui/taon-full-material.module.d.ts +0 -5
- package/lib/ui/taon-github-fork-me-corner/index.d.ts +0 -2
- package/lib/ui/taon-github-fork-me-corner/index.js +0 -5
- package/lib/ui/taon-github-fork-me-corner/index.js.map +0 -1
- package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.component.d.ts +0 -3
- package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.module.d.ts +0 -2
- package/lib/ui/taon-github-fork-me-ribbon/index.d.ts +0 -2
- package/lib/ui/taon-github-fork-me-ribbon/index.js +0 -5
- package/lib/ui/taon-github-fork-me-ribbon/index.js.map +0 -1
- package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.component.d.ts +0 -3
- package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.module.d.ts +0 -2
- package/lib/ui/taon-notifications/index.d.ts +0 -4
- package/lib/ui/taon-notifications/index.js +0 -24
- package/lib/ui/taon-notifications/index.js.map +0 -1
- package/lib/ui/taon-notifications/taon-notifications.component.d.ts +0 -9
- package/lib/ui/taon-notifications/taon-notifications.models.d.ts +0 -6
- package/lib/ui/taon-notifications/taon-notifications.models.js +0 -5
- package/lib/ui/taon-notifications/taon-notifications.models.js.map +0 -1
- package/lib/ui/taon-notifications/taon-notifications.module.d.ts +0 -2
- package/lib/ui/taon-notifications/taon-notifications.service.d.ts +0 -11
- package/lib/ui/taon-progress-bar/index.d.ts +0 -2
- package/lib/ui/taon-progress-bar/index.js +0 -5
- package/lib/ui/taon-progress-bar/index.js.map +0 -1
- package/lib/ui/taon-progress-bar/taon-progress-bar.component.d.ts +0 -13
- package/lib/ui/taon-progress-bar/taon-progress-bar.module.d.ts +0 -2
- package/lib/ui/taon-session-passcode/index.d.ts +0 -1
- package/lib/ui/taon-session-passcode/index.js +0 -5
- package/lib/ui/taon-session-passcode/index.js.map +0 -1
- package/lib/ui/taon-session-passcode/taon-session-passcode.component.d.ts +0 -35
- package/lib/ui/taon-table/index.d.ts +0 -2
- package/lib/ui/taon-table/index.js +0 -5
- package/lib/ui/taon-table/index.js.map +0 -1
- package/lib/ui/taon-table/taon-table.component.d.ts +0 -34
- package/lib/ui/taon-table/taon-table.module.d.ts +0 -2
- package/lib/ui/taon.models.d.ts +0 -11
- package/lib/ui/taon.models.js +0 -3
- package/lib/ui/taon.models.js.map +0 -1
- package/tmp-environment.json +0 -39
package/websql/fesm2022/taon.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import * as coreHelpers from 'tnp-core/websql';
|
|
3
|
-
import { _, Utils, UtilsMigrations, Helpers, UtilsOs, crossPlatformPath } from 'tnp-core/websql';
|
|
3
|
+
import { _, Utils, UtilsMigrations, Helpers, UtilsOs, crossPlatformPath, CoreModels } from 'tnp-core/websql';
|
|
4
4
|
import { __decorate, __metadata, __param } from 'tslib';
|
|
5
5
|
import * as tsorm from 'taon-typeorm/websql';
|
|
6
6
|
import { OrignalClassKey, Entity, Table, TableIndex, EventSubscriber, DataSource } from 'taon-typeorm/websql';
|
|
@@ -977,7 +977,7 @@ class ContextDbMigrations {
|
|
|
977
977
|
//#region methods & getters / make sure migration table exists
|
|
978
978
|
async ensureMigrationTableExists() {
|
|
979
979
|
//#region @websqlFunc
|
|
980
|
-
if (this.ctx.
|
|
980
|
+
if (this.ctx.isRemoteHost || !this.ctx.connection) {
|
|
981
981
|
return;
|
|
982
982
|
}
|
|
983
983
|
const queryRunner = this.ctx.connection.createQueryRunner();
|
|
@@ -1017,7 +1017,7 @@ class ContextDbMigrations {
|
|
|
1017
1017
|
}
|
|
1018
1018
|
async revertMigrationToTimestamp(timestamp) {
|
|
1019
1019
|
//#region @websqlFunc
|
|
1020
|
-
if (this.ctx.
|
|
1020
|
+
if (this.ctx.isRemoteHost || !this.ctx.connection) {
|
|
1021
1021
|
return;
|
|
1022
1022
|
}
|
|
1023
1023
|
if (!UtilsMigrations.isValidTimestamp(timestamp)) {
|
|
@@ -1085,7 +1085,7 @@ class ContextDbMigrations {
|
|
|
1085
1085
|
//#region methods & getters / clear migration table
|
|
1086
1086
|
async clearMigrationTable() {
|
|
1087
1087
|
//#region @websqlFunc
|
|
1088
|
-
if (this.ctx.
|
|
1088
|
+
if (this.ctx.isRemoteHost || !this.ctx.connection) {
|
|
1089
1089
|
return;
|
|
1090
1090
|
}
|
|
1091
1091
|
const queryRunner = this.ctx.connection.createQueryRunner();
|
|
@@ -1109,7 +1109,7 @@ class ContextDbMigrations {
|
|
|
1109
1109
|
//#region methods & getters / mark all migrations as applied
|
|
1110
1110
|
async markAllMigrationsAsApplied() {
|
|
1111
1111
|
//#region @websqlFunc
|
|
1112
|
-
if (this.ctx.
|
|
1112
|
+
if (this.ctx.isRemoteHost || !this.ctx.connection) {
|
|
1113
1113
|
return;
|
|
1114
1114
|
}
|
|
1115
1115
|
const migrationsClassFns = this.ctx.getClassFunByArr(Models.ClassType.MIGRATION);
|
|
@@ -1163,7 +1163,7 @@ class ContextDbMigrations {
|
|
|
1163
1163
|
//#region methods & getters / run all migrations
|
|
1164
1164
|
async runAllNotCompletedMigrations() {
|
|
1165
1165
|
//#region @websqlFunc
|
|
1166
|
-
if (this.ctx.
|
|
1166
|
+
if (this.ctx.isRemoteHost || !this.ctx.connection) {
|
|
1167
1167
|
return;
|
|
1168
1168
|
}
|
|
1169
1169
|
const migrationsClassFns = this.ctx.getClassFunByArr(Models.ClassType.MIGRATION);
|
|
@@ -1554,6 +1554,10 @@ class RealtimeClient {
|
|
|
1554
1554
|
this.subsManagers = {};
|
|
1555
1555
|
this.core = core;
|
|
1556
1556
|
if (!core.ctx.disabledRealtime) {
|
|
1557
|
+
// this.core.ctx.logRealtime &&
|
|
1558
|
+
// Helpers.info(`
|
|
1559
|
+
// [ctx=${this.core.ctx.contextName}] init RealtimeClient (type: ${this.core.ctx.contextType})
|
|
1560
|
+
// `);
|
|
1557
1561
|
this.init();
|
|
1558
1562
|
}
|
|
1559
1563
|
}
|
|
@@ -1568,13 +1572,15 @@ class RealtimeClient {
|
|
|
1568
1572
|
if (this.core.ctx.config.frontendHost &&
|
|
1569
1573
|
this.core.ctx.config.frontendHost !== '' &&
|
|
1570
1574
|
this.core.ctx.isRunningInsideDocker) {
|
|
1571
|
-
|
|
1572
|
-
`
|
|
1575
|
+
this.core.ctx.logRealtime &&
|
|
1576
|
+
Helpers.logInfo(`[${this.core.ctx.contextName}] USING FRONTEND HOST` +
|
|
1577
|
+
` ${this.core.ctx.config.frontendHost} FOR REALTIME`);
|
|
1573
1578
|
nspPath.global = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.global.pathname}`);
|
|
1574
1579
|
nspPath.realtime = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.realtime.pathname}`);
|
|
1575
1580
|
}
|
|
1576
1581
|
else {
|
|
1577
|
-
|
|
1582
|
+
this.core.ctx.logRealtime &&
|
|
1583
|
+
Helpers.logInfo(`[${this.core.ctx.contextName}] Not using frontend host for realtime`);
|
|
1578
1584
|
}
|
|
1579
1585
|
this.core.ctx.logRealtime &&
|
|
1580
1586
|
console.info('[CLIENT] NAMESPACE GLOBAL ', nspPath.global.href + ` host: ${this.core.ctx.host}`);
|
|
@@ -1719,14 +1725,9 @@ to use socket realtime connection;
|
|
|
1719
1725
|
//#endregion
|
|
1720
1726
|
//#region methods & getters / get room id from
|
|
1721
1727
|
getUniqueIdentifierForConnection(options) {
|
|
1722
|
-
let url;
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
}
|
|
1726
|
-
else {
|
|
1727
|
-
url = new URL(options.core.ctx.remoteHost); // backend-to-backend use remote host
|
|
1728
|
-
}
|
|
1729
|
-
return `${this.core.ctx.contextName}:${url.origin}|${options.roomName}|${options.property}|${options.customEvent}`;
|
|
1728
|
+
let url = new URL(options.core.ctx.host);
|
|
1729
|
+
let contextNameForCommunication = options.core.ctx.contextNameForCommunication;
|
|
1730
|
+
return `${contextNameForCommunication}:${url.origin}|${options.roomName}|${options.property}|${options.customEvent}`;
|
|
1730
1731
|
}
|
|
1731
1732
|
}
|
|
1732
1733
|
|
|
@@ -1738,11 +1739,12 @@ class RealtimeServer {
|
|
|
1738
1739
|
constructor(core) {
|
|
1739
1740
|
this.core = core;
|
|
1740
1741
|
this.core = core;
|
|
1741
|
-
if (
|
|
1742
|
-
|
|
1743
|
-
this.init();
|
|
1744
|
-
//#endregion
|
|
1742
|
+
if (core.ctx.disabledRealtime || this.core.ctx.isRemoteHost) {
|
|
1743
|
+
return;
|
|
1745
1744
|
}
|
|
1745
|
+
//#region @websql
|
|
1746
|
+
this.init();
|
|
1747
|
+
//#endregion
|
|
1746
1748
|
}
|
|
1747
1749
|
//#region methods & getters / init
|
|
1748
1750
|
init() {
|
|
@@ -1848,7 +1850,7 @@ class RealtimeServer {
|
|
|
1848
1850
|
// console.info('__triger entity changes');
|
|
1849
1851
|
//#region @websql
|
|
1850
1852
|
let roomName;
|
|
1851
|
-
if (this.core.ctx.disabledRealtime) {
|
|
1853
|
+
if (this.core.ctx.disabledRealtime || this.core.ctx.isRemoteHost) {
|
|
1852
1854
|
return;
|
|
1853
1855
|
}
|
|
1854
1856
|
if (customEvent) {
|
|
@@ -2566,8 +2568,10 @@ class RealtimeCore {
|
|
|
2566
2568
|
];
|
|
2567
2569
|
this.ctx = ctx;
|
|
2568
2570
|
this.strategy = this.resolveStrategy();
|
|
2569
|
-
this.ctx.logRealtime &&
|
|
2570
|
-
|
|
2571
|
+
// this.ctx.logRealtime &&
|
|
2572
|
+
// console.log(`
|
|
2573
|
+
// [ctx=${this.ctx.contextName}] realtime strategy: ${this.strategy}, context type: ${this.ctx.contextType}
|
|
2574
|
+
// `);
|
|
2571
2575
|
if (Helpers.isWebSQL) {
|
|
2572
2576
|
this.server = new RealtimeServer(this);
|
|
2573
2577
|
// console.log('DONE INITING SERVER');
|
|
@@ -2604,7 +2608,8 @@ class RealtimeCore {
|
|
|
2604
2608
|
pathFor(namespace) {
|
|
2605
2609
|
let nsp = namespace ? namespace : '';
|
|
2606
2610
|
nsp = nsp === '/' ? '' : nsp;
|
|
2607
|
-
|
|
2611
|
+
const contextNameForCommunication = this.ctx.contextNameForCommunication;
|
|
2612
|
+
let prefix = `${apiPrefix}/${contextNameForCommunication}/udp`;
|
|
2608
2613
|
if (Helpers.isElectron) {
|
|
2609
2614
|
prefix = ``;
|
|
2610
2615
|
}
|
|
@@ -2670,6 +2675,12 @@ class EndpointContext {
|
|
|
2670
2675
|
this.ngZone = ngZone;
|
|
2671
2676
|
//#endregion
|
|
2672
2677
|
}
|
|
2678
|
+
//#endregion
|
|
2679
|
+
//#endregion
|
|
2680
|
+
//#region fields / source context
|
|
2681
|
+
get sourceContext() {
|
|
2682
|
+
return this.cloneOptions?.sourceContext;
|
|
2683
|
+
}
|
|
2673
2684
|
get isRunOrRevertOnlyMigrationAppStart() {
|
|
2674
2685
|
return !!(this.onlyMigrationRun || this.onlyMigrationRevertToTimestamp);
|
|
2675
2686
|
}
|
|
@@ -2711,9 +2722,17 @@ class EndpointContext {
|
|
|
2711
2722
|
}
|
|
2712
2723
|
return this.config?.logs === true;
|
|
2713
2724
|
}
|
|
2714
|
-
constructor(originalConfig, configFn
|
|
2725
|
+
constructor(originalConfig, configFn,
|
|
2726
|
+
/**
|
|
2727
|
+
* (@default: false)
|
|
2728
|
+
* If TRUE context is NOT going to create db/express server/http endpoints
|
|
2729
|
+
* PURPOSE OF THIS PROPERTY
|
|
2730
|
+
* -> ONLY remote access from backend or frontend to specific backend
|
|
2731
|
+
*/
|
|
2732
|
+
cloneOptions) {
|
|
2715
2733
|
this.originalConfig = originalConfig;
|
|
2716
2734
|
this.configFn = configFn;
|
|
2735
|
+
this.cloneOptions = cloneOptions;
|
|
2717
2736
|
//#region static
|
|
2718
2737
|
/**
|
|
2719
2738
|
* JUST FOR TESTING PURPOSES
|
|
@@ -2759,7 +2778,6 @@ class EndpointContext {
|
|
|
2759
2778
|
//#region @websql
|
|
2760
2779
|
this.repos = new Map();
|
|
2761
2780
|
//#endregion
|
|
2762
|
-
//#endregion
|
|
2763
2781
|
this.skipWritingServerRoutes = false;
|
|
2764
2782
|
//#region fields / types from contexts
|
|
2765
2783
|
this.injectableTypesfromContexts = [
|
|
@@ -2888,12 +2906,13 @@ class EndpointContext {
|
|
|
2888
2906
|
}
|
|
2889
2907
|
return classes;
|
|
2890
2908
|
};
|
|
2909
|
+
this.cloneOptions = this.cloneOptions || {};
|
|
2891
2910
|
this.isRunningInsideDocker = UtilsOs.isRunningInDocker();
|
|
2892
2911
|
}
|
|
2893
2912
|
//#endregion
|
|
2894
2913
|
//#region methods & getters / init
|
|
2895
2914
|
async init(options) {
|
|
2896
|
-
const { initFromRecrusiveContextResovle,
|
|
2915
|
+
const { initFromRecrusiveContextResovle, onlyMigrationRun, onlyMigrationRevertToTimestamp, } = options || {}; // TODO use it ?
|
|
2897
2916
|
this.inited = true;
|
|
2898
2917
|
// @ts-ignore
|
|
2899
2918
|
this.onlyMigrationRun = onlyMigrationRun;
|
|
@@ -2903,31 +2922,23 @@ class EndpointContext {
|
|
|
2903
2922
|
if (_.isObject(this.config.database)) {
|
|
2904
2923
|
this.config.database = Models.DatabaseConfig.from(this.config.database).databaseConfigTypeORM;
|
|
2905
2924
|
}
|
|
2906
|
-
if (overrideHost && overrideRemoteHost) {
|
|
2907
|
-
Helpers.throw(`[taon-config] You can't have overrideHost and overrideRemoteHost at the same time`);
|
|
2908
|
-
}
|
|
2909
|
-
this.config.host = !_.isUndefined(overrideHost)
|
|
2910
|
-
? overrideHost
|
|
2911
|
-
: this.config.host;
|
|
2912
|
-
this.config.remoteHost = !_.isUndefined(overrideRemoteHost)
|
|
2913
|
-
? overrideRemoteHost
|
|
2914
|
-
: this.config.remoteHost;
|
|
2915
2925
|
this.config.host = this.host === null ? void 0 : this.host;
|
|
2916
|
-
this.
|
|
2917
|
-
this.
|
|
2926
|
+
if (this.cloneOptions.overrideHost &&
|
|
2927
|
+
!this.cloneOptions.useAsRemoteContext) {
|
|
2928
|
+
this.config.host = this.cloneOptions.overrideHost;
|
|
2929
|
+
}
|
|
2930
|
+
if (this.cloneOptions.overrideRemoteHost &&
|
|
2931
|
+
this.cloneOptions.useAsRemoteContext) {
|
|
2932
|
+
this.config.host = this.cloneOptions.overrideRemoteHost;
|
|
2933
|
+
}
|
|
2918
2934
|
if (this.config.host &&
|
|
2919
2935
|
!this.config.host.startsWith('http://') &&
|
|
2920
2936
|
!this.config.host.startsWith('https://')) {
|
|
2921
|
-
Helpers.throw(`[taon-config] Your 'host' must start with http:// or https://`);
|
|
2937
|
+
Helpers.throw(`[taon-config] Your${this.host ? ' remote' : ''} 'host' must start with http:// or https://`);
|
|
2922
2938
|
}
|
|
2923
2939
|
if (_.isUndefined(this.config.useIpcWhenElectron)) {
|
|
2924
2940
|
this.config.useIpcWhenElectron = true;
|
|
2925
2941
|
}
|
|
2926
|
-
if (this.config.remoteHost &&
|
|
2927
|
-
!this.config.remoteHost.startsWith('http://') &&
|
|
2928
|
-
!this.config.remoteHost.startsWith('https://')) {
|
|
2929
|
-
Helpers.throw(`[taon-config] Your 'remoteHost' must start with http:// or https://`);
|
|
2930
|
-
}
|
|
2931
2942
|
// console.log(`config for ${this.contextName}`, this.config);
|
|
2932
2943
|
//#region resolve if skipping writing server routes
|
|
2933
2944
|
//@ts-expect-error overriding readonly
|
|
@@ -2942,10 +2953,7 @@ class EndpointContext {
|
|
|
2942
2953
|
this.mode = 'backend-frontend(websql)';
|
|
2943
2954
|
//#endregion
|
|
2944
2955
|
}
|
|
2945
|
-
if (this.
|
|
2946
|
-
if (this.config.host) {
|
|
2947
|
-
Helpers.throw(`[taon] You can't have remoteHost and host at the same time`);
|
|
2948
|
-
}
|
|
2956
|
+
if (this.isRemoteHost) {
|
|
2949
2957
|
this.mode = 'remote-backend(tcp+udp)';
|
|
2950
2958
|
}
|
|
2951
2959
|
// console.log(`
|
|
@@ -2966,9 +2974,9 @@ class EndpointContext {
|
|
|
2966
2974
|
// console.log(this.config)
|
|
2967
2975
|
// }
|
|
2968
2976
|
if (!this.mode && !this.config.abstract) {
|
|
2969
|
-
const errMsg = `You need to provide host
|
|
2970
|
-
`useIpcWhenElectron
|
|
2971
|
-
Helpers.error(`[taon]
|
|
2977
|
+
const errMsg = `You need to provide host property or ` +
|
|
2978
|
+
`useIpcWhenElectron or mark it as abstract`;
|
|
2979
|
+
Helpers.error(`[taon][Context=${this.contextName}]: ${errMsg}`, false, true);
|
|
2972
2980
|
/* */
|
|
2973
2981
|
/* */
|
|
2974
2982
|
}
|
|
@@ -3016,7 +3024,7 @@ class EndpointContext {
|
|
|
3016
3024
|
axios.defaults.withCredentials = true;
|
|
3017
3025
|
}
|
|
3018
3026
|
//#endregion
|
|
3019
|
-
//#region prepare & gather all classes
|
|
3027
|
+
//#region prepare & gather all classes recursively
|
|
3020
3028
|
this.config.contexts = this.config.contexts || {};
|
|
3021
3029
|
this.config.entities = this.config.entities || {};
|
|
3022
3030
|
this.config.controllers = this.config.controllers || {};
|
|
@@ -3153,6 +3161,8 @@ class EndpointContext {
|
|
|
3153
3161
|
/* */
|
|
3154
3162
|
/* */
|
|
3155
3163
|
/* */
|
|
3164
|
+
this.logRealtime &&
|
|
3165
|
+
Helpers.info(`[ctx=${this.contextName}] Init Realtime for ${this.mode}`);
|
|
3156
3166
|
this.realtime = new RealtimeCore(this);
|
|
3157
3167
|
}
|
|
3158
3168
|
//#endregion
|
|
@@ -3164,9 +3174,9 @@ class EndpointContext {
|
|
|
3164
3174
|
Helpers.info(`[taon] Create abstract context: ${this.config.contextName}`);
|
|
3165
3175
|
}
|
|
3166
3176
|
else {
|
|
3167
|
-
if (this.
|
|
3177
|
+
if (this.isRemoteHost) {
|
|
3168
3178
|
this.logFramework &&
|
|
3169
|
-
Helpers.info(`[taon] Create context for remote host: ${this.config.
|
|
3179
|
+
Helpers.info(`[taon] Create context for remote host: ${this.config.host}`);
|
|
3170
3180
|
}
|
|
3171
3181
|
else {
|
|
3172
3182
|
this.logFramework &&
|
|
@@ -3353,6 +3363,10 @@ class EndpointContext {
|
|
|
3353
3363
|
/* */
|
|
3354
3364
|
/* */
|
|
3355
3365
|
/* */
|
|
3366
|
+
/* */
|
|
3367
|
+
/* */
|
|
3368
|
+
/* */
|
|
3369
|
+
/* */
|
|
3356
3370
|
return (void 0);
|
|
3357
3371
|
}
|
|
3358
3372
|
//#endregion
|
|
@@ -3591,7 +3605,7 @@ class EndpointContext {
|
|
|
3591
3605
|
//#endregion
|
|
3592
3606
|
//#region methods & getters / init classes
|
|
3593
3607
|
async initClasses() {
|
|
3594
|
-
if (this.
|
|
3608
|
+
if (this.isRemoteHost) {
|
|
3595
3609
|
return;
|
|
3596
3610
|
}
|
|
3597
3611
|
//#region @websql
|
|
@@ -3654,11 +3668,7 @@ class EndpointContext {
|
|
|
3654
3668
|
return uri;
|
|
3655
3669
|
}
|
|
3656
3670
|
get uri() {
|
|
3657
|
-
const url = this.host
|
|
3658
|
-
? new URL(this.host)
|
|
3659
|
-
: this.remoteHost
|
|
3660
|
-
? new URL(this.remoteHost)
|
|
3661
|
-
: void 0;
|
|
3671
|
+
const url = this.host ? new URL(this.host) : void 0;
|
|
3662
3672
|
return url;
|
|
3663
3673
|
}
|
|
3664
3674
|
//#endregion
|
|
@@ -3726,11 +3736,50 @@ class EndpointContext {
|
|
|
3726
3736
|
}
|
|
3727
3737
|
//#endregion
|
|
3728
3738
|
//#region methods & getters / public assets
|
|
3739
|
+
get isRemoteHost() {
|
|
3740
|
+
return !!this.cloneOptions?.useAsRemoteContext;
|
|
3741
|
+
}
|
|
3742
|
+
//#endregion
|
|
3743
|
+
//#region methods & getters / public assets
|
|
3729
3744
|
/**
|
|
3730
3745
|
* ipc/udp needs this
|
|
3731
3746
|
*/
|
|
3732
3747
|
get contextName() {
|
|
3733
|
-
|
|
3748
|
+
// console.log(this.originalConfig);
|
|
3749
|
+
return this.config?.contextName || this.originalConfig?.contextName;
|
|
3750
|
+
}
|
|
3751
|
+
//#endregion
|
|
3752
|
+
//#region methods & getters / public assets
|
|
3753
|
+
/**
|
|
3754
|
+
* ipc/udp needs this
|
|
3755
|
+
*/
|
|
3756
|
+
get contextNameForCommunication() {
|
|
3757
|
+
let contextName = this.contextName;
|
|
3758
|
+
if (this.isRemoteHost) {
|
|
3759
|
+
if (this.sourceContext?.contextName) {
|
|
3760
|
+
contextName = this.sourceContext?.contextName;
|
|
3761
|
+
}
|
|
3762
|
+
else {
|
|
3763
|
+
// console.log(
|
|
3764
|
+
// `CANT GET SOURCE CONTEXT NAME FOR REMOTE CONTEXT ${this.contextName}`,
|
|
3765
|
+
// );
|
|
3766
|
+
}
|
|
3767
|
+
}
|
|
3768
|
+
return contextName;
|
|
3769
|
+
}
|
|
3770
|
+
//#endregion
|
|
3771
|
+
//#region methods & getters / public assets
|
|
3772
|
+
/**
|
|
3773
|
+
* Check context type
|
|
3774
|
+
*/
|
|
3775
|
+
get contextType() {
|
|
3776
|
+
if (this.config.abstract) {
|
|
3777
|
+
return 'abstract';
|
|
3778
|
+
}
|
|
3779
|
+
if (this.host) {
|
|
3780
|
+
return this.isRemoteHost ? 'remote' : 'normal';
|
|
3781
|
+
}
|
|
3782
|
+
return 'invalid';
|
|
3734
3783
|
}
|
|
3735
3784
|
//#endregion
|
|
3736
3785
|
//#region methods & getters / current working directory
|
|
@@ -3758,11 +3807,6 @@ class EndpointContext {
|
|
|
3758
3807
|
return this.config.productionMode;
|
|
3759
3808
|
}
|
|
3760
3809
|
//#endregion
|
|
3761
|
-
//#region methods & getters / remote host
|
|
3762
|
-
get remoteHost() {
|
|
3763
|
-
return this.config.remoteHost;
|
|
3764
|
-
}
|
|
3765
|
-
//#endregion
|
|
3766
3810
|
//#region methods & getters / host
|
|
3767
3811
|
get host() {
|
|
3768
3812
|
return this.config.host;
|
|
@@ -3776,7 +3820,7 @@ class EndpointContext {
|
|
|
3776
3820
|
//#region methods & getters / init subscribers
|
|
3777
3821
|
async initSubscribers() {
|
|
3778
3822
|
//#region @websqlFunc
|
|
3779
|
-
if (this.
|
|
3823
|
+
if (this.isRemoteHost) {
|
|
3780
3824
|
return;
|
|
3781
3825
|
}
|
|
3782
3826
|
const subscriberClasses = this.getClassFunByArr(Models.ClassType.SUBSCRIBER);
|
|
@@ -3792,7 +3836,7 @@ class EndpointContext {
|
|
|
3792
3836
|
//#region methods & getters / init entities
|
|
3793
3837
|
async initEntities() {
|
|
3794
3838
|
//#region @websql
|
|
3795
|
-
if (this.
|
|
3839
|
+
if (this.isRemoteHost) {
|
|
3796
3840
|
return;
|
|
3797
3841
|
}
|
|
3798
3842
|
const entities = this.getClassFunByArr(Models.ClassType.ENTITY);
|
|
@@ -3838,7 +3882,7 @@ class EndpointContext {
|
|
|
3838
3882
|
//#region methods & getters / init connection
|
|
3839
3883
|
async initDatabaseConnection() {
|
|
3840
3884
|
//#region @websqlFunc
|
|
3841
|
-
if (this.
|
|
3885
|
+
if (this.isRemoteHost || !this.databaseConfig) {
|
|
3842
3886
|
return;
|
|
3843
3887
|
}
|
|
3844
3888
|
const entities = this.getClassFunByArr(Models.ClassType.ENTITY).map(entityFn => {
|
|
@@ -3944,12 +3988,13 @@ class EndpointContext {
|
|
|
3944
3988
|
return bc.className;
|
|
3945
3989
|
})
|
|
3946
3990
|
.join('/');
|
|
3991
|
+
const contextNameForCommunication = this.contextNameForCommunication;
|
|
3947
3992
|
if (TaonHelpers.isGoodPath(classConfig.path)) {
|
|
3948
3993
|
classConfig.calculatedPath = classConfig.path;
|
|
3949
3994
|
}
|
|
3950
3995
|
else {
|
|
3951
3996
|
classConfig.calculatedPath = (`${this.uriPathnameOrNothingIfRoot}` +
|
|
3952
|
-
`/${apiPrefix}/${
|
|
3997
|
+
`/${apiPrefix}/${contextNameForCommunication}/tcp${parentsCalculatedPath}/` +
|
|
3953
3998
|
`${ClassHelpers.getName(controllerClassFn)}`)
|
|
3954
3999
|
.replace(/\/\//g, '/')
|
|
3955
4000
|
.split('/')
|
|
@@ -3979,7 +4024,7 @@ class EndpointContext {
|
|
|
3979
4024
|
});
|
|
3980
4025
|
}
|
|
3981
4026
|
//#endregion
|
|
3982
|
-
async initControllersHook(
|
|
4027
|
+
async initControllersHook(ctxStorage) {
|
|
3983
4028
|
if (this.isRunOrRevertOnlyMigrationAppStart) {
|
|
3984
4029
|
return;
|
|
3985
4030
|
}
|
|
@@ -3987,7 +4032,7 @@ class EndpointContext {
|
|
|
3987
4032
|
for (const controllerClassFn of allControllers) {
|
|
3988
4033
|
const instance = this.getInstanceBy(controllerClassFn);
|
|
3989
4034
|
if (_.isFunction(instance.afterAllCtxInited)) {
|
|
3990
|
-
await instance.afterAllCtxInited(
|
|
4035
|
+
await instance.afterAllCtxInited({ ctxStorage });
|
|
3991
4036
|
}
|
|
3992
4037
|
}
|
|
3993
4038
|
}
|
|
@@ -4085,7 +4130,7 @@ class EndpointContext {
|
|
|
4085
4130
|
}
|
|
4086
4131
|
//#endregion
|
|
4087
4132
|
//#region init client
|
|
4088
|
-
const shouldInitClient = Helpers.isBrowser || this.
|
|
4133
|
+
const shouldInitClient = Helpers.isBrowser || this.isRemoteHost || Helpers.isWebSQL;
|
|
4089
4134
|
// console.log('shouldInitClient', shouldInitClient);
|
|
4090
4135
|
if (shouldInitClient) {
|
|
4091
4136
|
// console.log(
|
|
@@ -4112,7 +4157,7 @@ class EndpointContext {
|
|
|
4112
4157
|
//#endregion
|
|
4113
4158
|
//#region methods & getters / write active routes
|
|
4114
4159
|
writeActiveRoutes() {
|
|
4115
|
-
if (this.
|
|
4160
|
+
if (this.isRemoteHost ||
|
|
4116
4161
|
this.isRunOrRevertOnlyMigrationAppStart ||
|
|
4117
4162
|
this.skipWritingServerRoutes) {
|
|
4118
4163
|
return;
|
|
@@ -4393,7 +4438,7 @@ class EndpointContext {
|
|
|
4393
4438
|
/* */
|
|
4394
4439
|
/* */
|
|
4395
4440
|
}
|
|
4396
|
-
if (!this.
|
|
4441
|
+
if (!this.isRemoteHost) {
|
|
4397
4442
|
//#region apply dummy websql express routers
|
|
4398
4443
|
//#region @websql
|
|
4399
4444
|
if (Helpers.isWebSQL) {
|
|
@@ -4997,6 +5042,37 @@ instead
|
|
|
4997
5042
|
}
|
|
4998
5043
|
}
|
|
4999
5044
|
|
|
5045
|
+
class ContextsEndpointStorage {
|
|
5046
|
+
constructor() {
|
|
5047
|
+
this.SPECIAL_APP_READY_MESSAGE = CoreModels.SPECIAL_APP_READY_MESSAGE;
|
|
5048
|
+
this.taonEndpointContexts = new Map();
|
|
5049
|
+
// Private constructor to prevent direct instantiation
|
|
5050
|
+
}
|
|
5051
|
+
static get Instance() {
|
|
5052
|
+
if (!ContextsEndpointStorage.instance) {
|
|
5053
|
+
ContextsEndpointStorage.instance = new ContextsEndpointStorage();
|
|
5054
|
+
}
|
|
5055
|
+
return ContextsEndpointStorage.instance;
|
|
5056
|
+
}
|
|
5057
|
+
//#endregion
|
|
5058
|
+
set(context) {
|
|
5059
|
+
if (!this.taonEndpointContexts.has(context.contextName)) {
|
|
5060
|
+
this.taonEndpointContexts.set(context.contextName, context);
|
|
5061
|
+
}
|
|
5062
|
+
}
|
|
5063
|
+
get arr() {
|
|
5064
|
+
return Array.from(this.taonEndpointContexts.values()).filter(f => f.contextType === 'normal');
|
|
5065
|
+
}
|
|
5066
|
+
getBy(context) {
|
|
5067
|
+
if (typeof context === 'string') {
|
|
5068
|
+
return this.taonEndpointContexts.get(context);
|
|
5069
|
+
}
|
|
5070
|
+
return this.taonEndpointContexts.get(context.contextName);
|
|
5071
|
+
}
|
|
5072
|
+
}
|
|
5073
|
+
// TODO QUICK_FIX @LAST encapsulate this => move to separate package
|
|
5074
|
+
globalThis['$$$ContextsEndpointStorage$$$'] = ContextsEndpointStorage.Instance;
|
|
5075
|
+
|
|
5000
5076
|
//#region imports
|
|
5001
5077
|
//#endregion
|
|
5002
5078
|
/**
|
|
@@ -5013,14 +5089,15 @@ const createContextTemplate = (configFn) => {
|
|
|
5013
5089
|
* REQURIED PROPERTY:
|
|
5014
5090
|
* - contextName
|
|
5015
5091
|
*/
|
|
5016
|
-
const
|
|
5092
|
+
const createContextFn = (configFn, cloneOptions) => {
|
|
5093
|
+
cloneOptions = cloneOptions || {};
|
|
5017
5094
|
let config = configFn({});
|
|
5018
5095
|
// console.log(
|
|
5019
5096
|
// `
|
|
5020
5097
|
// [Taon] Creating context ${config.contextName}...`,
|
|
5021
5098
|
// {config},
|
|
5022
5099
|
// );
|
|
5023
|
-
const endpointContextRef = new EndpointContext(config, configFn);
|
|
5100
|
+
const endpointContextRef = new EndpointContext(config, configFn, cloneOptions);
|
|
5024
5101
|
const res = {
|
|
5025
5102
|
//#region contexts
|
|
5026
5103
|
get contextName() {
|
|
@@ -5030,6 +5107,24 @@ const createContext = (configFn) => {
|
|
|
5030
5107
|
get appId() {
|
|
5031
5108
|
return config.appId;
|
|
5032
5109
|
},
|
|
5110
|
+
cloneAsRemote: (cloneOpt) => {
|
|
5111
|
+
cloneOpt = cloneOpt || {};
|
|
5112
|
+
const opt = {
|
|
5113
|
+
...cloneOpt,
|
|
5114
|
+
sourceContext: endpointContextRef,
|
|
5115
|
+
useAsRemoteContext: true,
|
|
5116
|
+
};
|
|
5117
|
+
return createContextFn(configFn, opt);
|
|
5118
|
+
},
|
|
5119
|
+
cloneAsNormal: (cloneOpt) => {
|
|
5120
|
+
cloneOpt = cloneOpt || {};
|
|
5121
|
+
const opt = {
|
|
5122
|
+
...cloneOpt,
|
|
5123
|
+
sourceContext: endpointContextRef,
|
|
5124
|
+
useAsRemoteContext: false,
|
|
5125
|
+
};
|
|
5126
|
+
return createContextFn(configFn, opt);
|
|
5127
|
+
},
|
|
5033
5128
|
//#region context
|
|
5034
5129
|
/**
|
|
5035
5130
|
* @deprecated
|
|
@@ -5143,19 +5238,23 @@ const createContext = (configFn) => {
|
|
|
5143
5238
|
//#endregion
|
|
5144
5239
|
//#region run migrations tasks
|
|
5145
5240
|
if (endpointContextRef.onlyMigrationRun) {
|
|
5146
|
-
|
|
5241
|
+
endpointContextRef.logMigrations &&
|
|
5242
|
+
Helpers.log(`[taon] Running only migrations (context=${endpointContextRef.contextName}).`);
|
|
5147
5243
|
await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
|
|
5148
5244
|
}
|
|
5149
5245
|
else if (endpointContextRef.onlyMigrationRevertToTimestamp) {
|
|
5150
|
-
|
|
5246
|
+
endpointContextRef.logMigrations &&
|
|
5247
|
+
Helpers.log(`[taon] Reverting migrations to timestamp ${endpointContextRef.onlyMigrationRevertToTimestamp} (context=${endpointContextRef.contextName}).`);
|
|
5151
5248
|
await endpointContextRef.dbMigrations.revertMigrationToTimestamp(endpointContextRef.onlyMigrationRevertToTimestamp);
|
|
5152
5249
|
}
|
|
5153
5250
|
else {
|
|
5154
|
-
|
|
5251
|
+
endpointContextRef.logMigrations &&
|
|
5252
|
+
Helpers.log(`[taon] Running all not applied migrations (context=${endpointContextRef.contextName}).`);
|
|
5155
5253
|
await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
|
|
5156
5254
|
}
|
|
5157
5255
|
//#endregion
|
|
5158
5256
|
}
|
|
5257
|
+
ContextsEndpointStorage.Instance.set(endpointContextRef);
|
|
5159
5258
|
resolve(endpointContextRef);
|
|
5160
5259
|
});
|
|
5161
5260
|
//#endregion
|
|
@@ -5178,6 +5277,12 @@ const createContext = (configFn) => {
|
|
|
5178
5277
|
};
|
|
5179
5278
|
return res;
|
|
5180
5279
|
};
|
|
5280
|
+
//#endregion
|
|
5281
|
+
const createContext = (configFn) => {
|
|
5282
|
+
return createContextFn(configFn, { useAsRemoteContext: false });
|
|
5283
|
+
};
|
|
5284
|
+
// const AA = createContext(() => ({ contextName: 'aa' }));
|
|
5285
|
+
// const BB = AA.cloneAsRemoteContext();
|
|
5181
5286
|
|
|
5182
5287
|
/**
|
|
5183
5288
|
* Provider decorator
|
|
@@ -6202,14 +6307,12 @@ function Body(name) {
|
|
|
6202
6307
|
};
|
|
6203
6308
|
}
|
|
6204
6309
|
|
|
6205
|
-
/* */
|
|
6206
|
-
/* */
|
|
6207
6310
|
let BaseController = class BaseController extends BaseInjector {
|
|
6208
6311
|
/**
|
|
6209
6312
|
* Hook that is called when taon app is inited
|
|
6210
6313
|
* (all contexts are created and inited)
|
|
6211
6314
|
*/
|
|
6212
|
-
async afterAllCtxInited(
|
|
6315
|
+
async afterAllCtxInited(options) { }
|
|
6213
6316
|
//#region upload form data to server
|
|
6214
6317
|
uploadFormDataToServer(formData) {
|
|
6215
6318
|
/* */
|
|
@@ -6883,5 +6986,5 @@ var Taon;
|
|
|
6883
6986
|
* Generated bundle index. Do not edit.
|
|
6884
6987
|
*/
|
|
6885
6988
|
|
|
6886
|
-
export { BaseContext, BaseController, BaseCustomRepository, BaseEntity, BaseFileUploadMiddleware, BaseMigration, BaseProvider, BaseRepository, CURRENT_HOST_BACKEND_PORT, CURRENT_HOST_URL, ClassHelpers, EndpointContext, Models, TAON_CONTEXT, Taon, TaonAdminService, TaonEntityKeysToOmitArr, apiPrefix, createContext, inject };
|
|
6989
|
+
export { BaseContext, BaseController, BaseCustomRepository, BaseEntity, BaseFileUploadMiddleware, BaseMigration, BaseProvider, BaseRepository, CURRENT_HOST_BACKEND_PORT, CURRENT_HOST_URL, ClassHelpers, ContextsEndpointStorage, EndpointContext, Models, TAON_CONTEXT, Taon, TaonAdminService, TaonEntityKeysToOmitArr, apiPrefix, createContext, inject };
|
|
6887
6990
|
//# sourceMappingURL=taon.mjs.map
|