taon 21.0.89 → 21.0.91

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 (65) hide show
  1. package/VERIFIED-BUILD-DATA.jsonc +5 -0
  2. package/bin/taon +5 -5
  3. package/bin/taon-debug +5 -5
  4. package/bin/taon-debug-brk +4 -4
  5. package/browser/fesm2022/taon-browser.mjs +1097 -1190
  6. package/browser/fesm2022/taon-browser.mjs.map +1 -1
  7. package/browser/package.json +1 -1
  8. package/browser/types/taon-browser.d.ts +261 -256
  9. package/browser-prod/fesm2022/taon-browser-prod.mjs +1098 -1191
  10. package/browser-prod/fesm2022/taon-browser-prod.mjs.map +1 -1
  11. package/browser-prod/package.json +1 -1
  12. package/browser-prod/types/taon-browser-prod.d.ts +259 -254
  13. package/icon-menu-taon.svg +15 -15
  14. package/lib/base-classes/base-context.js +1 -2
  15. package/lib/base-classes/base-context.js.map +1 -1
  16. package/lib/build-info._auto-generated_.d.ts +1 -1
  17. package/lib/build-info._auto-generated_.js +1 -1
  18. package/lib/create-context.js +6 -0
  19. package/lib/create-context.js.map +1 -1
  20. package/lib/endpoint-context.d.ts +7 -1
  21. package/lib/endpoint-context.js +18 -1
  22. package/lib/endpoint-context.js.map +1 -1
  23. package/lib/package.json +1 -1
  24. package/lib/realtime/realtime-client.js +20 -9
  25. package/lib/realtime/realtime-client.js.map +1 -1
  26. package/lib/realtime/realtime-core.js +9 -4
  27. package/lib/realtime/realtime-core.js.map +1 -1
  28. package/lib/realtime/realtime-server.js +8 -2
  29. package/lib/realtime/realtime-server.js.map +1 -1
  30. package/lib/ui/index.js +2 -2
  31. package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
  32. package/lib-prod/base-classes/base-context.js +1 -2
  33. package/lib-prod/base-classes/base-context.js.map +1 -1
  34. package/lib-prod/base-classes/base-controller.js.map +1 -1
  35. package/lib-prod/build-info._auto-generated_.d.ts +1 -1
  36. package/lib-prod/build-info._auto-generated_.js +1 -1
  37. package/lib-prod/create-context.js +6 -0
  38. package/lib-prod/create-context.js.map +1 -1
  39. package/lib-prod/decorators/http/http-methods-decorators.js.map +1 -1
  40. package/lib-prod/endpoint-context-storage.js.map +1 -1
  41. package/lib-prod/endpoint-context.d.ts +7 -1
  42. package/lib-prod/endpoint-context.js +18 -1
  43. package/lib-prod/endpoint-context.js.map +1 -1
  44. package/lib-prod/helpers/class-helpers.js.map +1 -1
  45. package/lib-prod/index.js.map +1 -1
  46. package/lib-prod/package.json +1 -1
  47. package/lib-prod/realtime/realtime-client.js +20 -9
  48. package/lib-prod/realtime/realtime-client.js.map +1 -1
  49. package/lib-prod/realtime/realtime-core.js +9 -4
  50. package/lib-prod/realtime/realtime-core.js.map +1 -1
  51. package/lib-prod/realtime/realtime-server.js +8 -2
  52. package/lib-prod/realtime/realtime-server.js.map +1 -1
  53. package/lib-prod/ui/index.d.ts +1 -1
  54. package/lib-prod/ui/index.js +1 -1
  55. package/lib-prod/ui/taon-admin-mode-configuration/index.d.ts +1 -1
  56. package/lib-prod/ui/taon-admin-mode-configuration/index.js +1 -1
  57. package/package.json +1 -1
  58. package/websql/fesm2022/taon-websql.mjs +835 -1024
  59. package/websql/fesm2022/taon-websql.mjs.map +1 -1
  60. package/websql/package.json +1 -1
  61. package/websql/types/taon-websql.d.ts +261 -256
  62. package/websql-prod/fesm2022/taon-websql-prod.mjs +837 -1025
  63. package/websql-prod/fesm2022/taon-websql-prod.mjs.map +1 -1
  64. package/websql-prod/package.json +1 -1
  65. package/websql-prod/types/taon-websql-prod.d.ts +259 -254
@@ -3,19 +3,19 @@ import { ___NS__camelCase, ___NS__isUndefined, ___NS__isArray, ___NS__isFunction
3
3
  import axios from 'axios';
4
4
  import { JSON10 } from 'json10/browser-prod';
5
5
  import { walk } from 'lodash-walk-object/browser-prod';
6
- import { RestResponseWrapper, Resource__NS__globalInterceptors, Resource__NS__methodsInterceptors, HttpResponse, RestHeaders, Resource__NS__create, decodeMappingForHeaderJson, Resource__NS__Cookies, DefaultMapping, DefaultModel, HttpResponseError } from 'ng2-rest/browser-prod';
6
+ import { RestResponseWrapper, Resource__NS__globalInterceptors, Resource__NS__methodsInterceptors, HttpResponse, RestHeaders, Resource__NS__create, decodeMappingForHeaderJson, Resource__NS__Cookies, HttpResponseError, DefaultMapping, DefaultModel } from 'ng2-rest/browser-prod';
7
7
  import { Observable, from, Subject } from 'rxjs';
8
8
  import * as i0 from '@angular/core';
9
9
  import { InjectionToken, Injectable, signal, inject as inject$1, PLATFORM_ID, ViewContainerRef, ViewChild, Component } from '@angular/core';
10
10
  import { Table, Column } from 'taon-typeorm/browser-prod';
11
11
  export { AfterInsert, AfterLoad, AfterRecover, AfterRemove, AfterSoftRemove, AfterUpdate, BeforeInsert, BeforeRecover, BeforeRemove, BeforeSoftRemove, BeforeUpdate, Column, Connection, CreateDateColumn, Column as CustomColumn, DeleteDateColumn, Generated, Generated as GeneratedColumn, Index, JoinColumn, JoinTable, ManyToMany, ManyToOne, OneToMany, OneToOne, PrimaryColumn, PrimaryGeneratedColumn, Repository, TreeChildren, TreeParent, UpdateDateColumn, VersionColumn, VirtualColumn } from 'taon-typeorm/browser-prod';
12
- import { CLASS__NS__getName, CLASS__NS__setName, CLASS__NS__getBy } from 'typescript-class-helpers/browser-prod';
12
+ import { CLASS__NS__getName, CLASS__NS__getBy, CLASS__NS__setName } from 'typescript-class-helpers/browser-prod';
13
13
  import * as JSON5 from 'json5';
14
14
  import { io } from 'socket.io-client';
15
15
  import { TaonStor__NS__inLocalstorage } from 'taon-storage/browser-prod';
16
16
  import * as i1 from '@angular/cdk/layout';
17
17
  import { isPlatformServer, isPlatformBrowser } from '@angular/common';
18
- import { __decorate, __param, __metadata } from 'tslib';
18
+ import { __decorate, __metadata, __param } from 'tslib';
19
19
  import * as i1$1 from '@ngx-formly/core';
20
20
  import { FieldWrapper, FieldArrayType } from '@ngx-formly/core';
21
21
 
@@ -1338,18 +1338,29 @@ class RealtimeClient {
1338
1338
  realtime: this.core.pathFor(Symbols__NS__REALTIME.NAMESPACE(this.core.ctx.contextName)),
1339
1339
  };
1340
1340
  // console.log('[browser] nspPath', nspPath);
1341
- if (this.core.ctx.config.frontendHost &&
1342
- this.core.ctx.config.frontendHost !== '' &&
1343
- this.core.ctx.isRunningInsideDocker) {
1341
+ if (this.core.ctx.isRemoteHost) {
1342
+ // NEED for remote host
1343
+ const nodeClientHostOrigin = this.core.ctx.host;
1344
1344
  this.core.ctx.logRealtime &&
1345
- Helpers__NS__logInfo(`[${this.core.ctx.contextName}] USING FRONTEND HOST` +
1346
- ` ${this.core.ctx.config.frontendHost} FOR REALTIME`);
1347
- nspPath.global = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.global.pathname}`);
1348
- nspPath.realtime = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.realtime.pathname}`);
1345
+ Helpers__NS__logInfo(`[${this.core.ctx.contextName}] USING REMOTE FRONTEND HOST` +
1346
+ ` ${nodeClientHostOrigin} FOR REMOTE REALTIME`);
1347
+ nspPath.global = new URL(`${nodeClientHostOrigin}${nspPath.global.pathname}`);
1348
+ nspPath.realtime = new URL(`${nodeClientHostOrigin}${nspPath.realtime.pathname}`);
1349
1349
  }
1350
1350
  else {
1351
- this.core.ctx.logRealtime &&
1352
- Helpers__NS__logInfo(`[${this.core.ctx.contextName}] Not using frontend host for realtime`);
1351
+ if (this.core.ctx.config.frontendHost &&
1352
+ this.core.ctx.config.frontendHost !== '' &&
1353
+ this.core.ctx.isRunningInsideDocker) {
1354
+ this.core.ctx.logRealtime &&
1355
+ Helpers__NS__logInfo(`[${this.core.ctx.contextName}] USING FRONTEND HOST` +
1356
+ ` ${this.core.ctx.config.frontendHost} FOR REALTIME`);
1357
+ nspPath.global = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.global.pathname}`);
1358
+ nspPath.realtime = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.realtime.pathname}`);
1359
+ }
1360
+ else {
1361
+ this.core.ctx.logRealtime &&
1362
+ Helpers__NS__logInfo(`[${this.core.ctx.contextName}] Not using frontend host for realtime`);
1363
+ }
1353
1364
  }
1354
1365
  this.core.ctx.logRealtime &&
1355
1366
  console.info('[CLIENT] NAMESPACE GLOBAL ', nspPath.global.href + ` host: ${this.core.ctx.host}`);
