taon 19.0.6 → 19.0.7
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 +4009 -4053
- package/browser/fesm2022/taon.mjs.map +1 -1
- package/browser/lib/base-classes/base-angular-service.d.ts +14 -0
- package/browser/lib/base-classes/base-injector.d.ts +12 -7
- package/browser/lib/base-classes/base-repository.d.ts +3 -5
- package/browser/lib/base-classes/base.d.ts +6 -4
- package/browser/lib/create-context.d.ts +2 -1
- package/browser/lib/endpoint-context.d.ts +6 -5
- package/browser/lib/index.d.ts +6 -6
- package/browser/package.json +1 -1
- package/cli.js.map +1 -1
- package/client/README.md +24 -24
- package/client/fesm2022/taon.mjs +4009 -4053
- package/client/fesm2022/taon.mjs.map +1 -1
- package/client/lib/base-classes/base-angular-service.d.ts +14 -0
- package/client/lib/base-classes/base-injector.d.ts +12 -7
- package/client/lib/base-classes/base-repository.d.ts +3 -5
- package/client/lib/base-classes/base.d.ts +6 -4
- package/client/lib/create-context.d.ts +2 -1
- package/client/lib/endpoint-context.d.ts +6 -5
- package/client/lib/index.d.ts +6 -6
- package/client/package.json +1 -1
- package/index.js.map +1 -1
- package/lib/base-classes/base-abstract-entity.js.map +1 -1
- package/lib/base-classes/base-angular-service.d.ts +10 -0
- package/lib/base-classes/base-angular-service.js +19 -0
- package/lib/base-classes/base-angular-service.js.map +1 -0
- package/lib/base-classes/base-class.js.map +1 -1
- 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.map +1 -1
- package/lib/base-classes/base-entity.js.map +1 -1
- package/lib/base-classes/base-injector.d.ts +12 -7
- package/lib/base-classes/base-injector.js +19 -17
- package/lib/base-classes/base-injector.js.map +1 -1
- 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 +0 -3
- package/lib/base-classes/base-repository.js +17 -59
- package/lib/base-classes/base-repository.js.map +1 -1
- package/lib/base-classes/base-subscriber-for-entity.js.map +1 -1
- package/lib/base-classes/base-subscriber.d.ts +4 -0
- package/lib/base-classes/base-subscriber.js +25 -0
- package/lib/base-classes/base-subscriber.js.map +1 -0
- package/lib/base-classes/base.d.ts +6 -4
- package/lib/base-classes/base.js +7 -5
- package/lib/base-classes/base.js.map +1 -1
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/build-info._auto-generated_.js.map +1 -1
- package/lib/constants.js.map +1 -1
- package/lib/context-db-migrations.js.map +1 -1
- package/lib/create-context.d.ts +1 -0
- package/lib/create-context.js +1 -5
- package/lib/create-context.js.map +1 -1
- package/lib/decorators/classes/controller-decorator.js.map +1 -1
- 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.js.map +1 -1
- 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.d.ts +8 -5
- package/lib/endpoint-context.js +170 -179
- package/lib/endpoint-context.js.map +1 -1
- package/lib/entity-process.js.map +1 -1
- 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.js.map +1 -1
- package/lib/formly/type-from-entity.js.map +1 -1
- package/lib/get-response-value.js.map +1 -1
- package/lib/helpers/class-helpers.js.map +1 -1
- package/lib/helpers/taon-helpers.js.map +1 -1
- package/lib/index._auto-generated_.js.map +1 -1
- package/lib/index.d.ts +6 -6
- package/lib/index.js +8 -9
- package/lib/index.js.map +1 -1
- package/lib/inject.js +3 -1
- package/lib/inject.js.map +1 -1
- package/lib/models.js.map +1 -1
- package/lib/orm.d.ts +15 -2
- package/lib/orm.js +41 -3
- package/lib/orm.js.map +1 -1
- package/lib/realtime/realtime-client.js.map +1 -1
- package/lib/realtime/realtime-core.js.map +1 -1
- 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-models/index.d.ts +0 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.js +5 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.d.ts +22 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.js +139 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.d.ts +16 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.js +68 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.d.ts +10 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.js +56 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.d.ts +10 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.js +50 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.d.ts +13 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.js +3 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc.js.map +1 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.d.ts +2 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.js +6 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.d.ts +16 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.js +54 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.d.ts +17 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.js +52 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.d.ts +11 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.js +39 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.d.ts +13 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.js +46 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.d.ts +11 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.js +3 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.js.map +1 -0
- 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.map +1 -1
- package/lib/realtime/realtime.models.js.map +1 -1
- package/lib/storage.js.map +1 -1
- package/lib/symbols.js.map +1 -1
- package/lib/ui/directives/firedev-inject-html.directive.d.ts +6 -0
- package/lib/ui/directives/firedev-long-press.directive.d.ts +22 -0
- 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/components/taon-admin-edit-mode/index.d.ts +2 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.js +5 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.js.map +1 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/taon-admin-edit-mode.component.d.ts +29 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/taon-admin-edit-mode.module.d.ts +2 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.d.ts +1 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.js +5 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.js.map +1 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/taon-db-admin.component.d.ts +8 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.d.ts +2 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.js +5 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.js.map +1 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/taon-file-general-opt.component.d.ts +13 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/taon-file-general-opt.module.d.ts +2 -0
- 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/models/taon-admin-mode-tabs.d.ts +5 -0
- package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.js +3 -0
- package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.js.map +1 -0
- package/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.d.ts +14 -0
- package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.module.d.ts +2 -0
- 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.models.js.map +1 -1
- package/lib/ui/toan-full-material.module.d.ts +2 -0
- 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.map +1 -1
- package/package.json +1 -1
- package/playground.js.map +1 -1
- package/tmp-environment.json +3 -3
- package/websql/README.md +24 -24
- package/websql/fesm2022/taon.mjs +4751 -4739
- package/websql/fesm2022/taon.mjs.map +1 -1
- package/websql/lib/base-classes/base-angular-service.d.ts +14 -0
- package/websql/lib/base-classes/base-injector.d.ts +12 -7
- package/websql/lib/base-classes/base-repository.d.ts +0 -3
- package/websql/lib/base-classes/base.d.ts +6 -4
- package/websql/lib/create-context.d.ts +2 -1
- package/websql/lib/endpoint-context.d.ts +8 -5
- package/websql/lib/index.d.ts +6 -6
- package/websql/lib/orm.d.ts +15 -2
- package/websql/package.json +1 -1
package/lib/endpoint-context.js
CHANGED
|
@@ -1,43 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EndpointContext = void 0;
|
|
4
|
-
|
|
5
|
-
//#region imports
|
|
6
|
-
//#region @websql
|
|
7
|
-
const lib_1 = require("taon-typeorm/lib");
|
|
8
|
-
const lib_2 = require("taon-typeorm/lib");
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region @backend
|
|
11
|
-
const express = require("express");
|
|
12
|
-
const expressSession = require("express-session");
|
|
13
|
-
const cors = require("cors");
|
|
14
|
-
const bodyParser = require("body-parser");
|
|
15
|
-
const cookieParser = require("cookie-parser");
|
|
16
|
-
const methodOverride = require("method-override");
|
|
17
|
-
const fileUpload = require("express-fileupload");
|
|
18
|
-
const url_1 = require("url");
|
|
19
|
-
const lib_3 = require("tnp-core/lib");
|
|
20
|
-
//#endregion
|
|
21
|
-
/* */
|
|
4
|
+
const url_1 = require("url"); // @backend
|
|
22
5
|
/* */
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
6
|
+
const axios_1 = require("axios");
|
|
7
|
+
const bodyParser = require("body-parser"); // @backend
|
|
8
|
+
const cookieParser = require("cookie-parser"); // @backend
|
|
9
|
+
const cors = require("cors"); // @backend
|
|
10
|
+
const express = require("express"); // @backend
|
|
11
|
+
const fileUpload = require("express-fileupload"); // @backend
|
|
12
|
+
const expressSession = require("express-session"); // @backend
|
|
13
|
+
const lib_1 = require("json10/lib");
|
|
14
|
+
const methodOverride = require("method-override"); // @backend
|
|
15
|
+
const lib_2 = require("ng2-rest/lib");
|
|
33
16
|
const rxjs_1 = require("rxjs");
|
|
17
|
+
const lib_3 = require("taon-typeorm/lib"); // @websql
|
|
18
|
+
const lib_4 = require("taon-typeorm/lib"); // @websql
|
|
19
|
+
const lib_5 = require("taon-typeorm/lib");
|
|
20
|
+
const lib_6 = require("tnp-core/lib"); // @backend
|
|
21
|
+
const lib_7 = require("tnp-core/lib");
|
|
22
|
+
const lib_8 = require("tnp-core/lib");
|
|
23
|
+
const lib_9 = require("tnp-core/lib");
|
|
24
|
+
const context_db_migrations_1 = require("./context-db-migrations");
|
|
25
|
+
const di_container_1 = require("./dependency-injection/di-container");
|
|
34
26
|
const entity_process_1 = require("./entity-process");
|
|
35
|
-
const get_response_value_1 = require("./get-response-value");
|
|
36
|
-
const axios_1 = require("axios");
|
|
37
|
-
const lib_9 = require("taon-typeorm/lib");
|
|
38
27
|
const env_1 = require("./env");
|
|
28
|
+
const get_response_value_1 = require("./get-response-value");
|
|
29
|
+
const class_helpers_1 = require("./helpers/class-helpers");
|
|
30
|
+
const taon_helpers_1 = require("./helpers/taon-helpers");
|
|
31
|
+
const models_1 = require("./models");
|
|
39
32
|
const realtime_core_1 = require("./realtime/realtime-core");
|
|
40
|
-
const
|
|
33
|
+
const symbols_1 = require("./symbols");
|
|
34
|
+
/* */
|
|
41
35
|
//#endregion
|
|
42
36
|
class EndpointContext {
|
|
43
37
|
originalConfig;
|
|
@@ -45,10 +39,12 @@ class EndpointContext {
|
|
|
45
39
|
//#region static
|
|
46
40
|
/* */
|
|
47
41
|
/* */
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
/* */
|
|
43
|
+
/* */
|
|
44
|
+
/* */
|
|
45
|
+
/* */
|
|
46
|
+
/* */
|
|
47
|
+
/* */
|
|
52
48
|
// public static findForTraget(classFnOrObject: any): EndpointContext {
|
|
53
49
|
// const obj = ClassHelpers.getClassFnFromObject(classFnOrObject) || {};
|
|
54
50
|
// return (
|
|
@@ -84,6 +80,11 @@ class EndpointContext {
|
|
|
84
80
|
//#region fields / active routes
|
|
85
81
|
activeRoutes = [];
|
|
86
82
|
//#endregion
|
|
83
|
+
//#region fields / typeorm repositories
|
|
84
|
+
//#region @websql
|
|
85
|
+
repos = new Map();
|
|
86
|
+
//#endregion
|
|
87
|
+
//#endregion
|
|
87
88
|
skipWritingServerRoutes = false;
|
|
88
89
|
//#region fields / types from contexts
|
|
89
90
|
injectableTypesfromContexts = [
|
|
@@ -144,31 +145,31 @@ class EndpointContext {
|
|
|
144
145
|
//#endregion
|
|
145
146
|
//#region fields / logs
|
|
146
147
|
get logHttp() {
|
|
147
|
-
if (
|
|
148
|
+
if (lib_9._.isObject(this.config?.logs)) {
|
|
148
149
|
return !!this.config.logs.http;
|
|
149
150
|
}
|
|
150
151
|
return this.config?.logs === true;
|
|
151
152
|
}
|
|
152
153
|
get logRealtime() {
|
|
153
|
-
if (
|
|
154
|
+
if (lib_9._.isObject(this.config?.logs)) {
|
|
154
155
|
return !!this.config.logs.realtime;
|
|
155
156
|
}
|
|
156
157
|
return this.config?.logs === true;
|
|
157
158
|
}
|
|
158
159
|
get logFramework() {
|
|
159
|
-
if (
|
|
160
|
+
if (lib_9._.isObject(this.config?.logs)) {
|
|
160
161
|
return !!this.config.logs.framework;
|
|
161
162
|
}
|
|
162
163
|
return this.config?.logs === true;
|
|
163
164
|
}
|
|
164
165
|
get logDb() {
|
|
165
|
-
if (
|
|
166
|
+
if (lib_9._.isObject(this.config?.logs)) {
|
|
166
167
|
return !!this.config.logs.db;
|
|
167
168
|
}
|
|
168
169
|
return this.config?.logs === true;
|
|
169
170
|
}
|
|
170
171
|
get logMigrations() {
|
|
171
|
-
if (
|
|
172
|
+
if (lib_9._.isObject(this.config?.logs)) {
|
|
172
173
|
return !!this.config.logs.migrations;
|
|
173
174
|
}
|
|
174
175
|
return this.config?.logs === true;
|
|
@@ -190,16 +191,16 @@ class EndpointContext {
|
|
|
190
191
|
// @ts-ignore
|
|
191
192
|
this.onlyMigrationRevertToTimestamp = onlyMigrationRevertToTimestamp;
|
|
192
193
|
this.config = this.configFn(env_1.ENV);
|
|
193
|
-
if (
|
|
194
|
+
if (lib_9._.isObject(this.config.database)) {
|
|
194
195
|
this.config.database = models_1.Models.DatabaseConfig.from(this.config.database).databaseConfigTypeORM;
|
|
195
196
|
}
|
|
196
197
|
if (overrideHost && overrideRemoteHost) {
|
|
197
|
-
|
|
198
|
+
lib_9.Helpers.throw(`[taon-config] You can't have overrideHost and overrideRemoteHost at the same time`);
|
|
198
199
|
}
|
|
199
|
-
this.config.host = !
|
|
200
|
+
this.config.host = !lib_9._.isUndefined(overrideHost)
|
|
200
201
|
? overrideHost
|
|
201
202
|
: this.config.host;
|
|
202
|
-
this.config.remoteHost = !
|
|
203
|
+
this.config.remoteHost = !lib_9._.isUndefined(overrideRemoteHost)
|
|
203
204
|
? overrideRemoteHost
|
|
204
205
|
: this.config.remoteHost;
|
|
205
206
|
this.config.host = this.host === null ? void 0 : this.host;
|
|
@@ -208,19 +209,19 @@ class EndpointContext {
|
|
|
208
209
|
if (this.config.host &&
|
|
209
210
|
!this.config.host.startsWith('http://') &&
|
|
210
211
|
!this.config.host.startsWith('https://')) {
|
|
211
|
-
|
|
212
|
+
lib_9.Helpers.throw(`[taon-config] Your 'host' must start with http:// or https://`);
|
|
212
213
|
}
|
|
213
|
-
if (
|
|
214
|
+
if (lib_9._.isUndefined(this.config.useIpcWhenElectron)) {
|
|
214
215
|
this.config.useIpcWhenElectron = true;
|
|
215
216
|
}
|
|
216
217
|
if (this.config.remoteHost &&
|
|
217
218
|
!this.config.remoteHost.startsWith('http://') &&
|
|
218
219
|
!this.config.remoteHost.startsWith('https://')) {
|
|
219
|
-
|
|
220
|
+
lib_9.Helpers.throw(`[taon-config] Your 'remoteHost' must start with http:// or https://`);
|
|
220
221
|
}
|
|
221
222
|
//#region resolve if skipping writing server routes
|
|
222
223
|
//@ts-expect-error overriding readonly
|
|
223
|
-
this.skipWritingServerRoutes =
|
|
224
|
+
this.skipWritingServerRoutes = lib_9._.isBoolean(this.config.skipWritingServerRoutes)
|
|
224
225
|
? this.config.skipWritingServerRoutes
|
|
225
226
|
: false;
|
|
226
227
|
//#endregion
|
|
@@ -232,12 +233,12 @@ class EndpointContext {
|
|
|
232
233
|
}
|
|
233
234
|
if (this.config.remoteHost) {
|
|
234
235
|
if (this.config.host) {
|
|
235
|
-
|
|
236
|
+
lib_9.Helpers.throw(`[taon] You can't have remoteHost and host at the same time`);
|
|
236
237
|
}
|
|
237
238
|
this.mode = 'remote-backend(tcp+udp)';
|
|
238
239
|
}
|
|
239
|
-
if (this.config.useIpcWhenElectron &&
|
|
240
|
-
if (
|
|
240
|
+
if (this.config.useIpcWhenElectron && lib_9.Helpers.isElectron) {
|
|
241
|
+
if (lib_9.Helpers.isWebSQL) {
|
|
241
242
|
this.mode = 'backend-frontend(websql-electron)';
|
|
242
243
|
}
|
|
243
244
|
else {
|
|
@@ -245,7 +246,7 @@ class EndpointContext {
|
|
|
245
246
|
}
|
|
246
247
|
}
|
|
247
248
|
if (!this.mode && !this.config.abstract) {
|
|
248
|
-
|
|
249
|
+
lib_9.Helpers.error(`[taon] Context "${this.contextName}": You need to provide host or remoteHost or useIpcWhenElectron`, false, true);
|
|
249
250
|
//#region @backend
|
|
250
251
|
process.exit(1);
|
|
251
252
|
//#endregion
|
|
@@ -255,13 +256,13 @@ class EndpointContext {
|
|
|
255
256
|
if (this.config.database === true) {
|
|
256
257
|
this.databaseConfig = this.getAutoGeneratedConfig();
|
|
257
258
|
}
|
|
258
|
-
else if (
|
|
259
|
-
this.databaseConfig =
|
|
259
|
+
else if (lib_9._.isObject(this.config.database)) {
|
|
260
|
+
this.databaseConfig = lib_9._.merge(this.getAutoGeneratedConfig(), lib_9._.cloneDeep(this.config.database));
|
|
260
261
|
}
|
|
261
262
|
//#endregion
|
|
262
263
|
//#region resolve session
|
|
263
264
|
if (this.config.session) {
|
|
264
|
-
this.session =
|
|
265
|
+
this.session = lib_9._.cloneDeep(this.config.session);
|
|
265
266
|
const oneHour = 1000 * 60 * 60 * 1; // 24;
|
|
266
267
|
if (!this.session.cookieMaxAge) {
|
|
267
268
|
this.session.cookieMaxAge = oneHour;
|
|
@@ -353,11 +354,11 @@ class EndpointContext {
|
|
|
353
354
|
this.expressApp = express();
|
|
354
355
|
this.initMiddlewares();
|
|
355
356
|
this.serverTcpUdp = this.isHttpServer
|
|
356
|
-
? new
|
|
357
|
+
? new lib_6.https.Server({
|
|
357
358
|
key: this.config.https?.key,
|
|
358
359
|
cert: this.config.https?.cert,
|
|
359
360
|
}, this.expressApp)
|
|
360
|
-
: new
|
|
361
|
+
: new lib_6.http.Server(this.expressApp);
|
|
361
362
|
this.publicAssets.forEach(asset => {
|
|
362
363
|
this.expressApp.use(asset.serverPath, express.static(asset.locationOnDisk));
|
|
363
364
|
});
|
|
@@ -368,7 +369,7 @@ class EndpointContext {
|
|
|
368
369
|
if (!this.config.abstract) {
|
|
369
370
|
this.disabledRealtime = !!this.config.disabledRealtime;
|
|
370
371
|
//#region @backend
|
|
371
|
-
if (
|
|
372
|
+
if (lib_9.Helpers.isRunningIn.cliMode()) {
|
|
372
373
|
// TODO for now...
|
|
373
374
|
this.disabledRealtime = true;
|
|
374
375
|
}
|
|
@@ -381,16 +382,16 @@ class EndpointContext {
|
|
|
381
382
|
// console.log({ ref })
|
|
382
383
|
if (this.config.abstract) {
|
|
383
384
|
this.logFramework &&
|
|
384
|
-
|
|
385
|
+
lib_9.Helpers.info(`[taon] Create abstract context: ${this.config.contextName}`);
|
|
385
386
|
}
|
|
386
387
|
else {
|
|
387
388
|
if (this.config.remoteHost) {
|
|
388
389
|
this.logFramework &&
|
|
389
|
-
|
|
390
|
+
lib_9.Helpers.info(`[taon] Create context for remote host: ${this.config.remoteHost}`);
|
|
390
391
|
}
|
|
391
392
|
else {
|
|
392
393
|
this.logFramework &&
|
|
393
|
-
|
|
394
|
+
lib_9.Helpers.info(`[taon] Create context for host: ${this.config.host}`);
|
|
394
395
|
}
|
|
395
396
|
}
|
|
396
397
|
//#endregion
|
|
@@ -404,8 +405,8 @@ class EndpointContext {
|
|
|
404
405
|
getAutoGeneratedConfig() {
|
|
405
406
|
//#region @websqlFunc
|
|
406
407
|
let databaseConfig = models_1.Models.DatabaseConfig.from({});
|
|
407
|
-
if (
|
|
408
|
-
|
|
408
|
+
if (lib_7.UtilsOs.isRunningInDocker()) {
|
|
409
|
+
lib_9.Helpers.info('Running in docker, using in mysql database');
|
|
409
410
|
// TODO auto resolve database config in docker
|
|
410
411
|
databaseConfig = models_1.Models.DatabaseConfig.from({
|
|
411
412
|
database: `db-${this.contextName}.sqlite`,
|
|
@@ -420,7 +421,7 @@ class EndpointContext {
|
|
|
420
421
|
}
|
|
421
422
|
else {
|
|
422
423
|
this.logFramework &&
|
|
423
|
-
|
|
424
|
+
lib_9.Helpers.info(`[taon][database] Automatically resolving database config for mode ${this.mode}`);
|
|
424
425
|
switch (this.mode) {
|
|
425
426
|
//#region resolve database config for mode backend-frontend(tcp+udp)
|
|
426
427
|
case 'backend-frontend(ipc-electron)':
|
|
@@ -475,23 +476,26 @@ class EndpointContext {
|
|
|
475
476
|
}
|
|
476
477
|
//#endregion
|
|
477
478
|
//#region methods & getters / start server
|
|
478
|
-
startServer() {
|
|
479
|
+
async startServer() {
|
|
479
480
|
//#region @backendFunc
|
|
480
481
|
if (this.remoteHost || this.isRunOrRevertOnlyMigrationAppStart) {
|
|
481
482
|
return;
|
|
482
483
|
}
|
|
483
484
|
if (this.mode === 'backend-frontend(tcp+udp)') {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
485
|
+
return await new Promise(resolve => {
|
|
486
|
+
// this.displayRoutes(this.expressApp);
|
|
487
|
+
this.serverTcpUdp.listen(Number(this.uri.port), () => {
|
|
488
|
+
lib_9.Helpers.log(`[taon][express-server]listening on port: ${this.uri.port}, hostname: ${this.uri.pathname},
|
|
487
489
|
address: ${this.uri.protocol}//localhost:${this.uri.port}${this.uri.pathname}
|
|
488
490
|
env: ${this.expressApp.settings.env}
|
|
489
491
|
`);
|
|
492
|
+
resolve(void 0);
|
|
493
|
+
});
|
|
490
494
|
});
|
|
491
495
|
}
|
|
492
496
|
else {
|
|
493
497
|
this.logFramework &&
|
|
494
|
-
|
|
498
|
+
lib_9.Helpers.info('Ipc communication enable instead tcp/upd');
|
|
495
499
|
}
|
|
496
500
|
//#endregion
|
|
497
501
|
}
|
|
@@ -536,7 +540,6 @@ class EndpointContext {
|
|
|
536
540
|
}
|
|
537
541
|
//#endregion
|
|
538
542
|
//#region methods & getters / clone class
|
|
539
|
-
// eslint-disable-next-line @typescript-eslint/typedef
|
|
540
543
|
cloneClassWithNewMetadata = ({ BaseClass, className, config, ctx, classType, }) => {
|
|
541
544
|
// Return a new class that extends the base class
|
|
542
545
|
const cloneClass = () => {
|
|
@@ -546,18 +549,14 @@ class EndpointContext {
|
|
|
546
549
|
}
|
|
547
550
|
return class extends BaseClass {
|
|
548
551
|
// static ['_'] = BaseClass['_'];
|
|
549
|
-
// eslint-disable-next-line @typescript-eslint/typedef
|
|
550
552
|
// @ts-ignore
|
|
551
553
|
static [symbols_1.Symbols.orignalClass] = BaseClass;
|
|
552
|
-
// eslint-disable-next-line @typescript-eslint/typedef
|
|
553
554
|
// @ts-ignore
|
|
554
555
|
static [symbols_1.Symbols.fullClassNameStaticProperty] = `${ctx.contextName}.${className}`;
|
|
555
|
-
// eslint-disable-next-line @typescript-eslint/typedef
|
|
556
556
|
// @ts-ignore
|
|
557
557
|
static [symbols_1.Symbols.classNameStaticProperty] = className;
|
|
558
|
-
// eslint-disable-next-line @typescript-eslint/typedef
|
|
559
558
|
static [symbols_1.Symbols.ctxInClassOrClassObj] = ctx;
|
|
560
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
559
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
561
560
|
static __getFullPathForClass__(arr = []) {
|
|
562
561
|
const name = this[symbols_1.Symbols.fullClassNameStaticProperty];
|
|
563
562
|
arr.push(name);
|
|
@@ -604,7 +603,7 @@ class EndpointContext {
|
|
|
604
603
|
for (const key of Object.keys(classesInput || {})) {
|
|
605
604
|
const BaseClass = classesInput[key];
|
|
606
605
|
if (!BaseClass) {
|
|
607
|
-
|
|
606
|
+
lib_9.Helpers.error(`Class ${key} is not defined in context ${ctx.contextName}
|
|
608
607
|
|
|
609
608
|
Please check if you have correct import in context file
|
|
610
609
|
|
|
@@ -673,9 +672,6 @@ class EndpointContext {
|
|
|
673
672
|
//#endregion
|
|
674
673
|
//#region methods & getters / inject
|
|
675
674
|
inject(ctor, options) {
|
|
676
|
-
if (!options) {
|
|
677
|
-
options = {};
|
|
678
|
-
}
|
|
679
675
|
const className = class_helpers_1.ClassHelpers.getName(ctor);
|
|
680
676
|
const locaInstanceConstructorArgs = options.locaInstanceConstructorArgs || [];
|
|
681
677
|
if (this.isCLassType(models_1.Models.ClassType.REPOSITORY, ctor)) {
|
|
@@ -684,20 +680,27 @@ class EndpointContext {
|
|
|
684
680
|
if (options?.localInstance) {
|
|
685
681
|
const ctxClassFn = this.getClassFunByClassName(className);
|
|
686
682
|
let entityName = '';
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
683
|
+
// entity thing is only for repositories local repositories
|
|
684
|
+
// if (className === 'BaseRepository') {
|
|
685
|
+
const entityFn = lib_9._.first(locaInstanceConstructorArgs);
|
|
686
|
+
const entity = entityFn && entityFn();
|
|
687
|
+
entityName = (entity && class_helpers_1.ClassHelpers.getName(entity)) || '';
|
|
688
|
+
// console.log(`entityName `, entityName);
|
|
689
|
+
// }
|
|
692
690
|
if (!options.contextClassInstance[this.localInstaceObjSymbol]) {
|
|
693
691
|
options.contextClassInstance[this.localInstaceObjSymbol] = {};
|
|
694
692
|
}
|
|
695
693
|
const instanceKey = className + (entityName ? `.${entityName}` : '');
|
|
696
694
|
const existed = options.contextClassInstance[this.localInstaceObjSymbol][instanceKey];
|
|
697
695
|
if (existed) {
|
|
698
|
-
// console.log(
|
|
696
|
+
// console.log(
|
|
697
|
+
// `EXISTED ${ClassHelpers.getName(options.parentInstanceThatWillGetInjectedStuff)} Inject ${className} instanceKey "${instanceKey}"`,
|
|
698
|
+
// );
|
|
699
699
|
return existed;
|
|
700
700
|
}
|
|
701
|
+
// console.log(
|
|
702
|
+
// `NEW ${ClassHelpers.getName(options.parentInstanceThatWillGetInjectedStuff)} Inject ${className} instanceKey "${instanceKey}"`,
|
|
703
|
+
// );
|
|
701
704
|
if (!ctxClassFn) {
|
|
702
705
|
throw new Error(`Not able to inject "${className}" inside context "${this.contextName}"
|
|
703
706
|
|
|
@@ -734,12 +737,15 @@ class EndpointContext {
|
|
|
734
737
|
// }
|
|
735
738
|
// }
|
|
736
739
|
// }
|
|
737
|
-
return this.inject(ctor, {
|
|
740
|
+
return this.inject(ctor, {
|
|
741
|
+
localInstance: false,
|
|
742
|
+
parentInstanceThatWillGetInjectedStuff: this,
|
|
743
|
+
});
|
|
738
744
|
}
|
|
739
745
|
//#endregion
|
|
740
746
|
//#region methods & getters / check if context initialized
|
|
741
747
|
checkIfContextInitialized() {
|
|
742
|
-
if (
|
|
748
|
+
if (lib_9._.isUndefined(this.config)) {
|
|
743
749
|
throw new Error(`Please check if your context has been initialized.
|
|
744
750
|
|
|
745
751
|
// ...
|
|
@@ -825,11 +831,8 @@ class EndpointContext {
|
|
|
825
831
|
const controllers = this.getClassesInstancesArrBy(models_1.Models.ClassType.CONTROLLER);
|
|
826
832
|
// console.log('CONTROLLERS TO REINIT', controllers);
|
|
827
833
|
for (const ctrl of controllers) {
|
|
828
|
-
if (
|
|
829
|
-
await
|
|
830
|
-
functionFn: ctrl.initExampleDbData,
|
|
831
|
-
context: ctrl,
|
|
832
|
-
});
|
|
834
|
+
if (lib_9._.isFunction(ctrl.initExampleDbData)) {
|
|
835
|
+
await ctrl.initExampleDbData();
|
|
833
836
|
}
|
|
834
837
|
}
|
|
835
838
|
// Helpers.taskDone(
|
|
@@ -840,6 +843,12 @@ class EndpointContext {
|
|
|
840
843
|
if (this.remoteHost) {
|
|
841
844
|
return;
|
|
842
845
|
}
|
|
846
|
+
//#region @websql
|
|
847
|
+
for (const classFun of this.getClassFunByArr(models_1.Models.ClassType.ENTITY)) {
|
|
848
|
+
const repo = (await this.connection.getRepository(class_helpers_1.ClassHelpers.getOrginalClass(classFun)));
|
|
849
|
+
this.repos.set(class_helpers_1.ClassHelpers.getName(classFun), repo);
|
|
850
|
+
}
|
|
851
|
+
//#endregion
|
|
843
852
|
for (const classTypeName of [
|
|
844
853
|
models_1.Models.ClassType.PROVIDER,
|
|
845
854
|
models_1.Models.ClassType.REPOSITORY,
|
|
@@ -848,26 +857,11 @@ class EndpointContext {
|
|
|
848
857
|
models_1.Models.ClassType.MIGRATION,
|
|
849
858
|
]) {
|
|
850
859
|
//#region init class static _ property
|
|
851
|
-
// Helpers.taskStarted(
|
|
852
|
-
// `[taon] REINITING _ CLASS FN ${classTypeName} ${this.contextName} STARTED`,
|
|
853
|
-
// );
|
|
854
860
|
for (const classFun of this.getClassFunByArr(classTypeName)) {
|
|
855
|
-
if (
|
|
856
|
-
await
|
|
857
|
-
functionFn: classFun._,
|
|
858
|
-
context: classFun,
|
|
859
|
-
});
|
|
860
|
-
// const orgClass = ClassHelpers.getOrginalClass(classFun);
|
|
861
|
-
// // orgClass['ctrl'] = classFun['ctrl'];
|
|
862
|
-
// await Helpers.runSyncOrAsync({
|
|
863
|
-
// functionFn: orgClass._,
|
|
864
|
-
// context: orgClass,
|
|
865
|
-
// });
|
|
861
|
+
if (lib_9._.isFunction(classFun._)) {
|
|
862
|
+
await classFun._();
|
|
866
863
|
}
|
|
867
864
|
}
|
|
868
|
-
// Helpers.taskStarted(
|
|
869
|
-
// `[taon] REINITING _ CLASS FN ${classTypeName} ${this.contextName} DONE`,
|
|
870
|
-
// );
|
|
871
865
|
//#endregion
|
|
872
866
|
}
|
|
873
867
|
for (const classTypeName of [
|
|
@@ -881,11 +875,8 @@ class EndpointContext {
|
|
|
881
875
|
// `[taon] REINITING _ INS FN ${classTypeName} ${this.contextName} STARTED`,
|
|
882
876
|
// );
|
|
883
877
|
for (const ctrl of this.getClassesInstancesArrBy(classTypeName)) {
|
|
884
|
-
if (
|
|
885
|
-
await
|
|
886
|
-
functionFn: ctrl._,
|
|
887
|
-
context: ctrl,
|
|
888
|
-
});
|
|
878
|
+
if (lib_9._.isFunction(ctrl._)) {
|
|
879
|
+
await ctrl._();
|
|
889
880
|
}
|
|
890
881
|
}
|
|
891
882
|
// Helpers.taskStarted(
|
|
@@ -967,7 +958,7 @@ class EndpointContext {
|
|
|
967
958
|
const options = Reflect.getMetadata(symbols_1.Symbols.metadata.options.subscriber, subscriberClassFn);
|
|
968
959
|
// console.log('subscriber options', options);
|
|
969
960
|
// const nameForSubscriber = ClassHelpers.getName(subscriber);
|
|
970
|
-
(0,
|
|
961
|
+
(0, lib_3.EventSubscriber)()(subscriberClassFn);
|
|
971
962
|
}
|
|
972
963
|
//#endregion
|
|
973
964
|
}
|
|
@@ -981,15 +972,15 @@ class EndpointContext {
|
|
|
981
972
|
const entities = this.getClassFunByArr(models_1.Models.ClassType.ENTITY);
|
|
982
973
|
for (const entity of entities) {
|
|
983
974
|
const options = Reflect.getMetadata(symbols_1.Symbols.metadata.options.entity, entity);
|
|
984
|
-
const createTable =
|
|
975
|
+
const createTable = lib_9._.isUndefined(options.createTable)
|
|
985
976
|
? true
|
|
986
977
|
: options.createTable;
|
|
987
978
|
const nameForEntity = class_helpers_1.ClassHelpers.getName(entity);
|
|
988
|
-
if (
|
|
979
|
+
if (createTable) {
|
|
989
980
|
this.logDb &&
|
|
990
981
|
console.info(`[taon][typeorm] create table for entity "${nameForEntity}" ? '${createTable}'`);
|
|
991
982
|
// console.log('TypeormEntity', { TypeormEntity });
|
|
992
|
-
(0,
|
|
983
|
+
(0, lib_4.Entity)(nameForEntity)(entity);
|
|
993
984
|
}
|
|
994
985
|
else {
|
|
995
986
|
this.logDb &&
|
|
@@ -1028,7 +1019,7 @@ class EndpointContext {
|
|
|
1028
1019
|
return class_helpers_1.ClassHelpers.getOrginalClass(entityFn);
|
|
1029
1020
|
});
|
|
1030
1021
|
const subscribers = this.getClassFunByArr(models_1.Models.ClassType.SUBSCRIBER);
|
|
1031
|
-
const dataSourceDbConfig =
|
|
1022
|
+
const dataSourceDbConfig = lib_9._.isObject(this.databaseConfig)
|
|
1032
1023
|
? {
|
|
1033
1024
|
type: this.databaseConfig.type,
|
|
1034
1025
|
port: this.databaseConfig.databasePort,
|
|
@@ -1043,9 +1034,9 @@ class EndpointContext {
|
|
|
1043
1034
|
synchronize: this.isRunOrRevertOnlyMigrationAppStart
|
|
1044
1035
|
? false
|
|
1045
1036
|
: this.databaseConfig.synchronize,
|
|
1046
|
-
autoSave: !
|
|
1037
|
+
autoSave: !lib_9._.isNil(this.databaseConfig.autoSave)
|
|
1047
1038
|
? this.databaseConfig.autoSave
|
|
1048
|
-
: !
|
|
1039
|
+
: !lib_7.UtilsOs.isRunningInDocker(), // in docker I am using mysql or posgress
|
|
1049
1040
|
dropSchema: this.isRunOrRevertOnlyMigrationAppStart
|
|
1050
1041
|
? false
|
|
1051
1042
|
: this.databaseConfig.dropSchema,
|
|
@@ -1059,9 +1050,9 @@ class EndpointContext {
|
|
|
1059
1050
|
if (this.modeAllowsDatabaseCreation && this.databaseConfig) {
|
|
1060
1051
|
this.logDb &&
|
|
1061
1052
|
this.logFramework &&
|
|
1062
|
-
|
|
1053
|
+
lib_9.Helpers.info('[taon][database] prepare typeorm connection...');
|
|
1063
1054
|
try {
|
|
1064
|
-
const connection = new
|
|
1055
|
+
const connection = new lib_5.DataSource(dataSourceDbConfig);
|
|
1065
1056
|
this.connection = connection;
|
|
1066
1057
|
await this.connection.initialize();
|
|
1067
1058
|
}
|
|
@@ -1096,7 +1087,7 @@ class EndpointContext {
|
|
|
1096
1087
|
// debugger;
|
|
1097
1088
|
}
|
|
1098
1089
|
else {
|
|
1099
|
-
|
|
1090
|
+
lib_9.Helpers.info(`[taon][typeorm] Not initing db for mode ${this.mode}`);
|
|
1100
1091
|
}
|
|
1101
1092
|
//#endregion
|
|
1102
1093
|
}
|
|
@@ -1114,7 +1105,7 @@ class EndpointContext {
|
|
|
1114
1105
|
const configs = class_helpers_1.ClassHelpers.getControllerConfigs(controllerClassFn);
|
|
1115
1106
|
// console.log(`Class config for ${ClassHelpers.getName(controllerClassFn)}`, configs)
|
|
1116
1107
|
const classConfig = configs[0];
|
|
1117
|
-
const parentscalculatedPath =
|
|
1108
|
+
const parentscalculatedPath = lib_9._.slice(configs, 1)
|
|
1118
1109
|
.reverse()
|
|
1119
1110
|
.map(bc => {
|
|
1120
1111
|
if (taon_helpers_1.TaonHelpers.isGoodPath(bc.path)) {
|
|
@@ -1132,13 +1123,13 @@ class EndpointContext {
|
|
|
1132
1123
|
.replace(/\/\//g, '/')
|
|
1133
1124
|
.split('/')
|
|
1134
1125
|
.reduce((acc, bc) => {
|
|
1135
|
-
return
|
|
1126
|
+
return lib_9._.last(acc) === bc ? acc : [...acc, bc];
|
|
1136
1127
|
}, [])
|
|
1137
1128
|
.join('/');
|
|
1138
1129
|
}
|
|
1139
|
-
|
|
1130
|
+
lib_9._.slice(configs, 1).forEach(bc => {
|
|
1140
1131
|
const alreadyIs = classConfig.methods;
|
|
1141
|
-
const toMerge =
|
|
1132
|
+
const toMerge = lib_9._.cloneDeep(bc.methods);
|
|
1142
1133
|
for (const key in toMerge) {
|
|
1143
1134
|
if (toMerge.hasOwnProperty(key) && !alreadyIs[key]) {
|
|
1144
1135
|
const element = toMerge[key];
|
|
@@ -1147,7 +1138,7 @@ class EndpointContext {
|
|
|
1147
1138
|
}
|
|
1148
1139
|
});
|
|
1149
1140
|
//#region @backend
|
|
1150
|
-
if (!
|
|
1141
|
+
if (!lib_9.Helpers.isRunningIn.cliMode()) {
|
|
1151
1142
|
//#endregion
|
|
1152
1143
|
this.logHttp &&
|
|
1153
1144
|
console.groupCollapsed(`[taon][express-server] routes [${classConfig.className}]`);
|
|
@@ -1163,7 +1154,7 @@ class EndpointContext {
|
|
|
1163
1154
|
? `/${methodConfig.path?.replace(/\//, '')}`
|
|
1164
1155
|
: taon_helpers_1.TaonHelpers.getExpressPath(classConfig, methodConfig);
|
|
1165
1156
|
// console.log({ expressPath })
|
|
1166
|
-
if (
|
|
1157
|
+
if (lib_9.Helpers.isNode || lib_9.Helpers.isWebSQL) {
|
|
1167
1158
|
//#region @websql
|
|
1168
1159
|
const { routePath, method } = this.initServer(type, methodConfig, classConfig, expressPath, controllerClassFn);
|
|
1169
1160
|
this.activeRoutes.push({
|
|
@@ -1172,7 +1163,7 @@ class EndpointContext {
|
|
|
1172
1163
|
});
|
|
1173
1164
|
//#endregion
|
|
1174
1165
|
}
|
|
1175
|
-
const shouldInitClient =
|
|
1166
|
+
const shouldInitClient = lib_9.Helpers.isBrowser || this.remoteHost || lib_9.Helpers.isWebSQL;
|
|
1176
1167
|
// console.log('shouldInitClient', shouldInitClient);
|
|
1177
1168
|
if (shouldInitClient) {
|
|
1178
1169
|
// console.log(
|
|
@@ -1186,7 +1177,7 @@ class EndpointContext {
|
|
|
1186
1177
|
}
|
|
1187
1178
|
});
|
|
1188
1179
|
//#region @backend
|
|
1189
|
-
if (!
|
|
1180
|
+
if (!lib_9.Helpers.isRunningIn.cliMode()) {
|
|
1190
1181
|
//#endregion
|
|
1191
1182
|
this.logHttp && console.groupEnd();
|
|
1192
1183
|
//#region @backend
|
|
@@ -1204,11 +1195,11 @@ class EndpointContext {
|
|
|
1204
1195
|
}
|
|
1205
1196
|
const contexts = [this];
|
|
1206
1197
|
//#region @websql
|
|
1207
|
-
const troutes =
|
|
1198
|
+
const troutes = lib_7.Utils.uniqArray(this.activeRoutes.map(f => {
|
|
1208
1199
|
return `${f.method} ${f.routePath}`;
|
|
1209
1200
|
})).map(f => {
|
|
1210
1201
|
const [method, routePath] = f.split(' ');
|
|
1211
|
-
return (`\n### ${
|
|
1202
|
+
return (`\n### ${lib_9._.startCase(lib_9._.last(routePath.split('/')))}\n` +
|
|
1212
1203
|
taon_helpers_1.TaonHelpers.fillUpTo(method.toUpperCase() + ' ', 10) +
|
|
1213
1204
|
this.uri.href.replace(/\/$/, '') +
|
|
1214
1205
|
routePath);
|
|
@@ -1219,7 +1210,7 @@ class EndpointContext {
|
|
|
1219
1210
|
...['', `# ROUTES FOR HOST ${this.uri.href} `],
|
|
1220
1211
|
...troutes,
|
|
1221
1212
|
].join('\n');
|
|
1222
|
-
const fileName = (0,
|
|
1213
|
+
const fileName = (0, lib_8.crossPlatformPath)([
|
|
1223
1214
|
//#region @backend
|
|
1224
1215
|
process.cwd(),
|
|
1225
1216
|
//#endregion
|
|
@@ -1228,7 +1219,7 @@ class EndpointContext {
|
|
|
1228
1219
|
this.logFramework && console.log(`[taon] routes file: ${fileName} `);
|
|
1229
1220
|
// Helpers.log(JSON.stringify(routes, null, 4))
|
|
1230
1221
|
//#region @backend
|
|
1231
|
-
|
|
1222
|
+
lib_9.Helpers.writeFile(fileName, routes);
|
|
1232
1223
|
//#endregion
|
|
1233
1224
|
//#endregion
|
|
1234
1225
|
}
|
|
@@ -1259,7 +1250,7 @@ class EndpointContext {
|
|
|
1259
1250
|
app.use(methodOverride());
|
|
1260
1251
|
app.use(cookieParser());
|
|
1261
1252
|
if (this.session) {
|
|
1262
|
-
|
|
1253
|
+
lib_9.Helpers.info('[taon][express-server] session enabled for this context ' +
|
|
1263
1254
|
this.contextName);
|
|
1264
1255
|
const { cookieMaxAge } = this.session;
|
|
1265
1256
|
const frontendHost = this.config.frontendHost;
|
|
@@ -1285,7 +1276,7 @@ class EndpointContext {
|
|
|
1285
1276
|
else {
|
|
1286
1277
|
// if(this.config?.serverLogs) {
|
|
1287
1278
|
this.logHttp &&
|
|
1288
|
-
|
|
1279
|
+
lib_9.Helpers.info(`[taon][express-server] session not enabled for this context '${this.contextName}'`);
|
|
1289
1280
|
// }
|
|
1290
1281
|
app.use(cors({
|
|
1291
1282
|
// origin: "http://localhost:5555",
|
|
@@ -1366,10 +1357,10 @@ class EndpointContext {
|
|
|
1366
1357
|
expressPath = expressPath.replace(/\/\//g, '/');
|
|
1367
1358
|
// console.log(`BACKEND: expressPath: ${ expressPath } `)
|
|
1368
1359
|
//#endregion
|
|
1369
|
-
if (
|
|
1360
|
+
if (lib_9.Helpers.isElectron) {
|
|
1370
1361
|
//#region @backend
|
|
1371
1362
|
const ipcKeyName = taon_helpers_1.TaonHelpers.ipcKeyNameRequest(target, methodConfig, expressPath);
|
|
1372
|
-
|
|
1363
|
+
lib_9.Helpers.ipcMain.on(ipcKeyName, async (event, paramsFromBrowser) => {
|
|
1373
1364
|
const responseJsonData = await getResult(paramsFromBrowser, void 0, void 0);
|
|
1374
1365
|
event.sender.send(taon_helpers_1.TaonHelpers.ipcKeyNameResponse(target, methodConfig, expressPath), responseJsonData);
|
|
1375
1366
|
});
|
|
@@ -1382,7 +1373,7 @@ class EndpointContext {
|
|
|
1382
1373
|
if (!this.remoteHost) {
|
|
1383
1374
|
//#region apply dummy websql express routers
|
|
1384
1375
|
//#region @websql
|
|
1385
|
-
if (
|
|
1376
|
+
if (lib_9.Helpers.isWebSQL) {
|
|
1386
1377
|
if (!this.expressApp[type.toLowerCase()]) {
|
|
1387
1378
|
this.expressApp[type.toLowerCase()] = () => { };
|
|
1388
1379
|
}
|
|
@@ -1415,7 +1406,7 @@ class EndpointContext {
|
|
|
1415
1406
|
if (req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS]) {
|
|
1416
1407
|
try {
|
|
1417
1408
|
const entity = JSON.parse(req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS]);
|
|
1418
|
-
tBody =
|
|
1409
|
+
tBody = lib_2.Mapping.encode(tBody, entity);
|
|
1419
1410
|
}
|
|
1420
1411
|
catch (e) { }
|
|
1421
1412
|
}
|
|
@@ -1423,7 +1414,7 @@ class EndpointContext {
|
|
|
1423
1414
|
Object.keys(tBody).forEach(paramName => {
|
|
1424
1415
|
try {
|
|
1425
1416
|
const entityForParam = JSON.parse(req.headers[`${symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS}${paramName} `]);
|
|
1426
|
-
tBody[paramName] =
|
|
1417
|
+
tBody[paramName] = lib_2.Mapping.encode(tBody[paramName], entityForParam);
|
|
1427
1418
|
}
|
|
1428
1419
|
catch (e) { }
|
|
1429
1420
|
});
|
|
@@ -1433,7 +1424,7 @@ class EndpointContext {
|
|
|
1433
1424
|
if (req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS]) {
|
|
1434
1425
|
try {
|
|
1435
1426
|
const entity = JSON.parse(req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS]);
|
|
1436
|
-
tQuery = taon_helpers_1.TaonHelpers.parseJSONwithStringJSONs(
|
|
1427
|
+
tQuery = taon_helpers_1.TaonHelpers.parseJSONwithStringJSONs(lib_2.Mapping.encode(tQuery, entity));
|
|
1437
1428
|
}
|
|
1438
1429
|
catch (e) { }
|
|
1439
1430
|
}
|
|
@@ -1442,14 +1433,14 @@ class EndpointContext {
|
|
|
1442
1433
|
try {
|
|
1443
1434
|
const entityForParam = JSON.parse(req.headers[`${symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS}${queryParamName} `]);
|
|
1444
1435
|
let beforeTransofrm = tQuery[queryParamName];
|
|
1445
|
-
if (
|
|
1436
|
+
if (lib_9._.isString(beforeTransofrm)) {
|
|
1446
1437
|
try {
|
|
1447
1438
|
const paresed = taon_helpers_1.TaonHelpers.tryTransformParam(beforeTransofrm);
|
|
1448
1439
|
beforeTransofrm = paresed;
|
|
1449
1440
|
}
|
|
1450
1441
|
catch (e) { }
|
|
1451
1442
|
}
|
|
1452
|
-
const afterEncoding =
|
|
1443
|
+
const afterEncoding = lib_2.Mapping.encode(beforeTransofrm, entityForParam);
|
|
1453
1444
|
tQuery[queryParamName] =
|
|
1454
1445
|
taon_helpers_1.TaonHelpers.parseJSONwithStringJSONs(afterEncoding);
|
|
1455
1446
|
}
|
|
@@ -1504,7 +1495,7 @@ class EndpointContext {
|
|
|
1504
1495
|
res.end(file);
|
|
1505
1496
|
//#endregion
|
|
1506
1497
|
}
|
|
1507
|
-
else if (
|
|
1498
|
+
else if (lib_9._.isString(result) &&
|
|
1508
1499
|
methodConfig.responseType ===
|
|
1509
1500
|
'blob') {
|
|
1510
1501
|
// console.log('BASE64')
|
|
@@ -1531,8 +1522,8 @@ class EndpointContext {
|
|
|
1531
1522
|
}
|
|
1532
1523
|
catch (error) {
|
|
1533
1524
|
//#region process error
|
|
1534
|
-
if (
|
|
1535
|
-
res.status(400).send(
|
|
1525
|
+
if (lib_9._.isString(error)) {
|
|
1526
|
+
res.status(400).send(lib_1.JSON10.stringify({
|
|
1536
1527
|
message: `
|
|
1537
1528
|
Error inside: ${req.path}
|
|
1538
1529
|
|
|
@@ -1542,22 +1533,22 @@ class EndpointContext {
|
|
|
1542
1533
|
}));
|
|
1543
1534
|
}
|
|
1544
1535
|
else if (error instanceof models_1.Models.Http.Errors) {
|
|
1545
|
-
|
|
1536
|
+
lib_9.Helpers.error(error, true, false);
|
|
1546
1537
|
const err = error;
|
|
1547
|
-
res.status(400).send(
|
|
1538
|
+
res.status(400).send(lib_1.JSON10.stringify(err));
|
|
1548
1539
|
}
|
|
1549
1540
|
else if (error instanceof Error) {
|
|
1550
1541
|
const err = error;
|
|
1551
|
-
|
|
1552
|
-
res.status(400).send(
|
|
1542
|
+
lib_9.Helpers.error(error, true, false);
|
|
1543
|
+
res.status(400).send(lib_1.JSON10.stringify({
|
|
1553
1544
|
stack: err.stack,
|
|
1554
1545
|
message: err.message,
|
|
1555
1546
|
}));
|
|
1556
1547
|
}
|
|
1557
1548
|
else {
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
res.status(400).send(
|
|
1549
|
+
lib_9.Helpers.log(error);
|
|
1550
|
+
lib_9.Helpers.error(`[Taon] Bad result isomorphic method: ${error} `, true, false);
|
|
1551
|
+
res.status(400).send(lib_1.JSON10.stringify(error));
|
|
1561
1552
|
}
|
|
1562
1553
|
//#endregion
|
|
1563
1554
|
}
|
|
@@ -1583,36 +1574,36 @@ class EndpointContext {
|
|
|
1583
1574
|
// console.log('INITING', methodConfig); // TODO inject in static
|
|
1584
1575
|
//#region resolve storage
|
|
1585
1576
|
let storage;
|
|
1586
|
-
if (
|
|
1577
|
+
if (lib_9.Helpers.isBrowser) {
|
|
1587
1578
|
storage = window;
|
|
1588
1579
|
}
|
|
1589
1580
|
//#region @backend
|
|
1590
|
-
if (
|
|
1581
|
+
if (lib_9.Helpers.isNode) {
|
|
1591
1582
|
storage = global;
|
|
1592
1583
|
}
|
|
1593
1584
|
//#endregion
|
|
1594
1585
|
//#endregion
|
|
1595
1586
|
const orgMethods = target.prototype[methodConfig.methodName];
|
|
1596
1587
|
//#region handle electron ipc request
|
|
1597
|
-
if (
|
|
1588
|
+
if (lib_9.Helpers.isElectron) {
|
|
1598
1589
|
target.prototype[methodConfig.methodName] = function (...args) {
|
|
1599
1590
|
const received = new Promise(async (resolve, reject) => {
|
|
1600
1591
|
const headers = {};
|
|
1601
1592
|
const { request, response } = taon_helpers_1.TaonHelpers.websqlMocks(headers);
|
|
1602
|
-
|
|
1593
|
+
lib_9.Helpers.ipcRenderer.once(taon_helpers_1.TaonHelpers.ipcKeyNameResponse(target, methodConfig, expressPath), (event, responseData) => {
|
|
1603
1594
|
let res = responseData;
|
|
1604
1595
|
console.log({ responseData });
|
|
1605
1596
|
try {
|
|
1606
1597
|
const body = res;
|
|
1607
|
-
res = new
|
|
1598
|
+
res = new lib_2.Models.HttpResponse({
|
|
1608
1599
|
body: void 0,
|
|
1609
1600
|
isArray: void 0,
|
|
1610
1601
|
method: methodConfig.type,
|
|
1611
1602
|
url: `${ctx.uri.origin}${'' // TODO express path
|
|
1612
1603
|
}${methodConfig.path} `,
|
|
1613
|
-
},
|
|
1604
|
+
}, lib_9.Helpers.isBlob(body) || lib_9._.isString(body)
|
|
1614
1605
|
? body
|
|
1615
|
-
: JSON.stringify(body),
|
|
1606
|
+
: JSON.stringify(body), lib_2.RestHeaders.from(headers), void 0, () => body);
|
|
1616
1607
|
resolve(res);
|
|
1617
1608
|
}
|
|
1618
1609
|
catch (error) {
|
|
@@ -1620,7 +1611,7 @@ class EndpointContext {
|
|
|
1620
1611
|
reject(error);
|
|
1621
1612
|
}
|
|
1622
1613
|
});
|
|
1623
|
-
|
|
1614
|
+
lib_9.Helpers.ipcRenderer.send(taon_helpers_1.TaonHelpers.ipcKeyNameRequest(target, methodConfig, expressPath), args);
|
|
1624
1615
|
});
|
|
1625
1616
|
received['observable'] = (0, rxjs_1.from)(received);
|
|
1626
1617
|
return {
|
|
@@ -1788,25 +1779,25 @@ class EndpointContext {
|
|
|
1788
1779
|
if (!endpoints[ctx.uri.href][expressPath]) {
|
|
1789
1780
|
let headers = {};
|
|
1790
1781
|
if (methodConfig.contentType && !methodConfig.responseType) {
|
|
1791
|
-
rest =
|
|
1782
|
+
rest = lib_2.Resource.create(ctx.uri.href, expressPath, symbols_1.Symbols.old.MAPPING_CONFIG_HEADER, symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, lib_2.RestHeaders.from({
|
|
1792
1783
|
'Content-Type': methodConfig.contentType,
|
|
1793
1784
|
Accept: methodConfig.contentType,
|
|
1794
1785
|
}));
|
|
1795
1786
|
}
|
|
1796
1787
|
else if (methodConfig.contentType && methodConfig.responseType) {
|
|
1797
|
-
rest =
|
|
1788
|
+
rest = lib_2.Resource.create(ctx.uri.href, expressPath, symbols_1.Symbols.old.MAPPING_CONFIG_HEADER, symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, lib_2.RestHeaders.from({
|
|
1798
1789
|
'Content-Type': methodConfig.contentType,
|
|
1799
1790
|
Accept: methodConfig.contentType,
|
|
1800
1791
|
responsetypeaxios: methodConfig.responseType,
|
|
1801
1792
|
}));
|
|
1802
1793
|
}
|
|
1803
1794
|
else if (!methodConfig.contentType && methodConfig.responseType) {
|
|
1804
|
-
rest =
|
|
1795
|
+
rest = lib_2.Resource.create(ctx.uri.href, expressPath, symbols_1.Symbols.old.MAPPING_CONFIG_HEADER, symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, lib_2.RestHeaders.from({
|
|
1805
1796
|
responsetypeaxios: methodConfig.responseType,
|
|
1806
1797
|
}));
|
|
1807
1798
|
}
|
|
1808
1799
|
else {
|
|
1809
|
-
rest =
|
|
1800
|
+
rest = lib_2.Resource.create(ctx.uri.href, expressPath, symbols_1.Symbols.old.MAPPING_CONFIG_HEADER, symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY);
|
|
1810
1801
|
}
|
|
1811
1802
|
endpoints[ctx.uri.href][expressPath] = rest;
|
|
1812
1803
|
}
|
|
@@ -1832,18 +1823,18 @@ class EndpointContext {
|
|
|
1832
1823
|
}
|
|
1833
1824
|
if (currentParam.paramType === 'Query') {
|
|
1834
1825
|
if (currentParam.paramName) {
|
|
1835
|
-
const mapping =
|
|
1826
|
+
const mapping = lib_2.Mapping.decode(param, !ctx.isProductionMode);
|
|
1836
1827
|
if (mapping) {
|
|
1837
1828
|
rest.headers.set(`${symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
|
|
1838
1829
|
}
|
|
1839
1830
|
queryParams[currentParam.paramName] = param;
|
|
1840
1831
|
}
|
|
1841
1832
|
else {
|
|
1842
|
-
const mapping =
|
|
1833
|
+
const mapping = lib_2.Mapping.decode(param, !ctx.isProductionMode);
|
|
1843
1834
|
if (mapping) {
|
|
1844
1835
|
rest.headers.set(symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS, JSON.stringify(mapping));
|
|
1845
1836
|
}
|
|
1846
|
-
queryParams =
|
|
1837
|
+
queryParams = lib_9._.cloneDeep(param);
|
|
1847
1838
|
}
|
|
1848
1839
|
}
|
|
1849
1840
|
if (currentParam.paramType === 'Header') {
|
|
@@ -1863,7 +1854,7 @@ class EndpointContext {
|
|
|
1863
1854
|
}
|
|
1864
1855
|
}
|
|
1865
1856
|
if (currentParam.paramType === 'Cookie') {
|
|
1866
|
-
|
|
1857
|
+
lib_2.Resource.Cookies.write(currentParam.paramName, param, currentParam.expireInSeconds);
|
|
1867
1858
|
}
|
|
1868
1859
|
if (currentParam.paramType === 'Body') {
|
|
1869
1860
|
if (currentParam.paramName) {
|
|
@@ -1880,14 +1871,14 @@ instead
|
|
|
1880
1871
|
// ...
|
|
1881
1872
|
`);
|
|
1882
1873
|
}
|
|
1883
|
-
const mapping =
|
|
1874
|
+
const mapping = lib_2.Mapping.decode(param, !ctx.isProductionMode);
|
|
1884
1875
|
if (mapping) {
|
|
1885
1876
|
rest.headers.set(`${symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
|
|
1886
1877
|
}
|
|
1887
1878
|
bodyObject[currentParam.paramName] = param;
|
|
1888
1879
|
}
|
|
1889
1880
|
else {
|
|
1890
|
-
const mapping =
|
|
1881
|
+
const mapping = lib_2.Mapping.decode(param, !ctx.isProductionMode);
|
|
1891
1882
|
if (mapping) {
|
|
1892
1883
|
rest.headers.set(symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS, JSON.stringify(mapping));
|
|
1893
1884
|
}
|
|
@@ -1898,17 +1889,17 @@ instead
|
|
|
1898
1889
|
if (typeof bodyObject === 'object' &&
|
|
1899
1890
|
class_helpers_1.ClassHelpers.getName(bodyObject) !== 'FormData') {
|
|
1900
1891
|
let circuralFromItem = [];
|
|
1901
|
-
bodyObject =
|
|
1892
|
+
bodyObject = lib_1.JSON10.parse(lib_1.JSON10.stringify(bodyObject, void 0, void 0, circs => {
|
|
1902
1893
|
circuralFromItem = circs;
|
|
1903
1894
|
}));
|
|
1904
|
-
rest.headers.set(symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY,
|
|
1895
|
+
rest.headers.set(symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, lib_1.JSON10.stringify(circuralFromItem));
|
|
1905
1896
|
}
|
|
1906
1897
|
if (typeof queryParams === 'object') {
|
|
1907
1898
|
let circuralFromQueryParams = [];
|
|
1908
|
-
queryParams =
|
|
1899
|
+
queryParams = lib_1.JSON10.parse(lib_1.JSON10.stringify(queryParams, void 0, void 0, circs => {
|
|
1909
1900
|
circuralFromQueryParams = circs;
|
|
1910
1901
|
}));
|
|
1911
|
-
rest.headers.set(symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM,
|
|
1902
|
+
rest.headers.set(symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM, lib_1.JSON10.stringify(circuralFromQueryParams));
|
|
1912
1903
|
}
|
|
1913
1904
|
//#endregion
|
|
1914
1905
|
const httpResultObj = {
|