@wisemen/nestjs-custom-fields 0.0.0 → 0.0.1

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,100 @@
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('single select customFieldDefinition', () => {
8
+ it('creates a single select custom field definition', () => {
9
+ const definition = customFieldDefinition(CustomFieldType.SINGLE_SELECT, {
10
+ tenantUuid: null,
11
+ entityType: 'invoice',
12
+ key: 'status',
13
+ label: new LocalizedString([{ locale: 'en', value: 'Status' }]),
14
+ description: null,
15
+ isRequired: true,
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
+ });
29
+ expect(definition.type).toBe(CustomFieldType.SINGLE_SELECT);
30
+ expect(definition.choices).toEqual([
31
+ {
32
+ value: 'first',
33
+ label: new LocalizedString([{ locale: 'en', value: 'First' }]),
34
+ order: 1
35
+ },
36
+ {
37
+ value: 'second',
38
+ label: new LocalizedString([{ locale: 'en', value: 'Second' }]),
39
+ order: 2
40
+ }
41
+ ]);
42
+ expect(definition.rules).toBeNull();
43
+ });
44
+ it('rejects a single select field without choices', () => {
45
+ expect(() => customFieldDefinition(CustomFieldType.SINGLE_SELECT, {
46
+ tenantUuid: null,
47
+ entityType: 'invoice',
48
+ key: 'status',
49
+ label: new LocalizedString([{ locale: 'en', value: 'Status' }]),
50
+ description: null,
51
+ isRequired: false,
52
+ choices: []
53
+ })).toThrow(new CustomFieldDefinitionError('Select custom field must define at least one choice'));
54
+ });
55
+ it('rejects a select field with duplicate choice values', () => {
56
+ expect(() => customFieldDefinition(CustomFieldType.SINGLE_SELECT, {
57
+ tenantUuid: null,
58
+ entityType: 'invoice',
59
+ key: 'status',
60
+ label: new LocalizedString([{ locale: 'en', value: 'Status' }]),
61
+ description: null,
62
+ isRequired: false,
63
+ choices: [
64
+ {
65
+ value: 'first',
66
+ label: new LocalizedString([{ locale: 'en', value: 'First' }]),
67
+ order: 1
68
+ },
69
+ {
70
+ value: 'first',
71
+ label: new LocalizedString([{ locale: 'en', value: 'Duplicate first' }]),
72
+ order: 2
73
+ }
74
+ ]
75
+ })).toThrow(new CustomFieldDefinitionError('Custom field choice value must be unique'));
76
+ });
77
+ it('rejects a select field with duplicate choice orders', () => {
78
+ expect(() => customFieldDefinition(CustomFieldType.SINGLE_SELECT, {
79
+ tenantUuid: null,
80
+ entityType: 'invoice',
81
+ key: 'status',
82
+ label: new LocalizedString([{ locale: 'en', value: 'Status' }]),
83
+ description: null,
84
+ isRequired: false,
85
+ choices: [
86
+ {
87
+ value: 'first',
88
+ label: new LocalizedString([{ locale: 'en', value: 'First' }]),
89
+ order: 1
90
+ },
91
+ {
92
+ value: 'second',
93
+ label: new LocalizedString([{ locale: 'en', value: 'Second' }]),
94
+ order: 1
95
+ }
96
+ ]
97
+ })).toThrow(new CustomFieldDefinitionError('Custom field choice order must be unique'));
98
+ });
99
+ });
100
+ //# sourceMappingURL=single-select.custom-field-definition.factory.unit.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single-select.custom-field-definition.factory.unit.test.js","sourceRoot":"","sources":["../../../lib/custom-field-types/single-select/single-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,qCAAqC,EAAE,GAAG,EAAE;IACnD,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,UAAU,GAAG,qBAAqB,CAAC,eAAe,CAAC,aAAa,EAAE;YACtE,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,IAAI;YAChB,OAAO,EAAE;gBACP;oBACE,KAAK,EAAE,OAAO;oBACd,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CA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jB,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,QAAQ;oBACf,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;oBAC/D,KAAK,EAAE,CAAC;iBACT;aACF;SACF,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,0BAA0B,CAAC,0CAA0C,CAAC,CAAC,CAAA;IACzF,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 SingleSelectCustomFieldDefinition = CustomFieldDefinitionFieldsByType<CustomFieldType.SINGLE_SELECT>;
4
+ export declare function validateSingleSelectCustomFieldValue(definition: SingleSelectCustomFieldDefinition, value: string): void;
5
+ export {};
@@ -0,0 +1,10 @@
1
+ import { CustomFieldValueValidationError } from '#src/validators/custom-field-value-validation.error.js';
2
+ export function validateSingleSelectCustomFieldValue(definition, value) {
3
+ if (definition.choices === null) {
4
+ throw new CustomFieldValueValidationError('Select custom field definition must define choices');
5
+ }
6
+ if (!definition.choices.some(choice => choice.value === value)) {
7
+ throw new CustomFieldValueValidationError('Single select custom field value must be one of the defined choices');
8
+ }
9
+ }
10
+ //# sourceMappingURL=single-select.custom-field-value.validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single-select.custom-field-value.validator.js","sourceRoot":"","sources":["../../../lib/custom-field-types/single-select/single-select.custom-field-value.validator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,+BAA+B,EAAE,MAAM,wDAAwD,CAAA;AAKxG,MAAM,UAAU,oCAAoC,CAClD,UAA6C,EAC7C,KAAa;IAEb,IAAI,UAAU,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAChC,MAAM,IAAI,+BAA+B,CAAC,oDAAoD,CAAC,CAAA;IACjG,CAAC;IAED,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,KAAK,CAAC,EAAE,CAAC;QAC/D,MAAM,IAAI,+BAA+B,CAAC,qEAAqE,CAAC,CAAA;IAClH,CAAC;AACH,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { describe, it } from 'node:test';
2
+ import { LocalizedString } from '@wisemen/localized-string';
3
+ import { customFieldDefinition } from '#src/factory/custom-field-definition.factory.js';
4
+ import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
5
+ import { validateCustomFieldValue } from '#src/validators/custom-field-value.validator.js';
6
+ import { CustomFieldValueValidationError } from '#src/validators/custom-field-value-validation.error.js';
7
+ import { expect } from 'expect';
8
+ describe('single select validateCustomFieldValue', () => {
9
+ it('rejects a single select custom field value outside the defined choices', () => {
10
+ const definition = customFieldDefinition(CustomFieldType.SINGLE_SELECT, {
11
+ tenantUuid: null,
12
+ entityType: 'invoice',
13
+ key: 'status',
14
+ label: new LocalizedString([{ locale: 'en', value: 'Status' }]),
15
+ description: null,
16
+ isRequired: false,
17
+ choices: [
18
+ {
19
+ value: 'draft',
20
+ label: new LocalizedString([{ locale: 'en', value: 'Draft' }]),
21
+ order: 1
22
+ }
23
+ ]
24
+ });
25
+ expect(() => validateCustomFieldValue(definition, {
26
+ definitionUuid: definition.uuid,
27
+ type: CustomFieldType.SINGLE_SELECT,
28
+ value: 'sent'
29
+ })).toThrow(new CustomFieldValueValidationError('Single select custom field value must be one of the defined choices'));
30
+ });
31
+ it('rejects a single select custom field definition without choices', () => {
32
+ const definition = {
33
+ ...customFieldDefinition(CustomFieldType.SINGLE_SELECT, {
34
+ tenantUuid: null,
35
+ entityType: 'invoice',
36
+ key: 'status',
37
+ label: new LocalizedString([{ locale: 'en', value: 'Status' }]),
38
+ description: null,
39
+ isRequired: false,
40
+ choices: [
41
+ {
42
+ value: 'draft',
43
+ label: new LocalizedString([{ locale: 'en', value: 'Draft' }]),
44
+ order: 1
45
+ }
46
+ ]
47
+ }),
48
+ choices: null
49
+ };
50
+ expect(() => validateCustomFieldValue(definition, {
51
+ definitionUuid: definition.uuid,
52
+ type: CustomFieldType.SINGLE_SELECT,
53
+ value: 'draft'
54
+ })).toThrow(new CustomFieldValueValidationError('Select custom field definition must define choices'));
55
+ });
56
+ });
57
+ //# sourceMappingURL=single-select.custom-field-value.validator.unit.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single-select.custom-field-value.validator.unit.test.js","sourceRoot":"","sources":["../../../lib/custom-field-types/single-select/single-select.custom-field-value.validator.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAA;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAA;AAE1F,OAAO,EAAE,+BAA+B,EAAE,MAAM,wDAAwD,CAAA;AACxG,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,QAAQ,CAAC,wCAAwC,EAAE,GAAG,EAAE;IACtD,EAAE,CAAC,wEAAwE,EAAE,GAAG,EAAE;QAChF,MAAM,UAAU,GAAG,qBAAqB,CAAC,eAAe,CAAC,aAAa,EAAE;YACtE,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,SAAS;YACrB,GAAG,EAAE,QAAQ;YACb,KAAK,EAAE,IAAI,e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,EAAE,CAAC,wBAAwB,CAAC,UAAU,EAAE;YAChD,cAAc,EAAE,UAAU,CAAC,IAAI;YAC/B,IAAI,EAAE,eAAe,CAAC,aAAa;YACnC,KAAK,EAAE,OAAO;SACf,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,+BAA+B,CAAC,oDAAoD,CAAC,CAAC,CAAA;IACxG,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 SingleSelectCustomFieldDefinition = Extract<ResolvedCustomFieldDefinitionFields, {
4
+ type: CustomFieldType.SINGLE_SELECT;
5
+ }>;
6
+ export declare function validateSingleSelectCustomFieldDefinition(definition: SingleSelectCustomFieldDefinition): void;
7
+ export {};
@@ -0,0 +1,25 @@
1
+ import { CustomFieldDefinitionError } from '#src/errors/custom-field-definition.error.js';
2
+ export function validateSingleSelectCustomFieldDefinition(definition) {
3
+ if (definition.rules !== null) {
4
+ throw new CustomFieldDefinitionError('Single select custom field can not define rules');
5
+ }
6
+ validateSelectChoices(definition.choices);
7
+ }
8
+ function validateSelectChoices(choices) {
9
+ if (choices.length === 0) {
10
+ throw new CustomFieldDefinitionError('Select custom field must define at least one choice');
11
+ }
12
+ const choiceValues = new Set();
13
+ const choiceOrders = new Set();
14
+ for (const choice of choices) {
15
+ if (choiceValues.has(choice.value)) {
16
+ throw new CustomFieldDefinitionError('Custom field choice value must be unique');
17
+ }
18
+ if (choiceOrders.has(choice.order)) {
19
+ throw new CustomFieldDefinitionError('Custom field choice order must be unique');
20
+ }
21
+ choiceValues.add(choice.value);
22
+ choiceOrders.add(choice.order);
23
+ }
24
+ }
25
+ //# sourceMappingURL=single-select.definition-validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single-select.definition-validation.js","sourceRoot":"","sources":["../../../lib/custom-field-types/single-select/single-select.definition-validation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAA;AAKzF,MAAM,UAAU,yCAAyC,CAAC,UAA6C;IACrG,IAAI,UAAU,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QAC9B,MAAM,IAAI,0BAA0B,CAAC,iDAAiD,CAAC,CAAA;IACzF,CAAC;IAED,qBAAqB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;AAC3C,CAAC;AAED,SAAS,qBAAqB,CAAC,OAA4B;IACzD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,0BAA0B,CAAC,qDAAqD,CAAC,CAAA;IAC7F,CAAC;IAED,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAA;IACtC,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAA;IAEtC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,0BAA0B,CAAC,0CAA0C,CAAC,CAAA;QAClF,CAAC;QAED,IAAI,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,0BAA0B,CAAC,0CAA0C,CAAC,CAAA;QAClF,CAAC;QAED,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAC9B,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAChC,CAAC;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { BaseCustomFieldValueDto } from '#src/dto/base-custom-field-value.dto.js';
2
+ import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
3
+ import { SingleSelectCustomFieldValue } from '#src/custom-field-types/single-select/single-select.value.js';
4
+ export declare class SingleSelectCustomFieldValueDto extends BaseCustomFieldValueDto {
5
+ type: CustomFieldType.SINGLE_SELECT;
6
+ value: string;
7
+ parse(): SingleSelectCustomFieldValue;
8
+ static from(customFieldValue: SingleSelectCustomFieldValue): SingleSelectCustomFieldValueDto;
9
+ }
@@ -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 { IsEnum, IsNotEmpty, IsString } from 'class-validator';
12
+ import { BaseCustomFieldValueDto, createCustomFieldValueDto } from '#src/dto/base-custom-field-value.dto.js';
13
+ import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
14
+ export class SingleSelectCustomFieldValueDto extends BaseCustomFieldValueDto {
15
+ value;
16
+ parse() {
17
+ return this.toCustomFieldValue(CustomFieldType.SINGLE_SELECT, this.value);
18
+ }
19
+ static from(customFieldValue) {
20
+ return createCustomFieldValueDto(new SingleSelectCustomFieldValueDto(), CustomFieldType.SINGLE_SELECT, customFieldValue.definitionUuid, customFieldValue.value);
21
+ }
22
+ }
23
+ __decorate([
24
+ ApiProperty({ enum: [CustomFieldType.SINGLE_SELECT] }),
25
+ IsEnum([CustomFieldType.SINGLE_SELECT]),
26
+ __metadata("design:type", String)
27
+ ], SingleSelectCustomFieldValueDto.prototype, "type", void 0);
28
+ __decorate([
29
+ ApiProperty({ type: String }),
30
+ IsString(),
31
+ IsNotEmpty(),
32
+ __metadata("design:type", String)
33
+ ], SingleSelectCustomFieldValueDto.prototype, "value", void 0);
34
+ //# sourceMappingURL=single-select.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single-select.dto.js","sourceRoot":"","sources":["../../../lib/custom-field-types/single-select/single-select.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC9D,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAA;AAC5G,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAGrE,MAAM,OAAO,+BAAgC,SAAQ,uBAAuB;IAQ1E,KAAK,CAAQ;IAEb,KAAK;QACH,OAAO,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;IAC3E,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,gBAA8C;QACxD,OAAO,yBAAyB,CAAC,IAAI,+BAA+B,EAAE,EAAE,eAAe,CAAC,aAAa,EAAE,gBAAgB,CAAC,cAAc,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACjK,CAAC;CACF;AAdS;IAFP,WAAW,CAAC,EAAE,IAAI,EAAE,CAAC,eAAe,CAAC,aAAa,CAAC,EAAE,CAAC;IACtD,MAAM,CAAC,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;;6DACG;AAK3C;IAHC,WAAW,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC7B,QAAQ,EAAE;IACV,UAAU,EAAE;;8DACA"}
@@ -0,0 +1,5 @@
1
+ import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
2
+ import type { SingleSelectCustomFieldTypeContract } from './single-select.contract.js';
3
+ export type SelectCustomFieldRules = {
4
+ type: CustomFieldType.SINGLE_SELECT;
5
+ } & SingleSelectCustomFieldTypeContract['rules'];
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=single-select.rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single-select.rules.js","sourceRoot":"","sources":["../../../lib/custom-field-types/single-select/single-select.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 { SingleSelectCustomFieldTypeContract } from './single-select.contract.js';
4
+ export type SingleSelectCustomFieldValue = BaseCustomFieldValue<CustomFieldType.SINGLE_SELECT, SingleSelectCustomFieldTypeContract['value']>;
5
+ export type SingleSelectCustomFieldColumnValue = BaseCustomFieldValue<CustomFieldType.SINGLE_SELECT, SingleSelectCustomFieldTypeContract['columnValue']>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=single-select.value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single-select.value.js","sourceRoot":"","sources":["../../../lib/custom-field-types/single-select/single-select.value.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export * from './text.contract.js';
2
+ export * from './text.definition-validation.js';
3
+ export * from './text.dto.js';
4
+ export * from './text.rules.js';
5
+ export * from './text.custom-field-value.validator.js';
6
+ export * from './text.value.js';
@@ -0,0 +1,7 @@
1
+ export * from './text.contract.js';
2
+ export * from './text.definition-validation.js';
3
+ export * from './text.dto.js';
4
+ export * from './text.rules.js';
5
+ export * from './text.custom-field-value.validator.js';
6
+ export * from './text.value.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wCAAwC,CAAA;AACtD,cAAc,iBAAiB,CAAA"}
@@ -0,0 +1,12 @@
1
+ import type { DefineContract } from '#src/custom-field-type-contract.js';
2
+ export type TextCustomFieldTypeContract = DefineContract<{
3
+ value: string;
4
+ columnValue: string;
5
+ rules: {
6
+ minLength?: number;
7
+ maxLength?: number;
8
+ regex?: string;
9
+ };
10
+ rulesMode: 'optional';
11
+ choicesMode: 'none';
12
+ }>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=text.contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.contract.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text/text.contract.ts"],"names":[],"mappings":""}
@@ -0,0 +1,128 @@
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 { generateUuid } from '#src/custom-field-definition.uuid.js';
6
+ import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
7
+ import { customFieldDefinition } from '#src/factory/custom-field-definition.factory.js';
8
+ describe('text customFieldDefinition', () => {
9
+ it('creates a text custom field definition', () => {
10
+ const tenantUuid = generateUuid();
11
+ const definition = customFieldDefinition(CustomFieldType.TEXT, {
12
+ tenantUuid,
13
+ entityType: 'invoice',
14
+ key: 'notes',
15
+ label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
16
+ description: new LocalizedString([{ locale: 'en', value: 'Invoice notes' }]),
17
+ isRequired: true,
18
+ rules: {
19
+ minLength: 2,
20
+ maxLength: 50,
21
+ regex: '^[a-zA-Z ]+$'
22
+ }
23
+ });
24
+ expect(definition.type).toBe(CustomFieldType.TEXT);
25
+ expect(definition.tenantUuid).toBe(tenantUuid);
26
+ expect(definition.choices).toBeNull();
27
+ expect(definition.rules).toEqual({
28
+ type: CustomFieldType.TEXT,
29
+ minLength: 2,
30
+ maxLength: 50,
31
+ regex: '^[a-zA-Z ]+$'
32
+ });
33
+ });
34
+ it('rejects a custom field whose entityType is empty', () => {
35
+ expect(() => customFieldDefinition(CustomFieldType.TEXT, {
36
+ tenantUuid: null,
37
+ entityType: ' ',
38
+ key: 'notes',
39
+ label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
40
+ description: null,
41
+ isRequired: false
42
+ })).toThrow(new CustomFieldDefinitionError('Custom field entityType can not be empty'));
43
+ });
44
+ it('rejects a custom field whose key is empty', () => {
45
+ expect(() => customFieldDefinition(CustomFieldType.TEXT, {
46
+ tenantUuid: null,
47
+ entityType: 'invoice',
48
+ key: ' ',
49
+ label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
50
+ description: null,
51
+ isRequired: false
52
+ })).toThrow(new CustomFieldDefinitionError('Custom field key can not be empty'));
53
+ });
54
+ it('rejects a custom field whose label has no translations', () => {
55
+ expect(() => customFieldDefinition(CustomFieldType.TEXT, {
56
+ tenantUuid: null,
57
+ entityType: 'invoice',
58
+ key: 'notes',
59
+ label: new LocalizedString([]),
60
+ description: null,
61
+ isRequired: false
62
+ })).toThrow(new CustomFieldDefinitionError('Custom field label must contain at least one translation'));
63
+ });
64
+ it('rejects a custom field whose description has no translations', () => {
65
+ expect(() => customFieldDefinition(CustomFieldType.TEXT, {
66
+ tenantUuid: null,
67
+ entityType: 'invoice',
68
+ key: 'notes',
69
+ label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
70
+ description: new LocalizedString([]),
71
+ isRequired: false
72
+ })).toThrow(new CustomFieldDefinitionError('Custom field description must contain at least one translation'));
73
+ });
74
+ it('rejects a text field whose minLength is negative', () => {
75
+ expect(() => customFieldDefinition(CustomFieldType.TEXT, {
76
+ tenantUuid: null,
77
+ entityType: 'invoice',
78
+ key: 'notes',
79
+ label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
80
+ description: null,
81
+ isRequired: false,
82
+ rules: {
83
+ minLength: -1
84
+ }
85
+ })).toThrow(new CustomFieldDefinitionError('Text custom field minLength can not be negative'));
86
+ });
87
+ it('rejects a text field whose maxLength is negative', () => {
88
+ expect(() => customFieldDefinition(CustomFieldType.TEXT, {
89
+ tenantUuid: null,
90
+ entityType: 'invoice',
91
+ key: 'notes',
92
+ label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
93
+ description: null,
94
+ isRequired: false,
95
+ rules: {
96
+ maxLength: -1
97
+ }
98
+ })).toThrow(new CustomFieldDefinitionError('Text custom field maxLength can not be negative'));
99
+ });
100
+ it('rejects a text field whose minLength exceeds maxLength', () => {
101
+ expect(() => customFieldDefinition(CustomFieldType.TEXT, {
102
+ tenantUuid: null,
103
+ entityType: 'invoice',
104
+ key: 'notes',
105
+ label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
106
+ description: null,
107
+ isRequired: false,
108
+ rules: {
109
+ minLength: 10,
110
+ maxLength: 5
111
+ }
112
+ })).toThrow(new CustomFieldDefinitionError('Text custom field minLength can not be greater than maxLength'));
113
+ });
114
+ it('rejects a text field whose regex is invalid', () => {
115
+ expect(() => customFieldDefinition(CustomFieldType.TEXT, {
116
+ tenantUuid: null,
117
+ entityType: 'invoice',
118
+ key: 'notes',
119
+ label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
120
+ description: null,
121
+ isRequired: false,
122
+ rules: {
123
+ regex: '['
124
+ }
125
+ })).toThrow(new CustomFieldDefinitionError('Text custom field regex must be a valid regular expression'));
126
+ });
127
+ });
128
+ //# sourceMappingURL=text.custom-field-definition.factory.unit.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.custom-field-definition.factory.unit.test.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text/text.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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;YACjB,UAAU,EAAE,KAAK;YACjB,KAAK,EAAE;gBACL,KAAK,EAAE,GAAG;aACX;SACF,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,0BAA0B,CAAC,4DAA4D,CAAC,CAAC,CAAA;IAC3G,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 TextCustomFieldDefinition = CustomFieldDefinitionFieldsByType<CustomFieldType.TEXT>;
4
+ export declare function validateTextCustomFieldValue(definition: TextCustomFieldDefinition, value: string): void;
5
+ export {};
@@ -0,0 +1,17 @@
1
+ import { CustomFieldValueValidationError } from '#src/validators/custom-field-value-validation.error.js';
2
+ export function validateTextCustomFieldValue(definition, value) {
3
+ const rules = definition.rules;
4
+ if (rules === null) {
5
+ return;
6
+ }
7
+ if (rules.minLength !== undefined && value.length < rules.minLength) {
8
+ throw new CustomFieldValueValidationError('Text custom field value can not be shorter than minLength');
9
+ }
10
+ if (rules.maxLength !== undefined && value.length > rules.maxLength) {
11
+ throw new CustomFieldValueValidationError('Text custom field value can not be longer than maxLength');
12
+ }
13
+ if (rules.regex !== undefined && !new RegExp(rules.regex).test(value)) {
14
+ throw new CustomFieldValueValidationError('Text custom field value must match the configured regex');
15
+ }
16
+ }
17
+ //# sourceMappingURL=text.custom-field-value.validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.custom-field-value.validator.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text/text.custom-field-value.validator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,+BAA+B,EAAE,MAAM,wDAAwD,CAAA;AAKxG,MAAM,UAAU,4BAA4B,CAC1C,UAAqC,EACrC,KAAa;IAEb,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAA;IAE9B,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,OAAM;IACR,CAAC;IAED,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QACpE,MAAM,IAAI,+BAA+B,CAAC,2DAA2D,CAAC,CAAA;IACxG,CAAC;IAED,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QACpE,MAAM,IAAI,+BAA+B,CAAC,0DAA0D,CAAC,CAAA;IACvG,CAAC;IAED,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACtE,MAAM,IAAI,+BAA+B,CAAC,yDAAyD,CAAC,CAAA;IACtG,CAAC;AACH,CAAC"}
@@ -0,0 +1,64 @@
1
+ import { describe, it } from 'node:test';
2
+ import { LocalizedString } from '@wisemen/localized-string';
3
+ import { customFieldDefinition } from '#src/factory/custom-field-definition.factory.js';
4
+ import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
5
+ import { validateCustomFieldValue } from '#src/validators/custom-field-value.validator.js';
6
+ import { CustomFieldValueValidationError } from '#src/validators/custom-field-value-validation.error.js';
7
+ import { expect } from 'expect';
8
+ describe('text validateCustomFieldValue', () => {
9
+ it('rejects a text custom field value shorter than minLength', () => {
10
+ const definition = customFieldDefinition(CustomFieldType.TEXT, {
11
+ tenantUuid: null,
12
+ entityType: 'invoice',
13
+ key: 'notes',
14
+ label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
15
+ description: null,
16
+ isRequired: false,
17
+ rules: {
18
+ minLength: 3
19
+ }
20
+ });
21
+ expect(() => validateCustomFieldValue(definition, {
22
+ definitionUuid: definition.uuid,
23
+ type: CustomFieldType.TEXT,
24
+ value: 'no'
25
+ })).toThrow(new CustomFieldValueValidationError('Text custom field value can not be shorter than minLength'));
26
+ });
27
+ it('rejects a text custom field value longer than maxLength', () => {
28
+ const definition = customFieldDefinition(CustomFieldType.TEXT, {
29
+ tenantUuid: null,
30
+ entityType: 'invoice',
31
+ key: 'notes',
32
+ label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
33
+ description: null,
34
+ isRequired: false,
35
+ rules: {
36
+ maxLength: 2
37
+ }
38
+ });
39
+ expect(() => validateCustomFieldValue(definition, {
40
+ definitionUuid: definition.uuid,
41
+ type: CustomFieldType.TEXT,
42
+ value: 'long'
43
+ })).toThrow(new CustomFieldValueValidationError('Text custom field value can not be longer than maxLength'));
44
+ });
45
+ it('rejects a text custom field value that does not match the regex', () => {
46
+ const definition = customFieldDefinition(CustomFieldType.TEXT, {
47
+ tenantUuid: null,
48
+ entityType: 'invoice',
49
+ key: 'notes',
50
+ label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
51
+ description: null,
52
+ isRequired: false,
53
+ rules: {
54
+ regex: '^[A-Z]+$'
55
+ }
56
+ });
57
+ expect(() => validateCustomFieldValue(definition, {
58
+ definitionUuid: definition.uuid,
59
+ type: CustomFieldType.TEXT,
60
+ value: 'lowercase'
61
+ })).toThrow(new CustomFieldValueValidationError('Text custom field value must match the configured regex'));
62
+ });
63
+ });
64
+ //# sourceMappingURL=text.custom-field-value.validator.unit.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.custom-field-value.validator.unit.test.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text/text.custom-field-value.validator.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAA;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAA;AAC1F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AAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,UAAU,EAAE;YAChD,cAAc,EAAE,UAAU,CAAC,IAAI;YAC/B,IAAI,EAAE,eAAe,CAAC,IAAI;YAC1B,KAAK,EAAE,MAAM;SACd,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,+BAA+B,CAAC,0DAA0D,CAAC,CAAC,CAAA;IAC9G,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;QACzE,MAAM,UAAU,GAAG,qBAAqB,CAAC,eAAe,CAAC,IAAI,EAAE;YAC7D,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,SAAS;YACrB,GAAG,EAAE,OAAO;YACZ,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;YAC9D,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,KAAK;YACjB,KAAK,EAAE;gBACL,KAAK,EAAE,UAAU;aAClB;SACF,CAAC,CAAA;QAEF,MAAM,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,UAAU,EAAE;YAChD,cAAc,EAAE,UAAU,CAAC,IAAI;YAC/B,IAAI,EAAE,eAAe,CAAC,IAAI;YAC1B,KAAK,EAAE,WAAW;SACnB,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 TextCustomFieldDefinition = Extract<ResolvedCustomFieldDefinitionFields, {
4
+ type: CustomFieldType.TEXT;
5
+ }>;
6
+ export declare function validateTextCustomFieldDefinition(definition: TextCustomFieldDefinition): void;
7
+ export {};