taon 18.0.25 → 18.0.27

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 (197) hide show
  1. package/README.md +112 -51
  2. package/assets/shared/shared_folder_info.txt +1 -1
  3. package/browser/esm2022/lib/endpoint-context.mjs +4 -1
  4. package/browser/esm2022/lib/index.mjs +2 -2
  5. package/browser/esm2022/lib/models.mjs +1 -1
  6. package/browser/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.mjs +11 -11
  7. package/browser/fesm2022/taon.mjs +3 -0
  8. package/browser/fesm2022/taon.mjs.map +1 -1
  9. package/browser/lib/models.d.ts +5 -0
  10. package/browser/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +4 -4
  11. package/cli.js +11 -17
  12. package/cli.js.map +1 -1
  13. package/client/esm2022/lib/endpoint-context.mjs +4 -1
  14. package/client/esm2022/lib/index.mjs +2 -2
  15. package/client/esm2022/lib/models.mjs +1 -1
  16. package/client/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.mjs +11 -11
  17. package/client/fesm2022/taon.mjs +3 -0
  18. package/client/fesm2022/taon.mjs.map +1 -1
  19. package/client/lib/models.d.ts +5 -0
  20. package/client/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +4 -4
  21. package/index.js +15 -2
  22. package/index.js.map +1 -1
  23. package/lib/base-classes/base-abstract-entity.js +30 -28
  24. package/lib/base-classes/base-abstract-entity.js.map +1 -1
  25. package/lib/base-classes/base-class.js +9 -17
  26. package/lib/base-classes/base-class.js.map +1 -1
  27. package/lib/base-classes/base-context.js +4 -4
  28. package/lib/base-classes/base-context.js.map +1 -1
  29. package/lib/base-classes/base-controller.js +15 -15
  30. package/lib/base-classes/base-controller.js.map +1 -1
  31. package/lib/base-classes/base-crud-controller.js +211 -329
  32. package/lib/base-classes/base-crud-controller.js.map +1 -1
  33. package/lib/base-classes/base-entity.js +15 -15
  34. package/lib/base-classes/base-entity.js.map +1 -1
  35. package/lib/base-classes/base-injector.js +99 -124
  36. package/lib/base-classes/base-injector.js.map +1 -1
  37. package/lib/base-classes/base-migration.js +15 -31
  38. package/lib/base-classes/base-migration.js.map +1 -1
  39. package/lib/base-classes/base-provider.js +3 -9
  40. package/lib/base-classes/base-provider.js.map +1 -1
  41. package/lib/base-classes/base-repository.js +310 -444
  42. package/lib/base-classes/base-repository.js.map +1 -1
  43. package/lib/base-classes/base-subscriber-for-entity.js +73 -73
  44. package/lib/base-classes/base-subscriber-for-entity.js.map +1 -1
  45. package/lib/base-classes/base.js +10 -10
  46. package/lib/base-classes/base.js.map +1 -1
  47. package/lib/build-info._auto-generated_.js.map +1 -1
  48. package/lib/constants.js.map +1 -1
  49. package/lib/context-db-migrations.js +325 -581
  50. package/lib/context-db-migrations.js.map +1 -1
  51. package/lib/create-context.js +80 -109
  52. package/lib/create-context.js.map +1 -1
  53. package/lib/decorators/classes/controller-decorator.js +15 -13
  54. package/lib/decorators/classes/controller-decorator.js.map +1 -1
  55. package/lib/decorators/classes/entity-decorator.js +23 -20
  56. package/lib/decorators/classes/entity-decorator.js.map +1 -1
  57. package/lib/decorators/classes/migration-decorator.js +7 -13
  58. package/lib/decorators/classes/migration-decorator.js.map +1 -1
  59. package/lib/decorators/classes/provider-decorator.js +7 -13
  60. package/lib/decorators/classes/provider-decorator.js.map +1 -1
  61. package/lib/decorators/classes/repository-decorator.js +7 -13
  62. package/lib/decorators/classes/repository-decorator.js.map +1 -1
  63. package/lib/decorators/classes/subscriber-decorator.js +8 -13
  64. package/lib/decorators/classes/subscriber-decorator.js.map +1 -1
  65. package/lib/decorators/http/http-decorators.js +4 -4
  66. package/lib/decorators/http/http-decorators.js.map +1 -1
  67. package/lib/decorators/http/http-methods-decorators.js +19 -25
  68. package/lib/decorators/http/http-methods-decorators.js.map +1 -1
  69. package/lib/decorators/http/http-params-decorators.js +7 -9
  70. package/lib/decorators/http/http-params-decorators.js.map +1 -1
  71. package/lib/dependency-injection/di-container.js +13 -18
  72. package/lib/dependency-injection/di-container.js.map +1 -1
  73. package/lib/endpoint-context.js +1196 -1543
  74. package/lib/endpoint-context.js.map +1 -1
  75. package/lib/entity-process.js +102 -112
  76. package/lib/entity-process.js.map +1 -1
  77. package/lib/env.js +2 -2
  78. package/lib/env.js.map +1 -1
  79. package/lib/formly/formly-group-wrapper-component.js +45 -23
  80. package/lib/formly/formly-group-wrapper-component.js.map +1 -1
  81. package/lib/formly/formly-repeat-component.js +74 -27
  82. package/lib/formly/formly-repeat-component.js.map +1 -1
  83. package/lib/formly/formly.models.js.map +1 -1
  84. package/lib/formly/fromly.js +57 -61
  85. package/lib/formly/fromly.js.map +1 -1
  86. package/lib/formly/type-from-entity.js +11 -16
  87. package/lib/formly/type-from-entity.js.map +1 -1
  88. package/lib/get-response-value.js +22 -33
  89. package/lib/get-response-value.js.map +1 -1
  90. package/lib/helpers/class-helpers.js +62 -73
  91. package/lib/helpers/class-helpers.js.map +1 -1
  92. package/lib/helpers/taon-helpers.js +33 -31
  93. package/lib/helpers/taon-helpers.js.map +1 -1
  94. package/lib/index._auto-generated_.d.ts +1 -0
  95. package/lib/index._auto-generated_.js.map +1 -1
  96. package/lib/index.d.ts +1 -25
  97. package/lib/index.js +44 -41
  98. package/lib/index.js.map +1 -1
  99. package/lib/inject.js +15 -15
  100. package/lib/inject.js.map +1 -1
  101. package/lib/models.d.ts +5 -0
  102. package/lib/models.js +124 -100
  103. package/lib/models.js.map +1 -1
  104. package/lib/orm.js +13 -27
  105. package/lib/orm.js.map +1 -1
  106. package/lib/realtime/realtime-client.js +70 -65
  107. package/lib/realtime/realtime-client.js.map +1 -1
  108. package/lib/realtime/realtime-core.js +48 -29
  109. package/lib/realtime/realtime-core.js.map +1 -1
  110. package/lib/realtime/realtime-server.js +81 -80
  111. package/lib/realtime/realtime-server.js.map +1 -1
  112. package/lib/realtime/realtime-strategy/index.js +18 -5
  113. package/lib/realtime/realtime-strategy/index.js.map +1 -1
  114. package/lib/realtime/realtime-strategy/realtime-strategy-ipc.js +132 -172
  115. package/lib/realtime/realtime-strategy/realtime-strategy-ipc.js.map +1 -1
  116. package/lib/realtime/realtime-strategy/realtime-strategy-mock.js +158 -241
  117. package/lib/realtime/realtime-strategy/realtime-strategy-mock.js.map +1 -1
  118. package/lib/realtime/realtime-strategy/realtime-strategy-socket-io.js +18 -29
  119. package/lib/realtime/realtime-strategy/realtime-strategy-socket-io.js.map +1 -1
  120. package/lib/realtime/realtime-strategy/realtime-strategy.js +9 -13
  121. package/lib/realtime/realtime-strategy/realtime-strategy.js.map +1 -1
  122. package/lib/realtime/realtime-subs-manager.js +29 -30
  123. package/lib/realtime/realtime-subs-manager.js.map +1 -1
  124. package/lib/realtime/realtime.models.js.map +1 -1
  125. package/lib/storage.js +1 -1
  126. package/lib/storage.js.map +1 -1
  127. package/lib/symbols.js +62 -66
  128. package/lib/symbols.js.map +1 -1
  129. package/lib/ui/directives/index.js +2 -2
  130. package/lib/ui/directives/index.js.map +1 -1
  131. package/lib/ui/directives/view-mode.js.map +1 -1
  132. package/lib/ui/index.js +2 -2
  133. package/lib/ui/index.js.map +1 -1
  134. package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.d.ts +2 -0
  135. package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.js +5 -0
  136. package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.js.map +1 -0
  137. package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/taon-admin-edit-mode.component.d.ts +29 -0
  138. package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/taon-admin-edit-mode.module.d.ts +2 -0
  139. package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.d.ts +1 -0
  140. package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.js +5 -0
  141. package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.js.map +1 -0
  142. package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/taon-db-admin.component.d.ts +8 -0
  143. package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.d.ts +2 -0
  144. package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.js +5 -0
  145. package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.js.map +1 -0
  146. package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/taon-file-general-opt.component.d.ts +13 -0
  147. package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/taon-file-general-opt.module.d.ts +2 -0
  148. package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
  149. package/lib/ui/taon-admin-mode-configuration/index.js.map +1 -1
  150. package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.d.ts +5 -0
  151. package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.js +3 -0
  152. package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.js.map +1 -0
  153. package/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.d.ts +14 -0
  154. package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +4 -4
  155. package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.module.d.ts +2 -0
  156. package/lib/ui/taon-admin-mode-configuration/taon-admin.models.js.map +1 -1
  157. package/lib/ui/taon-github-fork-me-corner/index.js +2 -2
  158. package/lib/ui/taon-github-fork-me-corner/index.js.map +1 -1
  159. package/lib/ui/taon-github-fork-me-ribbon/index.js +2 -2
  160. package/lib/ui/taon-github-fork-me-ribbon/index.js.map +1 -1
  161. package/lib/ui/taon-notifications/index.js +15 -2
  162. package/lib/ui/taon-notifications/index.js.map +1 -1
  163. package/lib/ui/taon-notifications/taon-notifications.models.js +2 -2
  164. package/lib/ui/taon-notifications/taon-notifications.models.js.map +1 -1
  165. package/lib/ui/taon-progress-bar/index.js +2 -2
  166. package/lib/ui/taon-progress-bar/index.js.map +1 -1
  167. package/lib/ui/taon-progress-bar/taon-progress-bar.component.d.ts +2 -1
  168. package/lib/ui/taon-session-passcode/index.js +2 -2
  169. package/lib/ui/taon-session-passcode/index.js.map +1 -1
  170. package/lib/ui/taon-table/index.js +2 -2
  171. package/lib/ui/taon-table/index.js.map +1 -1
  172. package/lib/ui/taon.models.js.map +1 -1
  173. package/lib/validators.js +48 -16
  174. package/lib/validators.js.map +1 -1
  175. package/migrations/index.js +15 -2
  176. package/migrations/index.js.map +1 -1
  177. package/migrations/migrations_index._auto-generated_.d.ts +1 -0
  178. package/migrations/migrations_index._auto-generated_.js.map +1 -1
  179. package/old-app .d.ts +1 -0
  180. package/old-app .js +67 -78
  181. package/old-app .js.map +1 -1
  182. package/package.json +18 -65
  183. package/playground.d.ts +1 -0
  184. package/playground.js.map +1 -1
  185. package/src.d.ts +1 -1
  186. package/taon.jsonc +39 -42
  187. package/tmp-environment.json +8 -401
  188. package/websql/esm2022/lib/endpoint-context.mjs +4 -1
  189. package/websql/esm2022/lib/index.mjs +2 -2
  190. package/websql/esm2022/lib/models.mjs +1 -1
  191. package/websql/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.mjs +11 -11
  192. package/websql/fesm2022/taon.mjs +3 -0
  193. package/websql/fesm2022/taon.mjs.map +1 -1
  194. package/websql/lib/models.d.ts +5 -0
  195. package/websql/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +4 -4
  196. package/browser/package.json +0 -25
  197. package/websql/package.json +0 -25
