@warlock.js/notifications 5.30.0 → 5.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -1
- 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/config.mjs.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/define-notification.mjs.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/dispatch/notify.mjs.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/migration/notification-columns.mjs.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/bullmq-queue.mjs.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/notifications-worker.mjs.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/llms-full.txt +89 -81
- package/package.json +10 -9
- package/skills/configure-notifications/SKILL.md +7 -7
- package/skills/define-channel/SKILL.md +9 -7
- package/skills/define-notification/SKILL.md +22 -25
- package/skills/index.md +4 -1
- package/skills/notifications-basics/SKILL.md +12 -12
- package/skills/observe-notifications/SKILL.md +14 -10
- package/skills/send-ad-hoc/SKILL.md +9 -9
- package/skills/use-in-app/SKILL.md +6 -4
- package/skills/write-notification-migration/SKILL.md +10 -7
- 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-BFoWr21L.cjs +0 -3
- package/cjs/src-eu2jxS21.cjs +0 -11190
- package/cjs/src-eu2jxS21.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 -133
- 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 -32
- 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 -720
- 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 -445
- 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 -66
- package/esm/packages/seal/src/validators/union-validator.mjs.map +0 -1
|
@@ -1,388 +0,0 @@
|
|
|
1
|
-
import { __commonJSMin } from "../../../../../_virtual/_rolldown/runtime.mjs";
|
|
2
|
-
import { require_requires_port } from "../../../requires-port@1.0.0/node_modules/requires-port/index.mjs";
|
|
3
|
-
import { require_querystringify } from "../../../querystringify@2.2.0/node_modules/querystringify/index.mjs";
|
|
4
|
-
|
|
5
|
-
//#region ../../node_modules/.pnpm/url-parse@1.5.10/node_modules/url-parse/index.js
|
|
6
|
-
var require_url_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
7
|
-
var required = require_requires_port(), qs = require_querystringify(), controlOrWhitespace = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/, CRHTLF = /[\n\r\t]/g, slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//, port = /:\d+$/, protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i, windowsDriveLetter = /^[a-zA-Z]:/;
|
|
8
|
-
/**
|
|
9
|
-
* Remove control characters and whitespace from the beginning of a string.
|
|
10
|
-
*
|
|
11
|
-
* @param {Object|String} str String to trim.
|
|
12
|
-
* @returns {String} A new string representing `str` stripped of control
|
|
13
|
-
* characters and whitespace from its beginning.
|
|
14
|
-
* @public
|
|
15
|
-
*/
|
|
16
|
-
function trimLeft(str) {
|
|
17
|
-
return (str ? str : "").toString().replace(controlOrWhitespace, "");
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* These are the parse rules for the URL parser, it informs the parser
|
|
21
|
-
* about:
|
|
22
|
-
*
|
|
23
|
-
* 0. The char it Needs to parse, if it's a string it should be done using
|
|
24
|
-
* indexOf, RegExp using exec and NaN means set as current value.
|
|
25
|
-
* 1. The property we should set when parsing this value.
|
|
26
|
-
* 2. Indication if it's backwards or forward parsing, when set as number it's
|
|
27
|
-
* the value of extra chars that should be split off.
|
|
28
|
-
* 3. Inherit from location if non existing in the parser.
|
|
29
|
-
* 4. `toLowerCase` the resulting value.
|
|
30
|
-
*/
|
|
31
|
-
var rules = [
|
|
32
|
-
["#", "hash"],
|
|
33
|
-
["?", "query"],
|
|
34
|
-
function sanitize(address, url) {
|
|
35
|
-
return isSpecial(url.protocol) ? address.replace(/\\/g, "/") : address;
|
|
36
|
-
},
|
|
37
|
-
["/", "pathname"],
|
|
38
|
-
[
|
|
39
|
-
"@",
|
|
40
|
-
"auth",
|
|
41
|
-
1
|
|
42
|
-
],
|
|
43
|
-
[
|
|
44
|
-
NaN,
|
|
45
|
-
"host",
|
|
46
|
-
void 0,
|
|
47
|
-
1,
|
|
48
|
-
1
|
|
49
|
-
],
|
|
50
|
-
[
|
|
51
|
-
/:(\d*)$/,
|
|
52
|
-
"port",
|
|
53
|
-
void 0,
|
|
54
|
-
1
|
|
55
|
-
],
|
|
56
|
-
[
|
|
57
|
-
NaN,
|
|
58
|
-
"hostname",
|
|
59
|
-
void 0,
|
|
60
|
-
1,
|
|
61
|
-
1
|
|
62
|
-
]
|
|
63
|
-
];
|
|
64
|
-
/**
|
|
65
|
-
* These properties should not be copied or inherited from. This is only needed
|
|
66
|
-
* for all non blob URL's as a blob URL does not include a hash, only the
|
|
67
|
-
* origin.
|
|
68
|
-
*
|
|
69
|
-
* @type {Object}
|
|
70
|
-
* @private
|
|
71
|
-
*/
|
|
72
|
-
var ignore = {
|
|
73
|
-
hash: 1,
|
|
74
|
-
query: 1
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* The location object differs when your code is loaded through a normal page,
|
|
78
|
-
* Worker or through a worker using a blob. And with the blobble begins the
|
|
79
|
-
* trouble as the location object will contain the URL of the blob, not the
|
|
80
|
-
* location of the page where our code is loaded in. The actual origin is
|
|
81
|
-
* encoded in the `pathname` so we can thankfully generate a good "default"
|
|
82
|
-
* location from it so we can generate proper relative URL's again.
|
|
83
|
-
*
|
|
84
|
-
* @param {Object|String} loc Optional default location object.
|
|
85
|
-
* @returns {Object} lolcation object.
|
|
86
|
-
* @public
|
|
87
|
-
*/
|
|
88
|
-
function lolcation(loc) {
|
|
89
|
-
var globalVar;
|
|
90
|
-
if (typeof window !== "undefined") globalVar = window;
|
|
91
|
-
else if (typeof global !== "undefined") globalVar = global;
|
|
92
|
-
else if (typeof self !== "undefined") globalVar = self;
|
|
93
|
-
else globalVar = {};
|
|
94
|
-
var location = globalVar.location || {};
|
|
95
|
-
loc = loc || location;
|
|
96
|
-
var finaldestination = {}, type = typeof loc, key;
|
|
97
|
-
if ("blob:" === loc.protocol) finaldestination = new Url(unescape(loc.pathname), {});
|
|
98
|
-
else if ("string" === type) {
|
|
99
|
-
finaldestination = new Url(loc, {});
|
|
100
|
-
for (key in ignore) delete finaldestination[key];
|
|
101
|
-
} else if ("object" === type) {
|
|
102
|
-
for (key in loc) {
|
|
103
|
-
if (key in ignore) continue;
|
|
104
|
-
finaldestination[key] = loc[key];
|
|
105
|
-
}
|
|
106
|
-
if (finaldestination.slashes === void 0) finaldestination.slashes = slashes.test(loc.href);
|
|
107
|
-
}
|
|
108
|
-
return finaldestination;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Check whether a protocol scheme is special.
|
|
112
|
-
*
|
|
113
|
-
* @param {String} The protocol scheme of the URL
|
|
114
|
-
* @return {Boolean} `true` if the protocol scheme is special, else `false`
|
|
115
|
-
* @private
|
|
116
|
-
*/
|
|
117
|
-
function isSpecial(scheme) {
|
|
118
|
-
return scheme === "file:" || scheme === "ftp:" || scheme === "http:" || scheme === "https:" || scheme === "ws:" || scheme === "wss:";
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* @typedef ProtocolExtract
|
|
122
|
-
* @type Object
|
|
123
|
-
* @property {String} protocol Protocol matched in the URL, in lowercase.
|
|
124
|
-
* @property {Boolean} slashes `true` if protocol is followed by "//", else `false`.
|
|
125
|
-
* @property {String} rest Rest of the URL that is not part of the protocol.
|
|
126
|
-
*/
|
|
127
|
-
/**
|
|
128
|
-
* Extract protocol information from a URL with/without double slash ("//").
|
|
129
|
-
*
|
|
130
|
-
* @param {String} address URL we want to extract from.
|
|
131
|
-
* @param {Object} location
|
|
132
|
-
* @return {ProtocolExtract} Extracted information.
|
|
133
|
-
* @private
|
|
134
|
-
*/
|
|
135
|
-
function extractProtocol(address, location) {
|
|
136
|
-
address = trimLeft(address);
|
|
137
|
-
address = address.replace(CRHTLF, "");
|
|
138
|
-
location = location || {};
|
|
139
|
-
var match = protocolre.exec(address);
|
|
140
|
-
var protocol = match[1] ? match[1].toLowerCase() : "";
|
|
141
|
-
var forwardSlashes = !!match[2];
|
|
142
|
-
var otherSlashes = !!match[3];
|
|
143
|
-
var slashesCount = 0;
|
|
144
|
-
var rest;
|
|
145
|
-
if (forwardSlashes) if (otherSlashes) {
|
|
146
|
-
rest = match[2] + match[3] + match[4];
|
|
147
|
-
slashesCount = match[2].length + match[3].length;
|
|
148
|
-
} else {
|
|
149
|
-
rest = match[2] + match[4];
|
|
150
|
-
slashesCount = match[2].length;
|
|
151
|
-
}
|
|
152
|
-
else if (otherSlashes) {
|
|
153
|
-
rest = match[3] + match[4];
|
|
154
|
-
slashesCount = match[3].length;
|
|
155
|
-
} else rest = match[4];
|
|
156
|
-
if (protocol === "file:") {
|
|
157
|
-
if (slashesCount >= 2) rest = rest.slice(2);
|
|
158
|
-
} else if (isSpecial(protocol)) rest = match[4];
|
|
159
|
-
else if (protocol) {
|
|
160
|
-
if (forwardSlashes) rest = rest.slice(2);
|
|
161
|
-
} else if (slashesCount >= 2 && isSpecial(location.protocol)) rest = match[4];
|
|
162
|
-
return {
|
|
163
|
-
protocol,
|
|
164
|
-
slashes: forwardSlashes || isSpecial(protocol),
|
|
165
|
-
slashesCount,
|
|
166
|
-
rest
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Resolve a relative URL pathname against a base URL pathname.
|
|
171
|
-
*
|
|
172
|
-
* @param {String} relative Pathname of the relative URL.
|
|
173
|
-
* @param {String} base Pathname of the base URL.
|
|
174
|
-
* @return {String} Resolved pathname.
|
|
175
|
-
* @private
|
|
176
|
-
*/
|
|
177
|
-
function resolve(relative, base) {
|
|
178
|
-
if (relative === "") return base;
|
|
179
|
-
var path = (base || "/").split("/").slice(0, -1).concat(relative.split("/")), i = path.length, last = path[i - 1], unshift = false, up = 0;
|
|
180
|
-
while (i--) if (path[i] === ".") path.splice(i, 1);
|
|
181
|
-
else if (path[i] === "..") {
|
|
182
|
-
path.splice(i, 1);
|
|
183
|
-
up++;
|
|
184
|
-
} else if (up) {
|
|
185
|
-
if (i === 0) unshift = true;
|
|
186
|
-
path.splice(i, 1);
|
|
187
|
-
up--;
|
|
188
|
-
}
|
|
189
|
-
if (unshift) path.unshift("");
|
|
190
|
-
if (last === "." || last === "..") path.push("");
|
|
191
|
-
return path.join("/");
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* The actual URL instance. Instead of returning an object we've opted-in to
|
|
195
|
-
* create an actual constructor as it's much more memory efficient and
|
|
196
|
-
* faster and it pleases my OCD.
|
|
197
|
-
*
|
|
198
|
-
* It is worth noting that we should not use `URL` as class name to prevent
|
|
199
|
-
* clashes with the global URL instance that got introduced in browsers.
|
|
200
|
-
*
|
|
201
|
-
* @constructor
|
|
202
|
-
* @param {String} address URL we want to parse.
|
|
203
|
-
* @param {Object|String} [location] Location defaults for relative paths.
|
|
204
|
-
* @param {Boolean|Function} [parser] Parser for the query string.
|
|
205
|
-
* @private
|
|
206
|
-
*/
|
|
207
|
-
function Url(address, location, parser) {
|
|
208
|
-
address = trimLeft(address);
|
|
209
|
-
address = address.replace(CRHTLF, "");
|
|
210
|
-
if (!(this instanceof Url)) return new Url(address, location, parser);
|
|
211
|
-
var relative, extracted, parse, instruction, index, key, instructions = rules.slice(), type = typeof location, url = this, i = 0;
|
|
212
|
-
if ("object" !== type && "string" !== type) {
|
|
213
|
-
parser = location;
|
|
214
|
-
location = null;
|
|
215
|
-
}
|
|
216
|
-
if (parser && "function" !== typeof parser) parser = qs.parse;
|
|
217
|
-
location = lolcation(location);
|
|
218
|
-
extracted = extractProtocol(address || "", location);
|
|
219
|
-
relative = !extracted.protocol && !extracted.slashes;
|
|
220
|
-
url.slashes = extracted.slashes || relative && location.slashes;
|
|
221
|
-
url.protocol = extracted.protocol || location.protocol || "";
|
|
222
|
-
address = extracted.rest;
|
|
223
|
-
if (extracted.protocol === "file:" && (extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) || !extracted.slashes && (extracted.protocol || extracted.slashesCount < 2 || !isSpecial(url.protocol))) instructions[3] = [/(.*)/, "pathname"];
|
|
224
|
-
for (; i < instructions.length; i++) {
|
|
225
|
-
instruction = instructions[i];
|
|
226
|
-
if (typeof instruction === "function") {
|
|
227
|
-
address = instruction(address, url);
|
|
228
|
-
continue;
|
|
229
|
-
}
|
|
230
|
-
parse = instruction[0];
|
|
231
|
-
key = instruction[1];
|
|
232
|
-
if (parse !== parse) url[key] = address;
|
|
233
|
-
else if ("string" === typeof parse) {
|
|
234
|
-
index = parse === "@" ? address.lastIndexOf(parse) : address.indexOf(parse);
|
|
235
|
-
if (~index) if ("number" === typeof instruction[2]) {
|
|
236
|
-
url[key] = address.slice(0, index);
|
|
237
|
-
address = address.slice(index + instruction[2]);
|
|
238
|
-
} else {
|
|
239
|
-
url[key] = address.slice(index);
|
|
240
|
-
address = address.slice(0, index);
|
|
241
|
-
}
|
|
242
|
-
} else if (index = parse.exec(address)) {
|
|
243
|
-
url[key] = index[1];
|
|
244
|
-
address = address.slice(0, index.index);
|
|
245
|
-
}
|
|
246
|
-
url[key] = url[key] || (relative && instruction[3] ? location[key] || "" : "");
|
|
247
|
-
if (instruction[4]) url[key] = url[key].toLowerCase();
|
|
248
|
-
}
|
|
249
|
-
if (parser) url.query = parser(url.query);
|
|
250
|
-
if (relative && location.slashes && url.pathname.charAt(0) !== "/" && (url.pathname !== "" || location.pathname !== "")) url.pathname = resolve(url.pathname, location.pathname);
|
|
251
|
-
if (url.pathname.charAt(0) !== "/" && isSpecial(url.protocol)) url.pathname = "/" + url.pathname;
|
|
252
|
-
if (!required(url.port, url.protocol)) {
|
|
253
|
-
url.host = url.hostname;
|
|
254
|
-
url.port = "";
|
|
255
|
-
}
|
|
256
|
-
url.username = url.password = "";
|
|
257
|
-
if (url.auth) {
|
|
258
|
-
index = url.auth.indexOf(":");
|
|
259
|
-
if (~index) {
|
|
260
|
-
url.username = url.auth.slice(0, index);
|
|
261
|
-
url.username = encodeURIComponent(decodeURIComponent(url.username));
|
|
262
|
-
url.password = url.auth.slice(index + 1);
|
|
263
|
-
url.password = encodeURIComponent(decodeURIComponent(url.password));
|
|
264
|
-
} else url.username = encodeURIComponent(decodeURIComponent(url.auth));
|
|
265
|
-
url.auth = url.password ? url.username + ":" + url.password : url.username;
|
|
266
|
-
}
|
|
267
|
-
url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
|
|
268
|
-
url.href = url.toString();
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* This is convenience method for changing properties in the URL instance to
|
|
272
|
-
* insure that they all propagate correctly.
|
|
273
|
-
*
|
|
274
|
-
* @param {String} part Property we need to adjust.
|
|
275
|
-
* @param {Mixed} value The newly assigned value.
|
|
276
|
-
* @param {Boolean|Function} fn When setting the query, it will be the function
|
|
277
|
-
* used to parse the query.
|
|
278
|
-
* When setting the protocol, double slash will be
|
|
279
|
-
* removed from the final url if it is true.
|
|
280
|
-
* @returns {URL} URL instance for chaining.
|
|
281
|
-
* @public
|
|
282
|
-
*/
|
|
283
|
-
function set(part, value, fn) {
|
|
284
|
-
var url = this;
|
|
285
|
-
switch (part) {
|
|
286
|
-
case "query":
|
|
287
|
-
if ("string" === typeof value && value.length) value = (fn || qs.parse)(value);
|
|
288
|
-
url[part] = value;
|
|
289
|
-
break;
|
|
290
|
-
case "port":
|
|
291
|
-
url[part] = value;
|
|
292
|
-
if (!required(value, url.protocol)) {
|
|
293
|
-
url.host = url.hostname;
|
|
294
|
-
url[part] = "";
|
|
295
|
-
} else if (value) url.host = url.hostname + ":" + value;
|
|
296
|
-
break;
|
|
297
|
-
case "hostname":
|
|
298
|
-
url[part] = value;
|
|
299
|
-
if (url.port) value += ":" + url.port;
|
|
300
|
-
url.host = value;
|
|
301
|
-
break;
|
|
302
|
-
case "host":
|
|
303
|
-
url[part] = value;
|
|
304
|
-
if (port.test(value)) {
|
|
305
|
-
value = value.split(":");
|
|
306
|
-
url.port = value.pop();
|
|
307
|
-
url.hostname = value.join(":");
|
|
308
|
-
} else {
|
|
309
|
-
url.hostname = value;
|
|
310
|
-
url.port = "";
|
|
311
|
-
}
|
|
312
|
-
break;
|
|
313
|
-
case "protocol":
|
|
314
|
-
url.protocol = value.toLowerCase();
|
|
315
|
-
url.slashes = !fn;
|
|
316
|
-
break;
|
|
317
|
-
case "pathname":
|
|
318
|
-
case "hash":
|
|
319
|
-
if (value) {
|
|
320
|
-
var char = part === "pathname" ? "/" : "#";
|
|
321
|
-
url[part] = value.charAt(0) !== char ? char + value : value;
|
|
322
|
-
} else url[part] = value;
|
|
323
|
-
break;
|
|
324
|
-
case "username":
|
|
325
|
-
case "password":
|
|
326
|
-
url[part] = encodeURIComponent(value);
|
|
327
|
-
break;
|
|
328
|
-
case "auth":
|
|
329
|
-
var index = value.indexOf(":");
|
|
330
|
-
if (~index) {
|
|
331
|
-
url.username = value.slice(0, index);
|
|
332
|
-
url.username = encodeURIComponent(decodeURIComponent(url.username));
|
|
333
|
-
url.password = value.slice(index + 1);
|
|
334
|
-
url.password = encodeURIComponent(decodeURIComponent(url.password));
|
|
335
|
-
} else url.username = encodeURIComponent(decodeURIComponent(value));
|
|
336
|
-
}
|
|
337
|
-
for (var i = 0; i < rules.length; i++) {
|
|
338
|
-
var ins = rules[i];
|
|
339
|
-
if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();
|
|
340
|
-
}
|
|
341
|
-
url.auth = url.password ? url.username + ":" + url.password : url.username;
|
|
342
|
-
url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
|
|
343
|
-
url.href = url.toString();
|
|
344
|
-
return url;
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* Transform the properties back in to a valid and full URL string.
|
|
348
|
-
*
|
|
349
|
-
* @param {Function} stringify Optional query stringify function.
|
|
350
|
-
* @returns {String} Compiled version of the URL.
|
|
351
|
-
* @public
|
|
352
|
-
*/
|
|
353
|
-
function toString(stringify) {
|
|
354
|
-
if (!stringify || "function" !== typeof stringify) stringify = qs.stringify;
|
|
355
|
-
var query, url = this, host = url.host, protocol = url.protocol;
|
|
356
|
-
if (protocol && protocol.charAt(protocol.length - 1) !== ":") protocol += ":";
|
|
357
|
-
var result = protocol + (url.protocol && url.slashes || isSpecial(url.protocol) ? "//" : "");
|
|
358
|
-
if (url.username) {
|
|
359
|
-
result += url.username;
|
|
360
|
-
if (url.password) result += ":" + url.password;
|
|
361
|
-
result += "@";
|
|
362
|
-
} else if (url.password) {
|
|
363
|
-
result += ":" + url.password;
|
|
364
|
-
result += "@";
|
|
365
|
-
} else if (url.protocol !== "file:" && isSpecial(url.protocol) && !host && url.pathname !== "/") result += "@";
|
|
366
|
-
if (host[host.length - 1] === ":" || port.test(url.hostname) && !url.port) host += ":";
|
|
367
|
-
result += host + url.pathname;
|
|
368
|
-
query = "object" === typeof url.query ? stringify(url.query) : url.query;
|
|
369
|
-
if (query) result += "?" !== query.charAt(0) ? "?" + query : query;
|
|
370
|
-
if (url.hash) result += url.hash;
|
|
371
|
-
return result;
|
|
372
|
-
}
|
|
373
|
-
Url.prototype = {
|
|
374
|
-
set,
|
|
375
|
-
toString
|
|
376
|
-
};
|
|
377
|
-
Url.extractProtocol = extractProtocol;
|
|
378
|
-
Url.location = lolcation;
|
|
379
|
-
Url.trimLeft = trimLeft;
|
|
380
|
-
Url.qs = qs;
|
|
381
|
-
module.exports = Url;
|
|
382
|
-
}));
|
|
383
|
-
|
|
384
|
-
//#endregion
|
|
385
|
-
export default require_url_parse();
|
|
386
|
-
|
|
387
|
-
export { require_url_parse };
|
|
388
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../../../../../../node_modules/.pnpm/url-parse@1.5.10/node_modules/url-parse/index.js"],"sourcesContent":["'use strict';\n\nvar required = require('requires-port')\n , qs = require('querystringify')\n , controlOrWhitespace = /^[\\x00-\\x20\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]+/\n , CRHTLF = /[\\n\\r\\t]/g\n , slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\\/\\//\n , port = /:\\d+$/\n , protocolre = /^([a-z][a-z0-9.+-]*:)?(\\/\\/)?([\\\\/]+)?([\\S\\s]*)/i\n , windowsDriveLetter = /^[a-zA-Z]:/;\n\n/**\n * Remove control characters and whitespace from the beginning of a string.\n *\n * @param {Object|String} str String to trim.\n * @returns {String} A new string representing `str` stripped of control\n * characters and whitespace from its beginning.\n * @public\n */\nfunction trimLeft(str) {\n return (str ? str : '').toString().replace(controlOrWhitespace, '');\n}\n\n/**\n * These are the parse rules for the URL parser, it informs the parser\n * about:\n *\n * 0. The char it Needs to parse, if it's a string it should be done using\n * indexOf, RegExp using exec and NaN means set as current value.\n * 1. The property we should set when parsing this value.\n * 2. Indication if it's backwards or forward parsing, when set as number it's\n * the value of extra chars that should be split off.\n * 3. Inherit from location if non existing in the parser.\n * 4. `toLowerCase` the resulting value.\n */\nvar rules = [\n ['#', 'hash'], // Extract from the back.\n ['?', 'query'], // Extract from the back.\n function sanitize(address, url) { // Sanitize what is left of the address\n return isSpecial(url.protocol) ? address.replace(/\\\\/g, '/') : address;\n },\n ['/', 'pathname'], // Extract from the back.\n ['@', 'auth', 1], // Extract from the front.\n [NaN, 'host', undefined, 1, 1], // Set left over value.\n [/:(\\d*)$/, 'port', undefined, 1], // RegExp the back.\n [NaN, 'hostname', undefined, 1, 1] // Set left over.\n];\n\n/**\n * These properties should not be copied or inherited from. This is only needed\n * for all non blob URL's as a blob URL does not include a hash, only the\n * origin.\n *\n * @type {Object}\n * @private\n */\nvar ignore = { hash: 1, query: 1 };\n\n/**\n * The location object differs when your code is loaded through a normal page,\n * Worker or through a worker using a blob. And with the blobble begins the\n * trouble as the location object will contain the URL of the blob, not the\n * location of the page where our code is loaded in. The actual origin is\n * encoded in the `pathname` so we can thankfully generate a good \"default\"\n * location from it so we can generate proper relative URL's again.\n *\n * @param {Object|String} loc Optional default location object.\n * @returns {Object} lolcation object.\n * @public\n */\nfunction lolcation(loc) {\n var globalVar;\n\n if (typeof window !== 'undefined') globalVar = window;\n else if (typeof global !== 'undefined') globalVar = global;\n else if (typeof self !== 'undefined') globalVar = self;\n else globalVar = {};\n\n var location = globalVar.location || {};\n loc = loc || location;\n\n var finaldestination = {}\n , type = typeof loc\n , key;\n\n if ('blob:' === loc.protocol) {\n finaldestination = new Url(unescape(loc.pathname), {});\n } else if ('string' === type) {\n finaldestination = new Url(loc, {});\n for (key in ignore) delete finaldestination[key];\n } else if ('object' === type) {\n for (key in loc) {\n if (key in ignore) continue;\n finaldestination[key] = loc[key];\n }\n\n if (finaldestination.slashes === undefined) {\n finaldestination.slashes = slashes.test(loc.href);\n }\n }\n\n return finaldestination;\n}\n\n/**\n * Check whether a protocol scheme is special.\n *\n * @param {String} The protocol scheme of the URL\n * @return {Boolean} `true` if the protocol scheme is special, else `false`\n * @private\n */\nfunction isSpecial(scheme) {\n return (\n scheme === 'file:' ||\n scheme === 'ftp:' ||\n scheme === 'http:' ||\n scheme === 'https:' ||\n scheme === 'ws:' ||\n scheme === 'wss:'\n );\n}\n\n/**\n * @typedef ProtocolExtract\n * @type Object\n * @property {String} protocol Protocol matched in the URL, in lowercase.\n * @property {Boolean} slashes `true` if protocol is followed by \"//\", else `false`.\n * @property {String} rest Rest of the URL that is not part of the protocol.\n */\n\n/**\n * Extract protocol information from a URL with/without double slash (\"//\").\n *\n * @param {String} address URL we want to extract from.\n * @param {Object} location\n * @return {ProtocolExtract} Extracted information.\n * @private\n */\nfunction extractProtocol(address, location) {\n address = trimLeft(address);\n address = address.replace(CRHTLF, '');\n location = location || {};\n\n var match = protocolre.exec(address);\n var protocol = match[1] ? match[1].toLowerCase() : '';\n var forwardSlashes = !!match[2];\n var otherSlashes = !!match[3];\n var slashesCount = 0;\n var rest;\n\n if (forwardSlashes) {\n if (otherSlashes) {\n rest = match[2] + match[3] + match[4];\n slashesCount = match[2].length + match[3].length;\n } else {\n rest = match[2] + match[4];\n slashesCount = match[2].length;\n }\n } else {\n if (otherSlashes) {\n rest = match[3] + match[4];\n slashesCount = match[3].length;\n } else {\n rest = match[4]\n }\n }\n\n if (protocol === 'file:') {\n if (slashesCount >= 2) {\n rest = rest.slice(2);\n }\n } else if (isSpecial(protocol)) {\n rest = match[4];\n } else if (protocol) {\n if (forwardSlashes) {\n rest = rest.slice(2);\n }\n } else if (slashesCount >= 2 && isSpecial(location.protocol)) {\n rest = match[4];\n }\n\n return {\n protocol: protocol,\n slashes: forwardSlashes || isSpecial(protocol),\n slashesCount: slashesCount,\n rest: rest\n };\n}\n\n/**\n * Resolve a relative URL pathname against a base URL pathname.\n *\n * @param {String} relative Pathname of the relative URL.\n * @param {String} base Pathname of the base URL.\n * @return {String} Resolved pathname.\n * @private\n */\nfunction resolve(relative, base) {\n if (relative === '') return base;\n\n var path = (base || '/').split('/').slice(0, -1).concat(relative.split('/'))\n , i = path.length\n , last = path[i - 1]\n , unshift = false\n , up = 0;\n\n while (i--) {\n if (path[i] === '.') {\n path.splice(i, 1);\n } else if (path[i] === '..') {\n path.splice(i, 1);\n up++;\n } else if (up) {\n if (i === 0) unshift = true;\n path.splice(i, 1);\n up--;\n }\n }\n\n if (unshift) path.unshift('');\n if (last === '.' || last === '..') path.push('');\n\n return path.join('/');\n}\n\n/**\n * The actual URL instance. Instead of returning an object we've opted-in to\n * create an actual constructor as it's much more memory efficient and\n * faster and it pleases my OCD.\n *\n * It is worth noting that we should not use `URL` as class name to prevent\n * clashes with the global URL instance that got introduced in browsers.\n *\n * @constructor\n * @param {String} address URL we want to parse.\n * @param {Object|String} [location] Location defaults for relative paths.\n * @param {Boolean|Function} [parser] Parser for the query string.\n * @private\n */\nfunction Url(address, location, parser) {\n address = trimLeft(address);\n address = address.replace(CRHTLF, '');\n\n if (!(this instanceof Url)) {\n return new Url(address, location, parser);\n }\n\n var relative, extracted, parse, instruction, index, key\n , instructions = rules.slice()\n , type = typeof location\n , url = this\n , i = 0;\n\n //\n // The following if statements allows this module two have compatibility with\n // 2 different API:\n //\n // 1. Node.js's `url.parse` api which accepts a URL, boolean as arguments\n // where the boolean indicates that the query string should also be parsed.\n //\n // 2. The `URL` interface of the browser which accepts a URL, object as\n // arguments. The supplied object will be used as default values / fall-back\n // for relative paths.\n //\n if ('object' !== type && 'string' !== type) {\n parser = location;\n location = null;\n }\n\n if (parser && 'function' !== typeof parser) parser = qs.parse;\n\n location = lolcation(location);\n\n //\n // Extract protocol information before running the instructions.\n //\n extracted = extractProtocol(address || '', location);\n relative = !extracted.protocol && !extracted.slashes;\n url.slashes = extracted.slashes || relative && location.slashes;\n url.protocol = extracted.protocol || location.protocol || '';\n address = extracted.rest;\n\n //\n // When the authority component is absent the URL starts with a path\n // component.\n //\n if (\n extracted.protocol === 'file:' && (\n extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) ||\n (!extracted.slashes &&\n (extracted.protocol ||\n extracted.slashesCount < 2 ||\n !isSpecial(url.protocol)))\n ) {\n instructions[3] = [/(.*)/, 'pathname'];\n }\n\n for (; i < instructions.length; i++) {\n instruction = instructions[i];\n\n if (typeof instruction === 'function') {\n address = instruction(address, url);\n continue;\n }\n\n parse = instruction[0];\n key = instruction[1];\n\n if (parse !== parse) {\n url[key] = address;\n } else if ('string' === typeof parse) {\n index = parse === '@'\n ? address.lastIndexOf(parse)\n : address.indexOf(parse);\n\n if (~index) {\n if ('number' === typeof instruction[2]) {\n url[key] = address.slice(0, index);\n address = address.slice(index + instruction[2]);\n } else {\n url[key] = address.slice(index);\n address = address.slice(0, index);\n }\n }\n } else if ((index = parse.exec(address))) {\n url[key] = index[1];\n address = address.slice(0, index.index);\n }\n\n url[key] = url[key] || (\n relative && instruction[3] ? location[key] || '' : ''\n );\n\n //\n // Hostname, host and protocol should be lowercased so they can be used to\n // create a proper `origin`.\n //\n if (instruction[4]) url[key] = url[key].toLowerCase();\n }\n\n //\n // Also parse the supplied query string in to an object. If we're supplied\n // with a custom parser as function use that instead of the default build-in\n // parser.\n //\n if (parser) url.query = parser(url.query);\n\n //\n // If the URL is relative, resolve the pathname against the base URL.\n //\n if (\n relative\n && location.slashes\n && url.pathname.charAt(0) !== '/'\n && (url.pathname !== '' || location.pathname !== '')\n ) {\n url.pathname = resolve(url.pathname, location.pathname);\n }\n\n //\n // Default to a / for pathname if none exists. This normalizes the URL\n // to always have a /\n //\n if (url.pathname.charAt(0) !== '/' && isSpecial(url.protocol)) {\n url.pathname = '/' + url.pathname;\n }\n\n //\n // We should not add port numbers if they are already the default port number\n // for a given protocol. As the host also contains the port number we're going\n // override it with the hostname which contains no port number.\n //\n if (!required(url.port, url.protocol)) {\n url.host = url.hostname;\n url.port = '';\n }\n\n //\n // Parse down the `auth` for the username and password.\n //\n url.username = url.password = '';\n\n if (url.auth) {\n index = url.auth.indexOf(':');\n\n if (~index) {\n url.username = url.auth.slice(0, index);\n url.username = encodeURIComponent(decodeURIComponent(url.username));\n\n url.password = url.auth.slice(index + 1);\n url.password = encodeURIComponent(decodeURIComponent(url.password))\n } else {\n url.username = encodeURIComponent(decodeURIComponent(url.auth));\n }\n\n url.auth = url.password ? url.username +':'+ url.password : url.username;\n }\n\n url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host\n ? url.protocol +'//'+ url.host\n : 'null';\n\n //\n // The href is just the compiled result.\n //\n url.href = url.toString();\n}\n\n/**\n * This is convenience method for changing properties in the URL instance to\n * insure that they all propagate correctly.\n *\n * @param {String} part Property we need to adjust.\n * @param {Mixed} value The newly assigned value.\n * @param {Boolean|Function} fn When setting the query, it will be the function\n * used to parse the query.\n * When setting the protocol, double slash will be\n * removed from the final url if it is true.\n * @returns {URL} URL instance for chaining.\n * @public\n */\nfunction set(part, value, fn) {\n var url = this;\n\n switch (part) {\n case 'query':\n if ('string' === typeof value && value.length) {\n value = (fn || qs.parse)(value);\n }\n\n url[part] = value;\n break;\n\n case 'port':\n url[part] = value;\n\n if (!required(value, url.protocol)) {\n url.host = url.hostname;\n url[part] = '';\n } else if (value) {\n url.host = url.hostname +':'+ value;\n }\n\n break;\n\n case 'hostname':\n url[part] = value;\n\n if (url.port) value += ':'+ url.port;\n url.host = value;\n break;\n\n case 'host':\n url[part] = value;\n\n if (port.test(value)) {\n value = value.split(':');\n url.port = value.pop();\n url.hostname = value.join(':');\n } else {\n url.hostname = value;\n url.port = '';\n }\n\n break;\n\n case 'protocol':\n url.protocol = value.toLowerCase();\n url.slashes = !fn;\n break;\n\n case 'pathname':\n case 'hash':\n if (value) {\n var char = part === 'pathname' ? '/' : '#';\n url[part] = value.charAt(0) !== char ? char + value : value;\n } else {\n url[part] = value;\n }\n break;\n\n case 'username':\n case 'password':\n url[part] = encodeURIComponent(value);\n break;\n\n case 'auth':\n var index = value.indexOf(':');\n\n if (~index) {\n url.username = value.slice(0, index);\n url.username = encodeURIComponent(decodeURIComponent(url.username));\n\n url.password = value.slice(index + 1);\n url.password = encodeURIComponent(decodeURIComponent(url.password));\n } else {\n url.username = encodeURIComponent(decodeURIComponent(value));\n }\n }\n\n for (var i = 0; i < rules.length; i++) {\n var ins = rules[i];\n\n if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();\n }\n\n url.auth = url.password ? url.username +':'+ url.password : url.username;\n\n url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host\n ? url.protocol +'//'+ url.host\n : 'null';\n\n url.href = url.toString();\n\n return url;\n}\n\n/**\n * Transform the properties back in to a valid and full URL string.\n *\n * @param {Function} stringify Optional query stringify function.\n * @returns {String} Compiled version of the URL.\n * @public\n */\nfunction toString(stringify) {\n if (!stringify || 'function' !== typeof stringify) stringify = qs.stringify;\n\n var query\n , url = this\n , host = url.host\n , protocol = url.protocol;\n\n if (protocol && protocol.charAt(protocol.length - 1) !== ':') protocol += ':';\n\n var result =\n protocol +\n ((url.protocol && url.slashes) || isSpecial(url.protocol) ? '//' : '');\n\n if (url.username) {\n result += url.username;\n if (url.password) result += ':'+ url.password;\n result += '@';\n } else if (url.password) {\n result += ':'+ url.password;\n result += '@';\n } else if (\n url.protocol !== 'file:' &&\n isSpecial(url.protocol) &&\n !host &&\n url.pathname !== '/'\n ) {\n //\n // Add back the empty userinfo, otherwise the original invalid URL\n // might be transformed into a valid one with `url.pathname` as host.\n //\n result += '@';\n }\n\n //\n // Trailing colon is removed from `url.host` when it is parsed. If it still\n // ends with a colon, then add back the trailing colon that was removed. This\n // prevents an invalid URL from being transformed into a valid one.\n //\n if (host[host.length - 1] === ':' || (port.test(url.hostname) && !url.port)) {\n host += ':';\n }\n\n result += host + url.pathname;\n\n query = 'object' === typeof url.query ? stringify(url.query) : url.query;\n if (query) result += '?' !== query.charAt(0) ? '?'+ query : query;\n\n if (url.hash) result += url.hash;\n\n return result;\n}\n\nUrl.prototype = { set: set, toString: toString };\n\n//\n// Expose the URL parser and some additional properties that might be useful for\n// others or testing.\n//\nUrl.extractProtocol = extractProtocol;\nUrl.location = lolcation;\nUrl.trimLeft = trimLeft;\nUrl.qs = qs;\n\nmodule.exports = Url;\n"],"x_google_ignoreList":[0],"mappings":";;;;;;CAEA,IAAI,oCACA,+BACA,sBAAsB,8EACtB,SAAS,aACT,UAAU,iCACV,OAAO,SAC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X,WAAW,IAAI;EAEnB,IAAI,YAAY,SAAS,OAAO,SAAS,SAAS,CAAC,MAAM,KAAK,YAAY;EAE1E,IAAI,SACF,YACE,IAAI,YAAY,IAAI,WAAY,UAAU,IAAI,QAAQ,IAAI,OAAO;EAErE,IAAI,IAAI,UAAU;GAChB,UAAU,IAAI;GACd,IAAI,IAAI,UAAU,UAAU,MAAK,IAAI;GACrC,UAAU;EACZ,OAAO,IAAI,IAAI,UAAU;GACvB,UAAU,MAAK,IAAI;GACnB,UAAU;EACZ,OAAO,IACL,IAAI,aAAa,WACjB,UAAU,IAAI,QAAQ,KACtB,CAAC,QACD,IAAI,aAAa,KAMjB,UAAU;EAQZ,IAAI,KAAK,KAAK,SAAS,OAAO,OAAQ,KAAK,KAAK,IAAI,QAAQ,KAAK,CAAC,IAAI,MACpE,QAAQ;EAGV,UAAU,OAAO,IAAI;EAErB,QAAQ,aAAa,OAAO,IAAI,QAAQ,UAAU,IAAI,KAAK,IAAI,IAAI;EACnE,IAAI,OAAO,UAAU,QAAQ,MAAM,OAAO,CAAC,IAAI,MAAK,QAAQ;EAE5D,IAAI,IAAI,MAAM,UAAU,IAAI;EAE5B,OAAO;CACT;CAEA,IAAI,YAAY;EAAO;EAAe;CAAS;CAM/C,IAAI,kBAAkB;CACtB,IAAI,WAAW;CACf,IAAI,WAAW;CACf,IAAI,KAAK;CAET,OAAO,UAAU"}
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { Broker } from "./broker.mjs";
|
|
2
|
-
import { EventEmitter } from "node:events";
|
|
3
|
-
|
|
4
|
-
//#region ../../packages/herald/src/communicators/broker-registry.ts
|
|
5
|
-
/**
|
|
6
|
-
* Error thrown when a broker is not found
|
|
7
|
-
*/
|
|
8
|
-
var MissingBrokerError = class extends Error {
|
|
9
|
-
brokerName;
|
|
10
|
-
constructor(message, brokerName) {
|
|
11
|
-
super(message);
|
|
12
|
-
this.name = "MissingBrokerError";
|
|
13
|
-
this.brokerName = brokerName;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Broker Registry
|
|
18
|
-
*
|
|
19
|
-
* Maintains registry of named brokers.
|
|
20
|
-
* Similar to DataSourceRegistry in @warlock.js/cascade
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```typescript
|
|
24
|
-
* // Register a broker
|
|
25
|
-
* brokerRegistry.register({
|
|
26
|
-
* name: "default",
|
|
27
|
-
* driver: rabbitMQDriver,
|
|
28
|
-
* isDefault: true,
|
|
29
|
-
* });
|
|
30
|
-
*
|
|
31
|
-
* // Get the default broker
|
|
32
|
-
* const comm = brokerRegistry.get();
|
|
33
|
-
*
|
|
34
|
-
* // Get a specific broker by name
|
|
35
|
-
* const analytics = brokerRegistry.get("analytics");
|
|
36
|
-
*
|
|
37
|
-
* // Listen for events
|
|
38
|
-
* brokerRegistry.on("connected", (comm) => {
|
|
39
|
-
* console.log(`${comm.name} connected`);
|
|
40
|
-
* });
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
var BrokerRegistry = class {
|
|
44
|
-
sources = /* @__PURE__ */ new Map();
|
|
45
|
-
defaultSource;
|
|
46
|
-
events = new EventEmitter();
|
|
47
|
-
/**
|
|
48
|
-
* Register a new broker
|
|
49
|
-
*
|
|
50
|
-
* Sets up event forwarding from the driver to the registry.
|
|
51
|
-
*
|
|
52
|
-
* @param options - Broker configuration
|
|
53
|
-
* @returns The registered broker instance
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```typescript
|
|
57
|
-
* const broker = brokerRegistry.register({
|
|
58
|
-
* name: "primary",
|
|
59
|
-
* driver: myDriver,
|
|
60
|
-
* isDefault: true,
|
|
61
|
-
* });
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
register(options) {
|
|
65
|
-
const broker = new Broker(options);
|
|
66
|
-
this.sources.set(broker.name, broker);
|
|
67
|
-
const isNewDefault = broker.isDefault || !this.defaultSource;
|
|
68
|
-
if (isNewDefault) this.defaultSource = broker;
|
|
69
|
-
this.events.emit("registered", broker);
|
|
70
|
-
if (isNewDefault) this.events.emit("default-registered", broker);
|
|
71
|
-
broker.driver.on("connected", () => {
|
|
72
|
-
this.events.emit("connected", broker);
|
|
73
|
-
});
|
|
74
|
-
broker.driver.on("disconnected", () => {
|
|
75
|
-
this.events.emit("disconnected", broker);
|
|
76
|
-
});
|
|
77
|
-
return broker;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Clear all registered brokers
|
|
81
|
-
*/
|
|
82
|
-
clear() {
|
|
83
|
-
this.defaultSource = void 0;
|
|
84
|
-
this.sources.clear();
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Listen for registry events
|
|
88
|
-
*
|
|
89
|
-
* @param event - Event to listen for
|
|
90
|
-
* @param listener - Callback function
|
|
91
|
-
*
|
|
92
|
-
* @example
|
|
93
|
-
* ```typescript
|
|
94
|
-
* brokerRegistry.on("registered", (comm) => {
|
|
95
|
-
* console.log(`Broker "${comm.name}" registered`);
|
|
96
|
-
* });
|
|
97
|
-
*
|
|
98
|
-
* brokerRegistry.on("connected", (comm) => {
|
|
99
|
-
* console.log(`Broker "${comm.name}" connected`);
|
|
100
|
-
* });
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
|
-
on(event, listener) {
|
|
104
|
-
this.events.on(event, listener);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Listen for a registry event once
|
|
108
|
-
*
|
|
109
|
-
* @param event - Event to listen for
|
|
110
|
-
* @param listener - Callback function
|
|
111
|
-
*/
|
|
112
|
-
once(event, listener) {
|
|
113
|
-
this.events.once(event, listener);
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Remove an event listener
|
|
117
|
-
*
|
|
118
|
-
* @param event - Event to stop listening for
|
|
119
|
-
* @param listener - Callback to remove
|
|
120
|
-
*/
|
|
121
|
-
off(event, listener) {
|
|
122
|
-
this.events.off(event, listener);
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Get a broker by name or the default one
|
|
126
|
-
*
|
|
127
|
-
* @param name - Optional broker name
|
|
128
|
-
* @returns Broker instance
|
|
129
|
-
* @throws MissingBrokerError if not found
|
|
130
|
-
*
|
|
131
|
-
* @example
|
|
132
|
-
* ```typescript
|
|
133
|
-
* // Get default broker
|
|
134
|
-
* const comm = brokerRegistry.get();
|
|
135
|
-
*
|
|
136
|
-
* // Get specific broker
|
|
137
|
-
* const analytics = brokerRegistry.get("analytics");
|
|
138
|
-
* ```
|
|
139
|
-
*/
|
|
140
|
-
get(name) {
|
|
141
|
-
if (name !== void 0) {
|
|
142
|
-
const source = this.sources.get(name);
|
|
143
|
-
if (!source) throw new MissingBrokerError(`Broker "${name}" is not registered.`, name);
|
|
144
|
-
return source;
|
|
145
|
-
}
|
|
146
|
-
if (!this.defaultSource) throw new MissingBrokerError("No default broker registered.");
|
|
147
|
-
return this.defaultSource;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Check if a broker exists
|
|
151
|
-
*
|
|
152
|
-
* @param name - Broker name to check
|
|
153
|
-
* @returns True if exists
|
|
154
|
-
*/
|
|
155
|
-
has(name) {
|
|
156
|
-
return this.sources.has(name);
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Check if any brokers are registered
|
|
160
|
-
*/
|
|
161
|
-
hasAny() {
|
|
162
|
-
return this.sources.size > 0;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Get all registered brokers
|
|
166
|
-
*
|
|
167
|
-
* @returns Array of all brokers
|
|
168
|
-
*
|
|
169
|
-
* @example
|
|
170
|
-
* ```typescript
|
|
171
|
-
* // Disconnect all brokers
|
|
172
|
-
* for (const comm of brokerRegistry.getAll()) {
|
|
173
|
-
* await comm.disconnect();
|
|
174
|
-
* }
|
|
175
|
-
* ```
|
|
176
|
-
*/
|
|
177
|
-
getAll() {
|
|
178
|
-
return Array.from(this.sources.values());
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Get all broker names
|
|
182
|
-
*
|
|
183
|
-
* @returns Array of broker names
|
|
184
|
-
*/
|
|
185
|
-
getNames() {
|
|
186
|
-
return Array.from(this.sources.keys());
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Get the default broker (if any)
|
|
190
|
-
*
|
|
191
|
-
* @returns Default broker or undefined
|
|
192
|
-
*/
|
|
193
|
-
getDefault() {
|
|
194
|
-
return this.defaultSource;
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
/**
|
|
198
|
-
* Global broker registry instance
|
|
199
|
-
*/
|
|
200
|
-
const brokerRegistry = new BrokerRegistry();
|
|
201
|
-
|
|
202
|
-
//#endregion
|
|
203
|
-
export { MissingBrokerError, brokerRegistry };
|
|
204
|
-
//# sourceMappingURL=broker-registry.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"broker-registry.mjs","names":[],"sources":["../../../../../../../../../../../packages/herald/src/communicators/broker-registry.ts"],"sourcesContent":["import { EventEmitter } from \"node:events\";\nimport type { BrokerRegistryEvent, BrokerRegistryListener } from \"../types\";\nimport { Broker, type BrokerOptions } from \"./broker\";\n\n/**\n * Error thrown when a broker is not found\n */\nexport class MissingBrokerError extends Error {\n public readonly brokerName?: string;\n\n public constructor(message: string, brokerName?: string) {\n super(message);\n this.name = \"MissingBrokerError\";\n this.brokerName = brokerName;\n }\n}\n\n/**\n * Broker Registry\n *\n * Maintains registry of named brokers.\n * Similar to DataSourceRegistry in @warlock.js/cascade\n *\n * @example\n * ```typescript\n * // Register a broker\n * brokerRegistry.register({\n * name: \"default\",\n * driver: rabbitMQDriver,\n * isDefault: true,\n * });\n *\n * // Get the default broker\n * const comm = brokerRegistry.get();\n *\n * // Get a specific broker by name\n * const analytics = brokerRegistry.get(\"analytics\");\n *\n * // Listen for events\n * brokerRegistry.on(\"connected\", (comm) => {\n * console.log(`${comm.name} connected`);\n * });\n * ```\n */\nclass BrokerRegistry {\n private readonly sources = new Map<string, Broker>();\n private defaultSource?: Broker;\n private readonly events = new EventEmitter();\n\n /**\n * Register a new broker\n *\n * Sets up event forwarding from the driver to the registry.\n *\n * @param options - Broker configuration\n * @returns The registered broker instance\n *\n * @example\n * ```typescript\n * const broker = brokerRegistry.register({\n * name: \"primary\",\n * driver: myDriver,\n * isDefault: true,\n * });\n * ```\n */\n public register(options: BrokerOptions): Broker {\n const broker = new Broker(options);\n this.sources.set(broker.name, broker);\n\n const isNewDefault = broker.isDefault || !this.defaultSource;\n\n if (isNewDefault) {\n this.defaultSource = broker;\n }\n\n // Emit registration events\n this.events.emit(\"registered\", broker);\n\n if (isNewDefault) {\n this.events.emit(\"default-registered\", broker);\n }\n\n // Forward driver events to registry\n broker.driver.on(\"connected\", () => {\n this.events.emit(\"connected\", broker);\n });\n\n broker.driver.on(\"disconnected\", () => {\n this.events.emit(\"disconnected\", broker);\n });\n\n return broker;\n }\n\n /**\n * Clear all registered brokers\n */\n public clear(): void {\n this.defaultSource = undefined;\n this.sources.clear();\n }\n\n /**\n * Listen for registry events\n *\n * @param event - Event to listen for\n * @param listener - Callback function\n *\n * @example\n * ```typescript\n * brokerRegistry.on(\"registered\", (comm) => {\n * console.log(`Broker \"${comm.name}\" registered`);\n * });\n *\n * brokerRegistry.on(\"connected\", (comm) => {\n * console.log(`Broker \"${comm.name}\" connected`);\n * });\n * ```\n */\n public on(event: BrokerRegistryEvent, listener: BrokerRegistryListener): void {\n this.events.on(event, listener);\n }\n\n /**\n * Listen for a registry event once\n *\n * @param event - Event to listen for\n * @param listener - Callback function\n */\n public once(event: BrokerRegistryEvent, listener: BrokerRegistryListener): void {\n this.events.once(event, listener);\n }\n\n /**\n * Remove an event listener\n *\n * @param event - Event to stop listening for\n * @param listener - Callback to remove\n */\n public off(event: BrokerRegistryEvent, listener: BrokerRegistryListener): void {\n this.events.off(event, listener);\n }\n\n /**\n * Get a broker by name or the default one\n *\n * @param name - Optional broker name\n * @returns Broker instance\n * @throws MissingBrokerError if not found\n *\n * @example\n * ```typescript\n * // Get default broker\n * const comm = brokerRegistry.get();\n *\n * // Get specific broker\n * const analytics = brokerRegistry.get(\"analytics\");\n * ```\n */\n public get(name?: string): Broker {\n if (name !== undefined) {\n const source = this.sources.get(name);\n if (!source) {\n throw new MissingBrokerError(`Broker \"${name}\" is not registered.`, name);\n }\n return source;\n }\n\n if (!this.defaultSource) {\n throw new MissingBrokerError(\"No default broker registered.\");\n }\n\n return this.defaultSource;\n }\n\n /**\n * Check if a broker exists\n *\n * @param name - Broker name to check\n * @returns True if exists\n */\n public has(name: string): boolean {\n return this.sources.has(name);\n }\n\n /**\n * Check if any brokers are registered\n */\n public hasAny(): boolean {\n return this.sources.size > 0;\n }\n\n /**\n * Get all registered brokers\n *\n * @returns Array of all brokers\n *\n * @example\n * ```typescript\n * // Disconnect all brokers\n * for (const comm of brokerRegistry.getAll()) {\n * await comm.disconnect();\n * }\n * ```\n */\n public getAll(): Broker[] {\n return Array.from(this.sources.values());\n }\n\n /**\n * Get all broker names\n *\n * @returns Array of broker names\n */\n public getNames(): string[] {\n return Array.from(this.sources.keys());\n }\n\n /**\n * Get the default broker (if any)\n *\n * @returns Default broker or undefined\n */\n public getDefault(): Broker | undefined {\n return this.defaultSource;\n }\n}\n\n/**\n * Global broker registry instance\n */\nexport const brokerRegistry = new BrokerRegistry();\n"],"mappings":";;;;;;;AAOA,IAAa,qBAAb,cAAwC,MAAM;CAC5C,AAAgB;CAEhB,AAAO,YAAY,SAAiB,YAAqB;EACvD,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,aAAa;CACpB;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,IAAM,iBAAN,MAAqB;CACnB,AAAiB,0BAAU,IAAI,IAAoB;CACnD,AAAQ;CACR,AAAiB,SAAS,IAAI,aAAa;;;;;;;;;;;;;;;;;;CAmB3C,AAAO,SAAS,SAAgC;EAC9C,MAAM,SAAS,IAAI,OA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