better-ship 0.13.0 → 0.14.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-DnlgWcOZ.js → application-C4JOf71r.js} +22 -3
- package/dist/application-C4JOf71r.js.map +1 -0
- package/dist/application.d.ts +3 -3
- package/dist/application.js +2 -2
- package/dist/better-auth/apple-client-secret.d.ts +1 -1
- package/dist/better-auth/apple-client-secret.js +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 +1 -1
- package/dist/better-auth.js +1 -1
- package/dist/cloudflare/auth-secondary-storage.d.ts +1 -1
- package/dist/cloudflare/auth-secondary-storage.js +1 -1
- package/dist/cloudflare/queue.d.ts +2 -2
- package/dist/cloudflare/queue.js +2 -2
- package/dist/cloudflare/scheduled.d.ts +1 -1
- package/dist/cloudflare/scheduled.js +1 -1
- package/dist/cloudflare.d.ts +3 -3
- package/dist/cloudflare.js +3 -3
- package/dist/{core-BiqdOMwU.js → core-hdaNiCOU.js} +21 -2
- package/dist/core-hdaNiCOU.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 +2 -2
- package/dist/{index-DG4jkwad.d.ts → index-C28HgVfY.d.ts} +56 -3
- package/dist/index-C28HgVfY.d.ts.map +1 -0
- package/dist/{index-B5O6mNjZ.d.ts → index-G1QG0P5g.d.ts} +34 -2
- package/dist/index-G1QG0P5g.d.ts.map +1 -0
- package/dist/{outbox-repository-options-BiilQf4_.d.ts → outbox-repository-options-BZjfDqGf.d.ts} +3 -3
- package/dist/{outbox-repository-options-BiilQf4_.d.ts.map → outbox-repository-options-BZjfDqGf.d.ts.map} +1 -1
- package/dist/{outbox-repository-options-BI75j7b7.js → outbox-repository-options-DOTpJH-e.js} +2 -2
- package/dist/{outbox-repository-options-BI75j7b7.js.map → outbox-repository-options-DOTpJH-e.js.map} +1 -1
- package/dist/postgres.d.ts +3 -3
- package/dist/postgres.js +3 -3
- package/dist/posthog/client.d.ts +22 -0
- package/dist/posthog/client.d.ts.map +1 -0
- package/dist/posthog/client.js +34 -0
- package/dist/posthog/client.js.map +1 -0
- package/dist/posthog/metrics.d.ts +18 -0
- package/dist/posthog/metrics.d.ts.map +1 -0
- package/dist/posthog/metrics.js +30 -0
- package/dist/posthog/metrics.js.map +1 -0
- package/dist/posthog/proxy.d.ts +17 -0
- package/dist/posthog/proxy.d.ts.map +1 -0
- package/dist/posthog/proxy.js +34 -0
- package/dist/posthog/proxy.js.map +1 -0
- package/dist/posthog/server.d.ts +37 -0
- package/dist/posthog/server.d.ts.map +1 -0
- package/dist/posthog/server.js +81 -0
- package/dist/posthog/server.js.map +1 -0
- package/dist/resend.d.ts +3 -3
- package/dist/resend.js +2 -2
- package/dist/sentry/client.d.ts +22 -0
- package/dist/sentry/client.d.ts.map +1 -0
- package/dist/sentry/client.js +48 -0
- package/dist/sentry/client.js.map +1 -0
- package/dist/sentry/server.d.ts +24 -0
- package/dist/sentry/server.d.ts.map +1 -0
- package/dist/sentry/server.js +48 -0
- package/dist/sentry/server.js.map +1 -0
- package/dist/sentry/vite.d.ts +11 -0
- package/dist/sentry/vite.d.ts.map +1 -0
- package/dist/sentry/vite.js +17 -0
- package/dist/sentry/vite.js.map +1 -0
- package/dist/tanstack.d.ts +1 -1
- package/dist/tanstack.js +2 -2
- package/dist/testing/outbox-repository.d.ts +2 -2
- package/dist/{webhook-verification-CyBoERFz.d.ts → webhook-verification-D7DIhH6C.d.ts} +2 -2
- package/dist/{webhook-verification-CyBoERFz.d.ts.map → webhook-verification-D7DIhH6C.d.ts.map} +1 -1
- package/dist/{webhook-verification-CeXUJXVP.js → webhook-verification-trEgyz7I.js} +2 -2
- package/dist/{webhook-verification-CeXUJXVP.js.map → webhook-verification-trEgyz7I.js.map} +1 -1
- package/package.json +9 -2
- package/src/application/analytics-service.ts +21 -0
- package/src/application/index.ts +13 -0
- package/src/application/metrics-service.ts +28 -0
- package/src/application/observability-service.ts +16 -0
- package/src/core/analytics-event.ts +37 -0
- package/src/core/index.ts +9 -0
- package/src/core/missing-configuration.error.ts +12 -0
- package/src/infrastructure/posthog/client.ts +41 -0
- package/src/infrastructure/posthog/metrics.ts +30 -0
- package/src/infrastructure/posthog/proxy.ts +47 -0
- package/src/infrastructure/posthog/server.ts +107 -0
- package/src/infrastructure/sentry/client.ts +55 -0
- package/src/infrastructure/sentry/server.ts +51 -0
- package/src/infrastructure/sentry/vite.ts +17 -0
- package/dist/application-DnlgWcOZ.js.map +0 -1
- package/dist/core-BiqdOMwU.js.map +0 -1
- package/dist/index-B5O6mNjZ.d.ts.map +0 -1
- package/dist/index-DG4jkwad.d.ts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { At as RecordEmailEventPayload, G as DomainEvent, Ht as EmailAddress, J as MessageId, K as DomainMessage, Mt as BounceType, W as DomainCommand,
|
|
1
|
+
import { At as RecordEmailEventPayload, G as DomainEvent, Ht as EmailAddress, J as MessageId, Jt as AnalyticsProperties, K as DomainMessage, Kt as AnalyticsEventIdentity, Mt as BounceType, W as DomainCommand, Zt as AppError, q as DomainQuery, qt as AnalyticsEventInput, zt as EmailIdempotencyKey } from "./index-G1QG0P5g.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.
|
|
@@ -13,6 +13,59 @@ type QueryHandler<TQuery extends DomainQuery, QueryDeps, Value> = (query: TQuery
|
|
|
13
13
|
/** Completes one subscriber's work for an event. Failures throw. */
|
|
14
14
|
type EventHandler<TEvent extends DomainEvent, Deps> = (event: TEvent, deps: Deps) => Promise<void>;
|
|
15
15
|
//#endregion
|
|
16
|
+
//#region src/application/analytics-service.d.ts
|
|
17
|
+
/** Product analytics without an SDK dependency, ported from Typist and Porte. */
|
|
18
|
+
interface AnalyticsService<TEvent extends AnalyticsEventInput = AnalyticsEventInput> {
|
|
19
|
+
/** Attach traits to one person. */
|
|
20
|
+
identify(distinctId: string, properties?: AnalyticsProperties): void;
|
|
21
|
+
/** Merge a previous ID into this person; the application must establish that both identify the same person. */
|
|
22
|
+
alias(distinctId: string, previousDistinctId: string): void;
|
|
23
|
+
/** Schedule an event for a person; returning does not confirm remote acceptance. */
|
|
24
|
+
track(event: TEvent, distinctId: string, identity?: AnalyticsEventIdentity): void;
|
|
25
|
+
/** Schedule an event without creating a person profile for its distinct ID. */
|
|
26
|
+
trackAnonymous(event: TEvent, distinctId: string, identity?: AnalyticsEventIdentity): void;
|
|
27
|
+
}
|
|
28
|
+
/** Reports to nobody. The composition root selects this service when analytics is disabled. */
|
|
29
|
+
declare const NULL_ANALYTICS: AnalyticsService;
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/application/metrics-service.d.ts
|
|
32
|
+
/** A metric dimension; use a small, bounded value set and never user or request IDs. */
|
|
33
|
+
type MetricAttributeValue = string | number | boolean;
|
|
34
|
+
/** Dimensions shared by observations in one time series. */
|
|
35
|
+
type MetricAttributes = Readonly<Record<string, MetricAttributeValue>>;
|
|
36
|
+
/** Unit and dimensions for an operational measurement. */
|
|
37
|
+
interface MetricOptions {
|
|
38
|
+
readonly attributes?: MetricAttributes;
|
|
39
|
+
readonly unit?: string;
|
|
40
|
+
}
|
|
41
|
+
/** Operational measurements, ported from Typist's metrics-service.ts; applications own metric names. */
|
|
42
|
+
interface MetricsService<TName extends string = string> {
|
|
43
|
+
/** Add a nonnegative value to a total; the default increment is one. */
|
|
44
|
+
count(name: TName, value?: number, options?: MetricOptions): void;
|
|
45
|
+
/** Record a current value. */
|
|
46
|
+
gauge(name: TName, value: number, options?: MetricOptions): void;
|
|
47
|
+
/** Record one observation in a distribution. */
|
|
48
|
+
histogram(name: TName, value: number, options?: MetricOptions): void;
|
|
49
|
+
}
|
|
50
|
+
/** Records nothing when the composition root disables metrics. */
|
|
51
|
+
declare const NULL_METRICS_SERVICE: MetricsService;
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/application/observability-service.d.ts
|
|
54
|
+
/** The identity an error report belongs to. */
|
|
55
|
+
interface ObservabilityUser {
|
|
56
|
+
readonly id: string;
|
|
57
|
+
}
|
|
58
|
+
/** Identity within one isolated execution. */
|
|
59
|
+
interface ObservabilityScope {
|
|
60
|
+
/** Attribute reports in this scope to one person. */
|
|
61
|
+
setUser(user: ObservabilityUser): void;
|
|
62
|
+
}
|
|
63
|
+
/** Error identity and isolation, ported from Porte's sentry-observability-service.ts. */
|
|
64
|
+
interface ObservabilityService extends ObservabilityScope {
|
|
65
|
+
/** Await work in its own scope so concurrent executions do not share identity. */
|
|
66
|
+
withIsolationScope<T>(callback: (scope: ObservabilityScope) => T | Promise<T>): Promise<T>;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
16
69
|
//#region src/application/email-service.d.ts
|
|
17
70
|
/** A media type such as `application/pdf`. */
|
|
18
71
|
type MimeType = `${string}/${string}`;
|
|
@@ -338,5 +391,5 @@ declare class UnitOfWorkAlreadyActiveError extends AppError {
|
|
|
338
391
|
constructor();
|
|
339
392
|
}
|
|
340
393
|
//#endregion
|
|
341
|
-
export { IOutboxRepository as A, OutboundEmail as B, UnitOfWorkDeps as C, OutboxRelay as D, IOutboxRelay as E, IEventCollector as F,
|
|
342
|
-
//# sourceMappingURL=index-
|
|
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-C28HgVfY.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-C28HgVfY.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;;EAE9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S,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,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"}
|
|
@@ -36,6 +36,38 @@ declare abstract class AppError extends Error {
|
|
|
36
36
|
get name(): string;
|
|
37
37
|
}
|
|
38
38
|
//#endregion
|
|
39
|
+
//#region src/core/missing-configuration.error.d.ts
|
|
40
|
+
/** Required configuration is absent. Ported from Porte's configuration.errors.ts. */
|
|
41
|
+
declare class MissingConfigurationError extends AppError {
|
|
42
|
+
readonly key: string;
|
|
43
|
+
readonly _tag = "MissingConfigurationError";
|
|
44
|
+
readonly classification = "terminal";
|
|
45
|
+
/** Name the missing setting without including its value. */
|
|
46
|
+
constructor(key: string);
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/core/analytics-event.d.ts
|
|
50
|
+
/** An event name and its application-owned properties, ported from Typist's analytics/types.ts. */
|
|
51
|
+
interface AnalyticsEventInput<TName extends string = string, TProperties extends object = object> {
|
|
52
|
+
readonly name: TName;
|
|
53
|
+
readonly properties: TProperties;
|
|
54
|
+
}
|
|
55
|
+
/** A value supported by analytics person properties. */
|
|
56
|
+
type AnalyticsProperty = string | number | boolean | null | undefined | readonly AnalyticsProperty[] | AnalyticsProperties;
|
|
57
|
+
/** Person properties supplied by the application. */
|
|
58
|
+
interface AnalyticsProperties {
|
|
59
|
+
readonly [name: string]: AnalyticsProperty;
|
|
60
|
+
}
|
|
61
|
+
/** Parse a persisted analytics event UUID; the SDK generates ordinary event UUIDs itself. */
|
|
62
|
+
declare const AnalyticsEventIdSchema: z.core.$ZodBranded<z.ZodUUID, "AnalyticsEventId", "out">;
|
|
63
|
+
/** The identity of one analytics event across repeated application deliveries. */
|
|
64
|
+
type AnalyticsEventId = z.infer<typeof AnalyticsEventIdSchema>;
|
|
65
|
+
/** Supply both original values when replaying one event; never share them across different occurrences. */
|
|
66
|
+
interface AnalyticsEventIdentity {
|
|
67
|
+
readonly uuid: AnalyticsEventId;
|
|
68
|
+
readonly timestamp: Date;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
39
71
|
//#region src/core/email-address.d.ts
|
|
40
72
|
/** A parsed email address for message payloads and webhook recipients. Ported from Typist's `EmailSchema`. */
|
|
41
73
|
declare const EmailAddressSchema: z.core.$ZodBranded<z.ZodEmail, "EmailAddress", "out">;
|
|
@@ -717,5 +749,5 @@ declare class Logger {
|
|
|
717
749
|
/** Create a logger for one module. */
|
|
718
750
|
declare function createLogger(module: string, config?: LoggerConfig): Logger;
|
|
719
751
|
//#endregion
|
|
720
|
-
export { notImplemented as $, isCloudflareRetryableError as A, RecordEmailEventPayload as At, MessageOf as B, InvalidEmailIdempotencyKeyError as Bt, BoundaryErrorClassifier as C, ValidationProblemErrorSchema as Ct, CLOUDFLARE_TRANSIENT_ERROR_PATTERNS as D, StaleSessionError as Dt, retryAfterSecondsOf as E, NotAuthorizedError as Et, EntityData as F, parseBounceType as Ft, DomainEvent as G,
|
|
721
|
-
//# sourceMappingURL=index-
|
|
752
|
+
export { notImplemented as $, RetryOwner as $t, isCloudflareRetryableError as A, RecordEmailEventPayload as At, MessageOf as B, InvalidEmailIdempotencyKeyError as Bt, BoundaryErrorClassifier as C, ValidationProblemErrorSchema as Ct, CLOUDFLARE_TRANSIENT_ERROR_PATTERNS as D, StaleSessionError as Dt, retryAfterSecondsOf as E, NotAuthorizedError as Et, EntityData as F, parseBounceType as Ft, DomainEvent as G, AnalyticsEventIdSchema as Gt, QueryOf as H, EmailAddress as Ht, AppMessages as I, shouldUpdateBounce as It, MessageId as J, AnalyticsProperties as Jt, DomainMessage as K, AnalyticsEventIdentity as Kt, CommandOf as L, EmailSendFailureReason as Lt, isAbortError as M, BounceType as Mt, isTransientTransportError as N, BounceTypeSchema as Nt, isCloudflareObjectResetError as O, RateLimitError as Ot, Entity as P, isEmailDeliverable as Pt, defineId as Q, FailureClassification as Qt, EventOf as R, EmailServiceError as Rt, spreadJitterMs as S, ValidationProblemError as St, classifyFailure as T, ServiceUnavailableError as Tt, defineMessages as U, EmailAddressSchema as Ut, PayloadSchemas as V, emailIdempotencyKey as Vt, DomainCommand as W, AnalyticsEventId as Wt, IdDefinition as X, MissingConfigurationError as Xt, Id as Y, AnalyticsProperty as Yt, IdOf as Z, AppError as Zt, createLogger as _, ValidationIssue as _t, LogFormat as a, ErrorEntry as at, exponentialDelayCapMs as b, ValidationProblemDetails as bt, LogThreshold as c, ErrorTagOf as ct, LoggerConfig as d, sharedErrors as dt, shouldRetryFailure as en, unreachable as et, LoggerErrorHook as f, MalformedRequestError as ft, consoleSink as g, ValidationError as gt, configureLogger as h, UpgradeRequiredError as ht, LogFields as i, ErrorEntries as it, isTransientCloudflareRuntimeError as j, RecordEmailEventPayloadSchema as jt, isCloudflareOverloadedError as k, AuthenticationError as kt, LogValue as l, ResolvedError as lt, SerializedError as m, ResourceNotFoundError as mt, ErrorLogContext as n, DatabaseError as nt, LogLevel as o, ErrorPayloadOf as ot, LoggerSettings as p, RequestTimeoutError as pt, DomainQuery as q, AnalyticsEventInput as qt, LogEntry as r, DatabaseFailure as rt, LogSink as s, ErrorTable as st, ErrorCaptureEntry as t, D1ConstraintKind as tt, Logger as u, defineErrors as ut, setLogSink as v, ProblemDetails as vt, classifyBoundaryError as w, InternalServerError as wt, exponentialEqualJitterMs as x, ValidationProblemDetailsSchema as xt, setLoggerErrorHook as y, ProblemDetailsSchema as yt, MessageDefinition as z, EmailIdempotencyKey as zt };
|
|
753
|
+
//# sourceMappingURL=index-G1QG0P5g.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-G1QG0P5g.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/log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BAA2B,mBAAmB;;;;;iBAM1C,sBAAsB;WAC3B;WACA,kBAAkB;WAClB;IACP;;;;;iBAwBY,gBAAgB,iBAAiB;;iBAUjC,oBAAoB;;;;iBCrDpB,eAAe;;;;;iBAWf,yBACd,qBACA,oBACA;;iBAOc,sBACd,qBACA,oBACA;;;;;;;;;;KCnBU,0DAMR,cAAc,YACd;;KAGQ;YAAwB,cAAc;;;;;;;cAOrC;WACX;WACA;WACA;WACA;;KAEU,mBAAmB,uBAAuB;;KAG1C;WACD;WACA;WACA;WACA,SAAS;WACT,QAAQ;WACR,SAAS,cAAc;;;KAItB;WACD;WACA,OAAO;WACP;WACA;WACA,SAAS;WACT;;WAEA,QAAQ;;;KAIP;WACD;WACA;WACA,UAAU;;;KAIT,eAAe;;UAGV;WACN,QAAQ;;;KAIP;;;;;;;UAQK,uBAAuB;WAC7B,SAAS;;;;;;iBAgBJ,gBAAgB,QAAQ;;UAQvB;WACN;WACA;WACA,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"}
|
package/dist/{outbox-repository-options-BiilQf4_.d.ts → outbox-repository-options-BZjfDqGf.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { F as IEventCollector } from "./index-
|
|
1
|
+
import "./index-G1QG0P5g.js";
|
|
2
|
+
import { F as IEventCollector } from "./index-C28HgVfY.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-BZjfDqGf.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outbox-repository-options-
|
|
1
|
+
{"version":3,"file":"outbox-repository-options-BZjfDqGf.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/{outbox-repository-options-BI75j7b7.js → outbox-repository-options-DOTpJH-e.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as UnitOfWorkAlreadyActiveError } from "./application-
|
|
1
|
+
import { t as UnitOfWorkAlreadyActiveError } from "./application-C4JOf71r.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-DOTpJH-e.js.map
|
package/dist/{outbox-repository-options-BI75j7b7.js.map → outbox-repository-options-DOTpJH-e.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outbox-repository-options-
|
|
1
|
+
{"version":3,"file":"outbox-repository-options-DOTpJH-e.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/postgres.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { G as DomainEvent, J as MessageId, nt as DatabaseError, rt as DatabaseFailure } from "./index-
|
|
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 { G as DomainEvent, J as MessageId, nt as DatabaseError, rt as DatabaseFailure } from "./index-G1QG0P5g.js";
|
|
2
|
+
import { A as IOutboxRepository, M as OutboxClaim, N as OutboxMessage, P as IMessageStore, k as DeadLetterReason, w as ITransaction } from "./index-C28HgVfY.js";
|
|
3
|
+
import { n as eventCollector, r as DrizzleSchema, t as OutboxRepositoryOptions } from "./outbox-repository-options-BZjfDqGf.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 { D as DatabaseError, c as exponentialDelayCapMs, tt as AppError } from "./core-hdaNiCOU.js";
|
|
2
|
+
import { o as MessageAlreadyProcessedError } from "./application-C4JOf71r.js";
|
|
3
|
+
import { i as runWithUnitOfWorkContext, r as eventCollector, t as OUTBOX_REPOSITORY_DEFAULTS } from "./outbox-repository-options-DOTpJH-e.js";
|
|
4
4
|
import { DrizzleQueryError } from "drizzle-orm/errors";
|
|
5
5
|
import { and, asc, eq, inArray, isNull, lt, lte, or, sql } from "drizzle-orm";
|
|
6
6
|
import { index, integer, jsonb, pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PostHog, PostHogConfig } from "posthog-js";
|
|
2
|
+
import { PostHogProvider, usePostHog } from "@posthog/react";
|
|
3
|
+
//#region src/infrastructure/posthog/client.d.ts
|
|
4
|
+
/** The application controls enablement; disabled initialization needs no project key. */
|
|
5
|
+
export type PostHogClientConfig = {
|
|
6
|
+
readonly enabled: false;
|
|
7
|
+
} | {
|
|
8
|
+
readonly enabled: true;
|
|
9
|
+
readonly apiKey: string;
|
|
10
|
+
readonly environment: string;
|
|
11
|
+
readonly source: string;
|
|
12
|
+
readonly options?: Partial<PostHogConfig>;
|
|
13
|
+
};
|
|
14
|
+
/** Browser options from Typist and Porte; SDK option names and application overrides stay intact. */
|
|
15
|
+
export declare function createPostHogClientOptions(config: Extract<PostHogClientConfig, {
|
|
16
|
+
enabled: true;
|
|
17
|
+
}>): Partial<PostHogConfig>;
|
|
18
|
+
/** Initialize once in the browser entrypoint; pass the returned SDK client to PostHogProvider. */
|
|
19
|
+
export declare function initializePostHog(config: PostHogClientConfig): PostHog;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { PostHogProvider, usePostHog };
|
|
22
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","names":[],"sources":["../../src/infrastructure/posthog/client.ts"],"mappings":";;;;YAGY;WACG;;WAEA;WACA;WACA;WACA;WACA,UAAU,QAAQ;;;wBAIjB,2BACd,QAAQ,QAAQ;EAAuB;KACtC,QAAQ;;wBAkBK,kBAAkB,QAAQ,sBAAsB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import posthog from "posthog-js";
|
|
2
|
+
import { PostHogProvider, usePostHog } from "@posthog/react";
|
|
3
|
+
|
|
4
|
+
//#region src/infrastructure/posthog/client.ts
|
|
5
|
+
/** Browser options from Typist and Porte; SDK option names and application overrides stay intact. */
|
|
6
|
+
function createPostHogClientOptions(config) {
|
|
7
|
+
return {
|
|
8
|
+
api_host: "/relay",
|
|
9
|
+
ui_host: "https://us.posthog.com",
|
|
10
|
+
person_profiles: "identified_only",
|
|
11
|
+
defaults: "2026-08-29",
|
|
12
|
+
disable_surveys: true,
|
|
13
|
+
advanced_disable_feature_flags: true,
|
|
14
|
+
capture_performance: { web_vitals: false },
|
|
15
|
+
...config.options,
|
|
16
|
+
loaded: (client) => {
|
|
17
|
+
client.register({
|
|
18
|
+
environment: config.environment,
|
|
19
|
+
source: config.source
|
|
20
|
+
});
|
|
21
|
+
config.options?.loaded?.(client);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** Initialize once in the browser entrypoint; pass the returned SDK client to PostHogProvider. */
|
|
26
|
+
function initializePostHog(config) {
|
|
27
|
+
if (!config.enabled) return posthog;
|
|
28
|
+
posthog.init(config.apiKey, createPostHogClientOptions(config));
|
|
29
|
+
return posthog;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { PostHogProvider, createPostHogClientOptions, initializePostHog, usePostHog };
|
|
34
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","names":[],"sources":["../../src/infrastructure/posthog/client.ts"],"sourcesContent":["import posthog, { type PostHog, type PostHogConfig } from 'posthog-js'\n\n/** The application controls enablement; disabled initialization needs no project key. */\nexport type PostHogClientConfig =\n | { readonly enabled: false }\n | {\n readonly enabled: true\n readonly apiKey: string\n readonly environment: string\n readonly source: string\n readonly options?: Partial<PostHogConfig>\n }\n\n/** Browser options from Typist and Porte; SDK option names and application overrides stay intact. */\nexport function createPostHogClientOptions(\n config: Extract<PostHogClientConfig, { enabled: true }>,\n): Partial<PostHogConfig> {\n return {\n api_host: '/relay',\n ui_host: 'https://us.posthog.com',\n person_profiles: 'identified_only',\n defaults: '2026-08-29',\n disable_surveys: true,\n advanced_disable_feature_flags: true,\n capture_performance: { web_vitals: false },\n ...config.options,\n loaded: (client) => {\n client.register({ environment: config.environment, source: config.source })\n config.options?.loaded?.(client)\n },\n }\n}\n\n/** Initialize once in the browser entrypoint; pass the returned SDK client to PostHogProvider. */\nexport function initializePostHog(config: PostHogClientConfig): PostHog {\n if (!config.enabled) return posthog\n posthog.init(config.apiKey, createPostHogClientOptions(config))\n return posthog\n}\n\nexport { PostHogProvider, usePostHog } from '@posthog/react'\n"],"mappings":";;;;;AAcA,SAAgB,2BACd,QACwB;CACxB,OAAO;EACL,UAAU;EACV,SAAS;EACT,iBAAiB;EACjB,UAAU;EACV,iBAAiB;EACjB,gCAAgC;EAChC,qBAAqB,EAAE,YAAY,MAAM;EACzC,GAAG,OAAO;EACV,SAAS,WAAW;GAClB,OAAO,SAAS;IAAE,aAAa,OAAO;IAAa,QAAQ,OAAO;GAAO,CAAC;GAC1E,OAAO,SAAS,SAAS,MAAM;EACjC;CACF;AACF;;AAGA,SAAgB,kBAAkB,QAAsC;CACtE,IAAI,CAAC,OAAO,SAAS,OAAO;CAC5B,QAAQ,KAAK,OAAO,QAAQ,2BAA2B,MAAM,CAAC;CAC9D,OAAO;AACT"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { J as MetricsService, q as MetricOptions } from "../index-C28HgVfY.js";
|
|
2
|
+
import { PostHog } from "posthog-node";
|
|
3
|
+
//#region src/infrastructure/posthog/metrics.d.ts
|
|
4
|
+
/** PostHog Metrics with Worker lifetime management, ported from Typist's metrics-service.ts. */
|
|
5
|
+
export declare class PostHogMetricsService implements MetricsService {
|
|
6
|
+
private readonly client;
|
|
7
|
+
private readonly waitUntil;
|
|
8
|
+
/** Use the analytics client's metrics; the runtime owns each flush promise. */
|
|
9
|
+
constructor(client: Pick<PostHog, 'metrics'>, waitUntil: (promise: Promise<unknown>) => void);
|
|
10
|
+
/** Record a total and schedule its flush. */
|
|
11
|
+
count(name: string, value?: number, options?: MetricOptions): void;
|
|
12
|
+
/** Record a current value and schedule its flush. */
|
|
13
|
+
gauge(name: string, value: number, options?: MetricOptions): void;
|
|
14
|
+
/** Record an observation and schedule its flush. */
|
|
15
|
+
histogram(name: string, value: number, options?: MetricOptions): void;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//# sourceMappingURL=metrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","names":[],"sources":["../../src/infrastructure/posthog/metrics.ts"],"mappings":";;;;qBAKa,iCAAiC;mBAGzB;mBACA;;EAFnB,YACmB,QAAQ,KAAK,qBACb,YAAY,SAAS;;EAIxC,MAAM,cAAc,gBAAW,UAAU;;EAMzC,MAAM,cAAc,eAAe,UAAU;;EAM7C,UAAU,cAAc,eAAe,UAAU"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/infrastructure/posthog/metrics.ts
|
|
2
|
+
/** PostHog Metrics with Worker lifetime management, ported from Typist's metrics-service.ts. */
|
|
3
|
+
var PostHogMetricsService = class {
|
|
4
|
+
client;
|
|
5
|
+
waitUntil;
|
|
6
|
+
/** Use the analytics client's metrics; the runtime owns each flush promise. */
|
|
7
|
+
constructor(client, waitUntil) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
this.waitUntil = waitUntil;
|
|
10
|
+
}
|
|
11
|
+
/** Record a total and schedule its flush. */
|
|
12
|
+
count(name, value = 1, options) {
|
|
13
|
+
this.client.metrics.count(name, value, options);
|
|
14
|
+
this.waitUntil(this.client.metrics.flush());
|
|
15
|
+
}
|
|
16
|
+
/** Record a current value and schedule its flush. */
|
|
17
|
+
gauge(name, value, options) {
|
|
18
|
+
this.client.metrics.gauge(name, value, options);
|
|
19
|
+
this.waitUntil(this.client.metrics.flush());
|
|
20
|
+
}
|
|
21
|
+
/** Record an observation and schedule its flush. */
|
|
22
|
+
histogram(name, value, options) {
|
|
23
|
+
this.client.metrics.histogram(name, value, options);
|
|
24
|
+
this.waitUntil(this.client.metrics.flush());
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { PostHogMetricsService };
|
|
30
|
+
//# sourceMappingURL=metrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.js","names":[],"sources":["../../src/infrastructure/posthog/metrics.ts"],"sourcesContent":["import type { PostHog } from 'posthog-node'\n\nimport type { MetricOptions, MetricsService } from '@/application'\n\n/** PostHog Metrics with Worker lifetime management, ported from Typist's metrics-service.ts. */\nexport class PostHogMetricsService implements MetricsService {\n /** Use the analytics client's metrics; the runtime owns each flush promise. */\n constructor(\n private readonly client: Pick<PostHog, 'metrics'>,\n private readonly waitUntil: (promise: Promise<unknown>) => void,\n ) {}\n\n /** Record a total and schedule its flush. */\n count(name: string, value = 1, options?: MetricOptions): void {\n this.client.metrics.count(name, value, options)\n this.waitUntil(this.client.metrics.flush())\n }\n\n /** Record a current value and schedule its flush. */\n gauge(name: string, value: number, options?: MetricOptions): void {\n this.client.metrics.gauge(name, value, options)\n this.waitUntil(this.client.metrics.flush())\n }\n\n /** Record an observation and schedule its flush. */\n histogram(name: string, value: number, options?: MetricOptions): void {\n this.client.metrics.histogram(name, value, options)\n this.waitUntil(this.client.metrics.flush())\n }\n}\n"],"mappings":";;AAKA,IAAa,wBAAb,MAA6D;CAGxC;CACA;;CAFnB,YACE,AAAiB,QACjB,AAAiB,WACjB;EAFiB;EACA;CAChB;;CAGH,MAAM,MAAc,QAAQ,GAAG,SAA+B;EAC5D,KAAK,OAAO,QAAQ,MAAM,MAAM,OAAO,OAAO;EAC9C,KAAK,UAAU,KAAK,OAAO,QAAQ,MAAM,CAAC;CAC5C;;CAGA,MAAM,MAAc,OAAe,SAA+B;EAChE,KAAK,OAAO,QAAQ,MAAM,MAAM,OAAO,OAAO;EAC9C,KAAK,UAAU,KAAK,OAAO,QAAQ,MAAM,CAAC;CAC5C;;CAGA,UAAU,MAAc,OAAe,SAA+B;EACpE,KAAK,OAAO,QAAQ,UAAU,MAAM,OAAO,OAAO;EAClD,KAAK,UAAU,KAAK,OAAO,QAAQ,MAAM,CAAC;CAC5C;AACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/infrastructure/posthog/proxy.d.ts
|
|
2
|
+
/** Runtime resources and deployment hosts for Typist's same-origin proxy. */
|
|
3
|
+
export interface PostHogProxyOptions {
|
|
4
|
+
readonly cache: Pick<Cache, 'match' | 'put'>;
|
|
5
|
+
readonly waitUntil: (promise: Promise<void>) => void;
|
|
6
|
+
readonly basePath?: string;
|
|
7
|
+
readonly ingestHost?: string;
|
|
8
|
+
readonly assetHost?: string;
|
|
9
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Mount at /relay/$ with GET, POST, and OPTIONS handlers. Supply Cloudflare's asset cache and waitUntil.
|
|
13
|
+
* The application must use the same base path in the browser's api_host option.
|
|
14
|
+
*/
|
|
15
|
+
export declare function proxyPostHogRequest(request: Request, options: PostHogProxyOptions): Promise<Response>;
|
|
16
|
+
//#endregion
|
|
17
|
+
//# sourceMappingURL=proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","names":[],"sources":["../../src/infrastructure/posthog/proxy.ts"],"mappings":";;iBACiB;WACN,OAAO,KAAK;WACZ,YAAY,SAAS;WACrB;WACA;WACA;WACA,eAAe,WAAW;;;;;;wBAOf,oBACpB,SAAS,SACT,SAAS,sBACR,QAAQ"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/infrastructure/posthog/proxy.ts
|
|
2
|
+
/**
|
|
3
|
+
* Mount at /relay/$ with GET, POST, and OPTIONS handlers. Supply Cloudflare's asset cache and waitUntil.
|
|
4
|
+
* The application must use the same base path in the browser's api_host option.
|
|
5
|
+
*/
|
|
6
|
+
async function proxyPostHogRequest(request, options) {
|
|
7
|
+
const url = new URL(request.url);
|
|
8
|
+
const basePath = options.basePath ?? "/relay";
|
|
9
|
+
if (!url.pathname.startsWith(`${basePath}/`)) return new Response(null, { status: 404 });
|
|
10
|
+
const pathname = url.pathname.slice(basePath.length);
|
|
11
|
+
const pathWithSearch = pathname + url.search;
|
|
12
|
+
const send = options.fetch ?? globalThis.fetch;
|
|
13
|
+
if (pathname.startsWith("/static/") || pathname.startsWith("/array/")) {
|
|
14
|
+
const cached = await options.cache.match(request);
|
|
15
|
+
if (cached) return cached;
|
|
16
|
+
const response = await send(`https://${options.assetHost ?? "us-assets.i.posthog.com"}${pathWithSearch}`);
|
|
17
|
+
options.waitUntil(options.cache.put(request, response.clone()));
|
|
18
|
+
return response;
|
|
19
|
+
}
|
|
20
|
+
const headers = new Headers(request.headers);
|
|
21
|
+
headers.delete("cookie");
|
|
22
|
+
headers.delete("authorization");
|
|
23
|
+
headers.set("X-Forwarded-For", request.headers.get("CF-Connecting-IP") ?? "");
|
|
24
|
+
return await send(`https://${options.ingestHost ?? "us.i.posthog.com"}${pathWithSearch}`, {
|
|
25
|
+
method: request.method,
|
|
26
|
+
headers,
|
|
27
|
+
body: request.method !== "GET" && request.method !== "HEAD" ? await request.arrayBuffer() : null,
|
|
28
|
+
redirect: request.redirect
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { proxyPostHogRequest };
|
|
34
|
+
//# sourceMappingURL=proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.js","names":[],"sources":["../../src/infrastructure/posthog/proxy.ts"],"sourcesContent":["/** Runtime resources and deployment hosts for Typist's same-origin proxy. */\nexport interface PostHogProxyOptions {\n readonly cache: Pick<Cache, 'match' | 'put'>\n readonly waitUntil: (promise: Promise<void>) => void\n readonly basePath?: string\n readonly ingestHost?: string\n readonly assetHost?: string\n readonly fetch?: typeof globalThis.fetch\n}\n\n/**\n * Mount at /relay/$ with GET, POST, and OPTIONS handlers. Supply Cloudflare's asset cache and waitUntil.\n * The application must use the same base path in the browser's api_host option.\n */\nexport async function proxyPostHogRequest(\n request: Request,\n options: PostHogProxyOptions,\n): Promise<Response> {\n const url = new URL(request.url)\n const basePath = options.basePath ?? '/relay'\n if (!url.pathname.startsWith(`${basePath}/`)) return new Response(null, { status: 404 })\n const pathname = url.pathname.slice(basePath.length)\n const pathWithSearch = pathname + url.search\n const send = options.fetch ?? globalThis.fetch\n\n if (pathname.startsWith('/static/') || pathname.startsWith('/array/')) {\n const cached = await options.cache.match(request)\n if (cached) return cached\n const response = await send(\n `https://${options.assetHost ?? 'us-assets.i.posthog.com'}${pathWithSearch}`,\n )\n options.waitUntil(options.cache.put(request, response.clone()))\n return response\n }\n\n const headers = new Headers(request.headers)\n headers.delete('cookie')\n headers.delete('authorization')\n headers.set('X-Forwarded-For', request.headers.get('CF-Connecting-IP') ?? '')\n return await send(`https://${options.ingestHost ?? 'us.i.posthog.com'}${pathWithSearch}`, {\n method: request.method,\n headers,\n body:\n request.method !== 'GET' && request.method !== 'HEAD' ? await request.arrayBuffer() : null,\n redirect: request.redirect,\n })\n}\n"],"mappings":";;;;;AAcA,eAAsB,oBACpB,SACA,SACmB;CACnB,MAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;CAC/B,MAAM,WAAW,QAAQ,YAAY;CACrC,IAAI,CAAC,IAAI,SAAS,WAAW,GAAG,SAAS,EAAE,GAAG,OAAO,IAAI,SAAS,MAAM,EAAE,QAAQ,IAAI,CAAC;CACvF,MAAM,WAAW,IAAI,SAAS,MAAM,SAAS,MAAM;CACnD,MAAM,iBAAiB,WAAW,IAAI;CACtC,MAAM,OAAO,QAAQ,SAAS,WAAW;CAEzC,IAAI,SAAS,WAAW,UAAU,KAAK,SAAS,WAAW,SAAS,GAAG;EACrE,MAAM,SAAS,MAAM,QAAQ,MAAM,MAAM,OAAO;EAChD,IAAI,QAAQ,OAAO;EACnB,MAAM,WAAW,MAAM,KACrB,WAAW,QAAQ,aAAa,4BAA4B,gBAC9D;EACA,QAAQ,UAAU,QAAQ,MAAM,IAAI,SAAS,SAAS,MAAM,CAAC,CAAC;EAC9D,OAAO;CACT;CAEA,MAAM,UAAU,IAAI,QAAQ,QAAQ,OAAO;CAC3C,QAAQ,OAAO,QAAQ;CACvB,QAAQ,OAAO,eAAe;CAC9B,QAAQ,IAAI,mBAAmB,QAAQ,QAAQ,IAAI,kBAAkB,KAAK,EAAE;CAC5E,OAAO,MAAM,KAAK,WAAW,QAAQ,cAAc,qBAAqB,kBAAkB;EACxF,QAAQ,QAAQ;EAChB;EACA,MACE,QAAQ,WAAW,SAAS,QAAQ,WAAW,SAAS,MAAM,QAAQ,YAAY,IAAI;EACxF,UAAU,QAAQ;CACpB,CAAC;AACH"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Jt as AnalyticsProperties, Kt as AnalyticsEventIdentity, qt as AnalyticsEventInput } from "../index-G1QG0P5g.js";
|
|
2
|
+
import { X as AnalyticsService } from "../index-C28HgVfY.js";
|
|
3
|
+
import { PostHogMetricsService } from "./metrics.js";
|
|
4
|
+
import { PostHog, PostHogOptions } from "posthog-node";
|
|
5
|
+
//#region src/infrastructure/posthog/server.d.ts
|
|
6
|
+
/** Deployment values and SDK options; the runtime owns delivery promises. */
|
|
7
|
+
export interface PostHogAnalyticsConfig {
|
|
8
|
+
readonly apiKey: string;
|
|
9
|
+
readonly environment: string;
|
|
10
|
+
readonly source: string;
|
|
11
|
+
readonly waitUntil: (promise: Promise<unknown>) => void;
|
|
12
|
+
readonly options?: Omit<PostHogOptions, 'waitUntil' | 'flushAt' | 'flushInterval' | 'metrics' | 'disabled'> & {
|
|
13
|
+
readonly metrics?: Omit<NonNullable<PostHogOptions['metrics']>, 'serviceName' | 'environment'>;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** Worker analytics ported from Typist; disabled applications select Porte's NULL_ANALYTICS instead. */
|
|
17
|
+
export declare class PostHogAnalyticsService implements AnalyticsService {
|
|
18
|
+
/** Raw SDK access for integrations such as PostHog AI tracing. */
|
|
19
|
+
readonly posthog: PostHog;
|
|
20
|
+
private readonly waitUntil;
|
|
21
|
+
/** Metrics share this service's SDK client and delivery lifetime. */
|
|
22
|
+
readonly metrics: PostHogMetricsService;
|
|
23
|
+
private constructor();
|
|
24
|
+
/** Construct once per Worker invocation; a blank key throws MissingConfigurationError. */
|
|
25
|
+
static create(config: PostHogAnalyticsConfig): PostHogAnalyticsService;
|
|
26
|
+
/** Schedule person properties; the SDK's waitUntil option protects queued delivery. */
|
|
27
|
+
identify(distinctId: string, properties?: AnalyticsProperties): void;
|
|
28
|
+
/** Schedule an irreversible person merge; only alias IDs the application proves belong to one person. */
|
|
29
|
+
alias(distinctId: string, previousDistinctId: string): void;
|
|
30
|
+
/** Schedule an event; omit identity for SDK-generated UUID and capture time. */
|
|
31
|
+
track(event: AnalyticsEventInput, distinctId: string, identity?: AnalyticsEventIdentity): void;
|
|
32
|
+
/** Schedule an event without creating a person profile for an attempt or resource ID. */
|
|
33
|
+
trackAnonymous(event: AnalyticsEventInput, distinctId: string, identity?: AnalyticsEventIdentity): void;
|
|
34
|
+
private capture;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","names":[],"sources":["../../src/infrastructure/posthog/server.ts"],"mappings":";;;;;;iBAaiB;WACN;WACA;WACA;WACA,YAAY,SAAS;WACrB,UAAU,KACjB;aAGS,UAAU,KAAK,YAAY;;;;qBAK3B,mCAAmC;;WAMnC,SAAS;mBACD;;WALV,SAAS;UAEX;;SASA,OAAO,QAAQ,yBAAyB;;EAqB/C,SAAS,oBAAoB,aAAa;;EAO1C,MAAM,oBAAoB;;EAK1B,MAAM,OAAO,qBAAqB,oBAAoB,WAAW;;EAKjE,eACE,OAAO,qBACP,oBACA,WAAW;UAKL"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { et as MissingConfigurationError } from "../core-hdaNiCOU.js";
|
|
2
|
+
import { PostHogMetricsService } from "./metrics.js";
|
|
3
|
+
import { PostHog } from "posthog-node";
|
|
4
|
+
|
|
5
|
+
//#region src/infrastructure/posthog/server.ts
|
|
6
|
+
/** Worker analytics ported from Typist; disabled applications select Porte's NULL_ANALYTICS instead. */
|
|
7
|
+
var PostHogAnalyticsService = class PostHogAnalyticsService {
|
|
8
|
+
posthog;
|
|
9
|
+
waitUntil;
|
|
10
|
+
/** Metrics share this service's SDK client and delivery lifetime. */
|
|
11
|
+
metrics;
|
|
12
|
+
constructor(posthog, waitUntil) {
|
|
13
|
+
this.posthog = posthog;
|
|
14
|
+
this.waitUntil = waitUntil;
|
|
15
|
+
this.metrics = new PostHogMetricsService(posthog, waitUntil);
|
|
16
|
+
}
|
|
17
|
+
/** Construct once per Worker invocation; a blank key throws MissingConfigurationError. */
|
|
18
|
+
static create(config) {
|
|
19
|
+
const apiKey = config.apiKey.trim();
|
|
20
|
+
if (apiKey.length === 0) throw new MissingConfigurationError("POSTHOG_API_KEY");
|
|
21
|
+
const client = new PostHog(apiKey, {
|
|
22
|
+
host: "https://us.i.posthog.com",
|
|
23
|
+
...config.options,
|
|
24
|
+
flushAt: 1,
|
|
25
|
+
flushInterval: 0,
|
|
26
|
+
waitUntil: config.waitUntil,
|
|
27
|
+
metrics: {
|
|
28
|
+
...config.options?.metrics,
|
|
29
|
+
environment: config.environment,
|
|
30
|
+
serviceName: config.source
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
client.register({
|
|
34
|
+
environment: config.environment,
|
|
35
|
+
source: config.source
|
|
36
|
+
});
|
|
37
|
+
return new PostHogAnalyticsService(client, config.waitUntil);
|
|
38
|
+
}
|
|
39
|
+
/** Schedule person properties; the SDK's waitUntil option protects queued delivery. */
|
|
40
|
+
identify(distinctId, properties) {
|
|
41
|
+
const payload = { distinctId };
|
|
42
|
+
if (properties !== void 0) payload.properties = properties;
|
|
43
|
+
this.posthog.identify(payload);
|
|
44
|
+
}
|
|
45
|
+
/** Schedule an irreversible person merge; only alias IDs the application proves belong to one person. */
|
|
46
|
+
alias(distinctId, previousDistinctId) {
|
|
47
|
+
this.waitUntil(this.posthog.aliasImmediate({
|
|
48
|
+
distinctId,
|
|
49
|
+
alias: previousDistinctId
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
/** Schedule an event; omit identity for SDK-generated UUID and capture time. */
|
|
53
|
+
track(event, distinctId, identity) {
|
|
54
|
+
this.capture(event, distinctId, "person", identity);
|
|
55
|
+
}
|
|
56
|
+
/** Schedule an event without creating a person profile for an attempt or resource ID. */
|
|
57
|
+
trackAnonymous(event, distinctId, identity) {
|
|
58
|
+
this.capture(event, distinctId, "anonymous", identity);
|
|
59
|
+
}
|
|
60
|
+
capture(event, distinctId, profile, identity) {
|
|
61
|
+
const properties = { ...event.properties };
|
|
62
|
+
const payload = {
|
|
63
|
+
distinctId,
|
|
64
|
+
event: event.name,
|
|
65
|
+
properties
|
|
66
|
+
};
|
|
67
|
+
if (profile === "anonymous") payload.properties = {
|
|
68
|
+
...properties,
|
|
69
|
+
$process_person_profile: false
|
|
70
|
+
};
|
|
71
|
+
if (identity !== void 0) {
|
|
72
|
+
payload.uuid = identity.uuid;
|
|
73
|
+
payload.timestamp = identity.timestamp;
|
|
74
|
+
}
|
|
75
|
+
this.waitUntil(this.posthog.captureImmediate(payload));
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
export { PostHogAnalyticsService };
|
|
81
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","names":[],"sources":["../../src/infrastructure/posthog/server.ts"],"sourcesContent":["import { PostHog, type PostHogOptions } from 'posthog-node'\n\nimport type { AnalyticsService } from '@/application'\nimport {\n MissingConfigurationError,\n type AnalyticsEventIdentity,\n type AnalyticsEventInput,\n type AnalyticsProperties,\n} from '@/core'\n\nimport { PostHogMetricsService } from './metrics.ts'\n\n/** Deployment values and SDK options; the runtime owns delivery promises. */\nexport interface PostHogAnalyticsConfig {\n readonly apiKey: string\n readonly environment: string\n readonly source: string\n readonly waitUntil: (promise: Promise<unknown>) => void\n readonly options?: Omit<\n PostHogOptions,\n 'waitUntil' | 'flushAt' | 'flushInterval' | 'metrics' | 'disabled'\n > & {\n readonly metrics?: Omit<NonNullable<PostHogOptions['metrics']>, 'serviceName' | 'environment'>\n }\n}\n\n/** Worker analytics ported from Typist; disabled applications select Porte's NULL_ANALYTICS instead. */\nexport class PostHogAnalyticsService implements AnalyticsService {\n /** Metrics share this service's SDK client and delivery lifetime. */\n readonly metrics: PostHogMetricsService\n\n private constructor(\n /** Raw SDK access for integrations such as PostHog AI tracing. */\n readonly posthog: PostHog,\n private readonly waitUntil: (promise: Promise<unknown>) => void,\n ) {\n this.metrics = new PostHogMetricsService(posthog, waitUntil)\n }\n\n /** Construct once per Worker invocation; a blank key throws MissingConfigurationError. */\n static create(config: PostHogAnalyticsConfig): PostHogAnalyticsService {\n const apiKey = config.apiKey.trim()\n if (apiKey.length === 0) throw new MissingConfigurationError('POSTHOG_API_KEY')\n const client = new PostHog(apiKey, {\n host: 'https://us.i.posthog.com',\n ...config.options,\n flushAt: 1,\n flushInterval: 0,\n waitUntil: config.waitUntil,\n metrics: {\n ...config.options?.metrics,\n environment: config.environment,\n serviceName: config.source,\n },\n })\n // The SDK applies in-memory super properties synchronously before this promise resolves.\n void client.register({ environment: config.environment, source: config.source })\n return new PostHogAnalyticsService(client, config.waitUntil)\n }\n\n /** Schedule person properties; the SDK's waitUntil option protects queued delivery. */\n identify(distinctId: string, properties?: AnalyticsProperties): void {\n const payload: Parameters<PostHog['identify']>[0] = { distinctId }\n if (properties !== undefined) payload.properties = properties\n this.posthog.identify(payload)\n }\n\n /** Schedule an irreversible person merge; only alias IDs the application proves belong to one person. */\n alias(distinctId: string, previousDistinctId: string): void {\n this.waitUntil(this.posthog.aliasImmediate({ distinctId, alias: previousDistinctId }))\n }\n\n /** Schedule an event; omit identity for SDK-generated UUID and capture time. */\n track(event: AnalyticsEventInput, distinctId: string, identity?: AnalyticsEventIdentity): void {\n this.capture(event, distinctId, 'person', identity)\n }\n\n /** Schedule an event without creating a person profile for an attempt or resource ID. */\n trackAnonymous(\n event: AnalyticsEventInput,\n distinctId: string,\n identity?: AnalyticsEventIdentity,\n ): void {\n this.capture(event, distinctId, 'anonymous', identity)\n }\n\n private capture(\n event: AnalyticsEventInput,\n distinctId: string,\n profile: 'person' | 'anonymous',\n identity?: AnalyticsEventIdentity,\n ): void {\n const properties = { ...event.properties }\n const payload: Parameters<PostHog['captureImmediate']>[0] = {\n distinctId,\n event: event.name,\n properties,\n }\n if (profile === 'anonymous')\n payload.properties = { ...properties, $process_person_profile: false }\n if (identity !== undefined) {\n payload.uuid = identity.uuid\n payload.timestamp = identity.timestamp\n }\n this.waitUntil(this.posthog.captureImmediate(payload))\n }\n}\n"],"mappings":";;;;;;AA2BA,IAAa,0BAAb,MAAa,wBAAoD;CAMpD;CACQ;;CALnB,AAAS;CAET,AAAQ,YAEN,AAAS,SACT,AAAiB,WACjB;EAFS;EACQ;EAEjB,KAAK,UAAU,IAAI,sBAAsB,SAAS,SAAS;CAC7D;;CAGA,OAAO,OAAO,QAAyD;EACrE,MAAM,SAAS,OAAO,OAAO,KAAK;EAClC,IAAI,OAAO,WAAW,GAAG,MAAM,IAAI,0BAA0B,iBAAiB;EAC9E,MAAM,SAAS,IAAI,QAAQ,QAAQ;GACjC,MAAM;GACN,GAAG,OAAO;GACV,SAAS;GACT,eAAe;GACf,WAAW,OAAO;GAClB,SAAS;IACP,GAAG,OAAO,SAAS;IACnB,aAAa,OAAO;IACpB,aAAa,OAAO;GACtB;EACF,CAAC;EAED,AAAK,OAAO,SAAS;GAAE,aAAa,OAAO;GAAa,QAAQ,OAAO;EAAO,CAAC;EAC/E,OAAO,IAAI,wBAAwB,QAAQ,OAAO,SAAS;CAC7D;;CAGA,SAAS,YAAoB,YAAwC;EACnE,MAAM,UAA8C,EAAE,WAAW;EACjE,IAAI,eAAe,QAAW,QAAQ,aAAa;EACnD,KAAK,QAAQ,SAAS,OAAO;CAC/B;;CAGA,MAAM,YAAoB,oBAAkC;EAC1D,KAAK,UAAU,KAAK,QAAQ,eAAe;GAAE;GAAY,OAAO;EAAmB,CAAC,CAAC;CACvF;;CAGA,MAAM,OAA4B,YAAoB,UAAyC;EAC7F,KAAK,QAAQ,OAAO,YAAY,UAAU,QAAQ;CACpD;;CAGA,eACE,OACA,YACA,UACM;EACN,KAAK,QAAQ,OAAO,YAAY,aAAa,QAAQ;CACvD;CAEA,AAAQ,QACN,OACA,YACA,SACA,UACM;EACN,MAAM,aAAa,EAAE,GAAG,MAAM,WAAW;EACzC,MAAM,UAAsD;GAC1D;GACA,OAAO,MAAM;GACb;EACF;EACA,IAAI,YAAY,aACd,QAAQ,aAAa;GAAE,GAAG;GAAY,yBAAyB;EAAM;EACvE,IAAI,aAAa,QAAW;GAC1B,QAAQ,OAAO,SAAS;GACxB,QAAQ,YAAY,SAAS;EAC/B;EACA,KAAK,UAAU,KAAK,QAAQ,iBAAiB,OAAO,CAAC;CACvD;AACF"}
|
package/dist/resend.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Mt as BounceType } from "./index-
|
|
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 { Mt as BounceType } from "./index-G1QG0P5g.js";
|
|
2
|
+
import { B as OutboundEmail, I as EmailAccepted, R as IEmailService } from "./index-C28HgVfY.js";
|
|
3
|
+
import { r as WebhookVerifier, t as WebhookVerification } from "./webhook-verification-D7DIhH6C.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 { Q as EmailAddressSchema, Y as EmailServiceError, q as parseBounceType } from "./core-
|
|
2
|
-
import { t as WebhookVerificationError } from "./webhook-verification-
|
|
1
|
+
import { Q as EmailAddressSchema, Y as EmailServiceError, q as parseBounceType } from "./core-hdaNiCOU.js";
|
|
2
|
+
import { t as WebhookVerificationError } from "./webhook-verification-trEgyz7I.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { Buffer } from "node:buffer";
|
|
5
5
|
|