@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
package/LICENSE.md ADDED
@@ -0,0 +1,59 @@
1
+ # PolyForm Strict License 1.0.0
2
+
3
+ <https://polyformproject.org/licenses/strict/1.0.0>
4
+
5
+ ## Acceptance
6
+
7
+ In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
8
+
9
+ ## Copyright License
10
+
11
+ The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose, other than distributing the software or making changes or new works based on the software.
12
+
13
+ ## Patent License
14
+
15
+ The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
16
+
17
+ ## Noncommercial Purposes
18
+
19
+ Any noncommercial purpose is a permitted purpose.
20
+
21
+ ## Personal Uses
22
+
23
+ Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
24
+
25
+ ## Noncommercial Organizations
26
+
27
+ Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
28
+
29
+ ## Fair Use
30
+
31
+ You may have "fair use" rights for the software under the law. These terms do not limit them.
32
+
33
+ ## No Other Rights
34
+
35
+ These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
36
+
37
+ ## Patent Defense
38
+
39
+ If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
40
+
41
+ ## Violations
42
+
43
+ The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
44
+
45
+ ## No Liability
46
+
47
+ ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
48
+
49
+ ## Definitions
50
+
51
+ The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
52
+
53
+ **You** refers to the individual or entity agreeing to these terms.
54
+
55
+ **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
56
+
57
+ **Your licenses** are all the licenses granted to you for the software under these terms.
58
+
59
+ **Use** means anything you do with the software requiring one of your licenses.
package/README.md ADDED
@@ -0,0 +1,279 @@
1
+ # @wisemen/nestjs-custom-fields
2
+
3
+ Custom field definitions and values for NestJS applications with TypeORM
4
+ persistence, DTO support, and runtime validation.
5
+
6
+ Custom field definitions are developer-managed. This package does not target
7
+ end-user managed custom field creation.
8
+
9
+ It is intended that custom field definitions are read-only for users.
10
+ Creating, updating, and deleting definitions is handled manually by developers
11
+ through migrations or `playground.ts` scripts.
12
+
13
+ Definition uniqueness is scoped by `entityType`. For non-tenant definitions,
14
+ `key` must be unique per `entityType`. For tenant-scoped definitions,
15
+ `key + tenantUuid` must be unique per `entityType`.
16
+
17
+ ## Step 1: Register The Exported Entity And Create The Table
18
+
19
+ This package already exports the effective `CustomFieldDefinition` TypeORM
20
+ entity. Add it to your datasource entities yourself so TypeORM knows about the
21
+ table metadata. After that, generate and run a migration so the table and the
22
+ exported entity's partial unique indexes are created in your database.
23
+
24
+ ```ts
25
+ import { DataSource } from 'typeorm'
26
+ import { CustomFieldDefinition } from '@wisemen/nestjs-custom-fields'
27
+
28
+ const datasource = new DataSource({
29
+ entities: ['dist/src/**/*.entity.js', CustomFieldDefinition]
30
+ })
31
+ ```
32
+
33
+ ## Step 2: Define Definitions And Insert Them In The Database
34
+
35
+ Create a definition with `customFieldDefinition(...)`, then insert it yourself.
36
+ The package does not discover definitions automatically. At the moment this is
37
+ mainly done through a migration or through `playground.ts`.
38
+
39
+ For persisted definitions, `tenantUuid` is part of the definition shape and
40
+ should be `null` for non-tenant definitions or a tenant UUID for tenant-scoped
41
+ definitions. This is different from repository lookups, where `tenantUuid` is
42
+ optional and can simply be omitted.
43
+
44
+ `key` uniqueness is enforced per `entityType`. Use a unique `key` for global
45
+ definitions, and a unique `key + tenantUuid` combination for tenant-specific
46
+ definitions.
47
+
48
+ It is recommended to define your `entityType` values in an enum instead of
49
+ repeating string literals across your application.
50
+
51
+ ```ts
52
+ import type { INestApplicationContext } from '@nestjs/common'
53
+ import { NestFactory } from '@nestjs/core'
54
+ import { JobContainer } from '@wisemen/app-container/fastify'
55
+ import { LocalizedString } from '@wisemen/localized-string'
56
+ import { DataSource } from 'typeorm'
57
+ import {
58
+ CustomFieldDefinition,
59
+ CustomFieldType,
60
+ customFieldDefinition
61
+ } from '@wisemen/nestjs-custom-fields'
62
+
63
+ enum CustomFieldEntityType {
64
+ TICKET = 'ticket'
65
+ }
66
+
67
+ export class Playground extends JobContainer {
68
+ async bootstrap(): Promise<INestApplicationContext> {
69
+ return await NestFactory.createApplicationContext(PlayGroundModule)
70
+ }
71
+
72
+ async execute(app: INestApplicationContext): Promise<void> {
73
+ const priorityField = customFieldDefinition(CustomFieldType.SINGLE_SELECT, {
74
+ tenantUuid: null,
75
+ entityType: CustomFieldEntityType.TICKET,
76
+ key: 'priority',
77
+ label: new LocalizedString([{ locale: 'en', value: 'Priority' }]),
78
+ description: null,
79
+ isRequired: true,
80
+ choices: [
81
+ {
82
+ value: 'low',
83
+ order: 1,
84
+ label: new LocalizedString([{ locale: 'en', value: 'Low' }])
85
+ },
86
+ {
87
+ value: 'high',
88
+ order: 2,
89
+ label: new LocalizedString([{ locale: 'en', value: 'High' }])
90
+ }
91
+ ]
92
+ })
93
+
94
+ await app.get(DataSource).manager.insert(CustomFieldDefinition, priorityField)
95
+ }
96
+ }
97
+ ```
98
+
99
+ ## Step 3: Store Values On The Entity With The Custom Column
100
+
101
+ Resolved custom field values live on your own entity. Use
102
+ `@CustomFieldValueColumn()` for the persisted values column.
103
+
104
+ ```ts
105
+ import { Entity, PrimaryGeneratedColumn } from 'typeorm'
106
+ import {
107
+ CustomFieldValueColumn,
108
+ type CustomFieldValue
109
+ } from '@wisemen/nestjs-custom-fields'
110
+
111
+ @Entity()
112
+ export class Ticket {
113
+ @PrimaryGeneratedColumn('uuid')
114
+ uuid: string
115
+
116
+ @CustomFieldValueColumn({ nullable: true })
117
+ customFields: CustomFieldValue[] | null
118
+ }
119
+ ```
120
+
121
+ ## Step 4: Receive And Show Values With DTOs
122
+
123
+ Requests and responses use the DTO layer from this package. For incoming
124
+ payloads, use `CustomFieldValueDto` with `@IsCustomFields()`. For outgoing
125
+ payloads, map stored values back with `CustomFieldValueDto.from(...)`.
126
+
127
+ Calling `parse()` on a DTO turns the transport-friendly input into the domain
128
+ custom field value shape, including richer value objects when needed. For
129
+ example, a `MonetaryDto` is parsed into the package's monetary value object
130
+ instead of staying a plain JSON structure.
131
+
132
+ ```ts
133
+ import { ApiProperty } from '@nestjs/swagger'
134
+ import {
135
+ CustomFieldValueApiExtraModels,
136
+ CustomFieldValueDto,
137
+ CustomFieldValueDtoApiProperty,
138
+ IsCustomFields
139
+ } from '@wisemen/nestjs-custom-fields'
140
+
141
+ @CustomFieldValueApiExtraModels()
142
+ export class UpdateTicketCommand {
143
+ @CustomFieldValueDtoApiProperty({ isArray: true })
144
+ @IsCustomFields()
145
+ customFields: CustomFieldValueDto[]
146
+ }
147
+
148
+ @CustomFieldValueApiExtraModels()
149
+ export class TicketResponseDto {
150
+ @ApiProperty({ type: String, format: 'uuid' })
151
+ uuid: string
152
+
153
+ @CustomFieldValueDtoApiProperty({ isArray: true })
154
+ customFields: CustomFieldValueDto[]
155
+
156
+ constructor(ticket: Ticket) {
157
+ this.uuid = ticket.uuid
158
+ this.customFields = ticket.customFields?.map(value => CustomFieldValueDto.from(value)) ?? []
159
+ }
160
+ }
161
+ ```
162
+
163
+ `@IsCustomFields()` already applies array validation, nested DTO validation,
164
+ and uniqueness on `definitionUuid`.
165
+
166
+ ```ts
167
+ import {
168
+ CustomFieldType,
169
+ MonetaryCustomFieldValueDto
170
+ } from '@wisemen/nestjs-custom-fields'
171
+
172
+ const dto = new MonetaryCustomFieldValueDto()
173
+ dto.definitionUuid = definitionUuid
174
+ dto.value = {
175
+ amount: '12.50',
176
+ currency: 'EUR',
177
+ precision: 2
178
+ }
179
+
180
+ const parsed = dto.parse()
181
+
182
+ // parsed is now a domain custom field value object:
183
+ // {
184
+ // definitionUuid,
185
+ // type: CustomFieldType.MONETARY,
186
+ // value: dto.value.parse()
187
+ // }
188
+ ```
189
+
190
+ ## Step 5: Retrieve Definitions For Validation
191
+
192
+ When you process submitted values, retrieve the matching definitions through
193
+ `CustomFieldDefinitionsRepository` and validate against them with
194
+ `validateCustomFieldValues(...)`. If you also want to return definitions from
195
+ an API, map the same repository results with `CustomFieldDefinitionResponse`.
196
+ To inject the repository, register `CustomFieldDefinitionRepositoryModule` in
197
+ the Nest module that owns your use case or controller.
198
+
199
+ `validateCustomFieldValues(...)` throws `CustomFieldValueValidationError` when
200
+ the submitted values do not match the definitions. In controllers, document
201
+ that error according to the `@wisemen/api-error` package pattern by registering
202
+ it with `@ApiErrorResponse(...)`.
203
+
204
+ ```ts
205
+ import { Module } from '@nestjs/common'
206
+ import { CustomFieldDefinitionRepositoryModule } from '@wisemen/nestjs-custom-fields'
207
+
208
+ @Module({
209
+ imports: [CustomFieldDefinitionRepositoryModule],
210
+ providers: [UpdateTicketCustomFieldsUseCase]
211
+ })
212
+ export class UpdateTicketModule {}
213
+ ```
214
+
215
+ On repository lookups, `tenantUuid` is optional. Omit it to work with
216
+ non-tenant definitions, or set it to retrieve tenant-specific definitions in a
217
+ multi-tenant setup.
218
+
219
+ After DTO parsing, validate the resolved values against the definitions that
220
+ apply for that entity and tenant. This is the runtime check that enforces the
221
+ definition rules.
222
+
223
+ ```ts
224
+ import { Injectable } from '@nestjs/common'
225
+ import {
226
+ CustomFieldDefinitionResponse,
227
+ CustomFieldDefinitionsRepository,
228
+ validateCustomFieldValues
229
+ } from '@wisemen/nestjs-custom-fields'
230
+
231
+ enum CustomFieldEntityType {
232
+ TICKET = 'ticket'
233
+ }
234
+
235
+ @Injectable()
236
+ export class UpdateTicketCustomFieldsUseCase {
237
+ constructor(
238
+ private readonly repository: CustomFieldDefinitionsRepository
239
+ ) {}
240
+
241
+ async execute(command: UpdateTicketCommand): Promise<void> {
242
+ const definitions = await this.repository.findDefinitions({
243
+ entityType: CustomFieldEntityType.TICKET
244
+ })
245
+
246
+ const values = command.customFields.map(value => value.parse())
247
+
248
+ validateCustomFieldValues(definitions, values)
249
+
250
+ // Persist the validated values here.
251
+ }
252
+ }
253
+ ```
254
+
255
+ If you want to return definitions from a read endpoint, use
256
+ `CustomFieldDefinitionResponse` to map the repository results into the response
257
+ shape:
258
+
259
+ ```ts
260
+ async function findTicketDefinitions(
261
+ repository: CustomFieldDefinitionsRepository
262
+ ): Promise<CustomFieldDefinitionResponse[]> {
263
+ const definitions = await repository.findDefinitions({
264
+ entityType: CustomFieldEntityType.TICKET
265
+ })
266
+
267
+ return definitions.map(definition => new CustomFieldDefinitionResponse(definition))
268
+ }
269
+ ```
270
+
271
+ ```ts
272
+ import { ApiErrorResponse } from '@wisemen/api-error'
273
+ import { CustomFieldValueValidationError } from '@wisemen/nestjs-custom-fields'
274
+
275
+ @ApiErrorResponse(CustomFieldValueValidationError)
276
+ async update(...): Promise<void> {
277
+ // controller logic
278
+ }
279
+ ```
@@ -0,0 +1,6 @@
1
+ import { LocalizedString } from '@wisemen/localized-string';
2
+ export interface CustomFieldChoice {
3
+ value: string;
4
+ label: LocalizedString;
5
+ order: number;
6
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=custom-field-choice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-field-choice.js","sourceRoot":"","sources":["../lib/custom-field-choice.ts"],"names":[],"mappings":""}
@@ -0,0 +1,41 @@
1
+ import { CustomFieldChoice } from '#src/custom-field-choice.js';
2
+ import { CustomFieldDefinitionUuid } from '#src/custom-field-definition.uuid.js';
3
+ import { CustomFieldRules, CustomFieldRulesByType } from '#src/custom-field-rules.js';
4
+ import { CustomFieldChoicesModeByType, CustomFieldRulesModeByType } from '#src/custom-field-type-contract.js';
5
+ import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
6
+ import { LocalizedString } from '@wisemen/localized-string';
7
+ export interface CustomFieldDefinitionData {
8
+ uuid: CustomFieldDefinitionUuid;
9
+ tenantUuid: string | null;
10
+ entityType: string;
11
+ key: string;
12
+ label: LocalizedString;
13
+ description: LocalizedString | null;
14
+ type: CustomFieldType;
15
+ isRequired: boolean;
16
+ choices: CustomFieldChoice[] | null;
17
+ rules: CustomFieldRules | null;
18
+ }
19
+ type BaseCustomFieldDefinitionFields<T extends CustomFieldType> = Omit<CustomFieldDefinitionData, 'type' | 'choices' | 'rules'> & {
20
+ type: T;
21
+ };
22
+ type CustomFieldDefinitionChoicesField<T extends CustomFieldType> = CustomFieldChoicesModeByType<T> extends 'required' ? {
23
+ choices: CustomFieldChoice[];
24
+ } : {
25
+ choices: null;
26
+ };
27
+ type CustomFieldDefinitionRulesField<T extends CustomFieldType> = CustomFieldRulesModeByType<T> extends 'required' ? {
28
+ rules: CustomFieldRulesByType<T>;
29
+ } : CustomFieldRulesModeByType<T> extends 'optional' ? {
30
+ rules: CustomFieldRulesByType<T> | null;
31
+ } : {
32
+ rules: null;
33
+ };
34
+ export type CustomFieldDefinitionFieldsByType<T extends CustomFieldType> = BaseCustomFieldDefinitionFields<T> & CustomFieldDefinitionChoicesField<T> & CustomFieldDefinitionRulesField<T>;
35
+ export type ResolvedCustomFieldDefinitionFields = {
36
+ [T in CustomFieldType]: CustomFieldDefinitionFieldsByType<T>;
37
+ }[CustomFieldType];
38
+ export type CustomFieldDefinitionFieldsMap = {
39
+ [T in CustomFieldType]: CustomFieldDefinitionFieldsByType<T>;
40
+ };
41
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=custom-field-definition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-field-definition.js","sourceRoot":"","sources":["../lib/custom-field-definition.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export type Uuid<Brand extends string> = string & {
2
+ readonly __brand: 'uuid';
3
+ } & {
4
+ readonly __uuid: Brand;
5
+ };
6
+ export declare function generateUuid<Brand extends Uuid<string> | null>(): Exclude<Brand, null>;
7
+ export type CustomFieldDefinitionUuid = Uuid<'CustomFieldDefinition'>;
@@ -0,0 +1,4 @@
1
+ export function generateUuid() {
2
+ return crypto.randomUUID();
3
+ }
4
+ //# sourceMappingURL=custom-field-definition.uuid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-field-definition.uuid.js","sourceRoot":"","sources":["../lib/custom-field-definition.uuid.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,YAAY;IAC1B,OAAO,MAAM,CAAC,UAAU,EAA0B,CAAA;AACpD,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { CustomFieldType } from './enum/custom-field-type.enum.js';
2
+ import type { CustomFieldRuleConfigByType } from './custom-field-type-contract.js';
3
+ import type { BooleanCustomFieldRules as BooleanCustomFieldRulesModel } from '#src/custom-field-types/boolean/boolean.rules.js';
4
+ import type { DateCustomFieldRules as DateCustomFieldRulesModel } from '#src/custom-field-types/date/date.rules.js';
5
+ import type { MonetaryCustomFieldRules as MonetaryCustomFieldRulesModel } from '#src/custom-field-types/monetary/monetary.rules.js';
6
+ import type { MultiSelectCustomFieldRules as MultiSelectCustomFieldRulesModel } from '#src/custom-field-types/multi-select/multi-select.rules.js';
7
+ import type { NumberCustomFieldRules as NumberCustomFieldRulesModel } from '#src/custom-field-types/number/number.rules.js';
8
+ import type { SelectCustomFieldRules as SelectCustomFieldRulesModel } from '#src/custom-field-types/single-select/single-select.rules.js';
9
+ import type { TextArrayCustomFieldRules as TextArrayCustomFieldRulesModel } from '#src/custom-field-types/text-array/text-array.rules.js';
10
+ import type { TextCustomFieldRules as TextCustomFieldRulesModel } from '#src/custom-field-types/text/text.rules.js';
11
+ import type { TimestampCustomFieldRules as TimestampCustomFieldRulesModel } from '#src/custom-field-types/timestamp/timestamp.rules.js';
12
+ type CustomFieldRulesFor<T extends CustomFieldType> = {
13
+ type: T;
14
+ } & CustomFieldRuleConfigByType<T>;
15
+ export type TextCustomFieldRules = TextCustomFieldRulesModel;
16
+ export type TextArrayCustomFieldRules = TextArrayCustomFieldRulesModel;
17
+ export type NumberCustomFieldRules = NumberCustomFieldRulesModel;
18
+ export type BooleanCustomFieldRules = BooleanCustomFieldRulesModel;
19
+ export type DateCustomFieldRules = DateCustomFieldRulesModel;
20
+ export type TimestampCustomFieldRules = TimestampCustomFieldRulesModel;
21
+ export type SelectCustomFieldRules = SelectCustomFieldRulesModel;
22
+ export type MultiSelectCustomFieldRules = MultiSelectCustomFieldRulesModel;
23
+ export type MonetaryCustomFieldRules = MonetaryCustomFieldRulesModel;
24
+ export type CustomFieldRulesByType<T extends CustomFieldType> = CustomFieldRulesFor<T>;
25
+ export type CustomFieldRules = {
26
+ [T in CustomFieldType]: CustomFieldRulesByType<T>;
27
+ }[CustomFieldType];
28
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=custom-field-rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-field-rules.js","sourceRoot":"","sources":["../lib/custom-field-rules.ts"],"names":[],"mappings":""}
@@ -0,0 +1,38 @@
1
+ import type { BooleanCustomFieldTypeContract } from '#src/custom-field-types/boolean/boolean.contract.js';
2
+ import type { DateCustomFieldTypeContract } from '#src/custom-field-types/date/date.contract.js';
3
+ import type { MonetaryCustomFieldTypeContract } from '#src/custom-field-types/monetary/monetary.contract.js';
4
+ import type { MultiSelectCustomFieldTypeContract } from '#src/custom-field-types/multi-select/multi-select.contract.js';
5
+ import type { NumberCustomFieldTypeContract } from '#src/custom-field-types/number/number.contract.js';
6
+ import type { SingleSelectCustomFieldTypeContract } from '#src/custom-field-types/single-select/single-select.contract.js';
7
+ import type { TextArrayCustomFieldTypeContract } from '#src/custom-field-types/text-array/text-array.contract.js';
8
+ import type { TextCustomFieldTypeContract } from '#src/custom-field-types/text/text.contract.js';
9
+ import type { TimestampCustomFieldTypeContract } from '#src/custom-field-types/timestamp/timestamp.contract.js';
10
+ import { CustomFieldType } from './enum/custom-field-type.enum.js';
11
+ type Satisfies<T extends U, U> = T;
12
+ export type CustomFieldRulesMode = 'required' | 'optional' | 'none';
13
+ export type CustomFieldChoicesMode = 'required' | 'none';
14
+ export interface CustomFieldTypeContractBase {
15
+ value: unknown;
16
+ columnValue: unknown;
17
+ rules: unknown;
18
+ rulesMode: CustomFieldRulesMode;
19
+ choicesMode: CustomFieldChoicesMode;
20
+ }
21
+ export type DefineContract<T extends CustomFieldTypeContractBase & Record<Exclude<keyof T, keyof CustomFieldTypeContractBase>, never>> = T;
22
+ export type CustomFieldTypeContract = Satisfies<{
23
+ [CustomFieldType.TEXT]: TextCustomFieldTypeContract;
24
+ [CustomFieldType.TEXT_ARRAY]: TextArrayCustomFieldTypeContract;
25
+ [CustomFieldType.NUMBER]: NumberCustomFieldTypeContract;
26
+ [CustomFieldType.BOOLEAN]: BooleanCustomFieldTypeContract;
27
+ [CustomFieldType.TIMESTAMP]: TimestampCustomFieldTypeContract;
28
+ [CustomFieldType.DATE]: DateCustomFieldTypeContract;
29
+ [CustomFieldType.SINGLE_SELECT]: SingleSelectCustomFieldTypeContract;
30
+ [CustomFieldType.MULTI_SELECT]: MultiSelectCustomFieldTypeContract;
31
+ [CustomFieldType.MONETARY]: MonetaryCustomFieldTypeContract;
32
+ }, Record<CustomFieldType, CustomFieldTypeContractBase>>;
33
+ export type CustomFieldDomainValueByType<T extends CustomFieldType> = CustomFieldTypeContract[T]['value'];
34
+ export type CustomFieldColumnValueByType<T extends CustomFieldType> = CustomFieldTypeContract[T]['columnValue'];
35
+ export type CustomFieldRuleConfigByType<T extends CustomFieldType> = CustomFieldTypeContract[T]['rules'];
36
+ export type CustomFieldRulesModeByType<T extends CustomFieldType> = CustomFieldTypeContract[T]['rulesMode'];
37
+ export type CustomFieldChoicesModeByType<T extends CustomFieldType> = CustomFieldTypeContract[T]['choicesMode'];
38
+ export {};
@@ -0,0 +1,2 @@
1
+ import { CustomFieldType } from './enum/custom-field-type.enum.js';
2
+ //# sourceMappingURL=custom-field-type-contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-field-type-contract.js","sourceRoot":"","sources":["../lib/custom-field-type-contract.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA"}
@@ -0,0 +1,8 @@
1
+ import type { DefineContract } from '#src/custom-field-type-contract.js';
2
+ export type BooleanCustomFieldTypeContract = DefineContract<{
3
+ value: boolean;
4
+ columnValue: boolean;
5
+ rules: Record<never, never>;
6
+ rulesMode: 'none';
7
+ choicesMode: 'none';
8
+ }>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=boolean.contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boolean.contract.js","sourceRoot":"","sources":["../../../lib/custom-field-types/boolean/boolean.contract.ts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ import { describe, it } from 'node:test';
2
+ import { expect } from 'expect';
3
+ import { LocalizedString } from '@wisemen/localized-string';
4
+ import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
5
+ import { customFieldDefinition } from '#src/factory/custom-field-definition.factory.js';
6
+ describe('boolean customFieldDefinition', () => {
7
+ it('creates a boolean custom field definition', () => {
8
+ const definition = customFieldDefinition(CustomFieldType.BOOLEAN, {
9
+ tenantUuid: null,
10
+ entityType: 'invoice',
11
+ key: 'approved',
12
+ label: new LocalizedString([{ locale: 'en', value: 'Approved' }]),
13
+ description: null,
14
+ isRequired: false
15
+ });
16
+ expect(definition.type).toBe(CustomFieldType.BOOLEAN);
17
+ expect(definition.choices).toBeNull();
18
+ expect(definition.rules).toBeNull();
19
+ });
20
+ });
21
+ //# sourceMappingURL=boolean.custom-field-definition.factory.unit.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boolean.custom-field-definition.factory.unit.test.js","sourceRoot":"","sources":["../../../lib/custom-field-types/boolean/boolean.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,eAAe,EAAE,MAAM,qCAAqC,CAAA;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAA;AAEvF,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;IAC7C,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,MAAM,UAAU,GAAG,qBAAqB,CAAC,eAAe,CAAC,OAAO,EAAE;YAChE,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,SAAS;YACrB,GAAG,EAAE,UAAU;YACf,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;YACjE,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,KAAK;SAClB,CAAC,CAAA;QAEF,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;QACrD,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAA;QACrC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ export declare function validateBooleanCustomFieldValue(): void;
@@ -0,0 +1,2 @@
1
+ export function validateBooleanCustomFieldValue() { }
2
+ //# sourceMappingURL=boolean.custom-field-value.validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boolean.custom-field-value.validator.js","sourceRoot":"","sources":["../../../lib/custom-field-types/boolean/boolean.custom-field-value.validator.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,+BAA+B,KAAU,CAAC"}
@@ -0,0 +1,24 @@
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 { expect } from 'expect';
7
+ describe('boolean validateCustomFieldValue', () => {
8
+ it('accepts a boolean custom field value', () => {
9
+ const definition = customFieldDefinition(CustomFieldType.BOOLEAN, {
10
+ tenantUuid: null,
11
+ entityType: 'invoice',
12
+ key: 'approved',
13
+ label: new LocalizedString([{ locale: 'en', value: 'Approved' }]),
14
+ description: null,
15
+ isRequired: false
16
+ });
17
+ expect(() => validateCustomFieldValue(definition, {
18
+ definitionUuid: definition.uuid,
19
+ type: CustomFieldType.BOOLEAN,
20
+ value: true
21
+ })).not.toThrow();
22
+ });
23
+ });
24
+ //# sourceMappingURL=boolean.custom-field-value.validator.unit.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boolean.custom-field-value.validator.unit.test.js","sourceRoot":"","sources":["../../../lib/custom-field-types/boolean/boolean.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,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,QAAQ,CAAC,kCAAkC,EAAE,GAAG,EAAE;IAChD,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,UAAU,GAAG,qBAAqB,CAAC,eAAe,CAAC,OAAO,EAAE;YAChE,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,SAAS;YACrB,GAAG,EAAE,UAAU;YACf,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;YACjE,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,KAAK;SAClB,CAAC,CAAA;QAEF,MAAM,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,UAAU,EAAE;YAChD,cAAc,EAAE,UAAU,CAAC,IAAI;YAC/B,IAAI,EAAE,eAAe,CAAC,OAAO;YAC7B,KAAK,EAAE,IAAI;SACZ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAA;IACnB,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 BooleanCustomFieldDefinition = Extract<ResolvedCustomFieldDefinitionFields, {
4
+ type: CustomFieldType.BOOLEAN;
5
+ }>;
6
+ export declare function validateBooleanCustomFieldDefinition(definition: BooleanCustomFieldDefinition): void;
7
+ export {};
@@ -0,0 +1,10 @@
1
+ import { CustomFieldDefinitionError } from '#src/errors/custom-field-definition.error.js';
2
+ export function validateBooleanCustomFieldDefinition(definition) {
3
+ if (definition.choices !== null) {
4
+ throw new CustomFieldDefinitionError('Only select custom fields can define choices');
5
+ }
6
+ if (definition.rules !== null) {
7
+ throw new CustomFieldDefinitionError('Boolean custom field can not define rules');
8
+ }
9
+ }
10
+ //# sourceMappingURL=boolean.definition-validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boolean.definition-validation.js","sourceRoot":"","sources":["../../../lib/custom-field-types/boolean/boolean.definition-validation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAA;AAKzF,MAAM,UAAU,oCAAoC,CAAC,UAAwC;IAC3F,IAAI,UAAU,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAChC,MAAM,IAAI,0BAA0B,CAAC,8CAA8C,CAAC,CAAA;IACtF,CAAC;IAED,IAAI,UAAU,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QAC9B,MAAM,IAAI,0BAA0B,CAAC,2CAA2C,CAAC,CAAA;IACnF,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 { BooleanCustomFieldValue } from '#src/custom-field-types/boolean/boolean.value.js';
4
+ export declare class BooleanCustomFieldValueDto extends BaseCustomFieldValueDto {
5
+ type: CustomFieldType.BOOLEAN;
6
+ value: boolean;
7
+ parse(): BooleanCustomFieldValue;
8
+ static from(customFieldValue: BooleanCustomFieldValue): BooleanCustomFieldValueDto;
9
+ }