better-ship 0.37.0 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/{application-B5hnNUdI.js → application-Dsz-o9Aj.js} +8 -5
  2. package/dist/{application-B5hnNUdI.js.map → application-Dsz-o9Aj.js.map} +1 -1
  3. package/dist/application.d.ts +3 -3
  4. package/dist/application.js +1 -1
  5. package/dist/{auth-secondary-storage-b9ptwPSB.d.ts → auth-secondary-storage-CcNkkEk0.d.ts} +2 -2
  6. package/dist/{auth-secondary-storage-b9ptwPSB.d.ts.map → auth-secondary-storage-CcNkkEk0.d.ts.map} +1 -1
  7. package/dist/better-auth/apple-client-secret.d.ts +1 -1
  8. package/dist/better-auth/apple-client-secret.js +1 -1
  9. package/dist/better-auth/auth-client.d.ts +1 -0
  10. package/dist/better-auth/auth-client.js +1 -1
  11. package/dist/better-auth/rate-limit.d.ts +1 -1
  12. package/dist/better-auth/rate-limit.js +1 -1
  13. package/dist/better-auth/secondary-storage.d.ts +2 -1
  14. package/dist/better-auth.d.ts +1 -0
  15. package/dist/better-auth.js +1 -1
  16. package/dist/billing/client.d.ts +2 -1
  17. package/dist/billing/client.js +1 -1
  18. package/dist/browser-support/floor.d.ts +1 -1
  19. package/dist/browser-support/floor.js +1 -1
  20. package/dist/browser-support/oxlint.js +1 -1
  21. package/dist/cloudflare/auth-secondary-storage.d.ts +1 -1
  22. package/dist/cloudflare/auth-secondary-storage.js +1 -1
  23. package/dist/cloudflare/durable-object-client.d.ts +1 -0
  24. package/dist/cloudflare/durable-object-client.js +2 -2
  25. package/dist/cloudflare/durable-object-errors.d.ts +2 -1
  26. package/dist/cloudflare/durable-object-errors.js +1 -1
  27. package/dist/cloudflare/kv-client.js +2 -2
  28. package/dist/cloudflare/kv-errors.d.ts +1 -1
  29. package/dist/cloudflare/kv-errors.js +1 -1
  30. package/dist/cloudflare/queue.d.ts +2 -2
  31. package/dist/cloudflare/queue.js +2 -2
  32. package/dist/cloudflare/r2-client.js +2 -2
  33. package/dist/cloudflare/r2-errors.d.ts +1 -1
  34. package/dist/cloudflare/r2-errors.js +1 -1
  35. package/dist/cloudflare/rate-limiter.d.ts +1 -1
  36. package/dist/cloudflare/rate-limiter.js +1 -1
  37. package/dist/cloudflare/scheduled.d.ts +1 -1
  38. package/dist/cloudflare/scheduled.js +1 -1
  39. package/dist/cloudflare/turnstile.d.ts +1 -1
  40. package/dist/cloudflare/turnstile.js +1 -1
  41. package/dist/cloudflare.d.ts +3 -3
  42. package/dist/cloudflare.d.ts.map +1 -1
  43. package/dist/cloudflare.js +3 -3
  44. package/dist/{core-BiN6S_cm.js → core-DOBZeYSX.js} +2 -7
  45. package/dist/core-DOBZeYSX.js.map +1 -0
  46. package/dist/core.d.ts +2 -2
  47. package/dist/core.js +2 -2
  48. package/dist/{durable-object-errors-DkMFXQnK.js → durable-object-errors-CcfTu0PQ.js} +2 -2
  49. package/dist/{durable-object-errors-DkMFXQnK.js.map → durable-object-errors-CcfTu0PQ.js.map} +1 -1
  50. package/dist/{floor-Cuw8EIhg.js → floor-BTBtPI9_.js} +2 -2
  51. package/dist/{floor-Cuw8EIhg.js.map → floor-BTBtPI9_.js.map} +1 -1
  52. package/dist/http.d.ts +2 -2
  53. package/dist/http.js +2 -2
  54. package/dist/{index-BosM_da2.d.ts → index-BMY7ylgk.d.ts} +19 -7
  55. package/dist/index-BMY7ylgk.d.ts.map +1 -0
  56. package/dist/{index-DUFS0SJ_.d.ts → index-CtIdbnEZ.d.ts} +17 -11
  57. package/dist/index-CtIdbnEZ.d.ts.map +1 -0
  58. package/dist/{kv-errors-BUTpFy0t.js → kv-errors-B2k_2lyY.js} +2 -2
  59. package/dist/{kv-errors-BUTpFy0t.js.map → kv-errors-B2k_2lyY.js.map} +1 -1
  60. package/dist/{metrics-B89jvpZQ.d.ts → metrics-CdTF_lWR.d.ts} +2 -2
  61. package/dist/{metrics-B89jvpZQ.d.ts.map → metrics-CdTF_lWR.d.ts.map} +1 -1
  62. package/dist/{outbox-repository-options-BNpCWTht.js → outbox-repository-options-Ca67c3c9.js} +2 -2
  63. package/dist/{outbox-repository-options-BNpCWTht.js.map → outbox-repository-options-Ca67c3c9.js.map} +1 -1
  64. package/dist/{outbox-repository-options-A2fA1UDX.d.ts → outbox-repository-options-q-CGUoCr.d.ts} +3 -3
  65. package/dist/{outbox-repository-options-A2fA1UDX.d.ts.map → outbox-repository-options-q-CGUoCr.d.ts.map} +1 -1
  66. package/dist/{payment-service.error-CqF7GkNp.js → payment-service.error-BR10zqxk.js} +2 -2
  67. package/dist/{payment-service.error-CqF7GkNp.js.map → payment-service.error-BR10zqxk.js.map} +1 -1
  68. package/dist/postgres.d.ts +3 -3
  69. package/dist/postgres.d.ts.map +1 -1
  70. package/dist/postgres.js +3 -3
  71. package/dist/posthog/metrics.d.ts +1 -1
  72. package/dist/posthog/server.d.ts +6 -6
  73. package/dist/posthog/server.d.ts.map +1 -1
  74. package/dist/posthog/server.js +15 -13
  75. package/dist/posthog/server.js.map +1 -1
  76. package/dist/{r2-errors-rk7n7rvk.js → r2-errors-BF49eqU_.js} +2 -2
  77. package/dist/{r2-errors-rk7n7rvk.js.map → r2-errors-BF49eqU_.js.map} +1 -1
  78. package/dist/{request-4vJEWxyZ.js → request-BYQodKDU.js} +2 -2
  79. package/dist/{request-4vJEWxyZ.js.map → request-BYQodKDU.js.map} +1 -1
  80. package/dist/resend.d.ts +3 -3
  81. package/dist/resend.js +2 -2
  82. package/dist/sentry/client.d.ts +1 -1
  83. package/dist/sentry/client.js +1 -1
  84. package/dist/sentry/server.d.ts +2 -2
  85. package/dist/sentry/tanstack.d.ts +1 -1
  86. package/dist/stripe/client.d.ts.map +1 -1
  87. package/dist/stripe/event-map.d.ts +1 -0
  88. package/dist/stripe/payment-service.error.d.ts +1 -1
  89. package/dist/stripe/payment-service.error.js +1 -1
  90. package/dist/stripe/payment-service.js +1 -1
  91. package/dist/stripe/payment-webhook.d.ts +1 -1
  92. package/dist/stripe/payment-webhook.js +1 -1
  93. package/dist/stripe/request.js +1 -1
  94. package/dist/tanstack.d.ts +1 -1
  95. package/dist/tanstack.js +1 -1
  96. package/dist/testing/outbox-repository.d.ts +2 -2
  97. package/dist/testing/payment-service.js +1 -1
  98. package/dist/testing/stripe.d.ts +1 -0
  99. package/dist/{webhook-verification-lWso44-q.js → webhook-verification-C4R6OO7f.js} +2 -2
  100. package/dist/{webhook-verification-lWso44-q.js.map → webhook-verification-C4R6OO7f.js.map} +1 -1
  101. package/dist/{webhook-verification-D1c7BY4q.d.ts → webhook-verification-DL4L3zbu.d.ts} +2 -2
  102. package/dist/{webhook-verification-D1c7BY4q.d.ts.map → webhook-verification-DL4L3zbu.d.ts.map} +1 -1
  103. package/package.json +41 -41
  104. package/src/application/analytics-service.ts +35 -8
  105. package/src/application/index.ts +5 -1
  106. package/src/core/analytics-event.ts +17 -13
  107. package/src/core/index.ts +1 -3
  108. package/src/infrastructure/posthog/server.ts +28 -17
  109. package/dist/core-BiN6S_cm.js.map +0 -1
  110. package/dist/index-BosM_da2.d.ts.map +0 -1
  111. package/dist/index-DUFS0SJ_.d.ts.map +0 -1
@@ -1,13 +1,16 @@
1
- import { D as unreachable, O as DatabaseError, d as classifyFailure, nt as AppError, r as createLogger } from "./core-BiN6S_cm.js";
1
+ import { D as unreachable, O as DatabaseError, d as classifyFailure, r as createLogger, tt as AppError } from "./core-DOBZeYSX.js";
2
2
  import { panic } from "better-result";
3
3
 
4
4
  //#region src/application/analytics-service.ts
5
- /** Reports to nobody. The composition root selects this service when analytics is disabled. */
5
+ /**
6
+ * Reports to nobody. The composition root selects this service when analytics is disabled.
7
+ * `satisfies` keeps its own type, so it serves an `AnalyticsService` of any event map.
8
+ */
6
9
  const NULL_ANALYTICS = {
7
10
  identify: () => {},
8
11
  alias: () => {},
9
- track: () => {},
10
- trackAnonymous: () => {}
12
+ track: (_name, _properties, _target) => {},
13
+ trackAnonymous: (_name, _properties, _target) => {}
11
14
  };
12
15
 
13
16
  //#endregion
