@defra/forms-model 3.0.2

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 (336) hide show
  1. package/LICENCE +8 -0
  2. package/README.md +22 -0
  3. package/dist/browser/components/component-types.d.ts +3 -0
  4. package/dist/browser/components/component-types.d.ts.map +1 -0
  5. package/dist/browser/components/component-types.js +220 -0
  6. package/dist/browser/components/component-types.js.map +1 -0
  7. package/dist/browser/components/conditional-component-types.d.ts +3 -0
  8. package/dist/browser/components/conditional-component-types.d.ts.map +1 -0
  9. package/dist/browser/components/conditional-component-types.js +28 -0
  10. package/dist/browser/components/conditional-component-types.js.map +1 -0
  11. package/dist/browser/components/index.d.ts +4 -0
  12. package/dist/browser/components/index.d.ts.map +1 -0
  13. package/dist/browser/components/index.js +45 -0
  14. package/dist/browser/components/index.js.map +1 -0
  15. package/dist/browser/components/types.d.ts +244 -0
  16. package/dist/browser/components/types.d.ts.map +1 -0
  17. package/dist/browser/components/types.js +56 -0
  18. package/dist/browser/components/types.js.map +1 -0
  19. package/dist/browser/conditions/condition-abstract.d.ts +16 -0
  20. package/dist/browser/conditions/condition-abstract.d.ts.map +1 -0
  21. package/dist/browser/conditions/condition-abstract.js +62 -0
  22. package/dist/browser/conditions/condition-abstract.js.map +1 -0
  23. package/dist/browser/conditions/condition-field.d.ts +13 -0
  24. package/dist/browser/conditions/condition-field.d.ts.map +1 -0
  25. package/dist/browser/conditions/condition-field.js +45 -0
  26. package/dist/browser/conditions/condition-field.js.map +1 -0
  27. package/dist/browser/conditions/condition-group-def.d.ts +10 -0
  28. package/dist/browser/conditions/condition-group-def.d.ts.map +1 -0
  29. package/dist/browser/conditions/condition-group-def.js +45 -0
  30. package/dist/browser/conditions/condition-group-def.js.map +1 -0
  31. package/dist/browser/conditions/condition-group.d.ts +15 -0
  32. package/dist/browser/conditions/condition-group.d.ts.map +1 -0
  33. package/dist/browser/conditions/condition-group.js +64 -0
  34. package/dist/browser/conditions/condition-group.js.map +1 -0
  35. package/dist/browser/conditions/condition-model.d.ts +41 -0
  36. package/dist/browser/conditions/condition-model.d.ts.map +1 -0
  37. package/dist/browser/conditions/condition-model.js +214 -0
  38. package/dist/browser/conditions/condition-model.js.map +1 -0
  39. package/dist/browser/conditions/condition-operators.d.ts +248 -0
  40. package/dist/browser/conditions/condition-operators.d.ts.map +1 -0
  41. package/dist/browser/conditions/condition-operators.js +132 -0
  42. package/dist/browser/conditions/condition-operators.js.map +1 -0
  43. package/dist/browser/conditions/condition-ref.d.ts +12 -0
  44. package/dist/browser/conditions/condition-ref.d.ts.map +1 -0
  45. package/dist/browser/conditions/condition-ref.js +51 -0
  46. package/dist/browser/conditions/condition-ref.js.map +1 -0
  47. package/dist/browser/conditions/condition-value-abstract.d.ts +8 -0
  48. package/dist/browser/conditions/condition-value-abstract.d.ts.map +1 -0
  49. package/dist/browser/conditions/condition-value-abstract.js +41 -0
  50. package/dist/browser/conditions/condition-value-abstract.js.map +1 -0
  51. package/dist/browser/conditions/condition-value-registration.d.ts +10 -0
  52. package/dist/browser/conditions/condition-value-registration.d.ts.map +1 -0
  53. package/dist/browser/conditions/condition-value-registration.js +37 -0
  54. package/dist/browser/conditions/condition-value-registration.js.map +1 -0
  55. package/dist/browser/conditions/condition-values.d.ts +38 -0
  56. package/dist/browser/conditions/condition-values.d.ts.map +1 -0
  57. package/dist/browser/conditions/condition-values.js +127 -0
  58. package/dist/browser/conditions/condition-values.js.map +1 -0
  59. package/dist/browser/conditions/condition.d.ts +15 -0
  60. package/dist/browser/conditions/condition.d.ts.map +1 -0
  61. package/dist/browser/conditions/condition.js +56 -0
  62. package/dist/browser/conditions/condition.js.map +1 -0
  63. package/dist/browser/conditions/helpers.d.ts +3 -0
  64. package/dist/browser/conditions/helpers.d.ts.map +1 -0
  65. package/dist/browser/conditions/helpers.js +26 -0
  66. package/dist/browser/conditions/helpers.js.map +1 -0
  67. package/dist/browser/conditions/index.d.ts +11 -0
  68. package/dist/browser/conditions/index.d.ts.map +1 -0
  69. package/dist/browser/conditions/index.js +144 -0
  70. package/dist/browser/conditions/index.js.map +1 -0
  71. package/dist/browser/conditions/inline-condition-model.d.ts +86 -0
  72. package/dist/browser/conditions/inline-condition-model.d.ts.map +1 -0
  73. package/dist/browser/conditions/inline-condition-model.js +418 -0
  74. package/dist/browser/conditions/inline-condition-model.js.map +1 -0
  75. package/dist/browser/conditions/inline-condition-operators.d.ts +175 -0
  76. package/dist/browser/conditions/inline-condition-operators.d.ts.map +1 -0
  77. package/dist/browser/conditions/inline-condition-operators.js +132 -0
  78. package/dist/browser/conditions/inline-condition-operators.js.map +1 -0
  79. package/dist/browser/conditions/inline-condition-values.d.ts +93 -0
  80. package/dist/browser/conditions/inline-condition-values.d.ts.map +1 -0
  81. package/dist/browser/conditions/inline-condition-values.js +159 -0
  82. package/dist/browser/conditions/inline-condition-values.js.map +1 -0
  83. package/dist/browser/conditions/types.d.ts +38 -0
  84. package/dist/browser/conditions/types.d.ts.map +1 -0
  85. package/dist/browser/conditions/types.js +24 -0
  86. package/dist/browser/conditions/types.js.map +1 -0
  87. package/dist/browser/data-model/conditions-wrapper.d.ts +19 -0
  88. package/dist/browser/data-model/conditions-wrapper.d.ts.map +1 -0
  89. package/dist/browser/data-model/conditions-wrapper.js +49 -0
  90. package/dist/browser/data-model/conditions-wrapper.js.map +1 -0
  91. package/dist/browser/data-model/index.d.ts +4 -0
  92. package/dist/browser/data-model/index.d.ts.map +1 -0
  93. package/dist/browser/data-model/index.js +66 -0
  94. package/dist/browser/data-model/index.js.map +1 -0
  95. package/dist/browser/data-model/input-wrapper.d.ts +16 -0
  96. package/dist/browser/data-model/input-wrapper.d.ts.map +1 -0
  97. package/dist/browser/data-model/input-wrapper.js +49 -0
  98. package/dist/browser/data-model/input-wrapper.js.map +1 -0
  99. package/dist/browser/data-model/types.d.ts +153 -0
  100. package/dist/browser/data-model/types.d.ts.map +1 -0
  101. package/dist/browser/data-model/types.js +34 -0
  102. package/dist/browser/data-model/types.js.map +1 -0
  103. package/dist/browser/form/form-configuration.d.ts +8 -0
  104. package/dist/browser/form/form-configuration.d.ts.map +1 -0
  105. package/dist/browser/form/form-configuration.js +38 -0
  106. package/dist/browser/form/form-configuration.js.map +1 -0
  107. package/dist/browser/form/index.d.ts +2 -0
  108. package/dist/browser/form/index.d.ts.map +1 -0
  109. package/dist/browser/form/index.js +24 -0
  110. package/dist/browser/form/index.js.map +1 -0
  111. package/dist/browser/index.d.ts +12 -0
  112. package/dist/browser/index.d.ts.map +1 -0
  113. package/dist/browser/index.js +138 -0
  114. package/dist/browser/index.js.map +1 -0
  115. package/dist/browser/migration/index.d.ts +2 -0
  116. package/dist/browser/migration/index.d.ts.map +1 -0
  117. package/dist/browser/migration/index.js +24 -0
  118. package/dist/browser/migration/index.js.map +1 -0
  119. package/dist/browser/migration/migration.0-2.d.ts +3 -0
  120. package/dist/browser/migration/migration.0-2.d.ts.map +1 -0
  121. package/dist/browser/migration/migration.0-2.js +65 -0
  122. package/dist/browser/migration/migration.0-2.js.map +1 -0
  123. package/dist/browser/migration/migration.1-2.d.ts +3 -0
  124. package/dist/browser/migration/migration.1-2.d.ts.map +1 -0
  125. package/dist/browser/migration/migration.1-2.js +108 -0
  126. package/dist/browser/migration/migration.1-2.js.map +1 -0
  127. package/dist/browser/migration/types.d.ts +2 -0
  128. package/dist/browser/migration/types.d.ts.map +1 -0
  129. package/dist/browser/migration/types.js +16 -0
  130. package/dist/browser/migration/types.js.map +1 -0
  131. package/dist/browser/migration/whichMigrations.d.ts +7 -0
  132. package/dist/browser/migration/whichMigrations.d.ts.map +1 -0
  133. package/dist/browser/migration/whichMigrations.js +38 -0
  134. package/dist/browser/migration/whichMigrations.js.map +1 -0
  135. package/dist/browser/schema/index.d.ts +2 -0
  136. package/dist/browser/schema/index.d.ts.map +1 -0
  137. package/dist/browser/schema/index.js +30 -0
  138. package/dist/browser/schema/index.js.map +1 -0
  139. package/dist/browser/schema/schema.d.ts +20 -0
  140. package/dist/browser/schema/schema.d.ts.map +1 -0
  141. package/dist/browser/schema/schema.js +255 -0
  142. package/dist/browser/schema/schema.js.map +1 -0
  143. package/dist/browser/utils/helpers.d.ts +9 -0
  144. package/dist/browser/utils/helpers.d.ts.map +1 -0
  145. package/dist/browser/utils/helpers.js +48 -0
  146. package/dist/browser/utils/helpers.js.map +1 -0
  147. package/dist/browser/utils/logger.d.ts +11 -0
  148. package/dist/browser/utils/logger.d.ts.map +1 -0
  149. package/dist/browser/utils/logger.js +46 -0
  150. package/dist/browser/utils/logger.js.map +1 -0
  151. package/dist/module/components/component-types.d.ts +3 -0
  152. package/dist/module/components/component-types.d.ts.map +1 -0
  153. package/dist/module/components/component-types.js +206 -0
  154. package/dist/module/components/component-types.js.map +1 -0
  155. package/dist/module/components/conditional-component-types.d.ts +3 -0
  156. package/dist/module/components/conditional-component-types.d.ts.map +1 -0
  157. package/dist/module/components/conditional-component-types.js +14 -0
  158. package/dist/module/components/conditional-component-types.js.map +1 -0
  159. package/dist/module/components/index.d.ts +4 -0
  160. package/dist/module/components/index.d.ts.map +1 -0
  161. package/dist/module/components/index.js +34 -0
  162. package/dist/module/components/index.js.map +1 -0
  163. package/dist/module/components/types.d.ts +244 -0
  164. package/dist/module/components/types.d.ts.map +1 -0
  165. package/dist/module/components/types.js +42 -0
  166. package/dist/module/components/types.js.map +1 -0
  167. package/dist/module/conditions/condition-abstract.d.ts +16 -0
  168. package/dist/module/conditions/condition-abstract.d.ts.map +1 -0
  169. package/dist/module/conditions/condition-abstract.js +45 -0
  170. package/dist/module/conditions/condition-abstract.js.map +1 -0
  171. package/dist/module/conditions/condition-field.d.ts +13 -0
  172. package/dist/module/conditions/condition-field.d.ts.map +1 -0
  173. package/dist/module/conditions/condition-field.js +26 -0
  174. package/dist/module/conditions/condition-field.js.map +1 -0
  175. package/dist/module/conditions/condition-group-def.d.ts +10 -0
  176. package/dist/module/conditions/condition-group-def.d.ts.map +1 -0
  177. package/dist/module/conditions/condition-group-def.js +26 -0
  178. package/dist/module/conditions/condition-group-def.js.map +1 -0
  179. package/dist/module/conditions/condition-group.d.ts +15 -0
  180. package/dist/module/conditions/condition-group.d.ts.map +1 -0
  181. package/dist/module/conditions/condition-group.js +47 -0
  182. package/dist/module/conditions/condition-group.js.map +1 -0
  183. package/dist/module/conditions/condition-model.d.ts +41 -0
  184. package/dist/module/conditions/condition-model.d.ts.map +1 -0
  185. package/dist/module/conditions/condition-model.js +199 -0
  186. package/dist/module/conditions/condition-model.js.map +1 -0
  187. package/dist/module/conditions/condition-operators.d.ts +248 -0
  188. package/dist/module/conditions/condition-operators.d.ts.map +1 -0
  189. package/dist/module/conditions/condition-operators.js +119 -0
  190. package/dist/module/conditions/condition-operators.js.map +1 -0
  191. package/dist/module/conditions/condition-ref.d.ts +12 -0
  192. package/dist/module/conditions/condition-ref.d.ts.map +1 -0
  193. package/dist/module/conditions/condition-ref.js +33 -0
  194. package/dist/module/conditions/condition-ref.js.map +1 -0
  195. package/dist/module/conditions/condition-value-abstract.d.ts +8 -0
  196. package/dist/module/conditions/condition-value-abstract.d.ts.map +1 -0
  197. package/dist/module/conditions/condition-value-abstract.js +24 -0
  198. package/dist/module/conditions/condition-value-abstract.js.map +1 -0
  199. package/dist/module/conditions/condition-value-registration.d.ts +10 -0
  200. package/dist/module/conditions/condition-value-registration.d.ts.map +1 -0
  201. package/dist/module/conditions/condition-value-registration.js +19 -0
  202. package/dist/module/conditions/condition-value-registration.js.map +1 -0
  203. package/dist/module/conditions/condition-values.d.ts +38 -0
  204. package/dist/module/conditions/condition-values.d.ts.map +1 -0
  205. package/dist/module/conditions/condition-values.js +106 -0
  206. package/dist/module/conditions/condition-values.js.map +1 -0
  207. package/dist/module/conditions/condition.d.ts +15 -0
  208. package/dist/module/conditions/condition.d.ts.map +1 -0
  209. package/dist/module/conditions/condition.js +40 -0
  210. package/dist/module/conditions/condition.js.map +1 -0
  211. package/dist/module/conditions/helpers.d.ts +3 -0
  212. package/dist/module/conditions/helpers.d.ts.map +1 -0
  213. package/dist/module/conditions/helpers.js +12 -0
  214. package/dist/module/conditions/helpers.js.map +1 -0
  215. package/dist/module/conditions/index.d.ts +11 -0
  216. package/dist/module/conditions/index.d.ts.map +1 -0
  217. package/dist/module/conditions/index.js +140 -0
  218. package/dist/module/conditions/index.js.map +1 -0
  219. package/dist/module/conditions/inline-condition-model.d.ts +86 -0
  220. package/dist/module/conditions/inline-condition-model.d.ts.map +1 -0
  221. package/dist/module/conditions/inline-condition-model.js +384 -0
  222. package/dist/module/conditions/inline-condition-model.js.map +1 -0
  223. package/dist/module/conditions/inline-condition-operators.d.ts +175 -0
  224. package/dist/module/conditions/inline-condition-operators.d.ts.map +1 -0
  225. package/dist/module/conditions/inline-condition-operators.js +119 -0
  226. package/dist/module/conditions/inline-condition-operators.js.map +1 -0
  227. package/dist/module/conditions/inline-condition-values.d.ts +93 -0
  228. package/dist/module/conditions/inline-condition-values.d.ts.map +1 -0
  229. package/dist/module/conditions/inline-condition-values.js +134 -0
  230. package/dist/module/conditions/inline-condition-values.js.map +1 -0
  231. package/dist/module/conditions/types.d.ts +38 -0
  232. package/dist/module/conditions/types.d.ts.map +1 -0
  233. package/dist/module/conditions/types.js +10 -0
  234. package/dist/module/conditions/types.js.map +1 -0
  235. package/dist/module/data-model/conditions-wrapper.d.ts +19 -0
  236. package/dist/module/data-model/conditions-wrapper.d.ts.map +1 -0
  237. package/dist/module/data-model/conditions-wrapper.js +30 -0
  238. package/dist/module/data-model/conditions-wrapper.js.map +1 -0
  239. package/dist/module/data-model/index.d.ts +4 -0
  240. package/dist/module/data-model/index.d.ts.map +1 -0
  241. package/dist/module/data-model/index.js +55 -0
  242. package/dist/module/data-model/index.js.map +1 -0
  243. package/dist/module/data-model/input-wrapper.d.ts +16 -0
  244. package/dist/module/data-model/input-wrapper.d.ts.map +1 -0
  245. package/dist/module/data-model/input-wrapper.js +25 -0
  246. package/dist/module/data-model/input-wrapper.js.map +1 -0
  247. package/dist/module/data-model/types.d.ts +153 -0
  248. package/dist/module/data-model/types.d.ts.map +1 -0
  249. package/dist/module/data-model/types.js +20 -0
  250. package/dist/module/data-model/types.js.map +1 -0
  251. package/dist/module/form/form-configuration.d.ts +8 -0
  252. package/dist/module/form/form-configuration.d.ts.map +1 -0
  253. package/dist/module/form/form-configuration.js +17 -0
  254. package/dist/module/form/form-configuration.js.map +1 -0
  255. package/dist/module/form/index.d.ts +2 -0
  256. package/dist/module/form/index.d.ts.map +1 -0
  257. package/dist/module/form/index.js +11 -0
  258. package/dist/module/form/index.js.map +1 -0
  259. package/dist/module/index.d.ts +12 -0
  260. package/dist/module/index.d.ts.map +1 -0
  261. package/dist/module/index.js +135 -0
  262. package/dist/module/index.js.map +1 -0
  263. package/dist/module/migration/index.d.ts +2 -0
  264. package/dist/module/migration/index.d.ts.map +1 -0
  265. package/dist/module/migration/index.js +11 -0
  266. package/dist/module/migration/index.js.map +1 -0
  267. package/dist/module/migration/migration.0-2.d.ts +3 -0
  268. package/dist/module/migration/migration.0-2.d.ts.map +1 -0
  269. package/dist/module/migration/migration.0-2.js +42 -0
  270. package/dist/module/migration/migration.0-2.js.map +1 -0
  271. package/dist/module/migration/migration.1-2.d.ts +3 -0
  272. package/dist/module/migration/migration.1-2.d.ts.map +1 -0
  273. package/dist/module/migration/migration.1-2.js +90 -0
  274. package/dist/module/migration/migration.1-2.js.map +1 -0
  275. package/dist/module/migration/types.d.ts +2 -0
  276. package/dist/module/migration/types.d.ts.map +1 -0
  277. package/dist/module/migration/types.js +1 -0
  278. package/dist/module/migration/types.js.map +1 -0
  279. package/dist/module/migration/whichMigrations.d.ts +7 -0
  280. package/dist/module/migration/whichMigrations.d.ts.map +1 -0
  281. package/dist/module/migration/whichMigrations.js +26 -0
  282. package/dist/module/migration/whichMigrations.js.map +1 -0
  283. package/dist/module/schema/index.d.ts +2 -0
  284. package/dist/module/schema/index.d.ts.map +1 -0
  285. package/dist/module/schema/index.js +17 -0
  286. package/dist/module/schema/index.js.map +1 -0
  287. package/dist/module/schema/schema.d.ts +20 -0
  288. package/dist/module/schema/schema.d.ts.map +1 -0
  289. package/dist/module/schema/schema.js +239 -0
  290. package/dist/module/schema/schema.js.map +1 -0
  291. package/dist/module/utils/helpers.d.ts +9 -0
  292. package/dist/module/utils/helpers.d.ts.map +1 -0
  293. package/dist/module/utils/helpers.js +35 -0
  294. package/dist/module/utils/helpers.js.map +1 -0
  295. package/dist/module/utils/logger.d.ts +11 -0
  296. package/dist/module/utils/logger.d.ts.map +1 -0
  297. package/dist/module/utils/logger.js +27 -0
  298. package/dist/module/utils/logger.js.map +1 -0
  299. package/package.json +35 -0
  300. package/src/components/component-types.ts +229 -0
  301. package/src/components/conditional-component-types.ts +14 -0
  302. package/src/components/index.ts +3 -0
  303. package/src/components/types.ts +362 -0
  304. package/src/conditions/condition-abstract.ts +59 -0
  305. package/src/conditions/condition-field.ts +29 -0
  306. package/src/conditions/condition-group-def.ts +29 -0
  307. package/src/conditions/condition-group.ts +61 -0
  308. package/src/conditions/condition-model.ts +314 -0
  309. package/src/conditions/condition-operators.ts +176 -0
  310. package/src/conditions/condition-ref.ts +47 -0
  311. package/src/conditions/condition-value-abstract.ts +31 -0
  312. package/src/conditions/condition-value-registration.ts +18 -0
  313. package/src/conditions/condition-values.ts +146 -0
  314. package/src/conditions/condition.ts +64 -0
  315. package/src/conditions/helpers.ts +7 -0
  316. package/src/conditions/index.ts +27 -0
  317. package/src/conditions/inline-condition-model.ts +550 -0
  318. package/src/conditions/inline-condition-operators.ts +166 -0
  319. package/src/conditions/inline-condition-values.ts +153 -0
  320. package/src/conditions/types.ts +30 -0
  321. package/src/data-model/conditions-wrapper.ts +42 -0
  322. package/src/data-model/index.ts +3 -0
  323. package/src/data-model/input-wrapper.ts +40 -0
  324. package/src/data-model/types.ts +179 -0
  325. package/src/form/form-configuration.ts +21 -0
  326. package/src/form/index.ts +1 -0
  327. package/src/index.ts +11 -0
  328. package/src/migration/index.ts +1 -0
  329. package/src/migration/migration.0-2.ts +29 -0
  330. package/src/migration/migration.1-2.ts +105 -0
  331. package/src/migration/types.ts +1 -0
  332. package/src/migration/whichMigrations.ts +23 -0
  333. package/src/schema/index.ts +1 -0
  334. package/src/schema/schema.ts +300 -0
  335. package/src/utils/helpers.ts +37 -0
  336. package/src/utils/logger.ts +29 -0
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.customOperators = exports.absoluteDateOrTimeOperatorNames = void 0;
5
+ exports.getExpression = getExpression;
6
+ exports.getOperatorConfig = getOperatorConfig;
7
+ exports.getOperatorNames = getOperatorNames;
8
+ exports.relativeDateOrTimeOperatorNames = void 0;
9
+ var _conditionValues = require("./condition-values");
10
+ const defaultOperators = {
11
+ is: inline('=='),
12
+ 'is not': inline('!=')
13
+ };
14
+ function withDefaults(param) {
15
+ return Object.assign({}, param, defaultOperators);
16
+ }
17
+ const textBasedFieldCustomisations = {
18
+ 'is longer than': lengthIs('>'),
19
+ 'is shorter than': lengthIs('<'),
20
+ 'has length': lengthIs('==')
21
+ };
22
+ const absoluteDateTimeOperators = {
23
+ is: absoluteDateTime('=='),
24
+ 'is not': absoluteDateTime('!='),
25
+ 'is before': absoluteDateTime('<'),
26
+ 'is after': absoluteDateTime('>')
27
+ };
28
+ const relativeTimeOperators = units => ({
29
+ 'is at least': relativeTime('<=', '>=', units),
30
+ 'is at most': relativeTime('>=', '<=', units),
31
+ 'is less than': relativeTime('>', '<', units),
32
+ 'is more than': relativeTime('<', '>', units)
33
+ });
34
+ const customOperators = exports.customOperators = {
35
+ CheckboxesField: {
36
+ contains: reverseInline('in'),
37
+ 'does not contain': not(reverseInline('in'))
38
+ },
39
+ NumberField: withDefaults({
40
+ 'is at least': inline('>='),
41
+ 'is at most': inline('<='),
42
+ 'is less than': inline('<'),
43
+ 'is more than': inline('>')
44
+ }),
45
+ DateField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(_conditionValues.dateUnits)),
46
+ TimeField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(_conditionValues.timeUnits)),
47
+ DatePartsField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(_conditionValues.dateUnits)),
48
+ DateTimeField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(_conditionValues.dateTimeUnits)),
49
+ DateTimePartsField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(_conditionValues.dateTimeUnits)),
50
+ TextField: withDefaults(textBasedFieldCustomisations),
51
+ MultilineTextField: withDefaults(textBasedFieldCustomisations),
52
+ EmailAddressField: withDefaults(textBasedFieldCustomisations)
53
+ };
54
+ function getOperatorNames(fieldType) {
55
+ return Object.keys(getConditionals(fieldType)).sort();
56
+ }
57
+ function getExpression(fieldType, fieldName, operator, value) {
58
+ return getConditionals(fieldType)[operator].expression({
59
+ type: fieldType,
60
+ name: fieldName
61
+ }, value);
62
+ }
63
+ function getOperatorConfig(fieldType, operator) {
64
+ return getConditionals(fieldType)[operator];
65
+ }
66
+ function getConditionals(fieldType) {
67
+ return customOperators[fieldType] || defaultOperators;
68
+ }
69
+ function inline(operator) {
70
+ return {
71
+ expression: (field, value) => `${field.name} ${operator} ${formatValue(field.type, value.value)}`
72
+ };
73
+ }
74
+ function lengthIs(operator) {
75
+ return {
76
+ expression: (field, value) => `length(${field.name}) ${operator} ${value.value}`
77
+ };
78
+ }
79
+ function reverseInline(operator) {
80
+ return {
81
+ expression: (field, value) => `${formatValue(field.type, value.value)} ${operator} ${field.name}`
82
+ };
83
+ }
84
+ function not(operatorDefinition) {
85
+ return {
86
+ expression: (field, value) => `not (${operatorDefinition.expression(field, value)})`
87
+ };
88
+ }
89
+ function formatValue(fieldType, value) {
90
+ if (fieldType === 'NumberField' || fieldType === 'YesNoField') {
91
+ return value;
92
+ }
93
+ return `'${value}'`;
94
+ }
95
+ const absoluteDateOrTimeOperatorNames = exports.absoluteDateOrTimeOperatorNames = Object.keys(absoluteDateTimeOperators);
96
+ const relativeDateOrTimeOperatorNames = exports.relativeDateOrTimeOperatorNames = Object.keys(relativeTimeOperators(_conditionValues.dateTimeUnits));
97
+ function absoluteDateTime(operator) {
98
+ return {
99
+ expression: (field, value) => {
100
+ if (value instanceof _conditionValues.ConditionValue) {
101
+ return `${field.name} ${operator} '${value.toExpression()}'`;
102
+ }
103
+ throw Error('only Value types are supported');
104
+ }
105
+ };
106
+ }
107
+ function relativeTime(pastOperator, futureOperator, units) {
108
+ return {
109
+ units,
110
+ expression: (field, value) => {
111
+ if (value instanceof _conditionValues.RelativeTimeValue) {
112
+ const operator = value.direction === _conditionValues.DateDirections.PAST ? pastOperator : futureOperator;
113
+ return `${field.name} ${operator} ${value.toExpression()}`;
114
+ }
115
+ throw Error('time shift requires a TimeShiftValue');
116
+ }
117
+ };
118
+ }
119
+ //# sourceMappingURL=condition-operators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"condition-operators.js","names":["_conditionValues","require","defaultOperators","is","inline","withDefaults","param","Object","assign","textBasedFieldCustomisations","lengthIs","absoluteDateTimeOperators","absoluteDateTime","relativeTimeOperators","units","relativeTime","customOperators","exports","CheckboxesField","contains","reverseInline","not","NumberField","DateField","dateUnits","TimeField","timeUnits","DatePartsField","DateTimeField","dateTimeUnits","DateTimePartsField","TextField","MultilineTextField","EmailAddressField","getOperatorNames","fieldType","keys","getConditionals","sort","getExpression","fieldName","operator","value","expression","type","name","getOperatorConfig","field","formatValue","operatorDefinition","absoluteDateOrTimeOperatorNames","relativeDateOrTimeOperatorNames","ConditionValue","toExpression","Error","pastOperator","futureOperator","RelativeTimeValue","direction","DateDirections","PAST"],"sources":["../../../src/conditions/condition-operators.ts"],"sourcesContent":["import { ComponentType, ComponentDef } from '../components'\nimport { ConditionValueAbstract } from './condition-value-abstract'\n\nimport {\n timeUnits,\n dateUnits,\n dateTimeUnits,\n ConditionValue,\n DateDirections,\n RelativeTimeValue\n} from './condition-values'\n\ntype Operator = '==' | '!=' | '>=' | '<=' | '<' | '>'\n\nconst defaultOperators = {\n is: inline('=='),\n 'is not': inline('!=')\n}\n\nfunction withDefaults<T>(param: T) {\n return Object.assign({}, param, defaultOperators)\n}\n\nconst textBasedFieldCustomisations = {\n 'is longer than': lengthIs('>'),\n 'is shorter than': lengthIs('<'),\n 'has length': lengthIs('==')\n}\n\nconst absoluteDateTimeOperators = {\n is: absoluteDateTime('=='),\n 'is not': absoluteDateTime('!='),\n 'is before': absoluteDateTime('<'),\n 'is after': absoluteDateTime('>')\n}\n\nconst relativeTimeOperators = (units) => ({\n 'is at least': relativeTime('<=', '>=', units),\n 'is at most': relativeTime('>=', '<=', units),\n 'is less than': relativeTime('>', '<', units),\n 'is more than': relativeTime('<', '>', units)\n})\n\nexport const customOperators = {\n CheckboxesField: {\n contains: reverseInline('in'),\n 'does not contain': not(reverseInline('in'))\n },\n NumberField: withDefaults({\n 'is at least': inline('>='),\n 'is at most': inline('<='),\n 'is less than': inline('<'),\n 'is more than': inline('>')\n }),\n DateField: Object.assign(\n {},\n absoluteDateTimeOperators,\n relativeTimeOperators(dateUnits)\n ),\n TimeField: Object.assign(\n {},\n absoluteDateTimeOperators,\n relativeTimeOperators(timeUnits)\n ),\n DatePartsField: Object.assign(\n {},\n absoluteDateTimeOperators,\n relativeTimeOperators(dateUnits)\n ),\n DateTimeField: Object.assign(\n {},\n absoluteDateTimeOperators,\n relativeTimeOperators(dateTimeUnits)\n ),\n DateTimePartsField: Object.assign(\n {},\n absoluteDateTimeOperators,\n relativeTimeOperators(dateTimeUnits)\n ),\n TextField: withDefaults(textBasedFieldCustomisations),\n MultilineTextField: withDefaults(textBasedFieldCustomisations),\n EmailAddressField: withDefaults(textBasedFieldCustomisations)\n}\n\nexport function getOperatorNames(fieldType) {\n return Object.keys(getConditionals(fieldType)).sort()\n}\n\nexport function getExpression(\n fieldType: ComponentType,\n fieldName: string,\n operator: string,\n value: ConditionValueAbstract\n) {\n return getConditionals(fieldType)[operator].expression(\n { type: fieldType, name: fieldName },\n value\n )\n}\n\nexport function getOperatorConfig(fieldType: ComponentType, operator) {\n return getConditionals(fieldType)[operator]\n}\n\nfunction getConditionals(fieldType: ComponentType) {\n return customOperators[fieldType] || defaultOperators\n}\n\nfunction inline(operator: Operator) {\n return {\n expression: (field: ComponentDef, value) =>\n `${field.name} ${operator} ${formatValue(field.type, value.value)}`\n }\n}\n\nfunction lengthIs(operator: Operator) {\n return {\n expression: (field: ComponentDef, value) =>\n `length(${field.name}) ${operator} ${value.value}`\n }\n}\n\nfunction reverseInline(operator: 'in') {\n return {\n expression: (field: ComponentDef, value) =>\n `${formatValue(field.type, value.value)} ${operator} ${field.name}`\n }\n}\n\nfunction not(operatorDefinition) {\n return {\n expression: (field: ComponentDef, value) =>\n `not (${operatorDefinition.expression(field, value)})`\n }\n}\n\nfunction formatValue(fieldType: ComponentType, value) {\n if (fieldType === 'NumberField' || fieldType === 'YesNoField') {\n return value\n }\n return `'${value}'`\n}\n\nexport const absoluteDateOrTimeOperatorNames = Object.keys(\n absoluteDateTimeOperators\n)\nexport const relativeDateOrTimeOperatorNames = Object.keys(\n relativeTimeOperators(dateTimeUnits)\n)\n\nfunction absoluteDateTime(operator: Operator) {\n return {\n expression: (field: ComponentDef, value) => {\n if (value instanceof ConditionValue) {\n return `${field.name} ${operator} '${value.toExpression()}'`\n }\n throw Error('only Value types are supported')\n }\n }\n}\n\nfunction relativeTime(pastOperator, futureOperator, units) {\n return {\n units,\n expression: (field: ComponentDef, value) => {\n if (value instanceof RelativeTimeValue) {\n const operator =\n value.direction === DateDirections.PAST\n ? pastOperator\n : futureOperator\n return `${field.name} ${operator} ${value.toExpression()}`\n }\n throw Error('time shift requires a TimeShiftValue')\n }\n }\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,gBAAA,GAAAC,OAAA;AAWA,MAAMC,gBAAgB,GAAG;EACvBC,EAAE,EAAEC,MAAM,CAAC,IAAI,CAAC;EAChB,QAAQ,EAAEA,MAAM,CAAC,IAAI;AACvB,CAAC;AAED,SAASC,YAAYA,CAAIC,KAAQ,EAAE;EACjC,OAAOC,MAAM,CAACC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M,CAAC6B,IAAI,CACxDvB,qBAAqB,CAACgB,8BAAa,CACrC,CAAC;AAED,SAASjB,gBAAgBA,CAAC6B,QAAkB,EAAE;EAC5C,OAAO;IACLE,UAAU,EAAEA,CAACI,KAAmB,EAAEL,KAAK,KAAK;MAC1C,IAAIA,KAAK,YAAYU,+BAAc,EAAE;QACnC,OAAQ,GAAEL,KAAK,CAACF,IAAK,IAAGJ,QAAS,KAAIC,KAAK,CAACW,YAAY,CAAC,CAAE,GAAE;MAC9D;MACA,MAAMC,KAAK,CAAC,gCAAgC,CAAC;IAC/C;EACF,CAAC;AACH;AAEA,SAASvC,YAAYA,CAACwC,YAAY,EAAEC,cAAc,EAAE1C,KAAK,EAAE;EACzD,OAAO;IACLA,KAAK;IACL6B,UAAU,EAAEA,CAACI,KAAmB,EAAEL,KAAK,KAAK;MAC1C,IAAIA,KAAK,YAAYe,kCAAiB,EAAE;QACtC,MAAMhB,QAAQ,GACZC,KAAK,CAACgB,SAAS,KAAKC,+BAAc,CAACC,IAAI,GACnCL,YAAY,GACZC,cAAc;QACpB,OAAQ,GAAET,KAAK,CAACF,IAAK,IAAGJ,QAAS,IAAGC,KAAK,CAACW,YAAY,CAAC,CAAE,EAAC;MAC5D;MACA,MAAMC,KAAK,CAAC,sCAAsC,CAAC;IACrD;EACF,CAAC;AACH"}
@@ -0,0 +1,12 @@
1
+ import { ConditionAbstract } from './condition-abstract';
2
+ import { Coordinator } from './types';
3
+ export declare class ConditionRef extends ConditionAbstract {
4
+ conditionName: string;
5
+ conditionDisplayName: string;
6
+ constructor(conditionName: string, conditionDisplayName: string, coordinator: Coordinator | undefined);
7
+ asFirstCondition(): this;
8
+ conditionString(): string;
9
+ conditionExpression(): string;
10
+ clone(): ConditionRef;
11
+ }
12
+ //# sourceMappingURL=condition-ref.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"condition-ref.d.ts","sourceRoot":"","sources":["../../../src/conditions/condition-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAErC,qBAAa,YAAa,SAAQ,iBAAiB;IACjD,aAAa,EAAE,MAAM,CAAA;IACrB,oBAAoB,EAAE,MAAM,CAAA;gBAG1B,aAAa,EAAE,MAAM,EACrB,oBAAoB,EAAE,MAAM,EAC5B,WAAW,EAAE,WAAW,GAAG,SAAS;IAgBtC,gBAAgB;IAKhB,eAAe;IAIf,mBAAmB;IAInB,KAAK;CAON"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.ConditionRef = void 0;
5
+ var _conditionAbstract = require("./condition-abstract");
6
+ class ConditionRef extends _conditionAbstract.ConditionAbstract {
7
+ constructor(conditionName, conditionDisplayName, coordinator) {
8
+ super(coordinator);
9
+ if (typeof conditionName !== 'string') {
10
+ throw Error(`condition name ${conditionName} is not valid`);
11
+ }
12
+ if (typeof conditionDisplayName !== 'string') {
13
+ throw Error(`condition display name ${conditionDisplayName} is not valid`);
14
+ }
15
+ this.conditionName = conditionName;
16
+ this.conditionDisplayName = conditionDisplayName;
17
+ }
18
+ asFirstCondition() {
19
+ this._asFirstCondition();
20
+ return this;
21
+ }
22
+ conditionString() {
23
+ return `'${this.conditionDisplayName}'`;
24
+ }
25
+ conditionExpression() {
26
+ return this.conditionName;
27
+ }
28
+ clone() {
29
+ return new ConditionRef(this.conditionName, this.conditionDisplayName, this.coordinator);
30
+ }
31
+ }
32
+ exports.ConditionRef = ConditionRef;
33
+ //# sourceMappingURL=condition-ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"condition-ref.js","names":["_conditionAbstract","require","ConditionRef","ConditionAbstract","constructor","conditionName","conditionDisplayName","coordinator","Error","asFirstCondition","_asFirstCondition","conditionString","conditionExpression","clone","exports"],"sources":["../../../src/conditions/condition-ref.ts"],"sourcesContent":["import { ConditionAbstract } from './condition-abstract'\nimport { Coordinator } from './types'\n\nexport class ConditionRef extends ConditionAbstract {\n conditionName: string\n conditionDisplayName: string\n\n constructor(\n conditionName: string,\n conditionDisplayName: string,\n coordinator: Coordinator | undefined\n ) {\n super(coordinator)\n\n if (typeof conditionName !== 'string') {\n throw Error(`condition name ${conditionName} is not valid`)\n }\n\n if (typeof conditionDisplayName !== 'string') {\n throw Error(`condition display name ${conditionDisplayName} is not valid`)\n }\n\n this.conditionName = conditionName\n this.conditionDisplayName = conditionDisplayName\n }\n\n asFirstCondition() {\n this._asFirstCondition()\n return this\n }\n\n conditionString() {\n return `'${this.conditionDisplayName}'`\n }\n\n conditionExpression() {\n return this.conditionName\n }\n\n clone() {\n return new ConditionRef(\n this.conditionName,\n this.conditionDisplayName,\n this.coordinator\n )\n }\n}\n"],"mappings":";;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AAGO,MAAMC,YAAY,SAASC,oCAAiB,CAAC;EAIlDC,WAAWA,CACTC,aAAqB,EACrBC,oBAA4B,EAC5BC,WAAoC,EACpC;IACA,KAAK,CAACA,WAAW,CAAC;IAElB,IAAI,OAAOF,aAAa,KAAK,QAAQ,EAAE;MACrC,MAAMG,KAAK,CAAE,kBAAiBH,aAAc,eAAc,CAAC;IAC7D;IAEA,IAAI,OAAOC,oBAAoB,KAAK,QAAQ,EAAE;MAC5C,MAAME,KAAK,CAAE,0BAAyBF,oBAAqB,eAAc,CAAC;IAC5E;IAEA,IAAI,CAACD,aAAa,GAAGA,aAAa;IAClC,IAAI,CAACC,oBAAoB,GAAGA,oBAAoB;EAClD;EAEAG,gBAAgBA,CAAA,EAAG;IACjB,IAAI,CAACC,iBAAiB,CAAC,CAAC;IACxB,OAAO,IAAI;EACb;EAEAC,eAAeA,CAAA,EAAG;IAChB,OAAQ,IAAG,IAAI,CAACL,oBAAqB,GAAE;EACzC;EAEAM,mBAAmBA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACP,aAAa;EAC3B;EAEAQ,KAAKA,CAAA,EAAG;IACN,OAAO,IAAIX,YAAY,CACrB,IAAI,CAACG,aAAa,EAClB,IAAI,CAACC,oBAAoB,EACzB,IAAI,CAACC,WACP,CAAC;EACH;AACF;AAACO,OAAA,CAAAZ,YAAA,GAAAA,YAAA"}
@@ -0,0 +1,8 @@
1
+ import { Registration } from './condition-value-registration';
2
+ export declare class ConditionValueAbstract {
3
+ type: string;
4
+ constructor(registration: Registration);
5
+ toPresentationString(): void;
6
+ toExpression(): void;
7
+ }
8
+ //# sourceMappingURL=condition-value-abstract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"condition-value-abstract.d.ts","sourceRoot":"","sources":["../../../src/conditions/condition-value-abstract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAE7D,qBAAa,sBAAsB;IACjC,IAAI,EAAE,MAAM,CAAA;gBAEA,YAAY,EAAE,YAAY;IActC,oBAAoB;IAMpB,YAAY;CAKb"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.ConditionValueAbstract = void 0;
5
+ var _conditionValueRegistration = require("./condition-value-registration");
6
+ class ConditionValueAbstract {
7
+ constructor(registration) {
8
+ if (new.target === ConditionValueAbstract) {
9
+ throw new TypeError('Cannot construct ConditionValue instances directly');
10
+ }
11
+ if (!(registration instanceof _conditionValueRegistration.Registration)) {
12
+ throw new TypeError('You must register your value type! Call registerValueType!');
13
+ }
14
+ this.type = registration.type;
15
+ }
16
+ toPresentationString() {
17
+ throw new Error('Unsupported Operation. Method toPresentationString have not been implemented');
18
+ }
19
+ toExpression() {
20
+ throw new Error('Unsupported Operation. Method toExpression have not been implemented');
21
+ }
22
+ }
23
+ exports.ConditionValueAbstract = ConditionValueAbstract;
24
+ //# sourceMappingURL=condition-value-abstract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"condition-value-abstract.js","names":["_conditionValueRegistration","require","ConditionValueAbstract","constructor","registration","new","target","TypeError","Registration","type","toPresentationString","Error","toExpression","exports"],"sources":["../../../src/conditions/condition-value-abstract.ts"],"sourcesContent":["import { Registration } from './condition-value-registration'\n\nexport class ConditionValueAbstract {\n type: string\n\n constructor(registration: Registration) {\n if (new.target === ConditionValueAbstract) {\n throw new TypeError('Cannot construct ConditionValue instances directly')\n }\n\n if (!(registration instanceof Registration)) {\n throw new TypeError(\n 'You must register your value type! Call registerValueType!'\n )\n }\n\n this.type = registration.type\n }\n\n toPresentationString() {\n throw new Error(\n 'Unsupported Operation. Method toPresentationString have not been implemented'\n )\n }\n\n toExpression() {\n throw new Error(\n 'Unsupported Operation. Method toExpression have not been implemented'\n )\n }\n}\n"],"mappings":";;;;AAAA,IAAAA,2BAAA,GAAAC,OAAA;AAEO,MAAMC,sBAAsB,CAAC;EAGlCC,WAAWA,CAACC,YAA0B,EAAE;IACtC,IAAIC,GAAG,CAACC,MAAM,KAAKJ,sBAAsB,EAAE;MACzC,MAAM,IAAIK,SAAS,CAAC,oDAAoD,CAAC;IAC3E;IAEA,IAAI,EAAEH,YAAY,YAAYI,wCAAY,CAAC,EAAE;MAC3C,MAAM,IAAID,SAAS,CACjB,4DACF,CAAC;IACH;IAEA,IAAI,CAACE,IAAI,GAAGL,YAAY,CAACK,IAAI;EAC/B;EAEAC,oBAAoBA,CAAA,EAAG;IACrB,MAAM,IAAIC,KAAK,CACb,8EACF,CAAC;EACH;EAEAC,YAAYA,CAAA,EAAG;IACb,MAAM,IAAID,KAAK,CACb,sEACF,CAAC;EACH;AACF;AAACE,OAAA,CAAAX,sBAAA,GAAAA,sBAAA"}
@@ -0,0 +1,10 @@
1
+ export declare class Registration {
2
+ type: string;
3
+ constructor(type: string, factory: (obj: any) => Registration);
4
+ static register(type: string, factory: (obj: any) => Registration): Registration;
5
+ static conditionValueFrom(obj: {
6
+ type: string;
7
+ [prop: string]: any;
8
+ }): any;
9
+ }
10
+ //# sourceMappingURL=condition-value-registration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"condition-value-registration.d.ts","sourceRoot":"","sources":["../../../src/conditions/condition-value-registration.ts"],"names":[],"mappings":"AAEA,qBAAa,YAAY;IACvB,IAAI,EAAE,MAAM,CAAA;gBAEA,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,YAAY;IAK7D,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,YAAY;IAIjE,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE;CAGrE"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.Registration = void 0;
5
+ const conditionValueFactories = {};
6
+ class Registration {
7
+ constructor(type, factory) {
8
+ conditionValueFactories[type] = factory;
9
+ this.type = type;
10
+ }
11
+ static register(type, factory) {
12
+ return new Registration(type, factory);
13
+ }
14
+ static conditionValueFrom(obj) {
15
+ return conditionValueFactories[obj.type](obj);
16
+ }
17
+ }
18
+ exports.Registration = Registration;
19
+ //# sourceMappingURL=condition-value-registration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"condition-value-registration.js","names":["conditionValueFactories","Registration","constructor","type","factory","register","conditionValueFrom","obj","exports"],"sources":["../../../src/conditions/condition-value-registration.ts"],"sourcesContent":["const conditionValueFactories = {}\n\nexport class Registration {\n type: string\n\n constructor(type: string, factory: (obj: any) => Registration) {\n conditionValueFactories[type] = factory\n this.type = type\n }\n\n static register(type: string, factory: (obj: any) => Registration) {\n return new Registration(type, factory)\n }\n\n static conditionValueFrom(obj: { type: string; [prop: string]: any }) {\n return conditionValueFactories[obj.type](obj)\n }\n}\n"],"mappings":";;;;AAAA,MAAMA,uBAAuB,GAAG,CAAC,CAAC;AAE3B,MAAMC,YAAY,CAAC;EAGxBC,WAAWA,CAACC,IAAY,EAAEC,OAAmC,EAAE;IAC7DJ,uBAAuB,CAACG,IAAI,CAAC,GAAGC,OAAO;IACvC,IAAI,CAACD,IAAI,GAAGA,IAAI;EAClB;EAEA,OAAOE,QAAQA,CAACF,IAAY,EAAEC,OAAmC,EAAE;IACjE,OAAO,IAAIH,YAAY,CAACE,IAAI,EAAEC,OAAO,CAAC;EACxC;EAEA,OAAOE,kBAAkBA,CAACC,GAA0C,EAAE;IACpE,OAAOP,uBAAuB,CAACO,GAAG,CAACJ,IAAI,CAAC,CAACI,GAAG,CAAC;EAC/C;AACF;AAACC,OAAA,CAAAP,YAAA,GAAAA,YAAA"}
@@ -0,0 +1,38 @@
1
+ import { ConditionValueAbstract } from './condition-value-abstract';
2
+ import { Registration } from './condition-value-registration';
3
+ import { DateTimeUnitValues, DateUnits, TimeUnits } from './types';
4
+ export declare class ConditionValue extends ConditionValueAbstract {
5
+ value: string;
6
+ display: string;
7
+ constructor(value: string, display?: string);
8
+ toPresentationString(): string;
9
+ toExpression(): string;
10
+ static from(obj: {
11
+ value: string;
12
+ display?: string;
13
+ }): ConditionValue;
14
+ clone(): ConditionValue;
15
+ }
16
+ export declare enum DateDirections {
17
+ FUTURE = "in the future",
18
+ PAST = "in the past"
19
+ }
20
+ export declare const dateUnits: DateUnits;
21
+ export declare const timeUnits: TimeUnits;
22
+ export declare const dateTimeUnits: DateUnits & TimeUnits;
23
+ export declare class RelativeTimeValue extends ConditionValueAbstract {
24
+ timePeriod: string;
25
+ timeUnit: DateTimeUnitValues;
26
+ direction: DateDirections;
27
+ timeOnly: boolean;
28
+ constructor(timePeriod: string, timeUnit: DateTimeUnitValues, direction: DateDirections, timeOnly?: boolean);
29
+ toPresentationString(): string;
30
+ toExpression(): string;
31
+ static from(obj: any): RelativeTimeValue;
32
+ clone(): RelativeTimeValue;
33
+ }
34
+ export declare const relativeTimeValueType: Registration;
35
+ type ConditionValueFrom = Pick<ConditionValue, 'type' | 'value' | 'display'> | Pick<RelativeTimeValue, 'type' | 'timePeriod' | 'timeUnit' | 'direction' | 'timeOnly'>;
36
+ export declare function conditionValueFrom(obj: ConditionValueFrom): any;
37
+ export {};
38
+ //# sourceMappingURL=condition-values.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"condition-values.d.ts","sourceRoot":"","sources":["../../../src/conditions/condition-values.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAC7D,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAElE,qBAAa,cAAe,SAAQ,sBAAsB;IACxD,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;gBAEH,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;IAe3C,oBAAoB;IAIpB,YAAY;IAIZ,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IAIpD,KAAK;CAGN;AAMD,oBAAY,cAAc;IACxB,MAAM,kBAAkB;IACxB,IAAI,gBAAgB;CACrB;AAED,eAAO,MAAM,SAAS,EAAE,SAIvB,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,SAIvB,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,SAAS,GAAG,SAIvC,CAAA;AAED,qBAAa,iBAAkB,SAAQ,sBAAsB;IAC3D,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,SAAS,EAAE,cAAc,CAAA;IACzB,QAAQ,EAAE,OAAO,CAAA;gBAGf,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,kBAAkB,EAC5B,SAAS,EAAE,cAAc,EACzB,QAAQ,UAAQ;IA0BlB,oBAAoB;IAIpB,YAAY,IAAI,MAAM;IAUtB,MAAM,CAAC,IAAI,CAAC,GAAG,KAAA;IASf,KAAK;CAGN;AAED,eAAO,MAAM,qBAAqB,cAGjC,CAAA;AAED,KAAK,kBAAkB,GACnB,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,GAClD,IAAI,CACF,iBAAiB,EACjB,MAAM,GAAG,YAAY,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,CAC9D,CAAA;AAEL,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,kBAAkB,OAEzD"}
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.RelativeTimeValue = exports.DateDirections = exports.ConditionValue = void 0;
5
+ exports.conditionValueFrom = conditionValueFrom;
6
+ exports.timeUnits = exports.relativeTimeValueType = exports.dateUnits = exports.dateTimeUnits = void 0;
7
+ var _conditionValueAbstract = require("./condition-value-abstract");
8
+ var _conditionValueRegistration = require("./condition-value-registration");
9
+ class ConditionValue extends _conditionValueAbstract.ConditionValueAbstract {
10
+ constructor(value, display) {
11
+ super(valueType);
12
+ if (!value || typeof value !== 'string') {
13
+ throw Error(`value ${value} is not valid`);
14
+ }
15
+ if (display && typeof display !== 'string') {
16
+ throw Error(`display ${display} is not valid`);
17
+ }
18
+ this.value = value;
19
+ this.display = display || value;
20
+ }
21
+ toPresentationString() {
22
+ return this.display;
23
+ }
24
+ toExpression() {
25
+ return this.value;
26
+ }
27
+ static from(obj) {
28
+ return new ConditionValue(obj.value, obj.display);
29
+ }
30
+ clone() {
31
+ return ConditionValue.from(this);
32
+ }
33
+ }
34
+ exports.ConditionValue = ConditionValue;
35
+ const valueType = _conditionValueRegistration.Registration.register('Value', obj => ConditionValue.from(obj));
36
+ let DateDirections = exports.DateDirections = /*#__PURE__*/function (DateDirections) {
37
+ DateDirections["FUTURE"] = "in the future";
38
+ DateDirections["PAST"] = "in the past";
39
+ return DateDirections;
40
+ }({});
41
+ const dateUnits = exports.dateUnits = {
42
+ YEARS: {
43
+ display: 'year(s)',
44
+ value: 'years'
45
+ },
46
+ MONTHS: {
47
+ display: 'month(s)',
48
+ value: 'months'
49
+ },
50
+ DAYS: {
51
+ display: 'day(s)',
52
+ value: 'days'
53
+ }
54
+ };
55
+ const timeUnits = exports.timeUnits = {
56
+ HOURS: {
57
+ display: 'hour(s)',
58
+ value: 'hours'
59
+ },
60
+ MINUTES: {
61
+ display: 'minute(s)',
62
+ value: 'minutes'
63
+ },
64
+ SECONDS: {
65
+ display: 'second(s)',
66
+ value: 'seconds'
67
+ }
68
+ };
69
+ const dateTimeUnits = exports.dateTimeUnits = Object.assign({}, dateUnits, timeUnits);
70
+ class RelativeTimeValue extends _conditionValueAbstract.ConditionValueAbstract {
71
+ constructor(timePeriod, timeUnit, direction, timeOnly = false) {
72
+ super(relativeTimeValueType);
73
+ if (typeof timePeriod !== 'string') {
74
+ throw Error(`time period ${timePeriod} is not valid`);
75
+ }
76
+ if (!Object.values(dateTimeUnits).map(unit => unit.value).includes(timeUnit)) {
77
+ throw Error(`time unit ${timeUnit} is not valid`);
78
+ }
79
+ if (!Object.values(DateDirections).includes(direction)) {
80
+ throw Error(`direction ${direction} is not valid`);
81
+ }
82
+ this.timePeriod = timePeriod;
83
+ this.timeUnit = timeUnit;
84
+ this.direction = direction;
85
+ this.timeOnly = timeOnly;
86
+ }
87
+ toPresentationString() {
88
+ return `${this.timePeriod} ${this.timeUnit} ${this.direction}`;
89
+ }
90
+ toExpression() {
91
+ const timePeriod = this.direction === DateDirections.PAST ? 0 - Number(this.timePeriod) : this.timePeriod;
92
+ return this.timeOnly ? `timeForComparison(${timePeriod}, '${this.timeUnit}')` : `dateForComparison(${timePeriod}, '${this.timeUnit}')`;
93
+ }
94
+ static from(obj) {
95
+ return new RelativeTimeValue(obj.timePeriod, obj.timeUnit, obj.direction, obj.timeOnly);
96
+ }
97
+ clone() {
98
+ return RelativeTimeValue.from(this);
99
+ }
100
+ }
101
+ exports.RelativeTimeValue = RelativeTimeValue;
102
+ const relativeTimeValueType = exports.relativeTimeValueType = _conditionValueRegistration.Registration.register('RelativeTime', obj => RelativeTimeValue.from(obj));
103
+ function conditionValueFrom(obj) {
104
+ return _conditionValueRegistration.Registration.conditionValueFrom(obj);
105
+ }
106
+ //# sourceMappingURL=condition-values.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"condition-values.js","names":["_conditionValueAbstract","require","_conditionValueRegistration","ConditionValue","ConditionValueAbstract","constructor","value","display","valueType","Error","toPresentationString","toExpression","from","obj","clone","exports","Registration","register","DateDirections","dateUnits","YEARS","MONTHS","DAYS","timeUnits","HOURS","MINUTES","SECONDS","dateTimeUnits","Object","assign","RelativeTimeValue","timePeriod","timeUnit","direction","timeOnly","relativeTimeValueType","values","map","unit","includes","PAST","Number","conditionValueFrom"],"sources":["../../../src/conditions/condition-values.ts"],"sourcesContent":["import { ConditionValueAbstract } from './condition-value-abstract'\nimport { Registration } from './condition-value-registration'\nimport { DateTimeUnitValues, DateUnits, TimeUnits } from './types'\n\nexport class ConditionValue extends ConditionValueAbstract {\n value: string\n display: string\n\n constructor(value: string, display?: string) {\n super(valueType)\n\n if (!value || typeof value !== 'string') {\n throw Error(`value ${value} is not valid`)\n }\n\n if (display && typeof display !== 'string') {\n throw Error(`display ${display} is not valid`)\n }\n\n this.value = value\n this.display = display || value\n }\n\n toPresentationString() {\n return this.display\n }\n\n toExpression() {\n return this.value\n }\n\n static from(obj: { value: string; display?: string }) {\n return new ConditionValue(obj.value, obj.display)\n }\n\n clone() {\n return ConditionValue.from(this)\n }\n}\n\nconst valueType = Registration.register('Value', (obj) =>\n ConditionValue.from(obj)\n)\n\nexport enum DateDirections {\n FUTURE = 'in the future',\n PAST = 'in the past'\n}\n\nexport const dateUnits: DateUnits = {\n YEARS: { display: 'year(s)', value: 'years' },\n MONTHS: { display: 'month(s)', value: 'months' },\n DAYS: { display: 'day(s)', value: 'days' }\n}\n\nexport const timeUnits: TimeUnits = {\n HOURS: { display: 'hour(s)', value: 'hours' },\n MINUTES: { display: 'minute(s)', value: 'minutes' },\n SECONDS: { display: 'second(s)', value: 'seconds' }\n}\n\nexport const dateTimeUnits: DateUnits & TimeUnits = Object.assign(\n {},\n dateUnits,\n timeUnits\n)\n\nexport class RelativeTimeValue extends ConditionValueAbstract {\n timePeriod: string\n timeUnit: DateTimeUnitValues\n direction: DateDirections\n timeOnly: boolean\n\n constructor(\n timePeriod: string,\n timeUnit: DateTimeUnitValues,\n direction: DateDirections,\n timeOnly = false\n ) {\n super(relativeTimeValueType)\n\n if (typeof timePeriod !== 'string') {\n throw Error(`time period ${timePeriod} is not valid`)\n }\n\n if (\n !Object.values(dateTimeUnits)\n .map((unit) => unit.value)\n .includes(timeUnit)\n ) {\n throw Error(`time unit ${timeUnit} is not valid`)\n }\n\n if (!Object.values(DateDirections).includes(direction)) {\n throw Error(`direction ${direction} is not valid`)\n }\n\n this.timePeriod = timePeriod\n this.timeUnit = timeUnit\n this.direction = direction\n this.timeOnly = timeOnly\n }\n\n toPresentationString() {\n return `${this.timePeriod} ${this.timeUnit} ${this.direction}`\n }\n\n toExpression(): string {\n const timePeriod =\n this.direction === DateDirections.PAST\n ? 0 - Number(this.timePeriod)\n : this.timePeriod\n return this.timeOnly\n ? `timeForComparison(${timePeriod}, '${this.timeUnit}')`\n : `dateForComparison(${timePeriod}, '${this.timeUnit}')`\n }\n\n static from(obj) {\n return new RelativeTimeValue(\n obj.timePeriod,\n obj.timeUnit,\n obj.direction,\n obj.timeOnly\n )\n }\n\n clone() {\n return RelativeTimeValue.from(this)\n }\n}\n\nexport const relativeTimeValueType = Registration.register(\n 'RelativeTime',\n (obj): RelativeTimeValue => RelativeTimeValue.from(obj)\n)\n\ntype ConditionValueFrom =\n | Pick<ConditionValue, 'type' | 'value' | 'display'>\n | Pick<\n RelativeTimeValue,\n 'type' | 'timePeriod' | 'timeUnit' | 'direction' | 'timeOnly'\n >\n\nexport function conditionValueFrom(obj: ConditionValueFrom) {\n return Registration.conditionValueFrom(obj)\n}\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@ -0,0 +1,15 @@
1
+ import { ConditionField } from './condition-field';
2
+ import { ConditionAbstract } from './condition-abstract';
3
+ import { ConditionValue, RelativeTimeValue } from './condition-values';
4
+ import { Coordinator } from './types';
5
+ export declare class Condition extends ConditionAbstract {
6
+ field: ConditionField;
7
+ operator: string;
8
+ value: ConditionValue | RelativeTimeValue;
9
+ constructor(field: ConditionField, operator: string, value: ConditionValue | RelativeTimeValue, coordinator?: Coordinator);
10
+ asFirstCondition(): this;
11
+ conditionString(): string;
12
+ conditionExpression(): any;
13
+ clone(): Condition;
14
+ }
15
+ //# sourceMappingURL=condition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"condition.d.ts","sourceRoot":"","sources":["../../../src/conditions/condition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAErC,qBAAa,SAAU,SAAQ,iBAAiB;IAC9C,KAAK,EAAE,cAAc,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,cAAc,GAAG,iBAAiB,CAAA;gBAGvC,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,cAAc,GAAG,iBAAiB,EACzC,WAAW,CAAC,EAAE,WAAW;IAmB3B,gBAAgB;IAKhB,eAAe;IAMf,mBAAmB;IASnB,KAAK;CAQN"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.Condition = void 0;
5
+ var _conditionField = require("./condition-field");
6
+ var _conditionAbstract = require("./condition-abstract");
7
+ var _conditionOperators = require("./condition-operators");
8
+ var _conditionValueAbstract = require("./condition-value-abstract");
9
+ class Condition extends _conditionAbstract.ConditionAbstract {
10
+ constructor(field, operator, value, coordinator) {
11
+ super(coordinator);
12
+ if (!(field instanceof _conditionField.ConditionField)) {
13
+ throw Error(`field ${field} is not a valid ConditionField object`);
14
+ }
15
+ if (typeof operator !== 'string') {
16
+ throw Error(`operator ${operator} is not a valid operator`);
17
+ }
18
+ if (!(value instanceof _conditionValueAbstract.ConditionValueAbstract)) {
19
+ throw Error(`value ${value} is not a valid value type`);
20
+ }
21
+ this.field = field;
22
+ this.operator = operator;
23
+ this.value = value;
24
+ }
25
+ asFirstCondition() {
26
+ this._asFirstCondition();
27
+ return this;
28
+ }
29
+ conditionString() {
30
+ return `'${this.field.display}' ${this.operator} '${this.value.toPresentationString()}'`;
31
+ }
32
+ conditionExpression() {
33
+ return (0, _conditionOperators.getExpression)(this.field.type, this.field.name, this.operator, this.value);
34
+ }
35
+ clone() {
36
+ return new Condition(_conditionField.ConditionField.from(this.field), this.operator, this.value.clone(), this.coordinator);
37
+ }
38
+ }
39
+ exports.Condition = Condition;
40
+ //# sourceMappingURL=condition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"condition.js","names":["_conditionField","require","_conditionAbstract","_conditionOperators","_conditionValueAbstract","Condition","ConditionAbstract","constructor","field","operator","value","coordinator","ConditionField","Error","ConditionValueAbstract","asFirstCondition","_asFirstCondition","conditionString","display","toPresentationString","conditionExpression","getExpression","type","name","clone","from","exports"],"sources":["../../../src/conditions/condition.ts"],"sourcesContent":["import { ConditionField } from './condition-field'\nimport { ConditionAbstract } from './condition-abstract'\nimport { getExpression } from './condition-operators'\nimport { ConditionValue, RelativeTimeValue } from './condition-values'\nimport { ConditionValueAbstract } from './condition-value-abstract'\nimport { Coordinator } from './types'\n\nexport class Condition extends ConditionAbstract {\n field: ConditionField\n operator: string\n value: ConditionValue | RelativeTimeValue\n\n constructor(\n field: ConditionField,\n operator: string,\n value: ConditionValue | RelativeTimeValue,\n coordinator?: Coordinator\n ) {\n super(coordinator)\n\n if (!(field instanceof ConditionField)) {\n throw Error(`field ${field} is not a valid ConditionField object`)\n }\n if (typeof operator !== 'string') {\n throw Error(`operator ${operator} is not a valid operator`)\n }\n if (!(value instanceof ConditionValueAbstract)) {\n throw Error(`value ${value} is not a valid value type`)\n }\n\n this.field = field\n this.operator = operator\n this.value = value\n }\n\n asFirstCondition() {\n this._asFirstCondition()\n return this\n }\n\n conditionString() {\n return `'${this.field.display}' ${\n this.operator\n } '${this.value.toPresentationString()}'`\n }\n\n conditionExpression() {\n return getExpression(\n this.field.type,\n this.field.name,\n this.operator,\n this.value\n )\n }\n\n clone() {\n return new Condition(\n ConditionField.from(this.field),\n this.operator,\n this.value.clone(),\n this.coordinator\n )\n }\n}\n"],"mappings":";;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AAEA,IAAAG,uBAAA,GAAAH,OAAA;AAGO,MAAMI,SAAS,SAASC,oCAAiB,CAAC;EAK/CC,WAAWA,CACTC,KAAqB,EACrBC,QAAgB,EAChBC,KAAyC,EACzCC,WAAyB,EACzB;IACA,KAAK,CAACA,WAAW,CAAC;IAElB,IAAI,EAAEH,KAAK,YAAYI,8BAAc,CAAC,EAAE;MACtC,MAAMC,KAAK,CAAE,SAAQL,KAAM,uCAAsC,CAAC;IACpE;IACA,IAAI,OAAOC,QAAQ,KAAK,QAAQ,EAAE;MAChC,MAAMI,KAAK,CAAE,YAAWJ,QAAS,0BAAyB,CAAC;IAC7D;IACA,IAAI,EAAEC,KAAK,YAAYI,8CAAsB,CAAC,EAAE;MAC9C,MAAMD,KAAK,CAAE,SAAQH,KAAM,4BAA2B,CAAC;IACzD;IAEA,IAAI,CAACF,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,KAAK,GAAGA,KAAK;EACpB;EAEAK,gBAAgBA,CAAA,EAAG;IACjB,IAAI,CAACC,iBAAiB,CAAC,CAAC;IACxB,OAAO,IAAI;EACb;EAEAC,eAAeA,CAAA,EAAG;IAChB,OAAQ,IAAG,IAAI,CAACT,KAAK,CAACU,OAAQ,KAC5B,IAAI,CAACT,QACN,KAAI,IAAI,CAACC,KAAK,CAACS,oBAAoB,CAAC,CAAE,GAAE;EAC3C;EAEAC,mBAAmBA,CAAA,EAAG;IACpB,OAAO,IAAAC,iCAAa,EAClB,IAAI,CAACb,KAAK,CAACc,IAAI,EACf,IAAI,CAACd,KAAK,CAACe,IAAI,EACf,IAAI,CAACd,QAAQ,EACb,IAAI,CAACC,KACP,CAAC;EACH;EAEAc,KAAKA,CAAA,EAAG;IACN,OAAO,IAAInB,SAAS,CAClBO,8BAAc,CAACa,IAAI,CAAC,IAAI,CAACjB,KAAK,CAAC,EAC/B,IAAI,CAACC,QAAQ,EACb,IAAI,CAACC,KAAK,CAACc,KAAK,CAAC,CAAC,EAClB,IAAI,CAACb,WACP,CAAC;EACH;AACF;AAACe,OAAA,CAAArB,SAAA,GAAAA,SAAA"}
@@ -0,0 +1,3 @@
1
+ export declare function toPresentationString(condition: any): string;
2
+ export declare function toExpression(condition: any): string;
3
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/conditions/helpers.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAAC,SAAS,KAAA,UAE7C;AAED,wBAAgB,YAAY,CAAC,SAAS,KAAA,UAErC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.toExpression = toExpression;
5
+ exports.toPresentationString = toPresentationString;
6
+ function toPresentationString(condition) {
7
+ return `${condition.coordinatorString()}${condition.conditionString()}`;
8
+ }
9
+ function toExpression(condition) {
10
+ return `${condition.coordinatorString()}${condition.conditionExpression()}`;
11
+ }
12
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","names":["toPresentationString","condition","coordinatorString","conditionString","toExpression","conditionExpression"],"sources":["../../../src/conditions/helpers.ts"],"sourcesContent":["export function toPresentationString(condition) {\n return `${condition.coordinatorString()}${condition.conditionString()}`\n}\n\nexport function toExpression(condition) {\n return `${condition.coordinatorString()}${condition.conditionExpression()}`\n}\n"],"mappings":";;;;;AAAO,SAASA,oBAAoBA,CAACC,SAAS,EAAE;EAC9C,OAAQ,GAAEA,SAAS,CAACC,iBAAiB,CAAC,CAAE,GAAED,SAAS,CAACE,eAAe,CAAC,CAAE,EAAC;AACzE;AAEO,SAASC,YAAYA,CAACH,SAAS,EAAE;EACtC,OAAQ,GAAEA,SAAS,CAACC,iBAAiB,CAAC,CAAE,GAAED,SAAS,CAACI,mBAAmB,CAAC,CAAE,EAAC;AAC7E"}
@@ -0,0 +1,11 @@
1
+ export { getExpression, getOperatorConfig, getOperatorNames, absoluteDateOrTimeOperatorNames, relativeDateOrTimeOperatorNames } from './condition-operators';
2
+ export { timeUnits, dateUnits, dateTimeUnits, ConditionValue, DateDirections, RelativeTimeValue, conditionValueFrom } from './condition-values';
3
+ export { ConditionField } from './condition-field';
4
+ export { Condition } from './condition';
5
+ export { ConditionRef } from './condition-ref';
6
+ export { ConditionGroup } from './condition-group';
7
+ export { ConditionsModel } from './condition-model';
8
+ export { ConditionGroupDef } from './condition-group-def';
9
+ export { toExpression, toPresentationString } from './helpers';
10
+ export { Coordinator } from './types';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/conditions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,+BAA+B,EAC/B,+BAA+B,EAChC,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EACL,SAAS,EACT,SAAS,EACT,aAAa,EACb,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAE9D,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA"}