taon 21.0.56 → 21.0.57
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/package.json +1 -1
- package/browser-prod/package.json +1 -1
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/package.json +1 -1
- package/lib/ui/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
- package/lib-prod/base-classes/base-abstract-entity.js +9 -21
- package/lib-prod/base-classes/base-abstract-entity.js.map +1 -1
- package/lib-prod/base-classes/base-angular-service.js +3 -7
- package/lib-prod/base-classes/base-angular-service.js.map +1 -1
- package/lib-prod/base-classes/base-class.js +10 -14
- package/lib-prod/base-classes/base-class.js.map +1 -1
- package/lib-prod/base-classes/base-context.js +9 -12
- package/lib-prod/base-classes/base-context.js.map +1 -1
- package/lib-prod/base-classes/base-controller.js +26 -41
- package/lib-prod/base-classes/base-controller.js.map +1 -1
- package/lib-prod/base-classes/base-crud-controller.js +50 -65
- package/lib-prod/base-classes/base-crud-controller.js.map +1 -1
- package/lib-prod/base-classes/base-custom-repository.js +6 -15
- package/lib-prod/base-classes/base-custom-repository.js.map +1 -1
- package/lib-prod/base-classes/base-entity.js +6 -15
- package/lib-prod/base-classes/base-entity.js.map +1 -1
- package/lib-prod/base-classes/base-file-upload.middleware.js +14 -23
- package/lib-prod/base-classes/base-file-upload.middleware.js.map +1 -1
- package/lib-prod/base-classes/base-injector.js +13 -17
- package/lib-prod/base-classes/base-injector.js.map +1 -1
- package/lib-prod/base-classes/base-middleware.js +2 -6
- package/lib-prod/base-classes/base-middleware.js.map +1 -1
- package/lib-prod/base-classes/base-migration.js +7 -11
- package/lib-prod/base-classes/base-migration.js.map +1 -1
- package/lib-prod/base-classes/base-provider.js +2 -6
- package/lib-prod/base-classes/base-provider.js.map +1 -1
- package/lib-prod/base-classes/base-repository.js +19 -31
- package/lib-prod/base-classes/base-repository.js.map +1 -1
- package/lib-prod/base-classes/base-subscriber-for-entity.js +6 -15
- package/lib-prod/base-classes/base-subscriber-for-entity.js.map +1 -1
- package/lib-prod/base-classes/base.js +1 -2
- package/lib-prod/base-classes/base.js.map +1 -1
- package/lib-prod/build-info._auto-generated_.d.ts +1 -1
- package/lib-prod/build-info._auto-generated_.js +6 -9
- package/lib-prod/build-info._auto-generated_.js.map +1 -1
- package/lib-prod/config/controller-config.js +3 -8
- package/lib-prod/config/controller-config.js.map +1 -1
- package/lib-prod/config/controller-options.js +2 -6
- package/lib-prod/config/controller-options.js.map +1 -1
- package/lib-prod/config/method-config.js +1 -5
- package/lib-prod/config/method-config.js.map +1 -1
- package/lib-prod/config/param-config.js +1 -5
- package/lib-prod/config/param-config.js.map +1 -1
- package/lib-prod/constants.js +7 -5
- package/lib-prod/constants.js.map +1 -1
- package/lib-prod/context-db-migrations.js +17 -21
- package/lib-prod/context-db-migrations.js.map +1 -1
- package/lib-prod/create-context.js +13 -18
- package/lib-prod/create-context.js.map +1 -1
- package/lib-prod/decorators/classes/controller-decorator.js +6 -9
- package/lib-prod/decorators/classes/controller-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/entity-decorator.js +16 -21
- package/lib-prod/decorators/classes/entity-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/middleware-decorator.js +9 -14
- package/lib-prod/decorators/classes/middleware-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/migration-decorator.js +8 -13
- package/lib-prod/decorators/classes/migration-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/provider-decorator.js +8 -13
- package/lib-prod/decorators/classes/provider-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/repository-decorator.js +8 -13
- package/lib-prod/decorators/classes/repository-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/subscriber-decorator.js +8 -13
- package/lib-prod/decorators/classes/subscriber-decorator.js.map +1 -1
- package/lib-prod/decorators/decorator-abstract-opt.js +1 -5
- package/lib-prod/decorators/decorator-abstract-opt.js.map +1 -1
- package/lib-prod/decorators/http/http-decorators.js +2 -5
- package/lib-prod/decorators/http/http-decorators.js.map +1 -1
- package/lib-prod/decorators/http/http-methods-decorators.js +11 -20
- package/lib-prod/decorators/http/http-methods-decorators.js.map +1 -1
- package/lib-prod/decorators/http/http-params-decorators.js +7 -14
- package/lib-prod/decorators/http/http-params-decorators.js.map +1 -1
- package/lib-prod/dependency-injection/di-container.js +1 -5
- package/lib-prod/dependency-injection/di-container.js.map +1 -1
- package/lib-prod/endpoint-context-storage.js +3 -7
- package/lib-prod/endpoint-context-storage.js.map +1 -1
- package/lib-prod/endpoint-context.js +282 -286
- package/lib-prod/endpoint-context.js.map +1 -1
- package/lib-prod/entity-process.js +54 -60
- package/lib-prod/entity-process.js.map +1 -1
- package/lib-prod/env/env.angular-node-app.js +64 -68
- package/lib-prod/env/env.angular-node-app.js.map +1 -1
- package/lib-prod/env/env.docs-webapp.js +64 -68
- package/lib-prod/env/env.docs-webapp.js.map +1 -1
- package/lib-prod/env/env.electron-app.js +64 -68
- package/lib-prod/env/env.electron-app.js.map +1 -1
- package/lib-prod/env/env.mobile-app.js +64 -68
- package/lib-prod/env/env.mobile-app.js.map +1 -1
- package/lib-prod/env/env.npm-lib-and-cli-tool.js +64 -68
- package/lib-prod/env/env.npm-lib-and-cli-tool.js.map +1 -1
- package/lib-prod/env/env.vscode-plugin.js +64 -68
- package/lib-prod/env/env.vscode-plugin.js.map +1 -1
- package/lib-prod/env/index.js +6 -22
- package/lib-prod/env/index.js.map +1 -1
- package/lib-prod/express-types.js +1 -2
- package/lib-prod/formly/formly.models.js +1 -2
- package/lib-prod/formly/fromly.js +29 -32
- package/lib-prod/formly/fromly.js.map +1 -1
- package/lib-prod/formly/type-from-entity.js +15 -23
- package/lib-prod/formly/type-from-entity.js.map +1 -1
- package/lib-prod/get-response-value.js +1 -5
- package/lib-prod/get-response-value.js.map +1 -1
- package/lib-prod/global-state/taon-global-state/index.js +5 -21
- package/lib-prod/global-state/taon-global-state/index.js.map +1 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.abstract.context.js +14 -17
- package/lib-prod/global-state/taon-global-state/taon-global-state.abstract.context.js.map +1 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.constants.js +3 -6
- package/lib-prod/global-state/taon-global-state/taon-global-state.constants.js.map +1 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.js +16 -31
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.js.map +1 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.entity.js +13 -25
- package/lib-prod/global-state/taon-global-state/taon-global-state.entity.js.map +1 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.js +6 -15
- package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.js.map +1 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.models.js +3 -6
- package/lib-prod/global-state/taon-global-state/taon-global-state.models.js.map +1 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.provider.js +6 -15
- package/lib-prod/global-state/taon-global-state/taon-global-state.provider.js.map +1 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.repository.js +13 -22
- package/lib-prod/global-state/taon-global-state/taon-global-state.repository.js.map +1 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.js +10 -19
- package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.js.map +1 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.js +3 -7
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.js.map +1 -1
- package/lib-prod/global-state/taon-transaction-registry/index.js +10 -26
- package/lib-prod/global-state/taon-transaction-registry/index.js.map +1 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.js +16 -19
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.js.map +1 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.js +1 -4
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.js.map +1 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js +14 -29
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js.map +1 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.js +14 -26
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.js.map +1 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js +6 -15
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js.map +1 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.js +2 -5
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.js.map +1 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.js +6 -15
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.js.map +1 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.js +10 -19
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.js.map +1 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js +10 -19
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js.map +1 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js +1 -4
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js.map +1 -1
- package/lib-prod/helpers/class-helpers.js +60 -77
- package/lib-prod/helpers/class-helpers.js.map +1 -1
- package/lib-prod/helpers/clone-obj.js +7 -11
- package/lib-prod/helpers/clone-obj.js.map +1 -1
- package/lib-prod/helpers/taon-helpers.js +21 -35
- package/lib-prod/helpers/taon-helpers.js.map +1 -1
- package/lib-prod/index.js +73 -93
- package/lib-prod/index.js.map +1 -1
- package/lib-prod/inject.js +4 -8
- package/lib-prod/inject.js.map +1 -1
- package/lib-prod/migrations/index.js +1 -17
- package/lib-prod/migrations/index.js.map +1 -1
- package/lib-prod/models.js +14 -20
- package/lib-prod/models.js.map +1 -1
- package/lib-prod/orm/columns.js +22 -69
- package/lib-prod/orm/columns.js.map +1 -1
- package/lib-prod/orm/index.js +1 -17
- package/lib-prod/orm/index.js.map +1 -1
- package/lib-prod/package.json +1 -1
- package/lib-prod/realtime/realtime-client.js +23 -27
- package/lib-prod/realtime/realtime-client.js.map +1 -1
- package/lib-prod/realtime/realtime-core.js +16 -20
- package/lib-prod/realtime/realtime-core.js.map +1 -1
- package/lib-prod/realtime/realtime-server.js +28 -32
- package/lib-prod/realtime/realtime-server.js.map +1 -1
- package/lib-prod/realtime/realtime-strategy/index.js +4 -20
- package/lib-prod/realtime/realtime-strategy/index.js.map +1 -1
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js +11 -18
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js.map +1 -1
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js +5 -9
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js.map +1 -1
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.js +6 -10
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.js.map +1 -1
- package/lib-prod/realtime/realtime-strategy/realtime-strategy.js +1 -5
- package/lib-prod/realtime/realtime-strategy/realtime-strategy.js.map +1 -1
- package/lib-prod/realtime/realtime-subs-manager.js +11 -15
- package/lib-prod/realtime/realtime-subs-manager.js.map +1 -1
- package/lib-prod/realtime/realtime.models.js +1 -2
- package/lib-prod/realtime/realtime.models.js.map +1 -1
- package/lib-prod/symbols.js +14 -17
- package/lib-prod/symbols.js.map +1 -1
- package/lib-prod/ui/index.d.ts +1 -1
- package/lib-prod/ui/index.js +1 -4
- package/lib-prod/ui/index.js.map +1 -1
- package/lib-prod/ui/taon-admin-mode-configuration/index.d.ts +1 -1
- package/lib-prod/ui/taon-admin-mode-configuration/index.js +1 -4
- package/lib-prod/ui/taon-admin-mode-configuration/index.js.map +1 -1
- package/lib-prod/validators.js +12 -19
- package/lib-prod/validators.js.map +1 -1
- package/package.json +1 -1
- package/websql/package.json +1 -1
- package/websql-prod/package.json +1 -1
|
@@ -1,33 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const models_1 = require("./models");
|
|
29
|
-
const realtime_core_1 = require("./realtime/realtime-core");
|
|
30
|
-
const symbols_1 = require("./symbols");
|
|
1
|
+
import { URL } from 'url'; // @backend
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import { ipcMain } from 'electron'; // @backend
|
|
4
|
+
import { JSON10 } from 'json10/lib-prod';
|
|
5
|
+
import { walk } from 'lodash-walk-object/lib-prod';
|
|
6
|
+
import { Resource, RestHeaders, Mapping__NS__decode, Mapping__NS__encode } from 'ng2-rest/lib-prod';
|
|
7
|
+
import { from } from 'rxjs';
|
|
8
|
+
import { EventSubscriber } from 'taon-typeorm/lib-prod'; // @websql
|
|
9
|
+
import { Entity as TypeormEntity } from 'taon-typeorm/lib-prod'; // @websql
|
|
10
|
+
import { DataSource, } from 'taon-typeorm/lib-prod';
|
|
11
|
+
import { path, requireDefault } from 'tnp-core/lib-prod';
|
|
12
|
+
import { config } from 'tnp-core/lib-prod';
|
|
13
|
+
import { CoreModels__NS__TaonHttpErrorCustomProp } from 'tnp-core/lib-prod';
|
|
14
|
+
import { fse, http, https } from 'tnp-core/lib-prod'; // @backend
|
|
15
|
+
import { Utils__NS__uniqArray, UtilsOs__NS__getRealHomeDir, UtilsOs__NS__isBrowser, UtilsOs__NS__isElectron, UtilsOs__NS__isNode, UtilsOs__NS__isRunningInCliMode, UtilsOs__NS__isRunningInDocker, UtilsOs__NS__isWebSQL } from 'tnp-core/lib-prod';
|
|
16
|
+
import { crossPlatformPath } from 'tnp-core/lib-prod';
|
|
17
|
+
import { ___NS__cloneDeep, ___NS__first, ___NS__isBoolean, ___NS__isFunction, ___NS__isNil, ___NS__isObject, ___NS__isString, ___NS__isUndefined, ___NS__last, ___NS__set, ___NS__slice, ___NS__snakeCase, ___NS__startCase, Helpers__NS__error, Helpers__NS__exists, Helpers__NS__info, Helpers__NS__log, Helpers__NS__mkdirp, Helpers__NS__throwError, Helpers__NS__writeFile } from 'tnp-core/lib-prod';
|
|
18
|
+
import { apiPrefix } from './constants';
|
|
19
|
+
import { ContextDbMigrations } from './context-db-migrations';
|
|
20
|
+
import { DITaonContainer } from './dependency-injection/di-container';
|
|
21
|
+
import { EntityProcess } from './entity-process';
|
|
22
|
+
import { getResponseValue } from './get-response-value';
|
|
23
|
+
import { ClassHelpers__NS__asyncHandler, ClassHelpers__NS__getControllerConfigs, ClassHelpers__NS__getMethodsNames, ClassHelpers__NS__getName, ClassHelpers__NS__getOrginalClass } from './helpers/class-helpers';
|
|
24
|
+
import { TaonHelpers__NS__fillUpTo, TaonHelpers__NS__firstStringOrElemFromArray, TaonHelpers__NS__getExpressPath, TaonHelpers__NS__ipcKeyNameRequest, TaonHelpers__NS__ipcKeyNameResponse, TaonHelpers__NS__isGoodPath, TaonHelpers__NS__parseJSONwithStringJSONs, TaonHelpers__NS__tryTransformParam, TaonHelpers__NS__websqlMocks } from './helpers/taon-helpers';
|
|
25
|
+
import { Models__NS__ClassType, Models__NS__ClassTypeKey, Models__NS__DatabaseConfig, Models__NS__DatabasesFolder } from './models';
|
|
26
|
+
import { RealtimeCore } from './realtime/realtime-core';
|
|
27
|
+
import { Symbols__NS__classMethodsNames, Symbols__NS__classNameStaticProperty, Symbols__NS__ctxInClassOrClassObj, Symbols__NS__fullClassNameStaticProperty, Symbols__NS__metadata, Symbols__NS__old, Symbols__NS__orignalClass } from './symbols';
|
|
31
28
|
/* */
|
|
32
29
|
//#endregion
|
|
33
30
|
let bodyParser;
|
|
@@ -37,14 +34,14 @@ let express;
|
|
|
37
34
|
let methodOverride;
|
|
38
35
|
let expressSession;
|
|
39
36
|
//#region @backend
|
|
40
|
-
bodyParser =
|
|
41
|
-
cookieParser =
|
|
42
|
-
cors =
|
|
43
|
-
express =
|
|
44
|
-
methodOverride =
|
|
45
|
-
expressSession =
|
|
37
|
+
bodyParser = requireDefault('body-parser');
|
|
38
|
+
cookieParser = requireDefault('cookie-parser');
|
|
39
|
+
cors = requireDefault('cors');
|
|
40
|
+
express = requireDefault('express');
|
|
41
|
+
methodOverride = requireDefault('method-override');
|
|
42
|
+
expressSession = requireDefault('express-session');
|
|
46
43
|
//#endregion
|
|
47
|
-
class EndpointContext {
|
|
44
|
+
export class EndpointContext {
|
|
48
45
|
originalConfig;
|
|
49
46
|
configFn;
|
|
50
47
|
cloneOptions;
|
|
@@ -64,7 +61,7 @@ class EndpointContext {
|
|
|
64
61
|
inited = false;
|
|
65
62
|
//#endregion
|
|
66
63
|
//#region fields / db migrations
|
|
67
|
-
dbMigrations = new
|
|
64
|
+
dbMigrations = new ContextDbMigrations(this);
|
|
68
65
|
//#endregion
|
|
69
66
|
//#region fields / local instance obj symbol
|
|
70
67
|
localInstaceObjSymbol = Symbol('localInstaceObjSymbol');
|
|
@@ -100,18 +97,18 @@ class EndpointContext {
|
|
|
100
97
|
//#endregion
|
|
101
98
|
//#region fields / types from contexts
|
|
102
99
|
injectableTypesfromContexts = [
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
Models__NS__ClassType.CONTROLLER,
|
|
101
|
+
Models__NS__ClassType.PROVIDER,
|
|
102
|
+
Models__NS__ClassType.MIDDLEWARE,
|
|
103
|
+
Models__NS__ClassType.REPOSITORY,
|
|
104
|
+
Models__NS__ClassType.SUBSCRIBER,
|
|
105
|
+
Models__NS__ClassType.MIGRATION,
|
|
109
106
|
];
|
|
110
107
|
//#endregion
|
|
111
108
|
//#region fields / all types from contexts
|
|
112
109
|
allTypesfromContexts = [
|
|
113
110
|
...this.injectableTypesfromContexts,
|
|
114
|
-
|
|
111
|
+
Models__NS__ClassType.ENTITY,
|
|
115
112
|
];
|
|
116
113
|
//#endregion
|
|
117
114
|
//#region fields / express app
|
|
@@ -159,37 +156,37 @@ class EndpointContext {
|
|
|
159
156
|
//#endregion
|
|
160
157
|
//#region fields / logs
|
|
161
158
|
get logHttp() {
|
|
162
|
-
if (
|
|
159
|
+
if (___NS__isObject(this.config?.logs)) {
|
|
163
160
|
return !!this.config.logs.http;
|
|
164
161
|
}
|
|
165
162
|
return this.config?.logs === true;
|
|
166
163
|
}
|
|
167
164
|
get logRealtime() {
|
|
168
|
-
if (
|
|
165
|
+
if (___NS__isObject(this.config?.logs)) {
|
|
169
166
|
return !!this.config.logs.realtime;
|
|
170
167
|
}
|
|
171
168
|
return this.config?.logs === true;
|
|
172
169
|
}
|
|
173
170
|
get logFramework() {
|
|
174
|
-
if (
|
|
171
|
+
if (___NS__isObject(this.config?.logs)) {
|
|
175
172
|
return !!this.config.logs.framework;
|
|
176
173
|
}
|
|
177
174
|
return this.config?.logs === true;
|
|
178
175
|
}
|
|
179
176
|
get logRoutes() {
|
|
180
|
-
if (
|
|
177
|
+
if (___NS__isObject(this.config?.logs)) {
|
|
181
178
|
return !!this.config.logs.routes;
|
|
182
179
|
}
|
|
183
180
|
return this.config?.logs === true;
|
|
184
181
|
}
|
|
185
182
|
get logDb() {
|
|
186
|
-
if (
|
|
183
|
+
if (___NS__isObject(this.config?.logs)) {
|
|
187
184
|
return !!this.config.logs.db;
|
|
188
185
|
}
|
|
189
186
|
return this.config?.logs === true;
|
|
190
187
|
}
|
|
191
188
|
get logMigrations() {
|
|
192
|
-
if (
|
|
189
|
+
if (___NS__isObject(this.config?.logs)) {
|
|
193
190
|
return !!this.config.logs.migrations;
|
|
194
191
|
}
|
|
195
192
|
return this.config?.logs === true;
|
|
@@ -213,7 +210,7 @@ class EndpointContext {
|
|
|
213
210
|
this.configFn = configFn;
|
|
214
211
|
this.cloneOptions = cloneOptions;
|
|
215
212
|
this.cloneOptions = this.cloneOptions || {};
|
|
216
|
-
this.isRunningInsideDocker =
|
|
213
|
+
this.isRunningInsideDocker = UtilsOs__NS__isRunningInDocker();
|
|
217
214
|
}
|
|
218
215
|
//#endregion
|
|
219
216
|
//#region methods & getters / init
|
|
@@ -225,8 +222,8 @@ class EndpointContext {
|
|
|
225
222
|
// @ts-ignore
|
|
226
223
|
this.onlyMigrationRevertToTimestamp = onlyMigrationRevertToTimestamp;
|
|
227
224
|
this.config = this.configFn({});
|
|
228
|
-
if (
|
|
229
|
-
this.config.database =
|
|
225
|
+
if (___NS__isObject(this.config.database)) {
|
|
226
|
+
this.config.database = Models__NS__DatabaseConfig.from(this.config.database).databaseConfigTypeORM;
|
|
230
227
|
}
|
|
231
228
|
this.config.host = this.host === null ? void 0 : this.host;
|
|
232
229
|
if (this.cloneOptions.overrideHost &&
|
|
@@ -240,15 +237,15 @@ class EndpointContext {
|
|
|
240
237
|
if (this.config.host &&
|
|
241
238
|
!this.config.host.startsWith('http://') &&
|
|
242
239
|
!this.config.host.startsWith('https://')) {
|
|
243
|
-
|
|
240
|
+
Helpers__NS__throwError(`[taon-config] Your${this.host ? ' remote' : ''} 'host' must start with http:// or https://`);
|
|
244
241
|
}
|
|
245
|
-
if (
|
|
242
|
+
if (___NS__isUndefined(this.config.useIpcWhenElectron)) {
|
|
246
243
|
this.config.useIpcWhenElectron = true;
|
|
247
244
|
}
|
|
248
245
|
// console.log(`config for ${this.contextName}`, this.config);
|
|
249
246
|
//#region resolve if skipping writing server routes
|
|
250
247
|
//@ts-expect-error overriding readonly
|
|
251
|
-
this.skipWritingServerRoutes =
|
|
248
|
+
this.skipWritingServerRoutes = ___NS__isBoolean(this.config.skipWritingServerRoutes)
|
|
252
249
|
? this.config.skipWritingServerRoutes
|
|
253
250
|
: false;
|
|
254
251
|
//#endregion
|
|
@@ -265,8 +262,8 @@ class EndpointContext {
|
|
|
265
262
|
// useIpcWhenElectron: ${this.config.useIpcWhenElectron}
|
|
266
263
|
// UtilsOs__NS__isElectron: ${UtilsOs__NS__isElectron}
|
|
267
264
|
// `)
|
|
268
|
-
if (this.config.useIpcWhenElectron &&
|
|
269
|
-
if (
|
|
265
|
+
if (this.config.useIpcWhenElectron && UtilsOs__NS__isElectron) {
|
|
266
|
+
if (UtilsOs__NS__isWebSQL) {
|
|
270
267
|
this.mode = 'backend-frontend(websql-electron)';
|
|
271
268
|
}
|
|
272
269
|
else {
|
|
@@ -281,7 +278,7 @@ class EndpointContext {
|
|
|
281
278
|
if (!this.mode && !this.config.abstract) {
|
|
282
279
|
const errMsg = `You need to provide host property or ` +
|
|
283
280
|
`useIpcWhenElectron or mark it as abstract`;
|
|
284
|
-
|
|
281
|
+
Helpers__NS__error(`[taon][Context=${this.contextName}]: ${errMsg}`, false, true);
|
|
285
282
|
//#region @backend
|
|
286
283
|
process.exit(1);
|
|
287
284
|
//#endregion
|
|
@@ -297,7 +294,7 @@ class EndpointContext {
|
|
|
297
294
|
`);
|
|
298
295
|
this.databaseConfig = this.getAutoGeneratedConfig();
|
|
299
296
|
}
|
|
300
|
-
else if (
|
|
297
|
+
else if (___NS__isObject(this.config.database)) {
|
|
301
298
|
this.logFramework &&
|
|
302
299
|
console.log(`
|
|
303
300
|
|
|
@@ -305,14 +302,14 @@ class EndpointContext {
|
|
|
305
302
|
|
|
306
303
|
`);
|
|
307
304
|
this.databaseConfig = this.getAutoGeneratedConfig();
|
|
308
|
-
|
|
309
|
-
if (
|
|
305
|
+
walk.Object(this.config.database, (value, lodashPath) => {
|
|
306
|
+
if (___NS__isNil(value) || ___NS__isFunction(value) || ___NS__isObject(value)) {
|
|
310
307
|
// skipping
|
|
311
308
|
}
|
|
312
309
|
else {
|
|
313
310
|
this.logFramework &&
|
|
314
311
|
console.info(`Overriding database config: ${lodashPath}=${value}`);
|
|
315
|
-
|
|
312
|
+
___NS__set(this.databaseConfig, lodashPath, value);
|
|
316
313
|
}
|
|
317
314
|
}, {
|
|
318
315
|
walkGetters: false,
|
|
@@ -321,13 +318,13 @@ class EndpointContext {
|
|
|
321
318
|
//#endregion
|
|
322
319
|
//#region resolve session
|
|
323
320
|
if (this.config.session) {
|
|
324
|
-
this.session =
|
|
321
|
+
this.session = ___NS__cloneDeep(this.config.session);
|
|
325
322
|
const oneHour = 1000 * 60 * 60 * 1; // 24;
|
|
326
323
|
if (!this.session.cookieMaxAge) {
|
|
327
324
|
this.session.cookieMaxAge = oneHour;
|
|
328
325
|
}
|
|
329
326
|
// serever and browser cookie authentication
|
|
330
|
-
|
|
327
|
+
axios.defaults.withCredentials = true;
|
|
331
328
|
}
|
|
332
329
|
//#endregion
|
|
333
330
|
//#region prepare & gather all classes recursively
|
|
@@ -339,31 +336,31 @@ class EndpointContext {
|
|
|
339
336
|
this.config.subscribers = this.config.subscribers || {};
|
|
340
337
|
this.config.migrations = this.config.migrations || {};
|
|
341
338
|
this.config.entities = {
|
|
342
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
339
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models__NS__ClassType.ENTITY)),
|
|
343
340
|
...this.config.entities,
|
|
344
341
|
};
|
|
345
342
|
this.config.controllers = {
|
|
346
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
343
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models__NS__ClassType.CONTROLLER)),
|
|
347
344
|
...this.config.controllers,
|
|
348
345
|
};
|
|
349
346
|
this.config.providers = {
|
|
350
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
347
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models__NS__ClassType.PROVIDER)),
|
|
351
348
|
...this.config.providers,
|
|
352
349
|
};
|
|
353
350
|
this.config.middlewares = {
|
|
354
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
351
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models__NS__ClassType.MIDDLEWARE)),
|
|
355
352
|
...this.config.middlewares,
|
|
356
353
|
};
|
|
357
354
|
this.config.subscribers = {
|
|
358
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
355
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models__NS__ClassType.SUBSCRIBER)),
|
|
359
356
|
...this.config.subscribers,
|
|
360
357
|
};
|
|
361
358
|
this.config.repositories = {
|
|
362
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
359
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models__NS__ClassType.REPOSITORY)),
|
|
363
360
|
...this.config.repositories,
|
|
364
361
|
};
|
|
365
362
|
this.config.migrations = {
|
|
366
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
363
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models__NS__ClassType.MIGRATION)),
|
|
367
364
|
...this.config.migrations,
|
|
368
365
|
};
|
|
369
366
|
// console.log(this.config);
|
|
@@ -374,37 +371,37 @@ class EndpointContext {
|
|
|
374
371
|
classesInput: this.config.controllers,
|
|
375
372
|
config: this.config,
|
|
376
373
|
ctx: this,
|
|
377
|
-
classType:
|
|
374
|
+
classType: Models__NS__ClassType.CONTROLLER,
|
|
378
375
|
});
|
|
379
376
|
this.config.repositories = this.cloneClassesObjWithNewMetadata({
|
|
380
377
|
classesInput: this.config.repositories,
|
|
381
378
|
config: this.config,
|
|
382
379
|
ctx: this,
|
|
383
|
-
classType:
|
|
380
|
+
classType: Models__NS__ClassType.REPOSITORY,
|
|
384
381
|
});
|
|
385
382
|
this.config.providers = this.cloneClassesObjWithNewMetadata({
|
|
386
383
|
classesInput: this.config.providers,
|
|
387
384
|
config: this.config,
|
|
388
385
|
ctx: this,
|
|
389
|
-
classType:
|
|
386
|
+
classType: Models__NS__ClassType.PROVIDER,
|
|
390
387
|
});
|
|
391
388
|
this.config.middlewares = this.cloneClassesObjWithNewMetadata({
|
|
392
389
|
classesInput: this.config.middlewares,
|
|
393
390
|
config: this.config,
|
|
394
391
|
ctx: this,
|
|
395
|
-
classType:
|
|
392
|
+
classType: Models__NS__ClassType.MIDDLEWARE,
|
|
396
393
|
});
|
|
397
394
|
this.config.subscribers = this.cloneClassesObjWithNewMetadata({
|
|
398
395
|
classesInput: this.config.subscribers,
|
|
399
396
|
config: this.config,
|
|
400
397
|
ctx: this,
|
|
401
|
-
classType:
|
|
398
|
+
classType: Models__NS__ClassType.SUBSCRIBER,
|
|
402
399
|
});
|
|
403
400
|
this.config.migrations = this.cloneClassesObjWithNewMetadata({
|
|
404
401
|
classesInput: this.config.migrations,
|
|
405
402
|
config: this.config,
|
|
406
403
|
ctx: this,
|
|
407
|
-
classType:
|
|
404
|
+
classType: Models__NS__ClassType.MIGRATION,
|
|
408
405
|
});
|
|
409
406
|
//#endregion
|
|
410
407
|
//#region prepare instances
|
|
@@ -413,7 +410,7 @@ class EndpointContext {
|
|
|
413
410
|
this.objWithClassesInstancesArr[classTypeName] = [];
|
|
414
411
|
}
|
|
415
412
|
for (const classTypeName of this.injectableTypesfromContexts) {
|
|
416
|
-
await this.createInstances(this.config[
|
|
413
|
+
await this.createInstances(this.config[Models__NS__ClassTypeKey[classTypeName]], classTypeName);
|
|
417
414
|
}
|
|
418
415
|
//#endregion
|
|
419
416
|
if (!this.isRunOrRevertOnlyMigrationAppStart) {
|
|
@@ -428,17 +425,17 @@ class EndpointContext {
|
|
|
428
425
|
await this.initCustomBackendMiddlewares();
|
|
429
426
|
const shouldStartHttpsSecureServer = this.isHttpServer && !this.isRunningInsideDocker;
|
|
430
427
|
this.logFramework &&
|
|
431
|
-
|
|
428
|
+
Helpers__NS__info(`
|
|
432
429
|
|
|
433
430
|
Starting server ${shouldStartHttpsSecureServer ? 'with' : 'without'} HTTPS secure server
|
|
434
431
|
|
|
435
432
|
`);
|
|
436
433
|
this.serverTcpUdp = shouldStartHttpsSecureServer
|
|
437
|
-
? new
|
|
434
|
+
? new https.Server({
|
|
438
435
|
key: this.config.https?.key,
|
|
439
436
|
cert: this.config.https?.cert,
|
|
440
437
|
}, this.expressApp)
|
|
441
|
-
: new
|
|
438
|
+
: new http.Server(this.expressApp);
|
|
442
439
|
this.publicAssets.forEach(asset => {
|
|
443
440
|
this.expressApp.use(asset.serverPath, express.static(asset.locationOnDisk));
|
|
444
441
|
});
|
|
@@ -467,8 +464,8 @@ class EndpointContext {
|
|
|
467
464
|
// }
|
|
468
465
|
//#endregion
|
|
469
466
|
this.logRealtime &&
|
|
470
|
-
|
|
471
|
-
this.realtime = new
|
|
467
|
+
Helpers__NS__info(`[ctx=${this.contextName}] Init Realtime for ${this.mode}`);
|
|
468
|
+
this.realtime = new RealtimeCore(this);
|
|
472
469
|
}
|
|
473
470
|
//#endregion
|
|
474
471
|
}
|
|
@@ -476,16 +473,16 @@ class EndpointContext {
|
|
|
476
473
|
// console.log({ ref })
|
|
477
474
|
if (this.config.abstract) {
|
|
478
475
|
this.logFramework &&
|
|
479
|
-
|
|
476
|
+
Helpers__NS__info(`[taon] Create abstract context: ${this.config.contextName}`);
|
|
480
477
|
}
|
|
481
478
|
else {
|
|
482
479
|
if (this.isRemoteHost) {
|
|
483
480
|
this.logFramework &&
|
|
484
|
-
|
|
481
|
+
Helpers__NS__info(`[taon] Create context for remote host: ${this.config.host}`);
|
|
485
482
|
}
|
|
486
483
|
else {
|
|
487
484
|
this.logFramework &&
|
|
488
|
-
|
|
485
|
+
Helpers__NS__info(`[taon] Create context for host: ${this.config.host}`);
|
|
489
486
|
}
|
|
490
487
|
}
|
|
491
488
|
//#endregion
|
|
@@ -505,8 +502,8 @@ class EndpointContext {
|
|
|
505
502
|
|
|
506
503
|
`);
|
|
507
504
|
//#region @websqlFunc
|
|
508
|
-
let databaseConfig =
|
|
509
|
-
const tcpUdpDatabaseSqliteRelativeFileLocation = `${
|
|
505
|
+
let databaseConfig = Models__NS__DatabaseConfig.from({});
|
|
506
|
+
const tcpUdpDatabaseSqliteRelativeFileLocation = `${Models__NS__DatabasesFolder}/db-${this.contextName}.sqlite`;
|
|
510
507
|
if (this.isRunningInsideDocker) {
|
|
511
508
|
if (this.USE_MARIADB_MYSQL_IN_DOCKER) {
|
|
512
509
|
// Helpers__NS__info('Running in docker, using in mysql database');
|
|
@@ -531,12 +528,12 @@ class EndpointContext {
|
|
|
531
528
|
|
|
532
529
|
`);
|
|
533
530
|
//#region @backend
|
|
534
|
-
const locationOfTheDatabase =
|
|
531
|
+
const locationOfTheDatabase = crossPlatformPath([
|
|
535
532
|
process.cwd(),
|
|
536
533
|
`db-${this.contextName}.sqlite`,
|
|
537
534
|
]);
|
|
538
535
|
//#endregion
|
|
539
|
-
databaseConfig = databaseConfig =
|
|
536
|
+
databaseConfig = databaseConfig = Models__NS__DatabaseConfig.from({
|
|
540
537
|
location: tcpUdpDatabaseSqliteRelativeFileLocation,
|
|
541
538
|
type: 'sqljs',
|
|
542
539
|
useLocalForage: false,
|
|
@@ -544,14 +541,14 @@ class EndpointContext {
|
|
|
544
541
|
logging: true,
|
|
545
542
|
});
|
|
546
543
|
//#region @backend
|
|
547
|
-
if (!
|
|
544
|
+
if (!fse.existsSync(locationOfTheDatabase)) {
|
|
548
545
|
databaseConfig.recreateMode = 'DROP_DB+MIGRATIONS';
|
|
549
546
|
}
|
|
550
547
|
// TODO @LAST add same thing for mariadb/mysql
|
|
551
548
|
this.logFramework &&
|
|
552
549
|
console.log(`
|
|
553
550
|
location of database: ${locationOfTheDatabase}
|
|
554
|
-
db file exists: ${
|
|
551
|
+
db file exists: ${fse.existsSync(locationOfTheDatabase)}
|
|
555
552
|
synchronize: ${databaseConfig.synchronize}
|
|
556
553
|
dropSchema: ${databaseConfig.dropSchema}
|
|
557
554
|
`);
|
|
@@ -561,24 +558,24 @@ class EndpointContext {
|
|
|
561
558
|
else {
|
|
562
559
|
//#region auto resolve db config
|
|
563
560
|
this.logFramework &&
|
|
564
|
-
|
|
561
|
+
Helpers__NS__info(`[taon][database] Automatically resolving database config for mode ${this.mode}`);
|
|
565
562
|
switch (this.mode) {
|
|
566
563
|
//#region resolve database config for backend-frontend(ipc-electron)
|
|
567
564
|
case 'backend-frontend(ipc-electron)':
|
|
568
565
|
let dbLocationInOs;
|
|
569
566
|
//#region @backend
|
|
570
|
-
if (
|
|
571
|
-
dbLocationInOs =
|
|
572
|
-
|
|
573
|
-
`.taon/databases-for-electron-apps/${this.appId ||
|
|
567
|
+
if (UtilsOs__NS__isElectron) {
|
|
568
|
+
dbLocationInOs = crossPlatformPath([
|
|
569
|
+
UtilsOs__NS__getRealHomeDir(),
|
|
570
|
+
`.taon/databases-for-electron-apps/${this.appId || ___NS__snakeCase(process.cwd()).replace(/\_/, '.')}/${this.contextName}.sqlite`,
|
|
574
571
|
]);
|
|
575
|
-
if (!
|
|
576
|
-
|
|
572
|
+
if (!Helpers__NS__exists(path.dirname(dbLocationInOs))) {
|
|
573
|
+
Helpers__NS__mkdirp(path.dirname(dbLocationInOs));
|
|
577
574
|
}
|
|
578
575
|
}
|
|
579
576
|
//#endregion
|
|
580
|
-
databaseConfig =
|
|
581
|
-
location:
|
|
577
|
+
databaseConfig = Models__NS__DatabaseConfig.from({
|
|
578
|
+
location: UtilsOs__NS__isElectron
|
|
582
579
|
? dbLocationInOs
|
|
583
580
|
: `db-${this.contextName}.sqlite`,
|
|
584
581
|
type: 'sqljs',
|
|
@@ -594,7 +591,7 @@ class EndpointContext {
|
|
|
594
591
|
/* */
|
|
595
592
|
/* */
|
|
596
593
|
/* */
|
|
597
|
-
databaseConfig = databaseConfig =
|
|
594
|
+
databaseConfig = databaseConfig = Models__NS__DatabaseConfig.from({
|
|
598
595
|
location: `db-${this.contextName}.sqlite`,
|
|
599
596
|
type: 'sqljs',
|
|
600
597
|
useLocalForage: true, // !!window['localforage'], // TODO this need to be checked in runtime
|
|
@@ -607,7 +604,7 @@ class EndpointContext {
|
|
|
607
604
|
//#endregion
|
|
608
605
|
//#region resolve database config for mode backend-frontend(tcp+udp)
|
|
609
606
|
case 'backend-frontend(tcp+udp)':
|
|
610
|
-
databaseConfig =
|
|
607
|
+
databaseConfig = Models__NS__DatabaseConfig.from({
|
|
611
608
|
database: `context-db-${this.contextName}`,
|
|
612
609
|
location: tcpUdpDatabaseSqliteRelativeFileLocation,
|
|
613
610
|
type: 'sqljs',
|
|
@@ -635,9 +632,9 @@ class EndpointContext {
|
|
|
635
632
|
// this.displayRoutes(this.expressApp);
|
|
636
633
|
this.serverTcpUdp.listen(Number(this.uriPort), '0.0.0.0', () => {
|
|
637
634
|
this.logFramework &&
|
|
638
|
-
|
|
635
|
+
Helpers__NS__log(`[ctx=${this.contextName}] Express server (inside docker) started 0.0.0.0:${this.uriPort}`);
|
|
639
636
|
this.logFramework &&
|
|
640
|
-
|
|
637
|
+
Helpers__NS__log(`[taon][express-server]listening on port: ${this.uriPort}, hostname: ${this.uriPathname},
|
|
641
638
|
address: ${this.uriProtocol}//localhost:${this.uriPort}${this.uriPathname}
|
|
642
639
|
ExpressJS mode: ${this.expressApp.settings.env}
|
|
643
640
|
`);
|
|
@@ -648,9 +645,9 @@ class EndpointContext {
|
|
|
648
645
|
// this.displayRoutes(this.expressApp);
|
|
649
646
|
this.serverTcpUdp.listen(Number(this.uriPort), () => {
|
|
650
647
|
this.logFramework &&
|
|
651
|
-
|
|
648
|
+
Helpers__NS__log(`[ctx=${this.contextName}] Express server (inside nodejs app) started on localhost:${this.uriPort}`);
|
|
652
649
|
this.logFramework &&
|
|
653
|
-
|
|
650
|
+
Helpers__NS__log(`[taon][express-server]listening on port: ${this.uriPort}, hostname: ${this.uriPathname},
|
|
654
651
|
address: ${this.uriProtocol}//localhost:${this.uriPort}${this.uriPathname}
|
|
655
652
|
expressJS mode: ${this.expressApp.settings.env}
|
|
656
653
|
`);
|
|
@@ -661,7 +658,7 @@ class EndpointContext {
|
|
|
661
658
|
}
|
|
662
659
|
else {
|
|
663
660
|
this.logFramework &&
|
|
664
|
-
|
|
661
|
+
Helpers__NS__info('Ipc communication enable instead tcp/upd');
|
|
665
662
|
}
|
|
666
663
|
//#endregion
|
|
667
664
|
}
|
|
@@ -709,35 +706,35 @@ class EndpointContext {
|
|
|
709
706
|
cloneClassWithNewMetadata = ({ TaonBaseClass, className, config, ctx, classType, }) => {
|
|
710
707
|
// Return a new class that extends the base class
|
|
711
708
|
const cloneClass = () => {
|
|
712
|
-
if (TaonBaseClass[
|
|
709
|
+
if (TaonBaseClass[Symbols__NS__fullClassNameStaticProperty] ===
|
|
713
710
|
`${ctx.contextName}.${className}`) {
|
|
714
711
|
return TaonBaseClass;
|
|
715
712
|
}
|
|
716
713
|
return class extends TaonBaseClass {
|
|
717
714
|
// static ['_'] = TaonBaseClass['_'];
|
|
718
715
|
// @ts-ignore
|
|
719
|
-
static [
|
|
716
|
+
static [Symbols__NS__orignalClass] = TaonBaseClass;
|
|
720
717
|
// @ts-ignore
|
|
721
|
-
static [
|
|
718
|
+
static [Symbols__NS__fullClassNameStaticProperty] = `${ctx.contextName}.${className}`;
|
|
722
719
|
// @ts-ignore
|
|
723
|
-
static [
|
|
724
|
-
static [
|
|
720
|
+
static [Symbols__NS__classNameStaticProperty] = className;
|
|
721
|
+
static [Symbols__NS__ctxInClassOrClassObj] = ctx;
|
|
725
722
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
726
723
|
static __getFullPathForClass__(arr = []) {
|
|
727
|
-
const name = this[
|
|
724
|
+
const name = this[Symbols__NS__fullClassNameStaticProperty];
|
|
728
725
|
arr.push(name);
|
|
729
726
|
// @ts-ignore
|
|
730
|
-
if (this[
|
|
731
|
-
this[
|
|
727
|
+
if (this[Symbols__NS__orignalClass] && // @ts-ignore
|
|
728
|
+
this[Symbols__NS__orignalClass].__getFullPathForClass__) {
|
|
732
729
|
// @ts-ignore
|
|
733
|
-
this[
|
|
730
|
+
this[Symbols__NS__orignalClass].__getFullPathForClass__(arr);
|
|
734
731
|
}
|
|
735
732
|
return arr.join('/');
|
|
736
733
|
}
|
|
737
734
|
static get fullPathForClass() {
|
|
738
735
|
return this.__getFullPathForClass__();
|
|
739
736
|
}
|
|
740
|
-
[
|
|
737
|
+
[Symbols__NS__ctxInClassOrClassObj] = ctx;
|
|
741
738
|
};
|
|
742
739
|
};
|
|
743
740
|
const cloneClassFunction = cloneClass();
|
|
@@ -769,19 +766,19 @@ class EndpointContext {
|
|
|
769
766
|
for (const key of Object.keys(classesInput || {})) {
|
|
770
767
|
const TaonBaseClass = classesInput[key];
|
|
771
768
|
if (!TaonBaseClass) {
|
|
772
|
-
|
|
769
|
+
Helpers__NS__error(`Class ${key} is not defined in context ${ctx.contextName}
|
|
773
770
|
|
|
774
771
|
Please check if you have correct import in context file
|
|
775
772
|
|
|
776
773
|
`);
|
|
777
774
|
}
|
|
778
|
-
var className = Reflect.getMetadata(
|
|
775
|
+
var className = Reflect.getMetadata(Symbols__NS__metadata.className, TaonBaseClass);
|
|
779
776
|
// console.log('Metadata className', className, TaonBaseClass);
|
|
780
777
|
// if (!className) {
|
|
781
778
|
// console.warn(`Please provide className for ${TaonBaseClass.name} class`);
|
|
782
779
|
// }
|
|
783
780
|
className = className || key;
|
|
784
|
-
TaonBaseClass[
|
|
781
|
+
TaonBaseClass[Symbols__NS__classNameStaticProperty] = className;
|
|
785
782
|
const clonedClass = this.cloneClassWithNewMetadata({
|
|
786
783
|
TaonBaseClass,
|
|
787
784
|
className,
|
|
@@ -798,7 +795,7 @@ class EndpointContext {
|
|
|
798
795
|
async getRecrusiveClassesfromContextsObj(classType) {
|
|
799
796
|
const arr = await this.getRecrusiveClassesfromContexts(classType);
|
|
800
797
|
return arr.reduce((acc, c) => {
|
|
801
|
-
acc[
|
|
798
|
+
acc[ClassHelpers__NS__getName(c)] = c;
|
|
802
799
|
return acc;
|
|
803
800
|
}, {});
|
|
804
801
|
}
|
|
@@ -838,9 +835,9 @@ class EndpointContext {
|
|
|
838
835
|
//#endregion
|
|
839
836
|
//#region methods & getters / inject
|
|
840
837
|
inject(ctor, options) {
|
|
841
|
-
const className =
|
|
838
|
+
const className = ClassHelpers__NS__getName(ctor);
|
|
842
839
|
const locaInstanceConstructorArgs = options.locaInstanceConstructorArgs || [];
|
|
843
|
-
if (this.isCLassType(
|
|
840
|
+
if (this.isCLassType(Models__NS__ClassType.REPOSITORY, ctor)) {
|
|
844
841
|
options.localInstance = true;
|
|
845
842
|
}
|
|
846
843
|
if (options?.localInstance) {
|
|
@@ -848,9 +845,9 @@ class EndpointContext {
|
|
|
848
845
|
let entityName = '';
|
|
849
846
|
// entity thing is only for repositories local repositories
|
|
850
847
|
// if (className === 'TaonBaseRepository') {
|
|
851
|
-
const entityFn =
|
|
848
|
+
const entityFn = ___NS__first(locaInstanceConstructorArgs);
|
|
852
849
|
const entity = entityFn && entityFn();
|
|
853
|
-
entityName = (entity &&
|
|
850
|
+
entityName = (entity && ClassHelpers__NS__getName(entity)) || '';
|
|
854
851
|
// console.log(`entityName `, entityName);
|
|
855
852
|
// }
|
|
856
853
|
if (!options.contextClassInstance[this.localInstaceObjSymbol]) {
|
|
@@ -911,7 +908,7 @@ class EndpointContext {
|
|
|
911
908
|
//#endregion
|
|
912
909
|
//#region methods & getters / check if context initialized
|
|
913
910
|
checkIfContextInitialized() {
|
|
914
|
-
if (
|
|
911
|
+
if (___NS__isUndefined(this.config)) {
|
|
915
912
|
throw new Error(`Please check if your context has been initialized.
|
|
916
913
|
|
|
917
914
|
// ...
|
|
@@ -927,24 +924,24 @@ class EndpointContext {
|
|
|
927
924
|
getClassFunBy(classType) {
|
|
928
925
|
this.checkIfContextInitialized();
|
|
929
926
|
switch (classType) {
|
|
930
|
-
case
|
|
927
|
+
case Models__NS__ClassType.CONTROLLER:
|
|
931
928
|
return this.config.controllers;
|
|
932
|
-
case
|
|
929
|
+
case Models__NS__ClassType.ENTITY:
|
|
933
930
|
return this.config.entities;
|
|
934
|
-
case
|
|
931
|
+
case Models__NS__ClassType.PROVIDER:
|
|
935
932
|
return this.config.providers;
|
|
936
|
-
case
|
|
933
|
+
case Models__NS__ClassType.MIDDLEWARE:
|
|
937
934
|
return this.config.middlewares;
|
|
938
|
-
case
|
|
935
|
+
case Models__NS__ClassType.REPOSITORY:
|
|
939
936
|
return this.config.repositories;
|
|
940
|
-
case
|
|
937
|
+
case Models__NS__ClassType.SUBSCRIBER:
|
|
941
938
|
return this.config.subscribers;
|
|
942
|
-
case
|
|
939
|
+
case Models__NS__ClassType.MIGRATION:
|
|
943
940
|
return this.config.migrations;
|
|
944
941
|
}
|
|
945
942
|
}
|
|
946
943
|
isCLassType(classType, classFn) {
|
|
947
|
-
return !!this.getClassFunBy(classType)[
|
|
944
|
+
return !!this.getClassFunBy(classType)[ClassHelpers__NS__getName(classFn)];
|
|
948
945
|
}
|
|
949
946
|
/**
|
|
950
947
|
* Only for injectable types
|
|
@@ -952,14 +949,14 @@ class EndpointContext {
|
|
|
952
949
|
*/
|
|
953
950
|
getClassFunByClassName(className) {
|
|
954
951
|
for (const classTypeName of this.allTypesfromContexts) {
|
|
955
|
-
const classesForInjectableType = this.config[
|
|
952
|
+
const classesForInjectableType = this.config[Models__NS__ClassTypeKey[classTypeName]];
|
|
956
953
|
if (classesForInjectableType[className]) {
|
|
957
954
|
return classesForInjectableType[className];
|
|
958
955
|
}
|
|
959
956
|
}
|
|
960
957
|
}
|
|
961
958
|
getClassFunByClass(classFunction) {
|
|
962
|
-
const className =
|
|
959
|
+
const className = ClassHelpers__NS__getName(classFunction);
|
|
963
960
|
return this.getClassFunByClassName(className);
|
|
964
961
|
}
|
|
965
962
|
getClassFunByArr(classType) {
|
|
@@ -976,13 +973,13 @@ class EndpointContext {
|
|
|
976
973
|
// ...recrusiveValuesFromContext,
|
|
977
974
|
...Object.values(classes),
|
|
978
975
|
]) {
|
|
979
|
-
const instance =
|
|
976
|
+
const instance = DITaonContainer.resolve(classFn);
|
|
980
977
|
const classInstancesByNameObj = this.classInstancesByNameObj[classType];
|
|
981
|
-
const className =
|
|
978
|
+
const className = ClassHelpers__NS__getName(classFn);
|
|
982
979
|
// console.log({ classFn, classType, instance, place, className, 'classInstancesByNameObj': this.classInstancesByNameObj });
|
|
983
980
|
classInstancesByNameObj[className] = instance;
|
|
984
981
|
// update config
|
|
985
|
-
this.config[
|
|
982
|
+
this.config[Models__NS__ClassTypeKey[classType]][className] = classFn;
|
|
986
983
|
this.objWithClassesInstancesArr[classType].push(instance);
|
|
987
984
|
this.allClassesInstances[className] = instance;
|
|
988
985
|
}
|
|
@@ -994,40 +991,40 @@ class EndpointContext {
|
|
|
994
991
|
return;
|
|
995
992
|
}
|
|
996
993
|
//#region @websql
|
|
997
|
-
for (const classFun of this.getClassFunByArr(
|
|
998
|
-
const repo = (await this.connection.getRepository(
|
|
999
|
-
this.repos.set(
|
|
994
|
+
for (const classFun of this.getClassFunByArr(Models__NS__ClassType.ENTITY)) {
|
|
995
|
+
const repo = (await this.connection.getRepository(ClassHelpers__NS__getOrginalClass(classFun)));
|
|
996
|
+
this.repos.set(ClassHelpers__NS__getName(classFun), repo);
|
|
1000
997
|
}
|
|
1001
998
|
//#endregion
|
|
1002
999
|
for (const classTypeName of [
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1000
|
+
Models__NS__ClassType.MIDDLEWARE,
|
|
1001
|
+
Models__NS__ClassType.PROVIDER,
|
|
1002
|
+
Models__NS__ClassType.REPOSITORY,
|
|
1003
|
+
Models__NS__ClassType.CONTROLLER,
|
|
1004
|
+
Models__NS__ClassType.ENTITY,
|
|
1005
|
+
Models__NS__ClassType.MIGRATION,
|
|
1009
1006
|
]) {
|
|
1010
1007
|
//#region init class static _ property
|
|
1011
1008
|
for (const classFun of this.getClassFunByArr(classTypeName)) {
|
|
1012
|
-
if (
|
|
1009
|
+
if (___NS__isFunction(classFun._)) {
|
|
1013
1010
|
await classFun._();
|
|
1014
1011
|
}
|
|
1015
1012
|
}
|
|
1016
1013
|
//#endregion
|
|
1017
1014
|
}
|
|
1018
1015
|
for (const classTypeName of [
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1016
|
+
Models__NS__ClassType.MIDDLEWARE,
|
|
1017
|
+
Models__NS__ClassType.PROVIDER,
|
|
1018
|
+
Models__NS__ClassType.REPOSITORY,
|
|
1019
|
+
Models__NS__ClassType.CONTROLLER,
|
|
1020
|
+
Models__NS__ClassType.MIGRATION,
|
|
1024
1021
|
]) {
|
|
1025
1022
|
//#region init providers, repositories _ property
|
|
1026
1023
|
// Helpers__NS__taskStarted(
|
|
1027
1024
|
// `[taon] REINITING _ INS FN ${classTypeName} ${this.contextName} STARTED`,
|
|
1028
1025
|
// );
|
|
1029
1026
|
for (const ctrl of this.getClassesInstancesArrBy(classTypeName)) {
|
|
1030
|
-
if (
|
|
1027
|
+
if (___NS__isFunction(ctrl._)) {
|
|
1031
1028
|
await ctrl._();
|
|
1032
1029
|
}
|
|
1033
1030
|
}
|
|
@@ -1040,7 +1037,7 @@ class EndpointContext {
|
|
|
1040
1037
|
//#endregion
|
|
1041
1038
|
//#region methods & getters / is active on
|
|
1042
1039
|
isActiveOn(classInstance) {
|
|
1043
|
-
let contextRef = classInstance[
|
|
1040
|
+
let contextRef = classInstance[Symbols__NS__ctxInClassOrClassObj];
|
|
1044
1041
|
return this === contextRef;
|
|
1045
1042
|
}
|
|
1046
1043
|
//#endregion
|
|
@@ -1049,11 +1046,11 @@ class EndpointContext {
|
|
|
1049
1046
|
const url = this.config?.frontendHost?.startsWith('http')
|
|
1050
1047
|
? this.config.frontendHost
|
|
1051
1048
|
: `${globalThis?.location?.protocol || 'http:'}//${this.config?.frontendHost}`;
|
|
1052
|
-
const uri = new
|
|
1049
|
+
const uri = new URL(url.replace(/\/$/, ''));
|
|
1053
1050
|
return uri;
|
|
1054
1051
|
}
|
|
1055
1052
|
get uri() {
|
|
1056
|
-
const url = this.host ? new
|
|
1053
|
+
const url = this.host ? new URL(this.host) : void 0;
|
|
1057
1054
|
return url;
|
|
1058
1055
|
}
|
|
1059
1056
|
//#endregion
|
|
@@ -1211,12 +1208,12 @@ class EndpointContext {
|
|
|
1211
1208
|
if (this.isRemoteHost) {
|
|
1212
1209
|
return;
|
|
1213
1210
|
}
|
|
1214
|
-
const subscriberClasses = this.getClassFunByArr(
|
|
1211
|
+
const subscriberClasses = this.getClassFunByArr(Models__NS__ClassType.SUBSCRIBER);
|
|
1215
1212
|
for (const subscriberClassFn of subscriberClasses) {
|
|
1216
|
-
const options = Reflect.getMetadata(
|
|
1213
|
+
const options = Reflect.getMetadata(Symbols__NS__metadata.options.subscriber, subscriberClassFn);
|
|
1217
1214
|
// console.log('subscriber options', options);
|
|
1218
1215
|
// const nameForSubscriber = ClassHelpers__NS__getName(subscriber);
|
|
1219
|
-
|
|
1216
|
+
EventSubscriber()(subscriberClassFn);
|
|
1220
1217
|
}
|
|
1221
1218
|
//#endregion
|
|
1222
1219
|
}
|
|
@@ -1227,18 +1224,18 @@ class EndpointContext {
|
|
|
1227
1224
|
if (this.isRemoteHost) {
|
|
1228
1225
|
return;
|
|
1229
1226
|
}
|
|
1230
|
-
const entities = this.getClassFunByArr(
|
|
1227
|
+
const entities = this.getClassFunByArr(Models__NS__ClassType.ENTITY);
|
|
1231
1228
|
for (const entity of entities) {
|
|
1232
|
-
const options = Reflect.getMetadata(
|
|
1233
|
-
const createTable =
|
|
1229
|
+
const options = Reflect.getMetadata(Symbols__NS__metadata.options.entity, entity);
|
|
1230
|
+
const createTable = ___NS__isUndefined(options.createTable)
|
|
1234
1231
|
? true
|
|
1235
1232
|
: options.createTable;
|
|
1236
|
-
const nameForEntity =
|
|
1233
|
+
const nameForEntity = ClassHelpers__NS__getName(entity);
|
|
1237
1234
|
if (createTable) {
|
|
1238
1235
|
this.logDb &&
|
|
1239
1236
|
console.info(`[taon][typeorm] create table for entity "${nameForEntity}" ? '${createTable}'`);
|
|
1240
1237
|
// console.log('TypeormEntity', { TypeormEntity });
|
|
1241
|
-
(
|
|
1238
|
+
TypeormEntity(nameForEntity)(entity);
|
|
1242
1239
|
}
|
|
1243
1240
|
else {
|
|
1244
1241
|
this.logDb &&
|
|
@@ -1273,12 +1270,12 @@ class EndpointContext {
|
|
|
1273
1270
|
if (this.isRemoteHost || !this.databaseConfig) {
|
|
1274
1271
|
return;
|
|
1275
1272
|
}
|
|
1276
|
-
const entities = this.getClassFunByArr(
|
|
1277
|
-
return
|
|
1273
|
+
const entities = this.getClassFunByArr(Models__NS__ClassType.ENTITY).map(entityFn => {
|
|
1274
|
+
return ClassHelpers__NS__getOrginalClass(entityFn);
|
|
1278
1275
|
});
|
|
1279
|
-
const subscribers = this.getClassFunByArr(
|
|
1276
|
+
const subscribers = this.getClassFunByArr(Models__NS__ClassType.SUBSCRIBER);
|
|
1280
1277
|
let autoSave = false;
|
|
1281
|
-
if (!
|
|
1278
|
+
if (!___NS__isNil(this.databaseConfig.autoSave)) {
|
|
1282
1279
|
autoSave = this.databaseConfig.autoSave;
|
|
1283
1280
|
}
|
|
1284
1281
|
else {
|
|
@@ -1289,7 +1286,7 @@ class EndpointContext {
|
|
|
1289
1286
|
autoSave = true; // on docker with sqljs I need to save db
|
|
1290
1287
|
}
|
|
1291
1288
|
}
|
|
1292
|
-
const dataSourceDbConfig =
|
|
1289
|
+
const dataSourceDbConfig = ___NS__isObject(this.databaseConfig)
|
|
1293
1290
|
? {
|
|
1294
1291
|
type: this.databaseConfig.type,
|
|
1295
1292
|
port: this.databaseConfig.databasePort,
|
|
@@ -1318,9 +1315,9 @@ class EndpointContext {
|
|
|
1318
1315
|
if (this.modeAllowsDatabaseCreation && this.databaseConfig) {
|
|
1319
1316
|
this.logDb &&
|
|
1320
1317
|
this.logFramework &&
|
|
1321
|
-
|
|
1318
|
+
Helpers__NS__info('[taon][database] prepare typeorm connection...');
|
|
1322
1319
|
try {
|
|
1323
|
-
const connection = new
|
|
1320
|
+
const connection = new DataSource(dataSourceDbConfig);
|
|
1324
1321
|
this.connection = connection;
|
|
1325
1322
|
await this.connection.initialize();
|
|
1326
1323
|
}
|
|
@@ -1360,7 +1357,7 @@ class EndpointContext {
|
|
|
1360
1357
|
// debugger;
|
|
1361
1358
|
}
|
|
1362
1359
|
else {
|
|
1363
|
-
|
|
1360
|
+
Helpers__NS__info(`[taon][typeorm] Not initing db for mode ${this.mode}`);
|
|
1364
1361
|
}
|
|
1365
1362
|
//#endregion
|
|
1366
1363
|
}
|
|
@@ -1368,27 +1365,27 @@ class EndpointContext {
|
|
|
1368
1365
|
//#region methods & getters / initialize metadata
|
|
1369
1366
|
//#region methods & getters / update class calculate path
|
|
1370
1367
|
updateCalculatedPathsForControllers(rawConfigs, classConfig, controllerClassFn) {
|
|
1371
|
-
const parentsCalculatedPath =
|
|
1368
|
+
const parentsCalculatedPath = ___NS__slice(rawConfigs, 1)
|
|
1372
1369
|
.reverse()
|
|
1373
1370
|
.map(bc => {
|
|
1374
|
-
if (
|
|
1371
|
+
if (TaonHelpers__NS__isGoodPath(bc.path)) {
|
|
1375
1372
|
return bc.path;
|
|
1376
1373
|
}
|
|
1377
1374
|
return bc.className;
|
|
1378
1375
|
})
|
|
1379
1376
|
.join('/');
|
|
1380
1377
|
const contextNameForCommunication = this.contextNameForCommunication;
|
|
1381
|
-
if (
|
|
1378
|
+
if (TaonHelpers__NS__isGoodPath(classConfig.path)) {
|
|
1382
1379
|
classConfig.calculatedPath = classConfig.path;
|
|
1383
1380
|
}
|
|
1384
1381
|
else {
|
|
1385
1382
|
classConfig.calculatedPath = (`${this.uriPathnameOrNothingIfRoot}` +
|
|
1386
|
-
`/${
|
|
1387
|
-
`${
|
|
1383
|
+
`/${apiPrefix}/${contextNameForCommunication}/tcp${parentsCalculatedPath}/` +
|
|
1384
|
+
`${ClassHelpers__NS__getName(controllerClassFn)}`)
|
|
1388
1385
|
.replace(/\/\//g, '/')
|
|
1389
1386
|
.split('/')
|
|
1390
1387
|
.reduce((acc, bc) => {
|
|
1391
|
-
return
|
|
1388
|
+
return ___NS__last(acc) === bc ? acc : [...acc, bc];
|
|
1392
1389
|
}, [])
|
|
1393
1390
|
.join('/');
|
|
1394
1391
|
}
|
|
@@ -1398,8 +1395,8 @@ class EndpointContext {
|
|
|
1398
1395
|
//#region methods & getters / dedupe class configs
|
|
1399
1396
|
mergeControllerMethodsConfigs(rawConfigs, classConfig, controllerClassFn) {
|
|
1400
1397
|
const currentControllerMethodsConfig = classConfig.methods;
|
|
1401
|
-
|
|
1402
|
-
const parentControllerMethods =
|
|
1398
|
+
___NS__slice(rawConfigs, 1).forEach(bc => {
|
|
1399
|
+
const parentControllerMethods = ___NS__cloneDeep(bc.methods);
|
|
1403
1400
|
for (const methodsName in parentControllerMethods) {
|
|
1404
1401
|
if (parentControllerMethods.hasOwnProperty(methodsName)) {
|
|
1405
1402
|
if (!currentControllerMethodsConfig[methodsName]) {
|
|
@@ -1417,10 +1414,10 @@ class EndpointContext {
|
|
|
1417
1414
|
if (this.isRunOrRevertOnlyMigrationAppStart) {
|
|
1418
1415
|
return;
|
|
1419
1416
|
}
|
|
1420
|
-
const allControllers = this.getClassFunByArr(
|
|
1417
|
+
const allControllers = this.getClassFunByArr(Models__NS__ClassType.CONTROLLER);
|
|
1421
1418
|
for (const controllerClassFn of allControllers) {
|
|
1422
1419
|
const instance = this.getInstanceBy(controllerClassFn);
|
|
1423
|
-
if (
|
|
1420
|
+
if (___NS__isFunction(instance.afterAllCtxInited)) {
|
|
1424
1421
|
await instance.afterAllCtxInited({ ctxStorage });
|
|
1425
1422
|
}
|
|
1426
1423
|
}
|
|
@@ -1429,7 +1426,7 @@ class EndpointContext {
|
|
|
1429
1426
|
if (this.isRunOrRevertOnlyMigrationAppStart) {
|
|
1430
1427
|
return;
|
|
1431
1428
|
}
|
|
1432
|
-
const allControllers = this.getClassFunByArr(
|
|
1429
|
+
const allControllers = this.getClassFunByArr(Models__NS__ClassType.CONTROLLER);
|
|
1433
1430
|
// debugger
|
|
1434
1431
|
// console.log('allControllers', allControllers);
|
|
1435
1432
|
for (const controllerClassFn of allControllers) {
|
|
@@ -1439,9 +1436,9 @@ class EndpointContext {
|
|
|
1439
1436
|
// `for ${controllerName}`,
|
|
1440
1437
|
// ClassHelpers__NS__getClassConfig(controllerClassFn),
|
|
1441
1438
|
// );
|
|
1442
|
-
controllerClassFn[
|
|
1443
|
-
|
|
1444
|
-
const rawConfigs =
|
|
1439
|
+
controllerClassFn[Symbols__NS__classMethodsNames] =
|
|
1440
|
+
ClassHelpers__NS__getMethodsNames(controllerClassFn);
|
|
1441
|
+
const rawConfigs = ClassHelpers__NS__getControllerConfigs(controllerClassFn);
|
|
1445
1442
|
// console.log(controllerName, { rawConfigs });
|
|
1446
1443
|
// console.log(`Class config for ${ClassHelpers__NS__getName(controllerClassFn)}`, configs)
|
|
1447
1444
|
const classConfig = rawConfigs[0];
|
|
@@ -1450,11 +1447,11 @@ class EndpointContext {
|
|
|
1450
1447
|
//#region combine middlewares from controllers
|
|
1451
1448
|
classConfig.calculatedMiddlewaresControllerObj = {};
|
|
1452
1449
|
[...rawConfigs].reverse().forEach(rc => {
|
|
1453
|
-
if (
|
|
1450
|
+
if (___NS__isFunction(rc.middlewares)) {
|
|
1454
1451
|
classConfig.calculatedMiddlewaresControllerObj = rc.middlewares({
|
|
1455
1452
|
parentMiddlewares: classConfig.calculatedMiddlewaresControllerObj,
|
|
1456
1453
|
className(middlewareClass) {
|
|
1457
|
-
return
|
|
1454
|
+
return ClassHelpers__NS__getName(controllerClassFn);
|
|
1458
1455
|
},
|
|
1459
1456
|
});
|
|
1460
1457
|
}
|
|
@@ -1462,7 +1459,7 @@ class EndpointContext {
|
|
|
1462
1459
|
//#endregion
|
|
1463
1460
|
//#region group start
|
|
1464
1461
|
//#region @backend
|
|
1465
|
-
if (!
|
|
1462
|
+
if (!UtilsOs__NS__isRunningInCliMode()) {
|
|
1466
1463
|
//#endregion
|
|
1467
1464
|
this.logHttp &&
|
|
1468
1465
|
console.groupCollapsed(`[taon][express-server] routes [${classConfig.className}]`);
|
|
@@ -1479,11 +1476,11 @@ class EndpointContext {
|
|
|
1479
1476
|
[...rawConfigs].reverse().forEach(rc => {
|
|
1480
1477
|
if (rc.methods[methodName]) {
|
|
1481
1478
|
const parentMethodConfig = rc.methods[methodName];
|
|
1482
|
-
if (
|
|
1479
|
+
if (___NS__isFunction(parentMethodConfig.middlewares)) {
|
|
1483
1480
|
calculatedMiddlewaresMethodObj = parentMethodConfig.middlewares({
|
|
1484
1481
|
parentMiddlewares: calculatedMiddlewaresMethodObj,
|
|
1485
1482
|
className(middlewareClass) {
|
|
1486
|
-
return
|
|
1483
|
+
return ClassHelpers__NS__getName(controllerClassFn);
|
|
1487
1484
|
},
|
|
1488
1485
|
});
|
|
1489
1486
|
}
|
|
@@ -1502,15 +1499,15 @@ class EndpointContext {
|
|
|
1502
1499
|
// this is quick fix - in docker global path should not be used
|
|
1503
1500
|
const globalPathPart = this.isRunningInsideDocker ||
|
|
1504
1501
|
!this.frontendHostUri?.origin?.includes('localhost') // fe with domain -> is in docker
|
|
1505
|
-
? `${this.uriPathnameOrNothingIfRoot.replace(/\/$/, '')}/${
|
|
1502
|
+
? `${this.uriPathnameOrNothingIfRoot.replace(/\/$/, '')}/${apiPrefix}/${this.contextName}`.replace(/\/\//, '/')
|
|
1506
1503
|
: '';
|
|
1507
1504
|
const expressPath = methodConfig.global
|
|
1508
1505
|
? `${globalPathPart}/${methodConfig.path?.replace(/\/$/, '')}`.replace(/\/\//, '/')
|
|
1509
|
-
:
|
|
1506
|
+
: TaonHelpers__NS__getExpressPath(classConfig, methodConfig);
|
|
1510
1507
|
//#endregion
|
|
1511
1508
|
//#region init server
|
|
1512
1509
|
// console.log({ expressPath });
|
|
1513
|
-
if (
|
|
1510
|
+
if (UtilsOs__NS__isNode || UtilsOs__NS__isWebSQL) {
|
|
1514
1511
|
//#region @websql
|
|
1515
1512
|
const route = this.initServer(httpMethodType, methodConfig, classConfig, expressPath, controllerClassFn);
|
|
1516
1513
|
this.activeRoutes.push({
|
|
@@ -1521,7 +1518,7 @@ class EndpointContext {
|
|
|
1521
1518
|
}
|
|
1522
1519
|
//#endregion
|
|
1523
1520
|
//#region init client
|
|
1524
|
-
const shouldInitClient =
|
|
1521
|
+
const shouldInitClient = UtilsOs__NS__isBrowser || this.isRemoteHost || UtilsOs__NS__isWebSQL;
|
|
1525
1522
|
// console.log('shouldInitClient', shouldInitClient);
|
|
1526
1523
|
if (shouldInitClient) {
|
|
1527
1524
|
// console.log(
|
|
@@ -1538,7 +1535,7 @@ class EndpointContext {
|
|
|
1538
1535
|
//#endregion
|
|
1539
1536
|
//#region group end
|
|
1540
1537
|
//#region @backend
|
|
1541
|
-
if (!
|
|
1538
|
+
if (!UtilsOs__NS__isRunningInCliMode()) {
|
|
1542
1539
|
//#endregion
|
|
1543
1540
|
this.logHttp && console.groupEnd();
|
|
1544
1541
|
//#region @backend
|
|
@@ -1555,12 +1552,12 @@ class EndpointContext {
|
|
|
1555
1552
|
}
|
|
1556
1553
|
// const contexts: EndpointContext[] = [this];
|
|
1557
1554
|
//#region @websql
|
|
1558
|
-
const troutes =
|
|
1555
|
+
const troutes = Utils__NS__uniqArray(this.activeRoutes.map(f => {
|
|
1559
1556
|
return `${f.method} ${f.expressPath}`;
|
|
1560
1557
|
})).map(f => {
|
|
1561
1558
|
const [method, expressPath] = f.split(' ');
|
|
1562
|
-
return (`\n### ${
|
|
1563
|
-
|
|
1559
|
+
return (`\n### ${___NS__startCase(___NS__last(expressPath.split('/')))}\n` +
|
|
1560
|
+
TaonHelpers__NS__fillUpTo(method.toUpperCase() + ' ', 10) +
|
|
1564
1561
|
this.uriOrigin +
|
|
1565
1562
|
expressPath);
|
|
1566
1563
|
// return `${TaonHelpers.string(method.toUpperCase() + ':')
|
|
@@ -1570,7 +1567,7 @@ class EndpointContext {
|
|
|
1570
1567
|
...['', `# ROUTES FOR HOST ${this.uriOrigin} `],
|
|
1571
1568
|
...troutes,
|
|
1572
1569
|
].join('\n');
|
|
1573
|
-
const fileName =
|
|
1570
|
+
const fileName = crossPlatformPath([
|
|
1574
1571
|
//#region @backend
|
|
1575
1572
|
process.cwd(),
|
|
1576
1573
|
//#endregion
|
|
@@ -1579,8 +1576,8 @@ class EndpointContext {
|
|
|
1579
1576
|
this.logFramework && console.log(`[taon] routes file: ${fileName} `);
|
|
1580
1577
|
this.logRoutes && console.log(routes);
|
|
1581
1578
|
//#region @backend
|
|
1582
|
-
if (!
|
|
1583
|
-
|
|
1579
|
+
if (!UtilsOs__NS__isElectron && !this.skipWritingServerRoutes) {
|
|
1580
|
+
Helpers__NS__writeFile(fileName, routes);
|
|
1584
1581
|
}
|
|
1585
1582
|
//#endregion
|
|
1586
1583
|
//#endregion
|
|
@@ -1595,16 +1592,16 @@ class EndpointContext {
|
|
|
1595
1592
|
//#endregion
|
|
1596
1593
|
//#region methods & getters / init middlewares
|
|
1597
1594
|
async initCustomClientMiddlewares() {
|
|
1598
|
-
const middlewares = this.getClassesInstancesArrBy(
|
|
1595
|
+
const middlewares = this.getClassesInstancesArrBy(Models__NS__ClassType.MIDDLEWARE)
|
|
1599
1596
|
.map(f => f)
|
|
1600
|
-
.filter(f =>
|
|
1597
|
+
.filter(f => ___NS__isFunction(f.interceptClient));
|
|
1601
1598
|
middlewares.forEach(middlewareInstanceName => {
|
|
1602
1599
|
const contextName = this.contextName;
|
|
1603
|
-
const interceptorName = `${contextName}-${
|
|
1604
|
-
|
|
1600
|
+
const interceptorName = `${contextName}-${ClassHelpers__NS__getName(middlewareInstanceName)}`;
|
|
1601
|
+
Resource.request.interceptors.set(interceptorName, {
|
|
1605
1602
|
intercept: ({ req, next }) => {
|
|
1606
|
-
const url = new
|
|
1607
|
-
if (url.pathname.startsWith(`${this.uriPathnameOrNothingIfRoot}/${
|
|
1603
|
+
const url = new URL(req.url);
|
|
1604
|
+
if (url.pathname.startsWith(`${this.uriPathnameOrNothingIfRoot}/${apiPrefix}/${contextName}/`)) {
|
|
1608
1605
|
// console.log('intercepting', url.pathname, req);
|
|
1609
1606
|
return middlewareInstanceName.interceptClient({
|
|
1610
1607
|
req,
|
|
@@ -1619,12 +1616,12 @@ class EndpointContext {
|
|
|
1619
1616
|
async initCustomBackendMiddlewares() {
|
|
1620
1617
|
//#region @backend
|
|
1621
1618
|
const app = this.expressApp;
|
|
1622
|
-
const middlewares = this.getClassesInstancesArrBy(
|
|
1619
|
+
const middlewares = this.getClassesInstancesArrBy(Models__NS__ClassType.MIDDLEWARE);
|
|
1623
1620
|
for (const middleware of middlewares) {
|
|
1624
1621
|
const middlewareInstance = middleware;
|
|
1625
|
-
if (
|
|
1626
|
-
const middlewareFn =
|
|
1627
|
-
if (req.originalUrl.startsWith(`${this.uriPathnameOrNothingIfRoot}/${
|
|
1622
|
+
if (___NS__isFunction(middlewareInstance.interceptServer)) {
|
|
1623
|
+
const middlewareFn = ClassHelpers__NS__asyncHandler(async (req, res, next) => {
|
|
1624
|
+
if (req.originalUrl.startsWith(`${this.uriPathnameOrNothingIfRoot}/${apiPrefix}/${this.contextName}/`)) {
|
|
1628
1625
|
await middlewareInstance.interceptServer({
|
|
1629
1626
|
req,
|
|
1630
1627
|
res,
|
|
@@ -1658,7 +1655,7 @@ class EndpointContext {
|
|
|
1658
1655
|
app.use(methodOverride());
|
|
1659
1656
|
app.use(cookieParser());
|
|
1660
1657
|
if (this.session) {
|
|
1661
|
-
|
|
1658
|
+
Helpers__NS__info('[taon][express-server] session enabled for this context ' +
|
|
1662
1659
|
this.contextName);
|
|
1663
1660
|
const { cookieMaxAge } = this.session;
|
|
1664
1661
|
const frontendHost = this.config.frontendHost;
|
|
@@ -1684,7 +1681,7 @@ class EndpointContext {
|
|
|
1684
1681
|
else {
|
|
1685
1682
|
// if(this.config?.serverLogs) {
|
|
1686
1683
|
this.logHttp &&
|
|
1687
|
-
|
|
1684
|
+
Helpers__NS__info(`[taon][express-server] session not enabled for this context '${this.contextName}'`);
|
|
1688
1685
|
// }
|
|
1689
1686
|
app.use(cors({
|
|
1690
1687
|
// origin: "http://localhost:5555",
|
|
@@ -1718,10 +1715,10 @@ class EndpointContext {
|
|
|
1718
1715
|
'Content-Type',
|
|
1719
1716
|
'Authorization',
|
|
1720
1717
|
'X-Requested-With',
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1718
|
+
Symbols__NS__old.X_TOTAL_COUNT,
|
|
1719
|
+
Symbols__NS__old.MAPPING_CONFIG_HEADER,
|
|
1720
|
+
Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY,
|
|
1721
|
+
Symbols__NS__old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM,
|
|
1725
1722
|
].join(', '));
|
|
1726
1723
|
next();
|
|
1727
1724
|
});
|
|
@@ -1741,8 +1738,8 @@ class EndpointContext {
|
|
|
1741
1738
|
.map(middlewareClassFun => {
|
|
1742
1739
|
const middlewareInstance = this.getInstanceBy(middlewareClassFun);
|
|
1743
1740
|
if (middlewareInstance &&
|
|
1744
|
-
|
|
1745
|
-
const middlewareFn =
|
|
1741
|
+
___NS__isFunction(middlewareInstance.interceptServerMethod)) {
|
|
1742
|
+
const middlewareFn = ClassHelpers__NS__asyncHandler(async (req, res, next) => {
|
|
1746
1743
|
await middlewareInstance.interceptServerMethod({
|
|
1747
1744
|
req,
|
|
1748
1745
|
res,
|
|
@@ -1769,18 +1766,18 @@ class EndpointContext {
|
|
|
1769
1766
|
* Params for method @GET, @PUT etc.
|
|
1770
1767
|
*/
|
|
1771
1768
|
resolvedParams);
|
|
1772
|
-
let result = await
|
|
1769
|
+
let result = await getResponseValue(response, { req, res });
|
|
1773
1770
|
return result;
|
|
1774
1771
|
};
|
|
1775
1772
|
//#endregion
|
|
1776
1773
|
// console.log(`BACKEND: expressPath: "${expressPath}" `);
|
|
1777
1774
|
//#endregion
|
|
1778
|
-
if (
|
|
1775
|
+
if (UtilsOs__NS__isElectron) {
|
|
1779
1776
|
//#region @backend
|
|
1780
|
-
const ipcKeyName =
|
|
1781
|
-
|
|
1777
|
+
const ipcKeyName = TaonHelpers__NS__ipcKeyNameRequest(target, methodConfig, expressPath);
|
|
1778
|
+
ipcMain.on(ipcKeyName, async (event, paramsFromBrowser) => {
|
|
1782
1779
|
const responseJsonData = await getResult(paramsFromBrowser, void 0, void 0);
|
|
1783
|
-
const sendToIpsMainOn =
|
|
1780
|
+
const sendToIpsMainOn = TaonHelpers__NS__ipcKeyNameResponse(target, methodConfig, expressPath);
|
|
1784
1781
|
// console.log({ sendToIpsMainOn });
|
|
1785
1782
|
event.sender.send(sendToIpsMainOn, responseJsonData);
|
|
1786
1783
|
});
|
|
@@ -1793,7 +1790,7 @@ class EndpointContext {
|
|
|
1793
1790
|
if (!this.isRemoteHost) {
|
|
1794
1791
|
//#region apply dummy websql express routers
|
|
1795
1792
|
//#region @websql
|
|
1796
|
-
if (
|
|
1793
|
+
if (UtilsOs__NS__isWebSQL) {
|
|
1797
1794
|
if (!this.expressApp[httpMethodType.toLowerCase()]) {
|
|
1798
1795
|
this.expressApp[httpMethodType.toLowerCase()] = () => { };
|
|
1799
1796
|
// TODO add middlewares for WEBSQL and ELECTRON mode
|
|
@@ -1811,60 +1808,60 @@ class EndpointContext {
|
|
|
1811
1808
|
let tBody = req.body;
|
|
1812
1809
|
let tParams = req.params;
|
|
1813
1810
|
let tQuery = req.query;
|
|
1814
|
-
if (req.headers[
|
|
1811
|
+
if (req.headers[Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY]) {
|
|
1815
1812
|
try {
|
|
1816
|
-
tBody = JSON.parse(JSON.stringify(tBody), JSON.parse(
|
|
1813
|
+
tBody = JSON.parse(JSON.stringify(tBody), JSON.parse(TaonHelpers__NS__firstStringOrElemFromArray(req.headers[Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY])));
|
|
1817
1814
|
}
|
|
1818
1815
|
catch (e) { }
|
|
1819
1816
|
}
|
|
1820
|
-
if (req.headers[
|
|
1817
|
+
if (req.headers[Symbols__NS__old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM]) {
|
|
1821
1818
|
try {
|
|
1822
|
-
tQuery = JSON.parse(JSON.stringify(tQuery), JSON.parse(
|
|
1819
|
+
tQuery = JSON.parse(JSON.stringify(tQuery), JSON.parse(TaonHelpers__NS__firstStringOrElemFromArray(req.headers[Symbols__NS__old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM])));
|
|
1823
1820
|
}
|
|
1824
1821
|
catch (e) { }
|
|
1825
1822
|
}
|
|
1826
1823
|
// make class instance from body
|
|
1827
1824
|
// console.log('req.headers', req.headers)
|
|
1828
|
-
if (req.headers[
|
|
1825
|
+
if (req.headers[Symbols__NS__old.MAPPING_CONFIG_HEADER_BODY_PARAMS]) {
|
|
1829
1826
|
try {
|
|
1830
|
-
const entity = JSON.parse(
|
|
1831
|
-
tBody =
|
|
1827
|
+
const entity = JSON.parse(TaonHelpers__NS__firstStringOrElemFromArray(req.headers[Symbols__NS__old.MAPPING_CONFIG_HEADER_BODY_PARAMS]));
|
|
1828
|
+
tBody = Mapping__NS__encode(tBody, entity);
|
|
1832
1829
|
}
|
|
1833
1830
|
catch (e) { }
|
|
1834
1831
|
}
|
|
1835
1832
|
else {
|
|
1836
1833
|
Object.keys(tBody).forEach(paramName => {
|
|
1837
1834
|
try {
|
|
1838
|
-
const entityForParam = JSON.parse(
|
|
1839
|
-
tBody[paramName] =
|
|
1835
|
+
const entityForParam = JSON.parse(TaonHelpers__NS__firstStringOrElemFromArray(req.headers[`${Symbols__NS__old.MAPPING_CONFIG_HEADER_BODY_PARAMS}${paramName} `]));
|
|
1836
|
+
tBody[paramName] = Mapping__NS__encode(tBody[paramName], entityForParam);
|
|
1840
1837
|
}
|
|
1841
1838
|
catch (e) { }
|
|
1842
1839
|
});
|
|
1843
1840
|
}
|
|
1844
1841
|
// make class instance from query params
|
|
1845
1842
|
// console.log('req.headers', tQuery)
|
|
1846
|
-
if (req.headers[
|
|
1843
|
+
if (req.headers[Symbols__NS__old.MAPPING_CONFIG_HEADER_QUERY_PARAMS]) {
|
|
1847
1844
|
try {
|
|
1848
|
-
const entity = JSON.parse(
|
|
1849
|
-
tQuery =
|
|
1845
|
+
const entity = JSON.parse(TaonHelpers__NS__firstStringOrElemFromArray(req.headers[Symbols__NS__old.MAPPING_CONFIG_HEADER_QUERY_PARAMS]));
|
|
1846
|
+
tQuery = TaonHelpers__NS__parseJSONwithStringJSONs(Mapping__NS__encode(tQuery, entity));
|
|
1850
1847
|
}
|
|
1851
1848
|
catch (e) { }
|
|
1852
1849
|
}
|
|
1853
1850
|
else {
|
|
1854
1851
|
Object.keys(tQuery).forEach(queryParamName => {
|
|
1855
1852
|
try {
|
|
1856
|
-
const entityForParam = JSON.parse(
|
|
1853
|
+
const entityForParam = JSON.parse(TaonHelpers__NS__firstStringOrElemFromArray(req.headers[`${Symbols__NS__old.MAPPING_CONFIG_HEADER_QUERY_PARAMS}${queryParamName} `]));
|
|
1857
1854
|
let beforeTransofrm = tQuery[queryParamName];
|
|
1858
|
-
if (
|
|
1855
|
+
if (___NS__isString(beforeTransofrm)) {
|
|
1859
1856
|
try {
|
|
1860
|
-
const paresed =
|
|
1857
|
+
const paresed = TaonHelpers__NS__tryTransformParam(beforeTransofrm);
|
|
1861
1858
|
beforeTransofrm = paresed;
|
|
1862
1859
|
}
|
|
1863
1860
|
catch (e) { }
|
|
1864
1861
|
}
|
|
1865
|
-
const afterEncoding =
|
|
1862
|
+
const afterEncoding = Mapping__NS__encode(beforeTransofrm, entityForParam);
|
|
1866
1863
|
tQuery[queryParamName] =
|
|
1867
|
-
|
|
1864
|
+
TaonHelpers__NS__parseJSONwithStringJSONs(afterEncoding);
|
|
1868
1865
|
}
|
|
1869
1866
|
catch (e) { }
|
|
1870
1867
|
});
|
|
@@ -1900,7 +1897,7 @@ class EndpointContext {
|
|
|
1900
1897
|
//#endregion
|
|
1901
1898
|
const resolvedParams = args
|
|
1902
1899
|
.reverse()
|
|
1903
|
-
.map(v =>
|
|
1900
|
+
.map(v => TaonHelpers__NS__tryTransformParam(v));
|
|
1904
1901
|
try {
|
|
1905
1902
|
let result = await getResult(resolvedParams, req, res);
|
|
1906
1903
|
if (methodConfig.responseType)
|
|
@@ -1927,7 +1924,7 @@ class EndpointContext {
|
|
|
1927
1924
|
res.end(file);
|
|
1928
1925
|
//#endregion
|
|
1929
1926
|
}
|
|
1930
|
-
else if (
|
|
1927
|
+
else if (___NS__isString(result) &&
|
|
1931
1928
|
methodConfig.responseType ===
|
|
1932
1929
|
'blob') {
|
|
1933
1930
|
// console.log('BASE64')
|
|
@@ -1948,7 +1945,7 @@ class EndpointContext {
|
|
|
1948
1945
|
}
|
|
1949
1946
|
else {
|
|
1950
1947
|
//#region process json request
|
|
1951
|
-
await
|
|
1948
|
+
await EntityProcess.init(result, res);
|
|
1952
1949
|
//#endregion
|
|
1953
1950
|
}
|
|
1954
1951
|
}
|
|
@@ -2005,7 +2002,7 @@ class EndpointContext {
|
|
|
2005
2002
|
message,
|
|
2006
2003
|
details,
|
|
2007
2004
|
code,
|
|
2008
|
-
[
|
|
2005
|
+
[CoreModels__NS__TaonHttpErrorCustomProp]: true,
|
|
2009
2006
|
});
|
|
2010
2007
|
//#endregion
|
|
2011
2008
|
}
|
|
@@ -2024,12 +2021,12 @@ class EndpointContext {
|
|
|
2024
2021
|
const middlewares = methodConfig.calculatedMiddlewares;
|
|
2025
2022
|
const middlewaresInstances = middlewares
|
|
2026
2023
|
.map(f => this.getInstanceBy(f))
|
|
2027
|
-
.filter(f =>
|
|
2024
|
+
.filter(f => ___NS__isFunction(f.interceptClientMethod));
|
|
2028
2025
|
middlewaresInstances.forEach(instance => {
|
|
2029
|
-
const middlewareName =
|
|
2026
|
+
const middlewareName = ClassHelpers__NS__getName(instance);
|
|
2030
2027
|
// middlewareName - only needed for inheritace and uniqness of interceptors
|
|
2031
2028
|
const interceptorKey = `${middlewareName}-${methodConfig.type?.toUpperCase()}-${expressPath}`;
|
|
2032
|
-
|
|
2029
|
+
Resource.request.methodsInterceptors.set(interceptorKey, {
|
|
2033
2030
|
intercept: ({ req, next }) => {
|
|
2034
2031
|
return instance.interceptClientMethod({
|
|
2035
2032
|
req,
|
|
@@ -2053,12 +2050,12 @@ class EndpointContext {
|
|
|
2053
2050
|
//#endregion
|
|
2054
2051
|
const orgMethods = target.prototype[methodConfig.methodName];
|
|
2055
2052
|
//#region handle electron ipc request
|
|
2056
|
-
if (
|
|
2053
|
+
if (UtilsOs__NS__isElectron) {
|
|
2057
2054
|
const ipcRenderer = window.require('electron').ipcRenderer;
|
|
2058
2055
|
target.prototype[methodConfig.methodName] = function (...args) {
|
|
2059
2056
|
const received = new Promise(async (resolve, reject) => {
|
|
2060
2057
|
const headers = {};
|
|
2061
|
-
const { request, response } =
|
|
2058
|
+
const { request, response } = TaonHelpers__NS__websqlMocks(headers);
|
|
2062
2059
|
/* */
|
|
2063
2060
|
/* */
|
|
2064
2061
|
/* */
|
|
@@ -2096,7 +2093,7 @@ class EndpointContext {
|
|
|
2096
2093
|
/* */
|
|
2097
2094
|
/* */
|
|
2098
2095
|
});
|
|
2099
|
-
received['observable'] =
|
|
2096
|
+
received['observable'] = from(received);
|
|
2100
2097
|
return {
|
|
2101
2098
|
received,
|
|
2102
2099
|
request(axiosConfig) {
|
|
@@ -2264,34 +2261,34 @@ class EndpointContext {
|
|
|
2264
2261
|
// console.log('[init method browser] FRONTEND expressPath', expressPath)
|
|
2265
2262
|
// const productionMode = FrameworkContext.isProductionMode;
|
|
2266
2263
|
//#region resolve frontend parameters
|
|
2267
|
-
if (!storage[
|
|
2268
|
-
storage[
|
|
2269
|
-
if (!storage[
|
|
2270
|
-
storage[
|
|
2271
|
-
const endpoints = storage[
|
|
2264
|
+
if (!storage[Symbols__NS__old.ENDPOINT_META_CONFIG])
|
|
2265
|
+
storage[Symbols__NS__old.ENDPOINT_META_CONFIG] = {};
|
|
2266
|
+
if (!storage[Symbols__NS__old.ENDPOINT_META_CONFIG][ctx.uriOrigin])
|
|
2267
|
+
storage[Symbols__NS__old.ENDPOINT_META_CONFIG][ctx.uriOrigin] = {};
|
|
2268
|
+
const endpoints = storage[Symbols__NS__old.ENDPOINT_META_CONFIG];
|
|
2272
2269
|
let rest;
|
|
2273
2270
|
if (!endpoints[ctx.uriOrigin][expressPath]) {
|
|
2274
2271
|
let headers = {};
|
|
2275
2272
|
if (methodConfig.contentType && !methodConfig.responseType) {
|
|
2276
|
-
rest =
|
|
2273
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols__NS__old.MAPPING_CONFIG_HEADER, Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
2277
2274
|
'Content-Type': methodConfig.contentType,
|
|
2278
2275
|
Accept: methodConfig.contentType,
|
|
2279
2276
|
}));
|
|
2280
2277
|
}
|
|
2281
2278
|
else if (methodConfig.contentType && methodConfig.responseType) {
|
|
2282
|
-
rest =
|
|
2279
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols__NS__old.MAPPING_CONFIG_HEADER, Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
2283
2280
|
'Content-Type': methodConfig.contentType,
|
|
2284
2281
|
Accept: methodConfig.contentType,
|
|
2285
2282
|
responsetypeaxios: methodConfig.responseType,
|
|
2286
2283
|
}));
|
|
2287
2284
|
}
|
|
2288
2285
|
else if (!methodConfig.contentType && methodConfig.responseType) {
|
|
2289
|
-
rest =
|
|
2286
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols__NS__old.MAPPING_CONFIG_HEADER, Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
2290
2287
|
responsetypeaxios: methodConfig.responseType,
|
|
2291
2288
|
}));
|
|
2292
2289
|
}
|
|
2293
2290
|
else {
|
|
2294
|
-
rest =
|
|
2291
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols__NS__old.MAPPING_CONFIG_HEADER, Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY);
|
|
2295
2292
|
}
|
|
2296
2293
|
endpoints[ctx.uriOrigin][expressPath] = rest;
|
|
2297
2294
|
}
|
|
@@ -2312,7 +2309,7 @@ class EndpointContext {
|
|
|
2312
2309
|
}
|
|
2313
2310
|
}
|
|
2314
2311
|
if (!currentParam) {
|
|
2315
|
-
const errorMessage = `[${
|
|
2312
|
+
const errorMessage = `[${config.frameworkName}] Unable to resolve parameter` +
|
|
2316
2313
|
` at index ${i} for method ${methodConfig.methodName} at path ${expressPath}.`;
|
|
2317
2314
|
//#region @backend
|
|
2318
2315
|
console.error(errorMessage);
|
|
@@ -2325,23 +2322,23 @@ class EndpointContext {
|
|
|
2325
2322
|
}
|
|
2326
2323
|
if (currentParam.paramType === 'Query') {
|
|
2327
2324
|
if (currentParam.paramName) {
|
|
2328
|
-
const mapping =
|
|
2325
|
+
const mapping = Mapping__NS__decode(param, !ctx.isProductionMode);
|
|
2329
2326
|
if (mapping) {
|
|
2330
|
-
rest.headers.set(`${
|
|
2327
|
+
rest.headers.set(`${Symbols__NS__old.MAPPING_CONFIG_HEADER_QUERY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
|
|
2331
2328
|
}
|
|
2332
2329
|
queryParams[currentParam.paramName] = param;
|
|
2333
2330
|
}
|
|
2334
2331
|
else {
|
|
2335
|
-
const mapping =
|
|
2332
|
+
const mapping = Mapping__NS__decode(param, !ctx.isProductionMode);
|
|
2336
2333
|
if (mapping) {
|
|
2337
|
-
rest.headers.set(
|
|
2334
|
+
rest.headers.set(Symbols__NS__old.MAPPING_CONFIG_HEADER_QUERY_PARAMS, JSON.stringify(mapping));
|
|
2338
2335
|
}
|
|
2339
|
-
queryParams =
|
|
2336
|
+
queryParams = ___NS__cloneDeep(param);
|
|
2340
2337
|
}
|
|
2341
2338
|
}
|
|
2342
2339
|
if (currentParam.paramType === 'Header') {
|
|
2343
2340
|
if (currentParam.paramName) {
|
|
2344
|
-
if (currentParam.paramName ===
|
|
2341
|
+
if (currentParam.paramName === Symbols__NS__old.MDC_KEY) {
|
|
2345
2342
|
// parese MDC
|
|
2346
2343
|
rest.headers.set(currentParam.paramName, encodeURIComponent(JSON.stringify(param)));
|
|
2347
2344
|
}
|
|
@@ -2356,11 +2353,11 @@ class EndpointContext {
|
|
|
2356
2353
|
}
|
|
2357
2354
|
}
|
|
2358
2355
|
if (currentParam.paramType === 'Cookie') {
|
|
2359
|
-
|
|
2356
|
+
Resource.Cookies.write(currentParam.paramName, param, currentParam.expireInSeconds);
|
|
2360
2357
|
}
|
|
2361
2358
|
if (currentParam.paramType === 'Body') {
|
|
2362
2359
|
if (currentParam.paramName) {
|
|
2363
|
-
if (
|
|
2360
|
+
if (ClassHelpers__NS__getName(bodyObject) === 'FormData') {
|
|
2364
2361
|
throw new Error(`[taon - framework] Don use param names when posting / putting FormData.
|
|
2365
2362
|
Use this:
|
|
2366
2363
|
// ...
|
|
@@ -2373,35 +2370,35 @@ instead
|
|
|
2373
2370
|
// ...
|
|
2374
2371
|
`);
|
|
2375
2372
|
}
|
|
2376
|
-
const mapping =
|
|
2373
|
+
const mapping = Mapping__NS__decode(param, !ctx.isProductionMode);
|
|
2377
2374
|
if (mapping) {
|
|
2378
|
-
rest.headers.set(`${
|
|
2375
|
+
rest.headers.set(`${Symbols__NS__old.MAPPING_CONFIG_HEADER_BODY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
|
|
2379
2376
|
}
|
|
2380
2377
|
bodyObject[currentParam.paramName] = param;
|
|
2381
2378
|
}
|
|
2382
2379
|
else {
|
|
2383
|
-
const mapping =
|
|
2380
|
+
const mapping = Mapping__NS__decode(param, !ctx.isProductionMode);
|
|
2384
2381
|
if (mapping) {
|
|
2385
|
-
rest.headers.set(
|
|
2382
|
+
rest.headers.set(Symbols__NS__old.MAPPING_CONFIG_HEADER_BODY_PARAMS, JSON.stringify(mapping));
|
|
2386
2383
|
}
|
|
2387
2384
|
bodyObject = param;
|
|
2388
2385
|
}
|
|
2389
2386
|
}
|
|
2390
2387
|
});
|
|
2391
2388
|
if (typeof bodyObject === 'object' &&
|
|
2392
|
-
|
|
2389
|
+
ClassHelpers__NS__getName(bodyObject) !== 'FormData') {
|
|
2393
2390
|
let circuralFromItem = [];
|
|
2394
|
-
bodyObject =
|
|
2391
|
+
bodyObject = JSON10.parse(JSON10.stringify(bodyObject, void 0, void 0, circs => {
|
|
2395
2392
|
circuralFromItem = circs;
|
|
2396
2393
|
}));
|
|
2397
|
-
rest.headers.set(
|
|
2394
|
+
rest.headers.set(Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY, JSON10.stringify(circuralFromItem));
|
|
2398
2395
|
}
|
|
2399
2396
|
if (typeof queryParams === 'object') {
|
|
2400
2397
|
let circuralFromQueryParams = [];
|
|
2401
|
-
queryParams =
|
|
2398
|
+
queryParams = JSON10.parse(JSON10.stringify(queryParams, void 0, void 0, circs => {
|
|
2402
2399
|
circuralFromQueryParams = circs;
|
|
2403
2400
|
}));
|
|
2404
|
-
rest.headers.set(
|
|
2401
|
+
rest.headers.set(Symbols__NS__old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM, JSON10.stringify(circuralFromQueryParams));
|
|
2405
2402
|
}
|
|
2406
2403
|
//#endregion
|
|
2407
2404
|
const httpResultObj = {
|
|
@@ -2418,5 +2415,4 @@ instead
|
|
|
2418
2415
|
//#endregion
|
|
2419
2416
|
}
|
|
2420
2417
|
}
|
|
2421
|
-
exports.EndpointContext = EndpointContext;
|
|
2422
2418
|
//# sourceMappingURL=endpoint-context.js.map
|