taon 21.0.52 → 21.0.54

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 (193) hide show
  1. package/browser/package.json +1 -1
  2. package/browser-prod/package.json +1 -1
  3. package/icon-menu-taon.svg +15 -15
  4. package/lib/build-info._auto-generated_.d.ts +1 -1
  5. package/lib/build-info._auto-generated_.js +1 -1
  6. package/lib/package.json +1 -1
  7. package/lib/ui/index.js +2 -2
  8. package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
  9. package/lib-prod/base-classes/base-abstract-entity.js +19 -0
  10. package/lib-prod/base-classes/base-angular-service.js +84 -0
  11. package/lib-prod/base-classes/base-class.js +35 -0
  12. package/lib-prod/base-classes/{base-context.ts → base-context.js} +13 -15
  13. package/lib-prod/base-classes/base-controller.js +154 -0
  14. package/lib-prod/base-classes/base-crud-controller.js +264 -0
  15. package/lib-prod/base-classes/base-custom-repository.js +9 -0
  16. package/lib-prod/base-classes/{base-electron-service.ts → base-electron-service.js} +1 -12
  17. package/lib-prod/base-classes/base-entity.js +22 -0
  18. package/lib-prod/base-classes/base-file-upload.middleware.js +75 -0
  19. package/lib-prod/base-classes/base-injector.js +184 -0
  20. package/lib-prod/base-classes/base-middleware.js +9 -0
  21. package/lib-prod/base-classes/base-migration.js +20 -0
  22. package/lib-prod/base-classes/{base-provider.ts → base-provider.js} +2 -2
  23. package/lib-prod/base-classes/base-repository.js +617 -0
  24. package/lib-prod/base-classes/base-subscriber-for-entity.js +145 -0
  25. package/lib-prod/base-classes/{base.ts → base.js} +2 -15
  26. package/lib-prod/{build-info._auto-generated_.ts → build-info._auto-generated_.js} +1 -2
  27. package/lib-prod/config/controller-config.js +28 -0
  28. package/lib-prod/config/controller-options.js +3 -0
  29. package/lib-prod/config/method-config.js +7 -0
  30. package/lib-prod/config/param-config.js +3 -0
  31. package/lib-prod/constants.js +33 -0
  32. package/lib-prod/context-db-migrations.js +342 -0
  33. package/lib-prod/create-context.js +217 -0
  34. package/lib-prod/decorators/classes/controller-decorator.js +17 -0
  35. package/lib-prod/decorators/classes/entity-decorator.js +28 -0
  36. package/lib-prod/decorators/classes/middleware-decorator.js +16 -0
  37. package/lib-prod/decorators/classes/migration-decorator.js +15 -0
  38. package/lib-prod/decorators/classes/provider-decorator.js +15 -0
  39. package/lib-prod/decorators/classes/repository-decorator.js +15 -0
  40. package/lib-prod/decorators/classes/subscriber-decorator.js +15 -0
  41. package/lib-prod/decorators/decorator-abstract-opt.js +2 -0
  42. package/lib-prod/decorators/http/http-decorators.js +20 -0
  43. package/lib-prod/decorators/http/http-methods-decorators.js +102 -0
  44. package/lib-prod/decorators/http/http-params-decorators.js +42 -0
  45. package/lib-prod/dependency-injection/di-container.js +30 -0
  46. package/lib-prod/endpoint-context-storage.js +31 -0
  47. package/lib-prod/endpoint-context.js +2397 -0
  48. package/lib-prod/entity-process.js +225 -0
  49. package/lib-prod/env/{env.angular-node-app.ts → env.angular-node-app.js} +1 -1
  50. package/lib-prod/env/{env.docs-webapp.ts → env.docs-webapp.js} +1 -1
  51. package/lib-prod/env/{env.electron-app.ts → env.electron-app.js} +1 -1
  52. package/lib-prod/env/{env.mobile-app.ts → env.mobile-app.js} +1 -1
  53. package/lib-prod/env/{env.npm-lib-and-cli-tool.ts → env.npm-lib-and-cli-tool.js} +1 -1
  54. package/lib-prod/env/{env.vscode-plugin.ts → env.vscode-plugin.js} +1 -1
  55. package/lib-prod/express-types.js +1 -0
  56. package/lib-prod/formly/formly.models.js +1 -0
  57. package/lib-prod/formly/fromly.js +205 -0
  58. package/lib-prod/formly/type-from-entity.js +51 -0
  59. package/lib-prod/get-response-value.js +22 -0
  60. package/lib-prod/global-state/taon-global-state/{index.ts → index.js} +2 -2
  61. package/lib-prod/global-state/taon-global-state/{taon-global-state.abstract.context.ts → taon-global-state.abstract.context.js} +9 -11
  62. package/lib-prod/global-state/taon-global-state/taon-global-state.constants.js +7 -0
  63. package/lib-prod/global-state/taon-global-state/taon-global-state.controller.js +42 -0
  64. package/lib-prod/global-state/taon-global-state/taon-global-state.entity.js +35 -0
  65. package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.js +12 -0
  66. package/lib-prod/global-state/taon-global-state/taon-global-state.models.js +44 -0
  67. package/lib-prod/global-state/taon-global-state/taon-global-state.provider.js +12 -0
  68. package/lib-prod/global-state/taon-global-state/taon-global-state.repository.js +46 -0
  69. package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.js +22 -0
  70. package/lib-prod/global-state/taon-global-state/taon-global-state.utils.js +11 -0
  71. package/lib-prod/global-state/taon-transaction-registry/{index.ts → index.js} +2 -2
  72. package/lib-prod/global-state/taon-transaction-registry/{taon-transaction-registry.abstract.context.ts → taon-transaction-registry.abstract.context.js} +10 -12
  73. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.js +5 -0
  74. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js +36 -0
  75. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.js +36 -0
  76. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js +12 -0
  77. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.js +7 -0
  78. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.js +12 -0
  79. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.js +31 -0
  80. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js +22 -0
  81. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js +5 -0
  82. package/lib-prod/helpers/class-helpers.js +228 -0
  83. package/lib-prod/helpers/clone-obj.js +17 -0
  84. package/lib-prod/helpers/taon-helpers.js +147 -0
  85. package/lib-prod/{index._auto-generated_.ts → index._auto-generated_.js} +1 -1
  86. package/lib-prod/index.js +252 -0
  87. package/lib-prod/{inject.ts → inject.js} +35 -57
  88. package/lib-prod/migrations/index.js +2 -0
  89. package/lib-prod/migrations/{migrations_index._auto-generated_.ts → migrations_index._auto-generated_.js} +0 -2
  90. package/lib-prod/models.js +78 -0
  91. package/lib-prod/orm/columns.js +64 -0
  92. package/lib-prod/orm/index.js +56 -0
  93. package/lib-prod/package.json +1 -1
  94. package/lib-prod/realtime/realtime-client.js +198 -0
  95. package/lib-prod/realtime/realtime-core.js +81 -0
  96. package/lib-prod/realtime/realtime-server.js +237 -0
  97. package/lib-prod/realtime/realtime-strategy/{index.ts → index.js} +1 -1
  98. package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js +280 -0
  99. package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js +289 -0
  100. package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.js +27 -0
  101. package/lib-prod/realtime/realtime-strategy/realtime-strategy.js +11 -0
  102. package/lib-prod/realtime/realtime-subs-manager.js +88 -0
  103. package/lib-prod/realtime/realtime.models.js +2 -0
  104. package/lib-prod/symbols.js +108 -0
  105. package/lib-prod/ui/index.js +1 -0
  106. package/lib-prod/ui/taon-admin-mode-configuration/index.js +1 -0
  107. package/lib-prod/validators.js +80 -0
  108. package/lib-prod.split-namespaces.json +31 -91
  109. package/package.json +1 -1
  110. package/websql/package.json +1 -1
  111. package/websql-prod/package.json +1 -1
  112. package/lib-prod/base-classes/base-abstract-entity.ts +0 -34
  113. package/lib-prod/base-classes/base-angular-service.ts +0 -107
  114. package/lib-prod/base-classes/base-class.ts +0 -46
  115. package/lib-prod/base-classes/base-controller.ts +0 -240
  116. package/lib-prod/base-classes/base-crud-controller.ts +0 -298
  117. package/lib-prod/base-classes/base-custom-repository.ts +0 -10
  118. package/lib-prod/base-classes/base-entity.ts +0 -28
  119. package/lib-prod/base-classes/base-file-upload.middleware.ts +0 -92
  120. package/lib-prod/base-classes/base-injector.ts +0 -278
  121. package/lib-prod/base-classes/base-middleware.ts +0 -71
  122. package/lib-prod/base-classes/base-migration.ts +0 -26
  123. package/lib-prod/base-classes/base-repository.ts +0 -942
  124. package/lib-prod/base-classes/base-subscriber-for-entity.ts +0 -196
  125. package/lib-prod/config/controller-config.ts +0 -58
  126. package/lib-prod/config/controller-options.ts +0 -19
  127. package/lib-prod/config/method-config.ts +0 -55
  128. package/lib-prod/config/param-config.ts +0 -16
  129. package/lib-prod/constants.ts +0 -63
  130. package/lib-prod/context-db-migrations.ts +0 -488
  131. package/lib-prod/create-context.ts +0 -345
  132. package/lib-prod/decorators/classes/controller-decorator.ts +0 -25
  133. package/lib-prod/decorators/classes/entity-decorator.ts +0 -57
  134. package/lib-prod/decorators/classes/middleware-decorator.ts +0 -29
  135. package/lib-prod/decorators/classes/migration-decorator.ts +0 -27
  136. package/lib-prod/decorators/classes/provider-decorator.ts +0 -28
  137. package/lib-prod/decorators/classes/repository-decorator.ts +0 -26
  138. package/lib-prod/decorators/classes/subscriber-decorator.ts +0 -28
  139. package/lib-prod/decorators/decorator-abstract-opt.ts +0 -4
  140. package/lib-prod/decorators/http/http-decorators.ts +0 -26
  141. package/lib-prod/decorators/http/http-methods-decorators.ts +0 -275
  142. package/lib-prod/decorators/http/http-params-decorators.ts +0 -105
  143. package/lib-prod/dependency-injection/di-container.ts +0 -39
  144. package/lib-prod/endpoint-context-storage.ts +0 -47
  145. package/lib-prod/endpoint-context.ts +0 -3110
  146. package/lib-prod/entity-process.ts +0 -286
  147. package/lib-prod/express-types.ts +0 -4
  148. package/lib-prod/formly/formly.models.ts +0 -7
  149. package/lib-prod/formly/fromly.ts +0 -261
  150. package/lib-prod/formly/type-from-entity.ts +0 -80
  151. package/lib-prod/get-response-value.ts +0 -30
  152. package/lib-prod/global-state/taon-global-state/taon-global-state.constants.ts +0 -9
  153. package/lib-prod/global-state/taon-global-state/taon-global-state.controller.ts +0 -44
  154. package/lib-prod/global-state/taon-global-state/taon-global-state.entity.ts +0 -40
  155. package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.ts +0 -12
  156. package/lib-prod/global-state/taon-global-state/taon-global-state.models.ts +0 -48
  157. package/lib-prod/global-state/taon-global-state/taon-global-state.provider.ts +0 -16
  158. package/lib-prod/global-state/taon-global-state/taon-global-state.repository.ts +0 -47
  159. package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.ts +0 -18
  160. package/lib-prod/global-state/taon-global-state/taon-global-state.utils.ts +0 -21
  161. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.ts +0 -7
  162. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.ts +0 -38
  163. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.ts +0 -54
  164. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.ts +0 -12
  165. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.ts +0 -6
  166. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.ts +0 -16
  167. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.ts +0 -29
  168. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.ts +0 -20
  169. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.ts +0 -9
  170. package/lib-prod/helpers/class-helpers.ts +0 -315
  171. package/lib-prod/helpers/clone-obj.ts +0 -24
  172. package/lib-prod/helpers/taon-helpers.ts +0 -181
  173. package/lib-prod/index.ts +0 -323
  174. package/lib-prod/lib-info.md +0 -8
  175. package/lib-prod/migrations/index.ts +0 -2
  176. package/lib-prod/migrations/migrations-info.md +0 -6
  177. package/lib-prod/models.ts +0 -427
  178. package/lib-prod/orm/columns.ts +0 -121
  179. package/lib-prod/orm/index.ts +0 -62
  180. package/lib-prod/realtime/realtime-client.ts +0 -288
  181. package/lib-prod/realtime/realtime-core.ts +0 -134
  182. package/lib-prod/realtime/realtime-server.ts +0 -398
  183. package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.ts +0 -344
  184. package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.ts +0 -349
  185. package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.ts +0 -30
  186. package/lib-prod/realtime/realtime-strategy/realtime-strategy.ts +0 -21
  187. package/lib-prod/realtime/realtime-subs-manager.ts +0 -127
  188. package/lib-prod/realtime/realtime.models.ts +0 -33
  189. package/lib-prod/symbols.ts +0 -136
  190. package/lib-prod/ui/index.ts +0 -1
  191. package/lib-prod/ui/taon-admin-mode-configuration/index.ts +0 -1
  192. package/lib-prod/validators.ts +0 -103
  193. /package/lib-prod/env/{index.ts → index.js} +0 -0