@@ -286,4 +289,4 @@ var UnitOfWorkAlreadyActiveError = class extends AppError {
286
289
 
287
290
  //#endregion
288
291
  export { MessageBus as a, RecordingEmailService as c, OutboxRelay as i, NULL_METRICS_SERVICE as l, UnitOfWork as n, MessageAlreadyProcessedError as o, OutboxRetention as r, recordEmailEvent as s, UnitOfWorkAlreadyActiveError as t, NULL_ANALYTICS as u };
289
- //# sourceMappingURL=application-B5hnNUdI.js.map
292
+ //# sourceMappingURL=application-Dsz-o9Aj.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"application-B5hnNUdI.js","names":["logger"],"sources":["../src/application/analytics-service.ts","../src/application/metrics-service.ts","../src/application/email-service.ts","../src/application/record-email-event.ts","../src/application/message-already-processed.error.ts","../src/application/message-bus.ts","../src/application/outbox-relay.ts","../src/application/outbox-retention.ts","../src/application/unit-of-work.ts","../src/application/unit-of-work.errors.ts"],"sourcesContent":["import type { AnalyticsEventIdentity, AnalyticsEventInput, AnalyticsProperties } from '@/core'\n\n/** Product analytics without an SDK dependency, ported from Typist and Porte. */\nexport interface AnalyticsService<TEvent extends AnalyticsEventInput = AnalyticsEventInput> {\n /** Attach traits to one person. */\n identify(distinctId: string, properties?: AnalyticsProperties): void\n /** Merge a previous ID into this person; the application must establish that both identify the same person. */\n alias(distinctId: string, previousDistinctId: string): void\n /** Schedule an event for a person; returning does not confirm remote acceptance. */\n track(event: TEvent, distinctId: string, identity?: AnalyticsEventIdentity): void\n /** Schedule an event without creating a person profile for its distinct ID. */\n trackAnonymous(event: TEvent, distinctId: string, identity?: AnalyticsEventIdentity): void\n}\n\n/** Reports to nobody. The composition root selects this service when analytics is disabled. */\nexport const NULL_ANALYTICS: AnalyticsService = {\n identify: () => {},\n alias: () => {},\n track: () => {},\n trackAnonymous: () => {},\n}\n","/** A metric dimension; use a small, bounded value set and never user or request IDs. */\nexport type MetricAttributeValue = string | number | boolean\n\n/** Dimensions shared by observations in one time series. */\nexport type MetricAttributes = Readonly<Record<string, MetricAttributeValue>>\n\n/** Unit and dimensions for an operational measurement. */\nexport interface MetricOptions {\n readonly attributes?: MetricAttributes\n readonly unit?: string\n}\n\n/** Operational measurements, ported from Typist's metrics-service.ts; applications own metric names. */\nexport interface MetricsService<TName extends string = string> {\n /** Add a nonnegative value to a total; the default increment is one. */\n count(name: TName, value?: number, options?: MetricOptions): void\n /** Record a current value. */\n gauge(name: TName, value: number, options?: MetricOptions): void\n /** Record one observation in a distribution. */\n histogram(name: TName, value: number, options?: MetricOptions): void\n}\n\n/** Records nothing when the composition root disables metrics. */\nexport const NULL_METRICS_SERVICE: MetricsService = {\n count: () => {},\n gauge: () => {},\n histogram: () => {},\n}\n","import type { EmailIdempotencyKey } from '@/core'\n\n/** A media type such as `application/pdf`. */\nexport type MimeType = `${string}/${string}`\n\n/** A file to attach. Binary content is bytes; the adapter encodes it for the provider. */\nexport type EmailAttachment = {\n readonly filename: string\n readonly content: string | Uint8Array\n /** Optional MIME metadata; Resend accepts filename and content without it. */\n readonly contentType?: MimeType\n}\n\n/**\n * One transactional email. Resend accepts 50 recipients, 75 tags with ASCII names and values,\n * and 40 MB of attachments after base64. Sources: https://resend.com/docs/api-reference/emails/send-email\n * and https://resend.com/docs/dashboard/emails/tags\n */\nexport type OutboundEmail = {\n /** Override the default for this email, for example \"Display Name <address@domain.com>\". */\n readonly from?: string\n readonly to: string | readonly string[]\n readonly subject: string\n readonly html: string\n /** Optional stable identity of this send. Resend deduplicates supplied keys for 24 hours. */\n readonly idempotencyKey?: EmailIdempotencyKey\n /** Resend generates plain text from html when omitted. An empty string disables that generation. */\n readonly text?: string\n readonly replyTo?: string\n /** Labels the provider stores with the email and returns on every delivery event. */\n readonly tags?: Readonly<Record<string, string>>\n readonly attachments?: readonly EmailAttachment[]\n}\n\n/** Received email headers, without the body or attachments. */\nexport type ReceivedEmail = { readonly headers: Readonly<Record<string, string>> }\n\n/** One attachment of a received email. `downloadUrl` is a signed link that stops working at `expiresAt`. */\nexport type ReceivedAttachment = {\n readonly filename: string | null\n readonly contentType: string\n readonly size: number\n readonly downloadUrl: string\n readonly expiresAt: string\n}\n\n/** A received email's sender, plain text body, and attachments, for an application that reads mail it receives. */\nexport type ReceivedContent = {\n /** The sender as the email states it, for example \"Display Name <address@domain.com>\". */\n readonly from: string\n readonly text: string | null\n readonly attachments: readonly ReceivedAttachment[]\n}\n\n/** The provider accepted the email and assigned its id. */\nexport type EmailAccepted = { readonly providerId: string }\n\n/**\n * The adapter supplies the default sender and maps provider errors. Each email can override the sender.\n * A provider rejection throws `EmailServiceError`; unexpected SDK rejections propagate unchanged.\n */\nexport interface IEmailService {\n /** Resolve after provider acceptance; this does not confirm delivery to the recipient. */\n sendEmail(email: OutboundEmail): Promise<EmailAccepted>\n}\n\n/** Records every send for a test. Provider ids count up as `recorded-1`, `recorded-2`. */\nexport class RecordingEmailService implements IEmailService {\n /** Sends in call order, including repeated idempotency keys. */\n readonly sent: OutboundEmail[] = []\n\n /** Record the send before returning its provider id. */\n async sendEmail(email: OutboundEmail): Promise<EmailAccepted> {\n this.sent.push(email)\n return { providerId: `recorded-${this.sent.length}` }\n }\n}\n","import type { BounceType, DomainCommand, EmailAddress, RecordEmailEventPayload } from '@/core'\n\nimport type { IUnitOfWork } from './unit-of-work.ts'\n\n/** What a bounce records for one address. */\nexport type EmailBounceRecord = {\n readonly type: BounceType\n readonly subType: string | null\n}\n\n/**\n * The application's deliverability state per address. An implementation keeps the higher bounce\n * severity with `shouldUpdateBounce`, and treats an unknown address as nothing to record.\n */\nexport interface IEmailDeliverabilityStore {\n /** Keep the higher severity atomically. Equal severity permits replacement; the store owns timestamp ordering. */\n recordBounce(address: EmailAddress, bounce: EmailBounceRecord): Promise<void>\n /** Record a complaint without clearing existing suppression state. */\n recordComplaint(address: EmailAddress): Promise<void>\n}\n\n/** The repositories the handler needs from the unit of work. */\nexport type RecordEmailEventRepos = { readonly emailDeliverability: IEmailDeliverabilityStore }\n\n/** The container slice the handler reads. */\nexport type RecordEmailEventDeps = { readonly uow: IUnitOfWork<RecordEmailEventRepos> }\n\n/** The command, under whatever name the application registered the payload. */\nexport type RecordEmailEventCommand = DomainCommand & RecordEmailEventPayload\n\n/**\n * Record a bounce or a complaint for every recipient inside the command's unit of work.\n * The command id is the provider's event id, so a redelivered webhook is `MessageAlreadyProcessedError`.\n */\nexport async function recordEmailEvent(\n command: RecordEmailEventCommand,\n deps: RecordEmailEventDeps,\n): Promise<void> {\n await deps.uow.run(command.id, async ({ emailDeliverability }) => {\n for (const address of command.recipients) {\n if (command.event.type === 'bounced') {\n // oxlint-disable-next-line no-await-in-loop -- Finish each transaction write before starting another; a failure must leave no pending writes.\n await emailDeliverability.recordBounce(address, {\n type: command.event.bounceType,\n subType: command.event.bounceSubType,\n })\n } else {\n // oxlint-disable-next-line no-await-in-loop -- A rejected write must stop the transaction before another write starts.\n await emailDeliverability.recordComplaint(address)\n }\n }\n })\n}\n","import { AppError, DatabaseError, type MessageId } from '@/core'\n\n/** The message's effects already committed. A caller can skip duplicate delivery without repeating those effects. */\nexport class MessageAlreadyProcessedError extends AppError {\n readonly _tag = 'MessageAlreadyProcessedError'\n readonly classification = 'terminal'\n\n constructor(\n readonly messageId: MessageId,\n options?: { readonly cause: unknown },\n ) {\n super(`message ${messageId} already processed`, options)\n }\n\n /** Recognize only the processed-message primary key; preserve other failures unchanged at the call site. */\n static from(cause: unknown, messageId: MessageId): MessageAlreadyProcessedError | undefined {\n if (cause instanceof MessageAlreadyProcessedError) return cause\n if (!(cause instanceof DatabaseError)) return undefined\n const details = cause.details\n const duplicate =\n details.database === 'd1'\n ? details.kind === 'unique' &&\n details.table === 'processed_messages' &&\n details.column === 'message_id'\n : details.code === '23505' &&\n details.table_name === 'processed_messages' &&\n details.constraint_name === 'processed_messages_pkey'\n if (!duplicate) return undefined\n return new MessageAlreadyProcessedError(messageId, { cause })\n }\n}\n","import { panic } from 'better-result'\n\nimport {\n createLogger,\n unreachable,\n type DomainCommand,\n type DomainEvent,\n type DomainMessage,\n type DomainQuery,\n} from '@/core'\n\nimport { MessageAlreadyProcessedError } from './message-already-processed.error.ts'\nimport type { Handlers, MessageResult, RegistryMessage } from './registry.ts'\n\nconst logger = createLogger('message-bus')\n\n/** The port an entrypoint dispatches through. `AppDeps` names this as `IMessageBus<typeof registry>`. */\nexport interface IMessageBus<TRegistry extends Handlers<never>> {\n handle<TMessage extends DomainMessage & RegistryMessage<TRegistry>>(\n message: TMessage,\n ): Promise<MessageResult<TMessage, TRegistry>>\n}\n\n/**\n * Routes one message to its slot. The bus opens no transaction and keeps no outbox:\n * a handler that writes opens the unit of work itself.\n */\nexport class MessageBus<Deps, TRegistry extends Handlers<Deps>> implements IMessageBus<TRegistry> {\n constructor(\n private readonly deps: Deps,\n private readonly registry: TRegistry,\n ) {}\n\n /** Resolves to the handler's own value for a command or query, and to void for an event. */\n async handle<TMessage extends DomainMessage & RegistryMessage<TRegistry>>(\n message: TMessage,\n ): Promise<MessageResult<TMessage, TRegistry>> {\n // SAFETY: the slot for this name is what `MessageResult` names, and dispatch returns its value.\n return (await this.dispatch(message)) as MessageResult<TMessage, TRegistry>\n }\n\n // oxlint-disable-next-line anti-slop/no-unknown-returns -- one table holds every slot's value; `handle` names it.\n private dispatch(message: DomainMessage): Promise<unknown> {\n if (message.type === 'command') return this.handleCommand(message)\n if (message.type === 'query') return this.handleQuery(message)\n if (message.type === 'event') return this.handleEvent(message)\n // A message parsed at a boundary cannot reach here; one that does must not resolve silently.\n return unreachable(message)\n }\n\n // oxlint-disable-next-line anti-slop/no-unknown-returns -- see dispatch.\n private handleCommand(command: DomainCommand): Promise<unknown> {\n // `satisfies` proved the registry complete, so a missing slot is a broken registry object.\n const handler = this.registry.commands[command.name]\n if (handler === undefined) return panic(`No handler for command ${command.name}`)\n logger.debug('handling_command', { name: command.name, id: command.id })\n return handler(command, this.deps)\n }\n\n // oxlint-disable-next-line anti-slop/no-unknown-returns -- see dispatch.\n private handleQuery(query: DomainQuery): Promise<unknown> {\n const handler = this.registry.queries[query.name]\n if (handler === undefined) return panic(`No handler for query ${query.name}`)\n return handler(query, this.deps)\n }\n\n /**\n * Subscribers run one after another, so one unit of work finishes before the next starts.\n * Every subscriber still runs. One failure is rethrown as is. Several are thrown as one `AggregateError`.\n * A `MessageAlreadyProcessedError` means that subscriber already committed on an earlier delivery, so it counts as delivered.\n */\n private async handleEvent(event: DomainEvent): Promise<void> {\n const subscriptions = this.registry.events[event.name] ?? []\n const failures: unknown[] = []\n for (const [subscriber, subscription] of subscriptions.entries()) {\n try {\n await subscription(event, this.deps)\n } catch (reason) {\n if (reason instanceof MessageAlreadyProcessedError) {\n // The bus swallows this error, so this line is the only record that the skip happened.\n logger.info('duplicate_subscriber_ignored', {\n event: event.name,\n id: event.id,\n subscriber,\n })\n continue\n }\n failures.push(reason)\n }\n }\n if (failures.length === 1) throw failures[0]\n if (failures.length > 1) {\n throw new AggregateError(failures, `${event.name}: ${failures.length} subscribers failed`)\n }\n }\n}\n","import { classifyFailure, createLogger, type DomainEvent } from '@/core'\n\nimport type {\n DeadLetterReason,\n IOutboxRepository,\n OutboxClaim,\n OutboxMessage,\n} from './outbox-repository.ts'\n\n/**\n * Delivers committed outbox rows. The unit of work only wakes it after a commit that wrote\n * events; the app decides what a wake is: `waitUntil`, a Durable Object alarm, nothing.\n * The sweep is the source of truth, so a lost wake loses no events.\n */\nexport interface IOutboxRelay {\n wake(): void\n}\n\n/** The publisher sends valid events and returns oversized events. QueueClient satisfies this port directly. */\nexport interface IOutboxPublisher {\n /** Resolves after queue acceptance; a rejected batch may already have sent some events. */\n sendBatchPartial(messages: ReadonlyArray<DomainEvent>): Promise<ReadonlyArray<DomainEvent>>\n}\n\n/** Optional limits for one relay; durable attempts exclude the publisher's immediate retries. */\nexport type OutboxRelayOptions = {\n readonly batchSize?: number\n readonly maxBatches?: number\n readonly maxAttempts?: number\n}\n\nconst logger = createLogger('outbox-relay')\n\n/**\n * Publishes committed events with bounded durable retries. Ported from Typist's relay with per-row exhaustion.\n * Send failures are recorded; repository failures propagate to the wake or scheduled boundary.\n */\nexport class OutboxRelay {\n private readonly options: Required<OutboxRelayOptions>\n\n constructor(\n private readonly publisher: IOutboxPublisher,\n private readonly repository: IOutboxRepository,\n options: OutboxRelayOptions = {},\n ) {\n this.options = {\n batchSize: options.batchSize ?? 50,\n maxBatches: options.maxBatches ?? 10,\n maxAttempts: options.maxAttempts ?? 10,\n }\n }\n\n /** Return the claimed count, including released and dead-lettered rows. Zero means no due rows. */\n async flush(): Promise<number> {\n const claim = await this.repository.claimPending(this.options.batchSize)\n const exhausted = claim.messages.filter((row) => row.attempts > this.options.maxAttempts)\n await this.deadLetter(claim, exhausted, 'exhausted', 'Claim attempt limit exceeded')\n const pending = claim.messages.filter((row) => row.attempts <= this.options.maxAttempts)\n if (pending.length === 0) return claim.messages.length\n\n let oversized: ReadonlyArray<DomainEvent>\n try {\n oversized = await this.publisher.sendBatchPartial(pending.map((row) => row.payload))\n } catch (error) {\n await this.handleSendFailure(claim, pending, error)\n return claim.messages.length\n }\n\n const oversizedIds = new Set(oversized.map((event) => event.id))\n await this.deadLetter(\n claim,\n pending.filter((row) => oversizedIds.has(row.payload.id)),\n 'oversized',\n 'Exceeds queue message size limit',\n )\n const sent = pending.filter((row) => !oversizedIds.has(row.payload.id))\n if (sent.length > 0) await this.repository.markPublished(claim, sent)\n return claim.messages.length\n }\n\n /** Drain until an empty claim or the batch limit; return the total claimed count. */\n async drain(): Promise<number> {\n let total = 0\n for (let batch = 0; batch < this.options.maxBatches; batch += 1) {\n // oxlint-disable-next-line no-await-in-loop -- An empty claim must stop the drain before another claim starts.\n const claimed = await this.flush()\n total += claimed\n if (claimed === 0) break\n }\n return total\n }\n\n private async handleSendFailure(\n claim: OutboxClaim,\n pending: ReadonlyArray<OutboxMessage>,\n cause: unknown,\n ): Promise<void> {\n const classification = classifyFailure(cause)\n const message =\n cause instanceof Error ? cause.message : 'Publisher rejected with a non-error value'\n if (classification === 'terminal') {\n await this.deadLetter(claim, pending, 'terminal', message, cause)\n return\n }\n const exhausted = pending.filter((row) => row.attempts >= this.options.maxAttempts)\n await this.deadLetter(claim, exhausted, 'exhausted', message, cause)\n const retry = pending.filter((row) => row.attempts < this.options.maxAttempts)\n if (retry.length > 0) await this.repository.releaseClaim(claim, retry)\n }\n\n private async deadLetter(\n claim: OutboxClaim,\n messages: ReadonlyArray<OutboxMessage>,\n reason: DeadLetterReason,\n errorMessage: string,\n cause?: unknown,\n ): Promise<void> {\n if (messages.length === 0) return\n await this.repository.deadLetter(claim, messages, reason, errorMessage)\n logger.error('outbox_messages_dead_lettered', {\n error: cause,\n claimToken: claim.token,\n count: messages.length,\n reason,\n })\n }\n}\n","import type { IOutboxRetentionRepository } from './outbox-repository.ts'\n\n/** Typist's retention defaults; receipt retention must cover the application's supported replay period. */\nexport type OutboxRetentionOptions = {\n readonly publishedRetentionMs?: number\n readonly failedRetentionMs?: number\n readonly receiptRetentionMs?: number\n readonly batchSize?: number\n readonly maxBatches?: number\n}\n\n/** Deleted records per category during one bounded sweep. */\nexport type OutboxRetentionResult = {\n readonly published: number\n readonly failed: number\n readonly receipts: number\n}\n\n/** Bounded cleanup ported from Typist's message retention handler. The application schedules each sweep. */\nexport class OutboxRetention {\n private readonly options: Required<OutboxRetentionOptions>\n\n constructor(\n private readonly repository: IOutboxRetentionRepository,\n options: OutboxRetentionOptions = {},\n ) {\n this.options = {\n publishedRetentionMs: options.publishedRetentionMs ?? 86_400_000,\n failedRetentionMs: options.failedRetentionMs ?? 30 * 86_400_000,\n receiptRetentionMs: options.receiptRetentionMs ?? 7 * 86_400_000,\n batchSize: options.batchSize ?? 1_000,\n maxBatches: options.maxBatches ?? 10,\n }\n }\n\n /** Calculate all cutoffs from one supplied time; propagate repository failures to the calling boundary. */\n async sweep(at: Date): Promise<OutboxRetentionResult> {\n const { publishedRetentionMs, failedRetentionMs, receiptRetentionMs } = this.options\n const published = await this.deleteBatches((size) =>\n this.repository.deletePublishedBefore(new Date(at.getTime() - publishedRetentionMs), size),\n )\n const failed = await this.deleteBatches((size) =>\n this.repository.deleteFailedBefore(new Date(at.getTime() - failedRetentionMs), size),\n )\n const receipts = await this.deleteBatches((size) =>\n this.repository.deleteReceiptsBefore(new Date(at.getTime() - receiptRetentionMs), size),\n )\n return { published, failed, receipts }\n }\n\n private async deleteBatches(deleteBatch: (size: number) => Promise<number>): Promise<number> {\n let total = 0\n for (let batch = 0; batch < this.options.maxBatches; batch += 1) {\n // oxlint-disable-next-line no-await-in-loop -- The delete count decides whether another batch is needed.\n const deleted = await deleteBatch(this.options.batchSize)\n total += deleted\n if (deleted < this.options.batchSize) break\n }\n return total\n }\n}\n","import type { MessageId } from '@/core'\n\nimport type { IEventCollector } from './event-collector.ts'\nimport { MessageAlreadyProcessedError } from './message-already-processed.error.ts'\nimport type { IMessageStore } from './message-store.ts'\nimport type { IOutboxRelay } from './outbox-relay.ts'\nimport type { ITransaction } from './transaction.ts'\n\n/**\n * Commits the processed-message record, repository writes, and emitted events together before resolving.\n * An existing record rejects with `MessageAlreadyProcessedError`; external effects must run through the outbox after commit.\n * Nested calls reject with `UnitOfWorkAlreadyActiveError`.\n */\nexport interface IUnitOfWork<Repos> {\n run<T>(messageId: MessageId, work: (repos: Repos) => Promise<T>): Promise<T>\n}\n\nexport type UnitOfWorkDeps<Tx, Repos> = {\n readonly transaction: ITransaction<Tx>\n /** The processed-messages and outbox repository for this transaction. */\n readonly messageStore: (tx: Tx) => IMessageStore\n /** Repositories participate in the current transaction. */\n readonly createRepositories: (tx: Tx) => Repos\n readonly eventCollector: IEventCollector\n readonly relay: IOutboxRelay\n}\n\n/** The unit of work: the boundary, the repositories, the events. Every database call is a port. */\nexport class UnitOfWork<Tx, Repos> implements IUnitOfWork<Repos> {\n constructor(private readonly deps: UnitOfWorkDeps<Tx, Repos>) {}\n\n async run<T>(messageId: MessageId, work: (repos: Repos) => Promise<T>): Promise<T> {\n const { transaction, messageStore, createRepositories, eventCollector, relay } = this.deps\n let written = 0\n\n let value: T\n try {\n value = await transaction.transaction(async (tx) => {\n const store = messageStore(tx)\n await store.claim(messageId)\n const repos = createRepositories(tx)\n const result = await work(repos)\n const pending = eventCollector.collect()\n await store.persistEvents(pending)\n written = pending.length\n return result\n })\n } catch (error) {\n throw MessageAlreadyProcessedError.from(error, messageId) ?? error\n }\n\n if (written > 0) relay.wake()\n return value\n }\n}\n","import { AppError } from '@/core'\n\n/** A boundary was opened inside another. One message, one atomic scope. */\nexport class UnitOfWorkAlreadyActiveError extends AppError {\n readonly _tag = 'UnitOfWorkAlreadyActiveError'\n readonly classification = 'terminal'\n\n constructor() {\n super('a unit of work is already active')\n }\n}\n"],"mappings":";;;;;AAeA,MAAa,iBAAmC;CAC9C,gBAAgB,CAAC;CACjB,aAAa,CAAC;CACd,aAAa,CAAC;CACd,sBAAsB,CAAC;AACzB;;;;;ACGA,MAAa,uBAAuC;CAClD,aAAa,CAAC;CACd,aAAa,CAAC;CACd,iBAAiB,CAAC;AACpB;;;;;ACwCA,IAAa,wBAAb,MAA4D;;CAE1D,AAAS,OAAwB,CAAC;;CAGlC,MAAM,UAAU,OAA8C;EAC5D,KAAK,KAAK,KAAK,KAAK;EACpB,OAAO,EAAE,YAAY,YAAY,KAAK,KAAK,SAAS;CACtD;AACF;;;;;;;;AC1CA,eAAsB,iBACpB,SACA,MACe;CACf,MAAM,KAAK,IAAI,IAAI,QAAQ,IAAI,OAAO,EAAE,0BAA0B;EAChE,KAAK,MAAM,WAAW,QAAQ,YAC5B,IAAI,QAAQ,MAAM,SAAS,WAEzB,MAAM,oBAAoB,aAAa,SAAS;GAC9C,MAAM,QAAQ,MAAM;GACpB,SAAS,QAAQ,MAAM;EACzB,CAAC;OAGD,MAAM,oBAAoB,gBAAgB,OAAO;CAGvD,CAAC;AACH;;;;;ACjDA,IAAa,+BAAb,MAAa,qCAAqC,SAAS;CAK9C;CAJX,AAAS,OAAO;CAChB,AAAS,iBAAiB;CAE1B,YACE,AAAS,WACT,SACA;EACA,MAAM,WAAW,UAAU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B,gBAAgB,UAAU,KAAK;EACtF,IAAI,UAAU;EAEd,IAAI;EACJ,IAAI;GACF,QAAQ,MAAM,YAAY,YAAY,OAAO,OAAO;IAClD,MAAM,QAAQ,aAAa,EAAE;IAC7B,MAAM,MAAM,MAAM,SAAS;IAE3B,MAAM,SAAS,MAAM,KADP,mBAAmB,EACH,CAAC;IAC/B,MAAM,UAAU,eAAe,QAAQ;IACvC,MAAM,MAAM,cAAc,OAAO;IACjC,UAAU,QAAQ;IAClB,OAAO;GACT,CAAC;EACH,SAAS,OAAO;GACd,MAAM,6BAA6B,KAAK,OAAO,SAAS,KAAK;EAC/D;EAEA,IAAI,UAAU,GAAG,MAAM,KAAK;EAC5B,OAAO;CACT;AACF;;;;;ACnDA,IAAa,+BAAb,cAAkD,SAAS;CACzD,AAAS,OAAO;CAChB,AAAS,iBAAiB;CAE1B,cAAc;EACZ,MAAM,kCAAkC;CAC1C;AACF"}
1
+ {"version":3,"file":"application-Dsz-o9Aj.js","names":["logger"],"sources":["../src/application/analytics-service.ts","../src/application/metrics-service.ts","../src/application/email-service.ts","../src/application/record-email-event.ts","../src/application/message-already-processed.error.ts","../src/application/message-bus.ts","../src/application/outbox-relay.ts","../src/application/outbox-retention.ts","../src/application/unit-of-work.ts","../src/application/unit-of-work.errors.ts"],"sourcesContent":["import type { AnalyticsEventInput, AnalyticsProperties, AnalyticsTarget } from '@/core'\n\n/** The properties of one event name; an untyped service accepts any properties. */\nexport type AnalyticsPropertiesOf<\n TEvent extends AnalyticsEventInput,\n TName extends TEvent['name'],\n> = string extends TEvent['name']\n ? TEvent['properties']\n : Extract<TEvent, { readonly name: TName }>['properties']\n\n/** Product analytics without an SDK dependency, ported from Typist and Porte. */\nexport interface AnalyticsService<TEvent extends AnalyticsEventInput = AnalyticsEventInput> {\n /** Attach traits to one person. */\n identify(distinctId: string, properties?: AnalyticsProperties): void\n /** Merge a previous ID into this person; the application must establish that both identify the same person. */\n alias(distinctId: string, previousDistinctId: string): void\n /** Schedule an event for a person; returning does not confirm remote acceptance. */\n track<TName extends TEvent['name']>(\n name: TName,\n properties: AnalyticsPropertiesOf<TEvent, TName>,\n target: AnalyticsTarget,\n ): void\n /** Schedule an event without creating a person profile for its distinct ID. */\n trackAnonymous<TName extends TEvent['name']>(\n name: TName,\n properties: AnalyticsPropertiesOf<TEvent, TName>,\n target: AnalyticsTarget,\n ): void\n}\n\n/**\n * Reports to nobody. The composition root selects this service when analytics is disabled.\n * `satisfies` keeps its own type, so it serves an `AnalyticsService` of any event map.\n */\nexport const NULL_ANALYTICS = {\n identify: () => {},\n alias: () => {},\n track: (\n _name: string,\n _properties: AnalyticsEventInput['properties'],\n _target: AnalyticsTarget,\n ) => {},\n trackAnonymous: (\n _name: string,\n _properties: AnalyticsEventInput['properties'],\n _target: AnalyticsTarget,\n ) => {},\n} satisfies AnalyticsService\n","/** A metric dimension; use a small, bounded value set and never user or request IDs. */\nexport type MetricAttributeValue = string | number | boolean\n\n/** Dimensions shared by observations in one time series. */\nexport type MetricAttributes = Readonly<Record<string, MetricAttributeValue>>\n\n/** Unit and dimensions for an operational measurement. */\nexport interface MetricOptions {\n readonly attributes?: MetricAttributes\n readonly unit?: string\n}\n\n/** Operational measurements, ported from Typist's metrics-service.ts; applications own metric names. */\nexport interface MetricsService<TName extends string = string> {\n /** Add a nonnegative value to a total; the default increment is one. */\n count(name: TName, value?: number, options?: MetricOptions): void\n /** Record a current value. */\n gauge(name: TName, value: number, options?: MetricOptions): void\n /** Record one observation in a distribution. */\n histogram(name: TName, value: number, options?: MetricOptions): void\n}\n\n/** Records nothing when the composition root disables metrics. */\nexport const NULL_METRICS_SERVICE: MetricsService = {\n count: () => {},\n gauge: () => {},\n histogram: () => {},\n}\n","import type { EmailIdempotencyKey } from '@/core'\n\n/** A media type such as `application/pdf`. */\nexport type MimeType = `${string}/${string}`\n\n/** A file to attach. Binary content is bytes; the adapter encodes it for the provider. */\nexport type EmailAttachment = {\n readonly filename: string\n readonly content: string | Uint8Array\n /** Optional MIME metadata; Resend accepts filename and content without it. */\n readonly contentType?: MimeType\n}\n\n/**\n * One transactional email. Resend accepts 50 recipients, 75 tags with ASCII names and values,\n * and 40 MB of attachments after base64. Sources: https://resend.com/docs/api-reference/emails/send-email\n * and https://resend.com/docs/dashboard/emails/tags\n */\nexport type OutboundEmail = {\n /** Override the default for this email, for example \"Display Name <address@domain.com>\". */\n readonly from?: string\n readonly to: string | readonly string[]\n readonly subject: string\n readonly html: string\n /** Optional stable identity of this send. Resend deduplicates supplied keys for 24 hours. */\n readonly idempotencyKey?: EmailIdempotencyKey\n /** Resend generates plain text from html when omitted. An empty string disables that generation. */\n readonly text?: string\n readonly replyTo?: string\n /** Labels the provider stores with the email and returns on every delivery event. */\n readonly tags?: Readonly<Record<string, string>>\n readonly attachments?: readonly EmailAttachment[]\n}\n\n/** Received email headers, without the body or attachments. */\nexport type ReceivedEmail = { readonly headers: Readonly<Record<string, string>> }\n\n/** One attachment of a received email. `downloadUrl` is a signed link that stops working at `expiresAt`. */\nexport type ReceivedAttachment = {\n readonly filename: string | null\n readonly contentType: string\n readonly size: number\n readonly downloadUrl: string\n readonly expiresAt: string\n}\n\n/** A received email's sender, plain text body, and attachments, for an application that reads mail it receives. */\nexport type ReceivedContent = {\n /** The sender as the email states it, for example \"Display Name <address@domain.com>\". */\n readonly from: string\n readonly text: string | null\n readonly attachments: readonly ReceivedAttachment[]\n}\n\n/** The provider accepted the email and assigned its id. */\nexport type EmailAccepted = { readonly providerId: string }\n\n/**\n * The adapter supplies the default sender and maps provider errors. Each email can override the sender.\n * A provider rejection throws `EmailServiceError`; unexpected SDK rejections propagate unchanged.\n */\nexport interface IEmailService {\n /** Resolve after provider acceptance; this does not confirm delivery to the recipient. */\n sendEmail(email: OutboundEmail): Promise<EmailAccepted>\n}\n\n/** Records every send for a test. Provider ids count up as `recorded-1`, `recorded-2`. */\nexport class RecordingEmailService implements IEmailService {\n /** Sends in call order, including repeated idempotency keys. */\n readonly sent: OutboundEmail[] = []\n\n /** Record the send before returning its provider id. */\n async sendEmail(email: OutboundEmail): Promise<EmailAccepted> {\n this.sent.push(email)\n return { providerId: `recorded-${this.sent.length}` }\n }\n}\n","import type { BounceType, DomainCommand, EmailAddress, RecordEmailEventPayload } from '@/core'\n\nimport type { IUnitOfWork } from './unit-of-work.ts'\n\n/** What a bounce records for one address. */\nexport type EmailBounceRecord = {\n readonly type: BounceType\n readonly subType: string | null\n}\n\n/**\n * The application's deliverability state per address. An implementation keeps the higher bounce\n * severity with `shouldUpdateBounce`, and treats an unknown address as nothing to record.\n */\nexport interface IEmailDeliverabilityStore {\n /** Keep the higher severity atomically. Equal severity permits replacement; the store owns timestamp ordering. */\n recordBounce(address: EmailAddress, bounce: EmailBounceRecord): Promise<void>\n /** Record a complaint without clearing existing suppression state. */\n recordComplaint(address: EmailAddress): Promise<void>\n}\n\n/** The repositories the handler needs from the unit of work. */\nexport type RecordEmailEventRepos = { readonly emailDeliverability: IEmailDeliverabilityStore }\n\n/** The container slice the handler reads. */\nexport type RecordEmailEventDeps = { readonly uow: IUnitOfWork<RecordEmailEventRepos> }\n\n/** The command, under whatever name the application registered the payload. */\nexport type RecordEmailEventCommand = DomainCommand & RecordEmailEventPayload\n\n/**\n * Record a bounce or a complaint for every recipient inside the command's unit of work.\n * The command id is the provider's event id, so a redelivered webhook is `MessageAlreadyProcessedError`.\n */\nexport async function recordEmailEvent(\n command: RecordEmailEventCommand,\n deps: RecordEmailEventDeps,\n): Promise<void> {\n await deps.uow.run(command.id, async ({ emailDeliverability }) => {\n for (const address of command.recipients) {\n if (command.event.type === 'bounced') {\n // oxlint-disable-next-line no-await-in-loop -- Finish each transaction write before starting another; a failure must leave no pending writes.\n await emailDeliverability.recordBounce(address, {\n type: command.event.bounceType,\n subType: command.event.bounceSubType,\n })\n } else {\n // oxlint-disable-next-line no-await-in-loop -- A rejected write must stop the transaction before another write starts.\n await emailDeliverability.recordComplaint(address)\n }\n }\n })\n}\n","import { AppError, DatabaseError, type MessageId } from '@/core'\n\n/** The message's effects already committed. A caller can skip duplicate delivery without repeating those effects. */\nexport class MessageAlreadyProcessedError extends AppError {\n readonly _tag = 'MessageAlreadyProcessedError'\n readonly classification = 'terminal'\n\n constructor(\n readonly messageId: MessageId,\n options?: { readonly cause: unknown },\n ) {\n super(`message ${messageId} already processed`, options)\n }\n\n /** Recognize only the processed-message primary key; preserve other failures unchanged at the call site. */\n static from(cause: unknown, messageId: MessageId): MessageAlreadyProcessedError | undefined {\n if (cause instanceof MessageAlreadyProcessedError) return cause\n if (!(cause instanceof DatabaseError)) return undefined\n const details = cause.details\n const duplicate =\n details.database === 'd1'\n ? details.kind === 'unique' &&\n details.table === 'processed_messages' &&\n details.column === 'message_id'\n : details.code === '23505' &&\n details.table_name === 'processed_messages' &&\n details.constraint_name === 'processed_messages_pkey'\n if (!duplicate) return undefined\n return new MessageAlreadyProcessedError(messageId, { cause })\n }\n}\n","import { panic } from 'better-result'\n\nimport {\n createLogger,\n unreachable,\n type DomainCommand,\n type DomainEvent,\n type DomainMessage,\n type DomainQuery,\n} from '@/core'\n\nimport { MessageAlreadyProcessedError } from './message-already-processed.error.ts'\nimport type { Handlers, MessageResult, RegistryMessage } from './registry.ts'\n\nconst logger = createLogger('message-bus')\n\n/** The port an entrypoint dispatches through. `AppDeps` names this as `IMessageBus<typeof registry>`. */\nexport interface IMessageBus<TRegistry extends Handlers<never>> {\n handle<TMessage extends DomainMessage & RegistryMessage<TRegistry>>(\n message: TMessage,\n ): Promise<MessageResult<TMessage, TRegistry>>\n}\n\n/**\n * Routes one message to its slot. The bus opens no transaction and keeps no outbox:\n * a handler that writes opens the unit of work itself.\n */\nexport class MessageBus<Deps, TRegistry extends Handlers<Deps>> implements IMessageBus<TRegistry> {\n constructor(\n private readonly deps: Deps,\n private readonly registry: TRegistry,\n ) {}\n\n /** Resolves to the handler's own value for a command or query, and to void for an event. */\n async handle<TMessage extends DomainMessage & RegistryMessage<TRegistry>>(\n message: TMessage,\n ): Promise<MessageResult<TMessage, TRegistry>> {\n // SAFETY: the slot for this name is what `MessageResult` names, and dispatch returns its value.\n return (await this.dispatch(message)) as MessageResult<TMessage, TRegistry>\n }\n\n // oxlint-disable-next-line anti-slop/no-unknown-returns -- one table holds every slot's value; `handle` names it.\n private dispatch(message: DomainMessage): Promise<unknown> {\n if (message.type === 'command') return this.handleCommand(message)\n if (message.type === 'query') return this.handleQuery(message)\n if (message.type === 'event') return this.handleEvent(message)\n // A message parsed at a boundary cannot reach here; one that does must not resolve silently.\n return unreachable(message)\n }\n\n // oxlint-disable-next-line anti-slop/no-unknown-returns -- see dispatch.\n private handleCommand(command: DomainCommand): Promise<unknown> {\n // `satisfies` proved the registry complete, so a missing slot is a broken registry object.\n const handler = this.registry.commands[command.name]\n if (handler === undefined) return panic(`No handler for command ${command.name}`)\n logger.debug('handling_command', { name: command.name, id: command.id })\n return handler(command, this.deps)\n }\n\n // oxlint-disable-next-line anti-slop/no-unknown-returns -- see dispatch.\n private handleQuery(query: DomainQuery): Promise<unknown> {\n const handler = this.registry.queries[query.name]\n if (handler === undefined) return panic(`No handler for query ${query.name}`)\n return handler(query, this.deps)\n }\n\n /**\n * Subscribers run one after another, so one unit of work finishes before the next starts.\n * Every subscriber still runs. One failure is rethrown as is. Several are thrown as one `AggregateError`.\n * A `MessageAlreadyProcessedError` means that subscriber already committed on an earlier delivery, so it counts as delivered.\n */\n private async handleEvent(event: DomainEvent): Promise<void> {\n const subscriptions = this.registry.events[event.name] ?? []\n const failures: unknown[] = []\n for (const [subscriber, subscription] of subscriptions.entries()) {\n try {\n await subscription(event, this.deps)\n } catch (reason) {\n if (reason instanceof MessageAlreadyProcessedError) {\n // The bus swallows this error, so this line is the only record that the skip happened.\n logger.info('duplicate_subscriber_ignored', {\n event: event.name,\n id: event.id,\n subscriber,\n })\n continue\n }\n failures.push(reason)\n }\n }\n if (failures.length === 1) throw failures[0]\n if (failures.length > 1) {\n throw new AggregateError(failures, `${event.name}: ${failures.length} subscribers failed`)\n }\n }\n}\n","import { classifyFailure, createLogger, type DomainEvent } from '@/core'\n\nimport type {\n DeadLetterReason,\n IOutboxRepository,\n OutboxClaim,\n OutboxMessage,\n} from './outbox-repository.ts'\n\n/**\n * Delivers committed outbox rows. The unit of work only wakes it after a commit that wrote\n * events; the app decides what a wake is: `waitUntil`, a Durable Object alarm, nothing.\n * The sweep is the source of truth, so a lost wake loses no events.\n */\nexport interface IOutboxRelay {\n wake(): void\n}\n\n/** The publisher sends valid events and returns oversized events. QueueClient satisfies this port directly. */\nexport interface IOutboxPublisher {\n /** Resolves after queue acceptance; a rejected batch may already have sent some events. */\n sendBatchPartial(messages: ReadonlyArray<DomainEvent>): Promise<ReadonlyArray<DomainEvent>>\n}\n\n/** Optional limits for one relay; durable attempts exclude the publisher's immediate retries. */\nexport type OutboxRelayOptions = {\n readonly batchSize?: number\n readonly maxBatches?: number\n readonly maxAttempts?: number\n}\n\nconst logger = createLogger('outbox-relay')\n\n/**\n * Publishes committed events with bounded durable retries. Ported from Typist's relay with per-row exhaustion.\n * Send failures are recorded; repository failures propagate to the wake or scheduled boundary.\n */\nexport class OutboxRelay {\n private readonly options: Required<OutboxRelayOptions>\n\n constructor(\n private readonly publisher: IOutboxPublisher,\n private readonly repository: IOutboxRepository,\n options: OutboxRelayOptions = {},\n ) {\n this.options = {\n batchSize: options.batchSize ?? 50,\n maxBatches: options.maxBatches ?? 10,\n maxAttempts: options.maxAttempts ?? 10,\n }\n }\n\n /** Return the claimed count, including released and dead-lettered rows. Zero means no due rows. */\n async flush(): Promise<number> {\n const claim = await this.repository.claimPending(this.options.batchSize)\n const exhausted = claim.messages.filter((row) => row.attempts > this.options.maxAttempts)\n await this.deadLetter(claim, exhausted, 'exhausted', 'Claim attempt limit exceeded')\n const pending = claim.messages.filter((row) => row.attempts <= this.options.maxAttempts)\n if (pending.length === 0) return claim.messages.length\n\n let oversized: ReadonlyArray<DomainEvent>\n try {\n oversized = await this.publisher.sendBatchPartial(pending.map((row) => row.payload))\n } catch (error) {\n await this.handleSendFailure(claim, pending, error)\n return claim.messages.length\n }\n\n const oversizedIds = new Set(oversized.map((event) => event.id))\n await this.deadLetter(\n claim,\n pending.filter((row) => oversizedIds.has(row.payload.id)),\n 'oversized',\n 'Exceeds queue message size limit',\n )\n const sent = pending.filter((row) => !oversizedIds.has(row.payload.id))\n if (sent.length > 0) await this.repository.markPublished(claim, sent)\n return claim.messages.length\n }\n\n /** Drain until an empty claim or the batch limit; return the total claimed count. */\n async drain(): Promise<number> {\n let total = 0\n for (let batch = 0; batch < this.options.maxBatches; batch += 1) {\n // oxlint-disable-next-line no-await-in-loop -- An empty claim must stop the drain before another claim starts.\n const claimed = await this.flush()\n total += claimed\n if (claimed === 0) break\n }\n return total\n }\n\n private async handleSendFailure(\n claim: OutboxClaim,\n pending: ReadonlyArray<OutboxMessage>,\n cause: unknown,\n ): Promise<void> {\n const classification = classifyFailure(cause)\n const message =\n cause instanceof Error ? cause.message : 'Publisher rejected with a non-error value'\n if (classification === 'terminal') {\n await this.deadLetter(claim, pending, 'terminal', message, cause)\n return\n }\n const exhausted = pending.filter((row) => row.attempts >= this.options.maxAttempts)\n await this.deadLetter(claim, exhausted, 'exhausted', message, cause)\n const retry = pending.filter((row) => row.attempts < this.options.maxAttempts)\n if (retry.length > 0) await this.repository.releaseClaim(claim, retry)\n }\n\n private async deadLetter(\n claim: OutboxClaim,\n messages: ReadonlyArray<OutboxMessage>,\n reason: DeadLetterReason,\n errorMessage: string,\n cause?: unknown,\n ): Promise<void> {\n if (messages.length === 0) return\n await this.repository.deadLetter(claim, messages, reason, errorMessage)\n logger.error('outbox_messages_dead_lettered', {\n error: cause,\n claimToken: claim.token,\n count: messages.length,\n reason,\n })\n }\n}\n","import type { IOutboxRetentionRepository } from './outbox-repository.ts'\n\n/** Typist's retention defaults; receipt retention must cover the application's supported replay period. */\nexport type OutboxRetentionOptions = {\n readonly publishedRetentionMs?: number\n readonly failedRetentionMs?: number\n readonly receiptRetentionMs?: number\n readonly batchSize?: number\n readonly maxBatches?: number\n}\n\n/** Deleted records per category during one bounded sweep. */\nexport type OutboxRetentionResult = {\n readonly published: number\n readonly failed: number\n readonly receipts: number\n}\n\n/** Bounded cleanup ported from Typist's message retention handler. The application schedules each sweep. */\nexport class OutboxRetention {\n private readonly options: Required<OutboxRetentionOptions>\n\n constructor(\n private readonly repository: IOutboxRetentionRepository,\n options: OutboxRetentionOptions = {},\n ) {\n this.options = {\n publishedRetentionMs: options.publishedRetentionMs ?? 86_400_000,\n failedRetentionMs: options.failedRetentionMs ?? 30 * 86_400_000,\n receiptRetentionMs: options.receiptRetentionMs ?? 7 * 86_400_000,\n batchSize: options.batchSize ?? 1_000,\n maxBatches: options.maxBatches ?? 10,\n }\n }\n\n /** Calculate all cutoffs from one supplied time; propagate repository failures to the calling boundary. */\n async sweep(at: Date): Promise<OutboxRetentionResult> {\n const { publishedRetentionMs, failedRetentionMs, receiptRetentionMs } = this.options\n const published = await this.deleteBatches((size) =>\n this.repository.deletePublishedBefore(new Date(at.getTime() - publishedRetentionMs), size),\n )\n const failed = await this.deleteBatches((size) =>\n this.repository.deleteFailedBefore(new Date(at.getTime() - failedRetentionMs), size),\n )\n const receipts = await this.deleteBatches((size) =>\n this.repository.deleteReceiptsBefore(new Date(at.getTime() - receiptRetentionMs), size),\n )\n return { published, failed, receipts }\n }\n\n private async deleteBatches(deleteBatch: (size: number) => Promise<number>): Promise<number> {\n let total = 0\n for (let batch = 0; batch < this.options.maxBatches; batch += 1) {\n // oxlint-disable-next-line no-await-in-loop -- The delete count decides whether another batch is needed.\n const deleted = await deleteBatch(this.options.batchSize)\n total += deleted\n if (deleted < this.options.batchSize) break\n }\n return total\n }\n}\n","import type { MessageId } from '@/core'\n\nimport type { IEventCollector } from './event-collector.ts'\nimport { MessageAlreadyProcessedError } from './message-already-processed.error.ts'\nimport type { IMessageStore } from './message-store.ts'\nimport type { IOutboxRelay } from './outbox-relay.ts'\nimport type { ITransaction } from './transaction.ts'\n\n/**\n * Commits the processed-message record, repository writes, and emitted events together before resolving.\n * An existing record rejects with `MessageAlreadyProcessedError`; external effects must run through the outbox after commit.\n * Nested calls reject with `UnitOfWorkAlreadyActiveError`.\n */\nexport interface IUnitOfWork<Repos> {\n run<T>(messageId: MessageId, work: (repos: Repos) => Promise<T>): Promise<T>\n}\n\nexport type UnitOfWorkDeps<Tx, Repos> = {\n readonly transaction: ITransaction<Tx>\n /** The processed-messages and outbox repository for this transaction. */\n readonly messageStore: (tx: Tx) => IMessageStore\n /** Repositories participate in the current transaction. */\n readonly createRepositories: (tx: Tx) => Repos\n readonly eventCollector: IEventCollector\n readonly relay: IOutboxRelay\n}\n\n/** The unit of work: the boundary, the repositories, the events. Every database call is a port. */\nexport class UnitOfWork<Tx, Repos> implements IUnitOfWork<Repos> {\n constructor(private readonly deps: UnitOfWorkDeps<Tx, Repos>) {}\n\n async run<T>(messageId: MessageId, work: (repos: Repos) => Promise<T>): Promise<T> {\n const { transaction, messageStore, createRepositories, eventCollector, relay } = this.deps\n let written = 0\n\n let value: T\n try {\n value = await transaction.transaction(async (tx) => {\n const store = messageStore(tx)\n await store.claim(messageId)\n const repos = createRepositories(tx)\n const result = await work(repos)\n const pending = eventCollector.collect()\n await store.persistEvents(pending)\n written = pending.length\n return result\n })\n } catch (error) {\n throw MessageAlreadyProcessedError.from(error, messageId) ?? error\n }\n\n if (written > 0) relay.wake()\n return value\n }\n}\n","import { AppError } from '@/core'\n\n/** A boundary was opened inside another. One message, one atomic scope. */\nexport class UnitOfWorkAlreadyActiveError extends AppError {\n readonly _tag = 'UnitOfWorkAlreadyActiveError'\n readonly classification = 'terminal'\n\n constructor() {\n super('a unit of work is already active')\n }\n}\n"],"mappings":";;;;;;;;AAkCA,MAAa,iBAAiB;CAC5B,gBAAgB,CAAC;CACjB,aAAa,CAAC;CACd,QACE,OACA,aACA,YACG,CAAC;CACN,iBACE,OACA,aACA,YACG,CAAC;AACR;;;;;ACxBA,MAAa,uBAAuC;CAClD,aAAa,CAAC;CACd,aAAa,C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;AACF"}
@@ -1,3 +1,3 @@
1
- import { G as DomainMessage, K as DomainQuery, U as DomainCommand, W as DomainEvent, q as MessageId } from "./index-DUFS0SJ_.js";
2
- import { $ as MetricsService, A as IOutboxRepository, B as OutboundEmail, C as UnitOfWorkDeps, D as OutboxRelay, E as IOutboxRelay, F as IEventCollector, G as applyObservabilityUser, H as ReceivedContent, I as EmailAccepted, J as ObservabilityService, K as setObservabilityUserHook, L as EmailAttachment, M as OutboxClaim, N as OutboxMessage, O as OutboxRelayOptions, P as IMessageStore, Q as MetricOptions, R as IEmailService, S as UnitOfWork, T as IOutboxPublisher, U as ReceivedEmail, V as ReceivedAttachment, W as RecordingEmailService, X as MetricAttributeValue, Y as ObservabilityUser, Z as MetricAttributes, _ as RecordEmailEventCommand, a as OutboxRetentionResult, at as QueryHandler, b as recordEmailEvent, c as CommandRegistry, d as MessageRegistry, et as NULL_METRICS_SERVICE, f as MessageResult, g as IEmailDeliverabilityStore, h as EmailBounceRecord, i as OutboxRetentionOptions, it as EventHandler, j as IOutboxRetentionRepository, k as DeadLetterReason, l as EventRegistry, m as RegistryMessage, n as MessageAlreadyProcessedError, nt as NULL_ANALYTICS, o as IMessageBus, p as QueryRegistry, q as ObservabilityScope, r as OutboxRetention, rt as CommandHandler, s as MessageBus, t as UnitOfWorkAlreadyActiveError, tt as AnalyticsService, u as Handlers, v as RecordEmailEventDeps, w as ITransaction, x as IUnitOfWork, y as RecordEmailEventRepos, z as MimeType } from "./index-BosM_da2.js";
3
- export { type AnalyticsService, type CommandHandler, type CommandRegistry, type DeadLetterReason, type DomainCommand, type DomainEvent, type DomainMessage, type DomainQuery, type EmailAccepted, type EmailAttachment, type EmailBounceRecord, type EventHandler, type EventRegistry, type Handlers, type IEmailDeliverabilityStore, type IEmailService, type IEventCollector, type IMessageBus, type IMessageStore, type IOutboxPublisher, type IOutboxRelay, type IOutboxRepository, type IOutboxRetentionRepository, type ITransaction, type IUnitOfWork, MessageAlreadyProcessedError, MessageBus, type MessageId, type MessageRegistry, type MessageResult, type MetricAttributeValue, type MetricAttributes, type MetricOptions, type MetricsService, type MimeType, NULL_ANALYTICS, NULL_METRICS_SERVICE, type ObservabilityScope, type ObservabilityService, type ObservabilityUser, type OutboundEmail, type OutboxClaim, type OutboxMessage, OutboxRelay, type OutboxRelayOptions, OutboxRetention, type OutboxRetentionOptions, type OutboxRetentionResult, type QueryHandler, type QueryRegistry, type ReceivedAttachment, type ReceivedContent, type ReceivedEmail, type RecordEmailEventCommand, type RecordEmailEventDeps, type RecordEmailEventRepos, RecordingEmailService, type RegistryMessage, UnitOfWork, UnitOfWorkAlreadyActiveError, type UnitOfWorkDeps, applyObservabilityUser, recordEmailEvent, setObservabilityUserHook };
1
+ import { G as DomainMessage, K as DomainQuery, U as DomainCommand, W as DomainEvent, q as MessageId } from "./index-CtIdbnEZ.js";
2
+ import { $ as MetricsService, A as IOutboxRepository, B as OutboundEmail, C as UnitOfWorkDeps, D as OutboxRelay, E as IOutboxRelay, F as IEventCollector, G as applyObservabilityUser, H as ReceivedContent, I as EmailAccepted, J as ObservabilityService, K as setObservabilityUserHook, L as EmailAttachment, M as OutboxClaim, N as OutboxMessage, O as OutboxRelayOptions, P as IMessageStore, Q as MetricOptions, R as IEmailService, S as UnitOfWork, T as IOutboxPublisher, U as ReceivedEmail, V as ReceivedAttachment, W as RecordingEmailService, X as MetricAttributeValue, Y as ObservabilityUser, Z as MetricAttributes, _ as RecordEmailEventCommand, a as OutboxRetentionResult, at as EventHandler, b as recordEmailEvent, c as CommandRegistry, d as MessageRegistry, et as NULL_METRICS_SERVICE, f as MessageResult, g as IEmailDeliverabilityStore, h as EmailBounceRecord, i as OutboxRetentionOptions, it as CommandHandler, j as IOutboxRetentionRepository, k as DeadLetterReason, l as EventRegistry, m as RegistryMessage, n as MessageAlreadyProcessedError, nt as AnalyticsService, o as IMessageBus, ot as QueryHandler, p as QueryRegistry, q as ObservabilityScope, r as OutboxRetention, rt as NULL_ANALYTICS, s as MessageBus, t as UnitOfWorkAlreadyActiveError, tt as AnalyticsPropertiesOf, u as Handlers, v as RecordEmailEventDeps, w as ITransaction, x as IUnitOfWork, y as RecordEmailEventRepos, z as MimeType } from "./index-BMY7ylgk.js";
3
+ export { type AnalyticsPropertiesOf, type AnalyticsService, type CommandHandler, type CommandRegistry, type DeadLetterReason, type DomainCommand, type DomainEvent, type DomainMessage, type DomainQuery, type EmailAccepted, type EmailAttachment, type EmailBounceRecord, type EventHandler, type EventRegistry, type Handlers, type IEmailDeliverabilityStore, type IEmailService, type IEventCollector, type IMessageBus, type IMessageStore, type IOutboxPublisher, type IOutboxRelay, type IOutboxRepository, type IOutboxRetentionRepository, type ITransaction, type IUnitOfWork, MessageAlreadyProcessedError, MessageBus, type MessageId, type MessageRegistry, type MessageResult, type MetricAttributeValue, type MetricAttributes, type MetricOptions, type MetricsService, type MimeType, NULL_ANALYTICS, NULL_METRICS_SERVICE, type ObservabilityScope, type ObservabilityService, type ObservabilityUser, type OutboundEmail, type OutboxClaim, type OutboxMessage, OutboxRelay, type OutboxRelayOptions, OutboxRetention, type OutboxRetentionOptions, type OutboxRetentionResult, type QueryHandler, type QueryRegistry, type ReceivedAttachment, type ReceivedContent, type ReceivedEmail, type RecordEmailEventCommand, type RecordEmailEventDeps, type RecordEmailEventRepos, RecordingEmailService, type RegistryMessage, UnitOfWork, UnitOfWorkAlreadyActiveError, type UnitOfWorkDeps, applyObservabilityUser, recordEmailEvent, setObservabilityUserHook };
@@ -1,4 +1,4 @@
1
- import { a as MessageBus, c as RecordingEmailService, i as OutboxRelay, l as NULL_METRICS_SERVICE, n as UnitOfWork, o as MessageAlreadyProcessedError, r as OutboxRetention, s as recordEmailEvent, t as UnitOfWorkAlreadyActiveError, u as NULL_ANALYTICS } from "./application-B5hnNUdI.js";
1
+ import { a as MessageBus, c as RecordingEmailService, i as OutboxRelay, l as NULL_METRICS_SERVICE, n as UnitOfWork, o as MessageAlreadyProcessedError, r as OutboxRetention, s as recordEmailEvent, t as UnitOfWorkAlreadyActiveError, u as NULL_ANALYTICS } from "./application-Dsz-o9Aj.js";
2
2
  import { n as setObservabilityUserHook, t as applyObservabilityUser } from "./request-user-B4rh1c2-.js";
3
3
 
4
4
  export { MessageAlreadyProcessedError, MessageBus, NULL_ANALYTICS, NULL_METRICS_SERVICE, OutboxRelay, OutboxRetention, RecordingEmailService, UnitOfWork, UnitOfWorkAlreadyActiveError, applyObservabilityUser, recordEmailEvent, setObservabilityUserHook };
@@ -1,4 +1,4 @@
1
- import { Xt as AppError } from "./index-DUFS0SJ_.js";
1
+ import { Jt as AppError } from "./index-CtIdbnEZ.js";
2
2
  import { DurableObject } from "cloudflare:workers";
3
3
  //#region src/infrastructure/cloudflare/auth-secondary-storage.d.ts
4
4
  /** The supplied TTL cannot produce a valid expiry timestamp. Retrying the same input cannot fix it. */
@@ -34,4 +34,4 @@ declare class AuthSecondaryStorage extends DurableObject {
34
34
  }
35
35
  //#endregion
36
36
  export { InvalidCounterError as n, InvalidTtlError as r, AuthSecondaryStorage as t };
37
- //# sourceMappingURL=auth-secondary-storage-b9ptwPSB.d.ts.map
37
+ //# sourceMappingURL=auth-secondary-storage-CcNkkEk0.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-secondary-storage-b9ptwPSB.d.ts","names":[],"sources":["../src/infrastructure/cloudflare/auth-secondary-storage.ts"],"mappings":";;;;cAWa,wBAAwB;WAC1B;WACA;EAET;;;cAMW,4BAA4B;WAC9B;WACA;EAET;;;;;;;cAUW,6BAA6B;;EAElC,OAAO;;EAMP,IAAI,eAAe,eAAe;;EAUlC,UAAU;;EAKV,gBAAgB;;EAQhB,UAAU,cAAc;;EAef,SAAS"}
1
+ {"version":3,"file":"auth-secondary-storage-CcNkkEk0.d.ts","names":[],"sources":["../src/infrastructure/cloudflare/auth-secondary-storage.ts"],"mappings":";;;;cAWa,wBAAwB;WAC1B;WACA;EAET;;;cAMW,4BAA4B;WAC9B;WACA;EAET;;;;;;;cAUW,6BAA6B;;EAElC,OAAO;;EAMP,IAAI,eAAe,eAAe;;EAUlC,UAAU;;EAKV,gBAAgB;;EAQhB,UAAU,cAAc;;EAef,SAAS"}
@@ -1,4 +1,4 @@
1
- import { Xt as AppError } from "../index-DUFS0SJ_.js";
1
+ import { Jt as AppError } from "../index-CtIdbnEZ.js";
2
2
  //#region src/infrastructure/better-auth/apple-client-secret.d.ts
3
3
  /**
4
4
  * Apple's issuer and OAuth callback origin, and the `aud` claim of the client secret. Include it in
@@ -1,4 +1,4 @@
1
- import { nt as AppError, r as createLogger } from "../core-BiN6S_cm.js";
1
+ import { r as createLogger, tt as AppError } from "../core-DOBZeYSX.js";
2
2
  import { Buffer } from "node:buffer";
3
3
  import { createPrivateKey, sign } from "node:crypto";
4
4
 
@@ -13,4 +13,5 @@ export declare const authClient: import("better-auth/client").AuthClient<{
13
13
  };
14
14
  }>;
15
15
  //#endregion
16
+ export {};
16
17
  //# sourceMappingURL=auth-client.d.ts.map
@@ -1,4 +1,4 @@
1
- import { U as RateLimitError } from "../core-BiN6S_cm.js";
1
+ import { U as RateLimitError } from "../core-DOBZeYSX.js";
2
2
  import { createAuthClient } from "better-auth/client";
3
3
 
4
4
  //#region src/infrastructure/better-auth/auth-client.ts
@@ -1,4 +1,4 @@
1
- import { Xt as AppError } from "../index-DUFS0SJ_.js";
1
+ import { Jt as AppError } from "../index-CtIdbnEZ.js";
2
2
  import { BetterAuthOptions, BetterAuthRateLimitStorage } from "better-auth";
3
3
  //#region src/infrastructure/better-auth/rate-limit.d.ts
4
4
  /** A rule Better Auth passes to storage: a window in seconds and the requests it allows. */
@@ -1,4 +1,4 @@
1
- import { nt as AppError, r as createLogger } from "../core-BiN6S_cm.js";
1
+ import { r as createLogger, tt as AppError } from "../core-DOBZeYSX.js";
2
2
 
3
3
  //#region src/infrastructure/better-auth/rate-limit.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { t as AuthSecondaryStorage } from "../auth-secondary-storage-b9ptwPSB.js";
1
+ import { t as AuthSecondaryStorage } from "../auth-secondary-storage-CcNkkEk0.js";
2
2
  import { BetterAuthOptions } from "better-auth";
3
3
  //#region src/infrastructure/better-auth/secondary-storage.d.ts
4
4
  type SecondaryStorage = NonNullable<BetterAuthOptions['secondaryStorage']>;
@@ -8,4 +8,5 @@ type SecondaryStorage = NonNullable<BetterAuthOptions['secondaryStorage']>;
8
8
  */
9
9
  export declare function createAuthSecondaryStorage(binding: Pick<DurableObjectNamespace<AuthSecondaryStorage>, 'getByName'>): SecondaryStorage;
10
10
  //#endregion
11
+ export {};
11
12
  //# sourceMappingURL=secondary-storage.d.ts.map
@@ -99,4 +99,5 @@ export type BetterAuthOptionsFactory = <const Config extends AuthConfig, const P
99
99
  */
100
100
  export declare const createBetterAuthOptions: BetterAuthOptionsFactory;
101
101
  //#endregion
102
+ export {};
102
103
  //# sourceMappingURL=better-auth.d.ts.map
@@ -1,4 +1,4 @@
1
- import { r as createLogger } from "./core-BiN6S_cm.js";
1
+ import { r as createLogger } from "./core-DOBZeYSX.js";
2
2
  import { v7 } from "uuid";
3
3
  import { isAPIError } from "better-auth/api";
4
4
  import { anonymous, bearer, captcha, deviceAuthorization, emailOTP, lastLoginMethod, magicLink, openAPI } from "better-auth/plugins";
@@ -1,4 +1,4 @@
1
- import { Xt as AppError, Zt as FailureClassification } from "../index-DUFS0SJ_.js";
1
+ import { Jt as AppError, Yt as FailureClassification } from "../index-CtIdbnEZ.js";
2
2
  import { createAuthClient } from "better-auth/client";
3
3
  import { stripeClient } from "@better-auth/stripe/client";
4
4
  //#region src/infrastructure/billing/client.d.ts
@@ -83,4 +83,5 @@ export declare class BillingService<const Options extends BillingOptions> implem
83
83
  constructor(options: Options);
84
84
  }
