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.
- package/browser/fesm2022/taon.mjs +167 -77
- package/browser/fesm2022/taon.mjs.map +1 -1
- package/browser/lib/base-classes/base-context.d.ts +1 -0
- package/browser/lib/base-classes/base-controller.d.ts +0 -6
- package/browser/lib/base-classes/base-injector.d.ts +4 -5
- package/browser/lib/base-classes/base-middleware.d.ts +17 -0
- package/browser/lib/base-classes/base.d.ts +3 -0
- package/browser/lib/constants.d.ts +1 -1
- package/browser/lib/create-context.d.ts +4 -2
- package/browser/lib/decorators/classes/middleware-decorator.d.ts +8 -0
- package/browser/lib/endpoint-context.d.ts +6 -5
- package/browser/lib/index.d.ts +8 -2
- package/browser/lib/models.d.ts +65 -5
- package/browser/package.json +1 -1
- package/lib/base-classes/base-context.d.ts +1 -0
- package/lib/base-classes/base-controller.d.ts +0 -6
- package/lib/base-classes/base-controller.js +0 -8
- package/lib/base-classes/base-controller.js.map +1 -1
- package/lib/base-classes/base-injector.d.ts +4 -5
- package/lib/base-classes/base-injector.js +6 -7
- package/lib/base-classes/base-injector.js.map +1 -1
- package/lib/base-classes/base-middleware.d.ts +20 -0
- package/lib/base-classes/base-middleware.js +13 -0
- package/lib/base-classes/base-middleware.js.map +1 -0
- package/lib/base-classes/base.d.ts +3 -0
- package/lib/base-classes/base.js +2 -0
- package/lib/base-classes/base.js.map +1 -1
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/constants.d.ts +1 -1
- package/lib/constants.js +2 -3
- package/lib/constants.js.map +1 -1
- package/lib/create-context.d.ts +4 -2
- package/lib/create-context.js +40 -36
- package/lib/create-context.js.map +1 -1
- package/lib/decorators/classes/middleware-decorator.d.ts +7 -0
- package/lib/decorators/classes/middleware-decorator.js +21 -0
- package/lib/decorators/classes/middleware-decorator.js.map +1 -0
- package/lib/decorators/classes/provider-decorator.js +1 -1
- package/lib/decorators/classes/provider-decorator.js.map +1 -1
- package/lib/endpoint-context.d.ts +6 -5
- package/lib/endpoint-context.js +79 -29
- package/lib/endpoint-context.js.map +1 -1
- package/lib/env/env.angular-node-app.d.ts +1 -0
- package/lib/env/env.angular-node-app.js +3 -2
- package/lib/env/env.angular-node-app.js.map +1 -1
- package/lib/env/env.docs-webapp.d.ts +1 -0
- package/lib/env/env.docs-webapp.js +3 -2
- package/lib/env/env.docs-webapp.js.map +1 -1
- package/lib/env/env.electron-app.d.ts +1 -0
- package/lib/env/env.electron-app.js +3 -2
- package/lib/env/env.electron-app.js.map +1 -1
- package/lib/env/env.mobile-app.d.ts +1 -0
- package/lib/env/env.mobile-app.js +3 -2
- package/lib/env/env.mobile-app.js.map +1 -1
- package/lib/env/env.npm-lib-and-cli-tool.d.ts +1 -0
- package/lib/env/env.npm-lib-and-cli-tool.js +3 -2
- package/lib/env/env.npm-lib-and-cli-tool.js.map +1 -1
- package/lib/env/env.vscode-plugin.d.ts +1 -0
- package/lib/env/env.vscode-plugin.js +3 -2
- package/lib/env/env.vscode-plugin.js.map +1 -1
- package/lib/env.js +1 -5
- package/lib/env.js.map +1 -1
- package/lib/index.d.ts +8 -2
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/models.d.ts +65 -5
- package/lib/models.js +7 -5
- package/lib/models.js.map +1 -1
- package/lib/storage.d.ts +1 -1
- package/lib/storage.js +1 -5
- package/lib/storage.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 +168 -78
- package/websql/fesm2022/taon.mjs.map +1 -1
- package/websql/lib/base-classes/base-context.d.ts +1 -0
- package/websql/lib/base-classes/base-controller.d.ts +0 -6
- package/websql/lib/base-classes/base-injector.d.ts +4 -5
- package/websql/lib/base-classes/base-middleware.d.ts +21 -0
- package/websql/lib/base-classes/base.d.ts +3 -0
- package/websql/lib/constants.d.ts +1 -1
- package/websql/lib/create-context.d.ts +4 -2
- package/websql/lib/decorators/classes/middleware-decorator.d.ts +8 -0
- package/websql/lib/endpoint-context.d.ts +6 -5
- package/websql/lib/index.d.ts +8 -2
- package/websql/lib/models.d.ts +65 -5
- package/websql/package.json +1 -1
- package/lib/base-classes/base-subscriber.d.ts +0 -4
- package/lib/base-classes/base-subscriber.js +0 -25
- package/lib/base-classes/base-subscriber.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-abstract-mock.d.ts +0 -10
- package/lib/realtime/realtime-strategy/realtime-abstract-mock.js +0 -214
- package/lib/realtime/realtime-strategy/realtime-abstract-mock.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.d.ts +0 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.js +0 -5
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.d.ts +0 -22
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.js +0 -139
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.d.ts +0 -16
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.js +0 -68
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.d.ts +0 -10
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.js +0 -56
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.d.ts +0 -10
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.js +0 -50
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.d.ts +0 -13
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.js +0 -3
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.d.ts +0 -2
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.js +0 -6
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.d.ts +0 -16
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.js +0 -54
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.d.ts +0 -17
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.js +0 -52
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.d.ts +0 -11
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.js +0 -39
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.d.ts +0 -13
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.js +0 -46
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.d.ts +0 -11
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.js +0 -3
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.js.map +0 -1
- package/lib/ui/directives/firedev-inject-html.directive.d.ts +0 -6
- package/lib/ui/directives/firedev-long-press.directive.d.ts +0 -22
- 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/components/taon-admin-edit-mode/index.d.ts +0 -2
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.js +0 -5
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.js.map +0 -1
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/taon-admin-edit-mode.component.d.ts +0 -29
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/taon-admin-edit-mode.module.d.ts +0 -2
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.d.ts +0 -1
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.js +0 -5
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.js.map +0 -1
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/taon-db-admin.component.d.ts +0 -8
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.d.ts +0 -2
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.js +0 -5
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.js.map +0 -1
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/taon-file-general-opt.component.d.ts +0 -13
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/taon-file-general-opt.module.d.ts +0 -2
- package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.d.ts +0 -5
- package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.js +0 -3
- package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.js.map +0 -1
- package/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.d.ts +0 -14
- 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-mode-configuration.module.d.ts +0 -2
- 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/lib/ui/toan-full-material.module.d.ts +0 -2
- package/tmp-environment.json +0 -43
package/websql/fesm2022/taon.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import * as tsorm from 'taon-typeorm/websql';
|
|
|
6
6
|
import { OrignalClassKey, Entity, Table, TableIndex, EventSubscriber, DataSource } from 'taon-typeorm/websql';
|
|
7
7
|
import { walk } from 'lodash-walk-object/websql';
|
|
8
8
|
import { SYMBOL, CLASS } from 'typescript-class-helpers/websql';
|
|
9
|
-
import { Models as Models$1,
|
|
9
|
+
import { Models as Models$1, Resource, RestHeaders, Mapping } from 'ng2-rest/websql';
|
|
10
10
|
import * as i0 from '@angular/core';
|
|
11
11
|
import { InjectionToken, inject as inject$1, Injectable } from '@angular/core';
|
|
12
12
|
import axios from 'axios';
|
|
@@ -323,6 +323,7 @@ var Models;
|
|
|
323
323
|
ClassType["PROVIDER"] = "PROVIDER";
|
|
324
324
|
ClassType["SUBSCRIBER"] = "SUBSCRIBER";
|
|
325
325
|
ClassType["MIGRATION"] = "MIGRATION";
|
|
326
|
+
ClassType["MIDDLEWARE"] = "MIDDLEWARE";
|
|
326
327
|
})(ClassType = Models.ClassType || (Models.ClassType = {}));
|
|
327
328
|
Models.ClassTypeKey = {
|
|
328
329
|
[ClassType.ENTITY]: 'entities',
|
|
@@ -331,6 +332,7 @@ var Models;
|
|
|
331
332
|
[ClassType.PROVIDER]: 'providers',
|
|
332
333
|
[ClassType.SUBSCRIBER]: 'subscribers',
|
|
333
334
|
[ClassType.MIGRATION]: 'migrations',
|
|
335
|
+
[ClassType.MIDDLEWARE]: 'middlewares',
|
|
334
336
|
};
|
|
335
337
|
//#endregion
|
|
336
338
|
//#region models / database connection options
|
|
@@ -723,9 +725,8 @@ const TaonEntityKeysToOmitArr = [
|
|
|
723
725
|
'injectCustomRepo',
|
|
724
726
|
'injectController',
|
|
725
727
|
'injectCtrl',
|
|
726
|
-
'
|
|
727
|
-
'
|
|
728
|
-
'injectContextProvider',
|
|
728
|
+
'injectProvider',
|
|
729
|
+
'injectMiddleware',
|
|
729
730
|
];
|
|
730
731
|
let TAON_CONTEXT;
|
|
731
732
|
//#region @browser
|
|
@@ -2707,6 +2708,7 @@ class EndpointContext {
|
|
|
2707
2708
|
this.injectableTypesfromContexts = [
|
|
2708
2709
|
Models.ClassType.CONTROLLER,
|
|
2709
2710
|
Models.ClassType.PROVIDER,
|
|
2711
|
+
Models.ClassType.MIDDLEWARE,
|
|
2710
2712
|
Models.ClassType.REPOSITORY,
|
|
2711
2713
|
Models.ClassType.SUBSCRIBER,
|
|
2712
2714
|
Models.ClassType.MIGRATION,
|
|
@@ -2974,6 +2976,10 @@ class EndpointContext {
|
|
|
2974
2976
|
...(await this.getRecrusiveClassesfromContextsObj(Models.ClassType.PROVIDER)),
|
|
2975
2977
|
...this.config.providers,
|
|
2976
2978
|
};
|
|
2979
|
+
this.config.middlewares = {
|
|
2980
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models.ClassType.MIDDLEWARE)),
|
|
2981
|
+
...this.config.middlewares,
|
|
2982
|
+
};
|
|
2977
2983
|
this.config.subscribers = {
|
|
2978
2984
|
...(await this.getRecrusiveClassesfromContextsObj(Models.ClassType.SUBSCRIBER)),
|
|
2979
2985
|
...this.config.subscribers,
|
|
@@ -3008,6 +3014,12 @@ class EndpointContext {
|
|
|
3008
3014
|
ctx: this,
|
|
3009
3015
|
classType: Models.ClassType.PROVIDER,
|
|
3010
3016
|
});
|
|
3017
|
+
this.config.middlewares = this.cloneClassesObjWithNewMetadata({
|
|
3018
|
+
classesInput: this.config.middlewares,
|
|
3019
|
+
config: this.config,
|
|
3020
|
+
ctx: this,
|
|
3021
|
+
classType: Models.ClassType.MIDDLEWARE,
|
|
3022
|
+
});
|
|
3011
3023
|
this.config.subscribers = this.cloneClassesObjWithNewMetadata({
|
|
3012
3024
|
classesInput: this.config.subscribers,
|
|
3013
3025
|
config: this.config,
|
|
@@ -3060,6 +3072,7 @@ class EndpointContext {
|
|
|
3060
3072
|
/* */
|
|
3061
3073
|
/* */
|
|
3062
3074
|
/* */
|
|
3075
|
+
await this.initFrontnedMiddlewares();
|
|
3063
3076
|
}
|
|
3064
3077
|
//#endregion
|
|
3065
3078
|
//#region prepare realtime
|
|
@@ -3451,6 +3464,8 @@ class EndpointContext {
|
|
|
3451
3464
|
return this.config.entities;
|
|
3452
3465
|
case Models.ClassType.PROVIDER:
|
|
3453
3466
|
return this.config.providers;
|
|
3467
|
+
case Models.ClassType.MIDDLEWARE:
|
|
3468
|
+
return this.config.middlewares;
|
|
3454
3469
|
case Models.ClassType.REPOSITORY:
|
|
3455
3470
|
return this.config.repositories;
|
|
3456
3471
|
case Models.ClassType.SUBSCRIBER:
|
|
@@ -3464,7 +3479,7 @@ class EndpointContext {
|
|
|
3464
3479
|
}
|
|
3465
3480
|
/**
|
|
3466
3481
|
* Only for injectable types
|
|
3467
|
-
* Only for classType: CONTROLLER, REPOSITORY, PROVIDER
|
|
3482
|
+
* Only for classType: CONTROLLER, REPOSITORY, PROVIDER, MIDDLEWARES
|
|
3468
3483
|
*/
|
|
3469
3484
|
getClassFunByClassName(className) {
|
|
3470
3485
|
for (const classTypeName of this.allTypesfromContexts) {
|
|
@@ -3504,25 +3519,7 @@ class EndpointContext {
|
|
|
3504
3519
|
}
|
|
3505
3520
|
}
|
|
3506
3521
|
//#endregion
|
|
3507
|
-
//#region methods & getters /
|
|
3508
|
-
async reinitControllers() {
|
|
3509
|
-
if (this.remoteHost || Object.keys(this.config.migrations).length > 0) {
|
|
3510
|
-
return;
|
|
3511
|
-
}
|
|
3512
|
-
// Helpers.taskStarted(
|
|
3513
|
-
// `[taon] REINITING CONTROLLERS ${this.contextName} STARTED`,
|
|
3514
|
-
// );
|
|
3515
|
-
const controllers = this.getClassesInstancesArrBy(Models.ClassType.CONTROLLER);
|
|
3516
|
-
// console.log('CONTROLLERS TO REINIT', controllers);
|
|
3517
|
-
for (const ctrl of controllers) {
|
|
3518
|
-
if (_.isFunction(ctrl.initExampleDbData)) {
|
|
3519
|
-
await ctrl.initExampleDbData();
|
|
3520
|
-
}
|
|
3521
|
-
}
|
|
3522
|
-
// Helpers.taskDone(
|
|
3523
|
-
// `[taon] REINITING CONTROLLERS ${this.contextName} DONE`,
|
|
3524
|
-
// );
|
|
3525
|
-
}
|
|
3522
|
+
//#region methods & getters / init classes
|
|
3526
3523
|
async initClasses() {
|
|
3527
3524
|
if (this.remoteHost) {
|
|
3528
3525
|
return;
|
|
@@ -3534,6 +3531,7 @@ class EndpointContext {
|
|
|
3534
3531
|
}
|
|
3535
3532
|
//#endregion
|
|
3536
3533
|
for (const classTypeName of [
|
|
3534
|
+
Models.ClassType.MIDDLEWARE,
|
|
3537
3535
|
Models.ClassType.PROVIDER,
|
|
3538
3536
|
Models.ClassType.REPOSITORY,
|
|
3539
3537
|
Models.ClassType.CONTROLLER,
|
|
@@ -3549,6 +3547,7 @@ class EndpointContext {
|
|
|
3549
3547
|
//#endregion
|
|
3550
3548
|
}
|
|
3551
3549
|
for (const classTypeName of [
|
|
3550
|
+
Models.ClassType.MIDDLEWARE,
|
|
3552
3551
|
Models.ClassType.PROVIDER,
|
|
3553
3552
|
Models.ClassType.REPOSITORY,
|
|
3554
3553
|
Models.ClassType.CONTROLLER,
|
|
@@ -3749,7 +3748,7 @@ class EndpointContext {
|
|
|
3749
3748
|
//#region methods & getters / init connection
|
|
3750
3749
|
async initDatabaseConnection() {
|
|
3751
3750
|
//#region @websqlFunc
|
|
3752
|
-
if (this.remoteHost) {
|
|
3751
|
+
if (this.remoteHost || !this.databaseConfig) {
|
|
3753
3752
|
return;
|
|
3754
3753
|
}
|
|
3755
3754
|
const entities = this.getClassFunByArr(Models.ClassType.ENTITY).map(entityFn => {
|
|
@@ -3985,7 +3984,80 @@ class EndpointContext {
|
|
|
3985
3984
|
}
|
|
3986
3985
|
//#endregion
|
|
3987
3986
|
//#region methods & getters / init middlewares
|
|
3988
|
-
|
|
3987
|
+
async initFrontnedMiddlewares() {
|
|
3988
|
+
const middlewares = this.getClassesInstancesArrBy(Models.ClassType.MIDDLEWARE);
|
|
3989
|
+
for (const middleware of middlewares) {
|
|
3990
|
+
const middlewareInstance = middleware;
|
|
3991
|
+
if (_.isFunction(middlewareInstance.intercept)) {
|
|
3992
|
+
((instance, contextName, apiPart, uriPathnameOrNothingIfRoot) => {
|
|
3993
|
+
const interceptorName = `${contextName}-${ClassHelpers.getName(instance)}`;
|
|
3994
|
+
Resource.request.interceptors.set(interceptorName, async (req) => {
|
|
3995
|
+
console.log('request', req);
|
|
3996
|
+
const url = new URL(req.url);
|
|
3997
|
+
if (url.pathname.startsWith(`${uriPathnameOrNothingIfRoot}/${apiPart}/${contextName}/`)) {
|
|
3998
|
+
await instance.intercept({
|
|
3999
|
+
client: {
|
|
4000
|
+
req,
|
|
4001
|
+
},
|
|
4002
|
+
});
|
|
4003
|
+
}
|
|
4004
|
+
else {
|
|
4005
|
+
// console.log('not fit frontend', url.href);
|
|
4006
|
+
}
|
|
4007
|
+
return req;
|
|
4008
|
+
});
|
|
4009
|
+
})(middlewareInstance, this.contextName, apiPrefix, this.uriPathnameOrNothingIfRoot);
|
|
4010
|
+
}
|
|
4011
|
+
}
|
|
4012
|
+
}
|
|
4013
|
+
async initBackendMiddlewares() {
|
|
4014
|
+
/* */
|
|
4015
|
+
/* */
|
|
4016
|
+
/* */
|
|
4017
|
+
/* */
|
|
4018
|
+
/* */
|
|
4019
|
+
/* */
|
|
4020
|
+
/* */
|
|
4021
|
+
/* */
|
|
4022
|
+
/* */
|
|
4023
|
+
/* */
|
|
4024
|
+
/* */
|
|
4025
|
+
/* */
|
|
4026
|
+
/* */
|
|
4027
|
+
/* */
|
|
4028
|
+
/* */
|
|
4029
|
+
/* */
|
|
4030
|
+
/* */
|
|
4031
|
+
/* */
|
|
4032
|
+
/* */
|
|
4033
|
+
/* */
|
|
4034
|
+
/* */
|
|
4035
|
+
/* */
|
|
4036
|
+
/* */
|
|
4037
|
+
/* */
|
|
4038
|
+
/* */
|
|
4039
|
+
/* */
|
|
4040
|
+
/* */
|
|
4041
|
+
/* */
|
|
4042
|
+
/* */
|
|
4043
|
+
/* */
|
|
4044
|
+
/* */
|
|
4045
|
+
/* */
|
|
4046
|
+
/* */
|
|
4047
|
+
/* */
|
|
4048
|
+
/* */
|
|
4049
|
+
/* */
|
|
4050
|
+
/* */
|
|
4051
|
+
/* */
|
|
4052
|
+
/* */
|
|
4053
|
+
/* */
|
|
4054
|
+
/* */
|
|
4055
|
+
/* */
|
|
4056
|
+
/* */
|
|
4057
|
+
/* */
|
|
4058
|
+
/* */
|
|
4059
|
+
/* */
|
|
4060
|
+
/* */
|
|
3989
4061
|
/* */
|
|
3990
4062
|
/* */
|
|
3991
4063
|
/* */
|
|
@@ -4765,6 +4837,9 @@ const createContext = (configFn) => {
|
|
|
4765
4837
|
get migrations() {
|
|
4766
4838
|
return config.migrations; // TODO QUICK_FIX new typescript generated wrong types
|
|
4767
4839
|
},
|
|
4840
|
+
get middlewares() {
|
|
4841
|
+
return config.middlewares; // TODO QUICK_FIX new typescript generated wrong types
|
|
4842
|
+
},
|
|
4768
4843
|
},
|
|
4769
4844
|
//#endregion
|
|
4770
4845
|
//#region contexts
|
|
@@ -4859,43 +4934,44 @@ const createContext = (configFn) => {
|
|
|
4859
4934
|
endpointContextRef.writeActiveRoutes();
|
|
4860
4935
|
//#endregion
|
|
4861
4936
|
await endpointContextRef.initClasses();
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
!
|
|
4869
|
-
|
|
4870
|
-
`
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
`
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4937
|
+
if (endpointContextRef.databaseConfig) {
|
|
4938
|
+
let keepWebsqlDbDataAfterReload = false;
|
|
4939
|
+
//#region @browser
|
|
4940
|
+
keepWebsqlDbDataAfterReload =
|
|
4941
|
+
TaonAdminService.Instance?.keepWebsqlDbDataAfterReload;
|
|
4942
|
+
//#endregion
|
|
4943
|
+
if (!Helpers.isNode && keepWebsqlDbDataAfterReload) {
|
|
4944
|
+
!UtilsOs.isRunningInCliMode() &&
|
|
4945
|
+
Helpers.info(`[taon] Keeping websql data after reload ` +
|
|
4946
|
+
`(context=${endpointContextRef.contextName}).`);
|
|
4947
|
+
}
|
|
4948
|
+
else {
|
|
4949
|
+
!UtilsOs.isRunningInCliMode() &&
|
|
4950
|
+
Helpers.info(`[taon] Dropping all tables and data ` +
|
|
4951
|
+
`(context=${endpointContextRef.contextName}).`);
|
|
4952
|
+
}
|
|
4953
|
+
//#region TODO this may be usefull but for now
|
|
4954
|
+
// 2 separate contexts are fine
|
|
4955
|
+
// const shouldStartRemoteHost = endpointContextRef.mode !== 'remote-backend(tcp+udp)';
|
|
4956
|
+
// if(shouldStartRemoteHost) {
|
|
4957
|
+
// const endpointContextRemoteHostRef = new EndpointContext(config, configFn);
|
|
4958
|
+
// await endpointContextRemoteHostRef.init({
|
|
4959
|
+
// overrideRemoteHost: endpointContextRef.host,
|
|
4960
|
+
// overrideHost: null,
|
|
4961
|
+
// });
|
|
4962
|
+
// endpointContextRemoteHostRef.initMetadata();
|
|
4963
|
+
// endpointContextRef.__contextForControllerInstanceAccess = endpointContextRemoteHostRef;
|
|
4964
|
+
// }
|
|
4965
|
+
//#endregion
|
|
4966
|
+
if (endpointContextRef.onlyMigrationRun) {
|
|
4967
|
+
await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
|
|
4968
|
+
}
|
|
4969
|
+
else if (endpointContextRef.onlyMigrationRevertToTimestamp) {
|
|
4970
|
+
await endpointContextRef.dbMigrations.revertMigrationToTimestamp(endpointContextRef.onlyMigrationRevertToTimestamp);
|
|
4971
|
+
}
|
|
4972
|
+
else {
|
|
4973
|
+
await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
|
|
4974
|
+
}
|
|
4899
4975
|
}
|
|
4900
4976
|
resolve(endpointContextRef);
|
|
4901
4977
|
});
|
|
@@ -5027,18 +5103,17 @@ class BaseInjector {
|
|
|
5027
5103
|
//#endregion
|
|
5028
5104
|
//#region inject / global provider
|
|
5029
5105
|
/**
|
|
5030
|
-
*
|
|
5106
|
+
* inject middleware for context
|
|
5031
5107
|
*/
|
|
5032
|
-
|
|
5108
|
+
injectMiddleware(ctor) {
|
|
5033
5109
|
return this.__inject(ctor, { localInstance: false });
|
|
5034
5110
|
}
|
|
5035
5111
|
//#endregion
|
|
5036
5112
|
//#region inject / context provider
|
|
5037
5113
|
/**
|
|
5038
|
-
*
|
|
5039
|
-
* TODO
|
|
5114
|
+
* inject provider for context
|
|
5040
5115
|
*/
|
|
5041
|
-
|
|
5116
|
+
injectProvider(ctor) {
|
|
5042
5117
|
return this.__inject(ctor, { localInstance: false });
|
|
5043
5118
|
}
|
|
5044
5119
|
//#endregion
|
|
@@ -5072,7 +5147,7 @@ class BaseInjector {
|
|
|
5072
5147
|
throw new Error(`Not able to inject "${ClassHelpers.getName(ctor) || ctor.name}" inside ` +
|
|
5073
5148
|
`property "${propName?.toString()}" on class "${ClassHelpers.getName(this)}".
|
|
5074
5149
|
|
|
5075
|
-
Please add "${ClassHelpers.getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories)
|
|
5150
|
+
Please add "${ClassHelpers.getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories or middlewares)
|
|
5076
5151
|
|
|
5077
5152
|
`);
|
|
5078
5153
|
}
|
|
@@ -5106,7 +5181,7 @@ class BaseInjector {
|
|
|
5106
5181
|
throw new Error(`Not able to inject "${classNameNotResolved}" inside ` +
|
|
5107
5182
|
`property "${propName?.toString()}" on class "${ClassHelpers.getName(this)}".
|
|
5108
5183
|
|
|
5109
|
-
Please add "${ClassHelpers.getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories)
|
|
5184
|
+
Please add "${ClassHelpers.getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories or middlewares)
|
|
5110
5185
|
|
|
5111
5186
|
`);
|
|
5112
5187
|
}
|
|
@@ -5737,14 +5812,6 @@ class TaonControllerOptions extends Models.DecoratorAbstractOpt {
|
|
|
5737
5812
|
}
|
|
5738
5813
|
|
|
5739
5814
|
let BaseController = class BaseController extends BaseInjector {
|
|
5740
|
-
/**
|
|
5741
|
-
* @deprecated use migration instead
|
|
5742
|
-
* THIS ONLY WORKS IF NO MIGRATIONS PROVIDED IN CONFIG
|
|
5743
|
-
* Purpose: init example data for db.
|
|
5744
|
-
*/
|
|
5745
|
-
initExampleDbData() {
|
|
5746
|
-
return void 0;
|
|
5747
|
-
}
|
|
5748
5815
|
};
|
|
5749
5816
|
BaseController = __decorate([
|
|
5750
5817
|
TaonController({ className: 'BaseController' })
|
|
@@ -6144,6 +6211,14 @@ BaseCrudController = __decorate([
|
|
|
6144
6211
|
TaonController({ className: 'BaseCrudController' })
|
|
6145
6212
|
], BaseCrudController);
|
|
6146
6213
|
|
|
6214
|
+
/**
|
|
6215
|
+
* TODO
|
|
6216
|
+
* - global provider available in all contexts
|
|
6217
|
+
* - provider available in own context
|
|
6218
|
+
*/
|
|
6219
|
+
class BaseMiddleware extends BaseInjector {
|
|
6220
|
+
}
|
|
6221
|
+
|
|
6147
6222
|
class BaseMigration extends BaseInjector {
|
|
6148
6223
|
/**
|
|
6149
6224
|
* by default is READY to run
|
|
@@ -6338,6 +6413,7 @@ var Base;
|
|
|
6338
6413
|
Base.CustomRepository = BaseCustomRepository;
|
|
6339
6414
|
Base.SubscriberForEntity = BaseSubscriberForEntity;
|
|
6340
6415
|
Base.Migration = BaseMigration;
|
|
6416
|
+
Base.Middleware = BaseMiddleware;
|
|
6341
6417
|
Base.AngularService = BaseAngularsService;
|
|
6342
6418
|
Base.Context = BaseContext;
|
|
6343
6419
|
})(Base || (Base = {}));
|
|
@@ -6365,6 +6441,19 @@ function TaonEntity(options) {
|
|
|
6365
6441
|
class TaonEntityOptions extends Models.DecoratorAbstractOpt {
|
|
6366
6442
|
}
|
|
6367
6443
|
|
|
6444
|
+
/**
|
|
6445
|
+
* Provider decorator
|
|
6446
|
+
*/
|
|
6447
|
+
function TaonMiddleware(options) {
|
|
6448
|
+
return function (constructor) {
|
|
6449
|
+
Reflect.defineMetadata(Symbols.metadata.options.provider, options, constructor);
|
|
6450
|
+
Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
|
|
6451
|
+
ClassHelpers.setName(constructor, options?.className || constructor.name);
|
|
6452
|
+
};
|
|
6453
|
+
}
|
|
6454
|
+
class TaonMiddlewareOptions extends Models.DecoratorAbstractOpt {
|
|
6455
|
+
}
|
|
6456
|
+
|
|
6368
6457
|
/**
|
|
6369
6458
|
* Migration decorator
|
|
6370
6459
|
*/
|
|
@@ -6424,6 +6513,7 @@ var Taon;
|
|
|
6424
6513
|
Taon.Repository = TaonRepository;
|
|
6425
6514
|
Taon.Subscriber = TaonSubscriber;
|
|
6426
6515
|
Taon.Migration = TaonMigration;
|
|
6516
|
+
Taon.Middleware = TaonMiddleware;
|
|
6427
6517
|
//#endregion
|
|
6428
6518
|
//#region aliases to helpers
|
|
6429
6519
|
Taon.isBrowser = coreHelpers.Helpers.isBrowser;
|