@@ -0,0 +1,225 @@
1
+ import { JSON10 } from 'json10/lib-prod';
2
+ import { walk } from 'lodash-walk-object/lib-prod';
3
+ import { Mapping__NS__decode } from 'ng2-rest/lib-prod';
4
+ import { ___NS__isArray, ___NS__isBoolean, ___NS__isDate, ___NS__isFunction, ___NS__isNil, ___NS__isNull, ___NS__isNumber, ___NS__isObject, ___NS__isString, ___NS__set } from 'tnp-core/lib-prod';
5
+ import { config } from 'tnp-core/lib-prod';
6
+ import { ClassHelpers__NS__getClassFnFromObject, ClassHelpers__NS__getControllerConfigs, ClassHelpers__NS__getName, ClassHelpers__NS__getUniqueKey, ClassHelpers__NS__isContextClassObject } from './helpers/class-helpers';
7
+ import { Symbols__NS__old } from './symbols';
8
+ //#endregion
9
+ //#region get transform function
10
+ /**
11
+ * @deprecated
12
+ */
13
+ export const getTransformFunction = (target) => {
14
+ if (!target) {
15
+ return;
16
+ }
17
+ // const className = ClassHelpers__NS__getName(target)
18
+ // target = ClassHelpers.getBy(className);
19
+ if (!target) {
20
+ return void 0;
21
+ }
22
+ const configs = ClassHelpers__NS__getControllerConfigs(target);
23
+ // console.log(`CONFIGS TO CHECK`, configs)
24
+ const functions = configs
25
+ .map(c => {
26
+ if (___NS__isFunction(c.browserTransformFn)) {
27
+ return c.browserTransformFn;
28
+ }
29
+ })
30
+ .filter(f => ___NS__isFunction(f));
31
+ return functions.length === 0
32
+ ? void 0
33
+ : function (entity) {
34
+ for (let index = functions.length - 1; index >= 0; index--) {
35
+ const transformFun = functions[index];
36
+ transformFun(entity);
37
+ }
38
+ return entity;
39
+ };
40
+ };
41
+ //#endregion
42
+ //#region single transform
43
+ /**
44
+ * @deprecated
45
+ */
46
+ export const singleTransform = (json) => {
47
+ let ptarget = ClassHelpers__NS__getClassFnFromObject(json);
48
+ let pbrowserTransformFn = getTransformFunction(ptarget);
49
+ if (pbrowserTransformFn) {
50
+ const newValue = pbrowserTransformFn(json);
51
+ if (!___NS__isObject(newValue)) {
52
+ console.error(`Please return object in transform function for class: ` +
53
+ `${ClassHelpers__NS__getName(json)}`);
54
+ }
55
+ else {
56
+ json = newValue;
57
+ }
58
+ }
59
+ return json;
60
+ };
61
+ //#endregion
62
+ export class EntityProcess {
63
+ //#region init
64
+ static async init(result, response) {
65
+ return await new EntityProcess(result, response).run();
66
+ }
67
+ //#endregion
68
+ //#region constructor
69
+ constructor(
70
+ /**
71
+ * Data from backend
72
+ */
73
+ result, response) {
74
+ this.result = result;
75
+ this.response = response;
76
+ /**
77
+ * Say yes to:
78
+ * - circural object
79
+ * - transform browser fn in decorator
80
+ */
81
+ this.advancedManipulation = false;
82
+ this.circural = [];
83
+ }
84
+ //#endregion
85
+ //#region check advanced manipulation
86
+ checkAdvancedManiupulation() {
87
+ if (___NS__isFunction(this.result)) {
88
+ this.advancedManipulation = true;
89
+ this.result = this.result();
90
+ }
91
+ }
92
+ //#endregion
93
+ //#region run
94
+ async run() {
95
+ this.checkAdvancedManiupulation();
96
+ this.data = this.result;
97
+ if (___NS__isObject(this.result)) {
98
+ if (this.advancedManipulation) {
99
+ this.applayTransformFn();
100
+ }
101
+ this.setHeaders();
102
+ }
103
+ this.send();
104
+ }
105
+ //#endregion
106
+ //#region apply transform function
107
+ applayTransformFn() {
108
+ if (___NS__isObject(this.data) && !___NS__isArray(this.data)) {
109
+ this.data = singleTransform(this.data);
110
+ }
111
+ const { include } = { include: [] };
112
+ walk.Object(this.data, (value, lodashPath, changeValue, { skipObject, isCircural }) => {
113
+ // console.log(`${isCircural ? 'CIR' : 'NOT'} : ${lodashPath}`)
114
+ if (!isCircural) {
115
+ if (!___NS__isArray(value) && ___NS__isObject(value)) {
116
+ changeValue(singleTransform(value));
117
+ }
118
+ }
119
+ }, { checkCircural: true, breadthWalk: true, include });
120
+ const { circs } = walk.Object(this.data, void 0, {
121
+ checkCircural: true,
122
+ breadthWalk: true,
123
+ include,
124
+ });
125
+ this.circural = circs;
126
+ }
127
+ //#endregion
128
+ //#region set headers
129
+ setHeaders() {
130
+ const { include } = { include: [] };
131
+ const className = ClassHelpers__NS__getName(this.data);
132
+ const doNothing = ___NS__isNil(this.data) ||
133
+ [
134
+ 'Object',
135
+ '',
136
+ // void 0, null // TODO not sure about commenting this
137
+ ].includes(className);
138
+ // console.log('doNothing', doNothing)
139
+ if (!doNothing) {
140
+ const cleaned = JSON10.cleaned(this.data, void 0, {
141
+ breadthWalk: true,
142
+ include,
143
+ });
144
+ this.entityMapping = Mapping__NS__decode(cleaned, !this.advancedManipulation);
145
+ this.response.set(Symbols__NS__old.MAPPING_CONFIG_HEADER, JSON.stringify(this.entityMapping));
146
+ if (this.advancedManipulation) {
147
+ this.response.set(Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY, JSON.stringify(this.circural));
148
+ }
149
+ }
150
+ }
151
+ //#endregion
152
+ //#region send
153
+ send() {
154
+ if (this.advancedManipulation) {
155
+ const browserKey = config.folder.browser;
156
+ let toSend = ___NS__isArray(this.data) ? [] : {};
157
+ const { include = [], exclude = [] } = { include: [], exclude: [] };
158
+ walk.Object(this.data, (value, lodashPath, changeVAlue, { isCircural, skipObject }) => {
159
+ // console.log(`${isCircural ? 'CIR' : 'NOT'} ${lodashPath}`)
160
+ if (isCircural) {
161
+ ___NS__set(toSend, lodashPath, null);
162
+ }
163
+ else {
164
+ const fun = getTransformFunction(ClassHelpers__NS__getClassFnFromObject(value));
165
+ if (___NS__isFunction(fun)) {
166
+ ___NS__set(toSend, `${lodashPath}.${browserKey}`, value[browserKey]);
167
+ const indexProp = ClassHelpers__NS__getUniqueKey(value);
168
+ ___NS__set(toSend, `${lodashPath}.${indexProp}`, value[indexProp]);
169
+ // skipObject()
170
+ }
171
+ else {
172
+ ___NS__set(toSend, lodashPath, value);
173
+ }
174
+ }
175
+ }, { checkCircural: true, breadthWalk: true, include });
176
+ if (!___NS__isArray(this.data)) {
177
+ let funParent = getTransformFunction(ClassHelpers__NS__getClassFnFromObject(this.data));
178
+ // if (this.mdc && this.mdc.exclude && this.mdc.exclude.length > 0) {
179
+ // console.log(`funParent !!! have fun? ${!!funParent} `)
180
+ // }
181
+ if (___NS__isFunction(funParent)) {
182
+ toSend = {
183
+ [browserKey]: toSend[browserKey],
184
+ };
185
+ }
186
+ Object.keys(this.data).forEach(prop => {
187
+ if (prop !== browserKey) {
188
+ const v = this.data[prop];
189
+ if (!((include.length > 0 && !include.includes(prop)) ||
190
+ (exclude.length > 0 && exclude.includes(prop)))) {
191
+ if (ClassHelpers__NS__isContextClassObject(v) &&
192
+ ___NS__isFunction(getTransformFunction(ClassHelpers__NS__getClassFnFromObject(v)))) {
193
+ toSend[prop] = {
194
+ [browserKey]: v[browserKey],
195
+ };
196
+ const indexProp = ClassHelpers__NS__getUniqueKey(v);
197
+ toSend[prop][indexProp] = this.data[prop][indexProp];
198
+ for (const key in v) {
199
+ if (___NS__isObject(v) &&
200
+ v.hasOwnProperty(key) &&
201
+ ![indexProp, config.folder.browser].includes(key) &&
202
+ (___NS__isString(v[key]) ||
203
+ ___NS__isNumber(v[key]) ||
204
+ ___NS__isDate(v[key]) ||
205
+ ___NS__isNull(v[key]) ||
206
+ ___NS__isBoolean(v[key]))) {
207
+ toSend[prop][key] = v[key];
208
+ }
209
+ }
210
+ }
211
+ else {
212
+ toSend[prop] = v;
213
+ }
214
+ }
215
+ }
216
+ });
217
+ }
218
+ // toSend = Helpers.JSON.cleaned(toSend, void 0, { breadthWalk: true })
219
+ this.response.json(toSend);
220
+ }
221
+ else {
222
+ this.response.json(this.data);
223
+ }
224
+ }
225
+ }
@@ -63,4 +63,4 @@ export const ENV_ANGULAR_NODE_APP_IS_CI_PROCESS = undefined;
63
63
  export const ENV_ANGULAR_NODE_APP_DOCKER_ADDITIONAL_CONTAINER = undefined;
