taon 21.0.56 → 21.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/fesm2022/taon-browser.mjs +1 -0
- package/browser/fesm2022/taon-browser.mjs.map +1 -1
- package/browser/package.json +1 -1
- package/browser-prod/fesm2022/taon-browser.mjs +1 -0
- package/browser-prod/fesm2022/taon-browser.mjs.map +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/endpoint-context.js +2 -2
- package/lib/endpoint-context.js.map +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/fesm2022/taon-websql.mjs +1 -0
- package/websql/fesm2022/taon-websql.mjs.map +1 -1
- package/websql/package.json +1 -1
- package/websql-prod/fesm2022/taon-websql.mjs +1 -0
- package/websql-prod/fesm2022/taon-websql.mjs.map +1 -1
- package/websql-prod/package.json +1 -1
|
@@ -1,33 +1,29 @@
|
|
|
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
|
-
const taon_helpers_1 = require("./helpers/taon-helpers");
|
|
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 { JSON10 } from 'json10/lib-prod';
|
|
4
|
+
import { walk } from 'lodash-walk-object/lib-prod';
|
|
5
|
+
import { Resource, RestHeaders, Mapping__NS__decode, Mapping__NS__encode } from 'ng2-rest/lib-prod';
|
|
6
|
+
import { from } from 'rxjs';
|
|
7
|
+
import { EventSubscriber } from 'taon-typeorm/lib-prod'; // @websql
|
|
8
|
+
import { Entity as TypeormEntity } from 'taon-typeorm/lib-prod'; // @websql
|
|
9
|
+
import { DataSource, } from 'taon-typeorm/lib-prod';
|
|
10
|
+
import { path, requireDefault } from 'tnp-core/lib-prod';
|
|
11
|
+
import { config } from 'tnp-core/lib-prod';
|
|
12
|
+
import { CoreModels__NS__TaonHttpErrorCustomProp } from 'tnp-core/lib-prod';
|
|
13
|
+
import { fse, http, https } from 'tnp-core/lib-prod'; // @backend
|
|
14
|
+
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';
|
|
15
|
+
import { crossPlatformPath } from 'tnp-core/lib-prod';
|
|
16
|
+
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';
|
|
17
|
+
import { apiPrefix } from './constants';
|
|
18
|
+
import { ContextDbMigrations } from './context-db-migrations';
|
|
19
|
+
import { DITaonContainer } from './dependency-injection/di-container';
|
|
20
|
+
import { EntityProcess } from './entity-process';
|
|
21
|
+
import { getResponseValue } from './get-response-value';
|
|
22
|
+
import { ClassHelpers__NS__asyncHandler, ClassHelpers__NS__getControllerConfigs, ClassHelpers__NS__getMethodsNames, ClassHelpers__NS__getName, ClassHelpers__NS__getOrginalClass } from './helpers/class-helpers';
|
|
23
|
+
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';
|
|
24
|
+
import { Models__NS__ClassType, Models__NS__ClassTypeKey, Models__NS__DatabaseConfig, Models__NS__DatabasesFolder } from './models';
|
|
25
|
+
import { RealtimeCore } from './realtime/realtime-core';
|
|
26
|
+
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
27
|
/* */
|
|
32
28
|
//#endregion
|
|
33
29
|
let bodyParser;
|
|
@@ -37,14 +33,14 @@ let express;
|
|
|
37
33
|
let methodOverride;
|
|
38
34
|
let expressSession;
|
|
39
35
|
//#region @backend
|
|
40
|
-
bodyParser =
|
|
41
|
-
cookieParser =
|
|
42
|
-
cors =
|
|
43
|
-
express =
|
|
44
|
-
methodOverride =
|
|
45
|
-
expressSession =
|
|
36
|
+
bodyParser = requireDefault('body-parser');
|
|
37
|
+
cookieParser = requireDefault('cookie-parser');
|
|
38
|
+
cors = requireDefault('cors');
|
|
39
|
+
express = requireDefault('express');
|
|
40
|
+
methodOverride = requireDefault('method-override');
|
|
41
|
+
expressSession = requireDefault('express-session');
|
|
46
42
|
//#endregion
|
|
47
|
-
class EndpointContext {
|
|
43
|
+
export class EndpointContext {
|
|
48
44
|
originalConfig;
|
|
49
45
|
configFn;
|
|
50
46
|
cloneOptions;
|
|
@@ -64,7 +60,7 @@ class EndpointContext {
|
|
|
64
60
|
inited = false;
|
|
65
61
|
//#endregion
|
|
66
62
|
//#region fields / db migrations
|
|
67
|
-
dbMigrations = new
|
|
63
|
+
dbMigrations = new ContextDbMigrations(this);
|
|
68
64
|
//#endregion
|
|
69
65
|
//#region fields / local instance obj symbol
|
|
70
66
|
localInstaceObjSymbol = Symbol('localInstaceObjSymbol');
|
|
@@ -100,18 +96,18 @@ class EndpointContext {
|
|
|
100
96
|
//#endregion
|
|
101
97
|
//#region fields / types from contexts
|
|
102
98
|
injectableTypesfromContexts = [
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
99
|
+
Models__NS__ClassType.CONTROLLER,
|
|
100
|
+
Models__NS__ClassType.PROVIDER,
|
|
101
|
+
Models__NS__ClassType.MIDDLEWARE,
|
|
102
|
+
Models__NS__ClassType.REPOSITORY,
|
|
103
|
+
Models__NS__ClassType.SUBSCRIBER,
|
|
104
|
+
Models__NS__ClassType.MIGRATION,
|
|
109
105
|
];
|
|
110
106
|
//#endregion
|
|
111
107
|
//#region fields / all types from contexts
|
|
112
108
|
allTypesfromContexts = [
|
|
113
109
|
...this.injectableTypesfromContexts,
|
|
114
|
-
|
|
110
|
+
Models__NS__ClassType.ENTITY,
|
|
115
111
|
];
|
|
116
112
|
//#endregion
|
|
117
113
|
//#region fields / express app
|
|
@@ -159,37 +155,37 @@ class EndpointContext {
|
|
|
159
155
|
//#endregion
|
|
160
156
|
//#region fields / logs
|
|
161
157
|
get logHttp() {
|
|
162
|
-
if (
|
|
158
|
+
if (___NS__isObject(this.config?.logs)) {
|
|
163
159
|
return !!this.config.logs.http;
|
|
164
160
|
}
|
|
165
161
|
return this.config?.logs === true;
|
|
166
162
|
}
|
|
167
163
|
get logRealtime() {
|
|
168
|
-
if (
|
|
164
|
+
if (___NS__isObject(this.config?.logs)) {
|
|
169
165
|
return !!this.config.logs.realtime;
|
|
170
166
|
}
|
|
171
167
|
return this.config?.logs === true;
|
|
172
168
|
}
|
|
173
169
|
get logFramework() {
|
|
174
|
-
if (
|
|
170
|
+
if (___NS__isObject(this.config?.logs)) {
|
|
175
171
|
return !!this.config.logs.framework;
|
|
176
172
|
}
|
|
177
173
|
return this.config?.logs === true;
|
|
178
174
|
}
|
|
179
175
|
get logRoutes() {
|
|
180
|
-
if (
|
|
176
|
+
if (___NS__isObject(this.config?.logs)) {
|
|
181
177
|
return !!this.config.logs.routes;
|
|
182
178
|
}
|
|
183
179
|
return this.config?.logs === true;
|
|
184
180
|
}
|
|
185
181
|
get logDb() {
|
|
186
|
-
if (
|
|
182
|
+
if (___NS__isObject(this.config?.logs)) {
|
|
187
183
|
return !!this.config.logs.db;
|
|
188
184
|
}
|
|
189
185
|
return this.config?.logs === true;
|
|
190
186
|
}
|
|
191
187
|
get logMigrations() {
|
|
192
|
-
if (
|
|
188
|
+
if (___NS__isObject(this.config?.logs)) {
|
|
193
189
|
return !!this.config.logs.migrations;
|
|
194
190
|
}
|
|
195
191
|
return this.config?.logs === true;
|
|
@@ -213,7 +209,7 @@ class EndpointContext {
|
|
|
213
209
|
this.configFn = configFn;
|
|
214
210
|
this.cloneOptions = cloneOptions;
|
|
215
211
|
this.cloneOptions = this.cloneOptions || {};
|
|
216
|
-
this.isRunningInsideDocker =
|
|
212
|
+
this.isRunningInsideDocker = UtilsOs__NS__isRunningInDocker();
|
|
217
213
|
}
|
|
218
214
|
//#endregion
|
|
219
215
|
//#region methods & getters / init
|
|
@@ -225,8 +221,8 @@ class EndpointContext {
|
|
|
225
221
|
// @ts-ignore
|
|
226
222
|
this.onlyMigrationRevertToTimestamp = onlyMigrationRevertToTimestamp;
|
|
227
223
|
this.config = this.configFn({});
|
|
228
|
-
if (
|
|
229
|
-
this.config.database =
|
|
224
|
+
if (___NS__isObject(this.config.database)) {
|
|
225
|
+
this.config.database = Models__NS__DatabaseConfig.from(this.config.database).databaseConfigTypeORM;
|
|
230
226
|
}
|
|
231
227
|
this.config.host = this.host === null ? void 0 : this.host;
|
|
232
228
|
if (this.cloneOptions.overrideHost &&
|
|
@@ -240,15 +236,15 @@ class EndpointContext {
|
|
|
240
236
|
if (this.config.host &&
|
|
241
237
|
!this.config.host.startsWith('http://') &&
|
|
242
238
|
!this.config.host.startsWith('https://')) {
|
|
243
|
-
|
|
239
|
+
Helpers__NS__throwError(`[taon-config] Your${this.host ? ' remote' : ''} 'host' must start with http:// or https://`);
|
|
244
240
|
}
|
|
245
|
-
if (
|
|
241
|
+
if (___NS__isUndefined(this.config.useIpcWhenElectron)) {
|
|
246
242
|
this.config.useIpcWhenElectron = true;
|
|
247
243
|
}
|
|
248
244
|
// console.log(`config for ${this.contextName}`, this.config);
|
|
249
245
|
//#region resolve if skipping writing server routes
|
|
250
246
|
//@ts-expect-error overriding readonly
|
|
251
|
-
this.skipWritingServerRoutes =
|
|
247
|
+
this.skipWritingServerRoutes = ___NS__isBoolean(this.config.skipWritingServerRoutes)
|
|
252
248
|
? this.config.skipWritingServerRoutes
|
|
253
249
|
: false;
|
|
254
250
|
//#endregion
|
|
@@ -265,8 +261,8 @@ class EndpointContext {
|
|
|
265
261
|
// useIpcWhenElectron: ${this.config.useIpcWhenElectron}
|
|
266
262
|
// UtilsOs__NS__isElectron: ${UtilsOs__NS__isElectron}
|
|
267
263
|
// `)
|
|
268
|
-
if (this.config.useIpcWhenElectron &&
|
|
269
|
-
if (
|
|
264
|
+
if (this.config.useIpcWhenElectron && UtilsOs__NS__isElectron) {
|
|
265
|
+
if (UtilsOs__NS__isWebSQL) {
|
|
270
266
|
this.mode = 'backend-frontend(websql-electron)';
|
|
271
267
|
}
|
|
272
268
|
else {
|
|
@@ -281,7 +277,7 @@ class EndpointContext {
|
|
|
281
277
|
if (!this.mode && !this.config.abstract) {
|
|
282
278
|
const errMsg = `You need to provide host property or ` +
|
|
283
279
|
`useIpcWhenElectron or mark it as abstract`;
|
|
284
|
-
|
|
280
|
+
Helpers__NS__error(`[taon][Context=${this.contextName}]: ${errMsg}`, false, true);
|
|
285
281
|
//#region @backend
|
|
286
282
|
process.exit(1);
|
|
287
283
|
//#endregion
|
|
@@ -297,7 +293,7 @@ class EndpointContext {
|
|
|
297
293
|
`);
|
|
298
294
|
this.databaseConfig = this.getAutoGeneratedConfig();
|
|
299
295
|
}
|
|
300
|
-
else if (
|
|
296
|
+
else if (___NS__isObject(this.config.database)) {
|
|
301
297
|
this.logFramework &&
|
|
302
298
|
console.log(`
|
|
303
299
|
|
|
@@ -305,14 +301,14 @@ class EndpointContext {
|
|
|
305
301
|
|
|
306
302
|
`);
|
|
307
303
|
this.databaseConfig = this.getAutoGeneratedConfig();
|
|
308
|
-
|
|
309
|
-
if (
|
|
304
|
+
walk.Object(this.config.database, (value, lodashPath) => {
|
|
305
|
+
if (___NS__isNil(value) || ___NS__isFunction(value) || ___NS__isObject(value)) {
|
|
310
306
|
// skipping
|
|
311
307
|
}
|
|
312
308
|
else {
|
|
313
309
|
this.logFramework &&
|
|
314
310
|
console.info(`Overriding database config: ${lodashPath}=${value}`);
|
|
315
|
-
|
|
311
|
+
___NS__set(this.databaseConfig, lodashPath, value);
|
|
316
312
|
}
|
|
317
313
|
}, {
|
|
318
314
|
walkGetters: false,
|
|
@@ -321,13 +317,13 @@ class EndpointContext {
|
|
|
321
317
|
//#endregion
|
|
322
318
|
//#region resolve session
|
|
323
319
|
if (this.config.session) {
|
|
324
|
-
this.session =
|
|
320
|
+
this.session = ___NS__cloneDeep(this.config.session);
|
|
325
321
|
const oneHour = 1000 * 60 * 60 * 1; // 24;
|
|
326
322
|
if (!this.session.cookieMaxAge) {
|
|
327
323
|
this.session.cookieMaxAge = oneHour;
|
|
328
324
|
}
|
|
329
325
|
// serever and browser cookie authentication
|
|
330
|
-
|
|
326
|
+
axios.defaults.withCredentials = true;
|
|
331
327
|
}
|
|
332
328
|
//#endregion
|
|
333
329
|
//#region prepare & gather all classes recursively
|
|
@@ -339,31 +335,31 @@ class EndpointContext {
|
|
|
339
335
|
this.config.subscribers = this.config.subscribers || {};
|
|
340
336
|
this.config.migrations = this.config.migrations || {};
|
|
341
337
|
this.config.entities = {
|
|
342
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
338
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models__NS__ClassType.ENTITY)),
|
|
343
339
|
...this.config.entities,
|
|
344
340
|
};
|
|
345
341
|
this.config.controllers = {
|
|
346
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
342
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models__NS__ClassType.CONTROLLER)),
|
|
347
343
|
...this.config.controllers,
|
|
348
344
|
};
|
|
349
345
|
this.config.providers = {
|
|
350
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
346
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models__NS__ClassType.PROVIDER)),
|
|
351
347
|
...this.config.providers,
|
|
352
348
|
};
|
|
353
349
|
this.config.middlewares = {
|
|
354
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
350
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models__NS__ClassType.MIDDLEWARE)),
|
|
355
351
|
...this.config.middlewares,
|
|
356
352
|
};
|
|
357
353
|
this.config.subscribers = {
|
|
358
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
354
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models__NS__ClassType.SUBSCRIBER)),
|
|
359
355
|
...this.config.subscribers,
|
|
360
356
|
};
|
|
361
357
|
this.config.repositories = {
|
|
362
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
358
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models__NS__ClassType.REPOSITORY)),
|
|
363
359
|
...this.config.repositories,
|
|
364
360
|
};
|
|
365
361
|
this.config.migrations = {
|
|
366
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
362
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models__NS__ClassType.MIGRATION)),
|
|
367
363
|
...this.config.migrations,
|
|
368
364
|
};
|
|
369
365
|
// console.log(this.config);
|
|
@@ -374,37 +370,37 @@ class EndpointContext {
|
|
|
374
370
|
classesInput: this.config.controllers,
|
|
375
371
|
config: this.config,
|
|
376
372
|
ctx: this,
|
|
377
|
-
classType:
|
|
373
|
+
classType: Models__NS__ClassType.CONTROLLER,
|
|
378
374
|
});
|
|
379
375
|
this.config.repositories = this.cloneClassesObjWithNewMetadata({
|
|
380
376
|
classesInput: this.config.repositories,
|
|
381
377
|
config: this.config,
|
|
382
378
|
ctx: this,
|
|
383
|
-
classType:
|
|
379
|
+
classType: Models__NS__ClassType.REPOSITORY,
|
|
384
380
|
});
|
|
385
381
|
this.config.providers = this.cloneClassesObjWithNewMetadata({
|
|
386
382
|
classesInput: this.config.providers,
|
|
387
383
|
config: this.config,
|
|
388
384
|
ctx: this,
|
|
389
|
-
classType:
|
|
385
|
+
classType: Models__NS__ClassType.PROVIDER,
|
|
390
386
|
});
|
|
391
387
|
this.config.middlewares = this.cloneClassesObjWithNewMetadata({
|
|
392
388
|
classesInput: this.config.middlewares,
|
|
393
389
|
config: this.config,
|
|
394
390
|
ctx: this,
|
|
395
|
-
classType:
|
|
391
|
+
classType: Models__NS__ClassType.MIDDLEWARE,
|
|
396
392
|
});
|
|
397
393
|
this.config.subscribers = this.cloneClassesObjWithNewMetadata({
|
|
398
394
|
classesInput: this.config.subscribers,
|
|
399
395
|
config: this.config,
|
|
400
396
|
ctx: this,
|
|
401
|
-
classType:
|
|
397
|
+
classType: Models__NS__ClassType.SUBSCRIBER,
|
|
402
398
|
});
|
|
403
399
|
this.config.migrations = this.cloneClassesObjWithNewMetadata({
|
|
404
400
|
classesInput: this.config.migrations,
|
|
405
401
|
config: this.config,
|
|
406
402
|
ctx: this,
|
|
407
|
-
classType:
|
|
403
|
+
classType: Models__NS__ClassType.MIGRATION,
|
|
408
404
|
});
|
|
409
405
|
//#endregion
|
|
410
406
|
//#region prepare instances
|
|
@@ -413,7 +409,7 @@ class EndpointContext {
|
|
|
413
409
|
this.objWithClassesInstancesArr[classTypeName] = [];
|
|
414
410
|
}
|
|
415
411
|
for (const classTypeName of this.injectableTypesfromContexts) {
|
|
416
|
-
await this.createInstances(this.config[
|
|
412
|
+
await this.createInstances(this.config[Models__NS__ClassTypeKey[classTypeName]], classTypeName);
|
|
417
413
|
}
|
|
418
414
|
//#endregion
|
|
419
415
|
if (!this.isRunOrRevertOnlyMigrationAppStart) {
|
|
@@ -428,17 +424,17 @@ class EndpointContext {
|
|
|
428
424
|
await this.initCustomBackendMiddlewares();
|
|
429
425
|
const shouldStartHttpsSecureServer = this.isHttpServer && !this.isRunningInsideDocker;
|
|
430
426
|
this.logFramework &&
|
|
431
|
-
|
|
427
|
+
Helpers__NS__info(`
|
|
432
428
|
|
|
433
429
|
Starting server ${shouldStartHttpsSecureServer ? 'with' : 'without'} HTTPS secure server
|
|
434
430
|
|
|
435
431
|
`);
|
|
436
432
|
this.serverTcpUdp = shouldStartHttpsSecureServer
|
|
437
|
-
? new
|
|
433
|
+
? new https.Server({
|
|
438
434
|
key: this.config.https?.key,
|
|
439
435
|
cert: this.config.https?.cert,
|
|
440
436
|
}, this.expressApp)
|
|
441
|
-
: new
|
|
437
|
+
: new http.Server(this.expressApp);
|
|
442
438
|
this.publicAssets.forEach(asset => {
|
|
443
439
|
this.expressApp.use(asset.serverPath, express.static(asset.locationOnDisk));
|
|
444
440
|
});
|
|
@@ -467,8 +463,8 @@ class EndpointContext {
|
|
|
467
463
|
// }
|
|
468
464
|
//#endregion
|
|
469
465
|
this.logRealtime &&
|
|
470
|
-
|
|
471
|
-
this.realtime = new
|
|
466
|
+
Helpers__NS__info(`[ctx=${this.contextName}] Init Realtime for ${this.mode}`);
|
|
467
|
+
this.realtime = new RealtimeCore(this);
|
|
472
468
|
}
|
|
473
469
|
//#endregion
|
|
474
470
|
}
|
|
@@ -476,16 +472,16 @@ class EndpointContext {
|
|
|
476
472
|
// console.log({ ref })
|
|
477
473
|
if (this.config.abstract) {
|
|
478
474
|
this.logFramework &&
|
|
479
|
-
|
|
475
|
+
Helpers__NS__info(`[taon] Create abstract context: ${this.config.contextName}`);
|
|
480
476
|
}
|
|
481
477
|
else {
|
|
482
478
|
if (this.isRemoteHost) {
|
|
483
479
|
this.logFramework &&
|
|
484
|
-
|
|
480
|
+
Helpers__NS__info(`[taon] Create context for remote host: ${this.config.host}`);
|
|
485
481
|
}
|
|
486
482
|
else {
|
|
487
483
|
this.logFramework &&
|
|
488
|
-
|
|
484
|
+
Helpers__NS__info(`[taon] Create context for host: ${this.config.host}`);
|
|
489
485
|
}
|
|
490
486
|
}
|
|
491
487
|
//#endregion
|
|
@@ -505,8 +501,8 @@ class EndpointContext {
|
|
|
505
501
|
|
|
506
502
|
`);
|
|
507
503
|
//#region @websqlFunc
|
|
508
|
-
let databaseConfig =
|
|
509
|
-
const tcpUdpDatabaseSqliteRelativeFileLocation = `${
|
|
504
|
+
let databaseConfig = Models__NS__DatabaseConfig.from({});
|
|
505
|
+
const tcpUdpDatabaseSqliteRelativeFileLocation = `${Models__NS__DatabasesFolder}/db-${this.contextName}.sqlite`;
|
|
510
506
|
if (this.isRunningInsideDocker) {
|
|
511
507
|
if (this.USE_MARIADB_MYSQL_IN_DOCKER) {
|
|
512
508
|
// Helpers__NS__info('Running in docker, using in mysql database');
|
|
@@ -531,12 +527,12 @@ class EndpointContext {
|
|
|
531
527
|
|
|
532
528
|
`);
|
|
533
529
|
//#region @backend
|
|
534
|
-
const locationOfTheDatabase =
|
|
530
|
+
const locationOfTheDatabase = crossPlatformPath([
|
|
535
531
|
process.cwd(),
|
|
536
532
|
`db-${this.contextName}.sqlite`,
|
|
537
533
|
]);
|
|
538
534
|
//#endregion
|
|
539
|
-
databaseConfig = databaseConfig =
|
|
535
|
+
databaseConfig = databaseConfig = Models__NS__DatabaseConfig.from({
|
|
540
536
|
location: tcpUdpDatabaseSqliteRelativeFileLocation,
|
|
541
537
|
type: 'sqljs',
|
|
542
538
|
useLocalForage: false,
|
|
@@ -544,14 +540,14 @@ class EndpointContext {
|
|
|
544
540
|
logging: true,
|
|
545
541
|
});
|
|
546
542
|
//#region @backend
|
|
547
|
-
if (!
|
|
543
|
+
if (!fse.existsSync(locationOfTheDatabase)) {
|
|
548
544
|
databaseConfig.recreateMode = 'DROP_DB+MIGRATIONS';
|
|
549
545
|
}
|
|
550
546
|
// TODO @LAST add same thing for mariadb/mysql
|
|
551
547
|
this.logFramework &&
|
|
552
548
|
console.log(`
|
|
553
549
|
location of database: ${locationOfTheDatabase}
|
|
554
|
-
db file exists: ${
|
|
550
|
+
db file exists: ${fse.existsSync(locationOfTheDatabase)}
|
|
555
551
|
synchronize: ${databaseConfig.synchronize}
|
|
556
552
|
dropSchema: ${databaseConfig.dropSchema}
|
|
557
553
|
`);
|
|
@@ -561,24 +557,24 @@ class EndpointContext {
|
|
|
561
557
|
else {
|
|
562
558
|
//#region auto resolve db config
|
|
563
559
|
this.logFramework &&
|
|
564
|
-
|
|
560
|
+
Helpers__NS__info(`[taon][database] Automatically resolving database config for mode ${this.mode}`);
|
|
565
561
|
switch (this.mode) {
|
|
566
562
|
//#region resolve database config for backend-frontend(ipc-electron)
|
|
567
563
|
case 'backend-frontend(ipc-electron)':
|
|
568
564
|
let dbLocationInOs;
|
|
569
565
|
//#region @backend
|
|
570
|
-
if (
|
|
571
|
-
dbLocationInOs =
|
|
572
|
-
|
|
573
|
-
`.taon/databases-for-electron-apps/${this.appId ||
|
|
566
|
+
if (UtilsOs__NS__isElectron) {
|
|
567
|
+
dbLocationInOs = crossPlatformPath([
|
|
568
|
+
UtilsOs__NS__getRealHomeDir(),
|
|
569
|
+
`.taon/databases-for-electron-apps/${this.appId || ___NS__snakeCase(process.cwd()).replace(/\_/, '.')}/${this.contextName}.sqlite`,
|
|
574
570
|
]);
|
|
575
|
-
if (!
|
|
576
|
-
|
|
571
|
+
if (!Helpers__NS__exists(path.dirname(dbLocationInOs))) {
|
|
572
|
+
Helpers__NS__mkdirp(path.dirname(dbLocationInOs));
|
|
577
573
|
}
|
|
578
574
|
}
|
|
579
575
|
//#endregion
|
|
580
|
-
databaseConfig =
|
|
581
|
-
location:
|
|
576
|
+
databaseConfig = Models__NS__DatabaseConfig.from({
|
|
577
|
+
location: UtilsOs__NS__isElectron
|
|
582
578
|
? dbLocationInOs
|
|
583
579
|
: `db-${this.contextName}.sqlite`,
|
|
584
580
|
type: 'sqljs',
|
|
@@ -594,7 +590,7 @@ class EndpointContext {
|
|
|
594
590
|
/* */
|
|
595
591
|
/* */
|
|
596
592
|
/* */
|
|
597
|
-
databaseConfig = databaseConfig =
|
|
593
|
+
databaseConfig = databaseConfig = Models__NS__DatabaseConfig.from({
|
|
598
594
|
location: `db-${this.contextName}.sqlite`,
|
|
599
595
|
type: 'sqljs',
|
|
600
596
|
useLocalForage: true, // !!window['localforage'], // TODO this need to be checked in runtime
|
|
@@ -607,7 +603,7 @@ class EndpointContext {
|
|
|
607
603
|
//#endregion
|
|
608
604
|
//#region resolve database config for mode backend-frontend(tcp+udp)
|
|
609
605
|
case 'backend-frontend(tcp+udp)':
|
|
610
|
-
databaseConfig =
|
|
606
|
+
databaseConfig = Models__NS__DatabaseConfig.from({
|
|
611
607
|
database: `context-db-${this.contextName}`,
|
|
612
608
|
location: tcpUdpDatabaseSqliteRelativeFileLocation,
|
|
613
609
|
type: 'sqljs',
|
|
@@ -635,9 +631,9 @@ class EndpointContext {
|
|
|
635
631
|
// this.displayRoutes(this.expressApp);
|
|
636
632
|
this.serverTcpUdp.listen(Number(this.uriPort), '0.0.0.0', () => {
|
|
637
633
|
this.logFramework &&
|
|
638
|
-
|
|
634
|
+
Helpers__NS__log(`[ctx=${this.contextName}] Express server (inside docker) started 0.0.0.0:${this.uriPort}`);
|
|
639
635
|
this.logFramework &&
|
|
640
|
-
|
|
636
|
+
Helpers__NS__log(`[taon][express-server]listening on port: ${this.uriPort}, hostname: ${this.uriPathname},
|
|
641
637
|
address: ${this.uriProtocol}//localhost:${this.uriPort}${this.uriPathname}
|
|
642
638
|
ExpressJS mode: ${this.expressApp.settings.env}
|
|
643
639
|
`);
|
|
@@ -648,9 +644,9 @@ class EndpointContext {
|
|
|
648
644
|
// this.displayRoutes(this.expressApp);
|
|
649
645
|
this.serverTcpUdp.listen(Number(this.uriPort), () => {
|
|
650
646
|
this.logFramework &&
|
|
651
|
-
|
|
647
|
+
Helpers__NS__log(`[ctx=${this.contextName}] Express server (inside nodejs app) started on localhost:${this.uriPort}`);
|
|
652
648
|
this.logFramework &&
|
|
653
|
-
|
|
649
|
+
Helpers__NS__log(`[taon][express-server]listening on port: ${this.uriPort}, hostname: ${this.uriPathname},
|
|
654
650
|
address: ${this.uriProtocol}//localhost:${this.uriPort}${this.uriPathname}
|
|
655
651
|
expressJS mode: ${this.expressApp.settings.env}
|
|
656
652
|
`);
|
|
@@ -661,7 +657,7 @@ class EndpointContext {
|
|
|
661
657
|
}
|
|
662
658
|
else {
|
|
663
659
|
this.logFramework &&
|
|
664
|
-
|
|
660
|
+
Helpers__NS__info('Ipc communication enable instead tcp/upd');
|
|
665
661
|
}
|
|
666
662
|
//#endregion
|
|
667
663
|
}
|
|
@@ -709,35 +705,35 @@ class EndpointContext {
|
|
|
709
705
|
cloneClassWithNewMetadata = ({ TaonBaseClass, className, config, ctx, classType, }) => {
|
|
710
706
|
// Return a new class that extends the base class
|
|
711
707
|
const cloneClass = () => {
|
|
712
|
-
if (TaonBaseClass[
|
|
708
|
+
if (TaonBaseClass[Symbols__NS__fullClassNameStaticProperty] ===
|
|
713
709
|
`${ctx.contextName}.${className}`) {
|
|
714
710
|
return TaonBaseClass;
|
|
715
711
|
}
|
|
716
712
|
return class extends TaonBaseClass {
|
|
717
713
|
// static ['_'] = TaonBaseClass['_'];
|
|
718
714
|
// @ts-ignore
|
|
719
|
-
static [
|
|
715
|
+
static [Symbols__NS__orignalClass] = TaonBaseClass;
|
|
720
716
|
// @ts-ignore
|
|
721
|
-
static [
|
|
717
|
+
static [Symbols__NS__fullClassNameStaticProperty] = `${ctx.contextName}.${className}`;
|
|
722
718
|
// @ts-ignore
|
|
723
|
-
static [
|
|
724
|
-
static [
|
|
719
|
+
static [Symbols__NS__classNameStaticProperty] = className;
|
|
720
|
+
static [Symbols__NS__ctxInClassOrClassObj] = ctx;
|
|
725
721
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
726
722
|
static __getFullPathForClass__(arr = []) {
|
|
727
|
-
const name = this[
|
|
723
|
+
const name = this[Symbols__NS__fullClassNameStaticProperty];
|
|
728
724
|
arr.push(name);
|
|
729
725
|
// @ts-ignore
|
|
730
|
-
if (this[
|
|
731
|
-
this[
|
|
726
|
+
if (this[Symbols__NS__orignalClass] && // @ts-ignore
|
|
727
|
+
this[Symbols__NS__orignalClass].__getFullPathForClass__) {
|
|
732
728
|
// @ts-ignore
|
|
733
|
-
this[
|
|
729
|
+
this[Symbols__NS__orignalClass].__getFullPathForClass__(arr);
|
|
734
730
|
}
|
|
735
731
|
return arr.join('/');
|
|
736
732
|
}
|
|
737
733
|
static get fullPathForClass() {
|
|
738
734
|
return this.__getFullPathForClass__();
|
|
739
735
|
}
|
|
740
|
-
[
|
|
736
|
+
[Symbols__NS__ctxInClassOrClassObj] = ctx;
|
|
741
737
|
};
|
|
742
738
|
};
|
|
743
739
|
const cloneClassFunction = cloneClass();
|
|
@@ -769,19 +765,19 @@ class EndpointContext {
|
|
|
769
765
|
for (const key of Object.keys(classesInput || {})) {
|
|
770
766
|
const TaonBaseClass = classesInput[key];
|
|
771
767
|
if (!TaonBaseClass) {
|
|
772
|
-
|
|
768
|
+
Helpers__NS__error(`Class ${key} is not defined in context ${ctx.contextName}
|
|
773
769
|
|
|
774
770
|
Please check if you have correct import in context file
|
|
775
771
|
|
|
776
772
|
`);
|
|
777
773
|
}
|
|
778
|
-
var className = Reflect.getMetadata(
|
|
774
|
+
var className = Reflect.getMetadata(Symbols__NS__metadata.className, TaonBaseClass);
|
|
779
775
|
// console.log('Metadata className', className, TaonBaseClass);
|
|
780
776
|
// if (!className) {
|
|
781
777
|
// console.warn(`Please provide className for ${TaonBaseClass.name} class`);
|
|
782
778
|
// }
|
|
783
779
|
className = className || key;
|
|
784
|
-
TaonBaseClass[
|
|
780
|
+
TaonBaseClass[Symbols__NS__classNameStaticProperty] = className;
|
|
785
781
|
const clonedClass = this.cloneClassWithNewMetadata({
|
|
786
782
|
TaonBaseClass,
|
|
787
783
|
className,
|
|
@@ -798,7 +794,7 @@ class EndpointContext {
|
|
|
798
794
|
async getRecrusiveClassesfromContextsObj(classType) {
|
|
799
795
|
const arr = await this.getRecrusiveClassesfromContexts(classType);
|
|
800
796
|
return arr.reduce((acc, c) => {
|
|
801
|
-
acc[
|
|
797
|
+
acc[ClassHelpers__NS__getName(c)] = c;
|
|
802
798
|
return acc;
|
|
803
799
|
}, {});
|
|
804
800
|
}
|
|
@@ -838,9 +834,9 @@ class EndpointContext {
|
|
|
838
834
|
//#endregion
|
|
839
835
|
//#region methods & getters / inject
|
|
840
836
|
inject(ctor, options) {
|
|
841
|
-
const className =
|
|
837
|
+
const className = ClassHelpers__NS__getName(ctor);
|
|
842
838
|
const locaInstanceConstructorArgs = options.locaInstanceConstructorArgs || [];
|
|
843
|
-
if (this.isCLassType(
|
|
839
|
+
if (this.isCLassType(Models__NS__ClassType.REPOSITORY, ctor)) {
|
|
844
840
|
options.localInstance = true;
|
|
845
841
|
}
|
|
846
842
|
if (options?.localInstance) {
|
|
@@ -848,9 +844,9 @@ class EndpointContext {
|
|
|
848
844
|
let entityName = '';
|
|
849
845
|
// entity thing is only for repositories local repositories
|
|
850
846
|
// if (className === 'TaonBaseRepository') {
|
|
851
|
-
const entityFn =
|
|
847
|
+
const entityFn = ___NS__first(locaInstanceConstructorArgs);
|
|
852
848
|
const entity = entityFn && entityFn();
|
|
853
|
-
entityName = (entity &&
|
|
849
|
+
entityName = (entity && ClassHelpers__NS__getName(entity)) || '';
|
|
854
850
|
// console.log(`entityName `, entityName);
|
|
855
851
|
// }
|
|
856
852
|
if (!options.contextClassInstance[this.localInstaceObjSymbol]) {
|
|
@@ -911,7 +907,7 @@ class EndpointContext {
|
|
|
911
907
|
//#endregion
|
|
912
908
|
//#region methods & getters / check if context initialized
|
|
913
909
|
checkIfContextInitialized() {
|
|
914
|
-
if (
|
|
910
|
+
if (___NS__isUndefined(this.config)) {
|
|
915
911
|
throw new Error(`Please check if your context has been initialized.
|
|
916
912
|
|
|
917
913
|
// ...
|
|
@@ -927,24 +923,24 @@ class EndpointContext {
|
|
|
927
923
|
getClassFunBy(classType) {
|
|
928
924
|
this.checkIfContextInitialized();
|
|
929
925
|
switch (classType) {
|
|
930
|
-
case
|
|
926
|
+
case Models__NS__ClassType.CONTROLLER:
|
|
931
927
|
return this.config.controllers;
|
|
932
|
-
case
|
|
928
|
+
case Models__NS__ClassType.ENTITY:
|
|
933
929
|
return this.config.entities;
|
|
934
|
-
case
|
|
930
|
+
case Models__NS__ClassType.PROVIDER:
|
|
935
931
|
return this.config.providers;
|
|
936
|
-
case
|
|
932
|
+
case Models__NS__ClassType.MIDDLEWARE:
|
|
937
933
|
return this.config.middlewares;
|
|
938
|
-
case
|
|
934
|
+
case Models__NS__ClassType.REPOSITORY:
|
|
939
935
|
return this.config.repositories;
|
|
940
|
-
case
|
|
936
|
+
case Models__NS__ClassType.SUBSCRIBER:
|
|
941
937
|
return this.config.subscribers;
|
|
942
|
-
case
|
|
938
|
+
case Models__NS__ClassType.MIGRATION:
|
|
943
939
|
return this.config.migrations;
|
|
944
940
|
}
|
|
945
941
|
}
|
|
946
942
|
isCLassType(classType, classFn) {
|
|
947
|
-
return !!this.getClassFunBy(classType)[
|
|
943
|
+
return !!this.getClassFunBy(classType)[ClassHelpers__NS__getName(classFn)];
|
|
948
944
|
}
|
|
949
945
|
/**
|
|
950
946
|
* Only for injectable types
|
|
@@ -952,14 +948,14 @@ class EndpointContext {
|
|
|
952
948
|
*/
|
|
953
949
|
getClassFunByClassName(className) {
|
|
954
950
|
for (const classTypeName of this.allTypesfromContexts) {
|
|
955
|
-
const classesForInjectableType = this.config[
|
|
951
|
+
const classesForInjectableType = this.config[Models__NS__ClassTypeKey[classTypeName]];
|
|
956
952
|
if (classesForInjectableType[className]) {
|
|
957
953
|
return classesForInjectableType[className];
|
|
958
954
|
}
|
|
959
955
|
}
|
|
960
956
|
}
|
|
961
957
|
getClassFunByClass(classFunction) {
|
|
962
|
-
const className =
|
|
958
|
+
const className = ClassHelpers__NS__getName(classFunction);
|
|
963
959
|
return this.getClassFunByClassName(className);
|
|
964
960
|
}
|
|
965
961
|
getClassFunByArr(classType) {
|
|
@@ -976,13 +972,13 @@ class EndpointContext {
|
|
|
976
972
|
// ...recrusiveValuesFromContext,
|
|
977
973
|
...Object.values(classes),
|
|
978
974
|
]) {
|
|
979
|
-
const instance =
|
|
975
|
+
const instance = DITaonContainer.resolve(classFn);
|
|
980
976
|
const classInstancesByNameObj = this.classInstancesByNameObj[classType];
|
|
981
|
-
const className =
|
|
977
|
+
const className = ClassHelpers__NS__getName(classFn);
|
|
982
978
|
// console.log({ classFn, classType, instance, place, className, 'classInstancesByNameObj': this.classInstancesByNameObj });
|
|
983
979
|
classInstancesByNameObj[className] = instance;
|
|
984
980
|
// update config
|
|
985
|
-
this.config[
|
|
981
|
+
this.config[Models__NS__ClassTypeKey[classType]][className] = classFn;
|
|
986
982
|
this.objWithClassesInstancesArr[classType].push(instance);
|
|
987
983
|
this.allClassesInstances[className] = instance;
|
|
988
984
|
}
|
|
@@ -994,40 +990,40 @@ class EndpointContext {
|
|
|
994
990
|
return;
|
|
995
991
|
}
|
|
996
992
|
//#region @websql
|
|
997
|
-
for (const classFun of this.getClassFunByArr(
|
|
998
|
-
const repo = (await this.connection.getRepository(
|
|
999
|
-
this.repos.set(
|
|
993
|
+
for (const classFun of this.getClassFunByArr(Models__NS__ClassType.ENTITY)) {
|
|
994
|
+
const repo = (await this.connection.getRepository(ClassHelpers__NS__getOrginalClass(classFun)));
|
|
995
|
+
this.repos.set(ClassHelpers__NS__getName(classFun), repo);
|
|
1000
996
|
}
|
|
1001
997
|
//#endregion
|
|
1002
998
|
for (const classTypeName of [
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
999
|
+
Models__NS__ClassType.MIDDLEWARE,
|
|
1000
|
+
Models__NS__ClassType.PROVIDER,
|
|
1001
|
+
Models__NS__ClassType.REPOSITORY,
|
|
1002
|
+
Models__NS__ClassType.CONTROLLER,
|
|
1003
|
+
Models__NS__ClassType.ENTITY,
|
|
1004
|
+
Models__NS__ClassType.MIGRATION,
|
|
1009
1005
|
]) {
|
|
1010
1006
|
//#region init class static _ property
|
|
1011
1007
|
for (const classFun of this.getClassFunByArr(classTypeName)) {
|
|
1012
|
-
if (
|
|
1008
|
+
if (___NS__isFunction(classFun._)) {
|
|
1013
1009
|
await classFun._();
|
|
1014
1010
|
}
|
|
1015
1011
|
}
|
|
1016
1012
|
//#endregion
|
|
1017
1013
|
}
|
|
1018
1014
|
for (const classTypeName of [
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1015
|
+
Models__NS__ClassType.MIDDLEWARE,
|
|
1016
|
+
Models__NS__ClassType.PROVIDER,
|
|
1017
|
+
Models__NS__ClassType.REPOSITORY,
|
|
1018
|
+
Models__NS__ClassType.CONTROLLER,
|
|
1019
|
+
Models__NS__ClassType.MIGRATION,
|
|
1024
1020
|
]) {
|
|
1025
1021
|
//#region init providers, repositories _ property
|
|
1026
1022
|
// Helpers__NS__taskStarted(
|
|
1027
1023
|
// `[taon] REINITING _ INS FN ${classTypeName} ${this.contextName} STARTED`,
|
|
1028
1024
|
// );
|
|
1029
1025
|
for (const ctrl of this.getClassesInstancesArrBy(classTypeName)) {
|
|
1030
|
-
if (
|
|
1026
|
+
if (___NS__isFunction(ctrl._)) {
|
|
1031
1027
|
await ctrl._();
|
|
1032
1028
|
}
|
|
1033
1029
|
}
|
|
@@ -1040,7 +1036,7 @@ class EndpointContext {
|
|
|
1040
1036
|
//#endregion
|
|
1041
1037
|
//#region methods & getters / is active on
|
|
1042
1038
|
isActiveOn(classInstance) {
|
|
1043
|
-
let contextRef = classInstance[
|
|
1039
|
+
let contextRef = classInstance[Symbols__NS__ctxInClassOrClassObj];
|
|
1044
1040
|
return this === contextRef;
|
|
1045
1041
|
}
|
|
1046
1042
|
//#endregion
|
|
@@ -1049,11 +1045,11 @@ class EndpointContext {
|
|
|
1049
1045
|
const url = this.config?.frontendHost?.startsWith('http')
|
|
1050
1046
|
? this.config.frontendHost
|
|
1051
1047
|
: `${globalThis?.location?.protocol || 'http:'}//${this.config?.frontendHost}`;
|
|
1052
|
-
const uri = new
|
|
1048
|
+
const uri = new URL(url.replace(/\/$/, ''));
|
|
1053
1049
|
return uri;
|
|
1054
1050
|
}
|
|
1055
1051
|
get uri() {
|
|
1056
|
-
const url = this.host ? new
|
|
1052
|
+
const url = this.host ? new URL(this.host) : void 0;
|
|
1057
1053
|
return url;
|
|
1058
1054
|
}
|
|
1059
1055
|
//#endregion
|
|
@@ -1211,12 +1207,12 @@ class EndpointContext {
|
|
|
1211
1207
|
if (this.isRemoteHost) {
|
|
1212
1208
|
return;
|
|
1213
1209
|
}
|
|
1214
|
-
const subscriberClasses = this.getClassFunByArr(
|
|
1210
|
+
const subscriberClasses = this.getClassFunByArr(Models__NS__ClassType.SUBSCRIBER);
|
|
1215
1211
|
for (const subscriberClassFn of subscriberClasses) {
|
|
1216
|
-
const options = Reflect.getMetadata(
|
|
1212
|
+
const options = Reflect.getMetadata(Symbols__NS__metadata.options.subscriber, subscriberClassFn);
|
|
1217
1213
|
// console.log('subscriber options', options);
|
|
1218
1214
|
// const nameForSubscriber = ClassHelpers__NS__getName(subscriber);
|
|
1219
|
-
|
|
1215
|
+
EventSubscriber()(subscriberClassFn);
|
|
1220
1216
|
}
|
|
1221
1217
|
//#endregion
|
|
1222
1218
|
}
|
|
@@ -1227,18 +1223,18 @@ class EndpointContext {
|
|
|
1227
1223
|
if (this.isRemoteHost) {
|
|
1228
1224
|
return;
|
|
1229
1225
|
}
|
|
1230
|
-
const entities = this.getClassFunByArr(
|
|
1226
|
+
const entities = this.getClassFunByArr(Models__NS__ClassType.ENTITY);
|
|
1231
1227
|
for (const entity of entities) {
|
|
1232
|
-
const options = Reflect.getMetadata(
|
|
1233
|
-
const createTable =
|
|
1228
|
+
const options = Reflect.getMetadata(Symbols__NS__metadata.options.entity, entity);
|
|
1229
|
+
const createTable = ___NS__isUndefined(options.createTable)
|
|
1234
1230
|
? true
|
|
1235
1231
|
: options.createTable;
|
|
1236
|
-
const nameForEntity =
|
|
1232
|
+
const nameForEntity = ClassHelpers__NS__getName(entity);
|
|
1237
1233
|
if (createTable) {
|
|
1238
1234
|
this.logDb &&
|
|
1239
1235
|
console.info(`[taon][typeorm] create table for entity "${nameForEntity}" ? '${createTable}'`);
|
|
1240
1236
|
// console.log('TypeormEntity', { TypeormEntity });
|
|
1241
|
-
(
|
|
1237
|
+
TypeormEntity(nameForEntity)(entity);
|
|
1242
1238
|
}
|
|
1243
1239
|
else {
|
|
1244
1240
|
this.logDb &&
|
|
@@ -1273,12 +1269,12 @@ class EndpointContext {
|
|
|
1273
1269
|
if (this.isRemoteHost || !this.databaseConfig) {
|
|
1274
1270
|
return;
|
|
1275
1271
|
}
|
|
1276
|
-
const entities = this.getClassFunByArr(
|
|
1277
|
-
return
|
|
1272
|
+
const entities = this.getClassFunByArr(Models__NS__ClassType.ENTITY).map(entityFn => {
|
|
1273
|
+
return ClassHelpers__NS__getOrginalClass(entityFn);
|
|
1278
1274
|
});
|
|
1279
|
-
const subscribers = this.getClassFunByArr(
|
|
1275
|
+
const subscribers = this.getClassFunByArr(Models__NS__ClassType.SUBSCRIBER);
|
|
1280
1276
|
let autoSave = false;
|
|
1281
|
-
if (!
|
|
1277
|
+
if (!___NS__isNil(this.databaseConfig.autoSave)) {
|
|
1282
1278
|
autoSave = this.databaseConfig.autoSave;
|
|
1283
1279
|
}
|
|
1284
1280
|
else {
|
|
@@ -1289,7 +1285,7 @@ class EndpointContext {
|
|
|
1289
1285
|
autoSave = true; // on docker with sqljs I need to save db
|
|
1290
1286
|
}
|
|
1291
1287
|
}
|
|
1292
|
-
const dataSourceDbConfig =
|
|
1288
|
+
const dataSourceDbConfig = ___NS__isObject(this.databaseConfig)
|
|
1293
1289
|
? {
|
|
1294
1290
|
type: this.databaseConfig.type,
|
|
1295
1291
|
port: this.databaseConfig.databasePort,
|
|
@@ -1318,9 +1314,9 @@ class EndpointContext {
|
|
|
1318
1314
|
if (this.modeAllowsDatabaseCreation && this.databaseConfig) {
|
|
1319
1315
|
this.logDb &&
|
|
1320
1316
|
this.logFramework &&
|
|
1321
|
-
|
|
1317
|
+
Helpers__NS__info('[taon][database] prepare typeorm connection...');
|
|
1322
1318
|
try {
|
|
1323
|
-
const connection = new
|
|
1319
|
+
const connection = new DataSource(dataSourceDbConfig);
|
|
1324
1320
|
this.connection = connection;
|
|
1325
1321
|
await this.connection.initialize();
|
|
1326
1322
|
}
|
|
@@ -1360,7 +1356,7 @@ class EndpointContext {
|
|
|
1360
1356
|
// debugger;
|
|
1361
1357
|
}
|
|
1362
1358
|
else {
|
|
1363
|
-
|
|
1359
|
+
Helpers__NS__info(`[taon][typeorm] Not initing db for mode ${this.mode}`);
|
|
1364
1360
|
}
|
|
1365
1361
|
//#endregion
|
|
1366
1362
|
}
|
|
@@ -1368,27 +1364,27 @@ class EndpointContext {
|
|
|
1368
1364
|
//#region methods & getters / initialize metadata
|
|
1369
1365
|
//#region methods & getters / update class calculate path
|
|
1370
1366
|
updateCalculatedPathsForControllers(rawConfigs, classConfig, controllerClassFn) {
|
|
1371
|
-
const parentsCalculatedPath =
|
|
1367
|
+
const parentsCalculatedPath = ___NS__slice(rawConfigs, 1)
|
|
1372
1368
|
.reverse()
|
|
1373
1369
|
.map(bc => {
|
|
1374
|
-
if (
|
|
1370
|
+
if (TaonHelpers__NS__isGoodPath(bc.path)) {
|
|
1375
1371
|
return bc.path;
|
|
1376
1372
|
}
|
|
1377
1373
|
return bc.className;
|
|
1378
1374
|
})
|
|
1379
1375
|
.join('/');
|
|
1380
1376
|
const contextNameForCommunication = this.contextNameForCommunication;
|
|
1381
|
-
if (
|
|
1377
|
+
if (TaonHelpers__NS__isGoodPath(classConfig.path)) {
|
|
1382
1378
|
classConfig.calculatedPath = classConfig.path;
|
|
1383
1379
|
}
|
|
1384
1380
|
else {
|
|
1385
1381
|
classConfig.calculatedPath = (`${this.uriPathnameOrNothingIfRoot}` +
|
|
1386
|
-
`/${
|
|
1387
|
-
`${
|
|
1382
|
+
`/${apiPrefix}/${contextNameForCommunication}/tcp${parentsCalculatedPath}/` +
|
|
1383
|
+
`${ClassHelpers__NS__getName(controllerClassFn)}`)
|
|
1388
1384
|
.replace(/\/\//g, '/')
|
|
1389
1385
|
.split('/')
|
|
1390
1386
|
.reduce((acc, bc) => {
|
|
1391
|
-
return
|
|
1387
|
+
return ___NS__last(acc) === bc ? acc : [...acc, bc];
|
|
1392
1388
|
}, [])
|
|
1393
1389
|
.join('/');
|
|
1394
1390
|
}
|
|
@@ -1398,8 +1394,8 @@ class EndpointContext {
|
|
|
1398
1394
|
//#region methods & getters / dedupe class configs
|
|
1399
1395
|
mergeControllerMethodsConfigs(rawConfigs, classConfig, controllerClassFn) {
|
|
1400
1396
|
const currentControllerMethodsConfig = classConfig.methods;
|
|
1401
|
-
|
|
1402
|
-
const parentControllerMethods =
|
|
1397
|
+
___NS__slice(rawConfigs, 1).forEach(bc => {
|
|
1398
|
+
const parentControllerMethods = ___NS__cloneDeep(bc.methods);
|
|
1403
1399
|
for (const methodsName in parentControllerMethods) {
|
|
1404
1400
|
if (parentControllerMethods.hasOwnProperty(methodsName)) {
|
|
1405
1401
|
if (!currentControllerMethodsConfig[methodsName]) {
|
|
@@ -1417,10 +1413,10 @@ class EndpointContext {
|
|
|
1417
1413
|
if (this.isRunOrRevertOnlyMigrationAppStart) {
|
|
1418
1414
|
return;
|
|
1419
1415
|
}
|
|
1420
|
-
const allControllers = this.getClassFunByArr(
|
|
1416
|
+
const allControllers = this.getClassFunByArr(Models__NS__ClassType.CONTROLLER);
|
|
1421
1417
|
for (const controllerClassFn of allControllers) {
|
|
1422
1418
|
const instance = this.getInstanceBy(controllerClassFn);
|
|
1423
|
-
if (
|
|
1419
|
+
if (___NS__isFunction(instance.afterAllCtxInited)) {
|
|
1424
1420
|
await instance.afterAllCtxInited({ ctxStorage });
|
|
1425
1421
|
}
|
|
1426
1422
|
}
|
|
@@ -1429,7 +1425,7 @@ class EndpointContext {
|
|
|
1429
1425
|
if (this.isRunOrRevertOnlyMigrationAppStart) {
|
|
1430
1426
|
return;
|
|
1431
1427
|
}
|
|
1432
|
-
const allControllers = this.getClassFunByArr(
|
|
1428
|
+
const allControllers = this.getClassFunByArr(Models__NS__ClassType.CONTROLLER);
|
|
1433
1429
|
// debugger
|
|
1434
1430
|
// console.log('allControllers', allControllers);
|
|
1435
1431
|
for (const controllerClassFn of allControllers) {
|
|
@@ -1439,9 +1435,9 @@ class EndpointContext {
|
|
|
1439
1435
|
// `for ${controllerName}`,
|
|
1440
1436
|
// ClassHelpers__NS__getClassConfig(controllerClassFn),
|
|
1441
1437
|
// );
|
|
1442
|
-
controllerClassFn[
|
|
1443
|
-
|
|
1444
|
-
const rawConfigs =
|
|
1438
|
+
controllerClassFn[Symbols__NS__classMethodsNames] =
|
|
1439
|
+
ClassHelpers__NS__getMethodsNames(controllerClassFn);
|
|
1440
|
+
const rawConfigs = ClassHelpers__NS__getControllerConfigs(controllerClassFn);
|
|
1445
1441
|
// console.log(controllerName, { rawConfigs });
|
|
1446
1442
|
// console.log(`Class config for ${ClassHelpers__NS__getName(controllerClassFn)}`, configs)
|
|
1447
1443
|
const classConfig = rawConfigs[0];
|
|
@@ -1450,11 +1446,11 @@ class EndpointContext {
|
|
|
1450
1446
|
//#region combine middlewares from controllers
|
|
1451
1447
|
classConfig.calculatedMiddlewaresControllerObj = {};
|
|
1452
1448
|
[...rawConfigs].reverse().forEach(rc => {
|
|
1453
|
-
if (
|
|
1449
|
+
if (___NS__isFunction(rc.middlewares)) {
|
|
1454
1450
|
classConfig.calculatedMiddlewaresControllerObj = rc.middlewares({
|
|
1455
1451
|
parentMiddlewares: classConfig.calculatedMiddlewaresControllerObj,
|
|
1456
1452
|
className(middlewareClass) {
|
|
1457
|
-
return
|
|
1453
|
+
return ClassHelpers__NS__getName(controllerClassFn);
|
|
1458
1454
|
},
|
|
1459
1455
|
});
|
|
1460
1456
|
}
|
|
@@ -1462,7 +1458,7 @@ class EndpointContext {
|
|
|
1462
1458
|
//#endregion
|
|
1463
1459
|
//#region group start
|
|
1464
1460
|
//#region @backend
|
|
1465
|
-
if (!
|
|
1461
|
+
if (!UtilsOs__NS__isRunningInCliMode()) {
|
|
1466
1462
|
//#endregion
|
|
1467
1463
|
this.logHttp &&
|
|
1468
1464
|
console.groupCollapsed(`[taon][express-server] routes [${classConfig.className}]`);
|
|
@@ -1479,11 +1475,11 @@ class EndpointContext {
|
|
|
1479
1475
|
[...rawConfigs].reverse().forEach(rc => {
|
|
1480
1476
|
if (rc.methods[methodName]) {
|
|
1481
1477
|
const parentMethodConfig = rc.methods[methodName];
|
|
1482
|
-
if (
|
|
1478
|
+
if (___NS__isFunction(parentMethodConfig.middlewares)) {
|
|
1483
1479
|
calculatedMiddlewaresMethodObj = parentMethodConfig.middlewares({
|
|
1484
1480
|
parentMiddlewares: calculatedMiddlewaresMethodObj,
|
|
1485
1481
|
className(middlewareClass) {
|
|
1486
|
-
return
|
|
1482
|
+
return ClassHelpers__NS__getName(controllerClassFn);
|
|
1487
1483
|
},
|
|
1488
1484
|
});
|
|
1489
1485
|
}
|
|
@@ -1502,15 +1498,15 @@ class EndpointContext {
|
|
|
1502
1498
|
// this is quick fix - in docker global path should not be used
|
|
1503
1499
|
const globalPathPart = this.isRunningInsideDocker ||
|
|
1504
1500
|
!this.frontendHostUri?.origin?.includes('localhost') // fe with domain -> is in docker
|
|
1505
|
-
? `${this.uriPathnameOrNothingIfRoot.replace(/\/$/, '')}/${
|
|
1501
|
+
? `${this.uriPathnameOrNothingIfRoot.replace(/\/$/, '')}/${apiPrefix}/${this.contextName}`.replace(/\/\//, '/')
|
|
1506
1502
|
: '';
|
|
1507
1503
|
const expressPath = methodConfig.global
|
|
1508
1504
|
? `${globalPathPart}/${methodConfig.path?.replace(/\/$/, '')}`.replace(/\/\//, '/')
|
|
1509
|
-
:
|
|
1505
|
+
: TaonHelpers__NS__getExpressPath(classConfig, methodConfig);
|
|
1510
1506
|
//#endregion
|
|
1511
1507
|
//#region init server
|
|
1512
1508
|
// console.log({ expressPath });
|
|
1513
|
-
if (
|
|
1509
|
+
if (UtilsOs__NS__isNode || UtilsOs__NS__isWebSQL) {
|
|
1514
1510
|
//#region @websql
|
|
1515
1511
|
const route = this.initServer(httpMethodType, methodConfig, classConfig, expressPath, controllerClassFn);
|
|
1516
1512
|
this.activeRoutes.push({
|
|
@@ -1521,7 +1517,7 @@ class EndpointContext {
|
|
|
1521
1517
|
}
|
|
1522
1518
|
//#endregion
|
|
1523
1519
|
//#region init client
|
|
1524
|
-
const shouldInitClient =
|
|
1520
|
+
const shouldInitClient = UtilsOs__NS__isBrowser || this.isRemoteHost || UtilsOs__NS__isWebSQL;
|
|
1525
1521
|
// console.log('shouldInitClient', shouldInitClient);
|
|
1526
1522
|
if (shouldInitClient) {
|
|
1527
1523
|
// console.log(
|
|
@@ -1538,7 +1534,7 @@ class EndpointContext {
|
|
|
1538
1534
|
//#endregion
|
|
1539
1535
|
//#region group end
|
|
1540
1536
|
//#region @backend
|
|
1541
|
-
if (!
|
|
1537
|
+
if (!UtilsOs__NS__isRunningInCliMode()) {
|
|
1542
1538
|
//#endregion
|
|
1543
1539
|
this.logHttp && console.groupEnd();
|
|
1544
1540
|
//#region @backend
|
|
@@ -1555,12 +1551,12 @@ class EndpointContext {
|
|
|
1555
1551
|
}
|
|
1556
1552
|
// const contexts: EndpointContext[] = [this];
|
|
1557
1553
|
//#region @websql
|
|
1558
|
-
const troutes =
|
|
1554
|
+
const troutes = Utils__NS__uniqArray(this.activeRoutes.map(f => {
|
|
1559
1555
|
return `${f.method} ${f.expressPath}`;
|
|
1560
1556
|
})).map(f => {
|
|
1561
1557
|
const [method, expressPath] = f.split(' ');
|
|
1562
|
-
return (`\n### ${
|
|
1563
|
-
|
|
1558
|
+
return (`\n### ${___NS__startCase(___NS__last(expressPath.split('/')))}\n` +
|
|
1559
|
+
TaonHelpers__NS__fillUpTo(method.toUpperCase() + ' ', 10) +
|
|
1564
1560
|
this.uriOrigin +
|
|
1565
1561
|
expressPath);
|
|
1566
1562
|
// return `${TaonHelpers.string(method.toUpperCase() + ':')
|
|
@@ -1570,7 +1566,7 @@ class EndpointContext {
|
|
|
1570
1566
|
...['', `# ROUTES FOR HOST ${this.uriOrigin} `],
|
|
1571
1567
|
...troutes,
|
|
1572
1568
|
].join('\n');
|
|
1573
|
-
const fileName =
|
|
1569
|
+
const fileName = crossPlatformPath([
|
|
1574
1570
|
//#region @backend
|
|
1575
1571
|
process.cwd(),
|
|
1576
1572
|
//#endregion
|
|
@@ -1579,8 +1575,8 @@ class EndpointContext {
|
|
|
1579
1575
|
this.logFramework && console.log(`[taon] routes file: ${fileName} `);
|
|
1580
1576
|
this.logRoutes && console.log(routes);
|
|
1581
1577
|
//#region @backend
|
|
1582
|
-
if (!
|
|
1583
|
-
|
|
1578
|
+
if (!UtilsOs__NS__isElectron && !this.skipWritingServerRoutes) {
|
|
1579
|
+
Helpers__NS__writeFile(fileName, routes);
|
|
1584
1580
|
}
|
|
1585
1581
|
//#endregion
|
|
1586
1582
|
//#endregion
|
|
@@ -1595,16 +1591,16 @@ class EndpointContext {
|
|
|
1595
1591
|
//#endregion
|
|
1596
1592
|
//#region methods & getters / init middlewares
|
|
1597
1593
|
async initCustomClientMiddlewares() {
|
|
1598
|
-
const middlewares = this.getClassesInstancesArrBy(
|
|
1594
|
+
const middlewares = this.getClassesInstancesArrBy(Models__NS__ClassType.MIDDLEWARE)
|
|
1599
1595
|
.map(f => f)
|
|
1600
|
-
.filter(f =>
|
|
1596
|
+
.filter(f => ___NS__isFunction(f.interceptClient));
|
|
1601
1597
|
middlewares.forEach(middlewareInstanceName => {
|
|
1602
1598
|
const contextName = this.contextName;
|
|
1603
|
-
const interceptorName = `${contextName}-${
|
|
1604
|
-
|
|
1599
|
+
const interceptorName = `${contextName}-${ClassHelpers__NS__getName(middlewareInstanceName)}`;
|
|
1600
|
+
Resource.request.interceptors.set(interceptorName, {
|
|
1605
1601
|
intercept: ({ req, next }) => {
|
|
1606
|
-
const url = new
|
|
1607
|
-
if (url.pathname.startsWith(`${this.uriPathnameOrNothingIfRoot}/${
|
|
1602
|
+
const url = new URL(req.url);
|
|
1603
|
+
if (url.pathname.startsWith(`${this.uriPathnameOrNothingIfRoot}/${apiPrefix}/${contextName}/`)) {
|
|
1608
1604
|
// console.log('intercepting', url.pathname, req);
|
|
1609
1605
|
return middlewareInstanceName.interceptClient({
|
|
1610
1606
|
req,
|
|
@@ -1619,12 +1615,12 @@ class EndpointContext {
|
|
|
1619
1615
|
async initCustomBackendMiddlewares() {
|
|
1620
1616
|
//#region @backend
|
|
1621
1617
|
const app = this.expressApp;
|
|
1622
|
-
const middlewares = this.getClassesInstancesArrBy(
|
|
1618
|
+
const middlewares = this.getClassesInstancesArrBy(Models__NS__ClassType.MIDDLEWARE);
|
|
1623
1619
|
for (const middleware of middlewares) {
|
|
1624
1620
|
const middlewareInstance = middleware;
|
|
1625
|
-
if (
|
|
1626
|
-
const middlewareFn =
|
|
1627
|
-
if (req.originalUrl.startsWith(`${this.uriPathnameOrNothingIfRoot}/${
|
|
1621
|
+
if (___NS__isFunction(middlewareInstance.interceptServer)) {
|
|
1622
|
+
const middlewareFn = ClassHelpers__NS__asyncHandler(async (req, res, next) => {
|
|
1623
|
+
if (req.originalUrl.startsWith(`${this.uriPathnameOrNothingIfRoot}/${apiPrefix}/${this.contextName}/`)) {
|
|
1628
1624
|
await middlewareInstance.interceptServer({
|
|
1629
1625
|
req,
|
|
1630
1626
|
res,
|
|
@@ -1658,7 +1654,7 @@ class EndpointContext {
|
|
|
1658
1654
|
app.use(methodOverride());
|
|
1659
1655
|
app.use(cookieParser());
|
|
1660
1656
|
if (this.session) {
|
|
1661
|
-
|
|
1657
|
+
Helpers__NS__info('[taon][express-server] session enabled for this context ' +
|
|
1662
1658
|
this.contextName);
|
|
1663
1659
|
const { cookieMaxAge } = this.session;
|
|
1664
1660
|
const frontendHost = this.config.frontendHost;
|
|
@@ -1684,7 +1680,7 @@ class EndpointContext {
|
|
|
1684
1680
|
else {
|
|
1685
1681
|
// if(this.config?.serverLogs) {
|
|
1686
1682
|
this.logHttp &&
|
|
1687
|
-
|
|
1683
|
+
Helpers__NS__info(`[taon][express-server] session not enabled for this context '${this.contextName}'`);
|
|
1688
1684
|
// }
|
|
1689
1685
|
app.use(cors({
|
|
1690
1686
|
// origin: "http://localhost:5555",
|
|
@@ -1718,10 +1714,10 @@ class EndpointContext {
|
|
|
1718
1714
|
'Content-Type',
|
|
1719
1715
|
'Authorization',
|
|
1720
1716
|
'X-Requested-With',
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1717
|
+
Symbols__NS__old.X_TOTAL_COUNT,
|
|
1718
|
+
Symbols__NS__old.MAPPING_CONFIG_HEADER,
|
|
1719
|
+
Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY,
|
|
1720
|
+
Symbols__NS__old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM,
|
|
1725
1721
|
].join(', '));
|
|
1726
1722
|
next();
|
|
1727
1723
|
});
|
|
@@ -1741,8 +1737,8 @@ class EndpointContext {
|
|
|
1741
1737
|
.map(middlewareClassFun => {
|
|
1742
1738
|
const middlewareInstance = this.getInstanceBy(middlewareClassFun);
|
|
1743
1739
|
if (middlewareInstance &&
|
|
1744
|
-
|
|
1745
|
-
const middlewareFn =
|
|
1740
|
+
___NS__isFunction(middlewareInstance.interceptServerMethod)) {
|
|
1741
|
+
const middlewareFn = ClassHelpers__NS__asyncHandler(async (req, res, next) => {
|
|
1746
1742
|
await middlewareInstance.interceptServerMethod({
|
|
1747
1743
|
req,
|
|
1748
1744
|
res,
|
|
@@ -1769,18 +1765,19 @@ class EndpointContext {
|
|
|
1769
1765
|
* Params for method @GET, @PUT etc.
|
|
1770
1766
|
*/
|
|
1771
1767
|
resolvedParams);
|
|
1772
|
-
let result = await
|
|
1768
|
+
let result = await getResponseValue(response, { req, res });
|
|
1773
1769
|
return result;
|
|
1774
1770
|
};
|
|
1775
1771
|
//#endregion
|
|
1776
1772
|
// console.log(`BACKEND: expressPath: "${expressPath}" `);
|
|
1777
1773
|
//#endregion
|
|
1778
|
-
if (
|
|
1774
|
+
if (UtilsOs__NS__isElectron) {
|
|
1779
1775
|
//#region @backend
|
|
1780
|
-
const ipcKeyName =
|
|
1781
|
-
|
|
1776
|
+
const ipcKeyName = TaonHelpers__NS__ipcKeyNameRequest(target, methodConfig, expressPath);
|
|
1777
|
+
const electron = require('electron');
|
|
1778
|
+
electron.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
|