@warlock.js/notifications 4.15.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (344) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/cjs/channel_api-CH3DxhRU.cjs +7463 -0
  3. package/cjs/channel_api-CH3DxhRU.cjs.map +1 -0
  4. package/cjs/chunk-fl3r8ClO.cjs +41 -0
  5. package/cjs/index.cjs +34 -4
  6. package/cjs/index.cjs.map +1 -1
  7. package/cjs/rabbitmq-driver-CJtyxjUQ.cjs +3 -0
  8. package/cjs/src-Cus6pYPC.cjs +10981 -0
  9. package/cjs/src-Cus6pYPC.cjs.map +1 -0
  10. package/esm/_virtual/_rolldown/runtime.mjs +32 -0
  11. package/esm/herald/src/communicators/broker-registry.mjs +204 -0
  12. package/esm/herald/src/communicators/broker-registry.mjs.map +1 -0
  13. package/esm/herald/src/communicators/broker.mjs +110 -0
  14. package/esm/herald/src/communicators/broker.mjs.map +1 -0
  15. package/esm/herald/src/communicators/index.mjs +4 -0
  16. package/esm/herald/src/decorators/consumable.mjs +36 -0
  17. package/esm/herald/src/decorators/consumable.mjs.map +1 -0
  18. package/esm/herald/src/decorators/index.mjs +3 -0
  19. package/esm/herald/src/drivers/index.mjs +5 -0
  20. package/esm/herald/src/drivers/rabbitmq/index.mjs +4 -0
  21. package/esm/herald/src/drivers/rabbitmq/rabbitmq-channel.mjs +403 -0
  22. package/esm/herald/src/drivers/rabbitmq/rabbitmq-channel.mjs.map +1 -0
  23. package/esm/herald/src/drivers/rabbitmq/rabbitmq-driver.mjs +303 -0
  24. package/esm/herald/src/drivers/rabbitmq/rabbitmq-driver.mjs.map +1 -0
  25. package/esm/herald/src/index.mjs +16 -0
  26. package/esm/herald/src/message-managers/event-consumer.mjs +76 -0
  27. package/esm/herald/src/message-managers/event-consumer.mjs.map +1 -0
  28. package/esm/herald/src/message-managers/event-message.mjs +85 -0
  29. package/esm/herald/src/message-managers/event-message.mjs.map +1 -0
  30. package/esm/herald/src/message-managers/index.mjs +4 -0
  31. package/esm/herald/src/message-managers/prepare-consumer-subscription.mjs +42 -0
  32. package/esm/herald/src/message-managers/prepare-consumer-subscription.mjs.map +1 -0
  33. package/esm/herald/src/use-case-broadcast.mjs +30 -0
  34. package/esm/herald/src/use-case-broadcast.mjs.map +1 -0
  35. package/esm/herald/src/utils/connect-to-broker.mjs +168 -0
  36. package/esm/herald/src/utils/connect-to-broker.mjs.map +1 -0
  37. package/esm/herald/src/utils/index.mjs +3 -0
  38. package/esm/in-app/base-notifications-repository.d.mts +15 -1
  39. package/esm/in-app/base-notifications-repository.d.mts.map +1 -1
  40. package/esm/in-app/base-notifications-repository.mjs +33 -3
  41. package/esm/in-app/base-notifications-repository.mjs.map +1 -1
  42. package/esm/in-app/in-app.d.mts +3 -3
  43. package/esm/in-app/in-app.d.mts.map +1 -1
  44. package/esm/node_modules/@mongez/reinforcements/esm/Random/_internal.mjs +6 -0
  45. package/esm/node_modules/@mongez/reinforcements/esm/Random/_internal.mjs.map +1 -0
  46. package/esm/node_modules/@mongez/reinforcements/esm/Random/bool.mjs +3 -0
  47. package/esm/node_modules/@mongez/reinforcements/esm/Random/color.mjs +3 -0
  48. package/esm/node_modules/@mongez/reinforcements/esm/Random/date.mjs +3 -0
  49. package/esm/node_modules/@mongez/reinforcements/esm/Random/float.mjs +3 -0
  50. package/esm/node_modules/@mongez/reinforcements/esm/Random/id.mjs +3 -0
  51. package/esm/node_modules/@mongez/reinforcements/esm/Random/int.mjs +3 -0
  52. package/esm/node_modules/@mongez/reinforcements/esm/Random/nanoid.mjs +3 -0
  53. package/esm/node_modules/@mongez/reinforcements/esm/Random/pick.mjs +3 -0
  54. package/esm/node_modules/@mongez/reinforcements/esm/Random/random.mjs +16 -0
  55. package/esm/node_modules/@mongez/reinforcements/esm/Random/sample.mjs +3 -0
  56. package/esm/node_modules/@mongez/reinforcements/esm/Random/string.mjs +3 -0
  57. package/esm/node_modules/@mongez/reinforcements/esm/Random/token.mjs +3 -0
  58. package/esm/node_modules/@mongez/reinforcements/esm/Random/uuid.mjs +3 -0
  59. package/esm/node_modules/@mongez/reinforcements/esm/Random/weighted.mjs +3 -0
  60. package/esm/node_modules/@mongez/reinforcements/esm/async/retry.mjs +3 -0
  61. package/esm/node_modules/@mongez/reinforcements/esm/index.mjs +24 -0
  62. package/esm/node_modules/@mongez/reinforcements/esm/mixed/clone/clone.mjs +82 -0
  63. package/esm/node_modules/@mongez/reinforcements/esm/mixed/clone/clone.mjs.map +1 -0
  64. package/esm/node_modules/@mongez/reinforcements/esm/number/round.mjs +17 -0
  65. package/esm/node_modules/@mongez/reinforcements/esm/number/round.mjs.map +1 -0
  66. package/esm/node_modules/@mongez/reinforcements/esm/object/except.mjs +13 -0
  67. package/esm/node_modules/@mongez/reinforcements/esm/object/except.mjs.map +1 -0
  68. package/esm/node_modules/@mongez/reinforcements/esm/object/get.mjs +18 -0
  69. package/esm/node_modules/@mongez/reinforcements/esm/object/get.mjs.map +1 -0
  70. package/esm/node_modules/@mongez/reinforcements/esm/object/omit.mjs +17 -0
  71. package/esm/node_modules/@mongez/reinforcements/esm/object/omit.mjs.map +1 -0
  72. package/esm/node_modules/@mongez/reinforcements/esm/object/unset.mjs +30 -0
  73. package/esm/node_modules/@mongez/reinforcements/esm/object/unset.mjs.map +1 -0
  74. package/esm/node_modules/@mongez/reinforcements/esm/string/capitalize.mjs +19 -0
  75. package/esm/node_modules/@mongez/reinforcements/esm/string/capitalize.mjs.map +1 -0
  76. package/esm/node_modules/@mongez/reinforcements/esm/string/ltrim.mjs +18 -0
  77. package/esm/node_modules/@mongez/reinforcements/esm/string/ltrim.mjs.map +1 -0
  78. package/esm/node_modules/@mongez/reinforcements/esm/string/readMoreChars.mjs +14 -0
  79. package/esm/node_modules/@mongez/reinforcements/esm/string/readMoreChars.mjs.map +1 -0
  80. package/esm/node_modules/@mongez/reinforcements/esm/string/rtrim.mjs +18 -0
  81. package/esm/node_modules/@mongez/reinforcements/esm/string/rtrim.mjs.map +1 -0
  82. package/esm/node_modules/@mongez/reinforcements/esm/string/toCamelCase.mjs +22 -0
  83. package/esm/node_modules/@mongez/reinforcements/esm/string/toCamelCase.mjs.map +1 -0
  84. package/esm/node_modules/@mongez/reinforcements/esm/string/toKebabCase.mjs +17 -0
  85. package/esm/node_modules/@mongez/reinforcements/esm/string/toKebabCase.mjs.map +1 -0
  86. package/esm/node_modules/@mongez/reinforcements/esm/string/toSnakeCase.mjs +21 -0
  87. package/esm/node_modules/@mongez/reinforcements/esm/string/toSnakeCase.mjs.map +1 -0
  88. package/esm/node_modules/@mongez/reinforcements/esm/string/toStudlyCase.mjs +21 -0
  89. package/esm/node_modules/@mongez/reinforcements/esm/string/toStudlyCase.mjs.map +1 -0
  90. package/esm/node_modules/@mongez/reinforcements/esm/string/trim.mjs +20 -0
  91. package/esm/node_modules/@mongez/reinforcements/esm/string/trim.mjs.map +1 -0
  92. package/esm/node_modules/@mongez/reinforcements/esm/string/ucfirst.mjs +15 -0
  93. package/esm/node_modules/@mongez/reinforcements/esm/string/ucfirst.mjs.map +1 -0
  94. package/esm/node_modules/@mongez/reinforcements/esm/string/words.mjs +25 -0
  95. package/esm/node_modules/@mongez/reinforcements/esm/string/words.mjs.map +1 -0
  96. package/esm/node_modules/@mongez/reinforcements/esm/utils/escapeRegex.mjs +11 -0
  97. package/esm/node_modules/@mongez/reinforcements/esm/utils/escapeRegex.mjs.map +1 -0
  98. package/esm/node_modules/@mongez/reinforcements/esm/utils/lazy.mjs +100 -0
  99. package/esm/node_modules/@mongez/reinforcements/esm/utils/lazy.mjs.map +1 -0
  100. package/esm/node_modules/@mongez/reinforcements/esm/utils/tap.mjs +27 -0
  101. package/esm/node_modules/@mongez/reinforcements/esm/utils/tap.mjs.map +1 -0
  102. package/esm/node_modules/@mongez/supportive-is/esm/index.mjs +353 -0
  103. package/esm/node_modules/@mongez/supportive-is/esm/index.mjs.map +1 -0
  104. package/esm/node_modules/amqplib/channel_api.mjs +28 -0
  105. package/esm/node_modules/amqplib/channel_api.mjs.map +1 -0
  106. package/esm/node_modules/amqplib/lib/api_args.mjs +241 -0
  107. package/esm/node_modules/amqplib/lib/api_args.mjs.map +1 -0
  108. package/esm/node_modules/amqplib/lib/bitset.mjs +130 -0
  109. package/esm/node_modules/amqplib/lib/bitset.mjs.map +1 -0
  110. package/esm/node_modules/amqplib/lib/channel.mjs +302 -0
  111. package/esm/node_modules/amqplib/lib/channel.mjs.map +1 -0
  112. package/esm/node_modules/amqplib/lib/channel_model.mjs +206 -0
  113. package/esm/node_modules/amqplib/lib/channel_model.mjs.map +1 -0
  114. package/esm/node_modules/amqplib/lib/codec.mjs +273 -0
  115. package/esm/node_modules/amqplib/lib/codec.mjs.map +1 -0
  116. package/esm/node_modules/amqplib/lib/connect.mjs +143 -0
  117. package/esm/node_modules/amqplib/lib/connect.mjs.map +1 -0
  118. package/esm/node_modules/amqplib/lib/connection.mjs +416 -0
  119. package/esm/node_modules/amqplib/lib/connection.mjs.map +1 -0
  120. package/esm/node_modules/amqplib/lib/credentials.mjs +50 -0
  121. package/esm/node_modules/amqplib/lib/credentials.mjs.map +1 -0
  122. package/esm/node_modules/amqplib/lib/defs.mjs +4600 -0
  123. package/esm/node_modules/amqplib/lib/defs.mjs.map +1 -0
  124. package/esm/node_modules/amqplib/lib/error.mjs +29 -0
  125. package/esm/node_modules/amqplib/lib/error.mjs.map +1 -0
  126. package/esm/node_modules/amqplib/lib/format.mjs +28 -0
  127. package/esm/node_modules/amqplib/lib/format.mjs.map +1 -0
  128. package/esm/node_modules/amqplib/lib/frame.mjs +130 -0
  129. package/esm/node_modules/amqplib/lib/frame.mjs.map +1 -0
  130. package/esm/node_modules/amqplib/lib/heartbeat.mjs +40 -0
  131. package/esm/node_modules/amqplib/lib/heartbeat.mjs.map +1 -0
  132. package/esm/node_modules/amqplib/lib/mux.mjs +86 -0
  133. package/esm/node_modules/amqplib/lib/mux.mjs.map +1 -0
  134. package/esm/node_modules/amqplib/package.mjs +41 -0
  135. package/esm/node_modules/amqplib/package.mjs.map +1 -0
  136. package/esm/node_modules/buffer-more-ints/buffer-more-ints.mjs +360 -0
  137. package/esm/node_modules/buffer-more-ints/buffer-more-ints.mjs.map +1 -0
  138. package/esm/node_modules/dayjs/dayjs.min.mjs +305 -0
  139. package/esm/node_modules/dayjs/dayjs.min.mjs.map +1 -0
  140. package/esm/node_modules/querystringify/index.mjs +80 -0
  141. package/esm/node_modules/querystringify/index.mjs.map +1 -0
  142. package/esm/node_modules/requires-port/index.mjs +35 -0
  143. package/esm/node_modules/requires-port/index.mjs.map +1 -0
  144. package/esm/node_modules/url-parse/index.mjs +388 -0
  145. package/esm/node_modules/url-parse/index.mjs.map +1 -0
  146. package/esm/queue/load-herald.mjs +1 -1
  147. package/esm/seal/src/config.mjs +15 -0
  148. package/esm/seal/src/config.mjs.map +1 -0
  149. package/esm/seal/src/factory/index.mjs +4 -0
  150. package/esm/seal/src/factory/validate.mjs +34 -0
  151. package/esm/seal/src/factory/validate.mjs.map +1 -0
  152. package/esm/seal/src/factory/validators.mjs +132 -0
  153. package/esm/seal/src/factory/validators.mjs.map +1 -0
  154. package/esm/seal/src/helpers/date-helpers.mjs +24 -0
  155. package/esm/seal/src/helpers/date-helpers.mjs.map +1 -0
  156. package/esm/seal/src/helpers/get-field-value.mjs +46 -0
  157. package/esm/seal/src/helpers/get-field-value.mjs.map +1 -0
  158. package/esm/seal/src/helpers/index.mjs +6 -0
  159. package/esm/seal/src/helpers/is-empty-value.mjs +10 -0
  160. package/esm/seal/src/helpers/is-empty-value.mjs.map +1 -0
  161. package/esm/seal/src/helpers/path-helpers.mjs +12 -0
  162. package/esm/seal/src/helpers/path-helpers.mjs.map +1 -0
  163. package/esm/seal/src/helpers/validation-helpers.mjs +72 -0
  164. package/esm/seal/src/helpers/validation-helpers.mjs.map +1 -0
  165. package/esm/seal/src/index.mjs +87 -0
  166. package/esm/seal/src/mutators/array-mutators.mjs +32 -0
  167. package/esm/seal/src/mutators/array-mutators.mjs.map +1 -0
  168. package/esm/seal/src/mutators/date-mutators.mjs +94 -0
  169. package/esm/seal/src/mutators/date-mutators.mjs.map +1 -0
  170. package/esm/seal/src/mutators/index.mjs +8 -0
  171. package/esm/seal/src/mutators/number-mutators.mjs +52 -0
  172. package/esm/seal/src/mutators/number-mutators.mjs.map +1 -0
  173. package/esm/seal/src/mutators/object-mutators.mjs +30 -0
  174. package/esm/seal/src/mutators/object-mutators.mjs.map +1 -0
  175. package/esm/seal/src/mutators/scalar-mutators.mjs +9 -0
  176. package/esm/seal/src/mutators/scalar-mutators.mjs.map +1 -0
  177. package/esm/seal/src/mutators/string-mutators.mjs +186 -0
  178. package/esm/seal/src/mutators/string-mutators.mjs.map +1 -0
  179. package/esm/seal/src/rules/array/array-rules.mjs +41 -0
  180. package/esm/seal/src/rules/array/array-rules.mjs.map +1 -0
  181. package/esm/seal/src/rules/array/index.mjs +3 -0
  182. package/esm/seal/src/rules/color/color-rules.mjs +104 -0
  183. package/esm/seal/src/rules/color/color-rules.mjs.map +1 -0
  184. package/esm/seal/src/rules/color/index.mjs +3 -0
  185. package/esm/seal/src/rules/common/enum.mjs +77 -0
  186. package/esm/seal/src/rules/common/enum.mjs.map +1 -0
  187. package/esm/seal/src/rules/common/equals-field-rules.mjs +42 -0
  188. package/esm/seal/src/rules/common/equals-field-rules.mjs.map +1 -0
  189. package/esm/seal/src/rules/common/index.mjs +8 -0
  190. package/esm/seal/src/rules/common/instanceof.mjs +23 -0
  191. package/esm/seal/src/rules/common/instanceof.mjs.map +1 -0
  192. package/esm/seal/src/rules/common/literal.mjs +31 -0
  193. package/esm/seal/src/rules/common/literal.mjs.map +1 -0
  194. package/esm/seal/src/rules/common/type-rules.mjs +97 -0
  195. package/esm/seal/src/rules/common/type-rules.mjs.map +1 -0
  196. package/esm/seal/src/rules/common/unknown-key.mjs +25 -0
  197. package/esm/seal/src/rules/common/unknown-key.mjs.map +1 -0
  198. package/esm/seal/src/rules/conditional/forbidden-if-rules.mjs +116 -0
  199. package/esm/seal/src/rules/conditional/forbidden-if-rules.mjs.map +1 -0
  200. package/esm/seal/src/rules/conditional/index.mjs +12 -0
  201. package/esm/seal/src/rules/conditional/present-if-rules.mjs +97 -0
  202. package/esm/seal/src/rules/conditional/present-if-rules.mjs.map +1 -0
  203. package/esm/seal/src/rules/conditional/present-unless-rules.mjs +30 -0
  204. package/esm/seal/src/rules/conditional/present-unless-rules.mjs.map +1 -0
  205. package/esm/seal/src/rules/conditional/present-with-rules.mjs +76 -0
  206. package/esm/seal/src/rules/conditional/present-with-rules.mjs.map +1 -0
  207. package/esm/seal/src/rules/conditional/present-without-rules.mjs +76 -0
  208. package/esm/seal/src/rules/conditional/present-without-rules.mjs.map +1 -0
  209. package/esm/seal/src/rules/conditional/required-if-rules.mjs +204 -0
  210. package/esm/seal/src/rules/conditional/required-if-rules.mjs.map +1 -0
  211. package/esm/seal/src/rules/conditional/required-unless-rules.mjs +31 -0
  212. package/esm/seal/src/rules/conditional/required-unless-rules.mjs.map +1 -0
  213. package/esm/seal/src/rules/conditional/required-when-rule.mjs +32 -0
  214. package/esm/seal/src/rules/conditional/required-when-rule.mjs.map +1 -0
  215. package/esm/seal/src/rules/conditional/required-with-rules.mjs +67 -0
  216. package/esm/seal/src/rules/conditional/required-with-rules.mjs.map +1 -0
  217. package/esm/seal/src/rules/conditional/required-without-rules.mjs +67 -0
  218. package/esm/seal/src/rules/conditional/required-without-rules.mjs.map +1 -0
  219. package/esm/seal/src/rules/core/equal.mjs +22 -0
  220. package/esm/seal/src/rules/core/equal.mjs.map +1 -0
  221. package/esm/seal/src/rules/core/forbidden.mjs +20 -0
  222. package/esm/seal/src/rules/core/forbidden.mjs.map +1 -0
  223. package/esm/seal/src/rules/core/index.mjs +7 -0
  224. package/esm/seal/src/rules/core/required.mjs +36 -0
  225. package/esm/seal/src/rules/core/required.mjs.map +1 -0
  226. package/esm/seal/src/rules/core/union.mjs +30 -0
  227. package/esm/seal/src/rules/core/union.mjs.map +1 -0
  228. package/esm/seal/src/rules/core/when.mjs +37 -0
  229. package/esm/seal/src/rules/core/when.mjs.map +1 -0
  230. package/esm/seal/src/rules/date/date-comparison-rules.mjs +78 -0
  231. package/esm/seal/src/rules/date/date-comparison-rules.mjs.map +1 -0
  232. package/esm/seal/src/rules/date/date-day-rules.mjs +49 -0
  233. package/esm/seal/src/rules/date/date-day-rules.mjs.map +1 -0
  234. package/esm/seal/src/rules/date/date-field-comparison-rules.mjs +82 -0
  235. package/esm/seal/src/rules/date/date-field-comparison-rules.mjs.map +1 -0
  236. package/esm/seal/src/rules/date/date-period-rules.mjs +399 -0
  237. package/esm/seal/src/rules/date/date-period-rules.mjs.map +1 -0
  238. package/esm/seal/src/rules/date/date-relative-rules.mjs +55 -0
  239. package/esm/seal/src/rules/date/date-relative-rules.mjs.map +1 -0
  240. package/esm/seal/src/rules/date/date-special-rules.mjs +58 -0
  241. package/esm/seal/src/rules/date/date-special-rules.mjs.map +1 -0
  242. package/esm/seal/src/rules/date/date.mjs +235 -0
  243. package/esm/seal/src/rules/date/date.mjs.map +1 -0
  244. package/esm/seal/src/rules/date/index.mjs +9 -0
  245. package/esm/seal/src/rules/file/dimensions.mjs +3 -0
  246. package/esm/seal/src/rules/file/file-size.mjs +3 -0
  247. package/esm/seal/src/rules/file/index.mjs +4 -0
  248. package/esm/seal/src/rules/index.mjs +54 -0
  249. package/esm/seal/src/rules/length/index.mjs +3 -0
  250. package/esm/seal/src/rules/length/length-rules.mjs +98 -0
  251. package/esm/seal/src/rules/length/length-rules.mjs.map +1 -0
  252. package/esm/seal/src/rules/number/index.mjs +3 -0
  253. package/esm/seal/src/rules/number/number-rules.mjs +197 -0
  254. package/esm/seal/src/rules/number/number-rules.mjs.map +1 -0
  255. package/esm/seal/src/rules/scalar/accepted-rule.mjs +116 -0
  256. package/esm/seal/src/rules/scalar/accepted-rule.mjs.map +1 -0
  257. package/esm/seal/src/rules/scalar/declined-rule.mjs +116 -0
  258. package/esm/seal/src/rules/scalar/declined-rule.mjs.map +1 -0
  259. package/esm/seal/src/rules/scalar/index.mjs +4 -0
  260. package/esm/seal/src/rules/string/alpha.mjs +41 -0
  261. package/esm/seal/src/rules/string/alpha.mjs.map +1 -0
  262. package/esm/seal/src/rules/string/credit-card.mjs +32 -0
  263. package/esm/seal/src/rules/string/credit-card.mjs.map +1 -0
  264. package/esm/seal/src/rules/string/email.mjs +20 -0
  265. package/esm/seal/src/rules/string/email.mjs.map +1 -0
  266. package/esm/seal/src/rules/string/id-formats.mjs +104 -0
  267. package/esm/seal/src/rules/string/id-formats.mjs.map +1 -0
  268. package/esm/seal/src/rules/string/index.mjs +13 -0
  269. package/esm/seal/src/rules/string/ip.mjs +66 -0
  270. package/esm/seal/src/rules/string/ip.mjs.map +1 -0
  271. package/esm/seal/src/rules/string/matches.mjs +4 -0
  272. package/esm/seal/src/rules/string/pattern.mjs +20 -0
  273. package/esm/seal/src/rules/string/pattern.mjs.map +1 -0
  274. package/esm/seal/src/rules/string/string-comparison.mjs +56 -0
  275. package/esm/seal/src/rules/string/string-comparison.mjs.map +1 -0
  276. package/esm/seal/src/rules/string/strong-password-rule.mjs +31 -0
  277. package/esm/seal/src/rules/string/strong-password-rule.mjs.map +1 -0
  278. package/esm/seal/src/rules/string/url.mjs +23 -0
  279. package/esm/seal/src/rules/string/url.mjs.map +1 -0
  280. package/esm/seal/src/rules/string/without-whitespace.mjs +19 -0
  281. package/esm/seal/src/rules/string/without-whitespace.mjs.map +1 -0
  282. package/esm/seal/src/standard-schema/json-schema.mjs +81 -0
  283. package/esm/seal/src/standard-schema/json-schema.mjs.map +1 -0
  284. package/esm/seal/src/standard-schema/map-result.mjs +26 -0
  285. package/esm/seal/src/standard-schema/map-result.mjs.map +1 -0
  286. package/esm/seal/src/types/date-types.mjs +17 -0
  287. package/esm/seal/src/types/date-types.mjs.map +1 -0
  288. package/esm/seal/src/validators/any-validator.mjs +38 -0
  289. package/esm/seal/src/validators/any-validator.mjs.map +1 -0
  290. package/esm/seal/src/validators/array-validator.mjs +177 -0
  291. package/esm/seal/src/validators/array-validator.mjs.map +1 -0
  292. package/esm/seal/src/validators/base-validator.mjs +691 -0
  293. package/esm/seal/src/validators/base-validator.mjs.map +1 -0
  294. package/esm/seal/src/validators/boolean-validator.mjs +126 -0
  295. package/esm/seal/src/validators/boolean-validator.mjs.map +1 -0
  296. package/esm/seal/src/validators/computed-validator.mjs +118 -0
  297. package/esm/seal/src/validators/computed-validator.mjs.map +1 -0
  298. package/esm/seal/src/validators/date-validator.mjs +639 -0
  299. package/esm/seal/src/validators/date-validator.mjs.map +1 -0
  300. package/esm/seal/src/validators/discriminated-union-validator.mjs +129 -0
  301. package/esm/seal/src/validators/discriminated-union-validator.mjs.map +1 -0
  302. package/esm/seal/src/validators/float-validator.mjs +18 -0
  303. package/esm/seal/src/validators/float-validator.mjs.map +1 -0
  304. package/esm/seal/src/validators/index.mjs +28 -0
  305. package/esm/seal/src/validators/instanceof-validator.mjs +64 -0
  306. package/esm/seal/src/validators/instanceof-validator.mjs.map +1 -0
  307. package/esm/seal/src/validators/int-validator.mjs +30 -0
  308. package/esm/seal/src/validators/int-validator.mjs.map +1 -0
  309. package/esm/seal/src/validators/lazy-validator.mjs +87 -0
  310. package/esm/seal/src/validators/lazy-validator.mjs.map +1 -0
  311. package/esm/seal/src/validators/literal-validator.mjs +71 -0
  312. package/esm/seal/src/validators/literal-validator.mjs.map +1 -0
  313. package/esm/seal/src/validators/managed-validator.mjs +39 -0
  314. package/esm/seal/src/validators/managed-validator.mjs.map +1 -0
  315. package/esm/seal/src/validators/methods/equality-conditional-methods.mjs +129 -0
  316. package/esm/seal/src/validators/methods/equality-conditional-methods.mjs.map +1 -0
  317. package/esm/seal/src/validators/methods/forbidden-methods.mjs +131 -0
  318. package/esm/seal/src/validators/methods/forbidden-methods.mjs.map +1 -0
  319. package/esm/seal/src/validators/methods/present-methods.mjs +235 -0
  320. package/esm/seal/src/validators/methods/present-methods.mjs.map +1 -0
  321. package/esm/seal/src/validators/methods/required-methods.mjs +347 -0
  322. package/esm/seal/src/validators/methods/required-methods.mjs.map +1 -0
  323. package/esm/seal/src/validators/number-validator.mjs +310 -0
  324. package/esm/seal/src/validators/number-validator.mjs.map +1 -0
  325. package/esm/seal/src/validators/numeric-validator.mjs +27 -0
  326. package/esm/seal/src/validators/numeric-validator.mjs.map +1 -0
  327. package/esm/seal/src/validators/object-validator.mjs +442 -0
  328. package/esm/seal/src/validators/object-validator.mjs.map +1 -0
  329. package/esm/seal/src/validators/primitive-validator.mjs +89 -0
  330. package/esm/seal/src/validators/primitive-validator.mjs.map +1 -0
  331. package/esm/seal/src/validators/record-validator.mjs +112 -0
  332. package/esm/seal/src/validators/record-validator.mjs.map +1 -0
  333. package/esm/seal/src/validators/scalar-validator.mjs +172 -0
  334. package/esm/seal/src/validators/scalar-validator.mjs.map +1 -0
  335. package/esm/seal/src/validators/string-validator.mjs +459 -0
  336. package/esm/seal/src/validators/string-validator.mjs.map +1 -0
  337. package/esm/seal/src/validators/tuple-validator.mjs +134 -0
  338. package/esm/seal/src/validators/tuple-validator.mjs.map +1 -0
  339. package/esm/seal/src/validators/union-validator.mjs +66 -0
  340. package/esm/seal/src/validators/union-validator.mjs.map +1 -0
  341. package/llms-full.txt +5 -1
  342. package/package.json +5 -5
  343. package/skills/send-ad-hoc/SKILL.md +1 -1
  344. package/skills/use-in-app/SKILL.md +4 -0
