taon 19.0.62 → 19.0.63

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.
Files changed (125) hide show
  1. package/README.md +160 -160
  2. package/bin/start.js +281 -281
  3. package/bin/taon +6 -6
  4. package/bin/taon-debug +5 -5
  5. package/bin/taon-debug-brk +5 -5
  6. package/browser/README.md +24 -24
  7. package/browser/fesm2022/taon.mjs +177 -77
  8. package/browser/fesm2022/taon.mjs.map +1 -1
  9. package/browser/lib/base-classes/base-context.d.ts +6 -0
  10. package/browser/lib/base-classes/base-controller.d.ts +3 -3
  11. package/browser/lib/base-classes/base.d.ts +6 -0
  12. package/browser/lib/create-context.d.ts +12 -4
  13. package/browser/lib/endpoint-context-storage.d.ts +11 -0
  14. package/browser/lib/endpoint-context.d.ts +28 -8
  15. package/browser/lib/index.d.ts +19 -0
  16. package/browser/lib/models.d.ts +7 -8
  17. package/browser/package.json +1 -1
  18. package/icon-menu-taon.svg +15 -15
  19. package/lib/base-classes/base-context.d.ts +6 -0
  20. package/lib/base-classes/base-controller.d.ts +3 -3
  21. package/lib/base-classes/base-controller.js +2 -2
  22. package/lib/base-classes/base-controller.js.map +1 -1
  23. package/lib/base-classes/base.d.ts +6 -0
  24. package/lib/build-info._auto-generated_.d.ts +1 -1
  25. package/lib/build-info._auto-generated_.js +1 -1
  26. package/lib/context-db-migrations.js +5 -5
  27. package/lib/context-db-migrations.js.map +1 -1
  28. package/lib/create-context.d.ts +12 -4
  29. package/lib/create-context.js +35 -5
  30. package/lib/create-context.js.map +1 -1
  31. package/lib/endpoint-context-storage.d.ts +10 -0
  32. package/lib/endpoint-context-storage.js +34 -0
  33. package/lib/endpoint-context-storage.js.map +1 -0
  34. package/lib/endpoint-context.d.ts +28 -8
  35. package/lib/endpoint-context.js +96 -55
  36. package/lib/endpoint-context.js.map +1 -1
  37. package/lib/index.d.ts +19 -0
  38. package/lib/index.js +3 -1
  39. package/lib/index.js.map +1 -1
  40. package/lib/models.d.ts +7 -8
  41. package/lib/models.js.map +1 -1
  42. package/lib/realtime/realtime-client.js +12 -11
  43. package/lib/realtime/realtime-client.js.map +1 -1
  44. package/lib/realtime/realtime-core.js +6 -3
  45. package/lib/realtime/realtime-core.js.map +1 -1
  46. package/lib/realtime/realtime-server.js +6 -5
  47. package/lib/realtime/realtime-server.js.map +1 -1
  48. package/lib/ui/index.js +2 -2
  49. package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
  50. package/package.json +1 -1
  51. package/websql/README.md +24 -24
  52. package/websql/fesm2022/taon.mjs +184 -84
  53. package/websql/fesm2022/taon.mjs.map +1 -1
  54. package/websql/lib/base-classes/base-context.d.ts +6 -0
  55. package/websql/lib/base-classes/base-controller.d.ts +3 -3
  56. package/websql/lib/base-classes/base.d.ts +6 -0
  57. package/websql/lib/create-context.d.ts +12 -4
  58. package/websql/lib/endpoint-context-storage.d.ts +11 -0
  59. package/websql/lib/endpoint-context.d.ts +28 -8
  60. package/websql/lib/index.d.ts +19 -0
  61. package/websql/lib/models.d.ts +7 -8
  62. package/websql/package.json +1 -1
  63. package/lib/decorators/classes/controller-config.d.ts +0 -9
  64. package/lib/decorators/classes/controller-config.js +0 -11
  65. package/lib/decorators/classes/controller-config.js.map +0 -1
  66. package/lib/decorators/classes/controller-options.d.ts +0 -11
  67. package/lib/decorators/classes/controller-options.js +0 -16
  68. package/lib/decorators/classes/controller-options.js.map +0 -1
  69. package/lib/env.d.ts +0 -2
  70. package/lib/env.js +0 -7
  71. package/lib/env.js.map +0 -1
  72. package/lib/storage.d.ts +0 -1
  73. package/lib/storage.js +0 -6
  74. package/lib/storage.js.map +0 -1
  75. package/lib/ui/directives/index.d.ts +0 -3
  76. package/lib/ui/directives/index.js +0 -5
  77. package/lib/ui/directives/index.js.map +0 -1
  78. package/lib/ui/directives/safe.pipe.d.ts +0 -7
  79. package/lib/ui/directives/taon-inject-html.directive.d.ts +0 -6
  80. package/lib/ui/directives/taon-long-press.directive.d.ts +0 -22
  81. package/lib/ui/directives/view-mode.d.ts +0 -5
  82. package/lib/ui/directives/view-mode.js +0 -10
  83. package/lib/ui/directives/view-mode.js.map +0 -1
  84. package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +0 -43
  85. package/lib/ui/taon-admin-mode-configuration/taon-admin.models.d.ts +0 -5
  86. package/lib/ui/taon-admin-mode-configuration/taon-admin.models.js +0 -3
  87. package/lib/ui/taon-admin-mode-configuration/taon-admin.models.js.map +0 -1
  88. package/lib/ui/taon-full-material.module.d.ts +0 -5
  89. package/lib/ui/taon-github-fork-me-corner/index.d.ts +0 -2
  90. package/lib/ui/taon-github-fork-me-corner/index.js +0 -5
  91. package/lib/ui/taon-github-fork-me-corner/index.js.map +0 -1
  92. package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.component.d.ts +0 -3
  93. package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.module.d.ts +0 -2
  94. package/lib/ui/taon-github-fork-me-ribbon/index.d.ts +0 -2
  95. package/lib/ui/taon-github-fork-me-ribbon/index.js +0 -5
  96. package/lib/ui/taon-github-fork-me-ribbon/index.js.map +0 -1
  97. package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.component.d.ts +0 -3
  98. package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.module.d.ts +0 -2
  99. package/lib/ui/taon-notifications/index.d.ts +0 -4
  100. package/lib/ui/taon-notifications/index.js +0 -24
  101. package/lib/ui/taon-notifications/index.js.map +0 -1
  102. package/lib/ui/taon-notifications/taon-notifications.component.d.ts +0 -9
  103. package/lib/ui/taon-notifications/taon-notifications.models.d.ts +0 -6
  104. package/lib/ui/taon-notifications/taon-notifications.models.js +0 -5
  105. package/lib/ui/taon-notifications/taon-notifications.models.js.map +0 -1
  106. package/lib/ui/taon-notifications/taon-notifications.module.d.ts +0 -2
  107. package/lib/ui/taon-notifications/taon-notifications.service.d.ts +0 -11
  108. package/lib/ui/taon-progress-bar/index.d.ts +0 -2
  109. package/lib/ui/taon-progress-bar/index.js +0 -5
  110. package/lib/ui/taon-progress-bar/index.js.map +0 -1
  111. package/lib/ui/taon-progress-bar/taon-progress-bar.component.d.ts +0 -13
  112. package/lib/ui/taon-progress-bar/taon-progress-bar.module.d.ts +0 -2
  113. package/lib/ui/taon-session-passcode/index.d.ts +0 -1
  114. package/lib/ui/taon-session-passcode/index.js +0 -5
  115. package/lib/ui/taon-session-passcode/index.js.map +0 -1
  116. package/lib/ui/taon-session-passcode/taon-session-passcode.component.d.ts +0 -35
  117. package/lib/ui/taon-table/index.d.ts +0 -2
  118. package/lib/ui/taon-table/index.js +0 -5
  119. package/lib/ui/taon-table/index.js.map +0 -1
  120. package/lib/ui/taon-table/taon-table.component.d.ts +0 -34
  121. package/lib/ui/taon-table/taon-table.module.d.ts +0 -2
  122. package/lib/ui/taon.models.d.ts +0 -11
  123. package/lib/ui/taon.models.js +0 -3
  124. package/lib/ui/taon.models.js.map +0 -1
  125. package/tmp-environment.json +0 -39
