@warlock.js/notifications 5.31.0 → 5.33.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 (405) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/cjs/index.cjs +2 -2
  3. package/cjs/index.cjs.map +1 -1
  4. package/esm/channels/database-channel.d.mts +2 -3
  5. package/esm/channels/database-channel.d.mts.map +1 -1
  6. package/esm/channels/index.d.mts +2 -1
  7. package/esm/channels/index.mjs +1 -1
  8. package/esm/channels/mail-channel.d.mts +6 -4
  9. package/esm/channels/mail-channel.d.mts.map +1 -1
  10. package/esm/config.d.mts +13 -9
  11. package/esm/config.d.mts.map +1 -1
  12. package/esm/contracts/channel.contract.d.mts +1 -3
  13. package/esm/contracts/channel.contract.d.mts.map +1 -1
  14. package/esm/contracts/index.d.mts +2 -1
  15. package/esm/contracts/notification.contract.d.mts +1 -3
  16. package/esm/contracts/notification.contract.d.mts.map +1 -1
  17. package/esm/contracts/preference-provider.contract.d.mts +1 -3
  18. package/esm/contracts/preference-provider.contract.d.mts.map +1 -1
  19. package/esm/contracts/queue-dispatcher.contract.d.mts +1 -3
  20. package/esm/contracts/queue-dispatcher.contract.d.mts.map +1 -1
  21. package/esm/contracts/rate-limiter.contract.d.mts +1 -3
  22. package/esm/contracts/rate-limiter.contract.d.mts.map +1 -1
  23. package/esm/dispatch/define-channel.d.mts +2 -2
  24. package/esm/dispatch/define-channel.d.mts.map +1 -1
  25. package/esm/dispatch/define-notification.d.mts +5 -6
  26. package/esm/dispatch/define-notification.d.mts.map +1 -1
  27. package/esm/dispatch/index.d.mts +2 -1
  28. package/esm/dispatch/index.mjs +1 -1
  29. package/esm/dispatch/notifications-event-bus.d.mts +2 -3
  30. package/esm/dispatch/notifications-event-bus.d.mts.map +1 -1
  31. package/esm/dispatch/notify.d.mts +3 -5
  32. package/esm/dispatch/notify.d.mts.map +1 -1
  33. package/esm/errors.d.mts +5 -6
  34. package/esm/errors.d.mts.map +1 -1
  35. package/esm/in-app/base-notifications-repository.d.mts +6 -6
  36. package/esm/in-app/base-notifications-repository.d.mts.map +1 -1
  37. package/esm/in-app/base-notifications-repository.mjs +1 -1
  38. package/esm/in-app/base-notifications-repository.mjs.map +1 -1
  39. package/esm/in-app/column-map.d.mts +11 -8
  40. package/esm/in-app/column-map.d.mts.map +1 -1
  41. package/esm/in-app/database-notification.d.mts +2 -3
  42. package/esm/in-app/database-notification.d.mts.map +1 -1
  43. package/esm/in-app/in-app.d.mts +6 -5
  44. package/esm/in-app/in-app.d.mts.map +1 -1
  45. package/esm/in-app/index.d.mts +2 -1
  46. package/esm/in-app/index.mjs +1 -1
  47. package/esm/index.d.mts +6 -0
  48. package/esm/migration/index.d.mts +2 -1
  49. package/esm/migration/index.mjs +1 -1
  50. package/esm/migration/notification-columns.d.mts +6 -7
  51. package/esm/migration/notification-columns.d.mts.map +1 -1
  52. package/esm/queue/bullmq-queue.d.mts +9 -7
  53. package/esm/queue/bullmq-queue.d.mts.map +1 -1
  54. package/esm/queue/herald-queue.d.mts +6 -4
  55. package/esm/queue/herald-queue.d.mts.map +1 -1
  56. package/esm/queue/index.d.mts +2 -1
  57. package/esm/queue/index.mjs +1 -1
  58. package/esm/queue/load-herald.d.mts +1 -2
  59. package/esm/queue/load-herald.d.mts.map +1 -1
  60. package/esm/queue/load-herald.mjs +1 -1
  61. package/esm/queue/load-queue.d.mts +2 -3
  62. package/esm/queue/load-queue.d.mts.map +1 -1
  63. package/esm/queue/notifications-worker.d.mts +5 -4
  64. package/esm/queue/notifications-worker.d.mts.map +1 -1
  65. package/esm/queue/queue-package-not-installed.error.d.mts +1 -2
  66. package/esm/queue/queue-package-not-installed.error.d.mts.map +1 -1
  67. package/esm/types.d.mts +22 -18
  68. package/esm/types.d.mts.map +1 -1
  69. package/package.json +10 -9
  70. package/cjs/channel_api-C5ZZDkgQ.cjs +0 -7463
  71. package/cjs/channel_api-C5ZZDkgQ.cjs.map +0 -1
  72. package/cjs/chunk-fl3r8ClO.cjs +0 -41
  73. package/cjs/rabbitmq-driver-CkPaCswV.cjs +0 -3
  74. package/cjs/src-CcbF8Hr1.cjs +0 -11276
  75. package/cjs/src-CcbF8Hr1.cjs.map +0 -1
  76. package/esm/_virtual/_rolldown/runtime.mjs +0 -32
  77. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/_internal.mjs +0 -6
  78. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/_internal.mjs.map +0 -1
  79. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/bool.mjs +0 -3
  80. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/color.mjs +0 -3
  81. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/date.mjs +0 -3
  82. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/float.mjs +0 -3
  83. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/id.mjs +0 -3
  84. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/int.mjs +0 -3
  85. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/nanoid.mjs +0 -3
  86. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/pick.mjs +0 -3
  87. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/random.mjs +0 -16
  88. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/sample.mjs +0 -3
  89. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/string.mjs +0 -3
  90. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/token.mjs +0 -3
  91. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/uuid.mjs +0 -3
  92. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/weighted.mjs +0 -3
  93. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/async/retry.mjs +0 -3
  94. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/index.mjs +0 -24
  95. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/mixed/clone/clone.mjs +0 -82
  96. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/mixed/clone/clone.mjs.map +0 -1
  97. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/number/round.mjs +0 -17
  98. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/number/round.mjs.map +0 -1
  99. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/except.mjs +0 -13
  100. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/except.mjs.map +0 -1
  101. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/get.mjs +0 -18
  102. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/get.mjs.map +0 -1
  103. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/omit.mjs +0 -17
  104. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/omit.mjs.map +0 -1
  105. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/unset.mjs +0 -30
  106. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/unset.mjs.map +0 -1
  107. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/capitalize.mjs +0 -19
  108. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/capitalize.mjs.map +0 -1
  109. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/ltrim.mjs +0 -18
  110. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/ltrim.mjs.map +0 -1
  111. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/readMoreChars.mjs +0 -14
  112. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/readMoreChars.mjs.map +0 -1
  113. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/rtrim.mjs +0 -18
  114. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/rtrim.mjs.map +0 -1
  115. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toCamelCase.mjs +0 -22
  116. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toCamelCase.mjs.map +0 -1
  117. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toKebabCase.mjs +0 -17
  118. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toKebabCase.mjs.map +0 -1
  119. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toSnakeCase.mjs +0 -21
  120. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toSnakeCase.mjs.map +0 -1
  121. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toStudlyCase.mjs +0 -21
  122. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toStudlyCase.mjs.map +0 -1
  123. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/trim.mjs +0 -20
  124. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/trim.mjs.map +0 -1
  125. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/ucfirst.mjs +0 -15
  126. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/ucfirst.mjs.map +0 -1
  127. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/words.mjs +0 -25
  128. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/words.mjs.map +0 -1
  129. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/escapeRegex.mjs +0 -11
  130. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/escapeRegex.mjs.map +0 -1
  131. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/lazy.mjs +0 -100
  132. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/lazy.mjs.map +0 -1
  133. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/tap.mjs +0 -27
  134. package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/tap.mjs.map +0 -1
  135. package/esm/node_modules/.pnpm/@mongez_supportive-is@3.0.0/node_modules/@mongez/supportive-is/esm/index.mjs +0 -358
  136. package/esm/node_modules/.pnpm/@mongez_supportive-is@3.0.0/node_modules/@mongez/supportive-is/esm/index.mjs.map +0 -1
  137. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/channel_api.mjs +0 -28
  138. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/channel_api.mjs.map +0 -1
  139. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/api_args.mjs +0 -241
  140. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/api_args.mjs.map +0 -1
  141. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/bitset.mjs +0 -130
  142. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/bitset.mjs.map +0 -1
  143. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/channel.mjs +0 -302
  144. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/channel.mjs.map +0 -1
  145. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/channel_model.mjs +0 -206
  146. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/channel_model.mjs.map +0 -1
  147. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/codec.mjs +0 -273
  148. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/codec.mjs.map +0 -1
  149. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/connect.mjs +0 -143
  150. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/connect.mjs.map +0 -1
  151. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/connection.mjs +0 -416
  152. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/connection.mjs.map +0 -1
  153. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/credentials.mjs +0 -50
  154. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/credentials.mjs.map +0 -1
  155. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/defs.mjs +0 -4600
  156. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/defs.mjs.map +0 -1
  157. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/error.mjs +0 -29
  158. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/error.mjs.map +0 -1
  159. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/format.mjs +0 -28
  160. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/format.mjs.map +0 -1
  161. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/frame.mjs +0 -130
  162. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/frame.mjs.map +0 -1
  163. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/heartbeat.mjs +0 -40
  164. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/heartbeat.mjs.map +0 -1
  165. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/mux.mjs +0 -86
  166. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/mux.mjs.map +0 -1
  167. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/package.mjs +0 -41
  168. package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/package.mjs.map +0 -1
  169. package/esm/node_modules/.pnpm/buffer-more-ints@1.0.0/node_modules/buffer-more-ints/buffer-more-ints.mjs +0 -360
  170. package/esm/node_modules/.pnpm/buffer-more-ints@1.0.0/node_modules/buffer-more-ints/buffer-more-ints.mjs.map +0 -1
  171. package/esm/node_modules/.pnpm/dayjs@1.11.23/node_modules/dayjs/dayjs.min.mjs +0 -305
  172. package/esm/node_modules/.pnpm/dayjs@1.11.23/node_modules/dayjs/dayjs.min.mjs.map +0 -1
  173. package/esm/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.mjs +0 -80
  174. package/esm/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.mjs.map +0 -1
  175. package/esm/node_modules/.pnpm/requires-port@1.0.0/node_modules/requires-port/index.mjs +0 -35
  176. package/esm/node_modules/.pnpm/requires-port@1.0.0/node_modules/requires-port/index.mjs.map +0 -1
  177. package/esm/node_modules/.pnpm/url-parse@1.5.10/node_modules/url-parse/index.mjs +0 -388
  178. package/esm/node_modules/.pnpm/url-parse@1.5.10/node_modules/url-parse/index.mjs.map +0 -1
  179. package/esm/packages/herald/src/communicators/broker-registry.mjs +0 -204
  180. package/esm/packages/herald/src/communicators/broker-registry.mjs.map +0 -1
  181. package/esm/packages/herald/src/communicators/broker.mjs +0 -110
  182. package/esm/packages/herald/src/communicators/broker.mjs.map +0 -1
  183. package/esm/packages/herald/src/communicators/index.mjs +0 -4
  184. package/esm/packages/herald/src/decorators/consumable.mjs +0 -36
  185. package/esm/packages/herald/src/decorators/consumable.mjs.map +0 -1
  186. package/esm/packages/herald/src/decorators/index.mjs +0 -3
  187. package/esm/packages/herald/src/drivers/index.mjs +0 -5
  188. package/esm/packages/herald/src/drivers/rabbitmq/index.mjs +0 -4
  189. package/esm/packages/herald/src/drivers/rabbitmq/rabbitmq-channel.mjs +0 -403
  190. package/esm/packages/herald/src/drivers/rabbitmq/rabbitmq-channel.mjs.map +0 -1
  191. package/esm/packages/herald/src/drivers/rabbitmq/rabbitmq-driver.mjs +0 -303
  192. package/esm/packages/herald/src/drivers/rabbitmq/rabbitmq-driver.mjs.map +0 -1
  193. package/esm/packages/herald/src/index.mjs +0 -16
  194. package/esm/packages/herald/src/message-managers/event-consumer.mjs +0 -76
  195. package/esm/packages/herald/src/message-managers/event-consumer.mjs.map +0 -1
  196. package/esm/packages/herald/src/message-managers/event-message.mjs +0 -85
  197. package/esm/packages/herald/src/message-managers/event-message.mjs.map +0 -1
  198. package/esm/packages/herald/src/message-managers/index.mjs +0 -4
  199. package/esm/packages/herald/src/message-managers/prepare-consumer-subscription.mjs +0 -42
  200. package/esm/packages/herald/src/message-managers/prepare-consumer-subscription.mjs.map +0 -1
  201. package/esm/packages/herald/src/use-case-broadcast.mjs +0 -30
  202. package/esm/packages/herald/src/use-case-broadcast.mjs.map +0 -1
  203. package/esm/packages/herald/src/utils/connect-to-broker.mjs +0 -168
  204. package/esm/packages/herald/src/utils/connect-to-broker.mjs.map +0 -1
  205. package/esm/packages/herald/src/utils/index.mjs +0 -3
  206. package/esm/packages/seal/src/config.mjs +0 -15
  207. package/esm/packages/seal/src/config.mjs.map +0 -1
  208. package/esm/packages/seal/src/factory/index.mjs +0 -4
  209. package/esm/packages/seal/src/factory/validate.mjs +0 -42
  210. package/esm/packages/seal/src/factory/validate.mjs.map +0 -1
  211. package/esm/packages/seal/src/factory/validators.mjs +0 -139
  212. package/esm/packages/seal/src/factory/validators.mjs.map +0 -1
  213. package/esm/packages/seal/src/helpers/date-helpers.mjs +0 -24
  214. package/esm/packages/seal/src/helpers/date-helpers.mjs.map +0 -1
  215. package/esm/packages/seal/src/helpers/get-field-value.mjs +0 -46
  216. package/esm/packages/seal/src/helpers/get-field-value.mjs.map +0 -1
  217. package/esm/packages/seal/src/helpers/index.mjs +0 -6
  218. package/esm/packages/seal/src/helpers/is-empty-value.mjs +0 -10
  219. package/esm/packages/seal/src/helpers/is-empty-value.mjs.map +0 -1
  220. package/esm/packages/seal/src/helpers/path-helpers.mjs +0 -12
  221. package/esm/packages/seal/src/helpers/path-helpers.mjs.map +0 -1
  222. package/esm/packages/seal/src/helpers/validation-helpers.mjs +0 -78
  223. package/esm/packages/seal/src/helpers/validation-helpers.mjs.map +0 -1
  224. package/esm/packages/seal/src/index.mjs +0 -88
  225. package/esm/packages/seal/src/mutators/array-mutators.mjs +0 -32
  226. package/esm/packages/seal/src/mutators/array-mutators.mjs.map +0 -1
  227. package/esm/packages/seal/src/mutators/boolean-mutators.mjs +0 -40
  228. package/esm/packages/seal/src/mutators/boolean-mutators.mjs.map +0 -1
  229. package/esm/packages/seal/src/mutators/date-mutators.mjs +0 -94
  230. package/esm/packages/seal/src/mutators/date-mutators.mjs.map +0 -1
  231. package/esm/packages/seal/src/mutators/index.mjs +0 -9
  232. package/esm/packages/seal/src/mutators/number-mutators.mjs +0 -52
  233. package/esm/packages/seal/src/mutators/number-mutators.mjs.map +0 -1
  234. package/esm/packages/seal/src/mutators/object-mutators.mjs +0 -30
  235. package/esm/packages/seal/src/mutators/object-mutators.mjs.map +0 -1
  236. package/esm/packages/seal/src/mutators/scalar-mutators.mjs +0 -9
  237. package/esm/packages/seal/src/mutators/scalar-mutators.mjs.map +0 -1
  238. package/esm/packages/seal/src/mutators/string-mutators.mjs +0 -186
  239. package/esm/packages/seal/src/mutators/string-mutators.mjs.map +0 -1
  240. package/esm/packages/seal/src/object.mjs +0 -13
  241. package/esm/packages/seal/src/object.mjs.map +0 -1
  242. package/esm/packages/seal/src/rules/array/array-rules.mjs +0 -41
  243. package/esm/packages/seal/src/rules/array/array-rules.mjs.map +0 -1
  244. package/esm/packages/seal/src/rules/array/index.mjs +0 -3
  245. package/esm/packages/seal/src/rules/color/color-rules.mjs +0 -104
  246. package/esm/packages/seal/src/rules/color/color-rules.mjs.map +0 -1
  247. package/esm/packages/seal/src/rules/color/index.mjs +0 -3
  248. package/esm/packages/seal/src/rules/common/enum.mjs +0 -77
  249. package/esm/packages/seal/src/rules/common/enum.mjs.map +0 -1
  250. package/esm/packages/seal/src/rules/common/equals-field-rules.mjs +0 -42
  251. package/esm/packages/seal/src/rules/common/equals-field-rules.mjs.map +0 -1
  252. package/esm/packages/seal/src/rules/common/index.mjs +0 -8
  253. package/esm/packages/seal/src/rules/common/instanceof.mjs +0 -23
  254. package/esm/packages/seal/src/rules/common/instanceof.mjs.map +0 -1
  255. package/esm/packages/seal/src/rules/common/literal.mjs +0 -31
  256. package/esm/packages/seal/src/rules/common/literal.mjs.map +0 -1
  257. package/esm/packages/seal/src/rules/common/type-rules.mjs +0 -97
  258. package/esm/packages/seal/src/rules/common/type-rules.mjs.map +0 -1
  259. package/esm/packages/seal/src/rules/common/unknown-key.mjs +0 -25
  260. package/esm/packages/seal/src/rules/common/unknown-key.mjs.map +0 -1
  261. package/esm/packages/seal/src/rules/conditional/forbidden-if-rules.mjs +0 -116
  262. package/esm/packages/seal/src/rules/conditional/forbidden-if-rules.mjs.map +0 -1
  263. package/esm/packages/seal/src/rules/conditional/index.mjs +0 -12
  264. package/esm/packages/seal/src/rules/conditional/present-if-rules.mjs +0 -97
  265. package/esm/packages/seal/src/rules/conditional/present-if-rules.mjs.map +0 -1
  266. package/esm/packages/seal/src/rules/conditional/present-unless-rules.mjs +0 -30
  267. package/esm/packages/seal/src/rules/conditional/present-unless-rules.mjs.map +0 -1
  268. package/esm/packages/seal/src/rules/conditional/present-with-rules.mjs +0 -76
  269. package/esm/packages/seal/src/rules/conditional/present-with-rules.mjs.map +0 -1
  270. package/esm/packages/seal/src/rules/conditional/present-without-rules.mjs +0 -76
  271. package/esm/packages/seal/src/rules/conditional/present-without-rules.mjs.map +0 -1
  272. package/esm/packages/seal/src/rules/conditional/required-if-rules.mjs +0 -204
  273. package/esm/packages/seal/src/rules/conditional/required-if-rules.mjs.map +0 -1
  274. package/esm/packages/seal/src/rules/conditional/required-unless-rules.mjs +0 -31
  275. package/esm/packages/seal/src/rules/conditional/required-unless-rules.mjs.map +0 -1
  276. package/esm/packages/seal/src/rules/conditional/required-when-rule.mjs +0 -32
  277. package/esm/packages/seal/src/rules/conditional/required-when-rule.mjs.map +0 -1
  278. package/esm/packages/seal/src/rules/conditional/required-with-rules.mjs +0 -67
  279. package/esm/packages/seal/src/rules/conditional/required-with-rules.mjs.map +0 -1
  280. package/esm/packages/seal/src/rules/conditional/required-without-rules.mjs +0 -67
  281. package/esm/packages/seal/src/rules/conditional/required-without-rules.mjs.map +0 -1
  282. package/esm/packages/seal/src/rules/core/equal.mjs +0 -22
  283. package/esm/packages/seal/src/rules/core/equal.mjs.map +0 -1
  284. package/esm/packages/seal/src/rules/core/forbidden.mjs +0 -20
  285. package/esm/packages/seal/src/rules/core/forbidden.mjs.map +0 -1
  286. package/esm/packages/seal/src/rules/core/index.mjs +0 -7
  287. package/esm/packages/seal/src/rules/core/required.mjs +0 -36
  288. package/esm/packages/seal/src/rules/core/required.mjs.map +0 -1
  289. package/esm/packages/seal/src/rules/core/union.mjs +0 -78
  290. package/esm/packages/seal/src/rules/core/union.mjs.map +0 -1
  291. package/esm/packages/seal/src/rules/core/when.mjs +0 -37
  292. package/esm/packages/seal/src/rules/core/when.mjs.map +0 -1
  293. package/esm/packages/seal/src/rules/date/date-comparison-rules.mjs +0 -78
  294. package/esm/packages/seal/src/rules/date/date-comparison-rules.mjs.map +0 -1
  295. package/esm/packages/seal/src/rules/date/date-day-rules.mjs +0 -49
  296. package/esm/packages/seal/src/rules/date/date-day-rules.mjs.map +0 -1
  297. package/esm/packages/seal/src/rules/date/date-field-comparison-rules.mjs +0 -82
  298. package/esm/packages/seal/src/rules/date/date-field-comparison-rules.mjs.map +0 -1
  299. package/esm/packages/seal/src/rules/date/date-period-rules.mjs +0 -401
  300. package/esm/packages/seal/src/rules/date/date-period-rules.mjs.map +0 -1
  301. package/esm/packages/seal/src/rules/date/date-relative-rules.mjs +0 -55
  302. package/esm/packages/seal/src/rules/date/date-relative-rules.mjs.map +0 -1
  303. package/esm/packages/seal/src/rules/date/date-special-rules.mjs +0 -58
  304. package/esm/packages/seal/src/rules/date/date-special-rules.mjs.map +0 -1
  305. package/esm/packages/seal/src/rules/date/date.mjs +0 -235
  306. package/esm/packages/seal/src/rules/date/date.mjs.map +0 -1
  307. package/esm/packages/seal/src/rules/date/index.mjs +0 -9
  308. package/esm/packages/seal/src/rules/file/dimensions.mjs +0 -3
  309. package/esm/packages/seal/src/rules/file/file-size.mjs +0 -3
  310. package/esm/packages/seal/src/rules/file/index.mjs +0 -4
  311. package/esm/packages/seal/src/rules/index.mjs +0 -54
  312. package/esm/packages/seal/src/rules/length/index.mjs +0 -3
  313. package/esm/packages/seal/src/rules/length/length-rules.mjs +0 -98
  314. package/esm/packages/seal/src/rules/length/length-rules.mjs.map +0 -1
  315. package/esm/packages/seal/src/rules/number/index.mjs +0 -3
  316. package/esm/packages/seal/src/rules/number/number-rules.mjs +0 -197
  317. package/esm/packages/seal/src/rules/number/number-rules.mjs.map +0 -1
  318. package/esm/packages/seal/src/rules/scalar/accepted-rule.mjs +0 -123
  319. package/esm/packages/seal/src/rules/scalar/accepted-rule.mjs.map +0 -1
  320. package/esm/packages/seal/src/rules/scalar/declined-rule.mjs +0 -123
  321. package/esm/packages/seal/src/rules/scalar/declined-rule.mjs.map +0 -1
  322. package/esm/packages/seal/src/rules/scalar/index.mjs +0 -4
  323. package/esm/packages/seal/src/rules/string/alpha.mjs +0 -41
  324. package/esm/packages/seal/src/rules/string/alpha.mjs.map +0 -1
  325. package/esm/packages/seal/src/rules/string/credit-card.mjs +0 -32
  326. package/esm/packages/seal/src/rules/string/credit-card.mjs.map +0 -1
  327. package/esm/packages/seal/src/rules/string/email.mjs +0 -20
  328. package/esm/packages/seal/src/rules/string/email.mjs.map +0 -1
  329. package/esm/packages/seal/src/rules/string/id-formats.mjs +0 -104
  330. package/esm/packages/seal/src/rules/string/id-formats.mjs.map +0 -1
  331. package/esm/packages/seal/src/rules/string/index.mjs +0 -13
  332. package/esm/packages/seal/src/rules/string/ip.mjs +0 -66
  333. package/esm/packages/seal/src/rules/string/ip.mjs.map +0 -1
  334. package/esm/packages/seal/src/rules/string/matches.mjs +0 -4
  335. package/esm/packages/seal/src/rules/string/pattern.mjs +0 -20
  336. package/esm/packages/seal/src/rules/string/pattern.mjs.map +0 -1
  337. package/esm/packages/seal/src/rules/string/string-comparison.mjs +0 -56
  338. package/esm/packages/seal/src/rules/string/string-comparison.mjs.map +0 -1
  339. package/esm/packages/seal/src/rules/string/strong-password-rule.mjs +0 -31
  340. package/esm/packages/seal/src/rules/string/strong-password-rule.mjs.map +0 -1
  341. package/esm/packages/seal/src/rules/string/url.mjs +0 -23
  342. package/esm/packages/seal/src/rules/string/url.mjs.map +0 -1
  343. package/esm/packages/seal/src/rules/string/without-whitespace.mjs +0 -19
  344. package/esm/packages/seal/src/rules/string/without-whitespace.mjs.map +0 -1
  345. package/esm/packages/seal/src/standard-schema/json-schema.mjs +0 -81
  346. package/esm/packages/seal/src/standard-schema/json-schema.mjs.map +0 -1
  347. package/esm/packages/seal/src/standard-schema/map-result.mjs +0 -26
  348. package/esm/packages/seal/src/standard-schema/map-result.mjs.map +0 -1
  349. package/esm/packages/seal/src/string.mjs +0 -13
  350. package/esm/packages/seal/src/string.mjs.map +0 -1
  351. package/esm/packages/seal/src/types/date-types.mjs +0 -17
  352. package/esm/packages/seal/src/types/date-types.mjs.map +0 -1
  353. package/esm/packages/seal/src/validators/any-validator.mjs +0 -38
  354. package/esm/packages/seal/src/validators/any-validator.mjs.map +0 -1
  355. package/esm/packages/seal/src/validators/array-validator.mjs +0 -186
  356. package/esm/packages/seal/src/validators/array-validator.mjs.map +0 -1
  357. package/esm/packages/seal/src/validators/base-validator.mjs +0 -750
  358. package/esm/packages/seal/src/validators/base-validator.mjs.map +0 -1
  359. package/esm/packages/seal/src/validators/boolean-validator.mjs +0 -175
  360. package/esm/packages/seal/src/validators/boolean-validator.mjs.map +0 -1
  361. package/esm/packages/seal/src/validators/computed-validator.mjs +0 -118
  362. package/esm/packages/seal/src/validators/computed-validator.mjs.map +0 -1
  363. package/esm/packages/seal/src/validators/date-validator.mjs +0 -640
  364. package/esm/packages/seal/src/validators/date-validator.mjs.map +0 -1
  365. package/esm/packages/seal/src/validators/discriminated-union-validator.mjs +0 -138
  366. package/esm/packages/seal/src/validators/discriminated-union-validator.mjs.map +0 -1
  367. package/esm/packages/seal/src/validators/float-validator.mjs +0 -18
  368. package/esm/packages/seal/src/validators/float-validator.mjs.map +0 -1
  369. package/esm/packages/seal/src/validators/index.mjs +0 -28
  370. package/esm/packages/seal/src/validators/instanceof-validator.mjs +0 -64
  371. package/esm/packages/seal/src/validators/instanceof-validator.mjs.map +0 -1
  372. package/esm/packages/seal/src/validators/int-validator.mjs +0 -30
  373. package/esm/packages/seal/src/validators/int-validator.mjs.map +0 -1
  374. package/esm/packages/seal/src/validators/lazy-validator.mjs +0 -87
  375. package/esm/packages/seal/src/validators/lazy-validator.mjs.map +0 -1
  376. package/esm/packages/seal/src/validators/literal-validator.mjs +0 -72
  377. package/esm/packages/seal/src/validators/literal-validator.mjs.map +0 -1
  378. package/esm/packages/seal/src/validators/managed-validator.mjs +0 -39
  379. package/esm/packages/seal/src/validators/managed-validator.mjs.map +0 -1
  380. package/esm/packages/seal/src/validators/methods/equality-conditional-methods.mjs +0 -129
  381. package/esm/packages/seal/src/validators/methods/equality-conditional-methods.mjs.map +0 -1
  382. package/esm/packages/seal/src/validators/methods/forbidden-methods.mjs +0 -131
  383. package/esm/packages/seal/src/validators/methods/forbidden-methods.mjs.map +0 -1
  384. package/esm/packages/seal/src/validators/methods/present-methods.mjs +0 -235
  385. package/esm/packages/seal/src/validators/methods/present-methods.mjs.map +0 -1
  386. package/esm/packages/seal/src/validators/methods/required-methods.mjs +0 -347
  387. package/esm/packages/seal/src/validators/methods/required-methods.mjs.map +0 -1
  388. package/esm/packages/seal/src/validators/number-validator.mjs +0 -331
  389. package/esm/packages/seal/src/validators/number-validator.mjs.map +0 -1
  390. package/esm/packages/seal/src/validators/numeric-validator.mjs +0 -27
  391. package/esm/packages/seal/src/validators/numeric-validator.mjs.map +0 -1
  392. package/esm/packages/seal/src/validators/object-validator.mjs +0 -447
  393. package/esm/packages/seal/src/validators/object-validator.mjs.map +0 -1
  394. package/esm/packages/seal/src/validators/primitive-validator.mjs +0 -88
  395. package/esm/packages/seal/src/validators/primitive-validator.mjs.map +0 -1
  396. package/esm/packages/seal/src/validators/record-validator.mjs +0 -112
  397. package/esm/packages/seal/src/validators/record-validator.mjs.map +0 -1
  398. package/esm/packages/seal/src/validators/scalar-validator.mjs +0 -173
  399. package/esm/packages/seal/src/validators/scalar-validator.mjs.map +0 -1
  400. package/esm/packages/seal/src/validators/string-validator.mjs +0 -459
  401. package/esm/packages/seal/src/validators/string-validator.mjs.map +0 -1
  402. package/esm/packages/seal/src/validators/tuple-validator.mjs +0 -134
  403. package/esm/packages/seal/src/validators/tuple-validator.mjs.map +0 -1
  404. package/esm/packages/seal/src/validators/union-validator.mjs +0 -68
  405. package/esm/packages/seal/src/validators/union-validator.mjs.map +0 -1
