3xpr 1.10.4 → 1.11.0

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 (229) hide show
  1. package/__tests__/auto/comparison.test.js +2 -1
  2. package/__tests__/auto/comparison.test.js.map +1 -1
  3. package/__tests__/auto/parameters.test.js +1 -0
  4. package/__tests__/auto/parameters.test.js.map +1 -1
  5. package/__tests__/auto/string.test.js +5 -0
  6. package/__tests__/auto/string.test.js.map +1 -1
  7. package/__tests__/auto/type.test.js +1 -0
  8. package/__tests__/auto/type.test.js.map +1 -1
  9. package/{infrastructure/expression → expression/application}/expressions.d.ts +14 -19
  10. package/{infrastructure/expression → expression/application}/expressions.js +47 -40
  11. package/expression/application/expressions.js.map +1 -0
  12. package/expression/application/index.d.ts +6 -0
  13. package/expression/application/index.js +23 -0
  14. package/expression/application/index.js.map +1 -0
  15. package/expression/application/ports/converter.d.ts +3 -0
  16. package/expression/application/ports/converter.js +3 -0
  17. package/expression/application/ports/converter.js.map +1 -0
  18. package/expression/application/services/builder.d.ts +13 -0
  19. package/expression/application/services/builder.js +29 -0
  20. package/expression/application/services/builder.js.map +1 -0
  21. package/{application/expression/useCases/normalize.d.ts → expression/application/services/normalizer.d.ts} +1 -1
  22. package/{application/expression/useCases/normalize.js → expression/application/services/normalizer.js} +4 -4
  23. package/expression/application/services/normalizer.js.map +1 -0
  24. package/{application/expression → expression/application}/services/parser.d.ts +6 -1
  25. package/{application/expression → expression/application}/services/parser.js +21 -2
  26. package/expression/application/services/parser.js.map +1 -0
  27. package/expression/application/useCases/build.d.ts +8 -0
  28. package/expression/application/useCases/build.js +50 -0
  29. package/expression/application/useCases/build.js.map +1 -0
  30. package/expression/application/useCases/convert.d.ts +5 -0
  31. package/expression/application/useCases/convert.js +31 -0
  32. package/expression/application/useCases/convert.js.map +1 -0
  33. package/{application/ports → expression/domain}/expressions.d.ts +5 -6
  34. package/expression/domain/expressions.js.map +1 -0
  35. package/expression/domain/index.d.ts +1 -0
  36. package/{application/helper → expression/domain}/index.js +1 -2
  37. package/expression/domain/index.js.map +1 -0
  38. package/expression/infrastructure/convertFromFunction.d.ts +10 -0
  39. package/expression/infrastructure/convertFromFunction.js +58 -0
  40. package/expression/infrastructure/convertFromFunction.js.map +1 -0
  41. package/expression/infrastructure/convertFromGraphql.d.ts +4 -0
  42. package/{infrastructure/expression → expression/infrastructure}/convertFromGraphql.js +14 -4
  43. package/expression/infrastructure/convertFromGraphql.js.map +1 -0
  44. package/expression/infrastructure/helper.d.ts +5 -0
  45. package/expression/infrastructure/helper.js +47 -0
  46. package/expression/infrastructure/helper.js.map +1 -0
  47. package/expression/infrastructure/index.d.ts +1 -0
  48. package/{application → expression/infrastructure}/index.js +4 -4
  49. package/expression/infrastructure/index.js.map +1 -0
  50. package/{application/model → expression/infrastructure}/library.d.ts +2 -4
  51. package/{application/model → expression/infrastructure}/library.js +111 -94
  52. package/expression/infrastructure/library.js.map +1 -0
  53. package/index.d.ts +30 -3
  54. package/index.js +50 -3
  55. package/index.js.map +1 -1
  56. package/{application/model → model/application}/index.d.ts +0 -1
  57. package/{application/model → model/application}/index.js +0 -1
  58. package/model/application/index.js.map +1 -0
  59. package/{application/model → model/application}/modelService.d.ts +3 -1
  60. package/{application/model → model/application}/modelService.js +1 -2
  61. package/model/application/modelService.js.map +1 -0
  62. package/model/domain/index.d.ts +1 -0
  63. package/{application/operand/useCases/build/factory → model/domain}/index.js +1 -2
  64. package/model/domain/index.js.map +1 -0
  65. package/{domain/model → model/domain}/services.d.ts +2 -2
  66. package/model/domain/services.js.map +1 -0
  67. package/operand/application/index.d.ts +8 -0
  68. package/{application/operand → operand/application}/index.js +6 -8
  69. package/operand/application/index.js.map +1 -0
  70. package/operand/application/services/constBuilder.d.ts +4 -0
  71. package/operand/application/services/constBuilder.js +3 -0
  72. package/operand/application/services/constBuilder.js.map +1 -0
  73. package/operand/application/services/factory.d.ts +8 -0
  74. package/operand/application/services/factory.js +25 -0
  75. package/operand/application/services/factory.js.map +1 -0
  76. package/operand/application/services/parameterService.d.ts +4 -0
  77. package/{application/operand → operand/application}/services/parameterService.js +1 -1
  78. package/{application/operand → operand/application}/services/parameterService.js.map +1 -1
  79. package/{application/operand/useCases → operand/application/services}/serializer.d.ts +1 -1
  80. package/{application/operand/useCases → operand/application/services}/serializer.js +1 -1
  81. package/{application/operand/useCases → operand/application/services}/serializer.js.map +1 -1
  82. package/{application/operand → operand/application}/services/typeService.d.ts +7 -4
  83. package/{application/operand → operand/application}/services/typeService.js +74 -11
  84. package/operand/application/services/typeService.js.map +1 -0
  85. package/operand/application/useCases/clone.d.ts +7 -0
  86. package/operand/application/useCases/clone.js +39 -0
  87. package/operand/application/useCases/clone.js.map +1 -0
  88. package/operand/application/useCases/complete.d.ts +7 -0
  89. package/operand/application/useCases/complete.js +40 -0
  90. package/operand/application/useCases/complete.js.map +1 -0
  91. package/operand/application/useCases/normalize.d.ts +6 -0
  92. package/{application/operand/useCases/normalizer.js → operand/application/useCases/normalize.js} +16 -7
  93. package/operand/application/useCases/normalize.js.map +1 -0
  94. package/operand/application/useCases/reduce.d.ts +7 -0
  95. package/{application/operand/useCases/reducer.js → operand/application/useCases/reduce.js} +21 -9
  96. package/operand/application/useCases/reduce.js.map +1 -0
  97. package/{domain/operand → operand/domain}/entities.d.ts +4 -49
  98. package/operand/domain/entities.js +19 -0
  99. package/operand/domain/entities.js.map +1 -0
  100. package/operand/domain/index.d.ts +2 -0
  101. package/{domain → operand/domain}/index.js +1 -3
  102. package/operand/domain/index.js.map +1 -0
  103. package/operand/domain/services.d.ts +8 -0
  104. package/operand/domain/services.js.map +1 -0
  105. package/operand/infrastructure/constBuilder.d.ts +4 -0
  106. package/operand/infrastructure/constBuilder.js +25 -0
  107. package/operand/infrastructure/constBuilder.js.map +1 -0
  108. package/operand/infrastructure/evaluators/async.d.ts +119 -0
  109. package/operand/infrastructure/evaluators/async.js +560 -0
  110. package/operand/infrastructure/evaluators/async.js.map +1 -0
  111. package/operand/infrastructure/evaluators/sync.d.ts +110 -0
  112. package/operand/infrastructure/evaluators/sync.js +485 -0
  113. package/operand/infrastructure/evaluators/sync.js.map +1 -0
  114. package/operand/infrastructure/helper.d.ts +18 -0
  115. package/{application/helper/operandHelper.js → operand/infrastructure/helper.js} +23 -8
  116. package/operand/infrastructure/helper.js.map +1 -0
  117. package/operand/infrastructure/index.d.ts +2 -0
  118. package/operand/infrastructure/index.js +23 -0
  119. package/operand/infrastructure/index.js.map +1 -0
  120. package/package.json +2 -2
  121. package/shared/application/helper/expression.d.ts +3 -0
  122. package/shared/application/helper/expression.js +3 -0
  123. package/shared/application/helper/expression.js.map +1 -0
  124. package/shared/application/helper/helper.d.ts +7 -0
  125. package/shared/application/helper/helper.js +25 -0
  126. package/shared/application/helper/helper.js.map +1 -0
  127. package/{application/helper/operandHelper.d.ts → shared/application/helper/operand.d.ts} +1 -2
  128. package/shared/application/helper/operand.js +3 -0
  129. package/shared/application/helper/operand.js.map +1 -0
  130. package/shared/application/index.d.ts +3 -0
  131. package/{application/expression → shared/application}/index.js +3 -3
  132. package/shared/application/index.js.map +1 -0
  133. package/shared/domain/base.js.map +1 -0
  134. package/shared/domain/context.js.map +1 -0
  135. package/{domain/entities → shared/domain}/index.d.ts +1 -0
  136. package/{domain/entities → shared/domain}/index.js +1 -0
  137. package/shared/domain/index.js.map +1 -0
  138. package/{domain/entities → shared/domain}/observer.d.ts +1 -1
  139. package/shared/domain/observer.js.map +1 -0
  140. package/shared/domain/operand.d.ts +50 -0
  141. package/{domain/operand/entities.js → shared/domain/operand.js} +2 -17
  142. package/shared/domain/operand.js.map +1 -0
  143. package/shared/domain/signals.js.map +1 -0
  144. package/application/expression/index.d.ts +0 -3
  145. package/application/expression/index.js.map +0 -1
  146. package/application/expression/services/parser.js.map +0 -1
  147. package/application/expression/useCases/normalize.js.map +0 -1
  148. package/application/expression/useCases/parse.d.ts +0 -6
  149. package/application/expression/useCases/parse.js +0 -15
  150. package/application/expression/useCases/parse.js.map +0 -1
  151. package/application/helper/helper.d.ts +0 -13
  152. package/application/helper/helper.js +0 -45
  153. package/application/helper/helper.js.map +0 -1
  154. package/application/helper/index.d.ts +0 -2
  155. package/application/helper/index.js.map +0 -1
  156. package/application/helper/operandHelper.js.map +0 -1
  157. package/application/index.d.ts +0 -5
  158. package/application/index.js.map +0 -1
  159. package/application/model/index.js.map +0 -1
  160. package/application/model/library.js.map +0 -1
  161. package/application/model/modelService.js.map +0 -1
  162. package/application/operand/index.d.ts +0 -10
  163. package/application/operand/index.js.map +0 -1
  164. package/application/operand/services/operandService.d.ts +0 -13
  165. package/application/operand/services/operandService.js +0 -62
  166. package/application/operand/services/operandService.js.map +0 -1
  167. package/application/operand/services/parameterService.d.ts +0 -4
  168. package/application/operand/services/typeService.js.map +0 -1
  169. package/application/operand/useCases/build/basicOperandBuilder.d.ts +0 -6
  170. package/application/operand/useCases/build/basicOperandBuilder.js +0 -15
  171. package/application/operand/useCases/build/basicOperandBuilder.js.map +0 -1
  172. package/application/operand/useCases/build/factory/basic/evaluators.d.ts +0 -67
  173. package/application/operand/useCases/build/factory/basic/evaluators.js +0 -239
  174. package/application/operand/useCases/build/factory/basic/evaluators.js.map +0 -1
  175. package/application/operand/useCases/build/factory/basic/factory.d.ts +0 -11
  176. package/application/operand/useCases/build/factory/basic/factory.js +0 -128
  177. package/application/operand/useCases/build/factory/basic/factory.js.map +0 -1
  178. package/application/operand/useCases/build/factory/index.d.ts +0 -2
  179. package/application/operand/useCases/build/factory/index.js.map +0 -1
  180. package/application/operand/useCases/build/factory/process/evaluators.d.ts +0 -58
  181. package/application/operand/useCases/build/factory/process/evaluators.js +0 -317
  182. package/application/operand/useCases/build/factory/process/evaluators.js.map +0 -1
  183. package/application/operand/useCases/build/factory/process/factory.d.ts +0 -8
  184. package/application/operand/useCases/build/factory/process/factory.js +0 -122
  185. package/application/operand/useCases/build/factory/process/factory.js.map +0 -1
  186. package/application/operand/useCases/build/operandBuilder.d.ts +0 -15
  187. package/application/operand/useCases/build/operandBuilder.js +0 -46
  188. package/application/operand/useCases/build/operandBuilder.js.map +0 -1
  189. package/application/operand/useCases/build/processOperandBuilder.d.ts +0 -6
  190. package/application/operand/useCases/build/processOperandBuilder.js +0 -15
  191. package/application/operand/useCases/build/processOperandBuilder.js.map +0 -1
  192. package/application/operand/useCases/normalizer.d.ts +0 -7
  193. package/application/operand/useCases/normalizer.js.map +0 -1
  194. package/application/operand/useCases/reducer.d.ts +0 -7
  195. package/application/operand/useCases/reducer.js.map +0 -1
  196. package/application/ports/expressions.js.map +0 -1
  197. package/domain/entities/base.js.map +0 -1
  198. package/domain/entities/context.js.map +0 -1
  199. package/domain/entities/index.js.map +0 -1
  200. package/domain/entities/observer.js.map +0 -1
  201. package/domain/entities/signals.js.map +0 -1
  202. package/domain/index.d.ts +0 -4
  203. package/domain/index.js.map +0 -1
  204. package/domain/model/services.js.map +0 -1
  205. package/domain/operand/entities.js.map +0 -1
  206. package/domain/operand/services.d.ts +0 -23
  207. package/domain/operand/services.js.map +0 -1
  208. package/infrastructure/expression/builder.d.ts +0 -5
  209. package/infrastructure/expression/builder.js +0 -18
  210. package/infrastructure/expression/builder.js.map +0 -1
  211. package/infrastructure/expression/convertFromFunction.d.ts +0 -11
  212. package/infrastructure/expression/convertFromFunction.js +0 -45
  213. package/infrastructure/expression/convertFromFunction.js.map +0 -1
  214. package/infrastructure/expression/convertFromGraphql.d.ts +0 -3
  215. package/infrastructure/expression/convertFromGraphql.js.map +0 -1
  216. package/infrastructure/expression/expressions.js.map +0 -1
  217. package/infrastructure/index.d.ts +0 -19
  218. package/infrastructure/index.js +0 -52
  219. package/infrastructure/index.js.map +0 -1
  220. /package/{application/ports → expression/domain}/expressions.js +0 -0
  221. /package/{domain/model → model/domain}/services.js +0 -0
  222. /package/{domain/operand → operand/domain}/services.js +0 -0
  223. /package/{domain/entities → shared/domain}/base.d.ts +0 -0
  224. /package/{domain/entities → shared/domain}/base.js +0 -0
  225. /package/{domain/entities → shared/domain}/context.d.ts +0 -0
  226. /package/{domain/entities → shared/domain}/context.js +0 -0
  227. /package/{domain/entities → shared/domain}/observer.js +0 -0
  228. /package/{domain/entities → shared/domain}/signals.d.ts +0 -0
  229. /package/{domain/entities → shared/domain}/signals.js +0 -0
