@warlock.js/notifications 5.31.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.
- package/CHANGELOG.md +14 -0
- package/cjs/index.cjs +2 -2
- package/cjs/index.cjs.map +1 -1
- package/esm/channels/database-channel.d.mts +2 -3
- package/esm/channels/database-channel.d.mts.map +1 -1
- package/esm/channels/index.d.mts +2 -1
- package/esm/channels/index.mjs +1 -1
- package/esm/channels/mail-channel.d.mts +6 -4
- package/esm/channels/mail-channel.d.mts.map +1 -1
- package/esm/config.d.mts +13 -9
- package/esm/config.d.mts.map +1 -1
- package/esm/contracts/channel.contract.d.mts +1 -3
- package/esm/contracts/channel.contract.d.mts.map +1 -1
- package/esm/contracts/index.d.mts +2 -1
- package/esm/contracts/notification.contract.d.mts +1 -3
- package/esm/contracts/notification.contract.d.mts.map +1 -1
- package/esm/contracts/preference-provider.contract.d.mts +1 -3
- package/esm/contracts/preference-provider.contract.d.mts.map +1 -1
- package/esm/contracts/queue-dispatcher.contract.d.mts +1 -3
- package/esm/contracts/queue-dispatcher.contract.d.mts.map +1 -1
- package/esm/contracts/rate-limiter.contract.d.mts +1 -3
- package/esm/contracts/rate-limiter.contract.d.mts.map +1 -1
- package/esm/dispatch/define-channel.d.mts +2 -2
- package/esm/dispatch/define-channel.d.mts.map +1 -1
- package/esm/dispatch/define-notification.d.mts +5 -6
- package/esm/dispatch/define-notification.d.mts.map +1 -1
- package/esm/dispatch/index.d.mts +2 -1
- package/esm/dispatch/index.mjs +1 -1
- package/esm/dispatch/notifications-event-bus.d.mts +2 -3
- package/esm/dispatch/notifications-event-bus.d.mts.map +1 -1
- package/esm/dispatch/notify.d.mts +3 -5
- package/esm/dispatch/notify.d.mts.map +1 -1
- package/esm/errors.d.mts +5 -6
- package/esm/errors.d.mts.map +1 -1
- package/esm/in-app/base-notifications-repository.d.mts +6 -6
- package/esm/in-app/base-notifications-repository.d.mts.map +1 -1
- package/esm/in-app/base-notifications-repository.mjs +1 -1
- package/esm/in-app/base-notifications-repository.mjs.map +1 -1
- package/esm/in-app/column-map.d.mts +11 -8
- package/esm/in-app/column-map.d.mts.map +1 -1
- package/esm/in-app/database-notification.d.mts +2 -3
- package/esm/in-app/database-notification.d.mts.map +1 -1
- package/esm/in-app/in-app.d.mts +6 -5
- package/esm/in-app/in-app.d.mts.map +1 -1
- package/esm/in-app/index.d.mts +2 -1
- package/esm/in-app/index.mjs +1 -1
- package/esm/index.d.mts +6 -0
- package/esm/migration/index.d.mts +2 -1
- package/esm/migration/index.mjs +1 -1
- package/esm/migration/notification-columns.d.mts +6 -7
- package/esm/migration/notification-columns.d.mts.map +1 -1
- package/esm/queue/bullmq-queue.d.mts +9 -7
- package/esm/queue/bullmq-queue.d.mts.map +1 -1
- package/esm/queue/herald-queue.d.mts +6 -4
- package/esm/queue/herald-queue.d.mts.map +1 -1
- package/esm/queue/index.d.mts +2 -1
- package/esm/queue/index.mjs +1 -1
- package/esm/queue/load-herald.d.mts +1 -2
- package/esm/queue/load-herald.d.mts.map +1 -1
- package/esm/queue/load-herald.mjs +1 -1
- package/esm/queue/load-queue.d.mts +2 -3
- package/esm/queue/load-queue.d.mts.map +1 -1
- package/esm/queue/notifications-worker.d.mts +5 -4
- package/esm/queue/notifications-worker.d.mts.map +1 -1
- package/esm/queue/queue-package-not-installed.error.d.mts +1 -2
- package/esm/queue/queue-package-not-installed.error.d.mts.map +1 -1
- package/esm/types.d.mts +22 -18
- package/esm/types.d.mts.map +1 -1
- package/package.json +10 -9
- package/cjs/channel_api-C5ZZDkgQ.cjs +0 -7463
- package/cjs/channel_api-C5ZZDkgQ.cjs.map +0 -1
- package/cjs/chunk-fl3r8ClO.cjs +0 -41
- package/cjs/rabbitmq-driver-CkPaCswV.cjs +0 -3
- package/cjs/src-CcbF8Hr1.cjs +0 -11276
- package/cjs/src-CcbF8Hr1.cjs.map +0 -1
- package/esm/_virtual/_rolldown/runtime.mjs +0 -32
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/_internal.mjs +0 -6
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/_internal.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/bool.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/color.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/date.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/float.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/id.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/int.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/nanoid.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/pick.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/random.mjs +0 -16
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/sample.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/string.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/token.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/uuid.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/weighted.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/async/retry.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/index.mjs +0 -24
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/mixed/clone/clone.mjs +0 -82
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/mixed/clone/clone.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/number/round.mjs +0 -17
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/number/round.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/except.mjs +0 -13
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/except.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/get.mjs +0 -18
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/get.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/omit.mjs +0 -17
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/omit.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/unset.mjs +0 -30
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/unset.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/capitalize.mjs +0 -19
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/capitalize.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/ltrim.mjs +0 -18
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/ltrim.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/readMoreChars.mjs +0 -14
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/readMoreChars.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/rtrim.mjs +0 -18
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/rtrim.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toCamelCase.mjs +0 -22
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toCamelCase.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toKebabCase.mjs +0 -17
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toKebabCase.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toSnakeCase.mjs +0 -21
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toSnakeCase.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toStudlyCase.mjs +0 -21
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toStudlyCase.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/trim.mjs +0 -20
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/trim.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/ucfirst.mjs +0 -15
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/ucfirst.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/words.mjs +0 -25
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/words.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/escapeRegex.mjs +0 -11
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/escapeRegex.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/lazy.mjs +0 -100
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/lazy.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/tap.mjs +0 -27
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/tap.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_supportive-is@3.0.0/node_modules/@mongez/supportive-is/esm/index.mjs +0 -358
- package/esm/node_modules/.pnpm/@mongez_supportive-is@3.0.0/node_modules/@mongez/supportive-is/esm/index.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/channel_api.mjs +0 -28
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/channel_api.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/api_args.mjs +0 -241
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/api_args.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/bitset.mjs +0 -130
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/bitset.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/channel.mjs +0 -302
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/channel.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/channel_model.mjs +0 -206
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/channel_model.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/codec.mjs +0 -273
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/codec.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/connect.mjs +0 -143
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/connect.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/connection.mjs +0 -416
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/connection.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/credentials.mjs +0 -50
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/credentials.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/defs.mjs +0 -4600
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/defs.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/error.mjs +0 -29
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/error.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/format.mjs +0 -28
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/format.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/frame.mjs +0 -130
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/frame.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/heartbeat.mjs +0 -40
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/heartbeat.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/mux.mjs +0 -86
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/mux.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/package.mjs +0 -41
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/package.mjs.map +0 -1
- package/esm/node_modules/.pnpm/buffer-more-ints@1.0.0/node_modules/buffer-more-ints/buffer-more-ints.mjs +0 -360
- package/esm/node_modules/.pnpm/buffer-more-ints@1.0.0/node_modules/buffer-more-ints/buffer-more-ints.mjs.map +0 -1
- package/esm/node_modules/.pnpm/dayjs@1.11.23/node_modules/dayjs/dayjs.min.mjs +0 -305
- package/esm/node_modules/.pnpm/dayjs@1.11.23/node_modules/dayjs/dayjs.min.mjs.map +0 -1
- package/esm/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.mjs +0 -80
- package/esm/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.mjs.map +0 -1
- package/esm/node_modules/.pnpm/requires-port@1.0.0/node_modules/requires-port/index.mjs +0 -35
- package/esm/node_modules/.pnpm/requires-port@1.0.0/node_modules/requires-port/index.mjs.map +0 -1
- package/esm/node_modules/.pnpm/url-parse@1.5.10/node_modules/url-parse/index.mjs +0 -388
- package/esm/node_modules/.pnpm/url-parse@1.5.10/node_modules/url-parse/index.mjs.map +0 -1
- package/esm/packages/herald/src/communicators/broker-registry.mjs +0 -204
- package/esm/packages/herald/src/communicators/broker-registry.mjs.map +0 -1
- package/esm/packages/herald/src/communicators/broker.mjs +0 -110
- package/esm/packages/herald/src/communicators/broker.mjs.map +0 -1
- package/esm/packages/herald/src/communicators/index.mjs +0 -4
- package/esm/packages/herald/src/decorators/consumable.mjs +0 -36
- package/esm/packages/herald/src/decorators/consumable.mjs.map +0 -1
- package/esm/packages/herald/src/decorators/index.mjs +0 -3
- package/esm/packages/herald/src/drivers/index.mjs +0 -5
- package/esm/packages/herald/src/drivers/rabbitmq/index.mjs +0 -4
- package/esm/packages/herald/src/drivers/rabbitmq/rabbitmq-channel.mjs +0 -403
- package/esm/packages/herald/src/drivers/rabbitmq/rabbitmq-channel.mjs.map +0 -1
- package/esm/packages/herald/src/drivers/rabbitmq/rabbitmq-driver.mjs +0 -303
- package/esm/packages/herald/src/drivers/rabbitmq/rabbitmq-driver.mjs.map +0 -1
- package/esm/packages/herald/src/index.mjs +0 -16
- package/esm/packages/herald/src/message-managers/event-consumer.mjs +0 -76
- package/esm/packages/herald/src/message-managers/event-consumer.mjs.map +0 -1
- package/esm/packages/herald/src/message-managers/event-message.mjs +0 -85
- package/esm/packages/herald/src/message-managers/event-message.mjs.map +0 -1
- package/esm/packages/herald/src/message-managers/index.mjs +0 -4
- package/esm/packages/herald/src/message-managers/prepare-consumer-subscription.mjs +0 -42
- package/esm/packages/herald/src/message-managers/prepare-consumer-subscription.mjs.map +0 -1
- package/esm/packages/herald/src/use-case-broadcast.mjs +0 -30
- package/esm/packages/herald/src/use-case-broadcast.mjs.map +0 -1
- package/esm/packages/herald/src/utils/connect-to-broker.mjs +0 -168
- package/esm/packages/herald/src/utils/connect-to-broker.mjs.map +0 -1
- package/esm/packages/herald/src/utils/index.mjs +0 -3
- package/esm/packages/seal/src/config.mjs +0 -15
- package/esm/packages/seal/src/config.mjs.map +0 -1
- package/esm/packages/seal/src/factory/index.mjs +0 -4
- package/esm/packages/seal/src/factory/validate.mjs +0 -42
- package/esm/packages/seal/src/factory/validate.mjs.map +0 -1
- package/esm/packages/seal/src/factory/validators.mjs +0 -139
- package/esm/packages/seal/src/factory/validators.mjs.map +0 -1
- package/esm/packages/seal/src/helpers/date-helpers.mjs +0 -24
- package/esm/packages/seal/src/helpers/date-helpers.mjs.map +0 -1
- package/esm/packages/seal/src/helpers/get-field-value.mjs +0 -46
- package/esm/packages/seal/src/helpers/get-field-value.mjs.map +0 -1
- package/esm/packages/seal/src/helpers/index.mjs +0 -6
- package/esm/packages/seal/src/helpers/is-empty-value.mjs +0 -10
- package/esm/packages/seal/src/helpers/is-empty-value.mjs.map +0 -1
- package/esm/packages/seal/src/helpers/path-helpers.mjs +0 -12
- package/esm/packages/seal/src/helpers/path-helpers.mjs.map +0 -1
- package/esm/packages/seal/src/helpers/validation-helpers.mjs +0 -78
- package/esm/packages/seal/src/helpers/validation-helpers.mjs.map +0 -1
- package/esm/packages/seal/src/index.mjs +0 -88
- package/esm/packages/seal/src/mutators/array-mutators.mjs +0 -32
- package/esm/packages/seal/src/mutators/array-mutators.mjs.map +0 -1
- package/esm/packages/seal/src/mutators/boolean-mutators.mjs +0 -40
- package/esm/packages/seal/src/mutators/boolean-mutators.mjs.map +0 -1
- package/esm/packages/seal/src/mutators/date-mutators.mjs +0 -94
- package/esm/packages/seal/src/mutators/date-mutators.mjs.map +0 -1
- package/esm/packages/seal/src/mutators/index.mjs +0 -9
- package/esm/packages/seal/src/mutators/number-mutators.mjs +0 -52
- package/esm/packages/seal/src/mutators/number-mutators.mjs.map +0 -1
- package/esm/packages/seal/src/mutators/object-mutators.mjs +0 -30
- package/esm/packages/seal/src/mutators/object-mutators.mjs.map +0 -1
- package/esm/packages/seal/src/mutators/scalar-mutators.mjs +0 -9
- package/esm/packages/seal/src/mutators/scalar-mutators.mjs.map +0 -1
- package/esm/packages/seal/src/mutators/string-mutators.mjs +0 -186
- package/esm/packages/seal/src/mutators/string-mutators.mjs.map +0 -1
- package/esm/packages/seal/src/object.mjs +0 -13
- package/esm/packages/seal/src/object.mjs.map +0 -1
- package/esm/packages/seal/src/rules/array/array-rules.mjs +0 -41
- package/esm/packages/seal/src/rules/array/array-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/array/index.mjs +0 -3
- package/esm/packages/seal/src/rules/color/color-rules.mjs +0 -104
- package/esm/packages/seal/src/rules/color/color-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/color/index.mjs +0 -3
- package/esm/packages/seal/src/rules/common/enum.mjs +0 -77
- package/esm/packages/seal/src/rules/common/enum.mjs.map +0 -1
- package/esm/packages/seal/src/rules/common/equals-field-rules.mjs +0 -42
- package/esm/packages/seal/src/rules/common/equals-field-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/common/index.mjs +0 -8
- package/esm/packages/seal/src/rules/common/instanceof.mjs +0 -23
- package/esm/packages/seal/src/rules/common/instanceof.mjs.map +0 -1
- package/esm/packages/seal/src/rules/common/literal.mjs +0 -31
- package/esm/packages/seal/src/rules/common/literal.mjs.map +0 -1
- package/esm/packages/seal/src/rules/common/type-rules.mjs +0 -97
- package/esm/packages/seal/src/rules/common/type-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/common/unknown-key.mjs +0 -25
- package/esm/packages/seal/src/rules/common/unknown-key.mjs.map +0 -1
- package/esm/packages/seal/src/rules/conditional/forbidden-if-rules.mjs +0 -116
- package/esm/packages/seal/src/rules/conditional/forbidden-if-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/conditional/index.mjs +0 -12
- package/esm/packages/seal/src/rules/conditional/present-if-rules.mjs +0 -97
- package/esm/packages/seal/src/rules/conditional/present-if-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/conditional/present-unless-rules.mjs +0 -30
- package/esm/packages/seal/src/rules/conditional/present-unless-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/conditional/present-with-rules.mjs +0 -76
- package/esm/packages/seal/src/rules/conditional/present-with-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/conditional/present-without-rules.mjs +0 -76
- package/esm/packages/seal/src/rules/conditional/present-without-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/conditional/required-if-rules.mjs +0 -204
- package/esm/packages/seal/src/rules/conditional/required-if-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/conditional/required-unless-rules.mjs +0 -31
- package/esm/packages/seal/src/rules/conditional/required-unless-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/conditional/required-when-rule.mjs +0 -32
- package/esm/packages/seal/src/rules/conditional/required-when-rule.mjs.map +0 -1
- package/esm/packages/seal/src/rules/conditional/required-with-rules.mjs +0 -67
- package/esm/packages/seal/src/rules/conditional/required-with-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/conditional/required-without-rules.mjs +0 -67
- package/esm/packages/seal/src/rules/conditional/required-without-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/core/equal.mjs +0 -22
- package/esm/packages/seal/src/rules/core/equal.mjs.map +0 -1
- package/esm/packages/seal/src/rules/core/forbidden.mjs +0 -20
- package/esm/packages/seal/src/rules/core/forbidden.mjs.map +0 -1
- package/esm/packages/seal/src/rules/core/index.mjs +0 -7
- package/esm/packages/seal/src/rules/core/required.mjs +0 -36
- package/esm/packages/seal/src/rules/core/required.mjs.map +0 -1
- package/esm/packages/seal/src/rules/core/union.mjs +0 -78
- package/esm/packages/seal/src/rules/core/union.mjs.map +0 -1
- package/esm/packages/seal/src/rules/core/when.mjs +0 -37
- package/esm/packages/seal/src/rules/core/when.mjs.map +0 -1
- package/esm/packages/seal/src/rules/date/date-comparison-rules.mjs +0 -78
- package/esm/packages/seal/src/rules/date/date-comparison-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/date/date-day-rules.mjs +0 -49
- package/esm/packages/seal/src/rules/date/date-day-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/date/date-field-comparison-rules.mjs +0 -82
- package/esm/packages/seal/src/rules/date/date-field-comparison-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/date/date-period-rules.mjs +0 -401
- package/esm/packages/seal/src/rules/date/date-period-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/date/date-relative-rules.mjs +0 -55
- package/esm/packages/seal/src/rules/date/date-relative-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/date/date-special-rules.mjs +0 -58
- package/esm/packages/seal/src/rules/date/date-special-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/date/date.mjs +0 -235
- package/esm/packages/seal/src/rules/date/date.mjs.map +0 -1
- package/esm/packages/seal/src/rules/date/index.mjs +0 -9
- package/esm/packages/seal/src/rules/file/dimensions.mjs +0 -3
- package/esm/packages/seal/src/rules/file/file-size.mjs +0 -3
- package/esm/packages/seal/src/rules/file/index.mjs +0 -4
- package/esm/packages/seal/src/rules/index.mjs +0 -54
- package/esm/packages/seal/src/rules/length/index.mjs +0 -3
- package/esm/packages/seal/src/rules/length/length-rules.mjs +0 -98
- package/esm/packages/seal/src/rules/length/length-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/number/index.mjs +0 -3
- package/esm/packages/seal/src/rules/number/number-rules.mjs +0 -197
- package/esm/packages/seal/src/rules/number/number-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/scalar/accepted-rule.mjs +0 -123
- package/esm/packages/seal/src/rules/scalar/accepted-rule.mjs.map +0 -1
- package/esm/packages/seal/src/rules/scalar/declined-rule.mjs +0 -123
- package/esm/packages/seal/src/rules/scalar/declined-rule.mjs.map +0 -1
- package/esm/packages/seal/src/rules/scalar/index.mjs +0 -4
- package/esm/packages/seal/src/rules/string/alpha.mjs +0 -41
- package/esm/packages/seal/src/rules/string/alpha.mjs.map +0 -1
- package/esm/packages/seal/src/rules/string/credit-card.mjs +0 -32
- package/esm/packages/seal/src/rules/string/credit-card.mjs.map +0 -1
- package/esm/packages/seal/src/rules/string/email.mjs +0 -20
- package/esm/packages/seal/src/rules/string/email.mjs.map +0 -1
- package/esm/packages/seal/src/rules/string/id-formats.mjs +0 -104
- package/esm/packages/seal/src/rules/string/id-formats.mjs.map +0 -1
- package/esm/packages/seal/src/rules/string/index.mjs +0 -13
- package/esm/packages/seal/src/rules/string/ip.mjs +0 -66
- package/esm/packages/seal/src/rules/string/ip.mjs.map +0 -1
- package/esm/packages/seal/src/rules/string/matches.mjs +0 -4
- package/esm/packages/seal/src/rules/string/pattern.mjs +0 -20
- package/esm/packages/seal/src/rules/string/pattern.mjs.map +0 -1
- package/esm/packages/seal/src/rules/string/string-comparison.mjs +0 -56
- package/esm/packages/seal/src/rules/string/string-comparison.mjs.map +0 -1
- package/esm/packages/seal/src/rules/string/strong-password-rule.mjs +0 -31
- package/esm/packages/seal/src/rules/string/strong-password-rule.mjs.map +0 -1
- package/esm/packages/seal/src/rules/string/url.mjs +0 -23
- package/esm/packages/seal/src/rules/string/url.mjs.map +0 -1
- package/esm/packages/seal/src/rules/string/without-whitespace.mjs +0 -19
- package/esm/packages/seal/src/rules/string/without-whitespace.mjs.map +0 -1
- package/esm/packages/seal/src/standard-schema/json-schema.mjs +0 -81
- package/esm/packages/seal/src/standard-schema/json-schema.mjs.map +0 -1
- package/esm/packages/seal/src/standard-schema/map-result.mjs +0 -26
- package/esm/packages/seal/src/standard-schema/map-result.mjs.map +0 -1
- package/esm/packages/seal/src/string.mjs +0 -13
- package/esm/packages/seal/src/string.mjs.map +0 -1
- package/esm/packages/seal/src/types/date-types.mjs +0 -17
- package/esm/packages/seal/src/types/date-types.mjs.map +0 -1
- package/esm/packages/seal/src/validators/any-validator.mjs +0 -38
- package/esm/packages/seal/src/validators/any-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/array-validator.mjs +0 -186
- package/esm/packages/seal/src/validators/array-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/base-validator.mjs +0 -750
- package/esm/packages/seal/src/validators/base-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/boolean-validator.mjs +0 -175
- package/esm/packages/seal/src/validators/boolean-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/computed-validator.mjs +0 -118
- package/esm/packages/seal/src/validators/computed-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/date-validator.mjs +0 -640
- package/esm/packages/seal/src/validators/date-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/discriminated-union-validator.mjs +0 -138
- package/esm/packages/seal/src/validators/discriminated-union-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/float-validator.mjs +0 -18
- package/esm/packages/seal/src/validators/float-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/index.mjs +0 -28
- package/esm/packages/seal/src/validators/instanceof-validator.mjs +0 -64
- package/esm/packages/seal/src/validators/instanceof-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/int-validator.mjs +0 -30
- package/esm/packages/seal/src/validators/int-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/lazy-validator.mjs +0 -87
- package/esm/packages/seal/src/validators/lazy-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/literal-validator.mjs +0 -72
- package/esm/packages/seal/src/validators/literal-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/managed-validator.mjs +0 -39
- package/esm/packages/seal/src/validators/managed-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/methods/equality-conditional-methods.mjs +0 -129
- package/esm/packages/seal/src/validators/methods/equality-conditional-methods.mjs.map +0 -1
- package/esm/packages/seal/src/validators/methods/forbidden-methods.mjs +0 -131
- package/esm/packages/seal/src/validators/methods/forbidden-methods.mjs.map +0 -1
- package/esm/packages/seal/src/validators/methods/present-methods.mjs +0 -235
- package/esm/packages/seal/src/validators/methods/present-methods.mjs.map +0 -1
- package/esm/packages/seal/src/validators/methods/required-methods.mjs +0 -347
- package/esm/packages/seal/src/validators/methods/required-methods.mjs.map +0 -1
- package/esm/packages/seal/src/validators/number-validator.mjs +0 -331
- package/esm/packages/seal/src/validators/number-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/numeric-validator.mjs +0 -27
- package/esm/packages/seal/src/validators/numeric-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/object-validator.mjs +0 -447
- package/esm/packages/seal/src/validators/object-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/primitive-validator.mjs +0 -88
- package/esm/packages/seal/src/validators/primitive-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/record-validator.mjs +0 -112
- package/esm/packages/seal/src/validators/record-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/scalar-validator.mjs +0 -173
- package/esm/packages/seal/src/validators/scalar-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/string-validator.mjs +0 -459
- package/esm/packages/seal/src/validators/string-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/tuple-validator.mjs +0 -134
- package/esm/packages/seal/src/validators/tuple-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/union-validator.mjs +0 -68
- package/esm/packages/seal/src/validators/union-validator.mjs.map +0 -1
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { brokerRegistry } from "../communicators/broker-registry.mjs";
|
|
2
|
-
import "../communicators/index.mjs";
|
|
3
|
-
|
|
4
|
-
//#region ../../packages/herald/src/utils/connect-to-broker.ts
|
|
5
|
-
/**
|
|
6
|
-
* Connect to a message broker and register it.
|
|
7
|
-
*
|
|
8
|
-
* This is a high-level utility function that simplifies connection setup
|
|
9
|
-
* for most projects. It handles driver instantiation, connection,
|
|
10
|
-
* broker creation, and automatic registration.
|
|
11
|
-
*
|
|
12
|
-
* **Supported Drivers:**
|
|
13
|
-
* - `rabbitmq` (default) - RabbitMQ/AMQP driver
|
|
14
|
-
* - `kafka` - Apache Kafka driver (coming soon)
|
|
15
|
-
*
|
|
16
|
-
* @param options - Connection configuration options
|
|
17
|
-
* @returns A connected and registered Broker instance
|
|
18
|
-
* @throws {Error} If connection fails or driver is not implemented
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* // RabbitMQ connection
|
|
23
|
-
* const broker = await connectToBroker({
|
|
24
|
-
* driver: "rabbitmq",
|
|
25
|
-
* host: "localhost",
|
|
26
|
-
* port: 5672,
|
|
27
|
-
* username: "guest",
|
|
28
|
-
* password: "guest",
|
|
29
|
-
* });
|
|
30
|
-
*
|
|
31
|
-
* // Use the broker
|
|
32
|
-
* await broker.channel("user.created").publish({ userId: 1 });
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```typescript
|
|
37
|
-
* // Multiple brokers
|
|
38
|
-
* await connectToBroker({
|
|
39
|
-
* driver: "rabbitmq",
|
|
40
|
-
* name: "notifications",
|
|
41
|
-
* isDefault: true,
|
|
42
|
-
* host: process.env.RABBITMQ_HOST,
|
|
43
|
-
* });
|
|
44
|
-
*
|
|
45
|
-
* await connectToBroker({
|
|
46
|
-
* driver: "rabbitmq",
|
|
47
|
-
* name: "analytics",
|
|
48
|
-
* host: process.env.ANALYTICS_RABBITMQ_HOST,
|
|
49
|
-
* });
|
|
50
|
-
*
|
|
51
|
-
* // Use default broker
|
|
52
|
-
* herald().channel("notifications").publish({ ... });
|
|
53
|
-
*
|
|
54
|
-
* // Use specific broker
|
|
55
|
-
* herald("analytics").channel("events").publish({ ... });
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
async function connectToBroker(options) {
|
|
59
|
-
const driverType = options.driver ?? "rabbitmq";
|
|
60
|
-
const brokerName = options.name ?? "default";
|
|
61
|
-
const isDefault = options.isDefault ?? true;
|
|
62
|
-
let driver;
|
|
63
|
-
switch (driverType) {
|
|
64
|
-
case "rabbitmq": {
|
|
65
|
-
const rabbitOptions = options;
|
|
66
|
-
const { RabbitMQDriver } = await import("../drivers/rabbitmq/rabbitmq-driver.mjs");
|
|
67
|
-
driver = new RabbitMQDriver(rabbitOptions);
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
case "kafka": throw new Error("Kafka driver is not yet implemented. Coming soon! For now, please use RabbitMQ.");
|
|
71
|
-
default: throw new Error(`Unknown driver: "${driverType}". Supported drivers: rabbitmq, kafka`);
|
|
72
|
-
}
|
|
73
|
-
const broker = brokerRegistry.register({
|
|
74
|
-
name: brokerName,
|
|
75
|
-
driver,
|
|
76
|
-
isDefault
|
|
77
|
-
});
|
|
78
|
-
try {
|
|
79
|
-
await driver.connect();
|
|
80
|
-
} catch (error) {
|
|
81
|
-
throw new Error(`Failed to connect to ${driverType}: ${error instanceof Error ? error.message : String(error)}`);
|
|
82
|
-
}
|
|
83
|
-
return broker;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Get a broker by name or the default one.
|
|
87
|
-
*
|
|
88
|
-
* This is the main entry point for using brokers in your application.
|
|
89
|
-
* Named after the package — `herald()` carries your messages!
|
|
90
|
-
*
|
|
91
|
-
* @param name - Optional broker name (uses default if not provided)
|
|
92
|
-
* @returns Broker instance
|
|
93
|
-
* @throws MissingBrokerError if broker not found
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* // Get default broker
|
|
97
|
-
* const channel = herald().channel("user.created");
|
|
98
|
-
* await channel.publish({ userId: 1 });
|
|
99
|
-
*
|
|
100
|
-
* // Get specific broker
|
|
101
|
-
* const analyticsChannel = herald("analytics").channel("events");
|
|
102
|
-
* await analyticsChannel.publish({ event: "page_view" });
|
|
103
|
-
*
|
|
104
|
-
* // Subscribe to messages
|
|
105
|
-
* herald()
|
|
106
|
-
* .channel<UserPayload>("user.created")
|
|
107
|
-
* .subscribe(async (message, ctx) => {
|
|
108
|
-
* console.log("User created:", message.payload);
|
|
109
|
-
* await ctx.ack();
|
|
110
|
-
* });
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
|
-
function herald(name) {
|
|
114
|
-
return brokerRegistry.get(name);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Get channel instance for the given name from default broker.
|
|
118
|
-
*
|
|
119
|
-
* Shorthand for `herald().channel(name, options)`.
|
|
120
|
-
*
|
|
121
|
-
* @param name - Channel name
|
|
122
|
-
* @param options - Optional channel options
|
|
123
|
-
* @returns Channel instance
|
|
124
|
-
* @throws MissingBrokerError if broker not found
|
|
125
|
-
*
|
|
126
|
-
* @example
|
|
127
|
-
* ```typescript
|
|
128
|
-
* const channel = heraldChannel("user.created");
|
|
129
|
-
* await channel.publish({ userId: 1 });
|
|
130
|
-
* ```
|
|
131
|
-
*/
|
|
132
|
-
function heraldChannel(name, options) {
|
|
133
|
-
return herald().channel(name, options);
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Publish an EventMessage to the default broker.
|
|
137
|
-
*
|
|
138
|
-
* @param event - Event message to publish
|
|
139
|
-
* @returns Promise that resolves when the event is published
|
|
140
|
-
* @throws Error if the broker is not connected
|
|
141
|
-
*
|
|
142
|
-
* @example
|
|
143
|
-
* ```typescript
|
|
144
|
-
* await publishEvent(new UserUpdatedEvent({ id: 1, name: "John Doe" }));
|
|
145
|
-
* ```
|
|
146
|
-
*/
|
|
147
|
-
async function publishEvent(event) {
|
|
148
|
-
return herald().publish(event);
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Subscribe an EventConsumer class to the default broker.
|
|
152
|
-
*
|
|
153
|
-
* @param Consumer - Event consumer class
|
|
154
|
-
* @returns Unsubscribe function
|
|
155
|
-
* @throws MissingBrokerError if broker not found
|
|
156
|
-
*
|
|
157
|
-
* @example
|
|
158
|
-
* ```typescript
|
|
159
|
-
* await subscribeConsumer(UserUpdatedConsumer);
|
|
160
|
-
* ```
|
|
161
|
-
*/
|
|
162
|
-
async function subscribeConsumer(Consumer) {
|
|
163
|
-
return herald().subscribe(Consumer);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
//#endregion
|
|
167
|
-
export { connectToBroker, herald, heraldChannel, publishEvent, subscribeConsumer };
|
|
168
|
-
//# sourceMappingURL=connect-to-broker.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connect-to-broker.mjs","names":[],"sources":["../../../../../../../../../../../packages/herald/src/utils/connect-to-broker.ts"],"sourcesContent":["import { Broker, brokerRegistry } from \"../communicators\";\nimport type { BrokerDriverContract, ChannelContract } from \"../contracts\";\nimport { type EventConsumerClass, EventMessage } from \"../message-managers\";\nimport type { ChannelOptions, ConnectionOptions, RabbitMQConnectionOptions } from \"../types\";\n\n/**\n * Connect to a message broker and register it.\n *\n * This is a high-level utility function that simplifies connection setup\n * for most projects. It handles driver instantiation, connection,\n * broker creation, and automatic registration.\n *\n * **Supported Drivers:**\n * - `rabbitmq` (default) - RabbitMQ/AMQP driver\n * - `kafka` - Apache Kafka driver (coming soon)\n *\n * @param options - Connection configuration options\n * @returns A connected and registered Broker instance\n * @throws {Error} If connection fails or driver is not implemented\n *\n * @example\n * ```typescript\n * // RabbitMQ connection\n * const broker = await connectToBroker({\n * driver: \"rabbitmq\",\n * host: \"localhost\",\n * port: 5672,\n * username: \"guest\",\n * password: \"guest\",\n * });\n *\n * // Use the broker\n * await broker.channel(\"user.created\").publish({ userId: 1 });\n * ```\n *\n * @example\n * ```typescript\n * // Multiple brokers\n * await connectToBroker({\n * driver: \"rabbitmq\",\n * name: \"notifications\",\n * isDefault: true,\n * host: process.env.RABBITMQ_HOST,\n * });\n *\n * await connectToBroker({\n * driver: \"rabbitmq\",\n * name: \"analytics\",\n * host: process.env.ANALYTICS_RABBITMQ_HOST,\n * });\n *\n * // Use default broker\n * herald().channel(\"notifications\").publish({ ... });\n *\n * // Use specific broker\n * herald(\"analytics\").channel(\"events\").publish({ ... });\n * ```\n */\nexport async function connectToBroker(options: ConnectionOptions): Promise<Broker> {\n // Default values\n const driverType = options.driver ?? \"rabbitmq\";\n const brokerName = options.name ?? \"default\";\n const isDefault = options.isDefault ?? true;\n\n // Create driver based on type\n let driver: BrokerDriverContract;\n\n switch (driverType) {\n case \"rabbitmq\": {\n const rabbitOptions = options as RabbitMQConnectionOptions;\n // Dynamic import to avoid requiring amqplib if not used\n const { RabbitMQDriver } = await import(\"../drivers/rabbitmq/rabbitmq-driver\");\n driver = new RabbitMQDriver(rabbitOptions);\n break;\n }\n\n case \"kafka\": {\n // const kafkaOptions = options as KafkaConnectionOptions;\n // Dynamic import to avoid requiring kafkajs if not used\n throw new Error(\n \"Kafka driver is not yet implemented. Coming soon! For now, please use RabbitMQ.\",\n );\n }\n\n default:\n throw new Error(`Unknown driver: \"${driverType}\". Supported drivers: rabbitmq, kafka`);\n }\n\n // Create broker\n const broker = brokerRegistry.register({\n name: brokerName,\n driver,\n isDefault,\n });\n\n // Connect to the message broker\n try {\n await driver.connect();\n } catch (error) {\n throw new Error(\n `Failed to connect to ${driverType}: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n\n return broker;\n}\n\n/**\n * Get a broker by name or the default one.\n *\n * This is the main entry point for using brokers in your application.\n * Named after the package — `herald()` carries your messages!\n *\n * @param name - Optional broker name (uses default if not provided)\n * @returns Broker instance\n * @throws MissingBrokerError if broker not found\n *\n * @example\n * // Get default broker\n * const channel = herald().channel(\"user.created\");\n * await channel.publish({ userId: 1 });\n *\n * // Get specific broker\n * const analyticsChannel = herald(\"analytics\").channel(\"events\");\n * await analyticsChannel.publish({ event: \"page_view\" });\n *\n * // Subscribe to messages\n * herald()\n * .channel<UserPayload>(\"user.created\")\n * .subscribe(async (message, ctx) => {\n * console.log(\"User created:\", message.payload);\n * await ctx.ack();\n * });\n * ```\n */\nexport function herald(name?: string): Broker {\n return brokerRegistry.get(name);\n}\n\n/**\n * Get channel instance for the given name from default broker.\n *\n * Shorthand for `herald().channel(name, options)`.\n *\n * @param name - Channel name\n * @param options - Optional channel options\n * @returns Channel instance\n * @throws MissingBrokerError if broker not found\n *\n * @example\n * ```typescript\n * const channel = heraldChannel(\"user.created\");\n * await channel.publish({ userId: 1 });\n * ```\n */\nexport function heraldChannel<TPayload = unknown>(\n name: string,\n options?: ChannelOptions<TPayload>,\n): ChannelContract<TPayload> {\n return herald().channel<TPayload>(name, options);\n}\n\n/**\n * Publish an EventMessage to the default broker.\n *\n * @param event - Event message to publish\n * @returns Promise that resolves when the event is published\n * @throws Error if the broker is not connected\n *\n * @example\n * ```typescript\n * await publishEvent(new UserUpdatedEvent({ id: 1, name: \"John Doe\" }));\n * ```\n */\nexport async function publishEvent<TPayload = Record<string, any>>(event: EventMessage<TPayload>) {\n return herald().publish(event);\n}\n\n/**\n * Subscribe an EventConsumer class to the default broker.\n *\n * @param Consumer - Event consumer class\n * @returns Unsubscribe function\n * @throws MissingBrokerError if broker not found\n *\n * @example\n * ```typescript\n * await subscribeConsumer(UserUpdatedConsumer);\n * ```\n */\nexport async function subscribeConsumer<TPayload = Record<string, any>>(\n Consumer: EventConsumerClass<TPayload>,\n) {\n return herald().subscribe(Consumer);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,eAAsB,gBAAgB,SAA6C;CAEjF,MAAM,aAAa,QAAQ,UAAU;CACrC,MAAM,aAAa,QAAQ,QAAQ;CACnC,MAAM,YAAY,QAAQ,aAAa;CAGvC,IAAI;CAEJ,QAAQ,YAAR;EACE,KAAK,YAAY;GACf,MAAM,gBAAgB;GAEtB,MAAM,EAAE,mBAAmB,MAAM,OAAO;GACxC,SAAS,IAAI,eAAe,aAAa;GACzC;EACF;EAEA,KAAK,SAGH,MAAM,IAAI,MACR,iFACF;EAGF,SACE,MAAM,IAAI,MAAM,oBAAoB,WAAW,sCAAsC;CACzF;CAGA,MAAM,SAAS,eAAe,SAAS;EACrC,MAAM;EACN;EACA;CACF,CAAC;CAGD,IAAI;EACF,MAAM,OAAO,QAAQ;CACvB,SAAS,OAAO;EACd,MAAM,IAAI,MACR,wBAAwB,WAAW,IAAI,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAC9F;CACF;CAEA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,OAAO,MAAuB;CAC5C,OAAO,eAAe,IAAI,IAAI;AAChC;;;;;;;;;;;;;;;;;AAkBA,SAAgB,cACd,MACA,SAC2B;CAC3B,OAAO,OAAO,CAAC,CAAC,QAAkB,MAAM,OAAO;AACjD;;;;;;;;;;;;;AAcA,eAAsB,aAA6C,OAA+B;CAChG,OAAO,OAAO,CAAC,CAAC,QAAQ,KAAK;AAC/B;;;;;;;;;;;;;AAcA,eAAsB,kBACpB,UACA;CACA,OAAO,OAAO,CAAC,CAAC,UAAU,QAAQ;AACpC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//#region ../../packages/seal/src/config.ts
|
|
2
|
-
/**
|
|
3
|
-
* Global Seal configuration
|
|
4
|
-
*/
|
|
5
|
-
const config = { firstErrorOnly: true };
|
|
6
|
-
/**
|
|
7
|
-
* Get current Seal configuration
|
|
8
|
-
*/
|
|
9
|
-
function getSealConfig() {
|
|
10
|
-
return config;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
//#endregion
|
|
14
|
-
export { getSealConfig };
|
|
15
|
-
//# sourceMappingURL=config.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","names":[],"sources":["../../../../../../../../../../packages/seal/src/config.ts"],"sourcesContent":["/**\n * Seal Configuration\n *\n * Global configuration for the Seal validation library\n */\n\nimport type { AttributeTranslation, RuleTranslation } from \"./types\";\n\nexport type TranslateRuleCallback = (ruleTranslation: RuleTranslation) => string;\n\nexport type TranslateAttributeCallback = (attributeTranslation: AttributeTranslation) => string;\n\nexport type SealConfig = {\n /**\n * Translation function for error messages\n * Default: returns the key with attributes replaced\n */\n translateRule?: TranslateRuleCallback;\n /**\n * Translation function for attribute messages\n */\n translateAttribute?: TranslateAttributeCallback;\n\n /**\n * Default to first error only in validation\n * Default: true\n */\n firstErrorOnly?: boolean;\n};\n\n/**\n * Global Seal configuration\n */\nconst config: SealConfig = {\n firstErrorOnly: true,\n};\n\n/**\n * Configure Seal globally\n *\n * @example\n * ```ts\n * import { configureSeal } from \"@warlock.js/seal\";\n * import { trans } from \"@mongez/localization\";\n *\n * configureSeal({\n * translateRule: (ruleTranslation) => trans(`validation.${ruleTranslation.rule.name}`, ruleTranslation.attributes),\n * translateAttribute: (attributeTranslation) => trans(`validation.attributes.${attributeTranslation.rule.name}.${attributeTranslation.attribute}`, attributeTranslation.context.allValues),\n * });\n * ```\n */\nexport function configureSeal(options: Partial<SealConfig>): void {\n Object.assign(config, options);\n}\n\n/**\n * Get current Seal configuration\n */\nexport function getSealConfig(): SealConfig {\n return config;\n}\n\n/**\n * Reset configuration to defaults\n */\nexport function resetSealConfig(): void {\n delete config.translateRule;\n delete config.translateAttribute;\n\n config.firstErrorOnly = true;\n}\n"],"mappings":";;;;AAiCA,MAAM,SAAqB,EACzB,gBAAgB,KAClB;;;;AAuBA,SAAgB,gBAA4B;CAC1C,OAAO;AACT"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { getSealConfig } from "../config.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../../packages/seal/src/factory/validate.ts
|
|
4
|
-
/**
|
|
5
|
-
* Validate data against a schema.
|
|
6
|
-
*
|
|
7
|
-
* The result narrows on `isValid`: on success `data` is the schema's
|
|
8
|
-
* `Infer.Output`, on failure it is `undefined`.
|
|
9
|
-
*/
|
|
10
|
-
const validate = async (schema, data, { context: extendedContext, ...configurations } = getSealConfig() || {}) => {
|
|
11
|
-
const context = {
|
|
12
|
-
allValues: data,
|
|
13
|
-
parent: null,
|
|
14
|
-
value: data,
|
|
15
|
-
key: "",
|
|
16
|
-
path: "",
|
|
17
|
-
context: extendedContext,
|
|
18
|
-
rootContext: extendedContext,
|
|
19
|
-
translateRule(ruleTranslation) {
|
|
20
|
-
return configurations.translateRule?.(ruleTranslation) ?? "";
|
|
21
|
-
},
|
|
22
|
-
translateAttribute(attributeTranslation) {
|
|
23
|
-
return configurations.translateAttribute?.(attributeTranslation) ?? "";
|
|
24
|
-
},
|
|
25
|
-
configurations
|
|
26
|
-
};
|
|
27
|
-
const result = await schema.validate(data, context);
|
|
28
|
-
if (!result.isValid) return {
|
|
29
|
-
isValid: false,
|
|
30
|
-
errors: result.errors,
|
|
31
|
-
data: void 0
|
|
32
|
-
};
|
|
33
|
-
return {
|
|
34
|
-
isValid: true,
|
|
35
|
-
errors: result.errors,
|
|
36
|
-
data: result.data
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
//#endregion
|
|
41
|
-
export { validate };
|
|
42
|
-
//# sourceMappingURL=validate.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate.mjs","names":[],"sources":["../../../../../../../../../../../packages/seal/src/factory/validate.ts"],"sourcesContent":["import { getSealConfig } from \"../config\";\nimport type { SchemaContext, TypedValidationResult, ValidatedOutput } from \"../types\";\nimport type { BaseValidator } from \"../validators\";\nimport type { ValidateOptions } from \"./validators\";\n\n/**\n * Validate data against a schema.\n *\n * The result narrows on `isValid`: on success `data` is the schema's\n * `Infer.Output`, on failure it is `undefined`.\n */\nexport const validate = async <T extends BaseValidator>(\n schema: T,\n data: unknown,\n { context: extendedContext, ...configurations }: ValidateOptions = getSealConfig() || {},\n): Promise<TypedValidationResult<ValidatedOutput<T>>> => {\n const context: SchemaContext = {\n allValues: data,\n parent: null,\n value: data,\n key: \"\",\n path: \"\",\n context: extendedContext,\n rootContext: extendedContext,\n translateRule(ruleTranslation) {\n return configurations.translateRule?.(ruleTranslation) ?? \"\";\n },\n translateAttribute(attributeTranslation) {\n return configurations.translateAttribute?.(attributeTranslation) ?? \"\";\n },\n configurations,\n };\n\n const result = await schema.validate(data, context);\n\n // A failed validation never hands back the input it just rejected.\n //\n // `object` used to return the raw input on failure while `discriminatedUnion`\n // returned `undefined` — the same call shape with two different contracts.\n // The object behaviour was the dangerous one: validating an outbound DTO\n // specifically to keep internal fields out of a response, then doing the\n // natural `const { data } = await v.validate(dto, record); reply.send(data)`,\n // shipped every field the schema existed to exclude. A guard that returns the\n // unsafe value on failure reads as safe and isn't.\n if (!result.isValid) {\n return { isValid: false, errors: result.errors, data: undefined };\n }\n\n return { isValid: true, errors: result.errors, data: result.data };\n};\n"],"mappings":";;;;;;;;;AAWA,MAAa,WAAW,OACtB,QACA,MACA,EAAE,SAAS,iBAAiB,GAAG,mBAAoC,cAAc,KAAK,CAAC,MAChC;CACvD,MAAM,UAAyB;EAC7B,WAAW;EACX,QAAQ;EACR,OAAO;EACP,KAAK;EACL,MAAM;EACN,SAAS;EACT,aAAa;EACb,cAAc,iBAAiB;GAC7B,OAAO,eAAe,gBAAgB,eAAe,KAAK;EAC5D;EACA,mBAAmB,sBAAsB;GACvC,OAAO,eAAe,qBAAqB,oBAAoB,KAAK;EACtE;EACA;CACF;CAEA,MAAM,SAAS,MAAM,OAAO,SAAS,MAAM,OAAO;CAWlD,IAAI,CAAC,OAAO,SACV,OAAO;EAAE,SAAS;EAAO,QAAQ,OAAO;EAAQ,MAAM;CAAU;CAGlE,OAAO;EAAE,SAAS;EAAM,QAAQ,OAAO;EAAQ,MAAM,OAAO;CAAK;AACnE"}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { validate } from "./validate.mjs";
|
|
2
|
-
import { AnyValidator } from "../validators/any-validator.mjs";
|
|
3
|
-
import { ArrayValidator } from "../validators/array-validator.mjs";
|
|
4
|
-
import "../validators/methods/equality-conditional-methods.mjs";
|
|
5
|
-
import "../validators/methods/forbidden-methods.mjs";
|
|
6
|
-
import "../validators/methods/present-methods.mjs";
|
|
7
|
-
import "../validators/methods/required-methods.mjs";
|
|
8
|
-
import { BooleanValidator } from "../validators/boolean-validator.mjs";
|
|
9
|
-
import { ComputedValidator } from "../validators/computed-validator.mjs";
|
|
10
|
-
import { DateValidator } from "../validators/date-validator.mjs";
|
|
11
|
-
import { LiteralValidator } from "../validators/literal-validator.mjs";
|
|
12
|
-
import { DiscriminatedUnionValidator } from "../validators/discriminated-union-validator.mjs";
|
|
13
|
-
import { NumberValidator } from "../validators/number-validator.mjs";
|
|
14
|
-
import { FloatValidator } from "../validators/float-validator.mjs";
|
|
15
|
-
import { InstanceOfValidator } from "../validators/instanceof-validator.mjs";
|
|
16
|
-
import { IntValidator } from "../validators/int-validator.mjs";
|
|
17
|
-
import { LazyValidator } from "../validators/lazy-validator.mjs";
|
|
18
|
-
import { ManagedValidator } from "../validators/managed-validator.mjs";
|
|
19
|
-
import { NumericValidator } from "../validators/numeric-validator.mjs";
|
|
20
|
-
import { RecordValidator } from "../validators/record-validator.mjs";
|
|
21
|
-
import { ScalarValidator } from "../validators/scalar-validator.mjs";
|
|
22
|
-
import { StringValidator } from "../validators/string-validator.mjs";
|
|
23
|
-
import { TupleValidator } from "../validators/tuple-validator.mjs";
|
|
24
|
-
import { UnionValidator } from "../validators/union-validator.mjs";
|
|
25
|
-
import { object } from "../object.mjs";
|
|
26
|
-
import { string } from "../string.mjs";
|
|
27
|
-
|
|
28
|
-
//#region ../../packages/seal/src/factory/validators.ts
|
|
29
|
-
/**
|
|
30
|
-
* Seal factory object - creates instances of validators
|
|
31
|
-
*
|
|
32
|
-
* Use 'v' to create validation schemas (seals) for your data
|
|
33
|
-
*/
|
|
34
|
-
const v = {
|
|
35
|
-
/** Create an object validator */
|
|
36
|
-
object,
|
|
37
|
-
/** Create an any validator */
|
|
38
|
-
any: () => new AnyValidator(),
|
|
39
|
-
/** Create an array validator */
|
|
40
|
-
array: (validator, errorMessage) => new ArrayValidator(validator, errorMessage),
|
|
41
|
-
/** Create a record validator - object with dynamic keys and consistent value types */
|
|
42
|
-
record: (validator, errorMessage) => new RecordValidator(validator || v.any(), errorMessage),
|
|
43
|
-
/**
|
|
44
|
-
* Create a tuple validator - fixed-length array with position-specific types.
|
|
45
|
-
*
|
|
46
|
-
* The `| []` in the constraint makes TypeScript infer a literal list as a tuple, so
|
|
47
|
-
* `v.tuple([v.string(), v.int()])` is typed `[string, number]` rather than
|
|
48
|
-
* `(string | number)[]`; a `BaseValidator[]` variable is still accepted.
|
|
49
|
-
*/
|
|
50
|
-
tuple: (validators, errorMessage) => new TupleValidator(validators, errorMessage),
|
|
51
|
-
/** Create a date validator */
|
|
52
|
-
date: (errorMessage) => new DateValidator(errorMessage),
|
|
53
|
-
/**
|
|
54
|
-
* Create a literal validator — narrows to the union of given literal values
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* v.literal("items") // type: "items"
|
|
58
|
-
* v.literal("draft", "published") // type: "draft" | "published"
|
|
59
|
-
* v.literal(1, 2, 3) // type: 1 | 2 | 3
|
|
60
|
-
*/
|
|
61
|
-
literal: (...values) => new LiteralValidator(values),
|
|
62
|
-
/**
|
|
63
|
-
* Create an instanceof validator — value must be `instanceof` the constructor
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* v.instanceof(File) // type: File
|
|
67
|
-
* v.instanceof(Buffer) // type: Buffer
|
|
68
|
-
* v.instanceof(MyClass) // type: MyClass
|
|
69
|
-
*/
|
|
70
|
-
instanceof: (ctor, errorMessage) => new InstanceOfValidator(ctor, errorMessage),
|
|
71
|
-
/**
|
|
72
|
-
* Create a lazy validator — defers resolution of the inner validator until
|
|
73
|
-
* validate-time. Use for recursive or forward-referenced schemas.
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* type Category = { name: string; children: Category[] };
|
|
77
|
-
*
|
|
78
|
-
* const category: ObjectValidator<...> = v.object({
|
|
79
|
-
* name: v.string(),
|
|
80
|
-
* children: v.array(v.lazy(() => category)),
|
|
81
|
-
* });
|
|
82
|
-
*/
|
|
83
|
-
lazy: (thunk) => new LazyValidator(thunk),
|
|
84
|
-
/** Create a string validator */
|
|
85
|
-
string,
|
|
86
|
-
/** Create an email validator */
|
|
87
|
-
email: (emailErrorMessage, errorMessage) => new StringValidator(errorMessage).email(emailErrorMessage),
|
|
88
|
-
/**
|
|
89
|
-
* Create an enum validator — preserves the literal union of accepted
|
|
90
|
-
* values in the inferred Standard Schema output.
|
|
91
|
-
*
|
|
92
|
-
* Two input shapes:
|
|
93
|
-
* - Tuple of literals: `v.enum(["draft", "published"])` →
|
|
94
|
-
* `StandardSchemaV1<"draft" | "published">`
|
|
95
|
-
* - TypeScript enum object: `v.enum(Status)` →
|
|
96
|
-
* `StandardSchemaV1<Status[keyof Status]>`
|
|
97
|
-
*
|
|
98
|
-
* Implementation is loosely typed; the public `ValidatorV.enum`
|
|
99
|
-
* surface declares the precise overloads.
|
|
100
|
-
*/
|
|
101
|
-
enum: ((values, errorMessage) => Array.isArray(values) ? new ScalarValidator().oneOf(values, errorMessage) : new ScalarValidator().enum(values, errorMessage)),
|
|
102
|
-
/** Create a number validator */
|
|
103
|
-
number: (errorMessage) => new NumberValidator(errorMessage),
|
|
104
|
-
/** Create a numeric validator */
|
|
105
|
-
numeric: (errorMessage) => new NumericValidator(errorMessage),
|
|
106
|
-
/** Create an integer validator */
|
|
107
|
-
int: (errorMessage) => new IntValidator(errorMessage),
|
|
108
|
-
/** Create a float validator */
|
|
109
|
-
float: (errorMessage) => new FloatValidator(errorMessage),
|
|
110
|
-
/** Create a boolean validator */
|
|
111
|
-
boolean: (errorMessage) => new BooleanValidator(errorMessage),
|
|
112
|
-
/** Create a scalar validator */
|
|
113
|
-
scalar: (errorMessage) => new ScalarValidator(errorMessage),
|
|
114
|
-
/** Create a union validator - validates against multiple types */
|
|
115
|
-
union: (validators, errorMessage) => new UnionValidator().union(validators, errorMessage),
|
|
116
|
-
/**
|
|
117
|
-
* Create a discriminated union — routes payloads by a shared literal
|
|
118
|
-
* discriminator field. Each branch must be a `v.object(...)` with the
|
|
119
|
-
* discriminator typed as `v.literal(...)`.
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* const email = v.object({ type: v.literal("email"), email: v.string().email() });
|
|
123
|
-
* const sms = v.object({ type: v.literal("sms"), phone: v.string() });
|
|
124
|
-
* const notif = v.discriminatedUnion("type", [email, sms]);
|
|
125
|
-
* // type T = Infer<typeof notif>;
|
|
126
|
-
* // → { type: "email", email: string } | { type: "sms", phone: string }
|
|
127
|
-
*/
|
|
128
|
-
discriminatedUnion: (discriminator, validators) => new DiscriminatedUnionValidator(discriminator, validators),
|
|
129
|
-
/** Create a computed field validator - derives value from other validated fields */
|
|
130
|
-
computed: (callback, resultValidator) => new ComputedValidator(callback, resultValidator),
|
|
131
|
-
/** Create a managed field validator - framework-injected value */
|
|
132
|
-
managed: (callback, resultValidator) => new ManagedValidator(callback, resultValidator),
|
|
133
|
-
/** Validate data against a schema */
|
|
134
|
-
validate
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
//#endregion
|
|
138
|
-
export { v };
|
|
139
|
-
//# sourceMappingURL=validators.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validators.mjs","names":["validateFunction"],"sources":["../../../../../../../../../../../packages/seal/src/factory/validators.ts"],"sourcesContent":["import type { SealConfig } from \"../config\";\nimport { object } from \"../object\";\nimport { string } from \"../string\";\nimport type { StandardSchemaV1 } from \"../standard-schema/types\";\nimport type { Schema, SchemaContext, TypedValidationResult, ValidatedOutput } from \"../types\";\nimport type { Infer } from \"../types/inference-types\";\nimport { AnyValidator } from \"../validators/any-validator\";\nimport { ArrayValidator } from \"../validators/array-validator\";\nimport type { BaseValidator } from \"../validators/base-validator\";\nimport { BooleanValidator } from \"../validators/boolean-validator\";\nimport { ComputedValidator } from \"../validators/computed-validator\";\nimport { DateValidator } from \"../validators/date-validator\";\nimport { DiscriminatedUnionValidator } from \"../validators/discriminated-union-validator\";\nimport { FloatValidator } from \"../validators/float-validator\";\nimport { InstanceOfValidator } from \"../validators/instanceof-validator\";\nimport { IntValidator } from \"../validators/int-validator\";\nimport { LazyValidator } from \"../validators/lazy-validator\";\nimport { LiteralValidator } from \"../validators/literal-validator\";\nimport { ManagedValidator } from \"../validators/managed-validator\";\nimport { NumberValidator } from \"../validators/number-validator\";\nimport { NumericValidator } from \"../validators/numeric-validator\";\nimport { ObjectValidator } from \"../validators/object-validator\";\nimport { RecordValidator } from \"../validators/record-validator\";\nimport { ScalarValidator } from \"../validators/scalar-validator\";\nimport { StringValidator } from \"../validators/string-validator\";\nimport { TupleValidator } from \"../validators/tuple-validator\";\nimport { UnionValidator } from \"../validators/union-validator\";\n// BaseValidator prototype augmentations — side-effect imports so the `v`\n// factory always exposes the chain methods (.required, .requiredIf, .sameAs,\n// .present, .forbidden, .when, …) regardless of which entry path loaded it.\n// The package barrel (src/index.ts) loads these via the validators barrel, but\n// importing the factory leaf directly would otherwise yield a half-built `v`.\nimport \"../validators/methods/equality-conditional-methods\";\nimport \"../validators/methods/forbidden-methods\";\nimport \"../validators/methods/present-methods\";\nimport \"../validators/methods/required-methods\";\nimport { validate as validateFunction } from \"./validate\";\n\n/**\n * Seal factory object - creates instances of validators\n *\n * Use 'v' to create validation schemas (seals) for your data\n */\nexport const v: ValidatorV = {\n /** Create an object validator */\n object,\n\n /** Create an any validator */\n any: () => new AnyValidator() as AnyValidator & StandardSchemaV1<any>,\n\n /** Create an array validator */\n array: <T extends BaseValidator>(validator: T, errorMessage?: string) =>\n new ArrayValidator(validator, errorMessage) as ArrayValidator & {\n validator: T;\n } & StandardSchemaV1<Array<Infer.Input<T>>, Array<Infer.Output<T>>>,\n\n /** Create a record validator - object with dynamic keys and consistent value types */\n record: <T extends BaseValidator>(validator?: T, errorMessage?: string) =>\n new RecordValidator(validator || v.any(), errorMessage) as StandardSchemaV1<\n Record<string, Infer.Input<T>>,\n Record<string, Infer.Output<T>>\n > &\n RecordValidator & { valueValidator: T },\n\n /**\n * Create a tuple validator - fixed-length array with position-specific types.\n *\n * The `| []` in the constraint makes TypeScript infer a literal list as a tuple, so\n * `v.tuple([v.string(), v.int()])` is typed `[string, number]` rather than\n * `(string | number)[]`; a `BaseValidator[]` variable is still accepted.\n */\n tuple: <T extends BaseValidator[] | []>(validators: T, errorMessage?: string) =>\n new TupleValidator(validators, errorMessage) as TupleValidator & {\n validators: T;\n } & StandardSchemaV1<\n { [K in keyof T]: Infer.Input<T[K]> },\n { [K in keyof T]: Infer.Output<T[K]> }\n >,\n\n /** Create a date validator */\n date: (errorMessage?: string) =>\n new DateValidator(errorMessage) as DateValidator & StandardSchemaV1<Date>,\n\n /**\n * Create a literal validator — narrows to the union of given literal values\n *\n * @example\n * v.literal(\"items\") // type: \"items\"\n * v.literal(\"draft\", \"published\") // type: \"draft\" | \"published\"\n * v.literal(1, 2, 3) // type: 1 | 2 | 3\n */\n literal: <T extends readonly [string | number | boolean, ...(string | number | boolean)[]]>(\n ...values: T\n ) => new LiteralValidator<T>(values) as LiteralValidator<T> & StandardSchemaV1<T[number]>,\n\n /**\n * Create an instanceof validator — value must be `instanceof` the constructor\n *\n * @example\n * v.instanceof(File) // type: File\n * v.instanceof(Buffer) // type: Buffer\n * v.instanceof(MyClass) // type: MyClass\n */\n instanceof: <T>(ctor: new (...args: any[]) => T, errorMessage?: string) =>\n new InstanceOfValidator<T>(ctor, errorMessage) as InstanceOfValidator<T> & StandardSchemaV1<T>,\n\n /**\n * Create a lazy validator — defers resolution of the inner validator until\n * validate-time. Use for recursive or forward-referenced schemas.\n *\n * @example\n * type Category = { name: string; children: Category[] };\n *\n * const category: ObjectValidator<...> = v.object({\n * name: v.string(),\n * children: v.array(v.lazy(() => category)),\n * });\n */\n lazy: <T extends BaseValidator>(thunk: () => T) =>\n new LazyValidator(thunk) as LazyValidator<T> &\n StandardSchemaV1<Infer.Input<T>, Infer.Output<T>>,\n\n /** Create a string validator */\n string,\n\n /** Create an email validator */\n email: (emailErrorMessage?: string, errorMessage?: string) =>\n new StringValidator(errorMessage).email(emailErrorMessage) as StringValidator &\n StandardSchemaV1<string>,\n\n /**\n * Create an enum validator — preserves the literal union of accepted\n * values in the inferred Standard Schema output.\n *\n * Two input shapes:\n * - Tuple of literals: `v.enum([\"draft\", \"published\"])` →\n * `StandardSchemaV1<\"draft\" | \"published\">`\n * - TypeScript enum object: `v.enum(Status)` →\n * `StandardSchemaV1<Status[keyof Status]>`\n *\n * Implementation is loosely typed; the public `ValidatorV.enum`\n * surface declares the precise overloads.\n */\n enum: ((values: any, errorMessage?: string) =>\n Array.isArray(values)\n ? new ScalarValidator().oneOf(values, errorMessage)\n : new ScalarValidator().enum(values, errorMessage)) as ValidatorV[\"enum\"],\n\n /** Create a number validator */\n number: (errorMessage?: string) =>\n new NumberValidator(errorMessage) as NumberValidator & StandardSchemaV1<number>,\n\n /** Create a numeric validator */\n numeric: (errorMessage?: string) =>\n new NumericValidator(errorMessage) as NumericValidator & StandardSchemaV1<number>,\n\n /** Create an integer validator */\n int: (errorMessage?: string) =>\n new IntValidator(errorMessage) as IntValidator & StandardSchemaV1<number>,\n\n /** Create a float validator */\n float: (errorMessage?: string) =>\n new FloatValidator(errorMessage) as FloatValidator & StandardSchemaV1<number>,\n\n /** Create a boolean validator */\n boolean: (errorMessage?: string) =>\n new BooleanValidator(errorMessage) as BooleanValidator & StandardSchemaV1<boolean>,\n\n /** Create a scalar validator */\n scalar: (errorMessage?: string) =>\n new ScalarValidator(errorMessage) as ScalarValidator &\n StandardSchemaV1<string | number | boolean>,\n\n /** Create a union validator - validates against multiple types */\n union: <T extends BaseValidator[]>(validators: T, errorMessage?: string) =>\n new UnionValidator().union(validators, errorMessage) as StandardSchemaV1<\n Infer.Input<T[number]>,\n Infer.Output<T[number]>\n > &\n UnionValidator,\n\n /**\n * Create a discriminated union — routes payloads by a shared literal\n * discriminator field. Each branch must be a `v.object(...)` with the\n * discriminator typed as `v.literal(...)`.\n *\n * @example\n * const email = v.object({ type: v.literal(\"email\"), email: v.string().email() });\n * const sms = v.object({ type: v.literal(\"sms\"), phone: v.string() });\n * const notif = v.discriminatedUnion(\"type\", [email, sms]);\n * // type T = Infer<typeof notif>;\n * // → { type: \"email\", email: string } | { type: \"sms\", phone: string }\n */\n discriminatedUnion: <K extends string, Branches extends ReadonlyArray<ObjectValidator<any>>>(\n discriminator: K,\n validators: Branches,\n ) =>\n new DiscriminatedUnionValidator(discriminator, validators) as DiscriminatedUnionValidator<\n K,\n Branches\n > &\n StandardSchemaV1<Infer.Input<Branches[number]>, Infer.Output<Branches[number]>>,\n\n /** Create a computed field validator - derives value from other validated fields */\n computed: <TResult = any>(\n callback: (data: any, context: SchemaContext) => TResult | Promise<TResult>,\n resultValidator?: BaseValidator,\n ) =>\n new ComputedValidator<TResult>(callback, resultValidator) as ComputedValidator<TResult> &\n StandardSchemaV1<TResult>,\n\n /** Create a managed field validator - framework-injected value */\n managed: <TResult = any>(\n callback: (context: SchemaContext) => TResult | Promise<TResult>,\n resultValidator?: BaseValidator,\n ) =>\n new ManagedValidator<TResult>(callback, resultValidator) as ManagedValidator<TResult> &\n StandardSchemaV1<TResult>,\n\n /** Validate data against a schema */\n validate: validateFunction,\n} as unknown as ValidatorV;\n\nexport type ValidateOptions = {\n context?: Record<string, any>;\n /**\n * Rendered as `:value` in every error message — translated or custom —\n * instead of the submitted input. Unset keeps the raw value.\n */\n redactValue?: string;\n} & SealConfig;\n\n// Standard Schema comes first on record/union intersections so direct calls\n// select the precise validate() output overload rather than BaseValidator's.\nexport interface ValidatorV {\n object: <T extends Schema>(schema: T, errorMessage?: string) => ObjectValidator<T>;\n any: () => AnyValidator & StandardSchemaV1<any>;\n array: <T extends BaseValidator>(\n validator: T,\n errorMessage?: string,\n ) => ArrayValidator & {\n validator: T;\n } & StandardSchemaV1<Array<Infer.Input<T>>, Array<Infer.Output<T>>>;\n record: <T extends BaseValidator>(\n validator?: T,\n errorMessage?: string,\n ) => StandardSchemaV1<Record<string, Infer.Input<T>>, Record<string, Infer.Output<T>>> &\n RecordValidator & { valueValidator: T };\n tuple: <T extends BaseValidator[] | []>(\n validators: T,\n errorMessage?: string,\n ) => TupleValidator & {\n validators: T;\n } & StandardSchemaV1<\n { [K in keyof T]: Infer.Input<T[K]> },\n { [K in keyof T]: Infer.Output<T[K]> }\n >;\n date: (errorMessage?: string) => DateValidator & StandardSchemaV1<Date>;\n literal: <T extends readonly [string | number | boolean, ...(string | number | boolean)[]]>(\n ...values: T\n ) => LiteralValidator<T> & StandardSchemaV1<T[number]>;\n instanceof: <T>(\n ctor: new (...args: any[]) => T,\n errorMessage?: string,\n ) => InstanceOfValidator<T> & StandardSchemaV1<T>;\n lazy: <T extends BaseValidator>(\n thunk: () => T,\n ) => LazyValidator<T> & StandardSchemaV1<Infer.Input<T>, Infer.Output<T>>;\n string: (errorMessage?: string) => StringValidator & StandardSchemaV1<string>;\n email: (errorMessage?: string) => StringValidator & StandardSchemaV1<string>;\n enum: {\n <const T extends readonly (string | number | boolean)[]>(\n values: T,\n errorMessage?: string,\n ): ScalarValidator & StandardSchemaV1<T[number]>;\n <const T extends Record<string, string | number>>(\n values: T,\n errorMessage?: string,\n ): ScalarValidator & StandardSchemaV1<T[keyof T]>;\n };\n number: (errorMessage?: string) => NumberValidator & StandardSchemaV1<number>;\n numeric: (errorMessage?: string) => NumericValidator & StandardSchemaV1<number>;\n int: (errorMessage?: string) => IntValidator & StandardSchemaV1<number>;\n float: (errorMessage?: string) => FloatValidator & StandardSchemaV1<number>;\n boolean: (errorMessage?: string) => BooleanValidator & StandardSchemaV1<boolean>;\n scalar: (errorMessage?: string) => ScalarValidator & StandardSchemaV1<string | number | boolean>;\n union: <T extends BaseValidator[]>(\n validators: T,\n errorMessage?: string,\n ) => StandardSchemaV1<Infer.Input<T[number]>, Infer.Output<T[number]>> & UnionValidator;\n discriminatedUnion: <K extends string, Branches extends ReadonlyArray<ObjectValidator<any>>>(\n discriminator: K,\n validators: Branches,\n ) => DiscriminatedUnionValidator<K, Branches> &\n StandardSchemaV1<Infer.Input<Branches[number]>, Infer.Output<Branches[number]>>;\n computed: <TResult = any>(\n callback: (data: any, context: SchemaContext) => TResult | Promise<TResult>,\n resultValidator?: BaseValidator,\n ) => ComputedValidator<TResult> & StandardSchemaV1<TResult>;\n managed: <TResult = any>(\n callback?: (context: SchemaContext) => TResult | Promise<TResult>,\n resultValidator?: BaseValidator,\n ) => ManagedValidator<TResult> & StandardSchemaV1<TResult>;\n validate: <T extends BaseValidator>(\n schema: T,\n data: unknown,\n options?: ValidateOptions,\n ) => Promise<TypedValidationResult<ValidatedOutput<T>>>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAa,IAAgB;;CAE3B;;CAGA,WAAW,IAAI,aAAa;;CAG5B,QAAiC,WAAc,iBAC7C,IAAI,eAAe,WAAW,YAAY;;CAK5C,SAAkC,WAAe,iBAC/C,IAAI,gBAAgB,aAAa,EAAE,IAAI,GAAG,YAAY;;;;;;;;CAaxD,QAAwC,YAAe,iBACrD,IAAI,eAAe,YAAY,YAAY;;CAQ7C,OAAO,iBACL,IAAI,cAAc,YAAY;;;;;;;;;CAUhC,UACE,GAAG,WACA,IAAI,iBAAoB,MAAM;;;;;;;;;CAUnC,aAAgB,MAAiC,iBAC/C,IAAI,oBAAuB,MAAM,YAAY;;;;;;;;;;;;;CAc/C,OAAgC,UAC9B,IAAI,cAAc,KAAK;;CAIzB;;CAGA,QAAQ,mBAA4B,iBAClC,IAAI,gBAAgB,YAAY,CAAC,CAAC,MAAM,iBAAiB;;;;;;;;;;;;;;CAgB3D,QAAQ,QAAa,iBACnB,MAAM,QAAQ,MAAM,IAChB,IAAI,gBAAgB,CAAC,CAAC,MAAM,QAAQ,YAAY,IAChD,IAAI,gBAAgB,CAAC,CAAC,KAAK,QAAQ,YAAY;;CAGrD,SAAS,iBACP,IAAI,gBAAgB,YAAY;;CAGlC,UAAU,iBACR,IAAI,iBAAiB,YAAY;;CAGnC,MAAM,iBACJ,IAAI,aAAa,YAAY;;CAG/B,QAAQ,iBACN,IAAI,eAAe,YAAY;;CAGjC,UAAU,iBACR,IAAI,iBAAiB,YAAY;;CAGnC,SAAS,iBACP,IAAI,gBAAgB,YAAY;;CAIlC,QAAmC,YAAe,iBAChD,IAAI,eAAe,CAAC,CAAC,MAAM,YAAY,YAAY;;;;;;;;;;;;;CAkBrD,qBACE,eACA,eAEA,IAAI,4BAA4B,eAAe,UAAU;;CAO3D,WACE,UACA,oBAEA,IAAI,kBAA2B,UAAU,eAAe;;CAI1D,UACE,UACA,oBAEA,IAAI,iBAA0B,UAAU,eAAe;;CAI/CA;AACZ"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
//#region ../../packages/seal/src/helpers/date-helpers.ts
|
|
2
|
-
/**
|
|
3
|
-
* Detect if value is a date value or field name
|
|
4
|
-
*
|
|
5
|
-
* Date values:
|
|
6
|
-
* - Date instance
|
|
7
|
-
* - Number (timestamp)
|
|
8
|
-
* - String with date separators (- or /)
|
|
9
|
-
*
|
|
10
|
-
* Field names:
|
|
11
|
-
* - Strings without - or /
|
|
12
|
-
*
|
|
13
|
-
* @param value - Value to check
|
|
14
|
-
* @returns true if it's a date value, false if it's a field name
|
|
15
|
-
*/
|
|
16
|
-
function isDateValue(value) {
|
|
17
|
-
if (value instanceof Date) return true;
|
|
18
|
-
const date = new Date(value);
|
|
19
|
-
return !isNaN(date.getTime());
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
//#endregion
|
|
23
|
-
export { isDateValue };
|
|
24
|
-
//# sourceMappingURL=date-helpers.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"date-helpers.mjs","names":[],"sources":["../../../../../../../../../../../packages/seal/src/helpers/date-helpers.ts"],"sourcesContent":["/**\n * Detect if value is a date value or field name\n *\n * Date values:\n * - Date instance\n * - Number (timestamp)\n * - String with date separators (- or /)\n *\n * Field names:\n * - Strings without - or /\n *\n * @param value - Value to check\n * @returns true if it's a date value, false if it's a field name\n */\nexport function isDateValue(value: any): boolean {\n if (value instanceof Date) return true;\n\n const date = new Date(value);\n\n return !isNaN(date.getTime());\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,SAAgB,YAAY,OAAqB;CAC/C,IAAI,iBAAiB,MAAM,OAAO;CAElC,MAAM,OAAO,IAAI,KAAK,KAAK;CAE3B,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC;AAC9B"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { get } from "../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/get.mjs";
|
|
2
|
-
import "../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/index.mjs";
|
|
3
|
-
|
|
4
|
-
//#region ../../packages/seal/src/helpers/get-field-value.ts
|
|
5
|
-
/**
|
|
6
|
-
* Get field value based on scope from rule options
|
|
7
|
-
*
|
|
8
|
-
* This utility extracts a field value from either the global context or sibling context
|
|
9
|
-
* based on the `scope` option in the rule's context.
|
|
10
|
-
*
|
|
11
|
-
* @param rule - The contextual schema rule containing options with:
|
|
12
|
-
* - `field` (or custom fieldKey): The field name to extract
|
|
13
|
-
* - `scope` (optional): Either "global" (default) or "sibling"
|
|
14
|
-
* @param context - The schema validation context containing allValues and parent
|
|
15
|
-
* @param fieldKey - The key in rule.context.options that contains the field name (defaults to "field")
|
|
16
|
-
*
|
|
17
|
-
* @returns The value of the specified field from the appropriate source
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* // In a validation rule with scope support:
|
|
21
|
-
* async validate(value: any, context) {
|
|
22
|
-
* const otherFieldValue = getFieldValue(this, context);
|
|
23
|
-
* // Extracts from context.allValues if scope is "global"
|
|
24
|
-
* // Extracts from context.parent if scope is "sibling"
|
|
25
|
-
* }
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* // Using a custom field key:
|
|
29
|
-
* async validate(value: any, context) {
|
|
30
|
-
* const compareValue = getFieldValue(this, context, "compareField");
|
|
31
|
-
* // Looks for rule.context.options.compareField instead of .field
|
|
32
|
-
* }
|
|
33
|
-
*
|
|
34
|
-
* @remarks
|
|
35
|
-
* - **Global scope** (`scope: "global"`): Searches the entire input data (context.allValues)
|
|
36
|
-
* - **Sibling scope** (`scope: "sibling"`): Searches only within the parent object (context.parent)
|
|
37
|
-
* - Uses `@mongez/reinforcements.get()` to support nested paths (e.g., "user.email")
|
|
38
|
-
*/
|
|
39
|
-
function getFieldValue(rule, context, fieldKey = "field") {
|
|
40
|
-
const field = rule.context.options[fieldKey];
|
|
41
|
-
return get((rule.context.options.scope || "global") === "sibling" ? context.parent : context.allValues, field);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
//#endregion
|
|
45
|
-
export { getFieldValue };
|
|
46
|
-
//# sourceMappingURL=get-field-value.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-field-value.mjs","names":[],"sources":["../../../../../../../../../../../packages/seal/src/helpers/get-field-value.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\nimport type { ContextualSchemaRule, SchemaContext } from \"../types\";\n\n/**\n * Get field value based on scope from rule options\n *\n * This utility extracts a field value from either the global context or sibling context\n * based on the `scope` option in the rule's context.\n *\n * @param rule - The contextual schema rule containing options with:\n * - `field` (or custom fieldKey): The field name to extract\n * - `scope` (optional): Either \"global\" (default) or \"sibling\"\n * @param context - The schema validation context containing allValues and parent\n * @param fieldKey - The key in rule.context.options that contains the field name (defaults to \"field\")\n *\n * @returns The value of the specified field from the appropriate source\n *\n * @example\n * // In a validation rule with scope support:\n * async validate(value: any, context) {\n * const otherFieldValue = getFieldValue(this, context);\n * // Extracts from context.allValues if scope is \"global\"\n * // Extracts from context.parent if scope is \"sibling\"\n * }\n *\n * @example\n * // Using a custom field key:\n * async validate(value: any, context) {\n * const compareValue = getFieldValue(this, context, \"compareField\");\n * // Looks for rule.context.options.compareField instead of .field\n * }\n *\n * @remarks\n * - **Global scope** (`scope: \"global\"`): Searches the entire input data (context.allValues)\n * - **Sibling scope** (`scope: \"sibling\"`): Searches only within the parent object (context.parent)\n * - Uses `@mongez/reinforcements.get()` to support nested paths (e.g., \"user.email\")\n */\nexport function getFieldValue(\n rule: ContextualSchemaRule,\n context: SchemaContext,\n fieldKey = \"field\",\n) {\n const field = rule.context.options[fieldKey];\n const scope = rule.context.options.scope || \"global\";\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n return get(source, field);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,cACd,MACA,SACA,WAAW,SACX;CACA,MAAM,QAAQ,KAAK,QAAQ,QAAQ;CAGnC,OAAO,KAFO,KAAK,QAAQ,QAAQ,SAAS,cACnB,YAAY,QAAQ,SAAS,QAAQ,WAC3C,KAAK;AAC1B"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { isEmpty, isObject } from "../../../../node_modules/.pnpm/@mongez_supportive-is@3.0.0/node_modules/@mongez/supportive-is/esm/index.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../../packages/seal/src/helpers/is-empty-value.ts
|
|
4
|
-
function isEmptyValue(value) {
|
|
5
|
-
return isEmpty(value) && !isObject(value);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
//#endregion
|
|
9
|
-
export { isEmptyValue };
|
|
10
|
-
//# sourceMappingURL=is-empty-value.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-empty-value.mjs","names":[],"sources":["../../../../../../../../../../../packages/seal/src/helpers/is-empty-value.ts"],"sourcesContent":["import { isEmpty, isObject } from \"@mongez/supportive-is\";\n\nexport function isEmptyValue(value: any) {\n return isEmpty(value) && !isObject(value);\n}\n"],"mappings":";;;AAEA,SAAgB,aAAa,OAAY;CACvC,OAAO,QAAQ,KAAK,KAAK,CAAC,SAAS,KAAK;AAC1C"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
//#region ../../packages/seal/src/helpers/path-helpers.ts
|
|
2
|
-
/**
|
|
3
|
-
* Set the key path for nested validation
|
|
4
|
-
*/
|
|
5
|
-
const setKeyPath = (path, key) => {
|
|
6
|
-
if (!path) return key;
|
|
7
|
-
return `${path}.${key}`;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
//#endregion
|
|
11
|
-
export { setKeyPath };
|
|
12
|
-
//# sourceMappingURL=path-helpers.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"path-helpers.mjs","names":[],"sources":["../../../../../../../../../../../packages/seal/src/helpers/path-helpers.ts"],"sourcesContent":["/**\n * Set the key path for nested validation\n */\nexport const setKeyPath = (path: string, key: string): string => {\n if (!path) return key;\n return `${path}.${key}`;\n};\n"],"mappings":";;;;AAGA,MAAa,cAAc,MAAc,QAAwB;CAC/D,IAAI,CAAC,MAAM,OAAO;CAClB,OAAO,GAAG,KAAK,GAAG;AACpB"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { getSealConfig } from "../config.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../../packages/seal/src/helpers/validation-helpers.ts
|
|
4
|
-
const VALID_RULE = { isValid: true };
|
|
5
|
-
/**
|
|
6
|
-
* Resolve a single attribute value through the full translation priority chain:
|
|
7
|
-
* 1. attributesList[key] — developer direct text override (highest priority)
|
|
8
|
-
* 2. translatedAttributes[key] — developer explicit translation key
|
|
9
|
-
* 3. translator(rawValue) — auto-translate the raw value (fallback)
|
|
10
|
-
*
|
|
11
|
-
* Use this in rule bodies when you need per-item translation
|
|
12
|
-
* (e.g. translating each enum value before joining them).
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* // Translate each enum value individually then join
|
|
16
|
-
* const enumList = enumValues
|
|
17
|
-
* .map(v => resolveTranslation(String(v), String(v), this, context))
|
|
18
|
-
* .join(", ");
|
|
19
|
-
* this.context.translationParams.enumList = enumList;
|
|
20
|
-
*/
|
|
21
|
-
const resolveTranslation = ({ key, rawValue, rule, context }) => {
|
|
22
|
-
const translator = getSealConfig().translateAttribute;
|
|
23
|
-
const direct = rule.context.attributesList?.[key];
|
|
24
|
-
if (direct && typeof direct === "string") return direct;
|
|
25
|
-
if (!translator) return String(rawValue ?? key);
|
|
26
|
-
const transKey = rule.context.translatedAttributes?.[key];
|
|
27
|
-
if (transKey) return translator({
|
|
28
|
-
attribute: transKey,
|
|
29
|
-
context,
|
|
30
|
-
rule
|
|
31
|
-
});
|
|
32
|
-
return translator({
|
|
33
|
-
attribute: String(rawValue ?? key),
|
|
34
|
-
context,
|
|
35
|
-
rule
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
const resolveAttribute = resolveTranslation;
|
|
39
|
-
const invalidRule = (rule, context) => {
|
|
40
|
-
const translatableWithInput = {
|
|
41
|
-
input: context.key || "schema",
|
|
42
|
-
...rule.context.translatableParams
|
|
43
|
-
};
|
|
44
|
-
const resolvedParams = Object.fromEntries(Object.entries(translatableWithInput).map(([key, rawValue]) => [key, resolveAttribute({
|
|
45
|
-
key,
|
|
46
|
-
rawValue,
|
|
47
|
-
rule,
|
|
48
|
-
context
|
|
49
|
-
})]));
|
|
50
|
-
const input = resolveAttribute({
|
|
51
|
-
key: "input",
|
|
52
|
-
rawValue: translatableWithInput.input ?? "schema",
|
|
53
|
-
rule,
|
|
54
|
-
context
|
|
55
|
-
});
|
|
56
|
-
const attributes = {
|
|
57
|
-
path: context.path,
|
|
58
|
-
key: context.key,
|
|
59
|
-
value: context.configurations?.redactValue ?? context.value,
|
|
60
|
-
...rule.context.translationParams,
|
|
61
|
-
...resolvedParams,
|
|
62
|
-
input
|
|
63
|
-
};
|
|
64
|
-
return {
|
|
65
|
-
isValid: false,
|
|
66
|
-
error: (rule.context.errorMessage || rule.errorMessage || context.translateRule?.({
|
|
67
|
-
rule,
|
|
68
|
-
context,
|
|
69
|
-
attributes
|
|
70
|
-
}) || rule.defaultErrorMessage).replace(/:([a-zA-Z_]+)/g, (match, key) => key in attributes ? String(attributes[key]) : match),
|
|
71
|
-
input: attributes.input,
|
|
72
|
-
path: context.path
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
//#endregion
|
|
77
|
-
export { VALID_RULE, invalidRule, resolveTranslation };
|
|
78
|
-
//# sourceMappingURL=validation-helpers.mjs.map
|