85
85
  //#endregion
86
+ export {};
86
87
  //# sourceMappingURL=client.d.ts.map
@@ -1,4 +1,4 @@
1
- import { nt as AppError } from "../core-BiN6S_cm.js";
1
+ import { tt as AppError } from "../core-DOBZeYSX.js";
2
2
 
3
3
  //#region src/infrastructure/billing/client.ts
4
4
  /** A Better Auth billing endpoint rejected the request. The browser boundary owns reporting. */
@@ -1,4 +1,4 @@
1
- import { Xt as AppError } from "../index-DUFS0SJ_.js";
1
+ import { Jt as AppError } from "../index-CtIdbnEZ.js";
2
2
  //#region src/infrastructure/browser-support/browser-floor.error.d.ts
3
3
  /** The browserslist file is missing, empty, or not a query browserslist can resolve. */
4
4
  export declare class BrowserFloorError extends AppError {
@@ -1,3 +1,3 @@
1
- import { i as BrowserFloorError, n as buildTargets, r as updateScreenCopy, t as browserFloor } from "../floor-Cuw8EIhg.js";
1
+ import { i as BrowserFloorError, n as buildTargets, r as updateScreenCopy, t as browserFloor } from "../floor-BTBtPI9_.js";
2
2
 
3
3
  export { BrowserFloorError, browserFloor, buildTargets, updateScreenCopy };
@@ -1,4 +1,4 @@
1
- import { i as BrowserFloorError, t as browserFloor } from "../floor-Cuw8EIhg.js";
1
+ import { i as BrowserFloorError, t as browserFloor } from "../floor-BTBtPI9_.js";
2
2
  import { t as POLYFILLED_APIS } from "../polyfills-DEQFkqRI.js";
3
3
  import { defineRule, eslintCompatPlugin } from "@oxlint/plugins";
4
4
  import bcd from "@mdn/browser-compat-data/forLegacyNode";
@@ -1,2 +1,2 @@
1
- import { n as InvalidCounterError, r as InvalidTtlError, t as AuthSecondaryStorage } from "../auth-secondary-storage-b9ptwPSB.js";
1
+ import { n as InvalidCounterError, r as InvalidTtlError, t as AuthSecondaryStorage } from "../auth-secondary-storage-CcNkkEk0.js";
2
2
  export { AuthSecondaryStorage, InvalidCounterError, InvalidTtlError };
@@ -1,4 +1,4 @@
1
- import { nt as AppError } from "../core-BiN6S_cm.js";
1
+ import { tt as AppError } from "../core-DOBZeYSX.js";
2
2
  import { DurableObject } from "cloudflare:workers";
3
3
 
4
4
  //#region src/infrastructure/cloudflare/auth-secondary-storage.ts
@@ -15,4 +15,5 @@ export declare abstract class DurableObjectClient<T extends Rpc.DurableObjectBra
15
15
  private run;
16
16
  }
