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
|
@@ -5,7 +5,7 @@ import { __decorate, __metadata, __param } from 'tslib';
|
|
|
5
5
|
import { walk } from 'lodash-walk-object/browser';
|
|
6
6
|
import { OrignalClassKey, Table } from 'taon-typeorm/browser';
|
|
7
7
|
import { SYMBOL, CLASS } from 'typescript-class-helpers/browser';
|
|
8
|
-
import { Models as Models$1,
|
|
8
|
+
import { Models as Models$1, Resource, RestHeaders, Mapping } from 'ng2-rest/browser';
|
|
9
9
|
import * as i0 from '@angular/core';
|
|
10
10
|
import { InjectionToken, inject as inject$1, Injectable } from '@angular/core';
|
|
11
11
|
import axios from 'axios';
|
|
@@ -215,6 +215,7 @@ var Models;
|
|
|
215
215
|
ClassType["PROVIDER"] = "PROVIDER";
|
|
216
216
|
ClassType["SUBSCRIBER"] = "SUBSCRIBER";
|
|
217
217
|
ClassType["MIGRATION"] = "MIGRATION";
|
|
218
|
+
ClassType["MIDDLEWARE"] = "MIDDLEWARE";
|
|
218
219
|
})(ClassType = Models.ClassType || (Models.ClassType = {}));
|
|
219
220
|
Models.ClassTypeKey = {
|
|
220
221
|
[ClassType.ENTITY]: 'entities',
|
|
@@ -223,6 +224,7 @@ var Models;
|
|
|
223
224
|
[ClassType.PROVIDER]: 'providers',
|
|
224
225
|
[ClassType.SUBSCRIBER]: 'subscribers',
|
|
225
226
|
[ClassType.MIGRATION]: 'migrations',
|
|
227
|
+
[ClassType.MIDDLEWARE]: 'middlewares',
|
|
226
228
|
};
|
|
227
229
|
//#endregion
|
|
228
230
|
//#region models / database connection options
|
|
@@ -608,9 +610,8 @@ const TaonEntityKeysToOmitArr = [
|
|
|
608
610
|
'injectCustomRepo',
|
|
609
611
|
'injectController',
|
|
610
612
|
'injectCtrl',
|
|
611
|
-
'
|
|
612
|
-
'
|
|
613
|
-
'injectContextProvider',
|
|
613
|
+
'injectProvider',
|
|
614
|
+
'injectMiddleware',
|
|
614
615
|
];
|
|
615
616
|
let TAON_CONTEXT;
|
|
616
617
|
//#region @browser
|
|
@@ -717,29 +718,26 @@ const inject = (entity) => {
|
|
|
717
718
|
//#region @browser
|
|
718
719
|
//#endregion
|
|
719
720
|
class BaseAngularsService {
|
|
721
|
+
//#endregion
|
|
720
722
|
constructor() {
|
|
721
723
|
//#region @browser
|
|
722
724
|
this.currentContext = inject$1(TAON_CONTEXT);
|
|
723
|
-
//#region @browser
|
|
724
|
-
this.CURRENT_HOST_BACKEND_PORT = inject$1(CURRENT_HOST_BACKEND_PORT, {
|
|
725
|
-
optional: true,
|
|
726
|
-
});
|
|
727
|
-
// #endregion
|
|
728
725
|
}
|
|
726
|
+
injectController(ctor,
|
|
729
727
|
/**
|
|
730
|
-
*
|
|
731
|
-
* Returns the host URL for the backend service
|
|
732
|
-
* that is running on localhost (normal NodeJS/ExpressJS mode).
|
|
728
|
+
* optional override context
|
|
733
729
|
*/
|
|
734
|
-
|
|
735
|
-
return
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
730
|
+
overrideCurrentContext) {
|
|
731
|
+
return inject(() => {
|
|
732
|
+
let currentContext;
|
|
733
|
+
//#region @browser
|
|
734
|
+
currentContext = overrideCurrentContext ? overrideCurrentContext : this.currentContext;
|
|
735
|
+
//#endregion
|
|
736
|
+
if (!currentContext) {
|
|
737
|
+
throw new Error('No context available. Make sure to initialize the context before injecting controllers.');
|
|
738
|
+
}
|
|
739
|
+
return currentContext ? currentContext.getClass(ctor) : void 0;
|
|
740
|
+
});
|
|
743
741
|
}
|
|
744
742
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: BaseAngularsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
745
743
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: BaseAngularsService }); }
|
|
@@ -1512,7 +1510,8 @@ class RealtimeClient {
|
|
|
1512
1510
|
};
|
|
1513
1511
|
// console.log('[browser] nspPath', nspPath);
|
|
1514
1512
|
if (this.core.ctx.config.frontendHost &&
|
|
1515
|
-
this.core.ctx.config.frontendHost !== ''
|
|
1513
|
+
this.core.ctx.config.frontendHost !== '' &&
|
|
1514
|
+
this.core.ctx.isRunningInsideDocker) {
|
|
1516
1515
|
console.log(`[${this.core.ctx.contextName}] USING FRONTEND HOST ${this.core.ctx.config.frontendHost}`);
|
|
1517
1516
|
nspPath.global = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.global.pathname}`);
|
|
1518
1517
|
nspPath.realtime = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.realtime.pathname}`);
|
|
@@ -2755,6 +2754,7 @@ class EndpointContext {
|
|
|
2755
2754
|
this.injectableTypesfromContexts = [
|
|
2756
2755
|
Models.ClassType.CONTROLLER,
|
|
2757
2756
|
Models.ClassType.PROVIDER,
|
|
2757
|
+
Models.ClassType.MIDDLEWARE,
|
|
2758
2758
|
Models.ClassType.REPOSITORY,
|
|
2759
2759
|
Models.ClassType.SUBSCRIBER,
|
|
2760
2760
|
Models.ClassType.MIGRATION,
|
|
@@ -3021,6 +3021,10 @@ class EndpointContext {
|
|
|
3021
3021
|
...(await this.getRecrusiveClassesfromContextsObj(Models.ClassType.PROVIDER)),
|
|
3022
3022
|
...this.config.providers,
|
|
3023
3023
|
};
|
|
3024
|
+
this.config.middlewares = {
|
|
3025
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models.ClassType.MIDDLEWARE)),
|
|
3026
|
+
...this.config.middlewares,
|
|
3027
|
+
};
|
|
3024
3028
|
this.config.subscribers = {
|
|
3025
3029
|
...(await this.getRecrusiveClassesfromContextsObj(Models.ClassType.SUBSCRIBER)),
|
|
3026
3030
|
...this.config.subscribers,
|
|
@@ -3055,6 +3059,12 @@ class EndpointContext {
|
|
|
3055
3059
|
ctx: this,
|
|
3056
3060
|
classType: Models.ClassType.PROVIDER,
|
|
3057
3061
|
});
|
|
3062
|
+
this.config.middlewares = this.cloneClassesObjWithNewMetadata({
|
|
3063
|
+
classesInput: this.config.middlewares,
|
|
3064
|
+
config: this.config,
|
|
3065
|
+
ctx: this,
|
|
3066
|
+
classType: Models.ClassType.MIDDLEWARE,
|
|
3067
|
+
});
|
|
3058
3068
|
this.config.subscribers = this.cloneClassesObjWithNewMetadata({
|
|
3059
3069
|
classesInput: this.config.subscribers,
|
|
3060
3070
|
config: this.config,
|
|
@@ -3107,6 +3117,11 @@ class EndpointContext {
|
|
|
3107
3117
|
/* */
|
|
3108
3118
|
/* */
|
|
3109
3119
|
/* */
|
|
3120
|
+
/* */
|
|
3121
|
+
/* */
|
|
3122
|
+
/* */
|
|
3123
|
+
/* */
|
|
3124
|
+
await this.initFrontnedMiddlewares();
|
|
3110
3125
|
}
|
|
3111
3126
|
//#endregion
|
|
3112
3127
|
//#region prepare realtime
|
|
@@ -3327,6 +3342,7 @@ class EndpointContext {
|
|
|
3327
3342
|
/* */
|
|
3328
3343
|
/* */
|
|
3329
3344
|
/* */
|
|
3345
|
+
/* */
|
|
3330
3346
|
return (void 0);
|
|
3331
3347
|
}
|
|
3332
3348
|
//#endregion
|
|
@@ -3508,6 +3524,8 @@ class EndpointContext {
|
|
|
3508
3524
|
return this.config.entities;
|
|
3509
3525
|
case Models.ClassType.PROVIDER:
|
|
3510
3526
|
return this.config.providers;
|
|
3527
|
+
case Models.ClassType.MIDDLEWARE:
|
|
3528
|
+
return this.config.middlewares;
|
|
3511
3529
|
case Models.ClassType.REPOSITORY:
|
|
3512
3530
|
return this.config.repositories;
|
|
3513
3531
|
case Models.ClassType.SUBSCRIBER:
|
|
@@ -3521,7 +3539,7 @@ class EndpointContext {
|
|
|
3521
3539
|
}
|
|
3522
3540
|
/**
|
|
3523
3541
|
* Only for injectable types
|
|
3524
|
-
* Only for classType: CONTROLLER, REPOSITORY, PROVIDER
|
|
3542
|
+
* Only for classType: CONTROLLER, REPOSITORY, PROVIDER, MIDDLEWARES
|
|
3525
3543
|
*/
|
|
3526
3544
|
getClassFunByClassName(className) {
|
|
3527
3545
|
for (const classTypeName of this.allTypesfromContexts) {
|
|
@@ -3561,25 +3579,7 @@ class EndpointContext {
|
|
|
3561
3579
|
}
|
|
3562
3580
|
}
|
|
3563
3581
|
//#endregion
|
|
3564
|
-
//#region methods & getters /
|
|
3565
|
-
async reinitControllers() {
|
|
3566
|
-
if (this.remoteHost || Object.keys(this.config.migrations).length > 0) {
|
|
3567
|
-
return;
|
|
3568
|
-
}
|
|
3569
|
-
// Helpers.taskStarted(
|
|
3570
|
-
// `[taon] REINITING CONTROLLERS ${this.contextName} STARTED`,
|
|
3571
|
-
// );
|
|
3572
|
-
const controllers = this.getClassesInstancesArrBy(Models.ClassType.CONTROLLER);
|
|
3573
|
-
// console.log('CONTROLLERS TO REINIT', controllers);
|
|
3574
|
-
for (const ctrl of controllers) {
|
|
3575
|
-
if (_.isFunction(ctrl.initExampleDbData)) {
|
|
3576
|
-
await ctrl.initExampleDbData();
|
|
3577
|
-
}
|
|
3578
|
-
}
|
|
3579
|
-
// Helpers.taskDone(
|
|
3580
|
-
// `[taon] REINITING CONTROLLERS ${this.contextName} DONE`,
|
|
3581
|
-
// );
|
|
3582
|
-
}
|
|
3582
|
+
//#region methods & getters / init classes
|
|
3583
3583
|
async initClasses() {
|
|
3584
3584
|
if (this.remoteHost) {
|
|
3585
3585
|
return;
|
|
@@ -3594,6 +3594,7 @@ class EndpointContext {
|
|
|
3594
3594
|
/* */
|
|
3595
3595
|
/* */
|
|
3596
3596
|
for (const classTypeName of [
|
|
3597
|
+
Models.ClassType.MIDDLEWARE,
|
|
3597
3598
|
Models.ClassType.PROVIDER,
|
|
3598
3599
|
Models.ClassType.REPOSITORY,
|
|
3599
3600
|
Models.ClassType.CONTROLLER,
|
|
@@ -3609,6 +3610,7 @@ class EndpointContext {
|
|
|
3609
3610
|
//#endregion
|
|
3610
3611
|
}
|
|
3611
3612
|
for (const classTypeName of [
|
|
3613
|
+
Models.ClassType.MIDDLEWARE,
|
|
3612
3614
|
Models.ClassType.PROVIDER,
|
|
3613
3615
|
Models.ClassType.REPOSITORY,
|
|
3614
3616
|
Models.ClassType.CONTROLLER,
|
|
@@ -4095,7 +4097,80 @@ class EndpointContext {
|
|
|
4095
4097
|
}
|
|
4096
4098
|
//#endregion
|
|
4097
4099
|
//#region methods & getters / init middlewares
|
|
4098
|
-
|
|
4100
|
+
async initFrontnedMiddlewares() {
|
|
4101
|
+
const middlewares = this.getClassesInstancesArrBy(Models.ClassType.MIDDLEWARE);
|
|
4102
|
+
for (const middleware of middlewares) {
|
|
4103
|
+
const middlewareInstance = middleware;
|
|
4104
|
+
if (_.isFunction(middlewareInstance.intercept)) {
|
|
4105
|
+
((instance, contextName, apiPart, uriPathnameOrNothingIfRoot) => {
|
|
4106
|
+
const interceptorName = `${contextName}-${ClassHelpers.getName(instance)}`;
|
|
4107
|
+
Resource.request.interceptors.set(interceptorName, async (req) => {
|
|
4108
|
+
console.log('request', req);
|
|
4109
|
+
const url = new URL(req.url);
|
|
4110
|
+
if (url.pathname.startsWith(`${uriPathnameOrNothingIfRoot}/${apiPart}/${contextName}/`)) {
|
|
4111
|
+
await instance.intercept({
|
|
4112
|
+
client: {
|
|
4113
|
+
req,
|
|
4114
|
+
},
|
|
4115
|
+
});
|
|
4116
|
+
}
|
|
4117
|
+
else {
|
|
4118
|
+
// console.log('not fit frontend', url.href);
|
|
4119
|
+
}
|
|
4120
|
+
return req;
|
|
4121
|
+
});
|
|
4122
|
+
})(middlewareInstance, this.contextName, apiPrefix, this.uriPathnameOrNothingIfRoot);
|
|
4123
|
+
}
|
|
4124
|
+
}
|
|
4125
|
+
}
|
|
4126
|
+
async initBackendMiddlewares() {
|
|
4127
|
+
/* */
|
|
4128
|
+
/* */
|
|
4129
|
+
/* */
|
|
4130
|
+
/* */
|
|
4131
|
+
/* */
|
|
4132
|
+
/* */
|
|
4133
|
+
/* */
|
|
4134
|
+
/* */
|
|
4135
|
+
/* */
|
|
4136
|
+
/* */
|
|
4137
|
+
/* */
|
|
4138
|
+
/* */
|
|
4139
|
+
/* */
|
|
4140
|
+
/* */
|
|
4141
|
+
/* */
|
|
4142
|
+
/* */
|
|
4143
|
+
/* */
|
|
4144
|
+
/* */
|
|
4145
|
+
/* */
|
|
4146
|
+
/* */
|
|
4147
|
+
/* */
|
|
4148
|
+
/* */
|
|
4149
|
+
/* */
|
|
4150
|
+
/* */
|
|
4151
|
+
/* */
|
|
4152
|
+
/* */
|
|
4153
|
+
/* */
|
|
4154
|
+
/* */
|
|
4155
|
+
/* */
|
|
4156
|
+
/* */
|
|
4157
|
+
/* */
|
|
4158
|
+
/* */
|
|
4159
|
+
/* */
|
|
4160
|
+
/* */
|
|
4161
|
+
/* */
|
|
4162
|
+
/* */
|
|
4163
|
+
/* */
|
|
4164
|
+
/* */
|
|
4165
|
+
/* */
|
|
4166
|
+
/* */
|
|
4167
|
+
/* */
|
|
4168
|
+
/* */
|
|
4169
|
+
/* */
|
|
4170
|
+
/* */
|
|
4171
|
+
/* */
|
|
4172
|
+
/* */
|
|
4173
|
+
/* */
|
|
4099
4174
|
/* */
|
|
4100
4175
|
/* */
|
|
4101
4176
|
/* */
|
|
@@ -4944,6 +5019,9 @@ const createContext = (configFn) => {
|
|
|
4944
5019
|
get migrations() {
|
|
4945
5020
|
return config.migrations; // TODO QUICK_FIX new typescript generated wrong types
|
|
4946
5021
|
},
|
|
5022
|
+
get middlewares() {
|
|
5023
|
+
return config.middlewares; // TODO QUICK_FIX new typescript generated wrong types
|
|
5024
|
+
},
|
|
4947
5025
|
},
|
|
4948
5026
|
//#endregion
|
|
4949
5027
|
//#region contexts
|
|
@@ -5037,43 +5115,44 @@ const createContext = (configFn) => {
|
|
|
5037
5115
|
/* */
|
|
5038
5116
|
/* */
|
|
5039
5117
|
await endpointContextRef.initClasses();
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
!
|
|
5047
|
-
|
|
5048
|
-
`
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
`
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5118
|
+
if (endpointContextRef.databaseConfig) {
|
|
5119
|
+
let keepWebsqlDbDataAfterReload = false;
|
|
5120
|
+
//#region @browser
|
|
5121
|
+
keepWebsqlDbDataAfterReload =
|
|
5122
|
+
TaonAdminService.Instance?.keepWebsqlDbDataAfterReload;
|
|
5123
|
+
//#endregion
|
|
5124
|
+
if (!Helpers.isNode && keepWebsqlDbDataAfterReload) {
|
|
5125
|
+
!UtilsOs.isRunningInCliMode() &&
|
|
5126
|
+
Helpers.info(`[taon] Keeping websql data after reload ` +
|
|
5127
|
+
`(context=${endpointContextRef.contextName}).`);
|
|
5128
|
+
}
|
|
5129
|
+
else {
|
|
5130
|
+
!UtilsOs.isRunningInCliMode() &&
|
|
5131
|
+
Helpers.info(`[taon] Dropping all tables and data ` +
|
|
5132
|
+
`(context=${endpointContextRef.contextName}).`);
|
|
5133
|
+
}
|
|
5134
|
+
//#region TODO this may be usefull but for now
|
|
5135
|
+
// 2 separate contexts are fine
|
|
5136
|
+
// const shouldStartRemoteHost = endpointContextRef.mode !== 'remote-backend(tcp+udp)';
|
|
5137
|
+
// if(shouldStartRemoteHost) {
|
|
5138
|
+
// const endpointContextRemoteHostRef = new EndpointContext(config, configFn);
|
|
5139
|
+
// await endpointContextRemoteHostRef.init({
|
|
5140
|
+
// overrideRemoteHost: endpointContextRef.host,
|
|
5141
|
+
// overrideHost: null,
|
|
5142
|
+
// });
|
|
5143
|
+
// endpointContextRemoteHostRef.initMetadata();
|
|
5144
|
+
// endpointContextRef.__contextForControllerInstanceAccess = endpointContextRemoteHostRef;
|
|
5145
|
+
// }
|
|
5146
|
+
//#endregion
|
|
5147
|
+
if (endpointContextRef.onlyMigrationRun) {
|
|
5148
|
+
await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
|
|
5149
|
+
}
|
|
5150
|
+
else if (endpointContextRef.onlyMigrationRevertToTimestamp) {
|
|
5151
|
+
await endpointContextRef.dbMigrations.revertMigrationToTimestamp(endpointContextRef.onlyMigrationRevertToTimestamp);
|
|
5152
|
+
}
|
|
5153
|
+
else {
|
|
5154
|
+
await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
|
|
5155
|
+
}
|
|
5077
5156
|
}
|
|
5078
5157
|
resolve(endpointContextRef);
|
|
5079
5158
|
});
|
|
@@ -5205,18 +5284,17 @@ class BaseInjector {
|
|
|
5205
5284
|
//#endregion
|
|
5206
5285
|
//#region inject / global provider
|
|
5207
5286
|
/**
|
|
5208
|
-
*
|
|
5287
|
+
* inject middleware for context
|
|
5209
5288
|
*/
|
|
5210
|
-
|
|
5289
|
+
injectMiddleware(ctor) {
|
|
5211
5290
|
return this.__inject(ctor, { localInstance: false });
|
|
5212
5291
|
}
|
|
5213
5292
|
//#endregion
|
|
5214
5293
|
//#region inject / context provider
|
|
5215
5294
|
/**
|
|
5216
|
-
*
|
|
5217
|
-
* TODO
|
|
5295
|
+
* inject provider for context
|
|
5218
5296
|
*/
|
|
5219
|
-
|
|
5297
|
+
injectProvider(ctor) {
|
|
5220
5298
|
return this.__inject(ctor, { localInstance: false });
|
|
5221
5299
|
}
|
|
5222
5300
|
//#endregion
|
|
@@ -5250,7 +5328,7 @@ class BaseInjector {
|
|
|
5250
5328
|
throw new Error(`Not able to inject "${ClassHelpers.getName(ctor) || ctor.name}" inside ` +
|
|
5251
5329
|
`property "${propName?.toString()}" on class "${ClassHelpers.getName(this)}".
|
|
5252
5330
|
|
|
5253
|
-
Please add "${ClassHelpers.getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories)
|
|
5331
|
+
Please add "${ClassHelpers.getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories or middlewares)
|
|
5254
5332
|
|
|
5255
5333
|
`);
|
|
5256
5334
|
}
|
|
@@ -5284,7 +5362,7 @@ class BaseInjector {
|
|
|
5284
5362
|
throw new Error(`Not able to inject "${classNameNotResolved}" inside ` +
|
|
5285
5363
|
`property "${propName?.toString()}" on class "${ClassHelpers.getName(this)}".
|
|
5286
5364
|
|
|
5287
|
-
Please add "${ClassHelpers.getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories)
|
|
5365
|
+
Please add "${ClassHelpers.getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories or middlewares)
|
|
5288
5366
|
|
|
5289
5367
|
`);
|
|
5290
5368
|
}
|
|
@@ -5941,14 +6019,6 @@ class TaonControllerOptions extends Models.DecoratorAbstractOpt {
|
|
|
5941
6019
|
}
|
|
5942
6020
|
|
|
5943
6021
|
let BaseController = class BaseController extends BaseInjector {
|
|
5944
|
-
/**
|
|
5945
|
-
* @deprecated use migration instead
|
|
5946
|
-
* THIS ONLY WORKS IF NO MIGRATIONS PROVIDED IN CONFIG
|
|
5947
|
-
* Purpose: init example data for db.
|
|
5948
|
-
*/
|
|
5949
|
-
initExampleDbData() {
|
|
5950
|
-
return void 0;
|
|
5951
|
-
}
|
|
5952
6022
|
};
|
|
5953
6023
|
BaseController = __decorate([
|
|
5954
6024
|
TaonController({ className: 'BaseController' })
|
|
@@ -6356,6 +6426,14 @@ BaseCrudController = __decorate([
|
|
|
6356
6426
|
TaonController({ className: 'BaseCrudController' })
|
|
6357
6427
|
], BaseCrudController);
|
|
6358
6428
|
|
|
6429
|
+
/**
|
|
6430
|
+
* TODO
|
|
6431
|
+
* - global provider available in all contexts
|
|
6432
|
+
* - provider available in own context
|
|
6433
|
+
*/
|
|
6434
|
+
class BaseMiddleware extends BaseInjector {
|
|
6435
|
+
}
|
|
6436
|
+
|
|
6359
6437
|
class BaseMigration extends BaseInjector {
|
|
6360
6438
|
/**
|
|
6361
6439
|
* by default is READY to run
|
|
@@ -6550,6 +6628,7 @@ var Base;
|
|
|
6550
6628
|
Base.CustomRepository = BaseCustomRepository;
|
|
6551
6629
|
Base.SubscriberForEntity = BaseSubscriberForEntity;
|
|
6552
6630
|
Base.Migration = BaseMigration;
|
|
6631
|
+
Base.Middleware = BaseMiddleware;
|
|
6553
6632
|
Base.AngularService = BaseAngularsService;
|
|
6554
6633
|
Base.Context = BaseContext;
|
|
6555
6634
|
})(Base || (Base = {}));
|
|
@@ -6577,6 +6656,19 @@ function TaonEntity(options) {
|
|
|
6577
6656
|
class TaonEntityOptions extends Models.DecoratorAbstractOpt {
|
|
6578
6657
|
}
|
|
6579
6658
|
|
|
6659
|
+
/**
|
|
6660
|
+
* Provider decorator
|
|
6661
|
+
*/
|
|
6662
|
+
function TaonMiddleware(options) {
|
|
6663
|
+
return function (constructor) {
|
|
6664
|
+
Reflect.defineMetadata(Symbols.metadata.options.provider, options, constructor);
|
|
6665
|
+
Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
|
|
6666
|
+
ClassHelpers.setName(constructor, options?.className || constructor.name);
|
|
6667
|
+
};
|
|
6668
|
+
}
|
|
6669
|
+
class TaonMiddlewareOptions extends Models.DecoratorAbstractOpt {
|
|
6670
|
+
}
|
|
6671
|
+
|
|
6580
6672
|
/**
|
|
6581
6673
|
* Migration decorator
|
|
6582
6674
|
*/
|
|
@@ -6635,6 +6727,7 @@ var Taon;
|
|
|
6635
6727
|
Taon.Repository = TaonRepository;
|
|
6636
6728
|
Taon.Subscriber = TaonSubscriber;
|
|
6637
6729
|
Taon.Migration = TaonMigration;
|
|
6730
|
+
Taon.Middleware = TaonMiddleware;
|
|
6638
6731
|
//#endregion
|
|
6639
6732
|
//#region aliases to helpers
|
|
6640
6733
|
Taon.isBrowser = coreHelpers.Helpers.isBrowser;
|