@couriercrow/client 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Christoffer Artmann
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,50 @@
1
- # Temporary Holding Version
1
+ # @couriercrow/client
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Send transactional mail and series from your app through [Courier Crow](https://github.com/Artmann/courier-crow), a shared inbox for your side projects that runs in your own Cloudflare account.
4
+
5
+ The client uses plain `fetch`, so it runs in Node, Bun, Workers and edge runtimes.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ bun add @couriercrow/client
11
+ ```
12
+
13
+ npm, pnpm and yarn work too.
14
+
15
+ ## Send a message
16
+
17
+ You need a deployed Courier Crow app and credentials for your app. Declare the app in `mail.config.ts` and run `crow deploy`; deploy prints the client id and secret once.
18
+
19
+ ```ts
20
+ import { createMailClient } from '@couriercrow/client'
21
+
22
+ const mail = createMailClient({
23
+ clientId: process.env.COURIER_CROW_CLIENT_ID,
24
+ clientSecret: process.env.COURIER_CROW_CLIENT_SECRET,
25
+ url: process.env.COURIER_CROW_URL
26
+ })
27
+
28
+ const result = await mail.send({
29
+ from: 'no-reply@acme.dev',
30
+ html: '<p>Use this link to reset your password.</p>',
31
+ idempotencyKey: `reset-${user.id}-${token.id}`,
32
+ subject: 'Reset your password',
33
+ text: 'Use this link to reset your password.',
34
+ to: user.email
35
+ })
36
+ ```
37
+
38
+ Every message needs an `idempotencyKey` that is unique within the app. Sending again with the same key never sends a second mail.
39
+
40
+ ## React Email
41
+
42
+ `@couriercrow/client/react` has the same `createMailClient`, which also takes a React Email `template`. Install `@react-email/render` and `react` in the app to use it. The base entry has no reference to React, so it bundles in any app.
43
+
44
+ ## More
45
+
46
+ Results, errors, series and limits are described in the README of the repository: https://github.com/Artmann/courier-crow#sending-mail-from-your-app
47
+
48
+ ## License
49
+
50
+ MIT
@@ -0,0 +1,311 @@
1
+ // ../core/src/mail-rules.ts
2
+ var mebibyte = 1024 * 1024;
3
+ var sendLimits = {
4
+ attachmentCount: 32,
5
+ htmlBytes: 500000,
6
+ recipientCount: 50,
7
+ sizeInBytes: 25 * mebibyte,
8
+ subjectLength: 1000,
9
+ textBytes: 500000
10
+ };
11
+ var minute = 60000;
12
+ var hour = 60 * minute;
13
+ var day = 24 * hour;
14
+ var seriesLimits = {
15
+ keyLength: 200,
16
+ lastStepAfterMilliseconds: 90 * day,
17
+ nameLength: 100,
18
+ stepCount: 10
19
+ };
20
+ var maxEnrollmentRequestBytes = 2 * seriesLimits.stepCount * (sendLimits.htmlBytes + sendLimits.textBytes) + 64 * 1024;
21
+ var durationPattern = /^(\d{1,6}) (minute|minutes|hour|hours|day|days)$/;
22
+ var unitMilliseconds = {
23
+ day,
24
+ days: day,
25
+ hour,
26
+ hours: hour,
27
+ minute,
28
+ minutes: minute
29
+ };
30
+ function parseDuration(value) {
31
+ const match = durationPattern.exec(value.trim());
32
+ if (match === null) {
33
+ return;
34
+ }
35
+ const [, count, unit] = match;
36
+ const size = unitMilliseconds[unit ?? ""];
37
+ return size === undefined ? undefined : Number(count) * size;
38
+ }
39
+ function formatDuration(milliseconds) {
40
+ const [size, name] = milliseconds > 0 && milliseconds % day === 0 ? [day, "day"] : milliseconds > 0 && milliseconds % hour === 0 ? [hour, "hour"] : [minute, "minute"];
41
+ const count = Math.floor(milliseconds / size);
42
+ return `${count} ${name}${count === 1 ? "" : "s"}`;
43
+ }
44
+ var enrollmentMessages = {
45
+ keyTooLong: `The key is too long. Keep it to ${seriesLimits.keyLength} characters or fewer.`,
46
+ missingKey: "Give every enrolment a key, for example onboarding-<user id>. It makes retries safe and lets you cancel it.",
47
+ missingSeries: "Name the series, for example series: 'onboarding'.",
48
+ seriesTooLong: `The series name is too long. Keep it to ${seriesLimits.nameLength} characters or fewer.`
49
+ };
50
+ function notADurationMessage(value) {
51
+ return `"${value}" is not a duration. Use minutes, hours or days, for example "3 days".`;
52
+ }
53
+ function findStepsProblem(steps) {
54
+ if (steps.length === 0) {
55
+ return "A series needs at least one step.";
56
+ }
57
+ if (steps.length > seriesLimits.stepCount) {
58
+ return `A series can have at most ${seriesLimits.stepCount} steps. This one has ${steps.length}.`;
59
+ }
60
+ const withoutSubject = steps.findIndex((step) => step.subject !== undefined && stripControlCharacters(step.subject, " ").trim() === "");
61
+ if (withoutSubject !== -1) {
62
+ return `Step ${withoutSubject + 1} needs a subject.`;
63
+ }
64
+ const times = [];
65
+ for (const step of steps) {
66
+ const time = parseDuration(step.after);
67
+ if (time === undefined) {
68
+ return notADurationMessage(step.after);
69
+ }
70
+ times.push(time);
71
+ }
72
+ for (let index = 1;index < times.length; index++) {
73
+ const previous = times[index - 1] ?? 0;
74
+ const current = times[index] ?? 0;
75
+ if (current < previous) {
76
+ return `Steps must be in order of time. Step ${index + 1} (${steps[index]?.after.trim()}) comes before step ${index} (${steps[index - 1]?.after.trim()}).`;
77
+ }
78
+ }
79
+ const last = times.at(-1) ?? 0;
80
+ if (last > seriesLimits.lastStepAfterMilliseconds) {
81
+ return `The last step is ${formatDuration(last)} after enrolment. The limit is ${formatDuration(seriesLimits.lastStepAfterMilliseconds)}.`;
82
+ }
83
+ return;
84
+ }
85
+ var stuckAfterMilliseconds = 5 * 60000;
86
+ var maxChangesPerRequest = 200;
87
+ var tooManyChangesMessage = `That change list has more than ${maxChangesPerRequest} changes. Update the Courier Crow CLI to the version of the app and run deploy again; it sends changes in lists of ${maxChangesPerRequest}.`;
88
+ function stripControlCharacters(value, replacement = "") {
89
+ return value.replaceAll(/\p{Cc}/gu, replacement);
90
+ }
91
+
92
+ // src/mail-client.ts
93
+ class MailClientError extends Error {
94
+ name = "MailClientError";
95
+ status;
96
+ constructor(message, status = 0) {
97
+ super(message);
98
+ this.status = status;
99
+ }
100
+ }
101
+ var htmlAndText = (content) => Promise.resolve({ html: content.html, text: content.text });
102
+ var timeoutInMilliseconds = 90000;
103
+ var missingSettingsMessage = "Set COURIER_CROW_URL, COURIER_CROW_CLIENT_ID and COURIER_CROW_CLIENT_SECRET for this app. Run bunx couriercrow deploy to get them.";
104
+ var credentialsMessage = "Courier Crow rejected this app's credentials. Check COURIER_CROW_CLIENT_ID and COURIER_CROW_CLIENT_SECRET, or run bunx couriercrow rotate-app-secret <name>.";
105
+ var sendUncertainty = "The message may or may not have been sent.";
106
+ var enrollUncertainty = "The enrolment may or may not have been made; enrolling again with the same key is safe.";
107
+ var cancelUncertainty = "The enrolment may or may not have been cancelled; cancelling again is safe.";
108
+ function isTimeout(error) {
109
+ return typeof error === "object" && error !== null && "name" in error && (error.name === "TimeoutError" || error.name === "AbortError");
110
+ }
111
+ async function messageOf(response) {
112
+ if (!(response.headers.get("content-type") ?? "").includes("application/json")) {
113
+ return null;
114
+ }
115
+ try {
116
+ const body = await response.json();
117
+ return typeof body === "object" && body !== null && "message" in body && typeof body.message === "string" ? body.message : null;
118
+ } catch {
119
+ return null;
120
+ }
121
+ }
122
+ function appAddress(value) {
123
+ let parsed;
124
+ try {
125
+ parsed = new URL(value);
126
+ } catch {
127
+ throw new MailClientError("COURIER_CROW_URL must start with https://.");
128
+ }
129
+ const isLocal = parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1";
130
+ if (parsed.protocol !== "https:" && !(parsed.protocol === "http:" && isLocal)) {
131
+ throw new MailClientError("COURIER_CROW_URL must start with https://.");
132
+ }
133
+ if (parsed.pathname !== "/" || parsed.search !== "" || parsed.hash !== "") {
134
+ throw new MailClientError("COURIER_CROW_URL must be the address of the app only, for example https://mail.acme.dev.");
135
+ }
136
+ return parsed.origin;
137
+ }
138
+ function notOurAnswer(status) {
139
+ return new MailClientError(`Courier Crow answered with status ${status} but not in the expected form. Check COURIER_CROW_URL.`, status);
140
+ }
141
+ function isRecord(value) {
142
+ return typeof value === "object" && value !== null;
143
+ }
144
+ function isSendAnswer(value) {
145
+ return isRecord(value) && typeof value["id"] === "string" && typeof value["isOutcomeUncertain"] === "boolean" && (value["notice"] === null || typeof value["notice"] === "string") && (value["state"] === "failed" || value["state"] === "queued" || value["state"] === "sent");
146
+ }
147
+ function isEnrollmentAnswer(value) {
148
+ return isRecord(value) && typeof value["id"] === "string" && typeof value["key"] === "string" && typeof value["state"] === "string" && Array.isArray(value["steps"]);
149
+ }
150
+ function findEnrollmentProblem(enrollment) {
151
+ const key = enrollment.key.trim();
152
+ const series = enrollment.series.trim();
153
+ if (key === "") {
154
+ return enrollmentMessages.missingKey;
155
+ }
156
+ if ([...key].length > seriesLimits.keyLength) {
157
+ return enrollmentMessages.keyTooLong;
158
+ }
159
+ if (series === "") {
160
+ return enrollmentMessages.missingSeries;
161
+ }
162
+ if ([...series].length > seriesLimits.nameLength) {
163
+ return enrollmentMessages.seriesTooLong;
164
+ }
165
+ return findStepsProblem(enrollment.steps);
166
+ }
167
+ function createMailClient(options) {
168
+ return createMailClientWith(options, htmlAndText);
169
+ }
170
+ function createMailClientWith(options, render) {
171
+ const { clientId, clientSecret, url } = options;
172
+ if (clientId === undefined || clientId.trim() === "" || clientSecret === undefined || clientSecret.trim() === "" || url === undefined || url.trim() === "") {
173
+ throw new MailClientError(missingSettingsMessage);
174
+ }
175
+ const base = appAddress(url.trim());
176
+ const send = options.fetch ?? globalThis.fetch;
177
+ const request = async (method, path, body, uncertainty = sendUncertainty) => {
178
+ const unreachable = (error) => ({
179
+ _tag: "Unknown",
180
+ notice: isTimeout(error) ? `Courier Crow at ${base} did not answer within ${timeoutInMilliseconds / 1000} seconds. ${uncertainty}` : `Could not reach Courier Crow at ${base}. ${uncertainty}`
181
+ });
182
+ let response;
183
+ try {
184
+ response = await send(`${base}${path}`, {
185
+ ...body === undefined ? {} : { body: JSON.stringify(body) },
186
+ headers: {
187
+ "cf-access-client-id": clientId,
188
+ "cf-access-client-secret": clientSecret,
189
+ ...body === undefined ? {} : { "content-type": "application/json" }
190
+ },
191
+ method,
192
+ redirect: "manual",
193
+ signal: AbortSignal.timeout(timeoutInMilliseconds)
194
+ });
195
+ } catch (error) {
196
+ return unreachable(error);
197
+ }
198
+ if (response.type === "opaqueredirect" || response.status >= 300 && response.status < 400) {
199
+ throw new MailClientError(credentialsMessage, response.status);
200
+ }
201
+ if (response.ok) {
202
+ let text;
203
+ try {
204
+ text = await response.text();
205
+ } catch (error) {
206
+ return unreachable(error);
207
+ }
208
+ try {
209
+ return {
210
+ _tag: "Body",
211
+ body: JSON.parse(text),
212
+ status: response.status
213
+ };
214
+ } catch {
215
+ throw notOurAnswer(response.status);
216
+ }
217
+ }
218
+ const message = await messageOf(response);
219
+ if (response.status >= 500) {
220
+ return {
221
+ _tag: "Unknown",
222
+ notice: `${message ?? `Courier Crow answered with status ${response.status}.`} ${uncertainty}`
223
+ };
224
+ }
225
+ if (response.status === 401 || response.status === 403 && message === null) {
226
+ throw new MailClientError(credentialsMessage, response.status);
227
+ }
228
+ if (message === null) {
229
+ throw new MailClientError(`Courier Crow answered with status ${response.status}. Check COURIER_CROW_URL.`, response.status);
230
+ }
231
+ throw new MailClientError(message, response.status);
232
+ };
233
+ const enrollmentPath = (key) => `/api/series/enrollments/${encodeURIComponent(key)}`;
234
+ const toEnrollResult = (answer) => {
235
+ if (answer._tag === "Unknown") {
236
+ return { id: null, isOutcomeUncertain: true, notice: answer.notice, state: "unknown" };
237
+ }
238
+ if (!isEnrollmentAnswer(answer.body)) {
239
+ throw notOurAnswer(answer.status);
240
+ }
241
+ return answer.body;
242
+ };
243
+ return {
244
+ cancelEnrollment: async (key) => toEnrollResult(await request("DELETE", enrollmentPath(key), undefined, cancelUncertainty)),
245
+ enroll: async (enrollment) => {
246
+ const problem = findEnrollmentProblem(enrollment);
247
+ if (problem !== undefined) {
248
+ throw new MailClientError(problem);
249
+ }
250
+ const steps = await Promise.all(enrollment.steps.map(async (step) => {
251
+ const content = await render(step);
252
+ return { after: step.after, html: content.html, subject: step.subject, text: content.text };
253
+ }));
254
+ return toEnrollResult(await request("POST", "/api/series/enrollments", { key: enrollment.key, series: enrollment.series, steps, to: enrollment.to }, enrollUncertainty));
255
+ },
256
+ getEnrollment: async (key) => {
257
+ const answer = await request("GET", enrollmentPath(key));
258
+ if (answer._tag === "Unknown") {
259
+ throw new MailClientError(answer.notice.replace(` ${sendUncertainty}`, " Try again."));
260
+ }
261
+ if (!isEnrollmentAnswer(answer.body)) {
262
+ throw notOurAnswer(answer.status);
263
+ }
264
+ return answer.body;
265
+ },
266
+ getMessage: async (id) => {
267
+ const answer = await request("GET", `/api/transactional/messages/${encodeURIComponent(id)}`);
268
+ if (answer._tag === "Unknown") {
269
+ throw new MailClientError(answer.notice.replace(` ${sendUncertainty}`, " Try again."));
270
+ }
271
+ if (!isRecord(answer.body) || typeof answer.body["id"] !== "string" || typeof answer.body["state"] !== "string") {
272
+ throw notOurAnswer(answer.status);
273
+ }
274
+ return answer.body;
275
+ },
276
+ send: async (message) => {
277
+ const content = await render(message);
278
+ const templateName = message.templateName ?? content.templateName ?? "unnamed";
279
+ const answer = await request("POST", "/api/transactional/messages", {
280
+ ...message.allowDuplicate === undefined ? {} : { allowDuplicate: message.allowDuplicate },
281
+ from: message.from,
282
+ html: content.html,
283
+ idempotencyKey: message.idempotencyKey,
284
+ ...message.replyTo === undefined ? {} : { replyTo: message.replyTo },
285
+ subject: message.subject,
286
+ templateName,
287
+ text: content.text,
288
+ to: message.to
289
+ });
290
+ if (answer._tag === "Unknown") {
291
+ return {
292
+ id: null,
293
+ isOutcomeUncertain: true,
294
+ notice: answer.notice,
295
+ state: "failed"
296
+ };
297
+ }
298
+ const result = answer.body;
299
+ if (!isSendAnswer(result)) {
300
+ throw notOurAnswer(answer.status);
301
+ }
302
+ return result.state === "failed" ? {
303
+ id: result.id,
304
+ isOutcomeUncertain: result.isOutcomeUncertain,
305
+ notice: result.notice ?? "The message was not sent.",
306
+ state: "failed"
307
+ } : { id: result.id, state: result.state };
308
+ }
309
+ };
310
+ }
311
+ export { MailClientError, createMailClient, createMailClientWith };
@@ -0,0 +1,2 @@
1
+ export { createMailClient, MailClientError } from './mail-client';
2
+ export type { EnrollResult, HtmlContent, MailClient, MailClientOptions, MailMessage, MessageBase, SendResult, SeriesEnrollment, SeriesStep, StoredEnrollment, StoredEnrollmentStep, StoredMessage, UnknownOutcome } from './mail-client';
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ import {
2
+ MailClientError,
3
+ createMailClient
4
+ } from "./index-jx5yf66k.js";
5
+ export {
6
+ createMailClient,
7
+ MailClientError
8
+ };
@@ -0,0 +1,100 @@
1
+ export declare class MailClientError extends Error {
2
+ name: string;
3
+ readonly status: number;
4
+ constructor(message: string, status?: number);
5
+ }
6
+ export interface MailClientOptions {
7
+ clientId?: string | undefined;
8
+ clientSecret?: string | undefined;
9
+ fetch?: typeof fetch | undefined;
10
+ url?: string | undefined;
11
+ }
12
+ export interface HtmlContent {
13
+ html: string;
14
+ text: string;
15
+ }
16
+ export interface MessageBase {
17
+ allowDuplicate?: boolean;
18
+ from: string;
19
+ idempotencyKey: string;
20
+ replyTo?: string;
21
+ subject: string;
22
+ templateName?: string;
23
+ to: string;
24
+ }
25
+ export type MailMessage<Content = HtmlContent> = MessageBase & Content;
26
+ export type SendResult = {
27
+ id: string;
28
+ state: 'sent';
29
+ } | {
30
+ id: string;
31
+ state: 'queued';
32
+ } | {
33
+ id: string | null;
34
+ isOutcomeUncertain: boolean;
35
+ notice: string;
36
+ state: 'failed';
37
+ };
38
+ export interface StoredMessage {
39
+ createdAt: string;
40
+ failureReason: string | null;
41
+ from: string;
42
+ id: string;
43
+ idempotencyKey: string;
44
+ isOutcomeUncertain: boolean;
45
+ notice: string | null;
46
+ replyTo: string | null;
47
+ sentAt: string | null;
48
+ state: 'failed' | 'queued' | 'sent';
49
+ subject: string;
50
+ templateName: string;
51
+ to: string;
52
+ }
53
+ export type SeriesStep<Content = HtmlContent> = {
54
+ after: string;
55
+ subject: string;
56
+ } & Content;
57
+ export interface SeriesEnrollment<Content = HtmlContent> {
58
+ key: string;
59
+ series: string;
60
+ steps: readonly SeriesStep<Content>[];
61
+ to: string;
62
+ }
63
+ export interface StoredEnrollmentStep {
64
+ dueAt: string;
65
+ failureReason: string | null;
66
+ isOutcomeUncertain: boolean;
67
+ notice: string | null;
68
+ position: number;
69
+ sentAt: string | null;
70
+ state: 'failed' | 'queued' | 'scheduled' | 'sent' | 'skipped';
71
+ subject: string;
72
+ }
73
+ export interface StoredEnrollment {
74
+ createdAt: string;
75
+ id: string;
76
+ key: string;
77
+ series: string;
78
+ state: 'active' | 'cancelled' | 'finished' | 'unsubscribed';
79
+ steps: readonly StoredEnrollmentStep[];
80
+ to: string;
81
+ }
82
+ export interface UnknownOutcome {
83
+ id: null;
84
+ isOutcomeUncertain: true;
85
+ notice: string;
86
+ state: 'unknown';
87
+ }
88
+ export type EnrollResult = StoredEnrollment | UnknownOutcome;
89
+ export interface MailClient<Content = HtmlContent> {
90
+ cancelEnrollment: (key: string) => Promise<EnrollResult>;
91
+ enroll: (enrollment: SeriesEnrollment<Content>) => Promise<EnrollResult>;
92
+ getEnrollment: (key: string) => Promise<StoredEnrollment>;
93
+ getMessage: (id: string) => Promise<StoredMessage>;
94
+ send: (message: MailMessage<Content>) => Promise<SendResult>;
95
+ }
96
+ export type RenderContent<Content> = (content: Content) => Promise<HtmlContent & {
97
+ templateName?: string;
98
+ }>;
99
+ export declare function createMailClient(options: MailClientOptions): MailClient;
100
+ export declare function createMailClientWith<Content>(options: MailClientOptions, render: RenderContent<Content>): MailClient<Content>;
@@ -0,0 +1,11 @@
1
+ import type { HtmlContent, MailClient, MailClientOptions } from './mail-client';
2
+ export * from './index';
3
+ export interface TemplateElement {
4
+ key: unknown;
5
+ props: unknown;
6
+ type: unknown;
7
+ }
8
+ export type TemplateContent = HtmlContent | {
9
+ template: TemplateElement;
10
+ };
11
+ export declare function createMailClient(options: MailClientOptions): MailClient<TemplateContent>;
package/dist/react.js ADDED
@@ -0,0 +1,35 @@
1
+ import {
2
+ MailClientError,
3
+ createMailClientWith
4
+ } from "./index-jx5yf66k.js";
5
+
6
+ // src/react.ts
7
+ import { render } from "@react-email/render";
8
+ function templateNameOf(template) {
9
+ const type = template.type;
10
+ if (typeof type !== "function") {
11
+ return;
12
+ }
13
+ const named = type;
14
+ const name = typeof named.displayName === "string" && named.displayName !== "" ? named.displayName : named.name;
15
+ return typeof name === "string" && name !== "" ? name : undefined;
16
+ }
17
+ var renderTemplate = async (content) => {
18
+ if (!("template" in content)) {
19
+ return { html: content.html, text: content.text };
20
+ }
21
+ const node = content.template;
22
+ const templateName = templateNameOf(content.template);
23
+ return {
24
+ html: await render(node),
25
+ text: await render(node, { plainText: true }),
26
+ ...templateName === undefined ? {} : { templateName }
27
+ };
28
+ };
29
+ function createMailClient(options) {
30
+ return createMailClientWith(options, renderTemplate);
31
+ }
32
+ export {
33
+ createMailClient,
34
+ MailClientError
35
+ };
package/package.json CHANGED
@@ -1,6 +1,72 @@
1
1
  {
2
2
  "name": "@couriercrow/client",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Send transactional mail and series through Courier Crow from your app. Plain fetch: runs in Node, Bun, Workers and edge runtimes.",
5
+ "keywords": [
6
+ "cloudflare",
7
+ "courier-crow",
8
+ "couriercrow",
9
+ "drip-email",
10
+ "email",
11
+ "email-series",
12
+ "react-email",
13
+ "send-email",
14
+ "transactional-email"
15
+ ],
16
+ "homepage": "https://github.com/Artmann/courier-crow#readme",
17
+ "bugs": {
18
+ "url": "https://github.com/Artmann/courier-crow/issues"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/Artmann/courier-crow.git",
23
+ "directory": "packages/client"
24
+ },
25
+ "license": "MIT",
26
+ "author": "Christoffer Artmann",
27
+ "type": "module",
28
+ "main": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "@couriercrow/source": "./src/index.ts",
33
+ "types": "./dist/index.d.ts",
34
+ "default": "./dist/index.js"
35
+ },
36
+ "./react": {
37
+ "@couriercrow/source": "./src/react.ts",
38
+ "types": "./dist/react.d.ts",
39
+ "default": "./dist/react.js"
40
+ }
41
+ },
42
+ "files": [
43
+ "dist"
44
+ ],
45
+ "scripts": {
46
+ "build": "rm -rf dist && bun build ./src/index.ts ./src/react.ts --outdir dist --target browser --splitting --conditions @couriercrow/source --external @react-email/render --external react && tsc -p tsconfig.build.json",
47
+ "check": "tsc",
48
+ "lint": "oxlint --config ../../.oxlintrc.json src",
49
+ "prepack": "bun run build",
50
+ "test": "bun test"
51
+ },
52
+ "devDependencies": {
53
+ "@couriercrow/core": "0.1.0",
54
+ "@react-email/render": "^2.3.1",
55
+ "@types/react": "^19.3.0",
56
+ "@types/react-dom": "^19.3.0",
57
+ "react": "^19.3.1",
58
+ "react-dom": "^19.3.1"
59
+ },
60
+ "peerDependencies": {
61
+ "@react-email/render": ">=1.0.0",
62
+ "react": ">=18.0.0"
63
+ },
64
+ "peerDependenciesMeta": {
65
+ "@react-email/render": {
66
+ "optional": true
67
+ },
68
+ "react": {
69
+ "optional": true
70
+ }
71
+ }
72
+ }