17
17
  //#endregion
18
+ export {};
18
19
  //# sourceMappingURL=durable-object-client.d.ts.map
@@ -1,5 +1,5 @@
1
- import { b as shouldRetryFailure, v as isAbortError } from "../core-BiN6S_cm.js";
2
- import { i as isClassifiedDurableObjectError, n as DurableObjectCallError, r as classifyDurableObjectError } from "../durable-object-errors-DkMFXQnK.js";
1
+ import { b as shouldRetryFailure, v as isAbortError } from "../core-DOBZeYSX.js";
2
+ import { i as isClassifiedDurableObjectError, n as DurableObjectCallError, r as classifyDurableObjectError } from "../durable-object-errors-CcfTu0PQ.js";
3
3
  import { Result } from "better-result";
4
4
 
5
5
  //#region src/infrastructure/cloudflare/durable-object-client.ts
@@ -1,4 +1,4 @@
1
- import { Xt as AppError, Zt as FailureClassification } from "../index-DUFS0SJ_.js";
1
+ import { Jt as AppError, Yt as FailureClassification } from "../index-CtIdbnEZ.js";
2
2
  import { z } from "zod";
3
3
  //#region src/infrastructure/cloudflare/durable-object-errors.d.ts
4
4
  /** Stable tag for a failed Durable Object call. */
