taon 21.0.50 → 21.0.52

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.
Files changed (38) hide show
  1. package/browser/fesm2022/taon-browser.mjs +13 -1
  2. package/browser/fesm2022/taon-browser.mjs.map +1 -1
  3. package/browser/package.json +1 -1
  4. package/browser/types/taon-browser.d.ts +6 -6
  5. package/browser-prod/fesm2022/taon-browser.mjs +13 -1
  6. package/browser-prod/fesm2022/taon-browser.mjs.map +1 -1
  7. package/browser-prod/package.json +1 -1
  8. package/browser-prod/types/taon-browser.d.ts +6 -6
  9. package/lib/base-classes/base-file-upload.middleware.d.ts +2 -2
  10. package/lib/build-info._auto-generated_.d.ts +1 -1
  11. package/lib/build-info._auto-generated_.js +1 -1
  12. package/lib/endpoint-context.d.ts +2 -2
  13. package/lib/endpoint-context.js +97 -91
  14. package/lib/endpoint-context.js.map +1 -1
  15. package/lib/entity-process.d.ts +1 -1
  16. package/lib/entity-process.js +32 -33
  17. package/lib/entity-process.js.map +1 -1
  18. package/lib/express-types.d.ts +1 -1
  19. package/lib/package.json +1 -1
  20. package/lib/ui/index.js +2 -2
  21. package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
  22. package/lib-prod/base-classes/base-file-upload.middleware.ts +2 -2
  23. package/lib-prod/build-info._auto-generated_.ts +1 -1
  24. package/lib-prod/endpoint-context.ts +27 -17
  25. package/lib-prod/entity-process.ts +8 -5
  26. package/lib-prod/express-types.ts +1 -1
  27. package/lib-prod/package.json +1 -1
  28. package/lib-prod/ui/index.ts +1 -1
  29. package/lib-prod/ui/taon-admin-mode-configuration/index.ts +1 -1
  30. package/package.json +1 -1
  31. package/websql/fesm2022/taon-websql.mjs +13 -1
  32. package/websql/fesm2022/taon-websql.mjs.map +1 -1
  33. package/websql/package.json +1 -1
  34. package/websql/types/taon-websql.d.ts +6 -6
  35. package/websql-prod/fesm2022/taon-websql.mjs +13 -1
  36. package/websql-prod/fesm2022/taon-websql.mjs.map +1 -1
  37. package/websql-prod/package.json +1 -1
  38. package/websql-prod/types/taon-websql.d.ts +6 -6
@@ -3,17 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EndpointContext = void 0;
4
4
  const url_1 = require("url"); // @backend
5
5
  const axios_1 = require("axios");
6
- const bodyParser = require("body-parser"); // @backend
7
- const cookieParser = require("cookie-parser"); // @backend
8
- const cors = require("cors"); // @backend
9
6
  const electron_1 = require("electron"); // @backend
10
- const express = require("express");
11
- // multer in taon middleware will do better job than express-fileupload
12
- // import * as fileUpload from 'express-fileupload'; // @backend
13
- const expressSession = require("express-session"); // @backend
14
7
  const lib_1 = require("json10/lib");
15
8
  const lib_2 = require("lodash-walk-object/lib");
16
- const methodOverride = require("method-override"); // @backend
17
9
  const lib_3 = require("ng2-rest/lib");
18
10
  const rxjs_1 = require("rxjs");
19
11
  const lib_4 = require("taon-typeorm/lib"); // @websql
@@ -21,8 +13,8 @@ const lib_5 = require("taon-typeorm/lib"); // @websql
21
13
  const lib_6 = require("taon-typeorm/lib");
22
14
  const lib_7 = require("tnp-core/lib");
23
15
  const lib_8 = require("tnp-core/lib");
24
- const lib_9 = require("tnp-core/lib"); // @backend
25
- const lib_10 = require("tnp-core/lib");
16
+ const lib_9 = require("tnp-core/lib");
17
+ const lib_10 = require("tnp-core/lib"); // @backend
26
18
  const lib_11 = require("tnp-core/lib");
27
19
  const lib_12 = require("tnp-core/lib");
28
20
  const lib_13 = require("tnp-core/lib");
@@ -38,6 +30,20 @@ const realtime_core_1 = require("./realtime/realtime-core");
38
30
  const symbols_1 = require("./symbols");
39
31
  /* */
40
32
  //#endregion
