shipmail 0.2.3 → 0.4.1

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.js CHANGED
@@ -1,3 +1,81 @@
1
+ // src/api-key-scopes.ts
2
+ var API_KEY_SCOPES = [
3
+ "*",
4
+ "audiences:read",
5
+ "audiences:write",
6
+ "booking_pages:read",
7
+ "booking_pages:write",
8
+ "calendar:read",
9
+ "calendar:write",
10
+ "domains:read",
11
+ "domains:write",
12
+ "mailboxes:read",
13
+ "mailboxes:export",
14
+ "mailboxes:write",
15
+ "mailbox_credentials:read",
16
+ "mailbox_credentials:write",
17
+ "mailbox_forwarding:read",
18
+ "mailbox_forwarding:write",
19
+ "messages:read",
20
+ "messages:write",
21
+ "drafts:write",
22
+ "messages:send",
23
+ "newsletters:read",
24
+ "newsletters:write",
25
+ "threads:read",
26
+ "webhooks:read",
27
+ "webhooks:write",
28
+ "suppressions:read",
29
+ "suppressions:write",
30
+ "partner:organizations:read",
31
+ "partner:organizations:write",
32
+ "partner:organizations:access",
33
+ "partner:mailbox_credentials:issue",
34
+ "partner:usage:read"
35
+ ];
36
+ var API_KEY_SCOPE_DESCRIPTIONS = {
37
+ "*": "All non-partner API endpoints in this organization.",
38
+ "audiences:read": "List and retrieve newsletter audiences and their subscribers.",
39
+ "audiences:write": "Create audiences and add, update, or remove their subscribers.",
40
+ "booking_pages:read": "List and retrieve booking pages.",
41
+ "booking_pages:write": "Create, update, and delete booking pages.",
42
+ "calendar:read": "List and retrieve calendar events and open availability.",
43
+ "calendar:write": "Create, update, and delete calendar events.",
44
+ "domains:read": "List, retrieve, and verify domains.",
45
+ "domains:write": "Create, update, and delete domains.",
46
+ "mailboxes:read": "List and retrieve mailboxes.",
47
+ "mailboxes:export": "Create and download mailbox content exports.",
48
+ "mailboxes:write": "Create, update, suspend, resume, and delete mailboxes.",
49
+ "mailbox_credentials:read": "List revocable app passwords for allowed mailboxes.",
50
+ "mailbox_credentials:write": "Create and revoke app passwords for allowed mailboxes.",
51
+ "mailbox_forwarding:read": "List forwarding destinations for allowed mailboxes.",
52
+ "mailbox_forwarding:write": "Create and remove forwarding destinations for allowed mailboxes.",
53
+ "messages:read": "List and retrieve messages.",
54
+ "messages:write": "Update, move, delete, and inject sandbox messages.",
55
+ "drafts:write": "Create agent-safe reply drafts with server-derived recipients.",
56
+ "messages:send": "Send messages, replies, and approved reply drafts.",
57
+ "newsletters:read": "List and retrieve newsletter drafts and campaigns.",
58
+ "newsletters:write": "Create, update, test, schedule, cancel, and resume newsletters.",
59
+ "threads:read": "List threads and retrieve thread messages.",
60
+ "webhooks:read": "List webhooks, retrieve webhooks, and list deliveries.",
61
+ "webhooks:write": "Create, update, delete, test, and rotate webhooks.",
62
+ "suppressions:read": "List suppressed recipient addresses.",
63
+ "suppressions:write": "Remove addresses from the suppression list.",
64
+ "partner:organizations:read": "List and retrieve this partner's child organizations.",
65
+ "partner:organizations:write": "Create and manage this partner's child organizations.",
66
+ "partner:organizations:access": "Act on an active child using the delegated organization header.",
67
+ "partner:mailbox_credentials:issue": "List and consume operator-approved grants for embedded-webmail credentials.",
68
+ "partner:usage:read": "Read consolidated child and mailbox usage for this partner."
69
+ };
70
+ function isApiKeyScope(value) {
71
+ return API_KEY_SCOPES.some((scope) => scope === value);
72
+ }
73
+ function apiKeyScopesGrant(grantedScopes, requiredScope) {
74
+ if (requiredScope === "public") return true;
75
+ if (requiredScope.startsWith("partner:")) return grantedScopes.includes(requiredScope);
76
+ return grantedScopes.includes("*") || grantedScopes.includes(requiredScope);
77
+ }
78
+
1
79
  // src/errors.ts