@@ -1545,6 +1545,10 @@ class RealtimeClient {
1545
1545
  this.subsManagers = {};
1546
1546
  this.core = core;
1547
1547
  if (!core.ctx.disabledRealtime) {
1548
+ // this.core.ctx.logRealtime &&
1549
+ // Helpers.info(`
1550
+ // [ctx=${this.core.ctx.contextName}] init RealtimeClient (type: ${this.core.ctx.contextType})
1551
+ // `);
1548
1552
  this.init();
1549
1553
  }
1550
1554
  }
@@ -1559,13 +1563,15 @@ class RealtimeClient {
1559
1563
  if (this.core.ctx.config.frontendHost &&
1560
1564
  this.core.ctx.config.frontendHost !== '' &&
1561
1565
  this.core.ctx.isRunningInsideDocker) {
1562
- Helpers.logInfo(`[${this.core.ctx.contextName}] USING FRONTEND HOST` +
1563
- ` ${this.core.ctx.config.frontendHost} FOR REALTIME`);
1566
+ this.core.ctx.logRealtime &&
1567
+ Helpers.logInfo(`[${this.core.ctx.contextName}] USING FRONTEND HOST` +
1568
+ ` ${this.core.ctx.config.frontendHost} FOR REALTIME`);
1564
1569
  nspPath.global = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.global.pathname}`);
1565
1570
  nspPath.realtime = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.realtime.pathname}`);