@@ -0,0 +1,112 @@
1
+ import { applyNullable } from "../standard-schema/json-schema.mjs";
2
+ import { setKeyPath } from "../helpers/path-helpers.mjs";
3
+ import "../helpers/index.mjs";
4
+ import { isPlainObject } from "../../../node_modules/@mongez/supportive-is/esm/index.mjs";
5
+ import { BaseValidator } from "./base-validator.mjs";
6
+ import { objectRule, plainObjectRule } from "../rules/common/type-rules.mjs";
7
+ import "../rules/index.mjs";
8
+
9
+ //#region ../seal/src/validators/record-validator.ts
10
+ /**
11
+ * Record validator class - validates objects with dynamic keys and consistent value types
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * // Translations object
16
+ * v.record(v.string())
17
+ * // Valid: { en: "Hello", ar: "مرحبا", fr: "Bonjour" }
18
+ *
19
+ * // User preferences
20
+ * v.record(v.union([v.string(), v.number(), v.boolean()]))
21
+ * // Valid: { theme: "dark", fontSize: 16, notifications: true }
22
+ * ```
23
+ */
24
+ var RecordValidator = class extends BaseValidator {
25
+ valueValidator;
26
+ constructor(valueValidator, errorMessage) {
27
+ super();
28
+ this.valueValidator = valueValidator;
29
+ this.addMutableRule(objectRule, errorMessage);
30
+ }
31
+ /**
32
+ * Validate it as plain object
33
+ */
34
+ plainObject(errorMessage) {
35
+ return this.addRule(plainObjectRule, errorMessage);
36
+ }
37
+ /**
38
+ * Check if value is a plain object type
39
+ */
40
+ matchesType(value) {
41
+ return isPlainObject(value);
42
+ }
43
+ /**
44
+ * Clone the validator
45
+ */
46
+ clone() {
47
+ const cloned = super.clone();
48
+ cloned.valueValidator = this.valueValidator.clone();
49
+ return cloned;
50
+ }
51
+ /**
52
+ * Validate record - iterate all keys and validate each value
53
+ *
54
+ * Absent input (and absent without `.default()`) propagates as `data: undefined`
55
+ * so the parent ObjectValidator can omit the key. Without this, optional record
56
+ * fields would silently materialise as `{}` in the validated output.
57
+ */
58
+ async validate(data, context) {
59
+ const valueForRules = data ?? this.getDefaultValue();
60
+ const mutatedData = await this.mutate(valueForRules, context);
61
+ const result = await super.validate(data, context);
62
+ if (result.isValid === false) return result;
63
+ if (mutatedData === void 0 || mutatedData === null) return result;
64
+ if (!isPlainObject(mutatedData)) return result;
65
+ const errors = [];
66
+ const validationPromises = Object.keys(mutatedData).map(async (key) => {
67
+ const childContext = {
68
+ ...context,
69
+ parent: mutatedData,
70
+ value: mutatedData[key],
71
+ key,
72
+ path: setKeyPath(context.path, key)
73
+ };
74
+ const childResult = await this.valueValidator.validate(mutatedData[key], childContext);
75
+ mutatedData[key] = childResult.data;
76
+ if (childResult.isValid === false) errors.push(...childResult.errors);
77
+ });
78
+ await Promise.all(validationPromises);
79
+ return {
80
+ isValid: errors.length === 0,
81
+ errors,
82
+ data: await this.startTransformationPipeline(mutatedData, context)
83
+ };
84
+ }
85
+ /**
86
+ * @inheritdoc
87
+ *
88
+ * Generates `{ type: "object", additionalProperties: <valueSchema> }` —
89
+ * the standard JSON Schema for a dictionary/map with homogeneous values.
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * v.record(v.string()).toJsonSchema("draft-2020-12")
94
+ * // → { type: "object", additionalProperties: { type: "string" } }
95
+ *
96
+ * v.record(v.union([v.string(), v.number()])).toJsonSchema("draft-2020-12")
97
+ * // → { type: "object", additionalProperties: { oneOf: [{ type: "string" }, { type: "number" }] } }
98
+ * ```
99
+ */
100
+ toJsonSchema(target = "draft-2020-12") {
101
+ const schema = {
102
+ type: "object",
103
+ additionalProperties: this.valueValidator.toJsonSchema(target)
104
+ };
105
+ if (this.isNullable) applyNullable(schema, target);
106
+ return schema;
107
+ }
108
+ };
109
+
110
+ //#endregion
111
+ export { RecordValidator };
112
+ //# sourceMappingURL=record-validator.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-validator.mjs","names":[],"sources":["../../../../../../../../../seal/src/validators/record-validator.ts"],"sourcesContent":["import { isPlainObject } from \"@mongez/supportive-is\";\r\nimport { setKeyPath } from \"../helpers\";\r\nimport { objectRule, plainObjectRule } from \"../rules\";\r\nimport type { SchemaContext, ValidationResult } from \"../types\";\r\nimport { BaseValidator } from \"./base-validator\";\r\nimport { applyNullable } from \"../standard-schema/json-schema\";\r\nimport type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\r\n\r\n/**\r\n * Record validator class - validates objects with dynamic keys and consistent value types\r\n *\r\n * @example\r\n * ```ts\r\n * // Translations object\r\n * v.record(v.string())\r\n * // Valid: { en: \"Hello\", ar: \"مرحبا\", fr: \"Bonjour\" }\r\n *\r\n * // User preferences\r\n * v.record(v.union([v.string(), v.number(), v.boolean()]))\r\n * // Valid: { theme: \"dark\", fontSize: 16, notifications: true }\r\n * ```\r\n */\r\nexport class RecordValidator extends BaseValidator {\r\n public constructor(\r\n public valueValidator: BaseValidator,\r\n errorMessage?: string,\r\n ) {\r\n super();\r\n this.addMutableRule(objectRule, errorMessage);\r\n }\r\n\r\n /**\r\n * Validate it as plain object\r\n */\r\n public plainObject(errorMessage?: string) {\r\n return this.addRule(plainObjectRule, errorMessage);\r\n }\r\n\r\n /**\r\n * Check if value is a plain object type\r\n */\r\n public matchesType(value: any): boolean {\r\n return isPlainObject(value);\r\n }\r\n\r\n /**\r\n * Clone the validator\r\n */\r\n public override clone(): this {\r\n const cloned = super.clone();\r\n cloned.valueValidator = this.valueValidator.clone();\r\n return cloned;\r\n }\r\n\r\n /**\r\n * Validate record - iterate all keys and validate each value\r\n *\r\n * Absent input (and absent without `.default()`) propagates as `data: undefined`\r\n * so the parent ObjectValidator can omit the key. Without this, optional record\r\n * fields would silently materialise as `{}` in the validated output.\r\n */\r\n public async validate(data: any, context: SchemaContext): Promise<ValidationResult> {\r\n // Apply default when absent, then mutate. Mirrors BaseValidator's\r\n // `valueForRules = data ?? this.getDefaultValue()` so `.default({...})`\r\n // works on records too.\r\n const valueForRules = data ?? this.getDefaultValue();\r\n const mutatedData = await this.mutate(valueForRules, context);\r\n\r\n const result = await super.validate(data, context);\r\n\r\n if (result.isValid === false) return result;\r\n\r\n // Nothing to iterate for absent (no default) or null (nullable) inputs —\r\n // propagate so the parent ObjectValidator can omit the key.\r\n if (mutatedData === undefined || mutatedData === null) return result;\r\n\r\n // Defensive: type rule (objectRule) should have failed for non-objects.\r\n if (!isPlainObject(mutatedData)) return result;\r\n\r\n const errors: ValidationResult[\"errors\"] = [];\r\n const keys = Object.keys(mutatedData);\r\n\r\n // Validate all values in parallel\r\n const validationPromises = keys.map(async (key) => {\r\n const childContext: SchemaContext = {\r\n ...context,\r\n parent: mutatedData,\r\n value: mutatedData[key],\r\n key,\r\n path: setKeyPath(context.path, key),\r\n };\r\n\r\n const childResult = await this.valueValidator.validate(mutatedData[key], childContext);\r\n\r\n // Update mutated data with validated result\r\n mutatedData[key] = childResult.data;\r\n\r\n // Collect errors from this value\r\n if (childResult.isValid === false) {\r\n errors.push(...childResult.errors);\r\n }\r\n });\r\n\r\n await Promise.all(validationPromises);\r\n\r\n return {\r\n isValid: errors.length === 0,\r\n errors,\r\n data: await this.startTransformationPipeline(mutatedData, context),\r\n };\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n *\r\n * Generates `{ type: \"object\", additionalProperties: <valueSchema> }` —\r\n * the standard JSON Schema for a dictionary/map with homogeneous values.\r\n *\r\n * @example\r\n * ```ts\r\n * v.record(v.string()).toJsonSchema(\"draft-2020-12\")\r\n * // → { type: \"object\", additionalProperties: { type: \"string\" } }\r\n *\r\n * v.record(v.union([v.string(), v.number()])).toJsonSchema(\"draft-2020-12\")\r\n * // → { type: \"object\", additionalProperties: { oneOf: [{ type: \"string\" }, { type: \"number\" }] } }\r\n * ```\r\n */\r\n public override toJsonSchema(target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\r\n const schema: JsonSchemaResult = {\r\n type: \"object\",\r\n additionalProperties: this.valueValidator.toJsonSchema(target),\r\n };\r\n\r\n if (this.isNullable) applyNullable(schema, target);\r\n\r\n return schema;\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAa,kBAAb,cAAqC,cAAc;CAExC;CADT,AAAO,YACL,AAAO,gBACP,cACA;EACA,MAAM;EAHC;EAIP,KAAK,eAAe,YAAY,YAAY;CAC9C;;;;CAKA,AAAO,YAAY,cAAuB;EACxC,OAAO,KAAK,QAAQ,iBAAiB,YAAY;CACnD;;;;CAKA,AAAO,YAAY,OAAqB;EACtC,OAAO,cAAc,KAAK;CAC5B;;;;CAKA,AAAgB,QAAc;EAC5B,MAAM,SAAS,MAAM,MAAM;EAC3B,OAAO,iBAAiB,KAAK,eAAe,MAAM;EAClD,OAAO;CACT;;;;;;;;CASA,MAAa,SAAS,MAAW,SAAmD;EAIlF,MAAM,gBAAgB,QAAQ,KAAK,gBAAgB;EACnD,MAAM,cAAc,MAAM,KAAK,OAAO,eAAe,OAAO;EAE5D,MAAM,SAAS,MAAM,MAAM,SAAS,MAAM,OAAO;EAEjD,IAAI,OAAO,YAAY,OAAO,OAAO;EAIrC,IAAI,gBAAgB,UAAa,gBAAgB,MAAM,OAAO;EAG9D,IAAI,CAAC,cAAc,WAAW,GAAG,OAAO;EAExC,MAAM,SAAqC,CAAC;EAI5C,MAAM,qBAHO,OAAO,KAAK,WAGK,CAAC,CAAC,IAAI,OAAO,QAAQ;GACjD,MAAM,eAA8B;IAClC,GAAG;IACH,QAAQ;IACR,OAAO,YAAY;IACnB;IACA,MAAM,WAAW,QAAQ,MAAM,GAAG;GACpC;GAEA,MAAM,cAAc,MAAM,KAAK,eAAe,SAAS,YAAY,MAAM,YAAY;GAGrF,YAAY,OAAO,YAAY;GAG/B,IAAI,YAAY,YAAY,OAC1B,OAAO,KAAK,GAAG,YAAY,MAAM;EAErC,CAAC;EAED,MAAM,QAAQ,IAAI,kBAAkB;EAEpC,OAAO;GACL,SAAS,OAAO,WAAW;GAC3B;GACA,MAAM,MAAM,KAAK,4BAA4B,aAAa,OAAO;EACnE;CACF;;;;;;;;;;;;;;;;CAiBA,AAAgB,aAAa,SAA2B,iBAAmC;EACzF,MAAM,SAA2B;GAC/B,MAAM;GACN,sBAAsB,KAAK,eAAe,aAAa,MAAM;EAC/D;EAEA,IAAI,KAAK,YAAY,cAAc,QAAQ,MAAM;EAEjD,OAAO;CACT;AACF"}
@@ -0,0 +1,172 @@
1
+ import { getRuleOptions } from "../standard-schema/json-schema.mjs";
2
+ import { VALID_RULE, invalidRule } from "../helpers/validation-helpers.mjs";
3
+ import "../helpers/index.mjs";
4
+ import { numberMutator } from "../mutators/number-mutators.mjs";
5
+ import { stringMutator } from "../mutators/scalar-mutators.mjs";
6
+ import "../mutators/index.mjs";
7
+ import { PrimitiveValidator } from "./primitive-validator.mjs";
8
+ import { acceptedIfPresentRule, acceptedIfRequiredRule, acceptedIfRule, acceptedRule, acceptedUnlessRule, acceptedWithoutRule } from "../rules/scalar/accepted-rule.mjs";
9
+ import { declinedIfPresentRule, declinedIfRequiredRule, declinedIfRule, declinedRule, declinedUnlessRule, declinedWithoutRule } from "../rules/scalar/declined-rule.mjs";
10
+ import "../rules/scalar/index.mjs";
11
+
12
+ //#region ../seal/src/validators/scalar-validator.ts
13
+ /**
14
+ * Scalar validator class
15
+ *
16
+ * Core validator for scalar values (string, number, boolean).
17
+ * Extends PrimitiveValidator (inherits enum/in/oneOf/allowsOnly/forbids/notIn)
18
+ * and additionally provides type-coercion mutators and accepted/declined rules.
19
+ *
20
+ * Database methods (unique, exists, etc.) are injected by the framework
21
+ */
22
+ var ScalarValidator = class extends PrimitiveValidator {
23
+ constructor(errorMessage) {
24
+ super();
25
+ this.addMutableRule({
26
+ name: "scalar",
27
+ defaultErrorMessage: "The :input must be a scalar value",
28
+ async validate(value, context) {
29
+ if ([
30
+ "string",
31
+ "number",
32
+ "boolean"
33
+ ].includes(typeof value)) return VALID_RULE;
34
+ return invalidRule(this, context);
35
+ }
36
+ }, errorMessage);
37
+ }
38
+ /**
39
+ * Add matches type
40
+ */
41
+ matchesType(value) {
42
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
43
+ }
44
+ /**
45
+ * Mutate the scalar value to be number
46
+ */
47
+ asNumber() {
48
+ return this.addMutator(numberMutator);
49
+ }
50
+ /**
51
+ * Mutate the scalar value to be string
52
+ */
53
+ asString() {
54
+ return this.addMutator(stringMutator);
55
+ }
56
+ /**
57
+ * Accepted value
58
+ * The value will be valid if it equals 1 | "1" | true | "true" | "yes" | "y" | "on"
59
+ */
60
+ accepted(errorMessage) {
61
+ return this.addRule(acceptedRule, errorMessage);
62
+ }
63
+ /**
64
+ * Accepted value if another field's value equals to a specific value
65
+ */
66
+ acceptedIf(field, value, errorMessage) {
67
+ return this.addRule(acceptedIfRule, errorMessage, {
68
+ field,
69
+ value
70
+ });
71
+ }
72
+ /**
73
+ * Accepted value if another field's value is not equal to the given value
74
+ */
75
+ acceptedUnless(field, value, errorMessage) {
76
+ return this.addRule(acceptedUnlessRule, errorMessage, {
77
+ field,
78
+ value
79
+ });
80
+ }
81
+ /**
82
+ * Accepted value if another field is required
83
+ */
84
+ acceptedIfRequired(field, errorMessage) {
85
+ return this.addRule(acceptedIfRequiredRule, errorMessage, { field });
86
+ }
87
+ /**
88
+ * Accepted value if another field is present
89
+ */
90
+ acceptedIfPresent(field, errorMessage) {
91
+ return this.addRule(acceptedIfPresentRule, errorMessage, { field });
92
+ }
93
+ /**
94
+ * Accepted value if another field is missing
95
+ */
96
+ acceptedWithout(field, errorMessage) {
97
+ return this.addRule(acceptedWithoutRule, errorMessage, { field });
98
+ }
99
+ /**
100
+ * Declined value
101
+ * The value will be valid if it equals 0 | "0" | false | "false" | "no" | "n" | "off"
102
+ */
103
+ declined(errorMessage) {
104
+ return this.addRule(declinedRule, errorMessage);
105
+ }
106
+ /**
107
+ * Declined value if another field's value equals to a specific value
108
+ */
109
+ declinedIf(field, value, errorMessage) {
110
+ return this.addRule(declinedIfRule, errorMessage, {
111
+ field,
112
+ value
113
+ });
114
+ }
115
+ /**
116
+ * Declined value if another field's value is not equal to the given value
117
+ */
118
+ declinedUnless(field, value, errorMessage) {
119
+ return this.addRule(declinedUnlessRule, errorMessage, {
120
+ field,
121
+ value
122
+ });
123
+ }
124
+ /**
125
+ * Declined value if another field is required
126
+ */
127
+ declinedIfRequired(field, errorMessage) {
128
+ return this.addRule(declinedIfRequiredRule, errorMessage, { field });
129
+ }
130
+ /**
131
+ * Declined value if another field is present
132
+ */
133
+ declinedIfPresent(field, errorMessage) {
134
+ return this.addRule(declinedIfPresentRule, errorMessage, { field });
135
+ }
136
+ /**
137
+ * Declined value if another field is missing
138
+ */
139
+ declinedWithout(field, errorMessage) {
140
+ return this.addRule(declinedWithoutRule, errorMessage, { field });
141
+ }
142
+ /**
143
+ * @inheritdoc
144
+ *
145
+ * A scalar accepts string | number | boolean. If `.in()` / `.enum()` is used,
146
+ * output collapses to a simple `enum` list instead.
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * v.scalar().toJsonSchema("draft-2020-12")
151
+ * // → { oneOf: [{ type: "string" }, { type: "number" }, { type: "boolean" }] }
152
+ *
153
+ * v.scalar().in(["active", "inactive"]).toJsonSchema("draft-2020-12")
154
+ * // → { enum: ["active", "inactive"] }
155
+ * ```
156
+ */
157
+ toJsonSchema(_target = "draft-2020-12") {
158
+ const inOpts = getRuleOptions(this.rules, "in");
159
+ if (inOpts?.values && Array.isArray(inOpts.values)) return { enum: inOpts.values };
160
+ const enumOpts = getRuleOptions(this.rules, "enum");
161
+ if (enumOpts?.enum && Array.isArray(enumOpts.enum)) return { enum: enumOpts.enum };
162
+ return { oneOf: [
163
+ { type: "string" },
164
+ { type: "number" },
165
+ { type: "boolean" }
166
+ ] };
167
+ }
168
+ };
169
+
170
+ //#endregion
171
+ export { ScalarValidator };
172
+ //# sourceMappingURL=scalar-validator.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scalar-validator.mjs","names":[],"sources":["../../../../../../../../../seal/src/validators/scalar-validator.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../helpers\";\r\nimport { numberMutator, stringMutator } from \"../mutators\";\r\nimport {\r\n acceptedIfPresentRule,\r\n acceptedIfRequiredRule,\r\n acceptedIfRule,\r\n acceptedRule,\r\n acceptedUnlessRule,\r\n acceptedWithoutRule,\r\n declinedIfPresentRule,\r\n declinedIfRequiredRule,\r\n declinedIfRule,\r\n declinedRule,\r\n declinedUnlessRule,\r\n declinedWithoutRule,\r\n} from \"../rules/scalar\";\r\nimport { PrimitiveValidator } from \"./primitive-validator\";\r\nimport { getRuleOptions } from \"../standard-schema/json-schema\";\r\nimport type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\r\n\r\n/**\r\n * Scalar validator class\r\n *\r\n * Core validator for scalar values (string, number, boolean).\r\n * Extends PrimitiveValidator (inherits enum/in/oneOf/allowsOnly/forbids/notIn)\r\n * and additionally provides type-coercion mutators and accepted/declined rules.\r\n *\r\n * Database methods (unique, exists, etc.) are injected by the framework\r\n */\r\nexport class ScalarValidator extends PrimitiveValidator {\r\n public constructor(errorMessage?: string) {\r\n super();\r\n this.addMutableRule(\r\n {\r\n name: \"scalar\",\r\n defaultErrorMessage: \"The :input must be a scalar value\",\r\n async validate(value, context) {\r\n if ([\"string\", \"number\", \"boolean\"].includes(typeof value)) {\r\n return VALID_RULE;\r\n }\r\n return invalidRule(this, context);\r\n },\r\n },\r\n errorMessage,\r\n );\r\n }\r\n\r\n /**\r\n * Add matches type\r\n */\r\n public matchesType(value: any) {\r\n return typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\";\r\n }\r\n\r\n /**\r\n * Mutate the scalar value to be number\r\n */\r\n public asNumber() {\r\n return this.addMutator(numberMutator);\r\n }\r\n\r\n /**\r\n * Mutate the scalar value to be string\r\n */\r\n public asString() {\r\n return this.addMutator(stringMutator);\r\n }\r\n\r\n /**\r\n * Accepted value\r\n * The value will be valid if it equals 1 | \"1\" | true | \"true\" | \"yes\" | \"y\" | \"on\"\r\n */\r\n public accepted(errorMessage?: string) {\r\n return this.addRule(acceptedRule, errorMessage);\r\n }\r\n\r\n /**\r\n * Accepted value if another field's value equals to a specific value\r\n */\r\n public acceptedIf(field: string, value: any, errorMessage?: string) {\r\n return this.addRule(acceptedIfRule, errorMessage, { field, value });\r\n }\r\n\r\n /**\r\n * Accepted value if another field's value is not equal to the given value\r\n */\r\n public acceptedUnless(field: string, value: any, errorMessage?: string) {\r\n return this.addRule(acceptedUnlessRule, errorMessage, { field, value });\r\n }\r\n\r\n /**\r\n * Accepted value if another field is required\r\n */\r\n public acceptedIfRequired(field: string, errorMessage?: string) {\r\n return this.addRule(acceptedIfRequiredRule, errorMessage, { field });\r\n }\r\n\r\n /**\r\n * Accepted value if another field is present\r\n */\r\n public acceptedIfPresent(field: string, errorMessage?: string) {\r\n return this.addRule(acceptedIfPresentRule, errorMessage, { field });\r\n }\r\n\r\n /**\r\n * Accepted value if another field is missing\r\n */\r\n public acceptedWithout(field: string, errorMessage?: string) {\r\n return this.addRule(acceptedWithoutRule, errorMessage, { field });\r\n }\r\n\r\n /**\r\n * Declined value\r\n * The value will be valid if it equals 0 | \"0\" | false | \"false\" | \"no\" | \"n\" | \"off\"\r\n */\r\n public declined(errorMessage?: string) {\r\n return this.addRule(declinedRule, errorMessage);\r\n }\r\n\r\n /**\r\n * Declined value if another field's value equals to a specific value\r\n */\r\n public declinedIf(field: string, value: any, errorMessage?: string) {\r\n return this.addRule(declinedIfRule, errorMessage, { field, value });\r\n }\r\n\r\n /**\r\n * Declined value if another field's value is not equal to the given value\r\n */\r\n public declinedUnless(field: string, value: any, errorMessage?: string) {\r\n return this.addRule(declinedUnlessRule, errorMessage, { field, value });\r\n }\r\n\r\n /**\r\n * Declined value if another field is required\r\n */\r\n public declinedIfRequired(field: string, errorMessage?: string) {\r\n return this.addRule(declinedIfRequiredRule, errorMessage, { field });\r\n }\r\n\r\n /**\r\n * Declined value if another field is present\r\n */\r\n public declinedIfPresent(field: string, errorMessage?: string) {\r\n return this.addRule(declinedIfPresentRule, errorMessage, { field });\r\n }\r\n\r\n /**\r\n * Declined value if another field is missing\r\n */\r\n public declinedWithout(field: string, errorMessage?: string) {\r\n return this.addRule(declinedWithoutRule, errorMessage, { field });\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n *\r\n * A scalar accepts string | number | boolean. If `.in()` / `.enum()` is used,\r\n * output collapses to a simple `enum` list instead.\r\n *\r\n * @example\r\n * ```ts\r\n * v.scalar().toJsonSchema(\"draft-2020-12\")\r\n * // → { oneOf: [{ type: \"string\" }, { type: \"number\" }, { type: \"boolean\" }] }\r\n *\r\n * v.scalar().in([\"active\", \"inactive\"]).toJsonSchema(\"draft-2020-12\")\r\n * // → { enum: [\"active\", \"inactive\"] }\r\n * ```\r\n */\r\n public override toJsonSchema(_target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\r\n // If a value set is constrained, collapse to enum\r\n const inOpts = getRuleOptions(this.rules, \"in\");\r\n if (inOpts?.values && Array.isArray(inOpts.values)) {\r\n return { enum: inOpts.values };\r\n }\r\n\r\n const enumOpts = getRuleOptions(this.rules, \"enum\");\r\n if (enumOpts?.enum && Array.isArray(enumOpts.enum)) {\r\n return { enum: enumOpts.enum };\r\n }\r\n\r\n return {\r\n oneOf: [\r\n { type: \"string\" },\r\n { type: \"number\" },\r\n { type: \"boolean\" },\r\n ],\r\n };\r\n }\r\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6BA,IAAa,kBAAb,cAAqC,mBAAmB;CACtD,AAAO,YAAY,cAAuB;EACxC,MAAM;EACN,KAAK,eACH;GACE,MAAM;GACN,qBAAqB;GACrB,MAAM,SAAS,OAAO,SAAS;IAC7B,IAAI;KAAC;KAAU;KAAU;IAAS,CAAC,CAAC,SAAS,OAAO,KAAK,GACvD,OAAO;IAET,OAAO,YAAY,MAAM,OAAO;GAClC;EACF,GACA,YACF;CACF;;;;CAKA,AAAO,YAAY,OAAY;EAC7B,OAAO,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU;CACpF;;;;CAKA,AAAO,WAAW;EAChB,OAAO,KAAK,WAAW,aAAa;CACtC;;;;CAKA,AAAO,WAAW;EAChB,OAAO,KAAK,WAAW,aAAa;CACtC;;;;;CAMA,AAAO,SAAS,cAAuB;EACrC,OAAO,KAAK,QAAQ,cAAc,YAAY;CAChD;;;;CAKA,AAAO,WAAW,OAAe,OAAY,cAAuB;EAClE,OAAO,KAAK,QAAQ,gBAAgB,cAAc;GAAE;GAAO;EAAM,CAAC;CACpE;;;;CAKA,AAAO,eAAe,OAAe,OAAY,cAAuB;EACtE,OAAO,KAAK,QAAQ,oBAAoB,cAAc;GAAE;GAAO;EAAM,CAAC;CACxE;;;;CAKA,AAAO,mBAAmB,OAAe,cAAuB;EAC9D,OAAO,KAAK,QAAQ,wBAAwB,cAAc,EAAE,MAAM,CAAC;CACrE;;;;CAKA,AAAO,kBAAkB,OAAe,cAAuB;EAC7D,OAAO,KAAK,QAAQ,uBAAuB,cAAc,EAAE,MAAM,CAAC;CACpE;;;;CAKA,AAAO,gBAAgB,OAAe,cAAuB;EAC3D,OAAO,KAAK,QAAQ,qBAAqB,cAAc,EAAE,MAAM,CAAC;CAClE;;;;;CAMA,AAAO,SAAS,cAAuB;EACrC,OAAO,KAAK,QAAQ,cAAc,YAAY;CAChD;;;;CAKA,AAAO,WAAW,OAAe,OAAY,cAAuB;EAClE,OAAO,KAAK,QAAQ,gBAAgB,cAAc;GAAE;GAAO;EAAM,CAAC;CACpE;;;;CAKA,AAAO,eAAe,OAAe,OAAY,cAAuB;EACtE,OAAO,KAAK,QAAQ,oBAAoB,cAAc;GAAE;GAAO;EAAM,CAAC;CACxE;;;;CAKA,AAAO,mBAAmB,OAAe,cAAuB;EAC9D,OAAO,KAAK,QAAQ,wBAAwB,cAAc,EAAE,MAAM,CAAC;CACrE;;;;CAKA,AAAO,kBAAkB,OAAe,cAAuB;EAC7D,OAAO,KAAK,QAAQ,uBAAuB,cAAc,EAAE,MAAM,CAAC;CACpE;;;;CAKA,AAAO,gBAAgB,OAAe,cAAuB;EAC3D,OAAO,KAAK,QAAQ,qBAAqB,cAAc,EAAE,MAAM,CAAC;CAClE;;;;;;;;;;;;;;;;CAiBA,AAAgB,aAAa,UAA4B,iBAAmC;EAE1F,MAAM,SAAS,eAAe,KAAK,OAAO,IAAI;EAC9C,IAAI,QAAQ,UAAU,MAAM,QAAQ,OAAO,MAAM,GAC/C,OAAO,EAAE,MAAM,OAAO,OAAO;EAG/B,MAAM,WAAW,eAAe,KAAK,OAAO,MAAM;EAClD,IAAI,UAAU,QAAQ,MAAM,QAAQ,SAAS,IAAI,GAC/C,OAAO,EAAE,MAAM,SAAS,KAAK;EAG/B,OAAO,EACL,OAAO;GACL,EAAE,MAAM,SAAS;GACjB,EAAE,MAAM,SAAS;GACjB,EAAE,MAAM,UAAU;EACpB,EACF;CACF;AACF"}