@wisemen/nestjs-custom-fields 0.0.0 → 0.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 (337) hide show
  1. package/LICENSE.md +59 -0
  2. package/README.md +279 -0
  3. package/dist/custom-field-choice.d.ts +6 -0
  4. package/dist/custom-field-choice.js +2 -0
  5. package/dist/custom-field-choice.js.map +1 -0
  6. package/dist/custom-field-definition.d.ts +41 -0
  7. package/dist/custom-field-definition.js +2 -0
  8. package/dist/custom-field-definition.js.map +1 -0
  9. package/dist/custom-field-definition.uuid.d.ts +7 -0
  10. package/dist/custom-field-definition.uuid.js +4 -0
  11. package/dist/custom-field-definition.uuid.js.map +1 -0
  12. package/dist/custom-field-rules.d.ts +28 -0
  13. package/dist/custom-field-rules.js +2 -0
  14. package/dist/custom-field-rules.js.map +1 -0
  15. package/dist/custom-field-type-contract.d.ts +38 -0
  16. package/dist/custom-field-type-contract.js +2 -0
  17. package/dist/custom-field-type-contract.js.map +1 -0
  18. package/dist/custom-field-types/boolean/boolean.contract.d.ts +8 -0
  19. package/dist/custom-field-types/boolean/boolean.contract.js +2 -0
  20. package/dist/custom-field-types/boolean/boolean.contract.js.map +1 -0
  21. package/dist/custom-field-types/boolean/boolean.custom-field-definition.factory.unit.test.d.ts +1 -0
  22. package/dist/custom-field-types/boolean/boolean.custom-field-definition.factory.unit.test.js +21 -0
  23. package/dist/custom-field-types/boolean/boolean.custom-field-definition.factory.unit.test.js.map +1 -0
  24. package/dist/custom-field-types/boolean/boolean.custom-field-value.validator.d.ts +1 -0
  25. package/dist/custom-field-types/boolean/boolean.custom-field-value.validator.js +2 -0
  26. package/dist/custom-field-types/boolean/boolean.custom-field-value.validator.js.map +1 -0
  27. package/dist/custom-field-types/boolean/boolean.custom-field-value.validator.unit.test.d.ts +1 -0
  28. package/dist/custom-field-types/boolean/boolean.custom-field-value.validator.unit.test.js +24 -0
  29. package/dist/custom-field-types/boolean/boolean.custom-field-value.validator.unit.test.js.map +1 -0
  30. package/dist/custom-field-types/boolean/boolean.definition-validation.d.ts +7 -0
  31. package/dist/custom-field-types/boolean/boolean.definition-validation.js +10 -0
  32. package/dist/custom-field-types/boolean/boolean.definition-validation.js.map +1 -0
  33. package/dist/custom-field-types/boolean/boolean.dto.d.ts +9 -0
  34. package/dist/custom-field-types/boolean/boolean.dto.js +33 -0
  35. package/dist/custom-field-types/boolean/boolean.dto.js.map +1 -0
  36. package/dist/custom-field-types/boolean/boolean.rules.d.ts +5 -0
  37. package/dist/custom-field-types/boolean/boolean.rules.js +2 -0
  38. package/dist/custom-field-types/boolean/boolean.rules.js.map +1 -0
  39. package/dist/custom-field-types/boolean/boolean.value.d.ts +5 -0
  40. package/dist/custom-field-types/boolean/boolean.value.js +2 -0
  41. package/dist/custom-field-types/boolean/boolean.value.js.map +1 -0
  42. package/dist/custom-field-types/boolean/index.d.ts +6 -0
  43. package/dist/custom-field-types/boolean/index.js +7 -0
  44. package/dist/custom-field-types/boolean/index.js.map +1 -0
  45. package/dist/custom-field-types/date/date.contract.d.ts +12 -0
  46. package/dist/custom-field-types/date/date.contract.js +2 -0
  47. package/dist/custom-field-types/date/date.contract.js.map +1 -0
  48. package/dist/custom-field-types/date/date.custom-field-definition.factory.unit.test.d.ts +1 -0
  49. package/dist/custom-field-types/date/date.custom-field-definition.factory.unit.test.js +70 -0
  50. package/dist/custom-field-types/date/date.custom-field-definition.factory.unit.test.js.map +1 -0
  51. package/dist/custom-field-types/date/date.custom-field-value.validator.d.ts +6 -0
  52. package/dist/custom-field-types/date/date.custom-field-value.validator.js +14 -0
  53. package/dist/custom-field-types/date/date.custom-field-value.validator.js.map +1 -0
  54. package/dist/custom-field-types/date/date.custom-field-value.validator.unit.test.d.ts +1 -0
  55. package/dist/custom-field-types/date/date.custom-field-value.validator.unit.test.js +47 -0
  56. package/dist/custom-field-types/date/date.custom-field-value.validator.unit.test.js.map +1 -0
  57. package/dist/custom-field-types/date/date.definition-validation.d.ts +7 -0
  58. package/dist/custom-field-types/date/date.definition-validation.js +35 -0
  59. package/dist/custom-field-types/date/date.definition-validation.js.map +1 -0
  60. package/dist/custom-field-types/date/date.dto.d.ts +9 -0
  61. package/dist/custom-field-types/date/date.dto.js +34 -0
  62. package/dist/custom-field-types/date/date.dto.js.map +1 -0
  63. package/dist/custom-field-types/date/date.rules.d.ts +5 -0
  64. package/dist/custom-field-types/date/date.rules.js +2 -0
  65. package/dist/custom-field-types/date/date.rules.js.map +1 -0
  66. package/dist/custom-field-types/date/date.value.d.ts +5 -0
  67. package/dist/custom-field-types/date/date.value.js +2 -0
  68. package/dist/custom-field-types/date/date.value.js.map +1 -0
  69. package/dist/custom-field-types/date/index.d.ts +6 -0
  70. package/dist/custom-field-types/date/index.js +7 -0
  71. package/dist/custom-field-types/date/index.js.map +1 -0
  72. package/dist/custom-field-types/index.d.ts +9 -0
  73. package/dist/custom-field-types/index.js +10 -0
  74. package/dist/custom-field-types/index.js.map +1 -0
  75. package/dist/custom-field-types/monetary/index.d.ts +6 -0
  76. package/dist/custom-field-types/monetary/index.js +7 -0
  77. package/dist/custom-field-types/monetary/index.js.map +1 -0
  78. package/dist/custom-field-types/monetary/monetary.contract.d.ts +14 -0
  79. package/dist/custom-field-types/monetary/monetary.contract.js +2 -0
  80. package/dist/custom-field-types/monetary/monetary.contract.js.map +1 -0
  81. package/dist/custom-field-types/monetary/monetary.custom-field-definition.factory.unit.test.d.ts +1 -0
  82. package/dist/custom-field-types/monetary/monetary.custom-field-definition.factory.unit.test.js +98 -0
  83. package/dist/custom-field-types/monetary/monetary.custom-field-definition.factory.unit.test.js.map +1 -0
  84. package/dist/custom-field-types/monetary/monetary.custom-field-value.validator.d.ts +6 -0
  85. package/dist/custom-field-types/monetary/monetary.custom-field-value.validator.js +27 -0
  86. package/dist/custom-field-types/monetary/monetary.custom-field-value.validator.js.map +1 -0
  87. package/dist/custom-field-types/monetary/monetary.custom-field-value.validator.unit.test.d.ts +1 -0
  88. package/dist/custom-field-types/monetary/monetary.custom-field-value.validator.unit.test.js +130 -0
  89. package/dist/custom-field-types/monetary/monetary.custom-field-value.validator.unit.test.js.map +1 -0
  90. package/dist/custom-field-types/monetary/monetary.definition-validation.d.ts +7 -0
  91. package/dist/custom-field-types/monetary/monetary.definition-validation.js +25 -0
  92. package/dist/custom-field-types/monetary/monetary.definition-validation.js.map +1 -0
  93. package/dist/custom-field-types/monetary/monetary.dto.d.ts +10 -0
  94. package/dist/custom-field-types/monetary/monetary.dto.js +34 -0
  95. package/dist/custom-field-types/monetary/monetary.dto.js.map +1 -0
  96. package/dist/custom-field-types/monetary/monetary.rules.d.ts +5 -0
  97. package/dist/custom-field-types/monetary/monetary.rules.js +2 -0
  98. package/dist/custom-field-types/monetary/monetary.rules.js.map +1 -0
  99. package/dist/custom-field-types/monetary/monetary.value.d.ts +5 -0
  100. package/dist/custom-field-types/monetary/monetary.value.js +2 -0
  101. package/dist/custom-field-types/monetary/monetary.value.js.map +1 -0
  102. package/dist/custom-field-types/multi-select/index.d.ts +6 -0
  103. package/dist/custom-field-types/multi-select/index.js +7 -0
  104. package/dist/custom-field-types/multi-select/index.js.map +1 -0
  105. package/dist/custom-field-types/multi-select/multi-select.contract.d.ts +11 -0
  106. package/dist/custom-field-types/multi-select/multi-select.contract.js +2 -0
  107. package/dist/custom-field-types/multi-select/multi-select.contract.js.map +1 -0
  108. package/dist/custom-field-types/multi-select/multi-select.custom-field-definition.factory.unit.test.d.ts +1 -0
  109. package/dist/custom-field-types/multi-select/multi-select.custom-field-definition.factory.unit.test.js +169 -0
  110. package/dist/custom-field-types/multi-select/multi-select.custom-field-definition.factory.unit.test.js.map +1 -0
  111. package/dist/custom-field-types/multi-select/multi-select.custom-field-value.validator.d.ts +5 -0
  112. package/dist/custom-field-types/multi-select/multi-select.custom-field-value.validator.js +25 -0
  113. package/dist/custom-field-types/multi-select/multi-select.custom-field-value.validator.js.map +1 -0
  114. package/dist/custom-field-types/multi-select/multi-select.custom-field-value.validator.unit.test.d.ts +1 -0
  115. package/dist/custom-field-types/multi-select/multi-select.custom-field-value.validator.unit.test.js +122 -0
  116. package/dist/custom-field-types/multi-select/multi-select.custom-field-value.validator.unit.test.js.map +1 -0
  117. package/dist/custom-field-types/multi-select/multi-select.definition-validation.d.ts +7 -0
  118. package/dist/custom-field-types/multi-select/multi-select.definition-validation.js +45 -0
  119. package/dist/custom-field-types/multi-select/multi-select.definition-validation.js.map +1 -0
  120. package/dist/custom-field-types/multi-select/multi-select.dto.d.ts +9 -0
  121. package/dist/custom-field-types/multi-select/multi-select.dto.js +36 -0
  122. package/dist/custom-field-types/multi-select/multi-select.dto.js.map +1 -0
  123. package/dist/custom-field-types/multi-select/multi-select.rules.d.ts +5 -0
  124. package/dist/custom-field-types/multi-select/multi-select.rules.js +2 -0
  125. package/dist/custom-field-types/multi-select/multi-select.rules.js.map +1 -0
  126. package/dist/custom-field-types/multi-select/multi-select.value.d.ts +5 -0
  127. package/dist/custom-field-types/multi-select/multi-select.value.js +2 -0
  128. package/dist/custom-field-types/multi-select/multi-select.value.js.map +1 -0
  129. package/dist/custom-field-types/number/index.d.ts +6 -0
  130. package/dist/custom-field-types/number/index.js +7 -0
  131. package/dist/custom-field-types/number/index.js.map +1 -0
  132. package/dist/custom-field-types/number/number.contract.d.ts +11 -0
  133. package/dist/custom-field-types/number/number.contract.js +2 -0
  134. package/dist/custom-field-types/number/number.contract.js.map +1 -0
  135. package/dist/custom-field-types/number/number.custom-field-definition.factory.unit.test.d.ts +1 -0
  136. package/dist/custom-field-types/number/number.custom-field-definition.factory.unit.test.js +44 -0
  137. package/dist/custom-field-types/number/number.custom-field-definition.factory.unit.test.js.map +1 -0
  138. package/dist/custom-field-types/number/number.custom-field-value.validator.d.ts +5 -0
  139. package/dist/custom-field-types/number/number.custom-field-value.validator.js +14 -0
  140. package/dist/custom-field-types/number/number.custom-field-value.validator.js.map +1 -0
  141. package/dist/custom-field-types/number/number.custom-field-value.validator.unit.test.d.ts +1 -0
  142. package/dist/custom-field-types/number/number.custom-field-value.validator.unit.test.js +46 -0
  143. package/dist/custom-field-types/number/number.custom-field-value.validator.unit.test.js.map +1 -0
  144. package/dist/custom-field-types/number/number.definition-validation.d.ts +7 -0
  145. package/dist/custom-field-types/number/number.definition-validation.js +16 -0
  146. package/dist/custom-field-types/number/number.definition-validation.js.map +1 -0
  147. package/dist/custom-field-types/number/number.dto.d.ts +9 -0
  148. package/dist/custom-field-types/number/number.dto.js +33 -0
  149. package/dist/custom-field-types/number/number.dto.js.map +1 -0
  150. package/dist/custom-field-types/number/number.rules.d.ts +5 -0
  151. package/dist/custom-field-types/number/number.rules.js +2 -0
  152. package/dist/custom-field-types/number/number.rules.js.map +1 -0
  153. package/dist/custom-field-types/number/number.value.d.ts +5 -0
  154. package/dist/custom-field-types/number/number.value.js +2 -0
  155. package/dist/custom-field-types/number/number.value.js.map +1 -0
  156. package/dist/custom-field-types/single-select/index.d.ts +6 -0
  157. package/dist/custom-field-types/single-select/index.js +7 -0
  158. package/dist/custom-field-types/single-select/index.js.map +1 -0
  159. package/dist/custom-field-types/single-select/single-select.contract.d.ts +8 -0
  160. package/dist/custom-field-types/single-select/single-select.contract.js +2 -0
  161. package/dist/custom-field-types/single-select/single-select.contract.js.map +1 -0
  162. package/dist/custom-field-types/single-select/single-select.custom-field-definition.factory.unit.test.d.ts +1 -0
  163. package/dist/custom-field-types/single-select/single-select.custom-field-definition.factory.unit.test.js +100 -0
  164. package/dist/custom-field-types/single-select/single-select.custom-field-definition.factory.unit.test.js.map +1 -0
  165. package/dist/custom-field-types/single-select/single-select.custom-field-value.validator.d.ts +5 -0
  166. package/dist/custom-field-types/single-select/single-select.custom-field-value.validator.js +10 -0
  167. package/dist/custom-field-types/single-select/single-select.custom-field-value.validator.js.map +1 -0
  168. package/dist/custom-field-types/single-select/single-select.custom-field-value.validator.unit.test.d.ts +1 -0
  169. package/dist/custom-field-types/single-select/single-select.custom-field-value.validator.unit.test.js +57 -0
  170. package/dist/custom-field-types/single-select/single-select.custom-field-value.validator.unit.test.js.map +1 -0
  171. package/dist/custom-field-types/single-select/single-select.definition-validation.d.ts +7 -0
  172. package/dist/custom-field-types/single-select/single-select.definition-validation.js +25 -0
  173. package/dist/custom-field-types/single-select/single-select.definition-validation.js.map +1 -0
  174. package/dist/custom-field-types/single-select/single-select.dto.d.ts +9 -0
  175. package/dist/custom-field-types/single-select/single-select.dto.js +34 -0
  176. package/dist/custom-field-types/single-select/single-select.dto.js.map +1 -0
  177. package/dist/custom-field-types/single-select/single-select.rules.d.ts +5 -0
  178. package/dist/custom-field-types/single-select/single-select.rules.js +2 -0
  179. package/dist/custom-field-types/single-select/single-select.rules.js.map +1 -0
  180. package/dist/custom-field-types/single-select/single-select.value.d.ts +5 -0
  181. package/dist/custom-field-types/single-select/single-select.value.js +2 -0
  182. package/dist/custom-field-types/single-select/single-select.value.js.map +1 -0
  183. package/dist/custom-field-types/text/index.d.ts +6 -0
  184. package/dist/custom-field-types/text/index.js +7 -0
  185. package/dist/custom-field-types/text/index.js.map +1 -0
  186. package/dist/custom-field-types/text/text.contract.d.ts +12 -0
  187. package/dist/custom-field-types/text/text.contract.js +2 -0
  188. package/dist/custom-field-types/text/text.contract.js.map +1 -0
  189. package/dist/custom-field-types/text/text.custom-field-definition.factory.unit.test.d.ts +1 -0
  190. package/dist/custom-field-types/text/text.custom-field-definition.factory.unit.test.js +128 -0
  191. package/dist/custom-field-types/text/text.custom-field-definition.factory.unit.test.js.map +1 -0
  192. package/dist/custom-field-types/text/text.custom-field-value.validator.d.ts +5 -0
  193. package/dist/custom-field-types/text/text.custom-field-value.validator.js +17 -0
  194. package/dist/custom-field-types/text/text.custom-field-value.validator.js.map +1 -0
  195. package/dist/custom-field-types/text/text.custom-field-value.validator.unit.test.d.ts +1 -0
  196. package/dist/custom-field-types/text/text.custom-field-value.validator.unit.test.js +64 -0
  197. package/dist/custom-field-types/text/text.custom-field-value.validator.unit.test.js.map +1 -0
  198. package/dist/custom-field-types/text/text.definition-validation.d.ts +7 -0
  199. package/dist/custom-field-types/text/text.definition-validation.js +30 -0
  200. package/dist/custom-field-types/text/text.definition-validation.js.map +1 -0
  201. package/dist/custom-field-types/text/text.dto.d.ts +9 -0
  202. package/dist/custom-field-types/text/text.dto.js +33 -0
  203. package/dist/custom-field-types/text/text.dto.js.map +1 -0
  204. package/dist/custom-field-types/text/text.rules.d.ts +5 -0
  205. package/dist/custom-field-types/text/text.rules.js +2 -0
  206. package/dist/custom-field-types/text/text.rules.js.map +1 -0
  207. package/dist/custom-field-types/text/text.value.d.ts +5 -0
  208. package/dist/custom-field-types/text/text.value.js +2 -0
  209. package/dist/custom-field-types/text/text.value.js.map +1 -0
  210. package/dist/custom-field-types/text-array/index.d.ts +6 -0
  211. package/dist/custom-field-types/text-array/index.js +7 -0
  212. package/dist/custom-field-types/text-array/index.js.map +1 -0
  213. package/dist/custom-field-types/text-array/text-array.contract.d.ts +11 -0
  214. package/dist/custom-field-types/text-array/text-array.contract.js +2 -0
  215. package/dist/custom-field-types/text-array/text-array.contract.js.map +1 -0
  216. package/dist/custom-field-types/text-array/text-array.custom-field-definition.factory.unit.test.d.ts +1 -0
  217. package/dist/custom-field-types/text-array/text-array.custom-field-definition.factory.unit.test.js +71 -0
  218. package/dist/custom-field-types/text-array/text-array.custom-field-definition.factory.unit.test.js.map +1 -0
  219. package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.d.ts +5 -0
  220. package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.js +14 -0
  221. package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.js.map +1 -0
  222. package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.unit.test.d.ts +1 -0
  223. package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.unit.test.js +46 -0
  224. package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.unit.test.js.map +1 -0
  225. package/dist/custom-field-types/text-array/text-array.definition-validation.d.ts +7 -0
  226. package/dist/custom-field-types/text-array/text-array.definition-validation.js +22 -0
  227. package/dist/custom-field-types/text-array/text-array.definition-validation.js.map +1 -0
  228. package/dist/custom-field-types/text-array/text-array.dto.d.ts +9 -0
  229. package/dist/custom-field-types/text-array/text-array.dto.js +36 -0
  230. package/dist/custom-field-types/text-array/text-array.dto.js.map +1 -0
  231. package/dist/custom-field-types/text-array/text-array.rules.d.ts +5 -0
  232. package/dist/custom-field-types/text-array/text-array.rules.js +2 -0
  233. package/dist/custom-field-types/text-array/text-array.rules.js.map +1 -0
  234. package/dist/custom-field-types/text-array/text-array.value.d.ts +5 -0
  235. package/dist/custom-field-types/text-array/text-array.value.js +2 -0
  236. package/dist/custom-field-types/text-array/text-array.value.js.map +1 -0
  237. package/dist/custom-field-types/timestamp/index.d.ts +6 -0
  238. package/dist/custom-field-types/timestamp/index.js +7 -0
  239. package/dist/custom-field-types/timestamp/index.js.map +1 -0
  240. package/dist/custom-field-types/timestamp/timestamp.contract.d.ts +12 -0
  241. package/dist/custom-field-types/timestamp/timestamp.contract.js +2 -0
  242. package/dist/custom-field-types/timestamp/timestamp.contract.js.map +1 -0
  243. package/dist/custom-field-types/timestamp/timestamp.custom-field-definition.factory.unit.test.d.ts +1 -0
  244. package/dist/custom-field-types/timestamp/timestamp.custom-field-definition.factory.unit.test.js +70 -0
  245. package/dist/custom-field-types/timestamp/timestamp.custom-field-definition.factory.unit.test.js.map +1 -0
  246. package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.d.ts +6 -0
  247. package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.js +14 -0
  248. package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.js.map +1 -0
  249. package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.unit.test.d.ts +1 -0
  250. package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.unit.test.js +47 -0
  251. package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.unit.test.js.map +1 -0
  252. package/dist/custom-field-types/timestamp/timestamp.definition-validation.d.ts +7 -0
  253. package/dist/custom-field-types/timestamp/timestamp.definition-validation.js +38 -0
  254. package/dist/custom-field-types/timestamp/timestamp.definition-validation.js.map +1 -0
  255. package/dist/custom-field-types/timestamp/timestamp.dto.d.ts +9 -0
  256. package/dist/custom-field-types/timestamp/timestamp.dto.js +35 -0
  257. package/dist/custom-field-types/timestamp/timestamp.dto.js.map +1 -0
  258. package/dist/custom-field-types/timestamp/timestamp.rules.d.ts +5 -0
  259. package/dist/custom-field-types/timestamp/timestamp.rules.js +2 -0
  260. package/dist/custom-field-types/timestamp/timestamp.rules.js.map +1 -0
  261. package/dist/custom-field-types/timestamp/timestamp.value.d.ts +5 -0
  262. package/dist/custom-field-types/timestamp/timestamp.value.js +2 -0
  263. package/dist/custom-field-types/timestamp/timestamp.value.js.map +1 -0
  264. package/dist/custom-field-value.d.ts +17 -0
  265. package/dist/custom-field-value.js +2 -0
  266. package/dist/custom-field-value.js.map +1 -0
  267. package/dist/decorators/is-custom-fields.decorator.d.ts +1 -0
  268. package/dist/decorators/is-custom-fields.decorator.js +14 -0
  269. package/dist/decorators/is-custom-fields.decorator.js.map +1 -0
  270. package/dist/dto/base-custom-field-value.dto.d.ts +15 -0
  271. package/dist/dto/base-custom-field-value.dto.js +33 -0
  272. package/dist/dto/base-custom-field-value.dto.js.map +1 -0
  273. package/dist/dto/custom-field-value.dto.d.ts +46 -0
  274. package/dist/dto/custom-field-value.dto.js +72 -0
  275. package/dist/dto/custom-field-value.dto.js.map +1 -0
  276. package/dist/dto/custom-field-value.dto.unit.test.d.ts +1 -0
  277. package/dist/dto/custom-field-value.dto.unit.test.js +74 -0
  278. package/dist/dto/custom-field-value.dto.unit.test.js.map +1 -0
  279. package/dist/enum/custom-field-type.enum.d.ts +15 -0
  280. package/dist/enum/custom-field-type.enum.js +28 -0
  281. package/dist/enum/custom-field-type.enum.js.map +1 -0
  282. package/dist/errors/custom-field-definition.error.d.ts +2 -0
  283. package/dist/errors/custom-field-definition.error.js +3 -0
  284. package/dist/errors/custom-field-definition.error.js.map +1 -0
  285. package/dist/exhaustive-check.d.ts +1 -0
  286. package/dist/exhaustive-check.js +4 -0
  287. package/dist/exhaustive-check.js.map +1 -0
  288. package/dist/factory/custom-field-definition.factory.d.ts +41 -0
  289. package/dist/factory/custom-field-definition.factory.js +125 -0
  290. package/dist/factory/custom-field-definition.factory.js.map +1 -0
  291. package/dist/index.d.ts +18 -0
  292. package/dist/index.js +17 -0
  293. package/dist/index.js.map +1 -0
  294. package/dist/repositories/custom-field-definition.repository.module.d.ts +2 -0
  295. package/dist/repositories/custom-field-definition.repository.module.js +27 -0
  296. package/dist/repositories/custom-field-definition.repository.module.js.map +1 -0
  297. package/dist/repositories/custom-field-definitions.repository.d.ts +11 -0
  298. package/dist/repositories/custom-field-definitions.repository.integration.test.d.ts +1 -0
  299. package/dist/repositories/custom-field-definitions.repository.integration.test.js +174 -0
  300. package/dist/repositories/custom-field-definitions.repository.integration.test.js.map +1 -0
  301. package/dist/repositories/custom-field-definitions.repository.js +40 -0
  302. package/dist/repositories/custom-field-definitions.repository.js.map +1 -0
  303. package/dist/repositories/index.d.ts +2 -0
  304. package/dist/repositories/index.js +3 -0
  305. package/dist/repositories/index.js.map +1 -0
  306. package/dist/responses/custom-field-definition.response.d.ts +26 -0
  307. package/dist/responses/custom-field-definition.response.js +99 -0
  308. package/dist/responses/custom-field-definition.response.js.map +1 -0
  309. package/dist/responses/custom-field-definition.response.unit.test.d.ts +1 -0
  310. package/dist/responses/custom-field-definition.response.unit.test.js +96 -0
  311. package/dist/responses/custom-field-definition.response.unit.test.js.map +1 -0
  312. package/dist/tests/sql/datasource.d.ts +2 -0
  313. package/dist/tests/sql/datasource.js +17 -0
  314. package/dist/tests/sql/datasource.js.map +1 -0
  315. package/dist/tests/test-setup.d.ts +8 -0
  316. package/dist/tests/test-setup.js +46 -0
  317. package/dist/tests/test-setup.js.map +1 -0
  318. package/dist/typeorm/custom-field-choice.column.d.ts +2 -0
  319. package/dist/typeorm/custom-field-choice.column.js +49 -0
  320. package/dist/typeorm/custom-field-choice.column.js.map +1 -0
  321. package/dist/typeorm/custom-field-definition.entity.d.ts +20 -0
  322. package/dist/typeorm/custom-field-definition.entity.js +82 -0
  323. package/dist/typeorm/custom-field-definition.entity.js.map +1 -0
  324. package/dist/typeorm/custom-field-value.column.d.ts +2 -0
  325. package/dist/typeorm/custom-field-value.column.js +102 -0
  326. package/dist/typeorm/custom-field-value.column.js.map +1 -0
  327. package/dist/validators/custom-field-value-validation.error.d.ts +6 -0
  328. package/dist/validators/custom-field-value-validation.error.js +22 -0
  329. package/dist/validators/custom-field-value-validation.error.js.map +1 -0
  330. package/dist/validators/custom-field-value.validator.d.ts +4 -0
  331. package/dist/validators/custom-field-value.validator.js +81 -0
  332. package/dist/validators/custom-field-value.validator.js.map +1 -0
  333. package/dist/validators/custom-field-value.validator.unit.test.d.ts +1 -0
  334. package/dist/validators/custom-field-value.validator.unit.test.js +166 -0
  335. package/dist/validators/custom-field-value.validator.unit.test.js.map +1 -0
  336. package/package.json +56 -3
  337. package/skills/getting-started/SKILL.md +263 -0