@@ -1,230 +1,189 @@
1
1
  "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
3
9
  exports.BaseRepository = void 0;
4
- var tslib_1 = require("tslib");
5
- var tnp_core_1 = require("tnp-core");
6
- var tnp_core_2 = require("tnp-core");
7
- var class_helpers_1 = require("../helpers/class-helpers");
8
- var taon_type_sql_1 = require("taon-type-sql");
9
- var repository_decorator_1 = require("../decorators/classes/repository-decorator");
10
- var base_injector_1 = require("./base-injector");
10
+ const tnp_core_1 = require("tnp-core");
11
+ const tnp_core_2 = require("tnp-core");
12
+ const class_helpers_1 = require("../helpers/class-helpers");
13
+ const taon_type_sql_1 = require("taon-type-sql");
14
+ const repository_decorator_1 = require("../decorators/classes/repository-decorator");
15
+ const base_injector_1 = require("./base-injector");
11
16
  //#endregion
12
- var INDEX_KEYS_NO_FOR_UPDATE = ['id'];
13
- var BaseRepository = /** @class */ (function (_super) {
14
- tslib_1.__extends(BaseRepository, _super);
15
- function BaseRepository(
17
+ const INDEX_KEYS_NO_FOR_UPDATE = ['id'];
18
+ let BaseRepository = class BaseRepository extends base_injector_1.BaseInjector {
19
+ __entityClassResolveFn;
20
+ constructor(
16
21
  // Injected through BaseCrudController
17
22
  __entityClassResolveFn) {
18
- var _this = _super.call(this) || this;
19
- _this.__entityClassResolveFn = __entityClassResolveFn;
23
+ super();
24
+ this.__entityClassResolveFn = __entityClassResolveFn;
20
25
  // @ts-ignore
21
- _this.entityClassResolveFn = __entityClassResolveFn;
22
- return _this;
23
- }
24
- Object.defineProperty(BaseRepository.prototype, "dbQuery", {
25
- get: function () {
26
- var _a, _b;
27
- //#region @websqlFunc
28
- if (!this.__dbQuery) {
29
- if (!this.ctx) {
30
- return; // TODO
31
- throw new Error("[BaseRepository] Context not inited for class ".concat(class_helpers_1.ClassHelpers.getName(this)));
32
- }
33
- var connection = (_a = this.ctx) === null || _a === void 0 ? void 0 : _a.connection;
34
- if (!connection) {
35
- throw new Error("[BaseRepository] Database not inited for context ".concat((_b = this.ctx) === null || _b === void 0 ? void 0 : _b.contextName));
36
- }
37
- this.__dbQuery = new taon_type_sql_1.MySqlQuerySource(connection);
26
+ this.entityClassResolveFn = __entityClassResolveFn;
27
+ }
28
+ //#endregion
29
+ //#region db query
30
+ __dbQuery;
31
+ get dbQuery() {
32
+ //#region @websqlFunc
33
+ if (!this.__dbQuery) {
34
+ if (!this.ctx) {
35
+ return; // TODO
36
+ throw new Error(`[BaseRepository] Context not inited for class ${class_helpers_1.ClassHelpers.getName(this)}`);
37
+ }
38
+ const connection = this.ctx?.connection;
39
+ if (!connection) {
40
+ throw new Error(`[BaseRepository] Database not inited for context ${this.ctx?.contextName}`);
38
41
  }
39
- return this.__dbQuery;
40
- //#endregion
41
- },
42
- enumerable: false,
43
- configurable: true
44
- });
45
- Object.defineProperty(BaseRepository.prototype, "connection", {
42
+ this.__dbQuery = new taon_type_sql_1.MySqlQuerySource(connection);
43
+ }
44
+ return this.__dbQuery;
45
+ //#endregion
46
+ }
47
+ //#endregion
48
+ //#region connection
49
+ get connection() {
50
+ //#region @websqlFunc
51
+ return this.ctx?.connection;
52
+ //#endregion
53
+ }
54
+ //#endregion
55
+ //#region repository
56
+ //#region @websql
57
+ __repository;
58
+ //#endregion
59
+ get repository() {
60
+ //#region @websqlFunc
61
+ return this.__repository;
62
+ //#endregion
63
+ }
64
+ /**
65
+ * target for repository
66
+ */
67
+ get target() {
68
+ //#region @websqlFunc
69
+ return this?.repository?.target;
70
+ //#endregion
71
+ }
72
+ /**
73
+ * alias to repository
74
+ */
75
+ get repo() {
76
+ //#region @websqlFunc
77
+ return this.repository;
46
78
  //#endregion
47
- //#region connection
48
- get: function () {
49
- var _a;
50
- //#region @websqlFunc
51
- return (_a = this.ctx) === null || _a === void 0 ? void 0 : _a.connection;
52
- //#endregion
53
- },
54
- enumerable: false,
55
- configurable: true
56
- });
57
- Object.defineProperty(BaseRepository.prototype, "repository", {
79
+ }
80
+ get repositoryExists() {
81
+ //#region @websqlFunc
82
+ return !!this.__repository;
58
83
  //#endregion
59
- get: function () {
60
- //#region @websqlFunc
61
- return this.__repository;
62
- //#endregion
63
- },
64
- enumerable: false,
65
- configurable: true
66
- });
67
- Object.defineProperty(BaseRepository.prototype, "target", {
68
- /**
69
- * target for repository
70
- */
71
- get: function () {
72
- var _a;
73
- //#region @websqlFunc
74
- return (_a = this === null || this === void 0 ? void 0 : this.repository) === null || _a === void 0 ? void 0 : _a.target;
75
- //#endregion
76
- },
77
- enumerable: false,
78
- configurable: true
79
- });
80
- Object.defineProperty(BaseRepository.prototype, "repo", {
81
- /**
82
- * alias to repository
83
- */
84
- get: function () {
85
- //#region @websqlFunc
86
- return this.repository;
87
- //#endregion
88
- },
89
- enumerable: false,
90
- configurable: true
91
- });
92
- Object.defineProperty(BaseRepository.prototype, "repositoryExists", {
93
- get: function () {
94
- //#region @websqlFunc
95
- return !!this.__repository;
96
- //#endregion
97
- },
98
- enumerable: false,
99
- configurable: true
100
- });
84
+ }
101
85
  //#endregion
102
86
  //#region init
103
- BaseRepository.prototype.__init = function (context) {
104
- return tslib_1.__awaiter(this, void 0, void 0, function () {
105
- var entityClassFn, ctx, connection, _a;
106
- return tslib_1.__generator(this, function (_b) {
107
- switch (_b.label) {
108
- case 0:
109
- //#region @websql
110
- if (this.__repository) {
111
- return [2 /*return*/];
112
- }
113
- entityClassFn = this.entityClassResolveFn();
114
- if (!entityClassFn) {
115
- tnp_core_1.Helpers.warn("Entity class not provided for repository ".concat(class_helpers_1.ClassHelpers.getName(this)));
116
- return [2 /*return*/];
117
- }
118
- ctx = this.__endpoint_context__;
119
- if (ctx.remoteHost) {
120
- return [2 /*return*/];
121
- }
122
- connection = ctx.connection;
123
- if (!connection) {
124
- throw new Error("\n\n Connection not found for context ".concat(ctx.contextName, "\n\n\n Maybe you forgot to init database ?\n\n Taon.createContext({\n ...\n database:true\n ...\n })\n\n "));
125
- }
126
- if (!entityClassFn) {
127
- tnp_core_1.Helpers.warn("Entity class not found for repository ".concat(class_helpers_1.ClassHelpers.getName(this)));
128
- return [2 /*return*/];
129
- }
130
- _a = this;
131
- return [4 /*yield*/, connection.getRepository(class_helpers_1.ClassHelpers.getOrginalClass(entityClassFn))];
132
- case 1:
133
- _a.__repository = (_b.sent());
134
- return [2 /*return*/];
135
- }
136
- });
137
- });
138
- };
87
+ async __init(context) {
88
+ //#region @websql
89
+ if (this.__repository) {
90
+ return;
91
+ }
92
+ let entityClassFn = this.entityClassResolveFn();
93
+ if (!entityClassFn) {
94
+ tnp_core_1.Helpers.warn(`Entity class not provided for repository ${class_helpers_1.ClassHelpers.getName(this)}`);
95
+ return;
96
+ }
97
+ const ctx = this.__endpoint_context__;
98
+ if (ctx.remoteHost) {
99
+ return;
100
+ }
101
+ const connection = ctx.connection;
102
+ if (!connection) {
103
+ throw new Error(`
104
+
105
+ Connection not found for context ${ctx.contextName}
106
+
107
+
108
+ Maybe you forgot to init database ?
109
+
110
+ Taon.createContext({
111
+ ...
112
+ database:true
113
+ ...
114
+ })
115
+
116
+ `);
117
+ }
118
+ if (!entityClassFn) {
119
+ tnp_core_1.Helpers.warn(`Entity class not found for repository ${class_helpers_1.ClassHelpers.getName(this)}`);
120
+ return;
121
+ }
122
+ this.__repository = (await connection.getRepository(class_helpers_1.ClassHelpers.getOrginalClass(entityClassFn)));
123
+ // console.log(
124
+ // `Inited repository for (${ClassHelpers.getName(this)}/` +
125
+ // `${ClassHelpers.getName(entityClassFn)}/${ClassHelpers.getName(context)}`,
126
+ // this.repository,
127
+ // );
128
+ //#endregion
129
+ }
139
130
  //#endregion
140
131
  //#region crud operations / typeorm / has id
141
132
  /**
142
133
  * Checks if entity has an id.
143
134
  * If entity composite compose ids, it will check them all.
144
135
  */
145
- BaseRepository.prototype.hasId = function (entity) {
136
+ hasId(entity) {
146
137
  return this.repo.hasId(entity);
147
- };
138
+ }
148
139
  //#endregion
149
140
  //#region crud operations / typeorm / get id
150
141
  /**
151
142
  * Gets entity mixed id.
152
143
  */
153
- BaseRepository.prototype.getId = function (entity) {
144
+ getId(entity) {
154
145
  return this.repo.getId(entity);
155
- };
146
+ }
156
147
  //#endregion
157
148
  //#region crud operations / typeorm / create & bulk create
158
149
  /**
159
150
  Saves a given entity in the database.
160
151
  * If entity does not exist in the database then inserts, otherwise updates.
161
152
  */
162
- BaseRepository.prototype.save = function (item, options) {
163
- return tslib_1.__awaiter(this, void 0, void 0, function () {
164
- var model, id;
165
- return tslib_1.__generator(this, function (_a) {
166
- switch (_a.label) {
167
- case 0: return [4 /*yield*/, this.repo.create(item)];
168
- case 1:
169
- model = _a.sent();
170
- return [4 /*yield*/, this.repo.save(model, options)];
171
- case 2:
172
- model = _a.sent();
173
- id = model.id;
174
- return [4 /*yield*/, this.repo.findOne({
175
- where: { id: id },
176
- })];
177
- case 3:
178
- model = _a.sent();
179
- return [2 /*return*/, model];
180
- }
181
- });
153
+ async save(item, options) {
154
+ //#region @websqlFunc
155
+ let model = await this.repo.create(item);
156
+ model = await this.repo.save(model, options);
157
+ const { id } = model;
158
+ model = await this.repo.findOne({
159
+ where: { id },
182
160
  });
183
- };
161
+ return model;
162
+ //#endregion
163
+ }
184
164
  /**
185
165
  * alias to save
186
166
  * -> it will actuall create new entity in db
187
167
  * in oposite to typeorm create method
188
168
  */
189
- BaseRepository.prototype.create = function (item, options) {
190
- return tslib_1.__awaiter(this, void 0, void 0, function () {
191
- return tslib_1.__generator(this, function (_a) {
192
- return [2 /*return*/, this.save(item, options)];
193
- });
194
- });
195
- };
196
- BaseRepository.prototype.bulkSave = function (items, options) {
197
- return tslib_1.__awaiter(this, void 0, void 0, function () {
198
- var models, index, item, model;
199
- return tslib_1.__generator(this, function (_a) {
200
- switch (_a.label) {
201
- case 0:
202
- models = [];
203
- index = 0;
204
- _a.label = 1;
205
- case 1:
206
- if (!(index < items.length)) return [3 /*break*/, 4];
207
- item = items[index];
208
- return [4 /*yield*/, this.save(item, options)];
209
- case 2:
210
- model = _a.sent();
211
- models.push(model);
212
- _a.label = 3;
213
- case 3:
214
- index++;
215
- return [3 /*break*/, 1];
216
- case 4: return [2 /*return*/, models];
217
- }
218
- });
219
- });
220
- };
221
- BaseRepository.prototype.bulkCreate = function (items, options) {
222
- return tslib_1.__awaiter(this, void 0, void 0, function () {
223
- return tslib_1.__generator(this, function (_a) {
224
- return [2 /*return*/, this.bulkSave(items, options)];
225
- });
226
- });
227
- };
169
+ async create(item, options) {
170
+ return this.save(item, options);
171
+ }
172
+ async bulkSave(items, options) {
173
+ //#region @websqlFunc
174
+ const models = [];
175
+ for (let index = 0; index < items.length; index++) {
176
+ const item = items[index];
177
+ // TODO FIX THIS / REFACTOR
178
+ const model = await this.save(item, options);
179
+ models.push(model);
180
+ }
181
+ return models;
182
+ //#endregion
183
+ }
184
+ async bulkCreate(items, options) {
185
+ return this.bulkSave(items, options);
186
+ }
228
187
  //#region old typeorm version
229
188
  // /**
230
189
  // * Creates a new entity instance.
@@ -284,14 +243,9 @@ var BaseRepository = /** @class */ (function (_super) {
284
243
  /**
285
244
  * Merges multiple entities (or entity-like objects) into a given entity.
286
245
  */
287
- BaseRepository.prototype.merge = function (mergeIntoEntity) {
288
- var _a;
289
- var entityLikes = [];
290
- for (var _i = 1; _i < arguments.length; _i++) {
291
- entityLikes[_i - 1] = arguments[_i];
292
- }
293
- return (_a = this.repo).merge.apply(_a, tslib_1.__spreadArray([mergeIntoEntity], tslib_1.__read(entityLikes), false));
294
- };
246
+ merge(mergeIntoEntity, ...entityLikes) {
247
+ return this.repo.merge(mergeIntoEntity, ...entityLikes);
248
+ }
295
249
  //#endregion
296
250
  //#region crud operations / typeorm / preload
297
251
  /**
@@ -303,107 +257,69 @@ var BaseRepository = /** @class */ (function (_super) {
303
257
  * Note that given entity-like object must have an entity id / primary key to find entity by.
304
258
  * Returns undefined if entity with given id was not found.
305
259
  */
306
- BaseRepository.prototype.preload = function (entityLike) {
260
+ preload(entityLike) {
307
261
  return this.repo.preload(entityLike);
308
- };
262
+ }
309
263
  //#endregion
310
264
  //#region crud operations / typeorm / remove (delete) & bulk remove (delete)
311
265
  /**
312
266
  * Removes a given entities from the database.
313
267
  */
314
- BaseRepository.prototype.remove = function (idOrEntity) {
315
- return tslib_1.__awaiter(this, void 0, void 0, function () {
316
- var deletedEntity, idCopy;
317
- return tslib_1.__generator(this, function (_a) {
318
- switch (_a.label) {
319
- case 0:
320
- //#region @websqlFunc
321
- if (tnp_core_2._.isObject(idOrEntity)) {
322
- idOrEntity = idOrEntity.id;
323
- }
324
- return [4 /*yield*/, this.repo.findOne({
325
- where: { id: idOrEntity },
326
- })];
327
- case 1:
328
- deletedEntity = _a.sent();
329
- idCopy = deletedEntity.id;
330
- return [4 /*yield*/, this.repo.remove(deletedEntity)];
331
- case 2:
332
- _a.sent();
333
- deletedEntity.id = idCopy;
334
- return [2 /*return*/, deletedEntity];
335
- }
336
- });
268
+ async remove(idOrEntity) {
269
+ //#region @websqlFunc
270
+ if (tnp_core_2._.isObject(idOrEntity)) {
271
+ idOrEntity = idOrEntity.id;
272
+ }
273
+ const deletedEntity = await this.repo.findOne({
274
+ where: { id: idOrEntity },
337
275
  });
338
- };
276
+ const idCopy = deletedEntity.id;
277
+ await this.repo.remove(deletedEntity);
278
+ deletedEntity.id = idCopy;
279
+ return deletedEntity;
280
+ //#endregion
281
+ }
339
282
  /**
340
283
  * alias to remove
341
284
  */
342
- BaseRepository.prototype.delete = function (idOrEntity) {
343
- return tslib_1.__awaiter(this, void 0, void 0, function () {
344
- return tslib_1.__generator(this, function (_a) {
345
- return [2 /*return*/, this.remove(idOrEntity)];
346
- });
347
- });
348
- };
285
+ async delete(idOrEntity) {
286
+ return this.remove(idOrEntity);
287
+ }
349
288
  /**
350
289
  * alias to removeById
351
290
  */
352
- BaseRepository.prototype.deleteById = function (id) {
353
- return tslib_1.__awaiter(this, void 0, void 0, function () {
354
- return tslib_1.__generator(this, function (_a) {
355
- return [2 /*return*/, this.remove(id)];
356
- });
357
- });
358
- };
359
- BaseRepository.prototype.bulkRemove = function (idsOrEntities) {
360
- return tslib_1.__awaiter(this, void 0, void 0, function () {
361
- var models, index, id, model;
362
- return tslib_1.__generator(this, function (_a) {
363
- switch (_a.label) {
364
- case 0:
365
- //#region @websqlFunc
366
- idsOrEntities = idsOrEntities.map(function (id) {
367
- return tnp_core_2._.isObject(id) ? id.id : id;
368
- });
369
- models = [];
370
- index = 0;
371
- _a.label = 1;
372
- case 1:
373
- if (!(index < idsOrEntities.length)) return [3 /*break*/, 4];
374
- id = idsOrEntities[index];
375
- return [4 /*yield*/, this.remove(id)];
376
- case 2:
377
- model = _a.sent();
378
- models.push(model);
379
- _a.label = 3;
380
- case 3:
381
- index++;
382
- return [3 /*break*/, 1];
383
- case 4: return [2 /*return*/, models];
384
- }
385
- });
386
- });
387
- };
388
- BaseRepository.prototype.bulkDelete = function (ids) {
389
- return tslib_1.__awaiter(this, void 0, void 0, function () {
390
- return tslib_1.__generator(this, function (_a) {
391
- return [2 /*return*/, this.bulkRemove(ids)];
392
- });
291
+ async deleteById(id) {
292
+ return this.remove(id);
293
+ }
294
+ async bulkRemove(idsOrEntities) {
295
+ //#region @websqlFunc
296
+ idsOrEntities = idsOrEntities.map(id => {
297
+ return tnp_core_2._.isObject(id) ? id.id : id;
393
298
  });
394
- };
299
+ const models = [];
300
+ for (let index = 0; index < idsOrEntities.length; index++) {
301
+ const id = idsOrEntities[index];
302
+ const model = await this.remove(id);
303
+ models.push(model);
304
+ }
305
+ return models;
306
+ //#endregion
307
+ }
308
+ async bulkDelete(ids) {
309
+ return this.bulkRemove(ids);
310
+ }
395
311
  /**
396
312
  * Records the delete date of a given entity.
397
313
  */
398
- BaseRepository.prototype.softRemove = function (entity, options) {
314
+ softRemove(entity, options) {
399
315
  return this.repo.softRemove(entity, options);
400
- };
316
+ }
401
317
  /**
402
318
  * Recovers a given entity in the database.
403
319
  */
404
- BaseRepository.prototype.recover = function (entity, options) {
320
+ recover(entity, options) {
405
321
  return this.repo.recover(entity, options);
406
- };
322
+ }
407
323
  //#endregion
408
324
  //#region crud operations / typeorm / insert
409
325
  /**
@@ -412,100 +328,64 @@ var BaseRepository = /** @class */ (function (_super) {
412
328
  * Executes fast and efficient INSERT query.
413
329
  * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.
414
330
  */
415
- BaseRepository.prototype.insert = function (entity) {
331
+ insert(entity) {
416
332
  return this.repo.insert(entity);
417
- };
333
+ }
418
334
  //#endregion
419
335
  //#region crud operations / typeorm / update & build update
420
- BaseRepository.prototype.update = function (item) {
421
- return tslib_1.__awaiter(this, void 0, void 0, function () {
422
- var id;
423
- return tslib_1.__generator(this, function (_a) {
424
- switch (_a.label) {
425
- case 0:
426
- id = item.id;
427
- return [4 /*yield*/, this.updateById(id, item)];
428
- case 1: return [2 /*return*/, _a.sent()];
429
- }
430
- });
431
- });
432
- };
433
- BaseRepository.prototype.updateById = function (id, item) {
434
- return tslib_1.__awaiter(this, void 0, void 0, function () {
435
- var allowedPropsToUpdate, _loop_1, this_1, key, i, key, toSet, model;
436
- var _a;
437
- return tslib_1.__generator(this, function (_b) {
438
- switch (_b.label) {
439
- case 0:
440
- allowedPropsToUpdate = [];
441
- _loop_1 = function (key) {
442
- if (tnp_core_2._.isObject(item) &&
443
- item.hasOwnProperty(key) &&
444
- typeof item[key] !== 'object' &&
445
- !tnp_core_2._.isUndefined(this_1.repo.metadata.ownColumns.find(function (c) { return c.propertyName === key; }))) {
446
- allowedPropsToUpdate.push(key);
447
- }
448
- };
449
- this_1 = this;
450
- for (key in item) {
451
- _loop_1(key);
452
- }
453
- i = 0;
454
- _b.label = 1;
455
- case 1:
456
- if (!(i < allowedPropsToUpdate.length)) return [3 /*break*/, 4];
457
- key = allowedPropsToUpdate[i];
458
- if (!!INDEX_KEYS_NO_FOR_UPDATE.includes(key.toLowerCase())) return [3 /*break*/, 3];
459
- toSet = item[key];
460
- // const tableName = tableNameFrom(this.entity as any);
461
- return [4 /*yield*/, this.repo.update({
462
- id: id,
463
- }, (_a = {},
464
- _a[key] = toSet,
465
- _a))];
466
- case 2:
467
- // const tableName = tableNameFrom(this.entity as any);
468
- _b.sent();
469
- _b.label = 3;
470
- case 3:
471
- i++;
472
- return [3 /*break*/, 1];
473
- case 4: return [4 /*yield*/, this.repo.findOne({
474
- where: { id: id },
475
- })];
476
- case 5:
477
- model = _b.sent();
478
- return [2 /*return*/, model];
479
- }
480
- });
481
- });
482
- };
483
- BaseRepository.prototype.bulkUpdate = function (items) {
484
- return tslib_1.__awaiter(this, void 0, void 0, function () {
485
- var models, index, item, id, model;
486
- return tslib_1.__generator(this, function (_a) {
487
- switch (_a.label) {
488
- case 0:
489
- models = [];
490
- index = 0;
491
- _a.label = 1;
492
- case 1:
493
- if (!(index < items.length)) return [3 /*break*/, 4];
494
- item = items[index];
495
- id = item.id;
496
- return [4 /*yield*/, this.updateById(id, item)];
497
- case 2:
498
- model = _a.sent();
499
- models.push(model);
500
- _a.label = 3;
501
- case 3:
502
- index++;
503
- return [3 /*break*/, 1];
504
- case 4: return [2 /*return*/, { models: models }];
505
- }
506
- });
336
+ async update(item) {
337
+ //#region @websqlFunc
338
+ const { id } = item;
339
+ return await this.updateById(id, item);
340
+ //#endregion
341
+ }
342
+ async updateById(id, item) {
343
+ //#region @websqlFunc
344
+ const allowedPropsToUpdate = [];
345
+ for (const key in item) {
346
+ if (tnp_core_2._.isObject(item) &&
347
+ item.hasOwnProperty(key) &&
348
+ typeof item[key] !== 'object' &&
349
+ !tnp_core_2._.isUndefined(this.repo.metadata.ownColumns.find(c => c.propertyName === key))) {
350
+ allowedPropsToUpdate.push(key);
351
+ }
352
+ }
353
+ for (let i = 0; i < allowedPropsToUpdate.length; i++) {
354
+ const key = allowedPropsToUpdate[i];
355
+ if (!INDEX_KEYS_NO_FOR_UPDATE.includes(key.toLowerCase())) {
356
+ // const raw = _.isBoolean(item[key]) || _.isNumber(item[key]) || _.isNull(item[key]); // TODO does this make any sense ?
357
+ const toSet = item[key];
358
+ // const tableName = tableNameFrom(this.entity as any);
359
+ await this.repo.update({
360
+ id,
361
+ }, {
362
+ [key]: toSet,
363
+ });
364
+ // await this.repo.query(
365
+ // `UPDATE '${tableName}' as ${table}
366
+ // SET ${key}=${toSet}
367
+ // WHERE ${table}.id='${id}'
368
+ // `);
369
+ }
370
+ }
371
+ let model = await this.repo.findOne({
372
+ where: { id },
507
373
  });
508
- };
374
+ return model;
375
+ //#endregion
376
+ }
377
+ async bulkUpdate(items) {
378
+ //#region @websqlFunc
379
+ const models = [];
380
+ for (let index = 0; index < items.length; index++) {
381
+ const item = items[index];
382
+ const { id } = item; // TOOD
383
+ const model = await this.updateById(id, item);
384
+ models.push(model);
385
+ }
386
+ return { models };
387
+ //#endregion
388
+ }
509
389
  //#region tpeorm update version
510
390
  // this version suck and will not return update entity
511
391
  // /**
@@ -537,9 +417,9 @@ var BaseRepository = /** @class */ (function (_super) {
537
417
  * Unlike save method executes a primitive operation without cascades, relations and other operations included.
538
418
  * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.
539
419
  */
540
- BaseRepository.prototype.upsert = function (entityOrEntities, conflictPathsOrOptions) {
420
+ upsert(entityOrEntities, conflictPathsOrOptions) {
541
421
  return this.repo.upsert(entityOrEntities, conflictPathsOrOptions);
542
- };
422
+ }
543
423
  //#endregion
544
424
  //#region crud operations / typeorm / soft delete
545
425
  /**
@@ -548,9 +428,9 @@ var BaseRepository = /** @class */ (function (_super) {
548
428
  * Executes fast and efficient SOFT-DELETE query.
549
429
  * Does not check if entity exist in the database.
550
430
  */
551
- BaseRepository.prototype.softDelete = function (criteria) {
431
+ softDelete(criteria) {
552
432
  return this.repo.softDelete(criteria);
553
- };
433
+ }
554
434
  //#endregion
555
435
  //#region crud operations / typeorm / restore
556
436
  /**
@@ -559,43 +439,43 @@ var BaseRepository = /** @class */ (function (_super) {
559
439
  * Executes fast and efficient SOFT-DELETE query.
560
440
  * Does not check if entity exist in the database.
561
441
  */
562
- BaseRepository.prototype.restore = function (criteria) {
442
+ restore(criteria) {
563
443
  return this.repo.restore(criteria);
564
- };
444
+ }
565
445
  //#endregion
566
446
  //#region crud operations / typeorm / count
567
447
  /**
568
448
  * Counts entities that match given options.
569
449
  * Useful for pagination.
570
450
  */
571
- BaseRepository.prototype.count = function (options) {
451
+ count(options) {
572
452
  return this.repo.count(options);
573
- };
453
+ }
574
454
  //#endregion
575
455
  //#region crud operations / typeorm / count by
576
456
  /**
577
457
  * Counts entities that match given conditions.
578
458
  * Useful for pagination.
579
459
  */
580
- BaseRepository.prototype.countBy = function (where) {
460
+ countBy(where) {
581
461
  return this.repo.countBy(where);
582
- };
462
+ }
583
463
  //#endregion
584
464
  //#region crud operations / typeorm / find
585
465
  /**
586
466
  * Finds entities that match given find options.
587
467
  */
588
- BaseRepository.prototype.find = function (options) {
468
+ find(options) {
589
469
  return this.repo.find(options);
590
- };
470
+ }
591
471
  //#endregion
592
472
  //#region crud operations / typeorm / find by
593
473
  /**
594
474
  * Finds entities that match given find options.
595
475
  */
596
- BaseRepository.prototype.findBy = function (where) {
476
+ findBy(where) {
597
477
  return this.repo.findBy(where);
598
- };
478
+ }
599
479
  //#endregion
600
480
  //#region crud operations / typeorm / find and count
601
481
  // async findAndCount(options: { take: number; skip: number }) {
@@ -614,9 +494,9 @@ var BaseRepository = /** @class */ (function (_super) {
614
494
  * Also counts all entities that match given conditions,
615
495
  * but ignores pagination settings (from and take options).
616
496
  */
617
- BaseRepository.prototype.findAndCount = function (options) {
497
+ findAndCount(options) {
618
498
  return this.repo.findAndCount(options);
619
- };
499
+ }
620
500
  //#endregion
621
501
  //#region crud operations / typeorm / find and count by
622
502
  /**
@@ -624,9 +504,9 @@ var BaseRepository = /** @class */ (function (_super) {
624
504
  * Also counts all entities that match given conditions,
625
505
  * but ignores pagination settings (from and take options).
626
506
  */
627
- BaseRepository.prototype.findAndCountBy = function (where) {
507
+ findAndCountBy(where) {
628
508
  return this.repo.findAndCountBy(where);
629
- };
509
+ }
630
510
  //#endregion
631
511
  //#region crud operations / typeorm / find by ids
632
512
  /**
@@ -639,27 +519,27 @@ var BaseRepository = /** @class */ (function (_super) {
639
519
  * id: In([1, 2, 3])
640
520
  * })
641
521
  */
642
- BaseRepository.prototype.findByIds = function (ids) {
522
+ findByIds(ids) {
643
523
  return this.repo.findByIds(ids);
644
- };
524
+ }
645
525
  //#endregion
646
526
  //#region crud operations / typeorm / find one
647
527
  /**
648
528
  * Finds first entity by a given find options.
649
529
  * If entity was not found in the database - returns null.
650
530
  */
651
- BaseRepository.prototype.findOne = function (options) {
531
+ findOne(options) {
652
532
  return this.repo.findOne(options);
653
- };
533
+ }
654
534
  //#endregion
655
535
  //#region crud operations / typeorm / find one by
656
536
  /**
657
537
  * Finds first entity that matches given where condition.
658
538
  * If entity was not found in the database - returns null.
659
539
  */
660
- BaseRepository.prototype.findOneBy = function (where) {
540
+ findOneBy(where) {
661
541
  return this.repo.findOneBy(where);
662
- };
542
+ }
663
543
  //#endregion
664
544
  //#region crud operations / typeorm / find one or fail
665
545
  /**
@@ -672,36 +552,36 @@ var BaseRepository = /** @class */ (function (_super) {
672
552
  * id: 1 // where "id" is your primary column name
673
553
  * })
674
554
  */
675
- BaseRepository.prototype.findOneById = function (id) {
555
+ findOneById(id) {
676
556
  return this.repo.findOneById(id);
677
- };
557
+ }
678
558
  //#endregion
679
559
  //#region crud operations / typeorm / find one or fail
680
560
  /**
681
561
  * Finds first entity by a given find options.
682
562
  * If entity was not found in the database - rejects with error.
683
563
  */
684
- BaseRepository.prototype.findOneOrFail = function (options) {
564
+ findOneOrFail(options) {
685
565
  return this.repo.findOneOrFail(options);
686
- };
566
+ }
687
567
  //#endregion
688
568
  //#region crud operations / typeorm / find one by or fail
689
569
  /**
690
570
  * Finds first entity that matches given where condition.
691
571
  * If entity was not found in the database - rejects with error.
692
572
  */
693
- BaseRepository.prototype.findOneByOrFail = function (where) {
573
+ findOneByOrFail(where) {
694
574
  return this.repo.findOneByOrFail(where);
695
- };
575
+ }
696
576
  //#endregion
697
577
  //#region crud operations / typeorm / query
698
578
  /**
699
579
  * Executes a raw SQL query and returns a raw database results.
700
580
  * Raw query execution is supported only by relational databases (MongoDB is not supported).
701
581
  */
702
- BaseRepository.prototype.query = function (query, parameters) {
582
+ query(query, parameters) {
703
583
  return this.repo.query(query, parameters);
704
- };
584
+ }
705
585
  //#endregion
706
586
  //#region crud operations / typeorm / clear
707
587
  /**
@@ -710,71 +590,57 @@ var BaseRepository = /** @class */ (function (_super) {
710
590
  * Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms.
711
591
  * @see https://stackoverflow.com/a/5972738/925151
712
592
  */
713
- BaseRepository.prototype.clear = function () {
593
+ clear() {
714
594
  return this.repo.clear();
715
- };
595
+ }
716
596
  //#endregion
717
597
  //#region crud operations / typeorm / increment
718
598
  /**
719
599
  * Increments some column by provided value of the entities matched given conditions.
720
600
  */
721
- BaseRepository.prototype.increment = function (conditions, propertyPath, value) {
601
+ increment(conditions, propertyPath, value) {
722
602
  return this.repo.increment(conditions, propertyPath, value);
723
- };
603
+ }
724
604
  //#endregion
725
605
  //#region crud operations / typeorm / decrement
726
606
  /**
727
607
  * Decrements some column by provided value of the entities matched given conditions.
728
608
  */
729
- BaseRepository.prototype.decrement = function (conditions, propertyPath, value) {
609
+ decrement(conditions, propertyPath, value) {
730
610
  return this.repo.decrement(conditions, propertyPath, value);
731
- };
611
+ }
732
612
  //#endregion
733
613
  //#region crud operations / get all
734
614
  /**
735
615
  * @deprecated use findAndCount instead
736
616
  */
737
- BaseRepository.prototype.getAll = function () {
738
- return tslib_1.__awaiter(this, void 0, void 0, function () {
739
- var totalCount, models;
740
- return tslib_1.__generator(this, function (_a) {
741
- switch (_a.label) {
742
- case 0: return [4 /*yield*/, this.repo.count()];
743
- case 1:
744
- totalCount = _a.sent();
745
- return [4 /*yield*/, this.repo.find()];
746
- case 2:
747
- models = _a.sent();
748
- // console.log('models', models);
749
- // console.log('totalCount', totalCount);
750
- return [2 /*return*/, { models: models, totalCount: totalCount }];
751
- }
752
- });
753
- });
754
- };
617
+ async getAll() {
618
+ //#region @websqlFunc
619
+ // console.log('repo', this.__repository);
620
+ // console.log(
621
+ // `repo taget name "${ClassHelpers.getName(this.__repository.target)}"`,
622
+ // );
623
+ // debugger;
624
+ const totalCount = await this.repo.count();
625
+ const models = await this.repo.find();
626
+ // console.log('models', models);
627
+ // console.log('totalCount', totalCount);
628
+ return { models, totalCount };
629
+ //#endregion
630
+ }
755
631
  //#endregion
756
632
  //#region crud operations / get by id
757
- BaseRepository.prototype.getBy = function (id) {
758
- return tslib_1.__awaiter(this, void 0, void 0, function () {
759
- var model;
760
- return tslib_1.__generator(this, function (_a) {
761
- switch (_a.label) {
762
- case 0: return [4 /*yield*/, this.repo.findOne({
763
- where: { id: id },
764
- })];
765
- case 1: return [4 /*yield*/, _a.sent()];
766
- case 2:
767
- model = _a.sent();
768
- return [2 /*return*/, model];
769
- }
770
- });
633
+ async getBy(id) {
634
+ //#region @websqlFunc
635
+ const model = await await this.repo.findOne({
636
+ where: { id },
771
637
  });
772
- };
773
- BaseRepository = tslib_1.__decorate([
774
- (0, repository_decorator_1.TaonRepository)({ className: 'BaseRepository' }),
775
- tslib_1.__metadata("design:paramtypes", [Function])
776
- ], BaseRepository);
777
- return BaseRepository;
778
- }(base_injector_1.BaseInjector));
638
+ return model;
639
+ //#endregion
640
+ }
641
+ };
779
642
  exports.BaseRepository = BaseRepository;
643
+ exports.BaseRepository = BaseRepository = __decorate([
644
+ (0, repository_decorator_1.TaonRepository)({ className: 'BaseRepository' })
645
+ ], BaseRepository);
780
646
  //# sourceMappingURL=base-repository.js.map