@primitivedotdev/sdk 0.26.0 → 0.27.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/README.md +2 -2
- package/dist/api/index.js +3 -406
- package/dist/openapi/index.js +7631 -7
- package/package.json +6 -63
- package/bin/run.js +0 -20
- package/dist/api/generated/client/client.gen.js +0 -235
- package/dist/api/generated/client/index.js +0 -6
- package/dist/api/generated/client/types.gen.js +0 -2
- package/dist/api/generated/client/utils.gen.js +0 -228
- package/dist/api/generated/client.gen.js +0 -3
- package/dist/api/generated/core/auth.gen.js +0 -14
- package/dist/api/generated/core/bodySerializer.gen.js +0 -57
- package/dist/api/generated/core/params.gen.js +0 -100
- package/dist/api/generated/core/pathSerializer.gen.js +0 -106
- package/dist/api/generated/core/queryKeySerializer.gen.js +0 -92
- package/dist/api/generated/core/serverSentEvents.gen.js +0 -132
- package/dist/api/generated/core/types.gen.js +0 -2
- package/dist/api/generated/core/utils.gen.js +0 -87
- package/dist/api/generated/index.js +0 -2
- package/dist/api/generated/sdk.gen.js +0 -878
- package/dist/api/generated/types.gen.js +0 -2
- package/dist/api/verify-signature.js +0 -198
- package/dist/oclif/api-command.js +0 -755
- package/dist/oclif/auth.js +0 -223
- package/dist/oclif/commands/emails-latest.js +0 -185
- package/dist/oclif/commands/emails-poll.js +0 -121
- package/dist/oclif/commands/emails-wait.js +0 -171
- package/dist/oclif/commands/emails-watch.js +0 -165
- package/dist/oclif/commands/functions-deploy.js +0 -124
- package/dist/oclif/commands/functions-init.js +0 -256
- package/dist/oclif/commands/functions-redeploy.js +0 -113
- package/dist/oclif/commands/functions-set-secret.js +0 -213
- package/dist/oclif/commands/login.js +0 -237
- package/dist/oclif/commands/logout.js +0 -88
- package/dist/oclif/commands/send.js +0 -222
- package/dist/oclif/commands/whoami.js +0 -95
- package/dist/oclif/fish-completion.js +0 -87
- package/dist/oclif/index.js +0 -167
- package/dist/oclif/lint/raw-send-mail-fetch.js +0 -98
- package/dist/openapi/openapi.generated.js +0 -5754
- package/dist/openapi/operations.generated.js +0 -4626
- package/dist/parser/address-parser.js +0 -129
- package/dist/types.generated.js +0 -7
- package/dist/types.js +0 -53
- package/dist/webhook/errors.js +0 -224
- package/dist/webhook/received-email.js +0 -82
- package/oclif.manifest.json +0 -4380
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ The official Node.js library for [Primitive](https://primitive.dev), an email AP
|
|
|
4
4
|
|
|
5
5
|
## Looking for the CLI?
|
|
6
6
|
|
|
7
|
-
The `primitive` CLI
|
|
7
|
+
The `primitive` CLI ships as a separate package, [`@primitivedotdev/cli`](https://www.npmjs.com/package/@primitivedotdev/cli). Install it with:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
npm install -g @primitivedotdev/cli
|
|
@@ -12,7 +12,7 @@ npm install -g @primitivedotdev/cli
|
|
|
12
12
|
npx @primitivedotdev/cli@latest <command>
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
This package
|
|
15
|
+
This package no longer ships a `primitive` bin. Install `@primitivedotdev/cli` to get the CLI.
|
|
16
16
|
|
|
17
17
|
## Install
|
|
18
18
|
|
package/dist/api/index.js
CHANGED
|
@@ -1,406 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Generated operations are exported directly, and `PrimitiveApiClient`
|
|
5
|
-
* provides a configured fetch client for those operations.
|
|
6
|
-
*/
|
|
7
|
-
import { formatAddress } from "../webhook/received-email.js";
|
|
8
|
-
import { createClient, createConfig, } from "./generated/client/index.js";
|
|
9
|
-
import * as generatedOperations from "./generated/sdk.gen.js";
|
|
10
|
-
// Default production hosts. Two-host split exists because /send-mail
|
|
11
|
-
// needs a larger body cap than Vercel allows; host 2 is a Cloudflare
|
|
12
|
-
// Worker that accepts ~30 MiB raw. Host 1 carries everything else.
|
|
13
|
-
// Customers don't see this split: PrimitiveClient.send() always routes
|
|
14
|
-
// to host 2 internally, every other operation routes to host 1.
|
|
15
|
-
//
|
|
16
|
-
// Both base URLs are independently overridable via constructor options.
|
|
17
|
-
// Override is for internal staging/local testing; not part of the
|
|
18
|
-
// publicly-supported surface.
|
|
19
|
-
export const DEFAULT_API_BASE_URL_1 = "https://www.primitive.dev/api/v1";
|
|
20
|
-
export const DEFAULT_API_BASE_URL_2 = "https://api.primitive.dev/v1";
|
|
21
|
-
const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
22
|
-
const MAX_THREAD_REFERENCES = 100;
|
|
23
|
-
const MAX_THREAD_HEADER_BYTES = 8 * 1024;
|
|
24
|
-
const MAX_FROM_HEADER_LENGTH = 998;
|
|
25
|
-
const MAX_TO_HEADER_LENGTH = 320;
|
|
26
|
-
function createDefaultAuth(apiKey) {
|
|
27
|
-
return (security) => {
|
|
28
|
-
if (security.type === "http" && security.scheme === "bearer") {
|
|
29
|
-
return apiKey;
|
|
30
|
-
}
|
|
31
|
-
return undefined;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function validateAddressHeader(field, value) {
|
|
35
|
-
const trimmed = value.trim();
|
|
36
|
-
const maxLength = field === "from" ? MAX_FROM_HEADER_LENGTH : MAX_TO_HEADER_LENGTH;
|
|
37
|
-
if (trimmed.length < 3) {
|
|
38
|
-
throw new TypeError(`${field} must be at least 3 characters`);
|
|
39
|
-
}
|
|
40
|
-
if (trimmed.length > maxLength) {
|
|
41
|
-
throw new TypeError(`${field} must be at most ${maxLength} characters`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function validateEmailAddress(field, value) {
|
|
45
|
-
if (!EMAIL_REGEX.test(value) &&
|
|
46
|
-
!/^.+<[^\s@]+@[^\s@]+\.[^\s@]+>$/.test(value)) {
|
|
47
|
-
throw new TypeError(`${field} must be a valid email address`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function validateThreadHeaderValue(field, value) {
|
|
51
|
-
if (value.trim().length === 0) {
|
|
52
|
-
throw new TypeError(`${field} must be a non-empty string`);
|
|
53
|
-
}
|
|
54
|
-
if ([...value].some((char) => {
|
|
55
|
-
const code = char.charCodeAt(0);
|
|
56
|
-
return code <= 0x1f || code === 0x7f;
|
|
57
|
-
})) {
|
|
58
|
-
throw new TypeError(`${field} must not contain control characters`);
|
|
59
|
-
}
|
|
60
|
-
if (value.length > 998) {
|
|
61
|
-
throw new TypeError(`${field} must be at most 998 characters`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function validateSendInput(input) {
|
|
65
|
-
validateAddressHeader("from", input.from);
|
|
66
|
-
validateAddressHeader("to", input.to);
|
|
67
|
-
validateEmailAddress("to", input.to);
|
|
68
|
-
if (input.subject.trim().length === 0) {
|
|
69
|
-
throw new TypeError("subject must be a non-empty string");
|
|
70
|
-
}
|
|
71
|
-
if (!input.bodyText && !input.bodyHtml) {
|
|
72
|
-
throw new TypeError("one of bodyText or bodyHtml is required");
|
|
73
|
-
}
|
|
74
|
-
if (input.thread?.inReplyTo) {
|
|
75
|
-
validateThreadHeaderValue("thread.inReplyTo", input.thread.inReplyTo);
|
|
76
|
-
}
|
|
77
|
-
if (input.thread?.references) {
|
|
78
|
-
if (input.thread.references.length > MAX_THREAD_REFERENCES) {
|
|
79
|
-
throw new TypeError(`thread.references must contain at most ${MAX_THREAD_REFERENCES} values`);
|
|
80
|
-
}
|
|
81
|
-
for (const [index, reference] of input.thread.references.entries()) {
|
|
82
|
-
validateThreadHeaderValue(`thread.references[${index}]`, reference);
|
|
83
|
-
}
|
|
84
|
-
if (input.thread.references.join(" ").length > MAX_THREAD_HEADER_BYTES) {
|
|
85
|
-
throw new TypeError(`thread.references header must be at most ${MAX_THREAD_HEADER_BYTES} characters`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
if (input.waitTimeoutMs !== undefined) {
|
|
89
|
-
if (!Number.isInteger(input.waitTimeoutMs)) {
|
|
90
|
-
throw new TypeError("waitTimeoutMs must be an integer");
|
|
91
|
-
}
|
|
92
|
-
if (input.waitTimeoutMs < 1000 || input.waitTimeoutMs > 30000) {
|
|
93
|
-
throw new TypeError("waitTimeoutMs must be between 1000 and 30000");
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function validateForwardInput(input) {
|
|
98
|
-
validateEmailAddress("to", input.to);
|
|
99
|
-
if (input.subject !== undefined && input.subject.trim().length === 0) {
|
|
100
|
-
throw new TypeError("subject must be a non-empty string");
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
function parseApiErrorPayload(payload) {
|
|
104
|
-
const fallback = {
|
|
105
|
-
message: "Primitive API request failed",
|
|
106
|
-
code: undefined,
|
|
107
|
-
gates: undefined,
|
|
108
|
-
requestId: undefined,
|
|
109
|
-
details: undefined,
|
|
110
|
-
};
|
|
111
|
-
if (!payload || typeof payload !== "object") {
|
|
112
|
-
return fallback;
|
|
113
|
-
}
|
|
114
|
-
if ("error" in payload &&
|
|
115
|
-
payload.error &&
|
|
116
|
-
typeof payload.error === "object") {
|
|
117
|
-
const err = payload.error;
|
|
118
|
-
return {
|
|
119
|
-
message: typeof err.message === "string" ? err.message : fallback.message,
|
|
120
|
-
code: typeof err.code === "string" ? err.code : undefined,
|
|
121
|
-
gates: Array.isArray(err.gates) ? err.gates : undefined,
|
|
122
|
-
requestId: typeof err.request_id === "string" ? err.request_id : undefined,
|
|
123
|
-
details: err.details && typeof err.details === "object"
|
|
124
|
-
? err.details
|
|
125
|
-
: undefined,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
if ("message" in payload && typeof payload.message === "string") {
|
|
129
|
-
return { ...fallback, message: payload.message };
|
|
130
|
-
}
|
|
131
|
-
return fallback;
|
|
132
|
-
}
|
|
133
|
-
export class PrimitiveApiError extends Error {
|
|
134
|
-
status;
|
|
135
|
-
code;
|
|
136
|
-
gates;
|
|
137
|
-
requestId;
|
|
138
|
-
retryAfter;
|
|
139
|
-
details;
|
|
140
|
-
payload;
|
|
141
|
-
constructor(message, options) {
|
|
142
|
-
super(message);
|
|
143
|
-
this.name = "PrimitiveApiError";
|
|
144
|
-
this.payload = options.payload;
|
|
145
|
-
this.status = options.status;
|
|
146
|
-
this.code = options.code;
|
|
147
|
-
this.gates = options.gates;
|
|
148
|
-
this.requestId = options.requestId;
|
|
149
|
-
this.retryAfter = options.retryAfter;
|
|
150
|
-
this.details = options.details;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
function isAbortLikeError(error) {
|
|
154
|
-
if (!(error instanceof Error))
|
|
155
|
-
return false;
|
|
156
|
-
return error.name === "AbortError" || error.name === "TimeoutError";
|
|
157
|
-
}
|
|
158
|
-
function parseRetryAfterHeader(response) {
|
|
159
|
-
if (!response)
|
|
160
|
-
return undefined;
|
|
161
|
-
const raw = response.headers.get("retry-after");
|
|
162
|
-
if (!raw)
|
|
163
|
-
return undefined;
|
|
164
|
-
const seconds = Number.parseInt(raw, 10);
|
|
165
|
-
return Number.isFinite(seconds) ? seconds : undefined;
|
|
166
|
-
}
|
|
167
|
-
export class PrimitiveApiClient {
|
|
168
|
-
/**
|
|
169
|
-
* Generated client targeting the primary API host (apiBaseUrl1). Use
|
|
170
|
-
* this when passing `client: ...` to a generated operation function
|
|
171
|
-
* for every endpoint EXCEPT /send-mail. The hand-written
|
|
172
|
-
* PrimitiveClient.send / .reply / .forward methods on the subclass
|
|
173
|
-
* route /send-mail to the host-2 client internally.
|
|
174
|
-
*/
|
|
175
|
-
client;
|
|
176
|
-
/**
|
|
177
|
-
* @internal Generated client targeting the attachments-supporting
|
|
178
|
-
* send host (apiBaseUrl2). Used by PrimitiveClient.send() under the
|
|
179
|
-
* hood. Exposed for the CLI's hand-rolled send command, which calls
|
|
180
|
-
* the generated sendEmail directly; not part of the publicly-
|
|
181
|
-
* documented SDK surface. Customer code should call .send() on the
|
|
182
|
-
* subclass instead.
|
|
183
|
-
*/
|
|
184
|
-
_sendClient;
|
|
185
|
-
constructor(options = {}) {
|
|
186
|
-
const { apiKey, auth, apiBaseUrl1 = DEFAULT_API_BASE_URL_1, apiBaseUrl2 = DEFAULT_API_BASE_URL_2, ...config } = options;
|
|
187
|
-
const resolvedAuth = auth ?? createDefaultAuth(apiKey);
|
|
188
|
-
this.client = createClient(createConfig({
|
|
189
|
-
...config,
|
|
190
|
-
auth: resolvedAuth,
|
|
191
|
-
baseUrl: apiBaseUrl1,
|
|
192
|
-
}));
|
|
193
|
-
this._sendClient = createClient(createConfig({
|
|
194
|
-
...config,
|
|
195
|
-
auth: resolvedAuth,
|
|
196
|
-
baseUrl: apiBaseUrl2,
|
|
197
|
-
}));
|
|
198
|
-
}
|
|
199
|
-
getConfig() {
|
|
200
|
-
return this.client.getConfig();
|
|
201
|
-
}
|
|
202
|
-
setConfig(config) {
|
|
203
|
-
return this.client.setConfig(config);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
function resolveRequestOptions(options) {
|
|
207
|
-
const signals = [];
|
|
208
|
-
if (options?.signal)
|
|
209
|
-
signals.push(options.signal);
|
|
210
|
-
if (options?.timeout !== undefined) {
|
|
211
|
-
signals.push(AbortSignal.timeout(options.timeout));
|
|
212
|
-
}
|
|
213
|
-
const signal = signals.length === 0
|
|
214
|
-
? undefined
|
|
215
|
-
: signals.length === 1
|
|
216
|
-
? signals[0]
|
|
217
|
-
: AbortSignal.any(signals);
|
|
218
|
-
const headers = {
|
|
219
|
-
...(options?.headers ?? {}),
|
|
220
|
-
...(options?.idempotencyKey
|
|
221
|
-
? { "Idempotency-Key": options.idempotencyKey }
|
|
222
|
-
: {}),
|
|
223
|
-
};
|
|
224
|
-
const resolved = {};
|
|
225
|
-
if (signal)
|
|
226
|
-
resolved.signal = signal;
|
|
227
|
-
if (Object.keys(headers).length > 0)
|
|
228
|
-
resolved.headers = headers;
|
|
229
|
-
return resolved;
|
|
230
|
-
}
|
|
231
|
-
export class PrimitiveClient extends PrimitiveApiClient {
|
|
232
|
-
async send(input, options) {
|
|
233
|
-
validateSendInput(input);
|
|
234
|
-
const body = {
|
|
235
|
-
from: input.from,
|
|
236
|
-
to: input.to,
|
|
237
|
-
subject: input.subject,
|
|
238
|
-
...(input.bodyText !== undefined ? { body_text: input.bodyText } : {}),
|
|
239
|
-
...(input.bodyHtml !== undefined ? { body_html: input.bodyHtml } : {}),
|
|
240
|
-
...(input.thread?.inReplyTo
|
|
241
|
-
? { in_reply_to: input.thread.inReplyTo }
|
|
242
|
-
: {}),
|
|
243
|
-
...(input.thread?.references?.length
|
|
244
|
-
? { references: input.thread.references }
|
|
245
|
-
: {}),
|
|
246
|
-
...(input.wait !== undefined ? { wait: input.wait } : {}),
|
|
247
|
-
...(input.waitTimeoutMs !== undefined
|
|
248
|
-
? { wait_timeout_ms: input.waitTimeoutMs }
|
|
249
|
-
: {}),
|
|
250
|
-
};
|
|
251
|
-
const result = await generatedOperations.sendEmail({
|
|
252
|
-
body,
|
|
253
|
-
...resolveRequestOptions(options),
|
|
254
|
-
// /send-mail goes to the host that supports attachments. Same
|
|
255
|
-
// request body shape on both hosts; the host swap is the only
|
|
256
|
-
// difference. Callers don't see or configure this.
|
|
257
|
-
client: this._sendClient,
|
|
258
|
-
responseStyle: "fields",
|
|
259
|
-
});
|
|
260
|
-
return unwrapSendResult(result);
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Reply to an inbound email.
|
|
264
|
-
*
|
|
265
|
-
* Calls `POST /emails/{id}/reply`. The server derives recipients
|
|
266
|
-
* (Reply-To, then From, then sender), subject (`Re: <parent>` with
|
|
267
|
-
* idempotent prefix), and threading headers (`In-Reply-To`,
|
|
268
|
-
* `References`) from the stored inbound row. The customer controls
|
|
269
|
-
* only the body, an optional `from` override, and the `wait` flag.
|
|
270
|
-
*
|
|
271
|
-
* Subject overrides are intentionally not supported: Gmail's
|
|
272
|
-
* Conversation View needs both a References match and a normalized-
|
|
273
|
-
* subject match to thread, so a custom subject silently breaks the
|
|
274
|
-
* thread for half the recipient population.
|
|
275
|
-
*/
|
|
276
|
-
async reply(email, input, options) {
|
|
277
|
-
const resolved = typeof input === "string" ? { text: input } : input;
|
|
278
|
-
// Reject the subject override at runtime so a JS caller (no TS
|
|
279
|
-
// types) gets the same loud error as a TS caller. Without this,
|
|
280
|
-
// `client.reply(email, { text, subject: "Custom" })` silently
|
|
281
|
-
// dropped subject and sent a "Re:" reply, breaking Gmail
|
|
282
|
-
// threading without telling the caller. Mirrors Python's
|
|
283
|
-
// ValueError. Checked before the empty-body check so passing
|
|
284
|
-
// ONLY a subject surfaces the more informative error.
|
|
285
|
-
if ("subject" in resolved) {
|
|
286
|
-
throw new TypeError("reply does not support a subject override; the server prepends 'Re:' to the parent's subject for thread continuity");
|
|
287
|
-
}
|
|
288
|
-
if (!resolved.text && !resolved.html) {
|
|
289
|
-
throw new TypeError("reply requires text or html");
|
|
290
|
-
}
|
|
291
|
-
const body = {
|
|
292
|
-
...(resolved.text !== undefined ? { body_text: resolved.text } : {}),
|
|
293
|
-
...(resolved.html !== undefined ? { body_html: resolved.html } : {}),
|
|
294
|
-
...(resolved.from !== undefined ? { from: resolved.from } : {}),
|
|
295
|
-
...(resolved.wait !== undefined ? { wait: resolved.wait } : {}),
|
|
296
|
-
};
|
|
297
|
-
const result = await generatedOperations.replyToEmail({
|
|
298
|
-
body,
|
|
299
|
-
path: { id: email.id },
|
|
300
|
-
...resolveRequestOptions(options),
|
|
301
|
-
client: this.client,
|
|
302
|
-
responseStyle: "fields",
|
|
303
|
-
});
|
|
304
|
-
return unwrapSendResult(result);
|
|
305
|
-
}
|
|
306
|
-
async forward(email, input, options) {
|
|
307
|
-
validateForwardInput(input);
|
|
308
|
-
return this.send({
|
|
309
|
-
from: input.from ?? email.receivedBy,
|
|
310
|
-
to: input.to,
|
|
311
|
-
subject: input.subject ?? email.forwardSubject,
|
|
312
|
-
bodyText: buildForwardText(email, input.bodyText),
|
|
313
|
-
}, options);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
function buildForwardText(email, intro) {
|
|
317
|
-
const lines = [
|
|
318
|
-
...(intro ? [intro.trim(), ""] : []),
|
|
319
|
-
"---------- Forwarded message ----------",
|
|
320
|
-
`From: ${formatAddress(email.sender)}`,
|
|
321
|
-
`To: ${email.raw.email.headers.to}`,
|
|
322
|
-
`Subject: ${email.subject ?? ""}`,
|
|
323
|
-
...(email.raw.email.headers.date
|
|
324
|
-
? [`Date: ${email.raw.email.headers.date}`]
|
|
325
|
-
: []),
|
|
326
|
-
...(email.thread.messageId
|
|
327
|
-
? [`Message-ID: ${email.thread.messageId}`]
|
|
328
|
-
: []),
|
|
329
|
-
"",
|
|
330
|
-
email.text ?? "",
|
|
331
|
-
];
|
|
332
|
-
return lines.join("\n").trimEnd();
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* Shared response handler for `send`, `reply`, and any future
|
|
336
|
-
* operation that returns a SendMailResult envelope. Unifies the
|
|
337
|
-
* error-mapping path so the network call sites only have to invoke
|
|
338
|
-
* the generated operation.
|
|
339
|
-
*/
|
|
340
|
-
function unwrapSendResult(result) {
|
|
341
|
-
const response = result.response;
|
|
342
|
-
if (result.error) {
|
|
343
|
-
if (isAbortLikeError(result.error)) {
|
|
344
|
-
throw result.error;
|
|
345
|
-
}
|
|
346
|
-
const parsed = parseApiErrorPayload(result.error);
|
|
347
|
-
throw new PrimitiveApiError(parsed.message, {
|
|
348
|
-
payload: result.error,
|
|
349
|
-
status: response?.status,
|
|
350
|
-
code: parsed.code,
|
|
351
|
-
gates: parsed.gates,
|
|
352
|
-
requestId: parsed.requestId,
|
|
353
|
-
retryAfter: parseRetryAfterHeader(response),
|
|
354
|
-
details: parsed.details,
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
if (!result.data?.data) {
|
|
358
|
-
throw new PrimitiveApiError("Primitive API returned no send result", {
|
|
359
|
-
payload: result,
|
|
360
|
-
status: response?.status,
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
return mapSendResult(result.data.data);
|
|
364
|
-
}
|
|
365
|
-
function mapSendResult(result) {
|
|
366
|
-
return {
|
|
367
|
-
id: result.id,
|
|
368
|
-
status: result.status,
|
|
369
|
-
queueId: result.queue_id,
|
|
370
|
-
accepted: result.accepted,
|
|
371
|
-
rejected: result.rejected,
|
|
372
|
-
clientIdempotencyKey: result.client_idempotency_key,
|
|
373
|
-
requestId: result.request_id,
|
|
374
|
-
contentHash: result.content_hash,
|
|
375
|
-
// Default to false if the server omits the field (old-format
|
|
376
|
-
// response, mocked partial response in a customer's tests). The
|
|
377
|
-
// type signature claims `boolean`, so undefined would be a lie.
|
|
378
|
-
idempotentReplay: result.idempotent_replay ?? false,
|
|
379
|
-
...(result.delivery_status !== undefined
|
|
380
|
-
? { deliveryStatus: result.delivery_status }
|
|
381
|
-
: {}),
|
|
382
|
-
...(result.smtp_response_code !== undefined
|
|
383
|
-
? { smtpResponseCode: result.smtp_response_code }
|
|
384
|
-
: {}),
|
|
385
|
-
...(result.smtp_response_text !== undefined
|
|
386
|
-
? { smtpResponseText: result.smtp_response_text }
|
|
387
|
-
: {}),
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
export function createPrimitiveApiClient(options = {}) {
|
|
391
|
-
return new PrimitiveApiClient(options);
|
|
392
|
-
}
|
|
393
|
-
export function createPrimitiveClient(options = {}) {
|
|
394
|
-
return new PrimitiveClient(options);
|
|
395
|
-
}
|
|
396
|
-
export function client(options = {}) {
|
|
397
|
-
return new PrimitiveClient(options);
|
|
398
|
-
}
|
|
399
|
-
export const operations = generatedOperations;
|
|
400
|
-
export * from "./generated/index.js";
|
|
401
|
-
// Web Crypto verifier for in-handler webhook verification. Mirrors
|
|
402
|
-
// the surface of `verifyWebhookSignature` from `@primitivedotdev/sdk`
|
|
403
|
-
// (the Node version) but implements HMAC-SHA256 with `crypto.subtle`
|
|
404
|
-
// so it can be bundled into a Primitive Function without pulling in
|
|
405
|
-
// a `node:crypto` polyfill.
|
|
406
|
-
export { PRIMITIVE_SIGNATURE_HEADER, verifyWebhookSignature, WebhookVerificationError, } from "./verify-signature.js";
|
|
1
|
+
import { c as WebhookVerificationError } from "../errors-x91I_yEt.js";
|
|
2
|
+
import { $ as testFunction, A as getSendPermissions, B as listFunctionSecrets, C as deleteFunctionSecret, D as getAccount, E as downloadRawEmail, F as listDomains, G as replayEmailWebhooks, H as listSentEmails, I as listEmails, J as searchEmails, K as replyToEmail, L as listEndpoints, M as getStorageStats, N as getWebhookSecret, O as getEmail, P as listDeliveries, Q as testEndpoint, R as listFilters, S as deleteFunction, T as downloadAttachments, U as pollCliLogin, V as listFunctions, W as replayDelivery, X as setFunctionSecret, Y as sendEmail, Z as startCliLogin, _ as createFunctionSecret, a as PrimitiveClient, at as verifyDomain, b as deleteEndpoint, c as createPrimitiveClient, d as verifyWebhookSignature, et as updateAccount, f as addDomain, g as createFunction, h as createFilter, i as PrimitiveApiError, it as updateFunction, j as getSentEmail, k as getFunction, l as operations, m as createEndpoint, n as DEFAULT_API_BASE_URL_2, nt as updateEndpoint, o as client, p as cliLogout, q as rotateWebhookSecret, r as PrimitiveApiClient, rt as updateFilter, s as createPrimitiveApiClient, t as DEFAULT_API_BASE_URL_1, tt as updateDomain, u as PRIMITIVE_SIGNATURE_HEADER, v as deleteDomain, w as discardEmailContent, x as deleteFilter, y as deleteEmail, z as listFunctionLogs } from "../api-CnUa6o4r.js";
|
|
3
|
+
export { DEFAULT_API_BASE_URL_1, DEFAULT_API_BASE_URL_2, PRIMITIVE_SIGNATURE_HEADER, PrimitiveApiClient, PrimitiveApiError, PrimitiveClient, WebhookVerificationError, addDomain, cliLogout, client, createEndpoint, createFilter, createFunction, createFunctionSecret, createPrimitiveApiClient, createPrimitiveClient, deleteDomain, deleteEmail, deleteEndpoint, deleteFilter, deleteFunction, deleteFunctionSecret, discardEmailContent, downloadAttachments, downloadRawEmail, getAccount, getEmail, getFunction, getSendPermissions, getSentEmail, getStorageStats, getWebhookSecret, listDeliveries, listDomains, listEmails, listEndpoints, listFilters, listFunctionLogs, listFunctionSecrets, listFunctions, listSentEmails, operations, pollCliLogin, replayDelivery, replayEmailWebhooks, replyToEmail, rotateWebhookSecret, searchEmails, sendEmail, setFunctionSecret, startCliLogin, testEndpoint, testFunction, updateAccount, updateDomain, updateEndpoint, updateFilter, updateFunction, verifyDomain, verifyWebhookSignature };
|