taon 19.0.50 → 19.0.52

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 (204) hide show
  1. package/browser/fesm2022/taon.mjs +167 -77
  2. package/browser/fesm2022/taon.mjs.map +1 -1
  3. package/browser/lib/base-classes/base-context.d.ts +1 -0
  4. package/browser/lib/base-classes/base-controller.d.ts +0 -6
  5. package/browser/lib/base-classes/base-injector.d.ts +4 -5
  6. package/browser/lib/base-classes/base-middleware.d.ts +17 -0
  7. package/browser/lib/base-classes/base.d.ts +3 -0
  8. package/browser/lib/constants.d.ts +1 -1
  9. package/browser/lib/create-context.d.ts +4 -2
  10. package/browser/lib/decorators/classes/middleware-decorator.d.ts +8 -0
  11. package/browser/lib/endpoint-context.d.ts +6 -5
  12. package/browser/lib/index.d.ts +8 -2
  13. package/browser/lib/models.d.ts +65 -5
  14. package/browser/package.json +1 -1
  15. package/lib/base-classes/base-context.d.ts +1 -0
  16. package/lib/base-classes/base-controller.d.ts +0 -6
  17. package/lib/base-classes/base-controller.js +0 -8
  18. package/lib/base-classes/base-controller.js.map +1 -1
  19. package/lib/base-classes/base-injector.d.ts +4 -5
  20. package/lib/base-classes/base-injector.js +6 -7
  21. package/lib/base-classes/base-injector.js.map +1 -1
  22. package/lib/base-classes/base-middleware.d.ts +20 -0
  23. package/lib/base-classes/base-middleware.js +13 -0
  24. package/lib/base-classes/base-middleware.js.map +1 -0
  25. package/lib/base-classes/base.d.ts +3 -0
  26. package/lib/base-classes/base.js +2 -0
  27. package/lib/base-classes/base.js.map +1 -1
  28. package/lib/build-info._auto-generated_.d.ts +1 -1
  29. package/lib/build-info._auto-generated_.js +1 -1
  30. package/lib/constants.d.ts +1 -1
  31. package/lib/constants.js +2 -3
  32. package/lib/constants.js.map +1 -1
  33. package/lib/create-context.d.ts +4 -2
  34. package/lib/create-context.js +40 -36
  35. package/lib/create-context.js.map +1 -1
  36. package/lib/decorators/classes/middleware-decorator.d.ts +7 -0
  37. package/lib/decorators/classes/middleware-decorator.js +21 -0
  38. package/lib/decorators/classes/middleware-decorator.js.map +1 -0
  39. package/lib/decorators/classes/provider-decorator.js +1 -1
  40. package/lib/decorators/classes/provider-decorator.js.map +1 -1
  41. package/lib/endpoint-context.d.ts +6 -5
  42. package/lib/endpoint-context.js +79 -29
  43. package/lib/endpoint-context.js.map +1 -1
  44. package/lib/env/env.angular-node-app.d.ts +1 -0
  45. package/lib/env/env.angular-node-app.js +3 -2
  46. package/lib/env/env.angular-node-app.js.map +1 -1
  47. package/lib/env/env.docs-webapp.d.ts +1 -0
  48. package/lib/env/env.docs-webapp.js +3 -2
  49. package/lib/env/env.docs-webapp.js.map +1 -1
  50. package/lib/env/env.electron-app.d.ts +1 -0
  51. package/lib/env/env.electron-app.js +3 -2
  52. package/lib/env/env.electron-app.js.map +1 -1
  53. package/lib/env/env.mobile-app.d.ts +1 -0
  54. package/lib/env/env.mobile-app.js +3 -2
  55. package/lib/env/env.mobile-app.js.map +1 -1
  56. package/lib/env/env.npm-lib-and-cli-tool.d.ts +1 -0
  57. package/lib/env/env.npm-lib-and-cli-tool.js +3 -2
  58. package/lib/env/env.npm-lib-and-cli-tool.js.map +1 -1
  59. package/lib/env/env.vscode-plugin.d.ts +1 -0
  60. package/lib/env/env.vscode-plugin.js +3 -2
  61. package/lib/env/env.vscode-plugin.js.map +1 -1
  62. package/lib/env.js +1 -5
  63. package/lib/env.js.map +1 -1
  64. package/lib/index.d.ts +8 -2
  65. package/lib/index.js +2 -0
  66. package/lib/index.js.map +1 -1
  67. package/lib/models.d.ts +65 -5
  68. package/lib/models.js +7 -5
  69. package/lib/models.js.map +1 -1
  70. package/lib/storage.d.ts +1 -1
  71. package/lib/storage.js +1 -5
  72. package/lib/storage.js.map +1 -1
  73. package/lib/ui/index.js +2 -2
  74. package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
  75. package/package.json +1 -1
  76. package/websql/fesm2022/taon.mjs +168 -78
  77. package/websql/fesm2022/taon.mjs.map +1 -1
  78. package/websql/lib/base-classes/base-context.d.ts +1 -0
  79. package/websql/lib/base-classes/base-controller.d.ts +0 -6
  80. package/websql/lib/base-classes/base-injector.d.ts +4 -5
  81. package/websql/lib/base-classes/base-middleware.d.ts +21 -0
  82. package/websql/lib/base-classes/base.d.ts +3 -0
  83. package/websql/lib/constants.d.ts +1 -1
  84. package/websql/lib/create-context.d.ts +4 -2
  85. package/websql/lib/decorators/classes/middleware-decorator.d.ts +8 -0
  86. package/websql/lib/endpoint-context.d.ts +6 -5
  87. package/websql/lib/index.d.ts +8 -2
  88. package/websql/lib/models.d.ts +65 -5
  89. package/websql/package.json +1 -1
  90. package/lib/base-classes/base-subscriber.d.ts +0 -4
  91. package/lib/base-classes/base-subscriber.js +0 -25
  92. package/lib/base-classes/base-subscriber.js.map +0 -1
  93. package/lib/realtime/realtime-strategy/realtime-abstract-mock.d.ts +0 -10
  94. package/lib/realtime/realtime-strategy/realtime-abstract-mock.js +0 -214
  95. package/lib/realtime/realtime-strategy/realtime-abstract-mock.js.map +0 -1
  96. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.d.ts +0 -0
  97. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.js +0 -5
  98. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.js.map +0 -1
  99. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.d.ts +0 -22
  100. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.js +0 -139
  101. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.js.map +0 -1
  102. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.d.ts +0 -16
  103. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.js +0 -68
  104. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.js.map +0 -1
  105. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.d.ts +0 -10
  106. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.js +0 -56
  107. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.js.map +0 -1
  108. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.d.ts +0 -10
  109. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.js +0 -50
  110. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.js.map +0 -1
  111. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.d.ts +0 -13
  112. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.js +0 -3
  113. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.js.map +0 -1
  114. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.d.ts +0 -2
  115. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.js +0 -6
  116. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.js.map +0 -1
  117. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.d.ts +0 -16
  118. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.js +0 -54
  119. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.js.map +0 -1
  120. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.d.ts +0 -17
  121. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.js +0 -52
  122. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.js.map +0 -1
  123. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.d.ts +0 -11
  124. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.js +0 -39
  125. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.js.map +0 -1
  126. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.d.ts +0 -13
  127. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.js +0 -46
  128. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.js.map +0 -1
  129. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.d.ts +0 -11
  130. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.js +0 -3
  131. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.js.map +0 -1
  132. package/lib/ui/directives/firedev-inject-html.directive.d.ts +0 -6
  133. package/lib/ui/directives/firedev-long-press.directive.d.ts +0 -22
  134. package/lib/ui/directives/index.d.ts +0 -3
  135. package/lib/ui/directives/index.js +0 -5
  136. package/lib/ui/directives/index.js.map +0 -1
  137. package/lib/ui/directives/safe.pipe.d.ts +0 -7
  138. package/lib/ui/directives/taon-inject-html.directive.d.ts +0 -6
  139. package/lib/ui/directives/taon-long-press.directive.d.ts +0 -22
  140. package/lib/ui/directives/view-mode.d.ts +0 -5
  141. package/lib/ui/directives/view-mode.js +0 -10
  142. package/lib/ui/directives/view-mode.js.map +0 -1
  143. package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.d.ts +0 -2
  144. package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.js +0 -5
  145. package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.js.map +0 -1
  146. package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/taon-admin-edit-mode.component.d.ts +0 -29
  147. package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/taon-admin-edit-mode.module.d.ts +0 -2
  148. package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.d.ts +0 -1
  149. package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.js +0 -5
  150. package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.js.map +0 -1
  151. package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/taon-db-admin.component.d.ts +0 -8
  152. package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.d.ts +0 -2
  153. package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.js +0 -5
  154. package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.js.map +0 -1
  155. package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/taon-file-general-opt.component.d.ts +0 -13
  156. package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/taon-file-general-opt.module.d.ts +0 -2
  157. package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.d.ts +0 -5
  158. package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.js +0 -3
  159. package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.js.map +0 -1
  160. package/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.d.ts +0 -14
  161. package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +0 -43
  162. package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.module.d.ts +0 -2
  163. package/lib/ui/taon-admin-mode-configuration/taon-admin.models.d.ts +0 -5
  164. package/lib/ui/taon-admin-mode-configuration/taon-admin.models.js +0 -3
  165. package/lib/ui/taon-admin-mode-configuration/taon-admin.models.js.map +0 -1
  166. package/lib/ui/taon-full-material.module.d.ts +0 -5
  167. package/lib/ui/taon-github-fork-me-corner/index.d.ts +0 -2
  168. package/lib/ui/taon-github-fork-me-corner/index.js +0 -5
  169. package/lib/ui/taon-github-fork-me-corner/index.js.map +0 -1
  170. package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.component.d.ts +0 -3
  171. package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.module.d.ts +0 -2
  172. package/lib/ui/taon-github-fork-me-ribbon/index.d.ts +0 -2
  173. package/lib/ui/taon-github-fork-me-ribbon/index.js +0 -5
  174. package/lib/ui/taon-github-fork-me-ribbon/index.js.map +0 -1
  175. package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.component.d.ts +0 -3
  176. package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.module.d.ts +0 -2
  177. package/lib/ui/taon-notifications/index.d.ts +0 -4
  178. package/lib/ui/taon-notifications/index.js +0 -24
  179. package/lib/ui/taon-notifications/index.js.map +0 -1
  180. package/lib/ui/taon-notifications/taon-notifications.component.d.ts +0 -9
  181. package/lib/ui/taon-notifications/taon-notifications.models.d.ts +0 -6
  182. package/lib/ui/taon-notifications/taon-notifications.models.js +0 -5
  183. package/lib/ui/taon-notifications/taon-notifications.models.js.map +0 -1
  184. package/lib/ui/taon-notifications/taon-notifications.module.d.ts +0 -2
  185. package/lib/ui/taon-notifications/taon-notifications.service.d.ts +0 -11
  186. package/lib/ui/taon-progress-bar/index.d.ts +0 -2
  187. package/lib/ui/taon-progress-bar/index.js +0 -5
  188. package/lib/ui/taon-progress-bar/index.js.map +0 -1
  189. package/lib/ui/taon-progress-bar/taon-progress-bar.component.d.ts +0 -13
  190. package/lib/ui/taon-progress-bar/taon-progress-bar.module.d.ts +0 -2
  191. package/lib/ui/taon-session-passcode/index.d.ts +0 -1
  192. package/lib/ui/taon-session-passcode/index.js +0 -5
  193. package/lib/ui/taon-session-passcode/index.js.map +0 -1
  194. package/lib/ui/taon-session-passcode/taon-session-passcode.component.d.ts +0 -35
  195. package/lib/ui/taon-table/index.d.ts +0 -2
  196. package/lib/ui/taon-table/index.js +0 -5
  197. package/lib/ui/taon-table/index.js.map +0 -1
  198. package/lib/ui/taon-table/taon-table.component.d.ts +0 -34
  199. package/lib/ui/taon-table/taon-table.module.d.ts +0 -2
  200. package/lib/ui/taon.models.d.ts +0 -11
  201. package/lib/ui/taon.models.js +0 -3
  202. package/lib/ui/taon.models.js.map +0 -1
  203. package/lib/ui/toan-full-material.module.d.ts +0 -2
  204. package/tmp-environment.json +0 -43
