taon 19.0.60 → 19.0.62

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 (142) hide show
  1. package/README.md +160 -160
  2. package/bin/start.js +281 -279
  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 +82 -24
  8. package/browser/fesm2022/taon.mjs.map +1 -1
  9. package/browser/lib/base-classes/base-context.d.ts +1 -6
  10. package/browser/lib/base-classes/base-controller.d.ts +18 -2
  11. package/browser/lib/base-classes/base-repository.d.ts +1 -1
  12. package/browser/lib/base-classes/base.d.ts +1 -6
  13. package/browser/lib/create-context.d.ts +2 -12
  14. package/browser/lib/endpoint-context.d.ts +3 -0
  15. package/browser/lib/index.d.ts +5 -18
  16. package/browser/lib/models.d.ts +6 -0
  17. package/browser/lib/realtime/realtime-client.d.ts +2 -2
  18. package/browser/package.json +1 -1
  19. package/icon-menu-taon.svg +15 -15
  20. package/lib/base-classes/base-context.d.ts +1 -6
  21. package/lib/base-classes/base-controller.d.ts +18 -2
  22. package/lib/base-classes/base-controller.js +25 -5
  23. package/lib/base-classes/base-controller.js.map +1 -1
  24. package/lib/base-classes/base-repository.d.ts +1 -1
  25. package/lib/base-classes/base-repository.js +12 -6
  26. package/lib/base-classes/base-repository.js.map +1 -1
  27. package/lib/base-classes/base.d.ts +1 -6
  28. package/lib/build-info._auto-generated_.d.ts +1 -1
  29. package/lib/build-info._auto-generated_.js +1 -1
  30. package/lib/create-context.d.ts +2 -12
  31. package/lib/create-context.js +21 -11
  32. package/lib/create-context.js.map +1 -1
  33. package/lib/decorators/classes/controller-config.d.ts +0 -11
  34. package/lib/decorators/classes/controller-config.js +0 -10
  35. package/lib/decorators/classes/controller-config.js.map +1 -1
  36. package/lib/decorators/classes/controller-options.d.ts +0 -5
  37. package/lib/decorators/classes/controller-options.js +0 -4
  38. package/lib/decorators/classes/controller-options.js.map +1 -1
  39. package/lib/endpoint-context.d.ts +3 -0
  40. package/lib/endpoint-context.js +24 -6
  41. package/lib/endpoint-context.js.map +1 -1
  42. package/lib/env/env.angular-node-app.d.ts +2 -0
  43. package/lib/env/env.angular-node-app.js +4 -2
  44. package/lib/env/env.angular-node-app.js.map +1 -1
  45. package/lib/env/env.docs-webapp.d.ts +2 -0
  46. package/lib/env/env.docs-webapp.js +4 -2
  47. package/lib/env/env.docs-webapp.js.map +1 -1
  48. package/lib/env/env.electron-app.d.ts +2 -0
  49. package/lib/env/env.electron-app.js +4 -2
  50. package/lib/env/env.electron-app.js.map +1 -1
  51. package/lib/env/env.mobile-app.d.ts +2 -0
  52. package/lib/env/env.mobile-app.js +4 -2
  53. package/lib/env/env.mobile-app.js.map +1 -1
  54. package/lib/env/env.npm-lib-and-cli-tool.d.ts +2 -0
  55. package/lib/env/env.npm-lib-and-cli-tool.js +4 -2
  56. package/lib/env/env.npm-lib-and-cli-tool.js.map +1 -1
  57. package/lib/env/env.vscode-plugin.d.ts +2 -0
  58. package/lib/env/env.vscode-plugin.js +4 -2
  59. package/lib/env/env.vscode-plugin.js.map +1 -1
  60. package/lib/env.d.ts +2 -0
  61. package/lib/env.js +7 -0
  62. package/lib/env.js.map +1 -0
  63. package/lib/index.d.ts +5 -18
  64. package/lib/index.js +3 -1
  65. package/lib/index.js.map +1 -1
  66. package/lib/models.d.ts +6 -0
  67. package/lib/models.js.map +1 -1
  68. package/lib/realtime/realtime-client.d.ts +2 -2
  69. package/lib/realtime/realtime-client.js +14 -7
  70. package/lib/realtime/realtime-client.js.map +1 -1
  71. package/lib/realtime/realtime-server.js +17 -14
  72. package/lib/realtime/realtime-server.js.map +1 -1
  73. package/lib/storage.d.ts +1 -0
  74. package/lib/storage.js +6 -0
  75. package/lib/storage.js.map +1 -0
  76. package/lib/ui/directives/index.d.ts +3 -0
  77. package/lib/ui/directives/index.js +5 -0
  78. package/lib/ui/directives/index.js.map +1 -0
  79. package/lib/ui/directives/safe.pipe.d.ts +7 -0
  80. package/lib/ui/directives/taon-inject-html.directive.d.ts +6 -0
  81. package/lib/ui/directives/taon-long-press.directive.d.ts +22 -0
  82. package/lib/ui/directives/view-mode.d.ts +5 -0
  83. package/lib/ui/directives/view-mode.js +10 -0
  84. package/lib/ui/directives/view-mode.js.map +1 -0
  85. package/lib/ui/index.js +2 -2
  86. package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
  87. package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +43 -0
  88. package/lib/ui/taon-admin-mode-configuration/taon-admin.models.d.ts +5 -0
  89. package/lib/ui/taon-admin-mode-configuration/taon-admin.models.js +3 -0
  90. package/lib/ui/taon-admin-mode-configuration/taon-admin.models.js.map +1 -0
  91. package/lib/ui/taon-full-material.module.d.ts +5 -0
  92. package/lib/ui/taon-github-fork-me-corner/index.d.ts +2 -0
  93. package/lib/ui/taon-github-fork-me-corner/index.js +5 -0
  94. package/lib/ui/taon-github-fork-me-corner/index.js.map +1 -0
  95. package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.component.d.ts +3 -0
  96. package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.module.d.ts +2 -0
  97. package/lib/ui/taon-github-fork-me-ribbon/index.d.ts +2 -0
  98. package/lib/ui/taon-github-fork-me-ribbon/index.js +5 -0
  99. package/lib/ui/taon-github-fork-me-ribbon/index.js.map +1 -0
  100. package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.component.d.ts +3 -0
  101. package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.module.d.ts +2 -0
  102. package/lib/ui/taon-notifications/index.d.ts +4 -0
  103. package/lib/ui/taon-notifications/index.js +24 -0
  104. package/lib/ui/taon-notifications/index.js.map +1 -0
  105. package/lib/ui/taon-notifications/taon-notifications.component.d.ts +9 -0
  106. package/lib/ui/taon-notifications/taon-notifications.models.d.ts +6 -0
  107. package/lib/ui/taon-notifications/taon-notifications.models.js +5 -0
  108. package/lib/ui/taon-notifications/taon-notifications.models.js.map +1 -0
  109. package/lib/ui/taon-notifications/taon-notifications.module.d.ts +2 -0
  110. package/lib/ui/taon-notifications/taon-notifications.service.d.ts +11 -0
  111. package/lib/ui/taon-progress-bar/index.d.ts +2 -0
  112. package/lib/ui/taon-progress-bar/index.js +5 -0
  113. package/lib/ui/taon-progress-bar/index.js.map +1 -0
  114. package/lib/ui/taon-progress-bar/taon-progress-bar.component.d.ts +13 -0
  115. package/lib/ui/taon-progress-bar/taon-progress-bar.module.d.ts +2 -0
  116. package/lib/ui/taon-session-passcode/index.d.ts +1 -0
  117. package/lib/ui/taon-session-passcode/index.js +5 -0
  118. package/lib/ui/taon-session-passcode/index.js.map +1 -0
  119. package/lib/ui/taon-session-passcode/taon-session-passcode.component.d.ts +35 -0
  120. package/lib/ui/taon-table/index.d.ts +2 -0
  121. package/lib/ui/taon-table/index.js +5 -0
  122. package/lib/ui/taon-table/index.js.map +1 -0
  123. package/lib/ui/taon-table/taon-table.component.d.ts +34 -0
  124. package/lib/ui/taon-table/taon-table.module.d.ts +2 -0
  125. package/lib/ui/taon.models.d.ts +11 -0
  126. package/lib/ui/taon.models.js +3 -0
  127. package/lib/ui/taon.models.js.map +1 -0
  128. package/package.json +1 -1
  129. package/tmp-environment.json +39 -0
  130. package/websql/README.md +24 -24
  131. package/websql/fesm2022/taon.mjs +76 -20
  132. package/websql/fesm2022/taon.mjs.map +1 -1
  133. package/websql/lib/base-classes/base-context.d.ts +1 -6
  134. package/websql/lib/base-classes/base-controller.d.ts +18 -2
  135. package/websql/lib/base-classes/base-repository.d.ts +1 -1
  136. package/websql/lib/base-classes/base.d.ts +1 -6
  137. package/websql/lib/create-context.d.ts +2 -12
  138. package/websql/lib/endpoint-context.d.ts +3 -0
  139. package/websql/lib/index.d.ts +5 -18
  140. package/websql/lib/models.d.ts +6 -0
  141. package/websql/lib/realtime/realtime-client.d.ts +2 -2
  142. package/websql/package.json +1 -1