@@ -37,4 +37,5 @@ export declare class DurableObjectCallError extends AppError {
37
37
  });
38
38
  }
39
39
  //#endregion
40
+ export {};
40
41
  //# sourceMappingURL=durable-object-errors.d.ts.map
@@ -1,3 +1,3 @@
1
- import { a as isDurableObjectCallError, i as isClassifiedDurableObjectError, n as DurableObjectCallError, r as classifyDurableObjectError, t as DURABLE_OBJECT_CALL_ERROR } from "../durable-object-errors-DkMFXQnK.js";
1
+ import { a as isDurableObjectCallError, i as isClassifiedDurableObjectError, n as DurableObjectCallError, r as classifyDurableObjectError, t as DURABLE_OBJECT_CALL_ERROR } from "../durable-object-errors-CcfTu0PQ.js";
2
2
 
3
3
  export { DURABLE_OBJECT_CALL_ERROR, DurableObjectCallError, classifyDurableObjectError, isClassifiedDurableObjectError, isDurableObjectCallError };
@@ -1,5 +1,5 @@
1
- import { l as spreadJitterMs, s as exponentialDelayCapMs } from "../core-BiN6S_cm.js";
2
- import { i as isKVPutRateLimitError, n as decideKVRetry, t as KVError } from "../kv-errors-BUTpFy0t.js";
1
+ import { l as spreadJitterMs, s as exponentialDelayCapMs } from "../core-DOBZeYSX.js";
2
+ import { i as isKVPutRateLimitError, n as decideKVRetry, t as KVError } from "../kv-errors-B2k_2lyY.js";
3
3
  import { Result } from "better-result";
