better-ship 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{application-Cf9SER-i.js → application-CNdzHIXk.js} +5 -7
- package/dist/{application-Cf9SER-i.js.map → application-CNdzHIXk.js.map} +1 -1
- package/dist/application.d.ts +2 -2
- package/dist/application.js +1 -1
- package/dist/better-auth/apple-client-secret.d.ts +1 -1
- package/dist/better-auth/apple-client-secret.js +2 -2
- package/dist/better-auth/apple-client-secret.js.map +1 -1
- package/dist/better-auth/auth-client.js +1 -1
- package/dist/better-auth/rate-limit.d.ts +1 -1
- package/dist/better-auth/rate-limit.js +4 -6
- package/dist/better-auth/rate-limit.js.map +1 -1
- package/dist/better-auth.js +1 -1
- package/dist/billing/client.d.ts +86 -0
- package/dist/billing/client.d.ts.map +1 -0
- package/dist/billing/client.js +77 -0
- package/dist/billing/client.js.map +1 -0
- package/dist/cloudflare/auth-secondary-storage.d.ts +1 -1
- package/dist/cloudflare/auth-secondary-storage.js +1 -1
- package/dist/cloudflare/durable-object-client.js +1 -1
- package/dist/cloudflare/durable-object-errors.d.ts +1 -1
- package/dist/cloudflare/durable-object-errors.js +1 -1
- package/dist/cloudflare/kv-client.js +1 -1
- package/dist/cloudflare/kv-errors.d.ts +1 -1
- package/dist/cloudflare/kv-errors.js +1 -1
- package/dist/cloudflare/queue.d.ts +2 -2
- package/dist/cloudflare/queue.d.ts.map +1 -1
- package/dist/cloudflare/queue.js +10 -12
- package/dist/cloudflare/queue.js.map +1 -1
- package/dist/cloudflare/r2-client.d.ts +70 -0
- package/dist/cloudflare/r2-client.d.ts.map +1 -0
- package/dist/cloudflare/r2-client.js +153 -0
- package/dist/cloudflare/r2-client.js.map +1 -0
- package/dist/cloudflare/r2-errors.d.ts +34 -0
- package/dist/cloudflare/r2-errors.d.ts.map +1 -0
- package/dist/cloudflare/r2-errors.js +90 -0
- package/dist/cloudflare/r2-errors.js.map +1 -0
- package/dist/cloudflare/scheduled.d.ts +1 -1
- package/dist/cloudflare/scheduled.js +2 -2
- package/dist/cloudflare/scheduled.js.map +1 -1
- package/dist/cloudflare.d.ts +3 -3
- package/dist/cloudflare.js +3 -3
- package/dist/{core-ClSP5-V9.js → core-UUW2unJd.js} +106 -195
- package/dist/core-UUW2unJd.js.map +1 -0
- package/dist/core.d.ts +2 -2
- package/dist/core.js +2 -2
- package/dist/http.d.ts +2 -2
- package/dist/http.js +3 -3
- package/dist/http.js.map +1 -1
- package/dist/{index-Cchdg2aQ.d.ts → index-CYHXOH08.d.ts} +2 -2
- package/dist/{index-Cchdg2aQ.d.ts.map → index-CYHXOH08.d.ts.map} +1 -1
- package/dist/{index-DvJUcSW1.d.ts → index-DUFS0SJ_.d.ts} +41 -102
- package/dist/index-DUFS0SJ_.d.ts.map +1 -0
- package/dist/{outbox-repository-options-ICOF8g2h.js → outbox-repository-options-CgdqU20T.js} +2 -2
- package/dist/{outbox-repository-options-ICOF8g2h.js.map → outbox-repository-options-CgdqU20T.js.map} +1 -1
- package/dist/{outbox-repository-options-AkihEaik.d.ts → outbox-repository-options-DjBgFhMi.d.ts} +3 -3
- package/dist/{outbox-repository-options-AkihEaik.d.ts.map → outbox-repository-options-DjBgFhMi.d.ts.map} +1 -1
- package/dist/postgres.d.ts +3 -3
- package/dist/postgres.js +3 -3
- package/dist/posthog/metrics.d.ts +1 -1
- package/dist/posthog/server.d.ts +2 -2
- package/dist/posthog/server.js +1 -1
- package/dist/resend.d.ts +3 -3
- package/dist/resend.js +2 -2
- package/dist/sentry/client.d.ts +1 -1
- package/dist/sentry/client.d.ts.map +1 -1
- package/dist/sentry/client.js +10 -4
- package/dist/sentry/client.js.map +1 -1
- package/dist/sentry/server.d.ts +2 -2
- package/dist/sentry/server.js +5 -5
- package/dist/sentry/server.js.map +1 -1
- package/dist/stripe/payment-service.d.ts +52 -0
- package/dist/stripe/payment-service.d.ts.map +1 -0
- package/dist/stripe/payment-service.error.d.ts +13 -0
- package/dist/stripe/payment-service.error.d.ts.map +1 -0
- package/dist/stripe/payment-service.error.js +30 -0
- package/dist/stripe/payment-service.error.js.map +1 -0
- package/dist/stripe/payment-service.js +72 -0
- package/dist/stripe/payment-service.js.map +1 -0
- package/dist/stripe/payment-webhook.d.ts +18 -0
- package/dist/stripe/payment-webhook.d.ts.map +1 -0
- package/dist/stripe/payment-webhook.js +47 -0
- package/dist/stripe/payment-webhook.js.map +1 -0
- package/dist/tanstack.d.ts +1 -1
- package/dist/tanstack.js +4 -4
- package/dist/tanstack.js.map +1 -1
- package/dist/testing/outbox-repository.d.ts +2 -2
- package/dist/testing/payment-service.d.ts +10 -0
- package/dist/testing/payment-service.d.ts.map +1 -0
- package/dist/testing/payment-service.js +76 -0
- package/dist/testing/payment-service.js.map +1 -0
- package/dist/{webhook-verification-D6aGQfNi.js → webhook-verification-BBmjkHgI.js} +2 -2
- package/dist/{webhook-verification-D6aGQfNi.js.map → webhook-verification-BBmjkHgI.js.map} +1 -1
- package/dist/{webhook-verification-BcQQG-vY.d.ts → webhook-verification-BuxPzdr4.d.ts} +2 -2
- package/dist/{webhook-verification-BcQQG-vY.d.ts.map → webhook-verification-BuxPzdr4.d.ts.map} +1 -1
- package/package.json +13 -6
- package/src/application/outbox-relay.ts +3 -1
- package/src/core/console-log-sink.ts +65 -0
- package/src/core/index.ts +1 -4
- package/src/core/logger.ts +80 -281
- package/src/infrastructure/better-auth/apple-client-secret.ts +1 -1
- package/src/infrastructure/better-auth/rate-limit.ts +3 -1
- package/src/infrastructure/billing/client.ts +173 -0
- package/src/infrastructure/cloudflare/queue/queue-consumer.ts +8 -9
- package/src/infrastructure/cloudflare/r2-client.ts +162 -0
- package/src/infrastructure/cloudflare/r2-errors.ts +111 -0
- package/src/infrastructure/cloudflare/scheduled/scheduled-handler.ts +1 -1
- package/src/infrastructure/http/webhook-handler.ts +1 -1
- package/src/infrastructure/sentry/client.ts +6 -3
- package/src/infrastructure/sentry/server.ts +4 -4
- package/src/infrastructure/stripe/payment-service.error.ts +42 -0
- package/src/infrastructure/stripe/payment-service.ts +129 -0
- package/src/infrastructure/stripe/payment-webhook.ts +49 -0
- package/src/infrastructure/tanstack/resolve-failure.ts +3 -2
- package/src/infrastructure/testing/payment-service-contract.ts +91 -0
- package/dist/core-ClSP5-V9.js.map +0 -1
- package/dist/index-DvJUcSW1.d.ts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { G as DomainMessage, Gt as AnalyticsEventIdentity, K as DomainQuery, Kt as AnalyticsEventInput, Rt as EmailIdempotencyKey, U as DomainCommand, Vt as EmailAddress, W as DomainEvent, Xt as AppError, jt as BounceType, kt as RecordEmailEventPayload, q as MessageId, qt as AnalyticsProperties } from "./index-DUFS0SJ_.js";
|
|
2
2
|
//#region src/application/handlers.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Handles one command with the dependency container and returns the caller's value.
|
|
@@ -392,4 +392,4 @@ declare class UnitOfWorkAlreadyActiveError extends AppError {
|
|
|
392
392
|
}
|
|
393
393
|
//#endregion
|
|
394
394
|
export { EventHandler as $, IOutboxRepository as A, OutboundEmail as B, UnitOfWorkDeps as C, OutboxRelay as D, IOutboxRelay as E, IEventCollector as F, MetricAttributeValue as G, ObservabilityScope as H, EmailAccepted as I, MetricsService as J, MetricAttributes as K, EmailAttachment as L, OutboxClaim as M, OutboxMessage as N, OutboxRelayOptions as O, IMessageStore as P, CommandHandler as Q, IEmailService as R, UnitOfWork as S, IOutboxPublisher as T, ObservabilityService as U, RecordingEmailService as V, ObservabilityUser as W, AnalyticsService as X, NULL_METRICS_SERVICE as Y, NULL_ANALYTICS as Z, RecordEmailEventCommand as _, OutboxRetentionResult as a, recordEmailEvent as b, CommandRegistry as c, MessageRegistry as d, QueryHandler as et, MessageResult as f, IEmailDeliverabilityStore as g, EmailBounceRecord as h, OutboxRetentionOptions as i, IOutboxRetentionRepository as j, DeadLetterReason as k, EventRegistry as l, RegistryMessage as m, MessageAlreadyProcessedError as n, IMessageBus as o, QueryRegistry as p, MetricOptions as q, OutboxRetention as r, MessageBus as s, UnitOfWorkAlreadyActiveError as t, Handlers as u, RecordEmailEventDeps as v, ITransaction as w, IUnitOfWork as x, RecordEmailEventRepos as y, MimeType as z };
|
|
395
|
-
//# sourceMappingURL=index-
|
|
395
|
+
//# sourceMappingURL=index-CYHXOH08.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-CYHXOH08.d.ts","names":[],"sources":["../src/application/handlers.ts","../src/application/analytics-service.ts","../src/application/metrics-service.ts","../src/application/observability-service.ts","../src/application/email-service.ts","../src/application/event-collector.ts","../src/application/message-store.ts","../src/application/outbox-repository.ts","../src/application/outbox-relay.ts","../src/application/transaction.ts","../src/application/unit-of-work.ts","../src/application/record-email-event.ts","../src/application/registry.ts","../src/application/message-bus.ts","../src/application/outbox-retention.ts","../src/application/message-already-processed.error.ts","../src/application/unit-of-work.errors.ts"],"mappings":";;;;;;KAMY,eAAe,iBAAiB,eAAe,MAAM,UAC/D,SAAS,UACT,MAAM,SACH,QAAQ;;;;;KAMD,aAAa,eAAe,aAAa,WAAW,UAC9D,OAAO,QACP,MAAM,cACH,QAAQ;;KAGD,aAAa,eAAe,aAAa,SACnD,OAAO,QACP,MAAM,SACH;;;;UCrBY,iBAAiB,eAAe,sBAAsB;;EAErE,SAAS,oBAAoB,aAAa;;EAE1C,MAAM,oBAAoB;;EAE1B,MAAM,OAAO,QAAQ,oBAAoB,WAAW;;EAEpD,eAAe,OAAO,QAAQ,oBAAoB,WAAW;;;cAIlD,gBAAgB;;;;KCdjB;;KAGA,mBAAmB,SAAS,eAAe;;UAGtC;WACN,aAAa;WACb;;;UAIM,eAAe;;EAE9B,MAAM,MAAM,OAAO,gBAAgB,UAAU;;EAE7C,MAAM,MAAM,OAAO,eAAe,UAAU;;EAE5C,UAAU,MAAM,OAAO,eAAe,UAAU;;;cAIrC,sBAAsB;;;;U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KAE/D,oBAAoB,UACvB,YAAY,aAAa,iBAAiB,oBAAoB,iBAC1D,WAAW,QAAQ,eAAe;;KAI5B,gBAAgB,kBAAkB,mBAC1C,YAAY,yBACZ,YAAY,wBACZ,oBAAoB;KAEnB,UAAU,QAAQ,wBAAwB,oBAAoB,SAC/D,QAAQ,WAAW,QAAQ,OAAO,QAAQ;;KAIlC,cACV,iBAAiB,eACjB,kBAAkB,mBAChB,iBAAiB,gBACjB,UAAU,uBAAuB,oBACjC,iBAAiB,cACf,UAAU,sBAAsB;;;;UCvDrB,YAAY,kBAAkB;EAC7C,OAAO,iBAAiB,gBAAgB,gBAAgB,YACtD,SAAS,WACR,QAAQ,cAAc,UAAU;;;;;;cAOxB,WAAW,MAAM,kBAAkB,SAAS,kBAAkB,YAAY;mBAElE;mBACA;EAFnB,YACmB,MAAM,MACN,UAAU;;EAIvB,OAAO,iBAAiB,gBAAgB,gBAAgB,YAC5D,SAAS,WACR,QAAQ,cAAc,UAAU;UAM3B;UASA;UASA;;;;;;UAWM;;;;;KCpEJ;WACD;WACA;WACA;WACA;WACA;;;KAIC;WACD;WACA;WACA;;;cAIE;mBAIQ;mBAHF;EAEjB,YACmB,YAAY,4BAC7B,UAAS;;EAYL,MAAM,IAAI,OAAO,QAAQ;UAcjB;;;;;cC/CH,qCAAqC;WAKrC,WAAW;WAJb;WACA;EAET,YACW,WAAW,WACpB;aAAqB;;;SAMhB,KAAK,gBAAgB,WAAW,YAAY;;;;;cCZxC,qCAAqC;WACvC;WACA;EAET"}
|
|
@@ -678,24 +678,18 @@ declare function exponentialEqualJitterMs(baseDelayMs: number, maxDelayMs: numbe
|
|
|
678
678
|
/** Capped exponential delay for a durable retry recorded in storage. */
|
|
679
679
|
declare function exponentialDelayCapMs(baseDelayMs: number, maxDelayMs: number, attempt: number): number;
|
|
680
680
|
//#endregion
|
|
681
|
+
//#region src/core/console-log-sink.d.ts
|
|
682
|
+
/** Write one structured record or one readable development entry to `console`. */
|
|
683
|
+
declare const consoleSink: LogSink;
|
|
684
|
+
//#endregion
|
|
681
685
|
//#region src/core/logger.d.ts
|
|
682
|
-
/**
|
|
683
|
-
|
|
684
|
-
*
|
|
685
|
-
* A logger emits one plain-data entry per log. The default sink hands it to `console` as an
|
|
686
|
-
* entry object for a log service or as a colored line for a person, selected at startup.
|
|
687
|
-
*/
|
|
688
|
-
/** A value a log entry may carry. Errors enter only through `Logger.error`. */
|
|
689
|
-
type LogValue = string | number | boolean | null | undefined | ReadonlyArray<LogValue> | LogFields;
|
|
690
|
-
/** Named log values. */
|
|
691
|
-
type LogFields = {
|
|
686
|
+
/** One JSON-compatible value in a normal log field. */
|
|
687
|
+
type LogValue = string | number | boolean | null | readonly LogValue[] | {
|
|
692
688
|
readonly [key: string]: LogValue;
|
|
693
689
|
};
|
|
694
|
-
/**
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
* A const object, not an enum, so a parsed environment value typed `'INFO'` is a `LogLevel`.
|
|
698
|
-
*/
|
|
690
|
+
/** Flat fields for one log call. Only `error` can contain an arbitrary value. */
|
|
691
|
+
type LogFields = Readonly<Record<string, unknown>>;
|
|
692
|
+
/** Supported log levels in ascending order. */
|
|
699
693
|
declare const LogLevel: {
|
|
700
694
|
readonly DEBUG: 'DEBUG';
|
|
701
695
|
readonly INFO: 'INFO';
|
|
@@ -703,105 +697,50 @@ declare const LogLevel: {
|
|
|
703
697
|
readonly ERROR: 'ERROR';
|
|
704
698
|
};
|
|
705
699
|
type LogLevel = (typeof LogLevel)[keyof typeof LogLevel];
|
|
706
|
-
/**
|
|
707
|
-
type
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
readonly
|
|
713
|
-
readonly
|
|
714
|
-
}
|
|
715
|
-
/** One
|
|
700
|
+
/** The minimum emitted level, or `OFF` for no console output. */
|
|
701
|
+
type LogThreshold = LogLevel | 'OFF';
|
|
702
|
+
/** Explicit output formats for production, browser development, and terminal development. */
|
|
703
|
+
type LogFormat = 'json' | 'pretty-browser' | 'pretty-terminal';
|
|
704
|
+
/** Process-wide logger settings supplied at startup. */
|
|
705
|
+
interface LoggerSettings {
|
|
706
|
+
readonly level?: LogThreshold;
|
|
707
|
+
readonly format?: LogFormat;
|
|
708
|
+
}
|
|
709
|
+
/** One structured record sent to a log sink. */
|
|
716
710
|
type LogEntry = {
|
|
717
711
|
readonly timestamp: string;
|
|
718
712
|
readonly level: LogLevel;
|
|
719
713
|
readonly module: string;
|
|
720
|
-
readonly
|
|
721
|
-
readonly
|
|
714
|
+
readonly event: string;
|
|
715
|
+
readonly attributes: LogFields;
|
|
722
716
|
readonly userId?: string;
|
|
723
|
-
/** Present on `Logger.error` entries that carried an error. */
|
|
724
|
-
readonly error?: SerializedError;
|
|
725
|
-
};
|
|
726
|
-
/** The context an error log carries. */
|
|
727
|
-
type ErrorLogContext = {
|
|
728
717
|
readonly error?: unknown;
|
|
729
|
-
readonly userId?: string;
|
|
730
|
-
readonly details?: LogFields;
|
|
731
718
|
};
|
|
732
|
-
/**
|
|
733
|
-
type LogThreshold = LogLevel | 'OFF';
|
|
734
|
-
/** Overrides the application settings for one logger. */
|
|
735
|
-
interface LoggerConfig {
|
|
736
|
-
readonly level?: LogThreshold;
|
|
737
|
-
}
|
|
738
|
-
/** `json` writes the entry object. `pretty` writes one readable line for a person. */
|
|
739
|
-
type LogFormat = 'json' | 'pretty';
|
|
740
|
-
/**
|
|
741
|
-
* The application settings, set once at the composition root.
|
|
742
|
-
*
|
|
743
|
-
* An omitted field keeps its default. An explicit `undefined` is a compile error, so the root
|
|
744
|
-
* parses an environment value before passing it. The logger reads no environment itself.
|
|
745
|
-
*/
|
|
746
|
-
interface LoggerSettings extends LoggerConfig {
|
|
747
|
-
readonly format?: LogFormat;
|
|
748
|
-
}
|
|
749
|
-
/**
|
|
750
|
-
* Set application settings, including for existing loggers. Per-logger overrides take priority.
|
|
751
|
-
* Call at startup, never per request. An omitted field resets to INFO and JSON output.
|
|
752
|
-
*/
|
|
753
|
-
declare function configureLogger(config: LoggerSettings): void;
|
|
754
|
-
/** The error data sent to the configured error hook. */
|
|
719
|
+
/** The original error and fields sent to an error service. */
|
|
755
720
|
interface ErrorCaptureEntry {
|
|
756
721
|
readonly error: unknown;
|
|
757
|
-
readonly
|
|
758
|
-
readonly
|
|
722
|
+
readonly userId: string | undefined;
|
|
723
|
+
readonly attributes: LogFields;
|
|
759
724
|
}
|
|
760
|
-
/** A function that forwards one
|
|
725
|
+
/** A function that forwards one error to an error service. */
|
|
761
726
|
type LoggerErrorHook = (entry: ErrorCaptureEntry) => void;
|
|
762
|
-
/**
|
|
727
|
+
/** A destination for structured log records. */
|
|
763
728
|
type LogSink = (entry: LogEntry) => void;
|
|
764
|
-
/**
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
/**
|
|
771
|
-
* JSON format writes the entry object. Pretty format writes one line, then the details,
|
|
772
|
-
* the error, and the stack as separate console arguments.
|
|
773
|
-
*/
|
|
774
|
-
declare const consoleSink: LogSink;
|
|
775
|
-
/**
|
|
776
|
-
* Send every log entry somewhere other than `console`.
|
|
777
|
-
*
|
|
778
|
-
* Set once at the process entry point, never per module. A logger is created
|
|
779
|
-
* by name and nothing else, so its destination is a fact about the process.
|
|
780
|
-
*/
|
|
781
|
-
declare function setLogSink(fn: LogSink): void;
|
|
782
|
-
/** Write module-scoped logs with application defaults and optional overrides. */
|
|
783
|
-
declare class Logger {
|
|
784
|
-
private readonly module;
|
|
785
|
-
private readonly config;
|
|
786
|
-
/** Create a logger for one module. */
|
|
787
|
-
constructor(module: string, overrideConfig?: LoggerConfig);
|
|
788
|
-
private log;
|
|
789
|
-
/** Write a debug log. */
|
|
790
|
-
debug(message: string, details?: LogFields): void;
|
|
791
|
-
/** Write an information log. */
|
|
792
|
-
info(message: string, details?: LogFields): void;
|
|
793
|
-
/** Write a warning log. */
|
|
794
|
-
warn(message: string, details?: LogFields): void;
|
|
795
|
-
/**
|
|
796
|
-
* Write an error log and send the error to the configured hook.
|
|
797
|
-
*
|
|
798
|
-
* The details say which call this was, and the error says what went wrong
|
|
799
|
-
* inside it. Both the entry and the error hook receive the supplied user ID.
|
|
800
|
-
*/
|
|
801
|
-
error(message: string, context?: ErrorLogContext): void;
|
|
729
|
+
/** The common flat logger API for all levels. */
|
|
730
|
+
interface Logger {
|
|
731
|
+
debug(event: string, fields?: LogFields): void;
|
|
732
|
+
info(event: string, fields?: LogFields): void;
|
|
733
|
+
warn(event: string, fields?: LogFields): void;
|
|
734
|
+
error(event: string, fields?: LogFields): void;
|
|
802
735
|
}
|
|
736
|
+
/** Set the process-wide level and output format. Omitted fields restore production defaults. */
|
|
737
|
+
declare function configureLogger(settings: LoggerSettings): void;
|
|
738
|
+
/** Set the process-wide log destination. */
|
|
739
|
+
declare function setLogSink(sink: LogSink): void;
|
|
740
|
+
/** Set or clear the process-wide error service hook. */
|
|
741
|
+
declare function setLoggerErrorHook(hook: LoggerErrorHook | null): void;
|
|
803
742
|
/** Create a logger for one module. */
|
|
804
|
-
declare function createLogger(module: string
|
|
743
|
+
declare function createLogger(module: string): Logger;
|
|
805
744
|
//#endregion
|
|
806
|
-
export {
|
|
807
|
-
//# sourceMappingURL=index-
|
|
745
|
+
export { unreachable as $, shouldRetryFailure as $t, isTransientTransportError as A, RecordEmailEventPayloadSchema as At, QueryOf as B, emailIdempotencyKey as Bt, retryAfterSecondsOf as C, InternalServerError as Ct, isCloudflareRetryableError as D, RateLimitError as Dt, isCloudflareOverloadedError as E, StaleSessionError as Et, EventOf as F, shouldUpdateBounce as Ft, DomainMessage as G, AnalyticsEventIdentity as Gt, defineMessages as H, EmailAddressSchema as Ht, MessageCollection as I, EmailSendFailureReason as It, Id as J, AnalyticsProperty as Jt, DomainQuery as K, AnalyticsEventInput as Kt, MessageDefinition as L, EmailServiceError as Lt, EntityData as M, BounceTypeSchema as Mt, CommandOf as N, isEmailDeliverable as Nt, isTransientCloudflareRuntimeError as O, AuthenticationError as Ot, DuplicateMessageNameError as P, parseBounceType as Pt, notImplemented as Q, RetryOwner as Qt, MessageOf as R, EmailIdempotencyKey as Rt, classifyFailure as S, ValidationProblemErrorSchema as St, isCloudflareObjectResetError as T, NotAuthorizedError as Tt, DomainCommand as U, AnalyticsEventId as Ut, combineMessages as V, EmailAddress as Vt, DomainEvent as W, AnalyticsEventIdSchema as Wt, IdOf as X, AppError as Xt, IdDefinition as Y, MissingConfigurationError as Yt, defineId as Z, FailureClassification as Zt, exponentialDelayCapMs as _, ProblemDetails as _t, LogLevel as a, ErrorPayloadOf as at, BoundaryErrorClassifier as b, ValidationProblemDetailsSchema as bt, LogValue as c, ResolvedError as ct, LoggerSettings as d, MalformedRequestError as dt, D1ConstraintKind as et, configureLogger as f, RequestTimeoutError as ft, consoleSink as g, ValidationIssue as gt, setLoggerErrorHook as h, ValidationError as ht, LogFormat as i, ErrorEntry as it, Entity as j, BounceType as jt, isAbortError as k, RecordEmailEventPayload as kt, Logger as l, defineErrors as lt, setLogSink as m, UpgradeRequiredError as mt, LogEntry as n, DatabaseFailure as nt, LogSink as o, ErrorTable as ot, createLogger as p, ResourceNotFoundError as pt, MessageId as q, AnalyticsProperties as qt, LogFields as r, ErrorEntries as rt, LogThreshold as s, ErrorTagOf as st, ErrorCaptureEntry as t, DatabaseError as tt, LoggerErrorHook as u, sharedErrors as ut, exponentialEqualJitterMs as v, ProblemDetailsSchema as vt, CLOUDFLARE_TRANSIENT_ERROR_PATTERNS as w, ServiceUnavailableError as wt, classifyBoundaryError as x, ValidationProblemError as xt, spreadJitterMs as y, ValidationProblemDetails as yt, PayloadSchemas as z, InvalidEmailIdempotencyKeyError as zt };
|
|
746
|
+
//# sourceMappingURL=index-DUFS0SJ_.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DUFS0SJ_.d.ts","names":[],"sources":["../src/core/failure-classification.ts","../src/core/app-error.ts","../src/core/missing-configuration.error.ts","../src/core/analytics-event.ts","../src/core/email-address.ts","../src/core/email-idempotency-key.ts","../src/core/email-service.error.ts","../src/core/email-deliverability.ts","../src/core/record-email-event.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/identity.ts","../src/core/messages.ts","../src/core/define-messages.ts","../src/core/entity.ts","../src/core/transport-classification.ts","../src/core/cloudflare-classification.ts","../src/core/classify-failure.ts","../src/core/backoff.ts","../src/core/console-log-sink.ts","../src/core/logger.ts"],"mappings":";;;;;;;;KAMY;;;;;;;KAQA;;iBAGI,mBAAmB;WACxB,gBAAgB;WAChB;WACA,OAAO;;;;;;;;;;;;uBCVI,iBAAiB;oBACnB;oBACA,gBAAgB;MAErB;;;;;cCXF,kCAAkC;WAKxB;WAJZ;WACA;;EAGT,YAAqB;;;;;UCLN,oBACf,+BACA;WAES,MAAM;WACN,YAAY;;;KAIX,4EAMC,sBACT;;UAGa;YACL,eAAe;;;cAId,wBAAsB,EAAA,KAAA,YAAA,EAAA;;KAGvB,mBAAmB,EAAE,aAAa;;UAG7B;WACN,MAAM;WACN,WAAW;;;;;cChCT,oBAAkB,EAAA,KAAA,YAAA,EAAA;;KAGnB,eAAe,EAAE,aAAa;;;;KCD9B,+BAA+B,EAAE,KAAK;;cAMrC,wCAAwC;WAI9B;WAHZ;WACA;EAET,YAAqB;;;;;;;;;iBAYP,oBAAoB,eAAe,aAAa;;;;KCvBpD;;;;;cAqBC,0BAA0B;WAC5B;WACA,gBAAgB;WAChB,QAAQ;WACR;WACA;WACA;WACA;EAET,YAAY;aACD,QAAQ;aACR;aACA;aACA;aACA;aACA;;;;;;cCrCA,kBAAgB,EAAA;;;;;;KAGjB,aAAa,EAAE,aAAa;;iBAGxB,gBAAgB,4BAA4B;;iBAY5C,mBAAmB,UAAU,YAAY,SAAS;;iBAMlD,mBAAmB,YA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BAAmB;;;;;iBAM1C,sBAAsB;WAC3B;WACA,kBAAkB;WAClB;IACP;;;;;iBAwBY,gBAAgB,iBAAiB;;iBAUjC,oBAAoB;;;;iBCrDpB,eAAe;;;;;iBAWf,yBACd,qBACA,oBACA;;iBAOc,sBACd,qBACA,oBACA;;;;cCUW,aAAa;;;;KClCd,uDAKC;YACG,cAAc;;;KAIlB,YAAY,SAAS;;cAGpB;WACX;WACA;WACA;WACA;;KAEU,mBAAmB,uBAAuB;;KAG1C,eAAe;;KAGf;;UAGK;WACN,QAAQ;WACR,SAAS;;;KAIR;WACD;WACA,OAAO;WACP;WACA;WAEA,YAAY;WACZ;WACA;;;UAIM;WACN;WACA;WAEA,YAAY;;;KAIX,mBAAmB,OAAO;;KAG1B,WAAW,OAAO;;UAGb;EACf,MAAM,eAAe,SAAS;EAC9B,KAAK,eAAe,SAAS;EAC7B,KAAK,eAAe,SAAS;EAC7B,MAAM,eAAe,SAAS;;;iBAShB,gBAAgB,UAAU;;iBAM1B,WAAW,MAAM;;iBAKjB,mBAAmB,MAAM;;iBA0BzB,aAAa,iBAAiB"}
|
package/dist/{outbox-repository-options-ICOF8g2h.js → outbox-repository-options-CgdqU20T.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as UnitOfWorkAlreadyActiveError } from "./application-
|
|
1
|
+
import { t as UnitOfWorkAlreadyActiveError } from "./application-CNdzHIXk.js";
|
|
2
2
|
import { panic } from "better-result";
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
|
|
@@ -54,4 +54,4 @@ const OUTBOX_REPOSITORY_DEFAULTS = {
|
|
|
54
54
|
|
|
55
55
|
//#endregion
|
|
56
56
|
export { stageD1Statement as a, runWithUnitOfWorkContext as i, collectD1Statements as n, eventCollector as r, OUTBOX_REPOSITORY_DEFAULTS as t };
|
|
57
|
-
//# sourceMappingURL=outbox-repository-options-
|
|
57
|
+
//# sourceMappingURL=outbox-repository-options-CgdqU20T.js.map
|
package/dist/{outbox-repository-options-ICOF8g2h.js.map → outbox-repository-options-CgdqU20T.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outbox-repository-options-
|
|
1
|
+
{"version":3,"file":"outbox-repository-options-CgdqU20T.js","names":[],"sources":["../src/infrastructure/unit-of-work-context.ts","../src/infrastructure/outbox-repository-options.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks'\n\nimport { panic } from 'better-result'\nimport type { BatchItem } from 'drizzle-orm/batch'\n\nimport { UnitOfWorkAlreadyActiveError, type IEventCollector } from '@/application'\nimport type { DomainEvent } from '@/core'\n\ntype UnitOfWorkContext = { readonly events: DomainEvent[] } & (\n | { readonly database: 'd1'; readonly statements: BatchItem<'sqlite'>[] }\n | { readonly database: 'postgres' }\n)\n\n// One async scope isolates events and D1 statements and rejects nesting across both adapters.\nconst storage = new AsyncLocalStorage<UnitOfWorkContext>()\n\n/** Reject nested transactions before database work starts; preserve independent concurrent execution. */\nexport async function runWithUnitOfWorkContext<T>(\n database: UnitOfWorkContext['database'],\n work: () => Promise<T>,\n): Promise<T> {\n if (storage.getStore() !== undefined) throw new UnitOfWorkAlreadyActiveError()\n const context: UnitOfWorkContext =\n database === 'd1' ? { database, events: [], statements: [] } : { database, events: [] }\n return storage.run(context, work)\n}\n\n/** Inject this shared scope into the unit of work and expose its emitter to application handlers. */\nexport const eventCollector: IEventCollector = {\n emit(event) {\n currentContext().events.push(event)\n },\n collect() {\n return [...currentContext().events]\n },\n}\n\n/** Queue one native D1 statement for the active batch; other contexts cannot accept D1 writes. */\nexport function stageD1Statement(statement: BatchItem<'sqlite'>): void {\n d1Context().statements.push(statement)\n}\n\n/** Read the active D1 batch in staging order for commit. */\nexport function collectD1Statements(): ReadonlyArray<BatchItem<'sqlite'>> {\n return [...d1Context().statements]\n}\n\nfunction d1Context(): Extract<UnitOfWorkContext, { database: 'd1' }> {\n const context = currentContext()\n if (context.database !== 'd1') return panic('D1 statements require a D1 unit of work')\n return context\n}\n\nfunction currentContext(): UnitOfWorkContext {\n return storage.getStore() ?? panic('operation requires an active unit of work')\n}\n","/** Shared lease and delay defaults for both database adapters. */\nexport const OUTBOX_REPOSITORY_DEFAULTS = {\n leaseMs: 60_000,\n retryBaseDelayMs: 1_000,\n retryMaxDelayMs: 60_000,\n}\n\n/** Override lease and delay limits at the composition root. */\nexport type OutboxRepositoryOptions = Readonly<Partial<typeof OUTBOX_REPOSITORY_DEFAULTS>>\n"],"mappings":";;;;;AAcA,MAAM,UAAU,IAAI,kBAAqC;;AAGzD,eAAsB,yBACpB,UACA,MACY;CACZ,IAAI,QAAQ,SAAS,MAAM,QAAW,MAAM,IAAI,6BAA6B;CAC7E,MAAM,UACJ,aAAa,OAAO;EAAE;EAAU,QAAQ,CAAC;EAAG,YAAY,CAAC;CAAE,IAAI;EAAE;EAAU,QAAQ,CAAC;CAAE;CACxF,OAAO,QAAQ,IAAI,SAAS,IAAI;AAClC;;AAGA,MAAa,iBAAkC;CAC7C,KAAK,OAAO;EACV,eAAe,CAAC,CAAC,OAAO,KAAK,KAAK;CACpC;CACA,UAAU;EACR,OAAO,CAAC,GAAG,eAAe,CAAC,CAAC,MAAM;CACpC;AACF;;AAGA,SAAgB,iBAAiB,WAAsC;CACrE,UAAU,CAAC,CAAC,WAAW,KAAK,SAAS;AACvC;;AAGA,SAAgB,sBAA0D;CACxE,OAAO,CAAC,GAAG,UAAU,CAAC,CAAC,UAAU;AACnC;AAEA,SAAS,YAA4D;CACnE,MAAM,UAAU,eAAe;CAC/B,IAAI,QAAQ,aAAa,MAAM,OAAO,MAAM,yCAAyC;CACrF,OAAO;AACT;AAEA,SAAS,iBAAoC;CAC3C,OAAO,QAAQ,SAAS,KAAK,MAAM,2CAA2C;AAChF;;;;;ACtDA,MAAa,6BAA6B;CACxC,SAAS;CACT,kBAAkB;CAClB,iBAAiB;AACnB"}
|
package/dist/{outbox-repository-options-AkihEaik.d.ts → outbox-repository-options-DjBgFhMi.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { F as IEventCollector } from "./index-
|
|
1
|
+
import "./index-DUFS0SJ_.js";
|
|
2
|
+
import { F as IEventCollector } from "./index-CYHXOH08.js";
|
|
3
3
|
import { BatchItem } from "drizzle-orm/batch";
|
|
4
4
|
//#region src/infrastructure/drizzle-schema.d.ts
|
|
5
5
|
/**
|
|
@@ -23,4 +23,4 @@ declare const OUTBOX_REPOSITORY_DEFAULTS: {
|
|
|
23
23
|
type OutboxRepositoryOptions = Readonly<Partial<typeof OUTBOX_REPOSITORY_DEFAULTS>>;
|
|
24
24
|
//#endregion
|
|
25
25
|
export { eventCollector as n, DrizzleSchema as r, OutboxRepositoryOptions as t };
|
|
26
|
-
//# sourceMappingURL=outbox-repository-options-
|
|
26
|
+
//# sourceMappingURL=outbox-repository-options-DjBgFhMi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outbox-repository-options-
|
|
1
|
+
{"version":3,"file":"outbox-repository-options-DjBgFhMi.d.ts","names":[],"sources":["../src/infrastructure/drizzle-schema.ts","../src/infrastructure/unit-of-work-context.ts","../src/infrastructure/outbox-repository-options.ts"],"mappings":";;;;;;;;KAKY,gBAAgB;;;;cCuBf,gBAAgB;;;;cC3BhB;EACX;EACA;EACA;;;KAIU,0BAA0B,SAAS,eAAe"}
|
package/dist/postgres.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A as IOutboxRepository, M as OutboxClaim, N as OutboxMessage, P as IMessageStore, k as DeadLetterReason, w as ITransaction } from "./index-
|
|
3
|
-
import { n as eventCollector, r as DrizzleSchema, t as OutboxRepositoryOptions } from "./outbox-repository-options-
|
|
1
|
+
import { W as DomainEvent, 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-CYHXOH08.js";
|
|
3
|
+
import { n as eventCollector, r as DrizzleSchema, t as OutboxRepositoryOptions } from "./outbox-repository-options-DjBgFhMi.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 {
|
|
2
|
-
import { o as MessageAlreadyProcessedError } from "./application-
|
|
3
|
-
import { i as runWithUnitOfWorkContext, r as eventCollector, t as OUTBOX_REPOSITORY_DEFAULTS } from "./outbox-repository-options-
|
|
1
|
+
import { O as DatabaseError, nt as AppError, s as exponentialDelayCapMs } from "./core-UUW2unJd.js";
|
|
2
|
+
import { o as MessageAlreadyProcessedError } from "./application-CNdzHIXk.js";
|
|
3
|
+
import { i as runWithUnitOfWorkContext, r as eventCollector, t as OUTBOX_REPOSITORY_DEFAULTS } from "./outbox-repository-options-CgdqU20T.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";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { J as MetricsService, q as MetricOptions } from "../index-
|
|
1
|
+
import { J as MetricsService, q as MetricOptions } from "../index-CYHXOH08.js";
|
|
2
2
|
import { PostHog } from "posthog-node";
|
|
3
3
|
//#region src/infrastructure/posthog/metrics.d.ts
|
|
4
4
|
/** PostHog Metrics with Worker lifetime management, ported from Typist's metrics-service.ts. */
|
package/dist/posthog/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { X as AnalyticsService } from "../index-
|
|
1
|
+
import { Gt as AnalyticsEventIdentity, Kt as AnalyticsEventInput, qt as AnalyticsProperties } from "../index-DUFS0SJ_.js";
|
|
2
|
+
import { X as AnalyticsService } from "../index-CYHXOH08.js";
|
|
3
3
|
import { PostHogMetricsService } from "./metrics.js";
|
|
4
4
|
import { PostHog, PostHogOptions } from "posthog-node";
|
|
5
5
|
//#region src/infrastructure/posthog/server.d.ts
|
package/dist/posthog/server.js
CHANGED
package/dist/resend.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { B as OutboundEmail, I as EmailAccepted, R as IEmailService } from "./index-
|
|
3
|
-
import { r as WebhookVerifier, t as WebhookVerification } from "./webhook-verification-
|
|
1
|
+
import { jt as BounceType } from "./index-DUFS0SJ_.js";
|
|
2
|
+
import { B as OutboundEmail, I as EmailAccepted, R as IEmailService } from "./index-CYHXOH08.js";
|
|
3
|
+
import { r as WebhookVerifier, t as WebhookVerification } from "./webhook-verification-BuxPzdr4.js";
|
|
4
4
|
import { Resend } from "resend";
|
|
5
5
|
//#region src/infrastructure/resend/resend-email-service.d.ts
|
|
6
6
|
/** The SDK operations required by the adapter; a test factory can return a plain object. */
|
package/dist/resend.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as WebhookVerificationError } from "./webhook-verification-
|
|
1
|
+
import { $ as EmailAddressSchema, J as parseBounceType, X as EmailServiceError } from "./core-UUW2unJd.js";
|
|
2
|
+
import { t as WebhookVerificationError } from "./webhook-verification-BBmjkHgI.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { Buffer } from "node:buffer";
|
|
5
5
|
|
package/dist/sentry/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { u as LoggerErrorHook } from "../index-DUFS0SJ_.js";
|
|
2
2
|
import * as Sentry from "@sentry/tanstackstart-react";
|
|
3
3
|
//#region src/infrastructure/sentry/client.d.ts
|
|
4
4
|
/** Application settings use Sentry's names; enablement and environment belong to the application. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","names":[],"sources":["../../src/infrastructure/sentry/client.ts"],"mappings":";;;;YAMY,sBAAsB,OAAO;WAC9B;WACA;WACA;;;wBAIK,0BAA0B,SAAS,sBAAsB,OAAO;;wBAehE,+BAA+B;;
|
|
1
|
+
{"version":3,"file":"client.d.ts","names":[],"sources":["../../src/infrastructure/sentry/client.ts"],"mappings":";;;;YAMY,sBAAsB,OAAO;WAC9B;WACA;WACA;;;wBAIK,0BAA0B,SAAS,sBAAsB,OAAO;;wBAehE,+BAA+B;;wBAY/B,iBAAiB,SAAS,sBAAsB,kBAAkB,OAAO;;wBAOzE,uBACd,QAAQ,kBAAkB,OAAO;;qBAOtB,sBAAsB,OAAO"}
|
package/dist/sentry/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as setLoggerErrorHook } from "../core-UUW2unJd.js";
|
|
2
2
|
import * as Sentry from "@sentry/tanstackstart-react";
|
|
3
3
|
import { isNotFound, isRedirect } from "@tanstack/react-router";
|
|
4
4
|
|
|
@@ -23,10 +23,16 @@ function createSentryClientOptions(options) {
|
|
|
23
23
|
}
|
|
24
24
|
/** Forward logged browser errors once, excluding TanStack navigation control flow. */
|
|
25
25
|
function createSentryLoggerErrorHook() {
|
|
26
|
-
return ({ error,
|
|
26
|
+
return ({ error, userId, attributes }) => {
|
|
27
27
|
if (isNotFound(error) || isRedirect(error)) return;
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
if (userId !== void 0) {
|
|
29
|
+
Sentry.captureException(error, {
|
|
30
|
+
extra: attributes,
|
|
31
|
+
user: { id: userId }
|
|
32
|
+
});
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
Sentry.captureException(error, { extra: attributes });
|
|
30
36
|
};
|
|
31
37
|
}
|
|
32
38
|
/** Initialize once in the browser entrypoint before hydration; server imports have no side effects. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":[],"sources":["../../src/infrastructure/sentry/client.ts"],"sourcesContent":["import * as Sentry from '@sentry/tanstackstart-react'\nimport { isNotFound, isRedirect } from '@tanstack/react-router'\n\nimport { setLoggerErrorHook, type LoggerErrorHook } from '@/core'\n\n/** Application settings use Sentry's names; enablement and environment belong to the application. */\nexport type SentryClientOptions = Sentry.BrowserOptions & {\n readonly dsn: string\n readonly environment: string\n readonly enabled: boolean\n}\n\n/** Privacy defaults from Porte and browser noise filtering from Typist; explicit SDK options take precedence. */\nexport function createSentryClientOptions(options: SentryClientOptions): Sentry.BrowserOptions {\n return {\n enableLogs: true,\n ignoreErrors: [/Failed to execute '(insertBefore|removeChild)' on 'Node'/],\n ...options,\n dataCollection: {\n userInfo: false,\n httpBodies: [],\n ...options.dataCollection,\n genAI: { inputs: false, outputs: false, ...options.dataCollection?.genAI },\n },\n }\n}\n\n/** Forward logged browser errors once, excluding TanStack navigation control flow. */\nexport function createSentryLoggerErrorHook(): LoggerErrorHook {\n return ({ error,
|
|
1
|
+
{"version":3,"file":"client.js","names":[],"sources":["../../src/infrastructure/sentry/client.ts"],"sourcesContent":["import * as Sentry from '@sentry/tanstackstart-react'\nimport { isNotFound, isRedirect } from '@tanstack/react-router'\n\nimport { setLoggerErrorHook, type LoggerErrorHook } from '@/core'\n\n/** Application settings use Sentry's names; enablement and environment belong to the application. */\nexport type SentryClientOptions = Sentry.BrowserOptions & {\n readonly dsn: string\n readonly environment: string\n readonly enabled: boolean\n}\n\n/** Privacy defaults from Porte and browser noise filtering from Typist; explicit SDK options take precedence. */\nexport function createSentryClientOptions(options: SentryClientOptions): Sentry.BrowserOptions {\n return {\n enableLogs: true,\n ignoreErrors: [/Failed to execute '(insertBefore|removeChild)' on 'Node'/],\n ...options,\n dataCollection: {\n userInfo: false,\n httpBodies: [],\n ...options.dataCollection,\n genAI: { inputs: false, outputs: false, ...options.dataCollection?.genAI },\n },\n }\n}\n\n/** Forward logged browser errors once, excluding TanStack navigation control flow. */\nexport function createSentryLoggerErrorHook(): LoggerErrorHook {\n return ({ error, userId, attributes }) => {\n if (isNotFound(error) || isRedirect(error)) return\n if (userId !== undefined) {\n Sentry.captureException(error, { extra: attributes, user: { id: userId } })\n return\n }\n Sentry.captureException(error, { extra: attributes })\n }\n}\n\n/** Initialize once in the browser entrypoint before hydration; server imports have no side effects. */\nexport function initializeSentry(options: SentryClientOptions): ReturnType<typeof Sentry.init> {\n const client = Sentry.init(createSentryClientOptions(options))\n setLoggerErrorHook(createSentryLoggerErrorHook())\n return client\n}\n\n/** Attach tracing once after creating the browser router, as Porte does in getRouter. */\nexport function instrumentSentryRouter(\n router: Parameters<typeof Sentry.tanstackRouterBrowserTracingIntegration>[0],\n): void {\n if (router.isServer) return\n Sentry.addIntegration(Sentry.tanstackRouterBrowserTracingIntegration(router))\n}\n\n/** The SDK error boundary; the application supplies its fallback component. */\nexport const ErrorBoundary: typeof Sentry.ErrorBoundary = Sentry.ErrorBoundary\n\nexport { Sentry }\n"],"mappings":";;;;;;AAaA,SAAgB,0BAA0B,SAAqD;CAC7F,OAAO;EACL,YAAY;EACZ,cAAc,CAAC,0DAA0D;EACzE,GAAG;EACH,gBAAgB;GACd,UAAU;GACV,YAAY,CAAC;GACb,GAAG,QAAQ;GACX,OAAO;IAAE,QAAQ;IAAO,SAAS;IAAO,GAAG,QAAQ,gBAAgB;GAAM;EAC3E;CACF;AACF;;AAGA,SAAgB,8BAA+C;CAC7D,QAAQ,EAAE,OAAO,QAAQ,iBAAiB;EACxC,IAAI,WAAW,KAAK,KAAK,WAAW,KAAK,GAAG;EAC5C,IAAI,WAAW,QAAW;GACxB,OAAO,iBAAiB,OAAO;IAAE,OAAO;IAAY,MAAM,EAAE,IAAI,OAAO;GAAE,CAAC;GAC1E;EACF;EACA,OAAO,iBAAiB,OAAO,EAAE,OAAO,WAAW,CAAC;CACtD;AACF;;AAGA,SAAgB,iBAAiB,SAA8D;CAC7F,MAAM,SAAS,OAAO,KAAK,0BAA0B,OAAO,CAAC;CAC7D,mBAAmB,4BAA4B,CAAC;CAChD,OAAO;AACT;;AAGA,SAAgB,uBACd,QACM;CACN,IAAI,OAAO,UAAU;CACrB,OAAO,eAAe,OAAO,wCAAwC,MAAM,CAAC;AAC9E;;AAGA,MAAa,gBAA6C,OAAO"}
|
package/dist/sentry/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { H as ObservabilityScope, U as ObservabilityService, W as ObservabilityUser } from "../index-
|
|
1
|
+
import { u as LoggerErrorHook } from "../index-DUFS0SJ_.js";
|
|
2
|
+
import { H as ObservabilityScope, U as ObservabilityService, W as ObservabilityUser } from "../index-CYHXOH08.js";
|
|
3
3
|
import * as Sentry from "@sentry/cloudflare";
|
|
4
4
|
//#region src/infrastructure/sentry/server.d.ts
|
|
5
5
|
/** Application-owned deployment settings with the full Cloudflare SDK option contract. */
|
package/dist/sentry/server.js
CHANGED
|
@@ -20,15 +20,15 @@ function createSentryOptions(options) {
|
|
|
20
20
|
}
|
|
21
21
|
/** Register with setLoggerErrorHook once at startup; an explicit user applies only to this report. */
|
|
22
22
|
function createSentryLoggerErrorHook() {
|
|
23
|
-
return ({ error,
|
|
24
|
-
if (
|
|
23
|
+
return ({ error, userId, attributes }) => {
|
|
24
|
+
if (userId !== void 0) {
|
|
25
25
|
Sentry.captureException(error, {
|
|
26
|
-
extra:
|
|
27
|
-
user: { id:
|
|
26
|
+
extra: attributes,
|
|
27
|
+
user: { id: userId }
|
|
28
28
|
});
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
Sentry.captureException(error, { extra:
|
|
31
|
+
Sentry.captureException(error, { extra: attributes });
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
/** Identity and scope adapter from Typist and Porte; call inside Sentry's instrumented runtime. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","names":[],"sources":["../../src/infrastructure/sentry/server.ts"],"sourcesContent":["import * as Sentry from '@sentry/cloudflare'\n\nimport type { ObservabilityScope, ObservabilityService, ObservabilityUser } from '@/application'\nimport type { LoggerErrorHook } from '@/core'\n\n/** Application-owned deployment settings with the full Cloudflare SDK option contract. */\nexport type SentryServerOptions = Sentry.CloudflareOptions & {\n readonly dsn: string\n readonly environment: string\n readonly enabled: boolean\n}\n\n/** Options for Workers, Durable Objects, and Workflows, ported from Typist and Porte. */\nexport function createSentryOptions(options: SentryServerOptions): Sentry.CloudflareOptions {\n return {\n enableLogs: true,\n ...options,\n dataCollection: {\n userInfo: false,\n httpBodies: [],\n ...options.dataCollection,\n genAI: { inputs: false, outputs: false, ...options.dataCollection?.genAI },\n },\n }\n}\n\n/** Register with setLoggerErrorHook once at startup; an explicit user applies only to this report. */\nexport function createSentryLoggerErrorHook(): LoggerErrorHook {\n return ({ error,
|
|
1
|
+
{"version":3,"file":"server.js","names":[],"sources":["../../src/infrastructure/sentry/server.ts"],"sourcesContent":["import * as Sentry from '@sentry/cloudflare'\n\nimport type { ObservabilityScope, ObservabilityService, ObservabilityUser } from '@/application'\nimport type { LoggerErrorHook } from '@/core'\n\n/** Application-owned deployment settings with the full Cloudflare SDK option contract. */\nexport type SentryServerOptions = Sentry.CloudflareOptions & {\n readonly dsn: string\n readonly environment: string\n readonly enabled: boolean\n}\n\n/** Options for Workers, Durable Objects, and Workflows, ported from Typist and Porte. */\nexport function createSentryOptions(options: SentryServerOptions): Sentry.CloudflareOptions {\n return {\n enableLogs: true,\n ...options,\n dataCollection: {\n userInfo: false,\n httpBodies: [],\n ...options.dataCollection,\n genAI: { inputs: false, outputs: false, ...options.dataCollection?.genAI },\n },\n }\n}\n\n/** Register with setLoggerErrorHook once at startup; an explicit user applies only to this report. */\nexport function createSentryLoggerErrorHook(): LoggerErrorHook {\n return ({ error, userId, attributes }) => {\n if (userId !== undefined) {\n Sentry.captureException(error, { extra: attributes, user: { id: userId } })\n return\n }\n Sentry.captureException(error, { extra: attributes })\n }\n}\n\n/** Identity and scope adapter from Typist and Porte; call inside Sentry's instrumented runtime. */\nexport class SentryObservabilityService implements ObservabilityService {\n /** Attribute subsequent reports in the current isolation scope. */\n setUser(user: ObservabilityUser): void {\n Sentry.setUser(user)\n }\n\n /** Await work in a separate scope for each queue message or concurrent operation. */\n async withIsolationScope<T>(callback: (scope: ObservabilityScope) => T | Promise<T>): Promise<T> {\n return await Sentry.withIsolationScope(callback)\n }\n}\n\nexport { Sentry }\n"],"mappings":";;;;AAaA,SAAgB,oBAAoB,SAAwD;CAC1F,OAAO;EACL,YAAY;EACZ,GAAG;EACH,gBAAgB;GACd,UAAU;GACV,YAAY,CAAC;GACb,GAAG,QAAQ;GACX,OAAO;IAAE,QAAQ;IAAO,SAAS;IAAO,GAAG,QAAQ,gBAAgB;GAAM;EAC3E;CACF;AACF;;AAGA,SAAgB,8BAA+C;CAC7D,QAAQ,EAAE,OAAO,QAAQ,iBAAiB;EACxC,IAAI,WAAW,QAAW;GACxB,OAAO,iBAAiB,OAAO;IAAE,OAAO;IAAY,MAAM,EAAE,IAAI,OAAO;GAAE,CAAC;GAC1E;EACF;EACA,OAAO,iBAAiB,OAAO,EAAE,OAAO,WAAW,CAAC;CACtD;AACF;;AAGA,IAAa,6BAAb,MAAwE;;CAEtE,QAAQ,MAA+B;EACrC,OAAO,QAAQ,IAAI;CACrB;;CAGA,MAAM,mBAAsB,UAAqE;EAC/F,OAAO,MAAM,OAAO,mBAAmB,QAAQ;CACjD;AACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import Stripe from "stripe";
|
|
2
|
+
//#region src/infrastructure/stripe/payment-service.d.ts
|
|
3
|
+
/** Supply the same key and parameters when repeating one durable payment attempt. */
|
|
4
|
+
export type PaymentRequestOptions = Stripe.RequestOptions & Required<Pick<Stripe.RequestOptions, 'idempotencyKey'>>;
|
|
5
|
+
/** Native Checkout parameters; the service selects payment or setup mode. */
|
|
6
|
+
export type CheckoutInput = Omit<Stripe.Checkout.SessionCreateParams, 'mode'>;
|
|
7
|
+
/** A saved customer method; the service confirms the payment off-session. */
|
|
8
|
+
export type SavedMethodCharge = Omit<Stripe.PaymentIntentCreateParams, 'confirm' | 'off_session'> & Required<Pick<Stripe.PaymentIntentCreateParams, 'customer' | 'payment_method'>>;
|
|
9
|
+
/** Native customer response, including Stripe request metadata. */
|
|
10
|
+
export type CustomerResult = Awaited<ReturnType<Stripe['customers']['create']>>;
|
|
11
|
+
/** Native Checkout response. Its URL can be null; this does not confirm payment. */
|
|
12
|
+
export type CheckoutResult = Awaited<ReturnType<Stripe['checkout']['sessions']['create']>>;
|
|
13
|
+
/** Native PaymentIntent response. Applications decide what each status permits. */
|
|
14
|
+
export type PaymentResult = Awaited<ReturnType<Stripe['paymentIntents']['create']>>;
|
|
15
|
+
/**
|
|
16
|
+
* Stripe payment operations, with native types and stable keys for mutations.
|
|
17
|
+
* Rejects with PaymentServiceError or native StripeCardError; unexpected defects propagate.
|
|
18
|
+
*/
|
|
19
|
+
export interface IPaymentService {
|
|
20
|
+
/** Create a customer; the application owns persistence and reuse of the customer link. */
|
|
21
|
+
createCustomer(input: Stripe.CustomerCreateParams, options: PaymentRequestOptions): Promise<CustomerResult>;
|
|
22
|
+
/** Create one-time payment checkout; application fulfillment requires verified payment confirmation. */
|
|
23
|
+
createCheckout(input: CheckoutInput, options: PaymentRequestOptions): Promise<CheckoutResult>;
|
|
24
|
+
/** Create checkout in setup mode. The application records consent and verifies the saved method's owner. */
|
|
25
|
+
setupPaymentMethod(input: CheckoutInput, options: PaymentRequestOptions): Promise<CheckoutResult>;
|
|
26
|
+
/** Confirm a saved method off-session. Native card errors can require customer authentication. */
|
|
27
|
+
chargeSavedMethod(input: SavedMethodCharge, options: PaymentRequestOptions): Promise<PaymentResult>;
|
|
28
|
+
/** Retrieve an existing payment without starting another payment attempt. */
|
|
29
|
+
getPayment(paymentId: string, params?: Stripe.PaymentIntentRetrieveParams, options?: Stripe.RequestOptions): Promise<PaymentResult>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Ported from Typist's StripeClient request boundary; the native SDK now owns retries.
|
|
33
|
+
* Each request defaults to two SDK retries. Native request options can override retries and timeout.
|
|
34
|
+
*/
|
|
35
|
+
export declare class StripePaymentService implements IPaymentService {
|
|
36
|
+
private readonly stripe;
|
|
37
|
+
/** Inject a native SDK instance; its transport, credentials, and API version remain caller-owned. */
|
|
38
|
+
constructor(stripe: Stripe);
|
|
39
|
+
/** Create a customer with a stable application key and preserve the native response. */
|
|
40
|
+
createCustomer(input: Stripe.CustomerCreateParams, options: PaymentRequestOptions): Promise<CustomerResult>;
|
|
41
|
+
/** Force payment mode after caller parameters; return the native Checkout Session. */
|
|
42
|
+
createCheckout(input: CheckoutInput, options: PaymentRequestOptions): Promise<CheckoutResult>;
|
|
43
|
+
/** Force setup mode after caller parameters; this operation does not charge the customer. */
|
|
44
|
+
setupPaymentMethod(input: CheckoutInput, options: PaymentRequestOptions): Promise<CheckoutResult>;
|
|
45
|
+
/** Force confirmation and off-session use; preserve native card failures for application handling. */
|
|
46
|
+
chargeSavedMethod(input: SavedMethodCharge, options: PaymentRequestOptions): Promise<PaymentResult>;
|
|
47
|
+
/** Preserve every native status and response field when reconciling an existing payment. */
|
|
48
|
+
getPayment(paymentId: string, params?: Stripe.PaymentIntentRetrieveParams, options?: Stripe.RequestOptions): Promise<PaymentResult>;
|
|
49
|
+
private request;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//# sourceMappingURL=payment-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-service.d.ts","names":[],"sources":["../../src/infrastructure/stripe/payment-service.ts"],"mappings":";;;YAKY,wBAAwB,OAAO,iBACzC,SAAS,KAAK,OAAO;;YAGX,gBAAgB,KAAK,OAAO,SAAS;;YAGrC,oBAAoB,KAAK,OAAO,wDAC1C,SAAS,KAAK,OAAO;;YAGX,iBAAiB,QAAQ,WAAW;;YAGpC,iBAAiB,QAAQ,WAAW;;YAGpC,gBAAgB,QAAQ,WAAW;;;;;iBAM9B;;EAEf,eACE,OAAO,OAAO,sBACd,SAAS,wBACR,QAAQ;;EAEX,eAAe,OAAO,eAAe,SAAS,wBAAwB,QAAQ;;EAE9E,mBAAmB,OAAO,eAAe,SAAS,wBAAwB,QAAQ;;EAElF,kBACE,OAAO,mBACP,SAAS,wBACR,QAAQ;;EAEX,WACE,mBACA,SAAS,OAAO,6BAChB,UAAU,OAAO,iBAChB,QAAQ;;;;;;qBAOA,gCAAgC;mBAEd;;EAA7B,YAA6B,QAAQ;;EAGrC,eACE,OAAO,OAAO,sBACd,SAAS,wBACR,QAAQ;;EAOX,eAAe,OAAO,eAAe,SAAS,wBAAwB,QAAQ;;EAU9E,mBACE,OAAO,eACP,SAAS,wBACR,QAAQ;;EAUX,kBACE,OAAO,mBACP,SAAS,wBACR,QAAQ;;EAUX,WACE,mBACA,SAAS,OAAO,6BAChB,UAAU,OAAO,iBAChB,QAAQ;UAMG"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Xt as AppError, Zt as FailureClassification } from "../index-DUFS0SJ_.js";
|
|
2
|
+
import Stripe from "stripe";
|
|
3
|
+
//#region src/infrastructure/stripe/payment-service.error.d.ts
|
|
4
|
+
/** A final Stripe request failure. The caller logs once; native details remain in cause. */
|
|
5
|
+
export declare class PaymentServiceError extends AppError {
|
|
6
|
+
readonly operation: string;
|
|
7
|
+
readonly _tag = "PaymentServiceError";
|
|
8
|
+
readonly classification: FailureClassification;
|
|
9
|
+
/** Classify the final SDK error without scheduling another payment attempt. */
|
|
10
|
+
constructor(operation: string, cause: Stripe.errors.StripeError);
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
//# sourceMappingURL=payment-service.error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-service.error.d.ts","names":[],"sources":["../../src/infrastructure/stripe/payment-service.error.ts"],"mappings":";;;;qBAKa,4BAA4B;WAM5B;WALF;WACA,gBAAgB;;EAGzB,YACW,mBACT,OAAO,OAAO,OAAO"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { nt as AppError } from "../core-UUW2unJd.js";
|
|
2
|
+
import Stripe from "stripe";
|
|
3
|
+
|
|
4
|
+
//#region src/infrastructure/stripe/payment-service.error.ts
|
|
5
|
+
/** A final Stripe request failure. The caller logs once; native details remain in cause. */
|
|
6
|
+
var PaymentServiceError = class extends AppError {
|
|
7
|
+
operation;
|
|
8
|
+
_tag = "PaymentServiceError";
|
|
9
|
+
classification;
|
|
10
|
+
/** Classify the final SDK error without scheduling another payment attempt. */
|
|
11
|
+
constructor(operation, cause) {
|
|
12
|
+
super(`Stripe request failed: ${operation}`, { cause });
|
|
13
|
+
this.operation = operation;
|
|
14
|
+
this.classification = classifyStripeError(cause);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
function classifyStripeError(error) {
|
|
18
|
+
if (error.headers?.["stripe-should-retry"] === "false") return "terminal";
|
|
19
|
+
const status = error.statusCode;
|
|
20
|
+
if (status !== void 0 && status >= 400 && status < 500 && status !== 409 && status !== 429) return "terminal";
|
|
21
|
+
if (error instanceof Stripe.errors.StripeAuthenticationError || error instanceof Stripe.errors.StripePermissionError || error instanceof Stripe.errors.StripeInvalidRequestError || error instanceof Stripe.errors.StripeIdempotencyError) return "terminal";
|
|
22
|
+
if (error.headers?.["stripe-should-retry"] === "true") return "transient";
|
|
23
|
+
if (status === 409 || status === 429 || status !== void 0 && status >= 500) return "transient";
|
|
24
|
+
if (error instanceof Stripe.errors.StripeConnectionError || error instanceof Stripe.errors.StripeAPIError || error instanceof Stripe.errors.StripeRateLimitError) return "transient";
|
|
25
|
+
return "unknown";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { PaymentServiceError };
|
|
30
|
+
//# sourceMappingURL=payment-service.error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-service.error.js","names":[],"sources":["../../src/infrastructure/stripe/payment-service.error.ts"],"sourcesContent":["import Stripe from 'stripe'\n\nimport { AppError, type FailureClassification } from '@/core'\n\n/** A final Stripe request failure. The caller logs once; native details remain in cause. */\nexport class PaymentServiceError extends AppError {\n readonly _tag = 'PaymentServiceError'\n readonly classification: FailureClassification\n\n /** Classify the final SDK error without scheduling another payment attempt. */\n constructor(\n readonly operation: string,\n cause: Stripe.errors.StripeError,\n ) {\n super(`Stripe request failed: ${operation}`, { cause })\n this.classification = classifyStripeError(cause)\n }\n}\n\nfunction classifyStripeError(error: Stripe.errors.StripeError): FailureClassification {\n if (error.headers?.['stripe-should-retry'] === 'false') return 'terminal'\n const status = error.statusCode\n if (status !== undefined && status >= 400 && status < 500 && status !== 409 && status !== 429)\n return 'terminal'\n if (\n error instanceof Stripe.errors.StripeAuthenticationError ||\n error instanceof Stripe.errors.StripePermissionError ||\n error instanceof Stripe.errors.StripeInvalidRequestError ||\n error instanceof Stripe.errors.StripeIdempotencyError\n )\n return 'terminal'\n if (error.headers?.['stripe-should-retry'] === 'true') return 'transient'\n if (status === 409 || status === 429 || (status !== undefined && status >= 500))\n return 'transient'\n if (\n error instanceof Stripe.errors.StripeConnectionError ||\n error instanceof Stripe.errors.StripeAPIError ||\n error instanceof Stripe.errors.StripeRateLimitError\n )\n return 'transient'\n return 'unknown'\n}\n"],"mappings":";;;;;AAKA,IAAa,sBAAb,cAAyC,SAAS;CAMrC;CALX,AAAS,OAAO;CAChB,AAAS;;CAGT,YACE,AAAS,WACT,OACA;EACA,MAAM,0BAA0B,aAAa,EAAE,MAAM,CAAC;EAH7C;EAIT,KAAK,iBAAiB,oBAAoB,KAAK;CACjD;AACF;AAEA,SAAS,oBAAoB,OAAyD;CACpF,IAAI,MAAM,UAAU,2BAA2B,SAAS,OAAO;CAC/D,MAAM,SAAS,MAAM;CACrB,IAAI,WAAW,UAAa,UAAU,OAAO,SAAS,OAAO,WAAW,OAAO,WAAW,KACxF,OAAO;CACT,IACE,iBAAiB,OAAO,OAAO,6BAC/B,iBAAiB,OAAO,OAAO,yBAC/B,iBAAiB,OAAO,OAAO,6BAC/B,iBAAiB,OAAO,OAAO,wBAE/B,OAAO;CACT,IAAI,MAAM,UAAU,2BAA2B,QAAQ,OAAO;CAC9D,IAAI,WAAW,OAAO,WAAW,OAAQ,WAAW,UAAa,UAAU,KACzE,OAAO;CACT,IACE,iBAAiB,OAAO,OAAO,yBAC/B,iBAAiB,OAAO,OAAO,kBAC/B,iBAAiB,OAAO,OAAO,sBAE/B,OAAO;CACT,OAAO;AACT"}
|