@@ -1554,9 +1554,7 @@ class RealtimeClient {
1554
1554
  this.subsManagers = {};
1555
1555
  this.core = core;
1556
1556
  if (!core.ctx.disabledRealtime) {
1557
- //#region @browser
1558
1557
  this.init();
1559
- //#endregion
1560
1558
  }
1561
1559
  }
1562
1560
  //#region methods & getters / init
@@ -1570,12 +1568,13 @@ class RealtimeClient {
1570
1568
  if (this.core.ctx.config.frontendHost &&
1571
1569
  this.core.ctx.config.frontendHost !== '' &&
1572
1570
  this.core.ctx.isRunningInsideDocker) {
1573
- console.log(`[${this.core.ctx.contextName}] USING FRONTEND HOST ${this.core.ctx.config.frontendHost}`);
1571
+ Helpers.logInfo(`[${this.core.ctx.contextName}] USING FRONTEND HOST` +
1572
+ ` ${this.core.ctx.config.frontendHost} FOR REALTIME`);
1574
1573
  nspPath.global = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.global.pathname}`);
1575
1574
  nspPath.realtime = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.realtime.pathname}`);
1576
1575
  }
1577
1576
  else {
1578
- console.log(`[${this.core.ctx.contextName}] NOT USING FRONTEND HOST`);
1577
+ Helpers.logInfo(`[${this.core.ctx.contextName}] Not using frontend host for realtime`);
1579
1578
  }