4
4
 
5
5
  //#region src/infrastructure/cloudflare/kv-client.ts
@@ -1,4 +1,4 @@
1
- import { Xt as AppError, Zt as FailureClassification } from "../index-DUFS0SJ_.js";
1
+ import { Jt as AppError, Yt as FailureClassification } from "../index-CtIdbnEZ.js";
2
2
  //#region src/infrastructure/cloudflare/kv-errors.d.ts
3
3
  /** KV operations recognized in binding error messages. */
4
4
  export type KVOperation = 'get' | 'put' | 'delete' | 'list';
@@ -1,3 +1,3 @@
1
- import { a as isRetryableKVError, i as isKVPutRateLimitError, n as decideKVRetry, o as isTerminalKVError, r as extractKVMeta, s as isTransientKVError, t as KVError } from "../kv-errors-BUTpFy0t.js";
1
+ import { a as isRetryableKVError, i as isKVPutRateLimitError, n as decideKVRetry, o as isTerminalKVError, r as extractKVMeta, s as isTransientKVError, t as KVError } from "../kv-errors-B2k_2lyY.js";
2
2
 
3
3
  export { KVError, decideKVRetry, extractKVMeta, isKVPutRateLimitError, isRetryableKVError, isTerminalKVError, isTransientKVError };
