resend 2.1.0-canary.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -256,6 +256,12 @@ declare class Batch {
256
256
  create(payload: CreateBatchOptions, options?: CreateBatchRequestOptions): Promise<CreateBatchResponse>;
257
257
  }
258
258
 
259
+ interface PatchOptions {
260
+ query?: {
261
+ [key: string]: any;
262
+ };
263
+ }
264
+
259
265
  interface Contact {
260
266
  created_at: string;
261
267
  id: string;
@@ -298,6 +304,19 @@ interface RemoveContactsResponse {
298
304
  error: ErrorResponse | null;
299
305
  }
300
306
 
307
+ interface UpdateContactOptions {
308
+ id: string;
309
+ audience_id: string;
310
+ unsubscribed?: boolean;
311
+ first_name?: string;
312
+ last_name?: string;
313
+ }
314
+ type UpdateContactResponseSuccess = Pick<Contact, 'id'>;
315
+ interface UpdateContactResponse {
316
+ data: UpdateContactResponseSuccess | null;
317
+ error: ErrorResponse | null;
318
+ }
319
+
301
320
  declare class Contacts {
302
321
  private readonly resend;
303
322
  constructor(resend: Resend);
@@ -309,6 +328,7 @@ declare class Contacts {
309
328
  audience_id: string;
310
329
  id: string;
311
330
  }): Promise<GetContactResponse>;
331
+ update(payload: UpdateContactOptions): Promise<UpdateContactResponse>;
312
332
  remove({ audience_id, id, }: {
313
333
  audience_id: string;
314
334
  id: string;
@@ -452,6 +472,10 @@ declare class Resend {
452
472
  data: T | null;
453
473
  error: ErrorResponse | null;
454
474
  }>;
475
+ patch<T>(path: string, entity: any, options?: PatchOptions): Promise<{
476
+ data: T | null;
477
+ error: ErrorResponse | null;
478
+ }>;
455
479
  delete<T>(path: string, query?: unknown): Promise<{
456
480
  data: T | null;
457
481
  error: ErrorResponse | null;
package/dist/index.d.ts CHANGED
@@ -256,6 +256,12 @@ declare class Batch {
256
256
  create(payload: CreateBatchOptions, options?: CreateBatchRequestOptions): Promise<CreateBatchResponse>;
257
257
  }
258
258
 
259
+ interface PatchOptions {
260
+ query?: {
261
+ [key: string]: any;
262
+ };
263
+ }
264
+
259
265
  interface Contact {
260
266
  created_at: string;
261
267
  id: string;
@@ -298,6 +304,19 @@ interface RemoveContactsResponse {
298
304
  error: ErrorResponse | null;
299
305
  }
300
306
 
307
+ interface UpdateContactOptions {
308
+ id: string;
309
+ audience_id: string;
310
+ unsubscribed?: boolean;
311
+ first_name?: string;
312
+ last_name?: string;
313
+ }
314
+ type UpdateContactResponseSuccess = Pick<Contact, 'id'>;
315
+ interface UpdateContactResponse {
316
+ data: UpdateContactResponseSuccess | null;
317
+ error: ErrorResponse | null;
318
+ }
319
+
301
320
  declare class Contacts {
302
321
  private readonly resend;
303
322
  constructor(resend: Resend);
@@ -309,6 +328,7 @@ declare class Contacts {
309
328
  audience_id: string;
310
329
  id: string;
311
330
  }): Promise<GetContactResponse>;
331
+ update(payload: UpdateContactOptions): Promise<UpdateContactResponse>;
312
332
  remove({ audience_id, id, }: {
313
333
  audience_id: string;
314
334
  id: string;
@@ -452,6 +472,10 @@ declare class Resend {
452
472
  data: T | null;
453
473
  error: ErrorResponse | null;
454
474
  }>;
475
+ patch<T>(path: string, entity: any, options?: PatchOptions): Promise<{
476
+ data: T | null;
477
+ error: ErrorResponse | null;
478
+ }>;
455
479
  delete<T>(path: string, query?: unknown): Promise<{
456
480
  data: T | null;
457
481
  error: ErrorResponse | null;
package/dist/index.js CHANGED
@@ -59,7 +59,7 @@ __export(src_exports, {
59
59
  module.exports = __toCommonJS(src_exports);
60
60
 
61
61
  // package.json
62
- var version = "2.1.0-canary.1";
62
+ var version = "2.1.0";
63
63
 
64
64
  // src/api-keys/api-keys.ts
65
65
  var ApiKeys = class {
@@ -196,6 +196,15 @@ var Contacts = class {
196
196
  return data;
197
197
  });
198
198
  }
199
+ update(payload) {
200
+ return __async(this, null, function* () {
201
+ const data = yield this.resend.patch(
202
+ `/audiences/${payload.audience_id}/contacts/${payload.id}`,
203
+ payload
204
+ );
205
+ return data;
206
+ });
207
+ }
199
208
  remove(_0) {
200
209
  return __async(this, arguments, function* ({
201
210
  audience_id,
@@ -305,8 +314,10 @@ var isResendErrorResponse = (response) => {
305
314
  };
306
315
 
307
316
  // src/resend.ts
308
- var baseUrl = process.env.RESEND_BASE_URL || "https://api.resend.com";
309
- var userAgent = process.env.RESEND_USER_AGENT || `resend-node:${version}`;
317
+ var defaultBaseUrl = "https://api.resend.com";
318
+ var defaultUserAgent = `resend-node:${version}`;
319
+ var baseUrl = typeof process !== "undefined" && process.env ? process.env.RESEND_BASE_URL || defaultBaseUrl : defaultBaseUrl;
320
+ var userAgent = typeof process !== "undefined" && process.env ? process.env.RESEND_USER_AGENT || defaultUserAgent : defaultUserAgent;
310
321
  var Resend = class {
311
322
  constructor(key) {
312
323
  this.key = key;
@@ -317,7 +328,9 @@ var Resend = class {
317
328
  this.domains = new Domains(this);
318
329
  this.emails = new Emails(this);
319
330
  if (!key) {
320
- this.key = process.env.RESEND_API_KEY;
331
+ if (typeof process !== "undefined" && process.env) {
332
+ this.key = process.env.RESEND_API_KEY;
333
+ }
321
334
  if (!this.key) {
322
335
  throw new Error(
323
336
  'Missing API key. Pass it to the constructor `new Resend("re_123")`'
@@ -373,6 +386,16 @@ var Resend = class {
373
386
  return this.fetchRequest(path, requestOptions);
374
387
  });
375
388
  }
389
+ patch(_0, _1) {
390
+ return __async(this, arguments, function* (path, entity, options = {}) {
391
+ const requestOptions = __spreadValues({
392
+ method: "PATCH",
393
+ headers: this.headers,
394
+ body: JSON.stringify(entity)
395
+ }, options);
396
+ return this.fetchRequest(path, requestOptions);
397
+ });
398
+ }
376
399
  delete(path, query) {
377
400
  return __async(this, null, function* () {
378
401
  const requestOptions = {
package/dist/index.mjs CHANGED
@@ -36,7 +36,7 @@ var __async = (__this, __arguments, generator) => {
36
36
  };
37
37
 
38
38
  // package.json
39
- var version = "2.1.0-canary.1";
39
+ var version = "2.1.0";
40
40
 
41
41
  // src/api-keys/api-keys.ts
42
42
  var ApiKeys = class {
@@ -173,6 +173,15 @@ var Contacts = class {
173
173
  return data;
174
174
  });
175
175
  }
176
+ update(payload) {
177
+ return __async(this, null, function* () {
178
+ const data = yield this.resend.patch(
179
+ `/audiences/${payload.audience_id}/contacts/${payload.id}`,
180
+ payload
181
+ );
182
+ return data;
183
+ });
184
+ }
176
185
  remove(_0) {
177
186
  return __async(this, arguments, function* ({
178
187
  audience_id,
@@ -282,8 +291,10 @@ var isResendErrorResponse = (response) => {
282
291
  };
283
292
 
284
293
  // src/resend.ts
285
- var baseUrl = process.env.RESEND_BASE_URL || "https://api.resend.com";
286
- var userAgent = process.env.RESEND_USER_AGENT || `resend-node:${version}`;
294
+ var defaultBaseUrl = "https://api.resend.com";
295
+ var defaultUserAgent = `resend-node:${version}`;
296
+ var baseUrl = typeof process !== "undefined" && process.env ? process.env.RESEND_BASE_URL || defaultBaseUrl : defaultBaseUrl;
297
+ var userAgent = typeof process !== "undefined" && process.env ? process.env.RESEND_USER_AGENT || defaultUserAgent : defaultUserAgent;
287
298
  var Resend = class {
288
299
  constructor(key) {
289
300
  this.key = key;
@@ -294,7 +305,9 @@ var Resend = class {
294
305
  this.domains = new Domains(this);
295
306
  this.emails = new Emails(this);
296
307
  if (!key) {
297
- this.key = process.env.RESEND_API_KEY;
308
+ if (typeof process !== "undefined" && process.env) {
309
+ this.key = process.env.RESEND_API_KEY;
310
+ }
298
311
  if (!this.key) {
299
312
  throw new Error(
300
313
  'Missing API key. Pass it to the constructor `new Resend("re_123")`'
@@ -350,6 +363,16 @@ var Resend = class {
350
363
  return this.fetchRequest(path, requestOptions);
351
364
  });
352
365
  }
366
+ patch(_0, _1) {
367
+ return __async(this, arguments, function* (path, entity, options = {}) {
368
+ const requestOptions = __spreadValues({
369
+ method: "PATCH",
370
+ headers: this.headers,
371
+ body: JSON.stringify(entity)
372
+ }, options);
373
+ return this.fetchRequest(path, requestOptions);
374
+ });
375
+ }
353
376
  delete(path, query) {
354
377
  return __async(this, null, function* () {
355
378
  const requestOptions = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resend",
3
- "version": "2.1.0-canary.1",
3
+ "version": "2.1.0",
4
4
  "description": "Node.js library for the Resend API",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",