better-ship 0.24.0 → 0.26.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-C_xN_1pa.js.map +1 -1
- package/dist/application.d.ts +2 -2
- package/dist/auth-secondary-storage-b9ptwPSB.d.ts +37 -0
- package/dist/auth-secondary-storage-b9ptwPSB.d.ts.map +1 -0
- package/dist/better-auth/secondary-storage.d.ts +1 -1
- package/dist/bin/notify-ci.d.ts +1 -0
- package/dist/bin/notify-ci.js +24 -0
- package/dist/bin/notify-ci.js.map +1 -0
- package/dist/client-Dv1Ch7yY.js +20 -0
- package/dist/client-Dv1Ch7yY.js.map +1 -0
- package/dist/cloudflare/auth-secondary-storage.d.ts +2 -36
- package/dist/cloudflare/durable-object-client.js +1 -1
- package/dist/cloudflare/durable-object-errors.js +2 -47
- package/dist/cloudflare/kv-client.js +1 -1
- package/dist/cloudflare/kv-errors.js +2 -143
- package/dist/cloudflare/queue.d.ts +1 -1
- package/dist/cloudflare/r2-client.js +1 -1
- package/dist/cloudflare/r2-errors.js +2 -89
- package/dist/cloudflare.d.ts +2 -2
- package/dist/durable-object-errors-DkMFXQnK.js +48 -0
- package/dist/durable-object-errors-DkMFXQnK.js.map +1 -0
- package/dist/{index-tNZHSCpJ.d.ts → index-lS_g1olK.d.ts} +17 -2
- package/dist/index-lS_g1olK.d.ts.map +1 -0
- package/dist/kv-errors-BUTpFy0t.js +144 -0
- package/dist/kv-errors-BUTpFy0t.js.map +1 -0
- package/dist/metrics-CWv37yf9.js +30 -0
- package/dist/metrics-CWv37yf9.js.map +1 -0
- package/dist/metrics-cv9P5nvk.d.ts +19 -0
- package/dist/metrics-cv9P5nvk.d.ts.map +1 -0
- package/dist/{outbox-repository-options-_B8l8l6l.d.ts → outbox-repository-options-15Sv9WnG.d.ts} +2 -2
- package/dist/{outbox-repository-options-_B8l8l6l.d.ts.map → outbox-repository-options-15Sv9WnG.d.ts.map} +1 -1
- package/dist/payment-service-DUYd3Itt.d.ts +52 -0
- package/dist/payment-service-DUYd3Itt.d.ts.map +1 -0
- package/dist/payment-service.error-CqF7GkNp.js +30 -0
- package/dist/payment-service.error-CqF7GkNp.js.map +1 -0
- package/dist/postgres.d.ts +2 -2
- package/dist/posthog/metrics.d.ts +2 -18
- package/dist/posthog/metrics.js +2 -29
- package/dist/posthog/server.d.ts +2 -2
- package/dist/posthog/server.js +1 -1
- package/dist/r2-errors-rk7n7rvk.js +90 -0
- package/dist/r2-errors-rk7n7rvk.js.map +1 -0
- package/dist/request-4vJEWxyZ.js +21 -0
- package/dist/request-4vJEWxyZ.js.map +1 -0
- package/dist/resend.d.ts +6 -1
- package/dist/resend.d.ts.map +1 -1
- package/dist/resend.js +35 -0
- package/dist/resend.js.map +1 -1
- package/dist/sentry/server.d.ts +1 -1
- package/dist/slack-webhook-j1FCPeu8.js +270 -0
- package/dist/slack-webhook-j1FCPeu8.js.map +1 -0
- package/dist/slack.d.ts +102 -0
- package/dist/slack.d.ts.map +1 -0
- package/dist/slack.js +3 -0
- package/dist/stripe/client.js +2 -19
- package/dist/stripe/payment-service.d.ts +2 -51
- package/dist/stripe/payment-service.error.js +2 -29
- package/dist/stripe/payment-service.js +1 -1
- package/dist/stripe/request.js +2 -20
- package/dist/stripe-fixture-yFUknTJO.js +33 -0
- package/dist/stripe-fixture-yFUknTJO.js.map +1 -0
- package/dist/testing/outbox-repository.d.ts +1 -1
- package/dist/testing/payment-service.d.ts +1 -1
- package/dist/testing/payment-service.js +2 -2
- package/dist/testing/stripe.js +2 -32
- package/package.json +6 -1
- package/src/application/email-service.ts +17 -0
- package/src/application/index.ts +2 -0
- package/src/infrastructure/resend/resend-email-service.ts +39 -0
- package/src/infrastructure/slack/ci-message.ts +276 -0
- package/src/infrastructure/slack/index.ts +10 -0
- package/src/infrastructure/slack/notify-ci.ts +22 -0
- package/src/infrastructure/slack/slack-webhook.ts +36 -0
- package/dist/cloudflare/auth-secondary-storage.d.ts.map +0 -1
- package/dist/cloudflare/durable-object-errors.js.map +0 -1
- package/dist/cloudflare/kv-errors.js.map +0 -1
- package/dist/cloudflare/r2-errors.js.map +0 -1
- package/dist/index-tNZHSCpJ.d.ts.map +0 -1
- package/dist/posthog/metrics.d.ts.map +0 -1
- package/dist/posthog/metrics.js.map +0 -1
- package/dist/stripe/client.js.map +0 -1
- package/dist/stripe/payment-service.d.ts.map +0 -1
- package/dist/stripe/payment-service.error.js.map +0 -1
- package/dist/stripe/request.js.map +0 -1
- package/dist/testing/stripe.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"r2-errors-rk7n7rvk.js","names":[],"sources":["../src/infrastructure/cloudflare/r2-errors.ts"],"sourcesContent":["import { z } from 'zod'\n\nimport { AppError, classifyBoundaryError, isAbortError, type FailureClassification } from '@/core'\n\n/** The storage operation that failed. */\nexport type R2Operation =\n | 'head'\n | 'get'\n | 'getJson'\n | 'put'\n | 'delete'\n | 'list'\n | 'createMultipartUpload'\n | 'uploadPart'\n | 'complete'\n | 'abort'\n\n/** Provider diagnostics from the outer failure, without request bodies or credentials. */\nexport type R2Failure = {\n readonly code: number\n readonly action?: string | undefined\n}\n\nconst R2FailureSchema = z.object({\n code: z.number().int().positive(),\n action: z.string().optional(),\n})\n\n// R2 codes describe failures; the caller owns retry decisions and repeat safety.\nconst classifications: ReadonlyMap<number, FailureClassification> = new Map([\n [10001, 'transient'],\n [10043, 'transient'],\n [10054, 'transient'],\n [10058, 'transient'],\n [10013, 'transient'],\n [10002, 'terminal'],\n [10003, 'terminal'],\n [10018, 'terminal'],\n [10035, 'terminal'],\n [10042, 'terminal'],\n [10005, 'terminal'],\n [10006, 'terminal'],\n [10008, 'terminal'],\n [10009, 'terminal'],\n [10073, 'terminal'],\n [10007, 'terminal'],\n [10020, 'terminal'],\n [100100, 'terminal'],\n [10012, 'terminal'],\n [10069, 'terminal'],\n [10033, 'terminal'],\n [10014, 'terminal'],\n [10037, 'terminal'],\n [10039, 'terminal'],\n [10031, 'terminal'],\n [10011, 'terminal'],\n [10024, 'terminal'],\n [10025, 'terminal'],\n [10048, 'terminal'],\n])\n\nfunction extractR2Failure(cause: unknown): R2Failure | undefined {\n if (!(cause instanceof Error)) return undefined\n const parsed = R2FailureSchema.safeParse(cause)\n if (parsed.success) return parsed.data\n // Cloudflare documents the numeric suffix for bindings that omit structured fields.\n const match = /\\((\\d{5,6})\\)\\s*$/.exec(cause.message)\n return match?.[1] === undefined ? undefined : { code: Number(match[1]) }\n}\n\nfunction classifyR2Code(cause: unknown): FailureClassification | undefined {\n const failure = extractR2Failure(cause)\n return failure === undefined ? undefined : (classifications.get(failure.code) ?? 'unknown')\n}\n\nfunction classifyR2Error(cause: unknown): FailureClassification {\n if (isAbortError(cause)) return 'terminal'\n if (cause instanceof AppError) return cause.classification\n return classifyBoundaryError({ cause, classifyBoundary: classifyR2Code, includeCloudflare: true })\n}\n\n/** A raw binding failure after one attempt. Classification does not establish whether a mutation committed. */\nexport class R2Error extends AppError {\n readonly _tag = 'R2Error'\n readonly classification: FailureClassification\n readonly operation: R2Operation\n readonly r2?: R2Failure | undefined\n override readonly cause: unknown\n\n constructor(input: { operation: R2Operation; cause: unknown }) {\n super(`R2 ${input.operation} failed`, { cause: input.cause })\n this.operation = input.operation\n this.cause = input.cause\n this.r2 = extractR2Failure(input.cause)\n this.classification = classifyR2Error(input.cause)\n }\n}\n\n/** JSON serialization or syntax failed. Binding and body-read failures use R2Error. */\nexport class R2JsonError extends AppError {\n readonly _tag = 'R2JsonError'\n readonly classification = 'terminal'\n readonly operation: 'encode' | 'decode'\n override readonly cause: unknown\n\n constructor(input: { operation: 'encode' | 'decode'; cause: unknown }) {\n super(`R2 JSON ${input.operation} failed`, { cause: input.cause })\n this.operation = input.operation\n this.cause = input.cause\n }\n}\n"],"mappings":";;;;AAuBA,MAAM,kBAAkB,EAAE,OAAO;CAC/B,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;CAChC,QAAQ,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AAK,GAAG,OAAO;CAChC,IAAI,iBAAiB,UAAU,OAAO,MAAM;CAC5C,OAAO,sBAAsB;EAAE;EAAO,kBAAkB;EAAgB,mBAAmB;CAAK,CAAC;AACnG;;AAGA,IAAa,UAAb,cAA6B,SAAS;CACpC,AAAS,OAAO;CAChB,AAAS;CACT,AAAS;CACT,AAAS;CACT,AAAkB;CAElB,YAAY,OAAmD;EAC7D,MAAM,MAAM,MAAM,UAAU,UAAU,EAAE,OAAO,MAAM,MAAM,CAAC;EAC5D,KAAK,YAAY,MAAM;EACvB,KAAK,QAAQ,MAAM;EACnB,KAAK,KAAK,iBAAiB,MAAM,KAAK;EACtC,KAAK,iBAAiB,gBAAgB,MAAM,KAAK;CACnD;AACF;;AAGA,IAAa,cAAb,cAAiC,SAAS;CACxC,AAAS,OAAO;CAChB,AAAS,iBAAiB;CAC1B,AAAS;CACT,AAAkB;CAElB,YAAY,OAA2D;EACrE,MAAM,WAAW,MAAM,UAAU,UAAU,EAAE,OAAO,MAAM,MAAM,CAAC;EACjE,KAAK,YAAY,MAAM;EACvB,KAAK,QAAQ,MAAM;CACrB;AACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { t as PaymentServiceError } from "./payment-service.error-CqF7GkNp.js";
|
|
2
|
+
import Stripe from "stripe";
|
|
3
|
+
|
|
4
|
+
//#region src/infrastructure/stripe/request.ts
|
|
5
|
+
/**
|
|
6
|
+
* Invoke one SDK operation; the SDK owns retries configured on its client or request.
|
|
7
|
+
* Convert every Stripe error to PaymentServiceError without logging; preserve the original error in cause.
|
|
8
|
+
* Non-Stripe failures propagate unchanged.
|
|
9
|
+
*/
|
|
10
|
+
async function stripeRequest(operation, work) {
|
|
11
|
+
try {
|
|
12
|
+
return await work();
|
|
13
|
+
} catch (cause) {
|
|
14
|
+
if (!(cause instanceof Stripe.errors.StripeError)) throw cause;
|
|
15
|
+
throw new PaymentServiceError(operation, cause);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { stripeRequest as t };
|
|
21
|
+
//# sourceMappingURL=request-4vJEWxyZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-4vJEWxyZ.js","names":[],"sources":["../src/infrastructure/stripe/request.ts"],"sourcesContent":["import Stripe from 'stripe'\n\nimport { PaymentServiceError } from './payment-service.error.ts'\n\n/**\n * Invoke one SDK operation; the SDK owns retries configured on its client or request.\n * Convert every Stripe error to PaymentServiceError without logging; preserve the original error in cause.\n * Non-Stripe failures propagate unchanged.\n */\nexport async function stripeRequest<T>(operation: string, work: () => Promise<T>): Promise<T> {\n try {\n return await work()\n } catch (cause) {\n if (!(cause instanceof Stripe.errors.StripeError)) throw cause\n throw new PaymentServiceError(operation, cause)\n }\n}\n"],"mappings":";;;;;;;;;AASA,eAAsB,cAAiB,WAAmB,MAAoC;CAC5F,IAAI;EACF,OAAO,MAAM,KAAK;CACpB,SAAS,OAAO;EACd,IAAI,EAAE,iBAAiB,OAAO,OAAO,cAAc,MAAM;EACzD,MAAM,IAAI,oBAAoB,WAAW,KAAK;CAChD;AACF"}
|
package/dist/resend.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jt as BounceType } from "./index-DUFS0SJ_.js";
|
|
2
|
-
import { B as OutboundEmail, I as EmailAccepted, R as IEmailService,
|
|
2
|
+
import { B as OutboundEmail, H as ReceivedContent, I as EmailAccepted, R as IEmailService, U as ReceivedEmail } from "./index-lS_g1olK.js";
|
|
3
3
|
import { n as WebhookVerifier } from "./webhook-verification-D1c7BY4q.js";
|
|
4
4
|
import "resend";
|
|
5
5
|
//#region src/infrastructure/resend/resend-email-service.d.ts
|
|
@@ -19,6 +19,11 @@ export declare class ResendEmailService implements IEmailService {
|
|
|
19
19
|
sendEmail(email: OutboundEmail): Promise<EmailAccepted>;
|
|
20
20
|
/** Retrieve headers by the received email's provider ID. Provider failures throw EmailServiceError. */
|
|
21
21
|
getReceivedEmail(emailId: string): Promise<ReceivedEmail>;
|
|
22
|
+
/**
|
|
23
|
+
* Retrieve the sender, plain text body, and attachments by the received email's provider ID.
|
|
24
|
+
* Each attachment carries a signed download link. Provider failures throw EmailServiceError.
|
|
25
|
+
*/
|
|
26
|
+
getReceivedContent(emailId: string): Promise<ReceivedContent>;
|
|
22
27
|
private getClient;
|
|
23
28
|
}
|
|
24
29
|
//#endregion
|
package/dist/resend.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resend.d.ts","names":[],"sources":["../src/infrastructure/resend/resend-email-service.ts","../src/infrastructure/resend/email-event.ts","../src/infrastructure/resend/resend-webhook.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"resend.d.ts","names":[],"sources":["../src/infrastructure/resend/resend-email-service.ts","../src/infrastructure/resend/email-event.ts","../src/infrastructure/resend/resend-webhook.ts"],"mappings":";;;;;;;;;qBA8Fa,8BAA8B;mBAUtB;mBACA;;SATZ,OAAO,gBAAgB,sBAAsB;UAI5C;;EAGR,YACmB,gBACA;;EAIb,UAAU,OAAO,gBAAgB,QAAQ;;EA+BzC,iBAAiB,kBAAkB,QAAQ;;;;;EAoB3C,mBAAmB,kBAAkB,QAAQ;UAoBrC;;;;cC/KV;;KAYM,yBACA;KAiDP;WACM;WACA;WACA;WACA;WACA;WACA,MAAM,SAAS;WACf;;;KAIC,cACP;WACU;WACA;aACE,MAAM;aACN;aACA;;MAGZ;WAA4B;WAA+B;MAC3D;WAA4B;WAAgC;MAC5D;WAA4B,cAAc;;;;;qBC7ElC,yBAAyB,gBAAgB;mBASvB;;SAPtB,OAAO,wBAAwB;UAI9B;;EAGR,YAA6B;;EAGvB,OAAO,cAAc,SAAS,UAAU,QAAQ;UA0BxC"}
|
package/dist/resend.js
CHANGED
|
@@ -48,6 +48,16 @@ function retryAfterSeconds(value) {
|
|
|
48
48
|
const seconds = Number(value);
|
|
49
49
|
return Number.isSafeInteger(seconds) ? seconds : null;
|
|
50
50
|
}
|
|
51
|
+
function receivingError(error, headers) {
|
|
52
|
+
return new EmailServiceError({
|
|
53
|
+
reason: reasonFromResend(error),
|
|
54
|
+
provider: "resend",
|
|
55
|
+
providerCode: error.name,
|
|
56
|
+
statusCode: error.statusCode,
|
|
57
|
+
retryAfter: retryAfterSeconds(headers?.["retry-after"]),
|
|
58
|
+
cause: error
|
|
59
|
+
});
|
|
60
|
+
}
|
|
51
61
|
function toAttachment(attachment) {
|
|
52
62
|
const result = {
|
|
53
63
|
filename: attachment.filename,
|
|
@@ -113,6 +123,31 @@ var ResendEmailService = class ResendEmailService {
|
|
|
113
123
|
});
|
|
114
124
|
return { headers: result.data.headers ?? {} };
|
|
115
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Retrieve the sender, plain text body, and attachments by the received email's provider ID.
|
|
128
|
+
* Each attachment carries a signed download link. Provider failures throw EmailServiceError.
|
|
129
|
+
*/
|
|
130
|
+
async getReceivedContent(emailId) {
|
|
131
|
+
const client = await this.getClient();
|
|
132
|
+
const email = await client.emails.receiving.get(emailId);
|
|
133
|
+
if (email.error !== null) throw receivingError(email.error, email.headers);
|
|
134
|
+
const files = await client.emails.receiving.attachments.list({
|
|
135
|
+
emailId,
|
|
136
|
+
limit: 100
|
|
137
|
+
});
|
|
138
|
+
if (files.error !== null) throw receivingError(files.error, files.headers);
|
|
139
|
+
return {
|
|
140
|
+
from: email.data.from,
|
|
141
|
+
text: email.data.text,
|
|
142
|
+
attachments: files.data.data.map((file) => ({
|
|
143
|
+
filename: file.filename ?? null,
|
|
144
|
+
contentType: file.content_type,
|
|
145
|
+
size: file.size,
|
|
146
|
+
downloadUrl: file.download_url,
|
|
147
|
+
expiresAt: file.expires_at
|
|
148
|
+
}))
|
|
149
|
+
};
|
|
150
|
+
}
|
|
116
151
|
async getClient() {
|
|
117
152
|
if (this.client === void 0) {
|
|
118
153
|
const { Resend } = await import("resend");
|
package/dist/resend.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resend.js","names":[],"sources":["../src/infrastructure/resend/resend-email-service.ts","../src/infrastructure/resend/email-event.ts","../src/infrastructure/resend/resend-webhook.ts"],"sourcesContent":["import { Buffer } from 'node:buffer'\n\nimport type { Attachment, CreateEmailOptions, ErrorResponse, Resend } from 'resend'\n\nimport type {\n EmailAccepted,\n EmailAttachment,\n IEmailService,\n OutboundEmail,\n ReceivedEmail,\n} from '@/application'\nimport { EmailServiceError, type EmailSendFailureReason } from '@/core'\n\n// SDK additions must receive an explicit classification before the package builds.\nconst SDK_REASONS = {\n invalid_idempotency_key: 'invalid_request',\n validation_error: 'invalid_request',\n missing_api_key: 'configuration',\n restricted_api_key: 'configuration',\n invalid_api_key: 'configuration',\n not_found: 'invalid_request',\n method_not_allowed: 'invalid_request',\n invalid_idempotent_request: 'invalid_request',\n concurrent_idempotent_requests: 'idempotency_conflict',\n invalid_attachment: 'invalid_request',\n invalid_from_address: 'invalid_request',\n invalid_access: 'configuration',\n invalid_parameter: 'invalid_request',\n invalid_region: 'invalid_request',\n missing_required_field: 'invalid_request',\n monthly_quota_exceeded: 'quota_exceeded',\n daily_quota_exceeded: 'quota_exceeded',\n rate_limit_exceeded: 'rate_limited',\n security_error: 'configuration',\n application_error: 'provider_error',\n internal_server_error: 'provider_error',\n} satisfies Record<ErrorResponse['name'], EmailSendFailureReason>\n\n// Resend documents these codes before its SDK includes them in ErrorResponse.\nconst DOCUMENTED_REASONS = new Map<string, EmailSendFailureReason>([\n ['email_above_quota', 'quota_exceeded'],\n ['invalid_permission', 'configuration'],\n ['suspended_api_key', 'configuration'],\n ['resource_locked', 'idempotency_conflict'],\n ['service_unavailable', 'provider_error'],\n ['missing_required_parameter', 'invalid_request'],\n])\n\nfunction reasonFromResend(error: ErrorResponse): EmailSendFailureReason {\n if (Object.hasOwn(SDK_REASONS, error.name)) return SDK_REASONS[error.name]\n const reason = DOCUMENTED_REASONS.get(error.name)\n if (reason !== undefined) return reason\n if (error.statusCode === 429) return 'rate_limited'\n if (error.statusCode !== null && error.statusCode >= 400 && error.statusCode < 500)\n return 'invalid_request'\n return 'provider_error'\n}\n\nfunction retryAfterSeconds(value: string | undefined): number | null {\n if (value === undefined || !/^\\d+$/.test(value)) return null\n const seconds = Number(value)\n return Number.isSafeInteger(seconds) ? seconds : null\n}\n\nfunction toAttachment(attachment: EmailAttachment): Attachment {\n const result: Attachment = {\n filename: attachment.filename,\n content: ArrayBuffer.isView(attachment.content)\n ? Buffer.from(attachment.content)\n : attachment.content,\n }\n if (attachment.contentType !== undefined) result.contentType = attachment.contentType\n return result\n}\n\n/**\n * Send without package retries or logs. Ported from Suparelay's resend-email-service.ts.\n * The Resend SDK itself logs API errors outside production.\n */\nexport class ResendEmailService implements IEmailService {\n /** Load the SDK on the first email operation. Constructing the service does not load it. */\n static create(apiKey: string, fromAddress: string): ResendEmailService {\n return new ResendEmailService(apiKey, fromAddress)\n }\n\n private client: Resend | undefined\n\n /** Store configuration. Load the SDK and create its client on the first email operation. */\n constructor(\n private readonly apiKey: string,\n private readonly fromAddress: string,\n ) {}\n\n /** Resolve after acceptance. Provider failures throw EmailServiceError; SDK defects retain their identity. */\n async sendEmail(email: OutboundEmail): Promise<EmailAccepted> {\n const client = await this.getClient()\n const payload: CreateEmailOptions = {\n from: email.from ?? this.fromAddress,\n to: [email.to].flat(),\n subject: email.subject,\n html: email.html,\n }\n if (email.text !== undefined) payload.text = email.text\n if (email.replyTo !== undefined) payload.replyTo = email.replyTo\n if (email.tags !== undefined)\n payload.tags = Object.entries(email.tags).map(([name, value]) => ({ name, value }))\n if (email.attachments !== undefined) payload.attachments = email.attachments.map(toAttachment)\n const result = await client.emails.send(\n payload,\n email.idempotencyKey === undefined ? undefined : { idempotencyKey: email.idempotencyKey },\n )\n if (result.error !== null) {\n throw new EmailServiceError({\n reason: reasonFromResend(result.error),\n provider: 'resend',\n providerCode: result.error.name,\n statusCode: result.error.statusCode,\n retryAfter: retryAfterSeconds(result.headers?.['retry-after']),\n cause: result.error,\n })\n }\n return { providerId: result.data.id }\n }\n\n /** Retrieve headers by the received email's provider ID. Provider failures throw EmailServiceError. */\n async getReceivedEmail(emailId: string): Promise<ReceivedEmail> {\n const client = await this.getClient()\n const result = await client.emails.receiving.get(emailId)\n if (result.error !== null) {\n throw new EmailServiceError({\n reason: reasonFromResend(result.error),\n provider: 'resend',\n providerCode: result.error.name,\n statusCode: result.error.statusCode,\n retryAfter: retryAfterSeconds(result.headers?.['retry-after']),\n cause: result.error,\n })\n }\n return { headers: result.data.headers ?? {} }\n }\n\n private async getClient(): Promise<Resend> {\n if (this.client === undefined) {\n const { Resend } = await import('resend')\n // Recheck after the import so concurrent calls share one client.\n this.client ??= new Resend(this.apiKey)\n }\n return this.client\n }\n}\n","import type { WebhookEventPayload } from 'resend'\nimport { z } from 'zod'\n\nimport { EmailAddressSchema, parseBounceType, type BounceType } from '@/core'\n\nconst SIMPLE_EMAIL_TYPES = [\n 'email.sent',\n 'email.scheduled',\n 'email.delivered',\n 'email.delivery_delayed',\n 'email.complained',\n 'email.opened',\n 'email.received',\n 'email.suppressed',\n] as const\n\n/** Resend email event names supported by this module. */\nexport type EmailEventType =\n | (typeof SIMPLE_EMAIL_TYPES)[number]\n | 'email.bounced'\n | 'email.failed'\n | 'email.clicked'\n\nconst EMAIL_TYPES = {\n 'email.sent': true,\n 'email.scheduled': true,\n 'email.delivered': true,\n 'email.delivery_delayed': true,\n 'email.complained': true,\n 'email.opened': true,\n 'email.received': true,\n 'email.suppressed': true,\n 'email.bounced': true,\n 'email.failed': true,\n 'email.clicked': true,\n} satisfies Record<Extract<WebhookEventPayload['type'], `email.${string}`>, true>\n\nconst BaseDataSchema = z.object({\n email_id: z.string().min(1),\n message_id: z.string().min(1),\n to: z.array(EmailAddressSchema).min(1),\n subject: z.string(),\n tags: z.record(z.string(), z.string()).default({}),\n})\n\nconst EmailPayloadSchema = z.discriminatedUnion('type', [\n z.object({ type: z.enum(SIMPLE_EMAIL_TYPES), data: BaseDataSchema }),\n z.object({\n type: z.literal('email.bounced'),\n data: BaseDataSchema.extend({\n bounce: z.object({\n type: z.string().optional(),\n subType: z.string().nullable().optional(),\n message: z.string(),\n }),\n }),\n }),\n z.object({\n type: z.literal('email.failed'),\n data: BaseDataSchema.extend({ failed: z.object({ reason: z.string() }) }),\n }),\n z.object({\n type: z.literal('email.clicked'),\n data: BaseDataSchema.extend({ click: z.object({ link: z.string() }) }),\n }),\n])\n\ntype EmailEventBase = {\n readonly id: string\n readonly emailId: string\n readonly messageId: string\n readonly recipients: readonly string[]\n readonly subject: string\n readonly tags: Readonly<Record<string, string>>\n readonly occurredAt: string\n}\n\n/** A verified event. `id` is the Svix identity; use `resend:event:${id}` as the command id. */\nexport type EmailEvent =\n | (EmailEventBase & {\n readonly type: 'email.bounced'\n readonly bounce: {\n readonly type: BounceType\n readonly subType: string | null\n readonly message: string\n }\n })\n | (EmailEventBase & { readonly type: 'email.failed'; readonly reason: string })\n | (EmailEventBase & { readonly type: 'email.clicked'; readonly link: string })\n | (EmailEventBase & { readonly type: (typeof SIMPLE_EMAIL_TYPES)[number] })\n\nconst EventHeaderSchema = z.object({\n type: z.string(),\n created_at: z.iso.datetime({ offset: true }),\n})\n\n/** Validate signed provider data before projecting it into the public event contract. */\nexport function parseEmailEvent(payload: WebhookEventPayload, id: string): EmailEvent | null {\n const header = EventHeaderSchema.parse(payload)\n if (!Object.hasOwn(EMAIL_TYPES, header.type)) return null\n const event = EmailPayloadSchema.parse(payload)\n const base: EmailEventBase = {\n id,\n emailId: event.data.email_id,\n messageId: event.data.message_id,\n recipients: event.data.to,\n subject: event.data.subject,\n tags: event.data.tags,\n occurredAt: header.created_at,\n }\n switch (event.type) {\n case 'email.bounced':\n return {\n ...base,\n type: event.type,\n bounce: {\n type: parseBounceType(event.data.bounce.type),\n subType: event.data.bounce.subType ?? null,\n message: event.data.bounce.message,\n },\n }\n case 'email.failed':\n return { ...base, type: event.type, reason: event.data.failed.reason }\n case 'email.clicked':\n return { ...base, type: event.type, link: event.data.click.link }\n default:\n return { ...base, type: event.type }\n }\n}\n","import type { Resend } from 'resend'\nimport { z } from 'zod'\n\nimport { WebhookVerificationError, type WebhookVerifier } from '../http/webhook-verification.ts'\nimport { parseEmailEvent, type EmailEvent } from './email-event.ts'\n\n// Separate standardwebhooks versions have different prototypes; its error name remains the same.\nconst SignatureErrorSchema = z\n .instanceof(Error)\n .refine((error) => error.name === 'WebhookVerificationError')\n\n/** Verify Svix signatures and map Resend email events. Ported from Typist's Resend route. */\nexport class ResendWebhook implements WebhookVerifier<EmailEvent> {\n /** Load the SDK on the first verification. Only the webhook secret is required. */\n static create(webhookSecret: string): ResendWebhook {\n return new ResendWebhook(webhookSecret)\n }\n\n private client: Resend['webhooks'] | undefined\n\n /** Store the webhook secret. Load the SDK on the first verification. */\n constructor(private readonly webhookSecret: string) {}\n\n /** Verify the raw body and Svix headers. Invalid requests throw typed errors; other failures propagate. */\n async verify(body: string, headers: Headers): Promise<EmailEvent | null> {\n const id = headers.get('svix-id')\n const timestamp = headers.get('svix-timestamp')\n const signature = headers.get('svix-signature')\n if (!id || !timestamp || !signature) throw new WebhookVerificationError('missing_headers')\n const client = await this.getClient()\n let payload: ReturnType<Resend['webhooks']['verify']>\n try {\n payload = client.verify({\n payload: body,\n headers: { id, timestamp, signature },\n webhookSecret: this.webhookSecret,\n })\n } catch (cause) {\n if (cause instanceof SyntaxError) throw new WebhookVerificationError('invalid_payload', cause)\n if (!SignatureErrorSchema.safeParse(cause).success) throw cause\n throw new WebhookVerificationError('invalid_signature', cause)\n }\n try {\n return parseEmailEvent(payload, id)\n } catch (cause) {\n if (cause instanceof z.ZodError) throw new WebhookVerificationError('invalid_payload', cause)\n throw cause\n }\n }\n\n private async getClient(): Promise<Resend['webhooks']> {\n if (this.client === undefined) {\n const { Resend } = await import('resend')\n // The SDK requires a nonempty key even though its local verifier never uses that key.\n this.client ??= new Resend('re_webhook_verification_only').webhooks\n }\n return this.client\n }\n}\n"],"mappings":";;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ACA,OAAO,KAAK;CACd;AACF"}
|
|
1
|
+
{"version":3,"file":"resend.js","names":[],"sources":["../src/infrastructure/resend/resend-email-service.ts","../src/infrastructure/resend/email-event.ts","../src/infrastructure/resend/resend-webhook.ts"],"sourcesContent":["import { Buffer } from 'node:buffer'\n\nimport type { Attachment, CreateEmailOptions, ErrorResponse, Resend } from 'resend'\n\nimport type {\n EmailAccepted,\n EmailAttachment,\n IEmailService,\n OutboundEmail,\n ReceivedContent,\n ReceivedEmail,\n} from '@/application'\nimport { EmailServiceError, type EmailSendFailureReason } from '@/core'\n\n// SDK additions must receive an explicit classification before the package builds.\nconst SDK_REASONS = {\n invalid_idempotency_key: 'invalid_request',\n validation_error: 'invalid_request',\n missing_api_key: 'configuration',\n restricted_api_key: 'configuration',\n invalid_api_key: 'configuration',\n not_found: 'invalid_request',\n method_not_allowed: 'invalid_request',\n invalid_idempotent_request: 'invalid_request',\n concurrent_idempotent_requests: 'idempotency_conflict',\n invalid_attachment: 'invalid_request',\n invalid_from_address: 'invalid_request',\n invalid_access: 'configuration',\n invalid_parameter: 'invalid_request',\n invalid_region: 'invalid_request',\n missing_required_field: 'invalid_request',\n monthly_quota_exceeded: 'quota_exceeded',\n daily_quota_exceeded: 'quota_exceeded',\n rate_limit_exceeded: 'rate_limited',\n security_error: 'configuration',\n application_error: 'provider_error',\n internal_server_error: 'provider_error',\n} satisfies Record<ErrorResponse['name'], EmailSendFailureReason>\n\n// Resend documents these codes before its SDK includes them in ErrorResponse.\nconst DOCUMENTED_REASONS = new Map<string, EmailSendFailureReason>([\n ['email_above_quota', 'quota_exceeded'],\n ['invalid_permission', 'configuration'],\n ['suspended_api_key', 'configuration'],\n ['resource_locked', 'idempotency_conflict'],\n ['service_unavailable', 'provider_error'],\n ['missing_required_parameter', 'invalid_request'],\n])\n\nfunction reasonFromResend(error: ErrorResponse): EmailSendFailureReason {\n if (Object.hasOwn(SDK_REASONS, error.name)) return SDK_REASONS[error.name]\n const reason = DOCUMENTED_REASONS.get(error.name)\n if (reason !== undefined) return reason\n if (error.statusCode === 429) return 'rate_limited'\n if (error.statusCode !== null && error.statusCode >= 400 && error.statusCode < 500)\n return 'invalid_request'\n return 'provider_error'\n}\n\nfunction retryAfterSeconds(value: string | undefined): number | null {\n if (value === undefined || !/^\\d+$/.test(value)) return null\n const seconds = Number(value)\n return Number.isSafeInteger(seconds) ? seconds : null\n}\n\nfunction receivingError(\n error: ErrorResponse,\n headers: Record<string, string> | null,\n): EmailServiceError {\n return new EmailServiceError({\n reason: reasonFromResend(error),\n provider: 'resend',\n providerCode: error.name,\n statusCode: error.statusCode,\n retryAfter: retryAfterSeconds(headers?.['retry-after']),\n cause: error,\n })\n}\n\nfunction toAttachment(attachment: EmailAttachment): Attachment {\n const result: Attachment = {\n filename: attachment.filename,\n content: ArrayBuffer.isView(attachment.content)\n ? Buffer.from(attachment.content)\n : attachment.content,\n }\n if (attachment.contentType !== undefined) result.contentType = attachment.contentType\n return result\n}\n\n/**\n * Send without package retries or logs. Ported from Suparelay's resend-email-service.ts.\n * The Resend SDK itself logs API errors outside production.\n */\nexport class ResendEmailService implements IEmailService {\n /** Load the SDK on the first email operation. Constructing the service does not load it. */\n static create(apiKey: string, fromAddress: string): ResendEmailService {\n return new ResendEmailService(apiKey, fromAddress)\n }\n\n private client: Resend | undefined\n\n /** Store configuration. Load the SDK and create its client on the first email operation. */\n constructor(\n private readonly apiKey: string,\n private readonly fromAddress: string,\n ) {}\n\n /** Resolve after acceptance. Provider failures throw EmailServiceError; SDK defects retain their identity. */\n async sendEmail(email: OutboundEmail): Promise<EmailAccepted> {\n const client = await this.getClient()\n const payload: CreateEmailOptions = {\n from: email.from ?? this.fromAddress,\n to: [email.to].flat(),\n subject: email.subject,\n html: email.html,\n }\n if (email.text !== undefined) payload.text = email.text\n if (email.replyTo !== undefined) payload.replyTo = email.replyTo\n if (email.tags !== undefined)\n payload.tags = Object.entries(email.tags).map(([name, value]) => ({ name, value }))\n if (email.attachments !== undefined) payload.attachments = email.attachments.map(toAttachment)\n const result = await client.emails.send(\n payload,\n email.idempotencyKey === undefined ? undefined : { idempotencyKey: email.idempotencyKey },\n )\n if (result.error !== null) {\n throw new EmailServiceError({\n reason: reasonFromResend(result.error),\n provider: 'resend',\n providerCode: result.error.name,\n statusCode: result.error.statusCode,\n retryAfter: retryAfterSeconds(result.headers?.['retry-after']),\n cause: result.error,\n })\n }\n return { providerId: result.data.id }\n }\n\n /** Retrieve headers by the received email's provider ID. Provider failures throw EmailServiceError. */\n async getReceivedEmail(emailId: string): Promise<ReceivedEmail> {\n const client = await this.getClient()\n const result = await client.emails.receiving.get(emailId)\n if (result.error !== null) {\n throw new EmailServiceError({\n reason: reasonFromResend(result.error),\n provider: 'resend',\n providerCode: result.error.name,\n statusCode: result.error.statusCode,\n retryAfter: retryAfterSeconds(result.headers?.['retry-after']),\n cause: result.error,\n })\n }\n return { headers: result.data.headers ?? {} }\n }\n\n /**\n * Retrieve the sender, plain text body, and attachments by the received email's provider ID.\n * Each attachment carries a signed download link. Provider failures throw EmailServiceError.\n */\n async getReceivedContent(emailId: string): Promise<ReceivedContent> {\n const client = await this.getClient()\n const email = await client.emails.receiving.get(emailId)\n if (email.error !== null) throw receivingError(email.error, email.headers)\n // One page of 100, the API maximum, holds the attachments of any received email.\n const files = await client.emails.receiving.attachments.list({ emailId, limit: 100 })\n if (files.error !== null) throw receivingError(files.error, files.headers)\n return {\n from: email.data.from,\n text: email.data.text,\n attachments: files.data.data.map((file) => ({\n filename: file.filename ?? null,\n contentType: file.content_type,\n size: file.size,\n downloadUrl: file.download_url,\n expiresAt: file.expires_at,\n })),\n }\n }\n\n private async getClient(): Promise<Resend> {\n if (this.client === undefined) {\n const { Resend } = await import('resend')\n // Recheck after the import so concurrent calls share one client.\n this.client ??= new Resend(this.apiKey)\n }\n return this.client\n }\n}\n","import type { WebhookEventPayload } from 'resend'\nimport { z } from 'zod'\n\nimport { EmailAddressSchema, parseBounceType, type BounceType } from '@/core'\n\nconst SIMPLE_EMAIL_TYPES = [\n 'email.sent',\n 'email.scheduled',\n 'email.delivered',\n 'email.delivery_delayed',\n 'email.complained',\n 'email.opened',\n 'email.received',\n 'email.suppressed',\n] as const\n\n/** Resend email event names supported by this module. */\nexport type EmailEventType =\n | (typeof SIMPLE_EMAIL_TYPES)[number]\n | 'email.bounced'\n | 'email.failed'\n | 'email.clicked'\n\nconst EMAIL_TYPES = {\n 'email.sent': true,\n 'email.scheduled': true,\n 'email.delivered': true,\n 'email.delivery_delayed': true,\n 'email.complained': true,\n 'email.opened': true,\n 'email.received': true,\n 'email.suppressed': true,\n 'email.bounced': true,\n 'email.failed': true,\n 'email.clicked': true,\n} satisfies Record<Extract<WebhookEventPayload['type'], `email.${string}`>, true>\n\nconst BaseDataSchema = z.object({\n email_id: z.string().min(1),\n message_id: z.string().min(1),\n to: z.array(EmailAddressSchema).min(1),\n subject: z.string(),\n tags: z.record(z.string(), z.string()).default({}),\n})\n\nconst EmailPayloadSchema = z.discriminatedUnion('type', [\n z.object({ type: z.enum(SIMPLE_EMAIL_TYPES), data: BaseDataSchema }),\n z.object({\n type: z.literal('email.bounced'),\n data: BaseDataSchema.extend({\n bounce: z.object({\n type: z.string().optional(),\n subType: z.string().nullable().optional(),\n message: z.string(),\n }),\n }),\n }),\n z.object({\n type: z.literal('email.failed'),\n data: BaseDataSchema.extend({ failed: z.object({ reason: z.string() }) }),\n }),\n z.object({\n type: z.literal('email.clicked'),\n data: BaseDataSchema.extend({ click: z.object({ link: z.string() }) }),\n }),\n])\n\ntype EmailEventBase = {\n readonly id: string\n readonly emailId: string\n readonly messageId: string\n readonly recipients: readonly string[]\n readonly subject: string\n readonly tags: Readonly<Record<string, string>>\n readonly occurredAt: string\n}\n\n/** A verified event. `id` is the Svix identity; use `resend:event:${id}` as the command id. */\nexport type EmailEvent =\n | (EmailEventBase & {\n readonly type: 'email.bounced'\n readonly bounce: {\n readonly type: BounceType\n readonly subType: string | null\n readonly message: string\n }\n })\n | (EmailEventBase & { readonly type: 'email.failed'; readonly reason: string })\n | (EmailEventBase & { readonly type: 'email.clicked'; readonly link: string })\n | (EmailEventBase & { readonly type: (typeof SIMPLE_EMAIL_TYPES)[number] })\n\nconst EventHeaderSchema = z.object({\n type: z.string(),\n created_at: z.iso.datetime({ offset: true }),\n})\n\n/** Validate signed provider data before projecting it into the public event contract. */\nexport function parseEmailEvent(payload: WebhookEventPayload, id: string): EmailEvent | null {\n const header = EventHeaderSchema.parse(payload)\n if (!Object.hasOwn(EMAIL_TYPES, header.type)) return null\n const event = EmailPayloadSchema.parse(payload)\n const base: EmailEventBase = {\n id,\n emailId: event.data.email_id,\n messageId: event.data.message_id,\n recipients: event.data.to,\n subject: event.data.subject,\n tags: event.data.tags,\n occurredAt: header.created_at,\n }\n switch (event.type) {\n case 'email.bounced':\n return {\n ...base,\n type: event.type,\n bounce: {\n type: parseBounceType(event.data.bounce.type),\n subType: event.data.bounce.subType ?? null,\n message: event.data.bounce.message,\n },\n }\n case 'email.failed':\n return { ...base, type: event.type, reason: event.data.failed.reason }\n case 'email.clicked':\n return { ...base, type: event.type, link: event.data.click.link }\n default:\n return { ...base, type: event.type }\n }\n}\n","import type { Resend } from 'resend'\nimport { z } from 'zod'\n\nimport { WebhookVerificationError, type WebhookVerifier } from '../http/webhook-verification.ts'\nimport { parseEmailEvent, type EmailEvent } from './email-event.ts'\n\n// Separate standardwebhooks versions have different prototypes; its error name remains the same.\nconst SignatureErrorSchema = z\n .instanceof(Error)\n .refine((error) => error.name === 'WebhookVerificationError')\n\n/** Verify Svix signatures and map Resend email events. Ported from Typist's Resend route. */\nexport class ResendWebhook implements WebhookVerifier<EmailEvent> {\n /** Load the SDK on the first verification. Only the webhook secret is required. */\n static create(webhookSecret: string): ResendWebhook {\n return new ResendWebhook(webhookSecret)\n }\n\n private client: Resend['webhooks'] | undefined\n\n /** Store the webhook secret. Load the SDK on the first verification. */\n constructor(private readonly webhookSecret: string) {}\n\n /** Verify the raw body and Svix headers. Invalid requests throw typed errors; other failures propagate. */\n async verify(body: string, headers: Headers): Promise<EmailEvent | null> {\n const id = headers.get('svix-id')\n const timestamp = headers.get('svix-timestamp')\n const signature = headers.get('svix-signature')\n if (!id || !timestamp || !signature) throw new WebhookVerificationError('missing_headers')\n const client = await this.getClient()\n let payload: ReturnType<Resend['webhooks']['verify']>\n try {\n payload = client.verify({\n payload: body,\n headers: { id, timestamp, signature },\n webhookSecret: this.webhookSecret,\n })\n } catch (cause) {\n if (cause instanceof SyntaxError) throw new WebhookVerificationError('invalid_payload', cause)\n if (!SignatureErrorSchema.safeParse(cause).success) throw cause\n throw new WebhookVerificationError('invalid_signature', cause)\n }\n try {\n return parseEmailEvent(payload, id)\n } catch (cause) {\n if (cause instanceof z.ZodError) throw new WebhookVerificationError('invalid_payload', cause)\n throw cause\n }\n }\n\n private async getClient(): Promise<Resend['webhooks']> {\n if (this.client === undefined) {\n const { Resend } = await import('resend')\n // The SDK requires a nonempty key even though its local verifier never uses that key.\n this.client ??= new Resend('re_webhook_verification_only').webhooks\n }\n return this.client\n }\n}\n"],"mappings":";;;;;;AAeA,MAAM,cAAc;CAClB,yBAAyB;CACzB,kBAAkB;CAClB,iBAAiB;CACjB,oBAAoB;CACpB,iBAAiB;CACjB,WAAW;CACX,oBAAoB;CACpB,4BAA4B;CAC5B,gCAAgC;CAChC,oBAAoB;CACpB,sBAAsB;CACtB,gBAAgB;CAChB,mBAAmB;CACnB,gBAAgB;CAChB,wBAAwB;CACxB,wBAAwB;CACxB,sBAAsB;CACtB,qBAAqB;CACrB,gBAAgB;CAChB,mBAAmB;CACnB,uBAAuB;AACzB;AAGA,MAAM,qCAAqB,IAAI,IAAoC;CACjE,CAAC,qBAAqB,gBAAgB;CACtC,CAAC,sBAAsB,eAAe;CACtC,CAAC,qBAAqB,eAAe;CACrC,CAAC,mBAAmB,sBAAsB;CAC1C,CAAC,uBAAuB,gBAAgB;CACxC,CAAC,8BAA8B,iBAAiB;AAClD,CAAC;AAED,SAAS,iBAAiB,OAA8C;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,mBAAmB,KAAK;GAC5F,MAAM;EACR;CACF;CAEA,MAAc,YAAyC;EACrD,IAAI,KAAK,WAAW,QAAW;GAC7B,MAAM,EAAE,WAAW,MAAM,OAAO;GAEhC,KAAK,WAAW,IAAI,OAAO,8BAA8B,CAAC,CAAC;EAC7D;EACA,OAAO,KAAK;CACd;AACF"}
|
package/dist/sentry/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { u as LoggerErrorHook } from "../index-DUFS0SJ_.js";
|
|
2
|
-
import { G as
|
|
2
|
+
import { G as ObservabilityScope, K as ObservabilityService, q as ObservabilityUser } from "../index-lS_g1olK.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. */
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/infrastructure/slack/ci-message.ts
|
|
4
|
+
/** The CI environment could not be parsed. `issues` names each invalid variable. */
|
|
5
|
+
var CiRunParseError = class extends Error {
|
|
6
|
+
issues;
|
|
7
|
+
cause;
|
|
8
|
+
_tag = "CiRunParseError";
|
|
9
|
+
constructor(issues, cause) {
|
|
10
|
+
super(`Invalid CI environment: ${issues.join(", ")}`);
|
|
11
|
+
this.issues = issues;
|
|
12
|
+
this.cause = cause;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const OutcomeSchema = z.enum([
|
|
16
|
+
"success",
|
|
17
|
+
"failure",
|
|
18
|
+
"cancelled",
|
|
19
|
+
"skipped"
|
|
20
|
+
]);
|
|
21
|
+
const jsonRecord = (value) => z.string().transform((text, context) => {
|
|
22
|
+
try {
|
|
23
|
+
return JSON.parse(text);
|
|
24
|
+
} catch {
|
|
25
|
+
context.addIssue({
|
|
26
|
+
code: "custom",
|
|
27
|
+
message: "Invalid JSON"
|
|
28
|
+
});
|
|
29
|
+
return z.NEVER;
|
|
30
|
+
}
|
|
31
|
+
}).pipe(z.record(z.string(), value));
|
|
32
|
+
const CiEnvSchema = z.object({
|
|
33
|
+
REPO: z.string().regex(/^[\w.-]+\/[\w.-]+$/),
|
|
34
|
+
COMMIT_SHA: z.string().regex(/^[0-9a-f]{40}$/),
|
|
35
|
+
BRANCH: z.string().min(1),
|
|
36
|
+
RUN_URL: z.httpUrl(),
|
|
37
|
+
JOBS_JSON: jsonRecord(z.object({ result: OutcomeSchema })).optional(),
|
|
38
|
+
STEPS_JSON: jsonRecord(z.object({ outcome: OutcomeSchema })).optional(),
|
|
39
|
+
PR_NUMBER: z.coerce.number().int().positive().optional(),
|
|
40
|
+
PR_URL: z.httpUrl().optional(),
|
|
41
|
+
PR_TITLE: z.string().min(1).optional(),
|
|
42
|
+
ACTION: z.enum([
|
|
43
|
+
"check",
|
|
44
|
+
"deploy",
|
|
45
|
+
"publish"
|
|
46
|
+
]).default("check"),
|
|
47
|
+
CLOUDFLARE_ACCOUNT_ID: z.string().min(1).optional(),
|
|
48
|
+
CLOUDFLARE_WORKER: z.string().min(1).optional(),
|
|
49
|
+
SITE_URL: z.httpUrl().optional(),
|
|
50
|
+
DEPLOY_VERSION_ID: z.string().min(1).optional(),
|
|
51
|
+
NPM_PACKAGE: z.string().min(1).optional(),
|
|
52
|
+
NPM_VERSION: z.string().min(1).optional()
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Parse the variables that a workflow passes to the notifier. GitHub expressions render a
|
|
56
|
+
* missing value as an empty string, so an empty variable counts as unset.
|
|
57
|
+
* @throws {CiRunParseError} when a variable is missing or invalid.
|
|
58
|
+
*/
|
|
59
|
+
function parseCiRun(env) {
|
|
60
|
+
const present = Object.fromEntries(Object.entries(env).filter(([, value]) => value !== ""));
|
|
61
|
+
const parsed = CiEnvSchema.safeParse(present);
|
|
62
|
+
if (!parsed.success) {
|
|
63
|
+
const issues = parsed.error.issues.map((issue) => issue.path.join("."));
|
|
64
|
+
throw new CiRunParseError(issues, parsed.error);
|
|
65
|
+
}
|
|
66
|
+
return toCiRun(parsed.data);
|
|
67
|
+
}
|
|
68
|
+
function toCiRun(env) {
|
|
69
|
+
const ref = env.PR_NUMBER !== void 0 && env.PR_URL !== void 0 && env.PR_TITLE !== void 0 ? {
|
|
70
|
+
kind: "pullRequest",
|
|
71
|
+
number: env.PR_NUMBER,
|
|
72
|
+
url: env.PR_URL,
|
|
73
|
+
title: env.PR_TITLE
|
|
74
|
+
} : {
|
|
75
|
+
kind: "branch",
|
|
76
|
+
name: env.BRANCH
|
|
77
|
+
};
|
|
78
|
+
return {
|
|
79
|
+
repository: env.REPO,
|
|
80
|
+
commitSha: env.COMMIT_SHA,
|
|
81
|
+
ref,
|
|
82
|
+
runUrl: env.RUN_URL,
|
|
83
|
+
jobs: Object.entries(env.JOBS_JSON ?? {}).map(([id, job]) => ({
|
|
84
|
+
name: displayName(id),
|
|
85
|
+
outcome: job.result
|
|
86
|
+
})),
|
|
87
|
+
steps: Object.entries(env.STEPS_JSON ?? {}).map(([id, step]) => ({
|
|
88
|
+
name: displayName(id),
|
|
89
|
+
outcome: step.outcome
|
|
90
|
+
})),
|
|
91
|
+
target: toTarget(env)
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function toTarget(env) {
|
|
95
|
+
switch (env.ACTION) {
|
|
96
|
+
case "check": return { kind: "check" };
|
|
97
|
+
case "deploy": {
|
|
98
|
+
const { CLOUDFLARE_ACCOUNT_ID: accountId, CLOUDFLARE_WORKER: worker, SITE_URL: siteUrl } = env;
|
|
99
|
+
if (accountId === void 0 || worker === void 0 || siteUrl === void 0) throw new CiRunParseError([
|
|
100
|
+
"CLOUDFLARE_ACCOUNT_ID",
|
|
101
|
+
"CLOUDFLARE_WORKER",
|
|
102
|
+
"SITE_URL"
|
|
103
|
+
], void 0);
|
|
104
|
+
return {
|
|
105
|
+
kind: "deploy",
|
|
106
|
+
accountId,
|
|
107
|
+
worker,
|
|
108
|
+
siteUrl,
|
|
109
|
+
versionId: env.DEPLOY_VERSION_ID
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
case "publish":
|
|
113
|
+
if (env.NPM_PACKAGE === void 0) throw new CiRunParseError(["NPM_PACKAGE"], void 0);
|
|
114
|
+
return {
|
|
115
|
+
kind: "publish",
|
|
116
|
+
packageName: env.NPM_PACKAGE,
|
|
117
|
+
version: env.NPM_VERSION
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function displayName(id) {
|
|
122
|
+
const words = id.replaceAll(/[-_]/g, " ");
|
|
123
|
+
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
124
|
+
}
|
|
125
|
+
const logos = {
|
|
126
|
+
depot: "https://avatars.githubusercontent.com/u/68166601?s=64",
|
|
127
|
+
github: "https://avatars.githubusercontent.com/u/9919?s=64",
|
|
128
|
+
cloudflare: "https://avatars.githubusercontent.com/u/314135?s=64",
|
|
129
|
+
npm: "https://avatars.githubusercontent.com/u/6078720?s=64"
|
|
130
|
+
};
|
|
131
|
+
/** Build the four-line CI message: result, change, links, and identity. */
|
|
132
|
+
function buildCiMessage(run, commit) {
|
|
133
|
+
const headline = headlineFor(run);
|
|
134
|
+
const change = run.ref.kind === "pullRequest" ? run.ref.title : commit.subject;
|
|
135
|
+
return {
|
|
136
|
+
text: `${headline} — ${change}`,
|
|
137
|
+
blocks: [
|
|
138
|
+
{
|
|
139
|
+
type: "section",
|
|
140
|
+
text: {
|
|
141
|
+
type: "mrkdwn",
|
|
142
|
+
text: `*${headline}*\n${escape(change)}`
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
type: "context",
|
|
147
|
+
elements: linkElements(run)
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
type: "context",
|
|
151
|
+
elements: [{
|
|
152
|
+
type: "mrkdwn",
|
|
153
|
+
text: identityLine(run, commit)
|
|
154
|
+
}]
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function headlineFor(run) {
|
|
160
|
+
const failedJobs = namesWith(run.jobs, "failure");
|
|
161
|
+
if (failedJobs) return `:x: CI failed: ${failedJobs}`;
|
|
162
|
+
const cancelledJobs = namesWith(run.jobs, "cancelled");
|
|
163
|
+
if (cancelledJobs) return `:white_circle: CI cancelled: ${cancelledJobs}`;
|
|
164
|
+
const failedSteps = namesWith(run.steps, "failure");
|
|
165
|
+
const { target } = run;
|
|
166
|
+
switch (target.kind) {
|
|
167
|
+
case "check": return failedSteps ? `:x: CI failed: ${failedSteps}` : ":white_check_mark: CI passed";
|
|
168
|
+
case "deploy":
|
|
169
|
+
if (failedSteps) return `:x: Deploy failed: ${failedSteps}`;
|
|
170
|
+
return target.versionId === void 0 ? ":white_check_mark: CI passed" : ":white_check_mark: Deployed to production";
|
|
171
|
+
case "publish":
|
|
172
|
+
if (failedSteps) return `:x: Publish failed: ${failedSteps}`;
|
|
173
|
+
return target.version === void 0 ? ":white_check_mark: CI passed, nothing to publish" : `:white_check_mark: Published ${target.packageName} ${target.version}`;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function namesWith(results, outcome) {
|
|
177
|
+
return results.filter((result) => result.outcome === outcome).map((result) => result.name).join(", ");
|
|
178
|
+
}
|
|
179
|
+
function linkElements(run) {
|
|
180
|
+
const runHost = new URL(run.runUrl).hostname;
|
|
181
|
+
const elements = [{
|
|
182
|
+
type: "image",
|
|
183
|
+
image_url: runHost.endsWith("github.com") ? logos.github : logos.depot,
|
|
184
|
+
alt_text: runHost
|
|
185
|
+
}, {
|
|
186
|
+
type: "mrkdwn",
|
|
187
|
+
text: `<${run.runUrl}|CI run>`
|
|
188
|
+
}];
|
|
189
|
+
const { target } = run;
|
|
190
|
+
if (target.kind === "deploy" && target.versionId !== void 0) {
|
|
191
|
+
const dashboard = `https://dash.cloudflare.com/${target.accountId}/workers/services/view/${target.worker}/production/deployments`;
|
|
192
|
+
const site = new URL(target.siteUrl);
|
|
193
|
+
elements.push({
|
|
194
|
+
type: "mrkdwn",
|
|
195
|
+
text: "·"
|
|
196
|
+
}, {
|
|
197
|
+
type: "image",
|
|
198
|
+
image_url: logos.cloudflare,
|
|
199
|
+
alt_text: "Cloudflare"
|
|
200
|
+
}, {
|
|
201
|
+
type: "mrkdwn",
|
|
202
|
+
text: `<${dashboard}|Version \`${target.versionId.slice(0, 8)}\`>`
|
|
203
|
+
}, {
|
|
204
|
+
type: "mrkdwn",
|
|
205
|
+
text: `· :globe_with_meridians: <${site.origin}|${site.host}>`
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
if (target.kind === "publish" && target.version !== void 0) {
|
|
209
|
+
const npm = `https://www.npmjs.com/package/${target.packageName}/v/${target.version}`;
|
|
210
|
+
elements.push({
|
|
211
|
+
type: "mrkdwn",
|
|
212
|
+
text: "·"
|
|
213
|
+
}, {
|
|
214
|
+
type: "image",
|
|
215
|
+
image_url: logos.npm,
|
|
216
|
+
alt_text: "npm"
|
|
217
|
+
}, {
|
|
218
|
+
type: "mrkdwn",
|
|
219
|
+
text: `<${npm}|${target.packageName}@${target.version}>`
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
return elements;
|
|
223
|
+
}
|
|
224
|
+
function identityLine(run, commit) {
|
|
225
|
+
return [
|
|
226
|
+
run.repository.split("/").at(-1) ?? run.repository,
|
|
227
|
+
run.ref.kind === "pullRequest" ? `<${run.ref.url}|PR #${run.ref.number}>` : run.ref.name,
|
|
228
|
+
`<${`https://github.com/${run.repository}/commit/${run.commitSha}`}|\`${run.commitSha.slice(0, 7)}\`>`,
|
|
229
|
+
escape(commit.author)
|
|
230
|
+
].join(" · ");
|
|
231
|
+
}
|
|
232
|
+
function escape(text) {
|
|
233
|
+
return text.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region src/infrastructure/slack/slack-webhook.ts
|
|
238
|
+
/** Slack refused the message or could not be reached. */
|
|
239
|
+
var SlackWebhookError = class extends Error {
|
|
240
|
+
status;
|
|
241
|
+
cause;
|
|
242
|
+
_tag = "SlackWebhookError";
|
|
243
|
+
constructor(status, cause) {
|
|
244
|
+
super(status === void 0 ? "Slack webhook unreachable" : `Slack webhook returned ${status}`);
|
|
245
|
+
this.status = status;
|
|
246
|
+
this.cause = cause;
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
/**
|
|
250
|
+
* Post one message to a Slack incoming webhook.
|
|
251
|
+
* @throws {SlackWebhookError} when the request fails or Slack answers with an error status.
|
|
252
|
+
*/
|
|
253
|
+
async function postSlackMessage(webhookUrl, message, fetcher = fetch) {
|
|
254
|
+
let response;
|
|
255
|
+
try {
|
|
256
|
+
response = await fetcher(webhookUrl, {
|
|
257
|
+
method: "POST",
|
|
258
|
+
headers: { "Content-Type": "application/json" },
|
|
259
|
+
body: JSON.stringify(message),
|
|
260
|
+
signal: AbortSignal.timeout(3e4)
|
|
261
|
+
});
|
|
262
|
+
} catch (cause) {
|
|
263
|
+
throw new SlackWebhookError(void 0, cause);
|
|
264
|
+
}
|
|
265
|
+
if (!response.ok) throw new SlackWebhookError(response.status, await response.text());
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
//#endregion
|
|
269
|
+
export { parseCiRun as a, buildCiMessage as i, postSlackMessage as n, CiRunParseError as r, SlackWebhookError as t };
|
|
270
|
+
//# sourceMappingURL=slack-webhook-j1FCPeu8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slack-webhook-j1FCPeu8.js","names":[],"sources":["../src/infrastructure/slack/ci-message.ts","../src/infrastructure/slack/slack-webhook.ts"],"sourcesContent":["import { z } from 'zod'\n\n/** The result of one CI job or step, in GitHub Actions terms. */\nexport type CiOutcome = 'success' | 'failure' | 'cancelled' | 'skipped'\n\n/** What the run delivers after its checks pass. */\nexport type CiTarget =\n | { readonly kind: 'check' }\n | {\n readonly kind: 'deploy'\n readonly accountId: string\n readonly worker: string\n readonly siteUrl: string\n /** Absent when the run reached no deploy, such as a pull request. */\n readonly versionId: string | undefined\n }\n | {\n readonly kind: 'publish'\n readonly packageName: string\n /** Absent when npm already has the package version. */\n readonly version: string | undefined\n }\n\n/** One CI run, parsed from the environment that the workflow sets. */\nexport interface CiRun {\n readonly repository: string\n readonly commitSha: string\n readonly ref:\n | { readonly kind: 'branch'; readonly name: string }\n | {\n readonly kind: 'pullRequest'\n readonly number: number\n readonly url: string\n readonly title: string\n }\n readonly runUrl: string\n readonly jobs: ReadonlyArray<CiStepResult>\n readonly steps: ReadonlyArray<CiStepResult>\n readonly target: CiTarget\n}\n\n/** A named job or step and its outcome. */\nexport interface CiStepResult {\n readonly name: string\n readonly outcome: CiOutcome\n}\n\n/** The commit facts that only git knows. */\nexport interface CiCommit {\n readonly subject: string\n readonly author: string\n}\n\n/** A Slack incoming-webhook payload. */\nexport interface SlackMessage {\n readonly text: string\n readonly blocks: ReadonlyArray<SlackBlock>\n}\n\ntype SlackElement =\n | { readonly type: 'mrkdwn'; readonly text: string }\n | { readonly type: 'image'; readonly image_url: string; readonly alt_text: string }\n\ntype SlackBlock =\n | { readonly type: 'section'; readonly text: { readonly type: 'mrkdwn'; readonly text: string } }\n | { readonly type: 'context'; readonly elements: ReadonlyArray<SlackElement> }\n\n/** The CI environment could not be parsed. `issues` names each invalid variable. */\nexport class CiRunParseError extends Error {\n readonly _tag = 'CiRunParseError' as const\n\n constructor(\n readonly issues: ReadonlyArray<string>,\n override readonly cause: unknown,\n ) {\n super(`Invalid CI environment: ${issues.join(', ')}`)\n }\n}\n\nconst OutcomeSchema = z.enum(['success', 'failure', 'cancelled', 'skipped'])\n\nconst jsonRecord = <T extends z.ZodType>(value: T) =>\n z\n .string()\n .transform((text, context) => {\n try {\n const value: unknown = JSON.parse(text)\n return value\n } catch {\n context.addIssue({ code: 'custom', message: 'Invalid JSON' })\n return z.NEVER\n }\n })\n .pipe(z.record(z.string(), value))\n\nconst CiEnvSchema = z.object({\n REPO: z.string().regex(/^[\\w.-]+\\/[\\w.-]+$/),\n COMMIT_SHA: z.string().regex(/^[0-9a-f]{40}$/),\n BRANCH: z.string().min(1),\n RUN_URL: z.httpUrl(),\n JOBS_JSON: jsonRecord(z.object({ result: OutcomeSchema })).optional(),\n STEPS_JSON: jsonRecord(z.object({ outcome: OutcomeSchema })).optional(),\n PR_NUMBER: z.coerce.number().int().positive().optional(),\n PR_URL: z.httpUrl().optional(),\n PR_TITLE: z.string().min(1).optional(),\n ACTION: z.enum(['check', 'deploy', 'publish']).default('check'),\n CLOUDFLARE_ACCOUNT_ID: z.string().min(1).optional(),\n CLOUDFLARE_WORKER: z.string().min(1).optional(),\n SITE_URL: z.httpUrl().optional(),\n DEPLOY_VERSION_ID: z.string().min(1).optional(),\n NPM_PACKAGE: z.string().min(1).optional(),\n NPM_VERSION: z.string().min(1).optional(),\n})\n\ntype CiEnv = z.infer<typeof CiEnvSchema>\n\n/**\n * Parse the variables that a workflow passes to the notifier. GitHub expressions render a\n * missing value as an empty string, so an empty variable counts as unset.\n * @throws {CiRunParseError} when a variable is missing or invalid.\n */\nexport function parseCiRun(env: Readonly<Record<string, string | undefined>>): CiRun {\n const present = Object.fromEntries(Object.entries(env).filter(([, value]) => value !== ''))\n const parsed = CiEnvSchema.safeParse(present)\n if (!parsed.success) {\n const issues = parsed.error.issues.map((issue) => issue.path.join('.'))\n throw new CiRunParseError(issues, parsed.error)\n }\n return toCiRun(parsed.data)\n}\n\nfunction toCiRun(env: CiEnv): CiRun {\n const ref: CiRun['ref'] =\n env.PR_NUMBER !== undefined && env.PR_URL !== undefined && env.PR_TITLE !== undefined\n ? { kind: 'pullRequest', number: env.PR_NUMBER, url: env.PR_URL, title: env.PR_TITLE }\n : { kind: 'branch', name: env.BRANCH }\n return {\n repository: env.REPO,\n commitSha: env.COMMIT_SHA,\n ref,\n runUrl: env.RUN_URL,\n jobs: Object.entries(env.JOBS_JSON ?? {}).map(([id, job]) => ({\n name: displayName(id),\n outcome: job.result,\n })),\n steps: Object.entries(env.STEPS_JSON ?? {}).map(([id, step]) => ({\n name: displayName(id),\n outcome: step.outcome,\n })),\n target: toTarget(env),\n }\n}\n\nfunction toTarget(env: CiEnv): CiTarget {\n switch (env.ACTION) {\n case 'check':\n return { kind: 'check' }\n case 'deploy': {\n const { CLOUDFLARE_ACCOUNT_ID: accountId, CLOUDFLARE_WORKER: worker, SITE_URL: siteUrl } = env\n if (accountId === undefined || worker === undefined || siteUrl === undefined) {\n throw new CiRunParseError(\n ['CLOUDFLARE_ACCOUNT_ID', 'CLOUDFLARE_WORKER', 'SITE_URL'],\n undefined,\n )\n }\n return { kind: 'deploy', accountId, worker, siteUrl, versionId: env.DEPLOY_VERSION_ID }\n }\n case 'publish':\n if (env.NPM_PACKAGE === undefined) throw new CiRunParseError(['NPM_PACKAGE'], undefined)\n return { kind: 'publish', packageName: env.NPM_PACKAGE, version: env.NPM_VERSION }\n }\n}\n\n// A job or step id such as `check-and-build` reads as \"Check and build\".\nfunction displayName(id: string): string {\n const words = id.replaceAll(/[-_]/g, ' ')\n return words.charAt(0).toUpperCase() + words.slice(1)\n}\n\nconst logos = {\n depot: 'https://avatars.githubusercontent.com/u/68166601?s=64',\n github: 'https://avatars.githubusercontent.com/u/9919?s=64',\n cloudflare: 'https://avatars.githubusercontent.com/u/314135?s=64',\n npm: 'https://avatars.githubusercontent.com/u/6078720?s=64',\n} as const\n\n/** Build the four-line CI message: result, change, links, and identity. */\nexport function buildCiMessage(run: CiRun, commit: CiCommit): SlackMessage {\n const headline = headlineFor(run)\n const change = run.ref.kind === 'pullRequest' ? run.ref.title : commit.subject\n return {\n text: `${headline} — ${change}`,\n blocks: [\n { type: 'section', text: { type: 'mrkdwn', text: `*${headline}*\\n${escape(change)}` } },\n { type: 'context', elements: linkElements(run) },\n { type: 'context', elements: [{ type: 'mrkdwn', text: identityLine(run, commit) }] },\n ],\n }\n}\n\nfunction headlineFor(run: CiRun): string {\n const failedJobs = namesWith(run.jobs, 'failure')\n if (failedJobs) return `:x: CI failed: ${failedJobs}`\n const cancelledJobs = namesWith(run.jobs, 'cancelled')\n if (cancelledJobs) return `:white_circle: CI cancelled: ${cancelledJobs}`\n const failedSteps = namesWith(run.steps, 'failure')\n const { target } = run\n switch (target.kind) {\n case 'check':\n return failedSteps ? `:x: CI failed: ${failedSteps}` : ':white_check_mark: CI passed'\n case 'deploy':\n if (failedSteps) return `:x: Deploy failed: ${failedSteps}`\n return target.versionId === undefined\n ? ':white_check_mark: CI passed'\n : ':white_check_mark: Deployed to production'\n case 'publish':\n if (failedSteps) return `:x: Publish failed: ${failedSteps}`\n return target.version === undefined\n ? ':white_check_mark: CI passed, nothing to publish'\n : `:white_check_mark: Published ${target.packageName} ${target.version}`\n }\n}\n\nfunction namesWith(results: ReadonlyArray<CiStepResult>, outcome: CiOutcome): string {\n return results\n .filter((result) => result.outcome === outcome)\n .map((result) => result.name)\n .join(', ')\n}\n\nfunction linkElements(run: CiRun): ReadonlyArray<SlackElement> {\n const runHost = new URL(run.runUrl).hostname\n const runLogo = runHost.endsWith('github.com') ? logos.github : logos.depot\n const elements: SlackElement[] = [\n { type: 'image', image_url: runLogo, alt_text: runHost },\n { type: 'mrkdwn', text: `<${run.runUrl}|CI run>` },\n ]\n const { target } = run\n if (target.kind === 'deploy' && target.versionId !== undefined) {\n const dashboard = `https://dash.cloudflare.com/${target.accountId}/workers/services/view/${target.worker}/production/deployments`\n const site = new URL(target.siteUrl)\n elements.push(\n { type: 'mrkdwn', text: '·' },\n { type: 'image', image_url: logos.cloudflare, alt_text: 'Cloudflare' },\n { type: 'mrkdwn', text: `<${dashboard}|Version \\`${target.versionId.slice(0, 8)}\\`>` },\n { type: 'mrkdwn', text: `· :globe_with_meridians: <${site.origin}|${site.host}>` },\n )\n }\n if (target.kind === 'publish' && target.version !== undefined) {\n const npm = `https://www.npmjs.com/package/${target.packageName}/v/${target.version}`\n elements.push(\n { type: 'mrkdwn', text: '·' },\n { type: 'image', image_url: logos.npm, alt_text: 'npm' },\n { type: 'mrkdwn', text: `<${npm}|${target.packageName}@${target.version}>` },\n )\n }\n return elements\n}\n\nfunction identityLine(run: CiRun, commit: CiCommit): string {\n const repository = run.repository.split('/').at(-1) ?? run.repository\n const ref =\n run.ref.kind === 'pullRequest' ? `<${run.ref.url}|PR #${run.ref.number}>` : run.ref.name\n const commitUrl = `https://github.com/${run.repository}/commit/${run.commitSha}`\n return [\n repository,\n ref,\n `<${commitUrl}|\\`${run.commitSha.slice(0, 7)}\\`>`,\n escape(commit.author),\n ].join(' · ')\n}\n\n// Slack mrkdwn treats these three characters as markup.\nfunction escape(text: string): string {\n return text.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>')\n}\n","import type { SlackMessage } from './ci-message.ts'\n\n/** Slack refused the message or could not be reached. */\nexport class SlackWebhookError extends Error {\n readonly _tag = 'SlackWebhookError' as const\n\n constructor(\n readonly status: number | undefined,\n override readonly cause: unknown,\n ) {\n super(status === undefined ? 'Slack webhook unreachable' : `Slack webhook returned ${status}`)\n }\n}\n\n/**\n * Post one message to a Slack incoming webhook.\n * @throws {SlackWebhookError} when the request fails or Slack answers with an error status.\n */\nexport async function postSlackMessage(\n webhookUrl: string,\n message: SlackMessage,\n fetcher: typeof fetch = fetch,\n): Promise<void> {\n let response: Response\n try {\n response = await fetcher(webhookUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(message),\n signal: AbortSignal.timeout(30_000),\n })\n } catch (cause) {\n throw new SlackWebhookError(undefined, cause)\n }\n if (!response.ok) throw new SlackWebhookError(response.status, await response.text())\n}\n"],"mappings":";;;;AAoEA,IAAa,kBAAb,cAAqC,MAAM;CAI9B;CACS;CAJpB,AAAS,OAAO;CAEhB,YACE,AAAS,QACT,AAAkB,OAClB;EACA,MAAM,2BAA2B,OAAO,KAAK,IAAI,GAAG;EAH3C;EACS;CAGpB;AACF;AAEA,MAAM,gBAAgB,EAAE,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,IAAI,MAAM,IAAI,kBAAkB,SAAS,QAAQ,MAAM,SAAS,KAAK,CAAC;AACtF"}
|
package/dist/slack.d.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
//#region src/infrastructure/slack/ci-message.d.ts
|
|
2
|
+
/** The result of one CI job or step, in GitHub Actions terms. */
|
|
3
|
+
type CiOutcome = 'success' | 'failure' | 'cancelled' | 'skipped';
|
|
4
|
+
/** What the run delivers after its checks pass. */
|
|
5
|
+
type CiTarget = {
|
|
6
|
+
readonly kind: 'check';
|
|
7
|
+
} | {
|
|
8
|
+
readonly kind: 'deploy';
|
|
9
|
+
readonly accountId: string;
|
|
10
|
+
readonly worker: string;
|
|
11
|
+
readonly siteUrl: string;
|
|
12
|
+
/** Absent when the run reached no deploy, such as a pull request. */
|
|
13
|
+
readonly versionId: string | undefined;
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: 'publish';
|
|
16
|
+
readonly packageName: string;
|
|
17
|
+
/** Absent when npm already has the package version. */
|
|
18
|
+
readonly version: string | undefined;
|
|
19
|
+
};
|
|
20
|
+
/** One CI run, parsed from the environment that the workflow sets. */
|
|
21
|
+
interface CiRun {
|
|
22
|
+
readonly repository: string;
|
|
23
|
+
readonly commitSha: string;
|
|
24
|
+
readonly ref: {
|
|
25
|
+
readonly kind: 'branch';
|
|
26
|
+
readonly name: string;
|
|
27
|
+
} | {
|
|
28
|
+
readonly kind: 'pullRequest';
|
|
29
|
+
readonly number: number;
|
|
30
|
+
readonly url: string;
|
|
31
|
+
readonly title: string;
|
|
32
|
+
};
|
|
33
|
+
readonly runUrl: string;
|
|
34
|
+
readonly jobs: ReadonlyArray<CiStepResult>;
|
|
35
|
+
readonly steps: ReadonlyArray<CiStepResult>;
|
|
36
|
+
readonly target: CiTarget;
|
|
37
|
+
}
|
|
38
|
+
/** A named job or step and its outcome. */
|
|
39
|
+
interface CiStepResult {
|
|
40
|
+
readonly name: string;
|
|
41
|
+
readonly outcome: CiOutcome;
|
|
42
|
+
}
|
|
43
|
+
/** The commit facts that only git knows. */
|
|
44
|
+
interface CiCommit {
|
|
45
|
+
readonly subject: string;
|
|
46
|
+
readonly author: string;
|
|
47
|
+
}
|
|
48
|
+
/** A Slack incoming-webhook payload. */
|
|
49
|
+
interface SlackMessage {
|
|
50
|
+
readonly text: string;
|
|
51
|
+
readonly blocks: ReadonlyArray<SlackBlock>;
|
|
52
|
+
}
|
|
53
|
+
type SlackElement = {
|
|
54
|
+
readonly type: 'mrkdwn';
|
|
55
|
+
readonly text: string;
|
|
56
|
+
} | {
|
|
57
|
+
readonly type: 'image';
|
|
58
|
+
readonly image_url: string;
|
|
59
|
+
readonly alt_text: string;
|
|
60
|
+
};
|
|
61
|
+
type SlackBlock = {
|
|
62
|
+
readonly type: 'section';
|
|
63
|
+
readonly text: {
|
|
64
|
+
readonly type: 'mrkdwn';
|
|
65
|
+
readonly text: string;
|
|
66
|
+
};
|
|
67
|
+
} | {
|
|
68
|
+
readonly type: 'context';
|
|
69
|
+
readonly elements: ReadonlyArray<SlackElement>;
|
|
70
|
+
};
|
|
71
|
+
/** The CI environment could not be parsed. `issues` names each invalid variable. */
|
|
72
|
+
export declare class CiRunParseError extends Error {
|
|
73
|
+
readonly issues: ReadonlyArray<string>;
|
|
74
|
+
readonly cause: unknown;
|
|
75
|
+
readonly _tag: 'CiRunParseError';
|
|
76
|
+
constructor(issues: ReadonlyArray<string>, cause: unknown);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Parse the variables that a workflow passes to the notifier. GitHub expressions render a
|
|
80
|
+
* missing value as an empty string, so an empty variable counts as unset.
|
|
81
|
+
* @throws {CiRunParseError} when a variable is missing or invalid.
|
|
82
|
+
*/
|
|
83
|
+
export declare function parseCiRun(env: Readonly<Record<string, string | undefined>>): CiRun;
|
|
84
|
+
/** Build the four-line CI message: result, change, links, and identity. */
|
|
85
|
+
export declare function buildCiMessage(run: CiRun, commit: CiCommit): SlackMessage;
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/infrastructure/slack/slack-webhook.d.ts
|
|
88
|
+
/** Slack refused the message or could not be reached. */
|
|
89
|
+
export declare class SlackWebhookError extends Error {
|
|
90
|
+
readonly status: number | undefined;
|
|
91
|
+
readonly cause: unknown;
|
|
92
|
+
readonly _tag: 'SlackWebhookError';
|
|
93
|
+
constructor(status: number | undefined, cause: unknown);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Post one message to a Slack incoming webhook.
|
|
97
|
+
* @throws {SlackWebhookError} when the request fails or Slack answers with an error status.
|
|
98
|
+
*/
|
|
99
|
+
export declare function postSlackMessage(webhookUrl: string, message: SlackMessage, fetcher?: typeof fetch): Promise<void>;
|
|
100
|
+
//#endregion
|
|
101
|
+
export type { CiCommit, CiOutcome, CiRun, CiStepResult, CiTarget, SlackMessage };
|
|
102
|
+
//# sourceMappingURL=slack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slack.d.ts","names":[],"sources":["../src/infrastructure/slack/ci-message.ts","../src/infrastructure/slack/slack-webhook.ts"],"mappings":";;KAGY;;KAGA;WACG;;WAEA;WACA;WACA;WACA;;WAEA;;WAGA;WACA;;WAEA;;;UAIE;WACN;WACA;WACA;aACM;aAAyB;;aAEzB;aACA;aACA;aACA;;WAEN;WACA,MAAM,cAAc;WACpB,OAAO,cAAc;WACrB,QAAQ;;;UAIF;WACN;WACA,SAAS;;;UAIH;WACN;WACA;;;UAIM;WACN;WACA,QAAQ,cAAc;;KAG5B;WACU;WAAyB;;WACzB;WAAwB;WAA4B;;KAE9D;WACU;WAA0B;aAAiB;aAAyB;;;WACpE;WAA0B,UAAU,cAAc;;;qBAGpD,wBAAwB;WAIxB,QAAQ;WACC;WAJX;EAET,YACW,QAAQ,uBACC;;;;;;;wBAgDN,WAAW,KAAK,SAAS,sCAAsC;;wBAkE/D,eAAe,KAAK,OAAO,QAAQ,WAAW;;;;qBCxLjD,0BAA0B;WAI1B;WACS;WAJX;EAET,YACW,4BACS;;;;;;wBAUA,iBACpB,oBACA,SAAS,cACT,iBAAgB,QACf"}
|
package/dist/slack.js
ADDED