@@ -1,5 +1,5 @@
1
- import { U as DomainCommand, W as DomainEvent, Xt as AppError, Zt as FailureClassification } from "../index-DUFS0SJ_.js";
2
- import { D as OutboxRelay, E as IOutboxRelay } from "../index-BosM_da2.js";
1
+ import { Jt as AppError, U as DomainCommand, W as DomainEvent, Yt as FailureClassification } from "../index-CtIdbnEZ.js";
2
+ import { D as OutboxRelay, E as IOutboxRelay } from "../index-BMY7ylgk.js";
3
3
  import { z } from "zod";
4
4
  //#region src/infrastructure/cloudflare/queue/queue-message.d.ts
5
5
  /** A message a queue carries: a command from outside the request, or an event from the outbox. */
@@ -1,5 +1,5 @@
1
- import { b as shouldRetryFailure, c as exponentialEqualJitterMs, d as classifyFailure, f as retryAfterSecondsOf, l as spreadJitterMs, nt as AppError, r as createLogger, u as classifyBoundaryError } from "../core-BiN6S_cm.js";
2
- import { o as MessageAlreadyProcessedError } from "../application-B5hnNUdI.js";
1
+ import { b as shouldRetryFailure, c as exponentialEqualJitterMs, d as classifyFailure, f as retryAfterSecondsOf, l as spreadJitterMs, r as createLogger, tt as AppError, u as classifyBoundaryError } from "../core-DOBZeYSX.js";
2
+ import { o as MessageAlreadyProcessedError } from "../application-Dsz-o9Aj.js";
3
3
  import { Result } from "better-result";
4
4
 
5
5
  //#region src/infrastructure/cloudflare/queue/queue-limits.ts
@@ -1,5 +1,5 @@
1
- import { nt as AppError, v as isAbortError } from "../core-BiN6S_cm.js";
2
- import { n as R2JsonError, t as R2Error } from "../r2-errors-rk7n7rvk.js";
1
+ import { tt as AppError, v as isAbortError } from "../core-DOBZeYSX.js";
2
+ import { n as R2JsonError, t as R2Error } from "../r2-errors-BF49eqU_.js";
3
3
 
4
4
  //#region src/infrastructure/cloudflare/r2-client.ts
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { Xt as AppError, Zt as FailureClassification } from "../index-DUFS0SJ_.js";
1
+ import { Jt as AppError, Yt as FailureClassification } from "../index-CtIdbnEZ.js";
2
2
  //#region src/infrastructure/cloudflare/r2-errors.d.ts
3
3
  /** The storage operation that failed. */
4
4
  export type R2Operation = 'head' | 'get' | 'getJson' | 'put' | 'delete' | 'list' | 'createMultipartUpload' | 'uploadPart' | 'complete' | 'abort';
@@ -1,3 +1,3 @@
1
- import { n as R2JsonError, t as R2Error } from "../r2-errors-rk7n7rvk.js";
1
+ import { n as R2JsonError, t as R2Error } from "../r2-errors-BF49eqU_.js";
2
2
 
3
3
  export { R2Error, R2JsonError };
@@ -1,4 +1,4 @@
1
- import { Xt as AppError } from "../index-DUFS0SJ_.js";
1
+ import { Jt as AppError } from "../index-CtIdbnEZ.js";
2
2
  //#region src/infrastructure/cloudflare/rate-limiter.d.ts
3
3
  /**
4
4
  * Caller limits through a Workers Rate Limiting binding. Ported from the `consume` path of
@@ -1,4 +1,4 @@
1
- import { U as RateLimitError, nt as AppError } from "../core-BiN6S_cm.js";
1
+ import { U as RateLimitError, tt as AppError } from "../core-DOBZeYSX.js";
2
2
 
3
3
  //#region src/infrastructure/cloudflare/rate-limiter.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { q as MessageId } from "../index-DUFS0SJ_.js";
1
+ import { q as MessageId } from "../index-CtIdbnEZ.js";
2
2
  import { z } from "zod";
3
3
  //#region src/infrastructure/cloudflare/scheduled/scheduled-handler.d.ts
4
4
  /** The work one schedule runs. Nothing returns to the platform, so each run reports its own outcome. */
