better-ship 0.4.0 → 0.5.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 (81) hide show
  1. package/dist/{application-BpSwCKJ5.js → application-DEerezCl.js} +2 -2
  2. package/dist/{application-BpSwCKJ5.js.map → application-DEerezCl.js.map} +1 -1
  3. package/dist/application.d.ts +1 -1
  4. package/dist/application.js +1 -1
  5. package/dist/better-auth/apple-client-secret.d.ts +21 -0
  6. package/dist/better-auth/apple-client-secret.d.ts.map +1 -0
  7. package/dist/better-auth/apple-client-secret.js +44 -0
  8. package/dist/better-auth/apple-client-secret.js.map +1 -0
  9. package/dist/better-auth/auth-client.d.ts +16 -0
  10. package/dist/better-auth/auth-client.d.ts.map +1 -0
  11. package/dist/better-auth/auth-client.js +24 -0
  12. package/dist/better-auth/auth-client.js.map +1 -0
  13. package/dist/better-auth/rate-limit.d.ts +34 -0
  14. package/dist/better-auth/rate-limit.d.ts.map +1 -0
  15. package/dist/better-auth/rate-limit.js +59 -0
  16. package/dist/better-auth/rate-limit.js.map +1 -0
  17. package/dist/better-auth/secondary-storage.d.ts +11 -0
  18. package/dist/better-auth/secondary-storage.d.ts.map +1 -0
  19. package/dist/better-auth/secondary-storage.js +18 -0
  20. package/dist/better-auth/secondary-storage.js.map +1 -0
  21. package/dist/better-auth/stripe.d.ts +9 -0
  22. package/dist/better-auth/stripe.d.ts.map +1 -0
  23. package/dist/better-auth/stripe.js +17 -0
  24. package/dist/better-auth/stripe.js.map +1 -0
  25. package/dist/better-auth.d.ts +100 -0
  26. package/dist/better-auth.d.ts.map +1 -0
  27. package/dist/better-auth.js +112 -0
  28. package/dist/better-auth.js.map +1 -0
  29. package/dist/cloudflare/auth-secondary-storage.d.ts +36 -0
  30. package/dist/cloudflare/auth-secondary-storage.d.ts.map +1 -0
  31. package/dist/cloudflare/auth-secondary-storage.js +98 -0
  32. package/dist/cloudflare/auth-secondary-storage.js.map +1 -0
  33. package/dist/cloudflare.d.ts +3 -3
  34. package/dist/cloudflare.js +3 -3
  35. package/dist/core-CnwWj4MY.js +620 -0
  36. package/dist/core-CnwWj4MY.js.map +1 -0
  37. package/dist/core.d.ts +2 -2
  38. package/dist/core.js +2 -2
  39. package/dist/index-B9Y1hVh6.d.ts +460 -0
  40. package/dist/index-B9Y1hVh6.d.ts.map +1 -0
  41. package/dist/{index-CkaFqbbV.d.ts → index-Bdyh3_xC.d.ts} +2 -2
  42. package/dist/{index-CkaFqbbV.d.ts.map → index-Bdyh3_xC.d.ts.map} +1 -1
  43. package/dist/postgres.d.ts +3 -3
  44. package/dist/postgres.js +3 -3
  45. package/dist/tanstack.d.ts +81 -1
  46. package/dist/tanstack.d.ts.map +1 -0
  47. package/dist/tanstack.js +214 -0
  48. package/dist/tanstack.js.map +1 -0
  49. package/dist/{unit-of-work-context-CILhzKWb.js → unit-of-work-context-C7vz5OYS.js} +2 -2
  50. package/dist/{unit-of-work-context-CILhzKWb.js.map → unit-of-work-context-C7vz5OYS.js.map} +1 -1
  51. package/dist/{unit-of-work-context-DOkIB7HK.d.ts → unit-of-work-context-ml9L9cyY.d.ts} +2 -2
  52. package/dist/{unit-of-work-context-DOkIB7HK.d.ts.map → unit-of-work-context-ml9L9cyY.d.ts.map} +1 -1
  53. package/package.json +57 -12
  54. package/src/core/authentication.error.ts +11 -0
  55. package/src/core/error-table.ts +188 -0
  56. package/src/core/index.ts +31 -0
  57. package/src/core/internal.errors.ts +21 -0
  58. package/src/core/logger.ts +40 -19
  59. package/src/core/not-authorized.error.ts +11 -0
  60. package/src/core/problem-details.ts +57 -0
  61. package/src/core/rate-limit.error.ts +12 -0
  62. package/src/core/request.errors.ts +86 -0
  63. package/src/core/stale-session.error.ts +11 -0
  64. package/src/infrastructure/better-auth/apple-client-secret.ts +54 -0
  65. package/src/infrastructure/better-auth/auth-client.ts +26 -0
  66. package/src/infrastructure/better-auth/options.ts +232 -0
  67. package/src/infrastructure/better-auth/rate-limit.ts +69 -0
  68. package/src/infrastructure/better-auth/secondary-storage.ts +21 -0
  69. package/src/infrastructure/better-auth/stripe.ts +11 -0
  70. package/src/infrastructure/cloudflare/auth-secondary-storage.ts +113 -0
  71. package/src/infrastructure/tanstack/auth.middleware.ts +89 -0
  72. package/src/infrastructure/tanstack/error.middleware.ts +81 -0
  73. package/src/infrastructure/tanstack/http-error-response.ts +30 -0
  74. package/src/infrastructure/tanstack/index.ts +12 -0
  75. package/src/infrastructure/tanstack/resolve-failure.ts +24 -0
  76. package/src/infrastructure/tanstack/session-cookies.ts +36 -0
  77. package/src/infrastructure/tanstack/to-error-payload.ts +32 -0
  78. package/dist/core-D3G-2gIx.js +0 -298
  79. package/dist/core-D3G-2gIx.js.map +0 -1
  80. package/dist/index-CT1yZd4D.d.ts +0 -212
  81. package/dist/index-CT1yZd4D.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-CnwWj4MY.js","names":[],"sources":["../src/core/app-error.ts","../src/core/authentication.error.ts","../src/core/rate-limit.error.ts","../src/core/stale-session.error.ts","../src/core/not-authorized.error.ts","../src/core/internal.errors.ts","../src/core/request.errors.ts","../src/core/problem-details.ts","../src/core/error-table.ts","../src/core/database.error.ts","../src/core/defects.ts","../src/core/failure-classification.ts","../src/core/transport-classification.ts","../src/core/logger.ts"],"sourcesContent":["import type { FailureClassification } from './failure-classification.ts'\n\n/**\n * The base of every expected failure. A subclass declares its tag and its classification,\n * so no boundary has to guess what kind of failure it holds. A boundary tells our errors from\n * raw throws with `instanceof AppError`; a value that fails it was never judged.\n *\n * A `readonly` field with a literal initializer keeps the literal type, so\n * `readonly _tag = 'StoreUnavailable'` is enough for `Result` unions and `matchError`.\n */\nexport abstract class AppError extends Error {\n abstract readonly _tag: string\n abstract readonly classification: FailureClassification\n\n override get name(): string {\n return this._tag\n }\n}\n","import { AppError } from './app-error.ts'\n\n/** A protected operation requires a session that the caller did not provide. */\nexport class AuthenticationError extends AppError {\n readonly _tag = 'AuthenticationError'\n readonly classification = 'terminal'\n\n constructor() {\n super('Authentication required')\n }\n}\n","import { AppError } from './app-error.ts'\n\n/** HTTP 429 with a retry delay in seconds. A null delay means the response supplies no valid duration. */\nexport class RateLimitError extends AppError {\n readonly _tag = 'RateLimitError'\n readonly classification = 'transient'\n readonly status = 429\n\n constructor(readonly retryAfter: number | null) {\n super('Too many requests')\n }\n}\n","import { AppError } from './app-error.ts'\n\n/** A presented session cookie no longer resolves; the application owns cleanup and redirect policy. */\nexport class StaleSessionError extends AppError {\n readonly _tag = 'StaleSessionError'\n readonly classification = 'terminal'\n\n constructor() {\n super('Session is no longer valid. Sign in again.')\n }\n}\n","import { AppError } from './app-error.ts'\n\n/** The authenticated caller cannot perform this operation. Ported from Porte's auth.errors.ts. */\nexport class NotAuthorizedError extends AppError {\n readonly _tag = 'NotAuthorizedError'\n readonly classification = 'terminal'\n\n constructor() {\n super('Not allowed')\n }\n}\n","import { AppError } from './app-error.ts'\n\n/** Safe public replacement for an unknown failure, ported from Porte's internal.errors.ts. */\nexport class InternalServerError extends AppError {\n readonly _tag = 'InternalServerError'\n readonly classification = 'unknown'\n\n constructor() {\n super('Something went wrong')\n }\n}\n\n/** Safe public replacement for a classified transient failure. */\nexport class ServiceUnavailableError extends AppError {\n readonly _tag = 'ServiceUnavailableError'\n readonly classification = 'transient'\n\n constructor() {\n super('Try again shortly')\n }\n}\n","import { z } from 'zod'\n\nimport { AppError } from './app-error.ts'\nimport type { ValidationProblemError } from './problem-details.ts'\n\n/** One invalid value as a validator reports it: a message and a path of keys. */\nexport type ValidationIssue = {\n readonly message: string\n readonly path: readonly PropertyKey[]\n}\n\n/** Invalid user input, one entry per invalid value in the RFC 9457 shape. Technical failures use another error. */\nexport class ValidationError extends AppError {\n readonly _tag = 'ValidationError'\n readonly classification = 'terminal'\n\n constructor(\n readonly errors: readonly ValidationProblemError[],\n message = 'The request was not valid',\n ) {\n super(message)\n }\n\n /** Convert a Zod error. Each issue path becomes a JSON Pointer. */\n static fromZod(error: z.ZodError, message?: string): ValidationError {\n return ValidationError.fromIssues(error.issues, message)\n }\n\n /** Convert issues from any validator, such as issues TanStack serialized into an error message. */\n static fromIssues(issues: readonly ValidationIssue[], message?: string): ValidationError {\n return new ValidationError(\n issues.map((issue) => ({ detail: issue.message, pointer: jsonPointer(issue.path) })),\n message,\n )\n }\n}\n\n/** The server cannot parse the request syntax. */\nexport class MalformedRequestError extends AppError {\n readonly _tag = 'MalformedRequestError'\n readonly classification = 'terminal'\n\n constructor(args: { cause: unknown }) {\n super('The request was malformed', args)\n }\n}\n\n/** No resource matches the requested HTTP path. */\nexport class ResourceNotFoundError extends AppError {\n readonly _tag = 'ResourceNotFoundError'\n readonly classification = 'terminal'\n\n constructor() {\n super('Resource not found')\n }\n}\n\n/** A WebSocket route received a request without an upgrade. */\nexport class UpgradeRequiredError extends AppError {\n readonly _tag = 'UpgradeRequiredError'\n readonly classification = 'terminal'\n\n constructor() {\n super('WebSocket upgrade required')\n }\n}\n\n/** The requested operation did not answer before its deadline. */\nexport class RequestTimeoutError extends AppError {\n readonly _tag = 'RequestTimeoutError'\n readonly classification = 'transient'\n\n constructor() {\n super('The request timed out')\n }\n}\n\nconst readablePathSchema = z.array(z.union([z.string(), z.number()]))\n\n// A symbol step cannot be shown, so the pointer keeps only the steps a person can read.\nfunction jsonPointer(path: readonly PropertyKey[]): string {\n const parsed = readablePathSchema.safeParse(path)\n const steps = parsed.success ? parsed.data : []\n if (steps.length === 0) return '#'\n return `#/${steps.map((step) => String(step).replaceAll('~', '~0').replaceAll('/', '~1')).join('/')}`\n}\n","import { z } from 'zod'\n\n/**\n * The standard RFC 9457 body for a failed HTTP response.\n * The HTTP response status remains authoritative; extensions may add problem-specific data.\n * @see https://http.dev/problem-details\n */\nexport const ProblemDetailsSchema = z.looseObject({\n /**\n * Stable URI for the problem type; use `about:blank` when the HTTP status is sufficient.\n * @example \"about:blank\"\n */\n type: z.string(),\n /**\n * Stable human-readable name for the problem type.\n * @example \"Service Unavailable\"\n */\n title: z.string(),\n /**\n * Safe human-readable explanation for this occurrence; clients must not parse it.\n * @example \"The service is unavailable.\"\n */\n detail: z.string().optional(),\n /**\n * URI reference for this occurrence; omit it when no correlation resource exists.\n * @example \"/problems/occurrences/01K5F6Y7\"\n */\n instance: z.string().optional(),\n})\n\n/** An RFC 9457 problem body for a failed HTTP response. */\nexport type ProblemDetails = z.infer<typeof ProblemDetailsSchema>\n\n/** One invalid value in a `422` validation problem. */\nexport const ValidationProblemErrorSchema = z.object({\n /**\n * Safe explanation of why this value is invalid.\n * @example \"Must be a positive integer.\"\n */\n detail: z.string(),\n /**\n * RFC 6901 JSON Pointer fragment for the invalid value.\n * @example \"#/age\"\n */\n pointer: z.string().regex(/^#(?:\\/(?:[^~]|~[01])*)*$/u),\n})\n\n/** One invalid value in a `422` validation problem. */\nexport type ValidationProblemError = z.infer<typeof ValidationProblemErrorSchema>\n\n/** An RFC 9457 validation problem with one or more invalid content values. */\nexport const ValidationProblemDetailsSchema = ProblemDetailsSchema.extend({\n errors: z.array(ValidationProblemErrorSchema).min(1),\n})\n\n/** An RFC 9457 validation problem with one or more invalid content values. */\nexport type ValidationProblemDetails = z.infer<typeof ValidationProblemDetailsSchema>\n","import { panic } from 'better-result'\nimport { z } from 'zod'\n\nimport { AppError } from './app-error.ts'\nimport { AuthenticationError } from './authentication.error.ts'\nimport { InternalServerError, ServiceUnavailableError } from './internal.errors.ts'\nimport { NotAuthorizedError } from './not-authorized.error.ts'\nimport { ValidationProblemErrorSchema } from './problem-details.ts'\nimport { RateLimitError } from './rate-limit.error.ts'\nimport {\n MalformedRequestError,\n RequestTimeoutError,\n ResourceNotFoundError,\n UpgradeRequiredError,\n ValidationError,\n} from './request.errors.ts'\nimport { StaleSessionError } from './stale-session.error.ts'\n\ntype PublicFields = z.ZodObject\n\n/**\n * One public error: its class, its HTTP status, and the extra properties a client may read.\n * `fields` strips the thrown error on the server and parses the payload in the browser.\n */\nexport type ErrorEntry<Tag extends string, Fields extends PublicFields = PublicFields> = {\n readonly error: abstract new (...args: never[]) => AppError & { readonly _tag: Tag }\n readonly status: number\n readonly fields?: Fields\n}\n\ntype AnyErrorEntry = ErrorEntry<string>\n\n/** Entries keyed by tag. The compiler rejects a key that differs from the class's `_tag`. */\nexport type ErrorEntries<Entries> = {\n readonly [Tag in keyof Entries & string]: ErrorEntry<Tag>\n}\n\ntype EntryPayload<Tag extends string, Entry> = Entry extends {\n readonly fields: infer Fields extends z.ZodType\n}\n ? { readonly _tag: Tag; readonly message: string } & z.output<Fields>\n : { readonly _tag: Tag; readonly message: string }\n\ntype PayloadOfEntries<Entries> = {\n [Tag in keyof Entries & string]: EntryPayload<Tag, Entries[Tag]>\n}[keyof Entries & string]\n\n/** The HTTP status and public payload for one resolved failure. */\nexport type ResolvedError<Payload> = {\n readonly status: number\n readonly payload: Payload\n}\n\n/**\n * One application's public errors, shared by every transport boundary and the browser.\n * `resolve` and `fallback` serve boundaries. `parse` and `generic` serve screens.\n */\nexport type ErrorTable<Entries> = {\n readonly entries: Entries\n /** The discriminated union of every entry's `_tag`, `message`, and fields. */\n readonly payloadSchema: z.ZodType<PayloadOfEntries<Entries>>\n /** The `InternalServerError` payload, for screens that must show something. */\n readonly generic: PayloadOfEntries<Entries>\n /** Read a rejection value. Null means no known tag, so the request never reached the Worker. */\n parse(cause: unknown): PayloadOfEntries<Entries> | null\n /** Narrow a rejection value to one tag's payload, for a caller that acts on that one error. */\n is<Tag extends keyof Entries & string>(\n cause: unknown,\n tag: Tag,\n ): cause is Extract<PayloadOfEntries<Entries>, { readonly _tag: Tag }>\n /** Match a local instance or a remote error by tag. Null means the failure is not public. */\n resolve(cause: unknown): ResolvedError<PayloadOfEntries<Entries>> | null\n /** The replacement for an unmapped failure: 503 when it declared itself transient, else 500. */\n fallback(cause: unknown): ResolvedError<PayloadOfEntries<Entries>>\n}\n\n/** The union of payloads a table can produce. */\nexport type ErrorPayloadOf<Table> =\n Table extends ErrorTable<infer Entries> ? PayloadOfEntries<Entries> : never\n\n/** The union of tags a table contains. */\nexport type ErrorTagOf<Table> =\n Table extends ErrorTable<infer Entries> ? keyof Entries & string : never\n\nfunction entriesOf<const Entries extends ErrorEntries<Entries>>(entries: Entries): Entries {\n return entries\n}\n\nconst ValidationFields = z.object({ errors: z.array(ValidationProblemErrorSchema) })\nconst RateLimitFields = z.object({ retryAfter: z.number().nullable() })\n\n/** The errors every application can throw, with their statuses. `defineErrors` includes them. */\nexport const sharedErrors = entriesOf({\n MalformedRequestError: { error: MalformedRequestError, status: 400 },\n AuthenticationError: { error: AuthenticationError, status: 401 },\n StaleSessionError: { error: StaleSessionError, status: 401 },\n NotAuthorizedError: { error: NotAuthorizedError, status: 403 },\n ResourceNotFoundError: { error: ResourceNotFoundError, status: 404 },\n ValidationError: { error: ValidationError, status: 422, fields: ValidationFields },\n UpgradeRequiredError: { error: UpgradeRequiredError, status: 426 },\n RateLimitError: { error: RateLimitError, status: 429, fields: RateLimitFields },\n InternalServerError: { error: InternalServerError, status: 500 },\n ServiceUnavailableError: { error: ServiceUnavailableError, status: 503 },\n RequestTimeoutError: { error: RequestTimeoutError, status: 504 },\n})\n\ntype MergedEntries<Entries> = Omit<typeof sharedErrors, keyof Entries> & Entries\n\n// Workers RPC drops the prototype but keeps own properties and marks the error as remote.\nconst RemoteErrorSchema = z.object({\n _tag: z.string(),\n message: z.string(),\n remote: z.literal(true),\n})\n\ntype Match = { readonly tag: string; readonly entry: AnyErrorEntry; readonly error: Error }\n\nfunction match(byTag: ReadonlyMap<string, AnyErrorEntry>, cause: unknown): Match | null {\n if (cause instanceof AppError) {\n const entry = byTag.get(cause._tag)\n if (entry === undefined || !(cause instanceof entry.error)) return null\n return { tag: cause._tag, entry, error: cause }\n }\n if (!(cause instanceof Error)) return null\n const remote = RemoteErrorSchema.safeParse(cause)\n if (!remote.success) return null\n const entry = byTag.get(remote.data._tag)\n return entry === undefined ? null : { tag: remote.data._tag, entry, error: cause }\n}\n\n/**\n * Build the application's error table. The shared entries are always included;\n * an entry with the same key replaces the shared one.\n */\nexport function defineErrors<const Entries extends ErrorEntries<Entries>>(\n entries: Entries,\n): ErrorTable<MergedEntries<Entries>> {\n type Payload = PayloadOfEntries<MergedEntries<Entries>>\n const merged = { ...sharedErrors, ...entries }\n const byTag: ReadonlyMap<string, AnyErrorEntry> = new Map(Object.entries<AnyErrorEntry>(merged))\n\n const resolve = (cause: unknown): ResolvedError<Payload> | null => {\n const found = match(byTag, cause)\n if (found === null) return null\n const fields = found.entry.fields?.safeParse(found.error)\n if (fields !== undefined && !fields.success) return null\n // SAFETY: The entry's own `fields` schema produced these properties, so the payload has the shape declared for this tag.\n const payload = { _tag: found.tag, message: found.error.message, ...fields?.data } as Payload\n return { status: found.entry.status, payload }\n }\n\n const resolveShared = (error: AppError): ResolvedError<Payload> =>\n resolve(error) ?? panic(`Error table cannot resolve shared error ${error._tag}`)\n const generic = resolveShared(new InternalServerError())\n const unavailable = resolveShared(new ServiceUnavailableError())\n\n const variants = [...byTag].map(([tag, entry]) =>\n // oxlint-disable-next-line anti-slop/no-shape-in-symbol-names -- Zod names an object schema's property map `shape`.\n z.strictObject({ _tag: z.literal(tag), message: z.string(), ...entry.fields?.shape }),\n )\n const [first, ...rest] = variants\n if (first === undefined) return panic('Error table has no entries')\n // Each variant is one entry's `_tag`, `message`, and fields, which is the union `PayloadOfEntries` describes.\n const payloadSchema = z.discriminatedUnion('_tag', [first, ...rest]).pipe(z.custom<Payload>())\n\n // No return annotation: TypeScript resolves the deferred payload union differently in that position.\n const parse = (cause: unknown) => {\n const parsed = payloadSchema.safeParse(cause)\n return parsed.success ? parsed.data : null\n }\n\n return {\n entries: merged,\n payloadSchema,\n generic: generic.payload,\n parse,\n is<Tag extends keyof MergedEntries<Entries> & string>(\n cause: unknown,\n tag: Tag,\n ): cause is Extract<Payload, { readonly _tag: Tag }> {\n const parsed = parse(cause)\n return parsed !== null && parsed._tag === tag\n },\n resolve,\n fallback: (cause) =>\n cause instanceof AppError && cause.classification === 'transient' ? unavailable : generic,\n }\n}\n","import { AppError } from './app-error.ts'\nimport type { FailureClassification } from './failure-classification.ts'\n\n/** SQLite reports these constraint categories through D1. */\nexport type D1ConstraintKind = 'unique' | 'not_null' | 'foreign_key' | 'check'\n\n/** Database evidence for callers that interpret a specific code or constraint. */\nexport type DatabaseFailure =\n | {\n readonly database: 'd1'\n readonly code: string | undefined\n readonly kind: D1ConstraintKind | undefined\n readonly table: string | undefined\n readonly column: string | undefined\n readonly constraintName: string | undefined\n }\n | {\n readonly database: 'postgres'\n readonly code: string | undefined\n readonly table_name: string | undefined\n readonly column_name: string | undefined\n readonly constraint_name: string | undefined\n }\n\n/** Classification describes the failure; callers must separately establish whether repetition is safe. */\nexport class DatabaseError extends AppError {\n readonly _tag = 'DatabaseError'\n\n constructor(\n readonly operation: string,\n readonly classification: FailureClassification,\n readonly details: DatabaseFailure,\n options: { readonly cause: unknown },\n ) {\n super(`Database operation failed: ${operation}`, options)\n }\n}\n","import { panic } from 'better-result'\n\n/**\n * Mark a line the types say cannot run. A union member without a branch stops compilation here.\n *\n * @throws Panic when a value outside the union arrives at runtime.\n */\nexport function unreachable(value: never): never {\n return panic(`Unreachable: ${String(value)}`)\n}\n\n/**\n * Mark a body that is not written yet. A defect, not an expected failure.\n *\n * @param what - The behavior the body will provide, such as `invoice export`.\n * @throws Panic always.\n */\nexport function notImplemented(what: string): never {\n return panic(`Not implemented: ${what}`)\n}\n","/**\n * What one failure is, before any policy decides what to do about it.\n *\n * `transient`: the world may differ on the next attempt. `terminal`: repeating gives the\n * same answer. `unknown`: nobody judged this error, so it came from outside unwrapped.\n */\nexport type FailureClassification = 'transient' | 'terminal' | 'unknown'\n\n/**\n * Who is asking to repeat the work.\n *\n * An immediate owner holds a caller and a socket open. A durable owner already stored the\n * work, so it can afford to try again on a failure nobody classified.\n */\nexport type RetryOwner = 'immediate' | 'durable'\n\n/** Decide whether one retry owner may repeat a failed operation. */\nexport function shouldRetryFailure(args: {\n readonly classification: FailureClassification\n readonly repeatSafe: boolean\n readonly owner: RetryOwner\n}): boolean {\n if (!args.repeatSafe) return false\n if (args.classification === 'transient') return true\n if (args.classification === 'terminal') return false\n return args.owner === 'durable'\n}\n","/**\n * Messages that the platform-neutral transports raise for a failure that may pass.\n *\n * A boundary that knows its own runtime adds its own patterns before these.\n */\nconst TRANSIENT_TRANSPORT_PATTERNS = [\n /network/,\n /fetch failed/,\n /timeout/,\n /timed?\\s*out/,\n /connection.*(lost|reset|refused|closed|aborted)/,\n /econnreset/,\n /econnrefused/,\n /etimedout/,\n /eai_again/,\n]\n\n/** Cancellation is a decision, not a failure to repeat. */\nexport function isAbortError(cause: unknown): boolean {\n return cause instanceof Error && cause.name === 'AbortError'\n}\n\n/** Match known transient transport messages while excluding explicit cancellation. */\nexport function isTransientTransportError(cause: unknown): boolean {\n if (!(cause instanceof Error) || isAbortError(cause)) return false\n const message = cause.message.toLowerCase()\n return TRANSIENT_TRANSPORT_PATTERNS.some((pattern) => pattern.test(message))\n}\n","/**\n * Module-scoped logging for every host.\n *\n * A logger emits one plain-data entry per log. The default sink hands it to `console` as an\n * entry object for a log service or as a colored line for a person, selected at startup.\n */\n\n/** A value a log entry may carry. Errors enter only through `Logger.error`. */\nexport type LogValue =\n | string\n | number\n | boolean\n | null\n | undefined\n | ReadonlyArray<LogValue>\n | LogFields\n\n/** Named log values. */\nexport type LogFields = { readonly [key: string]: LogValue }\n\n/**\n * The supported log severity levels, in ascending order.\n *\n * A const object, not an enum, so a parsed environment value typed `'INFO'` is a `LogLevel`.\n */\nexport const LogLevel = {\n DEBUG: 'DEBUG',\n INFO: 'INFO',\n WARN: 'WARN',\n ERROR: 'ERROR',\n} as const\nexport type LogLevel = (typeof LogLevel)[keyof typeof LogLevel]\n\n/** An error as plain data, including diagnostics, causes, and aggregate members. */\nexport type SerializedError = {\n readonly name: string\n readonly message: string\n readonly stack?: string\n readonly fields?: LogFields\n readonly cause?: SerializedError\n readonly errors?: ReadonlyArray<SerializedError>\n}\n\n/** One log, as the sink receives it. Plain data, safe to stringify. */\nexport type LogEntry = {\n readonly timestamp: string\n readonly level: LogLevel\n readonly module: string\n readonly message: string\n readonly details: LogFields\n readonly userId?: string\n /** Present on `Logger.error` entries that carried an error. */\n readonly error?: SerializedError\n}\n\n/** The context an error log carries. */\nexport type ErrorLogContext = {\n readonly error?: unknown\n readonly userId?: string\n readonly details?: LogFields\n}\n\n/** What a logger lets through: a level and everything above it, or nothing. */\nexport type LogThreshold = LogLevel | 'OFF'\n\n/** Overrides the application settings for one logger. */\nexport interface LoggerConfig {\n readonly level?: LogThreshold\n}\n\n/** `json` writes the entry object. `pretty` writes one readable line for a person. */\nexport type LogFormat = 'json' | 'pretty'\n\n/**\n * The application settings, set once at the composition root.\n *\n * An omitted field keeps its default. An explicit `undefined` is a compile error, so the root\n * parses an environment value before passing it. The logger reads no environment itself.\n */\nexport interface LoggerSettings extends LoggerConfig {\n readonly format?: LogFormat\n}\n\n// The production server setting, so a root that never configures still logs safely.\nconst DEFAULT_SETTINGS: Required<LoggerSettings> = {\n level: LogLevel.INFO,\n format: 'json',\n}\n\n// The application configures once at startup; loggers can exist before startup completes.\nlet settings = DEFAULT_SETTINGS\n\n/**\n * Set application settings, including for existing loggers. Per-logger overrides take priority.\n * Call at startup, never per request. An omitted field resets to INFO and JSON output.\n */\nexport function configureLogger(config: LoggerSettings): void {\n settings = {\n level: config.level ?? DEFAULT_SETTINGS.level,\n format: config.format ?? DEFAULT_SETTINGS.format,\n }\n}\n\n/** The error data sent to the configured error hook. */\nexport interface ErrorCaptureEntry {\n readonly error: unknown\n readonly distinctId: string | undefined\n readonly context: LogFields\n}\n\n/** A function that forwards one logged error to an error service. */\nexport type LoggerErrorHook = (entry: ErrorCaptureEntry) => void\n\n/** Where every log entry goes. */\nexport type LogSink = (entry: LogEntry) => void\n\nlet errorHook: LoggerErrorHook | null = null\n\n/**\n * Register the function that receives each logged error.\n *\n * Set once at the process entry point. A later call replaces the earlier hook.\n */\nexport function setLoggerErrorHook(fn: LoggerErrorHook): void {\n errorHook = fn\n}\n\n// One console method per level, so a host that filters by method can tell them apart.\nconst CONSOLE_METHOD = {\n [LogLevel.DEBUG]: 'debug',\n [LogLevel.INFO]: 'info',\n [LogLevel.WARN]: 'warn',\n [LogLevel.ERROR]: 'error',\n} as const satisfies Record<LogLevel, 'debug' | 'info' | 'warn' | 'error'>\n\n// Built from the code point so no raw control character sits in the source.\nconst ESC = String.fromCharCode(27)\nconst ANSI_RESET = `${ESC}[0m`\nconst ANSI_GRAY = `${ESC}[90m`\nconst ANSI_BLUE = `${ESC}[34m`\n\n// Severity reads at a glance: quiet levels stay dim, and an error is the only bold line.\nconst LEVEL_ANSI = {\n DEBUG: `${ESC}[2;36m`,\n INFO: ANSI_BLUE,\n WARN: `${ESC}[33m`,\n ERROR: `${ESC}[1;31m`,\n} satisfies Record<LogLevel, string>\n\nfunction prettyLine(entry: LogEntry): string {\n // Node prints debug and info exactly like log, so the level must be in the text too.\n const level = `[${entry.level}]`\n const module = `[${entry.module}]`\n // A browser console colors by method on its own; a terminal needs ANSI to do the same.\n if ('window' in globalThis) return `${entry.timestamp} ${level} ${module} ${entry.message}`\n const timestamp = `${ANSI_GRAY}${entry.timestamp}${ANSI_RESET}`\n const coloredLevel = `${LEVEL_ANSI[entry.level]}${level}${ANSI_RESET}`\n const coloredModule = `${ANSI_BLUE}${module}${ANSI_RESET}`\n return `${timestamp} ${coloredLevel} ${coloredModule} ${entry.message}`\n}\n\n/**\n * JSON format writes the entry object. Pretty format writes one line, then the details,\n * the error, and the stack as separate console arguments.\n */\nexport const consoleSink: LogSink = (entry) => {\n // Resolved per call, so a console replaced after import still receives the output.\n const write = console[CONSOLE_METHOD[entry.level]]\n if (settings.format === 'json') {\n write(entry)\n return\n }\n const line = prettyLine(entry)\n const fields =\n entry.userId === undefined ? entry.details : { ...entry.details, userId: entry.userId }\n const details = Object.keys(fields).length === 0 ? [] : [fields]\n if (entry.error === undefined) {\n write(line, ...details)\n return\n }\n // A stack inside an object prints as one quoted string; as its own argument it prints as lines.\n const { stack, ...error } = entry.error\n if (stack === undefined) write(line, ...details, error)\n else write(line, ...details, error, `\\n${stack}`)\n}\n\nlet logSink: LogSink = consoleSink\n\n/**\n * Send every log entry somewhere other than `console`.\n *\n * Set once at the process entry point, never per module. A logger is created\n * by name and nothing else, so its destination is a fact about the process.\n */\nexport function setLogSink(fn: LogSink): void {\n logSink = fn\n}\n\nconst LOG_LEVELS = Object.values(LogLevel)\nconst MAX_ERROR_DEPTH = 3\n\n/**\n * Diagnostics worth keeping off an error, named one by one.\n *\n * An allowlist rather than every own property: an error raised by a library we\n * do not control may hang a request or a user payload off itself, and a log is\n * the wrong place to discover that. `_tag` and `classification` are what every `AppError`\n * declares. `remote` and the three flags after it are the ones workerd sets itself.\n */\nconst KEPT_ERROR_FIELDS = [\n '_tag',\n 'classification',\n 'code',\n 'operation',\n 'status',\n 'statusCode',\n 'remote',\n 'retryable',\n 'overloaded',\n 'durableObjectReset',\n] as const\n\ntype ErrorDiagnostics = Error & { readonly [K in (typeof KEPT_ERROR_FIELDS)[number]]?: LogValue }\n\ntype MutableSerializedError = { -readonly [K in keyof SerializedError]: SerializedError[K] }\n\nconst serializeError = (error: Error, depth = 0): SerializedError => {\n if (depth > MAX_ERROR_DEPTH) return { name: 'Error', message: '[error nesting truncated]' }\n\n // Every field is optional, so an `Error` is already one of these.\n const carrier: ErrorDiagnostics = error\n const kept = KEPT_ERROR_FIELDS.filter((key) => carrier[key] !== undefined)\n const serialized: MutableSerializedError = { name: error.name, message: error.message }\n if (error.stack !== undefined) serialized.stack = error.stack\n if (kept.length > 0)\n serialized.fields = Object.fromEntries(kept.map((key) => [key, carrier[key]]))\n if (error.cause instanceof Error) serialized.cause = serializeError(error.cause, depth + 1)\n else if (error.cause !== undefined)\n serialized.cause = { name: 'Error', message: '[non-error cause]' }\n if (error instanceof AggregateError) {\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- AggregateError accepts arbitrary values; instanceof Error validates each member.\n serialized.errors = error.errors.map((failure: unknown) =>\n failure instanceof Error\n ? serializeError(failure, depth + 1)\n : { name: 'NonError', message: '[non-error aggregate member]' },\n )\n }\n return serialized\n}\n\n/** Write module-scoped logs with application defaults and optional overrides. */\nexport class Logger {\n private readonly config: LoggerConfig\n\n /** Create a logger for one module. */\n constructor(\n private readonly module: string,\n overrideConfig?: LoggerConfig,\n ) {\n this.config = { ...overrideConfig }\n }\n\n private log(\n level: LogLevel,\n message: string,\n details: LogFields,\n error?: SerializedError,\n userId?: string,\n ): void {\n const threshold = this.config.level ?? settings.level\n if (threshold === 'OFF') return\n if (LOG_LEVELS.indexOf(level) < LOG_LEVELS.indexOf(threshold)) return\n\n let entry: LogEntry = {\n timestamp: new Date().toISOString(),\n level,\n module: this.module,\n message,\n details,\n }\n if (userId !== undefined) entry = { ...entry, userId }\n logSink(error === undefined ? entry : { ...entry, error })\n }\n\n /** Write a debug log. */\n debug(message: string, details: LogFields = {}): void {\n this.log(LogLevel.DEBUG, message, details)\n }\n\n /** Write an information log. */\n info(message: string, details: LogFields = {}): void {\n this.log(LogLevel.INFO, message, details)\n }\n\n /** Write a warning log. */\n warn(message: string, details: LogFields = {}): void {\n this.log(LogLevel.WARN, message, details)\n }\n\n /**\n * Write an error log and send the error to the configured hook.\n *\n * The details say which call this was, and the error says what went wrong\n * inside it. Both the entry and the error hook receive the supplied user ID.\n */\n error(message: string, context: ErrorLogContext = {}): void {\n const details = context.details ?? {}\n const thrown = context.error\n let error: SerializedError | undefined\n if (thrown instanceof Error) {\n error = serializeError(thrown)\n } else if (thrown !== undefined) {\n // Not an `Error`, so there is no name or stack to keep, only its JSON form.\n let json: string\n try {\n json = JSON.stringify(thrown)\n } catch {\n json = '[non-serializable error]'\n }\n error = { name: 'NonError', message: json }\n }\n this.log(LogLevel.ERROR, message, details, error, context.userId)\n\n if (errorHook !== null && thrown !== undefined) {\n errorHook({ error: thrown, distinctId: context.userId, context: details })\n }\n }\n}\n\n/** Create a logger for one module. */\nexport function createLogger(module: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C;EACA,KAAK,IAAI,SAAS,OAAO,SAAS,SAAS,OAAO,QAAQ,MAAM;EAEhE,IAAI,cAAc,QAAQ,WAAW,QACnC,UAAU;GAAE,OAAO;GAAQ,YAAY,QAAQ;GAAQ,SAAS;EAAQ,CAAC;CAE7E;AACF;;AAGA,SAAgB,aAAa,QAAgB,QAA+B;CAC1E,OAAO,IAAI,OAAO,QAAQ,MAAM;AAClC"}