64
64
  export const ENV_ANGULAR_NODE_APP_DOCKER_SKIP_START_IN_ORDER = undefined;
65
65
  export const ENV_ANGULAR_NODE_APP_DOCKER_SKIP_USING_MYSQL_DB = undefined;
66
- // THIS FILE IS GENERATED - DO NOT MODIFY
66
+ // THIS FILE IS GENERATED - DO NOT MODIFY
@@ -63,4 +63,4 @@ export const ENV_DOCS_WEBAPP_IS_CI_PROCESS = undefined;
63
63
  export const ENV_DOCS_WEBAPP_DOCKER_ADDITIONAL_CONTAINER = undefined;
64
64
  export const ENV_DOCS_WEBAPP_DOCKER_SKIP_START_IN_ORDER = undefined;
65
65
  export const ENV_DOCS_WEBAPP_DOCKER_SKIP_USING_MYSQL_DB = undefined;
66
- // THIS FILE IS GENERATED - DO NOT MODIFY
66
+ // THIS FILE IS GENERATED - DO NOT MODIFY
@@ -63,4 +63,4 @@ export const ENV_ELECTRON_APP_IS_CI_PROCESS = undefined;
63
63
  export const ENV_ELECTRON_APP_DOCKER_ADDITIONAL_CONTAINER = undefined;