@@ -5,13 +5,14 @@ import { Models } from './models';
5
5
  * Context function can be used to dynamically
6
6
  * create context with specific configuration.
7
7
  */
8
- export declare const createContextTemplate: <CTX extends Record<string, object>, CTRL extends Record<string, new (...args: any[]) => any>, ENTITY extends Record<string, new (...args: any[]) => any>, REPO extends Record<string, new (...args: any[]) => any>, PROVIDER extends Record<string, new (...args: any[]) => any>, SUBSCRIBER extends Record<string, new (...args: any[]) => any>, MIGRATION extends Record<string, new (...args: any[]) => any>>(configFn: (env: any) => Models.ContextOptions<CTX, CTRL, ENTITY, REPO, PROVIDER, SUBSCRIBER, MIGRATION>) => () => {
8
+ export declare const createContextTemplate: <CTX extends Record<string, object>, CTRL extends Record<string, new (...args: any[]) => any>, ENTITY extends Record<string, new (...args: any[]) => any>, REPO extends Record<string, new (...args: any[]) => any>, PROVIDER extends Record<string, new (...args: any[]) => any>, SUBSCRIBER extends Record<string, new (...args: any[]) => any>, MIGRATION extends Record<string, new (...args: any[]) => any>, MIDDLEWARE extends Record<string, new (...args: any[]) => any>>(configFn: (env: any) => Models.ContextOptions<CTX, CTRL, ENTITY, REPO, PROVIDER, SUBSCRIBER, MIGRATION, MIDDLEWARE>) => () => {
9
9
  types: {
10
10
  readonly controllers: any;
11
11
  readonly repositories: any;
12
12
  readonly providers: any;
13
13
  readonly subscribers: any;
14
14
  readonly migrations: any;
15
+ readonly middlewares: any;
15
16
  };
16
17
  readonly contexts: any;
17
18
  readonly contextName: string;
@@ -51,13 +52,14 @@ export declare const createContextTemplate: <CTX extends Record<string, object>,
51
52
  * REQURIED PROPERTY:
52
53
  * - contextName
53
54
  */
54
- export declare const createContext: <CTX extends Record<string, object>, CTRL extends Record<string, new (...args: any[]) => any>, ENTITY extends Record<string, new (...args: any[]) => any>, REPO extends Record<string, new (...args: any[]) => any>, PROVIDER extends Record<string, new (...args: any[]) => any>, SUBSCRIBER extends Record<string, new (...args: any[]) => any>, MIGRATION extends Record<string, new (...args: any[]) => any>>(configFn: (env: any) => Models.ContextOptions<CTX, CTRL, ENTITY, REPO, PROVIDER, SUBSCRIBER, MIGRATION>) => {
55
+ export declare const createContext: <CTX extends Record<string, object>, CTRL extends Record<string, new (...args: any[]) => any>, ENTITY extends Record<string, new (...args: any[]) => any>, REPO extends Record<string, new (...args: any[]) => any>, PROVIDER extends Record<string, new (...args: any[]) => any>, SUBSCRIBER extends Record<string, new (...args: any[]) => any>, MIGRATION extends Record<string, new (...args: any[]) => any>, MIDDLEWARES extends Record<string, new (...args: any[]) => any>>(configFn: (env: any) => Models.ContextOptions<CTX, CTRL, ENTITY, REPO, PROVIDER, SUBSCRIBER, MIGRATION, MIDDLEWARES>) => {
55
56
  types: {
56
57
  readonly controllers: any;
57
58
  readonly repositories: any;
58
59
  readonly providers: any;
59
60
  readonly subscribers: any;
60
61
  readonly migrations: any;
62
+ readonly middlewares: any;
61
63
  };
62
64
  readonly contexts: any;
63
65
  readonly contextName: string;
@@ -65,6 +65,9 @@ const createContext = (configFn) => {
65
65
  get migrations() {
66
66
  return config.migrations; // TODO QUICK_FIX new typescript generated wrong types
67
67
  },
68
+ get middlewares() {
69
+ return config.middlewares; // TODO QUICK_FIX new typescript generated wrong types
70
+ },
68
71
  },
69
72
  //#endregion
70
73
  //#region contexts
@@ -159,42 +162,43 @@ const createContext = (configFn) => {
159
162
  endpointContextRef.writeActiveRoutes();
160
163
  //#endregion
161
164
  await endpointContextRef.initClasses();
162
- let keepWebsqlDbDataAfterReload = false;
163
- /* */
164
- /* */
165
- /* */
166
- if (!lib_1.Helpers.isNode && keepWebsqlDbDataAfterReload) {
167
- !lib_1.UtilsOs.isRunningInCliMode() &&
168
- lib_1.Helpers.info(`[taon] Keeping websql data after reload ` +
169
- `(context=${endpointContextRef.contextName}).`);
170
- }
171
- else {
172
- !lib_1.UtilsOs.isRunningInCliMode() &&
173
- lib_1.Helpers.info(`[taon] Dropping all tables and data ` +
174
- `(context=${endpointContextRef.contextName}).`);
175
- await endpointContextRef.reinitControllers();
176
- }
177
- //#region TODO this may be usefull but for now
178
- // 2 separate contexts are fine
179
- // const shouldStartRemoteHost = endpointContextRef.mode !== 'remote-backend(tcp+udp)';
180
- // if(shouldStartRemoteHost) {
181
- // const endpointContextRemoteHostRef = new EndpointContext(config, configFn);
182
- // await endpointContextRemoteHostRef.init({
183
- // overrideRemoteHost: endpointContextRef.host,
184
- // overrideHost: null,
185
- // });
186
- // endpointContextRemoteHostRef.initMetadata();
187
- // endpointContextRef.__contextForControllerInstanceAccess = endpointContextRemoteHostRef;
188
- // }
189
- //#endregion
190
- if (endpointContextRef.onlyMigrationRun) {
191
- await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
192
- }
193
- else if (endpointContextRef.onlyMigrationRevertToTimestamp) {
194
- await endpointContextRef.dbMigrations.revertMigrationToTimestamp(endpointContextRef.onlyMigrationRevertToTimestamp);
195
- }
196
- else {
197
- await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
165
+ if (endpointContextRef.databaseConfig) {
166
+ let keepWebsqlDbDataAfterReload = false;
167
+ /* */
168
+ /* */
169
+ /* */
170
+ if (!lib_1.Helpers.isNode && keepWebsqlDbDataAfterReload) {
171
+ !lib_1.UtilsOs.isRunningInCliMode() &&
172
+ lib_1.Helpers.info(`[taon] Keeping websql data after reload ` +
173
+ `(context=${endpointContextRef.contextName}).`);
174
+ }
175
+ else {
176
+ !lib_1.UtilsOs.isRunningInCliMode() &&
177
+ lib_1.Helpers.info(`[taon] Dropping all tables and data ` +
178
+ `(context=${endpointContextRef.contextName}).`);
179
+ }
180
+ //#region TODO this may be usefull but for now
181
+ // 2 separate contexts are fine
182
+ // const shouldStartRemoteHost = endpointContextRef.mode !== 'remote-backend(tcp+udp)';
183
+ // if(shouldStartRemoteHost) {
184
+ // const endpointContextRemoteHostRef = new EndpointContext(config, configFn);
185
+ // await endpointContextRemoteHostRef.init({
186
+ // overrideRemoteHost: endpointContextRef.host,
187
+ // overrideHost: null,
188
+ // });
189
+ // endpointContextRemoteHostRef.initMetadata();
190
+ // endpointContextRef.__contextForControllerInstanceAccess = endpointContextRemoteHostRef;
191
+ // }
192
+ //#endregion
193
+ if (endpointContextRef.onlyMigrationRun) {
194
+ await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
195
+ }
196
+ else if (endpointContextRef.onlyMigrationRevertToTimestamp) {
197
+ await endpointContextRef.dbMigrations.revertMigrationToTimestamp(endpointContextRef.onlyMigrationRevertToTimestamp);
198
+ }
199
+ else {
200
+ await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
201
+ }
198
202
  }
199
203
  resolve(endpointContextRef);
200
204
  });
@@ -1 +1 @@
1
- {"version":3,"file":"create-context.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;AAAA,iBAAiB;AACjB,sCAAmD;AAEnD,yDAAqD;AAErD,KAAK;AACL,YAAY;AAEZ;;;;GAIG;AACI,MAAM,qBAAqB,GAAG,CAWnC,QAUC,EACD,EAAE;IACF,OAAO,GAAG,EAAE;QACV,OAAO,IAAA,qBAAa,EAQlB,QAAQ,CAAC,CAAC;IACd,CAAC,CAAC;AACJ,CAAC,CAAC;AAlCW,QAAA,qBAAqB,yBAkChC;AAEF;;;GAGG;AACI,MAAM,aAAa,GAAG,CAW3B,QAUC,EACD,EAAE;IACF,IAAI,MAAM,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC1B,eAAe;IACf,MAAM;IAEN,uDAAuD;IACvD,cAAc;IACd,KAAK;IACL,MAAM,kBAAkB,GAAG,IAAI,kCAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAEjE,MAAM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A0B;wBAC1B,QAAQ;wBACR,iDAAiD;wBAEjD,4FAA4F;wBAC5F,IAAI;wBACJ,YAAY;wBAEZ,IAAI,kBAAkB,CAAC,gBAAgB,EAAE,CAAC;4BACxC,MAAM,kBAAkB,CAAC,YAAY,CAAC,4BAA4B,EAAE,CAAC;wBACvE,CAAC;6BAAM,IAAI,kBAAkB,CAAC,8BAA8B,EAAE,CAAC;4BAC7D,MAAM,kBAAkB,CAAC,YAAY,CAAC,0BAA0B,CAC9D,kBAAkB,CAAC,8BAA8B,CAClD,CAAC;wBACJ,CAAC;6BAAM,CAAC;4BACN,MAAM,kBAAkB,CAAC,YAAY,CAAC,4BAA4B,EAAE,CAAC;wBACvE,CAAC;oBACH,CAAC;oBAED,OAAO,CAAC,kBAAkB,CAAC,CAAC;gBAC9B,CAAC,CAAC,CAAC;gBACH,YAAY;YACd,CAAC,CAAC,CAAC;QACL,CAAC;QACD;;;WAGG;QACH,IAAI,QAAQ;YACV,OAAO;gBACL,IAAI,MAAM;oBACR,OAAO,kBAAkB,CAAC,cAAc,CAAC;gBAC3C,CAAC;gBACD,IAAI,MAAM;oBACR,OAAO,kBAAkB,CAAC,cAAc,CAAC;gBAC3C,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;IACF,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AA9PW,QAAA,aAAa,iBA8PxB"}
@@ -0,0 +1,7 @@
1
+ import { Models } from '../../models';
2
+ /**
3
+ * Provider decorator
4
+ */
5
+ export declare function TaonMiddleware<T = any>(options?: TaonMiddlewareOptions<T>): (constructor: Function) => void;
6
+ export declare class TaonMiddlewareOptions<T = any> extends Models.DecoratorAbstractOpt {
7
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TaonMiddlewareOptions = void 0;
4
+ exports.TaonMiddleware = TaonMiddleware;
5
+ const class_helpers_1 = require("../../helpers/class-helpers");
6
+ const models_1 = require("../../models");
7
+ const symbols_1 = require("../../symbols");
8
+ /**
9
+ * Provider decorator
10
+ */
11
+ function TaonMiddleware(options) {
12
+ return function (constructor) {
13
+ Reflect.defineMetadata(symbols_1.Symbols.metadata.options.provider, options, constructor);
14
+ Reflect.defineMetadata(symbols_1.Symbols.metadata.className, options?.className || constructor.name, constructor);
15
+ class_helpers_1.ClassHelpers.setName(constructor, options?.className || constructor.name);
16
+ };
17
+ }
18
+ class TaonMiddlewareOptions extends models_1.Models.DecoratorAbstractOpt {
19
+ }
20
+ exports.TaonMiddlewareOptions = TaonMiddlewareOptions;
21
+ //# sourceMappingURL=middleware-decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware-decorator.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;AAOA,wCAcC;AArBD,+DAA2D;AAC3D,yCAAsC;AACtC,2CAAwC;AAExC;;GAEG;AACH,SAAgB,cAAc,CAAU,OAAkC;IACxE,OAAO,UAAU,WAAqB;QACpC,OAAO,CAAC,cAAc,CACpB,iBAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EACjC,OAAO,EACP,WAAW,CACZ,CAAC;QACF,OAAO,CAAC,cAAc,CACpB,iBAAO,CAAC,QAAQ,CAAC,SAAS,EAC1B,OAAO,EAAE,SAAS,IAAI,WAAW,CAAC,IAAI,EACtC,WAAW,CACZ,CAAC;QACF,4BAAY,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,EAAE,SAAS,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;IAC5E,CAAC,CAAC;AACJ,CAAC;AAED,MAAa,qBAEX,SAAQ,eAAM,CAAC,oBAAoB;CAEpC;AAJD,sDAIC"}
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TaonProviderOptions = void 0;
4
4
  exports.TaonProvider = TaonProvider;
5
5
  const class_helpers_1 = require("../../helpers/class-helpers");
6
- const symbols_1 = require("../../symbols");
7
6
  const models_1 = require("../../models");
7
+ const symbols_1 = require("../../symbols");
8
8
  /**
9
9
  * Provider decorator
10
10
  */
@@ -1 +1 @@
1
- {"version":3,"file":"provider-decorator.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;AAOA,oCAcC;AArBD,+DAA2D;AAC3D,2CAAwC;AACxC,yCAAsC;AAEtC;;GAEG;AACH,SAAgB,YAAY,CAAU,OAAgC;IACpE,OAAO,UAAU,WAAqB;QACpC,OAAO,CAAC,cAAc,CACpB,iBAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EACjC,OAAO,EACP,WAAW,CACZ,CAAC;QACF,OAAO,CAAC,cAAc,CACpB,iBAAO,CAAC,QAAQ,CAAC,SAAS,EAC1B,OAAO,EAAE,SAAS,IAAI,WAAW,CAAC,IAAI,EACtC,WAAW,CACZ,CAAC;QACF,4BAAY,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,EAAE,SAAS,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;IAC5E,CAAC,CAAC;AACJ,CAAC;AAED,MAAa,mBAEX,SAAQ,eAAM,CAAC,oBAAoB;CAEpC;AAJD,kDAIC"}
1
+ {"version":3,"file":"provider-decorator.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;AAOA,oCAcC;AArBD,+DAA2D;AAC3D,yCAAsC;AACtC,2CAAwC;AAExC;;GAEG;AACH,SAAgB,YAAY,CAAU,OAAgC;IACpE,OAAO,UAAU,WAAqB;QACpC,OAAO,CAAC,cAAc,CACpB,iBAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EACjC,OAAO,EACP,WAAW,CACZ,CAAC;QACF,OAAO,CAAC,cAAc,CACpB,iBAAO,CAAC,QAAQ,CAAC,SAAS,EAC1B,OAAO,EAAE,SAAS,IAAI,WAAW,CAAC,IAAI,EACtC,WAAW,CACZ,CAAC;QACF,4BAAY,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,EAAE,SAAS,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;IAC5E,CAAC,CAAC;AACJ,CAAC;AAED,MAAa,mBAEX,SAAQ,eAAM,CAAC,oBAAoB;CAEpC;AAJD,kDAIC"}
@@ -5,6 +5,7 @@ import type { Application } from 'express';
5
5
  import type { Repository } from 'taon-typeorm';
6
6
  import { DataSource } from 'taon-typeorm';
7
7
  import type { BaseInjector } from './base-classes/base-injector';
8
+ export type { TaonMiddlewareInterceptOptions } from './base-classes/base-middleware';
8
9
  import { ContextDbMigrations } from './context-db-migrations';
9
10
  import { Models } from './models';
10
11
  export declare class EndpointContext {
@@ -55,7 +56,7 @@ export declare class EndpointContext {
55
56
  /**
56
57
  * available after init()
57
58
  */
58
- config: Models.ContextOptions<any, any, any, any, any, any, any>;
59
+ config: Models.ContextOptions<any, any, any, any, any, any, any, any>;
59
60
  get logHttp(): boolean;
60
61
  get logRealtime(): boolean;
61
62
  get logFramework(): boolean;
@@ -65,7 +66,7 @@ export declare class EndpointContext {
65
66
  * Inside docker there is not need for https secure server
66
67
  */
67
68
  private isRunningInsideDocker;
68
- constructor(originalConfig: Models.ContextOptions<any, any, any, any, any, any, any>, configFn: (env: any) => Models.ContextOptions<any, any, any, any, any, any, any>);
69
+ constructor(originalConfig: Models.ContextOptions<any, any, any, any, any, any, any, any>, configFn: (env: any) => Models.ContextOptions<any, any, any, any, any, any, any, any>);
69
70
  init(options?: {
70
71
  initFromRecrusiveContextResovle?: boolean;
71
72
  overrideHost?: string | null;
@@ -99,13 +100,12 @@ export declare class EndpointContext {
99
100
  isCLassType(classType: Models.ClassType, classFn: Function): boolean;
100
101
  /**
101
102
  * Only for injectable types
102
- * Only for classType: CONTROLLER, REPOSITORY, PROVIDER
103
+ * Only for classType: CONTROLLER, REPOSITORY, PROVIDER, MIDDLEWARES
103
104
  */
104
105
  getClassFunByClassName(className: string): Function;
105
106
  getClassFunByClass(classFunction: Function): Function;
106
107
  getClassFunByArr(classType: Models.ClassType): Function[];
107
108
  private createInstances;
108
- reinitControllers(): Promise<void>;
109
109
  initClasses(): Promise<void>;
110
110
  isActiveOn(classInstance: object): boolean;
111
111
  get frontendHostUri(): URL;
@@ -158,7 +158,8 @@ export declare class EndpointContext {
158
158
  initControllers(): Promise<void>;
159
159
  writeActiveRoutes(): void;
160
160
  get middlewares(): Models.MiddlewareType[];
161
- private initMiddlewares;
161
+ private initFrontnedMiddlewares;
162
+ private initBackendMiddlewares;
162
163
  private initServer;
163
164
  /**
164
165
  * client can be browser or nodejs (when remote host)
@@ -97,6 +97,7 @@ class EndpointContext {
97
97
  injectableTypesfromContexts = [
98
98
  models_1.Models.ClassType.CONTROLLER,
99
99
  models_1.Models.ClassType.PROVIDER,
100
+ models_1.Models.ClassType.MIDDLEWARE,
100
101
  models_1.Models.ClassType.REPOSITORY,
101
102
  models_1.Models.ClassType.SUBSCRIBER,
102
103
  models_1.Models.ClassType.MIGRATION,
@@ -336,6 +337,10 @@ class EndpointContext {
336
337
  ...(await this.getRecrusiveClassesfromContextsObj(models_1.Models.ClassType.PROVIDER)),
337
338
  ...this.config.providers,
338
339
  };
340
+ this.config.middlewares = {
341
+ ...(await this.getRecrusiveClassesfromContextsObj(models_1.Models.ClassType.MIDDLEWARE)),
342
+ ...this.config.middlewares,
343
+ };
339
344
  this.config.subscribers = {
340
345
  ...(await this.getRecrusiveClassesfromContextsObj(models_1.Models.ClassType.SUBSCRIBER)),
341
346
  ...this.config.subscribers,
@@ -370,6 +375,12 @@ class EndpointContext {
370
375
  ctx: this,
371
376
  classType: models_1.Models.ClassType.PROVIDER,
372
377
  });
378
+ this.config.middlewares = this.cloneClassesObjWithNewMetadata({
379
+ classesInput: this.config.middlewares,
380
+ config: this.config,
381
+ ctx: this,
382
+ classType: models_1.Models.ClassType.MIDDLEWARE,
383
+ });
373
384
  this.config.subscribers = this.cloneClassesObjWithNewMetadata({
374
385
  classesInput: this.config.subscribers,
375
386
  config: this.config,
@@ -397,7 +408,7 @@ class EndpointContext {
397
408
  if (this.mode === 'backend-frontend(tcp+udp)' && !this.config.abstract) {
398
409
  //#region @backend
399
410
  this.expressApp = express();
400
- this.initMiddlewares();
411
+ await this.initBackendMiddlewares();
401
412
  const shouldStartHttpsSecureServer = this.isHttpServer && !this.isRunningInsideDocker;
402
413
  this.logFramework &&
403
414
  lib_10.Helpers.info(`
@@ -415,6 +426,7 @@ class EndpointContext {
415
426
  this.expressApp.use(asset.serverPath, express.static(asset.locationOnDisk));
416
427
  });
417
428
  //#endregion
429
+ await this.initFrontnedMiddlewares();
418
430
  }
419
431
  //#endregion
420
432
  //#region prepare realtime
@@ -526,7 +538,7 @@ class EndpointContext {
526
538
  //#region @backend
527
539
  if (lib_8.UtilsOs.isElectron) {
528
540
  dbLocationInOs = (0, lib_9.crossPlatformPath)([
529
- lib_7.os.userInfo().homedir,
541
+ lib_8.UtilsOs.getRealHomeDir(),
530
542
  `.taon/databases-for-electron-apps/${this.appId || lib_10._.snakeCase(process.cwd()).replace(/\_/, '.')}/${this.contextName}.sqlite`,
531
543
  ]);
532
544
  if (!lib_10.Helpers.exists(lib_11.path.dirname(dbLocationInOs))) {
@@ -893,6 +905,8 @@ class EndpointContext {
893
905
  return this.config.entities;
894
906
  case models_1.Models.ClassType.PROVIDER:
895
907
  return this.config.providers;
908
+ case models_1.Models.ClassType.MIDDLEWARE:
909
+ return this.config.middlewares;
896
910
  case models_1.Models.ClassType.REPOSITORY:
897
911
  return this.config.repositories;
898
912
  case models_1.Models.ClassType.SUBSCRIBER:
@@ -906,7 +920,7 @@ class EndpointContext {
906
920
  }
907
921
  /**
908
922
  * Only for injectable types
909
- * Only for classType: CONTROLLER, REPOSITORY, PROVIDER
923
+ * Only for classType: CONTROLLER, REPOSITORY, PROVIDER, MIDDLEWARES
910
924
  */
911
925
  getClassFunByClassName(className) {
912
926
  for (const classTypeName of this.allTypesfromContexts) {
@@ -946,25 +960,7 @@ class EndpointContext {
946
960
  }
947
961
  }
948
962
  //#endregion
949
- //#region methods & getters / reinit controllers db example data
950
- async reinitControllers() {
951
- if (this.remoteHost || Object.keys(this.config.migrations).length > 0) {
952
- return;
953
- }
954
- // Helpers.taskStarted(
955
- // `[taon] REINITING CONTROLLERS ${this.contextName} STARTED`,
956
- // );
957
- const controllers = this.getClassesInstancesArrBy(models_1.Models.ClassType.CONTROLLER);
958
- // console.log('CONTROLLERS TO REINIT', controllers);
959
- for (const ctrl of controllers) {
960
- if (lib_10._.isFunction(ctrl.initExampleDbData)) {
961
- await ctrl.initExampleDbData();
962
- }
963
- }
964
- // Helpers.taskDone(
965
- // `[taon] REINITING CONTROLLERS ${this.contextName} DONE`,
966
- // );
967
- }
963
+ //#region methods & getters / init classes
968
964
  async initClasses() {
969
965
  if (this.remoteHost) {
970
966
  return;
@@ -976,6 +972,7 @@ class EndpointContext {
976
972
  }
977
973
  //#endregion
978
974
  for (const classTypeName of [
975
+ models_1.Models.ClassType.MIDDLEWARE,
979
976
  models_1.Models.ClassType.PROVIDER,
980
977
  models_1.Models.ClassType.REPOSITORY,
981
978
  models_1.Models.ClassType.CONTROLLER,
@@ -991,6 +988,7 @@ class EndpointContext {
991
988
  //#endregion
992
989
  }
993
990
  for (const classTypeName of [
991
+ models_1.Models.ClassType.MIDDLEWARE,
994
992
  models_1.Models.ClassType.PROVIDER,
995
993
  models_1.Models.ClassType.REPOSITORY,
996
994
  models_1.Models.ClassType.CONTROLLER,
@@ -1191,7 +1189,7 @@ class EndpointContext {
1191
1189
  //#region methods & getters / init connection
1192
1190
  async initDatabaseConnection() {
1193
1191
  //#region @websqlFunc
1194
- if (this.remoteHost) {
1192
+ if (this.remoteHost || !this.databaseConfig) {
1195
1193
  return;
1196
1194
  }
1197
1195
  const entities = this.getClassFunByArr(models_1.Models.ClassType.ENTITY).map(entityFn => {
@@ -1434,15 +1432,67 @@ class EndpointContext {
1434
1432
  }
1435
1433
  //#endregion
1436
1434
  //#region methods & getters / init middlewares
1437
- initMiddlewares() {
1435
+ async initFrontnedMiddlewares() {
1436
+ const middlewares = this.getClassesInstancesArrBy(models_1.Models.ClassType.MIDDLEWARE);
1437
+ for (const middleware of middlewares) {
1438
+ const middlewareInstance = middleware;
1439
+ if (lib_10._.isFunction(middlewareInstance.intercept)) {
1440
+ ((instance, contextName, apiPart, uriPathnameOrNothingIfRoot) => {
1441
+ const interceptorName = `${contextName}-${class_helpers_1.ClassHelpers.getName(instance)}`;
1442
+ lib_3.Resource.request.interceptors.set(interceptorName, async (req) => {
1443
+ console.log('request', req);
1444
+ const url = new url_1.URL(req.url);
1445
+ if (url.pathname.startsWith(`${uriPathnameOrNothingIfRoot}/${apiPart}/${contextName}/`)) {
1446
+ await instance.intercept({
1447
+ client: {
1448
+ req,
1449
+ },
1450
+ });
1451
+ }
1452
+ else {
1453
+ // console.log('not fit frontend', url.href);
1454
+ }
1455
+ return req;
1456
+ });
1457
+ })(middlewareInstance, this.contextName, constants_1.apiPrefix, this.uriPathnameOrNothingIfRoot);
1458
+ }
1459
+ }
1460
+ }
1461
+ async initBackendMiddlewares() {
1438
1462
  //#region @backend
1439
1463
  const app = this.expressApp;
1440
- if (this.middlewares) {
1441
- this.middlewares.forEach(m => {
1442
- const [fun, args] = m;
1443
- app.use(fun.apply(null, args));
1444
- });
1464
+ const middlewares = this.getClassesInstancesArrBy(models_1.Models.ClassType.MIDDLEWARE);
1465
+ for (const middleware of middlewares) {
1466
+ const middlewareInstance = middleware;
1467
+ if (lib_10._.isFunction(middlewareInstance.intercept)) {
1468
+ ((instance, contextName, apiPart, uriPathnameOrNothingIfRoot) => {
1469
+ const asyncHandler = fn => (req, res, next) => {
1470
+ Promise.resolve(fn(req, res, next)).catch(next);
1471
+ };
1472
+ const middlewareFn = asyncHandler(async (req, res, next) => {
1473
+ if (req.originalUrl.startsWith(`${uriPathnameOrNothingIfRoot}/${apiPart}/${contextName}/`)) {
1474
+ await instance.intercept({
1475
+ server: {
1476
+ req,
1477
+ res,
1478
+ },
1479
+ });
1480
+ }
1481
+ else {
1482
+ // console.log('not fit backend', url.href);
1483
+ }
1484
+ next();
1485
+ });
1486
+ app.use(middlewareFn);
1487
+ })(middlewareInstance, this.contextName, constants_1.apiPrefix, this.uriPathnameOrNothingIfRoot);
1488
+ }
1445
1489
  }
1490
+ // if (this.middlewares) {
1491
+ // this.middlewares.forEach(m => {
1492
+ // const [fun, args] = m;
1493
+ // app.use(fun.apply(null, args));
1494
+ // });
1495
+ // }
1446
1496
  this.expressApp.get('/helloworld', (req, res) => {
1447
1497
  res.send(`Hello, world from context ${this.contextName}`);
1448
1498
  });