package/dist/core.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as shouldRetryFailure, C as unreachable, D as AppError, E as DatabaseFailure, O as FailureClassification, S as notImplemented, T as DatabaseError, _ as createLogger, a as LogFormat, b as isAbortError, c as LogThreshold, d as LoggerConfig, f as LoggerErrorHook, g as consoleSink, h as configureLogger, i as LogFields, k as RetryOwner, l as LogValue, m as SerializedError, n as ErrorLogContext, o as LogLevel, p as LoggerSettings, r as LogEntry, s as LogSink, t as ErrorCaptureEntry, u as Logger, v as setLogSink, w as D1ConstraintKind, x as isTransientTransportError, y as setLoggerErrorHook } from "./index-CT1yZd4D.js";
2
- export { AppError, type D1ConstraintKind, DatabaseError, type DatabaseFailure, type ErrorCaptureEntry, type ErrorLogContext, type FailureClassification, type LogEntry, type LogFields, type LogFormat, LogLevel, type LogSink, type LogThreshold, type LogValue, Logger, type LoggerConfig, type LoggerErrorHook, type LoggerSettings, type RetryOwner, type SerializedError, configureLogger, consoleSink, createLogger, isAbortError, isTransientTransportError, notImplemented, setLogSink, setLoggerErrorHook, shouldRetryFailure, unreachable };
1
+ import { $ as AppError, A as ErrorTable, B as ValidationIssue, C as unreachable, D as ErrorEntries, E as DatabaseFailure, F as MalformedRequestError, G as ValidationProblemError, H as ProblemDetailsSchema, I as RequestTimeoutError, J as ServiceUnavailableError, K as ValidationProblemErrorSchema, L as ResourceNotFoundError, M as ResolvedError, N as defineErrors, O as ErrorEntry, P as sharedErrors, Q as AuthenticationError, R as UpgradeRequiredError, S as notImplemented, T as DatabaseError, U as ValidationProblemDetails, V as ProblemDetails, W as ValidationProblemDetailsSchema, X as StaleSessionError, Y as NotAuthorizedError, Z as RateLimitError, _ as createLogger, a as LogFormat, b as isAbortError, c as LogThreshold, d as LoggerConfig, et as FailureClassification, f as LoggerErrorHook, g as consoleSink, h as configureLogger, i as LogFields, j as ErrorTagOf, k as ErrorPayloadOf, l as LogValue, m as SerializedError, n as ErrorLogContext, nt as shouldRetryFailure, o as LogLevel, p as LoggerSettings, q as InternalServerError, r as LogEntry, s as LogSink, t as ErrorCaptureEntry, tt as RetryOwner, u as Logger, v as setLogSink, w as D1ConstraintKind, x as isTransientTransportError, y as setLoggerErrorHook, z as ValidationError } from "./index-B9Y1hVh6.js";
2
+ export { AppError, AuthenticationError, type D1ConstraintKind, DatabaseError, type DatabaseFailure, type ErrorCaptureEntry, type ErrorEntries, type ErrorEntry, type ErrorLogContext, type ErrorPayloadOf, type ErrorTable, type ErrorTagOf, type FailureClassification, InternalServerError, type LogEntry, type LogFields, type LogFormat, LogLevel, type LogSink, type LogThreshold, type LogValue, Logger, type LoggerConfig, type LoggerErrorHook, type LoggerSettings, MalformedRequestError, NotAuthorizedError, type ProblemDetails, ProblemDetailsSchema, RateLimitError, RequestTimeoutError, type ResolvedError, ResourceNotFoundError, type RetryOwner, type SerializedError, ServiceUnavailableError, StaleSessionError, UpgradeRequiredError, ValidationError, type ValidationIssue, type ValidationProblemDetails, ValidationProblemDetailsSchema, type ValidationProblemError, ValidationProblemErrorSchema, configureLogger, consoleSink, createLogger, defineErrors, isAbortError, isTransientTransportError, notImplemented, setLogSink, setLoggerErrorHook, sharedErrors, shouldRetryFailure, unreachable };
package/dist/core.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as createLogger, c as isAbortError, d as notImplemented, f as unreachable, i as consoleSink, l as isTransientTransportError, m as AppError, n as Logger, o as setLogSink, p as DatabaseError, r as configureLogger, s as setLoggerErrorHook, t as LogLevel, u as shouldRetryFailure } from "./core-D3G-2gIx.js";
1
+ import { A as AppError, C as ValidationError, D as StaleSessionError, E as NotAuthorizedError, O as RateLimitError, S as UpgradeRequiredError, T as ServiceUnavailableError, _ as ValidationProblemDetailsSchema, a as createLogger, b as RequestTimeoutError, c as isAbortError, d as notImplemented, f as unreachable, g as ProblemDetailsSchema, h as sharedErrors, i as consoleSink, k as AuthenticationError, l as isTransientTransportError, m as defineErrors, n as Logger, o as setLogSink, p as DatabaseError, r as configureLogger, s as setLoggerErrorHook, t as LogLevel, u as shouldRetryFailure, v as ValidationProblemErrorSchema, w as InternalServerError, x as ResourceNotFoundError, y as MalformedRequestError } from "./core-CnwWj4MY.js";
2
2
 