33
+ let bodyParser;
34
+ let cookieParser;
35
+ let cors;
36
+ let express;
37
+ let methodOverride;
38
+ let expressSession;
39
+ //#region @backend
40
+ bodyParser = (0, lib_7.requireDefault)('body-parser');
41
+ cookieParser = (0, lib_7.requireDefault)('cookie-parser');
42
+ cors = (0, lib_7.requireDefault)('cors');
43
+ express = (0, lib_7.requireDefault)('express');
44
+ methodOverride = (0, lib_7.requireDefault)('method-override');
45
+ expressSession = (0, lib_7.requireDefault)('express-session');
46
+ //#endregion
41
47
  class EndpointContext {
42
48
  originalConfig;
43
49
  configFn;
@@ -153,37 +159,37 @@ class EndpointContext {
153
159
  //#endregion
154
160
  //#region fields / logs
155
161
  get logHttp() {
156
- if (lib_12._.isObject(this.config?.logs)) {
162
+ if (lib_13._.isObject(this.config?.logs)) {
157
163
  return !!this.config.logs.http;
158
164
  }
159
165
  return this.config?.logs === true;
160
166
  }
161
167
  get logRealtime() {
162
- if (lib_12._.isObject(this.config?.logs)) {
168
+ if (lib_13._.isObject(this.config?.logs)) {
163
169
  return !!this.config.logs.realtime;
164
170
  }
165
171
  return this.config?.logs === true;
166
172
  }
167
173
  get logFramework() {
168
- if (lib_12._.isObject(this.config?.logs)) {
174
+ if (lib_13._.isObject(this.config?.logs)) {
169
175
  return !!this.config.logs.framework;
170
176
  }
171
177
  return this.config?.logs === true;
172
178
  }
173
179
  get logRoutes() {
174
- if (lib_12._.isObject(this.config?.logs)) {
180
+ if (lib_13._.isObject(this.config?.logs)) {
175
181
  return !!this.config.logs.routes;
176
182
  }
177
183
  return this.config?.logs === true;
178
184
  }
179
185
  get logDb() {
180
- if (lib_12._.isObject(this.config?.logs)) {
186
+ if (lib_13._.isObject(this.config?.logs)) {
181
187
  return !!this.config.logs.db;
182
188
  }
183
189
  return this.config?.logs === true;
184
190
  }
185
191
  get logMigrations() {
186
- if (lib_12._.isObject(this.config?.logs)) {
192
+ if (lib_13._.isObject(this.config?.logs)) {
187
193
  return !!this.config.logs.migrations;
188
194
  }
189
195
  return this.config?.logs === true;
@@ -207,7 +213,7 @@ class EndpointContext {
207
213
  this.configFn = configFn;
208
214
  this.cloneOptions = cloneOptions;
209
215
  this.cloneOptions = this.cloneOptions || {};
210
- this.isRunningInsideDocker = lib_10.UtilsOs.isRunningInDocker();
216
+ this.isRunningInsideDocker = lib_11.UtilsOs.isRunningInDocker();
211
217
  }
212
218
  //#endregion
213
219
  //#region methods & getters / init
@@ -219,7 +225,7 @@ class EndpointContext {
219
225
  // @ts-ignore
220
226
  this.onlyMigrationRevertToTimestamp = onlyMigrationRevertToTimestamp;
221
227
  this.config = this.configFn({});
222
- if (lib_12._.isObject(this.config.database)) {
228
+ if (lib_13._.isObject(this.config.database)) {
223
229
  this.config.database = models_1.Models.DatabaseConfig.from(this.config.database).databaseConfigTypeORM;
224
230
  }
225
231
  this.config.host = this.host === null ? void 0 : this.host;
@@ -234,15 +240,15 @@ class EndpointContext {
234
240
  if (this.config.host &&
235
241
  !this.config.host.startsWith('http://') &&
236
242
  !this.config.host.startsWith('https://')) {
237
- lib_12.Helpers.throwError(`[taon-config] Your${this.host ? ' remote' : ''} 'host' must start with http:// or https://`);
243
+ lib_13.Helpers.throwError(`[taon-config] Your${this.host ? ' remote' : ''} 'host' must start with http:// or https://`);
238
244
  }
239
- if (lib_12._.isUndefined(this.config.useIpcWhenElectron)) {
245
+ if (lib_13._.isUndefined(this.config.useIpcWhenElectron)) {
240
246
  this.config.useIpcWhenElectron = true;
241
247
  }
242
248
  // console.log(`config for ${this.contextName}`, this.config);
243
249
  //#region resolve if skipping writing server routes
244
250
  //@ts-expect-error overriding readonly
245
- this.skipWritingServerRoutes = lib_12._.isBoolean(this.config.skipWritingServerRoutes)
251
+ this.skipWritingServerRoutes = lib_13._.isBoolean(this.config.skipWritingServerRoutes)
246
252
  ? this.config.skipWritingServerRoutes
247
253
  : false;
248
254
  //#endregion
@@ -259,8 +265,8 @@ class EndpointContext {
259
265
  // useIpcWhenElectron: ${this.config.useIpcWhenElectron}
260
266
  // UtilsOs.isElectron: ${UtilsOs.isElectron}
261
267
  // `)
262
- if (this.config.useIpcWhenElectron && lib_10.UtilsOs.isElectron) {
263
- if (lib_10.UtilsOs.isWebSQL) {
268
+ if (this.config.useIpcWhenElectron && lib_11.UtilsOs.isElectron) {
269
+ if (lib_11.UtilsOs.isWebSQL) {
264
270
  this.mode = 'backend-frontend(websql-electron)';
265
271
  }
266
272
  else {
@@ -275,7 +281,7 @@ class EndpointContext {
275
281
  if (!this.mode && !this.config.abstract) {
276
282
  const errMsg = `You need to provide host property or ` +
277
283
  `useIpcWhenElectron or mark it as abstract`;
278
- lib_12.Helpers.error(`[taon][Context=${this.contextName}]: ${errMsg}`, false, true);
284
+ lib_13.Helpers.error(`[taon][Context=${this.contextName}]: ${errMsg}`, false, true);
279
285
  //#region @backend
280
286
  process.exit(1);
281
287
  //#endregion
@@ -291,7 +297,7 @@ class EndpointContext {
291
297
  `);
292
298
  this.databaseConfig = this.getAutoGeneratedConfig();
293
299
  }
294
- else if (lib_12._.isObject(this.config.database)) {
300
+ else if (lib_13._.isObject(this.config.database)) {
295
301
  this.logFramework &&
296
302
  console.log(`
297
303
 
@@ -300,13 +306,13 @@ class EndpointContext {
300
306
  `);
301
307
  this.databaseConfig = this.getAutoGeneratedConfig();
302
308
  lib_2.walk.Object(this.config.database, (value, lodashPath) => {
303
- if (lib_12._.isNil(value) || lib_12._.isFunction(value) || lib_12._.isObject(value)) {
309
+ if (lib_13._.isNil(value) || lib_13._.isFunction(value) || lib_13._.isObject(value)) {
304
310
  // skipping
305
311
  }
306
312
  else {
307
313
  this.logFramework &&
308
314
  console.info(`Overriding database config: ${lodashPath}=${value}`);
309
- lib_12._.set(this.databaseConfig, lodashPath, value);
315
+ lib_13._.set(this.databaseConfig, lodashPath, value);
310
316
  }
311
317
  }, {
312
318
  walkGetters: false,
@@ -315,7 +321,7 @@ class EndpointContext {
315
321
  //#endregion
316
322
  //#region resolve session
317
323
  if (this.config.session) {
318
- this.session = lib_12._.cloneDeep(this.config.session);
324
+ this.session = lib_13._.cloneDeep(this.config.session);
319
325
  const oneHour = 1000 * 60 * 60 * 1; // 24;
320
326
  if (!this.session.cookieMaxAge) {
321
327
  this.session.cookieMaxAge = oneHour;
@@ -422,17 +428,17 @@ class EndpointContext {
422
428
  await this.initCustomBackendMiddlewares();
423
429
  const shouldStartHttpsSecureServer = this.isHttpServer && !this.isRunningInsideDocker;
424
430
  this.logFramework &&
425
- lib_12.Helpers.info(`
431
+ lib_13.Helpers.info(`
426
432
 
427
433
  Starting server ${shouldStartHttpsSecureServer ? 'with' : 'without'} HTTPS secure server
428
434
 
429
435
  `);
430
436
  this.serverTcpUdp = shouldStartHttpsSecureServer
431
- ? new lib_9.https.Server({
437
+ ? new lib_10.https.Server({
432
438
  key: this.config.https?.key,
433
439
  cert: this.config.https?.cert,
434
440
  }, this.expressApp)
435
- : new lib_9.http.Server(this.expressApp);
441
+ : new lib_10.http.Server(this.expressApp);
436
442
  this.publicAssets.forEach(asset => {
437
443
  this.expressApp.use(asset.serverPath, express.static(asset.locationOnDisk));
438
444
  });
@@ -461,7 +467,7 @@ class EndpointContext {
461
467
  // }
462
468
  //#endregion
463
469
  this.logRealtime &&
464
- lib_12.Helpers.info(`[ctx=${this.contextName}] Init Realtime for ${this.mode}`);
470
+ lib_13.Helpers.info(`[ctx=${this.contextName}] Init Realtime for ${this.mode}`);
465
471
  this.realtime = new realtime_core_1.RealtimeCore(this);
466
472
  }
467
473
  //#endregion
@@ -470,16 +476,16 @@ class EndpointContext {
470
476
  // console.log({ ref })
471
477
  if (this.config.abstract) {
472
478
  this.logFramework &&
473
- lib_12.Helpers.info(`[taon] Create abstract context: ${this.config.contextName}`);
479
+ lib_13.Helpers.info(`[taon] Create abstract context: ${this.config.contextName}`);
474
480
  }
475
481
  else {
476
482
  if (this.isRemoteHost) {
477
483
  this.logFramework &&
478
- lib_12.Helpers.info(`[taon] Create context for remote host: ${this.config.host}`);
484
+ lib_13.Helpers.info(`[taon] Create context for remote host: ${this.config.host}`);
479
485
  }
480
486
  else {
481
487
  this.logFramework &&
482
- lib_12.Helpers.info(`[taon] Create context for host: ${this.config.host}`);
488
+ lib_13.Helpers.info(`[taon] Create context for host: ${this.config.host}`);
483
489
  }
484
490
  }
485
491
  //#endregion
@@ -525,7 +531,7 @@ class EndpointContext {
525
531
 
526
532
  `);
527
533
  //#region @backend
528
- const locationOfTheDatabase = (0, lib_11.crossPlatformPath)([
534
+ const locationOfTheDatabase = (0, lib_12.crossPlatformPath)([
529
535
  process.cwd(),
530
536
  `db-${this.contextName}.sqlite`,
531
537
  ]);
@@ -538,14 +544,14 @@ class EndpointContext {
538
544
  logging: true,
539
545
  });
540
546
  //#region @backend
541
- if (!lib_9.fse.existsSync(locationOfTheDatabase)) {
547
+ if (!lib_10.fse.existsSync(locationOfTheDatabase)) {
542
548
  databaseConfig.recreateMode = 'DROP_DB+MIGRATIONS';
543
549
  }
544
550
  // TODO @LAST add same thing for mariadb/mysql
545
551
  this.logFramework &&
546
552
  console.log(`
547
553
  location of database: ${locationOfTheDatabase}
548
- db file exists: ${lib_9.fse.existsSync(locationOfTheDatabase)}
554
+ db file exists: ${lib_10.fse.existsSync(locationOfTheDatabase)}
549
555
  synchronize: ${databaseConfig.synchronize}
550
556
  dropSchema: ${databaseConfig.dropSchema}
551
557
  `);
@@ -555,24 +561,24 @@ class EndpointContext {
555
561
  else {
556
562
  //#region auto resolve db config
557
563
  this.logFramework &&
558
- lib_12.Helpers.info(`[taon][database] Automatically resolving database config for mode ${this.mode}`);
564
+ lib_13.Helpers.info(`[taon][database] Automatically resolving database config for mode ${this.mode}`);
559
565
  switch (this.mode) {
560
566
  //#region resolve database config for backend-frontend(ipc-electron)
561
567
  case 'backend-frontend(ipc-electron)':
562
568
  let dbLocationInOs;
563
569
  //#region @backend
564
- if (lib_10.UtilsOs.isElectron) {
565
- dbLocationInOs = (0, lib_11.crossPlatformPath)([
566
- lib_10.UtilsOs.getRealHomeDir(),
567
- `.taon/databases-for-electron-apps/${this.appId || lib_12._.snakeCase(process.cwd()).replace(/\_/, '.')}/${this.contextName}.sqlite`,
570
+ if (lib_11.UtilsOs.isElectron) {
571
+ dbLocationInOs = (0, lib_12.crossPlatformPath)([
572
+ lib_11.UtilsOs.getRealHomeDir(),
573
+ `.taon/databases-for-electron-apps/${this.appId || lib_13._.snakeCase(process.cwd()).replace(/\_/, '.')}/${this.contextName}.sqlite`,
568
574
  ]);
569
- if (!lib_12.Helpers.exists(lib_13.path.dirname(dbLocationInOs))) {
570
- lib_12.Helpers.mkdirp(lib_13.path.dirname(dbLocationInOs));
575
+ if (!lib_13.Helpers.exists(lib_7.path.dirname(dbLocationInOs))) {
576
+ lib_13.Helpers.mkdirp(lib_7.path.dirname(dbLocationInOs));
571
577
  }
572
578
  }
573
579
  //#endregion
574
580
  databaseConfig = models_1.Models.DatabaseConfig.from({
575
- location: lib_10.UtilsOs.isElectron
581
+ location: lib_11.UtilsOs.isElectron
576
582
  ? dbLocationInOs
577
583
  : `db-${this.contextName}.sqlite`,
578
584
  type: 'sqljs',
@@ -629,9 +635,9 @@ class EndpointContext {
629
635
  // this.displayRoutes(this.expressApp);
630
636
  this.serverTcpUdp.listen(Number(this.uriPort), '0.0.0.0', () => {
631
637
  this.logFramework &&
632
- lib_12.Helpers.log(`[ctx=${this.contextName}] Express server (inside docker) started 0.0.0.0:${this.uriPort}`);
638
+ lib_13.Helpers.log(`[ctx=${this.contextName}] Express server (inside docker) started 0.0.0.0:${this.uriPort}`);
633
639
  this.logFramework &&
634
- lib_12.Helpers.log(`[taon][express-server]listening on port: ${this.uriPort}, hostname: ${this.uriPathname},
640
+ lib_13.Helpers.log(`[taon][express-server]listening on port: ${this.uriPort}, hostname: ${this.uriPathname},
635
641
  address: ${this.uriProtocol}//localhost:${this.uriPort}${this.uriPathname}
636
642
  ExpressJS mode: ${this.expressApp.settings.env}
637
643
  `);
@@ -642,9 +648,9 @@ class EndpointContext {
642
648
  // this.displayRoutes(this.expressApp);
643
649
  this.serverTcpUdp.listen(Number(this.uriPort), () => {
644
650
  this.logFramework &&
645
- lib_12.Helpers.log(`[ctx=${this.contextName}] Express server (inside nodejs app) started on localhost:${this.uriPort}`);
651
+ lib_13.Helpers.log(`[ctx=${this.contextName}] Express server (inside nodejs app) started on localhost:${this.uriPort}`);
646
652
  this.logFramework &&
647
- lib_12.Helpers.log(`[taon][express-server]listening on port: ${this.uriPort}, hostname: ${this.uriPathname},
653
+ lib_13.Helpers.log(`[taon][express-server]listening on port: ${this.uriPort}, hostname: ${this.uriPathname},
648
654
  address: ${this.uriProtocol}//localhost:${this.uriPort}${this.uriPathname}
649
655
  expressJS mode: ${this.expressApp.settings.env}
650
656
  `);
@@ -655,7 +661,7 @@ class EndpointContext {
655
661
  }
656
662
  else {
657
663
  this.logFramework &&
658
- lib_12.Helpers.info('Ipc communication enable instead tcp/upd');
664
+ lib_13.Helpers.info('Ipc communication enable instead tcp/upd');
659
665
  }
660
666
  //#endregion
661
667
  }
@@ -763,7 +769,7 @@ class EndpointContext {
763
769
  for (const key of Object.keys(classesInput || {})) {
764
770
  const TaonBaseClass = classesInput[key];
765
771
  if (!TaonBaseClass) {
766
- lib_12.Helpers.error(`Class ${key} is not defined in context ${ctx.contextName}
772
+ lib_13.Helpers.error(`Class ${key} is not defined in context ${ctx.contextName}
767
773
 
768
774
  Please check if you have correct import in context file
769
775
 
@@ -842,7 +848,7 @@ class EndpointContext {
842
848
  let entityName = '';
843
849
  // entity thing is only for repositories local repositories
844
850
  // if (className === 'TaonBaseRepository') {
845
- const entityFn = lib_12._.first(locaInstanceConstructorArgs);
851
+ const entityFn = lib_13._.first(locaInstanceConstructorArgs);
846
852
  const entity = entityFn && entityFn();
847
853
  entityName = (entity && class_helpers_1.ClassHelpers.getName(entity)) || '';
848
854
  // console.log(`entityName `, entityName);
@@ -905,7 +911,7 @@ class EndpointContext {
905
911
  //#endregion
906
912
  //#region methods & getters / check if context initialized
907
913
  checkIfContextInitialized() {
908
- if (lib_12._.isUndefined(this.config)) {
914
+ if (lib_13._.isUndefined(this.config)) {
909
915
  throw new Error(`Please check if your context has been initialized.
910
916
 
911
917
  // ...
@@ -1003,7 +1009,7 @@ class EndpointContext {
1003
1009
  ]) {
1004
1010
  //#region init class static _ property
1005
1011
  for (const classFun of this.getClassFunByArr(classTypeName)) {
1006
- if (lib_12._.isFunction(classFun._)) {
1012
+ if (lib_13._.isFunction(classFun._)) {
1007
1013
  await classFun._();
1008
1014
  }
1009
1015
  }
@@ -1021,7 +1027,7 @@ class EndpointContext {
1021
1027
  // `[taon] REINITING _ INS FN ${classTypeName} ${this.contextName} STARTED`,
1022
1028
  // );
1023
1029
  for (const ctrl of this.getClassesInstancesArrBy(classTypeName)) {
1024
- if (lib_12._.isFunction(ctrl._)) {
1030
+ if (lib_13._.isFunction(ctrl._)) {
1025
1031
  await ctrl._();
1026
1032
  }
1027
1033
  }
@@ -1224,7 +1230,7 @@ class EndpointContext {
1224
1230
  const entities = this.getClassFunByArr(models_1.Models.ClassType.ENTITY);
1225
1231
  for (const entity of entities) {
1226
1232
  const options = Reflect.getMetadata(symbols_1.Symbols.metadata.options.entity, entity);
1227
- const createTable = lib_12._.isUndefined(options.createTable)
1233
+ const createTable = lib_13._.isUndefined(options.createTable)
1228
1234
  ? true
1229
1235
  : options.createTable;
1230
1236
  const nameForEntity = class_helpers_1.ClassHelpers.getName(entity);
@@ -1272,7 +1278,7 @@ class EndpointContext {
1272
1278
  });
1273
1279
  const subscribers = this.getClassFunByArr(models_1.Models.ClassType.SUBSCRIBER);
1274
1280
  let autoSave = false;
1275
- if (!lib_12._.isNil(this.databaseConfig.autoSave)) {
1281
+ if (!lib_13._.isNil(this.databaseConfig.autoSave)) {
1276
1282
  autoSave = this.databaseConfig.autoSave;
1277
1283
  }
1278
1284
  else {
@@ -1283,7 +1289,7 @@ class EndpointContext {
1283
1289
  autoSave = true; // on docker with sqljs I need to save db
1284
1290
  }
1285
1291
  }
1286
- const dataSourceDbConfig = lib_12._.isObject(this.databaseConfig)
1292
+ const dataSourceDbConfig = lib_13._.isObject(this.databaseConfig)
1287
1293
  ? {
1288
1294
  type: this.databaseConfig.type,
1289
1295
  port: this.databaseConfig.databasePort,
@@ -1312,7 +1318,7 @@ class EndpointContext {
1312
1318
  if (this.modeAllowsDatabaseCreation && this.databaseConfig) {
1313
1319
  this.logDb &&
1314
1320
  this.logFramework &&
1315
- lib_12.Helpers.info('[taon][database] prepare typeorm connection...');
1321
+ lib_13.Helpers.info('[taon][database] prepare typeorm connection...');
1316
1322
  try {
1317
1323
  const connection = new lib_6.DataSource(dataSourceDbConfig);
1318
1324
  this.connection = connection;
@@ -1354,7 +1360,7 @@ class EndpointContext {
1354
1360
  // debugger;
1355
1361
  }
1356
1362
  else {
1357
- lib_12.Helpers.info(`[taon][typeorm] Not initing db for mode ${this.mode}`);
1363
+ lib_13.Helpers.info(`[taon][typeorm] Not initing db for mode ${this.mode}`);
1358
1364
  }
1359
1365
  //#endregion
1360
1366
  }
@@ -1362,7 +1368,7 @@ class EndpointContext {
1362
1368
  //#region methods & getters / initialize metadata
1363
1369
  //#region methods & getters / update class calculate path
1364
1370
  updateCalculatedPathsForControllers(rawConfigs, classConfig, controllerClassFn) {
1365
- const parentsCalculatedPath = lib_12._.slice(rawConfigs, 1)
1371
+ const parentsCalculatedPath = lib_13._.slice(rawConfigs, 1)
1366
1372
  .reverse()
1367
1373
  .map(bc => {
1368
1374
  if (taon_helpers_1.TaonHelpers.isGoodPath(bc.path)) {
@@ -1382,7 +1388,7 @@ class EndpointContext {
1382
1388
  .replace(/\/\//g, '/')
1383
1389
  .split('/')
1384
1390
  .reduce((acc, bc) => {
1385
- return lib_12._.last(acc) === bc ? acc : [...acc, bc];
1391
+ return lib_13._.last(acc) === bc ? acc : [...acc, bc];
1386
1392
  }, [])
1387
1393
  .join('/');
1388
1394
  }
@@ -1392,8 +1398,8 @@ class EndpointContext {
1392
1398
  //#region methods & getters / dedupe class configs
1393
1399
  mergeControllerMethodsConfigs(rawConfigs, classConfig, controllerClassFn) {
1394
1400
  const currentControllerMethodsConfig = classConfig.methods;
1395
- lib_12._.slice(rawConfigs, 1).forEach(bc => {
1396
- const parentControllerMethods = lib_12._.cloneDeep(bc.methods);
1401
+ lib_13._.slice(rawConfigs, 1).forEach(bc => {
1402
+ const parentControllerMethods = lib_13._.cloneDeep(bc.methods);
1397
1403
  for (const methodsName in parentControllerMethods) {
1398
1404
  if (parentControllerMethods.hasOwnProperty(methodsName)) {
1399
1405
  if (!currentControllerMethodsConfig[methodsName]) {
@@ -1414,7 +1420,7 @@ class EndpointContext {
1414
1420
  const allControllers = this.getClassFunByArr(models_1.Models.ClassType.CONTROLLER);
1415
1421
  for (const controllerClassFn of allControllers) {
1416
1422
  const instance = this.getInstanceBy(controllerClassFn);
1417
- if (lib_12._.isFunction(instance.afterAllCtxInited)) {
1423
+ if (lib_13._.isFunction(instance.afterAllCtxInited)) {
1418
1424
  await instance.afterAllCtxInited({ ctxStorage });
1419
1425
  }
1420
1426
  }
@@ -1444,7 +1450,7 @@ class EndpointContext {
1444
1450
  //#region combine middlewares from controllers
1445
1451
  classConfig.calculatedMiddlewaresControllerObj = {};
1446
1452
  [...rawConfigs].reverse().forEach(rc => {
1447
- if (lib_12._.isFunction(rc.middlewares)) {
1453
+ if (lib_13._.isFunction(rc.middlewares)) {
1448
1454
  classConfig.calculatedMiddlewaresControllerObj = rc.middlewares({
1449
1455
  parentMiddlewares: classConfig.calculatedMiddlewaresControllerObj,
1450
1456
  className(middlewareClass) {
@@ -1456,7 +1462,7 @@ class EndpointContext {
1456
1462
  //#endregion
1457
1463
  //#region group start
1458
1464
  //#region @backend
1459
- if (!lib_10.UtilsOs.isRunningInCliMode()) {
1465
+ if (!lib_11.UtilsOs.isRunningInCliMode()) {
1460
1466
  //#endregion
1461
1467
  this.logHttp &&
1462
1468
  console.groupCollapsed(`[taon][express-server] routes [${classConfig.className}]`);
@@ -1473,7 +1479,7 @@ class EndpointContext {
1473
1479
  [...rawConfigs].reverse().forEach(rc => {
1474
1480
  if (rc.methods[methodName]) {
1475
1481
  const parentMethodConfig = rc.methods[methodName];
1476
- if (lib_12._.isFunction(parentMethodConfig.middlewares)) {
1482
+ if (lib_13._.isFunction(parentMethodConfig.middlewares)) {
1477
1483
  calculatedMiddlewaresMethodObj = parentMethodConfig.middlewares({
1478
1484
  parentMiddlewares: calculatedMiddlewaresMethodObj,
1479
1485
  className(middlewareClass) {
@@ -1504,7 +1510,7 @@ class EndpointContext {
1504
1510
  //#endregion
1505
1511
  //#region init server
1506
1512
  // console.log({ expressPath });
1507
- if (lib_10.UtilsOs.isNode || lib_10.UtilsOs.isWebSQL) {
1513
+ if (lib_11.UtilsOs.isNode || lib_11.UtilsOs.isWebSQL) {
1508
1514
  //#region @websql
1509
1515
  const route = this.initServer(httpMethodType, methodConfig, classConfig, expressPath, controllerClassFn);
1510
1516
  this.activeRoutes.push({
@@ -1515,7 +1521,7 @@ class EndpointContext {
1515
1521
  }
1516
1522
  //#endregion
1517
1523
  //#region init client
1518
- const shouldInitClient = lib_10.UtilsOs.isBrowser || this.isRemoteHost || lib_10.UtilsOs.isWebSQL;
1524
+ const shouldInitClient = lib_11.UtilsOs.isBrowser || this.isRemoteHost || lib_11.UtilsOs.isWebSQL;
1519
1525
  // console.log('shouldInitClient', shouldInitClient);
1520
1526
  if (shouldInitClient) {
1521
1527
  // console.log(
@@ -1532,7 +1538,7 @@ class EndpointContext {
1532
1538
  //#endregion
1533
1539
  //#region group end
1534
1540
  //#region @backend
1535
- if (!lib_10.UtilsOs.isRunningInCliMode()) {
1541
+ if (!lib_11.UtilsOs.isRunningInCliMode()) {
1536
1542
  //#endregion
1537
1543
  this.logHttp && console.groupEnd();
1538
1544
  //#region @backend
@@ -1549,11 +1555,11 @@ class EndpointContext {
1549
1555
  }
1550
1556
  // const contexts: EndpointContext[] = [this];
1551
1557
  //#region @websql
1552
- const troutes = lib_10.Utils.uniqArray(this.activeRoutes.map(f => {
1558
+ const troutes = lib_11.Utils.uniqArray(this.activeRoutes.map(f => {
1553
1559
  return `${f.method} ${f.expressPath}`;
1554
1560
  })).map(f => {
1555
1561
  const [method, expressPath] = f.split(' ');
1556
- return (`\n### ${lib_12._.startCase(lib_12._.last(expressPath.split('/')))}\n` +
1562
+ return (`\n### ${lib_13._.startCase(lib_13._.last(expressPath.split('/')))}\n` +
1557
1563
  taon_helpers_1.TaonHelpers.fillUpTo(method.toUpperCase() + ' ', 10) +
1558
1564
  this.uriOrigin +
1559
1565
  expressPath);
@@ -1564,7 +1570,7 @@ class EndpointContext {
1564
1570
  ...['', `# ROUTES FOR HOST ${this.uriOrigin} `],
1565
1571
  ...troutes,
1566
1572
  ].join('\n');
1567
- const fileName = (0, lib_11.crossPlatformPath)([
1573
+ const fileName = (0, lib_12.crossPlatformPath)([
1568
1574
  //#region @backend
1569
1575
  process.cwd(),
1570
1576
  //#endregion
@@ -1573,8 +1579,8 @@ class EndpointContext {
1573
1579
  this.logFramework && console.log(`[taon] routes file: ${fileName} `);
1574
1580
  this.logRoutes && console.log(routes);
1575
1581
  //#region @backend
1576
- if (!lib_10.UtilsOs.isElectron && !this.skipWritingServerRoutes) {
1577
- lib_12.Helpers.writeFile(fileName, routes);
1582
+ if (!lib_11.UtilsOs.isElectron && !this.skipWritingServerRoutes) {
1583
+ lib_13.Helpers.writeFile(fileName, routes);
1578
1584
  }
1579
1585
  //#endregion
1580
1586
  //#endregion
@@ -1591,7 +1597,7 @@ class EndpointContext {
1591
1597
  async initCustomClientMiddlewares() {
1592
1598
  const middlewares = this.getClassesInstancesArrBy(models_1.Models.ClassType.MIDDLEWARE)
1593
1599
  .map(f => f)
1594
- .filter(f => lib_12._.isFunction(f.interceptClient));
1600
+ .filter(f => lib_13._.isFunction(f.interceptClient));
1595
1601
  middlewares.forEach(middlewareInstanceName => {
1596
1602
  const contextName = this.contextName;
1597
1603
  const interceptorName = `${contextName}-${class_helpers_1.ClassHelpers.getName(middlewareInstanceName)}`;
@@ -1616,7 +1622,7 @@ class EndpointContext {
1616
1622
  const middlewares = this.getClassesInstancesArrBy(models_1.Models.ClassType.MIDDLEWARE);
1617
1623
  for (const middleware of middlewares) {
1618
1624
  const middlewareInstance = middleware;
1619
- if (lib_12._.isFunction(middlewareInstance.interceptServer)) {
1625
+ if (lib_13._.isFunction(middlewareInstance.interceptServer)) {
1620
1626
  const middlewareFn = class_helpers_1.ClassHelpers.asyncHandler(async (req, res, next) => {
1621
1627
  if (req.originalUrl.startsWith(`${this.uriPathnameOrNothingIfRoot}/${constants_1.apiPrefix}/${this.contextName}/`)) {
1622
1628
  await middlewareInstance.interceptServer({
@@ -1652,7 +1658,7 @@ class EndpointContext {
1652
1658
  app.use(methodOverride());
1653
1659
  app.use(cookieParser());
1654
1660
  if (this.session) {
1655
- lib_12.Helpers.info('[taon][express-server] session enabled for this context ' +
1661
+ lib_13.Helpers.info('[taon][express-server] session enabled for this context ' +
1656
1662
  this.contextName);
1657
1663
  const { cookieMaxAge } = this.session;
1658
1664
  const frontendHost = this.config.frontendHost;
@@ -1678,7 +1684,7 @@ class EndpointContext {
1678
1684
  else {
1679
1685
  // if(this.config?.serverLogs) {
1680
1686
  this.logHttp &&
1681
- lib_12.Helpers.info(`[taon][express-server] session not enabled for this context '${this.contextName}'`);
1687
+ lib_13.Helpers.info(`[taon][express-server] session not enabled for this context '${this.contextName}'`);
1682
1688
  // }
1683
1689
  app.use(cors({
1684
1690
  // origin: "http://localhost:5555",
@@ -1735,7 +1741,7 @@ class EndpointContext {
1735
1741
  .map(middlewareClassFun => {
1736
1742
  const middlewareInstance = this.getInstanceBy(middlewareClassFun);
1737
1743
  if (middlewareInstance &&
1738
- lib_12._.isFunction(middlewareInstance.interceptServerMethod)) {
1744
+ lib_13._.isFunction(middlewareInstance.interceptServerMethod)) {
1739
1745
  const middlewareFn = class_helpers_1.ClassHelpers.asyncHandler(async (req, res, next) => {
1740
1746
  await middlewareInstance.interceptServerMethod({
1741
1747
  req,
@@ -1769,7 +1775,7 @@ class EndpointContext {
1769
1775
  //#endregion
1770
1776
  // console.log(`BACKEND: expressPath: "${expressPath}" `);
1771
1777
  //#endregion
1772
- if (lib_10.UtilsOs.isElectron) {
1778
+ if (lib_11.UtilsOs.isElectron) {
1773
1779
  //#region @backend
1774
1780
  const ipcKeyName = taon_helpers_1.TaonHelpers.ipcKeyNameRequest(target, methodConfig, expressPath);
1775
1781
  electron_1.ipcMain.on(ipcKeyName, async (event, paramsFromBrowser) => {
@@ -1787,7 +1793,7 @@ class EndpointContext {
1787
1793
  if (!this.isRemoteHost) {
1788
1794
  //#region apply dummy websql express routers
1789
1795
  //#region @websql
1790
- if (lib_10.UtilsOs.isWebSQL) {
1796
+ if (lib_11.UtilsOs.isWebSQL) {
1791
1797
  if (!this.expressApp[httpMethodType.toLowerCase()]) {
1792
1798
  this.expressApp[httpMethodType.toLowerCase()] = () => { };
1793
1799
  // TODO add middlewares for WEBSQL and ELECTRON mode
@@ -1849,7 +1855,7 @@ class EndpointContext {
1849
1855
  try {
1850
1856
  const entityForParam = JSON.parse(taon_helpers_1.TaonHelpers.firstStringOrElemFromArray(req.headers[`${symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS}${queryParamName} `]));
1851
1857
  let beforeTransofrm = tQuery[queryParamName];
1852
- if (lib_12._.isString(beforeTransofrm)) {
1858
+ if (lib_13._.isString(beforeTransofrm)) {
1853
1859
  try {
1854
1860
  const paresed = taon_helpers_1.TaonHelpers.tryTransformParam(beforeTransofrm);
1855
1861
  beforeTransofrm = paresed;
@@ -1921,7 +1927,7 @@ class EndpointContext {
1921
1927
  res.end(file);
1922
1928
  //#endregion
1923
1929
  }
1924
- else if (lib_12._.isString(result) &&
1930
+ else if (lib_13._.isString(result) &&
1925
1931
  methodConfig.responseType ===
1926
1932
  'blob') {
1927
1933
  // console.log('BASE64')
@@ -1999,7 +2005,7 @@ class EndpointContext {
1999
2005
  message,
2000
2006
  details,
2001
2007
  code,
2002
- [lib_8.CoreModels.TaonHttpErrorCustomProp]: true,
2008
+ [lib_9.CoreModels.TaonHttpErrorCustomProp]: true,
2003
2009
  });
2004
2010
  //#endregion
2005
2011
  }
@@ -2018,7 +2024,7 @@ class EndpointContext {
2018
2024
  const middlewares = methodConfig.calculatedMiddlewares;
2019
2025
  const middlewaresInstances = middlewares
2020
2026
  .map(f => this.getInstanceBy(f))
2021
- .filter(f => lib_12._.isFunction(f.interceptClientMethod));
2027
+ .filter(f => lib_13._.isFunction(f.interceptClientMethod));
2022
2028
  middlewaresInstances.forEach(instance => {
2023
2029
  const middlewareName = class_helpers_1.ClassHelpers.getName(instance);
2024
2030
  // middlewareName - only needed for inheritace and uniqness of interceptors
@@ -2047,7 +2053,7 @@ class EndpointContext {
2047
2053
  //#endregion
2048
2054
  const orgMethods = target.prototype[methodConfig.methodName];
2049
2055
  //#region handle electron ipc request
2050
- if (lib_10.UtilsOs.isElectron) {
2056
+ if (lib_11.UtilsOs.isElectron) {
2051
2057
  const ipcRenderer = window.require('electron').ipcRenderer;
2052
2058
  target.prototype[methodConfig.methodName] = function (...args) {
2053
2059
  const received = new Promise(async (resolve, reject) => {
@@ -2306,7 +2312,7 @@ class EndpointContext {
2306
2312
  }
2307
2313
  }
2308
2314
  if (!currentParam) {
2309
- const errorMessage = `[${lib_7.config.frameworkName}] Unable to resolve parameter` +
2315
+ const errorMessage = `[${lib_8.config.frameworkName}] Unable to resolve parameter` +
2310
2316
  ` at index ${i} for method ${methodConfig.methodName} at path ${expressPath}.`;
2311
2317
  //#region @backend
2312
2318
  console.error(errorMessage);
@@ -2330,7 +2336,7 @@ class EndpointContext {
2330
2336
  if (mapping) {
2331
2337
  rest.headers.set(symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS, JSON.stringify(mapping));
2332
2338
  }
2333
- queryParams = lib_12._.cloneDeep(param);
2339
+ queryParams = lib_13._.cloneDeep(param);
2334
2340
  }
2335
2341
  }
2336
2342
  if (currentParam.paramType === 'Header') {