@warlock.js/notifications 4.15.0 → 5.0.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 +12 -0
- package/cjs/channel_api-CH3DxhRU.cjs +7463 -0
- package/cjs/channel_api-CH3DxhRU.cjs.map +1 -0
- package/cjs/chunk-fl3r8ClO.cjs +41 -0
- package/cjs/index.cjs +34 -4
- package/cjs/index.cjs.map +1 -1
- package/cjs/rabbitmq-driver-CJtyxjUQ.cjs +3 -0
- package/cjs/src-Cus6pYPC.cjs +10981 -0
- package/cjs/src-Cus6pYPC.cjs.map +1 -0
- package/esm/_virtual/_rolldown/runtime.mjs +32 -0
- package/esm/herald/src/communicators/broker-registry.mjs +204 -0
- package/esm/herald/src/communicators/broker-registry.mjs.map +1 -0
- package/esm/herald/src/communicators/broker.mjs +110 -0
- package/esm/herald/src/communicators/broker.mjs.map +1 -0
- package/esm/herald/src/communicators/index.mjs +4 -0
- package/esm/herald/src/decorators/consumable.mjs +36 -0
- package/esm/herald/src/decorators/consumable.mjs.map +1 -0
- package/esm/herald/src/decorators/index.mjs +3 -0
- package/esm/herald/src/drivers/index.mjs +5 -0
- package/esm/herald/src/drivers/rabbitmq/index.mjs +4 -0
- package/esm/herald/src/drivers/rabbitmq/rabbitmq-channel.mjs +403 -0
- package/esm/herald/src/drivers/rabbitmq/rabbitmq-channel.mjs.map +1 -0
- package/esm/herald/src/drivers/rabbitmq/rabbitmq-driver.mjs +303 -0
- package/esm/herald/src/drivers/rabbitmq/rabbitmq-driver.mjs.map +1 -0
- package/esm/herald/src/index.mjs +16 -0
- package/esm/herald/src/message-managers/event-consumer.mjs +76 -0
- package/esm/herald/src/message-managers/event-consumer.mjs.map +1 -0
- package/esm/herald/src/message-managers/event-message.mjs +85 -0
- package/esm/herald/src/message-managers/event-message.mjs.map +1 -0
- package/esm/herald/src/message-managers/index.mjs +4 -0
- package/esm/herald/src/message-managers/prepare-consumer-subscription.mjs +42 -0
- package/esm/herald/src/message-managers/prepare-consumer-subscription.mjs.map +1 -0
- package/esm/herald/src/use-case-broadcast.mjs +30 -0
- package/esm/herald/src/use-case-broadcast.mjs.map +1 -0
- package/esm/herald/src/utils/connect-to-broker.mjs +168 -0
- package/esm/herald/src/utils/connect-to-broker.mjs.map +1 -0
- package/esm/herald/src/utils/index.mjs +3 -0
- package/esm/in-app/base-notifications-repository.d.mts +15 -1
- package/esm/in-app/base-notifications-repository.d.mts.map +1 -1
- package/esm/in-app/base-notifications-repository.mjs +33 -3
- package/esm/in-app/base-notifications-repository.mjs.map +1 -1
- package/esm/in-app/in-app.d.mts +3 -3
- package/esm/in-app/in-app.d.mts.map +1 -1
- package/esm/node_modules/@mongez/reinforcements/esm/Random/_internal.mjs +6 -0
- package/esm/node_modules/@mongez/reinforcements/esm/Random/_internal.mjs.map +1 -0
- package/esm/node_modules/@mongez/reinforcements/esm/Random/bool.mjs +3 -0
- package/esm/node_modules/@mongez/reinforcements/esm/Random/color.mjs +3 -0
- package/esm/node_modules/@mongez/reinforcements/esm/Random/date.mjs +3 -0
- package/esm/node_modules/@mongez/reinforcements/esm/Random/float.mjs +3 -0
- package/esm/node_modules/@mongez/reinforcements/esm/Random/id.mjs +3 -0
- package/esm/node_modules/@mongez/reinforcements/esm/Random/int.mjs +3 -0
- package/esm/node_modules/@mongez/reinforcements/esm/Random/nanoid.mjs +3 -0
- package/esm/node_modules/@mongez/reinforcements/esm/Random/pick.mjs +3 -0
- package/esm/node_modules/@mongez/reinforcements/esm/Random/random.mjs +16 -0
- package/esm/node_modules/@mongez/reinforcements/esm/Random/sample.mjs +3 -0
- package/esm/node_modules/@mongez/reinforcements/esm/Random/string.mjs +3 -0
- package/esm/node_modules/@mongez/reinforcements/esm/Random/token.mjs +3 -0
- package/esm/node_modules/@mongez/reinforcements/esm/Random/uuid.mjs +3 -0
- package/esm/node_modules/@mongez/reinforcements/esm/Random/weighted.mjs +3 -0
- package/esm/node_modules/@mongez/reinforcements/esm/async/retry.mjs +3 -0
- package/esm/node_modules/@mongez/reinforcements/esm/index.mjs +24 -0
- package/esm/node_modules/@mongez/reinforcements/esm/mixed/clone/clone.mjs +82 -0
- package/esm/node_modules/@mongez/reinforcements/esm/mixed/clone/clone.mjs.map +1 -0
- package/esm/node_modules/@mongez/reinforcements/esm/number/round.mjs +17 -0
- package/esm/node_modules/@mongez/reinforcements/esm/number/round.mjs.map +1 -0
- package/esm/node_modules/@mongez/reinforcements/esm/object/except.mjs +13 -0
- package/esm/node_modules/@mongez/reinforcements/esm/object/except.mjs.map +1 -0
- package/esm/node_modules/@mongez/reinforcements/esm/object/get.mjs +18 -0
- package/esm/node_modules/@mongez/reinforcements/esm/object/get.mjs.map +1 -0
- package/esm/node_modules/@mongez/reinforcements/esm/object/omit.mjs +17 -0
- package/esm/node_modules/@mongez/reinforcements/esm/object/omit.mjs.map +1 -0
- package/esm/node_modules/@mongez/reinforcements/esm/object/unset.mjs +30 -0
- package/esm/node_modules/@mongez/reinforcements/esm/object/unset.mjs.map +1 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/capitalize.mjs +19 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/capitalize.mjs.map +1 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/ltrim.mjs +18 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/ltrim.mjs.map +1 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/readMoreChars.mjs +14 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/readMoreChars.mjs.map +1 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/rtrim.mjs +18 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/rtrim.mjs.map +1 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/toCamelCase.mjs +22 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/toCamelCase.mjs.map +1 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/toKebabCase.mjs +17 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/toKebabCase.mjs.map +1 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/toSnakeCase.mjs +21 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/toSnakeCase.mjs.map +1 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/toStudlyCase.mjs +21 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/toStudlyCase.mjs.map +1 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/trim.mjs +20 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/trim.mjs.map +1 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/ucfirst.mjs +15 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/ucfirst.mjs.map +1 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/words.mjs +25 -0
- package/esm/node_modules/@mongez/reinforcements/esm/string/words.mjs.map +1 -0
- package/esm/node_modules/@mongez/reinforcements/esm/utils/escapeRegex.mjs +11 -0
- package/esm/node_modules/@mongez/reinforcements/esm/utils/escapeRegex.mjs.map +1 -0
- package/esm/node_modules/@mongez/reinforcements/esm/utils/lazy.mjs +100 -0
- package/esm/node_modules/@mongez/reinforcements/esm/utils/lazy.mjs.map +1 -0
- package/esm/node_modules/@mongez/reinforcements/esm/utils/tap.mjs +27 -0
- package/esm/node_modules/@mongez/reinforcements/esm/utils/tap.mjs.map +1 -0
- package/esm/node_modules/@mongez/supportive-is/esm/index.mjs +353 -0
- package/esm/node_modules/@mongez/supportive-is/esm/index.mjs.map +1 -0
- package/esm/node_modules/amqplib/channel_api.mjs +28 -0
- package/esm/node_modules/amqplib/channel_api.mjs.map +1 -0
- package/esm/node_modules/amqplib/lib/api_args.mjs +241 -0
- package/esm/node_modules/amqplib/lib/api_args.mjs.map +1 -0
- package/esm/node_modules/amqplib/lib/bitset.mjs +130 -0
- package/esm/node_modules/amqplib/lib/bitset.mjs.map +1 -0
- package/esm/node_modules/amqplib/lib/channel.mjs +302 -0
- package/esm/node_modules/amqplib/lib/channel.mjs.map +1 -0
- package/esm/node_modules/amqplib/lib/channel_model.mjs +206 -0
- package/esm/node_modules/amqplib/lib/channel_model.mjs.map +1 -0
- package/esm/node_modules/amqplib/lib/codec.mjs +273 -0
- package/esm/node_modules/amqplib/lib/codec.mjs.map +1 -0
- package/esm/node_modules/amqplib/lib/connect.mjs +143 -0
- package/esm/node_modules/amqplib/lib/connect.mjs.map +1 -0
- package/esm/node_modules/amqplib/lib/connection.mjs +416 -0
- package/esm/node_modules/amqplib/lib/connection.mjs.map +1 -0
- package/esm/node_modules/amqplib/lib/credentials.mjs +50 -0
- package/esm/node_modules/amqplib/lib/credentials.mjs.map +1 -0
- package/esm/node_modules/amqplib/lib/defs.mjs +4600 -0
- package/esm/node_modules/amqplib/lib/defs.mjs.map +1 -0
- package/esm/node_modules/amqplib/lib/error.mjs +29 -0
- package/esm/node_modules/amqplib/lib/error.mjs.map +1 -0
- package/esm/node_modules/amqplib/lib/format.mjs +28 -0
- package/esm/node_modules/amqplib/lib/format.mjs.map +1 -0
- package/esm/node_modules/amqplib/lib/frame.mjs +130 -0
- package/esm/node_modules/amqplib/lib/frame.mjs.map +1 -0
- package/esm/node_modules/amqplib/lib/heartbeat.mjs +40 -0
- package/esm/node_modules/amqplib/lib/heartbeat.mjs.map +1 -0
- package/esm/node_modules/amqplib/lib/mux.mjs +86 -0
- package/esm/node_modules/amqplib/lib/mux.mjs.map +1 -0
- package/esm/node_modules/amqplib/package.mjs +41 -0
- package/esm/node_modules/amqplib/package.mjs.map +1 -0
- package/esm/node_modules/buffer-more-ints/buffer-more-ints.mjs +360 -0
- package/esm/node_modules/buffer-more-ints/buffer-more-ints.mjs.map +1 -0
- package/esm/node_modules/dayjs/dayjs.min.mjs +305 -0
- package/esm/node_modules/dayjs/dayjs.min.mjs.map +1 -0
- package/esm/node_modules/querystringify/index.mjs +80 -0
- package/esm/node_modules/querystringify/index.mjs.map +1 -0
- package/esm/node_modules/requires-port/index.mjs +35 -0
- package/esm/node_modules/requires-port/index.mjs.map +1 -0
- package/esm/node_modules/url-parse/index.mjs +388 -0
- package/esm/node_modules/url-parse/index.mjs.map +1 -0
- package/esm/queue/load-herald.mjs +1 -1
- package/esm/seal/src/config.mjs +15 -0
- package/esm/seal/src/config.mjs.map +1 -0
- package/esm/seal/src/factory/index.mjs +4 -0
- package/esm/seal/src/factory/validate.mjs +34 -0
- package/esm/seal/src/factory/validate.mjs.map +1 -0
- package/esm/seal/src/factory/validators.mjs +132 -0
- package/esm/seal/src/factory/validators.mjs.map +1 -0
- package/esm/seal/src/helpers/date-helpers.mjs +24 -0
- package/esm/seal/src/helpers/date-helpers.mjs.map +1 -0
- package/esm/seal/src/helpers/get-field-value.mjs +46 -0
- package/esm/seal/src/helpers/get-field-value.mjs.map +1 -0
- package/esm/seal/src/helpers/index.mjs +6 -0
- package/esm/seal/src/helpers/is-empty-value.mjs +10 -0
- package/esm/seal/src/helpers/is-empty-value.mjs.map +1 -0
- package/esm/seal/src/helpers/path-helpers.mjs +12 -0
- package/esm/seal/src/helpers/path-helpers.mjs.map +1 -0
- package/esm/seal/src/helpers/validation-helpers.mjs +72 -0
- package/esm/seal/src/helpers/validation-helpers.mjs.map +1 -0
- package/esm/seal/src/index.mjs +87 -0
- package/esm/seal/src/mutators/array-mutators.mjs +32 -0
- package/esm/seal/src/mutators/array-mutators.mjs.map +1 -0
- package/esm/seal/src/mutators/date-mutators.mjs +94 -0
- package/esm/seal/src/mutators/date-mutators.mjs.map +1 -0
- package/esm/seal/src/mutators/index.mjs +8 -0
- package/esm/seal/src/mutators/number-mutators.mjs +52 -0
- package/esm/seal/src/mutators/number-mutators.mjs.map +1 -0
- package/esm/seal/src/mutators/object-mutators.mjs +30 -0
- package/esm/seal/src/mutators/object-mutators.mjs.map +1 -0
- package/esm/seal/src/mutators/scalar-mutators.mjs +9 -0
- package/esm/seal/src/mutators/scalar-mutators.mjs.map +1 -0
- package/esm/seal/src/mutators/string-mutators.mjs +186 -0
- package/esm/seal/src/mutators/string-mutators.mjs.map +1 -0
- package/esm/seal/src/rules/array/array-rules.mjs +41 -0
- package/esm/seal/src/rules/array/array-rules.mjs.map +1 -0
- package/esm/seal/src/rules/array/index.mjs +3 -0
- package/esm/seal/src/rules/color/color-rules.mjs +104 -0
- package/esm/seal/src/rules/color/color-rules.mjs.map +1 -0
- package/esm/seal/src/rules/color/index.mjs +3 -0
- package/esm/seal/src/rules/common/enum.mjs +77 -0
- package/esm/seal/src/rules/common/enum.mjs.map +1 -0
- package/esm/seal/src/rules/common/equals-field-rules.mjs +42 -0
- package/esm/seal/src/rules/common/equals-field-rules.mjs.map +1 -0
- package/esm/seal/src/rules/common/index.mjs +8 -0
- package/esm/seal/src/rules/common/instanceof.mjs +23 -0
- package/esm/seal/src/rules/common/instanceof.mjs.map +1 -0
- package/esm/seal/src/rules/common/literal.mjs +31 -0
- package/esm/seal/src/rules/common/literal.mjs.map +1 -0
- package/esm/seal/src/rules/common/type-rules.mjs +97 -0
- package/esm/seal/src/rules/common/type-rules.mjs.map +1 -0
- package/esm/seal/src/rules/common/unknown-key.mjs +25 -0
- package/esm/seal/src/rules/common/unknown-key.mjs.map +1 -0
- package/esm/seal/src/rules/conditional/forbidden-if-rules.mjs +116 -0
- package/esm/seal/src/rules/conditional/forbidden-if-rules.mjs.map +1 -0
- package/esm/seal/src/rules/conditional/index.mjs +12 -0
- package/esm/seal/src/rules/conditional/present-if-rules.mjs +97 -0
- package/esm/seal/src/rules/conditional/present-if-rules.mjs.map +1 -0
- package/esm/seal/src/rules/conditional/present-unless-rules.mjs +30 -0
- package/esm/seal/src/rules/conditional/present-unless-rules.mjs.map +1 -0
- package/esm/seal/src/rules/conditional/present-with-rules.mjs +76 -0
- package/esm/seal/src/rules/conditional/present-with-rules.mjs.map +1 -0
- package/esm/seal/src/rules/conditional/present-without-rules.mjs +76 -0
- package/esm/seal/src/rules/conditional/present-without-rules.mjs.map +1 -0
- package/esm/seal/src/rules/conditional/required-if-rules.mjs +204 -0
- package/esm/seal/src/rules/conditional/required-if-rules.mjs.map +1 -0
- package/esm/seal/src/rules/conditional/required-unless-rules.mjs +31 -0
- package/esm/seal/src/rules/conditional/required-unless-rules.mjs.map +1 -0
- package/esm/seal/src/rules/conditional/required-when-rule.mjs +32 -0
- package/esm/seal/src/rules/conditional/required-when-rule.mjs.map +1 -0
- package/esm/seal/src/rules/conditional/required-with-rules.mjs +67 -0
- package/esm/seal/src/rules/conditional/required-with-rules.mjs.map +1 -0
- package/esm/seal/src/rules/conditional/required-without-rules.mjs +67 -0
- package/esm/seal/src/rules/conditional/required-without-rules.mjs.map +1 -0
- package/esm/seal/src/rules/core/equal.mjs +22 -0
- package/esm/seal/src/rules/core/equal.mjs.map +1 -0
- package/esm/seal/src/rules/core/forbidden.mjs +20 -0
- package/esm/seal/src/rules/core/forbidden.mjs.map +1 -0
- package/esm/seal/src/rules/core/index.mjs +7 -0
- package/esm/seal/src/rules/core/required.mjs +36 -0
- package/esm/seal/src/rules/core/required.mjs.map +1 -0
- package/esm/seal/src/rules/core/union.mjs +30 -0
- package/esm/seal/src/rules/core/union.mjs.map +1 -0
- package/esm/seal/src/rules/core/when.mjs +37 -0
- package/esm/seal/src/rules/core/when.mjs.map +1 -0
- package/esm/seal/src/rules/date/date-comparison-rules.mjs +78 -0
- package/esm/seal/src/rules/date/date-comparison-rules.mjs.map +1 -0
- package/esm/seal/src/rules/date/date-day-rules.mjs +49 -0
- package/esm/seal/src/rules/date/date-day-rules.mjs.map +1 -0
- package/esm/seal/src/rules/date/date-field-comparison-rules.mjs +82 -0
- package/esm/seal/src/rules/date/date-field-comparison-rules.mjs.map +1 -0
- package/esm/seal/src/rules/date/date-period-rules.mjs +399 -0
- package/esm/seal/src/rules/date/date-period-rules.mjs.map +1 -0
- package/esm/seal/src/rules/date/date-relative-rules.mjs +55 -0
- package/esm/seal/src/rules/date/date-relative-rules.mjs.map +1 -0
- package/esm/seal/src/rules/date/date-special-rules.mjs +58 -0
- package/esm/seal/src/rules/date/date-special-rules.mjs.map +1 -0
- package/esm/seal/src/rules/date/date.mjs +235 -0
- package/esm/seal/src/rules/date/date.mjs.map +1 -0
- package/esm/seal/src/rules/date/index.mjs +9 -0
- package/esm/seal/src/rules/file/dimensions.mjs +3 -0
- package/esm/seal/src/rules/file/file-size.mjs +3 -0
- package/esm/seal/src/rules/file/index.mjs +4 -0
- package/esm/seal/src/rules/index.mjs +54 -0
- package/esm/seal/src/rules/length/index.mjs +3 -0
- package/esm/seal/src/rules/length/length-rules.mjs +98 -0
- package/esm/seal/src/rules/length/length-rules.mjs.map +1 -0
- package/esm/seal/src/rules/number/index.mjs +3 -0
- package/esm/seal/src/rules/number/number-rules.mjs +197 -0
- package/esm/seal/src/rules/number/number-rules.mjs.map +1 -0
- package/esm/seal/src/rules/scalar/accepted-rule.mjs +116 -0
- package/esm/seal/src/rules/scalar/accepted-rule.mjs.map +1 -0
- package/esm/seal/src/rules/scalar/declined-rule.mjs +116 -0
- package/esm/seal/src/rules/scalar/declined-rule.mjs.map +1 -0
- package/esm/seal/src/rules/scalar/index.mjs +4 -0
- package/esm/seal/src/rules/string/alpha.mjs +41 -0
- package/esm/seal/src/rules/string/alpha.mjs.map +1 -0
- package/esm/seal/src/rules/string/credit-card.mjs +32 -0
- package/esm/seal/src/rules/string/credit-card.mjs.map +1 -0
- package/esm/seal/src/rules/string/email.mjs +20 -0
- package/esm/seal/src/rules/string/email.mjs.map +1 -0
- package/esm/seal/src/rules/string/id-formats.mjs +104 -0
- package/esm/seal/src/rules/string/id-formats.mjs.map +1 -0
- package/esm/seal/src/rules/string/index.mjs +13 -0
- package/esm/seal/src/rules/string/ip.mjs +66 -0
- package/esm/seal/src/rules/string/ip.mjs.map +1 -0
- package/esm/seal/src/rules/string/matches.mjs +4 -0
- package/esm/seal/src/rules/string/pattern.mjs +20 -0
- package/esm/seal/src/rules/string/pattern.mjs.map +1 -0
- package/esm/seal/src/rules/string/string-comparison.mjs +56 -0
- package/esm/seal/src/rules/string/string-comparison.mjs.map +1 -0
- package/esm/seal/src/rules/string/strong-password-rule.mjs +31 -0
- package/esm/seal/src/rules/string/strong-password-rule.mjs.map +1 -0
- package/esm/seal/src/rules/string/url.mjs +23 -0
- package/esm/seal/src/rules/string/url.mjs.map +1 -0
- package/esm/seal/src/rules/string/without-whitespace.mjs +19 -0
- package/esm/seal/src/rules/string/without-whitespace.mjs.map +1 -0
- package/esm/seal/src/standard-schema/json-schema.mjs +81 -0
- package/esm/seal/src/standard-schema/json-schema.mjs.map +1 -0
- package/esm/seal/src/standard-schema/map-result.mjs +26 -0
- package/esm/seal/src/standard-schema/map-result.mjs.map +1 -0
- package/esm/seal/src/types/date-types.mjs +17 -0
- package/esm/seal/src/types/date-types.mjs.map +1 -0
- package/esm/seal/src/validators/any-validator.mjs +38 -0
- package/esm/seal/src/validators/any-validator.mjs.map +1 -0
- package/esm/seal/src/validators/array-validator.mjs +177 -0
- package/esm/seal/src/validators/array-validator.mjs.map +1 -0
- package/esm/seal/src/validators/base-validator.mjs +691 -0
- package/esm/seal/src/validators/base-validator.mjs.map +1 -0
- package/esm/seal/src/validators/boolean-validator.mjs +126 -0
- package/esm/seal/src/validators/boolean-validator.mjs.map +1 -0
- package/esm/seal/src/validators/computed-validator.mjs +118 -0
- package/esm/seal/src/validators/computed-validator.mjs.map +1 -0
- package/esm/seal/src/validators/date-validator.mjs +639 -0
- package/esm/seal/src/validators/date-validator.mjs.map +1 -0
- package/esm/seal/src/validators/discriminated-union-validator.mjs +129 -0
- package/esm/seal/src/validators/discriminated-union-validator.mjs.map +1 -0
- package/esm/seal/src/validators/float-validator.mjs +18 -0
- package/esm/seal/src/validators/float-validator.mjs.map +1 -0
- package/esm/seal/src/validators/index.mjs +28 -0
- package/esm/seal/src/validators/instanceof-validator.mjs +64 -0
- package/esm/seal/src/validators/instanceof-validator.mjs.map +1 -0
- package/esm/seal/src/validators/int-validator.mjs +30 -0
- package/esm/seal/src/validators/int-validator.mjs.map +1 -0
- package/esm/seal/src/validators/lazy-validator.mjs +87 -0
- package/esm/seal/src/validators/lazy-validator.mjs.map +1 -0
- package/esm/seal/src/validators/literal-validator.mjs +71 -0
- package/esm/seal/src/validators/literal-validator.mjs.map +1 -0
- package/esm/seal/src/validators/managed-validator.mjs +39 -0
- package/esm/seal/src/validators/managed-validator.mjs.map +1 -0
- package/esm/seal/src/validators/methods/equality-conditional-methods.mjs +129 -0
- package/esm/seal/src/validators/methods/equality-conditional-methods.mjs.map +1 -0
- package/esm/seal/src/validators/methods/forbidden-methods.mjs +131 -0
- package/esm/seal/src/validators/methods/forbidden-methods.mjs.map +1 -0
- package/esm/seal/src/validators/methods/present-methods.mjs +235 -0
- package/esm/seal/src/validators/methods/present-methods.mjs.map +1 -0
- package/esm/seal/src/validators/methods/required-methods.mjs +347 -0
- package/esm/seal/src/validators/methods/required-methods.mjs.map +1 -0
- package/esm/seal/src/validators/number-validator.mjs +310 -0
- package/esm/seal/src/validators/number-validator.mjs.map +1 -0
- package/esm/seal/src/validators/numeric-validator.mjs +27 -0
- package/esm/seal/src/validators/numeric-validator.mjs.map +1 -0
- package/esm/seal/src/validators/object-validator.mjs +442 -0
- package/esm/seal/src/validators/object-validator.mjs.map +1 -0
- package/esm/seal/src/validators/primitive-validator.mjs +89 -0
- package/esm/seal/src/validators/primitive-validator.mjs.map +1 -0
- package/esm/seal/src/validators/record-validator.mjs +112 -0
- package/esm/seal/src/validators/record-validator.mjs.map +1 -0
- package/esm/seal/src/validators/scalar-validator.mjs +172 -0
- package/esm/seal/src/validators/scalar-validator.mjs.map +1 -0
- package/esm/seal/src/validators/string-validator.mjs +459 -0
- package/esm/seal/src/validators/string-validator.mjs.map +1 -0
- package/esm/seal/src/validators/tuple-validator.mjs +134 -0
- package/esm/seal/src/validators/tuple-validator.mjs.map +1 -0
- package/esm/seal/src/validators/union-validator.mjs +66 -0
- package/esm/seal/src/validators/union-validator.mjs.map +1 -0
- package/llms-full.txt +5 -1
- package/package.json +5 -5
- package/skills/send-ad-hoc/SKILL.md +1 -1
- package/skills/use-in-app/SKILL.md +4 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { brokerRegistry } from "../communicators/broker-registry.mjs";
|
|
2
|
+
import "../communicators/index.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../herald/src/utils/connect-to-broker.ts
|
|
5
|
+
/**
|
|
6
|
+
* Connect to a message broker and register it.
|
|
7
|
+
*
|
|
8
|
+
* This is a high-level utility function that simplifies connection setup
|
|
9
|
+
* for most projects. It handles driver instantiation, connection,
|
|
10
|
+
* broker creation, and automatic registration.
|
|
11
|
+
*
|
|
12
|
+
* **Supported Drivers:**
|
|
13
|
+
* - `rabbitmq` (default) - RabbitMQ/AMQP driver
|
|
14
|
+
* - `kafka` - Apache Kafka driver (coming soon)
|
|
15
|
+
*
|
|
16
|
+
* @param options - Connection configuration options
|
|
17
|
+
* @returns A connected and registered Broker instance
|
|
18
|
+
* @throws {Error} If connection fails or driver is not implemented
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // RabbitMQ connection
|
|
23
|
+
* const broker = await connectToBroker({
|
|
24
|
+
* driver: "rabbitmq",
|
|
25
|
+
* host: "localhost",
|
|
26
|
+
* port: 5672,
|
|
27
|
+
* username: "guest",
|
|
28
|
+
* password: "guest",
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* // Use the broker
|
|
32
|
+
* await broker.channel("user.created").publish({ userId: 1 });
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* // Multiple brokers
|
|
38
|
+
* await connectToBroker({
|
|
39
|
+
* driver: "rabbitmq",
|
|
40
|
+
* name: "notifications",
|
|
41
|
+
* isDefault: true,
|
|
42
|
+
* host: process.env.RABBITMQ_HOST,
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* await connectToBroker({
|
|
46
|
+
* driver: "rabbitmq",
|
|
47
|
+
* name: "analytics",
|
|
48
|
+
* host: process.env.ANALYTICS_RABBITMQ_HOST,
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* // Use default broker
|
|
52
|
+
* herald().channel("notifications").publish({ ... });
|
|
53
|
+
*
|
|
54
|
+
* // Use specific broker
|
|
55
|
+
* herald("analytics").channel("events").publish({ ... });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
async function connectToBroker(options) {
|
|
59
|
+
const driverType = options.driver ?? "rabbitmq";
|
|
60
|
+
const brokerName = options.name ?? "default";
|
|
61
|
+
const isDefault = options.isDefault ?? true;
|
|
62
|
+
let driver;
|
|
63
|
+
switch (driverType) {
|
|
64
|
+
case "rabbitmq": {
|
|
65
|
+
const rabbitOptions = options;
|
|
66
|
+
const { RabbitMQDriver } = await import("../drivers/rabbitmq/rabbitmq-driver.mjs");
|
|
67
|
+
driver = new RabbitMQDriver(rabbitOptions);
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
case "kafka": throw new Error("Kafka driver is not yet implemented. Coming soon! For now, please use RabbitMQ.");
|
|
71
|
+
default: throw new Error(`Unknown driver: "${driverType}". Supported drivers: rabbitmq, kafka`);
|
|
72
|
+
}
|
|
73
|
+
const broker = brokerRegistry.register({
|
|
74
|
+
name: brokerName,
|
|
75
|
+
driver,
|
|
76
|
+
isDefault
|
|
77
|
+
});
|
|
78
|
+
try {
|
|
79
|
+
await driver.connect();
|
|
80
|
+
} catch (error) {
|
|
81
|
+
throw new Error(`Failed to connect to ${driverType}: ${error instanceof Error ? error.message : String(error)}`);
|
|
82
|
+
}
|
|
83
|
+
return broker;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get a broker by name or the default one.
|
|
87
|
+
*
|
|
88
|
+
* This is the main entry point for using brokers in your application.
|
|
89
|
+
* Named after the package — `herald()` carries your messages!
|
|
90
|
+
*
|
|
91
|
+
* @param name - Optional broker name (uses default if not provided)
|
|
92
|
+
* @returns Broker instance
|
|
93
|
+
* @throws MissingBrokerError if broker not found
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* // Get default broker
|
|
97
|
+
* const channel = herald().channel("user.created");
|
|
98
|
+
* await channel.publish({ userId: 1 });
|
|
99
|
+
*
|
|
100
|
+
* // Get specific broker
|
|
101
|
+
* const analyticsChannel = herald("analytics").channel("events");
|
|
102
|
+
* await analyticsChannel.publish({ event: "page_view" });
|
|
103
|
+
*
|
|
104
|
+
* // Subscribe to messages
|
|
105
|
+
* herald()
|
|
106
|
+
* .channel<UserPayload>("user.created")
|
|
107
|
+
* .subscribe(async (message, ctx) => {
|
|
108
|
+
* console.log("User created:", message.payload);
|
|
109
|
+
* await ctx.ack();
|
|
110
|
+
* });
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
function herald(name) {
|
|
114
|
+
return brokerRegistry.get(name);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get channel instance for the given name from default broker.
|
|
118
|
+
*
|
|
119
|
+
* Shorthand for `herald().channel(name, options)`.
|
|
120
|
+
*
|
|
121
|
+
* @param name - Channel name
|
|
122
|
+
* @param options - Optional channel options
|
|
123
|
+
* @returns Channel instance
|
|
124
|
+
* @throws MissingBrokerError if broker not found
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* const channel = heraldChannel("user.created");
|
|
129
|
+
* await channel.publish({ userId: 1 });
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
function heraldChannel(name, options) {
|
|
133
|
+
return herald().channel(name, options);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Publish an EventMessage to the default broker.
|
|
137
|
+
*
|
|
138
|
+
* @param event - Event message to publish
|
|
139
|
+
* @returns Promise that resolves when the event is published
|
|
140
|
+
* @throws Error if the broker is not connected
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* await publishEvent(new UserUpdatedEvent({ id: 1, name: "John Doe" }));
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
async function publishEvent(event) {
|
|
148
|
+
return herald().publish(event);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Subscribe an EventConsumer class to the default broker.
|
|
152
|
+
*
|
|
153
|
+
* @param Consumer - Event consumer class
|
|
154
|
+
* @returns Unsubscribe function
|
|
155
|
+
* @throws MissingBrokerError if broker not found
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* await subscribeConsumer(UserUpdatedConsumer);
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
async function subscribeConsumer(Consumer) {
|
|
163
|
+
return herald().subscribe(Consumer);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
//#endregion
|
|
167
|
+
export { connectToBroker, herald, heraldChannel, publishEvent, subscribeConsumer };
|
|
168
|
+
//# sourceMappingURL=connect-to-broker.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect-to-broker.mjs","names":[],"sources":["../../../../../../../../../herald/src/utils/connect-to-broker.ts"],"sourcesContent":["import { Broker, brokerRegistry } from \"../communicators\";\r\nimport type { BrokerDriverContract, ChannelContract } from \"../contracts\";\r\nimport { EventConsumerClass, EventMessage } from \"../message-managers\";\r\nimport type { ChannelOptions, ConnectionOptions, RabbitMQConnectionOptions } from \"../types\";\r\n\r\n/**\r\n * Connect to a message broker and register it.\r\n *\r\n * This is a high-level utility function that simplifies connection setup\r\n * for most projects. It handles driver instantiation, connection,\r\n * broker creation, and automatic registration.\r\n *\r\n * **Supported Drivers:**\r\n * - `rabbitmq` (default) - RabbitMQ/AMQP driver\r\n * - `kafka` - Apache Kafka driver (coming soon)\r\n *\r\n * @param options - Connection configuration options\r\n * @returns A connected and registered Broker instance\r\n * @throws {Error} If connection fails or driver is not implemented\r\n *\r\n * @example\r\n * ```typescript\r\n * // RabbitMQ connection\r\n * const broker = await connectToBroker({\r\n * driver: \"rabbitmq\",\r\n * host: \"localhost\",\r\n * port: 5672,\r\n * username: \"guest\",\r\n * password: \"guest\",\r\n * });\r\n *\r\n * // Use the broker\r\n * await broker.channel(\"user.created\").publish({ userId: 1 });\r\n * ```\r\n *\r\n * @example\r\n * ```typescript\r\n * // Multiple brokers\r\n * await connectToBroker({\r\n * driver: \"rabbitmq\",\r\n * name: \"notifications\",\r\n * isDefault: true,\r\n * host: process.env.RABBITMQ_HOST,\r\n * });\r\n *\r\n * await connectToBroker({\r\n * driver: \"rabbitmq\",\r\n * name: \"analytics\",\r\n * host: process.env.ANALYTICS_RABBITMQ_HOST,\r\n * });\r\n *\r\n * // Use default broker\r\n * herald().channel(\"notifications\").publish({ ... });\r\n *\r\n * // Use specific broker\r\n * herald(\"analytics\").channel(\"events\").publish({ ... });\r\n * ```\r\n */\r\nexport async function connectToBroker(options: ConnectionOptions): Promise<Broker> {\r\n // Default values\r\n const driverType = options.driver ?? \"rabbitmq\";\r\n const brokerName = options.name ?? \"default\";\r\n const isDefault = options.isDefault ?? true;\r\n\r\n // Create driver based on type\r\n let driver: BrokerDriverContract;\r\n\r\n switch (driverType) {\r\n case \"rabbitmq\": {\r\n const rabbitOptions = options as RabbitMQConnectionOptions;\r\n // Dynamic import to avoid requiring amqplib if not used\r\n const { RabbitMQDriver } = await import(\"../drivers/rabbitmq/rabbitmq-driver\");\r\n driver = new RabbitMQDriver(rabbitOptions);\r\n break;\r\n }\r\n\r\n case \"kafka\": {\r\n // const kafkaOptions = options as KafkaConnectionOptions;\r\n // Dynamic import to avoid requiring kafkajs if not used\r\n throw new Error(\r\n \"Kafka driver is not yet implemented. Coming soon! For now, please use RabbitMQ.\",\r\n );\r\n }\r\n\r\n default:\r\n throw new Error(`Unknown driver: \"${driverType}\". Supported drivers: rabbitmq, kafka`);\r\n }\r\n\r\n // Create broker\r\n const broker = brokerRegistry.register({\r\n name: brokerName,\r\n driver,\r\n isDefault,\r\n });\r\n\r\n // Connect to the message broker\r\n try {\r\n await driver.connect();\r\n } catch (error) {\r\n throw new Error(\r\n `Failed to connect to ${driverType}: ${error instanceof Error ? error.message : String(error)}`,\r\n );\r\n }\r\n\r\n return broker;\r\n}\r\n\r\n/**\r\n * Get a broker by name or the default one.\r\n *\r\n * This is the main entry point for using brokers in your application.\r\n * Named after the package — `herald()` carries your messages!\r\n *\r\n * @param name - Optional broker name (uses default if not provided)\r\n * @returns Broker instance\r\n * @throws MissingBrokerError if broker not found\r\n *\r\n * @example\r\n * // Get default broker\r\n * const channel = herald().channel(\"user.created\");\r\n * await channel.publish({ userId: 1 });\r\n *\r\n * // Get specific broker\r\n * const analyticsChannel = herald(\"analytics\").channel(\"events\");\r\n * await analyticsChannel.publish({ event: \"page_view\" });\r\n *\r\n * // Subscribe to messages\r\n * herald()\r\n * .channel<UserPayload>(\"user.created\")\r\n * .subscribe(async (message, ctx) => {\r\n * console.log(\"User created:\", message.payload);\r\n * await ctx.ack();\r\n * });\r\n * ```\r\n */\r\nexport function herald(name?: string): Broker {\r\n return brokerRegistry.get(name);\r\n}\r\n\r\n/**\r\n * Get channel instance for the given name from default broker.\r\n *\r\n * Shorthand for `herald().channel(name, options)`.\r\n *\r\n * @param name - Channel name\r\n * @param options - Optional channel options\r\n * @returns Channel instance\r\n * @throws MissingBrokerError if broker not found\r\n *\r\n * @example\r\n * ```typescript\r\n * const channel = heraldChannel(\"user.created\");\r\n * await channel.publish({ userId: 1 });\r\n * ```\r\n */\r\nexport function heraldChannel<TPayload = unknown>(\r\n name: string,\r\n options?: ChannelOptions<TPayload>,\r\n): ChannelContract<TPayload> {\r\n return herald().channel<TPayload>(name, options);\r\n}\r\n\r\n/**\r\n * Publish an EventMessage to the default broker.\r\n *\r\n * @param event - Event message to publish\r\n * @returns Promise that resolves when the event is published\r\n * @throws Error if the broker is not connected\r\n *\r\n * @example\r\n * ```typescript\r\n * await publishEvent(new UserUpdatedEvent({ id: 1, name: \"John Doe\" }));\r\n * ```\r\n */\r\nexport async function publishEvent<TPayload = Record<string, any>>(event: EventMessage<TPayload>) {\r\n return herald().publish(event);\r\n}\r\n\r\n/**\r\n * Subscribe an EventConsumer class to the default broker.\r\n *\r\n * @param Consumer - Event consumer class\r\n * @returns Unsubscribe function\r\n * @throws MissingBrokerError if broker not found\r\n *\r\n * @example\r\n * ```typescript\r\n * await subscribeConsumer(UserUpdatedConsumer);\r\n * ```\r\n */\r\nexport async function subscribeConsumer<TPayload = Record<string, any>>(\r\n Consumer: EventConsumerClass<TPayload>,\r\n) {\r\n return herald().subscribe(Consumer);\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,eAAsB,gBAAgB,SAA6C;CAEjF,MAAM,aAAa,QAAQ,UAAU;CACrC,MAAM,aAAa,QAAQ,QAAQ;CACnC,MAAM,YAAY,QAAQ,aAAa;CAGvC,IAAI;CAEJ,QAAQ,YAAR;EACE,KAAK,YAAY;GACf,MAAM,gBAAgB;GAEtB,MAAM,EAAE,mBAAmB,MAAM,OAAO;GACxC,SAAS,IAAI,eAAe,aAAa;GACzC;EACF;EAEA,KAAK,SAGH,MAAM,IAAI,MACR,iFACF;EAGF,SACE,MAAM,IAAI,MAAM,oBAAoB,WAAW,sCAAsC;CACzF;CAGA,MAAM,SAAS,eAAe,SAAS;EACrC,MAAM;EACN;EACA;CACF,CAAC;CAGD,IAAI;EACF,MAAM,OAAO,QAAQ;CACvB,SAAS,OAAO;EACd,MAAM,IAAI,MACR,wBAAwB,WAAW,IAAI,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAC9F;CACF;CAEA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,OAAO,MAAuB;CAC5C,OAAO,eAAe,IAAI,IAAI;AAChC;;;;;;;;;;;;;;;;;AAkBA,SAAgB,cACd,MACA,SAC2B;CAC3B,OAAO,OAAO,CAAC,CAAC,QAAkB,MAAM,OAAO;AACjD;;;;;;;;;;;;;AAcA,eAAsB,aAA6C,OAA+B;CAChG,OAAO,OAAO,CAAC,CAAC,QAAQ,KAAK;AAC/B;;;;;;;;;;;;;AAcA,eAAsB,kBACpB,UACA;CACA,OAAO,OAAO,CAAC,CAAC,UAAU,QAAQ;AACpC"}
|
|
@@ -39,10 +39,24 @@ declare class BaseNotificationsRepository<TModel extends NotificationContract =
|
|
|
39
39
|
* filter (the paths `RepositoryManager` does NOT map).
|
|
40
40
|
*/
|
|
41
41
|
protected toRow(obj: Record<string, unknown>): Record<string, unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* Runtime backstop for the compile-time `DatabasePayload` `Omit`: untyped
|
|
44
|
+
* callers (`notify.channel(name).send`, payloads assembled from request
|
|
45
|
+
* JSON) can smuggle server-owned keys past the type system, and spreading
|
|
46
|
+
* them into the row would let a payload redirect the notification into
|
|
47
|
+
* another recipient's inbox (recipient spoofing), cross tenants, pre-set
|
|
48
|
+
* read-state, or clobber the primary key. Drops BOTH the logical names and
|
|
49
|
+
* the model's resolved physical columns — `toRow` passes unmapped keys
|
|
50
|
+
* through verbatim, so a payload carrying `user_id` would otherwise reach
|
|
51
|
+
* the recipient column directly.
|
|
52
|
+
*/
|
|
53
|
+
private stripServerOwnedKeys;
|
|
42
54
|
/**
|
|
43
55
|
* Create one row for the recipient. New rows start unread; the tenant column
|
|
44
56
|
* (when the model declares one) is written from `tenantId`, which the
|
|
45
|
-
* database channel reads off the recipient.
|
|
57
|
+
* database channel reads off the recipient. `recipientId` and the other
|
|
58
|
+
* server-owned keys always come from the trusted arguments — matching keys
|
|
59
|
+
* in `input` are stripped, never merged.
|
|
46
60
|
*
|
|
47
61
|
* Idempotency: when `input.idempotencyKey` is set, find-or-create — return
|
|
48
62
|
* the existing row instead of inserting a duplicate. A unique index on the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-notifications-repository.d.mts","names":[],"sources":["../../../../../../../notifications/src/in-app/base-notifications-repository.ts"],"mappings":";;;;;;;;;;;KA2CY,mBAAA;EACV,EAAA,GAAK,EAAA;EACL,IAAA,
|
|
1
|
+
{"version":3,"file":"base-notifications-repository.d.mts","names":[],"sources":["../../../../../../../notifications/src/in-app/base-notifications-repository.ts"],"mappings":";;;;;;;;;;;KA2CY,mBAAA;EACV,EAAA,GAAK,EAAA;EACL,IAAA,WAgJe;EA9If,MAAA;EACA,WAAA,GAAc,EAAE;EAChB,cAAA;AAAA;;KAIU,sBAAA,YAAkC,IAAA,YAAgB,oBAAA,IAC5D,yBAAyB;AAAA,cAEd,2BAAA,gBACI,oBAAA,GAAuB,oBAAA,UAC9B,iBAAA,CAAkB,MAAA,EAAQ,mBAAA;EAkLvB;EAAA,iBAhLM,OAAA;EAEV,QAAA,EAAU,WAAA;cAEE,KAAA,GAAQ,sBAAA;EAwLgB;EAAA,IA5KhC,YAAA;EAoM6B;;;;;EAAA,QA3LhC,aAAA;EAsNsB;;;;;;;EAAA,UA3KpB,KAAA,CAAM,GAAA,EAAK,MAAA,oBAA0B,MAAA;EAvET;;;;;;;;;;;EAAA,QA+F9B,oBAAA;EAxBE;;;;;;;;;;;EA4DG,SAAA,CACX,WAAA,EAAa,EAAA,EACb,KAAA,EAAO,eAAA,EACP,QAAA,GAAW,EAAA,GACV,OAAA,CAAQ,MAAA;EAAR;;;;;EAwCI,aAAA,CACL,YAAA,EAAc,EAAA,IACd,KAAA,EAAO,eAAA,EACP,QAAA,GAAW,EAAA,GACV,OAAA,CAAQ,MAAA;EAFT;;;;;;EAcK,QAAA,CAAS,WAAA,EAAa,EAAA,EAAI,EAAA,GAAK,EAAA,GAAK,OAAA;EAA3B;;;;EAwBT,UAAA,CAAW,WAAA,EAAa,EAAA,EAAI,EAAA,GAAK,EAAA,GAAK,OAAA;EAAd;EAmBxB,OAAA,CAAQ,WAAA,EAAa,EAAA,EAAI,EAAA,EAAI,EAAA,GAAK,OAAA,CAAQ,MAAA;EAnBT;;;;EA2BjC,SAAA,CAAU,WAAA,EAAa,EAAA,EAAI,EAAA,GAAK,EAAA,GAAK,OAAA;EAR7B;EAAA,QAaP,qBAAA;AAAA"}
|
|
@@ -86,9 +86,39 @@ var BaseNotificationsRepository = class extends RepositoryManager {
|
|
|
86
86
|
return row;
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
|
+
* Runtime backstop for the compile-time `DatabasePayload` `Omit`: untyped
|
|
90
|
+
* callers (`notify.channel(name).send`, payloads assembled from request
|
|
91
|
+
* JSON) can smuggle server-owned keys past the type system, and spreading
|
|
92
|
+
* them into the row would let a payload redirect the notification into
|
|
93
|
+
* another recipient's inbox (recipient spoofing), cross tenants, pre-set
|
|
94
|
+
* read-state, or clobber the primary key. Drops BOTH the logical names and
|
|
95
|
+
* the model's resolved physical columns — `toRow` passes unmapped keys
|
|
96
|
+
* through verbatim, so a payload carrying `user_id` would otherwise reach
|
|
97
|
+
* the recipient column directly.
|
|
98
|
+
*/
|
|
99
|
+
stripServerOwnedKeys(input) {
|
|
100
|
+
const { recipient, tenant, readAt, isRead } = this.columns;
|
|
101
|
+
const serverOwned = new Set([
|
|
102
|
+
"id",
|
|
103
|
+
"recipientId",
|
|
104
|
+
"tenant",
|
|
105
|
+
"readAt",
|
|
106
|
+
"isRead",
|
|
107
|
+
recipient,
|
|
108
|
+
tenant,
|
|
109
|
+
readAt,
|
|
110
|
+
isRead
|
|
111
|
+
]);
|
|
112
|
+
const safe = {};
|
|
113
|
+
for (const [key, value] of Object.entries(input)) if (!serverOwned.has(key)) safe[key] = value;
|
|
114
|
+
return safe;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
89
117
|
* Create one row for the recipient. New rows start unread; the tenant column
|
|
90
118
|
* (when the model declares one) is written from `tenantId`, which the
|
|
91
|
-
* database channel reads off the recipient.
|
|
119
|
+
* database channel reads off the recipient. `recipientId` and the other
|
|
120
|
+
* server-owned keys always come from the trusted arguments — matching keys
|
|
121
|
+
* in `input` are stripped, never merged.
|
|
92
122
|
*
|
|
93
123
|
* Idempotency: when `input.idempotencyKey` is set, find-or-create — return
|
|
94
124
|
* the existing row instead of inserting a duplicate. A unique index on the
|
|
@@ -101,8 +131,8 @@ var BaseNotificationsRepository = class extends RepositoryManager {
|
|
|
101
131
|
if (existing) return existing;
|
|
102
132
|
}
|
|
103
133
|
const row = {
|
|
104
|
-
|
|
105
|
-
|
|
134
|
+
...this.stripServerOwnedKeys(input),
|
|
135
|
+
recipientId
|
|
106
136
|
};
|
|
107
137
|
if (this.columns.isRead) row.isRead = false;
|
|
108
138
|
if (this.columns.tenant && tenantId !== void 0) row.tenant = tenantId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-notifications-repository.mjs","names":[],"sources":["../../../../../../../notifications/src/in-app/base-notifications-repository.ts"],"sourcesContent":["/**\n * Shipped behavior repository for the in-app store.\n *\n * Concrete (NOT abstract) so `inApp.configure({ model })` can\n * `new BaseNotificationsRepository(model)` without subclassing. The dev only\n * extends this when they need extra query methods.\n *\n * ## The single source of truth: the model's `columnMap`\n *\n * The model declares its physical columns ONCE via `static columnMap`. The\n * constructor resolves that map and derives BOTH sides from it:\n *\n * - the READ path — `filterBy` maps logical keys (`recipientId`, `unread`,\n * `type`, …) onto the model's columns; `RepositoryManager` applies it.\n * - the WRITE / UPDATE / DELETE path — `createFor` / `markRead` / … translate\n * logical keys through the same `filterBy` via `toRow`.\n *\n * Because both come from one `columnMap`, reads and writes can never target\n * different columns. `unread` is mode-agnostic: it filters `is_read = false`\n * when the model has that flag, otherwise `read_at IS NULL`.\n *\n * @example default (SQL snake_case — no subclass needed)\n * inApp.configure({ model: Notification })\n *\n * @example custom columns — declare them on the model, not here\n * class Notification extends DatabaseNotification {\n * public static columnMap = { recipient: \"audience_id\", isRead: \"seen\" };\n * }\n */\nimport { type FilterRules, RepositoryManager } from \"@warlock.js/core\";\nimport type { NotificationContract } from \"../contracts\";\nimport type { DatabasePayload, Id } from \"../types\";\nimport {\n type NotificationColumnMapHost,\n type ResolvedNotificationColumnMap,\n resolveColumnMap,\n} from \"./column-map\";\nimport type { DatabaseNotification } from \"./database-notification\";\n\n/**\n * Filter shape — logical keys the repo understands. `filterBy` maps each to a\n * physical column (or a predicate) derived from the model's `columnMap`.\n */\nexport type NotificationsFilter = {\n id?: Id;\n type?: string;\n /** Mode-agnostic unread filter — resolves to the model's read-state column. */\n unread?: boolean;\n recipientId?: Id;\n idempotencyKey?: string;\n};\n\n/** Class form of a `DatabaseNotification` subclass — what `configure()` accepts. */\nexport type NotificationModelClass = (new (...args: any[]) => DatabaseNotification) &\n NotificationColumnMapHost;\n\nexport class BaseNotificationsRepository<\n TModel extends NotificationContract = NotificationContract,\n> extends RepositoryManager<TModel, NotificationsFilter> {\n /** Resolved physical columns for the bound model — the single source. */\n private readonly columns: ResolvedNotificationColumnMap;\n\n public filterBy: FilterRules;\n\n public constructor(model?: NotificationModelClass) {\n super();\n\n if (model) {\n this.source = model;\n }\n\n this.columns = resolveColumnMap(model?.columnMap);\n this.filterBy = this.buildFilterBy();\n }\n\n /** The tenant column for this model, or `undefined` for single-tenant. */\n public get tenantColumn(): string | undefined {\n return this.columns.tenant;\n }\n\n /**\n * Build `filterBy` from the resolved column map. `unread` is the\n * mode-agnostic read filter; `isRead` / `readAt` / `tenant` are exposed for\n * direct filtering only when the model declares those columns.\n */\n private buildFilterBy(): FilterRules {\n const { recipient, tenant, readAt, isRead } = this.columns;\n\n const rules: FilterRules = {\n id: \"=\",\n type: \"=\",\n recipientId: [\"=\", recipient],\n idempotencyKey: [\"=\", \"idempotency_key\"],\n unread: (value, query) => {\n if (value !== true && value !== \"true\") {\n return;\n }\n\n if (isRead) {\n query.where(isRead, false);\n } else if (readAt) {\n query.whereNull(readAt);\n }\n },\n };\n\n if (isRead) {\n rules.isRead = [\"=\", isRead];\n }\n\n if (readAt) {\n rules.readAt = [\"=\", readAt];\n }\n\n if (tenant) {\n rules.tenant = [\"=\", tenant];\n }\n\n return rules;\n }\n\n /**\n * Translate an object keyed by LOGICAL names into one keyed by PHYSICAL\n * columns, using `filterBy` as the lookup. Keys with no `[op, column]` tuple\n * (e.g. `title`, `body`, `payload`, `type`, `id`) pass through unchanged —\n * they're already physical. Used for every write / update / delete payload +\n * filter (the paths `RepositoryManager` does NOT map).\n */\n protected toRow(obj: Record<string, unknown>): Record<string, unknown> {\n const rules = this.filterBy as Record<string, unknown>;\n const row: Record<string, unknown> = {};\n\n for (const [logical, value] of Object.entries(obj)) {\n const rule = rules[logical];\n const column = Array.isArray(rule) ? (rule[1] as string) : logical;\n row[column] = value;\n }\n\n return row;\n }\n\n /**\n * Create one row for the recipient. New rows start unread; the tenant column\n * (when the model declares one) is written from `tenantId`, which the\n * database channel reads off the recipient.\n *\n * Idempotency: when `input.idempotencyKey` is set, find-or-create — return\n * the existing row instead of inserting a duplicate. A unique index on the\n * key is the backstop for the rare insert race (we re-fetch on conflict).\n */\n public async createFor(\n recipientId: Id,\n input: DatabasePayload,\n tenantId?: Id,\n ): Promise<TModel> {\n const { idempotencyKey } = input;\n\n if (idempotencyKey) {\n const existing = await this.firstByIdempotencyKey(recipientId, idempotencyKey);\n if (existing) {\n return existing;\n }\n }\n\n const row: Record<string, unknown> = { recipientId, ...input };\n\n if (this.columns.isRead) {\n row.isRead = false;\n }\n\n if (this.columns.tenant && tenantId !== undefined) {\n row.tenant = tenantId;\n }\n\n try {\n return await this.create(this.toRow(row));\n } catch (error) {\n // Lost the insert race to a concurrent send with the same key → re-fetch.\n if (idempotencyKey) {\n const existing = await this.firstByIdempotencyKey(recipientId, idempotencyKey);\n if (existing) {\n return existing;\n }\n }\n\n throw error;\n }\n }\n\n /**\n * Bulk-create one row per recipient sharing the same input + tenant. Reserved\n * for the Phase-2 `Channel.sendMany` fan-out hook; not on the per-recipient\n * send path yet.\n */\n public createManyFor(\n recipientIds: Id[],\n input: DatabasePayload,\n tenantId?: Id,\n ): Promise<TModel[]> {\n return Promise.all(\n recipientIds.map((recipientId) => this.createFor(recipientId, input, tenantId)),\n );\n }\n\n /**\n * Mark rows read — recipient-scoped. `id` omitted → all unread rows for the\n * recipient; `id` given → that one row, still scoped to the recipient. Scoped\n * to unread so a re-mark never overwrites an earlier `read_at` timestamp.\n * Sets whichever read-state column(s) the model declares.\n */\n public markRead(recipientId: Id, id?: Id): Promise<number> {\n const { isRead, readAt } = this.columns;\n const unreadScope = isRead ? { isRead: false } : { readAt: null };\n\n const data: Record<string, unknown> = {};\n\n if (isRead) {\n data.isRead = true;\n }\n\n if (readAt) {\n data.readAt = new Date();\n }\n\n return this.updateMany(\n this.toRow({ recipientId, ...unreadScope, ...(id !== undefined ? { id } : {}) }),\n this.toRow(data),\n );\n }\n\n /**\n * Inverse of `markRead`, same recipient-scoping. No unread scope needed —\n * clearing the read-state of an already-unread row is a no-op.\n */\n public markUnread(recipientId: Id, id?: Id): Promise<number> {\n const { isRead, readAt } = this.columns;\n const data: Record<string, unknown> = {};\n\n if (isRead) {\n data.isRead = false;\n }\n\n if (readAt) {\n data.readAt = null;\n }\n\n return this.updateMany(\n this.toRow({ recipientId, ...(id !== undefined ? { id } : {}) }),\n this.toRow(data),\n );\n }\n\n /** Find one row for a recipient (read path — `filterBy` maps the keys). */\n public findFor(recipientId: Id, id: Id): Promise<TModel | null> {\n return this.first({ recipientId, id } as NotificationsFilter);\n }\n\n /**\n * Delete rows — recipient-scoped. `id` omitted → clear all for the\n * recipient; `id` given → that one row.\n */\n public deleteFor(recipientId: Id, id?: Id): Promise<number> {\n return this.deleteMany(this.toRow({ recipientId, ...(id !== undefined ? { id } : {}) }));\n }\n\n /** Read path — `filterBy` maps `recipientId`/`idempotencyKey` to columns. */\n private firstByIdempotencyKey(recipientId: Id, idempotencyKey: string): Promise<TModel | null> {\n return this.first({ recipientId, idempotencyKey } as NotificationsFilter);\n }\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"base-notifications-repository.mjs","names":[],"sources":["../../../../../../../notifications/src/in-app/base-notifications-repository.ts"],"sourcesContent":["/**\n * Shipped behavior repository for the in-app store.\n *\n * Concrete (NOT abstract) so `inApp.configure({ model })` can\n * `new BaseNotificationsRepository(model)` without subclassing. The dev only\n * extends this when they need extra query methods.\n *\n * ## The single source of truth: the model's `columnMap`\n *\n * The model declares its physical columns ONCE via `static columnMap`. The\n * constructor resolves that map and derives BOTH sides from it:\n *\n * - the READ path — `filterBy` maps logical keys (`recipientId`, `unread`,\n * `type`, …) onto the model's columns; `RepositoryManager` applies it.\n * - the WRITE / UPDATE / DELETE path — `createFor` / `markRead` / … translate\n * logical keys through the same `filterBy` via `toRow`.\n *\n * Because both come from one `columnMap`, reads and writes can never target\n * different columns. `unread` is mode-agnostic: it filters `is_read = false`\n * when the model has that flag, otherwise `read_at IS NULL`.\n *\n * @example default (SQL snake_case — no subclass needed)\n * inApp.configure({ model: Notification })\n *\n * @example custom columns — declare them on the model, not here\n * class Notification extends DatabaseNotification {\n * public static columnMap = { recipient: \"audience_id\", isRead: \"seen\" };\n * }\n */\nimport { type FilterRules, RepositoryManager } from \"@warlock.js/core\";\nimport type { NotificationContract } from \"../contracts\";\nimport type { DatabasePayload, Id } from \"../types\";\nimport {\n type NotificationColumnMapHost,\n type ResolvedNotificationColumnMap,\n resolveColumnMap,\n} from \"./column-map\";\nimport type { DatabaseNotification } from \"./database-notification\";\n\n/**\n * Filter shape — logical keys the repo understands. `filterBy` maps each to a\n * physical column (or a predicate) derived from the model's `columnMap`.\n */\nexport type NotificationsFilter = {\n id?: Id;\n type?: string;\n /** Mode-agnostic unread filter — resolves to the model's read-state column. */\n unread?: boolean;\n recipientId?: Id;\n idempotencyKey?: string;\n};\n\n/** Class form of a `DatabaseNotification` subclass — what `configure()` accepts. */\nexport type NotificationModelClass = (new (...args: any[]) => DatabaseNotification) &\n NotificationColumnMapHost;\n\nexport class BaseNotificationsRepository<\n TModel extends NotificationContract = NotificationContract,\n> extends RepositoryManager<TModel, NotificationsFilter> {\n /** Resolved physical columns for the bound model — the single source. */\n private readonly columns: ResolvedNotificationColumnMap;\n\n public filterBy: FilterRules;\n\n public constructor(model?: NotificationModelClass) {\n super();\n\n if (model) {\n this.source = model;\n }\n\n this.columns = resolveColumnMap(model?.columnMap);\n this.filterBy = this.buildFilterBy();\n }\n\n /** The tenant column for this model, or `undefined` for single-tenant. */\n public get tenantColumn(): string | undefined {\n return this.columns.tenant;\n }\n\n /**\n * Build `filterBy` from the resolved column map. `unread` is the\n * mode-agnostic read filter; `isRead` / `readAt` / `tenant` are exposed for\n * direct filtering only when the model declares those columns.\n */\n private buildFilterBy(): FilterRules {\n const { recipient, tenant, readAt, isRead } = this.columns;\n\n const rules: FilterRules = {\n id: \"=\",\n type: \"=\",\n recipientId: [\"=\", recipient],\n idempotencyKey: [\"=\", \"idempotency_key\"],\n unread: (value, query) => {\n if (value !== true && value !== \"true\") {\n return;\n }\n\n if (isRead) {\n query.where(isRead, false);\n } else if (readAt) {\n query.whereNull(readAt);\n }\n },\n };\n\n if (isRead) {\n rules.isRead = [\"=\", isRead];\n }\n\n if (readAt) {\n rules.readAt = [\"=\", readAt];\n }\n\n if (tenant) {\n rules.tenant = [\"=\", tenant];\n }\n\n return rules;\n }\n\n /**\n * Translate an object keyed by LOGICAL names into one keyed by PHYSICAL\n * columns, using `filterBy` as the lookup. Keys with no `[op, column]` tuple\n * (e.g. `title`, `body`, `payload`, `type`, `id`) pass through unchanged —\n * they're already physical. Used for every write / update / delete payload +\n * filter (the paths `RepositoryManager` does NOT map).\n */\n protected toRow(obj: Record<string, unknown>): Record<string, unknown> {\n const rules = this.filterBy as Record<string, unknown>;\n const row: Record<string, unknown> = {};\n\n for (const [logical, value] of Object.entries(obj)) {\n const rule = rules[logical];\n const column = Array.isArray(rule) ? (rule[1] as string) : logical;\n row[column] = value;\n }\n\n return row;\n }\n\n /**\n * Runtime backstop for the compile-time `DatabasePayload` `Omit`: untyped\n * callers (`notify.channel(name).send`, payloads assembled from request\n * JSON) can smuggle server-owned keys past the type system, and spreading\n * them into the row would let a payload redirect the notification into\n * another recipient's inbox (recipient spoofing), cross tenants, pre-set\n * read-state, or clobber the primary key. Drops BOTH the logical names and\n * the model's resolved physical columns — `toRow` passes unmapped keys\n * through verbatim, so a payload carrying `user_id` would otherwise reach\n * the recipient column directly.\n */\n private stripServerOwnedKeys(input: DatabasePayload): Record<string, unknown> {\n const { recipient, tenant, readAt, isRead } = this.columns;\n const serverOwned = new Set<string | undefined>([\n \"id\",\n \"recipientId\",\n \"tenant\",\n \"readAt\",\n \"isRead\",\n recipient,\n tenant,\n readAt,\n isRead,\n ]);\n\n const safe: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(input)) {\n if (!serverOwned.has(key)) {\n safe[key] = value;\n }\n }\n\n return safe;\n }\n\n /**\n * Create one row for the recipient. New rows start unread; the tenant column\n * (when the model declares one) is written from `tenantId`, which the\n * database channel reads off the recipient. `recipientId` and the other\n * server-owned keys always come from the trusted arguments — matching keys\n * in `input` are stripped, never merged.\n *\n * Idempotency: when `input.idempotencyKey` is set, find-or-create — return\n * the existing row instead of inserting a duplicate. A unique index on the\n * key is the backstop for the rare insert race (we re-fetch on conflict).\n */\n public async createFor(\n recipientId: Id,\n input: DatabasePayload,\n tenantId?: Id,\n ): Promise<TModel> {\n const { idempotencyKey } = input;\n\n if (idempotencyKey) {\n const existing = await this.firstByIdempotencyKey(recipientId, idempotencyKey);\n if (existing) {\n return existing;\n }\n }\n\n const row: Record<string, unknown> = { ...this.stripServerOwnedKeys(input), recipientId };\n\n if (this.columns.isRead) {\n row.isRead = false;\n }\n\n if (this.columns.tenant && tenantId !== undefined) {\n row.tenant = tenantId;\n }\n\n try {\n return await this.create(this.toRow(row));\n } catch (error) {\n // Lost the insert race to a concurrent send with the same key → re-fetch.\n if (idempotencyKey) {\n const existing = await this.firstByIdempotencyKey(recipientId, idempotencyKey);\n if (existing) {\n return existing;\n }\n }\n\n throw error;\n }\n }\n\n /**\n * Bulk-create one row per recipient sharing the same input + tenant. Reserved\n * for the Phase-2 `Channel.sendMany` fan-out hook; not on the per-recipient\n * send path yet.\n */\n public createManyFor(\n recipientIds: Id[],\n input: DatabasePayload,\n tenantId?: Id,\n ): Promise<TModel[]> {\n return Promise.all(\n recipientIds.map((recipientId) => this.createFor(recipientId, input, tenantId)),\n );\n }\n\n /**\n * Mark rows read — recipient-scoped. `id` omitted → all unread rows for the\n * recipient; `id` given → that one row, still scoped to the recipient. Scoped\n * to unread so a re-mark never overwrites an earlier `read_at` timestamp.\n * Sets whichever read-state column(s) the model declares.\n */\n public markRead(recipientId: Id, id?: Id): Promise<number> {\n const { isRead, readAt } = this.columns;\n const unreadScope = isRead ? { isRead: false } : { readAt: null };\n\n const data: Record<string, unknown> = {};\n\n if (isRead) {\n data.isRead = true;\n }\n\n if (readAt) {\n data.readAt = new Date();\n }\n\n return this.updateMany(\n this.toRow({ recipientId, ...unreadScope, ...(id !== undefined ? { id } : {}) }),\n this.toRow(data),\n );\n }\n\n /**\n * Inverse of `markRead`, same recipient-scoping. No unread scope needed —\n * clearing the read-state of an already-unread row is a no-op.\n */\n public markUnread(recipientId: Id, id?: Id): Promise<number> {\n const { isRead, readAt } = this.columns;\n const data: Record<string, unknown> = {};\n\n if (isRead) {\n data.isRead = false;\n }\n\n if (readAt) {\n data.readAt = null;\n }\n\n return this.updateMany(\n this.toRow({ recipientId, ...(id !== undefined ? { id } : {}) }),\n this.toRow(data),\n );\n }\n\n /** Find one row for a recipient (read path — `filterBy` maps the keys). */\n public findFor(recipientId: Id, id: Id): Promise<TModel | null> {\n return this.first({ recipientId, id } as NotificationsFilter);\n }\n\n /**\n * Delete rows — recipient-scoped. `id` omitted → clear all for the\n * recipient; `id` given → that one row.\n */\n public deleteFor(recipientId: Id, id?: Id): Promise<number> {\n return this.deleteMany(this.toRow({ recipientId, ...(id !== undefined ? { id } : {}) }));\n }\n\n /** Read path — `filterBy` maps `recipientId`/`idempotencyKey` to columns. */\n private firstByIdempotencyKey(recipientId: Id, idempotencyKey: string): Promise<TModel | null> {\n return this.first({ recipientId, idempotencyKey } as NotificationsFilter);\n }\n}\n"],"mappings":"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"}
|
package/esm/in-app/in-app.d.mts
CHANGED
|
@@ -32,14 +32,14 @@ declare class InApp {
|
|
|
32
32
|
configure(options: ConfigureOptions): Channel<DatabasePayload>;
|
|
33
33
|
private get repository();
|
|
34
34
|
/** General list — scoped to recipient; pass `options` for paging + filters. */
|
|
35
|
-
list(recipient: Notifiable | Id, options?: NotificationsListOptions):
|
|
35
|
+
list(recipient: Notifiable | Id, options?: NotificationsListOptions): Promise<import("@warlock.js/core").PaginationResult<NotificationContract>>;
|
|
36
36
|
/** Unread-only list — common case for badges + dashboards. */
|
|
37
|
-
listUnread(recipient: Notifiable | Id, options?: NotificationsListOptions):
|
|
37
|
+
listUnread(recipient: Notifiable | Id, options?: NotificationsListOptions): Promise<import("@warlock.js/core").PaginationResult<NotificationContract>>;
|
|
38
38
|
/**
|
|
39
39
|
* Cached unread count — backs the badge. Auto-invalidated by the repo's
|
|
40
40
|
* model create/update events (`RepositoryManager.registerEvents`).
|
|
41
41
|
*/
|
|
42
|
-
countUnread(recipient: Notifiable | Id):
|
|
42
|
+
countUnread(recipient: Notifiable | Id): Promise<number>;
|
|
43
43
|
/** Find one notification for a recipient — for a detail view. */
|
|
44
44
|
find(recipient: Notifiable | Id, id: Id): Promise<NotificationContract | null>;
|
|
45
45
|
/** Mark read — `id` omitted = all unread for this recipient. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in-app.d.mts","names":[],"sources":["../../../../../../../notifications/src/in-app/in-app.ts"],"mappings":";;;;;;;;;;;;KA4CY,wBAAA,GAA2B,+BAA+B,CAAC,mBAAA;;;;;;KAO3D,gBAAA;EACN,KAAA,EAAO,sBAAA;EAAwB,UAAA;AAAA;EAC/B,UAAA,EAAY,2BAA2B;EAAE,KAAA;AAAA;AAAA,cAKzC,KAAA;EAAA,QACI,IAAA;
|
|
1
|
+
{"version":3,"file":"in-app.d.mts","names":[],"sources":["../../../../../../../notifications/src/in-app/in-app.ts"],"mappings":";;;;;;;;;;;;KA4CY,wBAAA,GAA2B,+BAA+B,CAAC,mBAAA;;;;;;KAO3D,gBAAA;EACN,KAAA,EAAO,sBAAA;EAAwB,UAAA;AAAA;EAC/B,UAAA,EAAY,2BAA2B;EAAE,KAAA;AAAA;AAAA,cAKzC,KAAA;EAAA,QACI,IAAA;EAqDuB;;;;EA/CxB,SAAA,CAAU,OAAA,EAAS,gBAAA,GAAmB,OAAA,CAAQ,eAAA;EAAA,YAQzC,UAAA;EA4CoC;EAjCzC,IAAA,CAAK,SAAA,EAAW,UAAA,GAAa,EAAA,EAAI,OAAA,GAAU,wBAAA,GAAwB,OAAA,4BAAA,gBAAA,CAAA,oBAAA;EAiCxB;EA5B3C,UAAA,CAAW,SAAA,EAAW,UAAA,GAAa,EAAA,EAAI,OAAA,GAAU,wBAAA,GAAwB,OAAA,4BAAA,gBAAA,CAAA,oBAAA;EA9BxE;;;;EAsCD,WAAA,CAAY,SAAA,EAAW,UAAA,GAAa,EAAA,GAAE,OAAA;EAhCQ;EAqC9C,IAAA,CAAK,SAAA,EAAW,UAAA,GAAa,EAAA,EAAI,EAAA,EAAI,EAAA,GAAE,OAAA,CAAA,oBAAA;EAlBvC;EAuBA,UAAA,CAAW,SAAA,EAAW,UAAA,GAAa,EAAA,EAAI,EAAA,GAAK,EAAA,GAAE,OAAA;EAvBjB;EA4B7B,YAAA,CAAa,SAAA,EAAW,UAAA,GAAa,EAAA,EAAI,EAAA,GAAK,EAAA,GAAE,OAAA;EA5BL;EAiC3C,OAAA,CAAQ,SAAA,EAAW,UAAA,GAAa,EAAA,EAAI,EAAA,GAAK,EAAA,GAAE,OAAA;AAAA;;cAMvC,KAAA,EAAK,KAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_internal.mjs","names":[],"sources":["../../../../../../../../../../../node_modules/@mongez/reinforcements/esm/Random/_internal.mjs"],"sourcesContent":["//#region ../reinforcements/src/Random/_internal.ts\nconst ALPHANUMERIC = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\nconst URL_SAFE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-\";\nconst cryptoRef = typeof globalThis !== \"undefined\" && globalThis.crypto ? globalThis.crypto : {};\nconst BYTE_VALUES = 256;\n/** Thrown by every security-shaped generator when no CSPRNG exists. */\nconst NO_CSPRNG_ERROR = \"No CSPRNG available: crypto.getRandomValues is required\";\n/**\n* Return the runtime CSPRNG, throwing when there is none. Tokens, ids\n* and uuids must never silently degrade to the seedable `next()` — a\n* predictable token is worse than a loud failure.\n*/\nfunction requireCsprng() {\n\tif (typeof cryptoRef.getRandomValues !== \"function\") throw new Error(NO_CSPRNG_ERROR);\n\treturn cryptoRef.getRandomValues.bind(cryptoRef);\n}\n/** Cryptographically secure random bytes. Throws without a CSPRNG. */\nfunction cryptoBytes(size) {\n\treturn requireCsprng()(new Uint8Array(size));\n}\n/**\n* Build a `length`-character string out of `charset` using CSPRNG\n* bytes. Bytes above the largest multiple of the charset size are\n* rejected and redrawn so every character stays equally likely — a\n* plain `byte % charset.length` would bias the leading characters.\n*\n* Throws when no CSPRNG is available, whatever the requested length.\n*/\nfunction cryptoStringOf(charset, length) {\n\tconst getRandomValues = requireCsprng();\n\tconst size = charset.length;\n\tconst limit = Math.floor(BYTE_VALUES / size) * size;\n\tlet text = \"\";\n\twhile (text.length < length) {\n\t\tconst bytes = getRandomValues(new Uint8Array(length - text.length));\n\t\tfor (let i = 0; i < bytes.length && text.length < length; i++) {\n\t\t\tif (bytes[i] >= limit) continue;\n\t\t\ttext += charset.charAt(bytes[i] % size);\n\t\t}\n\t}\n\treturn text;\n}\nlet rngState;\nfunction setSeed(seed) {\n\trngState = seed;\n}\n/**\n* Return the next pseudo-random value in `[0, 1)`. Uses `Math.random` by\n* default; switches to a seeded mulberry32 PRNG when `setSeed` is called\n* with a numeric seed.\n*/\nfunction next() {\n\tif (rngState === void 0) return Math.random();\n\trngState |= 0;\n\trngState = rngState + 1831565813 | 0;\n\tlet t = rngState;\n\tt = Math.imul(t ^ t >>> 15, t | 1);\n\tt ^= t + Math.imul(t ^ t >>> 7, t | 61);\n\treturn ((t ^ t >>> 14) >>> 0) / 4294967296;\n}\n\n//#endregion\nexport { ALPHANUMERIC, URL_SAFE, cryptoBytes, cryptoRef, cryptoStringOf, next, setSeed };\n//# sourceMappingURL=_internal.mjs.map"],"x_google_ignoreList":[0],"mappings":";AAGA,MAAM,YAAY,OAAO,eAAe,eAAe,WAAW,SAAS,WAAW,SAAS,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "./_internal.mjs";
|
|
2
|
+
import "./bool.mjs";
|
|
3
|
+
import "./color.mjs";
|
|
4
|
+
import "./int.mjs";
|
|
5
|
+
import "./date.mjs";
|
|
6
|
+
import "./float.mjs";
|
|
7
|
+
import "./string.mjs";
|
|
8
|
+
import "./id.mjs";
|
|
9
|
+
import "./nanoid.mjs";
|
|
10
|
+
import "./pick.mjs";
|
|
11
|
+
import "./sample.mjs";
|
|
12
|
+
import "./token.mjs";
|
|
13
|
+
import "./uuid.mjs";
|
|
14
|
+
import "./weighted.mjs";
|
|
15
|
+
|
|
16
|
+
export { };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { get } from "./object/get.mjs";
|
|
2
|
+
import { clone } from "./mixed/clone/clone.mjs";
|
|
3
|
+
import { round } from "./number/round.mjs";
|
|
4
|
+
import { unset } from "./object/unset.mjs";
|
|
5
|
+
import { omit } from "./object/omit.mjs";
|
|
6
|
+
import { except } from "./object/except.mjs";
|
|
7
|
+
import "./Random/random.mjs";
|
|
8
|
+
import { ucfirst } from "./string/ucfirst.mjs";
|
|
9
|
+
import { capitalize } from "./string/capitalize.mjs";
|
|
10
|
+
import { escapeRegex } from "./utils/escapeRegex.mjs";
|
|
11
|
+
import { trim } from "./string/trim.mjs";
|
|
12
|
+
import { ltrim } from "./string/ltrim.mjs";
|
|
13
|
+
import { readMoreChars } from "./string/readMoreChars.mjs";
|
|
14
|
+
import { rtrim } from "./string/rtrim.mjs";
|
|
15
|
+
import { words } from "./string/words.mjs";
|
|
16
|
+
import { toCamelCase } from "./string/toCamelCase.mjs";
|
|
17
|
+
import { toSnakeCase } from "./string/toSnakeCase.mjs";
|
|
18
|
+
import { toKebabCase } from "./string/toKebabCase.mjs";
|
|
19
|
+
import { toStudlyCase } from "./string/toStudlyCase.mjs";
|
|
20
|
+
import { lazy } from "./utils/lazy.mjs";
|
|
21
|
+
import { tap } from "./utils/tap.mjs";
|
|
22
|
+
import "./async/retry.mjs";
|
|
23
|
+
|
|
24
|
+
export { };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
//#region ../node_modules/@mongez/reinforcements/esm/mixed/clone/clone.mjs
|
|
2
|
+
/**
|
|
3
|
+
* Deep-clone a value. Supports plain objects, arrays, `Date`, `RegExp`,
|
|
4
|
+
* `Map`, `Set`, `Error`, and typed arrays. Handles circular references
|
|
5
|
+
* via an internal `WeakMap`.
|
|
6
|
+
*
|
|
7
|
+
* Non-plain class instances are returned by reference — cloning custom
|
|
8
|
+
* constructors requires the class's own copy logic, so this function
|
|
9
|
+
* stops at that boundary rather than silently producing a half-clone.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const original = { user: { name: "Ada" }, tags: ["x"] };
|
|
13
|
+
* const copy = clone(original);
|
|
14
|
+
*
|
|
15
|
+
* copy.user.name = "Bob";
|
|
16
|
+
* original.user.name; // "Ada"
|
|
17
|
+
*/
|
|
18
|
+
function clone(value) {
|
|
19
|
+
if (value === null || typeof value !== "object") return value;
|
|
20
|
+
return cloneDeep(value, /* @__PURE__ */ new WeakMap());
|
|
21
|
+
}
|
|
22
|
+
function cloneDeep(value, seen) {
|
|
23
|
+
if (value === null || typeof value !== "object") return value;
|
|
24
|
+
if (seen.has(value)) return seen.get(value);
|
|
25
|
+
if (value instanceof Date) return new Date(value.getTime());
|
|
26
|
+
if (value instanceof RegExp) return cloneRegExp(value);
|
|
27
|
+
if (value instanceof Error) return cloneError(value, seen);
|
|
28
|
+
if (Array.isArray(value)) return cloneArray(value, seen);
|
|
29
|
+
if (value instanceof Map) return cloneMap(value, seen);
|
|
30
|
+
if (value instanceof Set) return cloneSet(value, seen);
|
|
31
|
+
if (ArrayBuffer.isView(value) && !(value instanceof DataView)) return cloneTypedArray(value);
|
|
32
|
+
if (value instanceof ArrayBuffer) return value.slice(0);
|
|
33
|
+
return clonePlainObject(value, seen);
|
|
34
|
+
}
|
|
35
|
+
function cloneRegExp(value) {
|
|
36
|
+
const copy = new RegExp(value.source, value.flags);
|
|
37
|
+
copy.lastIndex = value.lastIndex;
|
|
38
|
+
return copy;
|
|
39
|
+
}
|
|
40
|
+
function cloneError(value, seen) {
|
|
41
|
+
const Ctor = value.constructor;
|
|
42
|
+
const copy = new Ctor(value.message);
|
|
43
|
+
copy.stack = value.stack;
|
|
44
|
+
copy.name = value.name;
|
|
45
|
+
seen.set(value, copy);
|
|
46
|
+
for (const key of Object.keys(value)) copy[key] = cloneDeep(value[key], seen);
|
|
47
|
+
return copy;
|
|
48
|
+
}
|
|
49
|
+
function cloneArray(value, seen) {
|
|
50
|
+
const copy = [];
|
|
51
|
+
seen.set(value, copy);
|
|
52
|
+
for (const item of value) copy.push(cloneDeep(item, seen));
|
|
53
|
+
return copy;
|
|
54
|
+
}
|
|
55
|
+
function cloneMap(value, seen) {
|
|
56
|
+
const copy = /* @__PURE__ */ new Map();
|
|
57
|
+
seen.set(value, copy);
|
|
58
|
+
for (const [key, val] of value) copy.set(cloneDeep(key, seen), cloneDeep(val, seen));
|
|
59
|
+
return copy;
|
|
60
|
+
}
|
|
61
|
+
function cloneSet(value, seen) {
|
|
62
|
+
const copy = /* @__PURE__ */ new Set();
|
|
63
|
+
seen.set(value, copy);
|
|
64
|
+
for (const item of value) copy.add(cloneDeep(item, seen));
|
|
65
|
+
return copy;
|
|
66
|
+
}
|
|
67
|
+
function cloneTypedArray(value) {
|
|
68
|
+
const Ctor = value.constructor;
|
|
69
|
+
return new Ctor(value.buffer.slice(0));
|
|
70
|
+
}
|
|
71
|
+
function clonePlainObject(value, seen) {
|
|
72
|
+
const proto = Object.getPrototypeOf(value);
|
|
73
|
+
if (!(proto === Object.prototype || proto === null)) return value;
|
|
74
|
+
const copy = Object.create(proto);
|
|
75
|
+
seen.set(value, copy);
|
|
76
|
+
for (const key of Object.keys(value)) copy[key] = cloneDeep(value[key], seen);
|
|
77
|
+
return copy;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
export { clone };
|
|
82
|
+
//# sourceMappingURL=clone.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clone.mjs","names":[],"sources":["../../../../../../../../../../../../node_modules/@mongez/reinforcements/esm/mixed/clone/clone.mjs"],"sourcesContent":["//#region ../reinforcements/src/mixed/clone/clone.ts\n/**\n* Deep-clone a value. Supports plain objects, arrays, `Date`, `RegExp`,\n* `Map`, `Set`, `Error`, and typed arrays. Handles circular references\n* via an internal `WeakMap`.\n*\n* Non-plain class instances are returned by reference — cloning custom\n* constructors requires the class's own copy logic, so this function\n* stops at that boundary rather than silently producing a half-clone.\n*\n* @example\n* const original = { user: { name: \"Ada\" }, tags: [\"x\"] };\n* const copy = clone(original);\n*\n* copy.user.name = \"Bob\";\n* original.user.name; // \"Ada\"\n*/\nfunction clone(value) {\n\tif (value === null || typeof value !== \"object\") return value;\n\treturn cloneDeep(value, /* @__PURE__ */ new WeakMap());\n}\nfunction cloneDeep(value, seen) {\n\tif (value === null || typeof value !== \"object\") return value;\n\tif (seen.has(value)) return seen.get(value);\n\tif (value instanceof Date) return new Date(value.getTime());\n\tif (value instanceof RegExp) return cloneRegExp(value);\n\tif (value instanceof Error) return cloneError(value, seen);\n\tif (Array.isArray(value)) return cloneArray(value, seen);\n\tif (value instanceof Map) return cloneMap(value, seen);\n\tif (value instanceof Set) return cloneSet(value, seen);\n\tif (ArrayBuffer.isView(value) && !(value instanceof DataView)) return cloneTypedArray(value);\n\tif (value instanceof ArrayBuffer) return value.slice(0);\n\treturn clonePlainObject(value, seen);\n}\nfunction cloneRegExp(value) {\n\tconst copy = new RegExp(value.source, value.flags);\n\tcopy.lastIndex = value.lastIndex;\n\treturn copy;\n}\nfunction cloneError(value, seen) {\n\tconst Ctor = value.constructor;\n\tconst copy = new Ctor(value.message);\n\tcopy.stack = value.stack;\n\tcopy.name = value.name;\n\tseen.set(value, copy);\n\tfor (const key of Object.keys(value)) copy[key] = cloneDeep(value[key], seen);\n\treturn copy;\n}\nfunction cloneArray(value, seen) {\n\tconst copy = [];\n\tseen.set(value, copy);\n\tfor (const item of value) copy.push(cloneDeep(item, seen));\n\treturn copy;\n}\nfunction cloneMap(value, seen) {\n\tconst copy = /* @__PURE__ */ new Map();\n\tseen.set(value, copy);\n\tfor (const [key, val] of value) copy.set(cloneDeep(key, seen), cloneDeep(val, seen));\n\treturn copy;\n}\nfunction cloneSet(value, seen) {\n\tconst copy = /* @__PURE__ */ new Set();\n\tseen.set(value, copy);\n\tfor (const item of value) copy.add(cloneDeep(item, seen));\n\treturn copy;\n}\nfunction cloneTypedArray(value) {\n\tconst Ctor = value.constructor;\n\treturn new Ctor(value.buffer.slice(0));\n}\nfunction clonePlainObject(value, seen) {\n\tconst proto = Object.getPrototypeOf(value);\n\tif (!(proto === Object.prototype || proto === null)) return value;\n\tconst copy = Object.create(proto);\n\tseen.set(value, copy);\n\tfor (const key of Object.keys(value)) copy[key] = cloneDeep(value[key], seen);\n\treturn copy;\n}\n\n//#endregion\nexport { clone as default };\n//# sourceMappingURL=clone.mjs.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAS,MAAM,OAAO;CACrB,IAAI,UAAU,QAAQ,OAAO,UAAU,UAAU,OAAO;CACxD,OAAO,UAAU,uBAAuB,IAAI,QAAQ,CAAC;AACtD;AACA,SAAS,UAAU,OAAO,MAAM;CAC/B,IAAI,UAAU,QAAQ,OAAO,UAAU,UAAU,OAAO;CACxD,IAAI,KAAK,IAAI,KAAK,GAAG,OAAO,KAAK,IAAI,KAAK;CAC1C,IAAI,iBAAiB,MAAM,OAAO,IAAI,KAAK,MAAM,QAAQ,CAAC;CAC1D,IAAI,iBAAiB,QAAQ,OAAO,YAAY,KAAK;CACrD,IAAI,iBAAiB,OAAO,OAAO,WAAW,OAAO,IAAI;CACzD,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,WAAW,OAAO,IAAI;CACvD,IAAI,iBAAiB,KAAK,OAAO,SAAS,OAAO,IAAI;CACrD,IAAI,iBAAiB,KAAK,OAAO,SAAS,OAAO,IAAI;CACrD,IAAI,YAAY,OAAO,KAAK,KAAK,EAAE,iBAAiB,WAAW,OAAO,gBAAgB,KAAK;CAC3F,IAAI,iBAAiB,aAAa,OAAO,MAAM,MAAM,CAAC;CACtD,OAAO,iBAAiB,OAAO,IAAI;AACpC;AACA,SAAS,YAAY,OAAO;CAC3B,MAAM,OAAO,IAAI,OAAO,MAAM,QAAQ,MAAM,KAAK;CACjD,KAAK,YAAY,MAAM;CACvB,OAAO;AACR;AACA,SAAS,WAAW,OAAO,MAAM;CAChC,MAAM,OAAO,MAAM;CACnB,MAAM,OAAO,IAAI,KAAK,MAAM,OAAO;CACnC,KAAK,QAAQ,MAAM;CACnB,KAAK,OAAO,MAAM;CAClB,KAAK,IAAI,OAAO,IAAI;CACpB,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAAG,KAAK,OAAO,UAAU,MAAM,MAAM,IAAI;CAC5E,OAAO;AACR;AACA,SAAS,WAAW,OAAO,MAAM;CAChC,MAAM,OAAO,CAAC;CACd,KAAK,IAAI,OAAO,IAAI;CACpB,KAAK,MAAM,QAAQ,OAAO,KAAK,KAAK,UAAU,MAAM,IAAI,CAAC;CACzD,OAAO;AACR;AACA,SAAS,SAAS,OAAO,MAAM;CAC9B,MAAM,uBAAuB,IAAI,IAAI;CACrC,KAAK,IAAI,OAAO,IAAI;CACpB,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,KAAK,IAAI,UAAU,KAAK,IAAI,GAAG,UAAU,KAAK,IAAI,CAAC;CACnF,OAAO;AACR;AACA,SAAS,SAAS,OAAO,MAAM;CAC9B,MAAM,uBAAuB,IAAI,IAAI;CACrC,KAAK,IAAI,OAAO,IAAI;CACpB,KAAK,MAAM,QAAQ,OAAO,KAAK,IAAI,UAAU,MAAM,IAAI,CAAC;CACxD,OAAO;AACR;AACA,SAAS,gBAAgB,OAAO;CAC/B,MAAM,OAAO,MAAM;CACnB,OAAO,IAAI,KAAK,MAAM,OAAO,MAAM,CAAC,CAAC;AACtC;AACA,SAAS,iBAAiB,OAAO,MAAM;CACtC,MAAM,QAAQ,OAAO,eAAe,KAAK;CACzC,IAAI,EAAE,UAAU,OAAO,aAAa,UAAU,OAAO,OAAO;CAC5D,MAAM,OAAO,OAAO,OAAO,KAAK;CAChC,KAAK,IAAI,OAAO,IAAI;CACpB,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAAG,KAAK,OAAO,UAAU,MAAM,MAAM,IAAI;CAC5E,OAAO;AACR"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region ../node_modules/@mongez/reinforcements/esm/number/round.mjs
|
|
2
|
+
/**
|
|
3
|
+
* Round `value` to the given number of decimal places (banker's-style
|
|
4
|
+
* `Math.round`).
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* round(1.235, 2); // 1.24
|
|
8
|
+
* round(1.5); // 2
|
|
9
|
+
*/
|
|
10
|
+
function round(value, precision = 2) {
|
|
11
|
+
const multiplier = Math.pow(10, precision || 0);
|
|
12
|
+
return Math.round(value * multiplier) / multiplier;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { round };
|
|
17
|
+
//# sourceMappingURL=round.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"round.mjs","names":[],"sources":["../../../../../../../../../../../node_modules/@mongez/reinforcements/esm/number/round.mjs"],"sourcesContent":["//#region ../reinforcements/src/number/round.ts\n/**\n* Round `value` to the given number of decimal places (banker's-style\n* `Math.round`).\n*\n* @example\n* round(1.235, 2); // 1.24\n* round(1.5); // 2\n*/\nfunction round(value, precision = 2) {\n\tconst multiplier = Math.pow(10, precision || 0);\n\treturn Math.round(value * multiplier) / multiplier;\n}\n\n//#endregion\nexport { round as default };\n//# sourceMappingURL=round.mjs.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;AASA,SAAS,MAAM,OAAO,YAAY,GAAG;CACpC,MAAM,aAAa,KAAK,IAAI,IAAI,aAAa,CAAC;CAC9C,OAAO,KAAK,MAAM,QAAQ,UAAU,IAAI;AACzC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { omit } from "./omit.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../node_modules/@mongez/reinforcements/esm/object/except.mjs
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Use {@link omit} instead. Will be removed in a future major release.
|
|
6
|
+
*/
|
|
7
|
+
function except(object, keys) {
|
|
8
|
+
return omit(object, keys);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { except };
|
|
13
|
+
//# sourceMappingURL=except.mjs.map
|