@@ -1519,7 +1530,7 @@ class RealtimeServer {
1519
1530
  constructor(core) {
1520
1531
  this.core = core;
1521
1532
  this.core = core;
1522
- if (core.ctx.disabledRealtime || this.core.ctx.isRemoteHost) {
1533
+ if (core.ctx.disabledRealtime) {
1523
1534
  return;
1524
1535
  }
1525
1536
  /* */
@@ -1757,6 +1768,16 @@ class RealtimeServer {
1757
1768
  /* */
1758
1769
  /* */
1759
1770
  /* */
1771
+ /* */
1772
+ /* */
1773
+ /* */
1774
+ /* */
1775
+ /* */
1776
+ /* */
1777
+ /* */
1778
+ /* */
1779
+ /* */
1780
+ /* */
1760
1781
  }
1761
1782
  //#endregion
1762
1783
  //#region entity changes
@@ -2465,10 +2486,15 @@ class RealtimeCore {
2465
2486
  ];
2466
2487
  this.ctx = ctx;
2467
2488
  this.strategy = this.resolveStrategy();
2468
- // this.ctx.logRealtime &&
2469
- // console.log(`
2470
- // [ctx=${this.ctx.contextName}] realtime strategy: ${this.strategy}, context type: ${this.ctx.contextType}
2471
- // `);
2489
+ this.ctx.logRealtime &&
2490
+ console.log(`
2491
+
2492
+ [ctx=${this.ctx.contextName}]
2493
+ mode = ${this.ctx.mode}
2494
+ realtime strategy = ${this.strategy}
2495
+ context type = ${this.ctx.contextType}
2496
+
2497
+ `);
2472
2498
  if (UtilsOs__NS__isWebSQL) {
2473
2499
  this.server = new RealtimeServer(this);
2474
2500
  // console.log('DONE INITING SERVER');
@@ -2546,9 +2572,23 @@ class EndpointContext {
2546
2572
  get isRunOrRevertOnlyMigrationAppStart() {
2547
2573
  return !!(this.onlyMigrationRun || this.onlyMigrationRevertToTimestamp);
2548
2574
  }
2575
+ get realtime() {
2576
+ if (!this._realtime) {
2577
+ throw new Error(`Please initialize context before accessing
2578
+ .realtime.client or realtime.server properties.
2579
+
2580
+ `);
2581
+ }
2582
+ return this._realtime;
2583
+ }
2584
+ set realtime(v) {
2585
+ this._realtime = v;
2586
+ }
2587
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
2549
2588
  get realtimeClient() {
2550
2589
  return this.realtime.client;
2551
2590
  }
2591
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
2552
2592
  get realtimeServer() {
2553
2593
  return this.realtime.server;
2554
2594
  }
@@ -3492,6 +3532,8 @@ class EndpointContext {
3492
3532
  /* */
3493
3533
  /* */
3494
3534
  /* */
3535
+ /* */
3536
+ /* */
3495
3537
  for (const classTypeName of [
3496
3538
  Models__NS__ClassType.MIDDLEWARE,
3497
3539
  Models__NS__ClassType.PROVIDER,
@@ -3699,6 +3741,9 @@ class EndpointContext {
3699
3741
  }
3700
3742
  //#endregion
3701
3743
  //#region methods & getters / init subscribers
3744
+ /**
3745
+ * init typeorm subscribers
3746
+ */
3702
3747
  async initSubscribers() {
3703
3748
  /* */
3704
3749
  /* */
@@ -5478,9 +5523,15 @@ const createContextFn = (configFn, cloneOptions) => {
5478
5523
  get realtime() {
5479
5524
  return {
5480
5525
  get client() {
5526
+ if (!endpointContextRef) {
5527
+ throw new Error(`Please .initialize() context before using <context>.realtime.client.<anything> `);
5528
+ }
5481
5529
  return endpointContextRef.realtimeClient;
5482
5530
  },
5483
5531
  get server() {
5532
+ if (!endpointContextRef) {
5533
+ throw new Error(`Please .initialize() context before using <context>.realtime.server.<anything> `);
5534
+ }
5484
5535
  return endpointContextRef.realtimeServer;
5485
5536
  },
5486
5537
  };
@@ -5954,208 +6005,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImpor
5954
6005
  type: Injectable
5955
6006
  }], ctorParameters: () => [] });
5956
6007
 
5957
- /**
5958
- * Entity decorator
5959
- */
5960
- function TaonEntity(options) {
5961
- return function (constructor) {
5962
- options = options || {};
5963
- options.uniqueKeyProp = options.uniqueKeyProp || 'id';
5964
- if (!options.className) {
5965
- const nameForClass = constructor?.name || 'AnyClass';
5966
- throw `Please define 'classname' property inside decorator of class '${nameForClass}':
5967
-
5968
- @TaonEntity({
5969
- className: '${nameForClass}'
5970
- })
5971
- class ${constructor?.name} {
5972
- //...
5973
-
5974
- `;
5975
- }
5976
- ClassHelpers__NS__setName(constructor, options?.className);
5977
- DefaultMapping(options?.defaultModelMapping)(constructor);
5978
- DefaultModel(options.defaultModelMapping)(constructor);
5979
- Reflect.defineMetadata(Symbols__NS__metadata.options.entity, options, constructor);
5980
- Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
5981
- /* */
5982
- /* */
5983
- CLASS__NS__setName(constructor, options?.className); // TODO QUICK_FIX for ng2-rest
5984
- };
5985
- }
5986
- class TaonEntityOptions extends DecoratorAbstractOpt {
5987
- }
5988
-
5989
- //#region imports
5990
- //#endregion
5991
- let TAON_GLOBAL_STATE = class TAON_GLOBAL_STATE extends TaonBaseAbstractEntity {
5992
- };
5993
- TAON_GLOBAL_STATE = __decorate([
5994
- TaonEntity({
5995
- className: 'TAON_GLOBAL_STATE',
5996
- createTable: true,
5997
- })
5998
- ], TAON_GLOBAL_STATE);
5999
-
6000
- /**
6001
- * Controller decorator
6002
- */
6003
- function TaonController(options) {
6004
- return function (constructor) {
6005
- ClassHelpers__NS__setName(constructor, options?.className);
6006
- Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
6007
- const cfg = ClassHelpers__NS__ensureClassConfig(constructor);
6008
- options = options || {};
6009
- cfg.className = options.className || constructor.name;
6010
- cfg.path = options.path || '';
6011
- cfg.realtime = options.realtime;
6012
- cfg.middlewares = options.middlewares;
6013
- };
6014
- }
6015
-
6016
- const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal) => {
6017
- const methodConfig = ClassHelpers__NS__ensureMethodConfig(target, propertyKey);
6018
- let options;
6019
- if (typeof pathOrOptions === 'object') {
6020
- options = pathOrOptions;
6021
- pathOrOptions = options.path;
6022
- pathIsGlobal = !!options.pathIsGlobal;
6023
- path = options.path;
6024
- }
6025
- else {
6026
- options = { pathOrOptions, pathIsGlobal };
6027
- }
6028
- const { overrideContentType, overrideResponseType, overrideExpressSendAsHtml, middlewares, } = options;
6029
- methodConfig.methodName = propertyKey;
6030
- methodConfig.middlewares = middlewares;
6031
- methodConfig.type = method;
6032
- if (!path) {
6033
- let paramsPathConcatedPath = '';
6034
- for (const key in methodConfig.parameters) {
6035
- if (methodConfig.parameters.hasOwnProperty(key)) {
6036
- const element = methodConfig.parameters[key];
6037
- if (element.paramType === 'Path' &&
6038
- ___NS__isString(element.paramName) &&
6039
- element.paramName.trim().length > 0) {
6040
- paramsPathConcatedPath += `/${element.paramName}/:${element.paramName}`;
6041
- }
6042
- }
6043
- }
6044
- methodConfig.path = `/${propertyKey}${paramsPathConcatedPath}`;
6045
- }
6046
- else {
6047
- methodConfig.path = path;
6048
- }
6049
- methodConfig.descriptor = descriptor;
6050
- methodConfig.global = pathIsGlobal;
6051
- methodConfig.contentType = overrideContentType;
6052
- methodConfig.responseType = overrideResponseType;
6053
- methodConfig.overrideExpressSendAsHtml = overrideExpressSendAsHtml;
6054
- };
6055
- function GET(pathOrOptions, pathIsGlobal = false) {
6056
- return function (target, propertyKey, descriptor) {
6057
- metaReq('get', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
6058
- };
6059
- }
6060
- /**
6061
- * Method for sending html website from text
6062
- * Example
6063
- *
6064
- * ```ts
6065
- * ...
6066
- * // in your taon controller
6067
- * ..Taon.Http.HTML()
6068
- * sendHtmlDummyWebsite(): Taon__NS__ResponseHtml {
6069
- * return `
6070
- <html>
6071
- <head>
6072
- <title>Dummy website</title>
6073
- </head>
6074
- <body>
6075
- <h1>This is dummy website</h1>
6076
- <p>Served as HTML string from Taon controller method</p>
6077
- </body>
6078
- </html>
6079
- * `; *
6080
- * }
6081
- * ...
6082
- * ```
6083
- */
6084
- function HTML(pathOrOptions) {
6085
- return function (target, propertyKey, descriptor) {
6086
- const opt = pathOrOptions;
6087
- opt.overrideExpressSendAsHtml = true;
6088
- metaReq('get', opt, target, propertyKey, descriptor, pathOrOptions, opt.pathIsGlobal);
6089
- };
6090
- }
6091
- function HEAD(pathOrOptions, pathIsGlobal = false) {
6092
- return function (target, propertyKey, descriptor) {
6093
- metaReq('head', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
6094
- };
6095
- }
6096
- function POST(pathOrOptions, pathIsGlobal = false) {
6097
- return function (target, propertyKey, descriptor) {
6098
- metaReq('post', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
6099
- };
6100
- }
6101
- function PUT(pathOrOptions, pathIsGlobal = false) {
6102
- return function (target, propertyKey, descriptor) {
6103
- metaReq('put', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
6104
- };
6105
- }
6106
- function PATCH(pathOrOptions, pathIsGlobal = false) {
6107
- return function (target, propertyKey, descriptor) {
6108
- metaReq('patch', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
6109
- };
6110
- }
6111
- function DELETE(pathOrOptions, pathIsGlobal = false) {
6112
- return function (target, propertyKey, descriptor) {
6113
- metaReq('delete', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
6114
- };
6115
- }
6116
-
6117
- function metaParam(param, name, expire, defaultValue = undefined, target, propertyKey, parameterIndex) {
6118
- const methodCfg = ClassHelpers__NS__ensureMethodConfig(target, propertyKey);
6119
- const nameKey = name ? name : param;
6120
- // const key = name || `${param}_${parameterIndex}`;
6121
- methodCfg.parameters[nameKey] = {
6122
- index: parameterIndex,
6123
- paramName: name,
6124
- paramType: param,
6125
- defaultType: defaultValue,
6126
- expireInSeconds: expire,
6127
- };
6128
- // console.log('params updated', methodConfig);
6129
- }
6130
- /**
6131
- * @deprecated use Taon.Http.Param.Path (is more safe and cleaner)
6132
- */
6133
- function Path(name) {
6134
- return function (target, propertyKey, parameterIndex) {
6135
- metaParam('Path', name, undefined, {}, target, propertyKey, parameterIndex);
6136
- };
6137
- }
6138
- function Query(name) {
6139
- return function (target, propertyKey, parameterIndex) {
6140
- metaParam('Query', name, undefined, {}, target, propertyKey, parameterIndex);
6141
- };
6142
- }
6143
- function Cookie(name, expireInSecond = 3600) {
6144
- return function (target, propertyKey, parameterIndex) {
6145
- metaParam('Cookie', name, expireInSecond, {}, target, propertyKey, parameterIndex);
6146
- };
6147
- }
6148
- function Header(name) {
6149
- return function (target, propertyKey, parameterIndex) {
6150
- metaParam('Header', name, undefined, {}, target, propertyKey, parameterIndex);
6151
- };
6152
- }
6153
- function Body(name) {
6154
- return function (target, propertyKey, parameterIndex) {
6155
- metaParam('Body', name, undefined, {}, target, propertyKey, parameterIndex);
6156
- };
6157
- }
6158
-
6159
6008
  /**
6160
6009
  * Provider decorator
6161
6010
  */
@@ -6430,53 +6279,44 @@ TaonBaseFileUploadMiddleware = __decorate([
6430
6279
  })
6431
6280
  ], TaonBaseFileUploadMiddleware);
6432
6281
 
6433
- let TaonBaseController = class TaonBaseController extends TaonBaseInjector {
6434
- /**
6435
- * Hook that is called when taon app is inited
6436
- * (all contexts are created and inited)
6437
- */
6438
- async afterAllCtxInited(options) { }
6439
- //#region upload form data to server
6440
- uploadFormDataToServer(formData, queryParams) {
6441
- /* */
6442
- /* */
6443
- /* */
6444
- /* */
6445
- /* */
6446
- /* */
6447
- /* */
6448
- /* */
6449
- /* */
6450
- /* */
6451
- /* */
6452
- /* */
6453
- /* */
6454
- /* */
6455
- /* */
6456
- /* */
6457
- /* */
6458
- /* */
6459
- /* */
6460
- /* */
6461
- /* */
6282
+ /**
6283
+ * Repository decorator
6284
+ */
6285
+ function TaonRepository(options) {
6286
+ return function (constructor) {
6287
+ Reflect.defineMetadata(Symbols__NS__metadata.options.repository, options, constructor);
6288
+ Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
6289
+ ClassHelpers__NS__setName(constructor, options?.className);
6290
+ };
6291
+ }
6292
+ class TaonRepositoryOptions extends DecoratorAbstractOpt {
6293
+ }
6294
+
6295
+ //#endregion
6296
+ let TaonBaseCustomRepository = class TaonBaseCustomRepository extends TaonBaseInjector {
6297
+ };
6298
+ TaonBaseCustomRepository = __decorate([
6299
+ TaonRepository({ className: 'TaonBaseCustomRepository' })
6300
+ ], TaonBaseCustomRepository);
6301
+
6302
+ //#endregion
6303
+ const INDEX_KEYS_NO_FOR_UPDATE = ['id'];
6304
+ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomRepository {
6305
+ constructor(
6306
+ // Injected through TaonBaseCrudController
6307
+ __entityClassResolveFn) {
6308
+ super();
6309
+ this.REPOS_CACHE_KEY = Symbol('repository cache inside instance');
6310
+ this.allowedTypesToUpdate = ['simple-json', 'simple-array', 'json'];
6311
+ // @ts-ignore
6312
+ this.entityClassResolveFn = __entityClassResolveFn;
6313
+ }
6314
+ get dbQuery() {
6462
6315
  /* */
6463
6316
  /* */
6464
6317
  /* */
6465
6318
  /* */
6466
6319
  /* */
6467
- return (void 0);
6468
- }
6469
- //#endregion
6470
- //#region after file upload hook
6471
- /**
6472
- * Hook after file is uploaded
6473
- * through `uploadFormDataToServer` or `uploadLocalFileToServer`
6474
- */
6475
- afterFileUploadAction(file, queryParams) {
6476
- // empty
6477
- }
6478
- //#region upload local file to server
6479
- async uploadLocalFileToServer(absFilePath, options, queryParams) {
6480
6320
  /* */
6481
6321
  /* */
6482
6322
  /* */
@@ -6494,156 +6334,15 @@ let TaonBaseController = class TaonBaseController extends TaonBaseInjector {
6494
6334
  return (void 0);
6495
6335
  }
6496
6336
  //#endregion
6497
- // async check() {
6498
- // await this._waitForProperStatusChange({
6499
- // request: () => this.uploadFormDataToServer(void 0, void 0).request(),
6500
- // statusCheck: resp => resp.body.json[0].ok,
6501
- // });
6502
- // }
6503
- /**
6504
- * Easy way to wait for status change with http (1s default) pooling.
6505
- *
6506
- * example (in sub class):
6507
- * ```ts
6508
- async check() {
6509
- await this.waitForProperStatusChange({
6510
- request: () => this.uploadFormDataToServer(void 0, void 0).request(),
6511
- statusCheck: resp => resp.body.json[0].ok,
6512
- });
6513
- }
6514
- * ```
6515
- */
6516
- async _waitForProperStatusChange(options) {
6517
- const poolingInterval = options.poolingInterval || 1000;
6518
- const taonRequest = options.request;
6519
- let maxTries = options.maxTries || Number.POSITIVE_INFINITY;
6520
- let i = 0;
6521
- let httpErrorsCount = 0;
6522
- while (true) {
6523
- await UtilsTerminal__NS__waitMilliseconds(poolingInterval);
6524
- try {
6525
- const resp = await taonRequest({
6526
- reqIndexNum: i,
6527
- httpErrorsCount,
6528
- });
6529
- if (options.statusCheck && options.statusCheck(resp)) {
6530
- return;
6531
- }
6532
- }
6533
- catch (error) {
6534
- httpErrorsCount++;
6535
- if (options.loopRequestsOnBackendError) {
6536
- const isProperTaonError = error instanceof HttpResponseError &&
6537
- error.body.json[CoreModels__NS__TaonHttpErrorCustomProp];
6538
- const isHttpError = error instanceof HttpResponseError && !isProperTaonError;
6539
- const isUnknownError = !(error instanceof HttpResponseError);
6540
- const resBool = await options.loopRequestsOnBackendError({
6541
- taonError: isProperTaonError ? error : void 0,
6542
- unknownHttpError: isHttpError ? error : void 0,
6543
- unknownError: isUnknownError ? error : void 0,
6544
- reqIndexNum: i,
6545
- httpErrorsCount,
6546
- });
6547
- if (resBool) {
6548
- i++;
6549
- continue;
6550
- }
6551
- else {
6552
- return;
6553
- }
6554
- }
6555
- if (httpErrorsCount >
6556
- (options.allowedHttpErrors || Number.POSITIVE_INFINITY)) {
6557
- throw new Error(`Too many http errors (${httpErrorsCount}) for "${options.actionName}".`);
6558
- }
6559
- }
6560
- if (i++ > maxTries) {
6561
- throw new Error(`Timeout waiting for "${options.actionName}" to be finished. Waited for ${maxTries} seconds`);
6562
- }
6563
- }
6564
- }
6565
- };
6566
- __decorate([
6567
- POST({
6568
- overrideContentType: 'multipart/form-data',
6569
- middlewares: ({ parentMiddlewares }) => ({
6570
- ...parentMiddlewares,
6571
- TaonBaseFileUploadMiddleware,
6572
- }),
6573
- }),
6574
- __param(0, Body()),
6575
- __param(1, Query()),
6576
- __metadata("design:type", Function),
6577
- __metadata("design:paramtypes", [FormData, Object]),
6578
- __metadata("design:returntype", Object)
6579
- ], TaonBaseController.prototype, "uploadFormDataToServer", null);
6580
- TaonBaseController = __decorate([
6581
- TaonController({
6582
- className: 'TaonBaseController',
6583
- })
6584
- ], TaonBaseController);
6585
-
6586
- //#endregion
6587
- /**
6588
- * Please override property entityClassFn with entity class.
6589
- */
6590
- let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseController {
6591
- //#endregion
6592
- //#region init
6593
- async _() {
6594
- if (!___NS__isFunction(this.entityClassResolveFn)) {
6595
- Helpers__NS__warn(`Skipping initing CRUD controller ${ClassHelpers__NS__getName(this)} because entityClassResolveFn is not provided.`);
6596
- return;
6597
- }
6598
- let entityClassFn = this.entityClassResolveFn();
6599
- this.db = this.injectRepo(entityClassFn);
6600
- if (entityClassFn) {
6601
- const configEntity = Reflect.getMetadata(Symbols__NS__metadata.options.entity, ClassHelpers__NS__getClassFnFromObject(this));
6602
- if (configEntity?.createTable === false) {
6603
- Helpers__NS__warn(`Table for entity ${ClassHelpers__NS__getName(entityClassFn)} will not be created. Crud will not work properly.`);
6604
- }
6605
- }
6606
- else {
6607
- Helpers__NS__error(`Entity class not provided for controller ${ClassHelpers__NS__getName(this)}.
6608
-
6609
- Please provide entity as class property entityClassFn:
6610
-
6611
- class ${ClassHelpers__NS__getName(this)} extends TaonBaseCrudController<Entity> {
6612
- // ...
6613
- entityClassResolveFn = ()=> MyEntityClass;
6614
- // ...
6615
- }
6616
-
6617
- `);
6618
- }
6619
- await super._();
6620
- }
6621
- //#endregion
6622
- //#region bufferd changes
6623
- bufforedChanges(id, property, alreadyLength) {
6624
- /* */
6625
- /* */
6626
- /* */
6627
- /* */
6628
- /* */
6629
- /* */
6630
- /* */
6631
- /* */
6632
- /* */
6633
- /* */
6634
- /* */
6635
- /* */
6636
- /* */
6337
+ //#region connection
6338
+ get connection() {
6637
6339
  /* */
6638
6340
  /* */
6639
6341
  return (void 0);
6640
6342
  }
6641
6343
  //#endregion
6642
- //#region pagintation
6643
- pagination(pageNumber = 1, pageSize = 10, search = '') {
6644
- /* */
6645
- /* */
6646
- /* */
6344
+ //#region repository
6345
+ get repository() {
6647
6346
  /* */
6648
6347
  /* */
6649
6348
  /* */
@@ -6673,17 +6372,53 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
6673
6372
  /* */
6674
6373
  /* */
6675
6374
  /* */
6375
+ return (void 0);
6376
+ }
6377
+ /**
6378
+ * target for repository
6379
+ */
6380
+ get target() {
6676
6381
  /* */
6677
6382
  /* */
6383
+ return (void 0);
6384
+ }
6385
+ /**
6386
+ * alias to repository
6387
+ */
6388
+ get repo() {
6678
6389
  /* */
6679
6390
  /* */
6391
+ return (void 0);
6392
+ }
6393
+ get repositoryExists() {
6680
6394
  /* */
6681
6395
  /* */
6682
6396
  return (void 0);
6683
6397
  }
6684
6398
  //#endregion
6685
- //#region get all
6686
- getAll() {
6399
+ //#region crud operations / typeorm / has id
6400
+ /**
6401
+ * Checks if entity has an id.
6402
+ * If entity composite compose ids, it will check them all.
6403
+ */
6404
+ hasId(entity) {
6405
+ return this.repo.hasId(entity);
6406
+ }
6407
+ //#endregion
6408
+ //#region crud operations / typeorm / get id
6409
+ /**
6410
+ * Gets entity mixed id.
6411
+ */
6412
+ getId(entity) {
6413
+ return this.repo.getId(entity);
6414
+ }
6415
+ //#endregion
6416
+ //#region crud operations / typeorm / create & bulk create
6417
+ /**
6418
+ Saves a given entity in the database.
6419
+ * If entity does not exist in the database then inserts, otherwise updates.
6420
+ */
6421
+ async save(item, options) {
6687
6422
  /* */
6688
6423
  /* */
6689
6424
  /* */
@@ -6693,11 +6428,6 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
6693
6428
  /* */
6694
6429
  /* */
6695
6430
  /* */
6696
- return (void 0);
6697
- }
6698
- //#endregion
6699
- //#region get by id
6700
- getBy(id) {
6701
6431
  /* */
6702
6432
  /* */
6703
6433
  /* */
@@ -6705,9 +6435,17 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
6705
6435
  /* */
6706
6436
  return (void 0);
6707
6437
  }
6708
- //#endregion
6709
- //#region update by id
6710
- updateById(id, item) {
6438
+ /**
6439
+ * Creates a new entity instance or instances.
6440
+ * Can copy properties from the given object into new entities.
6441
+ */
6442
+ create(plainEntityLikeOrPlainEntityLikes) {
6443
+ return this.repo.create(plainEntityLikeOrPlainEntityLikes);
6444
+ }
6445
+ async bulkSave(items, options) {
6446
+ /* */
6447
+ /* */
6448
+ /* */
6711
6449
  /* */
6712
6450
  /* */
6713
6451
  /* */
@@ -6716,20 +6454,89 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
6716
6454
  /* */
6717
6455
  return (void 0);
6718
6456
  }
6719
- //#endregion
6720
- //#region patch by id
6721
- patchById(id, item) {
6457
+ /**
6458
+ * @deprecated use bulkSave instead
6459
+ */
6460
+ async bulkCreate(items, options) {
6461
+ return this.bulkSave(items, options);
6462
+ }
6463
+ //#region old typeorm version
6464
+ /**
6465
+ * Saves all given entities in the database.
6466
+ * If entities do not exist in the database then inserts, otherwise updates.
6467
+ */
6468
+ // save<T extends DeepPartial<Entity>>(
6469
+ // entities: T[],
6470
+ // options: SaveOptions & {
6471
+ // reload: false;
6472
+ // },
6473
+ // ): Promise<T[]>;
6474
+ // /**
6475
+ // * Saves all given entities in the database.
6476
+ // * If entities do not exist in the database then inserts, otherwise updates.
6477
+ // */
6478
+ // save<T extends DeepPartial<Entity>>(
6479
+ // entities: T[],
6480
+ // options?: SaveOptions,
6481
+ // ): Promise<(T & Entity)[]>;
6482
+ // /**
6483
+ // * Saves a given entity in the database.
6484
+ // * If entity does not exist in the database then inserts, otherwise updates.
6485
+ // */
6486
+ // save<T extends DeepPartial<Entity>>(
6487
+ // entity: T,
6488
+ // options: SaveOptions & {
6489
+ // reload: false;
6490
+ // },
6491
+ // ): Promise<T>;
6492
+ // /**
6493
+ // * Saves a given entity in the database.
6494
+ // * If entity does not exist in the database then inserts, otherwise updates.
6495
+ // */
6496
+ // save<T extends DeepPartial<Entity>>(
6497
+ // entity: T,
6498
+ // options?: SaveOptions,
6499
+ // ): Promise<T & Entity> {
6500
+ // return this.repo.save(entity, options);
6501
+ // }
6502
+ //#endregion
6503
+ //#endregion
6504
+ //#region crud operations / typeorm / merge
6505
+ /**
6506
+ * Merges multiple entities (or entity-like objects) into a given entity.
6507
+ */
6508
+ merge(mergeIntoEntity, ...entityLikes) {
6509
+ return this.repo.merge(mergeIntoEntity, ...entityLikes);
6510
+ }
6511
+ //#endregion
6512
+ //#region crud operations / typeorm / preload
6513
+ /**
6514
+ * Creates a new entity from the given plain javascript object. If entity already exist in the database, then
6515
+ * it loads it (and everything related to it), replaces all values with the new ones from the given object
6516
+ * and returns this new entity. This new entity is actually a loaded from the db entity with all properties
6517
+ * replaced from the new object.
6518
+ *
6519
+ * Note that given entity-like object must have an entity id / primary key to find entity by.
6520
+ * Returns undefined if entity with given id was not found.
6521
+ */
6522
+ preload(entityLike) {
6523
+ return this.repo.preload(entityLike);
6524
+ }
6525
+ //#endregion
6526
+ //#region crud operations / typeorm / remove (delete) & bulk remove (delete)
6527
+ /**
6528
+ * Removes a given entities from the database.
6529
+ */
6530
+ async remove(idOrEntity) {
6531
+ /* */
6532
+ /* */
6533
+ /* */
6722
6534
  /* */
6723
6535
  /* */
6724
6536
  /* */
6725
6537
  /* */
6726
6538
  /* */
6727
6539
  /* */
6728
- return (void 0);
6729
- }
6730
- //#endregion
6731
- //#region bulk update
6732
- bulkUpdate(items) {
6733
6540
  /* */
6734
6541
  /* */
6735
6542
  /* */
@@ -6738,11 +6545,6 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
6738
6545
  /* */
6739
6546
  /* */
6740
6547
  /* */
6741
- return (void 0);
6742
- }
6743
- //#endregion
6744
- //#region delete by id
6745
- deleteById(id) {
6746
6548
  /* */
6747
6549
  /* */
6748
6550
  /* */
@@ -6750,9 +6552,26 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
6750
6552
  /* */
6751
6553
  return (void 0);
6752
6554
  }
6753
- //#endregion
6754
- //#region bulk delete
6755
- bulkDelete(ids) {
6555
+ /**
6556
+ * alias to remove
6557
+ */
6558
+ async delete(idOrEntity) {
6559
+ return this.remove(idOrEntity);
6560
+ }
6561
+ /**
6562
+ * alias to removeById
6563
+ */
6564
+ async deleteById(id) {
6565
+ return this.remove(id);
6566
+ }
6567
+ async bulkRemove(idsOrEntities) {
6568
+ /* */
6569
+ /* */
6570
+ /* */
6571
+ /* */
6572
+ /* */
6573
+ /* */
6574
+ /* */
6756
6575
  /* */
6757
6576
  /* */
6758
6577
  /* */
@@ -6760,18 +6579,81 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
6760
6579
  /* */
6761
6580
  return (void 0);
6762
6581
  }
6582
+ async bulkDelete(ids) {
6583
+ return this.bulkRemove(ids);
6584
+ }
6585
+ /**
6586
+ * Records the delete date of a given entity.
6587
+ */
6588
+ softRemove(entity, options) {
6589
+ return this.repo.softRemove(entity, options);
6590
+ }
6591
+ /**
6592
+ * Recovers a given entity in the database.
6593
+ */
6594
+ recover(entity, options) {
6595
+ return this.repo.recover(entity, options);
6596
+ }
6763
6597
  //#endregion
6764
- //#region bulk delete
6765
- clearTable() {
6766
- /* */
6598
+ //#region crud operations / typeorm / insert
6599
+ /**
6600
+ * Inserts a given entity into the database.
6601
+ * Unlike save method executes a primitive operation without cascades, relations and other operations included.
6602
+ * Executes fast and efficient INSERT query.
6603
+ * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.
6604
+ */
6605
+ insert(entity) {
6606
+ // debugger;
6607
+ return this.repo.insert(entity);
6608
+ }
6609
+ //#endregion
6610
+ //#region crud operations / typeorm / update & build update
6611
+ async update(item) {
6767
6612
  /* */
6768
6613
  /* */
6769
6614
  /* */
6770
6615
  return (void 0);
6771
6616
  }
6772
- //#endregion
6773
- //#region create
6774
- save(item) {
6617
+ async updateById(id, item) {
6618
+ /* */
6619
+ /* */
6620
+ /* */
6621
+ /* */
6622
+ /* */
6623
+ /* */
6624
+ /* */
6625
+ /* */
6626
+ /* */
6627
+ /* */
6628
+ /* */
6629
+ /* */
6630
+ /* */
6631
+ /* */
6632
+ /* */
6633
+ /* */
6634
+ /* */
6635
+ /* */
6636
+ /* */
6637
+ /* */
6638
+ /* */
6639
+ /* */
6640
+ /* */
6641
+ /* */
6642
+ /* */
6643
+ /* */
6644
+ /* */
6645
+ /* */
6646
+ /* */
6647
+ /* */
6648
+ /* */
6649
+ /* */
6650
+ /* */
6651
+ /* */
6652
+ /* */
6653
+ /* */
6654
+ /* */
6655
+ /* */
6656
+ /* */
6775
6657
  /* */
6776
6658
  /* */
6777
6659
  /* */
@@ -6779,9 +6661,11 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
6779
6661
  /* */
6780
6662
  return (void 0);
6781
6663
  }
6782
- //#endregion
6783
- //#region bulk create
6784
- bulkCreate(items) {
6664
+ async bulkUpdate(items) {
6665
+ /* */
6666
+ /* */
6667
+ /* */
6668
+ /* */
6785
6669
  /* */
6786
6670
  /* */
6787
6671
  /* */
@@ -6789,359 +6673,244 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
6789
6673
  /* */
6790
6674
  return (void 0);
6791
6675
  }
6792
- };
6793
- __decorate([
6794
- GET(),
6795
- __param(0, Query(`id`)),
6796
- __param(1, Query(`property`)),
6797
- __param(2, Query('alreadyLength')),
6798
- __metadata("design:type", Function),
6799
- __metadata("design:paramtypes", [Object, String, Number]),
6800
- __metadata("design:returntype", Object)
6801
- ], TaonBaseCrudController.prototype, "bufforedChanges", null);
6802
- __decorate([
6803
- GET(),
6804
- __param(0, Query('pageNumber')),
6805
- __param(1, Query('pageSize')),
6806
- __param(2, Query('search')),
6807
- __metadata("design:type", Function),
6808
- __metadata("design:paramtypes", [Number, Number, String]),
6809
- __metadata("design:returntype", Object)
6810
- ], TaonBaseCrudController.prototype, "pagination", null);
6811
- __decorate([
6812
- GET(),
6813
- __metadata("design:type", Function),
6814
- __metadata("design:paramtypes", []),
6815
- __metadata("design:returntype", Object)
6816
- ], TaonBaseCrudController.prototype, "getAll", null);
6817
- __decorate([
6818
- GET(),
6819
- __param(0, Query(`id`)),
6820
- __metadata("design:type", Function),
6821
- __metadata("design:paramtypes", [Object]),
6822
- __metadata("design:returntype", Object)
6823
- ], TaonBaseCrudController.prototype, "getBy", null);
6824
- __decorate([
6825
- PUT(),
6826
- __param(0, Query(`id`)),
6827
- __param(1, Body()),
6828
- __metadata("design:type", Function),
6829
- __metadata("design:paramtypes", [Object, Object]),
6830
- __metadata("design:returntype", Object)
6831
- ], TaonBaseCrudController.prototype, "updateById", null);
6832
- __decorate([
6833
- PATCH(),
6834
- __param(0, Query(`id`)),
6835
- __param(1, Body()),
6836
- __metadata("design:type", Function),
6837
- __metadata("design:paramtypes", [Object, Object]),
6838
- __metadata("design:returntype", Object)
6839
- ], TaonBaseCrudController.prototype, "patchById", null);
6840
- __decorate([
6841
- PUT(),
6842
- __param(0, Body()),
6843
- __metadata("design:type", Function),
6844
- __metadata("design:paramtypes", [Array]),
6845
- __metadata("design:returntype", Object)
6846
- ], TaonBaseCrudController.prototype, "bulkUpdate", null);
6847
- __decorate([
6848
- DELETE(),
6849
- __param(0, Query(`id`)),
6850
- __metadata("design:type", Function),
6851
- __metadata("design:paramtypes", [Object]),
6852
- __metadata("design:returntype", Object)
6853
- ], TaonBaseCrudController.prototype, "deleteById", null);
6854
- __decorate([
6855
- DELETE(),
6856
- __param(0, Query(`ids`)),
6857
- __metadata("design:type", Function),
6858
- __metadata("design:paramtypes", [Array]),
6859
- __metadata("design:returntype", Object)
6860
- ], TaonBaseCrudController.prototype, "bulkDelete", null);
6861
- __decorate([
6862
- DELETE(),
6863
- __metadata("design:type", Function),
6864
- __metadata("design:paramtypes", []),
6865
- __metadata("design:returntype", Object)
6866
- ], TaonBaseCrudController.prototype, "clearTable", null);
6867
- __decorate([
6868
- POST(),
6869
- __param(0, Body()),
6870
- __metadata("design:type", Function),
6871
- __metadata("design:paramtypes", [Object]),
6872
- __metadata("design:returntype", Object)
6873
- ], TaonBaseCrudController.prototype, "save", null);
6874
- __decorate([
6875
- POST(),
6876
- __param(0, Body()),
6877
- __metadata("design:type", Function),
6878
- __metadata("design:paramtypes", [Object]),
6879
- __metadata("design:returntype", Object)
6880
- ], TaonBaseCrudController.prototype, "bulkCreate", null);
6881
- TaonBaseCrudController = __decorate([
6882
- TaonController({ className: 'TaonBaseCrudController' })
6883
- ], TaonBaseCrudController);
6884
-
6885
- /**
6886
- * Repository decorator
6887
- */
6888
- function TaonRepository(options) {
6889
- return function (constructor) {
6890
- Reflect.defineMetadata(Symbols__NS__metadata.options.repository, options, constructor);
6891
- Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
6892
- ClassHelpers__NS__setName(constructor, options?.className);
6893
- };
6894
- }
6895
- class TaonRepositoryOptions extends DecoratorAbstractOpt {
6896
- }
6897
-
6898
- //#endregion
6899
- let TaonBaseCustomRepository = class TaonBaseCustomRepository extends TaonBaseInjector {
6900
- };
6901
- TaonBaseCustomRepository = __decorate([
6902
- TaonRepository({ className: 'TaonBaseCustomRepository' })
6903
- ], TaonBaseCustomRepository);
6904
-
6905
- //#endregion
6906
- const INDEX_KEYS_NO_FOR_UPDATE = ['id'];
6907
- let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomRepository {
6908
- constructor(
6909
- // Injected through TaonBaseCrudController
6910
- __entityClassResolveFn) {
6911
- super();
6912
- this.REPOS_CACHE_KEY = Symbol('repository cache inside instance');
6913
- this.allowedTypesToUpdate = ['simple-json', 'simple-array', 'json'];
6914
- // @ts-ignore
6915
- this.entityClassResolveFn = __entityClassResolveFn;
6676
+ //#region tpeorm update version
6677
+ // this version suck and will not return update entity
6678
+ // /**
6679
+ // * Updates entity partially. Entity can be found by a given conditions.
6680
+ // * Unlike save method executes a primitive operation without cascades, relations and other operations included.
6681
+ // * Executes fast and efficient UPDATE query.
6682
+ // * Does not check if entity exist in the database.
6683
+ // */
6684
+ // update(
6685
+ // criteria:
6686
+ // | string
6687
+ // | string[]
6688
+ // | number
6689
+ // | number[]
6690
+ // | Date
6691
+ // | Date[]
6692
+ // | ObjectID
6693
+ // | ObjectID[]
6694
+ // | FindOptionsWhere<Entity>,
6695
+ // partialEntity: QueryDeepPartialEntity<Entity>,
6696
+ // ): Promise<UpdateResult> {
6697
+ // return this.repo.update(criteria, partialEntity);
6698
+ // }
6699
+ //#endregion
6700
+ //#endregion
6701
+ //#region crud operations / typeorm / upsert
6702
+ /**
6703
+ * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity
6704
+ * Unlike save method executes a primitive operation without cascades, relations and other operations included.
6705
+ * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.
6706
+ */
6707
+ upsert(entityOrEntities, conflictPathsOrOptions) {
6708
+ return this.repo.upsert(entityOrEntities, conflictPathsOrOptions);
6916
6709
  }
6917
- get dbQuery() {
6918
- /* */
6919
- /* */
6920
- /* */
6921
- /* */
6922
- /* */
6923
- /* */
6924
- /* */
6925
- /* */
6926
- /* */
6927
- /* */
6928
- /* */
6929
- /* */
6930
- /* */
6931
- /* */
6932
- /* */
6933
- /* */
6934
- /* */
6935
- /* */
6936
- /* */
6937
- return (void 0);
6710
+ //#endregion
6711
+ //#region crud operations / typeorm / soft delete
6712
+ /**
6713
+ * Records the delete date of entities by a given criteria.
6714
+ * Unlike save method executes a primitive operation without cascades, relations and other operations included.
6715
+ * Executes fast and efficient SOFT-DELETE query.
6716
+ * Does not check if entity exist in the database.
6717
+ */
6718
+ softDelete(criteria) {
6719
+ return this.repo.softDelete(criteria);
6938
6720
  }
6939
6721
  //#endregion
6940
- //#region connection
6941
- get connection() {
6942
- /* */
6943
- /* */
6944
- return (void 0);
6722
+ //#region crud operations / typeorm / restore
6723
+ /**
6724
+ * Restores entities by a given criteria.
6725
+ * Unlike save method executes a primitive operation without cascades, relations and other operations included.
6726
+ * Executes fast and efficient SOFT-DELETE query.
6727
+ * Does not check if entity exist in the database.
6728
+ */
6729
+ restore(criteria) {
6730
+ return this.repo.restore(criteria);
6945
6731
  }
6946
6732
  //#endregion
6947
- //#region repository
6948
- get repository() {
6949
- /* */
6950
- /* */
6951
- /* */
6952
- /* */
6953
- /* */
6954
- /* */
6955
- /* */
6956
- /* */
6957
- /* */
6958
- /* */
6959
- /* */
6960
- /* */
6961
- /* */
6962
- /* */
6963
- /* */
6964
- /* */
6965
- /* */
6966
- /* */
6967
- /* */
6968
- /* */
6969
- /* */
6970
- /* */
6971
- /* */
6972
- /* */
6973
- /* */
6974
- /* */
6975
- /* */
6976
- /* */
6977
- /* */
6978
- return (void 0);
6733
+ //#region crud operations / typeorm / count
6734
+ /**
6735
+ * Counts entities that match given options.
6736
+ * Useful for pagination.
6737
+ */
6738
+ count(options) {
6739
+ return this.repo.count(options);
6979
6740
  }
6741
+ //#endregion
6742
+ //#region crud operations / typeorm / count by
6980
6743
  /**
6981
- * target for repository
6744
+ * Counts entities that match given conditions.
6745
+ * Useful for pagination.
6982
6746
  */
6983
- get target() {
6984
- /* */
6985
- /* */
6986
- return (void 0);
6747
+ countBy(where) {
6748
+ return this.repo.countBy(where);
6987
6749
  }
6750
+ //#endregion
6751
+ //#region crud operations / typeorm / find
6988
6752
  /**
6989
- * alias to repository
6753
+ * Finds entities that match given find options.
6990
6754
  */
6991
- get repo() {
6992
- /* */
6993
- /* */
6994
- return (void 0);
6755
+ find(options) {
6756
+ return this.repo.find(options);
6995
6757
  }
6996
- get repositoryExists() {
6997
- /* */
6998
- /* */
6999
- return (void 0);
6758
+ //#endregion
6759
+ //#region crud operations / typeorm / find by
6760
+ /**
6761
+ * Finds entities that match given find options.
6762
+ */
6763
+ findBy(where) {
6764
+ return this.repo.findBy(where);
7000
6765
  }
7001
6766
  //#endregion
7002
- //#region crud operations / typeorm / has id
6767
+ //#region crud operations / typeorm / find and count
6768
+ // async findAndCount(options: { take: number; skip: number }) {
6769
+ // const { take, skip } = options;
6770
+ // const [result, total] = await this.repo.findAndCount({
6771
+ // // where: { name: Like('%' + keyword + '%') },
6772
+ // // order: { name: "DESC" },
6773
+ // take: take,
6774
+ // skip: skip,
6775
+ // });
6776
+ // return { result, total };
6777
+ // }
6778
+ //
7003
6779
  /**
7004
- * Checks if entity has an id.
7005
- * If entity composite compose ids, it will check them all.
6780
+ * Finds entities that match given find options.
6781
+ * Also counts all entities that match given conditions,
6782
+ * but ignores pagination settings (from and take options).
7006
6783
  */
7007
- hasId(entity) {
7008
- return this.repo.hasId(entity);
6784
+ findAndCount(options) {
6785
+ return this.repo.findAndCount(options);
7009
6786
  }
7010
6787
  //#endregion
7011
- //#region crud operations / typeorm / get id
6788
+ //#region crud operations / typeorm / find and count by
7012
6789
  /**
7013
- * Gets entity mixed id.
6790
+ * Finds entities that match given WHERE conditions.
6791
+ * Also counts all entities that match given conditions,
6792
+ * but ignores pagination settings (from and take options).
7014
6793
  */
7015
- getId(entity) {
7016
- return this.repo.getId(entity);
6794
+ findAndCountBy(where) {
6795
+ return this.repo.findAndCountBy(where);
7017
6796
  }
7018
6797
  //#endregion
7019
- //#region crud operations / typeorm / create & bulk create
6798
+ //#region crud operations / typeorm / find by ids
7020
6799
  /**
7021
- Saves a given entity in the database.
7022
- * If entity does not exist in the database then inserts, otherwise updates.
6800
+ * Finds entities with ids.
6801
+ * Optionally find options or conditions can be applied.
6802
+ *
6803
+ * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:
6804
+ *
6805
+ * .findBy({
6806
+ * id: In([1, 2, 3])
6807
+ * })
7023
6808
  */
7024
- async save(item, options) {
7025
- /* */
7026
- /* */
7027
- /* */
7028
- /* */
7029
- /* */
7030
- /* */
7031
- /* */
7032
- /* */
7033
- /* */
7034
- /* */
7035
- /* */
7036
- /* */
7037
- /* */
7038
- /* */
7039
- return (void 0);
6809
+ findByIds(ids) {
6810
+ return this.repo.findByIds(ids);
7040
6811
  }
6812
+ //#endregion
6813
+ //#region crud operations / typeorm / find one
7041
6814
  /**
7042
- * Creates a new entity instance or instances.
7043
- * Can copy properties from the given object into new entities.
6815
+ * Finds first entity by a given find options.
6816
+ * If entity was not found in the database - returns null.
7044
6817
  */
7045
- create(plainEntityLikeOrPlainEntityLikes) {
7046
- return this.repo.create(plainEntityLikeOrPlainEntityLikes);
6818
+ findOne(options) {
6819
+ return this.repo.findOne(options);
7047
6820
  }
7048
- async bulkSave(items, options) {
7049
- /* */
7050
- /* */
7051
- /* */
7052
- /* */
7053
- /* */
7054
- /* */
7055
- /* */
7056
- /* */
7057
- /* */
7058
- return (void 0);
6821
+ //#endregion
6822
+ //#region crud operations / typeorm / find one by
6823
+ /**
6824
+ * Finds first entity that matches given where condition.
6825
+ * If entity was not found in the database - returns null.
6826
+ */
6827
+ findOneBy(where) {
6828
+ return this.repo.findOneBy(where);
7059
6829
  }
6830
+ //#endregion
6831
+ //#region crud operations / typeorm / find one or fail
7060
6832
  /**
7061
- * @deprecated use bulkSave instead
6833
+ * Finds first entity that matches given id.
6834
+ * If entity was not found in the database - returns null.
6835
+ *
6836
+ * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:
6837
+ *
6838
+ * .findOneBy({
6839
+ * id: 1 // where "id" is your primary column name
6840
+ * })
7062
6841
  */
7063
- async bulkCreate(items, options) {
7064
- return this.bulkSave(items, options);
6842
+ findOneById(id) {
6843
+ return this.repo.findOneById(id);
7065
6844
  }
7066
- //#region old typeorm version
6845
+ //#endregion
6846
+ //#region crud operations / typeorm / find one or fail
7067
6847
  /**
7068
- * Saves all given entities in the database.
7069
- * If entities do not exist in the database then inserts, otherwise updates.
6848
+ * Finds first entity by a given find options.
6849
+ * If entity was not found in the database - rejects with error.
7070
6850
  */
7071
- // save<T extends DeepPartial<Entity>>(
7072
- // entities: T[],
7073
- // options: SaveOptions & {
7074
- // reload: false;
7075
- // },
7076
- // ): Promise<T[]>;
7077
- // /**
7078
- // * Saves all given entities in the database.
7079
- // * If entities do not exist in the database then inserts, otherwise updates.
7080
- // */
7081
- // save<T extends DeepPartial<Entity>>(
7082
- // entities: T[],
7083
- // options?: SaveOptions,
7084
- // ): Promise<(T & Entity)[]>;
7085
- // /**
7086
- // * Saves a given entity in the database.
7087
- // * If entity does not exist in the database then inserts, otherwise updates.
7088
- // */
7089
- // save<T extends DeepPartial<Entity>>(
7090
- // entity: T,
7091
- // options: SaveOptions & {
7092
- // reload: false;
7093
- // },
7094
- // ): Promise<T>;
7095
- // /**
7096
- // * Saves a given entity in the database.
7097
- // * If entity does not exist in the database then inserts, otherwise updates.
7098
- // */
7099
- // save<T extends DeepPartial<Entity>>(
7100
- // entity: T,
7101
- // options?: SaveOptions,
7102
- // ): Promise<T & Entity> {
7103
- // return this.repo.save(entity, options);
7104
- // }
6851
+ findOneOrFail(options) {
6852
+ return this.repo.findOneOrFail(options);
6853
+ }
6854
+ //#endregion
6855
+ //#region crud operations / typeorm / find one by or fail
6856
+ /**
6857
+ * Finds first entity that matches given where condition.
6858
+ * If entity was not found in the database - rejects with error.
6859
+ */
6860
+ findOneByOrFail(where) {
6861
+ return this.repo.findOneByOrFail(where);
6862
+ }
6863
+ //#endregion
6864
+ //#region crud operations / typeorm / query
6865
+ /**
6866
+ * Executes a raw SQL query and returns a raw database results.
6867
+ * Raw query execution is supported only by relational databases (MongoDB is not supported).
6868
+ */
6869
+ query(query, parameters) {
6870
+ return this.repo.query(query, parameters);
6871
+ }
6872
+ //#endregion
6873
+ //#region crud operations / typeorm / query
6874
+ /**
6875
+ * Executes a raw SQL query and returns a raw database results.
6876
+ * Raw query execution is supported only by relational databases (MongoDB is not supported).
6877
+ */
6878
+ createQueryBuilder(alias, queryRunner) {
6879
+ return this.repo.createQueryBuilder(alias, queryRunner);
6880
+ }
7105
6881
  //#endregion
6882
+ //#region crud operations / typeorm / clear
6883
+ /**
6884
+ * Clears all the data from the given table/collection (truncates/drops it).
6885
+ *
6886
+ * Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms.
6887
+ * @see https://stackoverflow.com/a/5972738/925151
6888
+ */
6889
+ clear() {
6890
+ return this.repo.clear();
6891
+ }
7106
6892
  //#endregion
7107
- //#region crud operations / typeorm / merge
6893
+ //#region crud operations / typeorm / increment
7108
6894
  /**
7109
- * Merges multiple entities (or entity-like objects) into a given entity.
6895
+ * Increments some column by provided value of the entities matched given conditions.
7110
6896
  */
7111
- merge(mergeIntoEntity, ...entityLikes) {
7112
- return this.repo.merge(mergeIntoEntity, ...entityLikes);
6897
+ increment(conditions, propertyPath, value) {
6898
+ return this.repo.increment(conditions, propertyPath, value);
7113
6899
  }
7114
6900
  //#endregion
7115
- //#region crud operations / typeorm / preload
6901
+ //#region crud operations / typeorm / decrement
7116
6902
  /**
7117
- * Creates a new entity from the given plain javascript object. If entity already exist in the database, then
7118
- * it loads it (and everything related to it), replaces all values with the new ones from the given object
7119
- * and returns this new entity. This new entity is actually a loaded from the db entity with all properties
7120
- * replaced from the new object.
7121
- *
7122
- * Note that given entity-like object must have an entity id / primary key to find entity by.
7123
- * Returns undefined if entity with given id was not found.
6903
+ * Decrements some column by provided value of the entities matched given conditions.
7124
6904
  */
7125
- preload(entityLike) {
7126
- return this.repo.preload(entityLike);
6905
+ decrement(conditions, propertyPath, value) {
6906
+ return this.repo.decrement(conditions, propertyPath, value);
7127
6907
  }
7128
6908
  //#endregion
7129
- //#region crud operations / typeorm / remove (delete) & bulk remove (delete)
6909
+ //#region crud operations / get all
7130
6910
  /**
7131
- * Removes a given entities from the database.
6911
+ * @deprecated use findAndCount instead
7132
6912
  */
7133
- async remove(idOrEntity) {
7134
- /* */
7135
- /* */
7136
- /* */
7137
- /* */
7138
- /* */
7139
- /* */
7140
- /* */
7141
- /* */
7142
- /* */
7143
- /* */
7144
- /* */
6913
+ async getAll() {
7145
6914
  /* */
7146
6915
  /* */
7147
6916
  /* */
@@ -7155,25 +6924,9 @@ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomReposito
7155
6924
  /* */
7156
6925
  return (void 0);
7157
6926
  }
7158
- /**
7159
- * alias to remove
7160
- */
7161
- async delete(idOrEntity) {
7162
- return this.remove(idOrEntity);
7163
- }
7164
- /**
7165
- * alias to removeById
7166
- */
7167
- async deleteById(id) {
7168
- return this.remove(id);
7169
- }
7170
- async bulkRemove(idsOrEntities) {
7171
- /* */
7172
- /* */
7173
- /* */
7174
- /* */
7175
- /* */
7176
- /* */
6927
+ //#endregion
6928
+ //#region crud operations / get by id
6929
+ async getBy(id) {
7177
6930
  /* */
7178
6931
  /* */
7179
6932
  /* */
@@ -7182,55 +6935,199 @@ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomReposito
7182
6935
  /* */
7183
6936
  return (void 0);
7184
6937
  }
7185
- async bulkDelete(ids) {
7186
- return this.bulkRemove(ids);
6938
+ };
6939
+ TaonBaseRepository = __decorate([
6940
+ TaonRepository({ className: 'TaonBaseRepository' }),
6941
+ __metadata("design:paramtypes", [Function])
6942
+ ], TaonBaseRepository);
6943
+
6944
+ const TaonBaseContext = createContext(() => ({
6945
+ contextName: 'TaonBaseContext',
6946
+ abstract: true,
6947
+ contexts: {
6948
+ // TaonGlobalStateContext,
6949
+ },
6950
+ middlewares: {
6951
+ TaonBaseFileUploadMiddleware,
6952
+ },
6953
+ repositories: {
6954
+ // @ts-ignore
6955
+ TaonBaseRepository,
6956
+ },
6957
+ }));
6958
+
6959
+ var baseContext = /*#__PURE__*/Object.freeze({
6960
+ __proto__: null,
6961
+ TaonBaseContext: TaonBaseContext
6962
+ });
6963
+
6964
+ /**
6965
+ * Controller decorator
6966
+ */
6967
+ function TaonController(options) {
6968
+ return function (constructor) {
6969
+ ClassHelpers__NS__setName(constructor, options?.className);
6970
+ Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
6971
+ const cfg = ClassHelpers__NS__ensureClassConfig(constructor);
6972
+ options = options || {};
6973
+ cfg.className = options.className || constructor.name;
6974
+ cfg.path = options.path || '';
6975
+ cfg.realtime = options.realtime;
6976
+ cfg.middlewares = options.middlewares;
6977
+ };
6978
+ }
6979
+
6980
+ const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal) => {
6981
+ const methodConfig = ClassHelpers__NS__ensureMethodConfig(target, propertyKey);
6982
+ let options;
6983
+ if (typeof pathOrOptions === 'object') {
6984
+ options = pathOrOptions;
6985
+ pathOrOptions = options.path;
6986
+ pathIsGlobal = !!options.pathIsGlobal;
6987
+ path = options.path;
7187
6988
  }
7188
- /**
7189
- * Records the delete date of a given entity.
7190
- */
7191
- softRemove(entity, options) {
7192
- return this.repo.softRemove(entity, options);
6989
+ else {
6990
+ options = { pathOrOptions, pathIsGlobal };
7193
6991
  }
7194
- /**
7195
- * Recovers a given entity in the database.
7196
- */
7197
- recover(entity, options) {
7198
- return this.repo.recover(entity, options);
6992
+ const { overrideContentType, overrideResponseType, overrideExpressSendAsHtml, middlewares, } = options;
6993
+ methodConfig.methodName = propertyKey;
6994
+ methodConfig.middlewares = middlewares;
6995
+ methodConfig.type = method;
6996
+ if (!path) {
6997
+ let paramsPathConcatedPath = '';
6998
+ for (const key in methodConfig.parameters) {
6999
+ if (methodConfig.parameters.hasOwnProperty(key)) {
7000
+ const element = methodConfig.parameters[key];
7001
+ if (element.paramType === 'Path' &&
7002
+ ___NS__isString(element.paramName) &&
7003
+ element.paramName.trim().length > 0) {
7004
+ paramsPathConcatedPath += `/${element.paramName}/:${element.paramName}`;
7005
+ }
7006
+ }
7007
+ }
7008
+ methodConfig.path = `/${propertyKey}${paramsPathConcatedPath}`;
7199
7009
  }
7200
- //#endregion
7201
- //#region crud operations / typeorm / insert
7010
+ else {
7011
+ methodConfig.path = path;
7012
+ }
7013
+ methodConfig.descriptor = descriptor;
7014
+ methodConfig.global = pathIsGlobal;
7015
+ methodConfig.contentType = overrideContentType;
7016
+ methodConfig.responseType = overrideResponseType;
7017
+ methodConfig.overrideExpressSendAsHtml = overrideExpressSendAsHtml;
7018
+ };
7019
+ function GET(pathOrOptions, pathIsGlobal = false) {
7020
+ return function (target, propertyKey, descriptor) {
7021
+ metaReq('get', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
7022
+ };
7023
+ }
7024
+ /**
7025
+ * Method for sending html website from text
7026
+ * Example
7027
+ *
7028
+ * ```ts
7029
+ * ...
7030
+ * // in your taon controller
7031
+ * ..Taon.Http.HTML()
7032
+ * sendHtmlDummyWebsite(): Taon__NS__ResponseHtml {
7033
+ * return `
7034
+ <html>
7035
+ <head>
7036
+ <title>Dummy website</title>
7037
+ </head>
7038
+ <body>
7039
+ <h1>This is dummy website</h1>
7040
+ <p>Served as HTML string from Taon controller method</p>
7041
+ </body>
7042
+ </html>
7043
+ * `; *
7044
+ * }
7045
+ * ...
7046
+ * ```
7047
+ */
7048
+ function HTML(pathOrOptions) {
7049
+ return function (target, propertyKey, descriptor) {
7050
+ const opt = pathOrOptions;
7051
+ opt.overrideExpressSendAsHtml = true;
7052
+ metaReq('get', opt, target, propertyKey, descriptor, pathOrOptions, opt.pathIsGlobal);
7053
+ };
7054
+ }
7055
+ function HEAD(pathOrOptions, pathIsGlobal = false) {
7056
+ return function (target, propertyKey, descriptor) {
7057
+ metaReq('head', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
7058
+ };
7059
+ }
7060
+ function POST(pathOrOptions, pathIsGlobal = false) {
7061
+ return function (target, propertyKey, descriptor) {
7062
+ metaReq('post', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
7063
+ };
7064
+ }
7065
+ function PUT(pathOrOptions, pathIsGlobal = false) {
7066
+ return function (target, propertyKey, descriptor) {
7067
+ metaReq('put', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
7068
+ };
7069
+ }
7070
+ function PATCH(pathOrOptions, pathIsGlobal = false) {
7071
+ return function (target, propertyKey, descriptor) {
7072
+ metaReq('patch', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
7073
+ };
7074
+ }
7075
+ function DELETE(pathOrOptions, pathIsGlobal = false) {
7076
+ return function (target, propertyKey, descriptor) {
7077
+ metaReq('delete', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
7078
+ };
7079
+ }
7080
+
7081
+ function metaParam(param, name, expire, defaultValue = undefined, target, propertyKey, parameterIndex) {
7082
+ const methodCfg = ClassHelpers__NS__ensureMethodConfig(target, propertyKey);
7083
+ const nameKey = name ? name : param;
7084
+ // const key = name || `${param}_${parameterIndex}`;
7085
+ methodCfg.parameters[nameKey] = {
7086
+ index: parameterIndex,
7087
+ paramName: name,
7088
+ paramType: param,
7089
+ defaultType: defaultValue,
7090
+ expireInSeconds: expire,
7091
+ };
7092
+ // console.log('params updated', methodConfig);
7093
+ }
7094
+ /**
7095
+ * @deprecated use Taon.Http.Param.Path (is more safe and cleaner)
7096
+ */
7097
+ function Path(name) {
7098
+ return function (target, propertyKey, parameterIndex) {
7099
+ metaParam('Path', name, undefined, {}, target, propertyKey, parameterIndex);
7100
+ };
7101
+ }
7102
+ function Query(name) {
7103
+ return function (target, propertyKey, parameterIndex) {
7104
+ metaParam('Query', name, undefined, {}, target, propertyKey, parameterIndex);
7105
+ };
7106
+ }
7107
+ function Cookie(name, expireInSecond = 3600) {
7108
+ return function (target, propertyKey, parameterIndex) {
7109
+ metaParam('Cookie', name, expireInSecond, {}, target, propertyKey, parameterIndex);
7110
+ };
7111
+ }
7112
+ function Header(name) {
7113
+ return function (target, propertyKey, parameterIndex) {
7114
+ metaParam('Header', name, undefined, {}, target, propertyKey, parameterIndex);
7115
+ };
7116
+ }
7117
+ function Body(name) {
7118
+ return function (target, propertyKey, parameterIndex) {
7119
+ metaParam('Body', name, undefined, {}, target, propertyKey, parameterIndex);
7120
+ };
7121
+ }
7122
+
7123
+ let TaonBaseController = class TaonBaseController extends TaonBaseInjector {
7202
7124
  /**
7203
- * Inserts a given entity into the database.
7204
- * Unlike save method executes a primitive operation without cascades, relations and other operations included.
7205
- * Executes fast and efficient INSERT query.
7206
- * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.
7125
+ * Hook that is called when taon app is inited
7126
+ * (all contexts are created and inited)
7207
7127
  */
7208
- insert(entity) {
7209
- // debugger;
7210
- return this.repo.insert(entity);
7211
- }
7212
- //#endregion
7213
- //#region crud operations / typeorm / update & build update
7214
- async update(item) {
7215
- /* */
7216
- /* */
7217
- /* */
7218
- return (void 0);
7219
- }
7220
- async updateById(id, item) {
7221
- /* */
7222
- /* */
7223
- /* */
7224
- /* */
7225
- /* */
7226
- /* */
7227
- /* */
7228
- /* */
7229
- /* */
7230
- /* */
7231
- /* */
7232
- /* */
7233
- /* */
7128
+ async afterAllCtxInited(options) { }
7129
+ //#region upload form data to server
7130
+ uploadFormDataToServer(formData, queryParams) {
7234
7131
  /* */
7235
7132
  /* */
7236
7133
  /* */
@@ -7257,14 +7154,24 @@ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomReposito
7257
7154
  /* */
7258
7155
  /* */
7259
7156
  /* */
7157
+ return (void 0);
7158
+ }
7159
+ //#endregion
7160
+ //#region after file upload hook
7161
+ /**
7162
+ * Hook after file is uploaded
7163
+ * through `uploadFormDataToServer` or `uploadLocalFileToServer`
7164
+ */
7165
+ afterFileUploadAction(file, queryParams) {
7166
+ // empty
7167
+ }
7168
+ //#region upload local file to server
7169
+ async uploadLocalFileToServer(absFilePath, options, queryParams) {
7260
7170
  /* */
7261
7171
  /* */
7262
7172
  /* */
7263
7173
  /* */
7264
7174
  /* */
7265
- return (void 0);
7266
- }
7267
- async bulkUpdate(items) {
7268
7175
  /* */
7269
7176
  /* */
7270
7177
  /* */
@@ -7276,249 +7183,232 @@ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomReposito
7276
7183
  /* */
7277
7184
  return (void 0);
7278
7185
  }
7279
- //#region tpeorm update version
7280
- // this version suck and will not return update entity
7281
- // /**
7282
- // * Updates entity partially. Entity can be found by a given conditions.
7283
- // * Unlike save method executes a primitive operation without cascades, relations and other operations included.
7284
- // * Executes fast and efficient UPDATE query.
7285
- // * Does not check if entity exist in the database.
7286
- // */
7287
- // update(
7288
- // criteria:
7289
- // | string
7290
- // | string[]
7291
- // | number
7292
- // | number[]
7293
- // | Date
7294
- // | Date[]
7295
- // | ObjectID
7296
- // | ObjectID[]
7297
- // | FindOptionsWhere<Entity>,
7298
- // partialEntity: QueryDeepPartialEntity<Entity>,
7299
- // ): Promise<UpdateResult> {
7300
- // return this.repo.update(criteria, partialEntity);
7301
- // }
7302
- //#endregion
7303
- //#endregion
7304
- //#region crud operations / typeorm / upsert
7305
- /**
7306
- * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity
7307
- * Unlike save method executes a primitive operation without cascades, relations and other operations included.
7308
- * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.
7309
- */
7310
- upsert(entityOrEntities, conflictPathsOrOptions) {
7311
- return this.repo.upsert(entityOrEntities, conflictPathsOrOptions);
7312
- }
7313
- //#endregion
7314
- //#region crud operations / typeorm / soft delete
7315
- /**
7316
- * Records the delete date of entities by a given criteria.
7317
- * Unlike save method executes a primitive operation without cascades, relations and other operations included.
7318
- * Executes fast and efficient SOFT-DELETE query.
7319
- * Does not check if entity exist in the database.
7320
- */
7321
- softDelete(criteria) {
7322
- return this.repo.softDelete(criteria);
7323
- }
7324
- //#endregion
7325
- //#region crud operations / typeorm / restore
7326
- /**
7327
- * Restores entities by a given criteria.
7328
- * Unlike save method executes a primitive operation without cascades, relations and other operations included.
7329
- * Executes fast and efficient SOFT-DELETE query.
7330
- * Does not check if entity exist in the database.
7331
- */
7332
- restore(criteria) {
7333
- return this.repo.restore(criteria);
7334
- }
7335
- //#endregion
7336
- //#region crud operations / typeorm / count
7337
- /**
7338
- * Counts entities that match given options.
7339
- * Useful for pagination.
7340
- */
7341
- count(options) {
7342
- return this.repo.count(options);
7343
- }
7344
- //#endregion
7345
- //#region crud operations / typeorm / count by
7346
- /**
7347
- * Counts entities that match given conditions.
7348
- * Useful for pagination.
7349
- */
7350
- countBy(where) {
7351
- return this.repo.countBy(where);
7352
- }
7353
- //#endregion
7354
- //#region crud operations / typeorm / find
7355
- /**
7356
- * Finds entities that match given find options.
7357
- */
7358
- find(options) {
7359
- return this.repo.find(options);
7360
- }
7361
- //#endregion
7362
- //#region crud operations / typeorm / find by
7363
- /**
7364
- * Finds entities that match given find options.
7365
- */
7366
- findBy(where) {
7367
- return this.repo.findBy(where);
7368
- }
7369
7186
  //#endregion
7370
- //#region crud operations / typeorm / find and count
7371
- // async findAndCount(options: { take: number; skip: number }) {
7372
- // const { take, skip } = options;
7373
- // const [result, total] = await this.repo.findAndCount({
7374
- // // where: { name: Like('%' + keyword + '%') },
7375
- // // order: { name: "DESC" },
7376
- // take: take,
7377
- // skip: skip,
7378
- // });
7379
- // return { result, total };
7187
+ // async check() {
7188
+ // await this._waitForProperStatusChange({
7189
+ // request: () => this.uploadFormDataToServer(void 0, void 0).request(),
7190
+ // statusCheck: resp => resp.body.json[0].ok,
7191
+ // });
7380
7192
  // }
7381
- //
7382
- /**
7383
- * Finds entities that match given find options.
7384
- * Also counts all entities that match given conditions,
7385
- * but ignores pagination settings (from and take options).
7386
- */
7387
- findAndCount(options) {
7388
- return this.repo.findAndCount(options);
7389
- }
7390
- //#endregion
7391
- //#region crud operations / typeorm / find and count by
7392
- /**
7393
- * Finds entities that match given WHERE conditions.
7394
- * Also counts all entities that match given conditions,
7395
- * but ignores pagination settings (from and take options).
7396
- */
7397
- findAndCountBy(where) {
7398
- return this.repo.findAndCountBy(where);
7399
- }
7400
- //#endregion
7401
- //#region crud operations / typeorm / find by ids
7402
7193
  /**
7403
- * Finds entities with ids.
7404
- * Optionally find options or conditions can be applied.
7405
- *
7406
- * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:
7407
- *
7408
- * .findBy({
7409
- * id: In([1, 2, 3])
7410
- * })
7411
- */
7412
- findByIds(ids) {
7413
- return this.repo.findByIds(ids);
7414
- }
7415
- //#endregion
7416
- //#region crud operations / typeorm / find one
7417
- /**
7418
- * Finds first entity by a given find options.
7419
- * If entity was not found in the database - returns null.
7420
- */
7421
- findOne(options) {
7422
- return this.repo.findOne(options);
7423
- }
7424
- //#endregion
7425
- //#region crud operations / typeorm / find one by
7426
- /**
7427
- * Finds first entity that matches given where condition.
7428
- * If entity was not found in the database - returns null.
7429
- */
7430
- findOneBy(where) {
7431
- return this.repo.findOneBy(where);
7432
- }
7433
- //#endregion
7434
- //#region crud operations / typeorm / find one or fail
7435
- /**
7436
- * Finds first entity that matches given id.
7437
- * If entity was not found in the database - returns null.
7438
- *
7439
- * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:
7194
+ * Easy way to wait for status change with http (1s default) pooling.
7440
7195
  *
7441
- * .findOneBy({
7442
- * id: 1 // where "id" is your primary column name
7443
- * })
7444
- */
7445
- findOneById(id) {
7446
- return this.repo.findOneById(id);
7447
- }
7448
- //#endregion
7449
- //#region crud operations / typeorm / find one or fail
7450
- /**
7451
- * Finds first entity by a given find options.
7452
- * If entity was not found in the database - rejects with error.
7453
- */
7454
- findOneOrFail(options) {
7455
- return this.repo.findOneOrFail(options);
7456
- }
7457
- //#endregion
7458
- //#region crud operations / typeorm / find one by or fail
7459
- /**
7460
- * Finds first entity that matches given where condition.
7461
- * If entity was not found in the database - rejects with error.
7196
+ * example (in sub class):
7197
+ * ```ts
7198
+ async check() {
7199
+ await this.waitForProperStatusChange({
7200
+ request: () => this.uploadFormDataToServer(void 0, void 0).request(),
7201
+ statusCheck: resp => resp.body.json[0].ok,
7202
+ });
7203
+ }
7204
+ * ```
7462
7205
  */
7463
- findOneByOrFail(where) {
7464
- return this.repo.findOneByOrFail(where);
7206
+ async _waitForProperStatusChange(options) {
7207
+ const poolingInterval = options.poolingInterval || 1000;
7208
+ const taonRequest = options.request;
7209
+ let maxTries = options.maxTries || Number.POSITIVE_INFINITY;
7210
+ let i = 0;
7211
+ let httpErrorsCount = 0;
7212
+ while (true) {
7213
+ await UtilsTerminal__NS__waitMilliseconds(poolingInterval);
7214
+ try {
7215
+ const resp = await taonRequest({
7216
+ reqIndexNum: i,
7217
+ httpErrorsCount,
7218
+ });
7219
+ if (options.statusCheck && options.statusCheck(resp)) {
7220
+ return;
7221
+ }
7222
+ }
7223
+ catch (error) {
7224
+ httpErrorsCount++;
7225
+ if (options.loopRequestsOnBackendError) {
7226
+ const isProperTaonError = error instanceof HttpResponseError &&
7227
+ error.body.json[CoreModels__NS__TaonHttpErrorCustomProp];
7228
+ const isHttpError = error instanceof HttpResponseError && !isProperTaonError;
7229
+ const isUnknownError = !(error instanceof HttpResponseError);
7230
+ const resBool = await options.loopRequestsOnBackendError({
7231
+ taonError: isProperTaonError ? error : void 0,
7232
+ unknownHttpError: isHttpError ? error : void 0,
7233
+ unknownError: isUnknownError ? error : void 0,
7234
+ reqIndexNum: i,
7235
+ httpErrorsCount,
7236
+ });
7237
+ if (resBool) {
7238
+ i++;
7239
+ continue;
7240
+ }
7241
+ else {
7242
+ return;
7243
+ }
7244
+ }
7245
+ if (httpErrorsCount >
7246
+ (options.allowedHttpErrors || Number.POSITIVE_INFINITY)) {
7247
+ throw new Error(`Too many http errors (${httpErrorsCount}) for "${options.actionName}".`);
7248
+ }
7249
+ }
7250
+ if (i++ > maxTries) {
7251
+ throw new Error(`Timeout waiting for "${options.actionName}" to be finished. Waited for ${maxTries} seconds`);
7252
+ }
7253
+ }
7465
7254
  }
7255
+ };
7256
+ __decorate([
7257
+ POST({
7258
+ overrideContentType: 'multipart/form-data',
7259
+ middlewares: ({ parentMiddlewares }) => ({
7260
+ ...parentMiddlewares,
7261
+ TaonBaseFileUploadMiddleware,
7262
+ }),
7263
+ }),
7264
+ __param(0, Body()),
7265
+ __param(1, Query()),
7266
+ __metadata("design:type", Function),
7267
+ __metadata("design:paramtypes", [FormData, Object]),
7268
+ __metadata("design:returntype", Object)
7269
+ ], TaonBaseController.prototype, "uploadFormDataToServer", null);
7270
+ TaonBaseController = __decorate([
7271
+ TaonController({
7272
+ className: 'TaonBaseController',
7273
+ })
7274
+ ], TaonBaseController);
7275
+
7276
+ //#endregion
7277
+ /**
7278
+ * Please override property entityClassFn with entity class.
7279
+ */
7280
+ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseController {
7466
7281
  //#endregion
7467
- //#region crud operations / typeorm / query
7468
- /**
7469
- * Executes a raw SQL query and returns a raw database results.
7470
- * Raw query execution is supported only by relational databases (MongoDB is not supported).
7471
- */
7472
- query(query, parameters) {
7473
- return this.repo.query(query, parameters);
7282
+ //#region init
7283
+ async _() {
7284
+ if (!___NS__isFunction(this.entityClassResolveFn)) {
7285
+ Helpers__NS__warn(`Skipping initing CRUD controller ${ClassHelpers__NS__getName(this)} because entityClassResolveFn is not provided.`);
7286
+ return;
7287
+ }
7288
+ let entityClassFn = this.entityClassResolveFn();
7289
+ this.db = this.injectRepo(entityClassFn);
7290
+ if (entityClassFn) {
7291
+ const configEntity = Reflect.getMetadata(Symbols__NS__metadata.options.entity, ClassHelpers__NS__getClassFnFromObject(this));
7292
+ if (configEntity?.createTable === false) {
7293
+ Helpers__NS__warn(`Table for entity ${ClassHelpers__NS__getName(entityClassFn)} will not be created. Crud will not work properly.`);
7294
+ }
7295
+ }
7296
+ else {
7297
+ Helpers__NS__error(`Entity class not provided for controller ${ClassHelpers__NS__getName(this)}.
7298
+
7299
+ Please provide entity as class property entityClassFn:
7300
+
7301
+ class ${ClassHelpers__NS__getName(this)} extends TaonBaseCrudController<Entity> {
7302
+ // ...
7303
+ entityClassResolveFn = ()=> MyEntityClass;
7304
+ // ...
7305
+ }
7306
+
7307
+ `);
7308
+ }
7309
+ await super._();
7474
7310
  }
7475
7311
  //#endregion
7476
- //#region crud operations / typeorm / query
7477
- /**
7478
- * Executes a raw SQL query and returns a raw database results.
7479
- * Raw query execution is supported only by relational databases (MongoDB is not supported).
7480
- */
7481
- createQueryBuilder(alias, queryRunner) {
7482
- return this.repo.createQueryBuilder(alias, queryRunner);
7312
+ //#region bufferd changes
7313
+ bufforedChanges(id, property, alreadyLength) {
7314
+ /* */
7315
+ /* */
7316
+ /* */
7317
+ /* */
7318
+ /* */
7319
+ /* */
7320
+ /* */
7321
+ /* */
7322
+ /* */
7323
+ /* */
7324
+ /* */
7325
+ /* */
7326
+ /* */
7327
+ /* */
7328
+ /* */
7329
+ return (void 0);
7483
7330
  }
7484
7331
  //#endregion
7485
- //#region crud operations / typeorm / clear
7486
- /**
7487
- * Clears all the data from the given table/collection (truncates/drops it).
7488
- *
7489
- * Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms.
7490
- * @see https://stackoverflow.com/a/5972738/925151
7491
- */
7492
- clear() {
7493
- return this.repo.clear();
7332
+ //#region pagintation
7333
+ pagination(pageNumber = 1, pageSize = 10, search = '') {
7334
+ /* */
7335
+ /* */
7336
+ /* */
7337
+ /* */
7338
+ /* */
7339
+ /* */
7340
+ /* */
7341
+ /* */
7342
+ /* */
7343
+ /* */
7344
+ /* */
7345
+ /* */
7346
+ /* */
7347
+ /* */
7348
+ /* */
7349
+ /* */
7350
+ /* */
7351
+ /* */
7352
+ /* */
7353
+ /* */
7354
+ /* */
7355
+ /* */
7356
+ /* */
7357
+ /* */
7358
+ /* */
7359
+ /* */
7360
+ /* */
7361
+ /* */
7362
+ /* */
7363
+ /* */
7364
+ /* */
7365
+ /* */
7366
+ /* */
7367
+ /* */
7368
+ /* */
7369
+ /* */
7370
+ /* */
7371
+ /* */
7372
+ return (void 0);
7494
7373
  }
7495
7374
  //#endregion
7496
- //#region crud operations / typeorm / increment
7497
- /**
7498
- * Increments some column by provided value of the entities matched given conditions.
7499
- */
7500
- increment(conditions, propertyPath, value) {
7501
- return this.repo.increment(conditions, propertyPath, value);
7375
+ //#region get all
7376
+ getAll() {
7377
+ /* */
7378
+ /* */
7379
+ /* */
7380
+ /* */
7381
+ /* */
7382
+ /* */
7383
+ /* */
7384
+ /* */
7385
+ /* */
7386
+ return (void 0);
7502
7387
  }
7503
7388
  //#endregion
7504
- //#region crud operations / typeorm / decrement
7505
- /**
7506
- * Decrements some column by provided value of the entities matched given conditions.
7507
- */
7508
- decrement(conditions, propertyPath, value) {
7509
- return this.repo.decrement(conditions, propertyPath, value);
7389
+ //#region get by id
7390
+ getBy(id) {
7391
+ /* */
7392
+ /* */
7393
+ /* */
7394
+ /* */
7395
+ /* */
7396
+ return (void 0);
7510
7397
  }
7511
7398
  //#endregion
7512
- //#region crud operations / get all
7513
- /**
7514
- * @deprecated use findAndCount instead
7515
- */
7516
- async getAll() {
7399
+ //#region update by id
7400
+ updateById(id, item) {
7401
+ /* */
7517
7402
  /* */
7518
7403
  /* */
7519
7404
  /* */
7520
7405
  /* */
7521
7406
  /* */
7407
+ return (void 0);
7408
+ }
7409
+ //#endregion
7410
+ //#region patch by id
7411
+ patchById(id, item) {
7522
7412
  /* */
7523
7413
  /* */
7524
7414
  /* */
@@ -7528,8 +7418,10 @@ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomReposito
7528
7418
  return (void 0);
7529
7419
  }
7530
7420
  //#endregion
7531
- //#region crud operations / get by id
7532
- async getBy(id) {
7421
+ //#region bulk update
7422
+ bulkUpdate(items) {
7423
+ /* */
7424
+ /* */
7533
7425
  /* */
7534
7426
  /* */
7535
7427
  /* */
@@ -7538,20 +7430,19 @@ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomReposito
7538
7430
  /* */
7539
7431
  return (void 0);
7540
7432
  }
7541
- };
7542
- TaonBaseRepository = __decorate([
7543
- TaonRepository({ className: 'TaonBaseRepository' }),
7544
- __metadata("design:paramtypes", [Function])
7545
- ], TaonBaseRepository);
7546
-
7547
- //#region imports
7548
- //#endregion
7549
- let TaonGlobalStateRepository = class TaonGlobalStateRepository extends TaonBaseRepository {
7550
- constructor() {
7551
- super(...arguments);
7552
- this.entityClassResolveFn = () => TAON_GLOBAL_STATE;
7433
+ //#endregion
7434
+ //#region delete by id
7435
+ deleteById(id) {
7436
+ /* */
7437
+ /* */
7438
+ /* */
7439
+ /* */
7440
+ /* */
7441
+ return (void 0);
7553
7442
  }
7554
- async getLastStatus() {
7443
+ //#endregion
7444
+ //#region bulk delete
7445
+ bulkDelete(ids) {
7555
7446
  /* */
7556
7447
  /* */
7557
7448
  /* */
@@ -7559,9 +7450,18 @@ let TaonGlobalStateRepository = class TaonGlobalStateRepository extends TaonBase
7559
7450
  /* */
7560
7451
  return (void 0);
7561
7452
  }
7562
- async setDraining(secondsBeforeReadonly = 0) {
7453
+ //#endregion
7454
+ //#region bulk delete
7455
+ clearTable() {
7456
+ /* */
7563
7457
  /* */
7564
7458
  /* */
7459
+ /* */
7460
+ return (void 0);
7461
+ }
7462
+ //#endregion
7463
+ //#region create
7464
+ save(item) {
7565
7465
  /* */
7566
7466
  /* */
7567
7467
  /* */
@@ -7569,8 +7469,9 @@ let TaonGlobalStateRepository = class TaonGlobalStateRepository extends TaonBase
7569
7469
  /* */
7570
7470
  return (void 0);
7571
7471
  }
7572
- async transitionTo(next) {
7573
- /* */
7472
+ //#endregion
7473
+ //#region bulk create
7474
+ bulkCreate(items) {
7574
7475
  /* */
7575
7476
  /* */
7576
7477
  /* */
@@ -7579,52 +7480,115 @@ let TaonGlobalStateRepository = class TaonGlobalStateRepository extends TaonBase
7579
7480
  return (void 0);
7580
7481
  }
7581
7482
  };
7582
- TaonGlobalStateRepository = __decorate([
7583
- TaonRepository({
7584
- className: 'TaonGlobalStateRepository',
7585
- })
7586
- ], TaonGlobalStateRepository);
7587
-
7588
- //#region imports
7589
- //#endregion
7590
- let TaonGlobalStateController = class TaonGlobalStateController extends TaonBaseCrudController {
7591
- constructor() {
7592
- super(...arguments);
7593
- this.entityClassResolveFn = () => TAON_GLOBAL_STATE;
7594
- this.taonGlobalStateRepository = this.injectCustomRepo(TaonGlobalStateRepository);
7595
- }
7596
- getStatus() {
7597
- return async () => {
7598
- /* */
7599
- /* */
7600
- /* */
7601
- return (void 0);
7602
- };
7603
- }
7604
- setDraining(secondsBeforeReadonly = 0) {
7605
- return async () => {
7606
- await this.taonGlobalStateRepository.setDraining(secondsBeforeReadonly);
7607
- };
7608
- }
7609
- };
7610
7483
  __decorate([
7611
7484
  GET(),
7485
+ __param(0, Query(`id`)),
7486
+ __param(1, Query(`property`)),
7487
+ __param(2, Query('alreadyLength')),
7488
+ __metadata("design:type", Function),
7489
+ __metadata("design:paramtypes", [Object, String, Number]),
7490
+ __metadata("design:returntype", Object)
7491
+ ], TaonBaseCrudController.prototype, "bufforedChanges", null);
7492
+ __decorate([
7493
+ GET(),
7494
+ __param(0, Query('pageNumber')),
7495
+ __param(1, Query('pageSize')),
7496
+ __param(2, Query('search')),
7497
+ __metadata("design:type", Function),
7498
+ __metadata("design:paramtypes", [Number, Number, String]),
7499
+ __metadata("design:returntype", Object)
7500
+ ], TaonBaseCrudController.prototype, "pagination", null);
7501
+ __decorate([
7502
+ GET(),
7503
+ __metadata("design:type", Function),
7504
+ __metadata("design:paramtypes", []),
7505
+ __metadata("design:returntype", Object)
7506
+ ], TaonBaseCrudController.prototype, "getAll", null);
7507
+ __decorate([
7508
+ GET(),
7509
+ __param(0, Query(`id`)),
7510
+ __metadata("design:type", Function),
7511
+ __metadata("design:paramtypes", [Object]),
7512
+ __metadata("design:returntype", Object)
7513
+ ], TaonBaseCrudController.prototype, "getBy", null);
7514
+ __decorate([
7515
+ PUT(),
7516
+ __param(0, Query(`id`)),
7517
+ __param(1, Body()),
7518
+ __metadata("design:type", Function),
7519
+ __metadata("design:paramtypes", [Object, Object]),
7520
+ __metadata("design:returntype", Object)
7521
+ ], TaonBaseCrudController.prototype, "updateById", null);
7522
+ __decorate([
7523
+ PATCH(),
7524
+ __param(0, Query(`id`)),
7525
+ __param(1, Body()),
7526
+ __metadata("design:type", Function),
7527
+ __metadata("design:paramtypes", [Object, Object]),
7528
+ __metadata("design:returntype", Object)
7529
+ ], TaonBaseCrudController.prototype, "patchById", null);
7530
+ __decorate([
7531
+ PUT(),
7532
+ __param(0, Body()),
7533
+ __metadata("design:type", Function),
7534
+ __metadata("design:paramtypes", [Array]),
7535
+ __metadata("design:returntype", Object)
7536
+ ], TaonBaseCrudController.prototype, "bulkUpdate", null);
7537
+ __decorate([
7538
+ DELETE(),
7539
+ __param(0, Query(`id`)),
7540
+ __metadata("design:type", Function),
7541
+ __metadata("design:paramtypes", [Object]),
7542
+ __metadata("design:returntype", Object)
7543
+ ], TaonBaseCrudController.prototype, "deleteById", null);
7544
+ __decorate([
7545
+ DELETE(),
7546
+ __param(0, Query(`ids`)),
7547
+ __metadata("design:type", Function),
7548
+ __metadata("design:paramtypes", [Array]),
7549
+ __metadata("design:returntype", Object)
7550
+ ], TaonBaseCrudController.prototype, "bulkDelete", null);
7551
+ __decorate([
7552
+ DELETE(),
7612
7553
  __metadata("design:type", Function),
7613
7554
  __metadata("design:paramtypes", []),
7614
7555
  __metadata("design:returntype", Object)
7615
- ], TaonGlobalStateController.prototype, "getStatus", null);
7556
+ ], TaonBaseCrudController.prototype, "clearTable", null);
7616
7557
  __decorate([
7617
7558
  POST(),
7618
- __param(0, Query('secondsBeforeReadonly')),
7559
+ __param(0, Body()),
7619
7560
  __metadata("design:type", Function),
7620
7561
  __metadata("design:paramtypes", [Object]),
7621
7562
  __metadata("design:returntype", Object)
7622
- ], TaonGlobalStateController.prototype, "setDraining", null);
7623
- TaonGlobalStateController = __decorate([
7624
- TaonController({
7625
- className: 'TaonGlobalStateController',
7626
- })
7627
- ], TaonGlobalStateController);
7563
+ ], TaonBaseCrudController.prototype, "save", null);
7564
+ __decorate([
7565
+ POST(),
7566
+ __param(0, Body()),
7567
+ __metadata("design:type", Function),
7568
+ __metadata("design:paramtypes", [Object]),
7569
+ __metadata("design:returntype", Object)
7570
+ ], TaonBaseCrudController.prototype, "bulkCreate", null);
7571
+ TaonBaseCrudController = __decorate([
7572
+ TaonController({ className: 'TaonBaseCrudController' })
7573
+ ], TaonBaseCrudController);
7574
+
7575
+ class TaonBaseMigration extends TaonBaseInjector {
7576
+ /**
7577
+ * by default is READY to run
7578
+ */
7579
+ isReadyToRun() {
7580
+ return true;
7581
+ }
7582
+ getDescription() {
7583
+ return ___NS__startCase(ClassHelpers__NS__getName(this));
7584
+ }
7585
+ async up(queryRunner) {
7586
+ console.log(`[TaonBaseMigration] Running migration UP "${ClassHelpers__NS__getName(this)}"`);
7587
+ }
7588
+ async down(queryRunner) {
7589
+ console.log(`[TaonBaseMigration] Running migration DOWN "${ClassHelpers__NS__getName(this)}"`);
7590
+ }
7591
+ }
7628
7592
 
7629
7593
  /**
7630
7594
  * TODO
@@ -7634,39 +7598,6 @@ TaonGlobalStateController = __decorate([
7634
7598
  class TaonBaseProvider extends TaonBaseInjector {
7635
7599
  }
7636
7600
 
7637
- /**
7638
- * Provider decorator
7639
- */
7640
- function TaonProvider(options) {
7641
- return function (constructor) {
7642
- Reflect.defineMetadata(Symbols__NS__metadata.options.provider, options, constructor);
7643
- Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
7644
- ClassHelpers__NS__setName(constructor, options?.className || constructor.name);
7645
- };
7646
- }
7647
- class TaonProviderOptions extends DecoratorAbstractOpt {
7648
- }
7649
-
7650
- //#region imports
7651
- //#endregion
7652
- let TaonGlobalStateProvider = class TaonGlobalStateProvider extends TaonBaseProvider {
7653
- };
7654
- TaonGlobalStateProvider = __decorate([
7655
- TaonProvider({
7656
- className: 'TaonGlobalStateProvider',
7657
- })
7658
- ], TaonGlobalStateProvider);
7659
-
7660
- //#region imports
7661
- //#endregion
7662
- let TaonGlobalStateMiddleware = class TaonGlobalStateMiddleware extends TaonBaseMiddleware {
7663
- };
7664
- TaonGlobalStateMiddleware = __decorate([
7665
- TaonMiddleware({
7666
- className: 'TaonGlobalStateMiddleware',
7667
- })
7668
- ], TaonGlobalStateMiddleware);
7669
-
7670
7601
  /**
7671
7602
  * Subscriber decorator
7672
7603
  */
@@ -7823,75 +7754,6 @@ TaonBaseSubscriberForEntity = __decorate([
7823
7754
  })
7824
7755
  ], TaonBaseSubscriberForEntity);
7825
7756
 
7826
- //#region imports
7827
- //#endregion
7828
- let TaonGlobalStateSubscriber = class TaonGlobalStateSubscriber extends TaonBaseSubscriberForEntity {
7829
- constructor() {
7830
- super(...arguments);
7831
- this.taonGlobalStateProvider = this.injectProvider(TaonGlobalStateProvider);
7832
- }
7833
- listenTo() {
7834
- return TAON_GLOBAL_STATE;
7835
- }
7836
- };
7837
- TaonGlobalStateSubscriber = __decorate([
7838
- TaonSubscriber({
7839
- className: 'TaonGlobalStateSubscriber',
7840
- // allowedEvents: ['afterUpdate'],
7841
- })
7842
- ], TaonGlobalStateSubscriber);
7843
-
7844
- //#region imports
7845
- //#endregion
7846
- const TaonGlobalStateContext = createContext(() => ({
7847
- contextName: 'TaonGlobalStateContext',
7848
- abstract: true,
7849
- entities: { TAON_GLOBAL_STATE },
7850
- controllers: { TaonGlobalStateController },
7851
- repositories: { TaonGlobalStateRepository },
7852
- providers: { TaonGlobalStateProvider },
7853
- middlewares: { TaonGlobalStateMiddleware },
7854
- subscribers: { TaonGlobalStateSubscriber },
7855
- }));
7856
-
7857
- const TaonBaseContext = createContext(() => ({
7858
- contextName: 'TaonBaseContext',
7859
- abstract: true,
7860
- contexts: {
7861
- TaonGlobalStateContext,
7862
- },
7863
- middlewares: {
7864
- TaonBaseFileUploadMiddleware,
7865
- },
7866
- repositories: {
7867
- // @ts-ignore
7868
- TaonBaseRepository,
7869
- },
7870
- }));
7871
-
7872
- var baseContext = /*#__PURE__*/Object.freeze({
7873
- __proto__: null,
7874
- TaonBaseContext: TaonBaseContext
7875
- });
7876
-
7877
- class TaonBaseMigration extends TaonBaseInjector {
7878
- /**
7879
- * by default is READY to run
7880
- */
7881
- isReadyToRun() {
7882
- return true;
7883
- }
7884
- getDescription() {
7885
- return ___NS__startCase(ClassHelpers__NS__getName(this));
7886
- }
7887
- async up(queryRunner) {
7888
- console.log(`[TaonBaseMigration] Running migration UP "${ClassHelpers__NS__getName(this)}"`);
7889
- }
7890
- async down(queryRunner) {
7891
- console.log(`[TaonBaseMigration] Running migration DOWN "${ClassHelpers__NS__getName(this)}"`);
7892
- }
7893
- }
7894
-
7895
7757
  //#region models / method config
7896
7758
  /**
7897
7759
  * @link './decorators/http/http-methods-decorators.ts' TaonHttpDecoratorOptions
@@ -8350,6 +8212,38 @@ const DateTimeColumn = (defaultValue = null) => Column({ type: 'datetime', nulla
8350
8212
 
8351
8213
  //end of namespace RealtimeModels
8352
8214
 
8215
+ /**
8216
+ * Entity decorator
8217
+ */
8218
+ function TaonEntity(options) {
8219
+ return function (constructor) {
8220
+ options = options || {};
8221
+ options.uniqueKeyProp = options.uniqueKeyProp || 'id';
8222
+ if (!options.className) {
8223
+ const nameForClass = constructor?.name || 'AnyClass';
8224
+ throw `Please define 'classname' property inside decorator of class '${nameForClass}':
8225
+
8226
+ @TaonEntity({
8227
+ className: '${nameForClass}'
8228
+ })
8229
+ class ${constructor?.name} {
8230
+ //...
8231
+
8232
+ `;
8233
+ }
8234
+ ClassHelpers__NS__setName(constructor, options?.className);
8235
+ DefaultMapping(options?.defaultModelMapping)(constructor);
8236
+ DefaultModel(options.defaultModelMapping)(constructor);
8237
+ Reflect.defineMetadata(Symbols__NS__metadata.options.entity, options, constructor);
8238
+ Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
8239
+ /* */
8240
+ /* */
8241
+ CLASS__NS__setName(constructor, options?.className); // TODO QUICK_FIX for ng2-rest
8242
+ };
8243
+ }
8244
+ class TaonEntityOptions extends DecoratorAbstractOpt {
8245
+ }
8246
+
8353
8247
  /**
8354
8248
  * Migration decorator
8355
8249
  */
@@ -8363,6 +8257,19 @@ function TaonMigration(options) {
8363
8257
  class TaonMigrationOptions extends DecoratorAbstractOpt {
8364
8258
  }
8365
8259
 
8260
+ /**
8261
+ * Provider decorator
8262
+ */
8263
+ function TaonProvider(options) {
8264
+ return function (constructor) {
8265
+ Reflect.defineMetadata(Symbols__NS__metadata.options.provider, options, constructor);
8266
+ Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
8267
+ ClassHelpers__NS__setName(constructor, options?.className || constructor.name);
8268
+ };
8269
+ }
8270
+ class TaonProviderOptions extends DecoratorAbstractOpt {
8271
+ }
8272
+
8366
8273
  // TODO export all things
8367
8274
  //namespace Taon
8368
8275
  /**