64
64
  export const ENV_ELECTRON_APP_DOCKER_SKIP_START_IN_ORDER = undefined;
65
65
  export const ENV_ELECTRON_APP_DOCKER_SKIP_USING_MYSQL_DB = undefined;
66
- // THIS FILE IS GENERATED - DO NOT MODIFY
66
+ // THIS FILE IS GENERATED - DO NOT MODIFY
@@ -63,4 +63,4 @@ export const ENV_MOBILE_APP_IS_CI_PROCESS = undefined;
63
63
  export const ENV_MOBILE_APP_DOCKER_ADDITIONAL_CONTAINER = undefined;
64
64
  export const ENV_MOBILE_APP_DOCKER_SKIP_START_IN_ORDER = undefined;
65
65
  export const ENV_MOBILE_APP_DOCKER_SKIP_USING_MYSQL_DB = undefined;
66
- // THIS FILE IS GENERATED - DO NOT MODIFY
66
+ // THIS FILE IS GENERATED - DO NOT MODIFY
@@ -63,4 +63,4 @@ export const ENV_NPM_LIB_AND_CLI_TOOL_IS_CI_PROCESS = undefined;
63
63
  export const ENV_NPM_LIB_AND_CLI_TOOL_DOCKER_ADDITIONAL_CONTAINER = undefined;