@@ -1,4 +1,4 @@
1
- import { r as createLogger } from "../core-BiN6S_cm.js";
1
+ import { r as createLogger } from "../core-DOBZeYSX.js";
2
2
  import { z } from "zod";
3
3
 
4
4
  //#region src/infrastructure/cloudflare/scheduled/scheduled-handler.ts
@@ -1,4 +1,4 @@
1
- import { Xt as AppError, Zt as FailureClassification } from "../index-DUFS0SJ_.js";
1
+ import { Jt as AppError, Yt as FailureClassification } from "../index-CtIdbnEZ.js";
2
2
  //#region src/infrastructure/cloudflare/turnstile/turnstile.error.d.ts
3
3
  /**
4
4
  * Siteverify did not produce a verdict.
@@ -1,4 +1,4 @@
1
- import { b as shouldRetryFailure, c as exponentialEqualJitterMs, nt as AppError, u as classifyBoundaryError } from "../core-BiN6S_cm.js";
1
+ import { b as shouldRetryFailure, c as exponentialEqualJitterMs, tt as AppError, u as classifyBoundaryError } from "../core-DOBZeYSX.js";
2
2
  import { z } from "zod";
3
3
  import { Result } from "better-result";
4
4
 
@@ -1,6 +1,6 @@
1
- import { W as DomainEvent, et as D1ConstraintKind, nt as DatabaseFailure, q as MessageId, tt as DatabaseError } from "./index-DUFS0SJ_.js";
2
- import { A as IOutboxRepository, M as OutboxClaim, N as OutboxMessage, P as IMessageStore, k as DeadLetterReason, w as ITransaction } from "./index-BosM_da2.js";
3
- import { n as eventCollector, r as DrizzleSchema, t as OutboxRepositoryOptions } from "./outbox-repository-options-A2fA1UDX.js";
1
+ import { W as DomainEvent, et as D1ConstraintKind, nt as DatabaseFailure, q as MessageId, tt as DatabaseError } from "./index-CtIdbnEZ.js";
2
+ import { A as IOutboxRepository, M as OutboxClaim, N as OutboxMessage, P as IMessageStore, k as DeadLetterReason, w as ITransaction } from "./index-BMY7ylgk.js";
3
+ import { n as eventCollector, r as DrizzleSchema, t as OutboxRepositoryOptions } from "./outbox-repository-options-q-CGUoCr.js";
4
4
  import { BatchItem } from "drizzle-orm/batch";
5
5
  import { AnyD1Database, DrizzleD1Database } from "drizzle-orm/d1";
6
6
  //#region src/infrastructure/cloudflare/d1-database-types.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"cloudflare.d.ts","names":[],"sources":["../src/infrastructure/cloudflare/d1-database-types.ts","../src/infrastructure/cloudflare/base-d1-repository.ts","../src/infrastructure/cloudflare/classify-d1-error.ts","../src/infrastructure/cloudflare/d1-message-store.ts","../src/infrastructure/cloudflare/d1-schema.ts","../src/infrastructure/cloudflare/d1-batch-transaction.ts","../src/infrastructure/cloudflare/d1-database-execution.ts","../src/infrastructure/cloudflare/d1-outbox-repository.ts"],"mappings":";;;;;;;KAKY,eAAe;;KAGf,KAAK,eAAe,iBAAiB,kBAAkB;;KAGvD,SAAS,eAAe,iBAAiB,KACnD,KAAK;;KAKK,KAAK,eAAe;WACrB,IAAI,KAAK;;;;;UCRH;EACf,iBAAiB,cAAc;EAC/B;;;;;;8BAOoB,iBAAiB,eAAe;qBACrB,IAAI,KAAK;EAAxC,YAA+B,IAAI,KAAK;;YAG9B,MAAM,WAAW;;YAKjB,KAAK,GAAG,mBAAmB,aAAa,YAAY,KAAK,QAAQ;;YAKjE,eAAe,WAAW;;;;;;;;wBCVtB,gBAAgB,gBAAgB,qBAAyB;;;;qBCb5D,eAAe,eAAe,uBACjC,iBAAiB,mBACd;EAEL,MAAM,WAAW,YAAY;EAc7B,cAAc,QAAQ,cAAc,eAAe;;;;;qBCtB9C,qDAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAAjB;;;;;;;;;;;;;;;;qBAYA,iDAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBCPb,mBAAmB,eAAe,0BAA0B,aACvE,KAAK;mBAEwB;EAA7B,YAA6B,IAAI,KAAK;EAEhC,YAAY,GAAG,OAAO,IAAI,KAAK,YAAY,QAAQ,KAAK,QAAQ;;;;;;;;wBCNlD,gBAAgB,GACpC,mBACA,YAAY,YAAY,IACxB;WAAoB;IACnB,QAAQ;;;;;;;qBCIE,mBAAmB,eAAe,0BAA0B;mBAIpD;mBAEA;mBALF;EAEjB,YACmB,IAAI,KAAK,SAC1B,UAAS,yBACQ,YAAW;;EAMxB,aAAa,oBAAoB,QAAQ;;EAmDzC,cAAc,OAAO,aAAa,UAAU,cAAc,iBAAiB;;EAgB3E,aAAa,OAAO,aAAa,UAAU,cAAc,iBAAiB;;EA6B1E,WACJ,OAAO,aACP,UAAU,cAAc,gBACxB,QAAQ,kBACR,uBACC;;EAqBG,sBAAsB,QAAQ,MAAM,oBAAoB;;EAqBxD,mBAAmB,QAAQ,MAAM,oBAAoB;;EAqBrD,qBAAqB,QAAQ,MAAM,oBAAoB"}
1
+ {"version":3,"file":"cloudflare.d.ts","names":[],"sources":["../src/infrastructure/cloudflare/d1-database-types.ts","../src/infrastructure/cloudflare/base-d1-repository.ts","../src/infrastructure/cloudflare/classify-d1-error.ts","../src/infrastructure/cloudflare/d1-message-store.ts","../src/infrastructure/cloudflare/d1-schema.ts","../src/infrastructure/cloudflare/d1-batch-transaction.ts","../src/infrastructure/cloudflare/d1-database-execution.ts","../src/infrastructure/cloudflare/d1-outbox-repository.ts"],"mappings":";;;;;;;KAKY,e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c,iBAAiB;;EA6B1E,WACJ,OAAO,aACP,UAAU,cAAc,gBACxB,QAAQ,kBACR,uBACC;;EAqBG,sBAAsB,QAAQ,MAAM,oBAAoB;;EAqBxD,mBAAmB,QAAQ,MAAM,oBAAoB;;EAqBrD,qBAAqB,QAAQ,MAAM,oBAAoB"}
@@ -1,6 +1,6 @@
1
- import { O as DatabaseError, nt as AppError, s as exponentialDelayCapMs } from "./core-BiN6S_cm.js";
2
- import { o as MessageAlreadyProcessedError } from "./application-B5hnNUdI.js";
3
- import { a as stageD1Statement, i as runWithUnitOfWorkContext, n as collectD1Statements, r as eventCollector, t as OUTBOX_REPOSITORY_DEFAULTS } from "./outbox-repository-options-BNpCWTht.js";
1
+ import { O as DatabaseError, s as exponentialDelayCapMs, tt as AppError } from "./core-DOBZeYSX.js";
2
+ import { o as MessageAlreadyProcessedError } from "./application-Dsz-o9Aj.js";
3
+ import { a as stageD1Statement, i as runWithUnitOfWorkContext, n as collectD1Statements, r as eventCollector, t as OUTBOX_REPOSITORY_DEFAULTS } from "./outbox-repository-options-Ca67c3c9.js";
4
4
  import { Result } from "better-result";
5
5
  import { DrizzleQueryError } from "drizzle-orm/errors";
6
6
  import { and, asc, eq, inArray, isNull, lt, lte, or, sql } from "drizzle-orm";
@@ -31,11 +31,6 @@ var MissingConfigurationError = class extends AppError {
31
31
  }
32
32
  };
33
33
 
34
- //#endregion
35
- //#region src/core/analytics-event.ts
36
- /** Parse a persisted analytics event UUID; the SDK generates ordinary event UUIDs itself. */
37
- const AnalyticsEventIdSchema = z.uuid().brand();
38
-
39
34
  //#endregion
40
35
  //#region src/core/email-address.ts
41
36
  /** A parsed email address for message payloads and webhook recipients. Ported from Typist's `EmailSchema`. */
@@ -915,5 +910,5 @@ function createLogger(module) {
915
910
  }
916
911
 
917
912
  //#endregion
918
- export { EmailAddressSchema as $, sharedErrors as A, ServiceUnavailableError as B, combineMessages as C, unreachable as D, notImplemented as E, RequestTimeoutError as F, RecordEmailEventPayloadSchema as G, StaleSessionError as H, ResourceNotFoundError as I, parseBounceType as J, BounceTypeSchema as K, UpgradeRequiredError as L, ValidationProblemDetailsSchema as M, ValidationProblemErrorSchema as N, DatabaseError as O, MalformedRequestError as P, emailIdempotencyKey as Q, ValidationError as R, DuplicateMessageNameError as S, defineId as T, RateLimitError as U, NotAuthorizedError as V, AuthenticationError as W, EmailServiceError as X, shouldUpdateBounce as Y, InvalidEmailIdempotencyKeyError as Z, isTransientCloudflareRuntimeError as _, setLoggerErrorHook as a, shouldRetryFailure as b, exponentialEqualJitterMs as c, classifyFailure as d, AnalyticsEventIdSchema as et, retryAfterSecondsOf as f, isCloudflareRetryableError as g, isCloudflareOverloadedError as h, setLogSink as i, ProblemDetailsSchema as j, defineErrors as k, spreadJitterMs as l, isCloudflareObjectResetError as m, configureLogger as n, AppError as nt, consoleSink as o, CLOUDFLARE_TRANSIENT_ERROR_PATTERNS as p, isEmailDeliverable as q, createLogger as r, exponentialDelayCapMs as s, LogLevel as t, MissingConfigurationError as tt, classifyBoundaryError as u, isAbortError as v, defineMessages as w, Entity as x, isTransientTransportError as y, InternalServerError as z };
919
- //# sourceMappingURL=core-BiN6S_cm.js.map
913
+ export { EmailAddressSchema as $, sharedErrors as A, ServiceUnavailableError as B, combineMessages as C, unreachable as D, notImplemented as E, RequestTimeoutError as F, RecordEmailEventPayloadSchema as G, StaleSessionError as H, ResourceNotFoundError as I, parseBounceType as J, BounceTypeSchema as K, UpgradeRequiredError as L, ValidationProblemDetailsSchema as M, ValidationProblemErrorSchema as N, DatabaseError as O, MalformedRequestError as P, emailIdempotencyKey as Q, ValidationError as R, DuplicateMessageNameError as S, defineId as T, RateLimitError as U, NotAuthorizedError as V, AuthenticationError as W, EmailServiceError as X, shouldUpdateBounce as Y, InvalidEmailIdempotencyKeyError as Z, isTransientCloudflareRuntimeError as _, setLoggerErrorHook as a, shouldRetryFailure as b, exponentialEqualJitterMs as c, classifyFailure as d, MissingConfigurationError as et, retryAfterSecondsOf as f, isCloudflareRetryableError as g, isCloudflareOverloadedError as h, setLogSink as i, ProblemDetailsSchema as j, defineErrors as k, spreadJitterMs as l, isCloudflareObjectResetError as m, configureLogger as n, consoleSink as o, CLOUDFLARE_TRANSIENT_ERROR_PATTERNS as p, isEmailDeliverable as q, createLogger as r, exponentialDelayCapMs as s, LogLevel as t, AppError as tt, classifyBoundaryError as u, isAbortError as v, defineMessages as w, Entity as x, isTransientTransportError as y, InternalServerError as z };
914
+ //# sourceMappingURL=core-DOBZeYSX.js.map