1566
1571
  }
1567
1572
  else {
1568
- Helpers.logInfo(`[${this.core.ctx.contextName}] Not using frontend host for realtime`);
1573
+ this.core.ctx.logRealtime &&
1574
+ Helpers.logInfo(`[${this.core.ctx.contextName}] Not using frontend host for realtime`);
1569
1575
  }
1570
1576
  this.core.ctx.logRealtime &&
1571
1577
  console.info('[CLIENT] NAMESPACE GLOBAL ', nspPath.global.href + ` host: ${this.core.ctx.host}`);
@@ -1710,14 +1716,9 @@ to use socket realtime connection;
1710
1716
  //#endregion
1711
1717
  //#region methods & getters / get room id from
1712
1718
  getUniqueIdentifierForConnection(options) {
1713
- let url;
1714
- if (UtilsOs.isBrowser) {
1715
- url = new URL(options.core.ctx.host);
1716
- }
1717
- else {
1718
- url = new URL(options.core.ctx.remoteHost); // backend-to-backend use remote host
1719
- }
1720
- return `${this.core.ctx.contextName}:${url.origin}|${options.roomName}|${options.property}|${options.customEvent}`;
1719
+ let url = new URL(options.core.ctx.host);
1720
+ let contextNameForCommunication = options.core.ctx.contextNameForCommunication;
1721
+ return `${contextNameForCommunication}:${url.origin}|${options.roomName}|${options.property}|${options.customEvent}`;
1721
1722
  }
1722
1723
  }
1723
1724
 