@@ -0,0 +1,50 @@
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
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.OperandBuild = void 0;
13
+ const __1 = require("../../..");
14
+ const h3lp_1 = require("h3lp");
15
+ class OperandBuild {
16
+ getBuilder(key) {
17
+ return this.builders[key];
18
+ }
19
+ build(expression, options) {
20
+ try {
21
+ const builder = this.getBuilder(options.type);
22
+ if (!options.cache) {
23
+ return builder.build(expression);
24
+ }
25
+ const key = `${__1.helper.utils.hashCode(expression)}-${options.type}`;
26
+ const value = this.cache.get(key);
27
+ if (!value) {
28
+ const operand = builder.build(expression);
29
+ this.cache.set(key, operand);
30
+ return operand;
31
+ }
32
+ else {
33
+ return value;
34
+ }
35
+ }
36
+ catch (error) {
37
+ throw new Error('expression: ' + expression + ' error: ' + error.toString());
38
+ }
39
+ }
40
+ }
41
+ __decorate([
42
+ (0, h3lp_1.Autowired)('exp.operand.cache'),
43
+ __metadata("design:type", Object)
44
+ ], OperandBuild.prototype, "cache", void 0);
45
+ __decorate([
46
+ (0, h3lp_1.Autowired)('exp.operand.builder'),
47
+ __metadata("design:type", Object)
48
+ ], OperandBuild.prototype, "builders", void 0);
49
+ exports.OperandBuild = OperandBuild;
50
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../../../../../src/lib/expression/application/useCases/build.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,gCAAiC;AAEjC,+BAAwC;AAExC,MAAa,YAAY;IAOhB,UAAU,CAAE,GAAU;QAC7B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAoB,CAAA;IAC7C,CAAC;IAEM,KAAK,CAAE,UAAkB,EAAE,OAA2B;QAC5D,IAAI;YACH,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YAC7C,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;gBACnB,OAAO,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;aAChC;YACD,MAAM,GAAG,GAAG,GAAG,UAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,IAAI,EAAE,CAAA;YAClE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACjC,IAAI,CAAC,KAAK,EAAE;gBACX,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;gBACzC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;gBAC5B,OAAO,OAAO,CAAA;aACd;iBAAM;gBACN,OAAO,KAAK,CAAA;aACZ;SACD;QAAC,OAAO,KAAU,EAAE;YACpB,MAAM,IAAI,KAAK,CAAC,cAAc,GAAG,UAAU,GAAG,UAAU,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;SAC5E;IACF,CAAC;CACD;AA7BA;IAAC,IAAA,gBAAS,EAAC,mBAAmB,CAAC;;2CACQ;AAEvC;IAAC,IAAA,gBAAS,EAAC,qBAAqB,CAAC;;8CACZ;AALtB,oCA8BC"}
@@ -0,0 +1,5 @@
1
+ export declare class ExpressionConvert {
2
+ private converts;
3
+ private getConverter;
4
+ convert(source: any, from: string): [string, any];
5
+ }
@@ -0,0 +1,31 @@
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
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ExpressionConvert = void 0;
13
+ const h3lp_1 = require("h3lp");
14
+ class ExpressionConvert {
15
+ getConverter(key) {
16
+ return this.converts[key];
17
+ }
18
+ convert(source, from) {
19
+ const converter = this.getConverter(from);
20
+ if (converter === undefined) {
21
+ throw new Error(`Converter ${from} not implemented`);
22
+ }
23
+ return converter.convert(source);
24
+ }
25
+ }
26
+ __decorate([
27
+ (0, h3lp_1.Autowired)('exp.expression.converter'),
28
+ __metadata("design:type", Object)
29
+ ], ExpressionConvert.prototype, "converts", void 0);
30
+ exports.ExpressionConvert = ExpressionConvert;
31
+ //# sourceMappingURL=convert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert.js","sourceRoot":"","sources":["../../../../../src/lib/expression/application/useCases/convert.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,+BAAgC;AAGhC,MAAa,iBAAiB;IAIrB,YAAY,CAAE,GAAU;QAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAwB,CAAA;IACjD,CAAC;IAEM,OAAO,CAAE,MAAU,EAAE,IAAW;QACtC,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;QACzC,IAAI,SAAS,KAAK,SAAS,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,aAAa,IAAI,kBAAkB,CAAC,CAAA;SACpD;QACD,OAAO,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACjC,CAAC;CACD;AAdA;IAAC,IAAA,gBAAS,EAAC,0BAA0B,CAAC;;mDACjB;AAFtB,8CAeC"}
@@ -1,4 +1,6 @@
1
- import { Parameter, Format, OperatorAdditionalInfo, FunctionAdditionalInfo, Operand, OperatorMetadata, ActionObserver, IModelService, IOperandBuilder, IOperandService } from '../../domain';
1
+ import { OperatorMetadata, OperatorAdditionalInfo, FunctionAdditionalInfo } from '../../operand/domain';
2
+ import { Format, Parameter, ActionObserver, Operand } from '../../shared/domain';
3
+ import { IModelService } from '../../model/domain';
2
4
  export interface IExpressions {
3
5
  get model(): IModelService;
4
6
  get enums(): [string, [string, any][]][];
@@ -6,7 +8,6 @@ export interface IExpressions {
6
8
  get constants(): [string, any][];
7
9
  get operators(): [string, OperatorMetadata][];
8
10
  get functions(): [string, OperatorMetadata][];
9
- operandService: IOperandService;
10
11
  addOperator(sing: string, source: any, additionalInfo: OperatorAdditionalInfo): void;
11
12
  addFunction(sing: string, source: any, additionalInfo?: FunctionAdditionalInfo): void;
12
13
  addOperatorAlias(alias: string, reference: string): void;
@@ -14,15 +15,13 @@ export interface IExpressions {
14
15
  addEnum(key: string, values: [string, any][] | any): void;
15
16
  addFormat(key: string, pattern: string): void;
16
17
  addConstant(key: string, value: any): void;
17
- addOperandBuilder(builder: IOperandBuilder): void;
18
- toExpression(func: Function): string;
19
- graphqlToExpression(graphql: string): [string, any];
18
+ convert(source: any, from: string): [string, any];
20
19
  clone(source: Operand): Operand;
21
20
  build(expression: string, useCache: boolean): Operand;
22
21
  parameters(expression: string): Parameter[];
23
22
  type(expression: string): string;
24
23
  eval(expression: string, data?: any): any;
25
- run(expression: string, data?: any): any;
24
+ evalAsync(expression: string, data?: any): Promise<any>;
26
25
  subscribe(observer: ActionObserver): void;
27
26
  unsubscribe(observer: ActionObserver): void;
28
27
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expressions.js","sourceRoot":"","sources":["../../../../src/lib/expression/domain/expressions.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export * from './expressions';
@@ -14,6 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./helper"), exports);
18
- __exportStar(require("./operandHelper"), exports);
17
+ __exportStar(require("./expressions"), exports);
19
18
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/expression/domain/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA6B"}
@@ -0,0 +1,10 @@
1
+ import { ExpressionConverter } from '../../';
2
+ export declare class ExpressionConvertFromFunction implements ExpressionConverter {
3
+ private operandBuilder;
4
+ /**
5
+ * Convert a lambda expression to a query expression
6
+ * @param lambda lambda expression
7
+ * @returns Expression manager
8
+ */
9
+ convert(func: Function): [string, any];
10
+ }
@@ -0,0 +1,58 @@
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
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ExpressionConvertFromFunction = void 0;
13
+ const __1 = require("../../");
14
+ const domain_1 = require("../../shared/domain");
15
+ const h3lp_1 = require("h3lp");
16
+ let ExpressionConvertFromFunction = class ExpressionConvertFromFunction {
17
+ /**
18
+ * Convert a lambda expression to a query expression
19
+ * @param lambda lambda expression
20
+ * @returns Expression manager
21
+ */
22
+ // eslint-disable-next-line @typescript-eslint/ban-types
23
+ convert(func) {
24
+ if (!func) {
25
+ throw new Error('empty lambda function}');
26
+ }
27
+ const expression = __1.helper.expression.clearLambda(func);
28
+ const operand = this.operandBuilder.build(expression);
29
+ let aux = operand;
30
+ while (aux.type !== domain_1.OperandType.Var) {
31
+ if (aux.children.length > 0) {
32
+ aux = aux.children[0];
33
+ }
34
+ }
35
+ if (aux.name.includes('.')) {
36
+ // Example: __model_1.Products.map(p=>p) => Products.map(p=>p)
37
+ // Example: __model_1.Orders.details.map(p=>p) => Orders.details.map(p=>p)
38
+ const names = aux.name.split('.');
39
+ if (names[0].startsWith('__')) {
40
+ // aux.name = names.slice(1).join('.')
41
+ const result = expression.replace(names[0] + '.', '');
42
+ return [result, undefined];
43
+ }
44
+ }
45
+ // Example: Products.map(p=>p) => Products.map(p=>p)
46
+ // Example: Orders.details.map(p=>p) => Orders.details.map(p=>p)
47
+ return [expression, undefined];
48
+ }
49
+ };
50
+ __decorate([
51
+ (0, h3lp_1.Autowired)('exp.operand.builder.sync'),
52
+ __metadata("design:type", Object)
53
+ ], ExpressionConvertFromFunction.prototype, "operandBuilder", void 0);
54
+ ExpressionConvertFromFunction = __decorate([
55
+ (0, h3lp_1.Service)('exp.expression.converter.fromFunction')
56
+ ], ExpressionConvertFromFunction);
57
+ exports.ExpressionConvertFromFunction = ExpressionConvertFromFunction;
58
+ //# sourceMappingURL=convertFromFunction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertFromFunction.js","sourceRoot":"","sources":["../../../../src/lib/expression/infrastructure/convertFromFunction.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8BAAoD;AAEpD,gDAAiD;AACjD,+BAAyC;AAGlC,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IAIzC;;;;OAIG;IACH,wDAAwD;IACjD,OAAO,CAAE,IAAc;QAC7B,IAAI,CAAC,IAAI,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;SACzC;QACD,MAAM,UAAU,GAAG,UAAM,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;QACtD,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;QACrD,IAAI,GAAG,GAAG,OAAO,CAAA;QACjB,OAAO,GAAG,CAAC,IAAI,KAAK,oBAAW,CAAC,GAAG,EAAE;YACpC,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC5B,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;aACrB;SACD;QACD,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YAC3B,+DAA+D;YAC/D,2EAA2E;YAC3E,MAAM,KAAK,GAAY,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YAC1C,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;gBAC9B,sCAAsC;gBACtC,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,CAAA;gBACrD,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;aAC1B;SACD;QACD,qDAAqD;QACrD,iEAAiE;QACjE,OAAO,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;IAC/B,CAAC;CACD,CAAA;AAnCA;IAAC,IAAA,gBAAS,EAAC,0BAA0B,CAAC;;qEACC;AAF3B,6BAA6B;IADzC,IAAA,cAAO,EAAC,uCAAuC,CAAC;GACpC,6BAA6B,CAoCzC;AApCY,sEAA6B"}
@@ -0,0 +1,4 @@
1
+ import { ExpressionConverter } from '../application';
2
+ export declare class ExpressionConvertFromGraphql implements ExpressionConverter {
3
+ convert(source: any): [string, any];
4
+ }
@@ -1,12 +1,21 @@
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.ExpressionConvertFromGraphql = void 0;
4
10
  const h3lp_1 = require("h3lp");
5
- class ExpressionConvertFromGraphql {
6
- toExpression(graphql) {
7
- return new GraphqlParser(graphql).parse();
11
+ let ExpressionConvertFromGraphql = class ExpressionConvertFromGraphql {
12
+ convert(source) {
13
+ return new GraphqlParser(source).parse();
8
14
  }
9
- }
15
+ };
16
+ ExpressionConvertFromGraphql = __decorate([
17
+ (0, h3lp_1.Service)('exp.expression.converter.fromGraphql')
18
+ ], ExpressionConvertFromGraphql);
10
19
  exports.ExpressionConvertFromGraphql = ExpressionConvertFromGraphql;
11
20
  class GraphqlParser {
12
21
  constructor(source) {
@@ -49,6 +58,7 @@ class GraphqlParser {
49
58
  }
50
59
  }
51
60
  }
61
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
52
62
  readArgs(_break = '') {
53
63
  // while (true) {
54
64
  // const name = this.getName()
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertFromGraphql.js","sourceRoot":"","sources":["../../../../src/lib/expression/infrastructure/convertFromGraphql.ts"],"names":[],"mappings":";;;;;;;;;AACA,+BAAoC;AAI7B,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IACjC,OAAO,CAAE,MAAW;QAC1B,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,CAAA;IACzC,CAAC;CACD,CAAA;AAJY,4BAA4B;IADxC,IAAA,cAAO,EAAC,sCAAsC,CAAC;GACnC,4BAA4B,CAIxC;AAJY,oEAA4B;AAMzC,MAAM,aAAa;IAMlB,YAAa,MAAc;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAA;QAChC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAA;QACd,IAAI,CAAC,UAAU,GAAG,EAAE,CAAA;QACpB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;IAClB,CAAC;IAED,IAAY,GAAG;QACd,OAAO,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,CAAA;IACjC,CAAC;IAED,IAAY,OAAO;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC/B,CAAC;IAEM,KAAK;QACX,IAAI,CAAC,IAAI,EAAE,CAAA;QACX,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;IAChD,CAAC;IAEO,IAAI,CAAE,KAAK,GAAG,CAAC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QACxC,IAAI;QACJ,IAAI;QACJ,wBAAwB;IACzB,CAAC;IAEO,OAAO,CAAE,SAAS,GAAG,IAAI;QAChC,MAAM,IAAI,GAAG,EAAE,CAAA;QACf,IAAI,SAAS,EAAE;YACd,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,WAAI,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;gBAC1D,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;gBACvB,IAAI,CAAC,KAAK,IAAI,CAAC,CAAA;aACf;SACD;aAAM;YACN,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;YACtB,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,WAAI,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE;gBAChE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;gBAC7B,KAAK,IAAI,CAAC,CAAA;aACV;SACD;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACrB,CAAC;IAEO,aAAa;QACpB,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE;YACpD,IAAI,CAAC,KAAK,IAAI,CAAC,CAAA;SACf;IACF,CAAC;CACD"}
@@ -0,0 +1,5 @@
1
+ import { IExpressionHelper } from '../../shared/application';
2
+ export declare class ExpressionHelper implements IExpressionHelper {
3
+ private str;
4
+ clearLambda(func: Function): string;
5
+ }
@@ -0,0 +1,47 @@
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
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ExpressionHelper = void 0;
13
+ const h3lp_1 = require("h3lp");
14
+ let ExpressionHelper = class ExpressionHelper {
15
+ // eslint-disable-next-line @typescript-eslint/ban-types
16
+ clearLambda(func) {
17
+ let str = func.toString().trim();
18
+ let index = str.indexOf('=>') + 2;
19
+ str = str.substring(index, str.length).trim();
20
+ index = str.indexOf('(');
21
+ if (index > -1) {
22
+ // Example: xxx.Products.map()
23
+ const form = str.substring(0, index).trim();
24
+ const parts = form.split('.');
25
+ if (parts.length > 2) {
26
+ return this.str.replace(str, parts[0] + '.', '');
27
+ }
28
+ }
29
+ else {
30
+ // Example: xxx.Products
31
+ const parts = str.split('.');
32
+ if (parts.length > 1) {
33
+ return this.str.replace(str, parts[0] + '.', '');
34
+ }
35
+ }
36
+ return str;
37
+ }
38
+ };
39
+ __decorate([
40
+ (0, h3lp_1.Autowired)('helper.str'),
41
+ __metadata("design:type", Object)
42
+ ], ExpressionHelper.prototype, "str", void 0);
43
+ ExpressionHelper = __decorate([
44
+ (0, h3lp_1.Service)('exp.helper.expression')
45
+ ], ExpressionHelper);
46
+ exports.ExpressionHelper = ExpressionHelper;
47
+ //# sourceMappingURL=helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../../src/lib/expression/infrastructure/helper.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAAwD;AAIjD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAI5B,wDAAwD;IACjD,WAAW,CAA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@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ const h3lp_1 = require("h3lp");
18
+ const application_1 = require("../application");
19
+ h3lp_1.Factory.add('exp.operand.builder.sync', new application_1.OperandBuilder('sync'));
20
+ h3lp_1.Factory.add('exp.operand.builder.async', new application_1.OperandBuilder('async'));
17
21
  __exportStar(require("./helper"), exports);
18
- __exportStar(require("./model"), exports);
19
- __exportStar(require("./expression"), exports);
20
- __exportStar(require("./operand"), exports);
21
- __exportStar(require("./ports/expressions"), exports);
22
22
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/expression/infrastructure/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+BAA8B;AAC9B,gDAA+C;AAC/C,cAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,IAAI,4BAAc,CAAC,MAAM,CAAC,CAAC,CAAA;AACnE,cAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,IAAI,4BAAc,CAAC,OAAO,CAAC,CAAC,CAAA;AACrE,2CAAwB"}
@@ -1,8 +1,6 @@
1
- import { IModelService, IOperandBuilder } from '../../domain';
2
1
  export declare class CoreLibrary {
3
- private readonly model;
4
- private readonly builder;
5
- constructor(model: IModelService, builder: IOperandBuilder);
2
+ private builder;
3
+ private model;
6
4
  load(): void;
7
5
  private constants;
8
6
  private enums;