resend 6.2.1 → 6.2.2

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.
Files changed (3) hide show
  1. package/dist/index.js +387 -485
  2. package/dist/index.mjs +387 -485
  3. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -29,29 +29,9 @@ var __objRest = (source, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
- var __async = (__this, __arguments, generator) => {
33
- return new Promise((resolve, reject) => {
34
- var fulfilled = (value) => {
35
- try {
36
- step(generator.next(value));
37
- } catch (e) {
38
- reject(e);
39
- }
40
- };
41
- var rejected = (value) => {
42
- try {
43
- step(generator.throw(value));
44
- } catch (e) {
45
- reject(e);
46
- }
47
- };
48
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
49
- step((generator = generator.apply(__this, __arguments)).next());
50
- });
51
- };
52
32
 
53
33
  // package.json
54
- var version = "6.2.1";
34
+ var version = "6.2.2";
55
35
 
56
36
  // src/common/utils/build-pagination-query.ts
57
37
  function buildPaginationQuery(options) {
@@ -73,31 +53,25 @@ var ApiKeys = class {
73
53
  constructor(resend) {
74
54
  this.resend = resend;
75
55
  }
76
- create(_0) {
77
- return __async(this, arguments, function* (payload, options = {}) {
78
- const data = yield this.resend.post(
79
- "/api-keys",
80
- payload,
81
- options
82
- );
83
- return data;
84
- });
85
- }
86
- list() {
87
- return __async(this, arguments, function* (options = {}) {
88
- const queryString = buildPaginationQuery(options);
89
- const url = queryString ? `/api-keys?${queryString}` : "/api-keys";
90
- const data = yield this.resend.get(url);
91
- return data;
92
- });
93
- }
94
- remove(id) {
95
- return __async(this, null, function* () {
96
- const data = yield this.resend.delete(
97
- `/api-keys/${id}`
98
- );
99
- return data;
100
- });
56
+ async create(payload, options = {}) {
57
+ const data = await this.resend.post(
58
+ "/api-keys",
59
+ payload,
60
+ options
61
+ );
62
+ return data;
63
+ }
64
+ async list(options = {}) {
65
+ const queryString = buildPaginationQuery(options);
66
+ const url = queryString ? `/api-keys?${queryString}` : "/api-keys";
67
+ const data = await this.resend.get(url);
68
+ return data;
69
+ }
70
+ async remove(id) {
71
+ const data = await this.resend.delete(
72
+ `/api-keys/${id}`
73
+ );
74
+ return data;
101
75
  }
102
76
  };
103
77
 
@@ -106,39 +80,31 @@ var Audiences = class {
106
80
  constructor(resend) {
107
81
  this.resend = resend;
108
82
  }
109
- create(_0) {
110
- return __async(this, arguments, function* (payload, options = {}) {
111
- const data = yield this.resend.post(
112
- "/audiences",
113
- payload,
114
- options
115
- );
116
- return data;
117
- });
118
- }
119
- list() {
120
- return __async(this, arguments, function* (options = {}) {
121
- const queryString = buildPaginationQuery(options);
122
- const url = queryString ? `/audiences?${queryString}` : "/audiences";
123
- const data = yield this.resend.get(url);
124
- return data;
125
- });
126
- }
127
- get(id) {
128
- return __async(this, null, function* () {
129
- const data = yield this.resend.get(
130
- `/audiences/${id}`
131
- );
132
- return data;
133
- });
134
- }
135
- remove(id) {
136
- return __async(this, null, function* () {
137
- const data = yield this.resend.delete(
138
- `/audiences/${id}`
139
- );
140
- return data;
141
- });
83
+ async create(payload, options = {}) {
84
+ const data = await this.resend.post(
85
+ "/audiences",
86
+ payload,
87
+ options
88
+ );
89
+ return data;
90
+ }
91
+ async list(options = {}) {
92
+ const queryString = buildPaginationQuery(options);
93
+ const url = queryString ? `/audiences?${queryString}` : "/audiences";
94
+ const data = await this.resend.get(url);
95
+ return data;
96
+ }
97
+ async get(id) {
98
+ const data = await this.resend.get(
99
+ `/audiences/${id}`
100
+ );
101
+ return data;
102
+ }
103
+ async remove(id) {
104
+ const data = await this.resend.delete(
105
+ `/audiences/${id}`
106
+ );
107
+ return data;
142
108
  }
143
109
  };
144
110
 
@@ -170,18 +136,16 @@ function parseEmailToApiOptions(email) {
170
136
  }
171
137
 
172
138
  // src/render.ts
173
- function render(node) {
174
- return new Promise((resolve, reject) => {
175
- import("@react-email/render").then(({ render: render2 }) => {
176
- resolve(render2(node));
177
- }).catch(() => {
178
- reject(
179
- Error(
180
- "Failed to render React component. Make sure to install `@react-email/render` or `@react-email/components`."
181
- )
182
- );
183
- });
184
- });
139
+ async function render(node) {
140
+ let render2;
141
+ try {
142
+ ({ render: render2 } = await import("@react-email/render"));
143
+ } catch (e) {
144
+ throw new Error(
145
+ "Failed to render React component. Make sure to install `@react-email/render` or `@react-email/components`."
146
+ );
147
+ }
148
+ return render2(node);
185
149
  }
186
150
 
187
151
  // src/batch/batch.ts
@@ -189,33 +153,29 @@ var Batch = class {
189
153
  constructor(resend) {
190
154
  this.resend = resend;
191
155
  }
192
- send(payload, options) {
193
- return __async(this, null, function* () {
194
- return this.create(payload, options);
195
- });
156
+ async send(payload, options) {
157
+ return this.create(payload, options);
196
158
  }
197
- create(payload, options) {
198
- return __async(this, null, function* () {
199
- var _a;
200
- const emails = [];
201
- for (const email of payload) {
202
- if (email.react) {
203
- email.html = yield render(email.react);
204
- email.react = void 0;
205
- }
206
- emails.push(parseEmailToApiOptions(email));
159
+ async create(payload, options) {
160
+ var _a;
161
+ const emails = [];
162
+ for (const email of payload) {
163
+ if (email.react) {
164
+ email.html = await render(email.react);
165
+ email.react = void 0;
207
166
  }
208
- const data = yield this.resend.post(
209
- "/emails/batch",
210
- emails,
211
- __spreadProps(__spreadValues({}, options), {
212
- headers: __spreadValues({
213
- "x-batch-validation": (_a = options == null ? void 0 : options.batchValidation) != null ? _a : "strict"
214
- }, options == null ? void 0 : options.headers)
215
- })
216
- );
217
- return data;
218
- });
167
+ emails.push(parseEmailToApiOptions(email));
168
+ }
169
+ const data = await this.resend.post(
170
+ "/emails/batch",
171
+ emails,
172
+ __spreadProps(__spreadValues({}, options), {
173
+ headers: __spreadValues({
174
+ "x-batch-validation": (_a = options == null ? void 0 : options.batchValidation) != null ? _a : "strict"
175
+ }, options == null ? void 0 : options.headers)
176
+ })
177
+ );
178
+ return data;
219
179
  }
220
180
  };
221
181
 
@@ -224,81 +184,69 @@ var Broadcasts = class {
224
184
  constructor(resend) {
225
185
  this.resend = resend;
226
186
  }
227
- create(_0) {
228
- return __async(this, arguments, function* (payload, options = {}) {
229
- if (payload.react) {
230
- payload.html = yield render(payload.react);
231
- }
232
- const data = yield this.resend.post(
233
- "/broadcasts",
234
- {
235
- name: payload.name,
236
- audience_id: payload.audienceId,
237
- preview_text: payload.previewText,
238
- from: payload.from,
239
- html: payload.html,
240
- reply_to: payload.replyTo,
241
- subject: payload.subject,
242
- text: payload.text
243
- },
244
- options
245
- );
246
- return data;
247
- });
248
- }
249
- send(id, payload) {
250
- return __async(this, null, function* () {
251
- const data = yield this.resend.post(
252
- `/broadcasts/${id}/send`,
253
- { scheduled_at: payload == null ? void 0 : payload.scheduledAt }
254
- );
255
- return data;
256
- });
257
- }
258
- list() {
259
- return __async(this, arguments, function* (options = {}) {
260
- const queryString = buildPaginationQuery(options);
261
- const url = queryString ? `/broadcasts?${queryString}` : "/broadcasts";
262
- const data = yield this.resend.get(url);
263
- return data;
264
- });
265
- }
266
- get(id) {
267
- return __async(this, null, function* () {
268
- const data = yield this.resend.get(
269
- `/broadcasts/${id}`
270
- );
271
- return data;
272
- });
273
- }
274
- remove(id) {
275
- return __async(this, null, function* () {
276
- const data = yield this.resend.delete(
277
- `/broadcasts/${id}`
278
- );
279
- return data;
280
- });
281
- }
282
- update(id, payload) {
283
- return __async(this, null, function* () {
284
- if (payload.react) {
285
- payload.html = yield render(payload.react);
187
+ async create(payload, options = {}) {
188
+ if (payload.react) {
189
+ payload.html = await render(payload.react);
190
+ }
191
+ const data = await this.resend.post(
192
+ "/broadcasts",
193
+ {
194
+ name: payload.name,
195
+ audience_id: payload.audienceId,
196
+ preview_text: payload.previewText,
197
+ from: payload.from,
198
+ html: payload.html,
199
+ reply_to: payload.replyTo,
200
+ subject: payload.subject,
201
+ text: payload.text
202
+ },
203
+ options
204
+ );
205
+ return data;
206
+ }
207
+ async send(id, payload) {
208
+ const data = await this.resend.post(
209
+ `/broadcasts/${id}/send`,
210
+ { scheduled_at: payload == null ? void 0 : payload.scheduledAt }
211
+ );
212
+ return data;
213
+ }
214
+ async list(options = {}) {
215
+ const queryString = buildPaginationQuery(options);
216
+ const url = queryString ? `/broadcasts?${queryString}` : "/broadcasts";
217
+ const data = await this.resend.get(url);
218
+ return data;
219
+ }
220
+ async get(id) {
221
+ const data = await this.resend.get(
222
+ `/broadcasts/${id}`
223
+ );
224
+ return data;
225
+ }
226
+ async remove(id) {
227
+ const data = await this.resend.delete(
228
+ `/broadcasts/${id}`
229
+ );
230
+ return data;
231
+ }
232
+ async update(id, payload) {
233
+ if (payload.react) {
234
+ payload.html = await render(payload.react);
235
+ }
236
+ const data = await this.resend.patch(
237
+ `/broadcasts/${id}`,
238
+ {
239
+ name: payload.name,
240
+ audience_id: payload.audienceId,
241
+ from: payload.from,
242
+ html: payload.html,
243
+ text: payload.text,
244
+ subject: payload.subject,
245
+ reply_to: payload.replyTo,
246
+ preview_text: payload.previewText
286
247
  }
287
- const data = yield this.resend.patch(
288
- `/broadcasts/${id}`,
289
- {
290
- name: payload.name,
291
- audience_id: payload.audienceId,
292
- from: payload.from,
293
- html: payload.html,
294
- text: payload.text,
295
- subject: payload.subject,
296
- reply_to: payload.replyTo,
297
- preview_text: payload.previewText
298
- }
299
- );
300
- return data;
301
- });
248
+ );
249
+ return data;
302
250
  }
303
251
  };
304
252
 
@@ -307,88 +255,78 @@ var Contacts = class {
307
255
  constructor(resend) {
308
256
  this.resend = resend;
309
257
  }
310
- create(_0) {
311
- return __async(this, arguments, function* (payload, options = {}) {
312
- const data = yield this.resend.post(
313
- `/audiences/${payload.audienceId}/contacts`,
314
- {
315
- unsubscribed: payload.unsubscribed,
316
- email: payload.email,
317
- first_name: payload.firstName,
318
- last_name: payload.lastName
319
- },
320
- options
321
- );
322
- return data;
323
- });
324
- }
325
- list(options) {
326
- return __async(this, null, function* () {
327
- const _a = options, { audienceId } = _a, paginationOptions = __objRest(_a, ["audienceId"]);
328
- const queryString = buildPaginationQuery(paginationOptions);
329
- const url = queryString ? `/audiences/${audienceId}/contacts?${queryString}` : `/audiences/${audienceId}/contacts`;
330
- const data = yield this.resend.get(url);
331
- return data;
332
- });
333
- }
334
- get(options) {
335
- return __async(this, null, function* () {
336
- if (!options.id && !options.email) {
337
- return {
338
- data: null,
339
- error: {
340
- message: "Missing `id` or `email` field.",
341
- statusCode: null,
342
- name: "missing_required_field"
343
- }
344
- };
345
- }
346
- const data = yield this.resend.get(
347
- `/audiences/${options.audienceId}/contacts/${(options == null ? void 0 : options.email) ? options == null ? void 0 : options.email : options == null ? void 0 : options.id}`
348
- );
349
- return data;
350
- });
351
- }
352
- update(options) {
353
- return __async(this, null, function* () {
354
- if (!options.id && !options.email) {
355
- return {
356
- data: null,
357
- error: {
358
- message: "Missing `id` or `email` field.",
359
- statusCode: null,
360
- name: "missing_required_field"
361
- }
362
- };
363
- }
364
- const data = yield this.resend.patch(
365
- `/audiences/${options.audienceId}/contacts/${(options == null ? void 0 : options.email) ? options == null ? void 0 : options.email : options == null ? void 0 : options.id}`,
366
- {
367
- unsubscribed: options.unsubscribed,
368
- first_name: options.firstName,
369
- last_name: options.lastName
258
+ async create(payload, options = {}) {
259
+ const data = await this.resend.post(
260
+ `/audiences/${payload.audienceId}/contacts`,
261
+ {
262
+ unsubscribed: payload.unsubscribed,
263
+ email: payload.email,
264
+ first_name: payload.firstName,
265
+ last_name: payload.lastName
266
+ },
267
+ options
268
+ );
269
+ return data;
270
+ }
271
+ async list(options) {
272
+ const _a = options, { audienceId } = _a, paginationOptions = __objRest(_a, ["audienceId"]);
273
+ const queryString = buildPaginationQuery(paginationOptions);
274
+ const url = queryString ? `/audiences/${audienceId}/contacts?${queryString}` : `/audiences/${audienceId}/contacts`;
275
+ const data = await this.resend.get(url);
276
+ return data;
277
+ }
278
+ async get(options) {
279
+ if (!options.id && !options.email) {
280
+ return {
281
+ data: null,
282
+ error: {
283
+ message: "Missing `id` or `email` field.",
284
+ statusCode: null,
285
+ name: "missing_required_field"
370
286
  }
371
- );
372
- return data;
373
- });
374
- }
375
- remove(payload) {
376
- return __async(this, null, function* () {
377
- if (!payload.id && !payload.email) {
378
- return {
379
- data: null,
380
- error: {
381
- message: "Missing `id` or `email` field.",
382
- statusCode: null,
383
- name: "missing_required_field"
384
- }
385
- };
287
+ };
288
+ }
289
+ const data = await this.resend.get(
290
+ `/audiences/${options.audienceId}/contacts/${(options == null ? void 0 : options.email) ? options == null ? void 0 : options.email : options == null ? void 0 : options.id}`
291
+ );
292
+ return data;
293
+ }
294
+ async update(options) {
295
+ if (!options.id && !options.email) {
296
+ return {
297
+ data: null,
298
+ error: {
299
+ message: "Missing `id` or `email` field.",
300
+ statusCode: null,
301
+ name: "missing_required_field"
302
+ }
303
+ };
304
+ }
305
+ const data = await this.resend.patch(
306
+ `/audiences/${options.audienceId}/contacts/${(options == null ? void 0 : options.email) ? options == null ? void 0 : options.email : options == null ? void 0 : options.id}`,
307
+ {
308
+ unsubscribed: options.unsubscribed,
309
+ first_name: options.firstName,
310
+ last_name: options.lastName
386
311
  }
387
- const data = yield this.resend.delete(
388
- `/audiences/${payload.audienceId}/contacts/${(payload == null ? void 0 : payload.email) ? payload == null ? void 0 : payload.email : payload == null ? void 0 : payload.id}`
389
- );
390
- return data;
391
- });
312
+ );
313
+ return data;
314
+ }
315
+ async remove(payload) {
316
+ if (!payload.id && !payload.email) {
317
+ return {
318
+ data: null,
319
+ error: {
320
+ message: "Missing `id` or `email` field.",
321
+ statusCode: null,
322
+ name: "missing_required_field"
323
+ }
324
+ };
325
+ }
326
+ const data = await this.resend.delete(
327
+ `/audiences/${payload.audienceId}/contacts/${(payload == null ? void 0 : payload.email) ? payload == null ? void 0 : payload.email : payload == null ? void 0 : payload.id}`
328
+ );
329
+ return data;
392
330
  }
393
331
  };
394
332
 
@@ -406,60 +344,48 @@ var Domains = class {
406
344
  constructor(resend) {
407
345
  this.resend = resend;
408
346
  }
409
- create(_0) {
410
- return __async(this, arguments, function* (payload, options = {}) {
411
- const data = yield this.resend.post(
412
- "/domains",
413
- parseDomainToApiOptions(payload),
414
- options
415
- );
416
- return data;
417
- });
418
- }
419
- list() {
420
- return __async(this, arguments, function* (options = {}) {
421
- const queryString = buildPaginationQuery(options);
422
- const url = queryString ? `/domains?${queryString}` : "/domains";
423
- const data = yield this.resend.get(url);
424
- return data;
425
- });
347
+ async create(payload, options = {}) {
348
+ const data = await this.resend.post(
349
+ "/domains",
350
+ parseDomainToApiOptions(payload),
351
+ options
352
+ );
353
+ return data;
354
+ }
355
+ async list(options = {}) {
356
+ const queryString = buildPaginationQuery(options);
357
+ const url = queryString ? `/domains?${queryString}` : "/domains";
358
+ const data = await this.resend.get(url);
359
+ return data;
360
+ }
361
+ async get(id) {
362
+ const data = await this.resend.get(
363
+ `/domains/${id}`
364
+ );
365
+ return data;
366
+ }
367
+ async update(payload) {
368
+ const data = await this.resend.patch(
369
+ `/domains/${payload.id}`,
370
+ {
371
+ click_tracking: payload.clickTracking,
372
+ open_tracking: payload.openTracking,
373
+ tls: payload.tls
374
+ }
375
+ );
376
+ return data;
426
377
  }
427
- get(id) {
428
- return __async(this, null, function* () {
429
- const data = yield this.resend.get(
430
- `/domains/${id}`
431
- );
432
- return data;
433
- });
378
+ async remove(id) {
379
+ const data = await this.resend.delete(
380
+ `/domains/${id}`
381
+ );
382
+ return data;
434
383
  }
435
- update(payload) {
436
- return __async(this, null, function* () {
437
- const data = yield this.resend.patch(
438
- `/domains/${payload.id}`,
439
- {
440
- click_tracking: payload.clickTracking,
441
- open_tracking: payload.openTracking,
442
- tls: payload.tls
443
- }
444
- );
445
- return data;
446
- });
447
- }
448
- remove(id) {
449
- return __async(this, null, function* () {
450
- const data = yield this.resend.delete(
451
- `/domains/${id}`
452
- );
453
- return data;
454
- });
455
- }
456
- verify(id) {
457
- return __async(this, null, function* () {
458
- const data = yield this.resend.post(
459
- `/domains/${id}/verify`
460
- );
461
- return data;
462
- });
384
+ async verify(id) {
385
+ const data = await this.resend.post(
386
+ `/domains/${id}/verify`
387
+ );
388
+ return data;
463
389
  }
464
390
  };
465
391
 
@@ -468,58 +394,46 @@ var Emails = class {
468
394
  constructor(resend) {
469
395
  this.resend = resend;
470
396
  }
471
- send(_0) {
472
- return __async(this, arguments, function* (payload, options = {}) {
473
- return this.create(payload, options);
474
- });
397
+ async send(payload, options = {}) {
398
+ return this.create(payload, options);
475
399
  }
476
- create(_0) {
477
- return __async(this, arguments, function* (payload, options = {}) {
478
- if (payload.react) {
479
- payload.html = yield render(payload.react);
400
+ async create(payload, options = {}) {
401
+ if (payload.react) {
402
+ payload.html = await render(payload.react);
403
+ }
404
+ const data = await this.resend.post(
405
+ "/emails",
406
+ parseEmailToApiOptions(payload),
407
+ options
408
+ );
409
+ return data;
410
+ }
411
+ async get(id) {
412
+ const data = await this.resend.get(
413
+ `/emails/${id}`
414
+ );
415
+ return data;
416
+ }
417
+ async list(options = {}) {
418
+ const queryString = buildPaginationQuery(options);
419
+ const url = queryString ? `/emails?${queryString}` : "/emails";
420
+ const data = await this.resend.get(url);
421
+ return data;
422
+ }
423
+ async update(payload) {
424
+ const data = await this.resend.patch(
425
+ `/emails/${payload.id}`,
426
+ {
427
+ scheduled_at: payload.scheduledAt
480
428
  }
481
- const data = yield this.resend.post(
482
- "/emails",
483
- parseEmailToApiOptions(payload),
484
- options
485
- );
486
- return data;
487
- });
488
- }
489
- get(id) {
490
- return __async(this, null, function* () {
491
- const data = yield this.resend.get(
492
- `/emails/${id}`
493
- );
494
- return data;
495
- });
429
+ );
430
+ return data;
496
431
  }
497
- list() {
498
- return __async(this, arguments, function* (options = {}) {
499
- const queryString = buildPaginationQuery(options);
500
- const url = queryString ? `/emails?${queryString}` : "/emails";
501
- const data = yield this.resend.get(url);
502
- return data;
503
- });
504
- }
505
- update(payload) {
506
- return __async(this, null, function* () {
507
- const data = yield this.resend.patch(
508
- `/emails/${payload.id}`,
509
- {
510
- scheduled_at: payload.scheduledAt
511
- }
512
- );
513
- return data;
514
- });
515
- }
516
- cancel(id) {
517
- return __async(this, null, function* () {
518
- const data = yield this.resend.post(
519
- `/emails/${id}/cancel`
520
- );
521
- return data;
522
- });
432
+ async cancel(id) {
433
+ const data = await this.resend.post(
434
+ `/emails/${id}/cancel`
435
+ );
436
+ return data;
523
437
  }
524
438
  };
525
439
 
@@ -568,129 +482,117 @@ var Resend = class {
568
482
  "Content-Type": "application/json"
569
483
  });
570
484
  }
571
- fetchRequest(_0) {
572
- return __async(this, arguments, function* (path, options = {}) {
573
- try {
574
- const response = yield fetch(`${baseUrl}${path}`, options);
575
- if (!response.ok) {
576
- try {
577
- const rawError = yield response.text();
578
- return { data: null, error: JSON.parse(rawError) };
579
- } catch (err) {
580
- if (err instanceof SyntaxError) {
581
- return {
582
- data: null,
583
- error: {
584
- name: "application_error",
585
- statusCode: response.status,
586
- message: "Internal server error. We are unable to process your request right now, please try again later."
587
- }
588
- };
589
- }
590
- const error = {
591
- message: response.statusText,
592
- statusCode: response.status,
593
- name: "application_error"
485
+ async fetchRequest(path, options = {}) {
486
+ try {
487
+ const response = await fetch(`${baseUrl}${path}`, options);
488
+ if (!response.ok) {
489
+ try {
490
+ const rawError = await response.text();
491
+ return { data: null, error: JSON.parse(rawError) };
492
+ } catch (err) {
493
+ if (err instanceof SyntaxError) {
494
+ return {
495
+ data: null,
496
+ error: {
497
+ name: "application_error",
498
+ statusCode: response.status,
499
+ message: "Internal server error. We are unable to process your request right now, please try again later."
500
+ }
594
501
  };
595
- if (err instanceof Error) {
596
- return { data: null, error: __spreadProps(__spreadValues({}, error), { message: err.message }) };
597
- }
598
- return { data: null, error };
599
502
  }
600
- }
601
- const data = yield response.json();
602
- return { data, error: null };
603
- } catch (e) {
604
- return {
605
- data: null,
606
- error: {
607
- name: "application_error",
608
- statusCode: null,
609
- message: "Unable to fetch data. The request could not be resolved."
503
+ const error = {
504
+ message: response.statusText,
505
+ statusCode: response.status,
506
+ name: "application_error"
507
+ };
508
+ if (err instanceof Error) {
509
+ return { data: null, error: __spreadProps(__spreadValues({}, error), { message: err.message }) };
610
510
  }
611
- };
612
- }
613
- });
614
- }
615
- post(_0, _1) {
616
- return __async(this, arguments, function* (path, entity, options = {}) {
617
- const headers = new Headers(this.headers);
618
- if (options.headers) {
619
- for (const [key, value] of new Headers(options.headers).entries()) {
620
- headers.set(key, value);
511
+ return { data: null, error };
621
512
  }
622
513
  }
623
- if (options.idempotencyKey) {
624
- headers.set("Idempotency-Key", options.idempotencyKey);
625
- }
626
- const requestOptions = __spreadProps(__spreadValues({
627
- method: "POST",
628
- body: JSON.stringify(entity)
629
- }, options), {
630
- headers
631
- });
632
- return this.fetchRequest(path, requestOptions);
633
- });
634
- }
635
- get(_0) {
636
- return __async(this, arguments, function* (path, options = {}) {
637
- const headers = new Headers(this.headers);
638
- if (options.headers) {
639
- for (const [key, value] of new Headers(options.headers).entries()) {
640
- headers.set(key, value);
514
+ const data = await response.json();
515
+ return { data, error: null };
516
+ } catch (e) {
517
+ return {
518
+ data: null,
519
+ error: {
520
+ name: "application_error",
521
+ statusCode: null,
522
+ message: "Unable to fetch data. The request could not be resolved."
641
523
  }
642
- }
643
- const requestOptions = __spreadProps(__spreadValues({
644
- method: "GET"
645
- }, options), {
646
- headers
647
- });
648
- return this.fetchRequest(path, requestOptions);
649
- });
524
+ };
525
+ }
650
526
  }
651
- put(_0, _1) {
652
- return __async(this, arguments, function* (path, entity, options = {}) {
653
- const headers = new Headers(this.headers);
654
- if (options.headers) {
655
- for (const [key, value] of new Headers(options.headers).entries()) {
656
- headers.set(key, value);
657
- }
527
+ async post(path, entity, options = {}) {
528
+ const headers = new Headers(this.headers);
529
+ if (options.headers) {
530
+ for (const [key, value] of new Headers(options.headers).entries()) {
531
+ headers.set(key, value);
658
532
  }
659
- const requestOptions = __spreadProps(__spreadValues({
660
- method: "PUT",
661
- body: JSON.stringify(entity)
662
- }, options), {
663
- headers
664
- });
665
- return this.fetchRequest(path, requestOptions);
666
- });
667
- }
668
- patch(_0, _1) {
669
- return __async(this, arguments, function* (path, entity, options = {}) {
670
- const headers = new Headers(this.headers);
671
- if (options.headers) {
672
- for (const [key, value] of new Headers(options.headers).entries()) {
673
- headers.set(key, value);
674
- }
533
+ }
534
+ if (options.idempotencyKey) {
535
+ headers.set("Idempotency-Key", options.idempotencyKey);
536
+ }
537
+ const requestOptions = __spreadProps(__spreadValues({
538
+ method: "POST",
539
+ body: JSON.stringify(entity)
540
+ }, options), {
541
+ headers
542
+ });
543
+ return this.fetchRequest(path, requestOptions);
544
+ }
545
+ async get(path, options = {}) {
546
+ const headers = new Headers(this.headers);
547
+ if (options.headers) {
548
+ for (const [key, value] of new Headers(options.headers).entries()) {
549
+ headers.set(key, value);
675
550
  }
676
- const requestOptions = __spreadProps(__spreadValues({
677
- method: "PATCH",
678
- body: JSON.stringify(entity)
679
- }, options), {
680
- headers
681
- });
682
- return this.fetchRequest(path, requestOptions);
683
- });
684
- }
685
- delete(path, query) {
686
- return __async(this, null, function* () {
687
- const requestOptions = {
688
- method: "DELETE",
689
- body: JSON.stringify(query),
690
- headers: this.headers
691
- };
692
- return this.fetchRequest(path, requestOptions);
693
- });
551
+ }
552
+ const requestOptions = __spreadProps(__spreadValues({
553
+ method: "GET"
554
+ }, options), {
555
+ headers
556
+ });
557
+ return this.fetchRequest(path, requestOptions);
558
+ }
559
+ async put(path, entity, options = {}) {
560
+ const headers = new Headers(this.headers);
561
+ if (options.headers) {
562
+ for (const [key, value] of new Headers(options.headers).entries()) {
563
+ headers.set(key, value);
564
+ }
565
+ }
566
+ const requestOptions = __spreadProps(__spreadValues({
567
+ method: "PUT",
568
+ body: JSON.stringify(entity)
569
+ }, options), {
570
+ headers
571
+ });
572
+ return this.fetchRequest(path, requestOptions);
573
+ }
574
+ async patch(path, entity, options = {}) {
575
+ const headers = new Headers(this.headers);
576
+ if (options.headers) {
577
+ for (const [key, value] of new Headers(options.headers).entries()) {
578
+ headers.set(key, value);
579
+ }
580
+ }
581
+ const requestOptions = __spreadProps(__spreadValues({
582
+ method: "PATCH",
583
+ body: JSON.stringify(entity)
584
+ }, options), {
585
+ headers
586
+ });
587
+ return this.fetchRequest(path, requestOptions);
588
+ }
589
+ async delete(path, query) {
590
+ const requestOptions = {
591
+ method: "DELETE",
592
+ body: JSON.stringify(query),
593
+ headers: this.headers
594
+ };
595
+ return this.fetchRequest(path, requestOptions);
694
596
  }
695
597
  };
696
598
  export {