mailchannels-sdk 0.7.8 → 0.7.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,11 +12,6 @@ Node.js SDK to integrate [MailChannels API](https://docs.mailchannels.net/) into
12
12
  This library provides a simple way to interact with the [MailChannels API](https://docs.mailchannels.net/). It is written in TypeScript and can be used in both JavaScript and TypeScript projects and in different runtimes.
13
13
  <!-- #endregion overview -->
14
14
 
15
- <!-- #region disclaimer -->
16
- > [!IMPORTANT]
17
- > **Disclaimer**: This library is not associated with [MailChannels Corporation](https://mailchannels.com/).
18
- <!-- #endregion disclaimer -->
19
-
20
15
  - [✨ Release Notes](CHANGELOG.md)
21
16
  - [📖 Documentation](https://mailchannels.yizack.com)
22
17
 
@@ -510,6 +510,14 @@ type EmailsCheckDomainResponse = DataResponse<{
510
510
  * A human-readable explanation of SPF check.
511
511
  */
512
512
  reason?: string;
513
+ /**
514
+ * The SPF record that was used for the check.
515
+ */
516
+ spfRecord?: string;
517
+ /**
518
+ * Error message if the SPF record lookup failed.
519
+ */
520
+ spfRecordError?: string;
513
521
  verdict: EmailsCheckDomainVerdict;
514
522
  };
515
523
  references?: string[];
@@ -1,6 +1,7 @@
1
1
  import { $fetch } from "ofetch";
2
2
  import { subtle } from "node:crypto";
3
3
  import { Buffer } from "node:buffer";
4
+ var version = "0.7.10";
4
5
  var MailChannelsClient = class MailChannelsClient {
5
6
  static DEFAULT_BASE_URL = "https://api.mailchannels.net";
6
7
  #baseUrl;
@@ -11,7 +12,8 @@ var MailChannelsClient = class MailChannelsClient {
11
12
  this.#headers = {
12
13
  "X-API-Key": key,
13
14
  "Accept": "application/json",
14
- "Content-Type": "application/json"
15
+ "Content-Type": "application/json",
16
+ "User-Agent": `mailchannels-node/${version}`
15
17
  };
16
18
  }
17
19
  async _fetch(path, options) {
@@ -55,16 +57,6 @@ var MailChannelsClient = class MailChannelsClient {
55
57
  });
56
58
  }
57
59
  };
58
- let ErrorCode = /* @__PURE__ */ function(ErrorCode) {
59
- ErrorCode[ErrorCode["BadRequest"] = 400] = "BadRequest";
60
- ErrorCode[ErrorCode["Unauthorized"] = 401] = "Unauthorized";
61
- ErrorCode[ErrorCode["Forbidden"] = 403] = "Forbidden";
62
- ErrorCode[ErrorCode["NotFound"] = 404] = "NotFound";
63
- ErrorCode[ErrorCode["Conflict"] = 409] = "Conflict";
64
- ErrorCode[ErrorCode["PayloadTooLarge"] = 413] = "PayloadTooLarge";
65
- ErrorCode[ErrorCode["UnprocessableEntity"] = 422] = "UnprocessableEntity";
66
- return ErrorCode;
67
- }({});
68
60
  const createError = (message, statusCode = null) => {
69
61
  return {
70
62
  message,
@@ -323,9 +315,9 @@ var Emails = class {
323
315
  body: payload,
324
316
  onResponseError: async ({ response }) => {
325
317
  error = getStatusError(response, {
326
- [ErrorCode.BadRequest]: "Bad Request.",
327
- [ErrorCode.Forbidden]: "User does not have access to this feature.",
328
- [ErrorCode.PayloadTooLarge]: "The total message size should not exceed 30MB. This includes the message itself, headers, and the combined size of any attachments."
318
+ [400]: "Bad Request.",
319
+ [403]: "User does not have access to this feature.",
320
+ [413]: "The total message size should not exceed 30MB. This includes the message itself, headers, and the combined size of any attachments."
329
321
  });
330
322
  }
331
323
  }).catch((e) => {
@@ -401,8 +393,8 @@ var Emails = class {
401
393
  body: payload,
402
394
  onResponseError: async ({ response }) => {
403
395
  error = getStatusError(response, {
404
- [ErrorCode.BadRequest]: "Bad Request.",
405
- [ErrorCode.Forbidden]: "User does not have access to this feature."
396
+ [400]: "Bad Request.",
397
+ [403]: "User does not have access to this feature."
406
398
  });
407
399
  }
408
400
  }).catch((e) => {
@@ -448,8 +440,8 @@ var Emails = class {
448
440
  body: payload,
449
441
  onResponseError: async ({ response }) => {
450
442
  error = getStatusError(response, {
451
- [ErrorCode.BadRequest]: "Bad Request.",
452
- [ErrorCode.Conflict]: "Key pair already created for domain, and selector."
443
+ [400]: "Bad Request.",
444
+ [409]: "Key pair already created for domain, and selector."
453
445
  });
454
446
  }
455
447
  }).catch((e) => {
@@ -492,7 +484,7 @@ var Emails = class {
492
484
  const response = await this.mailchannels.get(`/tx/v1/domains/${domain}/dkim-keys`, {
493
485
  query: payload,
494
486
  onResponseError: async ({ response }) => {
495
- error = getStatusError(response, { [ErrorCode.BadRequest]: "Bad Request." });
487
+ error = getStatusError(response, { [400]: "Bad Request." });
496
488
  }
497
489
  }).catch((e) => {
498
490
  error ||= getResultError(e, "Failed to fetch DKIM keys.");
@@ -521,8 +513,8 @@ var Emails = class {
521
513
  body: payload,
522
514
  onResponseError: async ({ response }) => {
523
515
  error = getStatusError(response, {
524
- [ErrorCode.BadRequest]: "Bad Request.",
525
- [ErrorCode.NotFound]: "Specified key pair not found, or no active key for rotation. This may also occur if the DKIM domain or selector path parameter is missing."
516
+ [400]: "Bad Request.",
517
+ [404]: "Specified key pair not found, or no active key for rotation. This may also occur if the DKIM domain or selector path parameter is missing."
526
518
  });
527
519
  }
528
520
  }).catch((e) => {
@@ -554,9 +546,9 @@ var Emails = class {
554
546
  body: payload,
555
547
  onResponseError: async ({ response }) => {
556
548
  error = getStatusError(response, {
557
- [ErrorCode.BadRequest]: "Bad Request.",
558
- [ErrorCode.NotFound]: "Specified key pair not found.",
559
- [ErrorCode.Conflict]: "Key pair already created for domain, and provided new key selector."
549
+ [400]: "Bad Request.",
550
+ [404]: "Specified key pair not found.",
551
+ [409]: "Key pair already created for domain, and provided new key selector."
560
552
  });
561
553
  }
562
554
  }).catch((e) => {
@@ -665,7 +657,7 @@ var Webhooks = class Webhooks {
665
657
  await this.mailchannels.post("/tx/v1/webhook", {
666
658
  query: { endpoint },
667
659
  onResponseError: async ({ response }) => {
668
- error = getStatusError(response, { [ErrorCode.Conflict]: `Endpoint '${endpoint}' is already enrolled to receive notifications.` });
660
+ error = getStatusError(response, { [409]: `Endpoint '${endpoint}' is already enrolled to receive notifications.` });
669
661
  }
670
662
  }).catch((e) => {
671
663
  error ||= getResultError(e, "Failed to enroll webhook.");
@@ -710,8 +702,8 @@ var Webhooks = class Webhooks {
710
702
  query: { id },
711
703
  onResponseError: async ({ response }) => {
712
704
  error = getStatusError(response, {
713
- [ErrorCode.BadRequest]: "Bad Request.",
714
- [ErrorCode.NotFound]: `The key '${id}' is not found.`
705
+ [400]: "Bad Request.",
706
+ [404]: `The key '${id}' is not found.`
715
707
  });
716
708
  }
717
709
  }).catch((e) => {
@@ -743,8 +735,8 @@ var Webhooks = class Webhooks {
743
735
  body: { request_id: requestId },
744
736
  onResponseError: async ({ response }) => {
745
737
  error = getStatusError(response, {
746
- [ErrorCode.BadRequest]: "Bad Request.",
747
- [ErrorCode.NotFound]: "No webhooks found for the account."
738
+ [400]: "Bad Request.",
739
+ [404]: "No webhooks found for the account."
748
740
  });
749
741
  }
750
742
  }).catch((e) => {
@@ -818,7 +810,7 @@ var Webhooks = class Webhooks {
818
810
  offset: options?.offset
819
811
  },
820
812
  onResponseError: async ({ response }) => {
821
- error = getStatusError(response, { [ErrorCode.BadRequest]: "Bad Request." });
813
+ error = getStatusError(response, { [400]: "Bad Request." });
822
814
  }
823
815
  }).catch((e) => {
824
816
  error ||= getResultError(e, "Failed to fetch webhook batches.");
@@ -846,8 +838,8 @@ var Webhooks = class Webhooks {
846
838
  let error = null;
847
839
  const response = await this.mailchannels.post(`/tx/v1/webhook-batch/${batchId}/resend`, { onResponseError: async ({ response }) => {
848
840
  error = getStatusError(response, {
849
- [ErrorCode.BadRequest]: "Bad Request. The batch ID is invalid.",
850
- [ErrorCode.NotFound]: `The batch '${batchId}' is not found for the customer.`
841
+ [400]: "Bad Request. The batch ID is invalid.",
842
+ [404]: `The batch '${batchId}' is not found for the customer.`
851
843
  });
852
844
  } }).catch((e) => {
853
845
  error ||= getResultError(e, "Failed to resend webhook batch.");
@@ -902,8 +894,8 @@ var SubAccounts = class SubAccounts {
902
894
  },
903
895
  onResponseError: async ({ response }) => {
904
896
  error = getStatusError(response, {
905
- [ErrorCode.Forbidden]: "The parent account does not have permission to create sub-accounts.",
906
- [ErrorCode.Conflict]: `Sub-account with handle '${handle}' already exists.`
897
+ [403]: "The parent account does not have permission to create sub-accounts.",
898
+ [409]: `Sub-account with handle '${handle}' already exists.`
907
899
  });
908
900
  }
909
901
  }).catch((e) => {
@@ -984,7 +976,7 @@ var SubAccounts = class SubAccounts {
984
976
  };
985
977
  }
986
978
  await this.mailchannels.post(`/tx/v1/sub-account/${handle}/suspend`, { onResponseError: async ({ response }) => {
987
- error = getStatusError(response, { [ErrorCode.NotFound]: `The specified sub-account '${handle}' does not exist.` });
979
+ error = getStatusError(response, { [404]: `The specified sub-account '${handle}' does not exist.` });
988
980
  } }).catch((e) => {
989
981
  error ||= getResultError(e, "Failed to suspend sub-account.");
990
982
  });
@@ -1004,8 +996,8 @@ var SubAccounts = class SubAccounts {
1004
996
  }
1005
997
  await this.mailchannels.post(`/tx/v1/sub-account/${handle}/activate`, { onResponseError: async ({ response }) => {
1006
998
  error = getStatusError(response, {
1007
- [ErrorCode.Forbidden]: "The parent account does not have permission to activate the sub-account.",
1008
- [ErrorCode.NotFound]: `The specified sub-account '${handle}' does not exist.`
999
+ [403]: "The parent account does not have permission to activate the sub-account.",
1000
+ [404]: `The specified sub-account '${handle}' does not exist.`
1009
1001
  });
1010
1002
  } }).catch((e) => {
1011
1003
  error ||= getResultError(e, "Failed to activate sub-account.");
@@ -1026,9 +1018,9 @@ var SubAccounts = class SubAccounts {
1026
1018
  }
1027
1019
  const response = await this.mailchannels.post(`/tx/v1/sub-account/${handle}/api-key`, { onResponseError: async ({ response }) => {
1028
1020
  error = getStatusError(response, {
1029
- [ErrorCode.Forbidden]: "You can't create API keys for this sub-account.",
1030
- [ErrorCode.NotFound]: `Sub-account with handle '${handle}' not found.`,
1031
- [ErrorCode.UnprocessableEntity]: "You have reached the limit of API keys you can create for this sub-account."
1021
+ [403]: "You can't create API keys for this sub-account.",
1022
+ [404]: `Sub-account with handle '${handle}' not found.`,
1023
+ [422]: "You have reached the limit of API keys you can create for this sub-account."
1032
1024
  });
1033
1025
  } }).catch((e) => {
1034
1026
  error ||= getResultError(e, "Failed to create sub-account API key.");
@@ -1064,7 +1056,7 @@ var SubAccounts = class SubAccounts {
1064
1056
  error
1065
1057
  };
1066
1058
  const response = await this.mailchannels.get(`/tx/v1/sub-account/${handle}/api-key`, { onResponseError: async ({ response }) => {
1067
- error = getStatusError(response, { [ErrorCode.NotFound]: `Sub-account with handle '${handle}' not found.` });
1059
+ error = getStatusError(response, { [404]: `Sub-account with handle '${handle}' not found.` });
1068
1060
  } }).catch((e) => {
1069
1061
  error ||= getResultError(e, "Failed to fetch sub-account API keys.");
1070
1062
  return null;
@@ -1091,7 +1083,7 @@ var SubAccounts = class SubAccounts {
1091
1083
  };
1092
1084
  }
1093
1085
  await this.mailchannels.delete(`/tx/v1/sub-account/${handle}/api-key/${id}`, { onResponseError: async ({ response }) => {
1094
- error = getStatusError(response, { [ErrorCode.BadRequest]: "Missing or invalid API key ID." });
1086
+ error = getStatusError(response, { [400]: "Missing or invalid API key ID." });
1095
1087
  } }).catch((e) => {
1096
1088
  error ||= getResultError(e, "Failed to delete sub-account API key.");
1097
1089
  });
@@ -1111,9 +1103,9 @@ var SubAccounts = class SubAccounts {
1111
1103
  }
1112
1104
  const response = await this.mailchannels.post(`/tx/v1/sub-account/${handle}/smtp-password`, { onResponseError: async ({ response }) => {
1113
1105
  error = getStatusError(response, {
1114
- [ErrorCode.Forbidden]: "You can't create SMTP passwords for this sub-account.",
1115
- [ErrorCode.NotFound]: `Sub-account with handle '${handle}' not found.`,
1116
- [ErrorCode.UnprocessableEntity]: "You have reached the limit of SMTP passwords you can create for this sub-account."
1106
+ [403]: "You can't create SMTP passwords for this sub-account.",
1107
+ [404]: `Sub-account with handle '${handle}' not found.`,
1108
+ [422]: "You have reached the limit of SMTP passwords you can create for this sub-account."
1117
1109
  });
1118
1110
  } }).catch((e) => {
1119
1111
  error ||= getResultError(e, "Failed to create sub-account SMTP password.");
@@ -1142,7 +1134,7 @@ var SubAccounts = class SubAccounts {
1142
1134
  };
1143
1135
  }
1144
1136
  const response = await this.mailchannels.get(`/tx/v1/sub-account/${handle}/smtp-password`, { onResponseError: async ({ response }) => {
1145
- error = getStatusError(response, { [ErrorCode.NotFound]: `Sub-account with handle '${handle}' not found.` });
1137
+ error = getStatusError(response, { [404]: `Sub-account with handle '${handle}' not found.` });
1146
1138
  } }).catch((e) => {
1147
1139
  error ||= getResultError(e, "Failed to fetch sub-account SMTP passwords.");
1148
1140
  return null;
@@ -1170,7 +1162,7 @@ var SubAccounts = class SubAccounts {
1170
1162
  };
1171
1163
  }
1172
1164
  await this.mailchannels.delete(`/tx/v1/sub-account/${handle}/smtp-password/${id}`, { onResponseError: async ({ response }) => {
1173
- error = getStatusError(response, { [ErrorCode.BadRequest]: "Missing or invalid SMTP password ID." });
1165
+ error = getStatusError(response, { [400]: "Missing or invalid SMTP password ID." });
1174
1166
  } }).catch((e) => {
1175
1167
  error ||= getResultError(e, "Failed to delete sub-account SMTP password.");
1176
1168
  });
@@ -1189,7 +1181,7 @@ var SubAccounts = class SubAccounts {
1189
1181
  };
1190
1182
  }
1191
1183
  const response = await this.mailchannels.get(`/tx/v1/sub-account/${handle}/limit`, { onResponseError: async ({ response }) => {
1192
- error = getStatusError(response, { [ErrorCode.NotFound]: `Sub-account with handle '${handle}' not found.` });
1184
+ error = getStatusError(response, { [404]: `Sub-account with handle '${handle}' not found.` });
1193
1185
  } }).catch((e) => {
1194
1186
  error ||= getResultError(e, "Failed to fetch sub-account limit.");
1195
1187
  return null;
@@ -1216,8 +1208,8 @@ var SubAccounts = class SubAccounts {
1216
1208
  body: limit,
1217
1209
  onResponseError: async ({ response }) => {
1218
1210
  error = getStatusError(response, {
1219
- [ErrorCode.BadRequest]: "Bad Request.",
1220
- [ErrorCode.NotFound]: `Sub-account with handle '${handle}' not found.`
1211
+ [400]: "Bad Request.",
1212
+ [404]: `Sub-account with handle '${handle}' not found.`
1221
1213
  });
1222
1214
  }
1223
1215
  }).catch((e) => {
@@ -1238,7 +1230,7 @@ var SubAccounts = class SubAccounts {
1238
1230
  };
1239
1231
  }
1240
1232
  await this.mailchannels.delete(`/tx/v1/sub-account/${handle}/limit`, { onResponseError: async ({ response }) => {
1241
- error = getStatusError(response, { [ErrorCode.NotFound]: `Sub-account with handle '${handle}' not found.` });
1233
+ error = getStatusError(response, { [404]: `Sub-account with handle '${handle}' not found.` });
1242
1234
  } }).catch((e) => {
1243
1235
  error ||= getResultError(e, "Failed to delete sub-account limit.");
1244
1236
  });
@@ -1257,7 +1249,7 @@ var SubAccounts = class SubAccounts {
1257
1249
  };
1258
1250
  }
1259
1251
  const response = await this.mailchannels.get(`/tx/v1/sub-account/${handle}/usage`, { onResponseError: async ({ response }) => {
1260
- error = getStatusError(response, { [ErrorCode.NotFound]: `Sub-account with handle '${handle}' not found.` });
1252
+ error = getStatusError(response, { [404]: `Sub-account with handle '${handle}' not found.` });
1261
1253
  } }).catch((e) => {
1262
1254
  error ||= getResultError(e, "Failed to fetch sub-account usage.");
1263
1255
  return null;
@@ -1290,7 +1282,7 @@ var Metrics = class {
1290
1282
  interval: options?.interval
1291
1283
  },
1292
1284
  onResponseError: async ({ response }) => {
1293
- error = getStatusError(response, { [ErrorCode.BadRequest]: "Bad Request." });
1285
+ error = getStatusError(response, { [400]: "Bad Request." });
1294
1286
  }
1295
1287
  }).catch((e) => {
1296
1288
  error ||= getResultError(e, "Failed to fetch engagement metrics.");
@@ -1328,7 +1320,7 @@ var Metrics = class {
1328
1320
  interval: options?.interval
1329
1321
  },
1330
1322
  onResponseError: async ({ response }) => {
1331
- error = getStatusError(response, { [ErrorCode.BadRequest]: "Bad Request." });
1323
+ error = getStatusError(response, { [400]: "Bad Request." });
1332
1324
  }
1333
1325
  }).catch((e) => {
1334
1326
  error ||= getResultError(e, "Failed to fetch performance metrics.");
@@ -1364,7 +1356,7 @@ var Metrics = class {
1364
1356
  interval: options?.interval
1365
1357
  },
1366
1358
  onResponseError: async ({ response }) => {
1367
- error = getStatusError(response, { [ErrorCode.BadRequest]: "Bad Request." });
1359
+ error = getStatusError(response, { [400]: "Bad Request." });
1368
1360
  }
1369
1361
  }).catch((e) => {
1370
1362
  error ||= getResultError(e, "Failed to fetch recipient behaviour metrics.");
@@ -1398,7 +1390,7 @@ var Metrics = class {
1398
1390
  interval: options?.interval
1399
1391
  },
1400
1392
  onResponseError: async ({ response }) => {
1401
- error = getStatusError(response, { [ErrorCode.BadRequest]: "Bad Request." });
1393
+ error = getStatusError(response, { [400]: "Bad Request." });
1402
1394
  }
1403
1395
  }).catch((e) => {
1404
1396
  error ||= getResultError(e, "Failed to fetch volume metrics.");
@@ -1464,7 +1456,7 @@ var Metrics = class {
1464
1456
  sort_order: options?.sortOrder
1465
1457
  },
1466
1458
  onResponseError: async ({ response }) => {
1467
- error = getStatusError(response, { [ErrorCode.BadRequest]: "Bad Request." });
1459
+ error = getStatusError(response, { [400]: "Bad Request." });
1468
1460
  }
1469
1461
  }).catch((e) => {
1470
1462
  error ||= getResultError(e, "Failed to fetch senders metrics.");
@@ -1506,9 +1498,9 @@ var Suppressions = class {
1506
1498
  body: payload,
1507
1499
  onResponseError: async ({ response }) => {
1508
1500
  error = getStatusError(response, {
1509
- [ErrorCode.BadRequest]: "Bad Request.",
1510
- [ErrorCode.Conflict]: "Conflict. One or more suppression entries in the request already exist and cannot be created again.",
1511
- [ErrorCode.PayloadTooLarge]: "Payload too large. The request exceeds the maximum allowed total of 1000 suppression entries for the parent account and/or its sub-accounts."
1501
+ [400]: "Bad Request.",
1502
+ [409]: "Conflict. One or more suppression entries in the request already exist and cannot be created again.",
1503
+ [413]: "Payload too large. The request exceeds the maximum allowed total of 1000 suppression entries for the parent account and/or its sub-accounts."
1512
1504
  });
1513
1505
  }
1514
1506
  }).catch((e) => {
@@ -1524,7 +1516,7 @@ var Suppressions = class {
1524
1516
  await this.mailchannels.delete(`/tx/v1/suppression-list/recipients/${recipient}`, {
1525
1517
  query: { source },
1526
1518
  onResponseError: async ({ response }) => {
1527
- error = getStatusError(response, { [ErrorCode.BadRequest]: "Bad Request." });
1519
+ error = getStatusError(response, { [400]: "Bad Request." });
1528
1520
  }
1529
1521
  }).catch((e) => {
1530
1522
  error ||= getResultError(e, "Failed to delete suppression entry.");
@@ -1555,7 +1547,7 @@ var Suppressions = class {
1555
1547
  const response = await this.mailchannels.get("/tx/v1/suppression-list", {
1556
1548
  query: payload,
1557
1549
  onResponseError: async ({ response }) => {
1558
- error = getStatusError(response, { [ErrorCode.BadRequest]: "Bad Request." });
1550
+ error = getStatusError(response, { [400]: "Bad Request." });
1559
1551
  }
1560
1552
  }).catch((e) => {
1561
1553
  error ||= getResultError(e, "Failed to fetch suppression entries.");
@@ -1593,9 +1585,9 @@ var Domains = class {
1593
1585
  body: payload,
1594
1586
  onResponseError: async ({ response }) => {
1595
1587
  error = getStatusError(response, {
1596
- [ErrorCode.BadRequest]: "Bad Request, returned in the case that an error occurs while converting an A-label domain to a U-label domain name.",
1597
- [ErrorCode.Forbidden]: "The limit on associated domains is reached or you are attempting to associate a domain with a subscription that is not your own.",
1598
- [ErrorCode.Conflict]: `The domain '${options.domain}' is already provisioned, and is associated with a different customer.`
1588
+ [400]: "Bad Request, returned in the case that an error occurs while converting an A-label domain to a U-label domain name.",
1589
+ [403]: "The limit on associated domains is reached or you are attempting to associate a domain with a subscription that is not your own.",
1590
+ [409]: `The domain '${options.domain}' is already provisioned, and is associated with a different customer.`
1599
1591
  });
1600
1592
  }
1601
1593
  }).catch((e) => {
@@ -1637,8 +1629,8 @@ var Domains = class {
1637
1629
  body: { domains },
1638
1630
  onResponseError: async ({ response }) => {
1639
1631
  error = getStatusError(response, {
1640
- [ErrorCode.BadRequest]: "Bad Request, returned in the case that a domain name fails RFC 5891 validation.",
1641
- [ErrorCode.Forbidden]: "The limit on associated domains is reached or you are attempting to associate a domain with a subscription that is not your own."
1632
+ [400]: "Bad Request, returned in the case that a domain name fails RFC 5891 validation.",
1633
+ [403]: "The limit on associated domains is reached or you are attempting to associate a domain with a subscription that is not your own."
1642
1634
  });
1643
1635
  }
1644
1636
  }).catch((e) => {
@@ -1696,8 +1688,8 @@ var Domains = class {
1696
1688
  }
1697
1689
  await this.mailchannels.delete(`/inbound/v1/domains/${domain}`, { onResponseError: async ({ response }) => {
1698
1690
  error = getStatusError(response, {
1699
- [ErrorCode.Forbidden]: "The domain is associated with an api key that is different than the one in the request, or the domain in the request is an alias domain.",
1700
- [ErrorCode.NotFound]: `The domain '${domain}' was not found.`
1691
+ [403]: "The domain is associated with an api key that is different than the one in the request, or the domain in the request is an alias domain.",
1692
+ [404]: `The domain '${domain}' was not found.`
1701
1693
  });
1702
1694
  } }).catch((e) => {
1703
1695
  error ||= getResultError(e, "Failed to delete domain.");
@@ -1728,8 +1720,8 @@ var Domains = class {
1728
1720
  body: { item },
1729
1721
  onResponseError: async ({ response }) => {
1730
1722
  error = getStatusError(response, {
1731
- [ErrorCode.Forbidden]: "The domain is associated with an api key that is different than the one in the request, the domain is associated with a different customer, or the domain in the request is an alias domain.",
1732
- [ErrorCode.NotFound]: `The domain '${domain}' was not found.`
1723
+ [403]: "The domain is associated with an api key that is different than the one in the request, the domain is associated with a different customer, or the domain in the request is an alias domain.",
1724
+ [404]: `The domain '${domain}' was not found.`
1733
1725
  });
1734
1726
  }
1735
1727
  }).catch((e) => {
@@ -1767,8 +1759,8 @@ var Domains = class {
1767
1759
  }
1768
1760
  const response = await this.mailchannels.get(`/inbound/v1/domains/${domain}/lists/${listName}`, { onResponseError: async ({ response }) => {
1769
1761
  error = getStatusError(response, {
1770
- [ErrorCode.Forbidden]: "The domain is associated with an api key that is different than the one in the request, the domain is associated with a different customer, or the domain in the request is an alias domain.",
1771
- [ErrorCode.NotFound]: `The domain '${domain}' was not found.`
1762
+ [403]: "The domain is associated with an api key that is different than the one in the request, the domain is associated with a different customer, or the domain in the request is an alias domain.",
1763
+ [404]: `The domain '${domain}' was not found.`
1772
1764
  });
1773
1765
  } }).catch((e) => {
1774
1766
  error ||= getResultError(e, "Failed to fetch domain list entries.");
@@ -1808,8 +1800,8 @@ var Domains = class {
1808
1800
  query: { item },
1809
1801
  onResponseError: async ({ response }) => {
1810
1802
  error = getStatusError(response, {
1811
- [ErrorCode.Forbidden]: "The domain is associated with an api key that is different than the one in the request, the domain is associated with a different customer, or the domain in the request is an alias domain.",
1812
- [ErrorCode.NotFound]: `The domain '${domain}' was not found.`
1803
+ [403]: "The domain is associated with an api key that is different than the one in the request, the domain is associated with a different customer, or the domain in the request is an alias domain.",
1804
+ [404]: `The domain '${domain}' was not found.`
1813
1805
  });
1814
1806
  }
1815
1807
  }).catch((e) => {
@@ -1831,9 +1823,9 @@ var Domains = class {
1831
1823
  }
1832
1824
  const response = await this.mailchannels.get(`/inbound/v1/domains/${domain}/login-link`, { onResponseError: async ({ response }) => {
1833
1825
  error = getStatusError(response, {
1834
- [ErrorCode.Unauthorized]: "The domain does not belong to this customer.",
1835
- [ErrorCode.Forbidden]: "The domain is associated with an api key that is different than the one in the request, the domain is associated with a different customer, or the domain in the request is an alias domain.",
1836
- [ErrorCode.NotFound]: `The domain '${domain}' was not found.`
1826
+ [401]: "The domain does not belong to this customer.",
1827
+ [403]: "The domain is associated with an api key that is different than the one in the request, the domain is associated with a different customer, or the domain in the request is an alias domain.",
1828
+ [404]: `The domain '${domain}' was not found.`
1837
1829
  });
1838
1830
  } }).catch((e) => {
1839
1831
  error ||= getResultError(e, "Failed to create login link.");
@@ -1875,8 +1867,8 @@ var Domains = class {
1875
1867
  body: { records },
1876
1868
  onResponseError: async ({ response }) => {
1877
1869
  error = getStatusError(response, {
1878
- [ErrorCode.Forbidden]: "The domain is associated with an api key that is different than the one in the request, the domain is associated with a different customer, or the domain in the request is an alias domain.",
1879
- [ErrorCode.NotFound]: `The domain '${domain}' was not found.`
1870
+ [403]: "The domain is associated with an api key that is different than the one in the request, the domain is associated with a different customer, or the domain in the request is an alias domain.",
1871
+ [404]: `The domain '${domain}' was not found.`
1880
1872
  });
1881
1873
  }
1882
1874
  }).catch((e) => {
@@ -1905,8 +1897,8 @@ var Domains = class {
1905
1897
  query: options,
1906
1898
  onResponseError: async ({ response }) => {
1907
1899
  error = getStatusError(response, {
1908
- [ErrorCode.Forbidden]: "The domain is associated with an api key that is different than the one in the request, the domain is associated with a different customer, or the domain in the request is an alias domain.",
1909
- [ErrorCode.NotFound]: `The domain '${domain}' was not found.`
1900
+ [403]: "The domain is associated with an api key that is different than the one in the request, the domain is associated with a different customer, or the domain in the request is an alias domain.",
1901
+ [404]: `The domain '${domain}' was not found.`
1910
1902
  });
1911
1903
  }
1912
1904
  }).catch((e) => {
@@ -1942,8 +1934,8 @@ var Domains = class {
1942
1934
  body: { apiKey: key },
1943
1935
  onResponseError: async ({ response }) => {
1944
1936
  error = getStatusError(response, {
1945
- [ErrorCode.Forbidden]: "The domain is associated with an api key that is different than the one in the request, the domain is associated with a different customer, or the domain in the request is an alias domain.",
1946
- [ErrorCode.NotFound]: "The domain does not exist."
1937
+ [403]: "The domain is associated with an api key that is different than the one in the request, the domain is associated with a different customer, or the domain in the request is an alias domain.",
1938
+ [404]: "The domain does not exist."
1947
1939
  });
1948
1940
  }
1949
1941
  }).catch((e) => {
@@ -1973,7 +1965,7 @@ var Domains = class {
1973
1965
  const response = await this.mailchannels.post("/inbound/v1/domains/batch/login-link", {
1974
1966
  body: { domains: domains.map((domain) => ({ domain })) },
1975
1967
  onResponseError: async ({ response }) => {
1976
- error = getStatusError(response, { [ErrorCode.BadRequest]: "Bad Request." });
1968
+ error = getStatusError(response, { [400]: "Bad Request." });
1977
1969
  }
1978
1970
  }).catch((e) => {
1979
1971
  error ||= getResultError(e, "Failed to create login links.");
@@ -2099,7 +2091,7 @@ var Users = class {
2099
2091
  },
2100
2092
  body: { list_entries: listEntries },
2101
2093
  onResponseError: async ({ response }) => {
2102
- error = getStatusError(response, { [ErrorCode.BadRequest]: `The email address '${email}' is invalid.` });
2094
+ error = getStatusError(response, { [400]: `The email address '${email}' is invalid.` });
2103
2095
  }
2104
2096
  }).catch((e) => {
2105
2097
  error ||= getResultError(e, "Failed to create user.");
@@ -2144,8 +2136,8 @@ var Users = class {
2144
2136
  body: { item },
2145
2137
  onResponseError: async ({ response }) => {
2146
2138
  error = getStatusError(response, {
2147
- [ErrorCode.Forbidden]: "The domain is associated with an api key that is different than the one in the request, the domain is associated with a different customer, or the domain in the request is an alias domain.",
2148
- [ErrorCode.NotFound]: `The recipient '${email}' was not found.`
2139
+ [403]: "The domain is associated with an api key that is different than the one in the request, the domain is associated with a different customer, or the domain in the request is an alias domain.",
2140
+ [404]: `The recipient '${email}' was not found.`
2149
2141
  });
2150
2142
  }
2151
2143
  }).catch((e) => {
@@ -2183,8 +2175,8 @@ var Users = class {
2183
2175
  }
2184
2176
  const response = await this.mailchannels.get(`/inbound/v1/users/${email}/lists/${listName}`, { onResponseError: async ({ response }) => {
2185
2177
  error = getStatusError(response, {
2186
- [ErrorCode.Forbidden]: "The domain is associated with an api key that is different than the one in the request, the domain is associated with a different customer, or the domain in the request is an alias domain.",
2187
- [ErrorCode.NotFound]: `The recipient '${email}' was not found.`
2178
+ [403]: "The domain is associated with an api key that is different than the one in the request, the domain is associated with a different customer, or the domain in the request is an alias domain.",
2179
+ [404]: `The recipient '${email}' was not found.`
2188
2180
  });
2189
2181
  } }).catch((e) => {
2190
2182
  error ||= getResultError(e, "Failed to fetch user list entries.");
@@ -2224,8 +2216,8 @@ var Users = class {
2224
2216
  query: { item },
2225
2217
  onResponseError: async ({ response }) => {
2226
2218
  error = getStatusError(response, {
2227
- [ErrorCode.Forbidden]: "The domain is associated with an api key that is different than the one in the request, the domain is associated with a different customer, or the domain in the request is an alias domain.",
2228
- [ErrorCode.NotFound]: `The recipient '${email}' was not found.`
2219
+ [403]: "The domain is associated with an api key that is different than the one in the request, the domain is associated with a different customer, or the domain in the request is an alias domain.",
2220
+ [404]: `The recipient '${email}' was not found.`
2229
2221
  });
2230
2222
  }
2231
2223
  }).catch((e) => {
@@ -2256,7 +2248,7 @@ var Service = class {
2256
2248
  async subscriptions() {
2257
2249
  let error = null;
2258
2250
  const response = await this.mailchannels.get("/inbound/v1/subscriptions", { onResponseError: async ({ response }) => {
2259
- error = getStatusError(response, { [ErrorCode.NotFound]: "We could not find a customer that matched the customerHandle." });
2251
+ error = getStatusError(response, { [404]: "We could not find a customer that matched the customerHandle." });
2260
2252
  } }).catch((e) => {
2261
2253
  error ||= getResultError(e, "Failed to fetch subscriptions.");
2262
2254
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mailchannels-sdk",
3
- "version": "0.7.8",
3
+ "version": "0.7.10",
4
4
  "description": "Node.js SDK to integrate MailChannels API into your JavaScript or TypeScript server-side applications.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,17 +40,17 @@
40
40
  "@stylistic/eslint-plugin": "^5.10.0",
41
41
  "@types/markdown-it": "^14.1.2",
42
42
  "@types/node": "^25.6.0",
43
- "@vitest/coverage-v8": "^4.1.4",
43
+ "@vitest/coverage-v8": "^4.1.5",
44
44
  "changelogen": "^0.6.2",
45
45
  "jiti": "^2.6.1",
46
46
  "obuild": "^0.4.33",
47
- "oxlint": "^1.59.0",
47
+ "oxlint": "^1.62.0",
48
48
  "scule": "^1.3.0",
49
- "typescript": "^6.0.2",
49
+ "typescript": "^6.0.3",
50
50
  "vitepress": "^2.0.0-alpha.17",
51
- "vitepress-plugin-group-icons": "^1.7.3",
52
- "vitepress-plugin-llms": "^1.12.0",
53
- "vitest": "^4.1.4"
51
+ "vitepress-plugin-group-icons": "^1.7.5",
52
+ "vitepress-plugin-llms": "^1.12.1",
53
+ "vitest": "^4.1.5"
54
54
  },
55
55
  "scripts": {
56
56
  "build": "obuild",