@@ -0,0 +1,6 @@
1
+ import { Currency, Monetary } from '@wisemen/monetary';
2
+ import type { CustomFieldDefinitionFieldsByType } from '#src/custom-field-definition.js';
3
+ import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
4
+ type MonetaryCustomFieldDefinition = CustomFieldDefinitionFieldsByType<CustomFieldType.MONETARY>;
5
+ export declare function validateMonetaryCustomFieldValue(definition: MonetaryCustomFieldDefinition, value: Monetary<Currency>): void;
6
+ export {};
@@ -0,0 +1,27 @@
1
+ import { Monetary } from '@wisemen/monetary';
2
+ import { CustomFieldValueValidationError } from '#src/validators/custom-field-value-validation.error.js';
3
+ export function validateMonetaryCustomFieldValue(definition, value) {
4
+ const rules = definition.rules;
5
+ if (rules === null) {
6
+ throw new CustomFieldValueValidationError('Monetary custom field definition must define rules');
7
+ }
8
+ if (rules.currencies !== undefined && !rules.currencies.includes(value.currency)) {
9
+ throw new CustomFieldValueValidationError('Monetary custom field value must use an allowed currency');
10
+ }
11
+ if (value.precision !== rules.precision) {
12
+ throw new CustomFieldValueValidationError('Monetary custom field value precision must match the configured precision');
13
+ }
14
+ if (rules.min !== undefined) {
15
+ const min = new Monetary(rules.min, value.currency, rules.precision);
16
+ if (value.isLessThan(min)) {
17
+ throw new CustomFieldValueValidationError('Monetary custom field value can not be lower than min');
18
+ }
19
+ }
20
+ if (rules.max !== undefined) {
21
+ const max = new Monetary(rules.max, value.currency, rules.precision);
22
+ if (value.isMoreThan(max)) {
23
+ throw new CustomFieldValueValidationError('Monetary custom field value can not be greater than max');
24
+ }
25
+ }
26
+ }
27
+ //# sourceMappingURL=monetary.custom-field-value.validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monetary.custom-field-value.validator.js","sourceRoot":"","sources":["../../../lib/custom-field-types/monetary/monetary.custom-field-value.validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEtD,OAAO,EAAE,+BAA+B,EAAE,MAAM,wDAAwD,CAAA;AAKxG,MAAM,UAAU,gCAAgC,CAC9C,UAAyC,EACzC,KAAyB;IAEzB,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAA;IAE9B,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,+BAA+B,CAAC,oDAAoD,CAAC,CAAA;IACjG,CAAC;IAED,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjF,MAAM,IAAI,+BAA+B,CAAC,0DAA0D,CAAC,CAAA;IACvG,CAAC;IAED,IAAI,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,SAAS,EAAE,CAAC;QACxC,MAAM,IAAI,+BAA+B,CAAC,2EAA2E,CAAC,CAAA;IACxH,CAAC;IAED,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;QAEpE,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,+BAA+B,CAAC,uDAAuD,CAAC,CAAA;QACpG,CAAC;IACH,CAAC;IAED,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;QAEpE,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,+BAA+B,CAAC,yDAAyD,CAAC,CAAA;QACtG,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,130 @@
1
+ import { describe, it } from 'node:test';
2
+ import { LocalizedString } from '@wisemen/localized-string';
3
+ import { Currency, Monetary } from '@wisemen/monetary';
4
+ import { customFieldDefinition } from '#src/factory/custom-field-definition.factory.js';
5
+ import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
6
+ import { validateCustomFieldValue } from '#src/validators/custom-field-value.validator.js';
7
+ import { CustomFieldValueValidationError } from '#src/validators/custom-field-value-validation.error.js';
8
+ import { expect } from 'expect';
9
+ describe('monetary validateCustomFieldValue', () => {
10
+ it('rejects a monetary custom field value with a disallowed currency', () => {
11
+ const definition = customFieldDefinition(CustomFieldType.MONETARY, {
12
+ tenantUuid: null,
13
+ entityType: 'invoice',
14
+ key: 'amount',
15
+ label: new LocalizedString([{ locale: 'en', value: 'Amount' }]),
16
+ description: null,
17
+ isRequired: false,
18
+ rules: {
19
+ currencies: [Currency.EUR],
20
+ precision: 2
21
+ }
22
+ });
23
+ expect(() => validateCustomFieldValue(definition, {
24
+ definitionUuid: definition.uuid,
25
+ type: CustomFieldType.MONETARY,
26
+ value: new Monetary(100, Currency.USD, 2)
27
+ })).toThrow(new CustomFieldValueValidationError('Monetary custom field value must use an allowed currency'));
28
+ });
29
+ it('rejects a monetary custom field value with a mismatched precision', () => {
30
+ const definition = customFieldDefinition(CustomFieldType.MONETARY, {
31
+ tenantUuid: null,
32
+ entityType: 'invoice',
33
+ key: 'amount',
34
+ label: new LocalizedString([{ locale: 'en', value: 'Amount' }]),
35
+ description: null,
36
+ isRequired: false,
37
+ rules: {
38
+ precision: 2
39
+ }
40
+ });
41
+ expect(() => validateCustomFieldValue(definition, {
42
+ definitionUuid: definition.uuid,
43
+ type: CustomFieldType.MONETARY,
44
+ value: new Monetary(100, Currency.EUR, 3)
45
+ })).toThrow(new CustomFieldValueValidationError('Monetary custom field value precision must match the configured precision'));
46
+ });
47
+ it('rejects a monetary custom field definition without rules', () => {
48
+ const definition = {
49
+ ...customFieldDefinition(CustomFieldType.MONETARY, {
50
+ tenantUuid: null,
51
+ entityType: 'invoice',
52
+ key: 'amount',
53
+ label: new LocalizedString([{ locale: 'en', value: 'Amount' }]),
54
+ description: null,
55
+ isRequired: false,
56
+ rules: {
57
+ precision: 2
58
+ }
59
+ }),
60
+ rules: null
61
+ };
62
+ expect(() => validateCustomFieldValue(definition, {
63
+ definitionUuid: definition.uuid,
64
+ type: CustomFieldType.MONETARY,
65
+ value: new Monetary(100, Currency.EUR, 2)
66
+ })).toThrow(new CustomFieldValueValidationError('Monetary custom field definition must define rules'));
67
+ });
68
+ it('rejects a monetary custom field definition without precision', () => {
69
+ const definition = {
70
+ ...customFieldDefinition(CustomFieldType.MONETARY, {
71
+ tenantUuid: null,
72
+ entityType: 'invoice',
73
+ key: 'amount',
74
+ label: new LocalizedString([{ locale: 'en', value: 'Amount' }]),
75
+ description: null,
76
+ isRequired: false,
77
+ rules: {
78
+ precision: 2
79
+ }
80
+ }),
81
+ rules: {
82
+ type: CustomFieldType.MONETARY
83
+ }
84
+ };
85
+ expect(() => validateCustomFieldValue(definition, {
86
+ definitionUuid: definition.uuid,
87
+ type: CustomFieldType.MONETARY,
88
+ value: new Monetary(100, Currency.EUR, 2)
89
+ })).toThrow(new CustomFieldValueValidationError('Monetary custom field definition must define precision'));
90
+ });
91
+ it('rejects a monetary custom field value lower than min', () => {
92
+ const definition = customFieldDefinition(CustomFieldType.MONETARY, {
93
+ tenantUuid: null,
94
+ entityType: 'invoice',
95
+ key: 'amount',
96
+ label: new LocalizedString([{ locale: 'en', value: 'Amount' }]),
97
+ description: null,
98
+ isRequired: false,
99
+ rules: {
100
+ precision: 2,
101
+ min: 100
102
+ }
103
+ });
104
+ expect(() => validateCustomFieldValue(definition, {
105
+ definitionUuid: definition.uuid,
106
+ type: CustomFieldType.MONETARY,
107
+ value: new Monetary(99, Currency.EUR, 2)
108
+ })).toThrow(new CustomFieldValueValidationError('Monetary custom field value can not be lower than min'));
109
+ });
110
+ it('rejects a monetary custom field value greater than max', () => {
111
+ const definition = customFieldDefinition(CustomFieldType.MONETARY, {
112
+ tenantUuid: null,
113
+ entityType: 'invoice',
114
+ key: 'amount',
115
+ label: new LocalizedString([{ locale: 'en', value: 'Amount' }]),
116
+ description: null,
117
+ isRequired: false,
118
+ rules: {
119
+ precision: 2,
120
+ max: 100
121
+ }
122
+ });
123
+ expect(() => validateCustomFieldValue(definition, {
124
+ definitionUuid: definition.uuid,
125
+ type: CustomFieldType.MONETARY,
126
+ value: new Monetary(101, Currency.EUR, 2)
127
+ })).toThrow(new CustomFieldValueValidationError('Monetary custom field value can not be greater than max'));
128
+ });
129
+ });
130
+ //# sourceMappingURL=monetary.custom-field-value.validator.unit.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monetary.custom-field-value.validator.unit.test.js","sourceRoot":"","sources":["../../../lib/custom-field-types/monetary/monetary.custom-field-value.validator.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,C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Q,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC;SAC1C,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,+BAA+B,CAAC,yDAAyD,CAAC,CAAC,CAAA;IAC7G,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ import type { ResolvedCustomFieldDefinitionFields } from '#src/custom-field-definition.js';
2
+ import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
3
+ type MonetaryCustomFieldDefinition = Extract<ResolvedCustomFieldDefinitionFields, {
4
+ type: CustomFieldType.MONETARY;
5
+ }>;
6
+ export declare function validateMonetaryCustomFieldDefinition(definition: MonetaryCustomFieldDefinition): void;
7
+ export {};
@@ -0,0 +1,25 @@
1
+ import { CustomFieldDefinitionError } from '#src/errors/custom-field-definition.error.js';
2
+ export function validateMonetaryCustomFieldDefinition(definition) {
3
+ if (definition.choices !== null) {
4
+ throw new CustomFieldDefinitionError('Only select custom fields can define choices');
5
+ }
6
+ const rules = definition.rules;
7
+ if (rules === null) {
8
+ throw new CustomFieldDefinitionError('Monetary custom field rules are required');
9
+ }
10
+ if (rules.currencies !== undefined && rules.currencies.length === 0) {
11
+ throw new CustomFieldDefinitionError('Monetary custom field must define at least one allowed currency');
12
+ }
13
+ if (rules.precision === undefined) {
14
+ throw new CustomFieldDefinitionError('Monetary custom field precision is required');
15
+ }
16
+ if (rules.precision <= 0) {
17
+ throw new CustomFieldDefinitionError('Monetary custom field precision must be greater than zero');
18
+ }
19
+ if (rules.min !== undefined
20
+ && rules.max !== undefined
21
+ && rules.min > rules.max) {
22
+ throw new CustomFieldDefinitionError('Monetary custom field min can not be greater than max');
23
+ }
24
+ }
25
+ //# sourceMappingURL=monetary.definition-validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monetary.definition-validation.js","sourceRoot":"","sources":["../../../lib/custom-field-types/monetary/monetary.definition-validation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAA;AAKzF,MAAM,UAAU,qCAAqC,CAAC,UAAyC;IAC7F,IAAI,UAAU,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAChC,MAAM,IAAI,0BAA0B,CAAC,8CAA8C,CAAC,CAAA;IACtF,CAAC;IAED,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAA;IAE9B,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,0BAA0B,CAAC,0CAA0C,CAAC,CAAA;IAClF,CAAC;IAED,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpE,MAAM,IAAI,0BAA0B,CAAC,iEAAiE,CAAC,CAAA;IACzG,CAAC;IAED,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAClC,MAAM,IAAI,0BAA0B,CAAC,6CAA6C,CAAC,CAAA;IACrF,CAAC;IAED,IAAI,KAAK,CAAC,SAAS,IAAI,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,0BAA0B,CAAC,2DAA2D,CAAC,CAAA;IACnG,CAAC;IAED,IACE,KAAK,CAAC,GAAG,KAAK,SAAS;WACpB,KAAK,CAAC,GAAG,KAAK,SAAS;WACvB,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,EACxB,CAAC;QACD,MAAM,IAAI,0BAA0B,CAAC,uDAAuD,CAAC,CAAA;IAC/F,CAAC;AACH,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { Currency, MonetaryDto } from '@wisemen/monetary';
2
+ import { BaseCustomFieldValueDto } from '#src/dto/base-custom-field-value.dto.js';
3
+ import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
4
+ import { MonetaryCustomFieldValue } from '#src/custom-field-types/monetary/monetary.value.js';
5
+ export declare class MonetaryCustomFieldValueDto extends BaseCustomFieldValueDto {
6
+ type: CustomFieldType.MONETARY;
7
+ value: MonetaryDto<Currency>;
8
+ parse(): MonetaryCustomFieldValue;
9
+ static from(customFieldValue: MonetaryCustomFieldValue): MonetaryCustomFieldValueDto;
10
+ }
@@ -0,0 +1,34 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { ApiProperty } from '@nestjs/swagger';
11
+ import { IsMonetary, MonetaryDto } from '@wisemen/monetary';
12
+ import { IsEnum } from 'class-validator';
13
+ import { BaseCustomFieldValueDto, createCustomFieldValueDto } from '#src/dto/base-custom-field-value.dto.js';
14
+ import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
15
+ export class MonetaryCustomFieldValueDto extends BaseCustomFieldValueDto {
16
+ value;
17
+ parse() {
18
+ return this.toCustomFieldValue(CustomFieldType.MONETARY, this.value.parse());
19
+ }
20
+ static from(customFieldValue) {
21
+ return createCustomFieldValueDto(new MonetaryCustomFieldValueDto(), CustomFieldType.MONETARY, customFieldValue.definitionUuid, MonetaryDto.from(customFieldValue.value));
22
+ }
23
+ }
24
+ __decorate([
25
+ ApiProperty({ enum: [CustomFieldType.MONETARY] }),
26
+ IsEnum([CustomFieldType.MONETARY]),
27
+ __metadata("design:type", String)
28
+ ], MonetaryCustomFieldValueDto.prototype, "type", void 0);
29
+ __decorate([
30
+ ApiProperty({ type: MonetaryDto }),
31
+ IsMonetary(),
32
+ __metadata("design:type", MonetaryDto)
33
+ ], MonetaryCustomFieldValueDto.prototype, "value", void 0);
34
+ //# sourceMappingURL=monetary.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monetary.dto.js","sourceRoot":"","sources":["../../../lib/custom-field-types/monetary/monetary.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAY,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAA;AAC5G,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAGrE,MAAM,OAAO,2BAA4B,SAAQ,uBAAuB;IAOtE,KAAK,CAAuB;IAE5B,KAAK;QACH,OAAO,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAA;IAC9E,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,gBAA0C;QACpD,OAAO,yBAAyB,CAC9B,IAAI,2BAA2B,EAAE,EACjC,eAAe,CAAC,QAAQ,EACxB,gBAAgB,CAAC,cAAc,EAC/B,WAAW,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CACzC,CAAA;IACH,CAAC;CACF;AAlBS;IAFP,WAAW,CAAC,EAAE,IAAI,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC;IACjD,MAAM,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;;yDACG;AAItC;IAFC,WAAW,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IAClC,UAAU,EAAE;8BACN,WAAW;0DAAU"}
@@ -0,0 +1,5 @@
1
+ import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
2
+ import type { MonetaryCustomFieldTypeContract } from './monetary.contract.js';
3
+ export type MonetaryCustomFieldRules = {
4
+ type: CustomFieldType.MONETARY;
5
+ } & MonetaryCustomFieldTypeContract['rules'];
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=monetary.rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monetary.rules.js","sourceRoot":"","sources":["../../../lib/custom-field-types/monetary/monetary.rules.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { BaseCustomFieldValue } from '#src/custom-field-value.js';
2
+ import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
3
+ import type { MonetaryCustomFieldTypeContract } from './monetary.contract.js';
4
+ export type MonetaryCustomFieldValue = BaseCustomFieldValue<CustomFieldType.MONETARY, MonetaryCustomFieldTypeContract['value']>;
5
+ export type MonetaryCustomFieldColumnValue = BaseCustomFieldValue<CustomFieldType.MONETARY, MonetaryCustomFieldTypeContract['columnValue']>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=monetary.value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monetary.value.js","sourceRoot":"","sources":["../../../lib/custom-field-types/monetary/monetary.value.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export * from './multi-select.contract.js';
2
+ export * from './multi-select.definition-validation.js';
3
+ export * from './multi-select.dto.js';
4
+ export * from './multi-select.rules.js';
5
+ export * from './multi-select.custom-field-value.validator.js';
6
+ export * from './multi-select.value.js';
@@ -0,0 +1,7 @@
1
+ export * from './multi-select.contract.js';
2
+ export * from './multi-select.definition-validation.js';
3
+ export * from './multi-select.dto.js';
4
+ export * from './multi-select.rules.js';
5
+ export * from './multi-select.custom-field-value.validator.js';
6
+ export * from './multi-select.value.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/custom-field-types/multi-select/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yCAAyC,CAAA;AACvD,cAAc,uBAAuB,CAAA;AACrC,cAAc,yBAAyB,CAAA;AACvC,cAAc,gDAAgD,CAAA;AAC9D,cAAc,yBAAyB,CAAA"}
@@ -0,0 +1,11 @@
1
+ import type { DefineContract } from '#src/custom-field-type-contract.js';
2
+ export type MultiSelectCustomFieldTypeContract = DefineContract<{
3
+ value: string[];
4
+ columnValue: string[];
5
+ rules: {
6
+ minSelections?: number;
7
+ maxSelections?: number;
8
+ };
9
+ rulesMode: 'optional';
10
+ choicesMode: 'required';
11
+ }>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=multi-select.contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi-select.contract.js","sourceRoot":"","sources":["../../../lib/custom-field-types/multi-select/multi-select.contract.ts"],"names":[],"mappings":""}
@@ -0,0 +1,169 @@
1
+ import { describe, it } from 'node:test';
2
+ import { expect } from 'expect';
3
+ import { LocalizedString } from '@wisemen/localized-string';
4
+ import { CustomFieldDefinitionError } from '#src/errors/custom-field-definition.error.js';
5
+ import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
6
+ import { customFieldDefinition } from '#src/factory/custom-field-definition.factory.js';
7
+ describe('multi select customFieldDefinition', () => {
8
+ it('creates a multi select custom field definition', () => {
9
+ const definition = customFieldDefinition(CustomFieldType.MULTI_SELECT, {
10
+ tenantUuid: null,
11
+ entityType: 'invoice',
12
+ key: 'labels',
13
+ label: new LocalizedString([{ locale: 'en', value: 'Labels' }]),
14
+ description: null,
15
+ isRequired: false,
16
+ choices: [
17
+ {
18
+ value: 'first',
19
+ label: new LocalizedString([{ locale: 'en', value: 'First' }]),
20
+ order: 1
21
+ },
22
+ {
23
+ value: 'second',
24
+ label: new LocalizedString([{ locale: 'en', value: 'Second' }]),
25
+ order: 2
26
+ }
27
+ ],
28
+ rules: {
29
+ minSelections: 1,
30
+ maxSelections: 2
31
+ }
32
+ });
33
+ expect(definition.type).toBe(CustomFieldType.MULTI_SELECT);
34
+ expect(definition.choices).toEqual([
35
+ {
36
+ value: 'first',
37
+ label: new LocalizedString([{ locale: 'en', value: 'First' }]),
38
+ order: 1
39
+ },
40
+ {
41
+ value: 'second',
42
+ label: new LocalizedString([{ locale: 'en', value: 'Second' }]),
43
+ order: 2
44
+ }
45
+ ]);
46
+ expect(definition.rules).toEqual({
47
+ type: CustomFieldType.MULTI_SELECT,
48
+ minSelections: 1,
49
+ maxSelections: 2
50
+ });
51
+ });
52
+ it('rejects a multi select field whose minSelections is negative', () => {
53
+ expect(() => customFieldDefinition(CustomFieldType.MULTI_SELECT, {
54
+ tenantUuid: null,
55
+ entityType: 'invoice',
56
+ key: 'labels',
57
+ label: new LocalizedString([{ locale: 'en', value: 'Labels' }]),
58
+ description: null,
59
+ isRequired: false,
60
+ choices: [
61
+ {
62
+ value: 'first',
63
+ label: new LocalizedString([{ locale: 'en', value: 'First' }]),
64
+ order: 1
65
+ }
66
+ ],
67
+ rules: {
68
+ minSelections: -1
69
+ }
70
+ })).toThrow(new CustomFieldDefinitionError('Multi select custom field minSelections can not be negative'));
71
+ });
72
+ it('rejects a multi select field whose maxSelections is negative', () => {
73
+ expect(() => customFieldDefinition(CustomFieldType.MULTI_SELECT, {
74
+ tenantUuid: null,
75
+ entityType: 'invoice',
76
+ key: 'labels',
77
+ label: new LocalizedString([{ locale: 'en', value: 'Labels' }]),
78
+ description: null,
79
+ isRequired: false,
80
+ choices: [
81
+ {
82
+ value: 'first',
83
+ label: new LocalizedString([{ locale: 'en', value: 'First' }]),
84
+ order: 1
85
+ }
86
+ ],
87
+ rules: {
88
+ maxSelections: -1
89
+ }
90
+ })).toThrow(new CustomFieldDefinitionError('Multi select custom field maxSelections can not be negative'));
91
+ });
92
+ it('rejects a multi select field whose minSelections exceeds maxSelections', () => {
93
+ expect(() => customFieldDefinition(CustomFieldType.MULTI_SELECT, {
94
+ tenantUuid: null,
95
+ entityType: 'invoice',
96
+ key: 'labels',
97
+ label: new LocalizedString([{ locale: 'en', value: 'Labels' }]),
98
+ description: null,
99
+ isRequired: false,
100
+ choices: [
101
+ {
102
+ value: 'first',
103
+ label: new LocalizedString([{ locale: 'en', value: 'First' }]),
104
+ order: 1
105
+ },
106
+ {
107
+ value: 'second',
108
+ label: new LocalizedString([{ locale: 'en', value: 'Second' }]),
109
+ order: 2
110
+ }
111
+ ],
112
+ rules: {
113
+ minSelections: 2,
114
+ maxSelections: 1
115
+ }
116
+ })).toThrow(new CustomFieldDefinitionError('Multi select custom field minSelections can not be greater than maxSelections'));
117
+ });
118
+ it('rejects a multi select field whose minSelections exceeds the amount of choices', () => {
119
+ expect(() => customFieldDefinition(CustomFieldType.MULTI_SELECT, {
120
+ tenantUuid: null,
121
+ entityType: 'invoice',
122
+ key: 'labels',
123
+ label: new LocalizedString([{ locale: 'en', value: 'Labels' }]),
124
+ description: null,
125
+ isRequired: false,
126
+ choices: [
127
+ {
128
+ value: 'first',
129
+ label: new LocalizedString([{ locale: 'en', value: 'First' }]),
130
+ order: 1
131
+ },
132
+ {
133
+ value: 'second',
134
+ label: new LocalizedString([{ locale: 'en', value: 'Second' }]),
135
+ order: 2
136
+ }
137
+ ],
138
+ rules: {
139
+ minSelections: 3
140
+ }
141
+ })).toThrow(new CustomFieldDefinitionError('Multi select custom field minSelections can not exceed the amount of choices'));
142
+ });
143
+ it('rejects a multi select field whose maxSelections exceeds the amount of choices', () => {
144
+ expect(() => customFieldDefinition(CustomFieldType.MULTI_SELECT, {
145
+ tenantUuid: null,
146
+ entityType: 'invoice',
147
+ key: 'labels',
148
+ label: new LocalizedString([{ locale: 'en', value: 'Labels' }]),
149
+ description: null,
150
+ isRequired: false,
151
+ choices: [
152
+ {
153
+ value: 'first',
154
+ label: new LocalizedString([{ locale: 'en', value: 'First' }]),
155
+ order: 1
156
+ },
157
+ {
158
+ value: 'second',
159
+ label: new LocalizedString([{ locale: 'en', value: 'Second' }]),
160
+ order: 2
161
+ }
162
+ ],
163
+ rules: {
164
+ maxSelections: 3
165
+ }
166
+ })).toThrow(new CustomFieldDefinitionError('Multi select custom field maxSelections can not exceed the amount of choices'));
167
+ });
168
+ });
169
+ //# sourceMappingURL=multi-select.custom-field-definition.factory.unit.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi-select.custom-field-definition.factory.unit.test.js","sourceRoot":"","sources":["../../../lib/custom-field-types/multi-select/multi-select.custom-field-definition.factory.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAA;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAA;AAEvF,QAAQ,CAAC,oCAAoC,EAAE,GAAG,EAAE;IAClD,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,MAAM,UAAU,GAAG,qBAAqB,CAAC,eAAe,CAAC,YAAY,EAAE;YACrE,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,SAAS;YACrB,GAAG,EAAE,QAAQ;YACb,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;YAC/D,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,KAAK;YACjB,OAAO,EAAE;gBACP;oBACE,KAAK,EAAE,OAAO;oBACd,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;oBAC9D,KAAK,EAAE,CAAC;iBACT;gBACD;oBACE,KAAK,EAAE,QA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B,CAAC,8EAA8E,CAAC,CAAC,CAAA;IAC7H,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import type { CustomFieldDefinitionFieldsByType } from '#src/custom-field-definition.js';
2
+ import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
3
+ type MultiSelectCustomFieldDefinition = CustomFieldDefinitionFieldsByType<CustomFieldType.MULTI_SELECT>;
4
+ export declare function validateMultiSelectCustomFieldValue(definition: MultiSelectCustomFieldDefinition, value: string[]): void;
5
+ export {};
@@ -0,0 +1,25 @@
1
+ import { CustomFieldValueValidationError } from '#src/validators/custom-field-value-validation.error.js';
2
+ export function validateMultiSelectCustomFieldValue(definition, value) {
3
+ if (definition.choices === null) {
4
+ throw new CustomFieldValueValidationError('Select custom field definition must define choices');
5
+ }
6
+ for (const selectedValue of value) {
7
+ if (!definition.choices.some(choice => choice.value === selectedValue)) {
8
+ throw new CustomFieldValueValidationError('Multi select custom field value must only contain defined choices');
9
+ }
10
+ }
11
+ if (new Set(value).size !== value.length) {
12
+ throw new CustomFieldValueValidationError('Multi select custom field value can not contain duplicate values');
13
+ }
14
+ const rules = definition.rules;
15
+ if (rules === null) {
16
+ return;
17
+ }
18
+ if (rules.minSelections !== undefined && value.length < rules.minSelections) {
19
+ throw new CustomFieldValueValidationError('Multi select custom field value can not contain fewer than minSelections');
20
+ }
21
+ if (rules.maxSelections !== undefined && value.length > rules.maxSelections) {
22
+ throw new CustomFieldValueValidationError('Multi select custom field value can not contain more than maxSelections');
23
+ }
24
+ }
25
+ //# sourceMappingURL=multi-select.custom-field-value.validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi-select.custom-field-value.validator.js","sourceRoot":"","sources":["../../../lib/custom-field-types/multi-select/multi-select.custom-field-value.validator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,+BAA+B,EAAE,MAAM,wDAAwD,CAAA;AAKxG,MAAM,UAAU,mCAAmC,CACjD,UAA4C,EAC5C,KAAe;IAEf,IAAI,UAAU,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAChC,MAAM,IAAI,+BAA+B,CAAC,oDAAoD,CAAC,CAAA;IACjG,CAAC;IAED,KAAK,MAAM,aAAa,IAAI,KAAK,EAAE,CAAC;QAClC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,aAAa,CAAC,EAAE,CAAC;YACvE,MAAM,IAAI,+BAA+B,CAAC,mEAAmE,CAAC,CAAA;QAChH,CAAC;IACH,CAAC;IAED,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;QACzC,MAAM,IAAI,+BAA+B,CAAC,kEAAkE,CAAC,CAAA;IAC/G,CAAC;IAED,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAA;IAE9B,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,OAAM;IACR,CAAC;IAED,IAAI,KAAK,CAAC,aAAa,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,aAAa,EAAE,CAAC;QAC5E,MAAM,IAAI,+BAA+B,CAAC,0EAA0E,CAAC,CAAA;IACvH,CAAC;IAED,IAAI,KAAK,CAAC,aAAa,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,aAAa,EAAE,CAAC;QAC5E,MAAM,IAAI,+BAA+B,CAAC,yEAAyE,CAAC,CAAA;IACtH,CAAC;AACH,CAAC"}