taon 19.0.51 → 19.0.53
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/README.md +160 -160
- package/bin/start.js +279 -279
- package/bin/taon +6 -6
- package/bin/taon-debug +5 -5
- package/bin/taon-debug-brk +5 -5
- package/browser/README.md +24 -24
- package/browser/fesm2022/taon.mjs +188 -95
- package/browser/fesm2022/taon.mjs.map +1 -1
- package/browser/lib/base-classes/base-angular-service.d.ts +3 -6
- 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 +7 -6
- 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-angular-service.d.ts +3 -6
- package/lib/base-classes/base-angular-service.js +12 -16
- package/lib/base-classes/base-angular-service.js.map +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 +7 -6
- package/lib/endpoint-context.js +87 -32
- package/lib/endpoint-context.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/realtime/realtime-client.js +2 -1
- package/lib/realtime/realtime-client.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/README.md +24 -24
- package/websql/fesm2022/taon.mjs +192 -97
- package/websql/fesm2022/taon.mjs.map +1 -1
- package/websql/lib/base-classes/base-angular-service.d.ts +3 -6
- 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 +7 -6
- package/websql/lib/index.d.ts +8 -2
- package/websql/lib/models.d.ts +65 -5
- package/websql/package.json +1 -1
- package/env.d.ts +0 -3
- package/environments/angular-node-app/env.angular-node-app.__.d.ts +0 -3
- package/environments/angular-node-app/env.angular-node-app.dev.d.ts +0 -3
- package/environments/angular-node-app/env.angular-node-app.localhost.d.ts +0 -3
- package/environments/angular-node-app/env.angular-node-app.prod.d.ts +0 -3
- package/environments/angular-node-app/env.angular-node-app.stage.d.ts +0 -3
- package/environments/docs-webapp/env.docs-webapp.__.d.ts +0 -3
- package/environments/electron-app/env.electron-app.__.d.ts +0 -3
- package/environments/electron-app/env.electron-app.prod.d.ts +0 -3
- package/environments/mobile-app/env.mobile-app.__.d.ts +0 -3
- package/environments/mobile-app/env.mobile-app.prod.d.ts +0 -3
- package/environments/npm-lib-and-cli-tool/env.npm-lib-and-cli-tool.__.d.ts +0 -3
- package/environments/npm-lib-and-cli-tool/env.npm-lib-and-cli-tool.prod.d.ts +0 -3
- package/environments/vscode-plugin/env.vscode-plugin.__.d.ts +0 -6
- package/environments/vscode-plugin/env.vscode-plugin.prod.d.ts +0 -4
- package/lib/ui/directives/index.d.ts +0 -3
- package/lib/ui/directives/index.js +0 -5
- package/lib/ui/directives/index.js.map +0 -1
- package/lib/ui/directives/safe.pipe.d.ts +0 -7
- package/lib/ui/directives/taon-inject-html.directive.d.ts +0 -6
- package/lib/ui/directives/taon-long-press.directive.d.ts +0 -22
- package/lib/ui/directives/view-mode.d.ts +0 -5
- package/lib/ui/directives/view-mode.js +0 -10
- package/lib/ui/directives/view-mode.js.map +0 -1
- package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +0 -43
- package/lib/ui/taon-admin-mode-configuration/taon-admin.models.d.ts +0 -5
- package/lib/ui/taon-admin-mode-configuration/taon-admin.models.js +0 -3
- package/lib/ui/taon-admin-mode-configuration/taon-admin.models.js.map +0 -1
- package/lib/ui/taon-full-material.module.d.ts +0 -5
- package/lib/ui/taon-github-fork-me-corner/index.d.ts +0 -2
- package/lib/ui/taon-github-fork-me-corner/index.js +0 -5
- package/lib/ui/taon-github-fork-me-corner/index.js.map +0 -1
- package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.component.d.ts +0 -3
- package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.module.d.ts +0 -2
- package/lib/ui/taon-github-fork-me-ribbon/index.d.ts +0 -2
- package/lib/ui/taon-github-fork-me-ribbon/index.js +0 -5
- package/lib/ui/taon-github-fork-me-ribbon/index.js.map +0 -1
- package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.component.d.ts +0 -3
- package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.module.d.ts +0 -2
- package/lib/ui/taon-notifications/index.d.ts +0 -4
- package/lib/ui/taon-notifications/index.js +0 -24
- package/lib/ui/taon-notifications/index.js.map +0 -1
- package/lib/ui/taon-notifications/taon-notifications.component.d.ts +0 -9
- package/lib/ui/taon-notifications/taon-notifications.models.d.ts +0 -6
- package/lib/ui/taon-notifications/taon-notifications.models.js +0 -5
- package/lib/ui/taon-notifications/taon-notifications.models.js.map +0 -1
- package/lib/ui/taon-notifications/taon-notifications.module.d.ts +0 -2
- package/lib/ui/taon-notifications/taon-notifications.service.d.ts +0 -11
- package/lib/ui/taon-progress-bar/index.d.ts +0 -2
- package/lib/ui/taon-progress-bar/index.js +0 -5
- package/lib/ui/taon-progress-bar/index.js.map +0 -1
- package/lib/ui/taon-progress-bar/taon-progress-bar.component.d.ts +0 -13
- package/lib/ui/taon-progress-bar/taon-progress-bar.module.d.ts +0 -2
- package/lib/ui/taon-session-passcode/index.d.ts +0 -1
- package/lib/ui/taon-session-passcode/index.js +0 -5
- package/lib/ui/taon-session-passcode/index.js.map +0 -1
- package/lib/ui/taon-session-passcode/taon-session-passcode.component.d.ts +0 -35
- package/lib/ui/taon-table/index.d.ts +0 -2
- package/lib/ui/taon-table/index.js +0 -5
- package/lib/ui/taon-table/index.js.map +0 -1
- package/lib/ui/taon-table/taon-table.component.d.ts +0 -34
- package/lib/ui/taon-table/taon-table.module.d.ts +0 -2
- package/lib/ui/taon.models.d.ts +0 -11
- package/lib/ui/taon.models.js +0 -3
- package/lib/ui/taon.models.js.map +0 -1
- package/tmp-environment.json +0 -32
package/package.json
CHANGED
package/websql/README.md
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
# MyLib
|
|
2
|
-
|
|
3
|
-
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.2.0.
|
|
4
|
-
|
|
5
|
-
## Code scaffolding
|
|
6
|
-
|
|
7
|
-
Run `ng generate component component-name --project my-lib` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project my-lib`.
|
|
8
|
-
> Note: Don't forget to add `--project my-lib` or else it will be added to the default project in your `angular.json` file.
|
|
9
|
-
|
|
10
|
-
## Build
|
|
11
|
-
|
|
12
|
-
Run `ng build my-lib` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
13
|
-
|
|
14
|
-
## Publishing
|
|
15
|
-
|
|
16
|
-
After building your library with `ng build my-lib`, go to the dist folder `cd dist/my-lib` and run `npm publish`.
|
|
17
|
-
|
|
18
|
-
## Running unit tests
|
|
19
|
-
|
|
20
|
-
Run `ng test my-lib` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
21
|
-
|
|
22
|
-
## Further help
|
|
23
|
-
|
|
24
|
-
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|
|
1
|
+
# MyLib
|
|
2
|
+
|
|
3
|
+
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.2.0.
|
|
4
|
+
|
|
5
|
+
## Code scaffolding
|
|
6
|
+
|
|
7
|
+
Run `ng generate component component-name --project my-lib` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project my-lib`.
|
|
8
|
+
> Note: Don't forget to add `--project my-lib` or else it will be added to the default project in your `angular.json` file.
|
|
9
|
+
|
|
10
|
+
## Build
|
|
11
|
+
|
|
12
|
+
Run `ng build my-lib` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
13
|
+
|
|
14
|
+
## Publishing
|
|
15
|
+
|
|
16
|
+
After building your library with `ng build my-lib`, go to the dist folder `cd dist/my-lib` and run `npm publish`.
|
|
17
|
+
|
|
18
|
+
## Running unit tests
|
|
19
|
+
|
|
20
|
+
Run `ng test my-lib` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
21
|
+
|
|
22
|
+
## Further help
|
|
23
|
+
|
|
24
|
+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|
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
|
|
@@ -832,29 +833,26 @@ const inject = (entity) => {
|
|
|
832
833
|
//#region @browser
|
|
833
834
|
//#endregion
|
|
834
835
|
class BaseAngularsService {
|
|
836
|
+
//#endregion
|
|
835
837
|
constructor() {
|
|
836
838
|
//#region @browser
|
|
837
839
|
this.currentContext = inject$1(TAON_CONTEXT);
|
|
838
|
-
//#region @browser
|
|
839
|
-
this.CURRENT_HOST_BACKEND_PORT = inject$1(CURRENT_HOST_BACKEND_PORT, {
|
|
840
|
-
optional: true,
|
|
841
|
-
});
|
|
842
|
-
// #endregion
|
|
843
840
|
}
|
|
841
|
+
injectController(ctor,
|
|
844
842
|
/**
|
|
845
|
-
*
|
|
846
|
-
* Returns the host URL for the backend service
|
|
847
|
-
* that is running on localhost (normal NodeJS/ExpressJS mode).
|
|
843
|
+
* optional override context
|
|
848
844
|
*/
|
|
849
|
-
|
|
850
|
-
return
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
845
|
+
overrideCurrentContext) {
|
|
846
|
+
return inject(() => {
|
|
847
|
+
let currentContext;
|
|
848
|
+
//#region @browser
|
|
849
|
+
currentContext = overrideCurrentContext ? overrideCurrentContext : this.currentContext;
|
|
850
|
+
//#endregion
|
|
851
|
+
if (!currentContext) {
|
|
852
|
+
throw new Error('No context available. Make sure to initialize the context before injecting controllers.');
|
|
853
|
+
}
|
|
854
|
+
return currentContext ? currentContext.getClass(ctor) : void 0;
|
|
855
|
+
});
|
|
858
856
|
}
|
|
859
857
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: BaseAngularsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
860
858
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: BaseAngularsService }); }
|
|
@@ -1520,7 +1518,8 @@ class RealtimeClient {
|
|
|
1520
1518
|
};
|
|
1521
1519
|
// console.log('[browser] nspPath', nspPath);
|
|
1522
1520
|
if (this.core.ctx.config.frontendHost &&
|
|
1523
|
-
this.core.ctx.config.frontendHost !== ''
|
|
1521
|
+
this.core.ctx.config.frontendHost !== '' &&
|
|
1522
|
+
this.core.ctx.isRunningInsideDocker) {
|
|
1524
1523
|
console.log(`[${this.core.ctx.contextName}] USING FRONTEND HOST ${this.core.ctx.config.frontendHost}`);
|
|
1525
1524
|
nspPath.global = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.global.pathname}`);
|
|
1526
1525
|
nspPath.realtime = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.realtime.pathname}`);
|
|
@@ -2707,6 +2706,7 @@ class EndpointContext {
|
|
|
2707
2706
|
this.injectableTypesfromContexts = [
|
|
2708
2707
|
Models.ClassType.CONTROLLER,
|
|
2709
2708
|
Models.ClassType.PROVIDER,
|
|
2709
|
+
Models.ClassType.MIDDLEWARE,
|
|
2710
2710
|
Models.ClassType.REPOSITORY,
|
|
2711
2711
|
Models.ClassType.SUBSCRIBER,
|
|
2712
2712
|
Models.ClassType.MIGRATION,
|
|
@@ -2974,6 +2974,10 @@ class EndpointContext {
|
|
|
2974
2974
|
...(await this.getRecrusiveClassesfromContextsObj(Models.ClassType.PROVIDER)),
|
|
2975
2975
|
...this.config.providers,
|
|
2976
2976
|
};
|
|
2977
|
+
this.config.middlewares = {
|
|
2978
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models.ClassType.MIDDLEWARE)),
|
|
2979
|
+
...this.config.middlewares,
|
|
2980
|
+
};
|
|
2977
2981
|
this.config.subscribers = {
|
|
2978
2982
|
...(await this.getRecrusiveClassesfromContextsObj(Models.ClassType.SUBSCRIBER)),
|
|
2979
2983
|
...this.config.subscribers,
|
|
@@ -3008,6 +3012,12 @@ class EndpointContext {
|
|
|
3008
3012
|
ctx: this,
|
|
3009
3013
|
classType: Models.ClassType.PROVIDER,
|
|
3010
3014
|
});
|
|
3015
|
+
this.config.middlewares = this.cloneClassesObjWithNewMetadata({
|
|
3016
|
+
classesInput: this.config.middlewares,
|
|
3017
|
+
config: this.config,
|
|
3018
|
+
ctx: this,
|
|
3019
|
+
classType: Models.ClassType.MIDDLEWARE,
|
|
3020
|
+
});
|
|
3011
3021
|
this.config.subscribers = this.cloneClassesObjWithNewMetadata({
|
|
3012
3022
|
classesInput: this.config.subscribers,
|
|
3013
3023
|
config: this.config,
|
|
@@ -3060,6 +3070,11 @@ class EndpointContext {
|
|
|
3060
3070
|
/* */
|
|
3061
3071
|
/* */
|
|
3062
3072
|
/* */
|
|
3073
|
+
/* */
|
|
3074
|
+
/* */
|
|
3075
|
+
/* */
|
|
3076
|
+
/* */
|
|
3077
|
+
await this.initFrontnedMiddlewares();
|
|
3063
3078
|
}
|
|
3064
3079
|
//#endregion
|
|
3065
3080
|
//#region prepare realtime
|
|
@@ -3270,6 +3285,7 @@ class EndpointContext {
|
|
|
3270
3285
|
/* */
|
|
3271
3286
|
/* */
|
|
3272
3287
|
/* */
|
|
3288
|
+
/* */
|
|
3273
3289
|
return (void 0);
|
|
3274
3290
|
}
|
|
3275
3291
|
//#endregion
|
|
@@ -3451,6 +3467,8 @@ class EndpointContext {
|
|
|
3451
3467
|
return this.config.entities;
|
|
3452
3468
|
case Models.ClassType.PROVIDER:
|
|
3453
3469
|
return this.config.providers;
|
|
3470
|
+
case Models.ClassType.MIDDLEWARE:
|
|
3471
|
+
return this.config.middlewares;
|
|
3454
3472
|
case Models.ClassType.REPOSITORY:
|
|
3455
3473
|
return this.config.repositories;
|
|
3456
3474
|
case Models.ClassType.SUBSCRIBER:
|
|
@@ -3464,7 +3482,7 @@ class EndpointContext {
|
|
|
3464
3482
|
}
|
|
3465
3483
|
/**
|
|
3466
3484
|
* Only for injectable types
|
|
3467
|
-
* Only for classType: CONTROLLER, REPOSITORY, PROVIDER
|
|
3485
|
+
* Only for classType: CONTROLLER, REPOSITORY, PROVIDER, MIDDLEWARES
|
|
3468
3486
|
*/
|
|
3469
3487
|
getClassFunByClassName(className) {
|
|
3470
3488
|
for (const classTypeName of this.allTypesfromContexts) {
|
|
@@ -3504,25 +3522,7 @@ class EndpointContext {
|
|
|
3504
3522
|
}
|
|
3505
3523
|
}
|
|
3506
3524
|
//#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
|
-
}
|
|
3525
|
+
//#region methods & getters / init classes
|
|
3526
3526
|
async initClasses() {
|
|
3527
3527
|
if (this.remoteHost) {
|
|
3528
3528
|
return;
|
|
@@ -3534,6 +3534,7 @@ class EndpointContext {
|
|
|
3534
3534
|
}
|
|
3535
3535
|
//#endregion
|
|
3536
3536
|
for (const classTypeName of [
|
|
3537
|
+
Models.ClassType.MIDDLEWARE,
|
|
3537
3538
|
Models.ClassType.PROVIDER,
|
|
3538
3539
|
Models.ClassType.REPOSITORY,
|
|
3539
3540
|
Models.ClassType.CONTROLLER,
|
|
@@ -3549,6 +3550,7 @@ class EndpointContext {
|
|
|
3549
3550
|
//#endregion
|
|
3550
3551
|
}
|
|
3551
3552
|
for (const classTypeName of [
|
|
3553
|
+
Models.ClassType.MIDDLEWARE,
|
|
3552
3554
|
Models.ClassType.PROVIDER,
|
|
3553
3555
|
Models.ClassType.REPOSITORY,
|
|
3554
3556
|
Models.ClassType.CONTROLLER,
|
|
@@ -3749,7 +3751,7 @@ class EndpointContext {
|
|
|
3749
3751
|
//#region methods & getters / init connection
|
|
3750
3752
|
async initDatabaseConnection() {
|
|
3751
3753
|
//#region @websqlFunc
|
|
3752
|
-
if (this.remoteHost) {
|
|
3754
|
+
if (this.remoteHost || !this.databaseConfig) {
|
|
3753
3755
|
return;
|
|
3754
3756
|
}
|
|
3755
3757
|
const entities = this.getClassFunByArr(Models.ClassType.ENTITY).map(entityFn => {
|
|
@@ -3823,7 +3825,9 @@ class EndpointContext {
|
|
|
3823
3825
|
[taon][typeorm] db prepration done.. db initialize=${this.connection?.isInitialized}
|
|
3824
3826
|
|
|
3825
3827
|
|
|
3826
|
-
`,
|
|
3828
|
+
`,
|
|
3829
|
+
// dataSourceDbConfig,
|
|
3830
|
+
{ 'this.connection': !!this.connection });
|
|
3827
3831
|
console.log(`Database file location: ${this.connection.options.database}`);
|
|
3828
3832
|
}
|
|
3829
3833
|
// const entityMetadata = getMetadataArgsStorage();
|
|
@@ -3985,7 +3989,80 @@ class EndpointContext {
|
|
|
3985
3989
|
}
|
|
3986
3990
|
//#endregion
|
|
3987
3991
|
//#region methods & getters / init middlewares
|
|
3988
|
-
|
|
3992
|
+
async initFrontnedMiddlewares() {
|
|
3993
|
+
const middlewares = this.getClassesInstancesArrBy(Models.ClassType.MIDDLEWARE);
|
|
3994
|
+
for (const middleware of middlewares) {
|
|
3995
|
+
const middlewareInstance = middleware;
|
|
3996
|
+
if (_.isFunction(middlewareInstance.intercept)) {
|
|
3997
|
+
((instance, contextName, apiPart, uriPathnameOrNothingIfRoot) => {
|
|
3998
|
+
const interceptorName = `${contextName}-${ClassHelpers.getName(instance)}`;
|
|
3999
|
+
Resource.request.interceptors.set(interceptorName, async (req) => {
|
|
4000
|
+
console.log('request', req);
|
|
4001
|
+
const url = new URL(req.url);
|
|
4002
|
+
if (url.pathname.startsWith(`${uriPathnameOrNothingIfRoot}/${apiPart}/${contextName}/`)) {
|
|
4003
|
+
await instance.intercept({
|
|
4004
|
+
client: {
|
|
4005
|
+
req,
|
|
4006
|
+
},
|
|
4007
|
+
});
|
|
4008
|
+
}
|
|
4009
|
+
else {
|
|
4010
|
+
// console.log('not fit frontend', url.href);
|
|
4011
|
+
}
|
|
4012
|
+
return req;
|
|
4013
|
+
});
|
|
4014
|
+
})(middlewareInstance, this.contextName, apiPrefix, this.uriPathnameOrNothingIfRoot);
|
|
4015
|
+
}
|
|
4016
|
+
}
|
|
4017
|
+
}
|
|
4018
|
+
async initBackendMiddlewares() {
|
|
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
|
+
/* */
|
|
4061
|
+
/* */
|
|
4062
|
+
/* */
|
|
4063
|
+
/* */
|
|
4064
|
+
/* */
|
|
4065
|
+
/* */
|
|
3989
4066
|
/* */
|
|
3990
4067
|
/* */
|
|
3991
4068
|
/* */
|
|
@@ -4765,6 +4842,9 @@ const createContext = (configFn) => {
|
|
|
4765
4842
|
get migrations() {
|
|
4766
4843
|
return config.migrations; // TODO QUICK_FIX new typescript generated wrong types
|
|
4767
4844
|
},
|
|
4845
|
+
get middlewares() {
|
|
4846
|
+
return config.middlewares; // TODO QUICK_FIX new typescript generated wrong types
|
|
4847
|
+
},
|
|
4768
4848
|
},
|
|
4769
4849
|
//#endregion
|
|
4770
4850
|
//#region contexts
|
|
@@ -4859,43 +4939,44 @@ const createContext = (configFn) => {
|
|
|
4859
4939
|
endpointContextRef.writeActiveRoutes();
|
|
4860
4940
|
//#endregion
|
|
4861
4941
|
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
|
-
|
|
4942
|
+
if (endpointContextRef.databaseConfig) {
|
|
4943
|
+
let keepWebsqlDbDataAfterReload = false;
|
|
4944
|
+
//#region @browser
|
|
4945
|
+
keepWebsqlDbDataAfterReload =
|
|
4946
|
+
TaonAdminService.Instance?.keepWebsqlDbDataAfterReload;
|
|
4947
|
+
//#endregion
|
|
4948
|
+
if (!Helpers.isNode && keepWebsqlDbDataAfterReload) {
|
|
4949
|
+
!UtilsOs.isRunningInCliMode() &&
|
|
4950
|
+
Helpers.info(`[taon] Keeping websql data after reload ` +
|
|
4951
|
+
`(context=${endpointContextRef.contextName}).`);
|
|
4952
|
+
}
|
|
4953
|
+
else {
|
|
4954
|
+
!UtilsOs.isRunningInCliMode() &&
|
|
4955
|
+
Helpers.info(`[taon] Dropping all tables and data ` +
|
|
4956
|
+
`(context=${endpointContextRef.contextName}).`);
|
|
4957
|
+
}
|
|
4958
|
+
//#region TODO this may be usefull but for now
|
|
4959
|
+
// 2 separate contexts are fine
|
|
4960
|
+
// const shouldStartRemoteHost = endpointContextRef.mode !== 'remote-backend(tcp+udp)';
|
|
4961
|
+
// if(shouldStartRemoteHost) {
|
|
4962
|
+
// const endpointContextRemoteHostRef = new EndpointContext(config, configFn);
|
|
4963
|
+
// await endpointContextRemoteHostRef.init({
|
|
4964
|
+
// overrideRemoteHost: endpointContextRef.host,
|
|
4965
|
+
// overrideHost: null,
|
|
4966
|
+
// });
|
|
4967
|
+
// endpointContextRemoteHostRef.initMetadata();
|
|
4968
|
+
// endpointContextRef.__contextForControllerInstanceAccess = endpointContextRemoteHostRef;
|
|
4969
|
+
// }
|
|
4970
|
+
//#endregion
|
|
4971
|
+
if (endpointContextRef.onlyMigrationRun) {
|
|
4972
|
+
await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
|
|
4973
|
+
}
|
|
4974
|
+
else if (endpointContextRef.onlyMigrationRevertToTimestamp) {
|
|
4975
|
+
await endpointContextRef.dbMigrations.revertMigrationToTimestamp(endpointContextRef.onlyMigrationRevertToTimestamp);
|
|
4976
|
+
}
|
|
4977
|
+
else {
|
|
4978
|
+
await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
|
|
4979
|
+
}
|
|
4899
4980
|
}
|
|
4900
4981
|
resolve(endpointContextRef);
|
|
4901
4982
|
});
|
|
@@ -5027,18 +5108,17 @@ class BaseInjector {
|
|
|
5027
5108
|
//#endregion
|
|
5028
5109
|
//#region inject / global provider
|
|
5029
5110
|
/**
|
|
5030
|
-
*
|
|
5111
|
+
* inject middleware for context
|
|
5031
5112
|
*/
|
|
5032
|
-
|
|
5113
|
+
injectMiddleware(ctor) {
|
|
5033
5114
|
return this.__inject(ctor, { localInstance: false });
|
|
5034
5115
|
}
|
|
5035
5116
|
//#endregion
|
|
5036
5117
|
//#region inject / context provider
|
|
5037
5118
|
/**
|
|
5038
|
-
*
|
|
5039
|
-
* TODO
|
|
5119
|
+
* inject provider for context
|
|
5040
5120
|
*/
|
|
5041
|
-
|
|
5121
|
+
injectProvider(ctor) {
|
|
5042
5122
|
return this.__inject(ctor, { localInstance: false });
|
|
5043
5123
|
}
|
|
5044
5124
|
//#endregion
|
|
@@ -5072,7 +5152,7 @@ class BaseInjector {
|
|
|
5072
5152
|
throw new Error(`Not able to inject "${ClassHelpers.getName(ctor) || ctor.name}" inside ` +
|
|
5073
5153
|
`property "${propName?.toString()}" on class "${ClassHelpers.getName(this)}".
|
|
5074
5154
|
|
|
5075
|
-
Please add "${ClassHelpers.getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories)
|
|
5155
|
+
Please add "${ClassHelpers.getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories or middlewares)
|
|
5076
5156
|
|
|
5077
5157
|
`);
|
|
5078
5158
|
}
|
|
@@ -5106,7 +5186,7 @@ class BaseInjector {
|
|
|
5106
5186
|
throw new Error(`Not able to inject "${classNameNotResolved}" inside ` +
|
|
5107
5187
|
`property "${propName?.toString()}" on class "${ClassHelpers.getName(this)}".
|
|
5108
5188
|
|
|
5109
|
-
Please add "${ClassHelpers.getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories)
|
|
5189
|
+
Please add "${ClassHelpers.getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories or middlewares)
|
|
5110
5190
|
|
|
5111
5191
|
`);
|
|
5112
5192
|
}
|
|
@@ -5737,14 +5817,6 @@ class TaonControllerOptions extends Models.DecoratorAbstractOpt {
|
|
|
5737
5817
|
}
|
|
5738
5818
|
|
|
5739
5819
|
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
5820
|
};
|
|
5749
5821
|
BaseController = __decorate([
|
|
5750
5822
|
TaonController({ className: 'BaseController' })
|
|
@@ -6144,6 +6216,14 @@ BaseCrudController = __decorate([
|
|
|
6144
6216
|
TaonController({ className: 'BaseCrudController' })
|
|
6145
6217
|
], BaseCrudController);
|
|
6146
6218
|
|
|
6219
|
+
/**
|
|
6220
|
+
* TODO
|
|
6221
|
+
* - global provider available in all contexts
|
|
6222
|
+
* - provider available in own context
|
|
6223
|
+
*/
|
|
6224
|
+
class BaseMiddleware extends BaseInjector {
|
|
6225
|
+
}
|
|
6226
|
+
|
|
6147
6227
|
class BaseMigration extends BaseInjector {
|
|
6148
6228
|
/**
|
|
6149
6229
|
* by default is READY to run
|
|
@@ -6338,6 +6418,7 @@ var Base;
|
|
|
6338
6418
|
Base.CustomRepository = BaseCustomRepository;
|
|
6339
6419
|
Base.SubscriberForEntity = BaseSubscriberForEntity;
|
|
6340
6420
|
Base.Migration = BaseMigration;
|
|
6421
|
+
Base.Middleware = BaseMiddleware;
|
|
6341
6422
|
Base.AngularService = BaseAngularsService;
|
|
6342
6423
|
Base.Context = BaseContext;
|
|
6343
6424
|
})(Base || (Base = {}));
|
|
@@ -6365,6 +6446,19 @@ function TaonEntity(options) {
|
|
|
6365
6446
|
class TaonEntityOptions extends Models.DecoratorAbstractOpt {
|
|
6366
6447
|
}
|
|
6367
6448
|
|
|
6449
|
+
/**
|
|
6450
|
+
* Provider decorator
|
|
6451
|
+
*/
|
|
6452
|
+
function TaonMiddleware(options) {
|
|
6453
|
+
return function (constructor) {
|
|
6454
|
+
Reflect.defineMetadata(Symbols.metadata.options.provider, options, constructor);
|
|
6455
|
+
Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
|
|
6456
|
+
ClassHelpers.setName(constructor, options?.className || constructor.name);
|
|
6457
|
+
};
|
|
6458
|
+
}
|
|
6459
|
+
class TaonMiddlewareOptions extends Models.DecoratorAbstractOpt {
|
|
6460
|
+
}
|
|
6461
|
+
|
|
6368
6462
|
/**
|
|
6369
6463
|
* Migration decorator
|
|
6370
6464
|
*/
|
|
@@ -6424,6 +6518,7 @@ var Taon;
|
|
|
6424
6518
|
Taon.Repository = TaonRepository;
|
|
6425
6519
|
Taon.Subscriber = TaonSubscriber;
|
|
6426
6520
|
Taon.Migration = TaonMigration;
|
|
6521
|
+
Taon.Middleware = TaonMiddleware;
|
|
6427
6522
|
//#endregion
|
|
6428
6523
|
//#region aliases to helpers
|
|
6429
6524
|
Taon.isBrowser = coreHelpers.Helpers.isBrowser;
|