3
- export { AppError, DatabaseError, LogLevel, Logger, configureLogger, consoleSink, createLogger, isAbortError, isTransientTransportError, notImplemented, setLogSink, setLoggerErrorHook, shouldRetryFailure, unreachable };
3
+ export { AppError, AuthenticationError, DatabaseError, InternalServerError, LogLevel, Logger, MalformedRequestError, NotAuthorizedError, ProblemDetailsSchema, RateLimitError, RequestTimeoutError, ResourceNotFoundError, ServiceUnavailableError, StaleSessionError, UpgradeRequiredError, ValidationError, ValidationProblemDetailsSchema, ValidationProblemErrorSchema, configureLogger, consoleSink, createLogger, defineErrors, isAbortError, isTransientTransportError, notImplemented, setLogSink, setLoggerErrorHook, sharedErrors, shouldRetryFailure, unreachable };
@@ -0,0 +1,460 @@
1
+ import { z } from "zod";
2
+ //#region src/core/failure-classification.d.ts
3
+ /**
4
+ * What one failure is, before any policy decides what to do about it.
5
+ *
6
+ * `transient`: the world may differ on the next attempt. `terminal`: repeating gives the
7
+ * same answer. `unknown`: nobody judged this error, so it came from outside unwrapped.
8
+ */
9
+ type FailureClassification = 'transient' | 'terminal' | 'unknown';
10
+ /**
11
+ * Who is asking to repeat the work.
12
+ *
13
+ * An immediate owner holds a caller and a socket open. A durable owner already stored the
14
+ * work, so it can afford to try again on a failure nobody classified.
15
+ */
16
+ type RetryOwner = 'immediate' | 'durable';
17
+ /** Decide whether one retry owner may repeat a failed operation. */
18
+ declare function shouldRetryFailure(args: {
19
+ readonly classification: FailureClassification;
20
+ readonly repeatSafe: boolean;
21
+ readonly owner: RetryOwner;
22
+ }): boolean;
23
+ //#endregion
24
+ //#region src/core/app-error.d.ts
25
+ /**
26
+ * The base of every expected failure. A subclass declares its tag and its classification,
27
+ * so no boundary has to guess what kind of failure it holds. A boundary tells our errors from
28
+ * raw throws with `instanceof AppError`; a value that fails it was never judged.
29
+ *
30
+ * A `readonly` field with a literal initializer keeps the literal type, so
31
+ * `readonly _tag = 'StoreUnavailable'` is enough for `Result` unions and `matchError`.
32
+ */
33
+ declare abstract class AppError extends Error {
34
+ abstract readonly _tag: string;
35
+ abstract readonly classification: FailureClassification;
36
+ get name(): string;
37
+ }
38
+ //#endregion
39
+ //#region src/core/authentication.error.d.ts
40
+ /** A protected operation requires a session that the caller did not provide. */
41
+ declare class AuthenticationError extends AppError {
42
+ readonly _tag = "AuthenticationError";
43
+ readonly classification = "terminal";
44
+ constructor();
45
+ }
46
+ //#endregion
47
+ //#region src/core/rate-limit.error.d.ts
48
+ /** HTTP 429 with a retry delay in seconds. A null delay means the response supplies no valid duration. */
49
+ declare class RateLimitError extends AppError {
50
+ readonly retryAfter: number | null;
51
+ readonly _tag = "RateLimitError";
52
+ readonly classification = "transient";
53
+ readonly status = 429;
54
+ constructor(retryAfter: number | null);
55
+ }
56
+ //#endregion
57
+ //#region src/core/stale-session.error.d.ts
58
+ /** A presented session cookie no longer resolves; the application owns cleanup and redirect policy. */
59
+ declare class StaleSessionError extends AppError {
60
+ readonly _tag = "StaleSessionError";
61
+ readonly classification = "terminal";
62
+ constructor();
63
+ }
64
+ //#endregion
65
+ //#region src/core/not-authorized.error.d.ts
66
+ /** The authenticated caller cannot perform this operation. Ported from Porte's auth.errors.ts. */
67
+ declare class NotAuthorizedError extends AppError {
68
+ readonly _tag = "NotAuthorizedError";
69
+ readonly classification = "terminal";
70
+ constructor();
71
+ }
72
+ //#endregion
73
+ //#region src/core/internal.errors.d.ts
74
+ /** Safe public replacement for an unknown failure, ported from Porte's internal.errors.ts. */
75
+ declare class InternalServerError extends AppError {
76
+ readonly _tag = "InternalServerError";
77
+ readonly classification = "unknown";
78
+ constructor();
79
+ }
80
+ /** Safe public replacement for a classified transient failure. */
81
+ declare class ServiceUnavailableError extends AppError {
82
+ readonly _tag = "ServiceUnavailableError";
83
+ readonly classification = "transient";
84
+ constructor();
85
+ }
86
+ //#endregion
87
+ //#region src/core/problem-details.d.ts
88
+ /**
89
+ * The standard RFC 9457 body for a failed HTTP response.
90
+ * The HTTP response status remains authoritative; extensions may add problem-specific data.
91
+ * @see https://http.dev/problem-details
92
+ */
93
+ declare const ProblemDetailsSchema: z.ZodObject<{
94
+ type: z.ZodString;
95
+ title: z.ZodString;
96
+ detail: z.ZodOptional<z.ZodString>;
97
+ instance: z.ZodOptional<z.ZodString>;
98
+ }, z.core.$loose>;
99
+ /** An RFC 9457 problem body for a failed HTTP response. */
100
+ type ProblemDetails = z.infer<typeof ProblemDetailsSchema>;
101
+ /** One invalid value in a `422` validation problem. */
102
+ declare const ValidationProblemErrorSchema: z.ZodObject<{
103
+ detail: z.ZodString;
104
+ pointer: z.ZodString;
105
+ }, z.core.$strip>;
106
+ /** One invalid value in a `422` validation problem. */
107
+ type ValidationProblemError = z.infer<typeof ValidationProblemErrorSchema>;
108
+ /** An RFC 9457 validation problem with one or more invalid content values. */
109
+ declare const ValidationProblemDetailsSchema: z.ZodObject<{
110
+ type: z.ZodString;
111
+ title: z.ZodString;
112
+ detail: z.ZodOptional<z.ZodString>;
113
+ instance: z.ZodOptional<z.ZodString>;
114
+ errors: z.ZodArray<z.ZodObject<{
115
+ detail: z.ZodString;
116
+ pointer: z.ZodString;
117
+ }, z.core.$strip>>;
118
+ }, z.core.$loose>;
119
+ /** An RFC 9457 validation problem with one or more invalid content values. */
120
+ type ValidationProblemDetails = z.infer<typeof ValidationProblemDetailsSchema>;
121
+ //#endregion
122
+ //#region src/core/request.errors.d.ts
123
+ /** One invalid value as a validator reports it: a message and a path of keys. */
124
+ type ValidationIssue = {
125
+ readonly message: string;
126
+ readonly path: readonly PropertyKey[];
127
+ };
128
+ /** Invalid user input, one entry per invalid value in the RFC 9457 shape. Technical failures use another error. */
129
+ declare class ValidationError extends AppError {
130
+ readonly errors: readonly ValidationProblemError[];
131
+ readonly _tag = "ValidationError";
132
+ readonly classification = "terminal";
133
+ constructor(errors: readonly ValidationProblemError[], message?: string);
134
+ /** Convert a Zod error. Each issue path becomes a JSON Pointer. */
135
+ static fromZod(error: z.ZodError, message?: string): ValidationError;
136
+ /** Convert issues from any validator, such as issues TanStack serialized into an error message. */
137
+ static fromIssues(issues: readonly ValidationIssue[], message?: string): ValidationError;
138
+ }
139
+ /** The server cannot parse the request syntax. */
140
+ declare class MalformedRequestError extends AppError {
141
+ readonly _tag = "MalformedRequestError";
142
+ readonly classification = "terminal";
143
+ constructor(args: {
144
+ cause: unknown;
145
+ });
146
+ }
147
+ /** No resource matches the requested HTTP path. */
148
+ declare class ResourceNotFoundError extends AppError {
149
+ readonly _tag = "ResourceNotFoundError";
150
+ readonly classification = "terminal";
151
+ constructor();
152
+ }
153
+ /** A WebSocket route received a request without an upgrade. */
154
+ declare class UpgradeRequiredError extends AppError {
155
+ readonly _tag = "UpgradeRequiredError";
156
+ readonly classification = "terminal";
157
+ constructor();
158
+ }
159
+ /** The requested operation did not answer before its deadline. */
160
+ declare class RequestTimeoutError extends AppError {
161
+ readonly _tag = "RequestTimeoutError";
162
+ readonly classification = "transient";
163
+ constructor();
164
+ }
165
+ //#endregion
166
+ //#region src/core/error-table.d.ts
167
+ type PublicFields = z.ZodObject;
168
+ /**
169
+ * One public error: its class, its HTTP status, and the extra properties a client may read.
170
+ * `fields` strips the thrown error on the server and parses the payload in the browser.
171
+ */
172
+ type ErrorEntry<Tag extends string, Fields extends PublicFields = PublicFields> = {
173
+ readonly error: abstract new (...args: never[]) => AppError & {
174
+ readonly _tag: Tag;
175
+ };
176
+ readonly status: number;
177
+ readonly fields?: Fields;
178
+ };
179
+ /** Entries keyed by tag. The compiler rejects a key that differs from the class's `_tag`. */
180
+ type ErrorEntries<Entries> = { readonly [Tag in keyof Entries & string]: ErrorEntry<Tag>; };
181
+ type EntryPayload<Tag extends string, Entry> = Entry extends {
182
+ readonly fields: infer Fields extends z.ZodType;
183
+ } ? {
184
+ readonly _tag: Tag;
185
+ readonly message: string;
186
+ } & z.output<Fields> : {
187
+ readonly _tag: Tag;
188
+ readonly message: string;
189
+ };
190
+ type PayloadOfEntries<Entries> = { [Tag in keyof Entries & string]: EntryPayload<Tag, Entries[Tag]>; }[keyof Entries & string];
191
+ /** The HTTP status and public payload for one resolved failure. */
192
+ type ResolvedError<Payload> = {
193
+ readonly status: number;
194
+ readonly payload: Payload;
195
+ };
196
+ /**
197
+ * One application's public errors, shared by every transport boundary and the browser.
198
+ * `resolve` and `fallback` serve boundaries. `parse` and `generic` serve screens.
199
+ */
200
+ type ErrorTable<Entries> = {
201
+ readonly entries: Entries;
202
+ /** The discriminated union of every entry's `_tag`, `message`, and fields. */
203
+ readonly payloadSchema: z.ZodType<PayloadOfEntries<Entries>>;
204
+ /** The `InternalServerError` payload, for screens that must show something. */
205
+ readonly generic: PayloadOfEntries<Entries>;
206
+ /** Read a rejection value. Null means no known tag, so the request never reached the Worker. */
207
+ parse(cause: unknown): PayloadOfEntries<Entries> | null;
208
+ /** Narrow a rejection value to one tag's payload, for a caller that acts on that one error. */
209
+ is<Tag extends keyof Entries & string>(cause: unknown, tag: Tag): cause is Extract<PayloadOfEntries<Entries>, {
210
+ readonly _tag: Tag;
211
+ }>;
212
+ /** Match a local instance or a remote error by tag. Null means the failure is not public. */
213
+ resolve(cause: unknown): ResolvedError<PayloadOfEntries<Entries>> | null;
214
+ /** The replacement for an unmapped failure: 503 when it declared itself transient, else 500. */
215
+ fallback(cause: unknown): ResolvedError<PayloadOfEntries<Entries>>;
216
+ };
217
+ /** The union of payloads a table can produce. */
218
+ type ErrorPayloadOf<Table> = Table extends ErrorTable<infer Entries> ? PayloadOfEntries<Entries> : never;
219
+ /** The union of tags a table contains. */
220
+ type ErrorTagOf<Table> = Table extends ErrorTable<infer Entries> ? keyof Entries & string : never;
221
+ /** The errors every application can throw, with their statuses. `defineErrors` includes them. */
222
+ declare const sharedErrors: {
223
+ readonly MalformedRequestError: {
224
+ readonly error: typeof MalformedRequestError;
225
+ readonly status: 400;
226
+ };
227
+ readonly AuthenticationError: {
228
+ readonly error: typeof AuthenticationError;
229
+ readonly status: 401;
230
+ };
231
+ readonly StaleSessionError: {
232
+ readonly error: typeof StaleSessionError;
233
+ readonly status: 401;
234
+ };
235
+ readonly NotAuthorizedError: {
236
+ readonly error: typeof NotAuthorizedError;
237
+ readonly status: 403;
238
+ };
239
+ readonly ResourceNotFoundError: {
240
+ readonly error: typeof ResourceNotFoundError;
241
+ readonly status: 404;
242
+ };
243
+ readonly ValidationError: {
244
+ readonly error: typeof ValidationError;
245
+ readonly status: 422;
246
+ readonly fields: z.ZodObject<{
247
+ errors: z.ZodArray<z.ZodObject<{
248
+ detail: z.ZodString;
249
+ pointer: z.ZodString;
250
+ }, z.core.$strip>>;
251
+ }, z.core.$strip>;
252
+ };
253
+ readonly UpgradeRequiredError: {
254
+ readonly error: typeof UpgradeRequiredError;
255
+ readonly status: 426;
256
+ };
257
+ readonly RateLimitError: {
258
+ readonly error: typeof RateLimitError;
259
+ readonly status: 429;
260
+ readonly fields: z.ZodObject<{
261
+ retryAfter: z.ZodNullable<z.ZodNumber>;
262
+ }, z.core.$strip>;
263
+ };
264
+ readonly InternalServerError: {
265
+ readonly error: typeof InternalServerError;
266
+ readonly status: 500;
267
+ };
268
+ readonly ServiceUnavailableError: {
269
+ readonly error: typeof ServiceUnavailableError;
270
+ readonly status: 503;
271
+ };
272
+ readonly RequestTimeoutError: {
273
+ readonly error: typeof RequestTimeoutError;
274
+ readonly status: 504;
275
+ };
276
+ };
277
+ type MergedEntries<Entries> = Omit<typeof sharedErrors, keyof Entries> & Entries;
278
+ /**
279
+ * Build the application's error table. The shared entries are always included;
280
+ * an entry with the same key replaces the shared one.
281
+ */
282
+ declare function defineErrors<const Entries extends ErrorEntries<Entries>>(entries: Entries): ErrorTable<MergedEntries<Entries>>;
283
+ //#endregion
284
+ //#region src/core/database.error.d.ts
285
+ /** SQLite reports these constraint categories through D1. */
286
+ type D1ConstraintKind = 'unique' | 'not_null' | 'foreign_key' | 'check';
287
+ /** Database evidence for callers that interpret a specific code or constraint. */
288
+ type DatabaseFailure = {
289
+ readonly database: 'd1';
290
+ readonly code: string | undefined;
291
+ readonly kind: D1ConstraintKind | undefined;
292
+ readonly table: string | undefined;
293
+ readonly column: string | undefined;
294
+ readonly constraintName: string | undefined;
295
+ } | {
296
+ readonly database: 'postgres';
297
+ readonly code: string | undefined;
298
+ readonly table_name: string | undefined;
299
+ readonly column_name: string | undefined;
300
+ readonly constraint_name: string | undefined;
301
+ };
302
+ /** Classification describes the failure; callers must separately establish whether repetition is safe. */
303
+ declare class DatabaseError extends AppError {
304
+ readonly operation: string;
305
+ readonly classification: FailureClassification;
306
+ readonly details: DatabaseFailure;
307
+ readonly _tag = "DatabaseError";
308
+ constructor(operation: string, classification: FailureClassification, details: DatabaseFailure, options: {
309
+ readonly cause: unknown;
310
+ });
311
+ }
312
+ //#endregion
313
+ //#region src/core/defects.d.ts
314
+ /**
315
+ * Mark a line the types say cannot run. A union member without a branch stops compilation here.
316
+ *
317
+ * @throws Panic when a value outside the union arrives at runtime.
318
+ */
319
+ declare function unreachable(value: never): never;
320
+ /**
321
+ * Mark a body that is not written yet. A defect, not an expected failure.
322
+ *
323
+ * @param what - The behavior the body will provide, such as `invoice export`.
324
+ * @throws Panic always.
325
+ */
326
+ declare function notImplemented(what: string): never;
327
+ //#endregion
328
+ //#region src/core/transport-classification.d.ts
329
+ /** Cancellation is a decision, not a failure to repeat. */
330
+ declare function isAbortError(cause: unknown): boolean;
331
+ /** Match known transient transport messages while excluding explicit cancellation. */
332
+ declare function isTransientTransportError(cause: unknown): boolean;
333
+ //#endregion
334
+ //#region src/core/logger.d.ts
335
+ /**
336
+ * Module-scoped logging for every host.
337
+ *
338
+ * A logger emits one plain-data entry per log. The default sink hands it to `console` as an
339
+ * entry object for a log service or as a colored line for a person, selected at startup.
340
+ */
341
+ /** A value a log entry may carry. Errors enter only through `Logger.error`. */
342
+ type LogValue = string | number | boolean | null | undefined | ReadonlyArray<LogValue> | LogFields;
343
+ /** Named log values. */
344
+ type LogFields = {
345
+ readonly [key: string]: LogValue;
346
+ };
347
+ /**
348
+ * The supported log severity levels, in ascending order.
349
+ *
350
+ * A const object, not an enum, so a parsed environment value typed `'INFO'` is a `LogLevel`.
351
+ */
352
+ declare const LogLevel: {
353
+ readonly DEBUG: 'DEBUG';
354
+ readonly INFO: 'INFO';
355
+ readonly WARN: 'WARN';
356
+ readonly ERROR: 'ERROR';
357
+ };
358
+ type LogLevel = (typeof LogLevel)[keyof typeof LogLevel];
359
+ /** An error as plain data, including diagnostics, causes, and aggregate members. */
360
+ type SerializedError = {
361
+ readonly name: string;
362
+ readonly message: string;
363
+ readonly stack?: string;
364
+ readonly fields?: LogFields;
365
+ readonly cause?: SerializedError;
366
+ readonly errors?: ReadonlyArray<SerializedError>;
367
+ };
368
+ /** One log, as the sink receives it. Plain data, safe to stringify. */
369
+ type LogEntry = {
370
+ readonly timestamp: string;
371
+ readonly level: LogLevel;
372
+ readonly module: string;
373
+ readonly message: string;
374
+ readonly details: LogFields;
375
+ readonly userId?: string;
376
+ /** Present on `Logger.error` entries that carried an error. */
377
+ readonly error?: SerializedError;
378
+ };
379
+ /** The context an error log carries. */
380
+ type ErrorLogContext = {
381
+ readonly error?: unknown;
382
+ readonly userId?: string;
383
+ readonly details?: LogFields;
384
+ };
385
+ /** What a logger lets through: a level and everything above it, or nothing. */
386
+ type LogThreshold = LogLevel | 'OFF';
387
+ /** Overrides the application settings for one logger. */
388
+ interface LoggerConfig {
389
+ readonly level?: LogThreshold;
390
+ }
391
+ /** `json` writes the entry object. `pretty` writes one readable line for a person. */
392
+ type LogFormat = 'json' | 'pretty';
393
+ /**
394
+ * The application settings, set once at the composition root.
395
+ *
396
+ * An omitted field keeps its default. An explicit `undefined` is a compile error, so the root
397
+ * parses an environment value before passing it. The logger reads no environment itself.
398
+ */
399
+ interface LoggerSettings extends LoggerConfig {
400
+ readonly format?: LogFormat;
401
+ }
402
+ /**
403
+ * Set application settings, including for existing loggers. Per-logger overrides take priority.
404
+ * Call at startup, never per request. An omitted field resets to INFO and JSON output.
405
+ */
406
+ declare function configureLogger(config: LoggerSettings): void;
407
+ /** The error data sent to the configured error hook. */
408
+ interface ErrorCaptureEntry {
409
+ readonly error: unknown;
410
+ readonly distinctId: string | undefined;
411
+ readonly context: LogFields;
412
+ }
413
+ /** A function that forwards one logged error to an error service. */
414
+ type LoggerErrorHook = (entry: ErrorCaptureEntry) => void;
415
+ /** Where every log entry goes. */
416
+ type LogSink = (entry: LogEntry) => void;
417
+ /**
418
+ * Register the function that receives each logged error.
419
+ *
420
+ * Set once at the process entry point. A later call replaces the earlier hook.
421
+ */
422
+ declare function setLoggerErrorHook(fn: LoggerErrorHook): void;
423
+ /**
424
+ * JSON format writes the entry object. Pretty format writes one line, then the details,
425
+ * the error, and the stack as separate console arguments.
426
+ */
427
+ declare const consoleSink: LogSink;
428
+ /**
429
+ * Send every log entry somewhere other than `console`.
430
+ *
431
+ * Set once at the process entry point, never per module. A logger is created
432
+ * by name and nothing else, so its destination is a fact about the process.
433
+ */
434
+ declare function setLogSink(fn: LogSink): void;
435
+ /** Write module-scoped logs with application defaults and optional overrides. */
436
+ declare class Logger {
437
+ private readonly module;
438
+ private readonly config;
439
+ /** Create a logger for one module. */
440
+ constructor(module: string, overrideConfig?: LoggerConfig);
441
+ private log;
442
+ /** Write a debug log. */
443
+ debug(message: string, details?: LogFields): void;
444
+ /** Write an information log. */
445
+ info(message: string, details?: LogFields): void;
446
+ /** Write a warning log. */
447
+ warn(message: string, details?: LogFields): void;
448
+ /**
449
+ * Write an error log and send the error to the configured hook.
450
+ *
451
+ * The details say which call this was, and the error says what went wrong
452
+ * inside it. Both the entry and the error hook receive the supplied user ID.
453
+ */
454
+ error(message: string, context?: ErrorLogContext): void;
455
+ }
456
+ /** Create a logger for one module. */
457
+ declare function createLogger(module: string, config?: LoggerConfig): Logger;
458
+ //#endregion
459
+ export { AppError as $, ErrorTable as A, ValidationIssue as B, unreachable as C, ErrorEntries as D, DatabaseFailure as E, MalformedRequestError as F, ValidationProblemError as G, ProblemDetailsSchema as H, RequestTimeoutError as I, ServiceUnavailableError as J, ValidationProblemErrorSchema as K, ResourceNotFoundError as L, ResolvedError as M, defineErrors as N, ErrorEntry as O, sharedErrors as P, AuthenticationError as Q, UpgradeRequiredError as R, notImplemented as S, DatabaseError as T, ValidationProblemDetails as U, ProblemDetails as V, ValidationProblemDetailsSchema as W, StaleSessionError as X, NotAuthorizedError as Y, RateLimitError as Z, createLogger as _, LogFormat as a, isAbortError as b, LogThreshold as c, LoggerConfig as d, FailureClassification as et, LoggerErrorHook as f, consoleSink as g, configureLogger as h, LogFields as i, ErrorTagOf as j, ErrorPayloadOf as k, LogValue as l, SerializedError as m, ErrorLogContext as n, shouldRetryFailure as nt, LogLevel as o, LoggerSettings as p, InternalServerError as q, LogEntry as r, LogSink as s, ErrorCaptureEntry as t, RetryOwner as tt, Logger as u, setLogSink as v, D1ConstraintKind as w, isTransientTransportError as x, setLoggerErrorHook as y, ValidationError as z };
460
+ //# sourceMappingURL=index-B9Y1hVh6.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-B9Y1hVh6.d.ts","names":[],"sources":["../src/core/failure-classification.ts","../src/core/app-error.ts","../src/core/authentication.error.ts","../src/core/rate-limit.error.ts","../src/core/stale-session.error.ts","../src/core/not-authorized.error.ts","../src/core/internal.errors.ts","../src/core/problem-details.ts","../src/core/request.errors.ts","../src/core/error-table.ts","../src/core/database.error.ts","../src/core/defects.ts","../src/core/transport-classification.ts","../src/core/logger.ts"],"mappings":";;;;;;;;KAMY;;;;;;;KAQA;;iB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ACA,SAAS;;;KAIR,mBAAmB,OAAO;;KAG1B,WAAW,OAAO;;;;;;iBASd,mBAAmB,IAAI;;;;;cA0C1B,aAAa;;;;;;;iBA6BV,WAAW,IAAI;;cAyDlB;mBAKQ;mBAJF;;EAGjB,YACmB,gBACjB,iBAAiB;UAKX;;EAuBR,MAAM,iBAAiB,UAAS;;EAKhC,KAAK,iBAAiB,UAAS;;EAK/B,KAAK,iBAAiB,UAAS;;;;;;;EAU/B,MAAM,iBAAiB,UAAS;;;iBAyBlB,aAAa,gBAAgB,SAAS,eAAe"}
@@ -1,4 +1,4 @@
1
- import { D as AppError } from "./index-CT1yZd4D.js";
1
+ import { $ as AppError } from "./index-B9Y1hVh6.js";
2
2
  //#region src/application/messages.d.ts
