taon 21.0.39 → 21.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/fesm2022/taon-browser.mjs +14 -15
- package/browser/fesm2022/taon-browser.mjs.map +1 -1
- package/browser/package.json +1 -1
- package/browser/types/taon-browser.d.ts +3 -3
- package/browser-prod/fesm2022/taon-browser.mjs +167 -168
- package/browser-prod/fesm2022/taon-browser.mjs.map +1 -1
- package/browser-prod/package.json +1 -1
- package/browser-prod/types/taon-browser.d.ts +3 -3
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/context-db-migrations.js +1 -1
- package/lib/context-db-migrations.js.map +1 -1
- package/lib/endpoint-context.js +11 -11
- package/lib/endpoint-context.js.map +1 -1
- package/lib/index.js +5 -5
- package/lib/index.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/realtime/realtime-core.js +2 -2
- package/lib/realtime/realtime-core.js.map +1 -1
- package/lib/realtime/realtime-server.js +2 -2
- package/lib/realtime/realtime-server.js.map +1 -1
- package/lib/ui/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
- package/lib-prod/base-classes/base-class.js +3 -3
- package/lib-prod/base-classes/base-class.js.map +1 -1
- package/lib-prod/base-classes/base-controller.js.map +1 -1
- package/lib-prod/base-classes/base-crud-controller.js +5 -5
- package/lib-prod/base-classes/base-crud-controller.js.map +1 -1
- package/lib-prod/base-classes/base-migration.js +1 -1
- package/lib-prod/base-classes/base-migration.js.map +1 -1
- package/lib-prod/base-classes/base-repository.js +7 -7
- package/lib-prod/base-classes/base-repository.js.map +1 -1
- package/lib-prod/build-info._auto-generated_.d.ts +1 -1
- package/lib-prod/build-info._auto-generated_.js +1 -1
- package/lib-prod/context-db-migrations.js +1 -1
- package/lib-prod/context-db-migrations.js.map +1 -1
- package/lib-prod/create-context.js +4 -4
- package/lib-prod/create-context.js.map +1 -1
- package/lib-prod/decorators/classes/entity-decorator.js +1 -1
- package/lib-prod/decorators/classes/entity-decorator.js.map +1 -1
- package/lib-prod/decorators/http/http-methods-decorators.js +1 -1
- package/lib-prod/decorators/http/http-methods-decorators.js.map +1 -1
- package/lib-prod/endpoint-context.js +75 -75
- package/lib-prod/endpoint-context.js.map +1 -1
- package/lib-prod/entity-process.js +23 -23
- package/lib-prod/entity-process.js.map +1 -1
- package/lib-prod/formly/fromly.js +20 -20
- package/lib-prod/formly/fromly.js.map +1 -1
- package/lib-prod/formly/type-from-entity.js +5 -5
- package/lib-prod/formly/type-from-entity.js.map +1 -1
- package/lib-prod/helpers/class-helpers.js +16 -16
- package/lib-prod/helpers/class-helpers.js.map +1 -1
- package/lib-prod/helpers/clone-obj.js +3 -3
- package/lib-prod/helpers/clone-obj.js.map +1 -1
- package/lib-prod/helpers/taon-helpers.js +4 -4
- package/lib-prod/helpers/taon-helpers.js.map +1 -1
- package/lib-prod/index.js +5 -5
- package/lib-prod/index.js.map +1 -1
- package/lib-prod/models.js +2 -2
- package/lib-prod/models.js.map +1 -1
- package/lib-prod/orm/columns.js +6 -6
- package/lib-prod/orm/columns.js.map +1 -1
- package/lib-prod/package.json +1 -1
- package/lib-prod/realtime/realtime-client.js +6 -6
- package/lib-prod/realtime/realtime-client.js.map +1 -1
- package/lib-prod/realtime/realtime-core.js +2 -2
- package/lib-prod/realtime/realtime-core.js.map +1 -1
- package/lib-prod/realtime/realtime-server.js +6 -6
- package/lib-prod/realtime/realtime-server.js.map +1 -1
- package/lib-prod/realtime/realtime-subs-manager.js +2 -2
- package/lib-prod/realtime/realtime-subs-manager.js.map +1 -1
- package/lib-prod/symbols.js +3 -3
- package/lib-prod/symbols.js.map +1 -1
- package/lib-prod/ui/index.d.ts +1 -1
- package/lib-prod/ui/index.js +2 -2
- package/lib-prod/ui/taon-admin-mode-configuration/index.d.ts +1 -1
- package/lib-prod/ui/taon-admin-mode-configuration/index.js +2 -2
- package/lib-prod/validators.js +7 -7
- package/lib-prod/validators.js.map +1 -1
- package/package.json +3 -2
- package/websql/fesm2022/taon-websql.mjs +20 -21
- package/websql/fesm2022/taon-websql.mjs.map +1 -1
- package/websql/package.json +1 -1
- package/websql/types/taon-websql.d.ts +3 -3
- package/websql-prod/fesm2022/taon-websql.mjs +197 -198
- package/websql-prod/fesm2022/taon-websql.mjs.map +1 -1
- package/websql-prod/package.json +1 -1
- package/websql-prod/types/taon-websql.d.ts +3 -3
|
@@ -153,37 +153,37 @@ class EndpointContext {
|
|
|
153
153
|
//#endregion
|
|
154
154
|
//#region fields / logs
|
|
155
155
|
get logHttp() {
|
|
156
|
-
if (lib_prod_12.
|
|
156
|
+
if ((0, lib_prod_12.___NS__isObject)(this.config?.logs)) {
|
|
157
157
|
return !!this.config.logs.http;
|
|
158
158
|
}
|
|
159
159
|
return this.config?.logs === true;
|
|
160
160
|
}
|
|
161
161
|
get logRealtime() {
|
|
162
|
-
if (lib_prod_12.
|
|
162
|
+
if ((0, lib_prod_12.___NS__isObject)(this.config?.logs)) {
|
|
163
163
|
return !!this.config.logs.realtime;
|
|
164
164
|
}
|
|
165
165
|
return this.config?.logs === true;
|
|
166
166
|
}
|
|
167
167
|
get logFramework() {
|
|
168
|
-
if (lib_prod_12.
|
|
168
|
+
if ((0, lib_prod_12.___NS__isObject)(this.config?.logs)) {
|
|
169
169
|
return !!this.config.logs.framework;
|
|
170
170
|
}
|
|
171
171
|
return this.config?.logs === true;
|
|
172
172
|
}
|
|
173
173
|
get logRoutes() {
|
|
174
|
-
if (lib_prod_12.
|
|
174
|
+
if ((0, lib_prod_12.___NS__isObject)(this.config?.logs)) {
|
|
175
175
|
return !!this.config.logs.routes;
|
|
176
176
|
}
|
|
177
177
|
return this.config?.logs === true;
|
|
178
178
|
}
|
|
179
179
|
get logDb() {
|
|
180
|
-
if (lib_prod_12.
|
|
180
|
+
if ((0, lib_prod_12.___NS__isObject)(this.config?.logs)) {
|
|
181
181
|
return !!this.config.logs.db;
|
|
182
182
|
}
|
|
183
183
|
return this.config?.logs === true;
|
|
184
184
|
}
|
|
185
185
|
get logMigrations() {
|
|
186
|
-
if (lib_prod_12.
|
|
186
|
+
if ((0, lib_prod_12.___NS__isObject)(this.config?.logs)) {
|
|
187
187
|
return !!this.config.logs.migrations;
|
|
188
188
|
}
|
|
189
189
|
return this.config?.logs === true;
|
|
@@ -219,7 +219,7 @@ class EndpointContext {
|
|
|
219
219
|
// @ts-ignore
|
|
220
220
|
this.onlyMigrationRevertToTimestamp = onlyMigrationRevertToTimestamp;
|
|
221
221
|
this.config = this.configFn({});
|
|
222
|
-
if (lib_prod_12.
|
|
222
|
+
if ((0, lib_prod_12.___NS__isObject)(this.config.database)) {
|
|
223
223
|
this.config.database = models_1.Models__NS__DatabaseConfig.from(this.config.database).databaseConfigTypeORM;
|
|
224
224
|
}
|
|
225
225
|
this.config.host = this.host === null ? void 0 : this.host;
|
|
@@ -234,15 +234,15 @@ class EndpointContext {
|
|
|
234
234
|
if (this.config.host &&
|
|
235
235
|
!this.config.host.startsWith('http://') &&
|
|
236
236
|
!this.config.host.startsWith('https://')) {
|
|
237
|
-
lib_prod_12.
|
|
237
|
+
(0, lib_prod_12.Helpers__NS__throwError)(`[taon-config] Your${this.host ? ' remote' : ''} 'host' must start with http:// or https://`);
|
|
238
238
|
}
|
|
239
|
-
if (lib_prod_12.
|
|
239
|
+
if ((0, lib_prod_12.___NS__isUndefined)(this.config.useIpcWhenElectron)) {
|
|
240
240
|
this.config.useIpcWhenElectron = true;
|
|
241
241
|
}
|
|
242
242
|
// console.log(`config for ${this.contextName}`, this.config);
|
|
243
243
|
//#region resolve if skipping writing server routes
|
|
244
244
|
//@ts-expect-error overriding readonly
|
|
245
|
-
this.skipWritingServerRoutes = lib_prod_12.
|
|
245
|
+
this.skipWritingServerRoutes = (0, lib_prod_12.___NS__isBoolean)(this.config.skipWritingServerRoutes)
|
|
246
246
|
? this.config.skipWritingServerRoutes
|
|
247
247
|
: false;
|
|
248
248
|
//#endregion
|
|
@@ -257,10 +257,10 @@ class EndpointContext {
|
|
|
257
257
|
}
|
|
258
258
|
// console.log(`
|
|
259
259
|
// useIpcWhenElectron: ${this.config.useIpcWhenElectron}
|
|
260
|
-
//
|
|
260
|
+
// UtilsOs__NS__isElectron: ${UtilsOs__NS__isElectron}
|
|
261
261
|
// `)
|
|
262
|
-
if (this.config.useIpcWhenElectron &&
|
|
263
|
-
if (
|
|
262
|
+
if (this.config.useIpcWhenElectron && lib_prod_10.UtilsOs__NS__isElectron) {
|
|
263
|
+
if (lib_prod_10.UtilsOs__NS__isWebSQL) {
|
|
264
264
|
this.mode = 'backend-frontend(websql-electron)';
|
|
265
265
|
}
|
|
266
266
|
else {
|
|
@@ -275,7 +275,7 @@ class EndpointContext {
|
|
|
275
275
|
if (!this.mode && !this.config.abstract) {
|
|
276
276
|
const errMsg = `You need to provide host property or ` +
|
|
277
277
|
`useIpcWhenElectron or mark it as abstract`;
|
|
278
|
-
lib_prod_12.
|
|
278
|
+
(0, lib_prod_12.Helpers__NS__error)(`[taon][Context=${this.contextName}]: ${errMsg}`, false, true);
|
|
279
279
|
//#region @backend
|
|
280
280
|
process.exit(1);
|
|
281
281
|
//#endregion
|
|
@@ -291,7 +291,7 @@ class EndpointContext {
|
|
|
291
291
|
`);
|
|
292
292
|
this.databaseConfig = this.getAutoGeneratedConfig();
|
|
293
293
|
}
|
|
294
|
-
else if (lib_prod_12.
|
|
294
|
+
else if ((0, lib_prod_12.___NS__isObject)(this.config.database)) {
|
|
295
295
|
this.logFramework &&
|
|
296
296
|
console.log(`
|
|
297
297
|
|
|
@@ -300,13 +300,13 @@ class EndpointContext {
|
|
|
300
300
|
`);
|
|
301
301
|
this.databaseConfig = this.getAutoGeneratedConfig();
|
|
302
302
|
lib_prod_2.walk.Object(this.config.database, (value, lodashPath) => {
|
|
303
|
-
if (lib_prod_12.
|
|
303
|
+
if ((0, lib_prod_12.___NS__isNil)(value) || (0, lib_prod_12.___NS__isFunction)(value) || (0, lib_prod_12.___NS__isObject)(value)) {
|
|
304
304
|
// skipping
|
|
305
305
|
}
|
|
306
306
|
else {
|
|
307
307
|
this.logFramework &&
|
|
308
308
|
console.info(`Overriding database config: ${lodashPath}=${value}`);
|
|
309
|
-
lib_prod_12.
|
|
309
|
+
(0, lib_prod_12.___NS__set)(this.databaseConfig, lodashPath, value);
|
|
310
310
|
}
|
|
311
311
|
}, {
|
|
312
312
|
walkGetters: false,
|
|
@@ -315,7 +315,7 @@ class EndpointContext {
|
|
|
315
315
|
//#endregion
|
|
316
316
|
//#region resolve session
|
|
317
317
|
if (this.config.session) {
|
|
318
|
-
this.session = lib_prod_12.
|
|
318
|
+
this.session = (0, lib_prod_12.___NS__cloneDeep)(this.config.session);
|
|
319
319
|
const oneHour = 1000 * 60 * 60 * 1; // 24;
|
|
320
320
|
if (!this.session.cookieMaxAge) {
|
|
321
321
|
this.session.cookieMaxAge = oneHour;
|
|
@@ -422,7 +422,7 @@ class EndpointContext {
|
|
|
422
422
|
await this.initCustomBackendMiddlewares();
|
|
423
423
|
const shouldStartHttpsSecureServer = this.isHttpServer && !this.isRunningInsideDocker;
|
|
424
424
|
this.logFramework &&
|
|
425
|
-
lib_prod_12.
|
|
425
|
+
(0, lib_prod_12.Helpers__NS__info)(`
|
|
426
426
|
|
|
427
427
|
Starting server ${shouldStartHttpsSecureServer ? 'with' : 'without'} HTTPS secure server
|
|
428
428
|
|
|
@@ -452,16 +452,16 @@ class EndpointContext {
|
|
|
452
452
|
`;
|
|
453
453
|
}
|
|
454
454
|
//#region @backend
|
|
455
|
-
// if (UtilsOs__NS__isRunningInCliMode() && !
|
|
455
|
+
// if (UtilsOs__NS__isRunningInCliMode() && !___NS__isNil(this.config.disabledRealtime)) {
|
|
456
456
|
// // TODO for now...
|
|
457
|
-
//
|
|
457
|
+
// Helpers__NS__logInfo(`Realtime disable on backend for cli mode`);
|
|
458
458
|
// this.disabledRealtime = true;
|
|
459
459
|
// } else {
|
|
460
|
-
//
|
|
460
|
+
// Helpers__NS__logInfo(`Realtime enabled on backend`);
|
|
461
461
|
// }
|
|
462
462
|
//#endregion
|
|
463
463
|
this.logRealtime &&
|
|
464
|
-
lib_prod_12.
|
|
464
|
+
(0, lib_prod_12.Helpers__NS__info)(`[ctx=${this.contextName}] Init Realtime for ${this.mode}`);
|
|
465
465
|
this.realtime = new realtime_core_1.RealtimeCore(this);
|
|
466
466
|
}
|
|
467
467
|
//#endregion
|
|
@@ -470,16 +470,16 @@ class EndpointContext {
|
|
|
470
470
|
// console.log({ ref })
|
|
471
471
|
if (this.config.abstract) {
|
|
472
472
|
this.logFramework &&
|
|
473
|
-
lib_prod_12.
|
|
473
|
+
(0, lib_prod_12.Helpers__NS__info)(`[taon] Create abstract context: ${this.config.contextName}`);
|
|
474
474
|
}
|
|
475
475
|
else {
|
|
476
476
|
if (this.isRemoteHost) {
|
|
477
477
|
this.logFramework &&
|
|
478
|
-
lib_prod_12.
|
|
478
|
+
(0, lib_prod_12.Helpers__NS__info)(`[taon] Create context for remote host: ${this.config.host}`);
|
|
479
479
|
}
|
|
480
480
|
else {
|
|
481
481
|
this.logFramework &&
|
|
482
|
-
lib_prod_12.
|
|
482
|
+
(0, lib_prod_12.Helpers__NS__info)(`[taon] Create context for host: ${this.config.host}`);
|
|
483
483
|
}
|
|
484
484
|
}
|
|
485
485
|
//#endregion
|
|
@@ -503,7 +503,7 @@ class EndpointContext {
|
|
|
503
503
|
const tcpUdpDatabaseSqliteRelativeFileLocation = `${models_1.Models__NS__DatabasesFolder}/db-${this.contextName}.sqlite`;
|
|
504
504
|
if (this.isRunningInsideDocker) {
|
|
505
505
|
if (this.USE_MARIADB_MYSQL_IN_DOCKER) {
|
|
506
|
-
//
|
|
506
|
+
// Helpers__NS__info('Running in docker, using in mysql database');
|
|
507
507
|
// // TODO auto resolve database config in docker
|
|
508
508
|
// databaseConfig = Models__NS__DatabaseConfig.from({
|
|
509
509
|
// database: `db-${this.contextName}.sqlite`,
|
|
@@ -555,7 +555,7 @@ class EndpointContext {
|
|
|
555
555
|
else {
|
|
556
556
|
//#region auto resolve db config
|
|
557
557
|
this.logFramework &&
|
|
558
|
-
lib_prod_12.
|
|
558
|
+
(0, lib_prod_12.Helpers__NS__info)(`[taon][database] Automatically resolving database config for mode ${this.mode}`);
|
|
559
559
|
switch (this.mode) {
|
|
560
560
|
//#region resolve database config for backend-frontend(ipc-electron)
|
|
561
561
|
case 'backend-frontend(ipc-electron)':
|
|
@@ -564,10 +564,10 @@ class EndpointContext {
|
|
|
564
564
|
if (lib_prod_10.UtilsOs__NS__isElectron) {
|
|
565
565
|
dbLocationInOs = (0, lib_prod_11.crossPlatformPath)([
|
|
566
566
|
(0, lib_prod_10.UtilsOs__NS__getRealHomeDir)(),
|
|
567
|
-
`.taon/databases-for-electron-apps/${this.appId || lib_prod_12.
|
|
567
|
+
`.taon/databases-for-electron-apps/${this.appId || (0, lib_prod_12.___NS__snakeCase)(process.cwd()).replace(/\_/, '.')}/${this.contextName}.sqlite`,
|
|
568
568
|
]);
|
|
569
|
-
if (!lib_prod_12.
|
|
570
|
-
lib_prod_12.
|
|
569
|
+
if (!(0, lib_prod_12.Helpers__NS__exists)(lib_prod_13.path.dirname(dbLocationInOs))) {
|
|
570
|
+
(0, lib_prod_12.Helpers__NS__mkdirp)(lib_prod_13.path.dirname(dbLocationInOs));
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
573
|
//#endregion
|
|
@@ -629,9 +629,9 @@ class EndpointContext {
|
|
|
629
629
|
// this.displayRoutes(this.expressApp);
|
|
630
630
|
this.serverTcpUdp.listen(Number(this.uriPort), '0.0.0.0', () => {
|
|
631
631
|
this.logFramework &&
|
|
632
|
-
lib_prod_12.
|
|
632
|
+
(0, lib_prod_12.Helpers__NS__log)(`[ctx=${this.contextName}] Express server (inside docker) started 0.0.0.0:${this.uriPort}`);
|
|
633
633
|
this.logFramework &&
|
|
634
|
-
lib_prod_12.
|
|
634
|
+
(0, lib_prod_12.Helpers__NS__log)(`[taon][express-server]listening on port: ${this.uriPort}, hostname: ${this.uriPathname},
|
|
635
635
|
address: ${this.uriProtocol}//localhost:${this.uriPort}${this.uriPathname}
|
|
636
636
|
ExpressJS mode: ${this.expressApp.settings.env}
|
|
637
637
|
`);
|
|
@@ -642,9 +642,9 @@ class EndpointContext {
|
|
|
642
642
|
// this.displayRoutes(this.expressApp);
|
|
643
643
|
this.serverTcpUdp.listen(Number(this.uriPort), () => {
|
|
644
644
|
this.logFramework &&
|
|
645
|
-
lib_prod_12.
|
|
645
|
+
(0, lib_prod_12.Helpers__NS__log)(`[ctx=${this.contextName}] Express server (inside nodejs app) started on localhost:${this.uriPort}`);
|
|
646
646
|
this.logFramework &&
|
|
647
|
-
lib_prod_12.
|
|
647
|
+
(0, lib_prod_12.Helpers__NS__log)(`[taon][express-server]listening on port: ${this.uriPort}, hostname: ${this.uriPathname},
|
|
648
648
|
address: ${this.uriProtocol}//localhost:${this.uriPort}${this.uriPathname}
|
|
649
649
|
expressJS mode: ${this.expressApp.settings.env}
|
|
650
650
|
`);
|
|
@@ -655,7 +655,7 @@ class EndpointContext {
|
|
|
655
655
|
}
|
|
656
656
|
else {
|
|
657
657
|
this.logFramework &&
|
|
658
|
-
lib_prod_12.
|
|
658
|
+
(0, lib_prod_12.Helpers__NS__info)('Ipc communication enable instead tcp/upd');
|
|
659
659
|
}
|
|
660
660
|
//#endregion
|
|
661
661
|
}
|
|
@@ -738,10 +738,10 @@ class EndpointContext {
|
|
|
738
738
|
//#region gather all instances for all contexts
|
|
739
739
|
// TODO this is not needed anymore - for typeorm I use normal entities
|
|
740
740
|
// this thinng belowe is nice for debugging purpose
|
|
741
|
-
// if (
|
|
741
|
+
// if (___NS__isUndefined(cloneClassFunction[Symbols__NS__orignalClassClonesObj])) {
|
|
742
742
|
// cloneClassFunction[Symbols__NS__orignalClassClonesObj] = {};
|
|
743
743
|
// }
|
|
744
|
-
// if (
|
|
744
|
+
// if (___NS__isUndefined(TaonBaseClass[Symbols__NS__orignalClassClonesObj])) {
|
|
745
745
|
// TaonBaseClass[Symbols__NS__orignalClassClonesObj] = {};
|
|
746
746
|
// }
|
|
747
747
|
// const all = {
|
|
@@ -763,7 +763,7 @@ class EndpointContext {
|
|
|
763
763
|
for (const key of Object.keys(classesInput || {})) {
|
|
764
764
|
const TaonBaseClass = classesInput[key];
|
|
765
765
|
if (!TaonBaseClass) {
|
|
766
|
-
lib_prod_12.
|
|
766
|
+
(0, lib_prod_12.Helpers__NS__error)(`Class ${key} is not defined in context ${ctx.contextName}
|
|
767
767
|
|
|
768
768
|
Please check if you have correct import in context file
|
|
769
769
|
|
|
@@ -842,7 +842,7 @@ class EndpointContext {
|
|
|
842
842
|
let entityName = '';
|
|
843
843
|
// entity thing is only for repositories local repositories
|
|
844
844
|
// if (className === 'TaonBaseRepository') {
|
|
845
|
-
const entityFn = lib_prod_12.
|
|
845
|
+
const entityFn = (0, lib_prod_12.___NS__first)(locaInstanceConstructorArgs);
|
|
846
846
|
const entity = entityFn && entityFn();
|
|
847
847
|
entityName = (entity && (0, class_helpers_1.ClassHelpers__NS__getName)(entity)) || '';
|
|
848
848
|
// console.log(`entityName `, entityName);
|
|
@@ -905,7 +905,7 @@ class EndpointContext {
|
|
|
905
905
|
//#endregion
|
|
906
906
|
//#region methods & getters / check if context initialized
|
|
907
907
|
checkIfContextInitialized() {
|
|
908
|
-
if (lib_prod_12.
|
|
908
|
+
if ((0, lib_prod_12.___NS__isUndefined)(this.config)) {
|
|
909
909
|
throw new Error(`Please check if your context has been initialized.
|
|
910
910
|
|
|
911
911
|
// ...
|
|
@@ -1003,7 +1003,7 @@ class EndpointContext {
|
|
|
1003
1003
|
]) {
|
|
1004
1004
|
//#region init class static _ property
|
|
1005
1005
|
for (const classFun of this.getClassFunByArr(classTypeName)) {
|
|
1006
|
-
if (lib_prod_12.
|
|
1006
|
+
if ((0, lib_prod_12.___NS__isFunction)(classFun._)) {
|
|
1007
1007
|
await classFun._();
|
|
1008
1008
|
}
|
|
1009
1009
|
}
|
|
@@ -1017,15 +1017,15 @@ class EndpointContext {
|
|
|
1017
1017
|
models_1.Models__NS__ClassType.MIGRATION,
|
|
1018
1018
|
]) {
|
|
1019
1019
|
//#region init providers, repositories _ property
|
|
1020
|
-
//
|
|
1020
|
+
// Helpers__NS__taskStarted(
|
|
1021
1021
|
// `[taon] REINITING _ INS FN ${classTypeName} ${this.contextName} STARTED`,
|
|
1022
1022
|
// );
|
|
1023
1023
|
for (const ctrl of this.getClassesInstancesArrBy(classTypeName)) {
|
|
1024
|
-
if (lib_prod_12.
|
|
1024
|
+
if ((0, lib_prod_12.___NS__isFunction)(ctrl._)) {
|
|
1025
1025
|
await ctrl._();
|
|
1026
1026
|
}
|
|
1027
1027
|
}
|
|
1028
|
-
//
|
|
1028
|
+
// Helpers__NS__taskStarted(
|
|
1029
1029
|
// `[taon] REINITING _ INS FN ${classTypeName} ${this.contextName} DONE`,
|
|
1030
1030
|
// );
|
|
1031
1031
|
//#endregion
|
|
@@ -1224,7 +1224,7 @@ class EndpointContext {
|
|
|
1224
1224
|
const entities = this.getClassFunByArr(models_1.Models__NS__ClassType.ENTITY);
|
|
1225
1225
|
for (const entity of entities) {
|
|
1226
1226
|
const options = Reflect.getMetadata(symbols_1.Symbols__NS__metadata.options.entity, entity);
|
|
1227
|
-
const createTable = lib_prod_12.
|
|
1227
|
+
const createTable = (0, lib_prod_12.___NS__isUndefined)(options.createTable)
|
|
1228
1228
|
? true
|
|
1229
1229
|
: options.createTable;
|
|
1230
1230
|
const nameForEntity = (0, class_helpers_1.ClassHelpers__NS__getName)(entity);
|
|
@@ -1272,7 +1272,7 @@ class EndpointContext {
|
|
|
1272
1272
|
});
|
|
1273
1273
|
const subscribers = this.getClassFunByArr(models_1.Models__NS__ClassType.SUBSCRIBER);
|
|
1274
1274
|
let autoSave = false;
|
|
1275
|
-
if (!lib_prod_12.
|
|
1275
|
+
if (!(0, lib_prod_12.___NS__isNil)(this.databaseConfig.autoSave)) {
|
|
1276
1276
|
autoSave = this.databaseConfig.autoSave;
|
|
1277
1277
|
}
|
|
1278
1278
|
else {
|
|
@@ -1283,7 +1283,7 @@ class EndpointContext {
|
|
|
1283
1283
|
autoSave = true; // on docker with sqljs I need to save db
|
|
1284
1284
|
}
|
|
1285
1285
|
}
|
|
1286
|
-
const dataSourceDbConfig = lib_prod_12.
|
|
1286
|
+
const dataSourceDbConfig = (0, lib_prod_12.___NS__isObject)(this.databaseConfig)
|
|
1287
1287
|
? {
|
|
1288
1288
|
type: this.databaseConfig.type,
|
|
1289
1289
|
port: this.databaseConfig.databasePort,
|
|
@@ -1312,7 +1312,7 @@ class EndpointContext {
|
|
|
1312
1312
|
if (this.modeAllowsDatabaseCreation && this.databaseConfig) {
|
|
1313
1313
|
this.logDb &&
|
|
1314
1314
|
this.logFramework &&
|
|
1315
|
-
lib_prod_12.
|
|
1315
|
+
(0, lib_prod_12.Helpers__NS__info)('[taon][database] prepare typeorm connection...');
|
|
1316
1316
|
try {
|
|
1317
1317
|
const connection = new lib_prod_6.DataSource(dataSourceDbConfig);
|
|
1318
1318
|
this.connection = connection;
|
|
@@ -1354,7 +1354,7 @@ class EndpointContext {
|
|
|
1354
1354
|
// debugger;
|
|
1355
1355
|
}
|
|
1356
1356
|
else {
|
|
1357
|
-
lib_prod_12.
|
|
1357
|
+
(0, lib_prod_12.Helpers__NS__info)(`[taon][typeorm] Not initing db for mode ${this.mode}`);
|
|
1358
1358
|
}
|
|
1359
1359
|
//#endregion
|
|
1360
1360
|
}
|
|
@@ -1362,7 +1362,7 @@ class EndpointContext {
|
|
|
1362
1362
|
//#region methods & getters / initialize metadata
|
|
1363
1363
|
//#region methods & getters / update class calculate path
|
|
1364
1364
|
updateCalculatedPathsForControllers(rawConfigs, classConfig, controllerClassFn) {
|
|
1365
|
-
const parentsCalculatedPath = lib_prod_12.
|
|
1365
|
+
const parentsCalculatedPath = (0, lib_prod_12.___NS__slice)(rawConfigs, 1)
|
|
1366
1366
|
.reverse()
|
|
1367
1367
|
.map(bc => {
|
|
1368
1368
|
if ((0, taon_helpers_1.TaonHelpers__NS__isGoodPath)(bc.path)) {
|
|
@@ -1382,7 +1382,7 @@ class EndpointContext {
|
|
|
1382
1382
|
.replace(/\/\//g, '/')
|
|
1383
1383
|
.split('/')
|
|
1384
1384
|
.reduce((acc, bc) => {
|
|
1385
|
-
return lib_prod_12.
|
|
1385
|
+
return (0, lib_prod_12.___NS__last)(acc) === bc ? acc : [...acc, bc];
|
|
1386
1386
|
}, [])
|
|
1387
1387
|
.join('/');
|
|
1388
1388
|
}
|
|
@@ -1392,8 +1392,8 @@ class EndpointContext {
|
|
|
1392
1392
|
//#region methods & getters / dedupe class configs
|
|
1393
1393
|
mergeControllerMethodsConfigs(rawConfigs, classConfig, controllerClassFn) {
|
|
1394
1394
|
const currentControllerMethodsConfig = classConfig.methods;
|
|
1395
|
-
lib_prod_12.
|
|
1396
|
-
const parentControllerMethods = lib_prod_12.
|
|
1395
|
+
(0, lib_prod_12.___NS__slice)(rawConfigs, 1).forEach(bc => {
|
|
1396
|
+
const parentControllerMethods = (0, lib_prod_12.___NS__cloneDeep)(bc.methods);
|
|
1397
1397
|
for (const methodsName in parentControllerMethods) {
|
|
1398
1398
|
if (parentControllerMethods.hasOwnProperty(methodsName)) {
|
|
1399
1399
|
if (!currentControllerMethodsConfig[methodsName]) {
|
|
@@ -1414,7 +1414,7 @@ class EndpointContext {
|
|
|
1414
1414
|
const allControllers = this.getClassFunByArr(models_1.Models__NS__ClassType.CONTROLLER);
|
|
1415
1415
|
for (const controllerClassFn of allControllers) {
|
|
1416
1416
|
const instance = this.getInstanceBy(controllerClassFn);
|
|
1417
|
-
if (lib_prod_12.
|
|
1417
|
+
if ((0, lib_prod_12.___NS__isFunction)(instance.afterAllCtxInited)) {
|
|
1418
1418
|
await instance.afterAllCtxInited({ ctxStorage });
|
|
1419
1419
|
}
|
|
1420
1420
|
}
|
|
@@ -1444,7 +1444,7 @@ class EndpointContext {
|
|
|
1444
1444
|
//#region combine middlewares from controllers
|
|
1445
1445
|
classConfig.calculatedMiddlewaresControllerObj = {};
|
|
1446
1446
|
[...rawConfigs].reverse().forEach(rc => {
|
|
1447
|
-
if (lib_prod_12.
|
|
1447
|
+
if ((0, lib_prod_12.___NS__isFunction)(rc.middlewares)) {
|
|
1448
1448
|
classConfig.calculatedMiddlewaresControllerObj = rc.middlewares({
|
|
1449
1449
|
parentMiddlewares: classConfig.calculatedMiddlewaresControllerObj,
|
|
1450
1450
|
className(middlewareClass) {
|
|
@@ -1456,7 +1456,7 @@ class EndpointContext {
|
|
|
1456
1456
|
//#endregion
|
|
1457
1457
|
//#region group start
|
|
1458
1458
|
//#region @backend
|
|
1459
|
-
if (!
|
|
1459
|
+
if (!(0, lib_prod_10.UtilsOs__NS__isRunningInCliMode)()) {
|
|
1460
1460
|
//#endregion
|
|
1461
1461
|
this.logHttp &&
|
|
1462
1462
|
console.groupCollapsed(`[taon][express-server] routes [${classConfig.className}]`);
|
|
@@ -1473,7 +1473,7 @@ class EndpointContext {
|
|
|
1473
1473
|
[...rawConfigs].reverse().forEach(rc => {
|
|
1474
1474
|
if (rc.methods[methodName]) {
|
|
1475
1475
|
const parentMethodConfig = rc.methods[methodName];
|
|
1476
|
-
if (lib_prod_12.
|
|
1476
|
+
if ((0, lib_prod_12.___NS__isFunction)(parentMethodConfig.middlewares)) {
|
|
1477
1477
|
calculatedMiddlewaresMethodObj = parentMethodConfig.middlewares({
|
|
1478
1478
|
parentMiddlewares: calculatedMiddlewaresMethodObj,
|
|
1479
1479
|
className(middlewareClass) {
|
|
@@ -1504,7 +1504,7 @@ class EndpointContext {
|
|
|
1504
1504
|
//#endregion
|
|
1505
1505
|
//#region init server
|
|
1506
1506
|
// console.log({ expressPath });
|
|
1507
|
-
if (
|
|
1507
|
+
if (lib_prod_10.UtilsOs__NS__isNode || lib_prod_10.UtilsOs__NS__isWebSQL) {
|
|
1508
1508
|
//#region @websql
|
|
1509
1509
|
const route = this.initServer(httpMethodType, methodConfig, classConfig, expressPath, controllerClassFn);
|
|
1510
1510
|
this.activeRoutes.push({
|
|
@@ -1515,7 +1515,7 @@ class EndpointContext {
|
|
|
1515
1515
|
}
|
|
1516
1516
|
//#endregion
|
|
1517
1517
|
//#region init client
|
|
1518
|
-
const shouldInitClient =
|
|
1518
|
+
const shouldInitClient = lib_prod_10.UtilsOs__NS__isBrowser || this.isRemoteHost || lib_prod_10.UtilsOs__NS__isWebSQL;
|
|
1519
1519
|
// console.log('shouldInitClient', shouldInitClient);
|
|
1520
1520
|
if (shouldInitClient) {
|
|
1521
1521
|
// console.log(
|
|
@@ -1532,7 +1532,7 @@ class EndpointContext {
|
|
|
1532
1532
|
//#endregion
|
|
1533
1533
|
//#region group end
|
|
1534
1534
|
//#region @backend
|
|
1535
|
-
if (!
|
|
1535
|
+
if (!(0, lib_prod_10.UtilsOs__NS__isRunningInCliMode)()) {
|
|
1536
1536
|
//#endregion
|
|
1537
1537
|
this.logHttp && console.groupEnd();
|
|
1538
1538
|
//#region @backend
|
|
@@ -1553,7 +1553,7 @@ class EndpointContext {
|
|
|
1553
1553
|
return `${f.method} ${f.expressPath}`;
|
|
1554
1554
|
})).map(f => {
|
|
1555
1555
|
const [method, expressPath] = f.split(' ');
|
|
1556
|
-
return (`\n### ${lib_prod_12.
|
|
1556
|
+
return (`\n### ${(0, lib_prod_12.___NS__startCase)((0, lib_prod_12.___NS__last)(expressPath.split('/')))}\n` +
|
|
1557
1557
|
(0, taon_helpers_1.TaonHelpers__NS__fillUpTo)(method.toUpperCase() + ' ', 10) +
|
|
1558
1558
|
this.uriOrigin +
|
|
1559
1559
|
expressPath);
|
|
@@ -1574,7 +1574,7 @@ class EndpointContext {
|
|
|
1574
1574
|
this.logRoutes && console.log(routes);
|
|
1575
1575
|
//#region @backend
|
|
1576
1576
|
if (!lib_prod_10.UtilsOs__NS__isElectron && !this.skipWritingServerRoutes) {
|
|
1577
|
-
lib_prod_12.
|
|
1577
|
+
(0, lib_prod_12.Helpers__NS__writeFile)(fileName, routes);
|
|
1578
1578
|
}
|
|
1579
1579
|
//#endregion
|
|
1580
1580
|
//#endregion
|
|
@@ -1591,7 +1591,7 @@ class EndpointContext {
|
|
|
1591
1591
|
async initCustomClientMiddlewares() {
|
|
1592
1592
|
const middlewares = this.getClassesInstancesArrBy(models_1.Models__NS__ClassType.MIDDLEWARE)
|
|
1593
1593
|
.map(f => f)
|
|
1594
|
-
.filter(f => lib_prod_12.
|
|
1594
|
+
.filter(f => (0, lib_prod_12.___NS__isFunction)(f.interceptClient));
|
|
1595
1595
|
middlewares.forEach(middlewareInstanceName => {
|
|
1596
1596
|
const contextName = this.contextName;
|
|
1597
1597
|
const interceptorName = `${contextName}-${(0, class_helpers_1.ClassHelpers__NS__getName)(middlewareInstanceName)}`;
|
|
@@ -1616,7 +1616,7 @@ class EndpointContext {
|
|
|
1616
1616
|
const middlewares = this.getClassesInstancesArrBy(models_1.Models__NS__ClassType.MIDDLEWARE);
|
|
1617
1617
|
for (const middleware of middlewares) {
|
|
1618
1618
|
const middlewareInstance = middleware;
|
|
1619
|
-
if (lib_prod_12.
|
|
1619
|
+
if ((0, lib_prod_12.___NS__isFunction)(middlewareInstance.interceptServer)) {
|
|
1620
1620
|
const middlewareFn = (0, class_helpers_1.ClassHelpers__NS__asyncHandler)(async (req, res, next) => {
|
|
1621
1621
|
if (req.originalUrl.startsWith(`${this.uriPathnameOrNothingIfRoot}/${constants_1.apiPrefix}/${this.contextName}/`)) {
|
|
1622
1622
|
await middlewareInstance.interceptServer({
|
|
@@ -1652,7 +1652,7 @@ class EndpointContext {
|
|
|
1652
1652
|
app.use(methodOverride());
|
|
1653
1653
|
app.use(cookieParser());
|
|
1654
1654
|
if (this.session) {
|
|
1655
|
-
lib_prod_12.
|
|
1655
|
+
(0, lib_prod_12.Helpers__NS__info)('[taon][express-server] session enabled for this context ' +
|
|
1656
1656
|
this.contextName);
|
|
1657
1657
|
const { cookieMaxAge } = this.session;
|
|
1658
1658
|
const frontendHost = this.config.frontendHost;
|
|
@@ -1678,7 +1678,7 @@ class EndpointContext {
|
|
|
1678
1678
|
else {
|
|
1679
1679
|
// if(this.config?.serverLogs) {
|
|
1680
1680
|
this.logHttp &&
|
|
1681
|
-
lib_prod_12.
|
|
1681
|
+
(0, lib_prod_12.Helpers__NS__info)(`[taon][express-server] session not enabled for this context '${this.contextName}'`);
|
|
1682
1682
|
// }
|
|
1683
1683
|
app.use(cors({
|
|
1684
1684
|
// origin: "http://localhost:5555",
|
|
@@ -1735,7 +1735,7 @@ class EndpointContext {
|
|
|
1735
1735
|
.map(middlewareClassFun => {
|
|
1736
1736
|
const middlewareInstance = this.getInstanceBy(middlewareClassFun);
|
|
1737
1737
|
if (middlewareInstance &&
|
|
1738
|
-
lib_prod_12.
|
|
1738
|
+
(0, lib_prod_12.___NS__isFunction)(middlewareInstance.interceptServerMethod)) {
|
|
1739
1739
|
const middlewareFn = (0, class_helpers_1.ClassHelpers__NS__asyncHandler)(async (req, res, next) => {
|
|
1740
1740
|
await middlewareInstance.interceptServerMethod({
|
|
1741
1741
|
req,
|
|
@@ -1769,7 +1769,7 @@ class EndpointContext {
|
|
|
1769
1769
|
//#endregion
|
|
1770
1770
|
// console.log(`BACKEND: expressPath: "${expressPath}" `);
|
|
1771
1771
|
//#endregion
|
|
1772
|
-
if (
|
|
1772
|
+
if (lib_prod_10.UtilsOs__NS__isElectron) {
|
|
1773
1773
|
//#region @backend
|
|
1774
1774
|
const ipcKeyName = (0, taon_helpers_1.TaonHelpers__NS__ipcKeyNameRequest)(target, methodConfig, expressPath);
|
|
1775
1775
|
electron_1.ipcMain.on(ipcKeyName, async (event, paramsFromBrowser) => {
|
|
@@ -1787,7 +1787,7 @@ class EndpointContext {
|
|
|
1787
1787
|
if (!this.isRemoteHost) {
|
|
1788
1788
|
//#region apply dummy websql express routers
|
|
1789
1789
|
//#region @websql
|
|
1790
|
-
if (
|
|
1790
|
+
if (lib_prod_10.UtilsOs__NS__isWebSQL) {
|
|
1791
1791
|
if (!this.expressApp[httpMethodType.toLowerCase()]) {
|
|
1792
1792
|
this.expressApp[httpMethodType.toLowerCase()] = () => { };
|
|
1793
1793
|
// TODO add middlewares for WEBSQL and ELECTRON mode
|
|
@@ -1849,7 +1849,7 @@ class EndpointContext {
|
|
|
1849
1849
|
try {
|
|
1850
1850
|
const entityForParam = JSON.parse((0, taon_helpers_1.TaonHelpers__NS__firstStringOrElemFromArray)(req.headers[`${symbols_1.Symbols__NS__old.MAPPING_CONFIG_HEADER_QUERY_PARAMS}${queryParamName} `]));
|
|
1851
1851
|
let beforeTransofrm = tQuery[queryParamName];
|
|
1852
|
-
if (lib_prod_12.
|
|
1852
|
+
if ((0, lib_prod_12.___NS__isString)(beforeTransofrm)) {
|
|
1853
1853
|
try {
|
|
1854
1854
|
const paresed = (0, taon_helpers_1.TaonHelpers__NS__tryTransformParam)(beforeTransofrm);
|
|
1855
1855
|
beforeTransofrm = paresed;
|
|
@@ -1921,7 +1921,7 @@ class EndpointContext {
|
|
|
1921
1921
|
res.end(file);
|
|
1922
1922
|
//#endregion
|
|
1923
1923
|
}
|
|
1924
|
-
else if (lib_prod_12.
|
|
1924
|
+
else if ((0, lib_prod_12.___NS__isString)(result) &&
|
|
1925
1925
|
methodConfig.responseType ===
|
|
1926
1926
|
'blob') {
|
|
1927
1927
|
// console.log('BASE64')
|
|
@@ -2018,7 +2018,7 @@ class EndpointContext {
|
|
|
2018
2018
|
const middlewares = methodConfig.calculatedMiddlewares;
|
|
2019
2019
|
const middlewaresInstances = middlewares
|
|
2020
2020
|
.map(f => this.getInstanceBy(f))
|
|
2021
|
-
.filter(f => lib_prod_12.
|
|
2021
|
+
.filter(f => (0, lib_prod_12.___NS__isFunction)(f.interceptClientMethod));
|
|
2022
2022
|
middlewaresInstances.forEach(instance => {
|
|
2023
2023
|
const middlewareName = (0, class_helpers_1.ClassHelpers__NS__getName)(instance);
|
|
2024
2024
|
// middlewareName - only needed for inheritace and uniqness of interceptors
|
|
@@ -2047,7 +2047,7 @@ class EndpointContext {
|
|
|
2047
2047
|
//#endregion
|
|
2048
2048
|
const orgMethods = target.prototype[methodConfig.methodName];
|
|
2049
2049
|
//#region handle electron ipc request
|
|
2050
|
-
if (
|
|
2050
|
+
if (lib_prod_10.UtilsOs__NS__isElectron) {
|
|
2051
2051
|
const ipcRenderer = window.require('electron').ipcRenderer;
|
|
2052
2052
|
target.prototype[methodConfig.methodName] = function (...args) {
|
|
2053
2053
|
const received = new Promise(async (resolve, reject) => {
|
|
@@ -2330,7 +2330,7 @@ class EndpointContext {
|
|
|
2330
2330
|
if (mapping) {
|
|
2331
2331
|
rest.headers.set(symbols_1.Symbols__NS__old.MAPPING_CONFIG_HEADER_QUERY_PARAMS, JSON.stringify(mapping));
|
|
2332
2332
|
}
|
|
2333
|
-
queryParams = lib_prod_12.
|
|
2333
|
+
queryParams = (0, lib_prod_12.___NS__cloneDeep)(param);
|
|
2334
2334
|
}
|
|
2335
2335
|
}
|
|
2336
2336
|
if (currentParam.paramType === 'Header') {
|