@@ -1729,10 +1730,11 @@ class RealtimeServer {
1729
1730
  constructor(core) {
1730
1731
  this.core = core;
1731
1732
  this.core = core;
1732
- if (!core.ctx.disabledRealtime) {
1733
- /* */
1734
- /* */
1733
+ if (core.ctx.disabledRealtime || this.core.ctx.isRemoteHost) {
1734
+ return;
1735
1735
  }
1736
+ /* */
1737
+ /* */
1736
1738
  }
1737
1739
  //#region methods & getters / init
1738
1740
  init() {
@@ -2659,8 +2661,10 @@ class RealtimeCore {
2659
2661
  ];
2660
2662
  this.ctx = ctx;
2661
2663
  this.strategy = this.resolveStrategy();
2662
- this.ctx.logRealtime &&
2663
- console.log(`[taon] realtime strategy: ${this.strategy}`);
2664
+ // this.ctx.logRealtime &&
2665
+ // console.log(`
2666
+ // [ctx=${this.ctx.contextName}] realtime strategy: ${this.strategy}, context type: ${this.ctx.contextType}
2667
+ // `);
2664
2668
  if (Helpers.isWebSQL) {
2665
2669
  this.server = new RealtimeServer(this);
2666
2670
  // console.log('DONE INITING SERVER');
@@ -2697,7 +2701,8 @@ class RealtimeCore {
2697
2701
  pathFor(namespace) {
2698
2702
  let nsp = namespace ? namespace : '';
2699
2703
  nsp = nsp === '/' ? '' : nsp;
2700
- let prefix = `${apiPrefix}/${this.ctx.contextName}/udp`;
2704
+ const contextNameForCommunication = this.ctx.contextNameForCommunication;
2705
+ let prefix = `${apiPrefix}/${contextNameForCommunication}/udp`;
2701
2706
  if (Helpers.isElectron) {
2702
2707
  prefix = ``;
2703
2708
  }
@@ -2717,6 +2722,15 @@ class EndpointContext {
2717
2722
  this.ngZone = ngZone;
2718
2723
  //#endregion
2719
2724
  }
2725
+ //#endregion
2726
+ //#region fields / typeorm repositories
2727
+ /* */
2728
+ /* */
2729
+ //#endregion
2730
+ //#region fields / source context
2731
+ get sourceContext() {
2732
+ return this.cloneOptions?.sourceContext;
2733
+ }
2720
2734
  get isRunOrRevertOnlyMigrationAppStart() {
2721
2735
  return !!(this.onlyMigrationRun || this.onlyMigrationRevertToTimestamp);
2722
2736
  }
@@ -2758,9 +2772,17 @@ class EndpointContext {
2758
2772
  }
2759
2773
  return this.config?.logs === true;
2760
2774
  }
2761
- constructor(originalConfig, configFn) {
2775
+ constructor(originalConfig, configFn,
2776
+ /**
2777
+ * (@default: false)
2778
+ * If TRUE context is NOT going to create db/express server/http endpoints
2779
+ * PURPOSE OF THIS PROPERTY
2780
+ * -> ONLY remote access from backend or frontend to specific backend
2781
+ */
2782
+ cloneOptions) {
2762
2783
  this.originalConfig = originalConfig;
2763
2784
  this.configFn = configFn;
2785
+ this.cloneOptions = cloneOptions;
2764
2786
  //#region static
2765
2787
  /**
2766
2788
  * JUST FOR TESTING PURPOSES
@@ -2802,10 +2824,6 @@ class EndpointContext {
2802
2824
  //#region fields / active routes
2803
2825
  this.activeRoutes = [];
2804
2826
  //#endregion
2805
- //#region fields / typeorm repositories
2806
- /* */
2807
- /* */
2808
- //#endregion
2809
2827
  this.skipWritingServerRoutes = false;
2810
2828
  //#region fields / types from contexts
2811
2829
  this.injectableTypesfromContexts = [
@@ -2934,12 +2952,13 @@ class EndpointContext {
2934
2952
  }
2935
2953
  return classes;
2936
2954
  };
2955
+ this.cloneOptions = this.cloneOptions || {};
2937
2956
  this.isRunningInsideDocker = UtilsOs.isRunningInDocker();
2938
2957
  }
2939
2958
  //#endregion
2940
2959
  //#region methods & getters / init
2941
2960
  async init(options) {
2942
- const { initFromRecrusiveContextResovle, overrideHost, overrideRemoteHost, onlyMigrationRun, onlyMigrationRevertToTimestamp, } = options || {}; // TODO use it ?
2961
+ const { initFromRecrusiveContextResovle, onlyMigrationRun, onlyMigrationRevertToTimestamp, } = options || {}; // TODO use it ?
2943
2962
  this.inited = true;
2944
2963
  // @ts-ignore
2945
2964
  this.onlyMigrationRun = onlyMigrationRun;
@@ -2949,31 +2968,23 @@ class EndpointContext {
2949
2968
  if (_.isObject(this.config.database)) {
2950
2969
  this.config.database = Models.DatabaseConfig.from(this.config.database).databaseConfigTypeORM;
2951
2970
  }
2952
- if (overrideHost && overrideRemoteHost) {
2953
- Helpers.throw(`[taon-config] You can't have overrideHost and overrideRemoteHost at the same time`);
2954
- }
2955
- this.config.host = !_.isUndefined(overrideHost)
2956
- ? overrideHost
2957
- : this.config.host;
2958
- this.config.remoteHost = !_.isUndefined(overrideRemoteHost)
2959
- ? overrideRemoteHost
2960
- : this.config.remoteHost;
2961
2971
  this.config.host = this.host === null ? void 0 : this.host;
2962
- this.config.remoteHost =
2963
- this.remoteHost === null ? void 0 : this.remoteHost;
2972
+ if (this.cloneOptions.overrideHost &&
2973
+ !this.cloneOptions.useAsRemoteContext) {
2974
+ this.config.host = this.cloneOptions.overrideHost;
2975
+ }
2976
+ if (this.cloneOptions.overrideRemoteHost &&
2977
+ this.cloneOptions.useAsRemoteContext) {
2978
+ this.config.host = this.cloneOptions.overrideRemoteHost;
2979
+ }
2964
2980
  if (this.config.host &&
2965
2981
  !this.config.host.startsWith('http://') &&
2966
2982
  !this.config.host.startsWith('https://')) {
2967
- Helpers.throw(`[taon-config] Your 'host' must start with http:// or https://`);
2983
+ Helpers.throw(`[taon-config] Your${this.host ? ' remote' : ''} 'host' must start with http:// or https://`);
2968
2984
  }
2969
2985
  if (_.isUndefined(this.config.useIpcWhenElectron)) {
2970
2986
  this.config.useIpcWhenElectron = true;
2971
2987
  }
2972
- if (this.config.remoteHost &&
2973
- !this.config.remoteHost.startsWith('http://') &&
2974
- !this.config.remoteHost.startsWith('https://')) {
2975
- Helpers.throw(`[taon-config] Your 'remoteHost' must start with http:// or https://`);
2976
- }
2977
2988
  // console.log(`config for ${this.contextName}`, this.config);
2978
2989
  //#region resolve if skipping writing server routes
2979
2990
  //@ts-expect-error overriding readonly
@@ -2987,10 +2998,7 @@ class EndpointContext {
2987
2998
  /* */
2988
2999
  /* */
2989
3000
  }
2990
- if (this.config.remoteHost) {
2991
- if (this.config.host) {
2992
- Helpers.throw(`[taon] You can't have remoteHost and host at the same time`);
2993
- }
3001
+ if (this.isRemoteHost) {
2994
3002
  this.mode = 'remote-backend(tcp+udp)';
2995
3003
  }
2996
3004
  // console.log(`
@@ -3011,9 +3019,9 @@ class EndpointContext {
3011
3019
  // console.log(this.config)
3012
3020
  // }
3013
3021
  if (!this.mode && !this.config.abstract) {
3014
- const errMsg = `You need to provide host or remoteHost or ` +
3015
- `useIpcWhenElectron (or mark it as abstract)`;
3016
- Helpers.error(`[taon] Context "${this.contextName}": ${errMsg}`, false, true);
3022
+ const errMsg = `You need to provide host property or ` +
3023
+ `useIpcWhenElectron or mark it as abstract`;
3024
+ Helpers.error(`[taon][Context=${this.contextName}]: ${errMsg}`, false, true);
3017
3025
  /* */
3018
3026
  /* */
3019
3027
  }
@@ -3061,7 +3069,7 @@ class EndpointContext {
3061
3069
  axios.defaults.withCredentials = true;
3062
3070
  }
3063
3071
  //#endregion
3064
- //#region prepare & gather all classes recrusively
3072
+ //#region prepare & gather all classes recursively
3065
3073
  this.config.contexts = this.config.contexts || {};
3066
3074
  this.config.entities = this.config.entities || {};
3067
3075
  this.config.controllers = this.config.controllers || {};
@@ -3198,6 +3206,8 @@ class EndpointContext {
3198
3206
  /* */
3199
3207
  /* */
3200
3208
  /* */
3209
+ this.logRealtime &&
3210
+ Helpers.info(`[ctx=${this.contextName}] Init Realtime for ${this.mode}`);
3201
3211
  this.realtime = new RealtimeCore(this);
3202
3212
  }
3203
3213
  //#endregion
@@ -3209,9 +3219,9 @@ class EndpointContext {
3209
3219
  Helpers.info(`[taon] Create abstract context: ${this.config.contextName}`);
3210
3220
  }
3211
3221
  else {
3212
- if (this.config.remoteHost) {
3222
+ if (this.isRemoteHost) {
3213
3223
  this.logFramework &&
3214
- Helpers.info(`[taon] Create context for remote host: ${this.config.remoteHost}`);
3224
+ Helpers.info(`[taon] Create context for remote host: ${this.config.host}`);
3215
3225
  }
3216
3226
  else {
3217
3227
  this.logFramework &&
@@ -3408,6 +3418,10 @@ class EndpointContext {
3408
3418
  /* */
3409
3419
  /* */
3410
3420
  /* */
3421
+ /* */
3422
+ /* */
3423
+ /* */
3424
+ /* */
3411
3425
  return (void 0);
3412
3426
  }
3413
3427
  //#endregion
@@ -3646,7 +3660,7 @@ class EndpointContext {
3646
3660
  //#endregion
3647
3661
  //#region methods & getters / init classes
3648
3662
  async initClasses() {
3649
- if (this.remoteHost) {
3663
+ if (this.isRemoteHost) {
3650
3664
  return;
3651
3665
  }
3652
3666
  /* */
@@ -3712,11 +3726,7 @@ class EndpointContext {
3712
3726
  return uri;
3713
3727
  }
3714
3728
  get uri() {
3715
- const url = this.host
3716
- ? new URL(this.host)
3717
- : this.remoteHost
3718
- ? new URL(this.remoteHost)
3719
- : void 0;
3729
+ const url = this.host ? new URL(this.host) : void 0;
3720
3730
  return url;
3721
3731
  }
3722
3732
  //#endregion
@@ -3784,11 +3794,50 @@ class EndpointContext {
3784
3794
  }
3785
3795
  //#endregion
3786
3796
  //#region methods & getters / public assets
3797
+ get isRemoteHost() {
3798
+ return !!this.cloneOptions?.useAsRemoteContext;
3799
+ }
3800
+ //#endregion
3801
+ //#region methods & getters / public assets
3787
3802
  /**
3788
3803
  * ipc/udp needs this
3789
3804
  */
3790
3805
  get contextName() {
3791
- return this.config.contextName;
3806
+ // console.log(this.originalConfig);
3807
+ return this.config?.contextName || this.originalConfig?.contextName;
3808
+ }
3809
+ //#endregion
3810
+ //#region methods & getters / public assets
3811
+ /**
3812
+ * ipc/udp needs this
3813
+ */
3814
+ get contextNameForCommunication() {
3815
+ let contextName = this.contextName;
3816
+ if (this.isRemoteHost) {
3817
+ if (this.sourceContext?.contextName) {
3818
+ contextName = this.sourceContext?.contextName;
3819
+ }
3820
+ else {
3821
+ // console.log(
3822
+ // `CANT GET SOURCE CONTEXT NAME FOR REMOTE CONTEXT ${this.contextName}`,
3823
+ // );
3824
+ }
3825
+ }
3826
+ return contextName;
3827
+ }
3828
+ //#endregion
3829
+ //#region methods & getters / public assets
3830
+ /**
3831
+ * Check context type
3832
+ */
3833
+ get contextType() {
3834
+ if (this.config.abstract) {
3835
+ return 'abstract';
3836
+ }
3837
+ if (this.host) {
3838
+ return this.isRemoteHost ? 'remote' : 'normal';
3839
+ }
3840
+ return 'invalid';
3792
3841
  }
3793
3842
  //#endregion
3794
3843
  //#region methods & getters / current working directory
@@ -3816,11 +3865,6 @@ class EndpointContext {
3816
3865
  return this.config.productionMode;
3817
3866
  }
3818
3867
  //#endregion
3819
- //#region methods & getters / remote host
3820
- get remoteHost() {
3821
- return this.config.remoteHost;
3822
- }
3823
- //#endregion
3824
3868
  //#region methods & getters / host
3825
3869
  get host() {
3826
3870
  return this.config.host;
@@ -4035,12 +4079,13 @@ class EndpointContext {
4035
4079
  return bc.className;
4036
4080
  })
4037
4081
  .join('/');
4082
+ const contextNameForCommunication = this.contextNameForCommunication;
4038
4083
  if (TaonHelpers.isGoodPath(classConfig.path)) {
4039
4084
  classConfig.calculatedPath = classConfig.path;
4040
4085
  }
4041
4086
  else {
4042
4087
  classConfig.calculatedPath = (`${this.uriPathnameOrNothingIfRoot}` +
4043
- `/${apiPrefix}/${this.contextName}/tcp${parentsCalculatedPath}/` +
4088
+ `/${apiPrefix}/${contextNameForCommunication}/tcp${parentsCalculatedPath}/` +
4044
4089
  `${ClassHelpers.getName(controllerClassFn)}`)
4045
4090
  .replace(/\/\//g, '/')
4046
4091
  .split('/')
@@ -4070,7 +4115,7 @@ class EndpointContext {
4070
4115
  });
4071
4116
  }
4072
4117
  //#endregion
4073
- async initControllersHook(allInitedEndpointContexts) {
4118
+ async initControllersHook(ctxStorage) {
4074
4119
  if (this.isRunOrRevertOnlyMigrationAppStart) {
4075
4120
  return;
4076
4121
  }
@@ -4078,7 +4123,7 @@ class EndpointContext {
4078
4123
  for (const controllerClassFn of allControllers) {
4079
4124
  const instance = this.getInstanceBy(controllerClassFn);
4080
4125
  if (_.isFunction(instance.afterAllCtxInited)) {
4081
- await instance.afterAllCtxInited(allInitedEndpointContexts);
4126
+ await instance.afterAllCtxInited({ ctxStorage });
4082
4127
  }
4083
4128
  }
4084
4129
  }
@@ -4183,7 +4228,7 @@ class EndpointContext {
4183
4228
  }
4184
4229
  //#endregion
4185
4230
  //#region init client
4186
- const shouldInitClient = Helpers.isBrowser || this.remoteHost || Helpers.isWebSQL;
4231
+ const shouldInitClient = Helpers.isBrowser || this.isRemoteHost || Helpers.isWebSQL;
4187
4232
  // console.log('shouldInitClient', shouldInitClient);
4188
4233
  if (shouldInitClient) {
4189
4234
  // console.log(
@@ -4210,7 +4255,7 @@ class EndpointContext {
4210
4255
  //#endregion
4211
4256
  //#region methods & getters / write active routes
4212
4257
  writeActiveRoutes() {
4213
- if (this.remoteHost ||
4258
+ if (this.isRemoteHost ||
4214
4259
  this.isRunOrRevertOnlyMigrationAppStart ||
4215
4260
  this.skipWritingServerRoutes) {
4216
4261
  return;
@@ -4499,7 +4544,7 @@ class EndpointContext {
4499
4544
  /* */
4500
4545
  /* */
4501
4546
  }
4502
- if (!this.remoteHost) {
4547
+ if (!this.isRemoteHost) {
4503
4548
  //#region apply dummy websql express routers
4504
4549
  /* */
4505
4550
  /* */
@@ -5172,6 +5217,34 @@ class TaonAdminService {
5172
5217
  logout() { }
5173
5218
  }
5174
5219
 
5220
+ class ContextsEndpointStorage {
5221
+ constructor() {
5222
+ this.taonEndpointContexts = new Map();
5223
+ // Private constructor to prevent direct instantiation
5224
+ }
5225
+ static get Instance() {
5226
+ if (!ContextsEndpointStorage.instance) {
5227
+ ContextsEndpointStorage.instance = new ContextsEndpointStorage();
5228
+ }
5229
+ return ContextsEndpointStorage.instance;
5230
+ }
5231
+ //#endregion
5232
+ set(context) {
5233
+ if (!this.taonEndpointContexts.has(context.contextName)) {
5234
+ this.taonEndpointContexts.set(context.contextName, context);
5235
+ }
5236
+ }
5237
+ get arr() {
5238
+ return Array.from(this.taonEndpointContexts.values()).filter(f => f.contextType === 'normal');
5239
+ }
5240
+ getBy(context) {
5241
+ if (typeof context === 'string') {
5242
+ return this.taonEndpointContexts.get(context);
5243
+ }
5244
+ return this.taonEndpointContexts.get(context.contextName);
5245
+ }
5246
+ }
5247
+
5175
5248
  //#region imports
5176
5249
  //#endregion
5177
5250
  /**
@@ -5188,14 +5261,15 @@ const createContextTemplate = (configFn) => {
5188
5261
  * REQURIED PROPERTY:
5189
5262
  * - contextName
5190
5263
  */
5191
- const createContext = (configFn) => {
5264
+ const createContextFn = (configFn, cloneOptions) => {
5265
+ cloneOptions = cloneOptions || {};
5192
5266
  let config = configFn({});
5193
5267
  // console.log(
5194
5268
  // `
5195
5269
  // [Taon] Creating context ${config.contextName}...`,
5196
5270
  // {config},
5197
5271
  // );
5198
- const endpointContextRef = new EndpointContext(config, configFn);
5272
+ const endpointContextRef = new EndpointContext(config, configFn, cloneOptions);
5199
5273
  const res = {
5200
5274
  //#region contexts
5201
5275
  get contextName() {
@@ -5205,6 +5279,24 @@ const createContext = (configFn) => {
5205
5279
  get appId() {
5206
5280
  return config.appId;
5207
5281
  },
5282
+ cloneAsRemote: (cloneOpt) => {
5283
+ cloneOpt = cloneOpt || {};
5284
+ const opt = {
5285
+ ...cloneOpt,
5286
+ sourceContext: endpointContextRef,
5287
+ useAsRemoteContext: true,
5288
+ };
5289
+ return createContextFn(configFn, opt);
5290
+ },
5291
+ cloneAsNormal: (cloneOpt) => {
5292
+ cloneOpt = cloneOpt || {};
5293
+ const opt = {
5294
+ ...cloneOpt,
5295
+ sourceContext: endpointContextRef,
5296
+ useAsRemoteContext: false,
5297
+ };
5298
+ return createContextFn(configFn, opt);
5299
+ },
5208
5300
  //#region context
5209
5301
  /**
5210
5302
  * @deprecated
@@ -5317,19 +5409,23 @@ const createContext = (configFn) => {
5317
5409
  //#endregion
5318
5410
  //#region run migrations tasks
5319
5411
  if (endpointContextRef.onlyMigrationRun) {
5320
- Helpers.log(`[taon] Running only migrations (context=${endpointContextRef.contextName}).`);
5412
+ endpointContextRef.logMigrations &&
5413
+ Helpers.log(`[taon] Running only migrations (context=${endpointContextRef.contextName}).`);
5321
5414
  await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
5322
5415
  }
5323
5416
  else if (endpointContextRef.onlyMigrationRevertToTimestamp) {
5324
- Helpers.log(`[taon] Reverting migrations to timestamp ${endpointContextRef.onlyMigrationRevertToTimestamp} (context=${endpointContextRef.contextName}).`);
5417
+ endpointContextRef.logMigrations &&
5418
+ Helpers.log(`[taon] Reverting migrations to timestamp ${endpointContextRef.onlyMigrationRevertToTimestamp} (context=${endpointContextRef.contextName}).`);
5325
5419
  await endpointContextRef.dbMigrations.revertMigrationToTimestamp(endpointContextRef.onlyMigrationRevertToTimestamp);
5326
5420
  }
5327
5421
  else {
5328
- Helpers.log(`[taon] Running all not applied migrations (context=${endpointContextRef.contextName}).`);
5422
+ endpointContextRef.logMigrations &&
5423
+ Helpers.log(`[taon] Running all not applied migrations (context=${endpointContextRef.contextName}).`);
5329
5424
  await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
5330
5425
  }
5331
5426
  //#endregion
5332
5427
  }
5428
+ ContextsEndpointStorage.Instance.set(endpointContextRef);
5333
5429
  resolve(endpointContextRef);
5334
5430
  });
5335
5431
  //#endregion
@@ -5352,6 +5448,12 @@ const createContext = (configFn) => {
5352
5448
  };
5353
5449
  return res;
5354
5450
  };
5451
+ //#endregion
5452
+ const createContext = (configFn) => {
5453
+ return createContextFn(configFn, { useAsRemoteContext: false });
5454
+ };
5455
+ // const AA = createContext(() => ({ contextName: 'aa' }));
5456
+ // const BB = AA.cloneAsRemoteContext();
5355
5457
 
5356
5458
  /**
5357
5459
  * Provider decorator
@@ -6405,14 +6507,12 @@ function Body(name) {
6405
6507
  };
6406
6508
  }
6407
6509
 
6408
- /* */
6409
- /* */
6410
6510
  let BaseController = class BaseController extends BaseInjector {
6411
6511
  /**
6412
6512
  * Hook that is called when taon app is inited
6413
6513
  * (all contexts are created and inited)
6414
6514
  */
6415
- async afterAllCtxInited(allContexts) { }
6515
+ async afterAllCtxInited(options) { }
6416
6516
  //#region upload form data to server
6417
6517
  uploadFormDataToServer(formData) {
6418
6518
  /* */
@@ -7092,5 +7192,5 @@ var Taon;
7092
7192
  * Generated bundle index. Do not edit.
7093
7193
  */
7094
7194
 
7095
- 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 };
7195
+ 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 };
7096
7196
  //# sourceMappingURL=taon.mjs.map