2
80
  var ShipMailError = class extends Error {
3
81
  constructor(message, options) {
@@ -409,6 +487,17 @@ var Calendar = class extends ApiResource {
409
487
  }
410
488
  };
411
489
 
490
+ // src/resources/capabilities.ts
491
+ var Capabilities = class extends ApiResource {
492
+ get(options) {
493
+ return this.client.request({
494
+ method: "GET",
495
+ path: "/capabilities",
496
+ methodOptions: options
497
+ });
498
+ }
499
+ };
500
+
412
501
  // src/resources/domains.ts
413
502
  var Domains = class extends ApiResource {
414
503
  create(params, options) {
@@ -491,6 +580,24 @@ var Domains = class extends ApiResource {
491
580
 
492
581
  // src/resources/mailboxes.ts
493
582
  var Mailboxes = class extends ApiResource {
583
+ prepareStagedAttachmentUpload(id, params, options) {
584
+ return this.client.request({
585
+ method: "POST",
586
+ path: `/mailboxes/${encodeURIComponent(id)}/staged-attachment-upload-tokens`,
587
+ body: params,
588
+ methodOptions: options
589
+ });
590
+ }
591
+ stageAttachment(id, params, options) {
592
+ return this.client.request({
593
+ method: "POST",
594
+ path: `/mailboxes/${encodeURIComponent(id)}/staged-attachments`,
595
+ query: { filename: params.filename },
596
+ rawBody: params.data,
597
+ contentType: params.content_type,
598
+ methodOptions: options
599
+ });
600
+ }
494
601
  injectSandboxInbound(id, params, options) {
495
602
  return this.client.request({
496
603
  method: "POST",
@@ -763,21 +870,6 @@ var Mailboxes = class extends ApiResource {
763
870
  methodOptions: options
764
871
  });
765
872
  }
766
- getRules(id, options) {
767
- return this.client.request({
768
- method: "GET",
769
- path: `/mailboxes/${encodeURIComponent(id)}/rules`,
770
- methodOptions: options
771
- });
772
- }
773
- updateRules(id, params, options) {
774
- return this.client.request({
775
- method: "PUT",
776
- path: `/mailboxes/${encodeURIComponent(id)}/rules`,
777
- body: params,
778
- methodOptions: options
779
- });
780
- }
781
873
  listForwarding(id, options) {
782
874
  return this.client.request({
783
875
  method: "GET",
@@ -1168,6 +1260,44 @@ var ReplyScans = class extends ApiResource {
1168
1260
  }
1169
1261
  };
1170
1262
 
1263
+ // src/resources/scheduled-messages.ts
1264
+ var ScheduledMessages = class extends ApiResource {
1265
+ list(params, options) {
1266
+ return this.client.request({
1267
+ method: "GET",
1268
+ path: "/scheduled-messages",
1269
+ query: {
1270
+ include_held: params?.include_held,
1271
+ search: params?.search,
1272
+ limit: params?.limit
1273
+ },
1274
+ methodOptions: options
1275
+ });
1276
+ }
1277
+ get(id, options) {
1278
+ return this.client.request({
1279
+ method: "GET",
1280
+ path: `/scheduled-messages/${encodeURIComponent(id)}`,
1281
+ methodOptions: options
1282
+ });
1283
+ }
1284
+ update(id, params, options) {
1285
+ return this.client.request({
1286
+ method: "PATCH",
1287
+ path: `/scheduled-messages/${encodeURIComponent(id)}`,
1288
+ body: params,
1289
+ methodOptions: options
1290
+ });
1291
+ }
1292
+ cancel(id, options) {
1293
+ return this.client.request({
1294
+ method: "DELETE",
1295
+ path: `/scheduled-messages/${encodeURIComponent(id)}`,
1296
+ methodOptions: options
1297
+ });
1298
+ }
1299
+ };
1300
+
1171
1301
  // src/resources/status.ts
1172
1302
  var Status = class extends ApiResource {
1173
1303
  get(options) {
@@ -1351,7 +1481,7 @@ var Webhooks = class extends ApiResource {
1351
1481
  };
1352
1482
 
1353
1483
  // src/version.ts
1354
- var VERSION = "0.2.3";
1484
+ var VERSION = "0.4.1";
1355
1485
 
1356
1486
  // src/client.ts
1357
1487
  var DEFAULT_BASE_URL = "https://shipmail.to/api/v1";
@@ -1406,6 +1536,7 @@ var ShipMailClient = class {
1406
1536
  }
1407
1537
  this.audiences = new Audiences(this);
1408
1538
  this.bookingPages = new BookingPages(this);
1539
+ this.capabilities = new Capabilities(this);
1409
1540
  this.calendar = new Calendar(this);
1410
1541
  this.domains = new Domains(this);
1411
1542
  this.mailboxes = new Mailboxes(this);
@@ -1413,6 +1544,7 @@ var ShipMailClient = class {
1413
1544
  this.newsletters = new Newsletters(this);
1414
1545
  this.partner = new Partner(this);
1415
1546
  this.replyScans = new ReplyScans(this);
1547
+ this.scheduledMessages = new ScheduledMessages(this);
1416
1548
  this.suppressions = new Suppressions(this);
1417
1549
  this.threads = new Threads(this);
1418
1550
  this.webhooks = new Webhooks(this);
@@ -1524,7 +1656,6 @@ var WEBHOOK_EVENT_TYPES = [
1524
1656
  "message.bounced",
1525
1657
  "message.complained",
1526
1658
  "thread.needs_reply",
1527
- "mailbox.rule_matched",
1528
1659
  "domain.verified",
1529
1660
  "domain.verification_failed",
1530
1661
  "domain.degraded",
@@ -1552,7 +1683,7 @@ var MESSAGE_SOURCES = [
1552
1683
  "dashboard",
1553
1684
  "inbound",
1554
1685
  "smtp",
1555
- "agent"
1686
+ "assistant"
1556
1687
  ];
1557
1688
  var WEBHOOK_DELIVERY_STATUSES = ["pending", "delivered", "failed"];
1558
1689
 
@@ -1604,6 +1735,6 @@ async function verifyWebhook(body, headers, secret, options) {
1604
1735
  return parsed;
1605
1736
  }
1606
1737
 
1607
- export { AuthenticationError, AuthorizationError, CONFERENCING_PROVIDER_IDS, ConflictError, ConnectionError, DOMAIN_STATUSES, InternalServerError, MESSAGE_SOURCES, MESSAGE_STATUSES, NotFoundError, Page, QuotaExceededError, RateLimitError, ShipMailClient, ShipMailError, ValidationError, WEBHOOK_DELIVERY_EVENT_TYPES, WEBHOOK_DELIVERY_STATUSES, WEBHOOK_EVENT_TYPES, WebhookVerificationError, ShipMailClient as default, verifyWebhook };
1738
+ export { API_KEY_SCOPES, API_KEY_SCOPE_DESCRIPTIONS, AuthenticationError, AuthorizationError, CONFERENCING_PROVIDER_IDS, ConflictError, ConnectionError, DOMAIN_STATUSES, InternalServerError, MESSAGE_SOURCES, MESSAGE_STATUSES, NotFoundError, Page, QuotaExceededError, RateLimitError, ShipMailClient, ShipMailError, ValidationError, WEBHOOK_DELIVERY_EVENT_TYPES, WEBHOOK_DELIVERY_STATUSES, WEBHOOK_EVENT_TYPES, WebhookVerificationError, apiKeyScopesGrant, ShipMailClient as default, isApiKeyScope, verifyWebhook };
1608
1739
  //# sourceMappingURL=index.js.map
1609
1740
  //# sourceMappingURL=index.js.map