64
64
  export const ENV_NPM_LIB_AND_CLI_TOOL_DOCKER_SKIP_START_IN_ORDER = undefined;
65
65
  export const ENV_NPM_LIB_AND_CLI_TOOL_DOCKER_SKIP_USING_MYSQL_DB = undefined;
66
- // THIS FILE IS GENERATED - DO NOT MODIFY
66
+ // THIS FILE IS GENERATED - DO NOT MODIFY
@@ -63,4 +63,4 @@ export const ENV_VSCODE_PLUGIN_IS_CI_PROCESS = undefined;
63
63
  export const ENV_VSCODE_PLUGIN_DOCKER_ADDITIONAL_CONTAINER = undefined;
64
64
  export const ENV_VSCODE_PLUGIN_DOCKER_SKIP_START_IN_ORDER = undefined;
65
65
  export const ENV_VSCODE_PLUGIN_DOCKER_SKIP_USING_MYSQL_DB = undefined;
66
- // THIS FILE IS GENERATED - DO NOT MODIFY
66
+ // THIS FILE IS GENERATED - DO NOT MODIFY
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,205 @@
1
+ import { Mapping__NS__getModelsMapping } from 'ng2-rest/lib-prod';
2
+ import { ___NS__first, ___NS__isArray, ___NS__isBoolean, ___NS__isDate, ___NS__isFunction, ___NS__isString, ___NS__isUndefined, ___NS__startCase } from 'tnp-core/lib-prod';
3
+ import { CLASS } from 'typescript-class-helpers/lib-prod';
4
+ import { findTypeForEntity } from './type-from-entity';
5
+ export function getFromlyConfigFor(target, options = {}) {
6
+ const { formType = 'material', keysPathesToExclude = [], keysPathesToInclude = [], parentModel, relativePath = '', level = 0, maxLevel = 4, } = options;
7
+ if (level === maxLevel) {
8
+ return [];
9
+ }
10
+ const mapping = Mapping__NS__getModelsMapping(target);
11
+ // console.log('mapping', mapping)
12
+ const fieldNames = CLASS.describeProperites(target);
13
+ const checkExclude = ___NS__isArray(keysPathesToExclude) && keysPathesToExclude.length > 0;
14
+ const checkInclude = ___NS__isArray(keysPathesToInclude) && keysPathesToInclude.length > 0;
15
+ if (checkExclude && checkInclude) {
16
+ throw new Error(`In Taon function getFromlyConfigFor(...) please use keysPathesToInclude or keysPathesToExclude, `);
17
+ }
18
+ // if (checkInclude) {
19
+ // console.log('check include', keysPathesToExclude)
20
+ // }
21
+ // if (checkExclude) {
22
+ // console.log('check exclude', keysPathesToExclude)
23
+ // }
24
+ let fields = [];
25
+ //#region input to push
26
+ function inputToPush(key, type, model, inptToPushOptions) {
27
+ const { targetChild, selectOptions } = inptToPushOptions || {};
28
+ // console.log(`key(${key}) type: ${type} | model: ${model} targetChild: ${targetChild && targetChild.name}`)
29
+ let res;
30
+ if (type === 'repeat') {
31
+ const fieldGroup = getFromlyConfigFor(targetChild, {
32
+ formType,
33
+ keysPathesToInclude,
34
+ keysPathesToExclude,
35
+ relativePath: `${relativePath}.${key}`,
36
+ level: level + 1,
37
+ maxLevel,
38
+ });
39
+ if (fieldGroup.length > 0) {
40
+ res = {
41
+ key,
42
+ type,
43
+ defaultValue: [],
44
+ fieldArray: {
45
+ fieldGroupClassName: 'row',
46
+ templateOptions: {
47
+ label: `Add new ${___NS__startCase(key)}`,
48
+ },
49
+ fieldGroup,
50
+ },
51
+ };
52
+ }
53
+ }
54
+ else if (type === 'group') {
55
+ const fieldGroup = getFromlyConfigFor(targetChild, {
56
+ formType,
57
+ keysPathesToInclude,
58
+ keysPathesToExclude,
59
+ parentModel: model,
60
+ relativePath: `${relativePath}.${key}`,
61
+ level: level + 1,
62
+ maxLevel,
63
+ });
64
+ if (fieldGroup.length > 0) {
65
+ res = {
66
+ fieldGroupClassName: 'row',
67
+ templateOptions: {
68
+ label: `${___NS__startCase(key)}`,
69
+ },
70
+ wrappers: ['groupwrap'],
71
+ fieldGroup,
72
+ };
73
+ }
74
+ }
75
+ else {
76
+ res = {
77
+ key,
78
+ model,
79
+ type,
80
+ defaultValue: !___NS__isUndefined(target.prototype[key])
81
+ ? target.prototype[key]
82
+ : undefined,
83
+ templateOptions: {
84
+ label: ___NS__isString(model)
85
+ ? `${model
86
+ .split('.')
87
+ .map(l => ___NS__startCase(l))
88
+ .join(' / ')} / ${___NS__startCase(key)}`
89
+ : ___NS__startCase(key),
90
+ options: selectOptions,
91
+ },
92
+ };
93
+ }
94
+ if (res) {
95
+ Object.keys(res).forEach(key => res[key] === undefined ? delete res[key] : '');
96
+ }
97
+ return res;
98
+ }
99
+ //#endregion
100
+ //#region is allowed path
101
+ function isAlowedPath(key) {
102
+ let isAlowed = true;
103
+ const matchPath = relativePath === '' ? key : `${relativePath}:${key}`;
104
+ if (checkExclude) {
105
+ if (keysPathesToExclude.includes(matchPath)) {
106
+ // console.log(`Not allowed key: ${key}`)
107
+ isAlowed = false;
108
+ }
109
+ else {
110
+ isAlowed = true;
111
+ }
112
+ }
113
+ else if (checkInclude) {
114
+ if (keysPathesToInclude.includes(matchPath)) {
115
+ // console.log(`Allowed key: ${key}`)
116
+ isAlowed = true;
117
+ }
118
+ else {
119
+ isAlowed = false;
120
+ }
121
+ }
122
+ // console.log(`Is allowed;${matchPath} `, isAlowed)
123
+ return isAlowed;
124
+ }
125
+ //#endregion
126
+ const simpleResolved = [];
127
+ //#region resolve simple types
128
+ function resolveSimpleTypes() {
129
+ for (const key in target.prototype) {
130
+ if (target.prototype.hasOwnProperty(key) &&
131
+ !___NS__isFunction(target.prototype[key])) {
132
+ if (!isAlowedPath(key)) {
133
+ continue;
134
+ }
135
+ if (!___NS__isUndefined(mapping[key])) {
136
+ continue;
137
+ }
138
+ const element = target.prototype[key];
139
+ let type = 'input';
140
+ if (___NS__isBoolean(element)) {
141
+ type = 'switch';
142
+ }
143
+ else if (___NS__isDate(element)) {
144
+ type = 'datepicker';
145
+ }
146
+ else if (___NS__isFunction(target['getOptionsFor'])) {
147
+ var selectOptions = target['getOptionsFor'](key);
148
+ if (!___NS__isUndefined(selectOptions)) {
149
+ type = 'select';
150
+ }
151
+ }
152
+ else if (___NS__isFunction(target.prototype?.getOptionsFor)) {
153
+ var selectOptions = target.prototype?.getOptionsFor(key);
154
+ if (!___NS__isUndefined(selectOptions)) {
155
+ type = 'select';
156
+ }
157
+ }
158
+ fields.push(inputToPush(key, type, parentModel, { selectOptions }));
159
+ simpleResolved.push(key);
160
+ }
161
+ }
162
+ }
163
+ //#endregion
164
+ //#region resolve complex types
165
+ function resolveComplexTypes() {
166
+ fieldNames
167
+ .filter(key => !simpleResolved.includes(key))
168
+ .forEach(key => {
169
+ if (isAlowedPath(key) && !___NS__isUndefined(mapping[key])) {
170
+ let className = mapping[key];
171
+ const isArray = ___NS__isArray(className);
172
+ className = isArray ? ___NS__first(className) : className;
173
+ if (className === 'Date') {
174
+ fields.push(inputToPush(key, 'datepicker', parentModel));
175
+ }
176
+ else {
177
+ const targetChild = CLASS.getBy(className);
178
+ if (targetChild) {
179
+ const ftype = findTypeForEntity(targetChild, isArray);
180
+ if (ftype) {
181
+ fields = fields.concat(inputToPush(key, ftype.name, key));
182
+ }
183
+ else {
184
+ if (isArray) {
185
+ fields = fields.concat(inputToPush(key, 'repeat', key, { targetChild }));
186
+ }
187
+ else {
188
+ fields = fields.concat(inputToPush(key, 'group', key, { targetChild }));
189
+ }
190
+ }
191
+ }
192
+ }
193
+ }
194
+ });
195
+ }
196
+ //#endregion
197
+ function generate() {
198
+ resolveSimpleTypes();
199
+ // console.log('after simple', fields);
200
+ resolveComplexTypes();
201
+ // console.log('after complext', fields);
202
+ }
203
+ generate();
204
+ return fields.filter(f => !!f);
205
+ }
@@ -0,0 +1,51 @@
1
+ import { ClassHelpers__NS__getName, ClassHelpers__NS__setName } from '../helpers/class-helpers';
2
+ import { ___NS__first, ___NS__isArray } from 'tnp-core/lib-prod';
3
+ export function findTypeForEntity(entity, isArray = false) {
4
+ if (!___NS__isArray(RegisterComponentType.prototype.types)) {
5
+ RegisterComponentType.prototype.types = [];
6
+ }
7
+ return getRegisteredComponents().find(c => c.entity === entity && c.isArray === isArray);
8
+ }
9
+ export function typeFromEntity(component, entity) {
10
+ const isArray = ___NS__isArray(entity);
11
+ if (isArray) {
12
+ entity = ___NS__first(entity);
13
+ }
14
+ let name = ClassHelpers__NS__getName(component);
15
+ let res = { name, component, entity, isArray };
16
+ // console.log(res);
17
+ return res;
18
+ }
19
+ export function typeFromName(component, name) {
20
+ let res = { name, component };
21
+ return res;
22
+ }
23
+ export function RegisterComponentTypeForEntity(entity) {
24
+ if (!___NS__isArray(RegisterComponentType.prototype.types)) {
25
+ RegisterComponentType.prototype.types = [];
26
+ }
27
+ return function (target, propertyKey, descriptor) {
28
+ RegisterComponentType.prototype.types.push(typeFromEntity(target, entity));
29
+ };
30
+ }
31
+ export function RegisterComponentType(className, ...optionslNames) {
32
+ if (!___NS__isArray(RegisterComponentType.prototype.types)) {
33
+ RegisterComponentType.prototype.types = [];
34
+ }
35
+ return function (target, propertyKey, descriptor) {
36
+ ClassHelpers__NS__setName(target, className);
37
+ RegisterComponentType.prototype.types.push(typeFromEntity(target));
38
+ optionslNames.forEach(name => {
39
+ RegisterComponentType.prototype.types.push(typeFromName(target, name));
40
+ });
41
+ };
42
+ }
43
+ // RegisterComponentType.prototype.types = []
44
+ export function getRegisteredComponents() {
45
+ let registered = RegisterComponentType.prototype.types;
46
+ if (!Array.isArray(registered)) {
47
+ return [];
48
+ }
49
+ // console.log(registered)
50
+ return registered;
51
+ }
@@ -0,0 +1,22 @@
1
+ export const getResponseValue = (response, options) => {
2
+ //#region @websqlFunc
3
+ const { req, res } = options || {};
4
+ return new Promise(async (resolve, reject) => {
5
+ //#region @websql
6
+ if (typeof response === 'function') {
7
+ const asyncResponse = response;
8
+ try {
9
+ const result = await asyncResponse(req, res);
10
+ resolve(result);
11
+ }
12
+ catch (e) {
13
+ reject(e);
14
+ }
15
+ }
16
+ else {
17
+ reject(`[taon] Not recognized type of response ${response}`);
18
+ }
19
+ //#endregion
20
+ });
21
+ //#endregion
22
+ };
@@ -1,6 +1,6 @@
1
- /* */
1
+ /* */
2
2
  export * from './taon-global-state.constants';
