taon 18.0.21 → 18.0.23
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 +114 -114
- package/assets/shared/shared_folder_info.txt +1 -1
- 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/esm2022/lib/base-classes/base-migration.mjs +3 -3
- package/browser/esm2022/lib/context-db-migrations.mjs +16 -1
- package/browser/esm2022/lib/create-context.mjs +8 -3
- package/browser/esm2022/lib/endpoint-context.mjs +12 -2
- package/browser/esm2022/lib/models.mjs +1 -1
- package/browser/esm2022/lib/orm.mjs +1 -1
- package/browser/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.mjs +24 -26
- package/browser/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin.service.mjs +4 -9
- package/browser/fesm2022/taon.mjs +63 -37
- package/browser/fesm2022/taon.mjs.map +1 -1
- package/browser/lib/context-db-migrations.d.ts +1 -0
- package/browser/lib/endpoint-context.d.ts +1 -0
- package/browser/lib/models.d.ts +1 -0
- package/browser/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +1 -2
- package/browser/lib/ui/taon-admin-mode-configuration/taon-admin.service.d.ts +0 -3
- package/client/README.md +24 -24
- package/client/esm2022/lib/base-classes/base-migration.mjs +3 -3
- package/client/esm2022/lib/context-db-migrations.mjs +16 -1
- package/client/esm2022/lib/create-context.mjs +8 -3
- package/client/esm2022/lib/endpoint-context.mjs +12 -2
- package/client/esm2022/lib/models.mjs +1 -1
- package/client/esm2022/lib/orm.mjs +1 -1
- package/client/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.mjs +24 -26
- package/client/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin.service.mjs +4 -9
- package/client/fesm2022/taon.mjs +63 -37
- package/client/fesm2022/taon.mjs.map +1 -1
- package/client/lib/context-db-migrations.d.ts +1 -0
- package/client/lib/endpoint-context.d.ts +1 -0
- package/client/lib/models.d.ts +1 -0
- package/client/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +1 -2
- package/client/lib/ui/taon-admin-mode-configuration/taon-admin.service.d.ts +0 -3
- package/lib/base-classes/base-migration.d.ts +2 -2
- package/lib/base-classes/base-migration.js +2 -2
- package/lib/base-classes/base-migration.js.map +1 -1
- package/lib/base-classes/base-repository.d.ts +4 -4
- package/lib/base-classes/base-subscriber-for-entity.d.ts +2 -2
- package/lib/context-db-migrations.d.ts +3 -2
- package/lib/context-db-migrations.js +35 -15
- package/lib/context-db-migrations.js.map +1 -1
- package/lib/create-context.js +8 -2
- package/lib/create-context.js.map +1 -1
- package/lib/decorators/classes/entity-decorator.d.ts +2 -2
- package/lib/decorators/http/http-decorators.d.ts +2 -2
- package/lib/decorators/http/http-methods-decorators.d.ts +3 -3
- package/lib/endpoint-context.d.ts +2 -1
- package/lib/endpoint-context.js +93 -83
- package/lib/endpoint-context.js.map +1 -1
- package/lib/formly/fromly.d.ts +2 -2
- package/lib/models.d.ts +4 -3
- package/lib/models.js.map +1 -1
- package/lib/orm.d.ts +7 -3
- package/lib/orm.js +11 -2
- package/lib/orm.js.map +1 -1
- package/lib/ui/directives/index.js +2 -2
- package/lib/ui/directives/taon-long-press.directive.d.ts +1 -1
- package/lib/ui/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +2 -3
- package/lib/ui/taon-github-fork-me-corner/index.js +2 -2
- package/lib/ui/taon-github-fork-me-ribbon/index.js +2 -2
- package/lib/ui/taon-notifications/taon-notifications.models.js +2 -2
- package/lib/ui/taon-progress-bar/index.js +2 -2
- package/lib/ui/taon-session-passcode/index.js +2 -2
- package/lib/ui/taon-table/index.js +2 -2
- package/lib/ui/taon-table/taon-table.component.d.ts +1 -1
- package/lib/ui/taon.models.d.ts +2 -2
- package/package.json +7 -7
- package/taon.jsonc +47 -47
- package/tmp-environment.json +30 -29
- package/websql/README.md +24 -24
- package/websql/esm2022/lib/base-classes/base-migration.mjs +3 -3
- package/websql/esm2022/lib/context-db-migrations.mjs +7 -2
- package/websql/esm2022/lib/create-context.mjs +8 -3
- package/websql/esm2022/lib/endpoint-context.mjs +24 -15
- package/websql/esm2022/lib/models.mjs +1 -1
- package/websql/esm2022/lib/orm.mjs +7 -2
- package/websql/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.mjs +24 -26
- package/websql/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin.service.mjs +4 -9
- package/websql/fesm2022/taon.mjs +70 -51
- package/websql/fesm2022/taon.mjs.map +1 -1
- package/websql/lib/context-db-migrations.d.ts +1 -0
- package/websql/lib/endpoint-context.d.ts +1 -0
- package/websql/lib/models.d.ts +1 -0
- package/websql/lib/orm.d.ts +5 -1
- package/websql/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +1 -2
- package/websql/lib/ui/taon-admin-mode-configuration/taon-admin.service.d.ts +0 -3
package/lib/endpoint-context.js
CHANGED
|
@@ -22,15 +22,15 @@ var tnp_core_1 = require("tnp-core");
|
|
|
22
22
|
/* */
|
|
23
23
|
/* */
|
|
24
24
|
var tnp_core_2 = require("tnp-core");
|
|
25
|
+
var tnp_core_3 = require("tnp-core");
|
|
25
26
|
var models_1 = require("./models");
|
|
26
27
|
var class_helpers_1 = require("./helpers/class-helpers");
|
|
27
28
|
var symbols_1 = require("./symbols");
|
|
28
|
-
var
|
|
29
|
+
var tnp_core_4 = require("tnp-core");
|
|
29
30
|
var di_container_1 = require("./dependency-injection/di-container");
|
|
30
31
|
var taon_helpers_1 = require("./helpers/taon-helpers");
|
|
31
32
|
var ng2_rest_1 = require("ng2-rest");
|
|
32
33
|
var json10_1 = require("json10");
|
|
33
|
-
var tnp_core_4 = require("tnp-core");
|
|
34
34
|
var rxjs_1 = require("rxjs");
|
|
35
35
|
var entity_process_1 = require("./entity-process");
|
|
36
36
|
var get_response_value_1 = require("./get-response-value");
|
|
@@ -83,6 +83,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
83
83
|
//#region fields / active routes
|
|
84
84
|
this.activeRoutes = [];
|
|
85
85
|
//#endregion
|
|
86
|
+
this.skipWritingServerRoutes = false;
|
|
86
87
|
//#region fields / types from contexts
|
|
87
88
|
this.injectableTypesfromContexts = [
|
|
88
89
|
models_1.Models.ClassType.CONTROLLER,
|
|
@@ -200,7 +201,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
200
201
|
var key = _d.value;
|
|
201
202
|
var BaseClass_1 = classesInput[key];
|
|
202
203
|
if (!BaseClass_1) {
|
|
203
|
-
|
|
204
|
+
tnp_core_4.Helpers.error("Class ".concat(key, " is not defined in context ").concat(ctx.contextName, "\n\n Please check if you have correct import in context file\n\n "));
|
|
204
205
|
}
|
|
205
206
|
var className = Reflect.getMetadata(symbols_1.Symbols.metadata.className, BaseClass_1);
|
|
206
207
|
// console.log('Metadata className', className, BaseClass);
|
|
@@ -262,7 +263,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
262
263
|
//#region fields / logs
|
|
263
264
|
get: function () {
|
|
264
265
|
var _a, _b;
|
|
265
|
-
if (
|
|
266
|
+
if (tnp_core_4._.isObject((_a = this.config) === null || _a === void 0 ? void 0 : _a.logs)) {
|
|
266
267
|
return !!this.config.logs.http;
|
|
267
268
|
}
|
|
268
269
|
return ((_b = this.config) === null || _b === void 0 ? void 0 : _b.logs) === true;
|
|
@@ -273,7 +274,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
273
274
|
Object.defineProperty(EndpointContext.prototype, "logRealtime", {
|
|
274
275
|
get: function () {
|
|
275
276
|
var _a, _b;
|
|
276
|
-
if (
|
|
277
|
+
if (tnp_core_4._.isObject((_a = this.config) === null || _a === void 0 ? void 0 : _a.logs)) {
|
|
277
278
|
return !!this.config.logs.realtime;
|
|
278
279
|
}
|
|
279
280
|
return ((_b = this.config) === null || _b === void 0 ? void 0 : _b.logs) === true;
|
|
@@ -284,7 +285,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
284
285
|
Object.defineProperty(EndpointContext.prototype, "logFramework", {
|
|
285
286
|
get: function () {
|
|
286
287
|
var _a, _b;
|
|
287
|
-
if (
|
|
288
|
+
if (tnp_core_4._.isObject((_a = this.config) === null || _a === void 0 ? void 0 : _a.logs)) {
|
|
288
289
|
return !!this.config.logs.framework;
|
|
289
290
|
}
|
|
290
291
|
return ((_b = this.config) === null || _b === void 0 ? void 0 : _b.logs) === true;
|
|
@@ -295,7 +296,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
295
296
|
Object.defineProperty(EndpointContext.prototype, "logDb", {
|
|
296
297
|
get: function () {
|
|
297
298
|
var _a, _b;
|
|
298
|
-
if (
|
|
299
|
+
if (tnp_core_4._.isObject((_a = this.config) === null || _a === void 0 ? void 0 : _a.logs)) {
|
|
299
300
|
return !!this.config.logs.db;
|
|
300
301
|
}
|
|
301
302
|
return ((_b = this.config) === null || _b === void 0 ? void 0 : _b.logs) === true;
|
|
@@ -306,7 +307,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
306
307
|
Object.defineProperty(EndpointContext.prototype, "logMigrations", {
|
|
307
308
|
get: function () {
|
|
308
309
|
var _a, _b;
|
|
309
|
-
if (
|
|
310
|
+
if (tnp_core_4._.isObject((_a = this.config) === null || _a === void 0 ? void 0 : _a.logs)) {
|
|
310
311
|
return !!this.config.logs.migrations;
|
|
311
312
|
}
|
|
312
313
|
return ((_b = this.config) === null || _b === void 0 ? void 0 : _b.logs) === true;
|
|
@@ -332,16 +333,16 @@ var EndpointContext = /** @class */ (function () {
|
|
|
332
333
|
// @ts-ignore
|
|
333
334
|
this.onlyMigrationRevertToTimestamp = onlyMigrationRevertToTimestamp;
|
|
334
335
|
this.config = this.configFn(env_1.ENV);
|
|
335
|
-
if (
|
|
336
|
+
if (tnp_core_4._.isObject(this.config.database)) {
|
|
336
337
|
this.config.database = models_1.Models.DatabaseConfig.from(this.config.database).databaseConfigTypeORM;
|
|
337
338
|
}
|
|
338
339
|
if (overrideHost && overrideRemoteHost) {
|
|
339
|
-
|
|
340
|
+
tnp_core_4.Helpers.throw("[taon-config] You can't have overrideHost and overrideRemoteHost at the same time");
|
|
340
341
|
}
|
|
341
|
-
this.config.host = !
|
|
342
|
+
this.config.host = !tnp_core_4._.isUndefined(overrideHost)
|
|
342
343
|
? overrideHost
|
|
343
344
|
: this.config.host;
|
|
344
|
-
this.config.remoteHost = !
|
|
345
|
+
this.config.remoteHost = !tnp_core_4._.isUndefined(overrideRemoteHost)
|
|
345
346
|
? overrideRemoteHost
|
|
346
347
|
: this.config.remoteHost;
|
|
347
348
|
this.config.host = this.host === null ? void 0 : this.host;
|
|
@@ -350,13 +351,19 @@ var EndpointContext = /** @class */ (function () {
|
|
|
350
351
|
if (this.config.host &&
|
|
351
352
|
!this.config.host.startsWith('http://') &&
|
|
352
353
|
!this.config.host.startsWith('https://')) {
|
|
353
|
-
|
|
354
|
+
tnp_core_4.Helpers.throw("[taon-config] Your 'host' must start with http:// or https://");
|
|
354
355
|
}
|
|
355
356
|
if (this.config.remoteHost &&
|
|
356
357
|
!this.config.remoteHost.startsWith('http://') &&
|
|
357
358
|
!this.config.remoteHost.startsWith('https://')) {
|
|
358
|
-
|
|
359
|
+
tnp_core_4.Helpers.throw("[taon-config] Your 'remoteHost' must start with http:// or https://");
|
|
359
360
|
}
|
|
361
|
+
//#region resolve if skipping writing server routes
|
|
362
|
+
//@ts-expect-error overriding readonly
|
|
363
|
+
this.skipWritingServerRoutes = tnp_core_4._.isBoolean(this.config.skipWritingServerRoutes)
|
|
364
|
+
? this.config.skipWritingServerRoutes
|
|
365
|
+
: false;
|
|
366
|
+
//#endregion
|
|
360
367
|
//#region resolve mode
|
|
361
368
|
if (this.config.host) {
|
|
362
369
|
this.mode = 'backend-frontend(tcp+udp)';
|
|
@@ -365,12 +372,12 @@ var EndpointContext = /** @class */ (function () {
|
|
|
365
372
|
}
|
|
366
373
|
if (this.config.remoteHost) {
|
|
367
374
|
if (this.config.host) {
|
|
368
|
-
|
|
375
|
+
tnp_core_4.Helpers.throw("[taon] You can't have remoteHost and host at the same time");
|
|
369
376
|
}
|
|
370
377
|
this.mode = 'remote-backend(tcp+udp)';
|
|
371
378
|
}
|
|
372
|
-
if (this.config.useIpcWhenElectron &&
|
|
373
|
-
if (
|
|
379
|
+
if (this.config.useIpcWhenElectron && tnp_core_4.Helpers.isElectron) {
|
|
380
|
+
if (tnp_core_4.Helpers.isWebSQL) {
|
|
374
381
|
this.mode = 'backend-frontend(websql-electron)';
|
|
375
382
|
}
|
|
376
383
|
else {
|
|
@@ -378,7 +385,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
378
385
|
}
|
|
379
386
|
}
|
|
380
387
|
if (!this.mode && !this.config.abstract) {
|
|
381
|
-
|
|
388
|
+
tnp_core_4.Helpers.error("[taon] Context \"".concat(this.contextName, "\": You need to provide host or remoteHost or useIpcWhenElectron"), false, true);
|
|
382
389
|
//#region @backend
|
|
383
390
|
process.exit(1);
|
|
384
391
|
//#endregion
|
|
@@ -388,13 +395,13 @@ var EndpointContext = /** @class */ (function () {
|
|
|
388
395
|
if (this.config.database === true) {
|
|
389
396
|
this.databaseConfig = this.getAutoGeneratedConfig();
|
|
390
397
|
}
|
|
391
|
-
else if (
|
|
392
|
-
this.databaseConfig =
|
|
398
|
+
else if (tnp_core_4._.isObject(this.config.database)) {
|
|
399
|
+
this.databaseConfig = tnp_core_4._.merge(this.getAutoGeneratedConfig(), tnp_core_4._.cloneDeep(this.config.database));
|
|
393
400
|
}
|
|
394
401
|
//#endregion
|
|
395
402
|
//#region resolve session
|
|
396
403
|
if (this.config.session) {
|
|
397
|
-
this.session =
|
|
404
|
+
this.session = tnp_core_4._.cloneDeep(this.config.session);
|
|
398
405
|
oneHour = 1000 * 60 * 60 * 1;
|
|
399
406
|
if (!this.session.cookieMaxAge) {
|
|
400
407
|
this.session.cookieMaxAge = oneHour;
|
|
@@ -541,7 +548,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
541
548
|
if (!this.config.abstract) {
|
|
542
549
|
this.disabledRealtime = !!this.config.disabledRealtime;
|
|
543
550
|
//#region @backend
|
|
544
|
-
if (
|
|
551
|
+
if (tnp_core_4.Helpers.isRunningIn.cliMode()) {
|
|
545
552
|
// TODO for now...
|
|
546
553
|
this.disabledRealtime = true;
|
|
547
554
|
}
|
|
@@ -554,16 +561,16 @@ var EndpointContext = /** @class */ (function () {
|
|
|
554
561
|
// console.log({ ref })
|
|
555
562
|
if (this.config.abstract) {
|
|
556
563
|
this.logFramework &&
|
|
557
|
-
|
|
564
|
+
tnp_core_4.Helpers.info("[taon] Create abstract context: ".concat(this.config.contextName));
|
|
558
565
|
}
|
|
559
566
|
else {
|
|
560
567
|
if (this.config.remoteHost) {
|
|
561
568
|
this.logFramework &&
|
|
562
|
-
|
|
569
|
+
tnp_core_4.Helpers.info("[taon] Create context for remote host: ".concat(this.config.remoteHost));
|
|
563
570
|
}
|
|
564
571
|
else {
|
|
565
572
|
this.logFramework &&
|
|
566
|
-
|
|
573
|
+
tnp_core_4.Helpers.info("[taon] Create context for host: ".concat(this.config.host));
|
|
567
574
|
}
|
|
568
575
|
}
|
|
569
576
|
//#endregion
|
|
@@ -582,7 +589,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
582
589
|
//#region @websqlFunc
|
|
583
590
|
var databaseConfig = models_1.Models.DatabaseConfig.from({});
|
|
584
591
|
if (tnp_core_2.UtilsOs.isRunningInDocker()) {
|
|
585
|
-
|
|
592
|
+
tnp_core_4.Helpers.info('Running in docker, using in mysql database');
|
|
586
593
|
// TODO auto resolve database config in docker
|
|
587
594
|
databaseConfig = models_1.Models.DatabaseConfig.from({
|
|
588
595
|
database: "db-".concat(this.contextName, ".sqlite"),
|
|
@@ -597,7 +604,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
597
604
|
}
|
|
598
605
|
else {
|
|
599
606
|
this.logFramework &&
|
|
600
|
-
|
|
607
|
+
tnp_core_4.Helpers.info("[taon][database] Automatically resolving database config for mode ".concat(this.mode));
|
|
601
608
|
switch (this.mode) {
|
|
602
609
|
//#region resolve database config for mode backend-frontend(tcp+udp)
|
|
603
610
|
case 'backend-frontend(ipc-electron)':
|
|
@@ -665,12 +672,12 @@ var EndpointContext = /** @class */ (function () {
|
|
|
665
672
|
if (this.mode === 'backend-frontend(tcp+udp)') {
|
|
666
673
|
// this.displayRoutes(this.expressApp);
|
|
667
674
|
this.serverTcpUdp.listen(Number(this.uri.port), function () {
|
|
668
|
-
|
|
675
|
+
tnp_core_4.Helpers.log("[taon][express-server]listening on port: ".concat(_this.uri.port, ", hostname: ").concat(_this.uri.pathname, ",\n address: ").concat(_this.uri.protocol, "//localhost:").concat(_this.uri.port).concat(_this.uri.pathname, "\n env: ").concat(_this.expressApp.settings.env, "\n "));
|
|
669
676
|
});
|
|
670
677
|
}
|
|
671
678
|
else {
|
|
672
679
|
this.logFramework &&
|
|
673
|
-
|
|
680
|
+
tnp_core_4.Helpers.info('Ipc communication enable instead tcp/upd');
|
|
674
681
|
}
|
|
675
682
|
//#endregion
|
|
676
683
|
};
|
|
@@ -864,7 +871,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
864
871
|
//#endregion
|
|
865
872
|
//#region methods & getters / check if context initialized
|
|
866
873
|
EndpointContext.prototype.checkIfContextInitialized = function () {
|
|
867
|
-
if (
|
|
874
|
+
if (tnp_core_4._.isUndefined(this.config)) {
|
|
868
875
|
throw new Error("Please check if your context has been initialized.\n\n // ...\n await Context.initialize();\n // ...\n\n\n ");
|
|
869
876
|
}
|
|
870
877
|
};
|
|
@@ -977,8 +984,8 @@ var EndpointContext = /** @class */ (function () {
|
|
|
977
984
|
case 2:
|
|
978
985
|
if (!!controllers_1_1.done) return [3 /*break*/, 5];
|
|
979
986
|
ctrl = controllers_1_1.value;
|
|
980
|
-
if (!
|
|
981
|
-
return [4 /*yield*/,
|
|
987
|
+
if (!tnp_core_4._.isFunction(ctrl.initExampleDbData)) return [3 /*break*/, 4];
|
|
988
|
+
return [4 /*yield*/, tnp_core_4.Helpers.runSyncOrAsync({
|
|
982
989
|
functionFn: ctrl.initExampleDbData,
|
|
983
990
|
context: ctrl,
|
|
984
991
|
})];
|
|
@@ -1036,8 +1043,8 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1036
1043
|
case 4:
|
|
1037
1044
|
if (!!_d.done) return [3 /*break*/, 7];
|
|
1038
1045
|
classFun = _d.value;
|
|
1039
|
-
if (!
|
|
1040
|
-
return [4 /*yield*/,
|
|
1046
|
+
if (!tnp_core_4._.isFunction(classFun._)) return [3 /*break*/, 6];
|
|
1047
|
+
return [4 /*yield*/, tnp_core_4.Helpers.runSyncOrAsync({
|
|
1041
1048
|
functionFn: classFun._,
|
|
1042
1049
|
context: classFun,
|
|
1043
1050
|
})];
|
|
@@ -1092,8 +1099,8 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1092
1099
|
case 17:
|
|
1093
1100
|
if (!!_h.done) return [3 /*break*/, 20];
|
|
1094
1101
|
ctrl = _h.value;
|
|
1095
|
-
if (!
|
|
1096
|
-
return [4 /*yield*/,
|
|
1102
|
+
if (!tnp_core_4._.isFunction(ctrl._)) return [3 /*break*/, 19];
|
|
1103
|
+
return [4 /*yield*/, tnp_core_4.Helpers.runSyncOrAsync({
|
|
1097
1104
|
functionFn: ctrl._,
|
|
1098
1105
|
context: ctrl,
|
|
1099
1106
|
})];
|
|
@@ -1269,11 +1276,11 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1269
1276
|
for (entities_1 = tslib_1.__values(entities), entities_1_1 = entities_1.next(); !entities_1_1.done; entities_1_1 = entities_1.next()) {
|
|
1270
1277
|
entity = entities_1_1.value;
|
|
1271
1278
|
options = Reflect.getMetadata(symbols_1.Symbols.metadata.options.entity, entity);
|
|
1272
|
-
createTable =
|
|
1279
|
+
createTable = tnp_core_4._.isUndefined(options.createTable)
|
|
1273
1280
|
? true
|
|
1274
1281
|
: options.createTable;
|
|
1275
1282
|
nameForEntity = class_helpers_1.ClassHelpers.getName(entity);
|
|
1276
|
-
if (
|
|
1283
|
+
if (tnp_core_4._.isUndefined(options.createTable) ? true : options.createTable) {
|
|
1277
1284
|
this.logDb &&
|
|
1278
1285
|
console.info("[taon][typeorm] create table for entity \"".concat(nameForEntity, "\" ? '").concat(createTable, "'"));
|
|
1279
1286
|
// console.log('TypeormEntity', { TypeormEntity });
|
|
@@ -1313,7 +1320,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1313
1320
|
return class_helpers_1.ClassHelpers.getOrginalClass(entityFn);
|
|
1314
1321
|
});
|
|
1315
1322
|
subscribers = this.getClassFunByArr(models_1.Models.ClassType.SUBSCRIBER);
|
|
1316
|
-
dataSourceDbConfig =
|
|
1323
|
+
dataSourceDbConfig = tnp_core_4._.isObject(this.databaseConfig)
|
|
1317
1324
|
? {
|
|
1318
1325
|
type: this.databaseConfig.type,
|
|
1319
1326
|
port: this.databaseConfig.databasePort,
|
|
@@ -1328,7 +1335,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1328
1335
|
synchronize: this.isRunOrRevertOnlyMigrationAppStart
|
|
1329
1336
|
? false
|
|
1330
1337
|
: this.databaseConfig.synchronize,
|
|
1331
|
-
autoSave: !
|
|
1338
|
+
autoSave: !tnp_core_4._.isNil(this.databaseConfig.autoSave)
|
|
1332
1339
|
? this.databaseConfig.autoSave
|
|
1333
1340
|
: !tnp_core_2.UtilsOs.isRunningInDocker(), // in docker I am using mysql or posgress
|
|
1334
1341
|
dropSchema: this.isRunOrRevertOnlyMigrationAppStart
|
|
@@ -1344,7 +1351,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1344
1351
|
if (!(this.modeAllowsDatabaseCreation && this.databaseConfig)) return [3 /*break*/, 5];
|
|
1345
1352
|
this.logDb &&
|
|
1346
1353
|
this.logFramework &&
|
|
1347
|
-
|
|
1354
|
+
tnp_core_4.Helpers.info('[taon][database] prepare typeorm connection...');
|
|
1348
1355
|
_c.label = 1;
|
|
1349
1356
|
case 1:
|
|
1350
1357
|
_c.trys.push([1, 3, , 4]);
|
|
@@ -1372,7 +1379,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1372
1379
|
}
|
|
1373
1380
|
return [3 /*break*/, 6];
|
|
1374
1381
|
case 5:
|
|
1375
|
-
|
|
1382
|
+
tnp_core_4.Helpers.info("[taon][typeorm] Not initing db for mode ".concat(this.mode));
|
|
1376
1383
|
_c.label = 6;
|
|
1377
1384
|
case 6: return [2 /*return*/];
|
|
1378
1385
|
}
|
|
@@ -1394,7 +1401,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1394
1401
|
var configs = class_helpers_1.ClassHelpers.getControllerConfigs(controllerClassFn);
|
|
1395
1402
|
// console.log(`Class config for ${ClassHelpers.getName(controllerClassFn)}`, configs)
|
|
1396
1403
|
var classConfig = configs[0];
|
|
1397
|
-
var parentscalculatedPath =
|
|
1404
|
+
var parentscalculatedPath = tnp_core_4._.slice(configs, 1)
|
|
1398
1405
|
.reverse()
|
|
1399
1406
|
.map(function (bc) {
|
|
1400
1407
|
if (taon_helpers_1.TaonHelpers.isGoodPath(bc.path)) {
|
|
@@ -1412,13 +1419,13 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1412
1419
|
.replace(/\/\//g, '/')
|
|
1413
1420
|
.split('/')
|
|
1414
1421
|
.reduce(function (acc, bc) {
|
|
1415
|
-
return
|
|
1422
|
+
return tnp_core_4._.last(acc) === bc ? acc : tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(acc), false), [bc], false);
|
|
1416
1423
|
}, [])
|
|
1417
1424
|
.join('/');
|
|
1418
1425
|
}
|
|
1419
|
-
|
|
1426
|
+
tnp_core_4._.slice(configs, 1).forEach(function (bc) {
|
|
1420
1427
|
var alreadyIs = classConfig.methods;
|
|
1421
|
-
var toMerge =
|
|
1428
|
+
var toMerge = tnp_core_4._.cloneDeep(bc.methods);
|
|
1422
1429
|
for (var key in toMerge) {
|
|
1423
1430
|
if (toMerge.hasOwnProperty(key) && !alreadyIs[key]) {
|
|
1424
1431
|
var element = toMerge[key];
|
|
@@ -1427,7 +1434,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1427
1434
|
}
|
|
1428
1435
|
});
|
|
1429
1436
|
//#region @backend
|
|
1430
|
-
if (!
|
|
1437
|
+
if (!tnp_core_4.Helpers.isRunningIn.cliMode()) {
|
|
1431
1438
|
//#endregion
|
|
1432
1439
|
this_1.logHttp &&
|
|
1433
1440
|
console.groupCollapsed("[taon][express-server] routes [".concat(classConfig.className, "]"));
|
|
@@ -1444,7 +1451,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1444
1451
|
? "/".concat((_a = methodConfig.path) === null || _a === void 0 ? void 0 : _a.replace(/\//, ''))
|
|
1445
1452
|
: taon_helpers_1.TaonHelpers.getExpressPath(classConfig, methodConfig);
|
|
1446
1453
|
// console.log({ expressPath })
|
|
1447
|
-
if (
|
|
1454
|
+
if (tnp_core_4.Helpers.isNode || tnp_core_4.Helpers.isWebSQL) {
|
|
1448
1455
|
//#region @websql
|
|
1449
1456
|
var _b = _this.initServer(type, methodConfig, classConfig, expressPath, controllerClassFn), routePath = _b.routePath, method = _b.method;
|
|
1450
1457
|
_this.activeRoutes.push({
|
|
@@ -1453,7 +1460,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1453
1460
|
});
|
|
1454
1461
|
//#endregion
|
|
1455
1462
|
}
|
|
1456
|
-
var shouldInitClient =
|
|
1463
|
+
var shouldInitClient = tnp_core_4.Helpers.isBrowser || _this.remoteHost || tnp_core_4.Helpers.isWebSQL;
|
|
1457
1464
|
// console.log('shouldInitClient', shouldInitClient);
|
|
1458
1465
|
if (shouldInitClient) {
|
|
1459
1466
|
// console.log(
|
|
@@ -1467,7 +1474,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1467
1474
|
}
|
|
1468
1475
|
});
|
|
1469
1476
|
//#region @backend
|
|
1470
|
-
if (!
|
|
1477
|
+
if (!tnp_core_4.Helpers.isRunningIn.cliMode()) {
|
|
1471
1478
|
//#endregion
|
|
1472
1479
|
this_1.logHttp && console.groupEnd();
|
|
1473
1480
|
//#region @backend
|
|
@@ -1493,32 +1500,35 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1493
1500
|
//#region methods & getters / write active routes
|
|
1494
1501
|
EndpointContext.prototype.writeActiveRoutes = function () {
|
|
1495
1502
|
var _this = this;
|
|
1496
|
-
if (this.remoteHost ||
|
|
1503
|
+
if (this.remoteHost ||
|
|
1504
|
+
this.isRunOrRevertOnlyMigrationAppStart ||
|
|
1505
|
+
this.skipWritingServerRoutes) {
|
|
1497
1506
|
return;
|
|
1498
1507
|
}
|
|
1499
1508
|
var contexts = [this];
|
|
1500
1509
|
//#region @websql
|
|
1501
|
-
var troutes = this.activeRoutes.map(function (
|
|
1502
|
-
|
|
1503
|
-
|
|
1510
|
+
var troutes = tnp_core_2.Utils.uniqArray(this.activeRoutes.map(function (f) {
|
|
1511
|
+
return "".concat(f.method, " ").concat(f.routePath);
|
|
1512
|
+
})).map(function (f) {
|
|
1513
|
+
var _a = tslib_1.__read(f.split(' '), 2), method = _a[0], routePath = _a[1];
|
|
1514
|
+
return ("\n### ".concat(tnp_core_4._.startCase(tnp_core_4._.last(routePath.split('/'))), "\n") +
|
|
1515
|
+
taon_helpers_1.TaonHelpers.fillUpTo(method.toUpperCase() + ' ', 10) +
|
|
1504
1516
|
_this.uri.href.replace(/\/$/, '') +
|
|
1505
1517
|
routePath);
|
|
1506
1518
|
// return `${TaonHelpers.string(method.toUpperCase() + ':')
|
|
1507
1519
|
// .fillUpTo(10)}${context.uri.href.replace(/\/$/, '')}${routePath}`
|
|
1508
1520
|
});
|
|
1509
|
-
var routes = tslib_1.__spreadArray(tslib_1.__spreadArray([], ['', "
|
|
1510
|
-
var fileName =
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1521
|
+
var routes = tslib_1.__spreadArray(tslib_1.__spreadArray([], ['', "# ROUTES FOR HOST ".concat(this.uri.href, " ")], false), tslib_1.__read(troutes), false).join('\n');
|
|
1522
|
+
var fileName = (0, tnp_core_3.crossPlatformPath)([
|
|
1523
|
+
//#region @backend
|
|
1524
|
+
process.cwd(),
|
|
1525
|
+
//#endregion
|
|
1526
|
+
"routes-".concat(this.config.contextName, ".rest"),
|
|
1527
|
+
]);
|
|
1515
1528
|
this.logFramework && console.log("[taon] routes file: ".concat(fileName, " "));
|
|
1516
1529
|
// Helpers.log(JSON.stringify(routes, null, 4))
|
|
1517
1530
|
//#region @backend
|
|
1518
|
-
|
|
1519
|
-
spaces: 2,
|
|
1520
|
-
encoding: 'utf8',
|
|
1521
|
-
});
|
|
1531
|
+
tnp_core_4.Helpers.writeFile(fileName, routes);
|
|
1522
1532
|
//#endregion
|
|
1523
1533
|
//#endregion
|
|
1524
1534
|
};
|
|
@@ -1554,7 +1564,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1554
1564
|
app.use(methodOverride());
|
|
1555
1565
|
app.use(cookieParser());
|
|
1556
1566
|
if (this.session) {
|
|
1557
|
-
|
|
1567
|
+
tnp_core_4.Helpers.info('[taon][express-server] session enabled for this context ' +
|
|
1558
1568
|
this.contextName);
|
|
1559
1569
|
var cookieMaxAge = this.session.cookieMaxAge;
|
|
1560
1570
|
var frontendHost = this.config.frontendHost;
|
|
@@ -1576,7 +1586,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1576
1586
|
else {
|
|
1577
1587
|
// if(this.config?.serverLogs) {
|
|
1578
1588
|
this.logHttp &&
|
|
1579
|
-
|
|
1589
|
+
tnp_core_4.Helpers.info("[taon][express-server] session not enabled for this context '".concat(this.contextName, "'"));
|
|
1580
1590
|
// }
|
|
1581
1591
|
app.use(cors({
|
|
1582
1592
|
// origin: "http://localhost:5555",
|
|
@@ -1662,10 +1672,10 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1662
1672
|
expressPath = expressPath.replace(/\/\//g, '/');
|
|
1663
1673
|
// console.log(`BACKEND: expressPath: ${ expressPath } `)
|
|
1664
1674
|
//#endregion
|
|
1665
|
-
if (
|
|
1675
|
+
if (tnp_core_4.Helpers.isElectron) {
|
|
1666
1676
|
//#region @backend
|
|
1667
1677
|
var ipcKeyName = taon_helpers_1.TaonHelpers.ipcKeyNameRequest(target, methodConfig, expressPath);
|
|
1668
|
-
|
|
1678
|
+
tnp_core_4.Helpers.ipcMain.on(ipcKeyName, function (event, paramsFromBrowser) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
1669
1679
|
var responseJsonData;
|
|
1670
1680
|
return tslib_1.__generator(this, function (_a) {
|
|
1671
1681
|
switch (_a.label) {
|
|
@@ -1686,7 +1696,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1686
1696
|
if (!this.remoteHost) {
|
|
1687
1697
|
//#region apply dummy websql express routers
|
|
1688
1698
|
//#region @websql
|
|
1689
|
-
if (
|
|
1699
|
+
if (tnp_core_4.Helpers.isWebSQL) {
|
|
1690
1700
|
if (!this.expressApp[type.toLowerCase()]) {
|
|
1691
1701
|
this.expressApp[type.toLowerCase()] = function () { };
|
|
1692
1702
|
}
|
|
@@ -1748,7 +1758,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1748
1758
|
try {
|
|
1749
1759
|
var entityForParam = JSON.parse(req.headers["".concat(symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS).concat(queryParamName, " ")]);
|
|
1750
1760
|
var beforeTransofrm = tQuery[queryParamName];
|
|
1751
|
-
if (
|
|
1761
|
+
if (tnp_core_4._.isString(beforeTransofrm)) {
|
|
1752
1762
|
try {
|
|
1753
1763
|
var paresed = taon_helpers_1.TaonHelpers.tryTransformParam(beforeTransofrm);
|
|
1754
1764
|
beforeTransofrm = paresed;
|
|
@@ -1814,7 +1824,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1814
1824
|
res.end(file);
|
|
1815
1825
|
return [3 /*break*/, 7];
|
|
1816
1826
|
case 4:
|
|
1817
|
-
if (!(
|
|
1827
|
+
if (!(tnp_core_4._.isString(result) &&
|
|
1818
1828
|
methodConfig.responseType ===
|
|
1819
1829
|
'blob')) return [3 /*break*/, 5];
|
|
1820
1830
|
img_base64 = result;
|
|
@@ -1841,27 +1851,27 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1841
1851
|
case 8:
|
|
1842
1852
|
error_2 = _d.sent();
|
|
1843
1853
|
//#region process error
|
|
1844
|
-
if (
|
|
1854
|
+
if (tnp_core_4._.isString(error_2)) {
|
|
1845
1855
|
res.status(400).send(json10_1.JSON10.stringify({
|
|
1846
1856
|
message: "\n Error inside: ".concat(req.path, "\n\n ").concat(error_2, "\n\n"),
|
|
1847
1857
|
}));
|
|
1848
1858
|
}
|
|
1849
1859
|
else if (error_2 instanceof models_1.Models.Http.Errors) {
|
|
1850
|
-
|
|
1860
|
+
tnp_core_4.Helpers.error(error_2, true, false);
|
|
1851
1861
|
err = error_2;
|
|
1852
1862
|
res.status(400).send(json10_1.JSON10.stringify(err));
|
|
1853
1863
|
}
|
|
1854
1864
|
else if (error_2 instanceof Error) {
|
|
1855
1865
|
err = error_2;
|
|
1856
|
-
|
|
1866
|
+
tnp_core_4.Helpers.error(error_2, true, false);
|
|
1857
1867
|
res.status(400).send(json10_1.JSON10.stringify({
|
|
1858
1868
|
stack: err.stack,
|
|
1859
1869
|
message: err.message,
|
|
1860
1870
|
}));
|
|
1861
1871
|
}
|
|
1862
1872
|
else {
|
|
1863
|
-
|
|
1864
|
-
|
|
1873
|
+
tnp_core_4.Helpers.log(error_2);
|
|
1874
|
+
tnp_core_4.Helpers.error("[Taon] Bad result isomorphic method: ".concat(error_2, " "), true, false);
|
|
1865
1875
|
res.status(400).send(json10_1.JSON10.stringify(error_2));
|
|
1866
1876
|
}
|
|
1867
1877
|
return [3 /*break*/, 9];
|
|
@@ -1890,18 +1900,18 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1890
1900
|
// console.log('INITING', methodConfig); // TODO inject in static
|
|
1891
1901
|
//#region resolve storage
|
|
1892
1902
|
var storage;
|
|
1893
|
-
if (
|
|
1903
|
+
if (tnp_core_4.Helpers.isBrowser) {
|
|
1894
1904
|
storage = window;
|
|
1895
1905
|
}
|
|
1896
1906
|
//#region @backend
|
|
1897
|
-
if (
|
|
1907
|
+
if (tnp_core_4.Helpers.isNode) {
|
|
1898
1908
|
storage = global;
|
|
1899
1909
|
}
|
|
1900
1910
|
//#endregion
|
|
1901
1911
|
//#endregion
|
|
1902
1912
|
var orgMethods = target.prototype[methodConfig.methodName];
|
|
1903
1913
|
//#region handle electron ipc request
|
|
1904
|
-
if (
|
|
1914
|
+
if (tnp_core_4.Helpers.isElectron) {
|
|
1905
1915
|
target.prototype[methodConfig.methodName] = function () {
|
|
1906
1916
|
var _this = this;
|
|
1907
1917
|
var args = [];
|
|
@@ -1913,7 +1923,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1913
1923
|
return tslib_1.__generator(this, function (_b) {
|
|
1914
1924
|
headers = {};
|
|
1915
1925
|
_a = taon_helpers_1.TaonHelpers.websqlMocks(headers), request = _a.request, response = _a.response;
|
|
1916
|
-
|
|
1926
|
+
tnp_core_4.Helpers.ipcRenderer.once(taon_helpers_1.TaonHelpers.ipcKeyNameResponse(target, methodConfig, expressPath), function (event, responseData) {
|
|
1917
1927
|
var res = responseData;
|
|
1918
1928
|
console.log({ responseData: responseData });
|
|
1919
1929
|
try {
|
|
@@ -1924,7 +1934,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1924
1934
|
method: methodConfig.type,
|
|
1925
1935
|
url: "".concat(ctx.uri.origin).concat('' // TODO express path
|
|
1926
1936
|
).concat(methodConfig.path, " "),
|
|
1927
|
-
},
|
|
1937
|
+
}, tnp_core_4.Helpers.isBlob(body_1) || tnp_core_4._.isString(body_1)
|
|
1928
1938
|
? body_1
|
|
1929
1939
|
: JSON.stringify(body_1), ng2_rest_1.RestHeaders.from(headers), void 0, function () { return body_1; });
|
|
1930
1940
|
resolve(res);
|
|
@@ -1934,7 +1944,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
1934
1944
|
reject(error);
|
|
1935
1945
|
}
|
|
1936
1946
|
});
|
|
1937
|
-
|
|
1947
|
+
tnp_core_4.Helpers.ipcRenderer.send(taon_helpers_1.TaonHelpers.ipcKeyNameRequest(target, methodConfig, expressPath), args);
|
|
1938
1948
|
return [2 /*return*/];
|
|
1939
1949
|
});
|
|
1940
1950
|
}); });
|
|
@@ -2163,7 +2173,7 @@ var EndpointContext = /** @class */ (function () {
|
|
|
2163
2173
|
if (mapping) {
|
|
2164
2174
|
rest.headers.set(symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS, JSON.stringify(mapping));
|
|
2165
2175
|
}
|
|
2166
|
-
queryParams =
|
|
2176
|
+
queryParams = tnp_core_4._.cloneDeep(param);
|
|
2167
2177
|
}
|
|
2168
2178
|
}
|
|
2169
2179
|
if (currentParam.paramType === 'Header') {
|