@primitivedotdev/sdk 0.9.0 → 0.11.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 +22 -0
- package/dist/api/generated/index.js +1 -1
- package/dist/api/generated/sdk.gen.js +26 -0
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.js +72 -33
- package/dist/{api-COSr-Fqm.js → api-CLLpjjWy.js} +87 -31
- package/dist/{index-DVow4Fjd.d.ts → index-K4KbjppU.d.ts} +220 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/oclif/api-command.js +217 -47
- package/dist/oclif/commands/send.js +159 -0
- package/dist/oclif/index.js +6 -0
- package/dist/openapi/openapi.generated.js +190 -3
- package/dist/openapi/operations.generated.js +49 -0
- package/oclif.manifest.json +359 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -103,6 +103,28 @@ await client.reply(email, {
|
|
|
103
103
|
});
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
+
### HTML replies and waiting on the delivery outcome
|
|
107
|
+
|
|
108
|
+
`reply()` accepts `html` as a sibling of `text`, plus the same `wait` flag the
|
|
109
|
+
top-level `send()` takes:
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
await client.reply(email, {
|
|
113
|
+
text: "Thanks for your email.",
|
|
114
|
+
html: "<p>Thanks for your email.</p>",
|
|
115
|
+
wait: true,
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
`subject` is intentionally not accepted on `reply()`. Gmail's Conversation View
|
|
120
|
+
needs both a References match and a normalized-subject match to thread, so a
|
|
121
|
+
custom subject silently breaks the thread for half the recipient population.
|
|
122
|
+
Use `client.send(...)` if you need full subject control.
|
|
123
|
+
|
|
124
|
+
If the inbound row is not in a state we can reply to (no `Message-Id` recorded,
|
|
125
|
+
or content was discarded), the API returns `inbound_not_repliable` (HTTP 422)
|
|
126
|
+
and the SDK throws.
|
|
127
|
+
|
|
106
128
|
### Forward an inbound email
|
|
107
129
|
|
|
108
130
|
```ts
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
export { addDomain, createEndpoint, createFilter, deleteDomain, deleteEmail, deleteEndpoint, deleteFilter, downloadAttachments, downloadRawEmail, getAccount, getEmail, getStorageStats, getWebhookSecret, listDeliveries, listDomains, listEmails, listEndpoints, listFilters, replayDelivery, replayEmailWebhooks, rotateWebhookSecret, sendEmail, testEndpoint, updateAccount, updateDomain, updateEndpoint, updateFilter, verifyDomain } from './sdk.gen.js';
|
|
2
|
+
export { addDomain, createEndpoint, createFilter, deleteDomain, deleteEmail, deleteEndpoint, deleteFilter, downloadAttachments, downloadRawEmail, getAccount, getEmail, getStorageStats, getWebhookSecret, listDeliveries, listDomains, listEmails, listEndpoints, listFilters, replayDelivery, replayEmailWebhooks, replyToEmail, rotateWebhookSecret, sendEmail, testEndpoint, updateAccount, updateDomain, updateEndpoint, updateFilter, verifyDomain } from './sdk.gen.js';
|
|
@@ -184,6 +184,32 @@ export const downloadAttachments = (options) => (options.client ?? client).get({
|
|
|
184
184
|
url: '/emails/{id}/attachments.tar.gz',
|
|
185
185
|
...options
|
|
186
186
|
});
|
|
187
|
+
/**
|
|
188
|
+
* Reply to an inbound email
|
|
189
|
+
*
|
|
190
|
+
* Sends an outbound reply to the inbound email identified by `id`.
|
|
191
|
+
* Threading headers (`In-Reply-To`, `References`), recipient
|
|
192
|
+
* derivation (Reply-To, then From, then bare sender), and the
|
|
193
|
+
* `Re:` subject prefix are all derived server-side from the
|
|
194
|
+
* stored inbound row. The request body carries only the message
|
|
195
|
+
* body and optional `wait` flag; passing any header or recipient
|
|
196
|
+
* override is rejected by the schema (`additionalProperties:
|
|
197
|
+
* false`).
|
|
198
|
+
*
|
|
199
|
+
* Forwards through the same gates as `/send-mail`: the response
|
|
200
|
+
* status, error envelope, and `idempotent_replay` flag mirror
|
|
201
|
+
* the send-mail contract verbatim.
|
|
202
|
+
*
|
|
203
|
+
*/
|
|
204
|
+
export const replyToEmail = (options) => (options.client ?? client).post({
|
|
205
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
206
|
+
url: '/emails/{id}/reply',
|
|
207
|
+
...options,
|
|
208
|
+
headers: {
|
|
209
|
+
'Content-Type': 'application/json',
|
|
210
|
+
...options.headers
|
|
211
|
+
}
|
|
212
|
+
});
|
|
187
213
|
/**
|
|
188
214
|
* Replay email webhooks
|
|
189
215
|
*
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { Account, AccountUpdated, AddDomainData, AddDomainError, AddDomainErrors, AddDomainInput, AddDomainResponse, AddDomainResponses, Auth, ClientOptions, CreateClientConfig, CreateEndpointData, CreateEndpointError, CreateEndpointErrors, CreateEndpointInput, CreateEndpointResponse, CreateEndpointResponses, CreateFilterData, CreateFilterError, CreateFilterErrors, CreateFilterInput, CreateFilterResponse, CreateFilterResponses, Cursor, DEFAULT_BASE_URL, DeleteDomainData, DeleteDomainError, DeleteDomainErrors, DeleteDomainResponse, DeleteDomainResponses, DeleteEmailData, DeleteEmailError, DeleteEmailErrors, DeleteEmailResponse, DeleteEmailResponses, DeleteEndpointData, DeleteEndpointError, DeleteEndpointErrors, DeleteEndpointResponse, DeleteEndpointResponses, DeleteFilterData, DeleteFilterError, DeleteFilterErrors, DeleteFilterResponse, DeleteFilterResponses, DeliveryStatus, DeliverySummary, Domain, DomainVerifyResult, DownloadAttachmentsData, DownloadAttachmentsError, DownloadAttachmentsErrors, DownloadAttachmentsResponse, DownloadAttachmentsResponses, DownloadRawEmailData, DownloadRawEmailError, DownloadRawEmailErrors, DownloadRawEmailResponse, DownloadRawEmailResponses, EmailDetail, EmailSummary, Endpoint, ErrorResponse, Filter, ForwardInput, GateDenial, GateFix, GetAccountData, GetAccountError, GetAccountErrors, GetAccountResponse, GetAccountResponses, GetEmailData, GetEmailError, GetEmailErrors, GetEmailResponse, GetEmailResponses, GetStorageStatsData, GetStorageStatsError, GetStorageStatsErrors, GetStorageStatsResponse, GetStorageStatsResponses, GetWebhookSecretData, GetWebhookSecretError, GetWebhookSecretErrors, GetWebhookSecretResponse, GetWebhookSecretResponses, Limit, ListDeliveriesData, ListDeliveriesError, ListDeliveriesErrors, ListDeliveriesResponse, ListDeliveriesResponses, ListDomainsData, ListDomainsError, ListDomainsErrors, ListDomainsResponse, ListDomainsResponses, ListEmailsData, ListEmailsError, ListEmailsErrors, ListEmailsResponse, ListEmailsResponses, ListEndpointsData, ListEndpointsError, ListEndpointsErrors, ListEndpointsResponse, ListEndpointsResponses, ListEnvelope, ListFiltersData, ListFiltersError, ListFiltersErrors, ListFiltersResponse, ListFiltersResponses, Options, PaginationMeta, PrimitiveApiClient, PrimitiveApiClientOptions, PrimitiveApiError, PrimitiveApiErrorDetails, PrimitiveClient, PrimitiveClientOptions, Client as PrimitiveGeneratedApiClient, ClientOptions$1 as PrimitiveGeneratedApiClientOptions, Config as PrimitiveGeneratedApiConfig, Options$1 as PrimitiveGeneratedApiOptions, RequestOptions as PrimitiveGeneratedApiRequestOptions, RequestResult as PrimitiveGeneratedApiRequestResult, ReplayDeliveryData, ReplayDeliveryError, ReplayDeliveryErrors, ReplayDeliveryResponse, ReplayDeliveryResponses, ReplayEmailWebhooksData, ReplayEmailWebhooksError, ReplayEmailWebhooksErrors, ReplayEmailWebhooksResponse, ReplayEmailWebhooksResponses, ReplayResult, ReplyInput, ResourceId, ResponseStyle, RotateWebhookSecretData, RotateWebhookSecretError, RotateWebhookSecretErrors, RotateWebhookSecretResponse, RotateWebhookSecretResponses, SendEmailData, SendEmailError, SendEmailErrors, SendEmailResponse, SendEmailResponses, SendInput, SendMailInput, SendMailResult, SendResult, SendThreadInput, SentEmailStatus, StorageStats, SuccessEnvelope, TestEndpointData, TestEndpointError, TestEndpointErrors, TestEndpointResponse, TestEndpointResponses, TestResult, UnverifiedDomain, UpdateAccountData, UpdateAccountError, UpdateAccountErrors, UpdateAccountInput, UpdateAccountResponse, UpdateAccountResponses, UpdateDomainData, UpdateDomainError, UpdateDomainErrors, UpdateDomainInput, UpdateDomainResponse, UpdateDomainResponses, UpdateEndpointData, UpdateEndpointError, UpdateEndpointErrors, UpdateEndpointInput, UpdateEndpointResponse, UpdateEndpointResponses, UpdateFilterData, UpdateFilterError, UpdateFilterErrors, UpdateFilterInput, UpdateFilterResponse, UpdateFilterResponses, VerifiedDomain, VerifyDomainData, VerifyDomainError, VerifyDomainErrors, VerifyDomainResponse, VerifyDomainResponses, WebhookSecret, addDomain, client, createEndpoint, createFilter, createPrimitiveApiClient, createPrimitiveClient, deleteDomain, deleteEmail, deleteEndpoint, deleteFilter, downloadAttachments, downloadRawEmail, getAccount, getEmail, getStorageStats, getWebhookSecret, listDeliveries, listDomains, listEmails, listEndpoints, listFilters, operations, replayDelivery, replayEmailWebhooks, rotateWebhookSecret, sendEmail, testEndpoint, updateAccount, updateDomain, updateEndpoint, updateFilter, verifyDomain };
|
|
1
|
+
import { $ as AddDomainResponse, $n as ReplayDeliveryErrors, $r as UpdateEndpointResponses, $t as ErrorResponse, A as getWebhookSecret, An as ListDomainsError, Ar as TestEndpointError, At as DeleteFilterData, B as sendEmail, Bn as ListEndpointsError, Br as UpdateAccountResponse, Bt as DownloadAttachmentsError, C as deleteEndpoint, Cn as Limit, Cr as SendEmailResponses, Ct as DeleteEmailResponse, D as getAccount, Dn as ListDeliveriesResponse, Dr as StorageStats, Dt as DeleteEndpointErrors, E as downloadRawEmail, En as ListDeliveriesErrors, Er as SentEmailStatus, Et as DeleteEndpointError, F as listFilters, Fn as ListEmailsError, Fr as UnverifiedDomain, Ft as DeliveryStatus, G as updateFilter, Gn as ListFiltersData, Gr as UpdateDomainInput, Gt as DownloadRawEmailError, H as updateAccount, Hn as ListEndpointsResponse, Hr as UpdateDomainData, Ht as DownloadAttachmentsResponse, I as replayDelivery, In as ListEmailsErrors, Ir as UpdateAccountData, It as DeliverySummary, J as AccountUpdated, Jn as ListFiltersResponse, Jr as UpdateEndpointData, Jt as DownloadRawEmailResponses, K as verifyDomain, Kn as ListFiltersError, Kr as UpdateDomainResponse, Kt as DownloadRawEmailErrors, L as replayEmailWebhooks, Ln as ListEmailsResponse, Lr as UpdateAccountError, Lt as Domain, M as listDomains, Mn as ListDomainsResponse, Mr as TestEndpointResponse, Mt as DeleteFilterErrors, N as listEmails, Nn as ListDomainsResponses, Nr as TestEndpointResponses, Nt as DeleteFilterResponse, O as getEmail, On as ListDeliveriesResponses, Or as SuccessEnvelope, Ot as DeleteEndpointResponse, P as listEndpoints, Pn as ListEmailsData, Pr as TestResult, Pt as DeleteFilterResponses, Q as AddDomainInput, Qn as ReplayDeliveryError, Qr as UpdateEndpointResponse, Qt as Endpoint, R as replyToEmail, Rn as ListEmailsResponses, Rr as UpdateAccountErrors, Rt as DomainVerifyResult, S as deleteEmail, Sn as GetWebhookSecretResponses, Sr as SendEmailResponse, St as DeleteEmailErrors, T as downloadAttachments, Tn as ListDeliveriesError, Tr as SendMailResult, Tt as DeleteEndpointData, U as updateDomain, Un as ListEndpointsResponses, Ur as UpdateDomainError, Ut as DownloadAttachmentsResponses, V as testEndpoint, Vn as ListEndpointsErrors, Vr as UpdateAccountResponses, Vt as DownloadAttachmentsErrors, W as updateEndpoint, Wn as ListEnvelope, Wr as UpdateDomainErrors, Wt as DownloadRawEmailData, X as AddDomainError, Xn as PaginationMeta, Xr as UpdateEndpointErrors, Xt as EmailDetailReply, Y as AddDomainData, Yn as ListFiltersResponses, Yr as UpdateEndpointError, Yt as EmailDetail, Z as AddDomainErrors, Zn as ReplayDeliveryData, Zr as UpdateEndpointInput, Zt as EmailSummary, _ as Options, _i as Options$1, _n as GetStorageStatsResponses, _r as RotateWebhookSecretResponse, _t as DeleteDomainErrors, a as PrimitiveApiError, ai as UpdateFilterResponses, an as GetAccountErrors, ar as ReplayEmailWebhooksResponse, at as CreateEndpointInput, b as createFilter, bi as ResponseStyle, bn as GetWebhookSecretErrors, br as SendEmailError, bt as DeleteEmailData, c as PrimitiveClientOptions, ci as VerifyDomainError, cn as GetEmailData, cr as ReplyToEmailData, ct as CreateFilterData, d as SendResult, di as VerifyDomainResponses, dn as GetEmailResponse, dr as ReplyToEmailResponse, dt as CreateFilterInput, ei as UpdateFilterData, en as Filter, er as ReplayDeliveryResponse, et as AddDomainResponses, f as SendThreadInput, fi as WebhookSecret, fn as GetEmailResponses, fr as ReplyToEmailResponses, ft as CreateFilterResponse, g as operations, gi as CreateClientConfig, gn as GetStorageStatsResponse, gr as RotateWebhookSecretErrors, gt as DeleteDomainError, h as createPrimitiveClient, hi as Config, hn as GetStorageStatsErrors, hr as RotateWebhookSecretError, ht as DeleteDomainData, i as PrimitiveApiClientOptions, ii as UpdateFilterResponse, in as GetAccountError, ir as ReplayEmailWebhooksErrors, it as CreateEndpointErrors, j as listDeliveries, jn as ListDomainsErrors, jr as TestEndpointErrors, jt as DeleteFilterError, k as getStorageStats, kn as ListDomainsData, kr as TestEndpointData, kt as DeleteEndpointResponses, l as ReplyInput, li as VerifyDomainErrors, ln as GetEmailError, lr as ReplyToEmailError, lt as CreateFilterError, m as createPrimitiveApiClient, mi as ClientOptions$1, mn as GetStorageStatsError, mr as RotateWebhookSecretData, mt as Cursor, n as ForwardInput, ni as UpdateFilterErrors, nn as GateFix, nr as ReplayEmailWebhooksData, nt as CreateEndpointData, o as PrimitiveApiErrorDetails, oi as VerifiedDomain, on as GetAccountResponse, or as ReplayEmailWebhooksResponses, ot as CreateEndpointResponse, p as client, pi as Client, pn as GetStorageStatsData, pr as ResourceId, pt as CreateFilterResponses, q as Account, qn as ListFiltersErrors, qr as UpdateDomainResponses, qt as DownloadRawEmailResponse, r as PrimitiveApiClient, ri as UpdateFilterInput, rn as GetAccountData, rr as ReplayEmailWebhooksError, rt as CreateEndpointError, s as PrimitiveClient, si as VerifyDomainData, sn as GetAccountResponses, sr as ReplayResult, st as CreateEndpointResponses, t as DEFAULT_BASE_URL, ti as UpdateFilterError, tn as GateDenial, tr as ReplayDeliveryResponses, tt as ClientOptions, u as SendInput, ui as VerifyDomainResponse, un as GetEmailErrors, ur as ReplyToEmailErrors, ut as CreateFilterErrors, v as addDomain, vi as RequestOptions, vn as GetWebhookSecretData, vr as RotateWebhookSecretResponses, vt as DeleteDomainResponse, w as deleteFilter, wn as ListDeliveriesData, wr as SendMailInput, wt as DeleteEmailResponses, x as deleteDomain, xi as Auth, xn as GetWebhookSecretResponse, xr as SendEmailErrors, xt as DeleteEmailError, y as createEndpoint, yi as RequestResult, yn as GetWebhookSecretError, yr as SendEmailData, yt as DeleteDomainResponses, z as rotateWebhookSecret, zn as ListEndpointsData, zr as UpdateAccountInput, zt as DownloadAttachmentsData } from "../index-K4KbjppU.js";
|
|
2
|
+
export { Account, AccountUpdated, AddDomainData, AddDomainError, AddDomainErrors, AddDomainInput, AddDomainResponse, AddDomainResponses, Auth, ClientOptions, CreateClientConfig, CreateEndpointData, CreateEndpointError, CreateEndpointErrors, CreateEndpointInput, CreateEndpointResponse, CreateEndpointResponses, CreateFilterData, CreateFilterError, CreateFilterErrors, CreateFilterInput, CreateFilterResponse, CreateFilterResponses, Cursor, DEFAULT_BASE_URL, DeleteDomainData, DeleteDomainError, DeleteDomainErrors, DeleteDomainResponse, DeleteDomainResponses, DeleteEmailData, DeleteEmailError, DeleteEmailErrors, DeleteEmailResponse, DeleteEmailResponses, DeleteEndpointData, DeleteEndpointError, DeleteEndpointErrors, DeleteEndpointResponse, DeleteEndpointResponses, DeleteFilterData, DeleteFilterError, DeleteFilterErrors, DeleteFilterResponse, DeleteFilterResponses, DeliveryStatus, DeliverySummary, Domain, DomainVerifyResult, DownloadAttachmentsData, DownloadAttachmentsError, DownloadAttachmentsErrors, DownloadAttachmentsResponse, DownloadAttachmentsResponses, DownloadRawEmailData, DownloadRawEmailError, DownloadRawEmailErrors, DownloadRawEmailResponse, DownloadRawEmailResponses, EmailDetail, EmailDetailReply, EmailSummary, Endpoint, ErrorResponse, Filter, ForwardInput, GateDenial, GateFix, GetAccountData, GetAccountError, GetAccountErrors, GetAccountResponse, GetAccountResponses, GetEmailData, GetEmailError, GetEmailErrors, GetEmailResponse, GetEmailResponses, GetStorageStatsData, GetStorageStatsError, GetStorageStatsErrors, GetStorageStatsResponse, GetStorageStatsResponses, GetWebhookSecretData, GetWebhookSecretError, GetWebhookSecretErrors, GetWebhookSecretResponse, GetWebhookSecretResponses, Limit, ListDeliveriesData, ListDeliveriesError, ListDeliveriesErrors, ListDeliveriesResponse, ListDeliveriesResponses, ListDomainsData, ListDomainsError, ListDomainsErrors, ListDomainsResponse, ListDomainsResponses, ListEmailsData, ListEmailsError, ListEmailsErrors, ListEmailsResponse, ListEmailsResponses, ListEndpointsData, ListEndpointsError, ListEndpointsErrors, ListEndpointsResponse, ListEndpointsResponses, ListEnvelope, ListFiltersData, ListFiltersError, ListFiltersErrors, ListFiltersResponse, ListFiltersResponses, Options, PaginationMeta, PrimitiveApiClient, PrimitiveApiClientOptions, PrimitiveApiError, PrimitiveApiErrorDetails, PrimitiveClient, PrimitiveClientOptions, Client as PrimitiveGeneratedApiClient, ClientOptions$1 as PrimitiveGeneratedApiClientOptions, Config as PrimitiveGeneratedApiConfig, Options$1 as PrimitiveGeneratedApiOptions, RequestOptions as PrimitiveGeneratedApiRequestOptions, RequestResult as PrimitiveGeneratedApiRequestResult, ReplayDeliveryData, ReplayDeliveryError, ReplayDeliveryErrors, ReplayDeliveryResponse, ReplayDeliveryResponses, ReplayEmailWebhooksData, ReplayEmailWebhooksError, ReplayEmailWebhooksErrors, ReplayEmailWebhooksResponse, ReplayEmailWebhooksResponses, ReplayResult, ReplyInput, ReplyToEmailData, ReplyToEmailError, ReplyToEmailErrors, ReplyToEmailResponse, ReplyToEmailResponses, ResourceId, ResponseStyle, RotateWebhookSecretData, RotateWebhookSecretError, RotateWebhookSecretErrors, RotateWebhookSecretResponse, RotateWebhookSecretResponses, SendEmailData, SendEmailError, SendEmailErrors, SendEmailResponse, SendEmailResponses, SendInput, SendMailInput, SendMailResult, SendResult, SendThreadInput, SentEmailStatus, StorageStats, SuccessEnvelope, TestEndpointData, TestEndpointError, TestEndpointErrors, TestEndpointResponse, TestEndpointResponses, TestResult, UnverifiedDomain, UpdateAccountData, UpdateAccountError, UpdateAccountErrors, UpdateAccountInput, UpdateAccountResponse, UpdateAccountResponses, UpdateDomainData, UpdateDomainError, UpdateDomainErrors, UpdateDomainInput, UpdateDomainResponse, UpdateDomainResponses, UpdateEndpointData, UpdateEndpointError, UpdateEndpointErrors, UpdateEndpointInput, UpdateEndpointResponse, UpdateEndpointResponses, UpdateFilterData, UpdateFilterError, UpdateFilterErrors, UpdateFilterInput, UpdateFilterResponse, UpdateFilterResponses, VerifiedDomain, VerifyDomainData, VerifyDomainError, VerifyDomainErrors, VerifyDomainResponse, VerifyDomainResponses, WebhookSecret, addDomain, client, createEndpoint, createFilter, createPrimitiveApiClient, createPrimitiveClient, deleteDomain, deleteEmail, deleteEndpoint, deleteFilter, downloadAttachments, downloadRawEmail, getAccount, getEmail, getStorageStats, getWebhookSecret, listDeliveries, listDomains, listEmails, listEndpoints, listFilters, operations, replayDelivery, replayEmailWebhooks, replyToEmail, rotateWebhookSecret, sendEmail, testEndpoint, updateAccount, updateDomain, updateEndpoint, updateFilter, verifyDomain };
|
package/dist/api/index.js
CHANGED
|
@@ -194,43 +194,50 @@ export class PrimitiveClient extends PrimitiveApiClient {
|
|
|
194
194
|
client: this.client,
|
|
195
195
|
responseStyle: "fields",
|
|
196
196
|
});
|
|
197
|
-
|
|
198
|
-
if (result.error) {
|
|
199
|
-
const parsed = parseApiErrorPayload(result.error);
|
|
200
|
-
throw new PrimitiveApiError(parsed.message, {
|
|
201
|
-
payload: result.error,
|
|
202
|
-
status: response?.status,
|
|
203
|
-
code: parsed.code,
|
|
204
|
-
gates: parsed.gates,
|
|
205
|
-
requestId: parsed.requestId,
|
|
206
|
-
retryAfter: parseRetryAfterHeader(response),
|
|
207
|
-
details: parsed.details,
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
if (!result.data?.data) {
|
|
211
|
-
throw new PrimitiveApiError("Primitive API returned no send result", {
|
|
212
|
-
payload: result,
|
|
213
|
-
status: response?.status,
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
return mapSendResult(result.data.data);
|
|
197
|
+
return unwrapSendResult(result);
|
|
217
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Reply to an inbound email.
|
|
201
|
+
*
|
|
202
|
+
* Calls `POST /emails/{id}/reply`. The server derives recipients
|
|
203
|
+
* (Reply-To, then From, then sender), subject (`Re: <parent>` with
|
|
204
|
+
* idempotent prefix), and threading headers (`In-Reply-To`,
|
|
205
|
+
* `References`) from the stored inbound row. The customer controls
|
|
206
|
+
* only the body, an optional `from` override, and the `wait` flag.
|
|
207
|
+
*
|
|
208
|
+
* Subject overrides are intentionally not supported: Gmail's
|
|
209
|
+
* Conversation View needs both a References match and a normalized-
|
|
210
|
+
* subject match to thread, so a custom subject silently breaks the
|
|
211
|
+
* thread for half the recipient population.
|
|
212
|
+
*/
|
|
218
213
|
async reply(email, input) {
|
|
219
214
|
const resolved = typeof input === "string" ? { text: input } : input;
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
215
|
+
// Reject the subject override at runtime so a JS caller (no TS
|
|
216
|
+
// types) gets the same loud error as a TS caller. Without this,
|
|
217
|
+
// `client.reply(email, { text, subject: "Custom" })` silently
|
|
218
|
+
// dropped subject and sent a "Re:" reply, breaking Gmail
|
|
219
|
+
// threading without telling the caller. Mirrors Python's
|
|
220
|
+
// ValueError. Checked before the empty-body check so passing
|
|
221
|
+
// ONLY a subject surfaces the more informative error.
|
|
222
|
+
if ("subject" in resolved) {
|
|
223
|
+
throw new TypeError("reply does not support a subject override; the server prepends 'Re:' to the parent's subject for thread continuity");
|
|
224
|
+
}
|
|
225
|
+
if (!resolved.text && !resolved.html) {
|
|
226
|
+
throw new TypeError("reply requires text or html");
|
|
227
|
+
}
|
|
228
|
+
const body = {
|
|
229
|
+
...(resolved.text !== undefined ? { body_text: resolved.text } : {}),
|
|
230
|
+
...(resolved.html !== undefined ? { body_html: resolved.html } : {}),
|
|
231
|
+
...(resolved.from !== undefined ? { from: resolved.from } : {}),
|
|
232
|
+
...(resolved.wait !== undefined ? { wait: resolved.wait } : {}),
|
|
233
|
+
};
|
|
234
|
+
const result = await generatedOperations.replyToEmail({
|
|
235
|
+
body,
|
|
236
|
+
path: { id: email.id },
|
|
237
|
+
client: this.client,
|
|
238
|
+
responseStyle: "fields",
|
|
233
239
|
});
|
|
240
|
+
return unwrapSendResult(result);
|
|
234
241
|
}
|
|
235
242
|
async forward(email, input) {
|
|
236
243
|
validateForwardInput(input);
|
|
@@ -260,6 +267,34 @@ function buildForwardText(email, intro) {
|
|
|
260
267
|
];
|
|
261
268
|
return lines.join("\n").trimEnd();
|
|
262
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* Shared response handler for `send`, `reply`, and any future
|
|
272
|
+
* operation that returns a SendMailResult envelope. Unifies the
|
|
273
|
+
* error-mapping path so the network call sites only have to invoke
|
|
274
|
+
* the generated operation.
|
|
275
|
+
*/
|
|
276
|
+
function unwrapSendResult(result) {
|
|
277
|
+
const response = result.response;
|
|
278
|
+
if (result.error) {
|
|
279
|
+
const parsed = parseApiErrorPayload(result.error);
|
|
280
|
+
throw new PrimitiveApiError(parsed.message, {
|
|
281
|
+
payload: result.error,
|
|
282
|
+
status: response?.status,
|
|
283
|
+
code: parsed.code,
|
|
284
|
+
gates: parsed.gates,
|
|
285
|
+
requestId: parsed.requestId,
|
|
286
|
+
retryAfter: parseRetryAfterHeader(response),
|
|
287
|
+
details: parsed.details,
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
if (!result.data?.data) {
|
|
291
|
+
throw new PrimitiveApiError("Primitive API returned no send result", {
|
|
292
|
+
payload: result,
|
|
293
|
+
status: response?.status,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
return mapSendResult(result.data.data);
|
|
297
|
+
}
|
|
263
298
|
function mapSendResult(result) {
|
|
264
299
|
return {
|
|
265
300
|
id: result.id,
|
|
@@ -270,6 +305,10 @@ function mapSendResult(result) {
|
|
|
270
305
|
clientIdempotencyKey: result.client_idempotency_key,
|
|
271
306
|
requestId: result.request_id,
|
|
272
307
|
contentHash: result.content_hash,
|
|
308
|
+
// Default to false if the server omits the field (old-format
|
|
309
|
+
// response, mocked partial response in a customer's tests). The
|
|
310
|
+
// type signature claims `boolean`, so undefined would be a lie.
|
|
311
|
+
idempotentReplay: result.idempotent_replay ?? false,
|
|
273
312
|
...(result.delivery_status !== undefined
|
|
274
313
|
? { deliveryStatus: result.delivery_status }
|
|
275
314
|
: {}),
|
|
@@ -633,6 +633,7 @@ var sdk_gen_exports = /* @__PURE__ */ __exportAll({
|
|
|
633
633
|
listFilters: () => listFilters,
|
|
634
634
|
replayDelivery: () => replayDelivery,
|
|
635
635
|
replayEmailWebhooks: () => replayEmailWebhooks,
|
|
636
|
+
replyToEmail: () => replyToEmail,
|
|
636
637
|
rotateWebhookSecret: () => rotateWebhookSecret,
|
|
637
638
|
sendEmail: () => sendEmail,
|
|
638
639
|
testEndpoint: () => testEndpoint,
|
|
@@ -872,6 +873,35 @@ const downloadAttachments = (options) => (options.client ?? client$1).get({
|
|
|
872
873
|
...options
|
|
873
874
|
});
|
|
874
875
|
/**
|
|
876
|
+
* Reply to an inbound email
|
|
877
|
+
*
|
|
878
|
+
* Sends an outbound reply to the inbound email identified by `id`.
|
|
879
|
+
* Threading headers (`In-Reply-To`, `References`), recipient
|
|
880
|
+
* derivation (Reply-To, then From, then bare sender), and the
|
|
881
|
+
* `Re:` subject prefix are all derived server-side from the
|
|
882
|
+
* stored inbound row. The request body carries only the message
|
|
883
|
+
* body and optional `wait` flag; passing any header or recipient
|
|
884
|
+
* override is rejected by the schema (`additionalProperties:
|
|
885
|
+
* false`).
|
|
886
|
+
*
|
|
887
|
+
* Forwards through the same gates as `/send-mail`: the response
|
|
888
|
+
* status, error envelope, and `idempotent_replay` flag mirror
|
|
889
|
+
* the send-mail contract verbatim.
|
|
890
|
+
*
|
|
891
|
+
*/
|
|
892
|
+
const replyToEmail = (options) => (options.client ?? client$1).post({
|
|
893
|
+
security: [{
|
|
894
|
+
scheme: "bearer",
|
|
895
|
+
type: "http"
|
|
896
|
+
}],
|
|
897
|
+
url: "/emails/{id}/reply",
|
|
898
|
+
...options,
|
|
899
|
+
headers: {
|
|
900
|
+
"Content-Type": "application/json",
|
|
901
|
+
...options.headers
|
|
902
|
+
}
|
|
903
|
+
});
|
|
904
|
+
/**
|
|
875
905
|
* Replay email webhooks
|
|
876
906
|
*
|
|
877
907
|
* Re-delivers the webhook payload for this email to all active
|
|
@@ -1211,7 +1241,7 @@ var PrimitiveApiClient = class {
|
|
|
1211
1241
|
var PrimitiveClient = class extends PrimitiveApiClient {
|
|
1212
1242
|
async send(input) {
|
|
1213
1243
|
validateSendInput(input);
|
|
1214
|
-
|
|
1244
|
+
return unwrapSendResult(await sendEmail({
|
|
1215
1245
|
body: {
|
|
1216
1246
|
from: input.from,
|
|
1217
1247
|
to: input.to,
|
|
@@ -1226,38 +1256,37 @@ var PrimitiveClient = class extends PrimitiveApiClient {
|
|
|
1226
1256
|
...input.idempotencyKey ? { headers: { "Idempotency-Key": input.idempotencyKey } } : {},
|
|
1227
1257
|
client: this.client,
|
|
1228
1258
|
responseStyle: "fields"
|
|
1229
|
-
});
|
|
1230
|
-
const response = result.response;
|
|
1231
|
-
if (result.error) {
|
|
1232
|
-
const parsed = parseApiErrorPayload(result.error);
|
|
1233
|
-
throw new PrimitiveApiError(parsed.message, {
|
|
1234
|
-
payload: result.error,
|
|
1235
|
-
status: response?.status,
|
|
1236
|
-
code: parsed.code,
|
|
1237
|
-
gates: parsed.gates,
|
|
1238
|
-
requestId: parsed.requestId,
|
|
1239
|
-
retryAfter: parseRetryAfterHeader(response),
|
|
1240
|
-
details: parsed.details
|
|
1241
|
-
});
|
|
1242
|
-
}
|
|
1243
|
-
if (!result.data?.data) throw new PrimitiveApiError("Primitive API returned no send result", {
|
|
1244
|
-
payload: result,
|
|
1245
|
-
status: response?.status
|
|
1246
|
-
});
|
|
1247
|
-
return mapSendResult(result.data.data);
|
|
1259
|
+
}));
|
|
1248
1260
|
}
|
|
1261
|
+
/**
|
|
1262
|
+
* Reply to an inbound email.
|
|
1263
|
+
*
|
|
1264
|
+
* Calls `POST /emails/{id}/reply`. The server derives recipients
|
|
1265
|
+
* (Reply-To, then From, then sender), subject (`Re: <parent>` with
|
|
1266
|
+
* idempotent prefix), and threading headers (`In-Reply-To`,
|
|
1267
|
+
* `References`) from the stored inbound row. The customer controls
|
|
1268
|
+
* only the body, an optional `from` override, and the `wait` flag.
|
|
1269
|
+
*
|
|
1270
|
+
* Subject overrides are intentionally not supported: Gmail's
|
|
1271
|
+
* Conversation View needs both a References match and a normalized-
|
|
1272
|
+
* subject match to thread, so a custom subject silently breaks the
|
|
1273
|
+
* thread for half the recipient population.
|
|
1274
|
+
*/
|
|
1249
1275
|
async reply(email, input) {
|
|
1250
1276
|
const resolved = typeof input === "string" ? { text: input } : input;
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
...
|
|
1258
|
-
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1277
|
+
if ("subject" in resolved) throw new TypeError("reply does not support a subject override; the server prepends 'Re:' to the parent's subject for thread continuity");
|
|
1278
|
+
if (!resolved.text && !resolved.html) throw new TypeError("reply requires text or html");
|
|
1279
|
+
return unwrapSendResult(await replyToEmail({
|
|
1280
|
+
body: {
|
|
1281
|
+
...resolved.text !== void 0 ? { body_text: resolved.text } : {},
|
|
1282
|
+
...resolved.html !== void 0 ? { body_html: resolved.html } : {},
|
|
1283
|
+
...resolved.from !== void 0 ? { from: resolved.from } : {},
|
|
1284
|
+
...resolved.wait !== void 0 ? { wait: resolved.wait } : {}
|
|
1285
|
+
},
|
|
1286
|
+
path: { id: email.id },
|
|
1287
|
+
client: this.client,
|
|
1288
|
+
responseStyle: "fields"
|
|
1289
|
+
}));
|
|
1261
1290
|
}
|
|
1262
1291
|
async forward(email, input) {
|
|
1263
1292
|
validateForwardInput(input);
|
|
@@ -1282,6 +1311,32 @@ function buildForwardText(email, intro) {
|
|
|
1282
1311
|
email.text ?? ""
|
|
1283
1312
|
].join("\n").trimEnd();
|
|
1284
1313
|
}
|
|
1314
|
+
/**
|
|
1315
|
+
* Shared response handler for `send`, `reply`, and any future
|
|
1316
|
+
* operation that returns a SendMailResult envelope. Unifies the
|
|
1317
|
+
* error-mapping path so the network call sites only have to invoke
|
|
1318
|
+
* the generated operation.
|
|
1319
|
+
*/
|
|
1320
|
+
function unwrapSendResult(result) {
|
|
1321
|
+
const response = result.response;
|
|
1322
|
+
if (result.error) {
|
|
1323
|
+
const parsed = parseApiErrorPayload(result.error);
|
|
1324
|
+
throw new PrimitiveApiError(parsed.message, {
|
|
1325
|
+
payload: result.error,
|
|
1326
|
+
status: response?.status,
|
|
1327
|
+
code: parsed.code,
|
|
1328
|
+
gates: parsed.gates,
|
|
1329
|
+
requestId: parsed.requestId,
|
|
1330
|
+
retryAfter: parseRetryAfterHeader(response),
|
|
1331
|
+
details: parsed.details
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1334
|
+
if (!result.data?.data) throw new PrimitiveApiError("Primitive API returned no send result", {
|
|
1335
|
+
payload: result,
|
|
1336
|
+
status: response?.status
|
|
1337
|
+
});
|
|
1338
|
+
return mapSendResult(result.data.data);
|
|
1339
|
+
}
|
|
1285
1340
|
function mapSendResult(result) {
|
|
1286
1341
|
return {
|
|
1287
1342
|
id: result.id,
|
|
@@ -1292,6 +1347,7 @@ function mapSendResult(result) {
|
|
|
1292
1347
|
clientIdempotencyKey: result.client_idempotency_key,
|
|
1293
1348
|
requestId: result.request_id,
|
|
1294
1349
|
contentHash: result.content_hash,
|
|
1350
|
+
idempotentReplay: result.idempotent_replay ?? false,
|
|
1295
1351
|
...result.delivery_status !== void 0 ? { deliveryStatus: result.delivery_status } : {},
|
|
1296
1352
|
...result.smtp_response_code !== void 0 ? { smtpResponseCode: result.smtp_response_code } : {},
|
|
1297
1353
|
...result.smtp_response_text !== void 0 ? { smtpResponseText: result.smtp_response_text } : {}
|
|
@@ -1308,4 +1364,4 @@ function client(options = {}) {
|
|
|
1308
1364
|
}
|
|
1309
1365
|
const operations = sdk_gen_exports;
|
|
1310
1366
|
//#endregion
|
|
1311
|
-
export {
|
|
1367
|
+
export { rotateWebhookSecret as A, listDomains as C, replayDelivery as D, listFilters as E, updateEndpoint as F, updateFilter as I, verifyDomain as L, testEndpoint as M, updateAccount as N, replayEmailWebhooks as O, updateDomain as P, listDeliveries as S, listEndpoints as T, downloadRawEmail as _, client as a, getStorageStats as b, operations as c, createFilter as d, deleteDomain as f, downloadAttachments as g, deleteFilter as h, PrimitiveClient as i, sendEmail as j, replyToEmail as k, addDomain as l, deleteEndpoint as m, PrimitiveApiClient as n, createPrimitiveApiClient as o, deleteEmail as p, PrimitiveApiError as r, createPrimitiveClient as s, DEFAULT_BASE_URL as t, createEndpoint as u, getAccount as v, listEmails as w, getWebhookSecret as x, getEmail as y };
|