3
3
  export * from './taon-global-state.entity';
4
4
  export * from './taon-global-state.controller';
5
5
  export * from './taon-global-state.repository';
6
- export * from './taon-global-state.abstract.context';
6
+ export * from './taon-global-state.abstract.context';
@@ -1,5 +1,4 @@
1
1
  //#region imports
2
-
3
2
  import { createContext } from '../../create-context';
4
3
  import { TAON_GLOBAL_STATE } from './taon-global-state.entity';
5
4
  import { TaonGlobalStateController } from './taon-global-state.controller';
@@ -8,14 +7,13 @@ import { TaonGlobalStateProvider } from './taon-global-state.provider';
8
7
  import { TaonGlobalStateMiddleware } from './taon-global-state.middleware';
9
8
  import { TaonGlobalStateSubscriber } from './taon-global-state.subscriber';
10
9
  //#endregion
11
-
12
10
  export const TaonGlobalStateContext = createContext(() => ({
13
- contextName: 'TaonGlobalStateContext',
14
- abstract: true,
15
- entities: { TAON_GLOBAL_STATE },
16
- controllers: { TaonGlobalStateController },
17
- repositories: { TaonGlobalStateRepository },
18
- providers: { TaonGlobalStateProvider },
19
- middlewares: { TaonGlobalStateMiddleware },
20
- subscribers: { TaonGlobalStateSubscriber },
21
- }));
11
+ contextName: 'TaonGlobalStateContext',
12
+ abstract: true,
13
+ entities: { TAON_GLOBAL_STATE },
14
+ controllers: { TaonGlobalStateController },
15
+ repositories: { TaonGlobalStateRepository },
16
+ providers: { TaonGlobalStateProvider },
17
+ middlewares: { TaonGlobalStateMiddleware },
18
+ subscribers: { TaonGlobalStateSubscriber },
19
+ }));
@@ -0,0 +1,7 @@
1
+ import { TaonGlobalStateStatus } from './taon-global-state.models';
2
+ export const TaonGlobalStateDefaultsValues = {
3
+ description: '',
4
+ version: 0,
5
+ id: void 0,
6
+ status: TaonGlobalStateStatus.NORMAL,
7
+ };
@@ -0,0 +1,42 @@
1
+ //#region imports
2
+ import { TaonController } from '../../decorators/classes/controller-decorator';
3
+ import { TaonBaseCrudController } from '../../base-classes/base-crud-controller';
4
+ import { Query } from '../../decorators/http/http-params-decorators';
5
+ import { GET } from '../../decorators/http/http-methods-decorators';
6
+ import { POST } from '../../decorators/http/http-methods-decorators';
7
+ import { TAON_GLOBAL_STATE } from './taon-global-state.entity';
8
+ import { TaonGlobalStateRepository } from './taon-global-state.repository';
9
+ //#endregion
10
+ let TaonGlobalStateController = class TaonGlobalStateController extends TaonBaseCrudController {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.entityClassResolveFn = () => TAON_GLOBAL_STATE;
14
+ this.taonGlobalStateRepository = this.injectCustomRepo(TaonGlobalStateRepository);
15
+ }
16
+ getStatus() {
17
+ return async () => {
18
+ //#region @websqlFunc
19
+ const stateEntity = await this.taonGlobalStateRepository.getLastStatus();
20
+ return stateEntity.status;
21
+ //#endregion
22
+ };
23
+ }
24
+ setDraining(secondsBeforeReadonly = 0) {
25
+ return async () => {
26
+ await this.taonGlobalStateRepository.setDraining(secondsBeforeReadonly);
27
+ };
28
+ }
29
+ };
30
+ __decorate([
31
+ GET()
32
+ ], TaonGlobalStateController.prototype, "getStatus", null);
33
+ __decorate([
34
+ POST(),
35
+ __param(0, Query('secondsBeforeReadonly'))
36
+ ], TaonGlobalStateController.prototype, "setDraining", null);
37
+ TaonGlobalStateController = __decorate([
38
+ TaonController({
39
+ className: 'TaonGlobalStateController',
40
+ })
41
+ ], TaonGlobalStateController);
42
+ export { TaonGlobalStateController };