3
3
  /**
4
4
  * The identity of a command or event. Receipts and the outbox are keyed by it.
@@ -197,4 +197,4 @@ declare class UnitOfWorkAlreadyActiveError extends AppError {
197
197
  }
198
198
  //#endregion
199
199
  export { Event as C, Query as E, Command as S, MessageId as T, RegistryMessage as _, UnitOfWorkDeps as a, EventHandler as b, IOutboxRelay as c, CommandRegistry as d, EventRegistry as f, QueryRegistry as g, MessageResult as h, UnitOfWork as i, IMessageBus as l, MessageRegistry as m, MessageAlreadyProcessedError as n, IEventCollector as o, Handlers as p, IUnitOfWork as r, ITransaction as s, UnitOfWorkAlreadyActiveError as t, MessageBus as u, IMessageStore as v, Message as w, QueryHandler as x, CommandHandler as y };
200
- //# sourceMappingURL=index-CkaFqbbV.d.ts.map
200
+ //# sourceMappingURL=index-Bdyh3_xC.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-CkaFqbbV.d.ts","names":[],"sources":["../src/application/messages.ts","../src/application/handlers.ts","../src/application/message-store.ts","../src/application/registry.ts","../src/application/message-bus.ts","../src/application/outbox-relay.ts","../src/application/transaction.ts","../src/application/event-collector.ts","../src/application/unit-of-work.ts","../src/application/message-already-processed.error.ts","../src/application/unit-of-work.errors.ts"],"mappings":";;;;;;;;;KAOY;;K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wB,oBAAoB,SAC/D,QAAQ,WAAW,QAAQ,OAAO,QAAQ;;KAIlC,cACV,iBAAiB,SACjB,kBAAkB,mBAChB,iBAAiB,UACjB,UAAU,uBAAuB,oBACjC,iBAAiB,QACf,UAAU,sBAAsB;;;;UC5DrB,YAAY,kBAAkB;EAC7C,OAAO,iBAAiB,UAAU,gBAAgB,YAChD,SAAS,WACR,QAAQ,cAAc,UAAU;;;;;;cAOxB,WAAW,MAAM,kBAAkB,SAAS,kBAAkB,YAAY;mBAElE;mBACA;EAFnB,YACmB,MAAM,MACN,UAAU;;EAIvB,OAAO,iBAAiB,UAAU,gBAAgB,YACtD,SAAS,WACR,QAAQ,cAAc,UAAU;UAM3B;UASA;UASA;;;;;;UAWM;;;;;;;;;UC5DC;EACf;;;;;;;;;UCDe,aAAa;EAC5B,YAAY,GAAG,OAAO,IAAI,OAAO,QAAQ,KAAK,QAAQ;;;;;UCHvC;EACf,KAAK,OAAO;EACZ,WAAW,cAAc;;;;;;;;;UCOV,YAAY;EAC3B,IAAI,GAAG,WAAW,WAAW,OAAO,OAAO,UAAU,QAAQ,KAAK,QAAQ;;KAGhE,eAAe,IAAI;WACpB,aAAa,aAAa;;WAE1B,eAAe,IAAI,OAAO;;WAE1B,qBAAqB,IAAI,OAAO;WAChC,gBAAgB;WAChB,OAAO;;;cAIL,WAAW,IAAI,kBAAkB,YAAY;mBAC3B;EAA7B,YAA6B,MAAM,eAAe,IAAI;EAEhD,IAAI,GAAG,WAAW,WAAW,OAAO,OAAO,UAAU,QAAQ,KAAK,QAAQ;;;;;cCzBrE,qCAAqC;WAKrC,WAAW;WAJb;WACA;EAET,YACW,WAAW,WACpB;aAAqB;;;SAMhB,KAAK,gBAAgB,WAAW,YAAY;;;;;cCdxC,qCAAqC;WACvC;WACA;EAET"}
1
+ {"version":3,"file":"index-Bdyh3_xC.d.ts","names":[],"sources":["../src/application/messages.ts","../src/application/handlers.ts","../src/application/message-store.ts","../src/application/registry.ts","../src/application/message-bus.ts","../src/application/outbox-relay.ts","../src/application/transaction.ts","../src/application/event-collector.ts","../src/application/unit-of-work.ts","../src/application/message-already-processed.error.ts","../src/application/unit-of-work.errors.ts"],"mappings":";;;;;;;;;KAOY;;KAGA,QAAQ;WACT;WACA,MAAM;WACN,IAAI;;;KAIH,MAAM;WACP;WACA,MAAM;;;KAIL,MAAM;WACP;WACA,MAAM;WACN,IAAI;;;KAIH,UAAU,UAAU,QAAQ;;;;;;;KCxB5B,eAAe,iBAAiB,SAAS,MAAM,UACzD,SAAS,UACT,MAAM,SACH,QAAQ;;;;;KAMD,aAAa,eAAe,OAAO,WAAW,UACxD,OAAO,QACP,MAAM,cACH,QAAQ;;KAGD,aAAa,eAAe,OAAO,SAAS,OAAO,QAAQ,MAAM,SAAS;;;;;;;UCfrE;;EAEf,MAAM,WAAW,YAAY;;EAE7B,cAAc,QAAQ,cAAc,SAAS;;;;;KCNnC,gBAAgB,iBAAiB,SAAS,oBAC1C,KAAK,YAAY,YAAY,eAAe,GAAG;;KAI/C,cAAc,eAAe,OAAO,yBACpC,KAAK,UAAU,YAAY,aAAa,GAAG;;;;;KAO3C,cAAc,eAAe,OAAO,oBACpC,KAAK,UAAU,aAAa,cAAc,aAAa,GAAG;;;;;;KAQ1D,gBAAgB,iBAAiB,SAAS,aAAa,WAAW;WACnE,UAAU,gBAAgB,QAAQ,UAAU,UAAU;WACtD,SAAS,cAAc,QAAQ,UAAU,QAAQ;WACjD,QAAQ,cAAc,QAAQ,UAAU,QAAQ;;KAKtD,KAAK;EAAU,OAAO,SAAS,SAAS,MAAM,OAAO;;KACrD,aAAa;EAAU,OAAO,OAAO,OAAO,MAAM,OAAO;;;;;;KAMlD,SAAS;WACV,UAAU,SAAS,eAAe,KAAK;WACvC,SAAS,SAAS,eAAe,KAAK;WACtC,QAAQ,SAAS,QAAQ,eAAe,cAAc,aAAa;;KAGzE,YAAY,UAAU,WAAW,QAAQ,aAAa,SAAS;KAE/D,oBAAoB,UACvB,YAAY,aAAa,iBA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vC;WACA;EAET"}
@@ -1,6 +1,6 @@
1
- import { C as Event, T as MessageId, s as ITransaction, v as IMessageStore } from "./index-CkaFqbbV.js";
2
- import { E as DatabaseFailure, T as DatabaseError } from "./index-CT1yZd4D.js";
3
- import { n as DrizzleSchema, t as eventCollector } from "./unit-of-work-context-DOkIB7HK.js";
1
+ import { C as Event, T as MessageId, s as ITransaction, v as IMessageStore } from "./index-Bdyh3_xC.js";
2
+ import { E as DatabaseFailure, T as DatabaseError } from "./index-B9Y1hVh6.js";
3
+ import { n as DrizzleSchema, t as eventCollector } from "./unit-of-work-context-ml9L9cyY.js";
4
4
  import { ExtractTablesWithRelations } from "drizzle-orm";
5
5
  import { PostgresJsDatabase, PostgresJsTransaction, drizzle } from "drizzle-orm/postgres-js";
6
6
  //#region src/infrastructure/postgres/postgres-database-types.d.ts
package/dist/postgres.js CHANGED
@@ -1,6 +1,6 @@
1
- import { m as AppError, p as DatabaseError } from "./core-D3G-2gIx.js";
2
- import { i as MessageAlreadyProcessedError } from "./application-BpSwCKJ5.js";
3
- import { n as eventCollector, r as runWithUnitOfWorkContext } from "./unit-of-work-context-CILhzKWb.js";
1
+ import { A as AppError, p as DatabaseError } from "./core-CnwWj4MY.js";
2
+ import { i as MessageAlreadyProcessedError } from "./application-DEerezCl.js";
3
+ import { n as eventCollector, r as runWithUnitOfWorkContext } from "./unit-of-work-context-C7vz5OYS.js";
4
4
  import { DrizzleQueryError } from "drizzle-orm/errors";
5
5
  import { isNull } from "drizzle-orm";
6
6
  import { index, integer, jsonb, pgTable, text, timestamp } from "drizzle-orm/pg-core";