@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.js CHANGED
@@ -1,3 +1,8 @@
1
+ const AUDIENCE_MEMBER_STATUSES = {
2
+ SUBSCRIBED: 'subscribed',
3
+ UNSUBSCRIBED: 'unsubscribed'
4
+ };
5
+
1
6
  const BROADCAST_STATUSES = {
2
7
  SCHEDULED: 'scheduled',
3
8
  QUEUED: 'queued',
@@ -6,8 +11,20 @@ const BROADCAST_STATUSES = {
6
11
  CANCELLED: 'cancelled',
7
12
  FAILED: 'failed'
8
13
  };
14
+ const BROADCAST_RECIPIENT_FILTERS = {
15
+ PENDING: 'pending',
16
+ SENT: 'sent',
17
+ DELIVERED: 'delivered',
18
+ OPENED: 'opened',
19
+ NOT_OPENED: 'not_opened',
20
+ CLICKED: 'clicked',
21
+ BOUNCED: 'bounced',
22
+ COMPLAINED: 'complained',
23
+ FAILED: 'failed',
24
+ UNSUBSCRIBED: 'unsubscribed'
25
+ };
9
26
 
10
- var version = "0.0.3";
27
+ var version = "0.0.5";
11
28
 
12
29
  const BUILD_BASE_URL = 'https://api.openemail.uk';
13
30
 
@@ -74,6 +91,18 @@ const CONTACT_PHOTO_TYPES = {
74
91
  GIF: 'image/gif'
75
92
  };
76
93
 
94
+ const DOMAIN_RECORD_STATUSES = {
95
+ FOUND: 'found',
96
+ MISSING: 'missing'
97
+ };
98
+ const DOMAIN_DMARC_STAGES = {
99
+ MISSING: 'missing',
100
+ INVALID: 'invalid',
101
+ MONITOR: 'monitor',
102
+ QUARANTINE: 'quarantine',
103
+ REJECT: 'reject'
104
+ };
105
+
77
106
  const MESSAGE_ENCRYPTION_FORMATS = {
78
107
  PGP_MIME: 'pgp-mime',
79
108
  PGP_SIGNED: 'pgp-signed',
@@ -139,6 +168,10 @@ const FILE_USAGES = {
139
168
  LINKED: 'linked',
140
169
  SCHEDULED: 'scheduled'
141
170
  };
171
+ const FILE_VISIBILITIES = {
172
+ PUBLIC: 'public',
173
+ PRIVATE: 'private'
174
+ };
142
175
 
143
176
  const HTTP_METHODS = {
144
177
  GET: 'GET',
@@ -450,6 +483,8 @@ const QUERY_KEYS = {
450
483
  REASSIGN_TO: 'reassignTo',
451
484
  SOURCE: 'source',
452
485
  ADDRESS: 'address',
486
+ DIRECTION: 'direction',
487
+ FILTER: 'filter',
453
488
  SEARCH: 'search',
454
489
  SORT: 'sort',
455
490
  PAGE: 'page',
@@ -563,8 +598,10 @@ const SEGMENTS = {
563
598
  REVOKE: 'revoke',
564
599
  ROTATE: 'rotate',
565
600
  ROTATE_SECRET: 'rotate-secret',
601
+ RECIPIENTS: 'recipients',
566
602
  SEND: 'send',
567
603
  SENDS: 'sends',
604
+ STATS: 'stats',
568
605
  SNOOZE: 'snooze',
569
606
  START: 'start',
570
607
  TEST: 'test',
@@ -573,6 +610,7 @@ const SEGMENTS = {
573
610
  TRASH: 'trash',
574
611
  UNSNOOZE: 'unsnooze',
575
612
  UPLOAD: 'upload',
613
+ VERIFY: 'verify',
576
614
  VERSIONS: 'versions'
577
615
  };
578
616
 
@@ -639,6 +677,8 @@ const API_SCOPES = {
639
677
  DRAFTS_WRITE: 'drafts:write',
640
678
  THREADS_READ: 'threads:read',
641
679
  THREADS_WRITE: 'threads:write',
680
+ FILES_READ: 'files:read',
681
+ FILES_WRITE: 'files:write',
642
682
  LABELS_READ: 'labels:read',
643
683
  LABELS_WRITE: 'labels:write',
644
684
  CONTACTS_READ: 'contacts:read',
@@ -700,7 +740,9 @@ const WEBHOOK_EVENTS = {
700
740
  DOMAIN_SENDING_CHANGED: 'domain.sending_changed',
701
741
  DOMAIN_DELETED: 'domain.deleted',
702
742
  SUPPRESSION_ADDED: 'suppression.added',
703
- SUPPRESSION_REMOVED: 'suppression.removed'
743
+ SUPPRESSION_REMOVED: 'suppression.removed',
744
+ FILE_UPLOADED: 'file.uploaded',
745
+ FILE_DELETED: 'file.deleted'
704
746
  };
705
747
  const WEBHOOK_REPLAY_ERROR_CODES = {
706
748
  RESOURCE_NOT_FOUND: 'resource_not_found',
@@ -1316,7 +1358,11 @@ const AudienceContactsChildPath = (id, segment) => `${AudienceContactsPath(id)}/
1316
1358
  const AudienceContactPath = (id, email) => `${AudienceContactsPath(id)}/${Segment(email)}`;
1317
1359
  const BroadcastPath = (id) => `${PATHS.BROADCASTS}/${Segment(id)}`;
1318
1360
  const BroadcastChildPath = (id, segment) => `${BroadcastPath(id)}/${segment}`;
1361
+ const BroadcastRecipientPath = (id, emailId) => `${BroadcastChildPath(id, SEGMENTS.RECIPIENTS)}/${Segment(emailId)}`;
1319
1362
  const DomainPath = (id) => `${PATHS.DOMAINS}/${Segment(id)}`;
1363
+ const DomainChildPath = (id, segment) => `${DomainPath(id)}/${segment}`;
1364
+ const DomainAddressesPath = (id) => `${DomainPath(id)}/${SEGMENTS.ADDRESSES}`;
1365
+ const DomainAddressPath = (id, addressId) => `${DomainAddressesPath(id)}/${Segment(addressId)}`;
1320
1366
  const WebhookPath = (id) => `${PATHS.WEBHOOKS}/${Segment(id)}`;
1321
1367
  const WebhookChildPath = (id, segment) => `${WebhookPath(id)}/${segment}`;
1322
1368
  const WebhookDeliveryPath = (id, deliveryId) => `${WebhookChildPath(id, SEGMENTS.DELIVERIES)}/${Segment(deliveryId)}`;
@@ -1348,6 +1394,7 @@ const MemberInvitationResendPath = (id) => `${MemberInvitationPath(id)}/${SEGMEN
1348
1394
  const SuppressionPath = (id) => `${PATHS.SUPPRESSIONS}/${Segment(id)}`;
1349
1395
  const FilePath = (id) => `${PATHS.FILES}/${Segment(id)}`;
1350
1396
  const FileChildPath = (id, segment) => `${FilePath(id)}/${segment}`;
1397
+ const FileLinkPath = (id, linkId) => `${FileChildPath(id, SEGMENTS.LINKS)}/${Segment(linkId)}`;
1351
1398
  const TempInboxPath = (id) => `${PATHS.TEMP_MAIL_INBOXES}/${Segment(id)}`;
1352
1399
  const TempInboxExtendPath = (id) => `${TempInboxPath(id)}/${SEGMENTS.EXTEND}`;
1353
1400
  const TempMessagesPath = (id) => `${TempInboxPath(id)}/${SEGMENTS.MESSAGES}`;
@@ -1388,7 +1435,8 @@ const Addresses = (transport) => {
1388
1435
  const MemberQuery = (options) => ({
1389
1436
  [QUERY_KEYS.Q]: options.q,
1390
1437
  [QUERY_KEYS.SOURCE]: options.source,
1391
- [QUERY_KEYS.SORT]: options.sort
1438
+ [QUERY_KEYS.SORT]: options.sort,
1439
+ [QUERY_KEYS.STATUS]: options.statuses?.length ? options.statuses.join(LIST_SEPARATOR) : undefined
1392
1440
  });
1393
1441
  const GrowthQuery = (options) => ({
1394
1442
  [QUERY_KEYS.AUDIENCE_IDS]: options.audienceIds?.join(LIST_SEPARATOR),
@@ -1510,6 +1558,11 @@ const ToInstant = Instant;
1510
1558
  const ListQuery$a = (options) => ({
1511
1559
  [QUERY_KEYS.AUDIENCE_ID]: options.audienceId
1512
1560
  });
1561
+ const RecipientQuery = (options) => ({
1562
+ [QUERY_KEYS.FILTER]: options.filter,
1563
+ [QUERY_KEYS.Q]: options.q
1564
+ });
1565
+ const RecipientsPath = (id) => BroadcastChildPath(id, SEGMENTS.RECIPIENTS);
1513
1566
  const Broadcasts = (transport) => ({
1514
1567
  preview: (body, options = {}) => transport.request(PATHS.BROADCASTS_PREVIEW, {
1515
1568
  method: HTTP_METHODS.POST,
@@ -1531,6 +1584,21 @@ const Broadcasts = (transport) => ({
1531
1584
  listAll: (options = {}) => CollectAll(transport, PATHS.BROADCASTS, CURSOR_STYLES.CURSOR, options, ListQuery$a(options)),
1532
1585
  iterate: (options = {}) => IteratePages(transport, PATHS.BROADCASTS, CURSOR_STYLES.CURSOR, options, ListQuery$a(options)),
1533
1586
  get: (id, options = {}) => transport.request(BroadcastPath(id), { signal: options.signal, apiKey: options.apiKey }),
1587
+ listRecipients: (id, options = {}) => FetchPage(transport, RecipientsPath(id), CURSOR_STYLES.CURSOR, options, RecipientQuery(options)),
1588
+ listAllRecipients: (id, options = {}) => CollectAll(transport, RecipientsPath(id), CURSOR_STYLES.CURSOR, options, RecipientQuery(options)),
1589
+ iterateRecipients: (id, options = {}) => IteratePages(transport, RecipientsPath(id), CURSOR_STYLES.CURSOR, options, RecipientQuery(options)),
1590
+ getRecipient: (id, emailId, options = {}) => transport.request(BroadcastRecipientPath(id, emailId), {
1591
+ signal: options.signal,
1592
+ apiKey: options.apiKey
1593
+ }),
1594
+ stats: (id, options = {}) => transport.request(BroadcastChildPath(id, SEGMENTS.STATS), {
1595
+ query: {
1596
+ [QUERY_KEYS.GRAIN]: options.grain,
1597
+ [QUERY_KEYS.OFFSET_MINUTES]: options.offsetMinutes
1598
+ },
1599
+ signal: options.signal,
1600
+ apiKey: options.apiKey
1601
+ }),
1534
1602
  cancel: (id, options = {}) => transport.request(BroadcastChildPath(id, SEGMENTS.CANCEL), {
1535
1603
  method: HTTP_METHODS.POST,
1536
1604
  repeatable: true,
@@ -1686,12 +1754,52 @@ const Domains = (transport) => ({
1686
1754
  listAll: (options = {}) => CollectAll(transport, PATHS.DOMAINS, CURSOR_STYLES.CURSOR, options),
1687
1755
  iterate: (options = {}) => IteratePages(transport, PATHS.DOMAINS, CURSOR_STYLES.CURSOR, options),
1688
1756
  get: (id, options = {}) => transport.request(DomainPath(id), { signal: options.signal, apiKey: options.apiKey }),
1757
+ create: (body, options = {}) => transport.request(PATHS.DOMAINS, {
1758
+ method: HTTP_METHODS.POST,
1759
+ body,
1760
+ signal: options.signal,
1761
+ apiKey: options.apiKey
1762
+ }),
1763
+ verify: (id, options = {}) => transport.request(DomainChildPath(id, SEGMENTS.VERIFY), {
1764
+ method: HTTP_METHODS.POST,
1765
+ repeatable: true,
1766
+ signal: options.signal,
1767
+ apiKey: options.apiKey
1768
+ }),
1689
1769
  update: (id, patch, options = {}) => transport.request(DomainPath(id), {
1690
1770
  method: HTTP_METHODS.PATCH,
1691
1771
  body: patch,
1692
1772
  repeatable: true,
1693
1773
  signal: options.signal,
1694
1774
  apiKey: options.apiKey
1775
+ }),
1776
+ delete: (id, options = {}) => transport.request(DomainPath(id), {
1777
+ method: HTTP_METHODS.DELETE,
1778
+ signal: options.signal,
1779
+ apiKey: options.apiKey
1780
+ }),
1781
+ listAddresses: (id, options = {}) => FetchPage(transport, DomainAddressesPath(id), CURSOR_STYLES.CURSOR, options),
1782
+ listAllAddresses: (id, options = {}) => CollectAll(transport, DomainAddressesPath(id), CURSOR_STYLES.CURSOR, options),
1783
+ iterateAddresses: (id, options = {}) => IteratePages(transport, DomainAddressesPath(id), CURSOR_STYLES.CURSOR, options),
1784
+ createAddress: (id, body, options = {}) => transport.request(DomainAddressesPath(id), {
1785
+ method: HTTP_METHODS.POST,
1786
+ body,
1787
+ repeatable: true,
1788
+ signal: options.signal,
1789
+ apiKey: options.apiKey
1790
+ }),
1791
+ getAddress: (id, addressId, options = {}) => transport.request(DomainAddressPath(id, addressId), { signal: options.signal, apiKey: options.apiKey }),
1792
+ updateAddress: (id, addressId, patch, options = {}) => transport.request(DomainAddressPath(id, addressId), {
1793
+ method: HTTP_METHODS.PATCH,
1794
+ body: patch,
1795
+ repeatable: true,
1796
+ signal: options.signal,
1797
+ apiKey: options.apiKey
1798
+ }),
1799
+ deleteAddress: (id, addressId, options = {}) => transport.request(DomainAddressPath(id, addressId), {
1800
+ method: HTTP_METHODS.DELETE,
1801
+ signal: options.signal,
1802
+ apiKey: options.apiKey
1695
1803
  })
1696
1804
  });
1697
1805
 
@@ -1779,6 +1887,10 @@ const Emails = (transport) => ({
1779
1887
  const ListQuery$6 = (options) => ({
1780
1888
  [QUERY_KEYS.Q]: options.q,
1781
1889
  [QUERY_KEYS.KIND]: options.kind,
1890
+ [QUERY_KEYS.DIRECTION]: options.direction,
1891
+ [QUERY_KEYS.ADDRESS]: options.address,
1892
+ [QUERY_KEYS.SINCE]: ToInstant(options.since),
1893
+ [QUERY_KEYS.UNTIL]: ToInstant(options.until),
1782
1894
  [QUERY_KEYS.SORT]: options.sort
1783
1895
  });
1784
1896
  const UploadName = (options) => {
@@ -1811,6 +1923,18 @@ const Files = (transport) => ({
1811
1923
  listLinks: (id, options = {}) => FetchPage(transport, FileChildPath(id, SEGMENTS.LINKS), CURSOR_STYLES.CURSOR, options),
1812
1924
  listAllLinks: (id, options = {}) => CollectAll(transport, FileChildPath(id, SEGMENTS.LINKS), CURSOR_STYLES.CURSOR, options),
1813
1925
  iterateLinks: (id, options = {}) => IteratePages(transport, FileChildPath(id, SEGMENTS.LINKS), CURSOR_STYLES.CURSOR, options),
1926
+ createLink: (id, options = {}) => transport.request(FileChildPath(id, SEGMENTS.LINKS), {
1927
+ method: HTTP_METHODS.POST,
1928
+ body: options.domain ? { domain: options.domain } : {},
1929
+ signal: options.signal,
1930
+ apiKey: options.apiKey
1931
+ }),
1932
+ revokeLink: (id, linkId, options = {}) => transport.request(FileLinkPath(id, linkId), {
1933
+ method: HTTP_METHODS.DELETE,
1934
+ repeatable: true,
1935
+ signal: options.signal,
1936
+ apiKey: options.apiKey
1937
+ }),
1814
1938
  upload: (data, options) => transport.request(PATHS.FILES, {
1815
1939
  method: HTTP_METHODS.POST,
1816
1940
  query: { [QUERY_KEYS.FILENAME]: UploadName(options) },
@@ -2788,4 +2912,4 @@ const resolveLanguage = ResolveLanguage;
2788
2912
  const languageByCode = LanguageByCode;
2789
2913
  const isRtlLanguage = IsRtlLanguage;
2790
2914
 
2791
- export { API_SCOPES, BROADCAST_STATUSES, CONTACT_BLOCK_LISTS, CONTACT_PHOTO_TYPES, CONTACT_THREAD_SORTS, ERROR_TYPES, FILE_DIRECTIONS, FILE_KINDS, FILE_SORTS, FILE_USAGES, LANGUAGES, MESSAGE_ENCRYPTION_FORMATS, OpenEmail, OpenEmailApiError, OpenEmailNetworkError, PAGE_LIMITS, PEOPLE_SORTS, PROVIDER_IMPORT_DOMAIN_STATES, PROVIDER_IMPORT_RESOURCES, PROVIDER_IMPORT_STATUSES, RULE_ACTIONS, RULE_FIELDS, RULE_OPERATORS, SUPPRESSION_REASONS, THREAD_SORTS, VERSION, WEBHOOK_EVENTS, WEBHOOK_REPLAY_ERROR_CODES, WEBHOOK_SIGNATURE_HEADERS, createClient, createOpenEmail, createTempMail, OpenEmail as default, getClient, init, isApiKey, isRtlLanguage, isSealed, languageByCode, openemail, resetClient, resolveLanguage, toBase64, verifyWebhookSignature };
2915
+ export { API_SCOPES, AUDIENCE_MEMBER_STATUSES, BROADCAST_RECIPIENT_FILTERS, BROADCAST_STATUSES, CONTACT_BLOCK_LISTS, CONTACT_PHOTO_TYPES, CONTACT_THREAD_SORTS, DOMAIN_DMARC_STAGES, DOMAIN_RECORD_STATUSES, ERROR_TYPES, FILE_DIRECTIONS, FILE_KINDS, FILE_SORTS, FILE_USAGES, FILE_VISIBILITIES, LANGUAGES, MESSAGE_ENCRYPTION_FORMATS, OpenEmail, OpenEmailApiError, OpenEmailNetworkError, PAGE_LIMITS, PEOPLE_SORTS, PROVIDER_IMPORT_DOMAIN_STATES, PROVIDER_IMPORT_RESOURCES, PROVIDER_IMPORT_STATUSES, RULE_ACTIONS, RULE_FIELDS, RULE_OPERATORS, SUPPRESSION_REASONS, THREAD_SORTS, VERSION, WEBHOOK_EVENTS, WEBHOOK_REPLAY_ERROR_CODES, WEBHOOK_SIGNATURE_HEADERS, createClient, createOpenEmail, createTempMail, OpenEmail as default, getClient, init, isApiKey, isRtlLanguage, isSealed, languageByCode, openemail, resetClient, resolveLanguage, toBase64, verifyWebhookSignature };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openemail/sdk",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "author": "OpenEmail",
5
5
  "license": "UNLICENSED",
6
6
  "description": "The official TypeScript SDK for the OpenEmail API. Send email and broadcasts, work with threads, drafts, labels, templates, rules, webhooks, tracking, contacts, audiences, domains, suppressions, files, API keys, roles, members, mailbox imports and disposable inboxes from code.",