1580
1579
  this.core.ctx.logRealtime &&
1581
1580
  console.info('[CLIENT] NAMESPACE GLOBAL ', nspPath.global.href + ` host: ${this.core.ctx.host}`);
@@ -1720,7 +1719,13 @@ to use socket realtime connection;
1720
1719
  //#endregion
1721
1720
  //#region methods & getters / get room id from
1722
1721
  getUniqueIdentifierForConnection(options) {
1723
- const url = new URL(options.core.ctx.host);
1722
+ let url;
1723
+ if (UtilsOs.isBrowser) {
1724
+ url = new URL(options.core.ctx.host);
1725
+ }
1726
+ else {
1727
+ url = new URL(options.core.ctx.remoteHost); // backend-to-backend use remote host
1728
+ }
1724
1729
  return `${this.core.ctx.contextName}:${url.origin}|${options.roomName}|${options.property}|${options.customEvent}`;
1725
1730
  }
1726
1731
  }
@@ -1741,7 +1746,7 @@ class RealtimeServer {
1741
1746
  }
1742
1747
  //#region methods & getters / init
1743
1748
  init() {
1744
- //#region @websql
1749
+ //#region @browser
1745
1750
  if (!this.core.ctx.config.frontendHost) {
1746
1751
  console.warn(`[Taon][Realtime]
1747
1752
 
@@ -1752,6 +1757,8 @@ class RealtimeServer {
1752
1757
 
1753
1758
  `);
1754
1759
  }
1760
+ //#endregion
1761
+ //#region @websql
1755
1762
  //#region prepare namespaces pathes
1756
1763
  const nspPathGlobal = this.core.pathFor();
1757
1764
  const nspPathRealtime = this.core.pathFor(Symbols.REALTIME.NAMESPACE(this.core.ctx.contextName));
@@ -1773,8 +1780,9 @@ class RealtimeServer {
1773
1780
  console.info(`[backend] CREATE GLOBAL NAMESPACE: '${this.core.connectSocketBE.path()}'` +
1774
1781
  ` , path: '${nspPathGlobal.pathname}'`);
1775
1782
  this.core.connectSocketBE.on('connection', clientSocket => {
1776
- console.info(`[backend] client connected to namespace "${nspPathGlobal.pathname}", ` +
1777
- ` host: ${this.core.ctx.host}`);
1783
+ this.core.ctx.logRealtime &&
1784
+ console.info(`[backend] client connected to namespace "${nspPathGlobal.pathname}", ` +
1785
+ ` host: ${this.core.ctx.host}`);
1778
1786
  });
1779
1787
  //#endregion
1780
1788
  //#region prepare realtime BE socket
@@ -1789,8 +1797,9 @@ class RealtimeServer {
1789
1797
  console.info(`[backend] CREATE REALTIME NAMESPACE: '${this.core.socketBE.path()}'` +
1790
1798
  ` , path: '${nspPathRealtime.pathname}' `);
1791
1799
  this.core.socketBE.on('connection', backendSocketForClient => {
1792
- console.info(`[backend] client connected to namespace "${nspPathRealtime.pathname}", ` +
1793
- ` host: ${this.core.ctx.host}`);
1800
+ this.core.ctx.logRealtime &&
1801
+ console.info(`[backend] client connected to namespace "${nspPathRealtime.pathname}", ` +
1802
+ ` host: ${this.core.ctx.host}`);
1794
1803
  backendSocketForClient.on(Symbols.REALTIME.ROOM_SUBSCRIBE_CUSTOM(this.core.ctx.contextName), roomName => {
1795
1804
  this.core.ctx.logRealtime &&
1796
1805
  console.info(`Joining room ${roomName} in namespace REALTIME` +
@@ -2919,6 +2928,7 @@ class EndpointContext {
2919
2928
  !this.config.remoteHost.startsWith('https://')) {
2920
2929
  Helpers.throw(`[taon-config] Your 'remoteHost' must start with http:// or https://`);
2921
2930
  }
2931
+ // console.log(`config for ${this.contextName}`, this.config);
2922
2932
  //#region resolve if skipping writing server routes
2923
2933
  //@ts-expect-error overriding readonly
2924
2934
  this.skipWritingServerRoutes = _.isBoolean(this.config.skipWritingServerRoutes)
@@ -2956,7 +2966,9 @@ class EndpointContext {
2956
2966
  // console.log(this.config)
2957
2967
  // }
2958
2968
  if (!this.mode && !this.config.abstract) {
2959
- Helpers.error(`[taon] Context "${this.contextName}": You need to provide host or remoteHost or useIpcWhenElectron`, false, true);
2969
+ const errMsg = `You need to provide host or remoteHost or ` +
2970
+ `useIpcWhenElectron (or mark it as abstract)`;
2971
+ Helpers.error(`[taon] Context "${this.contextName}": ${errMsg}`, false, true);
2960
2972
  /* */
2961
2973
  /* */
2962
2974
  }
@@ -3132,7 +3144,10 @@ class EndpointContext {
3132
3144
  //#endregion
3133
3145
  //#region prepare realtime
3134
3146
  if (!this.config.abstract) {
3135
- this.disabledRealtime = !!this.config.disabledRealtime;
3147
+ this.disabledRealtime = this.config.disabledRealtime;
3148
+ /* */
3149
+ /* */
3150
+ /* */
3136
3151
  /* */
3137
3152
  /* */
3138
3153
  /* */
@@ -3964,6 +3979,18 @@ class EndpointContext {
3964
3979
  });
3965
3980
  }
3966
3981
  //#endregion
3982
+ async initControllersHook(allInitedEndpointContexts) {
3983
+ if (this.isRunOrRevertOnlyMigrationAppStart) {
3984
+ return;
3985
+ }
3986
+ const allControllers = this.getClassFunByArr(Models.ClassType.CONTROLLER);
3987
+ for (const controllerClassFn of allControllers) {
3988
+ const instance = this.getInstanceBy(controllerClassFn);
3989
+ if (_.isFunction(instance.afterAllCtxInited)) {
3990
+ await instance.afterAllCtxInited(allInitedEndpointContexts);
3991
+ }
3992
+ }
3993
+ }
3967
3994
  async initControllers() {
3968
3995
  if (this.isRunOrRevertOnlyMigrationAppStart) {
3969
3996
  return;
@@ -5085,21 +5112,22 @@ const createContext = (configFn) => {
5085
5112
  //#endregion
5086
5113
  await endpointContextRef.initClasses();
5087
5114
  if (endpointContextRef.databaseConfig) {
5088
- let keepWebsqlDbDataAfterReload = false;
5115
+ //#region handle websql reload data
5089
5116
  //#region @browser
5117
+ let keepWebsqlDbDataAfterReload = false;
5090
5118
  keepWebsqlDbDataAfterReload =
5091
5119
  TaonAdminService.Instance?.keepWebsqlDbDataAfterReload;
5092
- //#endregion
5093
- if (!Helpers.isNode && keepWebsqlDbDataAfterReload) {
5120
+ if (keepWebsqlDbDataAfterReload) {
5094
5121
  !UtilsOs.isRunningInCliMode() &&
5095
5122
  Helpers.info(`[taon] Keeping websql data after reload ` +
5096
5123
  `(context=${endpointContextRef.contextName}).`);
5097
5124
  }
5098
5125
  else {
5099
- !UtilsOs.isRunningInCliMode() &&
5100
- Helpers.info(`[taon] Dropping all tables and data ` +
5101
- `(context=${endpointContextRef.contextName}).`);
5126
+ Helpers.info(`[taon] Dropping all tables and data ` +
5127
+ `(context=${endpointContextRef.contextName}).`);
5102
5128
  }
5129
+ //#endregion
5130
+ //#endregion
5103
5131
  //#region TODO this may be usefull but for now
5104
5132
  // 2 separate contexts are fine
5105
5133
  // const shouldStartRemoteHost = endpointContextRef.mode !== 'remote-backend(tcp+udp)';
@@ -5113,15 +5141,20 @@ const createContext = (configFn) => {
5113
5141
  // endpointContextRef.__contextForControllerInstanceAccess = endpointContextRemoteHostRef;
5114
5142
  // }
5115
5143
  //#endregion
5144
+ //#region run migrations tasks
5116
5145
  if (endpointContextRef.onlyMigrationRun) {
5146
+ Helpers.log(`[taon] Running only migrations (context=${endpointContextRef.contextName}).`);
5117
5147
  await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
5118
5148
  }
5119
5149
  else if (endpointContextRef.onlyMigrationRevertToTimestamp) {
5150
+ Helpers.log(`[taon] Reverting migrations to timestamp ${endpointContextRef.onlyMigrationRevertToTimestamp} (context=${endpointContextRef.contextName}).`);
5120
5151
  await endpointContextRef.dbMigrations.revertMigrationToTimestamp(endpointContextRef.onlyMigrationRevertToTimestamp);
5121
5152
  }
5122
5153
  else {
5154
+ Helpers.log(`[taon] Running all not applied migrations (context=${endpointContextRef.contextName}).`);
5123
5155
  await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
5124
5156
  }
5157
+ //#endregion
5125
5158
  }
5126
5159
  resolve(endpointContextRef);
5127
5160
  });
@@ -5641,6 +5674,11 @@ let BaseRepository = class BaseRepository extends BaseCustomRepository {
5641
5674
  const deletedEntity = await this.repo.findOne({
5642
5675
  where: { id: idOrEntity },
5643
5676
  });
5677
+ if (!deletedEntity) {
5678
+ Helpers.warn(`[BaseRepository] Entity "${ClassHelpers.getName(this.repo.target)}" ` +
5679
+ `with id ${idOrEntity} not found, cannot remove`);
5680
+ return;
5681
+ }
5644
5682
  const idCopy = deletedEntity.id;
5645
5683
  await this.repo.remove(deletedEntity);
5646
5684
  deletedEntity.id = idCopy;
@@ -6167,6 +6205,11 @@ function Body(name) {
6167
6205
  /* */
6168
6206
  /* */
6169
6207
  let BaseController = class BaseController extends BaseInjector {
6208
+ /**
6209
+ * Hook that is called when taon app is inited
6210
+ * (all contexts are created and inited)
6211
+ */
6212
+ async afterAllCtxInited(allContexts) { }
6170
6213
  //#region upload form data to server
6171
6214
  uploadFormDataToServer(formData) {
6172
6215
  /* */
@@ -6190,11 +6233,24 @@ let BaseController = class BaseController extends BaseInjector {
6190
6233
  /* */
6191
6234
  /* */
6192
6235
  /* */
6236
+ /* */
6237
+ /* */
6238
+ /* */
6239
+ /* */
6240
+ /* */
6193
6241
  return (void 0);
6194
6242
  }
6195
6243
  //#endregion
6244
+ //#region after file upload hook
6245
+ /**
6246
+ * Hook after file is uploaded
6247
+ * through `uploadFormDataToServer` or `uploadLocalFileToServer`
6248
+ */
6249
+ afterFileUploadAction(file) {
6250
+ // empty
6251
+ }
6196
6252
  //#region upload local file to server
6197
- async uploadLocalFileToServer(absFilePath) {
6253
+ async uploadLocalFileToServer(absFilePath, options) {
6198
6254
  /* */
6199
6255
  /* */
6200
6256
  /* */
@@ -6827,5 +6883,5 @@ var Taon;
6827
6883
  * Generated bundle index. Do not edit.
6828
6884
  */
6829
6885
 
6830
- export { BaseContext, BaseController, BaseCustomRepository, BaseEntity, BaseMigration, BaseProvider, BaseRepository, CURRENT_HOST_BACKEND_PORT, CURRENT_HOST_URL, ClassHelpers, EndpointContext, Models, TAON_CONTEXT, Taon, TaonAdminService, TaonEntityKeysToOmitArr, apiPrefix, createContext, inject };
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 };
6831
6887
  //# sourceMappingURL=taon.mjs.map