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