@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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation-helpers.mjs","names":[],"sources":["../../../../../../../../../../../packages/seal/src/helpers/validation-helpers.ts"],"sourcesContent":["import { getSealConfig } from \"../config\";\nimport type { ContextualSchemaRule, RuleResult, RuleTranslation, SchemaContext } from \"../types\";\n\nexport const VALID_RULE: RuleResult = {\n isValid: true,\n};\n/**\n * Resolve a single attribute value through the full translation priority chain:\n * 1. attributesList[key] — developer direct text override (highest priority)\n * 2. translatedAttributes[key] — developer explicit translation key\n * 3. translator(rawValue) — auto-translate the raw value (fallback)\n *\n * Use this in rule bodies when you need per-item translation\n * (e.g. translating each enum value before joining them).\n *\n * @example\n * // Translate each enum value individually then join\n * const enumList = enumValues\n * .map(v => resolveTranslation(String(v), String(v), this, context))\n * .join(\", \");\n * this.context.translationParams.enumList = enumList;\n */\nexport const resolveTranslation = ({\n key,\n rawValue,\n rule,\n context,\n}: {\n key: string;\n rawValue: any;\n rule: ContextualSchemaRule;\n context: SchemaContext;\n}): string => {\n const translator = getSealConfig().translateAttribute;\n\n // 1. Direct text override wins\n const direct = rule.context.attributesList?.[key];\n if (direct && typeof direct === \"string\") return direct;\n\n if (!translator) return String(rawValue ?? key);\n\n // 2. Explicit translation key\n const transKey = rule.context.translatedAttributes?.[key];\n if (transKey) return translator({ attribute: transKey, context, rule });\n\n // 3. Auto-translate the raw value (fallback)\n return translator({ attribute: String(rawValue ?? key), context, rule });\n};\n\n// Internal alias — invalidRule uses the same function without re-importing config\nconst resolveAttribute = resolveTranslation;\n\nexport const invalidRule = (rule: ContextualSchemaRule, context: SchemaContext): RuleResult => {\n // `input` is always translatable — rules may add more (e.g., field references in sameAs)\n // Rule-defined translatableParams override the default input if the key matches\n const translatableWithInput: Record<string, string> = {\n // Fall back to \"schema\" when validating at the root level (no key)\n input: context.key || \"schema\",\n ...rule.context.translatableParams,\n };\n\n // Resolve all translatable params through the full priority chain\n const resolvedParams = Object.fromEntries(\n Object.entries(translatableWithInput).map(([key, rawValue]) => [\n key,\n resolveAttribute({ key, rawValue, rule, context }),\n ]),\n );\n const input = resolveAttribute({\n key: \"input\",\n rawValue: translatableWithInput.input ?? \"schema\",\n rule,\n context,\n });\n\n const attributes: RuleTranslation[\"attributes\"] = {\n path: context.path,\n key: context.key,\n // A per-call `redactValue` stands in for the submitted input, so neither a\n // translation nor a custom message can echo it through `:value`\n value: context.configurations?.redactValue ?? context.value,\n // Raw placeholders (:enumList, :min, :max, etc.) — no translation\n ...rule.context.translationParams,\n // Translated placeholders (:input, :field, etc.) — override raws if key collides\n ...resolvedParams,\n // Satisfy TypeScript's required field (always present via resolvedParams)\n input,\n };\n\n const rawError =\n rule.context.errorMessage ||\n rule.errorMessage ||\n context.translateRule?.({ rule, context, attributes }) ||\n rule.defaultErrorMessage!;\n\n // Fallback interpolation: replace :placeholder patterns from attributes\n // This kicks in when translateRule is absent or returns \"\" (not configured)\n const error = rawError.replace(/:([a-zA-Z_]+)/g, (match, key) =>\n key in attributes ? String(attributes[key as keyof typeof attributes]) : match,\n );\n\n return {\n isValid: false,\n error,\n input: attributes.input, // use resolved input, not raw context.key (may be \"\")\n path: context.path,\n };\n};\n"],"mappings":";;;AAGA,MAAa,aAAyB,EACpC,SAAS,KACX;;;;;;;;;;;;;;;;;AAiBA,MAAa,sBAAsB,EACjC,KACA,UACA,MACA,cAMY;CACZ,MAAM,aAAa,cAAc,CAAC,CAAC;CAGnC,MAAM,SAAS,KAAK,QAAQ,iBAAiB;CAC7C,IAAI,UAAU,OAAO,WAAW,UAAU,OAAO;CAEjD,IAAI,CAAC,YAAY,OAAO,OAAO,YAAY,GAAG;CAG9C,MAAM,WAAW,KAAK,QAAQ,uBAAuB;CACrD,IAAI,UAAU,OAAO,WAAW;EAAE,WAAW;EAAU;EAAS;CAAK,CAAC;CAGtE,OAAO,WAAW;EAAE,WAAW,OAAO,YAAY,GAAG;EAAG;EAAS;CAAK,CAAC;AACzE;AAGA,MAAM,mBAAmB;AAEzB,MAAa,eAAe,MAA4B,YAAuC;CAG7F,MAAM,wBAAgD;EAEpD,OAAO,QAAQ,OAAO;EACtB,GAAG,KAAK,QAAQ;CAClB;CAGA,MAAM,iBAAiB,OAAO,YAC5B,OAAO,QAAQ,qBAAqB,CAAC,CAAC,KAAK,CAAC,KAAK,cAAc,CAC7D,KACA,iBAAiB;EAAE;EAAK;EAAU;EAAM;CAAQ,CAAC,CACnD,CAAC,CACH;CACA,MAAM,QAAQ,iBAAiB;EAC7B,KAAK;EACL,UAAU,sBAAsB,SAAS;EACzC;EACA;CACF,CAAC;CAED,MAAM,aAA4C;EAChD,MAAM,QAAQ;EACd,KAAK,QAAQ;EAGb,OAAO,QAAQ,gBAAgB,eAAe,QAAQ;EAEtD,GAAG,KAAK,QAAQ;EAEhB,GAAG;EAEH;CACF;CAcA,OAAO;EACL,SAAS;EACT,QAbA,KAAK,QAAQ,gBACb,KAAK,gBACL,QAAQ,gBAAgB;GAAE;GAAM;GAAS;EAAW,CAAC,KACrD,KAAK,oBAIe,CAAC,QAAQ,mBAAmB,OAAO,QACvD,OAAO,aAAa,OAAO,WAAW,IAA+B,IAAI,KAKrE;EACJ,OAAO,WAAW;EAClB,MAAM,QAAQ;CAChB;AACF"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { applyNullable, getRuleOptions, wrapNullableStrict } from "./standard-schema/json-schema.mjs";
|
|
2
|
-
import { getSealConfig } from "./config.mjs";
|
|
3
|
-
import { validate } from "./factory/validate.mjs";
|
|
4
|
-
import { VALID_RULE, invalidRule, resolveTranslation } from "./helpers/validation-helpers.mjs";
|
|
5
|
-
import { isDateValue } from "./helpers/date-helpers.mjs";
|
|
6
|
-
import { getFieldValue } from "./helpers/get-field-value.mjs";
|
|
7
|
-
import { setKeyPath } from "./helpers/path-helpers.mjs";
|
|
8
|
-
import "./helpers/index.mjs";
|
|
9
|
-
import { presentRule, requiredRule } from "./rules/core/required.mjs";
|
|
10
|
-
import { mapToStandardResult } from "./standard-schema/map-result.mjs";
|
|
11
|
-
import { BaseValidator } from "./validators/base-validator.mjs";
|
|
12
|
-
import { AnyValidator } from "./validators/any-validator.mjs";
|
|
13
|
-
import { flipArrayMutator, sortArrayMutator, uniqueArrayMutator } from "./mutators/array-mutators.mjs";
|
|
14
|
-
import { booleanCoerceMutator, formBooleanMutator } from "./mutators/boolean-mutators.mjs";
|
|
15
|
-
import { addDaysMutator, addHoursMutator, addMonthsMutator, addYearsMutator, dateMutator, toEndOfDayMutator, toEndOfMonthMutator, toEndOfYearMutator, toStartOfDayMutator, toStartOfMonthMutator, toStartOfYearMutator, toUTCMutator } from "./mutators/date-mutators.mjs";
|
|
16
|
-
import { absMutator, ceilMutator, floorMutator, numberMutator, numericMutator, roundMutator, toFixedMutator } from "./mutators/number-mutators.mjs";
|
|
17
|
-
import { objectTrimMutator, stripUnknownMutator } from "./mutators/object-mutators.mjs";
|
|
18
|
-
import { stringMutator } from "./mutators/scalar-mutators.mjs";
|
|
19
|
-
import { alphaOnlyMutator, alphanumericOnlyMutator, appendMutator, base64DecodeMutator, base64EncodeMutator, camelCaseMutator, capitalizeMutator, htmlEscapeMutator, kebabCaseMutator, lowercaseMutator, ltrimMutator, maskMutator, padEndMutator, padStartMutator, pascalCaseMutator, prependMutator, removeNumbersMutator, removeSpecialCharactersMutator, repeatMutator, replaceAllMutator, replaceMutator, reverseMutator, rtrimMutator, slugMutator, snakeCaseMutator, stringifyMutator, stripTagsMutator, titleCaseMutator, trimMultipleWhitespaceMutator, trimMutator, truncateMutator, unescapeHtmlMutator, uppercaseMutator, urlDecodeMutator, urlEncodeMutator } from "./mutators/string-mutators.mjs";
|
|
20
|
-
import "./mutators/index.mjs";
|
|
21
|
-
import { equalRule } from "./rules/core/equal.mjs";
|
|
22
|
-
import { forbiddenRule } from "./rules/core/forbidden.mjs";
|
|
23
|
-
import { unionRule } from "./rules/core/union.mjs";
|
|
24
|
-
import { whenRule } from "./rules/core/when.mjs";
|
|
25
|
-
import { alphaNumericRule, alphaRule, isNumericRule } from "./rules/string/alpha.mjs";
|
|
26
|
-
import { isCreditCardRule } from "./rules/string/credit-card.mjs";
|
|
27
|
-
import { emailRule } from "./rules/string/email.mjs";
|
|
28
|
-
import { cuidRule, nanoidRule, ulidRule, uuidRule } from "./rules/string/id-formats.mjs";
|
|
29
|
-
import { ip4Rule, ip6Rule, ipRule, isIP, isIPv4, isIPv6 } from "./rules/string/ip.mjs";
|
|
30
|
-
import { patternRule } from "./rules/string/pattern.mjs";
|
|
31
|
-
import { containsRule, endsWithRule, notContainsRule, startsWithRule } from "./rules/string/string-comparison.mjs";
|
|
32
|
-
import { strongPasswordRule } from "./rules/string/strong-password-rule.mjs";
|
|
33
|
-
import { urlRule } from "./rules/string/url.mjs";
|
|
34
|
-
import { withoutWhitespaceRule } from "./rules/string/without-whitespace.mjs";
|
|
35
|
-
import { betweenNumbersRule, evenRule, greaterThanRule, lessThanRule, maxRule, minRule, moduloRule, negativeRule, oddRule, positiveRule } from "./rules/number/number-rules.mjs";
|
|
36
|
-
import { betweenLengthRule, lengthRule, maxLengthRule, maxWordsRule, minLengthRule, minWordsRule, wordsRule } from "./rules/length/length-rules.mjs";
|
|
37
|
-
import { sortedArrayRule, uniqueArrayRule } from "./rules/array/array-rules.mjs";
|
|
38
|
-
import { WEEK_DAYS } from "./types/date-types.mjs";
|
|
39
|
-
import { ageRule, beforeHourRule, beforeMinuteRule, beforeTodayRule, betweenHoursRule, betweenMinutesRule, dateRule, fromHourRule, fromMinuteRule, fromTodayRule, maxAgeRule, maxDateRule, minAgeRule, minDateRule, weekDayRule } from "./rules/date/date.mjs";
|
|
40
|
-
import { afterTodayRule, betweenDatesRule, futureRule, pastRule, todayRule } from "./rules/date/date-comparison-rules.mjs";
|
|
41
|
-
import { businessDayRule, weekdaysRule, weekendRule } from "./rules/date/date-day-rules.mjs";
|
|
42
|
-
import { afterFieldRule, beforeFieldRule, sameAsFieldDateRule } from "./rules/date/date-field-comparison-rules.mjs";
|
|
43
|
-
import { betweenDaysRule, betweenMonthsRule, betweenTimesRule, betweenYearsRule, maxDayRule, maxMonthRule, maxYearRule, minDayRule, minMonthRule, minYearRule, monthRule, quarterRule, yearRule } from "./rules/date/date-period-rules.mjs";
|
|
44
|
-
import { withinDaysRule, withinFutureDaysRule, withinPastDaysRule } from "./rules/date/date-relative-rules.mjs";
|
|
45
|
-
import { betweenAgeRule, birthdayRule, leapYearRule } from "./rules/date/date-special-rules.mjs";
|
|
46
|
-
import { colorRule, darkColorRule, hexColorRule, hslColorRule, lightColorRule, rgbColorRule, rgbaColorRule } from "./rules/color/color-rules.mjs";
|
|
47
|
-
import { requiredIfAllEmptyRule, requiredIfAllNotEmptyRule, requiredIfAnyEmptyRule, requiredIfAnyNotEmptyRule, requiredIfEmptyRule, requiredIfInRule, requiredIfNotEmptyRule, requiredIfNotInRule, requiredIfRule } from "./rules/conditional/required-if-rules.mjs";
|
|
48
|
-
import { requiredUnlessRule } from "./rules/conditional/required-unless-rules.mjs";
|
|
49
|
-
import { requiredWhenRule } from "./rules/conditional/required-when-rule.mjs";
|
|
50
|
-
import { requiredWithAllRule, requiredWithAnyRule, requiredWithRule } from "./rules/conditional/required-with-rules.mjs";
|
|
51
|
-
import { requiredWithoutAllRule, requiredWithoutAnyRule, requiredWithoutRule } from "./rules/conditional/required-without-rules.mjs";
|
|
52
|
-
import { presentIfEmptyRule, presentIfInRule, presentIfNotEmptyRule, presentIfNotInRule, presentIfRule } from "./rules/conditional/present-if-rules.mjs";
|
|
53
|
-
import { presentUnlessRule } from "./rules/conditional/present-unless-rules.mjs";
|
|
54
|
-
import { presentWithAllRule, presentWithAnyRule, presentWithRule } from "./rules/conditional/present-with-rules.mjs";
|
|
55
|
-
import { presentWithoutAllRule, presentWithoutAnyRule, presentWithoutRule } from "./rules/conditional/present-without-rules.mjs";
|
|
56
|
-
import { forbiddenIfEmptyRule, forbiddenIfInRule, forbiddenIfNotEmptyRule, forbiddenIfNotInRule, forbiddenIfNotRule, forbiddenIfRule } from "./rules/conditional/forbidden-if-rules.mjs";
|
|
57
|
-
import { allowedValuesRule, enumRule, inRule, notAllowedValuesRule } from "./rules/common/enum.mjs";
|
|
58
|
-
import { equalsFieldRule, notEqualsFieldRule } from "./rules/common/equals-field-rules.mjs";
|
|
59
|
-
import { instanceofRule } from "./rules/common/instanceof.mjs";
|
|
60
|
-
import { literalRule } from "./rules/common/literal.mjs";
|
|
61
|
-
import { arrayRule, booleanRule, floatRule, intRule, numberRule, objectRule, plainObjectRule, stringRule } from "./rules/common/type-rules.mjs";
|
|
62
|
-
import { unknownKeyRule } from "./rules/common/unknown-key.mjs";
|
|
63
|
-
import "./rules/index.mjs";
|
|
64
|
-
import { ArrayValidator } from "./validators/array-validator.mjs";
|
|
65
|
-
import { PrimitiveValidator } from "./validators/primitive-validator.mjs";
|
|
66
|
-
import { BooleanValidator } from "./validators/boolean-validator.mjs";
|
|
67
|
-
import { ComputedValidator } from "./validators/computed-validator.mjs";
|
|
68
|
-
import { DateValidator } from "./validators/date-validator.mjs";
|
|
69
|
-
import { LiteralValidator } from "./validators/literal-validator.mjs";
|
|
70
|
-
import { DiscriminatedUnionValidator } from "./validators/discriminated-union-validator.mjs";
|
|
71
|
-
import { NumberValidator } from "./validators/number-validator.mjs";
|
|
72
|
-
import { FloatValidator } from "./validators/float-validator.mjs";
|
|
73
|
-
import { InstanceOfValidator } from "./validators/instanceof-validator.mjs";
|
|
74
|
-
import { IntValidator } from "./validators/int-validator.mjs";
|
|
75
|
-
import { LazyValidator } from "./validators/lazy-validator.mjs";
|
|
76
|
-
import { ManagedValidator } from "./validators/managed-validator.mjs";
|
|
77
|
-
import { NumericValidator } from "./validators/numeric-validator.mjs";
|
|
78
|
-
import { ObjectValidator } from "./validators/object-validator.mjs";
|
|
79
|
-
import { RecordValidator } from "./validators/record-validator.mjs";
|
|
80
|
-
import { ScalarValidator } from "./validators/scalar-validator.mjs";
|
|
81
|
-
import { StringValidator } from "./validators/string-validator.mjs";
|
|
82
|
-
import { TupleValidator } from "./validators/tuple-validator.mjs";
|
|
83
|
-
import { UnionValidator } from "./validators/union-validator.mjs";
|
|
84
|
-
import "./validators/index.mjs";
|
|
85
|
-
import { v } from "./factory/validators.mjs";
|
|
86
|
-
import "./factory/index.mjs";
|
|
87
|
-
|
|
88
|
-
export { };
|
|
@@ -1,32 +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/mutators/array-mutators.ts
|
|
5
|
-
/** Reverse array order */
|
|
6
|
-
const flipArrayMutator = async (value) => {
|
|
7
|
-
return value.reverse();
|
|
8
|
-
};
|
|
9
|
-
/** Sort array */
|
|
10
|
-
const sortArrayMutator = async (value, context) => {
|
|
11
|
-
if (!Array.isArray(value)) return value;
|
|
12
|
-
const sortDirection = context?.options.direction ?? "asc";
|
|
13
|
-
const sortByKey = context?.options.key ?? null;
|
|
14
|
-
return value.sort((a, b) => {
|
|
15
|
-
if (sortByKey) {
|
|
16
|
-
const aValue = get(a, sortByKey);
|
|
17
|
-
const bValue = get(b, sortByKey);
|
|
18
|
-
if (sortDirection === "asc") return aValue - bValue;
|
|
19
|
-
return bValue - aValue;
|
|
20
|
-
}
|
|
21
|
-
if (sortDirection === "asc") return a - b;
|
|
22
|
-
return b - a;
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
/** Make array have only unique values */
|
|
26
|
-
const uniqueArrayMutator = async (value) => {
|
|
27
|
-
return [...new Set(value)];
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
//#endregion
|
|
31
|
-
export { flipArrayMutator, sortArrayMutator, uniqueArrayMutator };
|
|
32
|
-
//# sourceMappingURL=array-mutators.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array-mutators.mjs","names":[],"sources":["../../../../../../../../../../../packages/seal/src/mutators/array-mutators.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\nimport { isEmptyValue } from \"../helpers/is-empty-value\";\nimport type { Mutator } from \"../types\";\n\n/** Reverse array order */\nexport const flipArrayMutator: Mutator = async (value) => {\n return value.reverse();\n};\n\n/** Reverse array order (alias) */\nexport const reverseArrayMutator: Mutator = async (value) => {\n return value.reverse();\n};\n\n/** Sort array */\nexport const sortArrayMutator: Mutator = async (value, context) => {\n if (!Array.isArray(value)) return value;\n\n const sortDirection = context?.options.direction ?? \"asc\";\n const sortByKey = context?.options.key ?? null;\n\n return value.sort((a: any, b: any) => {\n if (sortByKey) {\n const aValue = get(a, sortByKey);\n const bValue = get(b, sortByKey);\n\n if (sortDirection === \"asc\") {\n return aValue - bValue;\n }\n return bValue - aValue;\n }\n\n if (sortDirection === \"asc\") {\n return a - b;\n }\n return b - a;\n });\n};\n\n/** Make array have only unique values */\nexport const uniqueArrayMutator: Mutator = async (value) => {\n return [...new Set(value)];\n};\n\n/** Remove empty elements from array */\nexport const removeEmptyArrayElementsMutator: Mutator = async (value) => {\n return value.filter((item: any) => !isEmptyValue(item));\n};\n"],"mappings":";;;;;AAKA,MAAa,mBAA4B,OAAO,UAAU;CACxD,OAAO,MAAM,QAAQ;AACvB;;AAQA,MAAa,mBAA4B,OAAO,OAAO,YAAY;CACjE,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG,OAAO;CAElC,MAAM,gBAAgB,SAAS,QAAQ,aAAa;CACpD,MAAM,YAAY,SAAS,QAAQ,OAAO;CAE1C,OAAO,MAAM,MAAM,GAAQ,MAAW;EACpC,IAAI,WAAW;GACb,MAAM,SAAS,IAAI,GAAG,SAAS;GAC/B,MAAM,SAAS,IAAI,GAAG,SAAS;GAE/B,IAAI,kBAAkB,OACpB,OAAO,SAAS;GAElB,OAAO,SAAS;EAClB;EAEA,IAAI,kBAAkB,OACpB,OAAO,IAAI;EAEb,OAAO,IAAI;CACb,CAAC;AACH;;AAGA,MAAa,qBAA8B,OAAO,UAAU;CAC1D,OAAO,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC;AAC3B"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { ACCEPTED_VALUES } from "../rules/scalar/accepted-rule.mjs";
|
|
2
|
-
import { DECLINED_VALUES } from "../rules/scalar/declined-rule.mjs";
|
|
3
|
-
|
|
4
|
-
//#region ../../packages/seal/src/mutators/boolean-mutators.ts
|
|
5
|
-
/**
|
|
6
|
-
* Coerce a query-string-shaped boolean into a real boolean.
|
|
7
|
-
*
|
|
8
|
-
* Converts exactly: `"true"` / `"1"` / `1` → `true`, `"false"` / `"0"` / `0` → `false`.
|
|
9
|
-
* Case-sensitive, no trimming. Any other value (`"yes"`, `"on"`, `"TRUE"`, `""`,
|
|
10
|
-
* `2`, `null`, etc.) passes through unchanged so the boolean type rule rejects it.
|
|
11
|
-
*/
|
|
12
|
-
const booleanCoerceMutator = async (value) => {
|
|
13
|
-
if (value === "true" || value === "1" || value === 1) return true;
|
|
14
|
-
if (value === "false" || value === "0" || value === 0) return false;
|
|
15
|
-
return value;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Parse form-shaped boolean values into a real boolean, ahead of the type
|
|
19
|
-
* rule.
|
|
20
|
-
*
|
|
21
|
-
* Opted into by calling any `accepted*`/`declined*` method on
|
|
22
|
-
* `v.boolean()` (see `BooleanValidator`'s `withFormBooleanMutator`). Converts
|
|
23
|
-
* every value in `ACCEPTED_VALUES` (`1`, `"1"`, `true`, `"true"`, `"yes"`,
|
|
24
|
-
* `"y"`, `"on"`, `"Yes"`, `"Y"`, `"On"`) to `true`, and every value in
|
|
25
|
-
* `DECLINED_VALUES` (`0`, `"0"`, `false`, `"false"`, `"no"`, `"n"`, `"off"`,
|
|
26
|
-
* `"No"`, `"N"`, `"Off"`) to `false`. Any other value passes through
|
|
27
|
-
* unchanged so the boolean type rule still rejects it.
|
|
28
|
-
*
|
|
29
|
-
* Named (not anonymous) so callers can detect whether it has already been
|
|
30
|
-
* added — see the idempotence check in `BooleanValidator`.
|
|
31
|
-
*/
|
|
32
|
-
const formBooleanMutator = async (value) => {
|
|
33
|
-
if (ACCEPTED_VALUES.includes(value)) return true;
|
|
34
|
-
if (DECLINED_VALUES.includes(value)) return false;
|
|
35
|
-
return value;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
//#endregion
|
|
39
|
-
export { booleanCoerceMutator, formBooleanMutator };
|
|
40
|
-
//# sourceMappingURL=boolean-mutators.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"boolean-mutators.mjs","names":[],"sources":["../../../../../../../../../../../packages/seal/src/mutators/boolean-mutators.ts"],"sourcesContent":["import { ACCEPTED_VALUES } from \"../rules/scalar/accepted-rule\";\nimport { DECLINED_VALUES } from \"../rules/scalar/declined-rule\";\nimport type { Mutator } from \"../types\";\n\n/**\n * Coerce a query-string-shaped boolean into a real boolean.\n *\n * Converts exactly: `\"true\"` / `\"1\"` / `1` → `true`, `\"false\"` / `\"0\"` / `0` → `false`.\n * Case-sensitive, no trimming. Any other value (`\"yes\"`, `\"on\"`, `\"TRUE\"`, `\"\"`,\n * `2`, `null`, etc.) passes through unchanged so the boolean type rule rejects it.\n */\nexport const booleanCoerceMutator: Mutator = async (value) => {\n if (value === \"true\" || value === \"1\" || value === 1) {\n return true;\n }\n\n if (value === \"false\" || value === \"0\" || value === 0) {\n return false;\n }\n\n return value;\n};\n\n/**\n * Parse form-shaped boolean values into a real boolean, ahead of the type\n * rule.\n *\n * Opted into by calling any `accepted*`/`declined*` method on\n * `v.boolean()` (see `BooleanValidator`'s `withFormBooleanMutator`). Converts\n * every value in `ACCEPTED_VALUES` (`1`, `\"1\"`, `true`, `\"true\"`, `\"yes\"`,\n * `\"y\"`, `\"on\"`, `\"Yes\"`, `\"Y\"`, `\"On\"`) to `true`, and every value in\n * `DECLINED_VALUES` (`0`, `\"0\"`, `false`, `\"false\"`, `\"no\"`, `\"n\"`, `\"off\"`,\n * `\"No\"`, `\"N\"`, `\"Off\"`) to `false`. Any other value passes through\n * unchanged so the boolean type rule still rejects it.\n *\n * Named (not anonymous) so callers can detect whether it has already been\n * added — see the idempotence check in `BooleanValidator`.\n */\nexport const formBooleanMutator: Mutator = async (value) => {\n if (ACCEPTED_VALUES.includes(value)) {\n return true;\n }\n\n if (DECLINED_VALUES.includes(value)) {\n return false;\n }\n\n return value;\n};\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,uBAAgC,OAAO,UAAU;CAC5D,IAAI,UAAU,UAAU,UAAU,OAAO,UAAU,GACjD,OAAO;CAGT,IAAI,UAAU,WAAW,UAAU,OAAO,UAAU,GAClD,OAAO;CAGT,OAAO;AACT;;;;;;;;;;;;;;;;AAiBA,MAAa,qBAA8B,OAAO,UAAU;CAC1D,IAAI,gBAAgB,SAAS,KAAK,GAChC,OAAO;CAGT,IAAI,gBAAgB,SAAS,KAAK,GAChC,OAAO;CAGT,OAAO;AACT"}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { __toESM } from "../../../../_virtual/_rolldown/runtime.mjs";
|
|
2
|
-
import { require_dayjs_min } from "../../../../node_modules/.pnpm/dayjs@1.11.23/node_modules/dayjs/dayjs.min.mjs";
|
|
3
|
-
|
|
4
|
-
//#region ../../packages/seal/src/mutators/date-mutators.ts
|
|
5
|
-
var import_dayjs_min = /* @__PURE__ */ __toESM(require_dayjs_min(), 1);
|
|
6
|
-
/**
|
|
7
|
-
* Convert value to Date object
|
|
8
|
-
* Returns Invalid Date if value cannot be converted
|
|
9
|
-
*/
|
|
10
|
-
const dateMutator = async (value) => {
|
|
11
|
-
if (!value) return;
|
|
12
|
-
if (value instanceof Date) return value;
|
|
13
|
-
return new Date(value);
|
|
14
|
-
};
|
|
15
|
-
/** Convert date to start of day (00:00:00) */
|
|
16
|
-
const toStartOfDayMutator = async (value) => {
|
|
17
|
-
const date = new Date(value);
|
|
18
|
-
date.setHours(0, 0, 0, 0);
|
|
19
|
-
return date;
|
|
20
|
-
};
|
|
21
|
-
/** Convert date to end of day (23:59:59.999) */
|
|
22
|
-
const toEndOfDayMutator = async (value) => {
|
|
23
|
-
const date = new Date(value);
|
|
24
|
-
date.setHours(23, 59, 59, 999);
|
|
25
|
-
return date;
|
|
26
|
-
};
|
|
27
|
-
/** Add or subtract days from date */
|
|
28
|
-
const addDaysMutator = async (value, context) => {
|
|
29
|
-
const date = new Date(value);
|
|
30
|
-
const days = context?.options.days ?? 0;
|
|
31
|
-
date.setDate(date.getDate() + days);
|
|
32
|
-
return date;
|
|
33
|
-
};
|
|
34
|
-
/** Add or subtract months from date */
|
|
35
|
-
const addMonthsMutator = async (value, context) => {
|
|
36
|
-
const date = new Date(value);
|
|
37
|
-
const months = context?.options.months ?? 0;
|
|
38
|
-
date.setMonth(date.getMonth() + months);
|
|
39
|
-
return date;
|
|
40
|
-
};
|
|
41
|
-
/** Add or subtract years from date */
|
|
42
|
-
const addYearsMutator = async (value, context) => {
|
|
43
|
-
const date = new Date(value);
|
|
44
|
-
const years = context?.options.years ?? 0;
|
|
45
|
-
date.setFullYear(date.getFullYear() + years);
|
|
46
|
-
return date;
|
|
47
|
-
};
|
|
48
|
-
/** Add or subtract hours from date */
|
|
49
|
-
const addHoursMutator = async (value, context) => {
|
|
50
|
-
const date = new Date(value);
|
|
51
|
-
const hours = context?.options.hours ?? 0;
|
|
52
|
-
date.setHours(date.getHours() + hours);
|
|
53
|
-
return date;
|
|
54
|
-
};
|
|
55
|
-
/** Convert date to UTC */
|
|
56
|
-
const toUTCMutator = async (value) => {
|
|
57
|
-
const date = new Date(value);
|
|
58
|
-
return new Date(date.toUTCString());
|
|
59
|
-
};
|
|
60
|
-
/** Set to start of month */
|
|
61
|
-
const toStartOfMonthMutator = async (value) => {
|
|
62
|
-
const date = new Date(value);
|
|
63
|
-
date.setDate(1);
|
|
64
|
-
date.setHours(0, 0, 0, 0);
|
|
65
|
-
return date;
|
|
66
|
-
};
|
|
67
|
-
/** Set to end of month */
|
|
68
|
-
const toEndOfMonthMutator = async (value) => {
|
|
69
|
-
const date = new Date(value);
|
|
70
|
-
date.setMonth(date.getMonth() + 1);
|
|
71
|
-
date.setDate(0);
|
|
72
|
-
date.setHours(23, 59, 59, 999);
|
|
73
|
-
return date;
|
|
74
|
-
};
|
|
75
|
-
/** Set to start of year */
|
|
76
|
-
const toStartOfYearMutator = async (value) => {
|
|
77
|
-
const date = new Date(value);
|
|
78
|
-
date.setMonth(0);
|
|
79
|
-
date.setDate(1);
|
|
80
|
-
date.setHours(0, 0, 0, 0);
|
|
81
|
-
return date;
|
|
82
|
-
};
|
|
83
|
-
/** Set to end of year */
|
|
84
|
-
const toEndOfYearMutator = async (value) => {
|
|
85
|
-
const date = new Date(value);
|
|
86
|
-
date.setMonth(11);
|
|
87
|
-
date.setDate(31);
|
|
88
|
-
date.setHours(23, 59, 59, 999);
|
|
89
|
-
return date;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
//#endregion
|
|
93
|
-
export { addDaysMutator, addHoursMutator, addMonthsMutator, addYearsMutator, dateMutator, toEndOfDayMutator, toEndOfMonthMutator, toEndOfYearMutator, toStartOfDayMutator, toStartOfMonthMutator, toStartOfYearMutator, toUTCMutator };
|
|
94
|
-
//# sourceMappingURL=date-mutators.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"date-mutators.mjs","names":[],"sources":["../../../../../../../../../../../packages/seal/src/mutators/date-mutators.ts"],"sourcesContent":["import dayjs from \"dayjs\";\nimport type { Mutator } from \"../types\";\n\n/**\n * Convert value to Date object\n * Returns Invalid Date if value cannot be converted\n */\nexport const dateMutator: Mutator = async (value) => {\n // Handle null/undefined\n if (!value) {\n return;\n }\n\n // Already a Date object\n if (value instanceof Date) {\n return value;\n }\n\n // Try to convert to Date\n const date = new Date(value);\n\n // Return the date (valid or Invalid Date)\n // dateRule will validate and fail if invalid\n return date;\n};\n\n/** Convert date to ISO string format */\nexport const toISOStringMutator: Mutator = async (value) => {\n const date = new Date(value);\n return date.toISOString();\n};\n\n/** Convert date to Unix timestamp (milliseconds) */\nexport const toTimestampMutator: Mutator = async (value) => {\n const date = new Date(value);\n return date.getTime();\n};\n\n/** Convert date to start of day (00:00:00) */\nexport const toStartOfDayMutator: Mutator = async (value) => {\n const date = new Date(value);\n date.setHours(0, 0, 0, 0);\n return date;\n};\n\n/** Convert date to end of day (23:59:59.999) */\nexport const toEndOfDayMutator: Mutator = async (value) => {\n const date = new Date(value);\n date.setHours(23, 59, 59, 999);\n return date;\n};\n\n/** Add or subtract days from date */\nexport const addDaysMutator: Mutator = async (value, context) => {\n const date = new Date(value);\n const days = context?.options.days ?? 0;\n date.setDate(date.getDate() + days);\n return date;\n};\n\n/** Add or subtract months from date */\nexport const addMonthsMutator: Mutator = async (value, context) => {\n const date = new Date(value);\n const months = context?.options.months ?? 0;\n date.setMonth(date.getMonth() + months);\n return date;\n};\n\n/** Add or subtract years from date */\nexport const addYearsMutator: Mutator = async (value, context) => {\n const date = new Date(value);\n const years = context?.options.years ?? 0;\n date.setFullYear(date.getFullYear() + years);\n return date;\n};\n\n/** Add or subtract hours from date */\nexport const addHoursMutator: Mutator = async (value, context) => {\n const date = new Date(value);\n const hours = context?.options.hours ?? 0;\n date.setHours(date.getHours() + hours);\n return date;\n};\n\n/** Convert date to UTC */\nexport const toUTCMutator: Mutator = async (value) => {\n const date = new Date(value);\n return new Date(date.toUTCString());\n};\n\n/** Convert date to specific format using dayjs */\nexport const toFormatMutator: Mutator = async (value, context) => {\n const format = context?.options.format ?? \"YYYY-MM-DD\";\n return dayjs(value).format(format);\n};\n\n/** Convert to date only (remove time) */\nexport const toDateOnlyMutator: Mutator = async (value) => {\n const date = new Date(value);\n return date.toISOString().split(\"T\")[0];\n};\n\n/** Convert to time only (HH:MM:SS) */\nexport const toTimeOnlyMutator: Mutator = async (value) => {\n const date = new Date(value);\n return date.toTimeString().split(\" \")[0];\n};\n\n/** Set to start of month */\nexport const toStartOfMonthMutator: Mutator = async (value) => {\n const date = new Date(value);\n date.setDate(1);\n date.setHours(0, 0, 0, 0);\n return date;\n};\n\n/** Set to end of month */\nexport const toEndOfMonthMutator: Mutator = async (value) => {\n const date = new Date(value);\n date.setMonth(date.getMonth() + 1);\n date.setDate(0);\n date.setHours(23, 59, 59, 999);\n return date;\n};\n\n/** Set to start of year */\nexport const toStartOfYearMutator: Mutator = async (value) => {\n const date = new Date(value);\n date.setMonth(0);\n date.setDate(1);\n date.setHours(0, 0, 0, 0);\n return date;\n};\n\n/** Set to end of year */\nexport const toEndOfYearMutator: Mutator = async (value) => {\n const date = new Date(value);\n date.setMonth(11);\n date.setDate(31);\n date.setHours(23, 59, 59, 999);\n return date;\n};\n"],"mappings":";;;;;;;;;AAOA,MAAa,cAAuB,OAAO,UAAU;CAEnD,IAAI,CAAC,OACH;CAIF,IAAI,iBAAiB,MACnB,OAAO;CAQT,OAAO,IAJU,KAAK,KAIZ;AACZ;;AAeA,MAAa,sBAA+B,OAAO,UAAU;CAC3D,MAAM,OAAO,IAAI,KAAK,KAAK;CAC3B,KAAK,SAAS,GAAG,GAAG,GAAG,CAAC;CACxB,OAAO;AACT;;AAGA,MAAa,oBAA6B,OAAO,UAAU;CACzD,MAAM,OAAO,IAAI,KAAK,KAAK;CAC3B,KAAK,SAAS,IAAI,IAAI,IAAI,GAAG;CAC7B,OAAO;AACT;;AAGA,MAAa,iBAA0B,OAAO,OAAO,YAAY;CAC/D,MAAM,OAAO,IAAI,KAAK,KAAK;CAC3B,MAAM,OAAO,SAAS,QAAQ,QAAQ;CACtC,KAAK,QAAQ,KAAK,QAAQ,IAAI,IAAI;CAClC,OAAO;AACT;;AAGA,MAAa,mBAA4B,OAAO,OAAO,YAAY;CACjE,MAAM,OAAO,IAAI,KAAK,KAAK;CAC3B,MAAM,SAAS,SAAS,QAAQ,UAAU;CAC1C,KAAK,SAAS,KAAK,SAAS,IAAI,MAAM;CACtC,OAAO;AACT;;AAGA,MAAa,kBAA2B,OAAO,OAAO,YAAY;CAChE,MAAM,OAAO,IAAI,KAAK,KAAK;CAC3B,MAAM,QAAQ,SAAS,QAAQ,SAAS;CACxC,KAAK,YAAY,KAAK,YAAY,IAAI,KAAK;CAC3C,OAAO;AACT;;AAGA,MAAa,kBAA2B,OAAO,OAAO,YAAY;CAChE,MAAM,OAAO,IAAI,KAAK,KAAK;CAC3B,MAAM,QAAQ,SAAS,QAAQ,SAAS;CACxC,KAAK,SAAS,KAAK,SAAS,IAAI,KAAK;CACrC,OAAO;AACT;;AAGA,MAAa,eAAwB,OAAO,UAAU;CACpD,MAAM,OAAO,IAAI,KAAK,KAAK;CAC3B,OAAO,IAAI,KAAK,KAAK,YAAY,CAAC;AACpC;;AAqBA,MAAa,wBAAiC,OAAO,UAAU;CAC7D,MAAM,OAAO,IAAI,KAAK,KAAK;CAC3B,KAAK,QAAQ,CAAC;CACd,KAAK,SAAS,GAAG,GAAG,GAAG,CAAC;CACxB,OAAO;AACT;;AAGA,MAAa,sBAA+B,OAAO,UAAU;CAC3D,MAAM,OAAO,IAAI,KAAK,KAAK;CAC3B,KAAK,SAAS,KAAK,SAAS,IAAI,CAAC;CACjC,KAAK,QAAQ,CAAC;CACd,KAAK,SAAS,IAAI,IAAI,IAAI,GAAG;CAC7B,OAAO;AACT;;AAGA,MAAa,uBAAgC,OAAO,UAAU;CAC5D,MAAM,OAAO,IAAI,KAAK,KAAK;CAC3B,KAAK,SAAS,CAAC;CACf,KAAK,QAAQ,CAAC;CACd,KAAK,SAAS,GAAG,GAAG,GAAG,CAAC;CACxB,OAAO;AACT;;AAGA,MAAa,qBAA8B,OAAO,UAAU;CAC1D,MAAM,OAAO,IAAI,KAAK,KAAK;CAC3B,KAAK,SAAS,EAAE;CAChB,KAAK,QAAQ,EAAE;CACf,KAAK,SAAS,IAAI,IAAI,IAAI,GAAG;CAC7B,OAAO;AACT"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { flipArrayMutator, sortArrayMutator, uniqueArrayMutator } from "./array-mutators.mjs";
|
|
2
|
-
import { booleanCoerceMutator, formBooleanMutator } from "./boolean-mutators.mjs";
|
|
3
|
-
import { addDaysMutator, addHoursMutator, addMonthsMutator, addYearsMutator, dateMutator, toEndOfDayMutator, toEndOfMonthMutator, toEndOfYearMutator, toStartOfDayMutator, toStartOfMonthMutator, toStartOfYearMutator, toUTCMutator } from "./date-mutators.mjs";
|
|
4
|
-
import { absMutator, ceilMutator, floorMutator, numberMutator, numericMutator, roundMutator, toFixedMutator } from "./number-mutators.mjs";
|
|
5
|
-
import { objectTrimMutator, stripUnknownMutator } from "./object-mutators.mjs";
|
|
6
|
-
import { stringMutator } from "./scalar-mutators.mjs";
|
|
7
|
-
import { alphaOnlyMutator, alphanumericOnlyMutator, appendMutator, base64DecodeMutator, base64EncodeMutator, camelCaseMutator, capitalizeMutator, htmlEscapeMutator, kebabCaseMutator, lowercaseMutator, ltrimMutator, maskMutator, padEndMutator, padStartMutator, pascalCaseMutator, prependMutator, removeNumbersMutator, removeSpecialCharactersMutator, repeatMutator, replaceAllMutator, replaceMutator, reverseMutator, rtrimMutator, slugMutator, snakeCaseMutator, stringifyMutator, stripTagsMutator, titleCaseMutator, trimMultipleWhitespaceMutator, trimMutator, truncateMutator, unescapeHtmlMutator, uppercaseMutator, urlDecodeMutator, urlEncodeMutator } from "./string-mutators.mjs";
|
|
8
|
-
|
|
9
|
-
export { };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { round } from "../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/number/round.mjs";
|
|
2
|
-
import "../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/index.mjs";
|
|
3
|
-
import { isNumeric } from "../../../../node_modules/.pnpm/@mongez_supportive-is@3.0.0/node_modules/@mongez/supportive-is/esm/index.mjs";
|
|
4
|
-
|
|
5
|
-
//#region ../../packages/seal/src/mutators/number-mutators.ts
|
|
6
|
-
/** Convert value to number */
|
|
7
|
-
const numberMutator = async (value) => {
|
|
8
|
-
if (!value) return value;
|
|
9
|
-
return Number(value);
|
|
10
|
-
};
|
|
11
|
-
const numericMutator = async (value) => {
|
|
12
|
-
if (!isNumeric(value)) return value;
|
|
13
|
-
return Number(value);
|
|
14
|
-
};
|
|
15
|
-
/** Absolute value mutator */
|
|
16
|
-
const absMutator = async (value) => {
|
|
17
|
-
return Math.abs(Number(value));
|
|
18
|
-
};
|
|
19
|
-
/** Ceil mutator */
|
|
20
|
-
const ceilMutator = async (value) => {
|
|
21
|
-
return Math.ceil(Number(value));
|
|
22
|
-
};
|
|
23
|
-
/** Floor mutator */
|
|
24
|
-
const floorMutator = async (value) => {
|
|
25
|
-
return Math.floor(Number(value));
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Round mutator
|
|
29
|
-
* Supports decimal precision via options.decimals
|
|
30
|
-
*/
|
|
31
|
-
const roundMutator = async (value, context) => {
|
|
32
|
-
const decimals = context?.options?.decimals ?? 0;
|
|
33
|
-
if (decimals === 0) return Math.round(Number(value));
|
|
34
|
-
return round(Number(value), decimals);
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* To fixed mutator — rounds to a fixed number of decimal places, as a number.
|
|
38
|
-
*
|
|
39
|
-
* `Number.prototype.toFixed` returns a *string*, which the number validator's
|
|
40
|
-
* own type rule then rejected: `v.number().toFixed(2)` could never produce a
|
|
41
|
-
* valid result. Coercing back to a number keeps the method usable where it
|
|
42
|
-
* lives. For the fixed-point string form, format at the edge instead of asking
|
|
43
|
-
* a number schema to output a string.
|
|
44
|
-
*/
|
|
45
|
-
const toFixedMutator = async (value, context) => {
|
|
46
|
-
const decimals = context?.options?.decimals ?? 2;
|
|
47
|
-
return Number(Number(value).toFixed(decimals));
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
//#endregion
|
|
51
|
-
export { absMutator, ceilMutator, floorMutator, numberMutator, numericMutator, roundMutator, toFixedMutator };
|
|
52
|
-
//# sourceMappingURL=number-mutators.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"number-mutators.mjs","names":[],"sources":["../../../../../../../../../../../packages/seal/src/mutators/number-mutators.ts"],"sourcesContent":["import { round } from \"@mongez/reinforcements\";\nimport { isNumeric } from \"@mongez/supportive-is\";\nimport type { Mutator } from \"../types\";\n\n/** Convert value to number */\nexport const numberMutator: Mutator = async (value) => {\n if (!value) return value;\n return Number(value);\n};\n\n/** Round number to specified decimals */\nexport const roundNumberMutator: Mutator = async (value, context) => {\n return round(value, context?.options?.decimals ?? 2);\n};\n\n/** Convert to boolean */\nexport const booleanMutator: Mutator = async (value) => {\n if (value === \"true\") return true;\n if (value === \"false\") return false;\n return Boolean(value);\n};\n\nexport const numericMutator: Mutator = async (value) => {\n if (!isNumeric(value)) return value;\n return Number(value);\n};\n\n/** Absolute value mutator */\nexport const absMutator: Mutator = async (value) => {\n return Math.abs(Number(value));\n};\n\n/** Ceil mutator */\nexport const ceilMutator: Mutator = async (value) => {\n return Math.ceil(Number(value));\n};\n\n/** Floor mutator */\nexport const floorMutator: Mutator = async (value) => {\n return Math.floor(Number(value));\n};\n\n/**\n * Round mutator\n * Supports decimal precision via options.decimals\n */\nexport const roundMutator: Mutator = async (value, context) => {\n const decimals = context?.options?.decimals ?? 0;\n // If decimals is 0, use standard Math.round for integers\n if (decimals === 0) {\n return Math.round(Number(value));\n }\n // Otherwise use reinforcements round helper for precision\n return round(Number(value), decimals);\n};\n\n/**\n * To fixed mutator — rounds to a fixed number of decimal places, as a number.\n *\n * `Number.prototype.toFixed` returns a *string*, which the number validator's\n * own type rule then rejected: `v.number().toFixed(2)` could never produce a\n * valid result. Coercing back to a number keeps the method usable where it\n * lives. For the fixed-point string form, format at the edge instead of asking\n * a number schema to output a string.\n */\nexport const toFixedMutator: Mutator = async (value, context) => {\n const decimals = context?.options?.decimals ?? 2;\n return Number(Number(value).toFixed(decimals));\n};\n"],"mappings":";;;;;;AAKA,MAAa,gBAAyB,OAAO,UAAU;CACrD,IAAI,CAAC,OAAO,OAAO;CACnB,OAAO,OAAO,KAAK;AACrB;AAcA,MAAa,iBAA0B,OAAO,UAAU;CACtD,IAAI,CAAC,UAAU,KAAK,GAAG,OAAO;CAC9B,OAAO,OAAO,KAAK;AACrB;;AAGA,MAAa,aAAsB,OAAO,UAAU;CAClD,OAAO,KAAK,IAAI,OAAO,KAAK,CAAC;AAC/B;;AAGA,MAAa,cAAuB,OAAO,UAAU;CACnD,OAAO,KAAK,KAAK,OAAO,KAAK,CAAC;AAChC;;AAGA,MAAa,eAAwB,OAAO,UAAU;CACpD,OAAO,KAAK,MAAM,OAAO,KAAK,CAAC;AACjC;;;;;AAMA,MAAa,eAAwB,OAAO,OAAO,YAAY;CAC7D,MAAM,WAAW,SAAS,SAAS,YAAY;CAE/C,IAAI,aAAa,GACf,OAAO,KAAK,MAAM,OAAO,KAAK,CAAC;CAGjC,OAAO,MAAM,OAAO,KAAK,GAAG,QAAQ;AACtC;;;;;;;;;;AAWA,MAAa,iBAA0B,OAAO,OAAO,YAAY;CAC/D,MAAM,WAAW,SAAS,SAAS,YAAY;CAC/C,OAAO,OAAO,OAAO,KAAK,CAAC,CAAC,QAAQ,QAAQ,CAAC;AAC/C"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { trim } from "../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/trim.mjs";
|
|
2
|
-
import "../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/index.mjs";
|
|
3
|
-
import { isPlainObject } from "../../../../node_modules/.pnpm/@mongez_supportive-is@3.0.0/node_modules/@mongez/supportive-is/esm/index.mjs";
|
|
4
|
-
|
|
5
|
-
//#region ../../packages/seal/src/mutators/object-mutators.ts
|
|
6
|
-
/** Strip unknown keys from object */
|
|
7
|
-
const stripUnknownMutator = async (value, context) => {
|
|
8
|
-
const allowedKeys = [...context?.ctx.schema ? Object.keys(context.ctx.schema) : [], ...context?.options.allowedKeys ?? []];
|
|
9
|
-
const result = {};
|
|
10
|
-
for (const key in value) if (allowedKeys.includes(key)) result[key] = value[key];
|
|
11
|
-
return result;
|
|
12
|
-
};
|
|
13
|
-
/** Trim all string values in object */
|
|
14
|
-
const objectTrimMutator = async (value, context) => {
|
|
15
|
-
if (!isPlainObject(value)) return value;
|
|
16
|
-
const result = {};
|
|
17
|
-
const recursive = context?.options.recursive ?? false;
|
|
18
|
-
for (const key in value) {
|
|
19
|
-
const item = value[key];
|
|
20
|
-
if (recursive) if (Array.isArray(item)) result[key] = await Promise.all(item.map(async (i) => typeof i === "string" ? trim(i) : await objectTrimMutator(i, context)));
|
|
21
|
-
else if (isPlainObject(item)) result[key] = await objectTrimMutator(item, context);
|
|
22
|
-
else result[key] = typeof item === "string" ? trim(item) : item;
|
|
23
|
-
else result[key] = typeof item === "string" ? trim(item) : item;
|
|
24
|
-
}
|
|
25
|
-
return result;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
29
|
-
export { objectTrimMutator, stripUnknownMutator };
|
|
30
|
-
//# sourceMappingURL=object-mutators.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object-mutators.mjs","names":[],"sources":["../../../../../../../../../../../packages/seal/src/mutators/object-mutators.ts"],"sourcesContent":["import { trim } from \"@mongez/reinforcements\";\nimport { isPlainObject } from \"@mongez/supportive-is\";\nimport type { Mutator } from \"../types\";\n\n/** Strip unknown keys from object */\nexport const stripUnknownMutator: Mutator = async (value, context) => {\n const allowedKeys = [\n ...(context?.ctx.schema ? Object.keys(context.ctx.schema) : []),\n ...(context?.options.allowedKeys ?? []),\n ];\n\n const result: Record<string, any> = {};\n\n for (const key in value) {\n if (allowedKeys.includes(key)) {\n result[key] = value[key];\n }\n }\n\n return result;\n};\n\n/** Trim all string values in object */\nexport const objectTrimMutator: Mutator = async (value, context) => {\n if (!isPlainObject(value)) return value;\n\n const result: Record<string, any> = {};\n const recursive = context?.options.recursive ?? false;\n\n for (const key in value) {\n const item = value[key];\n\n if (recursive) {\n if (Array.isArray(item)) {\n result[key] = await Promise.all(\n item.map(async (i: any) =>\n typeof i === \"string\" ? trim(i) : await objectTrimMutator(i, context),\n ),\n );\n } else if (isPlainObject(item)) {\n result[key] = await objectTrimMutator(item, context);\n } else {\n result[key] = typeof item === \"string\" ? trim(item) : item;\n }\n } else {\n result[key] = typeof item === \"string\" ? trim(item) : item;\n }\n }\n\n return result;\n};\n\n/** Parse JSON string */\nexport const jsonMutator: Mutator = async (value) => {\n try {\n return JSON.parse(value);\n } catch {\n return value;\n }\n};\n"],"mappings":";;;;;;AAKA,MAAa,sBAA+B,OAAO,OAAO,YAAY;CACpE,MAAM,cAAc,CAClB,GAAI,SAAS,IAAI,SAAS,OAAO,KAAK,QAAQ,IAAI,MAAM,IAAI,CAAC,GAC7D,GAAI,SAAS,QAAQ,eAAe,CAAC,CACvC;CAEA,MAAM,SAA8B,CAAC;CAErC,KAAK,MAAM,OAAO,OAChB,IAAI,YAAY,SAAS,GAAG,GAC1B,OAAO,OAAO,MAAM;CAIxB,OAAO;AACT;;AAGA,MAAa,oBAA6B,OAAO,OAAO,YAAY;CAClE,IAAI,CAAC,cAAc,KAAK,GAAG,OAAO;CAElC,MAAM,SAA8B,CAAC;CACrC,MAAM,YAAY,SAAS,QAAQ,aAAa;CAEhD,KAAK,MAAM,OAAO,OAAO;EACvB,MAAM,OAAO,MAAM;EAEnB,IAAI,WACF,IAAI,MAAM,QAAQ,IAAI,GACpB,OAAO,OAAO,MAAM,QAAQ,IAC1B,KAAK,IAAI,OAAO,MACd,OAAO,MAAM,WAAW,KAAK,CAAC,IAAI,MAAM,kBAAkB,GAAG,OAAO,CACtE,CACF;OACK,IAAI,cAAc,IAAI,GAC3B,OAAO,OAAO,MAAM,kBAAkB,MAAM,OAAO;OAEnD,OAAO,OAAO,OAAO,SAAS,WAAW,KAAK,IAAI,IAAI;OAGxD,OAAO,OAAO,OAAO,SAAS,WAAW,KAAK,IAAI,IAAI;CAE1D;CAEA,OAAO;AACT"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
//#region ../../packages/seal/src/mutators/scalar-mutators.ts
|
|
2
|
-
const stringMutator = async (value) => {
|
|
3
|
-
if ([void 0, null].includes(value)) return value;
|
|
4
|
-
return String(value);
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
//#endregion
|
|
8
|
-
export { stringMutator };
|
|
9
|
-
//# sourceMappingURL=scalar-mutators.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scalar-mutators.mjs","names":[],"sources":["../../../../../../../../../../../packages/seal/src/mutators/scalar-mutators.ts"],"sourcesContent":["import type { Mutator } from \"../types\";\n\nexport const stringMutator: Mutator = async (value) => {\n if ([undefined, null].includes(value)) {\n return value;\n }\n\n return String(value);\n};\n"],"mappings":";AAEA,MAAa,gBAAyB,OAAO,UAAU;CACrD,IAAI,CAAC,QAAW,IAAI,CAAC,CAAC,SAAS,KAAK,GAClC,OAAO;CAGT,OAAO,OAAO,KAAK;AACrB"}
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { capitalize } from "../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/capitalize.mjs";
|
|
2
|
-
import { trim } from "../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/trim.mjs";
|
|
3
|
-
import { ltrim } from "../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/ltrim.mjs";
|
|
4
|
-
import { readMoreChars } from "../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/readMoreChars.mjs";
|
|
5
|
-
import { rtrim } from "../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/rtrim.mjs";
|
|
6
|
-
import { toCamelCase } from "../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toCamelCase.mjs";
|
|
7
|
-
import { toSnakeCase } from "../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toSnakeCase.mjs";
|
|
8
|
-
import { toKebabCase } from "../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toKebabCase.mjs";
|
|
9
|
-
import { toStudlyCase } from "../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toStudlyCase.mjs";
|
|
10
|
-
import "../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/index.mjs";
|
|
11
|
-
|
|
12
|
-
//#region ../../packages/seal/src/mutators/string-mutators.ts
|
|
13
|
-
/** Convert string to lowercase */
|
|
14
|
-
const lowercaseMutator = async (value) => {
|
|
15
|
-
return value?.toString().toLowerCase();
|
|
16
|
-
};
|
|
17
|
-
/** Convert string to uppercase */
|
|
18
|
-
const uppercaseMutator = async (value) => {
|
|
19
|
-
return value?.toString().toUpperCase();
|
|
20
|
-
};
|
|
21
|
-
/** Capitalize only the first letter of the string */
|
|
22
|
-
const capitalizeMutator = async (value) => {
|
|
23
|
-
const str = value?.toString();
|
|
24
|
-
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
25
|
-
};
|
|
26
|
-
/** Capitalize the first letter of each word (Title Case) */
|
|
27
|
-
const titleCaseMutator = async (value) => {
|
|
28
|
-
return capitalize(value?.toString());
|
|
29
|
-
};
|
|
30
|
-
/** Convert value to string */
|
|
31
|
-
const stringifyMutator = async (value) => {
|
|
32
|
-
if (!value && value !== 0) return "";
|
|
33
|
-
if (typeof value === "string") return value;
|
|
34
|
-
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
35
|
-
};
|
|
36
|
-
/** Trim whitespace */
|
|
37
|
-
const trimMutator = async (value, context) => {
|
|
38
|
-
return trim(value?.toString(), context?.options?.needle ?? " ");
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Strip HTML tags with a naive `<...>` regex.
|
|
42
|
-
*
|
|
43
|
-
* This is a **tag stripper, not an XSS sanitizer**: it is not a parser, so
|
|
44
|
-
* malformed/nested markup, attribute payloads, or content re-introduced
|
|
45
|
-
* later in a pipeline can defeat it. Do not rely on this alone to make
|
|
46
|
-
* untrusted rich text safe to render — use a real parser-based sanitizer
|
|
47
|
-
* (e.g. DOMPurify / sanitize-html) for that.
|
|
48
|
-
*/
|
|
49
|
-
const stripTagsMutator = async (value) => {
|
|
50
|
-
return value?.toString().replace(/<[^>]*>?/gm, "");
|
|
51
|
-
};
|
|
52
|
-
/** HTML escape */
|
|
53
|
-
const htmlEscapeMutator = async (value) => {
|
|
54
|
-
return value?.toString().replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
55
|
-
};
|
|
56
|
-
/** Remove special characters */
|
|
57
|
-
const removeSpecialCharactersMutator = async (value) => {
|
|
58
|
-
return value?.toString().replace(/[^a-zA-Z0-9]/g, "");
|
|
59
|
-
};
|
|
60
|
-
/** URL decode */
|
|
61
|
-
const urlDecodeMutator = async (value) => {
|
|
62
|
-
return decodeURIComponent(value);
|
|
63
|
-
};
|
|
64
|
-
/** URL encode */
|
|
65
|
-
const urlEncodeMutator = async (value) => {
|
|
66
|
-
return encodeURIComponent(value);
|
|
67
|
-
};
|
|
68
|
-
/** Convert to camelCase */
|
|
69
|
-
const camelCaseMutator = async (value) => {
|
|
70
|
-
return toCamelCase(value?.toString());
|
|
71
|
-
};
|
|
72
|
-
/** Convert to PascalCase */
|
|
73
|
-
const pascalCaseMutator = async (value) => {
|
|
74
|
-
return toStudlyCase(value?.toString());
|
|
75
|
-
};
|
|
76
|
-
/** Convert to snake_case */
|
|
77
|
-
const snakeCaseMutator = async (value) => {
|
|
78
|
-
return toSnakeCase(value?.toString());
|
|
79
|
-
};
|
|
80
|
-
/** Convert to kebab-case */
|
|
81
|
-
const kebabCaseMutator = async (value) => {
|
|
82
|
-
return toKebabCase(value?.toString());
|
|
83
|
-
};
|
|
84
|
-
/** Convert to URL-friendly slug */
|
|
85
|
-
const slugMutator = async (value) => {
|
|
86
|
-
return value?.toString().toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_]+/g, "-").replace(/--+/g, "-").replace(/^-+|-+$/g, "");
|
|
87
|
-
};
|
|
88
|
-
/** Trim from the left/start */
|
|
89
|
-
const ltrimMutator = async (value, context) => {
|
|
90
|
-
return ltrim(value?.toString(), context?.options?.needle ?? " ");
|
|
91
|
-
};
|
|
92
|
-
/** Trim from the right/end */
|
|
93
|
-
const rtrimMutator = async (value, context) => {
|
|
94
|
-
return rtrim(value?.toString(), context?.options?.needle ?? " ");
|
|
95
|
-
};
|
|
96
|
-
/** Base64 encode */
|
|
97
|
-
const base64EncodeMutator = async (value) => {
|
|
98
|
-
return Buffer.from(value?.toString()).toString("base64");
|
|
99
|
-
};
|
|
100
|
-
/** Base64 decode */
|
|
101
|
-
const base64DecodeMutator = async (value) => {
|
|
102
|
-
return Buffer.from(value?.toString(), "base64").toString("utf-8");
|
|
103
|
-
};
|
|
104
|
-
/** Replace substring or pattern */
|
|
105
|
-
const replaceMutator = async (value, context) => {
|
|
106
|
-
const { search, replace } = context?.options ?? {};
|
|
107
|
-
if (!search) return value?.toString();
|
|
108
|
-
return value?.toString().replace(search, replace ?? "");
|
|
109
|
-
};
|
|
110
|
-
/** Replace all occurrences of substring or pattern */
|
|
111
|
-
const replaceAllMutator = async (value, context) => {
|
|
112
|
-
const { search, replace } = context?.options ?? {};
|
|
113
|
-
if (!search) return value?.toString();
|
|
114
|
-
const searchValue = typeof search === "string" ? new RegExp(search, "g") : search;
|
|
115
|
-
return value?.toString().replace(searchValue, replace ?? "");
|
|
116
|
-
};
|
|
117
|
-
/** Append/suffix text to the end */
|
|
118
|
-
const appendMutator = async (value, context) => {
|
|
119
|
-
const suffix = context?.options?.suffix ?? "";
|
|
120
|
-
return value?.toString() + suffix;
|
|
121
|
-
};
|
|
122
|
-
/** Prepend/prefix text to the beginning */
|
|
123
|
-
const prependMutator = async (value, context) => {
|
|
124
|
-
return (context?.options?.prefix ?? "") + value?.toString();
|
|
125
|
-
};
|
|
126
|
-
/** Reverse the string */
|
|
127
|
-
const reverseMutator = async (value) => {
|
|
128
|
-
return value?.toString().split("").reverse().join("");
|
|
129
|
-
};
|
|
130
|
-
/** Truncate to a maximum length */
|
|
131
|
-
const truncateMutator = async (value, context) => {
|
|
132
|
-
const str = value?.toString();
|
|
133
|
-
return readMoreChars(str, context?.options?.maxLength ?? 100, context?.options?.suffix ?? "...");
|
|
134
|
-
};
|
|
135
|
-
/** Trim multiple whitespace into single space */
|
|
136
|
-
const trimMultipleWhitespaceMutator = async (value) => {
|
|
137
|
-
return value?.toString().replace(/\s+/g, " ");
|
|
138
|
-
};
|
|
139
|
-
/** Pad string from the start to reach target length */
|
|
140
|
-
const padStartMutator = async (value, context) => {
|
|
141
|
-
const length = context?.options?.length ?? 0;
|
|
142
|
-
const char = context?.options?.char ?? " ";
|
|
143
|
-
return value?.toString().padStart(length, char);
|
|
144
|
-
};
|
|
145
|
-
/** Pad string from the end to reach target length */
|
|
146
|
-
const padEndMutator = async (value, context) => {
|
|
147
|
-
const length = context?.options?.length ?? 0;
|
|
148
|
-
const char = context?.options?.char ?? " ";
|
|
149
|
-
return value?.toString().padEnd(length, char);
|
|
150
|
-
};
|
|
151
|
-
/** Repeat string N times */
|
|
152
|
-
const repeatMutator = async (value, context) => {
|
|
153
|
-
const count = context?.options?.count ?? 1;
|
|
154
|
-
return value?.toString()?.repeat(count);
|
|
155
|
-
};
|
|
156
|
-
/** Mask part of string */
|
|
157
|
-
const maskMutator = async (value, context) => {
|
|
158
|
-
const str = value?.toString();
|
|
159
|
-
const maskChar = context?.options?.char ?? "*";
|
|
160
|
-
const start = context?.options?.start ?? 0;
|
|
161
|
-
const end = context?.options?.end ?? str?.length;
|
|
162
|
-
const visibleStart = str?.substring(0, start);
|
|
163
|
-
const visibleEnd = str?.substring(end);
|
|
164
|
-
const maskedLength = end - start;
|
|
165
|
-
return visibleStart + maskChar.repeat(maskedLength) + visibleEnd;
|
|
166
|
-
};
|
|
167
|
-
/** Unescape HTML entities */
|
|
168
|
-
const unescapeHtmlMutator = async (value) => {
|
|
169
|
-
return value?.toString().replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, "\"").replace(/'/g, "'");
|
|
170
|
-
};
|
|
171
|
-
/** Keep only alphabetic characters */
|
|
172
|
-
const alphaOnlyMutator = async (value) => {
|
|
173
|
-
return value.toString().replace(/[^a-zA-Z]/g, "");
|
|
174
|
-
};
|
|
175
|
-
/** Keep only alphanumeric characters */
|
|
176
|
-
const alphanumericOnlyMutator = async (value) => {
|
|
177
|
-
return value.toString().replace(/[^a-zA-Z0-9]/g, "");
|
|
178
|
-
};
|
|
179
|
-
/** Remove all numeric characters */
|
|
180
|
-
const removeNumbersMutator = async (value) => {
|
|
181
|
-
return value.toString().replace(/[0-9]/g, "");
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
//#endregion
|
|
185
|
-
export { alphaOnlyMutator, alphanumericOnlyMutator, appendMutator, base64DecodeMutator, base64EncodeMutator, camelCaseMutator, capitalizeMutator, htmlEscapeMutator, kebabCaseMutator, lowercaseMutator, ltrimMutator, maskMutator, padEndMutator, padStartMutator, pascalCaseMutator, prependMutator, removeNumbersMutator, removeSpecialCharactersMutator, repeatMutator, replaceAllMutator, replaceMutator, reverseMutator, rtrimMutator, slugMutator, snakeCaseMutator, stringifyMutator, stripTagsMutator, titleCaseMutator, trimMultipleWhitespaceMutator, trimMutator, truncateMutator, unescapeHtmlMutator, uppercaseMutator, urlDecodeMutator, urlEncodeMutator };
|
|
186
|
-
//# sourceMappingURL=string-mutators.mjs.map
|