@openemail/sdk 0.0.3 → 0.0.5

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 (5) hide show
  1. package/index.cjs +132 -3
  2. package/index.d.cts +283 -64
  3. package/index.d.ts +283 -64
  4. package/index.js +128 -4
  5. package/package.json +1 -1
package/index.cjs CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ const AUDIENCE_MEMBER_STATUSES = {
6
+ SUBSCRIBED: 'subscribed',
7
+ UNSUBSCRIBED: 'unsubscribed'
8
+ };
9
+
5
10
  const BROADCAST_STATUSES = {
6
11
  SCHEDULED: 'scheduled',
7
12
  QUEUED: 'queued',
@@ -10,8 +15,20 @@ const BROADCAST_STATUSES = {
10
15
  CANCELLED: 'cancelled',
11
16
  FAILED: 'failed'
12
17
  };
18
+ const BROADCAST_RECIPIENT_FILTERS = {
19
+ PENDING: 'pending',
20
+ SENT: 'sent',
21
+ DELIVERED: 'delivered',
22
+ OPENED: 'opened',
23
+ NOT_OPENED: 'not_opened',
24
+ CLICKED: 'clicked',
25
+ BOUNCED: 'bounced',
26
+ COMPLAINED: 'complained',
27
+ FAILED: 'failed',
28
+ UNSUBSCRIBED: 'unsubscribed'
29
+ };
13
30
 
14
- var version = "0.0.3";
31
+ var version = "0.0.5";
15
32
 
16
33
  const BUILD_BASE_URL = 'https://api.openemail.uk';
17
34
 
@@ -78,6 +95,18 @@ const CONTACT_PHOTO_TYPES = {
78
95
  GIF: 'image/gif'
79
96
  };
80
97
 
98
+ const DOMAIN_RECORD_STATUSES = {
99
+ FOUND: 'found',
100
+ MISSING: 'missing'
101
+ };
102
+ const DOMAIN_DMARC_STAGES = {
103
+ MISSING: 'missing',
104
+ INVALID: 'invalid',
105
+ MONITOR: 'monitor',
106
+ QUARANTINE: 'quarantine',
107
+ REJECT: 'reject'
108
+ };
109
+
81
110
  const MESSAGE_ENCRYPTION_FORMATS = {
82
111
  PGP_MIME: 'pgp-mime',
83
112
  PGP_SIGNED: 'pgp-signed',
@@ -143,6 +172,10 @@ const FILE_USAGES = {
143
172
  LINKED: 'linked',
144
173
  SCHEDULED: 'scheduled'
145
174
  };
175
+ const FILE_VISIBILITIES = {
176
+ PUBLIC: 'public',
177
+ PRIVATE: 'private'
178
+ };
146
179
 
147
180
  const HTTP_METHODS = {
148
181
  GET: 'GET',
@@ -454,6 +487,8 @@ const QUERY_KEYS = {
454
487
  REASSIGN_TO: 'reassignTo',
455
488
  SOURCE: 'source',
456
489
  ADDRESS: 'address',
490
+ DIRECTION: 'direction',
491
+ FILTER: 'filter',
457
492
  SEARCH: 'search',
458
493
  SORT: 'sort',
459
494
  PAGE: 'page',
@@ -567,8 +602,10 @@ const SEGMENTS = {
567
602
  REVOKE: 'revoke',
568
603
  ROTATE: 'rotate',
569
604
  ROTATE_SECRET: 'rotate-secret',
605
+ RECIPIENTS: 'recipients',
570
606
  SEND: 'send',
571
607
  SENDS: 'sends',
608
+ STATS: 'stats',
572
609
  SNOOZE: 'snooze',
573
610
  START: 'start',
574
611
  TEST: 'test',
@@ -577,6 +614,7 @@ const SEGMENTS = {
577
614
  TRASH: 'trash',
578
615
  UNSNOOZE: 'unsnooze',
579
616
  UPLOAD: 'upload',
617
+ VERIFY: 'verify',
580
618
  VERSIONS: 'versions'
581
619
  };
582
620
 
@@ -643,6 +681,8 @@ const API_SCOPES = {
643
681
  DRAFTS_WRITE: 'drafts:write',
644
682
  THREADS_READ: 'threads:read',
645
683
  THREADS_WRITE: 'threads:write',
684
+ FILES_READ: 'files:read',
685
+ FILES_WRITE: 'files:write',
646
686
  LABELS_READ: 'labels:read',
647
687
  LABELS_WRITE: 'labels:write',
648
688
  CONTACTS_READ: 'contacts:read',
@@ -704,7 +744,9 @@ const WEBHOOK_EVENTS = {
704
744
  DOMAIN_SENDING_CHANGED: 'domain.sending_changed',
705
745
  DOMAIN_DELETED: 'domain.deleted',
706
746
  SUPPRESSION_ADDED: 'suppression.added',
707
- SUPPRESSION_REMOVED: 'suppression.removed'
747
+ SUPPRESSION_REMOVED: 'suppression.removed',
748
+ FILE_UPLOADED: 'file.uploaded',
749
+ FILE_DELETED: 'file.deleted'
708
750
  };
709
751
  const WEBHOOK_REPLAY_ERROR_CODES = {
710
752
  RESOURCE_NOT_FOUND: 'resource_not_found',
@@ -1320,7 +1362,11 @@ const AudienceContactsChildPath = (id, segment) => `${AudienceContactsPath(id)}/
1320
1362
  const AudienceContactPath = (id, email) => `${AudienceContactsPath(id)}/${Segment(email)}`;
1321
1363
  const BroadcastPath = (id) => `${PATHS.BROADCASTS}/${Segment(id)}`;
1322
1364
  const BroadcastChildPath = (id, segment) => `${BroadcastPath(id)}/${segment}`;
1365
+ const BroadcastRecipientPath = (id, emailId) => `${BroadcastChildPath(id, SEGMENTS.RECIPIENTS)}/${Segment(emailId)}`;
1323
1366
  const DomainPath = (id) => `${PATHS.DOMAINS}/${Segment(id)}`;
1367
+ const DomainChildPath = (id, segment) => `${DomainPath(id)}/${segment}`;
1368
+ const DomainAddressesPath = (id) => `${DomainPath(id)}/${SEGMENTS.ADDRESSES}`;
1369
+ const DomainAddressPath = (id, addressId) => `${DomainAddressesPath(id)}/${Segment(addressId)}`;
1324
1370
  const WebhookPath = (id) => `${PATHS.WEBHOOKS}/${Segment(id)}`;
1325
1371
  const WebhookChildPath = (id, segment) => `${WebhookPath(id)}/${segment}`;
1326
1372
  const WebhookDeliveryPath = (id, deliveryId) => `${WebhookChildPath(id, SEGMENTS.DELIVERIES)}/${Segment(deliveryId)}`;
@@ -1352,6 +1398,7 @@ const MemberInvitationResendPath = (id) => `${MemberInvitationPath(id)}/${SEGMEN
1352
1398
  const SuppressionPath = (id) => `${PATHS.SUPPRESSIONS}/${Segment(id)}`;
1353
1399
  const FilePath = (id) => `${PATHS.FILES}/${Segment(id)}`;
1354
1400
  const FileChildPath = (id, segment) => `${FilePath(id)}/${segment}`;
1401
+ const FileLinkPath = (id, linkId) => `${FileChildPath(id, SEGMENTS.LINKS)}/${Segment(linkId)}`;
1355
1402
  const TempInboxPath = (id) => `${PATHS.TEMP_MAIL_INBOXES}/${Segment(id)}`;
1356
1403
  const TempInboxExtendPath = (id) => `${TempInboxPath(id)}/${SEGMENTS.EXTEND}`;
1357
1404
  const TempMessagesPath = (id) => `${TempInboxPath(id)}/${SEGMENTS.MESSAGES}`;
@@ -1392,7 +1439,8 @@ const Addresses = (transport) => {
1392
1439
  const MemberQuery = (options) => ({
1393
1440
  [QUERY_KEYS.Q]: options.q,
1394
1441
  [QUERY_KEYS.SOURCE]: options.source,
1395
- [QUERY_KEYS.SORT]: options.sort
1442
+ [QUERY_KEYS.SORT]: options.sort,
1443
+ [QUERY_KEYS.STATUS]: options.statuses?.length ? options.statuses.join(LIST_SEPARATOR) : undefined
1396
1444
  });
1397
1445
  const GrowthQuery = (options) => ({
1398
1446
  [QUERY_KEYS.AUDIENCE_IDS]: options.audienceIds?.join(LIST_SEPARATOR),
@@ -1514,6 +1562,11 @@ const ToInstant = Instant;
1514
1562
  const ListQuery$a = (options) => ({
1515
1563
  [QUERY_KEYS.AUDIENCE_ID]: options.audienceId
1516
1564
  });
1565
+ const RecipientQuery = (options) => ({
1566
+ [QUERY_KEYS.FILTER]: options.filter,
1567
+ [QUERY_KEYS.Q]: options.q
1568
+ });
1569
+ const RecipientsPath = (id) => BroadcastChildPath(id, SEGMENTS.RECIPIENTS);
1517
1570
  const Broadcasts = (transport) => ({
1518
1571
  preview: (body, options = {}) => transport.request(PATHS.BROADCASTS_PREVIEW, {
1519
1572
  method: HTTP_METHODS.POST,
@@ -1535,6 +1588,21 @@ const Broadcasts = (transport) => ({
1535
1588
  listAll: (options = {}) => CollectAll(transport, PATHS.BROADCASTS, CURSOR_STYLES.CURSOR, options, ListQuery$a(options)),
1536
1589
  iterate: (options = {}) => IteratePages(transport, PATHS.BROADCASTS, CURSOR_STYLES.CURSOR, options, ListQuery$a(options)),
1537
1590
  get: (id, options = {}) => transport.request(BroadcastPath(id), { signal: options.signal, apiKey: options.apiKey }),
1591
+ listRecipients: (id, options = {}) => FetchPage(transport, RecipientsPath(id), CURSOR_STYLES.CURSOR, options, RecipientQuery(options)),
1592
+ listAllRecipients: (id, options = {}) => CollectAll(transport, RecipientsPath(id), CURSOR_STYLES.CURSOR, options, RecipientQuery(options)),
1593
+ iterateRecipients: (id, options = {}) => IteratePages(transport, RecipientsPath(id), CURSOR_STYLES.CURSOR, options, RecipientQuery(options)),
1594
+ getRecipient: (id, emailId, options = {}) => transport.request(BroadcastRecipientPath(id, emailId), {
1595
+ signal: options.signal,
1596
+ apiKey: options.apiKey
1597
+ }),
1598
+ stats: (id, options = {}) => transport.request(BroadcastChildPath(id, SEGMENTS.STATS), {
1599
+ query: {
1600
+ [QUERY_KEYS.GRAIN]: options.grain,
1601
+ [QUERY_KEYS.OFFSET_MINUTES]: options.offsetMinutes
1602
+ },
1603
+ signal: options.signal,
1604
+ apiKey: options.apiKey
1605
+ }),
1538
1606
  cancel: (id, options = {}) => transport.request(BroadcastChildPath(id, SEGMENTS.CANCEL), {
1539
1607
  method: HTTP_METHODS.POST,
1540
1608
  repeatable: true,
@@ -1690,12 +1758,52 @@ const Domains = (transport) => ({
1690
1758
  listAll: (options = {}) => CollectAll(transport, PATHS.DOMAINS, CURSOR_STYLES.CURSOR, options),
1691
1759
  iterate: (options = {}) => IteratePages(transport, PATHS.DOMAINS, CURSOR_STYLES.CURSOR, options),
1692
1760
  get: (id, options = {}) => transport.request(DomainPath(id), { signal: options.signal, apiKey: options.apiKey }),
1761
+ create: (body, options = {}) => transport.request(PATHS.DOMAINS, {
1762
+ method: HTTP_METHODS.POST,
1763
+ body,
1764
+ signal: options.signal,
1765
+ apiKey: options.apiKey
1766
+ }),
1767
+ verify: (id, options = {}) => transport.request(DomainChildPath(id, SEGMENTS.VERIFY), {
1768
+ method: HTTP_METHODS.POST,
1769
+ repeatable: true,
1770
+ signal: options.signal,
1771
+ apiKey: options.apiKey
1772
+ }),
1693
1773
  update: (id, patch, options = {}) => transport.request(DomainPath(id), {
1694
1774
  method: HTTP_METHODS.PATCH,
1695
1775
  body: patch,
1696
1776
  repeatable: true,
1697
1777
  signal: options.signal,
1698
1778
  apiKey: options.apiKey
1779
+ }),
1780
+ delete: (id, options = {}) => transport.request(DomainPath(id), {
1781
+ method: HTTP_METHODS.DELETE,
1782
+ signal: options.signal,
1783
+ apiKey: options.apiKey
1784
+ }),
1785
+ listAddresses: (id, options = {}) => FetchPage(transport, DomainAddressesPath(id), CURSOR_STYLES.CURSOR, options),
1786
+ listAllAddresses: (id, options = {}) => CollectAll(transport, DomainAddressesPath(id), CURSOR_STYLES.CURSOR, options),
1787
+ iterateAddresses: (id, options = {}) => IteratePages(transport, DomainAddressesPath(id), CURSOR_STYLES.CURSOR, options),
1788
+ createAddress: (id, body, options = {}) => transport.request(DomainAddressesPath(id), {
1789
+ method: HTTP_METHODS.POST,
1790
+ body,
1791
+ repeatable: true,
1792
+ signal: options.signal,
1793
+ apiKey: options.apiKey
1794
+ }),
1795
+ getAddress: (id, addressId, options = {}) => transport.request(DomainAddressPath(id, addressId), { signal: options.signal, apiKey: options.apiKey }),
1796
+ updateAddress: (id, addressId, patch, options = {}) => transport.request(DomainAddressPath(id, addressId), {
1797
+ method: HTTP_METHODS.PATCH,
1798
+ body: patch,
1799
+ repeatable: true,
1800
+ signal: options.signal,
1801
+ apiKey: options.apiKey
1802
+ }),
1803
+ deleteAddress: (id, addressId, options = {}) => transport.request(DomainAddressPath(id, addressId), {
1804
+ method: HTTP_METHODS.DELETE,
1805
+ signal: options.signal,
1806
+ apiKey: options.apiKey
1699
1807
  })
1700
1808
  });
1701
1809
 
@@ -1783,6 +1891,10 @@ const Emails = (transport) => ({
1783
1891
  const ListQuery$6 = (options) => ({
1784
1892
  [QUERY_KEYS.Q]: options.q,
1785
1893
  [QUERY_KEYS.KIND]: options.kind,
1894
+ [QUERY_KEYS.DIRECTION]: options.direction,
1895
+ [QUERY_KEYS.ADDRESS]: options.address,
1896
+ [QUERY_KEYS.SINCE]: ToInstant(options.since),
1897
+ [QUERY_KEYS.UNTIL]: ToInstant(options.until),
1786
1898
  [QUERY_KEYS.SORT]: options.sort
1787
1899
  });
1788
1900
  const UploadName = (options) => {
@@ -1815,6 +1927,18 @@ const Files = (transport) => ({
1815
1927
  listLinks: (id, options = {}) => FetchPage(transport, FileChildPath(id, SEGMENTS.LINKS), CURSOR_STYLES.CURSOR, options),
1816
1928
  listAllLinks: (id, options = {}) => CollectAll(transport, FileChildPath(id, SEGMENTS.LINKS), CURSOR_STYLES.CURSOR, options),
1817
1929
  iterateLinks: (id, options = {}) => IteratePages(transport, FileChildPath(id, SEGMENTS.LINKS), CURSOR_STYLES.CURSOR, options),
1930
+ createLink: (id, options = {}) => transport.request(FileChildPath(id, SEGMENTS.LINKS), {
1931
+ method: HTTP_METHODS.POST,
1932
+ body: options.domain ? { domain: options.domain } : {},
1933
+ signal: options.signal,
1934
+ apiKey: options.apiKey
1935
+ }),
1936
+ revokeLink: (id, linkId, options = {}) => transport.request(FileLinkPath(id, linkId), {
1937
+ method: HTTP_METHODS.DELETE,
1938
+ repeatable: true,
1939
+ signal: options.signal,
1940
+ apiKey: options.apiKey
1941
+ }),
1818
1942
  upload: (data, options) => transport.request(PATHS.FILES, {
1819
1943
  method: HTTP_METHODS.POST,
1820
1944
  query: { [QUERY_KEYS.FILENAME]: UploadName(options) },
@@ -2793,15 +2917,20 @@ const languageByCode = LanguageByCode;
2793
2917
  const isRtlLanguage = IsRtlLanguage;
2794
2918
 
2795
2919
  exports.API_SCOPES = API_SCOPES;
2920
+ exports.AUDIENCE_MEMBER_STATUSES = AUDIENCE_MEMBER_STATUSES;
2921
+ exports.BROADCAST_RECIPIENT_FILTERS = BROADCAST_RECIPIENT_FILTERS;
2796
2922
  exports.BROADCAST_STATUSES = BROADCAST_STATUSES;
2797
2923
  exports.CONTACT_BLOCK_LISTS = CONTACT_BLOCK_LISTS;
2798
2924
  exports.CONTACT_PHOTO_TYPES = CONTACT_PHOTO_TYPES;
2799
2925
  exports.CONTACT_THREAD_SORTS = CONTACT_THREAD_SORTS;
2926
+ exports.DOMAIN_DMARC_STAGES = DOMAIN_DMARC_STAGES;
2927
+ exports.DOMAIN_RECORD_STATUSES = DOMAIN_RECORD_STATUSES;
2800
2928
  exports.ERROR_TYPES = ERROR_TYPES;
2801
2929
  exports.FILE_DIRECTIONS = FILE_DIRECTIONS;
2802
2930
  exports.FILE_KINDS = FILE_KINDS;
2803
2931
  exports.FILE_SORTS = FILE_SORTS;
2804
2932
  exports.FILE_USAGES = FILE_USAGES;
2933
+ exports.FILE_VISIBILITIES = FILE_VISIBILITIES;
2805
2934
  exports.LANGUAGES = LANGUAGES;
2806
2935
  exports.MESSAGE_ENCRYPTION_FORMATS = MESSAGE_ENCRYPTION_FORMATS;
2807
2936
  exports.OpenEmail = OpenEmail;