@@ -1,750 +0,0 @@
1
- import { clone } from "../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/mixed/clone/clone.mjs";
2
- import "../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/index.mjs";
3
- import { validate } from "../factory/validate.mjs";
4
- import { VALID_RULE, invalidRule } from "../helpers/validation-helpers.mjs";
5
- import { isEmptyValue } from "../helpers/is-empty-value.mjs";
6
- import { requiredRule } from "../rules/core/required.mjs";
7
- import { mapToStandardResult } from "../standard-schema/map-result.mjs";
8
-
9
- //#region ../../packages/seal/src/validators/base-validator.ts
10
- /**
11
- * Base validator class - foundation for all validators
12
- */
13
- var BaseValidator = class {
14
- rules = [];
15
- refinements = [];
16
- mutators = [];
17
- defaultValue;
18
- description;
19
- shouldOmit = false;
20
- isNullable = false;
21
- isMutable = false;
22
- /** Treat empty or whitespace-only form strings as an absent value. */
23
- blankIsMissing = false;
24
- /**
25
- * Catch state — when `hasCatch` is true and validation fails, `catchValue`
26
- * (or its callback result) substitutes for the failed value, and the public
27
- * result reports `isValid: true` with no errors.
28
- *
29
- * See `.catch()` for semantics and the v1 scope (leaf-only).
30
- */
31
- catchValue;
32
- hasCatch = false;
33
- /**
34
- * Whether the field is optional.
35
- * - false (default): field is required unless a requiredRule governs the condition.
36
- * - true: field can be absent or empty — set by calling .optional().
37
- *
38
- * Also used as a TypeScript literal brand via the optional() return type.
39
- */
40
- isOptional = false;
41
- /**
42
- * The single required-condition rule for this field.
43
- * - null: field uses strict default (always required when not optional).
44
- * - set: the rule governs when the field is required (e.g., requiredIf).
45
- *
46
- * Stored separately from rules[] and prepended at validate() time.
47
- */
48
- requiredRule = this.createRule(requiredRule);
49
- /**
50
- * Pipeline to transform the mutated/original data before returning it
51
- */
52
- dataTransformers = [];
53
- /**
54
- * Attributes text to be replaced on translations
55
- * If the value is an object, it will be used as the attributes list for the rule
56
- * If the value is a string, it will be used as the attributes list for the rule
57
- */
58
- attributesText = {};
59
- /**
60
- * Attributed that will be always using the attribute translator
61
- */
62
- translatedAttributes = {};
63
- /**
64
- * Mark the validator as mutable
65
- */
66
- get mutable() {
67
- this.isMutable = true;
68
- return this;
69
- }
70
- /**
71
- * Mark the validator as immutable
72
- */
73
- get immutable() {
74
- this.isMutable = false;
75
- return this;
76
- }
77
- /**
78
- * Get the instance to apply changes to.
79
- * By default (immutable), returns a clone so the original is unchanged.
80
- * When `.mutable` is set, returns `this` to mutate in place.
81
- */
82
- get instance() {
83
- return this.isMutable ? this : this.clone();
84
- }
85
- /**
86
- * Get the default value
87
- * Supports lazy evaluation via callbacks
88
- */
89
- getDefaultValue() {
90
- return typeof this.defaultValue === "function" ? this.defaultValue() : this.defaultValue;
91
- }
92
- /**
93
- * Allow null as a valid value.
94
- *
95
- * Brands the return type with `{ isNullable: true }` so `Infer<>` widens
96
- * the inferred output to include `| null`.
97
- */
98
- nullable() {
99
- const instance = this.instance;
100
- instance.isNullable = true;
101
- return instance;
102
- }
103
- /**
104
- * Explicitly disallow null values after calling nullable.
105
- *
106
- * Brands the return type with `{ isNullable: false }` to cancel any prior
107
- * `.nullable()` at the type level.
108
- */
109
- notNullable() {
110
- const instance = this.instance;
111
- instance.isNullable = false;
112
- return instance;
113
- }
114
- /**
115
- * Add transformer with optional options
116
- *
117
- * @param transform - The transformer callback function
118
- * @param options - Optional options to pass to the transformer
119
- *
120
- * @example
121
- * ```ts
122
- * // Without options
123
- * v.date().addTransformer(data => data.toISOString())
124
- *
125
- * // With options
126
- * v.date().addTransformer(
127
- * (data, { options }) => dayjs(data).format(options.format),
128
- * { format: 'YYYY-MM-DD' }
129
- * )
130
- * ```
131
- */
132
- addTransformer(transform, options = {}) {
133
- const instance = this.instance;
134
- instance.addMutableTransformer(transform, options);
135
- return instance;
136
- }
137
- /**
138
- * Add transformer with optional options
139
- *
140
- * @param transform - The transformer callback function
141
- * @param options - Optional options to pass to the transformer
142
- *
143
- * @example
144
- * ```ts
145
- * // Without options
146
- * v.date().addTransformer(data => data.toISOString())
147
- *
148
- * // With options
149
- * v.date().addTransformer(
150
- * (data, { options }) => dayjs(data).format(options.format),
151
- * { format: 'YYYY-MM-DD' }
152
- * )
153
- * ```
154
- */
155
- addMutableTransformer(transform, options = {}) {
156
- this.dataTransformers.push({
157
- transform,
158
- options
159
- });
160
- }
161
- /**
162
- * Transform the output value - simple one-time transformation
163
- *
164
- * @param callback - Simple callback receiving data and context
165
- *
166
- * @example
167
- * ```ts
168
- * // Simple transformation
169
- * v.string().outputAs(data => data.toUpperCase())
170
- *
171
- * // With context
172
- * v.string().outputAs((data, context) => {
173
- * console.log(`Transforming ${context.path}`);
174
- * return data.toLowerCase();
175
- * })
176
- * ```
177
- */
178
- outputAs(callback) {
179
- return this.addTransformer((data, { context }) => callback(data, context));
180
- }
181
- /**
182
- * Transform output to JSON string
183
- *
184
- * Works with any validator type (string, number, date, object, array, etc.)
185
- *
186
- * @param indent - Optional indentation for pretty printing (default: 0 for compact)
187
- *
188
- * @example
189
- * ```ts
190
- * // Compact JSON
191
- * v.object({ name: v.string() }).toJSON()
192
- * // Output: '{"name":"John"}'
193
- *
194
- * // Pretty-printed JSON
195
- * v.array(v.object({...})).toJSON(2)
196
- * // Output:
197
- * // [
198
- * // {
199
- * // "name": "John"
200
- * // }
201
- * // ]
202
- *
203
- * // Works with any type
204
- * v.string().toJSON() // '"hello"'
205
- * v.number().toJSON() // '42'
206
- * v.date().toJSON() // '"2024-10-26T00:00:00.000Z"'
207
- * ```
208
- *
209
- * @category Transformer
210
- */
211
- toJSON(indent) {
212
- return this.addTransformer((data, { options }) => JSON.stringify(data, null, options.indent), { indent: indent ?? 0 });
213
- }
214
- /**
215
- * Start data transformation pipeline
216
- * Context is passed at runtime, not stored
217
- */
218
- async startTransformationPipeline(data, context) {
219
- for (const transformer of this.dataTransformers) data = await transformer.transform(data, {
220
- options: transformer.options,
221
- context
222
- });
223
- return data;
224
- }
225
- /**
226
- * Set attributes text to be replaced on translations
227
- * If the value is an object, it will be used as the attributes list for the rule
228
- * If the value is a string, it will be used as the attributes list for the rule
229
- *
230
- * @example
231
- * v.string().attributes({
232
- * name: "Name",
233
- * email: "Email",
234
- * });
235
- * // Example 2: Add custom attributes for matches
236
- * v.string().matches("confirmPassword").attributes({
237
- * matches: {
238
- * confirmPassword: "Confirm Password",
239
- * },
240
- * });
241
- */
242
- attributes(attributes) {
243
- const instance = this.instance;
244
- for (const [key, value] of Object.entries(attributes)) instance.attributesText[key] = value;
245
- return instance;
246
- }
247
- /**
248
- * Define a lazy getter property for each attribute in the given object and use the config attribute translator
249
- */
250
- transAttributes(attributes) {
251
- const instance = this.instance;
252
- for (const [key, value] of Object.entries(attributes)) instance.translatedAttributes[key] = value;
253
- return instance;
254
- }
255
- /**
256
- * Add description to the validator
257
- */
258
- describe(description) {
259
- const instance = this.instance;
260
- instance.description = description;
261
- return instance;
262
- }
263
- /**
264
- * Check if this validator can handle the given value's type
265
- * Override this in specific validators to enable type-based routing in union validators
266
- *
267
- * Default: returns true (validator will attempt to validate any type)
268
- *
269
- * @param value - The value to check
270
- * @returns True if this validator can handle this type
271
- *
272
- * @example
273
- * ```ts
274
- * // StringValidator
275
- * public matchesType(value: any): boolean {
276
- * return typeof value === 'string';
277
- * }
278
- *
279
- * // Custom FileValidator
280
- * public matchesType(value: any): boolean {
281
- * return value instanceof UploadedFile;
282
- * }
283
- * ```
284
- */
285
- matchesType(_value) {
286
- return true;
287
- }
288
- /**
289
- * Create a copy of this validator with the same configuration
290
- * Copies all rules, mutators, transformers, default values, and settings
291
- *
292
- * @returns A new validator instance with copied configuration
293
- *
294
- * @example
295
- * ```ts
296
- * // Create reusable validator templates
297
- * const baseString = v.string().required().trim().min(3);
298
- * const emailField = baseString.clone().email();
299
- * const usernameField = baseString.clone().alphanumeric().max(20);
300
- *
301
- * // Works with all validators
302
- * const positiveInt = v.int().positive().required();
303
- * const ageField = positiveInt.clone().min(18).max(120);
304
- * ```
305
- */
306
- clone() {
307
- const Constructor = this.constructor;
308
- const cloned = Object.create(Constructor.prototype);
309
- cloned.rules = [...this.rules];
310
- cloned.refinements = [...this.refinements];
311
- cloned.mutators = [...this.mutators];
312
- cloned.dataTransformers = [...this.dataTransformers];
313
- cloned.defaultValue = this.defaultValue;
314
- cloned.shouldOmit = this.shouldOmit;
315
- cloned.description = this.description;
316
- cloned.attributesText = { ...this.attributesText };
317
- cloned.translatedAttributes = { ...this.translatedAttributes };
318
- cloned.isNullable = this.isNullable;
319
- cloned.isOptional = this.isOptional;
320
- cloned.blankIsMissing = this.blankIsMissing;
321
- cloned.requiredRule = this.requiredRule;
322
- cloned.catchValue = this.catchValue;
323
- cloned.hasCatch = this.hasCatch;
324
- return cloned;
325
- }
326
- /**
327
- * @deprecated This method is no longer needed and does nothing.
328
- * Empty values are now automatically skipped for validation rules by default.
329
- * Only presence validators (required, present, etc.) will check empty values.
330
- * You can safely remove this call from your code.
331
- */
332
- ignoreEmptyValue(_ignoreEmptyValue = true) {
333
- return this;
334
- }
335
- /**
336
- * Omit this field from the validated data output
337
- *
338
- * Field will still be validated but not included in the final result.
339
- * Useful for confirmation fields, captcha, terms acceptance, etc.
340
- *
341
- * @example
342
- * ```ts
343
- * v.object({
344
- * password: v.string().required(),
345
- * confirmPassword: v.string().required().sameAs("password").omit(),
346
- * acceptTerms: v.boolean().required().omit(),
347
- * });
348
- * // Output: { password: "..." }
349
- * // confirmPassword and acceptTerms validated but omitted
350
- * ```
351
- */
352
- omit() {
353
- const instance = this.instance;
354
- instance.shouldOmit = true;
355
- return instance;
356
- }
357
- /**
358
- * @alias omit
359
- */
360
- exclude() {
361
- return this.omit();
362
- }
363
- /**
364
- * Check if this field should be omitted from the output
365
- */
366
- isOmitted() {
367
- return this.shouldOmit;
368
- }
369
- /**
370
- * Add rule to the validator
371
- */
372
- addRule(rule, errorMessage, options = {}) {
373
- const instance = this.instance;
374
- instance.addMutableRule(rule, errorMessage, options);
375
- return instance;
376
- }
377
- /**
378
- * Set the required-condition rule for this field.
379
- *
380
- * Unlike addRule(), this does NOT push to rules[]. The rule is stored in the
381
- * dedicated `requiredRule` slot and is prepended to the validation pipeline
382
- * at runtime. Only one required rule can be active per field — this replaces
383
- * any previously set required rule.
384
- *
385
- * Also marks the field as not optional (isOptional = false).
386
- *
387
- * @example
388
- * ```ts
389
- * // Used internally by required(), requiredIf(), requiredWith(), etc.
390
- * BaseValidator.prototype.required = function(msg) {
391
- * return this.setRequiredRule(requiredRule, msg);
392
- * };
393
- * ```
394
- */
395
- setRequiredRule(rule, errorMessage, options = {}) {
396
- const instance = this.instance;
397
- instance.isOptional = false;
398
- instance.requiredRule = instance.createRule(rule, errorMessage, options);
399
- return instance;
400
- }
401
- /**
402
- * Add mutable rule
403
- */
404
- addMutableRule(rule, errorMessage, options = {}) {
405
- const newRule = this.createRule(rule, errorMessage, options);
406
- this.rules.push(newRule);
407
- return newRule;
408
- }
409
- /**
410
- * Create new rule
411
- */
412
- createRule(rule, errorMessage, options = {}) {
413
- const newRule = {
414
- ...clone(rule),
415
- context: {
416
- errorMessage,
417
- options,
418
- attributesList: this.attributesText,
419
- translatedAttributes: this.translatedAttributes,
420
- translationParams: {},
421
- translatableParams: {}
422
- }
423
- };
424
- if (errorMessage) newRule.errorMessage = errorMessage;
425
- if (rule.sortOrder === void 0) newRule.sortOrder = this.rules.length + 1;
426
- return newRule;
427
- }
428
- /**
429
- * Use a custom or pre-built validation rule
430
- *
431
- * @param rule - The validation rule to apply
432
- * @param options - Rule options including errorMessage and any rule-specific options
433
- *
434
- * @example
435
- * ```ts
436
- * import { hexColorRule } from "@warlock.js/seal";
437
- *
438
- * v.string().useRule(hexColorRule, { errorMessage: "Invalid color" });
439
- * ```
440
- *
441
- * @example
442
- * ```ts
443
- * // With rule options
444
- * v.string().useRule(myCustomRule, {
445
- * customOption: true,
446
- * errorMessage: "Custom validation failed"
447
- * });
448
- * ```
449
- */
450
- useRule(rule, options) {
451
- const { errorMessage, ...ruleOptions } = options || {};
452
- return this.addRule(rule, errorMessage, ruleOptions);
453
- }
454
- /**
455
- * Validate the successful output after type rules, children and transformers.
456
- * Refinements are skipped for absent/null values and failed validation.
457
- */
458
- refine(callback) {
459
- const instance = this.instance;
460
- instance.refinements.push(instance.createRule({
461
- name: "custom",
462
- async validate(value, context) {
463
- const result = await callback(value, context);
464
- if (result) {
465
- this.context.errorMessage = result;
466
- return invalidRule(this, context);
467
- }
468
- return VALID_RULE;
469
- }
470
- }));
471
- return instance;
472
- }
473
- /** Complete validation only after the entire output is available. */
474
- async refineResult(result, context) {
475
- if (!result.isValid || result.data == null) return result;
476
- const errors = [];
477
- for (const rule of this.refinements) {
478
- this.setRuleAttributesList(rule);
479
- const refined = await rule.validate(result.data, context);
480
- if (!refined.isValid) {
481
- errors.push({
482
- type: rule.name,
483
- error: refined.error,
484
- input: refined.path ?? context.path
485
- });
486
- if (context.configurations?.firstErrorOnly ?? true) break;
487
- }
488
- }
489
- return errors.length ? {
490
- isValid: false,
491
- errors,
492
- data: void 0
493
- } : result;
494
- }
495
- /**
496
- * Add mutator to the validator
497
- */
498
- addMutator(mutator, options = {}) {
499
- const instance = this.instance;
500
- instance.addMutableMutator(mutator, options);
501
- return instance;
502
- }
503
- /**
504
- * Add mutable mutator
505
- */
506
- addMutableMutator(mutator, options = {}) {
507
- this.mutators.push({
508
- mutate: mutator,
509
- context: {
510
- options,
511
- ctx: {}
512
- }
513
- });
514
- }
515
- /**
516
- * Set default value for the field. The default is used when the input is
517
- * absent (`undefined`); it then flows through the rule pipeline.
518
- *
519
- * Brands the return type with `{ hasDefault: true }` so `Infer<>` treats
520
- * the field as guaranteed-present even when chained with `.optional()`.
521
- */
522
- default(value) {
523
- const instance = this.instance;
524
- instance.defaultValue = value;
525
- return instance;
526
- }
527
- /**
528
- * Fallback to a value when validation fails.
529
- *
530
- * Complementary to `.default()`: `.default(x)` fires when input is **absent**,
531
- * `.catch(y)` fires when input is **present but invalid**. Combine them when
532
- * you want both behaviours: `.optional().default(x).catch(y)`.
533
- *
534
- * The fallback can be a value or a callback `(errors, originalInput) => fallback`.
535
- * The callback variant is the only side-channel for the swallowed errors —
536
- * use it to log/alert before the fallback substitutes.
537
- *
538
- * Brands the return type with `{ hasCatch: true }` so `Infer<>` treats the
539
- * field as guaranteed-present (the catch ensures a value will always exist).
540
- *
541
- * **Scope (v1).** Catch is honoured for **leaf validators** (string, number,
542
- * boolean, date, …) and for fields inside containers. It is a **no-op on
543
- * container validators themselves** (`v.object`, `v.array`, `v.record`,
544
- * `v.tuple`, `v.discriminatedUnion`) — those use their own iteration logic
545
- * that bypasses the catch hook in `BaseValidator.validate()`.
546
- *
547
- * @example
548
- * ```ts
549
- * v.int().min(0).catch(3) // bad number → 3
550
- * v.string().in(["us", "eu"]).catch("us") // unknown enum → "us"
551
- * v.string().catch((errors, input) => {
552
- * console.warn(`bad user value: ${JSON.stringify(input)}`, errors);
553
- * return "anonymous";
554
- * })
555
- * ```
556
- */
557
- catch(fallback) {
558
- const instance = this.instance;
559
- instance.catchValue = fallback;
560
- instance.hasCatch = true;
561
- return instance;
562
- }
563
- /**
564
- * Mutate the data
565
- */
566
- async mutate(data, context) {
567
- let mutatedData = data;
568
- for (const mutator of this.mutators) {
569
- mutator.context.ctx = context;
570
- mutatedData = await mutator.mutate(mutatedData, mutator.context);
571
- }
572
- return mutatedData;
573
- }
574
- /**
575
- * Set the label for the validator that will be matching the :input attribute
576
- */
577
- label(label) {
578
- const instance = this.instance;
579
- instance.attributesText.input = label;
580
- return instance;
581
- }
582
- /**
583
- * Validate the data
584
- */
585
- async validate(data, context) {
586
- const result = await this.refineResult(await this.validateRules(data, context), context);
587
- if (!result.isValid && this.hasCatch) return {
588
- isValid: true,
589
- errors: [],
590
- data: typeof this.catchValue === "function" ? await this.catchValue(result.errors, data) : this.catchValue
591
- };
592
- return result;
593
- }
594
- /** Validate presence and value rules before containers descend into children. */
595
- async validateRules(data, context) {
596
- if (data === null && this.isNullable) return {
597
- isValid: true,
598
- errors: [],
599
- data: null
600
- };
601
- const isBlank = this.blankIsMissing && typeof data === "string" && data.trim() === "";
602
- if (isBlank && this.isNullable) return {
603
- isValid: true,
604
- errors: [],
605
- data: null
606
- };
607
- const input = isBlank ? void 0 : data;
608
- let valueForRules = input ?? this.getDefaultValue();
609
- const parentFilledDefault = context?.valueIsDefault === true;
610
- if (parentFilledDefault) context.valueIsDefault = false;
611
- const isUsableDefault = (value) => value !== void 0 && (value !== null || this.isNullable);
612
- let blankMatchesDefault = false;
613
- if (typeof input === "string" && input.trim() === "" && this.defaultValue !== void 0) {
614
- const fallback = this.getDefaultValue();
615
- if (typeof fallback === "string" && fallback.trim() === "") {
616
- valueForRules = fallback;
617
- blankMatchesDefault = true;
618
- }
619
- }
620
- const usedDefault = blankMatchesDefault || input == null && isUsableDefault(valueForRules) || parentFilledDefault && isUsableDefault(input);
621
- let mutatedData = this.isOptional && valueForRules === void 0 ? void 0 : await this.mutate(valueForRules, context);
622
- const errors = [];
623
- let isValid = true;
624
- const isFirstErrorOnly = context.configurations?.firstErrorOnly ?? true;
625
- const isEmpty = isEmptyValue(valueForRules);
626
- const skipEmptyRules = usedDefault && isEmpty && valueForRules !== null && !this.matchesType(valueForRules) ? false : this.isOptional ? valueForRules === void 0 : isEmpty;
627
- const rulesToRun = this.requiredRule && !usedDefault ? [this.requiredRule, ...this.rules] : this.rules;
628
- for (const rule of rulesToRun) {
629
- if ((rule.requiresValue ?? true) && skipEmptyRules) continue;
630
- this.setRuleAttributesList(rule);
631
- const result = await rule.validate(mutatedData, context);
632
- if (result.isValid && "data" in result) mutatedData = result.data;
633
- if (result.isValid === false) {
634
- isValid = false;
635
- const reported = result.errors?.length ? result.errors : [{
636
- error: result.error,
637
- path: result.path
638
- }];
639
- for (const { error, path } of reported) errors.push({
640
- type: rule.name,
641
- error,
642
- input: path ?? context.path
643
- });
644
- if (isFirstErrorOnly) break;
645
- }
646
- }
647
- return {
648
- isValid,
649
- errors,
650
- data: mutatedData !== void 0 ? await this.startTransformationPipeline(mutatedData, context) : void 0
651
- };
652
- }
653
- /**
654
- * Set rule attributes list
655
- */
656
- setRuleAttributesList(rule) {
657
- rule.context.attributesList = typeof this.attributesText[rule.name] === "object" ? this.attributesText[rule.name] : this.attributesText;
658
- rule.context.translatedAttributes = this.translatedAttributes;
659
- }
660
- /**
661
- * Standard Schema V1 compliance.
662
- *
663
- * Allows this validator to be used with any Standard Schema-aware library
664
- * (OpenAI structured outputs, LangGraph, TanStack Form, Conform, Valibot adapters, etc.)
665
- * without extra adapters.
666
- *
667
- * Delegates to the `validate()` factory so all `configureSeal()` options
668
- * (translations, firstErrorOnly) are picked up automatically at call time.
669
- *
670
- * Includes Standard JSON Schema support via `jsonSchema.input()` / `jsonSchema.output()`.
671
- *
672
- * ## How Standard Schema libraries consume this
673
- *
674
- * You pass the **schema object itself** to the library — they internally read
675
- * `schema["~standard"]`. Do NOT pass `schema["~standard"]` directly.
676
- *
677
- * @example
678
- * ```ts
679
- * const schema = v.object({ name: v.string().required() });
680
- *
681
- * // TanStack Form — pass schema, library reads ["~standard"] internally
682
- * const form = useForm({ validators: { onChange: schema } });
683
- *
684
- * // Conform (Remix) — same pattern
685
- * const [form] = useForm({ onValidate({ formData }) {
686
- * return parseWithStandardSchema(formData, { schema });
687
- * }});
688
- *
689
- * // Direct validation (lower level — most apps don't need this)
690
- * const result = await schema["~standard"].validate({ name: "Hasan" });
691
- * // → { value: { name: "Hasan" } } on success
692
- * // → { issues: [{ message: "...", path: [{ key: "name" }] }] } on failure
693
- *
694
- * // JSON Schema for OpenAI / LangChain tool calling
695
- * const parameters = schema["~standard"].jsonSchema.input({ target: "openai-strict" });
696
- * // → { type: "object", properties: {...}, required: [...], additionalProperties: false }
697
- * ```
698
- *
699
- * @note Cross-field rules (sameAs, requiredIf, requiredWith) rely on sibling values
700
- * available in the full validation context. When called on a standalone scalar validator,
701
- * sibling data is absent and those rules will not evaluate correctly.
702
- * Always call on the parent ObjectValidator for full-payload validation.
703
- */
704
- get ["~standard"]() {
705
- return {
706
- version: 1,
707
- vendor: "seal",
708
- types: void 0,
709
- validate: async (value) => {
710
- return mapToStandardResult(await validate(this, value));
711
- },
712
- jsonSchema: {
713
- input: (options) => this.toJsonSchema(options.target),
714
- output: (options) => this.toJsonSchema(options.target)
715
- }
716
- };
717
- }
718
- /**
719
- * Generate a JSON Schema representation of this validator.
720
- *
721
- * Supports targets: `"draft-2020-12"` (default), `"draft-07"`, `"openapi-3.0"`.
722
- *
723
- * Subclasses override this to describe their specific constraints.
724
- * The base implementation returns `{}` (permissive — accepts anything),
725
- * which is correct for validators with no representable JSON Schema constraints.
726
- *
727
- * @note Rules that cannot be expressed in JSON Schema are silently omitted:
728
- * - Cross-field rules: sameAs, requiredIf, requiredWith, requiredWithout
729
- * - Custom callbacks: refine()
730
- * - Framework-specific runtime rules (core/cascade plugins)
731
- * These rules still run normally at validation time — only absent from JSON Schema.
732
- *
733
- * @example
734
- * ```ts
735
- * v.string().min(3).max(50).toJsonSchema("draft-2020-12")
736
- * // → { type: "string", minLength: 3, maxLength: 50 }
737
- *
738
- * v.object({ name: v.string().required(), age: v.int().optional() })
739
- * .toJsonSchema("draft-07")
740
- * // → { type: "object", properties: { name: { type: "string" }, age: { type: "integer" } }, required: ["name"] }
741
- * ```
742
- */
743
- toJsonSchema(_target = "draft-2020-12") {
744
- return {};
745
- }
746
- };
747
-
748
- //#endregion
749
- export { BaseValidator };
750
- //# sourceMappingURL=base-validator.mjs.map