taon 19.0.5 → 19.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +175 -175
- package/bin/start.js +279 -279
- package/bin/taon +6 -6
- package/bin/taon-debug +5 -5
- package/bin/taon-debug-brk +5 -5
- package/browser/README.md +24 -24
- package/browser/fesm2022/taon.mjs +1313 -259
- package/browser/fesm2022/taon.mjs.map +1 -1
- package/browser/lib/base-classes/base-class.d.ts +1 -1
- package/browser/lib/base-classes/base-context.d.ts +6 -6
- package/browser/lib/base-classes/base-repository.d.ts +3 -2
- package/browser/lib/base-classes/base.d.ts +6 -6
- package/browser/lib/create-context.d.ts +12 -12
- package/browser/lib/index.d.ts +18 -18
- package/browser/lib/inject.d.ts +4 -1
- package/browser/lib/ui/taon-table/taon-table.component.d.ts +8 -7
- package/browser/package.json +1 -1
- package/cli.js.map +1 -1
- package/client/README.md +24 -24
- package/client/fesm2022/taon.mjs +1313 -259
- package/client/fesm2022/taon.mjs.map +1 -1
- package/client/lib/base-classes/base-class.d.ts +1 -1
- package/client/lib/base-classes/base-context.d.ts +6 -6
- package/client/lib/base-classes/base-repository.d.ts +3 -2
- package/client/lib/base-classes/base.d.ts +6 -6
- package/client/lib/create-context.d.ts +12 -12
- package/client/lib/index.d.ts +18 -18
- package/client/lib/inject.d.ts +4 -1
- package/client/lib/ui/taon-table/taon-table.component.d.ts +8 -7
- package/client/package.json +1 -1
- package/index.js.map +1 -1
- package/lib/base-classes/base-abstract-entity.js +2 -2
- package/lib/base-classes/base-abstract-entity.js.map +1 -1
- package/lib/base-classes/base-class.d.ts +1 -1
- package/lib/base-classes/base-class.js +13 -4
- package/lib/base-classes/base-class.js.map +1 -1
- package/lib/base-classes/base-context.d.ts +6 -6
- package/lib/base-classes/base-context.js.map +1 -1
- package/lib/base-classes/base-controller.js.map +1 -1
- package/lib/base-classes/base-crud-controller.js +6 -6
- package/lib/base-classes/base-crud-controller.js.map +1 -1
- package/lib/base-classes/base-entity.js +2 -2
- package/lib/base-classes/base-entity.js.map +1 -1
- package/lib/base-classes/base-injector.js +2 -2
- package/lib/base-classes/base-injector.js.map +1 -1
- package/lib/base-classes/base-migration.d.ts +1 -1
- package/lib/base-classes/base-migration.js +2 -2
- package/lib/base-classes/base-migration.js.map +1 -1
- package/lib/base-classes/base-provider.js.map +1 -1
- package/lib/base-classes/base-repository.d.ts +3 -2
- package/lib/base-classes/base-repository.js +14 -11
- package/lib/base-classes/base-repository.js.map +1 -1
- package/lib/base-classes/base-subscriber-for-entity.d.ts +1 -1
- package/lib/base-classes/base-subscriber-for-entity.js.map +1 -1
- package/lib/base-classes/base.d.ts +6 -6
- package/lib/base-classes/base.js.map +1 -1
- package/lib/build-info._auto-generated_.d.ts +2 -1
- package/lib/build-info._auto-generated_.js +3 -2
- package/lib/build-info._auto-generated_.js.map +1 -1
- package/lib/constants.js.map +1 -1
- package/lib/context-db-migrations.d.ts +1 -1
- package/lib/context-db-migrations.js +7 -7
- package/lib/context-db-migrations.js.map +1 -1
- package/lib/create-context.d.ts +12 -12
- package/lib/create-context.js +13 -13
- package/lib/create-context.js.map +1 -1
- package/lib/decorators/classes/controller-decorator.js.map +1 -1
- package/lib/decorators/classes/entity-decorator.d.ts +1 -1
- package/lib/decorators/classes/entity-decorator.js +8 -8
- package/lib/decorators/classes/entity-decorator.js.map +1 -1
- package/lib/decorators/classes/migration-decorator.js.map +1 -1
- package/lib/decorators/classes/provider-decorator.js.map +1 -1
- package/lib/decorators/classes/repository-decorator.js.map +1 -1
- package/lib/decorators/classes/subscriber-decorator.js.map +1 -1
- package/lib/decorators/http/http-decorators.d.ts +1 -1
- package/lib/decorators/http/http-decorators.js +2 -2
- package/lib/decorators/http/http-decorators.js.map +1 -1
- package/lib/decorators/http/http-methods-decorators.d.ts +1 -1
- package/lib/decorators/http/http-methods-decorators.js +2 -2
- package/lib/decorators/http/http-methods-decorators.js.map +1 -1
- package/lib/decorators/http/http-params-decorators.js.map +1 -1
- package/lib/dependency-injection/di-container.js.map +1 -1
- package/lib/endpoint-context.js +112 -112
- package/lib/endpoint-context.js.map +1 -1
- package/lib/entity-process.js +35 -35
- package/lib/entity-process.js.map +1 -1
- package/lib/env.js +2 -2
- package/lib/env.js.map +1 -1
- package/lib/formly/formly-group-wrapper-component.js.map +1 -1
- package/lib/formly/formly-repeat-component.js.map +1 -1
- package/lib/formly/formly.models.js.map +1 -1
- package/lib/formly/fromly.d.ts +1 -1
- package/lib/formly/fromly.js +26 -26
- package/lib/formly/fromly.js.map +1 -1
- package/lib/formly/type-from-entity.js +6 -6
- package/lib/formly/type-from-entity.js.map +1 -1
- package/lib/get-response-value.js +2 -2
- package/lib/get-response-value.js.map +1 -1
- package/lib/helpers/class-helpers.js +21 -21
- package/lib/helpers/class-helpers.js.map +1 -1
- package/lib/helpers/taon-helpers.js +4 -4
- package/lib/helpers/taon-helpers.js.map +1 -1
- package/lib/index._auto-generated_.js.map +1 -1
- package/lib/index.d.ts +18 -18
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/inject.js +0 -5
- package/lib/inject.js.map +1 -1
- package/lib/models.d.ts +1 -1
- package/lib/models.js +5 -5
- package/lib/models.js.map +1 -1
- package/lib/orm.d.ts +1 -1
- package/lib/orm.js +4 -4
- package/lib/orm.js.map +1 -1
- package/lib/realtime/realtime-client.js +3 -3
- package/lib/realtime/realtime-client.js.map +1 -1
- package/lib/realtime/realtime-core.js +3 -3
- package/lib/realtime/realtime-core.js.map +1 -1
- package/lib/realtime/realtime-server.js +7 -7
- package/lib/realtime/realtime-server.js.map +1 -1
- package/lib/realtime/realtime-strategy/index.js.map +1 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc.js.map +1 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock.js.map +1 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-socket-io.js.map +1 -1
- package/lib/realtime/realtime-strategy/realtime-strategy.js.map +1 -1
- package/lib/realtime/realtime-subs-manager.js +3 -3
- package/lib/realtime/realtime-subs-manager.js.map +1 -1
- package/lib/realtime/realtime.models.js.map +1 -1
- package/lib/storage.js +2 -2
- package/lib/storage.js.map +1 -1
- package/lib/symbols.js +7 -7
- package/lib/symbols.js.map +1 -1
- package/lib/ui/directives/index.js +2 -2
- package/lib/ui/directives/index.js.map +1 -1
- package/lib/ui/directives/view-mode.js.map +1 -1
- package/lib/ui/index.js +2 -2
- package/lib/ui/index.js.map +1 -1
- package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/index.js.map +1 -1
- package/lib/ui/taon-admin-mode-configuration/taon-admin.models.js.map +1 -1
- package/lib/ui/taon-github-fork-me-corner/index.js +2 -2
- package/lib/ui/taon-github-fork-me-corner/index.js.map +1 -1
- package/lib/ui/taon-github-fork-me-ribbon/index.js +2 -2
- package/lib/ui/taon-github-fork-me-ribbon/index.js.map +1 -1
- package/lib/ui/taon-notifications/index.js.map +1 -1
- package/lib/ui/taon-notifications/taon-notifications.models.js +2 -2
- package/lib/ui/taon-notifications/taon-notifications.models.js.map +1 -1
- package/lib/ui/taon-progress-bar/index.js +2 -2
- package/lib/ui/taon-progress-bar/index.js.map +1 -1
- package/lib/ui/taon-session-passcode/index.js +2 -2
- package/lib/ui/taon-session-passcode/index.js.map +1 -1
- package/lib/ui/taon-table/index.js +2 -2
- package/lib/ui/taon-table/index.js.map +1 -1
- package/lib/ui/taon-table/taon-table.component.d.ts +7 -6
- package/lib/ui/taon.models.d.ts +1 -1
- package/lib/ui/taon.models.js.map +1 -1
- package/lib/validators.js +8 -8
- package/lib/validators.js.map +1 -1
- package/migrations/index.js.map +1 -1
- package/migrations/migrations_index._auto-generated_.js.map +1 -1
- package/old-app .js +1 -1
- package/old-app .js.map +1 -1
- package/package.json +1 -1
- package/playground.js.map +1 -1
- package/tmp-environment.json +4 -4
- package/websql/README.md +24 -24
- package/websql/fesm2022/taon.mjs +1609 -282
- package/websql/fesm2022/taon.mjs.map +1 -1
- package/websql/lib/base-classes/base-class.d.ts +1 -1
- package/websql/lib/base-classes/base-context.d.ts +6 -6
- package/websql/lib/base-classes/base-repository.d.ts +3 -2
- package/websql/lib/base-classes/base.d.ts +6 -6
- package/websql/lib/create-context.d.ts +12 -12
- package/websql/lib/index.d.ts +18 -18
- package/websql/lib/inject.d.ts +4 -1
- package/websql/lib/ui/taon-table/taon-table.component.d.ts +8 -7
- package/websql/package.json +1 -1
- package/browser/lib/storage.d.ts +0 -2
- package/client/lib/storage.d.ts +0 -2
- package/lib/base-classes/base-subscriber.d.ts +0 -4
- package/lib/base-classes/base-subscriber.js +0 -25
- package/lib/base-classes/base-subscriber.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.d.ts +0 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.js +0 -5
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.d.ts +0 -22
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.js +0 -139
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.d.ts +0 -16
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.js +0 -68
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.d.ts +0 -10
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.js +0 -56
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.d.ts +0 -10
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.js +0 -50
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.d.ts +0 -13
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.js +0 -3
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.d.ts +0 -2
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.js +0 -6
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.d.ts +0 -16
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.js +0 -54
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.d.ts +0 -17
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.js +0 -52
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.d.ts +0 -11
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.js +0 -39
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.d.ts +0 -13
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.js +0 -46
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.d.ts +0 -11
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.js +0 -3
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.js.map +0 -1
- package/lib/ui/directives/firedev-inject-html.directive.d.ts +0 -6
- package/lib/ui/directives/firedev-long-press.directive.d.ts +0 -22
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.d.ts +0 -2
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.js +0 -5
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.js.map +0 -1
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/taon-admin-edit-mode.component.d.ts +0 -29
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/taon-admin-edit-mode.module.d.ts +0 -2
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.d.ts +0 -1
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.js +0 -5
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.js.map +0 -1
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/taon-db-admin.component.d.ts +0 -8
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.d.ts +0 -2
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.js +0 -5
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.js.map +0 -1
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/taon-file-general-opt.component.d.ts +0 -13
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/taon-file-general-opt.module.d.ts +0 -2
- package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.d.ts +0 -5
- package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.js +0 -3
- package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.js.map +0 -1
- package/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.d.ts +0 -14
- package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.module.d.ts +0 -2
- package/lib/ui/toan-full-material.module.d.ts +0 -2
- package/websql/lib/storage.d.ts +0 -2
package/lib/endpoint-context.js
CHANGED
|
@@ -4,8 +4,8 @@ exports.EndpointContext = void 0;
|
|
|
4
4
|
/* eslint-disable @typescript-eslint/typedef */
|
|
5
5
|
//#region imports
|
|
6
6
|
//#region @websql
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const lib_1 = require("taon-typeorm/lib");
|
|
8
|
+
const lib_2 = require("taon-typeorm/lib");
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region @backend
|
|
11
11
|
const express = require("express");
|
|
@@ -16,25 +16,25 @@ const cookieParser = require("cookie-parser");
|
|
|
16
16
|
const methodOverride = require("method-override");
|
|
17
17
|
const fileUpload = require("express-fileupload");
|
|
18
18
|
const url_1 = require("url");
|
|
19
|
-
const
|
|
19
|
+
const lib_3 = require("tnp-core/lib");
|
|
20
20
|
//#endregion
|
|
21
21
|
/* */
|
|
22
22
|
/* */
|
|
23
|
-
const
|
|
24
|
-
const
|
|
23
|
+
const lib_4 = require("tnp-core/lib");
|
|
24
|
+
const lib_5 = require("tnp-core/lib");
|
|
25
25
|
const models_1 = require("./models");
|
|
26
26
|
const class_helpers_1 = require("./helpers/class-helpers");
|
|
27
27
|
const symbols_1 = require("./symbols");
|
|
28
|
-
const
|
|
28
|
+
const lib_6 = require("tnp-core/lib");
|
|
29
29
|
const di_container_1 = require("./dependency-injection/di-container");
|
|
30
30
|
const taon_helpers_1 = require("./helpers/taon-helpers");
|
|
31
|
-
const
|
|
32
|
-
const
|
|
31
|
+
const lib_7 = require("ng2-rest/lib");
|
|
32
|
+
const lib_8 = require("json10/lib");
|
|
33
33
|
const rxjs_1 = require("rxjs");
|
|
34
34
|
const entity_process_1 = require("./entity-process");
|
|
35
35
|
const get_response_value_1 = require("./get-response-value");
|
|
36
36
|
const axios_1 = require("axios");
|
|
37
|
-
const
|
|
37
|
+
const lib_9 = require("taon-typeorm/lib");
|
|
38
38
|
const env_1 = require("./env");
|
|
39
39
|
const realtime_core_1 = require("./realtime/realtime-core");
|
|
40
40
|
const context_db_migrations_1 = require("./context-db-migrations");
|
|
@@ -144,31 +144,31 @@ class EndpointContext {
|
|
|
144
144
|
//#endregion
|
|
145
145
|
//#region fields / logs
|
|
146
146
|
get logHttp() {
|
|
147
|
-
if (
|
|
147
|
+
if (lib_6._.isObject(this.config?.logs)) {
|
|
148
148
|
return !!this.config.logs.http;
|
|
149
149
|
}
|
|
150
150
|
return this.config?.logs === true;
|
|
151
151
|
}
|
|
152
152
|
get logRealtime() {
|
|
153
|
-
if (
|
|
153
|
+
if (lib_6._.isObject(this.config?.logs)) {
|
|
154
154
|
return !!this.config.logs.realtime;
|
|
155
155
|
}
|
|
156
156
|
return this.config?.logs === true;
|
|
157
157
|
}
|
|
158
158
|
get logFramework() {
|
|
159
|
-
if (
|
|
159
|
+
if (lib_6._.isObject(this.config?.logs)) {
|
|
160
160
|
return !!this.config.logs.framework;
|
|
161
161
|
}
|
|
162
162
|
return this.config?.logs === true;
|
|
163
163
|
}
|
|
164
164
|
get logDb() {
|
|
165
|
-
if (
|
|
165
|
+
if (lib_6._.isObject(this.config?.logs)) {
|
|
166
166
|
return !!this.config.logs.db;
|
|
167
167
|
}
|
|
168
168
|
return this.config?.logs === true;
|
|
169
169
|
}
|
|
170
170
|
get logMigrations() {
|
|
171
|
-
if (
|
|
171
|
+
if (lib_6._.isObject(this.config?.logs)) {
|
|
172
172
|
return !!this.config.logs.migrations;
|
|
173
173
|
}
|
|
174
174
|
return this.config?.logs === true;
|
|
@@ -190,16 +190,16 @@ class EndpointContext {
|
|
|
190
190
|
// @ts-ignore
|
|
191
191
|
this.onlyMigrationRevertToTimestamp = onlyMigrationRevertToTimestamp;
|
|
192
192
|
this.config = this.configFn(env_1.ENV);
|
|
193
|
-
if (
|
|
193
|
+
if (lib_6._.isObject(this.config.database)) {
|
|
194
194
|
this.config.database = models_1.Models.DatabaseConfig.from(this.config.database).databaseConfigTypeORM;
|
|
195
195
|
}
|
|
196
196
|
if (overrideHost && overrideRemoteHost) {
|
|
197
|
-
|
|
197
|
+
lib_6.Helpers.throw(`[taon-config] You can't have overrideHost and overrideRemoteHost at the same time`);
|
|
198
198
|
}
|
|
199
|
-
this.config.host = !
|
|
199
|
+
this.config.host = !lib_6._.isUndefined(overrideHost)
|
|
200
200
|
? overrideHost
|
|
201
201
|
: this.config.host;
|
|
202
|
-
this.config.remoteHost = !
|
|
202
|
+
this.config.remoteHost = !lib_6._.isUndefined(overrideRemoteHost)
|
|
203
203
|
? overrideRemoteHost
|
|
204
204
|
: this.config.remoteHost;
|
|
205
205
|
this.config.host = this.host === null ? void 0 : this.host;
|
|
@@ -208,19 +208,19 @@ class EndpointContext {
|
|
|
208
208
|
if (this.config.host &&
|
|
209
209
|
!this.config.host.startsWith('http://') &&
|
|
210
210
|
!this.config.host.startsWith('https://')) {
|
|
211
|
-
|
|
211
|
+
lib_6.Helpers.throw(`[taon-config] Your 'host' must start with http:// or https://`);
|
|
212
212
|
}
|
|
213
|
-
if (
|
|
213
|
+
if (lib_6._.isUndefined(this.config.useIpcWhenElectron)) {
|
|
214
214
|
this.config.useIpcWhenElectron = true;
|
|
215
215
|
}
|
|
216
216
|
if (this.config.remoteHost &&
|
|
217
217
|
!this.config.remoteHost.startsWith('http://') &&
|
|
218
218
|
!this.config.remoteHost.startsWith('https://')) {
|
|
219
|
-
|
|
219
|
+
lib_6.Helpers.throw(`[taon-config] Your 'remoteHost' must start with http:// or https://`);
|
|
220
220
|
}
|
|
221
221
|
//#region resolve if skipping writing server routes
|
|
222
222
|
//@ts-expect-error overriding readonly
|
|
223
|
-
this.skipWritingServerRoutes =
|
|
223
|
+
this.skipWritingServerRoutes = lib_6._.isBoolean(this.config.skipWritingServerRoutes)
|
|
224
224
|
? this.config.skipWritingServerRoutes
|
|
225
225
|
: false;
|
|
226
226
|
//#endregion
|
|
@@ -232,12 +232,12 @@ class EndpointContext {
|
|
|
232
232
|
}
|
|
233
233
|
if (this.config.remoteHost) {
|
|
234
234
|
if (this.config.host) {
|
|
235
|
-
|
|
235
|
+
lib_6.Helpers.throw(`[taon] You can't have remoteHost and host at the same time`);
|
|
236
236
|
}
|
|
237
237
|
this.mode = 'remote-backend(tcp+udp)';
|
|
238
238
|
}
|
|
239
|
-
if (this.config.useIpcWhenElectron &&
|
|
240
|
-
if (
|
|
239
|
+
if (this.config.useIpcWhenElectron && lib_6.Helpers.isElectron) {
|
|
240
|
+
if (lib_6.Helpers.isWebSQL) {
|
|
241
241
|
this.mode = 'backend-frontend(websql-electron)';
|
|
242
242
|
}
|
|
243
243
|
else {
|
|
@@ -245,7 +245,7 @@ class EndpointContext {
|
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
if (!this.mode && !this.config.abstract) {
|
|
248
|
-
|
|
248
|
+
lib_6.Helpers.error(`[taon] Context "${this.contextName}": You need to provide host or remoteHost or useIpcWhenElectron`, false, true);
|
|
249
249
|
//#region @backend
|
|
250
250
|
process.exit(1);
|
|
251
251
|
//#endregion
|
|
@@ -255,13 +255,13 @@ class EndpointContext {
|
|
|
255
255
|
if (this.config.database === true) {
|
|
256
256
|
this.databaseConfig = this.getAutoGeneratedConfig();
|
|
257
257
|
}
|
|
258
|
-
else if (
|
|
259
|
-
this.databaseConfig =
|
|
258
|
+
else if (lib_6._.isObject(this.config.database)) {
|
|
259
|
+
this.databaseConfig = lib_6._.merge(this.getAutoGeneratedConfig(), lib_6._.cloneDeep(this.config.database));
|
|
260
260
|
}
|
|
261
261
|
//#endregion
|
|
262
262
|
//#region resolve session
|
|
263
263
|
if (this.config.session) {
|
|
264
|
-
this.session =
|
|
264
|
+
this.session = lib_6._.cloneDeep(this.config.session);
|
|
265
265
|
const oneHour = 1000 * 60 * 60 * 1; // 24;
|
|
266
266
|
if (!this.session.cookieMaxAge) {
|
|
267
267
|
this.session.cookieMaxAge = oneHour;
|
|
@@ -353,11 +353,11 @@ class EndpointContext {
|
|
|
353
353
|
this.expressApp = express();
|
|
354
354
|
this.initMiddlewares();
|
|
355
355
|
this.serverTcpUdp = this.isHttpServer
|
|
356
|
-
? new
|
|
356
|
+
? new lib_3.https.Server({
|
|
357
357
|
key: this.config.https?.key,
|
|
358
358
|
cert: this.config.https?.cert,
|
|
359
359
|
}, this.expressApp)
|
|
360
|
-
: new
|
|
360
|
+
: new lib_3.http.Server(this.expressApp);
|
|
361
361
|
this.publicAssets.forEach(asset => {
|
|
362
362
|
this.expressApp.use(asset.serverPath, express.static(asset.locationOnDisk));
|
|
363
363
|
});
|
|
@@ -368,7 +368,7 @@ class EndpointContext {
|
|
|
368
368
|
if (!this.config.abstract) {
|
|
369
369
|
this.disabledRealtime = !!this.config.disabledRealtime;
|
|
370
370
|
//#region @backend
|
|
371
|
-
if (
|
|
371
|
+
if (lib_6.Helpers.isRunningIn.cliMode()) {
|
|
372
372
|
// TODO for now...
|
|
373
373
|
this.disabledRealtime = true;
|
|
374
374
|
}
|
|
@@ -381,16 +381,16 @@ class EndpointContext {
|
|
|
381
381
|
// console.log({ ref })
|
|
382
382
|
if (this.config.abstract) {
|
|
383
383
|
this.logFramework &&
|
|
384
|
-
|
|
384
|
+
lib_6.Helpers.info(`[taon] Create abstract context: ${this.config.contextName}`);
|
|
385
385
|
}
|
|
386
386
|
else {
|
|
387
387
|
if (this.config.remoteHost) {
|
|
388
388
|
this.logFramework &&
|
|
389
|
-
|
|
389
|
+
lib_6.Helpers.info(`[taon] Create context for remote host: ${this.config.remoteHost}`);
|
|
390
390
|
}
|
|
391
391
|
else {
|
|
392
392
|
this.logFramework &&
|
|
393
|
-
|
|
393
|
+
lib_6.Helpers.info(`[taon] Create context for host: ${this.config.host}`);
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
396
|
//#endregion
|
|
@@ -404,8 +404,8 @@ class EndpointContext {
|
|
|
404
404
|
getAutoGeneratedConfig() {
|
|
405
405
|
//#region @websqlFunc
|
|
406
406
|
let databaseConfig = models_1.Models.DatabaseConfig.from({});
|
|
407
|
-
if (
|
|
408
|
-
|
|
407
|
+
if (lib_4.UtilsOs.isRunningInDocker()) {
|
|
408
|
+
lib_6.Helpers.info('Running in docker, using in mysql database');
|
|
409
409
|
// TODO auto resolve database config in docker
|
|
410
410
|
databaseConfig = models_1.Models.DatabaseConfig.from({
|
|
411
411
|
database: `db-${this.contextName}.sqlite`,
|
|
@@ -420,7 +420,7 @@ class EndpointContext {
|
|
|
420
420
|
}
|
|
421
421
|
else {
|
|
422
422
|
this.logFramework &&
|
|
423
|
-
|
|
423
|
+
lib_6.Helpers.info(`[taon][database] Automatically resolving database config for mode ${this.mode}`);
|
|
424
424
|
switch (this.mode) {
|
|
425
425
|
//#region resolve database config for mode backend-frontend(tcp+udp)
|
|
426
426
|
case 'backend-frontend(ipc-electron)':
|
|
@@ -483,7 +483,7 @@ class EndpointContext {
|
|
|
483
483
|
if (this.mode === 'backend-frontend(tcp+udp)') {
|
|
484
484
|
// this.displayRoutes(this.expressApp);
|
|
485
485
|
this.serverTcpUdp.listen(Number(this.uri.port), () => {
|
|
486
|
-
|
|
486
|
+
lib_6.Helpers.log(`[taon][express-server]listening on port: ${this.uri.port}, hostname: ${this.uri.pathname},
|
|
487
487
|
address: ${this.uri.protocol}//localhost:${this.uri.port}${this.uri.pathname}
|
|
488
488
|
env: ${this.expressApp.settings.env}
|
|
489
489
|
`);
|
|
@@ -491,7 +491,7 @@ class EndpointContext {
|
|
|
491
491
|
}
|
|
492
492
|
else {
|
|
493
493
|
this.logFramework &&
|
|
494
|
-
|
|
494
|
+
lib_6.Helpers.info('Ipc communication enable instead tcp/upd');
|
|
495
495
|
}
|
|
496
496
|
//#endregion
|
|
497
497
|
}
|
|
@@ -604,7 +604,7 @@ class EndpointContext {
|
|
|
604
604
|
for (const key of Object.keys(classesInput || {})) {
|
|
605
605
|
const BaseClass = classesInput[key];
|
|
606
606
|
if (!BaseClass) {
|
|
607
|
-
|
|
607
|
+
lib_6.Helpers.error(`Class ${key} is not defined in context ${ctx.contextName}
|
|
608
608
|
|
|
609
609
|
Please check if you have correct import in context file
|
|
610
610
|
|
|
@@ -739,7 +739,7 @@ class EndpointContext {
|
|
|
739
739
|
//#endregion
|
|
740
740
|
//#region methods & getters / check if context initialized
|
|
741
741
|
checkIfContextInitialized() {
|
|
742
|
-
if (
|
|
742
|
+
if (lib_6._.isUndefined(this.config)) {
|
|
743
743
|
throw new Error(`Please check if your context has been initialized.
|
|
744
744
|
|
|
745
745
|
// ...
|
|
@@ -825,8 +825,8 @@ class EndpointContext {
|
|
|
825
825
|
const controllers = this.getClassesInstancesArrBy(models_1.Models.ClassType.CONTROLLER);
|
|
826
826
|
// console.log('CONTROLLERS TO REINIT', controllers);
|
|
827
827
|
for (const ctrl of controllers) {
|
|
828
|
-
if (
|
|
829
|
-
await
|
|
828
|
+
if (lib_6._.isFunction(ctrl.initExampleDbData)) {
|
|
829
|
+
await lib_6.Helpers.runSyncOrAsync({
|
|
830
830
|
functionFn: ctrl.initExampleDbData,
|
|
831
831
|
context: ctrl,
|
|
832
832
|
});
|
|
@@ -852,8 +852,8 @@ class EndpointContext {
|
|
|
852
852
|
// `[taon] REINITING _ CLASS FN ${classTypeName} ${this.contextName} STARTED`,
|
|
853
853
|
// );
|
|
854
854
|
for (const classFun of this.getClassFunByArr(classTypeName)) {
|
|
855
|
-
if (
|
|
856
|
-
await
|
|
855
|
+
if (lib_6._.isFunction(classFun._)) {
|
|
856
|
+
await lib_6.Helpers.runSyncOrAsync({
|
|
857
857
|
functionFn: classFun._,
|
|
858
858
|
context: classFun,
|
|
859
859
|
});
|
|
@@ -881,8 +881,8 @@ class EndpointContext {
|
|
|
881
881
|
// `[taon] REINITING _ INS FN ${classTypeName} ${this.contextName} STARTED`,
|
|
882
882
|
// );
|
|
883
883
|
for (const ctrl of this.getClassesInstancesArrBy(classTypeName)) {
|
|
884
|
-
if (
|
|
885
|
-
await
|
|
884
|
+
if (lib_6._.isFunction(ctrl._)) {
|
|
885
|
+
await lib_6.Helpers.runSyncOrAsync({
|
|
886
886
|
functionFn: ctrl._,
|
|
887
887
|
context: ctrl,
|
|
888
888
|
});
|
|
@@ -967,7 +967,7 @@ class EndpointContext {
|
|
|
967
967
|
const options = Reflect.getMetadata(symbols_1.Symbols.metadata.options.subscriber, subscriberClassFn);
|
|
968
968
|
// console.log('subscriber options', options);
|
|
969
969
|
// const nameForSubscriber = ClassHelpers.getName(subscriber);
|
|
970
|
-
(0,
|
|
970
|
+
(0, lib_1.EventSubscriber)()(subscriberClassFn);
|
|
971
971
|
}
|
|
972
972
|
//#endregion
|
|
973
973
|
}
|
|
@@ -981,15 +981,15 @@ class EndpointContext {
|
|
|
981
981
|
const entities = this.getClassFunByArr(models_1.Models.ClassType.ENTITY);
|
|
982
982
|
for (const entity of entities) {
|
|
983
983
|
const options = Reflect.getMetadata(symbols_1.Symbols.metadata.options.entity, entity);
|
|
984
|
-
const createTable =
|
|
984
|
+
const createTable = lib_6._.isUndefined(options.createTable)
|
|
985
985
|
? true
|
|
986
986
|
: options.createTable;
|
|
987
987
|
const nameForEntity = class_helpers_1.ClassHelpers.getName(entity);
|
|
988
|
-
if (
|
|
988
|
+
if (lib_6._.isUndefined(options.createTable) ? true : options.createTable) {
|
|
989
989
|
this.logDb &&
|
|
990
990
|
console.info(`[taon][typeorm] create table for entity "${nameForEntity}" ? '${createTable}'`);
|
|
991
991
|
// console.log('TypeormEntity', { TypeormEntity });
|
|
992
|
-
(0,
|
|
992
|
+
(0, lib_2.Entity)(nameForEntity)(entity);
|
|
993
993
|
}
|
|
994
994
|
else {
|
|
995
995
|
this.logDb &&
|
|
@@ -1028,7 +1028,7 @@ class EndpointContext {
|
|
|
1028
1028
|
return class_helpers_1.ClassHelpers.getOrginalClass(entityFn);
|
|
1029
1029
|
});
|
|
1030
1030
|
const subscribers = this.getClassFunByArr(models_1.Models.ClassType.SUBSCRIBER);
|
|
1031
|
-
const dataSourceDbConfig =
|
|
1031
|
+
const dataSourceDbConfig = lib_6._.isObject(this.databaseConfig)
|
|
1032
1032
|
? {
|
|
1033
1033
|
type: this.databaseConfig.type,
|
|
1034
1034
|
port: this.databaseConfig.databasePort,
|
|
@@ -1043,9 +1043,9 @@ class EndpointContext {
|
|
|
1043
1043
|
synchronize: this.isRunOrRevertOnlyMigrationAppStart
|
|
1044
1044
|
? false
|
|
1045
1045
|
: this.databaseConfig.synchronize,
|
|
1046
|
-
autoSave: !
|
|
1046
|
+
autoSave: !lib_6._.isNil(this.databaseConfig.autoSave)
|
|
1047
1047
|
? this.databaseConfig.autoSave
|
|
1048
|
-
: !
|
|
1048
|
+
: !lib_4.UtilsOs.isRunningInDocker(), // in docker I am using mysql or posgress
|
|
1049
1049
|
dropSchema: this.isRunOrRevertOnlyMigrationAppStart
|
|
1050
1050
|
? false
|
|
1051
1051
|
: this.databaseConfig.dropSchema,
|
|
@@ -1059,9 +1059,9 @@ class EndpointContext {
|
|
|
1059
1059
|
if (this.modeAllowsDatabaseCreation && this.databaseConfig) {
|
|
1060
1060
|
this.logDb &&
|
|
1061
1061
|
this.logFramework &&
|
|
1062
|
-
|
|
1062
|
+
lib_6.Helpers.info('[taon][database] prepare typeorm connection...');
|
|
1063
1063
|
try {
|
|
1064
|
-
const connection = new
|
|
1064
|
+
const connection = new lib_9.DataSource(dataSourceDbConfig);
|
|
1065
1065
|
this.connection = connection;
|
|
1066
1066
|
await this.connection.initialize();
|
|
1067
1067
|
}
|
|
@@ -1096,7 +1096,7 @@ class EndpointContext {
|
|
|
1096
1096
|
// debugger;
|
|
1097
1097
|
}
|
|
1098
1098
|
else {
|
|
1099
|
-
|
|
1099
|
+
lib_6.Helpers.info(`[taon][typeorm] Not initing db for mode ${this.mode}`);
|
|
1100
1100
|
}
|
|
1101
1101
|
//#endregion
|
|
1102
1102
|
}
|
|
@@ -1114,7 +1114,7 @@ class EndpointContext {
|
|
|
1114
1114
|
const configs = class_helpers_1.ClassHelpers.getControllerConfigs(controllerClassFn);
|
|
1115
1115
|
// console.log(`Class config for ${ClassHelpers.getName(controllerClassFn)}`, configs)
|
|
1116
1116
|
const classConfig = configs[0];
|
|
1117
|
-
const parentscalculatedPath =
|
|
1117
|
+
const parentscalculatedPath = lib_6._.slice(configs, 1)
|
|
1118
1118
|
.reverse()
|
|
1119
1119
|
.map(bc => {
|
|
1120
1120
|
if (taon_helpers_1.TaonHelpers.isGoodPath(bc.path)) {
|
|
@@ -1132,13 +1132,13 @@ class EndpointContext {
|
|
|
1132
1132
|
.replace(/\/\//g, '/')
|
|
1133
1133
|
.split('/')
|
|
1134
1134
|
.reduce((acc, bc) => {
|
|
1135
|
-
return
|
|
1135
|
+
return lib_6._.last(acc) === bc ? acc : [...acc, bc];
|
|
1136
1136
|
}, [])
|
|
1137
1137
|
.join('/');
|
|
1138
1138
|
}
|
|
1139
|
-
|
|
1139
|
+
lib_6._.slice(configs, 1).forEach(bc => {
|
|
1140
1140
|
const alreadyIs = classConfig.methods;
|
|
1141
|
-
const toMerge =
|
|
1141
|
+
const toMerge = lib_6._.cloneDeep(bc.methods);
|
|
1142
1142
|
for (const key in toMerge) {
|
|
1143
1143
|
if (toMerge.hasOwnProperty(key) && !alreadyIs[key]) {
|
|
1144
1144
|
const element = toMerge[key];
|
|
@@ -1147,7 +1147,7 @@ class EndpointContext {
|
|
|
1147
1147
|
}
|
|
1148
1148
|
});
|
|
1149
1149
|
//#region @backend
|
|
1150
|
-
if (!
|
|
1150
|
+
if (!lib_6.Helpers.isRunningIn.cliMode()) {
|
|
1151
1151
|
//#endregion
|
|
1152
1152
|
this.logHttp &&
|
|
1153
1153
|
console.groupCollapsed(`[taon][express-server] routes [${classConfig.className}]`);
|
|
@@ -1163,7 +1163,7 @@ class EndpointContext {
|
|
|
1163
1163
|
? `/${methodConfig.path?.replace(/\//, '')}`
|
|
1164
1164
|
: taon_helpers_1.TaonHelpers.getExpressPath(classConfig, methodConfig);
|
|
1165
1165
|
// console.log({ expressPath })
|
|
1166
|
-
if (
|
|
1166
|
+
if (lib_6.Helpers.isNode || lib_6.Helpers.isWebSQL) {
|
|
1167
1167
|
//#region @websql
|
|
1168
1168
|
const { routePath, method } = this.initServer(type, methodConfig, classConfig, expressPath, controllerClassFn);
|
|
1169
1169
|
this.activeRoutes.push({
|
|
@@ -1172,7 +1172,7 @@ class EndpointContext {
|
|
|
1172
1172
|
});
|
|
1173
1173
|
//#endregion
|
|
1174
1174
|
}
|
|
1175
|
-
const shouldInitClient =
|
|
1175
|
+
const shouldInitClient = lib_6.Helpers.isBrowser || this.remoteHost || lib_6.Helpers.isWebSQL;
|
|
1176
1176
|
// console.log('shouldInitClient', shouldInitClient);
|
|
1177
1177
|
if (shouldInitClient) {
|
|
1178
1178
|
// console.log(
|
|
@@ -1186,7 +1186,7 @@ class EndpointContext {
|
|
|
1186
1186
|
}
|
|
1187
1187
|
});
|
|
1188
1188
|
//#region @backend
|
|
1189
|
-
if (!
|
|
1189
|
+
if (!lib_6.Helpers.isRunningIn.cliMode()) {
|
|
1190
1190
|
//#endregion
|
|
1191
1191
|
this.logHttp && console.groupEnd();
|
|
1192
1192
|
//#region @backend
|
|
@@ -1204,11 +1204,11 @@ class EndpointContext {
|
|
|
1204
1204
|
}
|
|
1205
1205
|
const contexts = [this];
|
|
1206
1206
|
//#region @websql
|
|
1207
|
-
const troutes =
|
|
1207
|
+
const troutes = lib_4.Utils.uniqArray(this.activeRoutes.map(f => {
|
|
1208
1208
|
return `${f.method} ${f.routePath}`;
|
|
1209
1209
|
})).map(f => {
|
|
1210
1210
|
const [method, routePath] = f.split(' ');
|
|
1211
|
-
return (`\n### ${
|
|
1211
|
+
return (`\n### ${lib_6._.startCase(lib_6._.last(routePath.split('/')))}\n` +
|
|
1212
1212
|
taon_helpers_1.TaonHelpers.fillUpTo(method.toUpperCase() + ' ', 10) +
|
|
1213
1213
|
this.uri.href.replace(/\/$/, '') +
|
|
1214
1214
|
routePath);
|
|
@@ -1219,7 +1219,7 @@ class EndpointContext {
|
|
|
1219
1219
|
...['', `# ROUTES FOR HOST ${this.uri.href} `],
|
|
1220
1220
|
...troutes,
|
|
1221
1221
|
].join('\n');
|
|
1222
|
-
const fileName = (0,
|
|
1222
|
+
const fileName = (0, lib_5.crossPlatformPath)([
|
|
1223
1223
|
//#region @backend
|
|
1224
1224
|
process.cwd(),
|
|
1225
1225
|
//#endregion
|
|
@@ -1228,7 +1228,7 @@ class EndpointContext {
|
|
|
1228
1228
|
this.logFramework && console.log(`[taon] routes file: ${fileName} `);
|
|
1229
1229
|
// Helpers.log(JSON.stringify(routes, null, 4))
|
|
1230
1230
|
//#region @backend
|
|
1231
|
-
|
|
1231
|
+
lib_6.Helpers.writeFile(fileName, routes);
|
|
1232
1232
|
//#endregion
|
|
1233
1233
|
//#endregion
|
|
1234
1234
|
}
|
|
@@ -1259,7 +1259,7 @@ class EndpointContext {
|
|
|
1259
1259
|
app.use(methodOverride());
|
|
1260
1260
|
app.use(cookieParser());
|
|
1261
1261
|
if (this.session) {
|
|
1262
|
-
|
|
1262
|
+
lib_6.Helpers.info('[taon][express-server] session enabled for this context ' +
|
|
1263
1263
|
this.contextName);
|
|
1264
1264
|
const { cookieMaxAge } = this.session;
|
|
1265
1265
|
const frontendHost = this.config.frontendHost;
|
|
@@ -1285,7 +1285,7 @@ class EndpointContext {
|
|
|
1285
1285
|
else {
|
|
1286
1286
|
// if(this.config?.serverLogs) {
|
|
1287
1287
|
this.logHttp &&
|
|
1288
|
-
|
|
1288
|
+
lib_6.Helpers.info(`[taon][express-server] session not enabled for this context '${this.contextName}'`);
|
|
1289
1289
|
// }
|
|
1290
1290
|
app.use(cors({
|
|
1291
1291
|
// origin: "http://localhost:5555",
|
|
@@ -1366,10 +1366,10 @@ class EndpointContext {
|
|
|
1366
1366
|
expressPath = expressPath.replace(/\/\//g, '/');
|
|
1367
1367
|
// console.log(`BACKEND: expressPath: ${ expressPath } `)
|
|
1368
1368
|
//#endregion
|
|
1369
|
-
if (
|
|
1369
|
+
if (lib_6.Helpers.isElectron) {
|
|
1370
1370
|
//#region @backend
|
|
1371
1371
|
const ipcKeyName = taon_helpers_1.TaonHelpers.ipcKeyNameRequest(target, methodConfig, expressPath);
|
|
1372
|
-
|
|
1372
|
+
lib_6.Helpers.ipcMain.on(ipcKeyName, async (event, paramsFromBrowser) => {
|
|
1373
1373
|
const responseJsonData = await getResult(paramsFromBrowser, void 0, void 0);
|
|
1374
1374
|
event.sender.send(taon_helpers_1.TaonHelpers.ipcKeyNameResponse(target, methodConfig, expressPath), responseJsonData);
|
|
1375
1375
|
});
|
|
@@ -1382,7 +1382,7 @@ class EndpointContext {
|
|
|
1382
1382
|
if (!this.remoteHost) {
|
|
1383
1383
|
//#region apply dummy websql express routers
|
|
1384
1384
|
//#region @websql
|
|
1385
|
-
if (
|
|
1385
|
+
if (lib_6.Helpers.isWebSQL) {
|
|
1386
1386
|
if (!this.expressApp[type.toLowerCase()]) {
|
|
1387
1387
|
this.expressApp[type.toLowerCase()] = () => { };
|
|
1388
1388
|
}
|
|
@@ -1415,7 +1415,7 @@ class EndpointContext {
|
|
|
1415
1415
|
if (req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS]) {
|
|
1416
1416
|
try {
|
|
1417
1417
|
const entity = JSON.parse(req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS]);
|
|
1418
|
-
tBody =
|
|
1418
|
+
tBody = lib_7.Mapping.encode(tBody, entity);
|
|
1419
1419
|
}
|
|
1420
1420
|
catch (e) { }
|
|
1421
1421
|
}
|
|
@@ -1423,7 +1423,7 @@ class EndpointContext {
|
|
|
1423
1423
|
Object.keys(tBody).forEach(paramName => {
|
|
1424
1424
|
try {
|
|
1425
1425
|
const entityForParam = JSON.parse(req.headers[`${symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS}${paramName} `]);
|
|
1426
|
-
tBody[paramName] =
|
|
1426
|
+
tBody[paramName] = lib_7.Mapping.encode(tBody[paramName], entityForParam);
|
|
1427
1427
|
}
|
|
1428
1428
|
catch (e) { }
|
|
1429
1429
|
});
|
|
@@ -1433,7 +1433,7 @@ class EndpointContext {
|
|
|
1433
1433
|
if (req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS]) {
|
|
1434
1434
|
try {
|
|
1435
1435
|
const entity = JSON.parse(req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS]);
|
|
1436
|
-
tQuery = taon_helpers_1.TaonHelpers.parseJSONwithStringJSONs(
|
|
1436
|
+
tQuery = taon_helpers_1.TaonHelpers.parseJSONwithStringJSONs(lib_7.Mapping.encode(tQuery, entity));
|
|
1437
1437
|
}
|
|
1438
1438
|
catch (e) { }
|
|
1439
1439
|
}
|
|
@@ -1442,14 +1442,14 @@ class EndpointContext {
|
|
|
1442
1442
|
try {
|
|
1443
1443
|
const entityForParam = JSON.parse(req.headers[`${symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS}${queryParamName} `]);
|
|
1444
1444
|
let beforeTransofrm = tQuery[queryParamName];
|
|
1445
|
-
if (
|
|
1445
|
+
if (lib_6._.isString(beforeTransofrm)) {
|
|
1446
1446
|
try {
|
|
1447
1447
|
const paresed = taon_helpers_1.TaonHelpers.tryTransformParam(beforeTransofrm);
|
|
1448
1448
|
beforeTransofrm = paresed;
|
|
1449
1449
|
}
|
|
1450
1450
|
catch (e) { }
|
|
1451
1451
|
}
|
|
1452
|
-
const afterEncoding =
|
|
1452
|
+
const afterEncoding = lib_7.Mapping.encode(beforeTransofrm, entityForParam);
|
|
1453
1453
|
tQuery[queryParamName] =
|
|
1454
1454
|
taon_helpers_1.TaonHelpers.parseJSONwithStringJSONs(afterEncoding);
|
|
1455
1455
|
}
|
|
@@ -1504,7 +1504,7 @@ class EndpointContext {
|
|
|
1504
1504
|
res.end(file);
|
|
1505
1505
|
//#endregion
|
|
1506
1506
|
}
|
|
1507
|
-
else if (
|
|
1507
|
+
else if (lib_6._.isString(result) &&
|
|
1508
1508
|
methodConfig.responseType ===
|
|
1509
1509
|
'blob') {
|
|
1510
1510
|
// console.log('BASE64')
|
|
@@ -1531,8 +1531,8 @@ class EndpointContext {
|
|
|
1531
1531
|
}
|
|
1532
1532
|
catch (error) {
|
|
1533
1533
|
//#region process error
|
|
1534
|
-
if (
|
|
1535
|
-
res.status(400).send(
|
|
1534
|
+
if (lib_6._.isString(error)) {
|
|
1535
|
+
res.status(400).send(lib_8.JSON10.stringify({
|
|
1536
1536
|
message: `
|
|
1537
1537
|
Error inside: ${req.path}
|
|
1538
1538
|
|
|
@@ -1542,22 +1542,22 @@ class EndpointContext {
|
|
|
1542
1542
|
}));
|
|
1543
1543
|
}
|
|
1544
1544
|
else if (error instanceof models_1.Models.Http.Errors) {
|
|
1545
|
-
|
|
1545
|
+
lib_6.Helpers.error(error, true, false);
|
|
1546
1546
|
const err = error;
|
|
1547
|
-
res.status(400).send(
|
|
1547
|
+
res.status(400).send(lib_8.JSON10.stringify(err));
|
|
1548
1548
|
}
|
|
1549
1549
|
else if (error instanceof Error) {
|
|
1550
1550
|
const err = error;
|
|
1551
|
-
|
|
1552
|
-
res.status(400).send(
|
|
1551
|
+
lib_6.Helpers.error(error, true, false);
|
|
1552
|
+
res.status(400).send(lib_8.JSON10.stringify({
|
|
1553
1553
|
stack: err.stack,
|
|
1554
1554
|
message: err.message,
|
|
1555
1555
|
}));
|
|
1556
1556
|
}
|
|
1557
1557
|
else {
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
res.status(400).send(
|
|
1558
|
+
lib_6.Helpers.log(error);
|
|
1559
|
+
lib_6.Helpers.error(`[Taon] Bad result isomorphic method: ${error} `, true, false);
|
|
1560
|
+
res.status(400).send(lib_8.JSON10.stringify(error));
|
|
1561
1561
|
}
|
|
1562
1562
|
//#endregion
|
|
1563
1563
|
}
|
|
@@ -1583,36 +1583,36 @@ class EndpointContext {
|
|
|
1583
1583
|
// console.log('INITING', methodConfig); // TODO inject in static
|
|
1584
1584
|
//#region resolve storage
|
|
1585
1585
|
let storage;
|
|
1586
|
-
if (
|
|
1586
|
+
if (lib_6.Helpers.isBrowser) {
|
|
1587
1587
|
storage = window;
|
|
1588
1588
|
}
|
|
1589
1589
|
//#region @backend
|
|
1590
|
-
if (
|
|
1590
|
+
if (lib_6.Helpers.isNode) {
|
|
1591
1591
|
storage = global;
|
|
1592
1592
|
}
|
|
1593
1593
|
//#endregion
|
|
1594
1594
|
//#endregion
|
|
1595
1595
|
const orgMethods = target.prototype[methodConfig.methodName];
|
|
1596
1596
|
//#region handle electron ipc request
|
|
1597
|
-
if (
|
|
1597
|
+
if (lib_6.Helpers.isElectron) {
|
|
1598
1598
|
target.prototype[methodConfig.methodName] = function (...args) {
|
|
1599
1599
|
const received = new Promise(async (resolve, reject) => {
|
|
1600
1600
|
const headers = {};
|
|
1601
1601
|
const { request, response } = taon_helpers_1.TaonHelpers.websqlMocks(headers);
|
|
1602
|
-
|
|
1602
|
+
lib_6.Helpers.ipcRenderer.once(taon_helpers_1.TaonHelpers.ipcKeyNameResponse(target, methodConfig, expressPath), (event, responseData) => {
|
|
1603
1603
|
let res = responseData;
|
|
1604
1604
|
console.log({ responseData });
|
|
1605
1605
|
try {
|
|
1606
1606
|
const body = res;
|
|
1607
|
-
res = new
|
|
1607
|
+
res = new lib_7.Models.HttpResponse({
|
|
1608
1608
|
body: void 0,
|
|
1609
1609
|
isArray: void 0,
|
|
1610
1610
|
method: methodConfig.type,
|
|
1611
1611
|
url: `${ctx.uri.origin}${'' // TODO express path
|
|
1612
1612
|
}${methodConfig.path} `,
|
|
1613
|
-
},
|
|
1613
|
+
}, lib_6.Helpers.isBlob(body) || lib_6._.isString(body)
|
|
1614
1614
|
? body
|
|
1615
|
-
: JSON.stringify(body),
|
|
1615
|
+
: JSON.stringify(body), lib_7.RestHeaders.from(headers), void 0, () => body);
|
|
1616
1616
|
resolve(res);
|
|
1617
1617
|
}
|
|
1618
1618
|
catch (error) {
|
|
@@ -1620,7 +1620,7 @@ class EndpointContext {
|
|
|
1620
1620
|
reject(error);
|
|
1621
1621
|
}
|
|
1622
1622
|
});
|
|
1623
|
-
|
|
1623
|
+
lib_6.Helpers.ipcRenderer.send(taon_helpers_1.TaonHelpers.ipcKeyNameRequest(target, methodConfig, expressPath), args);
|
|
1624
1624
|
});
|
|
1625
1625
|
received['observable'] = (0, rxjs_1.from)(received);
|
|
1626
1626
|
return {
|
|
@@ -1788,25 +1788,25 @@ class EndpointContext {
|
|
|
1788
1788
|
if (!endpoints[ctx.uri.href][expressPath]) {
|
|
1789
1789
|
let headers = {};
|
|
1790
1790
|
if (methodConfig.contentType && !methodConfig.responseType) {
|
|
1791
|
-
rest =
|
|
1791
|
+
rest = lib_7.Resource.create(ctx.uri.href, expressPath, symbols_1.Symbols.old.MAPPING_CONFIG_HEADER, symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, lib_7.RestHeaders.from({
|
|
1792
1792
|
'Content-Type': methodConfig.contentType,
|
|
1793
1793
|
Accept: methodConfig.contentType,
|
|
1794
1794
|
}));
|
|
1795
1795
|
}
|
|
1796
1796
|
else if (methodConfig.contentType && methodConfig.responseType) {
|
|
1797
|
-
rest =
|
|
1797
|
+
rest = lib_7.Resource.create(ctx.uri.href, expressPath, symbols_1.Symbols.old.MAPPING_CONFIG_HEADER, symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, lib_7.RestHeaders.from({
|
|
1798
1798
|
'Content-Type': methodConfig.contentType,
|
|
1799
1799
|
Accept: methodConfig.contentType,
|
|
1800
1800
|
responsetypeaxios: methodConfig.responseType,
|
|
1801
1801
|
}));
|
|
1802
1802
|
}
|
|
1803
1803
|
else if (!methodConfig.contentType && methodConfig.responseType) {
|
|
1804
|
-
rest =
|
|
1804
|
+
rest = lib_7.Resource.create(ctx.uri.href, expressPath, symbols_1.Symbols.old.MAPPING_CONFIG_HEADER, symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, lib_7.RestHeaders.from({
|
|
1805
1805
|
responsetypeaxios: methodConfig.responseType,
|
|
1806
1806
|
}));
|
|
1807
1807
|
}
|
|
1808
1808
|
else {
|
|
1809
|
-
rest =
|
|
1809
|
+
rest = lib_7.Resource.create(ctx.uri.href, expressPath, symbols_1.Symbols.old.MAPPING_CONFIG_HEADER, symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY);
|
|
1810
1810
|
}
|
|
1811
1811
|
endpoints[ctx.uri.href][expressPath] = rest;
|
|
1812
1812
|
}
|
|
@@ -1832,18 +1832,18 @@ class EndpointContext {
|
|
|
1832
1832
|
}
|
|
1833
1833
|
if (currentParam.paramType === 'Query') {
|
|
1834
1834
|
if (currentParam.paramName) {
|
|
1835
|
-
const mapping =
|
|
1835
|
+
const mapping = lib_7.Mapping.decode(param, !ctx.isProductionMode);
|
|
1836
1836
|
if (mapping) {
|
|
1837
1837
|
rest.headers.set(`${symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
|
|
1838
1838
|
}
|
|
1839
1839
|
queryParams[currentParam.paramName] = param;
|
|
1840
1840
|
}
|
|
1841
1841
|
else {
|
|
1842
|
-
const mapping =
|
|
1842
|
+
const mapping = lib_7.Mapping.decode(param, !ctx.isProductionMode);
|
|
1843
1843
|
if (mapping) {
|
|
1844
1844
|
rest.headers.set(symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS, JSON.stringify(mapping));
|
|
1845
1845
|
}
|
|
1846
|
-
queryParams =
|
|
1846
|
+
queryParams = lib_6._.cloneDeep(param);
|
|
1847
1847
|
}
|
|
1848
1848
|
}
|
|
1849
1849
|
if (currentParam.paramType === 'Header') {
|
|
@@ -1863,7 +1863,7 @@ class EndpointContext {
|
|
|
1863
1863
|
}
|
|
1864
1864
|
}
|
|
1865
1865
|
if (currentParam.paramType === 'Cookie') {
|
|
1866
|
-
|
|
1866
|
+
lib_7.Resource.Cookies.write(currentParam.paramName, param, currentParam.expireInSeconds);
|
|
1867
1867
|
}
|
|
1868
1868
|
if (currentParam.paramType === 'Body') {
|
|
1869
1869
|
if (currentParam.paramName) {
|
|
@@ -1880,14 +1880,14 @@ instead
|
|
|
1880
1880
|
// ...
|
|
1881
1881
|
`);
|
|
1882
1882
|
}
|
|
1883
|
-
const mapping =
|
|
1883
|
+
const mapping = lib_7.Mapping.decode(param, !ctx.isProductionMode);
|
|
1884
1884
|
if (mapping) {
|
|
1885
1885
|
rest.headers.set(`${symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
|
|
1886
1886
|
}
|
|
1887
1887
|
bodyObject[currentParam.paramName] = param;
|
|
1888
1888
|
}
|
|
1889
1889
|
else {
|
|
1890
|
-
const mapping =
|
|
1890
|
+
const mapping = lib_7.Mapping.decode(param, !ctx.isProductionMode);
|
|
1891
1891
|
if (mapping) {
|
|
1892
1892
|
rest.headers.set(symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS, JSON.stringify(mapping));
|
|
1893
1893
|
}
|
|
@@ -1898,17 +1898,17 @@ instead
|
|
|
1898
1898
|
if (typeof bodyObject === 'object' &&
|
|
1899
1899
|
class_helpers_1.ClassHelpers.getName(bodyObject) !== 'FormData') {
|
|
1900
1900
|
let circuralFromItem = [];
|
|
1901
|
-
bodyObject =
|
|
1901
|
+
bodyObject = lib_8.JSON10.parse(lib_8.JSON10.stringify(bodyObject, void 0, void 0, circs => {
|
|
1902
1902
|
circuralFromItem = circs;
|
|
1903
1903
|
}));
|
|
1904
|
-
rest.headers.set(symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY,
|
|
1904
|
+
rest.headers.set(symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, lib_8.JSON10.stringify(circuralFromItem));
|
|
1905
1905
|
}
|
|
1906
1906
|
if (typeof queryParams === 'object') {
|
|
1907
1907
|
let circuralFromQueryParams = [];
|
|
1908
|
-
queryParams =
|
|
1908
|
+
queryParams = lib_8.JSON10.parse(lib_8.JSON10.stringify(queryParams, void 0, void 0, circs => {
|
|
1909
1909
|
circuralFromQueryParams = circs;
|
|
1910
1910
|
}));
|
|
1911
|
-
rest.headers.set(symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM,
|
|
1911
|
+
rest.headers.set(symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM, lib_8.JSON10.stringify(circuralFromQueryParams));
|
|
1912
1912
|
}
|
|
1913
1913
|
//#endregion
|
|
1914
1914
|
const httpResultObj = {
|