@rpcbase/server 0.638.0 → 0.640.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/accountDeletion.d.ts.map +1 -1
- package/dist/applyRouteLoaders.d.ts.map +1 -1
- package/dist/{email-6gJ8ibKp.js → email-CXD08Xm7.js} +368 -281
- package/dist/email-CXD08Xm7.js.map +1 -0
- package/dist/fileReferences-Dcv9PTqD.js.map +1 -1
- package/dist/{handler-Dy_L6_-U.js → handler-Bwmvm0pQ.js} +5 -4
- package/dist/handler-Bwmvm0pQ.js.map +1 -0
- package/dist/{handler-DOLNpMkW.js → handler-CMEIng_C.js} +2 -2
- package/dist/handler-CMEIng_C.js.map +1 -0
- package/dist/{handler-BL-Je36s.js → handler-Cb8opBxn.js} +3 -3
- package/dist/handler-Cb8opBxn.js.map +1 -0
- package/dist/{handler-BkGfOJ1l.js → handler-F-JQoj8x.js} +5 -4
- package/dist/handler-F-JQoj8x.js.map +1 -0
- package/dist/index.js +4344 -2310
- package/dist/index.js.map +1 -1
- package/dist/initServer.d.ts.map +1 -1
- package/dist/node-C1tH2rT4.js.map +1 -1
- package/dist/notifications.js +2 -2
- package/dist/queryWindow-RHVy3D0L.js.map +1 -1
- package/dist/renderSSR.d.ts.map +1 -1
- package/dist/rts/api/changes/handler.d.ts.map +1 -1
- package/dist/rts/index.js +1 -1
- package/dist/rts/index.js.map +1 -1
- package/dist/{schemas-LLeSMkcz.js → schemas-BzNluG2q.js} +2393 -1137
- package/dist/schemas-BzNluG2q.js.map +1 -0
- package/dist/shared-B1VLaHsk.js.map +1 -1
- package/dist/uploads/api/file-uploads/fileReferences.d.ts +3 -2
- package/dist/uploads/api/file-uploads/fileReferences.d.ts.map +1 -1
- package/dist/uploads/api/file-uploads/imageVariantsPostProcessor.d.ts.map +1 -1
- package/dist/uploads/api/file-uploads/shared.d.ts +2 -2
- package/dist/uploads/api/file-uploads/shared.d.ts.map +1 -1
- package/dist/uploads/api/files/handlers/deleteFile.d.ts.map +1 -1
- package/dist/uploads/api/files/handlers/getFile.d.ts.map +1 -1
- package/dist/uploads/worker.js +3 -2
- package/dist/uploads/worker.js.map +1 -1
- package/dist/uploads.js +2 -2
- package/package.json +24 -14
- package/dist/email-6gJ8ibKp.js.map +0 -1
- package/dist/handler-BL-Je36s.js.map +0 -1
- package/dist/handler-BkGfOJ1l.js.map +0 -1
- package/dist/handler-DOLNpMkW.js.map +0 -1
- package/dist/handler-Dy_L6_-U.js.map +0 -1
- package/dist/schemas-LLeSMkcz.js.map +0 -1
|
@@ -342,6 +342,7 @@ var MimeNode = class {
|
|
|
342
342
|
}
|
|
343
343
|
await this.finalizeChildNodes();
|
|
344
344
|
this.content = this.contentDecoder ? await this.contentDecoder.finalize() : null;
|
|
345
|
+
this.contentDecoder = false;
|
|
345
346
|
this.state = "finished";
|
|
346
347
|
}
|
|
347
348
|
async finalizeChildNodes() {
|
|
@@ -3238,19 +3239,27 @@ function base64ArrayBuffer(arrayBuffer) {
|
|
|
3238
3239
|
//#region ../../node_modules/postal-mime/src/postal-mime.js
|
|
3239
3240
|
var MAX_NESTING_DEPTH = 256;
|
|
3240
3241
|
var MAX_HEADERS_SIZE = 2097152;
|
|
3242
|
+
var MAX_RFC822_NESTING_DEPTH = 10;
|
|
3241
3243
|
function toCamelCase(key) {
|
|
3242
3244
|
return key.replace(/-(.)/g, (o, c) => c.toUpperCase());
|
|
3243
3245
|
}
|
|
3246
|
+
function parseLimitOption(value, defaultValue, name) {
|
|
3247
|
+
if (value === void 0 || value === null) return defaultValue;
|
|
3248
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < 0) throw new TypeError(`${name} must be a non-negative integer`);
|
|
3249
|
+
return value;
|
|
3250
|
+
}
|
|
3244
3251
|
var PostalMime = class PostalMime {
|
|
3245
|
-
static parse(buf, options) {
|
|
3252
|
+
static async parse(buf, options) {
|
|
3246
3253
|
return new PostalMime(options).parse(buf);
|
|
3247
3254
|
}
|
|
3248
|
-
constructor(options) {
|
|
3255
|
+
constructor(options, rfc822NestingDepth = 0) {
|
|
3249
3256
|
this.options = options || {};
|
|
3250
3257
|
this.mimeOptions = {
|
|
3251
|
-
maxNestingDepth: this.options.maxNestingDepth
|
|
3252
|
-
maxHeadersSize: this.options.maxHeadersSize
|
|
3258
|
+
maxNestingDepth: parseLimitOption(this.options.maxNestingDepth, MAX_NESTING_DEPTH, "maxNestingDepth"),
|
|
3259
|
+
maxHeadersSize: parseLimitOption(this.options.maxHeadersSize, MAX_HEADERS_SIZE, "maxHeadersSize")
|
|
3253
3260
|
};
|
|
3261
|
+
this.maxRfc822NestingDepth = parseLimitOption(this.options.maxRfc822NestingDepth, MAX_RFC822_NESTING_DEPTH, "maxRfc822NestingDepth");
|
|
3262
|
+
this.rfc822NestingDepth = rfc822NestingDepth;
|
|
3254
3263
|
this.root = this.currentNode = new MimeNode({
|
|
3255
3264
|
postalMime: this,
|
|
3256
3265
|
...this.mimeOptions
|
|
@@ -3330,8 +3339,14 @@ var PostalMime = class PostalMime {
|
|
|
3330
3339
|
alternative = alternative || false;
|
|
3331
3340
|
related = related || false;
|
|
3332
3341
|
if (!node.contentType.multipart) {
|
|
3333
|
-
|
|
3334
|
-
|
|
3342
|
+
const inlineRfc822 = this.isInlineMessageRfc822(node) && !forceRfc822Attachments;
|
|
3343
|
+
const rfc822DepthExceeded = inlineRfc822 && this.rfc822NestingDepth >= this.maxRfc822NestingDepth;
|
|
3344
|
+
if (inlineRfc822 && !rfc822DepthExceeded) {
|
|
3345
|
+
const subParser = new PostalMime({
|
|
3346
|
+
...this.mimeOptions,
|
|
3347
|
+
maxRfc822NestingDepth: this.maxRfc822NestingDepth,
|
|
3348
|
+
attachmentEncoding: "arraybuffer"
|
|
3349
|
+
}, this.rfc822NestingDepth + 1);
|
|
3335
3350
|
node.subMessage = await subParser.parse(node.content);
|
|
3336
3351
|
if (!textMap.has(node)) textMap.set(node, {});
|
|
3337
3352
|
let textEntry = textMap.get(node);
|
|
@@ -3373,7 +3388,8 @@ var PostalMime = class PostalMime {
|
|
|
3373
3388
|
mimeType: node.contentType.parsed.value,
|
|
3374
3389
|
disposition: node.contentDisposition?.parsed?.value || null
|
|
3375
3390
|
};
|
|
3376
|
-
if (related && node.contentId) attachment.related = true;
|
|
3391
|
+
if (related && node.contentId && !rfc822DepthExceeded) attachment.related = true;
|
|
3392
|
+
if (rfc822DepthExceeded) attachment.rfc822DepthExceeded = true;
|
|
3377
3393
|
if (node.contentDescription) attachment.description = node.contentDescription;
|
|
3378
3394
|
if (node.contentId) attachment.contentId = node.contentId;
|
|
3379
3395
|
switch (node.contentType.parsed.value) {
|
|
@@ -3581,28 +3597,6 @@ var PostalMime = class PostalMime {
|
|
|
3581
3597
|
}
|
|
3582
3598
|
};
|
|
3583
3599
|
//#endregion
|
|
3584
|
-
//#region ../../node_modules/standardwebhooks/dist/timing_safe_equal.js
|
|
3585
|
-
var require_timing_safe_equal = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3586
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3587
|
-
exports.timingSafeEqual = void 0;
|
|
3588
|
-
function assert(expr, msg = "") {
|
|
3589
|
-
if (!expr) throw new Error(msg);
|
|
3590
|
-
}
|
|
3591
|
-
function timingSafeEqual(a, b) {
|
|
3592
|
-
if (a.byteLength !== b.byteLength) return false;
|
|
3593
|
-
if (!(a instanceof DataView)) a = new DataView(ArrayBuffer.isView(a) ? a.buffer : a);
|
|
3594
|
-
if (!(b instanceof DataView)) b = new DataView(ArrayBuffer.isView(b) ? b.buffer : b);
|
|
3595
|
-
assert(a instanceof DataView);
|
|
3596
|
-
assert(b instanceof DataView);
|
|
3597
|
-
const length = a.byteLength;
|
|
3598
|
-
let out = 0;
|
|
3599
|
-
let i = -1;
|
|
3600
|
-
while (++i < length) out |= a.getUint8(i) ^ b.getUint8(i);
|
|
3601
|
-
return out === 0;
|
|
3602
|
-
}
|
|
3603
|
-
exports.timingSafeEqual = timingSafeEqual;
|
|
3604
|
-
}));
|
|
3605
|
-
//#endregion
|
|
3606
3600
|
//#region ../../node_modules/@stablelib/base64/lib/base64.js
|
|
3607
3601
|
var require_base64 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3608
3602
|
var __extends = exports && exports.__extends || (function() {
|
|
@@ -4165,13 +4159,34 @@ var require_sha256 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
4165
4159
|
});
|
|
4166
4160
|
}));
|
|
4167
4161
|
//#endregion
|
|
4162
|
+
//#region ../../node_modules/standardwebhooks/dist/timing_safe_equal.js
|
|
4163
|
+
var require_timing_safe_equal = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
4164
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4165
|
+
exports.timingSafeEqual = timingSafeEqual;
|
|
4166
|
+
function assert(expr, msg = "") {
|
|
4167
|
+
if (!expr) throw new Error(msg);
|
|
4168
|
+
}
|
|
4169
|
+
function timingSafeEqual(a, b) {
|
|
4170
|
+
if (a.byteLength !== b.byteLength) return false;
|
|
4171
|
+
if (!(a instanceof DataView)) a = new DataView(ArrayBuffer.isView(a) ? a.buffer : a);
|
|
4172
|
+
if (!(b instanceof DataView)) b = new DataView(ArrayBuffer.isView(b) ? b.buffer : b);
|
|
4173
|
+
assert(a instanceof DataView);
|
|
4174
|
+
assert(b instanceof DataView);
|
|
4175
|
+
const length = a.byteLength;
|
|
4176
|
+
let out = 0;
|
|
4177
|
+
let i = -1;
|
|
4178
|
+
while (++i < length) out |= a.getUint8(i) ^ b.getUint8(i);
|
|
4179
|
+
return out === 0;
|
|
4180
|
+
}
|
|
4181
|
+
}));
|
|
4182
|
+
//#endregion
|
|
4168
4183
|
//#region ../../node_modules/resend/dist/index.mjs
|
|
4169
4184
|
var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
4170
4185
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4171
4186
|
exports.Webhook = exports.WebhookVerificationError = void 0;
|
|
4172
|
-
var timing_safe_equal_1 = require_timing_safe_equal();
|
|
4173
4187
|
var base64 = require_base64();
|
|
4174
4188
|
var sha256 = require_sha256();
|
|
4189
|
+
var timing_safe_equal_1 = require_timing_safe_equal();
|
|
4175
4190
|
var WEBHOOK_TOLERANCE_IN_SECONDS = 300;
|
|
4176
4191
|
var ExtendableError = class ExtendableError extends Error {
|
|
4177
4192
|
constructor(message) {
|
|
@@ -4191,7 +4206,6 @@ var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
4191
4206
|
exports.WebhookVerificationError = WebhookVerificationError;
|
|
4192
4207
|
var Webhook = class Webhook {
|
|
4193
4208
|
constructor(secret, options) {
|
|
4194
|
-
if (!secret) throw new Error("Secret can't be empty.");
|
|
4195
4209
|
if ((options === null || options === void 0 ? void 0 : options.format) === "raw") {
|
|
4196
4210
|
if (secret instanceof Uint8Array) this.key = secret;
|
|
4197
4211
|
else this.key = Uint8Array.from(secret, (c) => c.charCodeAt(0));
|
|
@@ -4200,13 +4214,16 @@ var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
4200
4214
|
if (secret.startsWith(Webhook.prefix)) secret = secret.substring(Webhook.prefix.length);
|
|
4201
4215
|
this.key = base64.decode(secret);
|
|
4202
4216
|
}
|
|
4217
|
+
if (this.key.length === 0) throw new Error("Secret can't be empty.");
|
|
4203
4218
|
}
|
|
4204
|
-
verify(payload,
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
const
|
|
4208
|
-
const
|
|
4209
|
-
const
|
|
4219
|
+
verify(payload, headers, options) {
|
|
4220
|
+
var _a;
|
|
4221
|
+
const jsonParse = (_a = options === null || options === void 0 ? void 0 : options.jsonParse) !== null && _a !== void 0 ? _a : true;
|
|
4222
|
+
const normalizedHeaders = {};
|
|
4223
|
+
for (const key of Object.keys(headers)) normalizedHeaders[key.toLowerCase()] = headers[key];
|
|
4224
|
+
const msgId = normalizedHeaders["webhook-id"];
|
|
4225
|
+
const msgSignature = normalizedHeaders["webhook-signature"];
|
|
4226
|
+
const msgTimestamp = normalizedHeaders["webhook-timestamp"];
|
|
4210
4227
|
if (!msgSignature || !msgId || !msgTimestamp) throw new WebhookVerificationError("Missing required headers");
|
|
4211
4228
|
const timestamp = this.verifyTimestamp(msgTimestamp);
|
|
4212
4229
|
const expectedSignature = this.sign(msgId, timestamp, payload).split(",")[1];
|
|
@@ -4215,7 +4232,12 @@ var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
4215
4232
|
for (const versionedSignature of passedSignatures) {
|
|
4216
4233
|
const [version, signature] = versionedSignature.split(",");
|
|
4217
4234
|
if (version !== "v1") continue;
|
|
4218
|
-
if ((0, timing_safe_equal_1.timingSafeEqual)(encoder.encode(signature), encoder.encode(expectedSignature)))
|
|
4235
|
+
if ((0, timing_safe_equal_1.timingSafeEqual)(encoder.encode(signature), encoder.encode(expectedSignature))) {
|
|
4236
|
+
const payloadString = payload.toString();
|
|
4237
|
+
if (payloadString === "") return;
|
|
4238
|
+
if (jsonParse) return JSON.parse(payloadString);
|
|
4239
|
+
else return;
|
|
4240
|
+
}
|
|
4219
4241
|
}
|
|
4220
4242
|
throw new WebhookVerificationError("No matching signature found");
|
|
4221
4243
|
}
|
|
@@ -4230,7 +4252,7 @@ var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
4230
4252
|
verifyTimestamp(timestampHeader) {
|
|
4231
4253
|
const now = Math.floor(Date.now() / 1e3);
|
|
4232
4254
|
const timestamp = parseInt(timestampHeader, 10);
|
|
4233
|
-
if (isNaN(timestamp)) throw new WebhookVerificationError("Invalid Signature Headers");
|
|
4255
|
+
if (Number.isNaN(timestamp)) throw new WebhookVerificationError("Invalid Signature Headers");
|
|
4234
4256
|
if (now - timestamp > WEBHOOK_TOLERANCE_IN_SECONDS) throw new WebhookVerificationError("Message timestamp too old");
|
|
4235
4257
|
if (timestamp > now + WEBHOOK_TOLERANCE_IN_SECONDS) throw new WebhookVerificationError("Message timestamp too new");
|
|
4236
4258
|
return /* @__PURE__ */ new Date(timestamp * 1e3);
|
|
@@ -4239,7 +4261,7 @@ var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
4239
4261
|
exports.Webhook = Webhook;
|
|
4240
4262
|
Webhook.prefix = "whsec_";
|
|
4241
4263
|
})))();
|
|
4242
|
-
var version = "6.
|
|
4264
|
+
var version = "6.32.0";
|
|
4243
4265
|
function buildPaginationUrl(base, options) {
|
|
4244
4266
|
const queryString = buildPaginationQuery(options);
|
|
4245
4267
|
return queryString ? `${base}?${queryString}` : base;
|
|
@@ -4260,28 +4282,28 @@ var ApiKeys = class {
|
|
|
4260
4282
|
constructor(resend) {
|
|
4261
4283
|
this.resend = resend;
|
|
4262
4284
|
}
|
|
4263
|
-
async create(payload,
|
|
4264
|
-
return await this.resend.post("/api-keys", payload,
|
|
4285
|
+
async create(payload, requestOptions = {}) {
|
|
4286
|
+
return await this.resend.post("/api-keys", payload, requestOptions);
|
|
4265
4287
|
}
|
|
4266
|
-
async list(options = {}) {
|
|
4288
|
+
async list(options = {}, requestOptions = {}) {
|
|
4267
4289
|
const url = buildPaginationUrl("/api-keys", options);
|
|
4268
|
-
return await this.resend.get(url);
|
|
4290
|
+
return await this.resend.get(url, requestOptions);
|
|
4269
4291
|
}
|
|
4270
|
-
async update(id, payload) {
|
|
4271
|
-
return await this.resend.patch(`/api-keys/${id}`, payload);
|
|
4292
|
+
async update(id, payload, requestOptions = {}) {
|
|
4293
|
+
return await this.resend.patch(`/api-keys/${id}`, payload, requestOptions);
|
|
4272
4294
|
}
|
|
4273
|
-
async remove(id) {
|
|
4274
|
-
return await this.resend.delete(`/api-keys/${id}
|
|
4295
|
+
async remove(id, requestOptions = {}) {
|
|
4296
|
+
return await this.resend.delete(`/api-keys/${id}`, void 0, requestOptions);
|
|
4275
4297
|
}
|
|
4276
4298
|
};
|
|
4277
4299
|
var AutomationRuns = class {
|
|
4278
4300
|
constructor(resend) {
|
|
4279
4301
|
this.resend = resend;
|
|
4280
4302
|
}
|
|
4281
|
-
async get(options) {
|
|
4282
|
-
return await this.resend.get(`/automations/${options.automationId}/runs/${options.runId}
|
|
4303
|
+
async get(options, requestOptions = {}) {
|
|
4304
|
+
return await this.resend.get(`/automations/${options.automationId}/runs/${options.runId}`, requestOptions);
|
|
4283
4305
|
}
|
|
4284
|
-
async list(options) {
|
|
4306
|
+
async list(options, requestOptions = {}) {
|
|
4285
4307
|
const queryString = buildPaginationQuery(options);
|
|
4286
4308
|
const searchParams = new URLSearchParams(queryString);
|
|
4287
4309
|
if (options.status) {
|
|
@@ -4290,7 +4312,7 @@ var AutomationRuns = class {
|
|
|
4290
4312
|
}
|
|
4291
4313
|
const qs = searchParams.toString();
|
|
4292
4314
|
const url = qs ? `/automations/${options.automationId}/runs?${qs}` : `/automations/${options.automationId}/runs`;
|
|
4293
|
-
return await this.resend.get(url);
|
|
4315
|
+
return await this.resend.get(url, requestOptions);
|
|
4294
4316
|
}
|
|
4295
4317
|
};
|
|
4296
4318
|
function parseStepConfig(step) {
|
|
@@ -4379,35 +4401,35 @@ var Automations = class {
|
|
|
4379
4401
|
this.resend = resend;
|
|
4380
4402
|
this.runs = new AutomationRuns(this.resend);
|
|
4381
4403
|
}
|
|
4382
|
-
async create(payload) {
|
|
4383
|
-
return await this.resend.post("/automations", parseAutomationToApiOptions(payload));
|
|
4404
|
+
async create(payload, requestOptions = {}) {
|
|
4405
|
+
return await this.resend.post("/automations", parseAutomationToApiOptions(payload), requestOptions);
|
|
4384
4406
|
}
|
|
4385
|
-
async list(options = {}) {
|
|
4407
|
+
async list(options = {}, requestOptions = {}) {
|
|
4386
4408
|
const params = [buildPaginationQuery(options)];
|
|
4387
4409
|
if (options.status) params.push(`status=${encodeURIComponent(options.status)}`);
|
|
4388
4410
|
const qs = params.filter(Boolean).join("&");
|
|
4389
4411
|
const url = qs ? `/automations?${qs}` : "/automations";
|
|
4390
|
-
return await this.resend.get(url);
|
|
4412
|
+
return await this.resend.get(url, requestOptions);
|
|
4391
4413
|
}
|
|
4392
|
-
async get(id) {
|
|
4393
|
-
return await this.resend.get(`/automations/${id}
|
|
4414
|
+
async get(id, requestOptions = {}) {
|
|
4415
|
+
return await this.resend.get(`/automations/${id}`, requestOptions);
|
|
4394
4416
|
}
|
|
4395
|
-
async remove(id) {
|
|
4396
|
-
return await this.resend.delete(`/automations/${id}
|
|
4417
|
+
async remove(id, requestOptions = {}) {
|
|
4418
|
+
return await this.resend.delete(`/automations/${id}`, void 0, requestOptions);
|
|
4397
4419
|
}
|
|
4398
|
-
async update(id, payload) {
|
|
4420
|
+
async update(id, payload, requestOptions = {}) {
|
|
4399
4421
|
const apiPayload = {};
|
|
4400
4422
|
if (payload.name !== void 0) apiPayload.name = payload.name;
|
|
4401
4423
|
if (payload.status !== void 0) apiPayload.status = payload.status;
|
|
4402
4424
|
if (payload.steps !== void 0) apiPayload.steps = payload.steps.map(parseStepConfig);
|
|
4403
4425
|
if (payload.connections !== void 0) apiPayload.connections = payload.connections.map(parseConnection);
|
|
4404
|
-
return await this.resend.patch(`/automations/${id}`, apiPayload);
|
|
4426
|
+
return await this.resend.patch(`/automations/${id}`, apiPayload, requestOptions);
|
|
4405
4427
|
}
|
|
4406
|
-
async duplicate(id) {
|
|
4407
|
-
return await this.resend.post(`/automations/${id}/duplicate
|
|
4428
|
+
async duplicate(id, requestOptions = {}) {
|
|
4429
|
+
return await this.resend.post(`/automations/${id}/duplicate`, void 0, requestOptions);
|
|
4408
4430
|
}
|
|
4409
|
-
async stop(id) {
|
|
4410
|
-
return await this.resend.post(`/automations/${id}/stop
|
|
4431
|
+
async stop(id, requestOptions = {}) {
|
|
4432
|
+
return await this.resend.post(`/automations/${id}/stop`, void 0, requestOptions);
|
|
4411
4433
|
}
|
|
4412
4434
|
};
|
|
4413
4435
|
function parseAttachments(attachments) {
|
|
@@ -4453,10 +4475,10 @@ var Batch$1 = class {
|
|
|
4453
4475
|
constructor(resend) {
|
|
4454
4476
|
this.resend = resend;
|
|
4455
4477
|
}
|
|
4456
|
-
async send(payload,
|
|
4457
|
-
return this.create(payload,
|
|
4478
|
+
async send(payload, requestOptions) {
|
|
4479
|
+
return this.create(payload, requestOptions);
|
|
4458
4480
|
}
|
|
4459
|
-
async create(payload,
|
|
4481
|
+
async create(payload, requestOptions) {
|
|
4460
4482
|
const emails = [];
|
|
4461
4483
|
for (const email of payload) {
|
|
4462
4484
|
if (email.react) {
|
|
@@ -4465,12 +4487,11 @@ var Batch$1 = class {
|
|
|
4465
4487
|
}
|
|
4466
4488
|
emails.push(parseEmailToApiOptions(email));
|
|
4467
4489
|
}
|
|
4490
|
+
const headers = new Headers({ "x-batch-validation": requestOptions?.batchValidation ?? "strict" });
|
|
4491
|
+
for (const [key, value] of new Headers(requestOptions?.headers || void 0)) headers.set(key, value);
|
|
4468
4492
|
return await this.resend.post("/emails/batch", emails, {
|
|
4469
|
-
...
|
|
4470
|
-
headers
|
|
4471
|
-
"x-batch-validation": options?.batchValidation ?? "strict",
|
|
4472
|
-
...options?.headers
|
|
4473
|
-
}
|
|
4493
|
+
...requestOptions,
|
|
4494
|
+
headers
|
|
4474
4495
|
});
|
|
4475
4496
|
}
|
|
4476
4497
|
};
|
|
@@ -4478,7 +4499,7 @@ var Broadcasts = class {
|
|
|
4478
4499
|
constructor(resend) {
|
|
4479
4500
|
this.resend = resend;
|
|
4480
4501
|
}
|
|
4481
|
-
async create(payload,
|
|
4502
|
+
async create(payload, requestOptions = {}) {
|
|
4482
4503
|
const html = payload.react ? await render(payload.react) : payload.html;
|
|
4483
4504
|
return await this.resend.post("/broadcasts", {
|
|
4484
4505
|
name: payload.name,
|
|
@@ -4493,33 +4514,36 @@ var Broadcasts = class {
|
|
|
4493
4514
|
topic_id: payload.topicId,
|
|
4494
4515
|
send: payload.send,
|
|
4495
4516
|
scheduled_at: payload.scheduledAt
|
|
4496
|
-
},
|
|
4517
|
+
}, requestOptions);
|
|
4497
4518
|
}
|
|
4498
|
-
async send(id, payload) {
|
|
4499
|
-
return await this.resend.post(`/broadcasts/${id}/send`, { scheduled_at: payload?.scheduledAt });
|
|
4519
|
+
async send(id, payload, requestOptions = {}) {
|
|
4520
|
+
return await this.resend.post(`/broadcasts/${id}/send`, { scheduled_at: payload?.scheduledAt }, requestOptions);
|
|
4500
4521
|
}
|
|
4501
|
-
async list(options = {}) {
|
|
4522
|
+
async list(options = {}, requestOptions = {}) {
|
|
4502
4523
|
const url = buildPaginationUrl("/broadcasts", options);
|
|
4503
|
-
return await this.resend.get(url);
|
|
4524
|
+
return await this.resend.get(url, requestOptions);
|
|
4504
4525
|
}
|
|
4505
|
-
async get(id) {
|
|
4506
|
-
return await this.resend.get(`/broadcasts/${id}
|
|
4526
|
+
async get(id, requestOptions = {}) {
|
|
4527
|
+
return await this.resend.get(`/broadcasts/${id}`, requestOptions);
|
|
4507
4528
|
}
|
|
4508
|
-
async recipients(id, options) {
|
|
4529
|
+
async recipients(id, options, requestOptions = {}) {
|
|
4509
4530
|
const url = `/broadcasts/${id}/recipients?${buildRecipientsQuery(options)}`;
|
|
4510
|
-
return await this.resend.get(url);
|
|
4531
|
+
return await this.resend.get(url, requestOptions);
|
|
4511
4532
|
}
|
|
4512
|
-
async clickedLinks(id, options = {}) {
|
|
4533
|
+
async clickedLinks(id, options = {}, requestOptions = {}) {
|
|
4513
4534
|
const url = buildPaginationUrl(`/broadcasts/${id}/clicked-links`, options);
|
|
4514
|
-
return await this.resend.get(url);
|
|
4535
|
+
return await this.resend.get(url, requestOptions);
|
|
4536
|
+
}
|
|
4537
|
+
async remove(id, requestOptions = {}) {
|
|
4538
|
+
return await this.resend.delete(`/broadcasts/${id}`, void 0, requestOptions);
|
|
4515
4539
|
}
|
|
4516
|
-
async
|
|
4517
|
-
return await this.resend.
|
|
4540
|
+
async cancel(id, requestOptions = {}) {
|
|
4541
|
+
return await this.resend.post(`/broadcasts/${id}/cancel`, void 0, requestOptions);
|
|
4518
4542
|
}
|
|
4519
|
-
async
|
|
4520
|
-
return await this.resend.post(`/broadcasts/${id}/
|
|
4543
|
+
async duplicate(id, requestOptions = {}) {
|
|
4544
|
+
return await this.resend.post(`/broadcasts/${id}/duplicate`, void 0, requestOptions);
|
|
4521
4545
|
}
|
|
4522
|
-
async update(id, payload) {
|
|
4546
|
+
async update(id, payload, requestOptions = {}) {
|
|
4523
4547
|
const html = payload.react ? await render(payload.react) : payload.html;
|
|
4524
4548
|
return await this.resend.patch(`/broadcasts/${id}`, {
|
|
4525
4549
|
name: payload.name,
|
|
@@ -4532,7 +4556,7 @@ var Broadcasts = class {
|
|
|
4532
4556
|
reply_to: payload.replyTo,
|
|
4533
4557
|
preview_text: payload.previewText,
|
|
4534
4558
|
topic_id: payload.topicId
|
|
4535
|
-
});
|
|
4559
|
+
}, requestOptions);
|
|
4536
4560
|
}
|
|
4537
4561
|
};
|
|
4538
4562
|
function buildRecipientsQuery(options) {
|
|
@@ -4564,13 +4588,13 @@ var ContactProperties = class {
|
|
|
4564
4588
|
constructor(resend) {
|
|
4565
4589
|
this.resend = resend;
|
|
4566
4590
|
}
|
|
4567
|
-
async create(options) {
|
|
4591
|
+
async create(options, requestOptions = {}) {
|
|
4568
4592
|
const apiOptions = parseContactPropertyToApiOptions(options);
|
|
4569
|
-
return await this.resend.post("/contact-properties", apiOptions);
|
|
4593
|
+
return await this.resend.post("/contact-properties", apiOptions, requestOptions);
|
|
4570
4594
|
}
|
|
4571
|
-
async list(options = {}) {
|
|
4595
|
+
async list(options = {}, requestOptions = {}) {
|
|
4572
4596
|
const url = buildPaginationUrl("/contact-properties", options);
|
|
4573
|
-
const response = await this.resend.get(url);
|
|
4597
|
+
const response = await this.resend.get(url, requestOptions);
|
|
4574
4598
|
if (response.data) return {
|
|
4575
4599
|
data: {
|
|
4576
4600
|
...response.data,
|
|
@@ -4581,7 +4605,7 @@ var ContactProperties = class {
|
|
|
4581
4605
|
};
|
|
4582
4606
|
return response;
|
|
4583
4607
|
}
|
|
4584
|
-
async get(id) {
|
|
4608
|
+
async get(id, requestOptions = {}) {
|
|
4585
4609
|
if (!id) return {
|
|
4586
4610
|
data: null,
|
|
4587
4611
|
headers: null,
|
|
@@ -4591,7 +4615,7 @@ var ContactProperties = class {
|
|
|
4591
4615
|
name: "missing_required_field"
|
|
4592
4616
|
}
|
|
4593
4617
|
};
|
|
4594
|
-
const response = await this.resend.get(`/contact-properties/${id}
|
|
4618
|
+
const response = await this.resend.get(`/contact-properties/${id}`, requestOptions);
|
|
4595
4619
|
if (response.data) return {
|
|
4596
4620
|
data: {
|
|
4597
4621
|
object: "contact_property",
|
|
@@ -4602,7 +4626,7 @@ var ContactProperties = class {
|
|
|
4602
4626
|
};
|
|
4603
4627
|
return response;
|
|
4604
4628
|
}
|
|
4605
|
-
async update(payload) {
|
|
4629
|
+
async update(payload, requestOptions = {}) {
|
|
4606
4630
|
if (!payload.id) return {
|
|
4607
4631
|
data: null,
|
|
4608
4632
|
headers: null,
|
|
@@ -4613,9 +4637,9 @@ var ContactProperties = class {
|
|
|
4613
4637
|
}
|
|
4614
4638
|
};
|
|
4615
4639
|
const apiOptions = parseContactPropertyToApiOptions(payload);
|
|
4616
|
-
return await this.resend.patch(`/contact-properties/${payload.id}`, apiOptions);
|
|
4640
|
+
return await this.resend.patch(`/contact-properties/${payload.id}`, apiOptions, requestOptions);
|
|
4617
4641
|
}
|
|
4618
|
-
async remove(id) {
|
|
4642
|
+
async remove(id, requestOptions = {}) {
|
|
4619
4643
|
if (!id) return {
|
|
4620
4644
|
data: null,
|
|
4621
4645
|
headers: null,
|
|
@@ -4625,26 +4649,26 @@ var ContactProperties = class {
|
|
|
4625
4649
|
name: "missing_required_field"
|
|
4626
4650
|
}
|
|
4627
4651
|
};
|
|
4628
|
-
return await this.resend.delete(`/contact-properties/${id}
|
|
4652
|
+
return await this.resend.delete(`/contact-properties/${id}`, void 0, requestOptions);
|
|
4629
4653
|
}
|
|
4630
4654
|
};
|
|
4631
4655
|
var ContactImports = class {
|
|
4632
4656
|
constructor(resend) {
|
|
4633
4657
|
this.resend = resend;
|
|
4634
4658
|
}
|
|
4635
|
-
async create(payload,
|
|
4659
|
+
async create(payload, requestOptions = {}) {
|
|
4636
4660
|
const formData = this.buildCreateFormData(payload);
|
|
4637
|
-
return this.resend.post("/contacts/imports", formData,
|
|
4661
|
+
return this.resend.post("/contacts/imports", formData, requestOptions);
|
|
4638
4662
|
}
|
|
4639
|
-
async list(options = {}) {
|
|
4663
|
+
async list(options = {}, requestOptions = {}) {
|
|
4640
4664
|
const searchParams = new URLSearchParams(buildPaginationQuery(options));
|
|
4641
4665
|
if (options.status !== void 0) searchParams.set("status", options.status);
|
|
4642
4666
|
const queryString = searchParams.toString();
|
|
4643
4667
|
const url = queryString ? `/contacts/imports?${queryString}` : "/contacts/imports";
|
|
4644
|
-
return this.resend.get(url);
|
|
4668
|
+
return this.resend.get(url, requestOptions);
|
|
4645
4669
|
}
|
|
4646
|
-
async get(id) {
|
|
4647
|
-
return this.resend.get(`/contacts/imports/${id}
|
|
4670
|
+
async get(id, requestOptions = {}) {
|
|
4671
|
+
return this.resend.get(`/contacts/imports/${id}`, requestOptions);
|
|
4648
4672
|
}
|
|
4649
4673
|
buildCreateFormData(payload) {
|
|
4650
4674
|
const formData = new FormData();
|
|
@@ -4674,7 +4698,7 @@ var ContactSegments = class {
|
|
|
4674
4698
|
constructor(resend) {
|
|
4675
4699
|
this.resend = resend;
|
|
4676
4700
|
}
|
|
4677
|
-
async list(options) {
|
|
4701
|
+
async list(options, requestOptions = {}) {
|
|
4678
4702
|
if (!options.contactId && !options.email) return {
|
|
4679
4703
|
data: null,
|
|
4680
4704
|
headers: null,
|
|
@@ -4685,9 +4709,9 @@ var ContactSegments = class {
|
|
|
4685
4709
|
}
|
|
4686
4710
|
};
|
|
4687
4711
|
const url = buildPaginationUrl(`/contacts/${options.email ? options.email : options.contactId}/segments`, options);
|
|
4688
|
-
return await this.resend.get(url);
|
|
4712
|
+
return await this.resend.get(url, requestOptions);
|
|
4689
4713
|
}
|
|
4690
|
-
async add(options) {
|
|
4714
|
+
async add(options, requestOptions = {}) {
|
|
4691
4715
|
if (!options.contactId && !options.email) return {
|
|
4692
4716
|
data: null,
|
|
4693
4717
|
headers: null,
|
|
@@ -4698,9 +4722,9 @@ var ContactSegments = class {
|
|
|
4698
4722
|
}
|
|
4699
4723
|
};
|
|
4700
4724
|
const identifier = options.email ? options.email : options.contactId;
|
|
4701
|
-
return this.resend.post(`/contacts/${identifier}/segments/${options.segmentId}
|
|
4725
|
+
return this.resend.post(`/contacts/${identifier}/segments/${options.segmentId}`, void 0, requestOptions);
|
|
4702
4726
|
}
|
|
4703
|
-
async remove(options) {
|
|
4727
|
+
async remove(options, requestOptions = {}) {
|
|
4704
4728
|
if (!options.contactId && !options.email) return {
|
|
4705
4729
|
data: null,
|
|
4706
4730
|
headers: null,
|
|
@@ -4711,14 +4735,14 @@ var ContactSegments = class {
|
|
|
4711
4735
|
}
|
|
4712
4736
|
};
|
|
4713
4737
|
const identifier = options.email ? options.email : options.contactId;
|
|
4714
|
-
return this.resend.delete(`/contacts/${identifier}/segments/${options.segmentId}
|
|
4738
|
+
return this.resend.delete(`/contacts/${identifier}/segments/${options.segmentId}`, void 0, requestOptions);
|
|
4715
4739
|
}
|
|
4716
4740
|
};
|
|
4717
4741
|
var ContactTopics = class {
|
|
4718
4742
|
constructor(resend) {
|
|
4719
4743
|
this.resend = resend;
|
|
4720
4744
|
}
|
|
4721
|
-
async update(payload) {
|
|
4745
|
+
async update(payload, requestOptions = {}) {
|
|
4722
4746
|
if (!payload.id && !payload.email) return {
|
|
4723
4747
|
data: null,
|
|
4724
4748
|
headers: null,
|
|
@@ -4729,9 +4753,9 @@ var ContactTopics = class {
|
|
|
4729
4753
|
}
|
|
4730
4754
|
};
|
|
4731
4755
|
const identifier = payload.email ? payload.email : payload.id;
|
|
4732
|
-
return this.resend.patch(`/contacts/${identifier}/topics`, payload.topics);
|
|
4756
|
+
return this.resend.patch(`/contacts/${identifier}/topics`, payload.topics, requestOptions);
|
|
4733
4757
|
}
|
|
4734
|
-
async list(options) {
|
|
4758
|
+
async list(options, requestOptions = {}) {
|
|
4735
4759
|
if (!options.id && !options.email) return {
|
|
4736
4760
|
data: null,
|
|
4737
4761
|
headers: null,
|
|
@@ -4742,7 +4766,7 @@ var ContactTopics = class {
|
|
|
4742
4766
|
}
|
|
4743
4767
|
};
|
|
4744
4768
|
const url = buildPaginationUrl(`/contacts/${options.email ? options.email : options.id}/topics`, options);
|
|
4745
|
-
return this.resend.get(url);
|
|
4769
|
+
return this.resend.get(url, requestOptions);
|
|
4746
4770
|
}
|
|
4747
4771
|
};
|
|
4748
4772
|
var Contacts = class {
|
|
@@ -4752,7 +4776,7 @@ var Contacts = class {
|
|
|
4752
4776
|
this.topics = new ContactTopics(this.resend);
|
|
4753
4777
|
this.segments = new ContactSegments(this.resend);
|
|
4754
4778
|
}
|
|
4755
|
-
async create(payload,
|
|
4779
|
+
async create(payload, requestOptions = {}) {
|
|
4756
4780
|
if ("audienceId" in payload) {
|
|
4757
4781
|
if ("segments" in payload || "topics" in payload) return {
|
|
4758
4782
|
data: null,
|
|
@@ -4769,7 +4793,7 @@ var Contacts = class {
|
|
|
4769
4793
|
first_name: payload.firstName,
|
|
4770
4794
|
last_name: payload.lastName,
|
|
4771
4795
|
properties: payload.properties
|
|
4772
|
-
},
|
|
4796
|
+
}, requestOptions);
|
|
4773
4797
|
}
|
|
4774
4798
|
return await this.resend.post("/contacts", {
|
|
4775
4799
|
unsubscribed: payload.unsubscribed,
|
|
@@ -4779,19 +4803,19 @@ var Contacts = class {
|
|
|
4779
4803
|
properties: payload.properties,
|
|
4780
4804
|
segments: payload.segments,
|
|
4781
4805
|
topics: payload.topics
|
|
4782
|
-
},
|
|
4806
|
+
}, requestOptions);
|
|
4783
4807
|
}
|
|
4784
|
-
async list(options = {}) {
|
|
4808
|
+
async list(options = {}, requestOptions = {}) {
|
|
4785
4809
|
const segmentId = options.segmentId ?? options.audienceId;
|
|
4786
4810
|
if (!segmentId) {
|
|
4787
4811
|
const url = buildPaginationUrl("/contacts", options);
|
|
4788
|
-
return await this.resend.get(url);
|
|
4812
|
+
return await this.resend.get(url, requestOptions);
|
|
4789
4813
|
}
|
|
4790
4814
|
const url = buildPaginationUrl(`/segments/${segmentId}/contacts`, options);
|
|
4791
|
-
return await this.resend.get(url);
|
|
4815
|
+
return await this.resend.get(url, requestOptions);
|
|
4792
4816
|
}
|
|
4793
|
-
async get(options) {
|
|
4794
|
-
if (typeof options === "string") return this.resend.get(`/contacts/${options}
|
|
4817
|
+
async get(options, requestOptions = {}) {
|
|
4818
|
+
if (typeof options === "string") return this.resend.get(`/contacts/${options}`, requestOptions);
|
|
4795
4819
|
if (!options.id && !options.email) return {
|
|
4796
4820
|
data: null,
|
|
4797
4821
|
headers: null,
|
|
@@ -4801,10 +4825,10 @@ var Contacts = class {
|
|
|
4801
4825
|
name: "missing_required_field"
|
|
4802
4826
|
}
|
|
4803
4827
|
};
|
|
4804
|
-
if (!options.audienceId) return this.resend.get(`/contacts/${options?.email ? options?.email : options?.id}
|
|
4805
|
-
return this.resend.get(`/audiences/${options.audienceId}/contacts/${options?.email ? options?.email : options?.id}
|
|
4828
|
+
if (!options.audienceId) return this.resend.get(`/contacts/${options?.email ? options?.email : options?.id}`, requestOptions);
|
|
4829
|
+
return this.resend.get(`/audiences/${options.audienceId}/contacts/${options?.email ? options?.email : options?.id}`, requestOptions);
|
|
4806
4830
|
}
|
|
4807
|
-
async update(options) {
|
|
4831
|
+
async update(options, requestOptions = {}) {
|
|
4808
4832
|
if (!options.id && !options.email) return {
|
|
4809
4833
|
data: null,
|
|
4810
4834
|
headers: null,
|
|
@@ -4819,16 +4843,16 @@ var Contacts = class {
|
|
|
4819
4843
|
first_name: options.firstName,
|
|
4820
4844
|
last_name: options.lastName,
|
|
4821
4845
|
properties: options.properties
|
|
4822
|
-
});
|
|
4846
|
+
}, requestOptions);
|
|
4823
4847
|
return await this.resend.patch(`/audiences/${options.audienceId}/contacts/${options?.email ? options?.email : options?.id}`, {
|
|
4824
4848
|
unsubscribed: options.unsubscribed,
|
|
4825
4849
|
first_name: options.firstName,
|
|
4826
4850
|
last_name: options.lastName,
|
|
4827
4851
|
properties: options.properties
|
|
4828
|
-
});
|
|
4852
|
+
}, requestOptions);
|
|
4829
4853
|
}
|
|
4830
|
-
async remove(payload) {
|
|
4831
|
-
if (typeof payload === "string") return this.resend.delete(`/contacts/${payload}
|
|
4854
|
+
async remove(payload, requestOptions = {}) {
|
|
4855
|
+
if (typeof payload === "string") return this.resend.delete(`/contacts/${payload}`, void 0, requestOptions);
|
|
4832
4856
|
if (!payload.id && !payload.email) return {
|
|
4833
4857
|
data: null,
|
|
4834
4858
|
headers: null,
|
|
@@ -4838,8 +4862,8 @@ var Contacts = class {
|
|
|
4838
4862
|
name: "missing_required_field"
|
|
4839
4863
|
}
|
|
4840
4864
|
};
|
|
4841
|
-
if (!payload.audienceId) return this.resend.delete(`/contacts/${payload?.email ? payload?.email : payload?.id}
|
|
4842
|
-
return this.resend.delete(`/audiences/${payload.audienceId}/contacts/${payload?.email ? payload?.email : payload?.id}
|
|
4865
|
+
if (!payload.audienceId) return this.resend.delete(`/contacts/${payload?.email ? payload?.email : payload?.id}`, void 0, requestOptions);
|
|
4866
|
+
return this.resend.delete(`/audiences/${payload.audienceId}/contacts/${payload?.email ? payload?.email : payload?.id}`, void 0, requestOptions);
|
|
4843
4867
|
}
|
|
4844
4868
|
};
|
|
4845
4869
|
function parseDomainToApiOptions(domain) {
|
|
@@ -4858,7 +4882,7 @@ var DomainClaims = class {
|
|
|
4858
4882
|
constructor(resend) {
|
|
4859
4883
|
this.resend = resend;
|
|
4860
4884
|
}
|
|
4861
|
-
async create(payload,
|
|
4885
|
+
async create(payload, requestOptions = {}) {
|
|
4862
4886
|
return await this.resend.post("/domains/claim", {
|
|
4863
4887
|
name: payload.name,
|
|
4864
4888
|
region: payload.region,
|
|
@@ -4866,13 +4890,13 @@ var DomainClaims = class {
|
|
|
4866
4890
|
open_tracking: payload.openTracking,
|
|
4867
4891
|
click_tracking: payload.clickTracking,
|
|
4868
4892
|
tracking_subdomain: payload.trackingSubdomain
|
|
4869
|
-
},
|
|
4893
|
+
}, requestOptions);
|
|
4870
4894
|
}
|
|
4871
|
-
async get(domainId) {
|
|
4872
|
-
return await this.resend.get(`/domains/${domainId}/claim
|
|
4895
|
+
async get(domainId, requestOptions = {}) {
|
|
4896
|
+
return await this.resend.get(`/domains/${domainId}/claim`, requestOptions);
|
|
4873
4897
|
}
|
|
4874
|
-
async verify(domainId) {
|
|
4875
|
-
return await this.resend.post(`/domains/${domainId}/claim/verify
|
|
4898
|
+
async verify(domainId, requestOptions = {}) {
|
|
4899
|
+
return await this.resend.post(`/domains/${domainId}/claim/verify`, void 0, requestOptions);
|
|
4876
4900
|
}
|
|
4877
4901
|
};
|
|
4878
4902
|
var Domains = class {
|
|
@@ -4880,58 +4904,58 @@ var Domains = class {
|
|
|
4880
4904
|
this.resend = resend;
|
|
4881
4905
|
this.claims = new DomainClaims(this.resend);
|
|
4882
4906
|
}
|
|
4883
|
-
async create(payload,
|
|
4884
|
-
return await this.resend.post("/domains", parseDomainToApiOptions(payload),
|
|
4907
|
+
async create(payload, requestOptions = {}) {
|
|
4908
|
+
return await this.resend.post("/domains", parseDomainToApiOptions(payload), requestOptions);
|
|
4885
4909
|
}
|
|
4886
|
-
async list(options = {}) {
|
|
4910
|
+
async list(options = {}, requestOptions = {}) {
|
|
4887
4911
|
const url = buildPaginationUrl("/domains", options);
|
|
4888
|
-
return await this.resend.get(url);
|
|
4912
|
+
return await this.resend.get(url, requestOptions);
|
|
4889
4913
|
}
|
|
4890
|
-
async get(id) {
|
|
4891
|
-
return await this.resend.get(`/domains/${id}
|
|
4914
|
+
async get(id, requestOptions = {}) {
|
|
4915
|
+
return await this.resend.get(`/domains/${id}`, requestOptions);
|
|
4892
4916
|
}
|
|
4893
|
-
async update(payload) {
|
|
4917
|
+
async update(payload, requestOptions = {}) {
|
|
4894
4918
|
return await this.resend.patch(`/domains/${payload.id}`, {
|
|
4895
4919
|
click_tracking: payload.clickTracking,
|
|
4896
4920
|
open_tracking: payload.openTracking,
|
|
4897
4921
|
tls: payload.tls,
|
|
4898
4922
|
capabilities: payload.capabilities,
|
|
4899
4923
|
tracking_subdomain: payload.trackingSubdomain
|
|
4900
|
-
});
|
|
4924
|
+
}, requestOptions);
|
|
4901
4925
|
}
|
|
4902
|
-
async remove(id) {
|
|
4903
|
-
return await this.resend.delete(`/domains/${id}
|
|
4926
|
+
async remove(id, requestOptions = {}) {
|
|
4927
|
+
return await this.resend.delete(`/domains/${id}`, void 0, requestOptions);
|
|
4904
4928
|
}
|
|
4905
|
-
async verify(id) {
|
|
4906
|
-
return await this.resend.post(`/domains/${id}/verify
|
|
4929
|
+
async verify(id, requestOptions = {}) {
|
|
4930
|
+
return await this.resend.post(`/domains/${id}/verify`, void 0, requestOptions);
|
|
4907
4931
|
}
|
|
4908
4932
|
};
|
|
4909
4933
|
var Attachments$1 = class {
|
|
4910
4934
|
constructor(resend) {
|
|
4911
4935
|
this.resend = resend;
|
|
4912
4936
|
}
|
|
4913
|
-
async get(options) {
|
|
4937
|
+
async get(options, requestOptions = {}) {
|
|
4914
4938
|
const { emailId, id } = options;
|
|
4915
|
-
return await this.resend.get(`/emails/${emailId}/attachments/${id}
|
|
4939
|
+
return await this.resend.get(`/emails/${emailId}/attachments/${id}`, requestOptions);
|
|
4916
4940
|
}
|
|
4917
|
-
async list(options) {
|
|
4941
|
+
async list(options, requestOptions = {}) {
|
|
4918
4942
|
const { emailId } = options;
|
|
4919
4943
|
const url = buildPaginationUrl(`/emails/${emailId}/attachments`, options);
|
|
4920
|
-
return await this.resend.get(url);
|
|
4944
|
+
return await this.resend.get(url, requestOptions);
|
|
4921
4945
|
}
|
|
4922
4946
|
};
|
|
4923
4947
|
var Attachments = class {
|
|
4924
4948
|
constructor(resend) {
|
|
4925
4949
|
this.resend = resend;
|
|
4926
4950
|
}
|
|
4927
|
-
async get(options) {
|
|
4951
|
+
async get(options, requestOptions = {}) {
|
|
4928
4952
|
const { emailId, id } = options;
|
|
4929
|
-
return await this.resend.get(`/emails/receiving/${emailId}/attachments/${id}
|
|
4953
|
+
return await this.resend.get(`/emails/receiving/${emailId}/attachments/${id}`, requestOptions);
|
|
4930
4954
|
}
|
|
4931
|
-
async list(options) {
|
|
4955
|
+
async list(options, requestOptions = {}) {
|
|
4932
4956
|
const { emailId } = options;
|
|
4933
4957
|
const url = buildPaginationUrl(`/emails/receiving/${emailId}/attachments`, options);
|
|
4934
|
-
return await this.resend.get(url);
|
|
4958
|
+
return await this.resend.get(url, requestOptions);
|
|
4935
4959
|
}
|
|
4936
4960
|
};
|
|
4937
4961
|
var Receiving = class {
|
|
@@ -4939,21 +4963,21 @@ var Receiving = class {
|
|
|
4939
4963
|
this.resend = resend;
|
|
4940
4964
|
this.attachments = new Attachments(resend);
|
|
4941
4965
|
}
|
|
4942
|
-
async get(id, options = {}) {
|
|
4966
|
+
async get(id, options = {}, requestOptions = {}) {
|
|
4943
4967
|
const searchParams = new URLSearchParams();
|
|
4944
4968
|
if (options.html_format !== void 0) searchParams.set("html_format", options.html_format);
|
|
4945
4969
|
const queryString = searchParams.toString();
|
|
4946
4970
|
const path = queryString ? `/emails/receiving/${id}?${queryString}` : `/emails/receiving/${id}`;
|
|
4947
|
-
return await this.resend.get(path);
|
|
4971
|
+
return await this.resend.get(path, requestOptions);
|
|
4948
4972
|
}
|
|
4949
|
-
async list(options = {}) {
|
|
4973
|
+
async list(options = {}, requestOptions = {}) {
|
|
4950
4974
|
const url = buildPaginationUrl("/emails/receiving", options);
|
|
4951
|
-
return await this.resend.get(url);
|
|
4975
|
+
return await this.resend.get(url, requestOptions);
|
|
4952
4976
|
}
|
|
4953
4977
|
async forward(options, requestOptions = {}) {
|
|
4954
4978
|
const { emailId, to, from } = options;
|
|
4955
4979
|
const passthrough = options.passthrough !== false;
|
|
4956
|
-
const emailResponse = await this.get(emailId);
|
|
4980
|
+
const emailResponse = await this.get(emailId, {}, { signal: requestOptions.signal });
|
|
4957
4981
|
if (emailResponse.error) return {
|
|
4958
4982
|
data: null,
|
|
4959
4983
|
error: emailResponse.error,
|
|
@@ -4986,18 +5010,13 @@ var Receiving = class {
|
|
|
4986
5010
|
},
|
|
4987
5011
|
headers: null
|
|
4988
5012
|
};
|
|
4989
|
-
const
|
|
4990
|
-
if (
|
|
5013
|
+
const raw = await this.downloadRaw(email.raw.download_url, requestOptions.signal);
|
|
5014
|
+
if (raw.error) return {
|
|
4991
5015
|
data: null,
|
|
4992
|
-
error:
|
|
4993
|
-
name: "application_error",
|
|
4994
|
-
message: "Failed to download raw email content",
|
|
4995
|
-
statusCode: rawResponse.status
|
|
4996
|
-
},
|
|
5016
|
+
error: raw.error,
|
|
4997
5017
|
headers: null
|
|
4998
5018
|
};
|
|
4999
|
-
const
|
|
5000
|
-
const parsed = await PostalMime.parse(rawEmailContent, { attachmentEncoding: "base64" });
|
|
5019
|
+
const parsed = await PostalMime.parse(raw.content, { attachmentEncoding: "base64" });
|
|
5001
5020
|
const attachments = parsed.attachments.map((attachment) => {
|
|
5002
5021
|
const contentId = attachment.contentId ? attachment.contentId.replace(/^<|>$/g, "") : void 0;
|
|
5003
5022
|
return {
|
|
@@ -5027,17 +5046,12 @@ var Receiving = class {
|
|
|
5027
5046
|
},
|
|
5028
5047
|
headers: null
|
|
5029
5048
|
};
|
|
5030
|
-
const
|
|
5031
|
-
if (
|
|
5049
|
+
const raw = await this.downloadRaw(email.raw.download_url, requestOptions.signal);
|
|
5050
|
+
if (raw.error) return {
|
|
5032
5051
|
data: null,
|
|
5033
|
-
error:
|
|
5034
|
-
name: "application_error",
|
|
5035
|
-
message: "Failed to download raw email content",
|
|
5036
|
-
statusCode: rawResponse.status
|
|
5037
|
-
},
|
|
5052
|
+
error: raw.error,
|
|
5038
5053
|
headers: null
|
|
5039
5054
|
};
|
|
5040
|
-
const rawEmailContent = await rawResponse.text();
|
|
5041
5055
|
return await this.resend.post("/emails", {
|
|
5042
5056
|
from,
|
|
5043
5057
|
to,
|
|
@@ -5046,11 +5060,37 @@ var Receiving = class {
|
|
|
5046
5060
|
html,
|
|
5047
5061
|
attachments: [{
|
|
5048
5062
|
filename: "forwarded_message.eml",
|
|
5049
|
-
content: Buffer.from(
|
|
5063
|
+
content: Buffer.from(raw.content).toString("base64"),
|
|
5050
5064
|
content_type: "message/rfc822"
|
|
5051
5065
|
}]
|
|
5052
5066
|
}, requestOptions);
|
|
5053
5067
|
}
|
|
5068
|
+
async downloadRaw(url, signal) {
|
|
5069
|
+
try {
|
|
5070
|
+
const response = await fetch(url, { signal });
|
|
5071
|
+
if (!response.ok) return {
|
|
5072
|
+
content: null,
|
|
5073
|
+
error: {
|
|
5074
|
+
name: "application_error",
|
|
5075
|
+
message: "Failed to download raw email content",
|
|
5076
|
+
statusCode: response.status
|
|
5077
|
+
}
|
|
5078
|
+
};
|
|
5079
|
+
return {
|
|
5080
|
+
content: await response.text(),
|
|
5081
|
+
error: null
|
|
5082
|
+
};
|
|
5083
|
+
} catch {
|
|
5084
|
+
return {
|
|
5085
|
+
content: null,
|
|
5086
|
+
error: {
|
|
5087
|
+
name: "application_error",
|
|
5088
|
+
message: "Failed to download raw email content",
|
|
5089
|
+
statusCode: null
|
|
5090
|
+
}
|
|
5091
|
+
};
|
|
5092
|
+
}
|
|
5093
|
+
}
|
|
5054
5094
|
};
|
|
5055
5095
|
var Emails = class {
|
|
5056
5096
|
constructor(resend) {
|
|
@@ -5058,34 +5098,34 @@ var Emails = class {
|
|
|
5058
5098
|
this.attachments = new Attachments$1(resend);
|
|
5059
5099
|
this.receiving = new Receiving(resend);
|
|
5060
5100
|
}
|
|
5061
|
-
async send(payload,
|
|
5062
|
-
return this.create(payload,
|
|
5101
|
+
async send(payload, requestOptions = {}) {
|
|
5102
|
+
return this.create(payload, requestOptions);
|
|
5063
5103
|
}
|
|
5064
|
-
async create(payload,
|
|
5104
|
+
async create(payload, requestOptions = {}) {
|
|
5065
5105
|
const body = { ...payload };
|
|
5066
5106
|
if (payload.react) body.html = await render(payload.react);
|
|
5067
|
-
return await this.resend.post("/emails", parseEmailToApiOptions(body),
|
|
5107
|
+
return await this.resend.post("/emails", parseEmailToApiOptions(body), requestOptions);
|
|
5068
5108
|
}
|
|
5069
|
-
async get(id) {
|
|
5070
|
-
return await this.resend.get(`/emails/${id}
|
|
5109
|
+
async get(id, requestOptions = {}) {
|
|
5110
|
+
return await this.resend.get(`/emails/${id}`, requestOptions);
|
|
5071
5111
|
}
|
|
5072
|
-
async list(options = {}) {
|
|
5112
|
+
async list(options = {}, requestOptions = {}) {
|
|
5073
5113
|
const url = buildPaginationUrl("/emails", options);
|
|
5074
|
-
return await this.resend.get(url);
|
|
5114
|
+
return await this.resend.get(url, requestOptions);
|
|
5075
5115
|
}
|
|
5076
|
-
async update(payload) {
|
|
5077
|
-
return await this.resend.patch(`/emails/${payload.id}`, { scheduled_at: payload.scheduledAt });
|
|
5116
|
+
async update(payload, requestOptions = {}) {
|
|
5117
|
+
return await this.resend.patch(`/emails/${payload.id}`, { scheduled_at: payload.scheduledAt }, requestOptions);
|
|
5078
5118
|
}
|
|
5079
|
-
async cancel(id) {
|
|
5080
|
-
return await this.resend.post(`/emails/${id}/cancel
|
|
5119
|
+
async cancel(id, requestOptions = {}) {
|
|
5120
|
+
return await this.resend.post(`/emails/${id}/cancel`, void 0, requestOptions);
|
|
5081
5121
|
}
|
|
5082
|
-
async share(id, payload) {
|
|
5083
|
-
return await this.resend.post(`/emails/${id}/share`, { expires_in: payload?.expiresIn });
|
|
5122
|
+
async share(id, payload, requestOptions = {}) {
|
|
5123
|
+
return await this.resend.post(`/emails/${id}/share`, { expires_in: payload?.expiresIn }, requestOptions);
|
|
5084
5124
|
}
|
|
5085
|
-
async metrics(options = {}) {
|
|
5125
|
+
async metrics(options = {}, requestOptions = {}) {
|
|
5086
5126
|
const queryString = buildMetricsQuery(options);
|
|
5087
5127
|
const url = queryString ? `/emails/metrics?${queryString}` : "/emails/metrics";
|
|
5088
|
-
return await this.resend.get(url);
|
|
5128
|
+
return await this.resend.get(url, requestOptions);
|
|
5089
5129
|
}
|
|
5090
5130
|
};
|
|
5091
5131
|
function buildMetricsQuery(options) {
|
|
@@ -5104,81 +5144,84 @@ function buildMetricsQuery(options) {
|
|
|
5104
5144
|
for (const [key, value] of Object.entries(params)) if (value !== void 0 && value !== "") searchParams.set(key, value);
|
|
5105
5145
|
return searchParams.toString();
|
|
5106
5146
|
}
|
|
5107
|
-
var Events = class {
|
|
5147
|
+
var Events$1 = class {
|
|
5108
5148
|
constructor(resend) {
|
|
5109
5149
|
this.resend = resend;
|
|
5110
5150
|
}
|
|
5111
|
-
async send(payload) {
|
|
5112
|
-
return await this.resend.post("/events/send", parseEventToApiOptions(payload));
|
|
5151
|
+
async send(payload, requestOptions = {}) {
|
|
5152
|
+
return await this.resend.post("/events/send", parseEventToApiOptions(payload), requestOptions);
|
|
5113
5153
|
}
|
|
5114
|
-
async create(payload) {
|
|
5115
|
-
return await this.resend.post("/events", payload);
|
|
5154
|
+
async create(payload, requestOptions = {}) {
|
|
5155
|
+
return await this.resend.post("/events", payload, requestOptions);
|
|
5116
5156
|
}
|
|
5117
|
-
async get(identifier) {
|
|
5118
|
-
return await this.resend.get(`/events/${encodeURIComponent(identifier)}
|
|
5157
|
+
async get(identifier, requestOptions = {}) {
|
|
5158
|
+
return await this.resend.get(`/events/${encodeURIComponent(identifier)}`, requestOptions);
|
|
5119
5159
|
}
|
|
5120
|
-
async list(options = {}) {
|
|
5160
|
+
async list(options = {}, requestOptions = {}) {
|
|
5121
5161
|
const url = buildPaginationUrl("/events", options);
|
|
5122
|
-
return await this.resend.get(url);
|
|
5162
|
+
return await this.resend.get(url, requestOptions);
|
|
5123
5163
|
}
|
|
5124
|
-
async update(identifier, payload) {
|
|
5125
|
-
return await this.resend.patch(`/events/${encodeURIComponent(identifier)}`, payload);
|
|
5164
|
+
async update(identifier, payload, requestOptions = {}) {
|
|
5165
|
+
return await this.resend.patch(`/events/${encodeURIComponent(identifier)}`, payload, requestOptions);
|
|
5126
5166
|
}
|
|
5127
|
-
async remove(identifier) {
|
|
5128
|
-
return await this.resend.delete(`/events/${encodeURIComponent(identifier)}
|
|
5167
|
+
async remove(identifier, requestOptions = {}) {
|
|
5168
|
+
return await this.resend.delete(`/events/${encodeURIComponent(identifier)}`, void 0, requestOptions);
|
|
5129
5169
|
}
|
|
5130
5170
|
};
|
|
5131
5171
|
var Logs = class {
|
|
5132
5172
|
constructor(resend) {
|
|
5133
5173
|
this.resend = resend;
|
|
5134
5174
|
}
|
|
5135
|
-
async list(options = {}) {
|
|
5175
|
+
async list(options = {}, requestOptions = {}) {
|
|
5136
5176
|
const url = buildPaginationUrl("/logs", options);
|
|
5137
|
-
return await this.resend.get(url);
|
|
5177
|
+
return await this.resend.get(url, requestOptions);
|
|
5138
5178
|
}
|
|
5139
|
-
async get(id) {
|
|
5140
|
-
return await this.resend.get(`/logs/${id}
|
|
5179
|
+
async get(id, requestOptions = {}) {
|
|
5180
|
+
return await this.resend.get(`/logs/${id}`, requestOptions);
|
|
5141
5181
|
}
|
|
5142
5182
|
};
|
|
5143
5183
|
var OAuthGrants = class {
|
|
5144
5184
|
constructor(resend) {
|
|
5145
5185
|
this.resend = resend;
|
|
5146
5186
|
}
|
|
5147
|
-
async list(options = {}) {
|
|
5187
|
+
async list(options = {}, requestOptions = {}) {
|
|
5148
5188
|
const url = buildPaginationUrl("/oauth/grants", options);
|
|
5149
|
-
return await this.resend.get(url);
|
|
5189
|
+
return await this.resend.get(url, requestOptions);
|
|
5150
5190
|
}
|
|
5151
|
-
async revoke(id) {
|
|
5152
|
-
return await this.resend.delete(`/oauth/grants/${id}
|
|
5191
|
+
async revoke(id, requestOptions = {}) {
|
|
5192
|
+
return await this.resend.delete(`/oauth/grants/${id}`, void 0, requestOptions);
|
|
5153
5193
|
}
|
|
5154
5194
|
};
|
|
5155
5195
|
var Segments = class {
|
|
5156
5196
|
constructor(resend) {
|
|
5157
5197
|
this.resend = resend;
|
|
5158
5198
|
}
|
|
5159
|
-
async create(payload,
|
|
5160
|
-
return await this.resend.post("/segments", payload,
|
|
5199
|
+
async create(payload, requestOptions = {}) {
|
|
5200
|
+
return await this.resend.post("/segments", payload, requestOptions);
|
|
5161
5201
|
}
|
|
5162
|
-
async list(options = {}) {
|
|
5202
|
+
async list(options = {}, requestOptions = {}) {
|
|
5163
5203
|
const url = buildPaginationUrl("/segments", options);
|
|
5164
|
-
return await this.resend.get(url);
|
|
5204
|
+
return await this.resend.get(url, requestOptions);
|
|
5165
5205
|
}
|
|
5166
|
-
async get(id) {
|
|
5167
|
-
return await this.resend.get(`/segments/${id}
|
|
5206
|
+
async get(id, requestOptions = {}) {
|
|
5207
|
+
return await this.resend.get(`/segments/${id}`, requestOptions);
|
|
5168
5208
|
}
|
|
5169
|
-
async
|
|
5170
|
-
return await this.resend.
|
|
5209
|
+
async update(id, payload, requestOptions = {}) {
|
|
5210
|
+
return await this.resend.patch(`/segments/${id}`, payload, requestOptions);
|
|
5211
|
+
}
|
|
5212
|
+
async remove(id, requestOptions = {}) {
|
|
5213
|
+
return await this.resend.delete(`/segments/${id}`, void 0, requestOptions);
|
|
5171
5214
|
}
|
|
5172
5215
|
};
|
|
5173
5216
|
var Batch = class {
|
|
5174
5217
|
constructor(resend) {
|
|
5175
5218
|
this.resend = resend;
|
|
5176
5219
|
}
|
|
5177
|
-
async add(options) {
|
|
5178
|
-
return this.resend.post("/suppressions/batch/add", options);
|
|
5220
|
+
async add(options, requestOptions = {}) {
|
|
5221
|
+
return this.resend.post("/suppressions/batch/add", options, requestOptions);
|
|
5179
5222
|
}
|
|
5180
|
-
async remove(options) {
|
|
5181
|
-
return this.resend.post("/suppressions/batch/remove", options);
|
|
5223
|
+
async remove(options, requestOptions = {}) {
|
|
5224
|
+
return this.resend.post("/suppressions/batch/remove", options, requestOptions);
|
|
5182
5225
|
}
|
|
5183
5226
|
};
|
|
5184
5227
|
var missingIdentifierError = () => ({
|
|
@@ -5195,21 +5238,21 @@ var Suppressions = class {
|
|
|
5195
5238
|
this.resend = resend;
|
|
5196
5239
|
this.batch = new Batch(resend);
|
|
5197
5240
|
}
|
|
5198
|
-
async add(options) {
|
|
5199
|
-
return this.resend.post("/suppressions", options);
|
|
5241
|
+
async add(options, requestOptions = {}) {
|
|
5242
|
+
return this.resend.post("/suppressions", options, requestOptions);
|
|
5200
5243
|
}
|
|
5201
|
-
async list(options = {}) {
|
|
5244
|
+
async list(options = {}, requestOptions = {}) {
|
|
5202
5245
|
const queryString = buildSuppressionsQuery(options);
|
|
5203
5246
|
const url = queryString ? `/suppressions?${queryString}` : "/suppressions";
|
|
5204
|
-
return this.resend.get(url);
|
|
5247
|
+
return this.resend.get(url, requestOptions);
|
|
5205
5248
|
}
|
|
5206
|
-
async get(idOrEmail) {
|
|
5249
|
+
async get(idOrEmail, requestOptions = {}) {
|
|
5207
5250
|
if (!idOrEmail) return missingIdentifierError();
|
|
5208
|
-
return this.resend.get(`/suppressions/${encodeURIComponent(idOrEmail)}
|
|
5251
|
+
return this.resend.get(`/suppressions/${encodeURIComponent(idOrEmail)}`, requestOptions);
|
|
5209
5252
|
}
|
|
5210
|
-
async remove(idOrEmail) {
|
|
5253
|
+
async remove(idOrEmail, requestOptions = {}) {
|
|
5211
5254
|
if (!idOrEmail) return missingIdentifierError();
|
|
5212
|
-
return this.resend.delete(`/suppressions/${encodeURIComponent(idOrEmail)}
|
|
5255
|
+
return this.resend.delete(`/suppressions/${encodeURIComponent(idOrEmail)}`, void 0, requestOptions);
|
|
5213
5256
|
}
|
|
5214
5257
|
};
|
|
5215
5258
|
function buildSuppressionsQuery(options) {
|
|
@@ -5252,62 +5295,62 @@ var ChainableTemplateResult = class {
|
|
|
5252
5295
|
then(onfulfilled, onrejected) {
|
|
5253
5296
|
return this.promise.then(onfulfilled, onrejected);
|
|
5254
5297
|
}
|
|
5255
|
-
async publish() {
|
|
5298
|
+
async publish(requestOptions = {}) {
|
|
5256
5299
|
const { data, error } = await this.promise;
|
|
5257
5300
|
if (error) return {
|
|
5258
5301
|
data: null,
|
|
5259
5302
|
headers: null,
|
|
5260
5303
|
error
|
|
5261
5304
|
};
|
|
5262
|
-
return this.publishFn(data.id);
|
|
5305
|
+
return this.publishFn(data.id, requestOptions);
|
|
5263
5306
|
}
|
|
5264
5307
|
};
|
|
5265
5308
|
var Templates = class {
|
|
5266
5309
|
constructor(resend) {
|
|
5267
5310
|
this.resend = resend;
|
|
5268
5311
|
}
|
|
5269
|
-
create(payload) {
|
|
5270
|
-
return new ChainableTemplateResult(this.performCreate(payload), this.publish.bind(this));
|
|
5312
|
+
create(payload, requestOptions = {}) {
|
|
5313
|
+
return new ChainableTemplateResult(this.performCreate(payload, requestOptions), this.publish.bind(this));
|
|
5271
5314
|
}
|
|
5272
|
-
async performCreate(payload) {
|
|
5315
|
+
async performCreate(payload, requestOptions) {
|
|
5273
5316
|
const body = { ...payload };
|
|
5274
5317
|
if (payload.react) body.html = await render(payload.react);
|
|
5275
|
-
return this.resend.post("/templates", parseTemplateToApiOptions(body));
|
|
5318
|
+
return this.resend.post("/templates", parseTemplateToApiOptions(body), requestOptions);
|
|
5276
5319
|
}
|
|
5277
|
-
async remove(identifier) {
|
|
5278
|
-
return await this.resend.delete(`/templates/${identifier}
|
|
5320
|
+
async remove(identifier, requestOptions = {}) {
|
|
5321
|
+
return await this.resend.delete(`/templates/${identifier}`, void 0, requestOptions);
|
|
5279
5322
|
}
|
|
5280
|
-
async get(identifier) {
|
|
5281
|
-
return await this.resend.get(`/templates/${identifier}
|
|
5323
|
+
async get(identifier, requestOptions = {}) {
|
|
5324
|
+
return await this.resend.get(`/templates/${identifier}`, requestOptions);
|
|
5282
5325
|
}
|
|
5283
|
-
async list(options = {}) {
|
|
5284
|
-
return this.resend.get(`/templates${getPaginationQueryProperties(options)}
|
|
5326
|
+
async list(options = {}, requestOptions = {}) {
|
|
5327
|
+
return this.resend.get(`/templates${getPaginationQueryProperties(options)}`, requestOptions);
|
|
5285
5328
|
}
|
|
5286
|
-
duplicate(identifier) {
|
|
5287
|
-
return new ChainableTemplateResult(this.resend.post(`/templates/${identifier}/duplicate
|
|
5329
|
+
duplicate(identifier, requestOptions = {}) {
|
|
5330
|
+
return new ChainableTemplateResult(this.resend.post(`/templates/${identifier}/duplicate`, void 0, requestOptions), this.publish.bind(this));
|
|
5288
5331
|
}
|
|
5289
|
-
async publish(identifier) {
|
|
5290
|
-
return await this.resend.post(`/templates/${identifier}/publish
|
|
5332
|
+
async publish(identifier, requestOptions = {}) {
|
|
5333
|
+
return await this.resend.post(`/templates/${identifier}/publish`, void 0, requestOptions);
|
|
5291
5334
|
}
|
|
5292
|
-
async update(identifier, payload) {
|
|
5293
|
-
return await this.resend.patch(`/templates/${identifier}`, parseTemplateToApiOptions(payload));
|
|
5335
|
+
async update(identifier, payload, requestOptions = {}) {
|
|
5336
|
+
return await this.resend.patch(`/templates/${identifier}`, parseTemplateToApiOptions(payload), requestOptions);
|
|
5294
5337
|
}
|
|
5295
5338
|
};
|
|
5296
5339
|
var Topics = class {
|
|
5297
5340
|
constructor(resend) {
|
|
5298
5341
|
this.resend = resend;
|
|
5299
5342
|
}
|
|
5300
|
-
async create(payload) {
|
|
5343
|
+
async create(payload, requestOptions = {}) {
|
|
5301
5344
|
const { defaultSubscription, ...body } = payload;
|
|
5302
5345
|
return await this.resend.post("/topics", {
|
|
5303
5346
|
...body,
|
|
5304
5347
|
default_subscription: defaultSubscription
|
|
5305
|
-
});
|
|
5348
|
+
}, requestOptions);
|
|
5306
5349
|
}
|
|
5307
|
-
async list() {
|
|
5308
|
-
return await this.resend.get("/topics");
|
|
5350
|
+
async list(requestOptions = {}) {
|
|
5351
|
+
return await this.resend.get("/topics", requestOptions);
|
|
5309
5352
|
}
|
|
5310
|
-
async get(id) {
|
|
5353
|
+
async get(id, requestOptions = {}) {
|
|
5311
5354
|
if (!id) return {
|
|
5312
5355
|
data: null,
|
|
5313
5356
|
headers: null,
|
|
@@ -5317,9 +5360,9 @@ var Topics = class {
|
|
|
5317
5360
|
name: "missing_required_field"
|
|
5318
5361
|
}
|
|
5319
5362
|
};
|
|
5320
|
-
return await this.resend.get(`/topics/${id}
|
|
5363
|
+
return await this.resend.get(`/topics/${id}`, requestOptions);
|
|
5321
5364
|
}
|
|
5322
|
-
async update(payload) {
|
|
5365
|
+
async update(payload, requestOptions = {}) {
|
|
5323
5366
|
if (!payload.id) return {
|
|
5324
5367
|
data: null,
|
|
5325
5368
|
headers: null,
|
|
@@ -5329,9 +5372,9 @@ var Topics = class {
|
|
|
5329
5372
|
name: "missing_required_field"
|
|
5330
5373
|
}
|
|
5331
5374
|
};
|
|
5332
|
-
return await this.resend.patch(`/topics/${payload.id}`, payload);
|
|
5375
|
+
return await this.resend.patch(`/topics/${payload.id}`, payload, requestOptions);
|
|
5333
5376
|
}
|
|
5334
|
-
async remove(id) {
|
|
5377
|
+
async remove(id, requestOptions = {}) {
|
|
5335
5378
|
if (!id) return {
|
|
5336
5379
|
data: null,
|
|
5337
5380
|
headers: null,
|
|
@@ -5341,28 +5384,69 @@ var Topics = class {
|
|
|
5341
5384
|
name: "missing_required_field"
|
|
5342
5385
|
}
|
|
5343
5386
|
};
|
|
5344
|
-
return await this.resend.delete(`/topics/${id}
|
|
5387
|
+
return await this.resend.delete(`/topics/${id}`, void 0, requestOptions);
|
|
5388
|
+
}
|
|
5389
|
+
};
|
|
5390
|
+
var Usage = class {
|
|
5391
|
+
constructor(resend) {
|
|
5392
|
+
this.resend = resend;
|
|
5393
|
+
}
|
|
5394
|
+
async get(requestOptions = {}) {
|
|
5395
|
+
return await this.resend.get("/usage", requestOptions);
|
|
5396
|
+
}
|
|
5397
|
+
};
|
|
5398
|
+
var Attempts = class {
|
|
5399
|
+
constructor(resend) {
|
|
5400
|
+
this.resend = resend;
|
|
5401
|
+
}
|
|
5402
|
+
async list(options, requestOptions = {}) {
|
|
5403
|
+
const { webhookId, eventId } = options;
|
|
5404
|
+
const url = buildPaginationUrl(`/webhooks/${webhookId}/events/${eventId}/attempts`, options);
|
|
5405
|
+
return await this.resend.get(url, requestOptions);
|
|
5406
|
+
}
|
|
5407
|
+
};
|
|
5408
|
+
var Events = class {
|
|
5409
|
+
constructor(resend) {
|
|
5410
|
+
this.resend = resend;
|
|
5411
|
+
this.attempts = new Attempts(resend);
|
|
5412
|
+
}
|
|
5413
|
+
async list(options, requestOptions = {}) {
|
|
5414
|
+
const { webhookId } = options;
|
|
5415
|
+
const url = buildPaginationUrl(`/webhooks/${webhookId}/events`, options);
|
|
5416
|
+
return await this.resend.get(url, requestOptions);
|
|
5417
|
+
}
|
|
5418
|
+
async get(options, requestOptions = {}) {
|
|
5419
|
+
const { webhookId, eventId } = options;
|
|
5420
|
+
return await this.resend.get(`/webhooks/${webhookId}/events/${eventId}`, requestOptions);
|
|
5421
|
+
}
|
|
5422
|
+
async replay(options, requestOptions = {}) {
|
|
5423
|
+
const { webhookId, eventId } = options;
|
|
5424
|
+
return await this.resend.post(`/webhooks/${webhookId}/events/${eventId}/replay`, void 0, requestOptions);
|
|
5345
5425
|
}
|
|
5346
5426
|
};
|
|
5347
5427
|
var Webhooks = class {
|
|
5348
5428
|
constructor(resend) {
|
|
5349
5429
|
this.resend = resend;
|
|
5430
|
+
this.events = new Events(resend);
|
|
5350
5431
|
}
|
|
5351
|
-
async create(payload,
|
|
5352
|
-
return await this.resend.post("/webhooks", payload,
|
|
5432
|
+
async create(payload, requestOptions = {}) {
|
|
5433
|
+
return await this.resend.post("/webhooks", payload, requestOptions);
|
|
5353
5434
|
}
|
|
5354
|
-
async get(id) {
|
|
5355
|
-
return await this.resend.get(`/webhooks/${id}
|
|
5435
|
+
async get(id, requestOptions = {}) {
|
|
5436
|
+
return await this.resend.get(`/webhooks/${id}`, requestOptions);
|
|
5356
5437
|
}
|
|
5357
|
-
async list(options = {}) {
|
|
5438
|
+
async list(options = {}, requestOptions = {}) {
|
|
5358
5439
|
const url = buildPaginationUrl("/webhooks", options);
|
|
5359
|
-
return await this.resend.get(url);
|
|
5440
|
+
return await this.resend.get(url, requestOptions);
|
|
5441
|
+
}
|
|
5442
|
+
async update(id, payload, requestOptions = {}) {
|
|
5443
|
+
return await this.resend.patch(`/webhooks/${id}`, payload, requestOptions);
|
|
5360
5444
|
}
|
|
5361
|
-
async
|
|
5362
|
-
return await this.resend.
|
|
5445
|
+
async remove(id, requestOptions = {}) {
|
|
5446
|
+
return await this.resend.delete(`/webhooks/${id}`, void 0, requestOptions);
|
|
5363
5447
|
}
|
|
5364
|
-
async
|
|
5365
|
-
return await this.resend.
|
|
5448
|
+
async rotateSigningSecret(id, requestOptions = {}) {
|
|
5449
|
+
return await this.resend.post(`/webhooks/${id}/signing-secret/rotate`, void 0, requestOptions);
|
|
5366
5450
|
}
|
|
5367
5451
|
verify(payload) {
|
|
5368
5452
|
return new import_dist.Webhook(payload.webhookSecret).verify(payload.payload, {
|
|
@@ -5393,12 +5477,13 @@ var Resend = class {
|
|
|
5393
5477
|
this.contacts = new Contacts(this);
|
|
5394
5478
|
this.domains = new Domains(this);
|
|
5395
5479
|
this.emails = new Emails(this);
|
|
5396
|
-
this.events = new Events(this);
|
|
5480
|
+
this.events = new Events$1(this);
|
|
5397
5481
|
this.logs = new Logs(this);
|
|
5398
5482
|
this.oauthGrants = new OAuthGrants(this);
|
|
5399
5483
|
this.suppressions = new Suppressions(this);
|
|
5400
5484
|
this.templates = new Templates(this);
|
|
5401
5485
|
this.topics = new Topics(this);
|
|
5486
|
+
this.usage = new Usage(this);
|
|
5402
5487
|
this.webhooks = new Webhooks(this);
|
|
5403
5488
|
if (!key) {
|
|
5404
5489
|
if (typeof process !== "undefined" && process.env) this.key = process.env.RESEND_API_KEY;
|
|
@@ -5420,6 +5505,7 @@ var Resend = class {
|
|
|
5420
5505
|
});
|
|
5421
5506
|
}
|
|
5422
5507
|
async fetchRequest(path, options = {}) {
|
|
5508
|
+
const { signal } = options;
|
|
5423
5509
|
try {
|
|
5424
5510
|
const response = await fetch(`${this.baseUrl}${path}`, options);
|
|
5425
5511
|
if (!response.ok) try {
|
|
@@ -5432,6 +5518,7 @@ var Resend = class {
|
|
|
5432
5518
|
headers: Object.fromEntries(response.headers.entries())
|
|
5433
5519
|
};
|
|
5434
5520
|
} catch (err) {
|
|
5521
|
+
if (signal?.aborted && err === signal.reason) throw err;
|
|
5435
5522
|
if (err instanceof SyntaxError) {
|
|
5436
5523
|
const error = {
|
|
5437
5524
|
name: "application_error",
|
|
@@ -5637,4 +5724,4 @@ var sendEmail = async (params, options = {}) => {
|
|
|
5637
5724
|
//#endregion
|
|
5638
5725
|
export { sendEmail as i, configureEmailTransport as n, createResendEmailTransport as r, EmailDeliveryError as t };
|
|
5639
5726
|
|
|
5640
|
-
//# sourceMappingURL=email-
|
|
5727
|
+
//# sourceMappingURL=email-CXD08Xm7.js.map
|