@openemail/sdk 0.0.1 → 0.0.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 (6) hide show
  1. package/README.md +4 -4
  2. package/index.cjs +1223 -206
  3. package/index.d.cts +2009 -131
  4. package/index.d.ts +2009 -131
  5. package/index.js +1210 -207
  6. package/package.json +3 -3
package/index.js CHANGED
@@ -1,4 +1,13 @@
1
- var version = "0.0.1";
1
+ const BROADCAST_STATUSES = {
2
+ SCHEDULED: 'scheduled',
3
+ QUEUED: 'queued',
4
+ SENDING: 'sending',
5
+ SENT: 'sent',
6
+ CANCELLED: 'cancelled',
7
+ FAILED: 'failed'
8
+ };
9
+
10
+ var version = "0.0.2";
2
11
 
3
12
  const BUILD_BASE_URL = 'https://api.openemail.uk';
4
13
 
@@ -41,43 +50,59 @@ const CLIENT_MESSAGES = {
41
50
  DOT_SEGMENT: 'is not a usable id: a path segment made only of dots is removed by URL parsers, so the request would reach a different endpoint.'
42
51
  };
43
52
 
44
- const MESSAGE_ENCRYPTION_FORMATS = [
45
- 'pgp-mime',
46
- 'pgp-signed',
47
- 'pgp-inline',
48
- 'smime-encrypted',
49
- 'smime-signed'
53
+ const PEOPLE_SORTS = {
54
+ RECENT: 'recent',
55
+ NAME: 'name',
56
+ THREADS: 'threads'
57
+ };
58
+ const CONTACT_THREAD_SORTS = {
59
+ NEWEST: 'newest',
60
+ OLDEST: 'oldest',
61
+ SENDER: 'sender',
62
+ SUBJECT: 'subject'
63
+ };
64
+ const CONTACT_BLOCK_LISTS = {
65
+ BLOCKED_SENDERS: 'blockedSenders',
66
+ BLOCKED_DOMAINS: 'blockedDomains'
67
+ };
68
+ const CONTACT_PHOTO_TYPES = {
69
+ PNG: 'image/png',
70
+ JPEG: 'image/jpeg',
71
+ WEBP: 'image/webp',
72
+ GIF: 'image/gif'
73
+ };
74
+
75
+ const MESSAGE_ENCRYPTION_FORMATS = {
76
+ PGP_MIME: 'pgp-mime',
77
+ PGP_SIGNED: 'pgp-signed',
78
+ PGP_INLINE: 'pgp-inline',
79
+ SMIME_ENCRYPTED: 'smime-encrypted',
80
+ SMIME_SIGNED: 'smime-signed'
81
+ };
82
+ const SEALED_ENCRYPTION_FORMATS = [
83
+ MESSAGE_ENCRYPTION_FORMATS.PGP_MIME,
84
+ MESSAGE_ENCRYPTION_FORMATS.PGP_INLINE,
85
+ MESSAGE_ENCRYPTION_FORMATS.SMIME_ENCRYPTED
50
86
  ];
51
- const SEALED_ENCRYPTION_FORMATS = ['pgp-mime', 'pgp-inline', 'smime-encrypted'];
52
87
  const BASE64_CHUNK_SIZE = 0x8000;
53
88
 
54
- const ERROR_TYPES = [
55
- 'invalid_request_error',
56
- 'authentication_error',
57
- 'permission_error',
58
- 'not_found_error',
59
- 'conflict_error',
60
- 'validation_error',
61
- 'rate_limit_error',
62
- 'api_error'
63
- ];
64
- const ERROR_TYPE = {
65
- INVALID_REQUEST: 'invalid_request_error',
66
- AUTHENTICATION: 'authentication_error',
67
- PERMISSION: 'permission_error',
68
- NOT_FOUND: 'not_found_error',
69
- CONFLICT: 'conflict_error',
70
- VALIDATION: 'validation_error',
71
- RATE_LIMIT: 'rate_limit_error',
72
- API: 'api_error'
89
+ const ERROR_TYPES = {
90
+ INVALID_REQUEST_ERROR: 'invalid_request_error',
91
+ AUTHENTICATION_ERROR: 'authentication_error',
92
+ PERMISSION_ERROR: 'permission_error',
93
+ NOT_FOUND_ERROR: 'not_found_error',
94
+ CONFLICT_ERROR: 'conflict_error',
95
+ VALIDATION_ERROR: 'validation_error',
96
+ RATE_LIMIT_ERROR: 'rate_limit_error',
97
+ API_ERROR: 'api_error'
73
98
  };
74
99
  const ERROR_TYPE_BY_STATUS = {
75
- 401: ERROR_TYPE.AUTHENTICATION,
76
- 403: ERROR_TYPE.PERMISSION,
77
- 404: ERROR_TYPE.NOT_FOUND,
78
- 409: ERROR_TYPE.CONFLICT,
79
- 422: ERROR_TYPE.VALIDATION,
80
- 429: ERROR_TYPE.RATE_LIMIT
100
+ 401: ERROR_TYPES.AUTHENTICATION_ERROR,
101
+ 403: ERROR_TYPES.PERMISSION_ERROR,
102
+ 404: ERROR_TYPES.NOT_FOUND_ERROR,
103
+ 409: ERROR_TYPES.CONFLICT_ERROR,
104
+ 422: ERROR_TYPES.VALIDATION_ERROR,
105
+ 429: ERROR_TYPES.RATE_LIMIT_ERROR
81
106
  };
82
107
  const ERROR_CODES = {
83
108
  INSUFFICIENT_SCOPE: 'insufficient_scope',
@@ -88,9 +113,28 @@ const ERROR_NAMES = {
88
113
  NETWORK: 'OpenEmailNetworkError',
89
114
  TIMEOUT: 'TimeoutError'};
90
115
 
116
+ const FILE_SORTS = {
117
+ NEWEST: 'newest',
118
+ OLDEST: 'oldest',
119
+ LARGEST: 'largest',
120
+ NAME: 'name'
121
+ };
122
+ const FILE_KINDS = {
123
+ IMAGE: 'image',
124
+ PDF: 'pdf',
125
+ AUDIO: 'audio',
126
+ VIDEO: 'video',
127
+ TEXT: 'text'
128
+ };
129
+ const FILE_DIRECTIONS = {
130
+ INBOUND: 'inbound',
131
+ OUTBOUND: 'outbound'
132
+ };
133
+
91
134
  const HTTP_METHODS = {
92
135
  GET: 'GET',
93
136
  POST: 'POST',
137
+ PUT: 'PUT',
94
138
  PATCH: 'PATCH',
95
139
  DELETE: 'DELETE'
96
140
  };
@@ -105,7 +149,8 @@ const HEADER_KEYS = {
105
149
  };
106
150
  const CONTENT_TYPES = {
107
151
  JSON: 'application/json',
108
- CALENDAR: 'text/calendar'
152
+ CALENDAR: 'text/calendar',
153
+ OCTET_STREAM: 'application/octet-stream'
109
154
  };
110
155
  const RETRY = {
111
156
  STATUSES: [408, 429, 500, 502, 503, 504],
@@ -117,6 +162,28 @@ const RETRY = {
117
162
  };
118
163
  const IDEMPOTENCY_KEY_PREFIX = 'oe-';
119
164
 
165
+ const PROVIDER_IMPORT_RESOURCES = {
166
+ SUPPRESSIONS: 'suppressions',
167
+ AUDIENCES: 'audiences',
168
+ CONTACTS: 'contacts',
169
+ TEMPLATES: 'templates',
170
+ WEBHOOKS: 'webhooks',
171
+ DOMAINS: 'domains',
172
+ API_KEYS: 'api-keys'
173
+ };
174
+ const PROVIDER_IMPORT_STATUSES = {
175
+ QUEUED: 'queued',
176
+ RUNNING: 'running',
177
+ COMPLETED: 'completed',
178
+ FAILED: 'failed',
179
+ CANCELLED: 'cancelled'
180
+ };
181
+ const PROVIDER_IMPORT_DOMAIN_STATES = {
182
+ ABSENT: 'absent',
183
+ ADDED: 'added',
184
+ VERIFIED: 'verified'
185
+ };
186
+
120
187
  const LANGUAGES = [
121
188
  { code: 'en', label: 'English', native: 'English', flag: '🇬🇧', rtl: false },
122
189
  { code: 'es', label: 'Spanish', native: 'Español', flag: '🇪🇸', rtl: false },
@@ -353,6 +420,7 @@ const CURSOR_STYLES = {
353
420
  };
354
421
  const QUERY_KEYS = {
355
422
  LIMIT: 'limit',
423
+ CURSOR: 'cursor',
356
424
  STATUS: 'status',
357
425
  FROM: 'from',
358
426
  TO: 'to',
@@ -370,13 +438,41 @@ const QUERY_KEYS = {
370
438
  GRAIN: 'grain',
371
439
  OFFSET_MINUTES: 'offsetMinutes',
372
440
  INCLUDE_MACHINE: 'includeMachine',
373
- REASSIGN_TO: 'reassignTo'
441
+ REASSIGN_TO: 'reassignTo',
442
+ SOURCE: 'source',
443
+ ADDRESS: 'address',
444
+ SEARCH: 'search',
445
+ SORT: 'sort',
446
+ PAGE: 'page',
447
+ PAGE_SIZE: 'pageSize',
448
+ VERSION: 'version',
449
+ TRACKED: 'tracked',
450
+ Q: 'q',
451
+ AUDIENCE_IDS: 'audienceIds',
452
+ AUDIENCE_ID: 'audienceId',
453
+ BROADCAST_ID: 'broadcastId',
454
+ EMAIL: 'email',
455
+ BLOCKED: 'blocked',
456
+ DATE_FROM: 'dateFrom',
457
+ DATE_TO: 'dateTo',
458
+ FROM_CONTACTS: 'fromContacts',
459
+ REASON: 'reason',
460
+ KIND: 'kind',
461
+ ENDPOINT_IDS: 'endpointIds',
462
+ KEY_IDS: 'keyIds',
463
+ SINCE: 'since',
464
+ UNTIL: 'until',
465
+ FAILED_ONLY: 'failedOnly'
374
466
  };
375
467
  const LIST_SEPARATOR = ',';
376
468
 
377
469
  const PATHS = {
378
470
  PING: '/ping',
471
+ KEYS: '/keys',
472
+ KEYS_REQUESTS: '/keys/requests',
473
+ KEYS_ACTIVITY: '/keys/activity',
379
474
  KEYS_SELF: '/keys/self',
475
+ KEYS_SELF_ROTATE: '/keys/self/rotate',
380
476
  ADDRESSES: '/addresses',
381
477
  LANGUAGES: '/languages',
382
478
  EMAILS: '/emails',
@@ -385,10 +481,25 @@ const PATHS = {
385
481
  THREADS: '/threads',
386
482
  DRAFTS: '/drafts',
387
483
  LABELS: '/labels',
484
+ LABELS_COLORS: '/labels/colors',
388
485
  CONTACTS: '/contacts',
486
+ CONTACTS_PEOPLE: '/contacts/people',
487
+ CONTACTS_BATCH_DELETE: '/contacts/batch-delete',
488
+ AUDIENCES: '/audiences',
489
+ AUDIENCES_GROWTH: '/audiences/growth',
490
+ BROADCASTS: '/broadcasts',
491
+ BROADCASTS_PREVIEW: '/broadcasts/preview',
389
492
  DOMAINS: '/domains',
390
493
  WEBHOOKS: '/webhooks',
494
+ WEBHOOKS_DELIVERIES: '/webhooks/deliveries',
495
+ WEBHOOKS_ACTIVITY: '/webhooks/activity',
496
+ IMPORTS: '/imports',
497
+ PROVIDER_IMPORTS: '/provider-imports',
498
+ PROVIDER_IMPORTS_INSPECT: '/provider-imports/inspect',
391
499
  TEMPLATES: '/templates',
500
+ TEMPLATES_FONTS: '/templates/fonts',
501
+ TEMPLATES_RENDER: '/templates/render',
502
+ TEMPLATES_STARTERS: '/templates/starters',
392
503
  RULES: '/rules',
393
504
  RULES_RUNS: '/rules/runs',
394
505
  RULES_REORDER: '/rules/reorder',
@@ -399,28 +510,57 @@ const PATHS = {
399
510
  ROLES: '/roles',
400
511
  ROLES_PERMISSIONS: '/roles/permissions',
401
512
  MEMBERS: '/members',
513
+ MEMBERS_INVITATIONS: '/members/invitations',
514
+ SUPPRESSIONS: '/suppressions',
515
+ FILES: '/files',
402
516
  TEMP_MAIL_DOMAINS: '/temp-mail/domains',
403
517
  TEMP_MAIL_INBOXES: '/temp-mail/inboxes'
404
518
  };
405
519
  const SEGMENTS = {
520
+ ACTIVITY: 'activity',
406
521
  ADDRESSES: 'addresses',
522
+ ANALYTICS: 'analytics',
407
523
  ATTACHMENTS: 'attachments',
524
+ AUDIENCES: 'audiences',
525
+ BATCH: 'batch',
526
+ BATCH_REMOVE: 'batch-remove',
527
+ BLOCK: 'block',
408
528
  CANCEL: 'cancel',
529
+ CHUNKS: 'chunks',
409
530
  CLICKS: 'clicks',
531
+ CONTACTS: 'contacts',
532
+ CONTENT: 'content',
410
533
  DELIVERIES: 'deliveries',
534
+ DUPLICATE: 'duplicate',
535
+ EMPTY: 'empty',
411
536
  EVENTS: 'events',
412
537
  EXTEND: 'extend',
538
+ FAILURES: 'failures',
539
+ FILES: 'files',
413
540
  ICS: 'ics',
541
+ IMPORT: 'import',
542
+ LINKS: 'links',
414
543
  MESSAGES: 'messages',
415
544
  OPENS: 'opens',
545
+ PHOTO: 'photo',
416
546
  PREVIEW: 'preview',
547
+ REPLAY: 'replay',
548
+ REQUESTS: 'requests',
549
+ RESEND: 'resend',
550
+ RESTORE: 'restore',
551
+ REVOKE: 'revoke',
552
+ ROTATE: 'rotate',
417
553
  ROTATE_SECRET: 'rotate-secret',
418
554
  SEND: 'send',
555
+ SENDS: 'sends',
419
556
  SNOOZE: 'snooze',
557
+ START: 'start',
420
558
  TEST: 'test',
559
+ THREADS: 'threads',
421
560
  TRACKING: 'tracking',
422
561
  TRASH: 'trash',
423
562
  UNSNOOZE: 'unsnooze',
563
+ UPLOAD: 'upload',
424
564
  VERSIONS: 'versions'
425
565
  };
426
566
 
@@ -430,89 +570,135 @@ const UPDATE_NOTICE = {
430
570
  ENV_DISABLE: 'OPENEMAIL_DISABLE_UPDATE_NOTICE',
431
571
  TIMEOUT_MS: 2_000,
432
572
  PACKAGE: '@openemail/sdk',
433
- CHANGELOG_URL: 'https://www.npmjs.com/package/@openemail/sdk?activeTab=versions',
573
+ CHANGELOG_URL: 'https://openemail.uk/docs/sdk/changelog',
434
574
  ICON: 'ℹ'
435
575
  };
436
576
 
437
- const RULE_FIELDS = [
438
- 'from',
439
- 'from_domain',
440
- 'envelope_from',
441
- 'to',
442
- 'cc',
443
- 'bcc',
444
- 'recipient',
445
- 'reply_to',
446
- 'delivered_to',
447
- 'subject',
448
- 'body',
449
- 'header',
450
- 'list_id',
451
- 'attachment_name',
452
- 'attachment_type',
453
- 'has_attachment',
454
- 'attachment_size',
455
- 'message_size',
456
- 'spam',
457
- 'hour',
458
- 'weekday'
459
- ];
460
- const RULE_OPERATORS = ['matches', 'contains', 'equals', 'starts_with', 'ends_with', 'gt', 'lt'];
461
- const RULE_ACTIONS = [
462
- 'label',
463
- 'remove_label',
464
- 'archive',
465
- 'mark_read',
466
- 'star',
467
- 'spam',
468
- 'trash',
469
- 'forward',
470
- 'reply',
471
- 'block_sender',
472
- 'reject'
473
- ];
577
+ const RULE_FIELDS = {
578
+ FROM: 'from',
579
+ FROM_DOMAIN: 'from_domain',
580
+ ENVELOPE_FROM: 'envelope_from',
581
+ TO: 'to',
582
+ CC: 'cc',
583
+ BCC: 'bcc',
584
+ RECIPIENT: 'recipient',
585
+ REPLY_TO: 'reply_to',
586
+ DELIVERED_TO: 'delivered_to',
587
+ SUBJECT: 'subject',
588
+ BODY: 'body',
589
+ HEADER: 'header',
590
+ LIST_ID: 'list_id',
591
+ ATTACHMENT_NAME: 'attachment_name',
592
+ ATTACHMENT_TYPE: 'attachment_type',
593
+ HAS_ATTACHMENT: 'has_attachment',
594
+ ATTACHMENT_SIZE: 'attachment_size',
595
+ MESSAGE_SIZE: 'message_size',
596
+ SPAM: 'spam',
597
+ HOUR: 'hour',
598
+ WEEKDAY: 'weekday'
599
+ };
600
+ const RULE_OPERATORS = {
601
+ MATCHES: 'matches',
602
+ CONTAINS: 'contains',
603
+ EQUALS: 'equals',
604
+ STARTS_WITH: 'starts_with',
605
+ ENDS_WITH: 'ends_with',
606
+ GT: 'gt',
607
+ LT: 'lt'
608
+ };
609
+ const RULE_ACTIONS = {
610
+ LABEL: 'label',
611
+ REMOVE_LABEL: 'remove_label',
612
+ ARCHIVE: 'archive',
613
+ MARK_READ: 'mark_read',
614
+ STAR: 'star',
615
+ SPAM: 'spam',
616
+ TRASH: 'trash',
617
+ FORWARD: 'forward',
618
+ REPLY: 'reply',
619
+ BLOCK_SENDER: 'block_sender',
620
+ REJECT: 'reject'
621
+ };
474
622
 
475
- const API_SCOPES = [
476
- 'emails:send',
477
- 'emails:read',
478
- 'drafts:read',
479
- 'drafts:write',
480
- 'threads:read',
481
- 'threads:write',
482
- 'labels:read',
483
- 'labels:write',
484
- 'contacts:read',
485
- 'calendar:read',
486
- 'calendar:write',
487
- 'templates:read',
488
- 'templates:write',
489
- 'domains:read',
490
- 'domains:write',
491
- 'webhooks:read',
492
- 'webhooks:write',
493
- 'rules:read',
494
- 'rules:write',
495
- 'connections:read',
496
- 'members:read',
497
- 'members:write',
498
- 'roles:read',
499
- 'roles:write',
500
- 'settings:read',
501
- 'settings:write'
502
- ];
623
+ const API_SCOPES = {
624
+ EMAILS_SEND: 'emails:send',
625
+ EMAILS_READ: 'emails:read',
626
+ DRAFTS_READ: 'drafts:read',
627
+ DRAFTS_WRITE: 'drafts:write',
628
+ THREADS_READ: 'threads:read',
629
+ THREADS_WRITE: 'threads:write',
630
+ LABELS_READ: 'labels:read',
631
+ LABELS_WRITE: 'labels:write',
632
+ CONTACTS_READ: 'contacts:read',
633
+ CONTACTS_WRITE: 'contacts:write',
634
+ AUDIENCES_READ: 'audiences:read',
635
+ AUDIENCES_WRITE: 'audiences:write',
636
+ CALENDAR_READ: 'calendar:read',
637
+ CALENDAR_WRITE: 'calendar:write',
638
+ TEMPLATES_READ: 'templates:read',
639
+ TEMPLATES_WRITE: 'templates:write',
640
+ DOMAINS_READ: 'domains:read',
641
+ DOMAINS_WRITE: 'domains:write',
642
+ WEBHOOKS_READ: 'webhooks:read',
643
+ WEBHOOKS_WRITE: 'webhooks:write',
644
+ RULES_READ: 'rules:read',
645
+ RULES_WRITE: 'rules:write',
646
+ CONNECTIONS_READ: 'connections:read',
647
+ MEMBERS_READ: 'members:read',
648
+ MEMBERS_WRITE: 'members:write',
649
+ ROLES_READ: 'roles:read',
650
+ ROLES_WRITE: 'roles:write',
651
+ SETTINGS_READ: 'settings:read',
652
+ SETTINGS_WRITE: 'settings:write',
653
+ KEYS_WRITE: 'keys:write',
654
+ KEYS_READ: 'keys:read',
655
+ KEYS_MANAGE: 'keys:manage'
656
+ };
503
657
 
504
- const WEBHOOK_EVENTS = [
505
- 'email.received',
506
- 'email.sent',
507
- 'email.failed',
508
- 'email.cancelled',
509
- 'email.scheduled',
510
- 'email.queued',
511
- 'email.bounced',
512
- 'email.complained',
513
- 'email.opened',
514
- 'email.clicked'
515
- ];
658
+ const SUPPRESSION_REASONS = {
659
+ BOUNCE: 'bounce',
660
+ COMPLAINT: 'complaint',
661
+ MANUAL: 'manual'
662
+ };
663
+
664
+ const THREAD_SORTS = {
665
+ NEWEST: 'newest',
666
+ OLDEST: 'oldest',
667
+ SENDER: 'sender',
668
+ SUBJECT: 'subject'
669
+ };
670
+
671
+ const WEBHOOK_EVENTS = {
672
+ EMAIL_RECEIVED: 'email.received',
673
+ EMAIL_REPLIED: 'email.replied',
674
+ EMAIL_SENT: 'email.sent',
675
+ EMAIL_FAILED: 'email.failed',
676
+ EMAIL_CANCELLED: 'email.cancelled',
677
+ EMAIL_SCHEDULED: 'email.scheduled',
678
+ EMAIL_QUEUED: 'email.queued',
679
+ EMAIL_DELIVERED: 'email.delivered',
680
+ EMAIL_DELIVERY_DELAYED: 'email.delivery_delayed',
681
+ EMAIL_BOUNCED: 'email.bounced',
682
+ EMAIL_COMPLAINED: 'email.complained',
683
+ EMAIL_SUPPRESSED: 'email.suppressed',
684
+ EMAIL_OPENED: 'email.opened',
685
+ EMAIL_CLICKED: 'email.clicked',
686
+ EMAIL_DOWNLOADED: 'email.downloaded',
687
+ DOMAIN_VERIFIED: 'domain.verified',
688
+ DOMAIN_SENDING_CHANGED: 'domain.sending_changed',
689
+ DOMAIN_DELETED: 'domain.deleted',
690
+ SUPPRESSION_ADDED: 'suppression.added',
691
+ SUPPRESSION_REMOVED: 'suppression.removed'
692
+ };
693
+ const WEBHOOK_REPLAY_ERROR_CODES = {
694
+ RESOURCE_NOT_FOUND: 'resource_not_found',
695
+ WEBHOOK_DISABLED: 'webhook_disabled',
696
+ EVENT_NOT_SUBSCRIBED: 'event_not_subscribed',
697
+ EVENT_OUT_OF_SCOPE: 'event_out_of_scope',
698
+ DELIVERY_NOT_REPLAYABLE: 'delivery_not_replayable',
699
+ RETRY_IN_PROGRESS: 'retry_in_progress',
700
+ REPLAY_IN_PROGRESS: 'replay_in_progress'
701
+ };
516
702
  const WEBHOOK_HEADERS = {
517
703
  SIGNATURE: 'X-OpenEmail-Signature',
518
704
  EVENT: 'X-OpenEmail-Event',
@@ -545,6 +731,108 @@ const ENDPOINT_SCHEME_PATTERN = /^[a-z][a-z0-9+.-]*:\/\//i;
545
731
  const RETRYABLE_STATUSES = new Set(RETRY.STATUSES);
546
732
  const RETRYABLE_METHODS = new Set(RETRY.METHODS);
547
733
 
734
+ ({
735
+ scopes: [API_SCOPES.KEYS_MANAGE]});
736
+
737
+ ({
738
+ scopes: [API_SCOPES.KEYS_MANAGE]});
739
+
740
+ ({
741
+ scopes: [API_SCOPES.KEYS_READ]});
742
+
743
+ ({
744
+ scopes: [API_SCOPES.KEYS_READ]});
745
+
746
+ ({
747
+ scopes: [API_SCOPES.KEYS_READ]});
748
+
749
+ ({
750
+ scopes: [API_SCOPES.KEYS_READ]});
751
+
752
+ ({
753
+ scopes: [API_SCOPES.KEYS_READ]});
754
+
755
+ ({
756
+ scopes: [API_SCOPES.KEYS_READ]});
757
+
758
+ ({
759
+ scopes: [API_SCOPES.KEYS_READ]});
760
+
761
+ ({
762
+ scopes: [API_SCOPES.KEYS_READ]});
763
+
764
+ ({
765
+ scopes: [API_SCOPES.KEYS_READ]});
766
+
767
+ ({
768
+ scopes: [API_SCOPES.KEYS_READ]});
769
+
770
+ ({
771
+ scopes: [API_SCOPES.KEYS_READ]});
772
+
773
+ ({
774
+ scopes: [API_SCOPES.KEYS_READ]});
775
+
776
+ ({
777
+ scopes: [API_SCOPES.KEYS_READ]});
778
+
779
+ ({
780
+ scopes: [API_SCOPES.KEYS_READ]});
781
+
782
+ ({
783
+ scopes: [API_SCOPES.KEYS_READ]});
784
+
785
+ ({
786
+ scopes: [API_SCOPES.KEYS_READ]});
787
+
788
+ ({
789
+ scopes: [API_SCOPES.KEYS_MANAGE]});
790
+
791
+ ({
792
+ scopes: [API_SCOPES.KEYS_MANAGE]});
793
+
794
+ ({
795
+ scopes: [API_SCOPES.KEYS_MANAGE]});
796
+
797
+ ({
798
+ scopes: [API_SCOPES.KEYS_WRITE]});
799
+
800
+ ({
801
+ scopes: [API_SCOPES.WEBHOOKS_READ]});
802
+
803
+ ({
804
+ scopes: [API_SCOPES.WEBHOOKS_READ]});
805
+
806
+ ({
807
+ scopes: [API_SCOPES.WEBHOOKS_READ]});
808
+
809
+ ({
810
+ scopes: [API_SCOPES.WEBHOOKS_READ]});
811
+
812
+ ({
813
+ scopes: [API_SCOPES.WEBHOOKS_READ]});
814
+
815
+ ({
816
+ scopes: [API_SCOPES.WEBHOOKS_READ]});
817
+
818
+ ({
819
+ scopes: [API_SCOPES.WEBHOOKS_READ]});
820
+
821
+ ({
822
+ scopes: [API_SCOPES.WEBHOOKS_READ]});
823
+
824
+ ({
825
+ scopes: [API_SCOPES.WEBHOOKS_READ]});
826
+
827
+ ({
828
+ scopes: [API_SCOPES.WEBHOOKS_READ]});
829
+
830
+ ({
831
+ scopes: [API_SCOPES.WEBHOOKS_READ]});
832
+
833
+ ({
834
+ scopes: [API_SCOPES.WEBHOOKS_READ]});
835
+
548
836
  const IsApiKey = (value) => typeof value === 'string' && (value.startsWith(API_KEY_PREFIXES.LIVE) || value.startsWith(API_KEY_PREFIXES.TEST));
549
837
  const ModeOf = (apiKey) => apiKey.startsWith(API_KEY_PREFIXES.TEST) ? API_KEY_MODES.TEST : API_KEY_MODES.LIVE;
550
838
  const AssertApiKey = (apiKey, where) => {
@@ -582,28 +870,28 @@ class OpenEmailApiError extends Error {
582
870
  this.retryAfterSeconds = retryAfterSeconds;
583
871
  }
584
872
  get isAuth() {
585
- return this.type === ERROR_TYPE.AUTHENTICATION;
873
+ return this.type === ERROR_TYPES.AUTHENTICATION_ERROR;
586
874
  }
587
875
  get isPermission() {
588
- return this.type === ERROR_TYPE.PERMISSION;
876
+ return this.type === ERROR_TYPES.PERMISSION_ERROR;
589
877
  }
590
878
  get isScopeMissing() {
591
879
  return this.code === ERROR_CODES.INSUFFICIENT_SCOPE;
592
880
  }
593
881
  get isInvalidRequest() {
594
- return this.type === ERROR_TYPE.INVALID_REQUEST;
882
+ return this.type === ERROR_TYPES.INVALID_REQUEST_ERROR;
595
883
  }
596
884
  get isValidation() {
597
- return this.type === ERROR_TYPE.VALIDATION;
885
+ return this.type === ERROR_TYPES.VALIDATION_ERROR;
598
886
  }
599
887
  get isNotFound() {
600
- return this.type === ERROR_TYPE.NOT_FOUND;
888
+ return this.type === ERROR_TYPES.NOT_FOUND_ERROR;
601
889
  }
602
890
  get isConflict() {
603
- return this.type === ERROR_TYPE.CONFLICT;
891
+ return this.type === ERROR_TYPES.CONFLICT_ERROR;
604
892
  }
605
893
  get isRateLimited() {
606
- return this.type === ERROR_TYPE.RATE_LIMIT;
894
+ return this.type === ERROR_TYPES.RATE_LIMIT_ERROR;
607
895
  }
608
896
  get isServerError() {
609
897
  return this.status !== null && this.status >= 500;
@@ -769,12 +1057,13 @@ const Sleep = (ms, signal) => new Promise((resolve, reject) => {
769
1057
  signal?.addEventListener('abort', onAbort, { once: true });
770
1058
  });
771
1059
 
772
- const IsErrorType = (value) => typeof value === 'string' && ERROR_TYPES.includes(value);
1060
+ const errorTypes = new Set(Object.values(ERROR_TYPES));
1061
+ const IsErrorType = (value) => typeof value === 'string' && errorTypes.has(value);
773
1062
  const TypeForStatus = (status) => {
774
1063
  if (status >= 500)
775
- return ERROR_TYPE.API;
1064
+ return ERROR_TYPES.API_ERROR;
776
1065
  const mapped = ERROR_TYPE_BY_STATUS[status];
777
- return IsErrorType(mapped) ? mapped : ERROR_TYPE.INVALID_REQUEST;
1066
+ return IsErrorType(mapped) ? mapped : ERROR_TYPES.INVALID_REQUEST_ERROR;
778
1067
  };
779
1068
  const ReadPayload = (body) => {
780
1069
  if (typeof body !== 'object' || body === null || !('error' in body))
@@ -849,11 +1138,13 @@ class Transport {
849
1138
  const method = (options.method ?? HTTP_METHODS.GET).toUpperCase();
850
1139
  const url = BuildUrl(this.baseUrl, path, options.query);
851
1140
  const headers = this.headersFor(options);
852
- const body = options.body === undefined ? undefined : JSON.stringify(options.body);
1141
+ const body = options.raw !== undefined
1142
+ ? options.raw
1143
+ : options.body === undefined ? undefined : JSON.stringify(options.body);
853
1144
  const repeatable = options.repeatable ?? RETRYABLE_METHODS.has(method);
854
1145
  let attempt = 0;
855
1146
  for (;;) {
856
- const outcome = await this.attempt(url, method, headers, body, options.signal);
1147
+ const outcome = await this.attempt(url, method, headers, body, options.signal, options.binary === true);
857
1148
  if (outcome instanceof OpenEmailNetworkError) {
858
1149
  if (options.signal?.aborted || !repeatable || attempt >= this.maxRetries)
859
1150
  throw outcome;
@@ -861,7 +1152,9 @@ class Transport {
861
1152
  attempt += 1;
862
1153
  continue;
863
1154
  }
864
- const { response, text } = outcome;
1155
+ const { response, text, bytes } = outcome;
1156
+ if (response.ok && bytes !== undefined)
1157
+ return bytes;
865
1158
  if (response.ok)
866
1159
  return this.parse(response, text, options.accept);
867
1160
  const retryAfter = RetryAfter(response.headers.get(HEADER_KEYS.RETRY_AFTER));
@@ -883,7 +1176,9 @@ class Transport {
883
1176
  };
884
1177
  if (!IsBrowser())
885
1178
  headers[HEADER_KEYS.USER_AGENT] = this.userAgent;
886
- if (options.body !== undefined)
1179
+ if (options.raw !== undefined)
1180
+ headers[HEADER_KEYS.CONTENT_TYPE] = options.contentType ?? CONTENT_TYPES.OCTET_STREAM;
1181
+ else if (options.body !== undefined)
887
1182
  headers[HEADER_KEYS.CONTENT_TYPE] = CONTENT_TYPES.JSON;
888
1183
  if (options.anonymous !== true) {
889
1184
  if (options.apiKey !== undefined)
@@ -896,7 +1191,7 @@ class Transport {
896
1191
  headers[HEADER_KEYS.IDEMPOTENCY_KEY] = options.idempotencyKey ?? IdempotencyKey();
897
1192
  return headers;
898
1193
  }
899
- async attempt(url, method, headers, body, signal) {
1194
+ async attempt(url, method, headers, body, signal, binary) {
900
1195
  const deadline = Deadline(this.timeoutMs, signal);
901
1196
  const Failure = (error, fallback) => {
902
1197
  if (signal?.aborted)
@@ -914,6 +1209,8 @@ class Transport {
914
1209
  return Failure(error, `Could not reach ${this.baseUrl}`);
915
1210
  }
916
1211
  try {
1212
+ if (binary && response.ok)
1213
+ return { response, text: '', bytes: new Uint8Array(await response.arrayBuffer()) };
917
1214
  return { response, text: await response.text() };
918
1215
  }
919
1216
  catch (error) {
@@ -937,24 +1234,13 @@ class Transport {
937
1234
  throw new OpenEmailApiError({
938
1235
  message: `The API answered ${response.status} with a body that is not JSON.`,
939
1236
  status: response.status,
940
- type: ERROR_TYPE.API,
1237
+ type: ERROR_TYPES.API_ERROR,
941
1238
  code: ERROR_CODES.UNRECOGNISED_RESPONSE,
942
1239
  requestId: response.headers.get(HEADER_KEYS.REQUEST_ID) ?? undefined
943
1240
  });
944
1241
  }
945
1242
  }
946
1243
 
947
- const Addresses = (transport) => ({
948
- list: async (options = {}) => {
949
- const envelope = await transport.request(PATHS.ADDRESSES, { signal: options.signal, apiKey: options.apiKey });
950
- return {
951
- unrestricted: envelope.unrestricted,
952
- addresses: envelope.data ?? [],
953
- domains: envelope.domains ?? []
954
- };
955
- }
956
- });
957
-
958
1244
  const FetchPage = async (transport, path, style, options = {}, query = {}) => {
959
1245
  const payload = await transport.request(path, {
960
1246
  query: { ...query, [QUERY_KEYS.LIMIT]: options.limit, [style.PARAM]: options.cursor },
@@ -1010,11 +1296,31 @@ const ThreadMessageAttachmentsPath = (id, messageId) => `${ThreadPath(id)}/${SEG
1010
1296
  const DraftPath = (id) => `${PATHS.DRAFTS}/${Segment(id)}`;
1011
1297
  const LabelPath = (id) => `${PATHS.LABELS}/${Segment(id)}`;
1012
1298
  const ContactPath = (email) => `${PATHS.CONTACTS}/${Segment(email)}`;
1299
+ const ContactChildPath = (email, segment) => `${ContactPath(email)}/${segment}`;
1300
+ const AudiencePath = (id) => `${PATHS.AUDIENCES}/${Segment(id)}`;
1301
+ const AudienceChildPath = (id, segment) => `${AudiencePath(id)}/${segment}`;
1302
+ const AudienceContactsPath = (id) => `${AudiencePath(id)}/${SEGMENTS.CONTACTS}`;
1303
+ const AudienceContactsChildPath = (id, segment) => `${AudienceContactsPath(id)}/${segment}`;
1304
+ const AudienceContactPath = (id, email) => `${AudienceContactsPath(id)}/${Segment(email)}`;
1305
+ const BroadcastPath = (id) => `${PATHS.BROADCASTS}/${Segment(id)}`;
1306
+ const BroadcastChildPath = (id, segment) => `${BroadcastPath(id)}/${segment}`;
1013
1307
  const DomainPath = (id) => `${PATHS.DOMAINS}/${Segment(id)}`;
1014
1308
  const WebhookPath = (id) => `${PATHS.WEBHOOKS}/${Segment(id)}`;
1015
1309
  const WebhookChildPath = (id, segment) => `${WebhookPath(id)}/${segment}`;
1310
+ const WebhookDeliveryPath = (id, deliveryId) => `${WebhookChildPath(id, SEGMENTS.DELIVERIES)}/${Segment(deliveryId)}`;
1311
+ const WebhookDeliveryReplayPath = (id, deliveryId) => `${WebhookDeliveryPath(id, deliveryId)}/${SEGMENTS.REPLAY}`;
1312
+ const KeyPath = (id) => `${PATHS.KEYS}/${Segment(id)}`;
1313
+ const KeyChildPath = (id, segment) => `${KeyPath(id)}/${segment}`;
1314
+ const ImportPath = (id) => `${PATHS.IMPORTS}/${Segment(id)}`;
1315
+ const ProviderImportPath = (id) => `${PATHS.PROVIDER_IMPORTS}/${Segment(id)}`;
1316
+ const ProviderImportChildPath = (id, segment) => `${ProviderImportPath(id)}/${segment}`;
1317
+ const ImportChildPath = (id, segment) => `${ImportPath(id)}/${segment}`;
1318
+ const ImportChunkPath = (id, file, chunk) => `${ImportPath(id)}/${SEGMENTS.FILES}/${Segment(String(file))}/${SEGMENTS.CHUNKS}/${Segment(String(chunk))}`;
1016
1319
  const TemplatePath = (idOrSlug) => `${PATHS.TEMPLATES}/${Segment(idOrSlug)}`;
1017
1320
  const TemplateChildPath = (idOrSlug, segment) => `${TemplatePath(idOrSlug)}/${segment}`;
1321
+ const TemplateStarterPath = (slug) => `${PATHS.TEMPLATES_STARTERS}/${Segment(slug)}`;
1322
+ const TemplateVersionPath = (idOrSlug, version) => `${TemplateChildPath(idOrSlug, SEGMENTS.VERSIONS)}/${Segment(String(version))}`;
1323
+ const TemplateVersionChildPath = (idOrSlug, version, segment) => `${TemplateVersionPath(idOrSlug, version)}/${segment}`;
1018
1324
  const RulePath = (id) => `${PATHS.RULES}/${Segment(id)}`;
1019
1325
  const RuleChildPath = (id, segment) => `${RulePath(id)}/${segment}`;
1020
1326
  const TrackingPath = (id) => `${PATHS.TRACKING}/${Segment(id)}`;
@@ -1025,12 +1331,131 @@ const RolePath = (id) => `${PATHS.ROLES}/${Segment(id)}`;
1025
1331
  const MemberPath = (userId) => `${PATHS.MEMBERS}/${Segment(userId)}`;
1026
1332
  const MemberAddressesPath = (userId) => `${MemberPath(userId)}/${SEGMENTS.ADDRESSES}`;
1027
1333
  const MemberAddressPath = (userId, addressId) => `${MemberAddressesPath(userId)}/${Segment(addressId)}`;
1334
+ const MemberInvitationPath = (id) => `${PATHS.MEMBERS_INVITATIONS}/${Segment(id)}`;
1335
+ const MemberInvitationResendPath = (id) => `${MemberInvitationPath(id)}/${SEGMENTS.RESEND}`;
1336
+ const SuppressionPath = (id) => `${PATHS.SUPPRESSIONS}/${Segment(id)}`;
1337
+ const FilePath = (id) => `${PATHS.FILES}/${Segment(id)}`;
1338
+ const FileChildPath = (id, segment) => `${FilePath(id)}/${segment}`;
1028
1339
  const TempInboxPath = (id) => `${PATHS.TEMP_MAIL_INBOXES}/${Segment(id)}`;
1029
1340
  const TempInboxExtendPath = (id) => `${TempInboxPath(id)}/${SEGMENTS.EXTEND}`;
1030
1341
  const TempMessagesPath = (id) => `${TempInboxPath(id)}/${SEGMENTS.MESSAGES}`;
1031
1342
  const TempMessagePath = (id, messageId) => `${TempMessagesPath(id)}/${Segment(messageId)}`;
1032
1343
  const TempMessageAttachmentsPath = (id, messageId) => `${TempMessagePath(id, messageId)}/${SEGMENTS.ATTACHMENTS}`;
1033
1344
 
1345
+ const Addresses = (transport) => {
1346
+ const page = async (options = {}) => {
1347
+ const envelope = await transport.request(PATHS.ADDRESSES, {
1348
+ query: { [QUERY_KEYS.LIMIT]: options.limit, [CURSOR_STYLES.CURSOR.PARAM]: options.cursor },
1349
+ signal: options.signal,
1350
+ apiKey: options.apiKey
1351
+ });
1352
+ const nextCursor = typeof envelope.nextCursor === 'string' && envelope.nextCursor.length > 0 ? envelope.nextCursor : null;
1353
+ return {
1354
+ unrestricted: envelope.unrestricted,
1355
+ addresses: envelope.data ?? [],
1356
+ domains: envelope.domains ?? [],
1357
+ hasMore: typeof envelope.hasMore === 'boolean' ? envelope.hasMore : nextCursor !== null,
1358
+ nextCursor
1359
+ };
1360
+ };
1361
+ return {
1362
+ list: page,
1363
+ listAll: async (options = {}) => {
1364
+ let current = await page(options);
1365
+ const addresses = [...current.addresses];
1366
+ while (current.hasMore && current.nextCursor) {
1367
+ current = await page({ ...options, cursor: current.nextCursor });
1368
+ addresses.push(...current.addresses);
1369
+ }
1370
+ return { unrestricted: current.unrestricted, addresses, domains: current.domains };
1371
+ },
1372
+ iterate: (options = {}) => IteratePages(transport, PATHS.ADDRESSES, CURSOR_STYLES.CURSOR, options)
1373
+ };
1374
+ };
1375
+
1376
+ const MemberQuery = (options) => ({
1377
+ [QUERY_KEYS.Q]: options.q,
1378
+ [QUERY_KEYS.SOURCE]: options.source,
1379
+ [QUERY_KEYS.SORT]: options.sort
1380
+ });
1381
+ const GrowthQuery = (options) => ({
1382
+ [QUERY_KEYS.AUDIENCE_IDS]: options.audienceIds?.join(LIST_SEPARATOR),
1383
+ [QUERY_KEYS.DAYS]: options.days,
1384
+ [QUERY_KEYS.MINUTES]: options.minutes,
1385
+ [QUERY_KEYS.GRAIN]: options.grain,
1386
+ [QUERY_KEYS.OFFSET_MINUTES]: options.offsetMinutes
1387
+ });
1388
+ const Audiences = (transport) => ({
1389
+ list: (options = {}) => FetchPage(transport, PATHS.AUDIENCES, CURSOR_STYLES.CURSOR, options),
1390
+ listAll: (options = {}) => CollectAll(transport, PATHS.AUDIENCES, CURSOR_STYLES.CURSOR, options),
1391
+ iterate: (options = {}) => IteratePages(transport, PATHS.AUDIENCES, CURSOR_STYLES.CURSOR, options),
1392
+ growth: (options = {}) => transport.request(PATHS.AUDIENCES_GROWTH, {
1393
+ query: GrowthQuery(options),
1394
+ signal: options.signal,
1395
+ apiKey: options.apiKey
1396
+ }),
1397
+ get: (id, options = {}) => transport.request(AudiencePath(id), { signal: options.signal, apiKey: options.apiKey }),
1398
+ create: (body, options = {}) => transport.request(PATHS.AUDIENCES, {
1399
+ method: HTTP_METHODS.POST,
1400
+ body,
1401
+ signal: options.signal,
1402
+ apiKey: options.apiKey
1403
+ }),
1404
+ update: (id, patch, options = {}) => transport.request(AudiencePath(id), {
1405
+ method: HTTP_METHODS.PATCH,
1406
+ body: patch,
1407
+ repeatable: true,
1408
+ signal: options.signal,
1409
+ apiKey: options.apiKey
1410
+ }),
1411
+ delete: (id, options = {}) => transport.request(AudiencePath(id), {
1412
+ method: HTTP_METHODS.DELETE,
1413
+ signal: options.signal,
1414
+ apiKey: options.apiKey
1415
+ }),
1416
+ empty: (id, options = {}) => transport.request(AudienceChildPath(id, SEGMENTS.EMPTY), {
1417
+ method: HTTP_METHODS.POST,
1418
+ signal: options.signal,
1419
+ apiKey: options.apiKey
1420
+ }),
1421
+ listContacts: (id, options = {}) => FetchPage(transport, AudienceContactsPath(id), CURSOR_STYLES.CURSOR, options, MemberQuery(options)),
1422
+ listAllContacts: (id, options = {}) => CollectAll(transport, AudienceContactsPath(id), CURSOR_STYLES.CURSOR, options, MemberQuery(options)),
1423
+ iterateContacts: (id, options = {}) => IteratePages(transport, AudienceContactsPath(id), CURSOR_STYLES.CURSOR, options, MemberQuery(options)),
1424
+ addContact: (id, body, options = {}) => transport.request(AudienceContactsPath(id), {
1425
+ method: HTTP_METHODS.POST,
1426
+ body,
1427
+ repeatable: true,
1428
+ signal: options.signal,
1429
+ apiKey: options.apiKey
1430
+ }),
1431
+ removeContact: (id, email, options = {}) => transport.request(AudienceContactPath(id, email), {
1432
+ method: HTTP_METHODS.DELETE,
1433
+ signal: options.signal,
1434
+ apiKey: options.apiKey
1435
+ }),
1436
+ addContacts: (id, body, options = {}) => transport.request(AudienceContactsChildPath(id, SEGMENTS.BATCH), {
1437
+ method: HTTP_METHODS.POST,
1438
+ body,
1439
+ repeatable: true,
1440
+ signal: options.signal,
1441
+ apiKey: options.apiKey
1442
+ }),
1443
+ removeContacts: (id, body, options = {}) => transport.request(AudienceContactsChildPath(id, SEGMENTS.BATCH_REMOVE), {
1444
+ method: HTTP_METHODS.POST,
1445
+ body,
1446
+ repeatable: true,
1447
+ signal: options.signal,
1448
+ apiKey: options.apiKey
1449
+ }),
1450
+ importContacts: (id, body, options = {}) => transport.request(AudienceChildPath(id, SEGMENTS.IMPORT), {
1451
+ method: HTTP_METHODS.POST,
1452
+ body,
1453
+ repeatable: true,
1454
+ signal: options.signal,
1455
+ apiKey: options.apiKey
1456
+ })
1457
+ });
1458
+
1034
1459
  const ToBase64 = (bytes) => {
1035
1460
  const view = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
1036
1461
  let binary = '';
@@ -1046,11 +1471,13 @@ const Many = (value) => {
1046
1471
  return Array.isArray(value) ? value : [value];
1047
1472
  };
1048
1473
  const Instant = (value) => value instanceof Date ? value.toISOString() : value;
1049
- const Attachment = (attachment) => ({
1050
- filename: attachment.filename,
1051
- content: typeof attachment.content === 'string' ? attachment.content : ToBase64(attachment.content),
1052
- ...(attachment.contentType === undefined ? {} : { contentType: attachment.contentType })
1053
- });
1474
+ const Attachment = (attachment) => 'fileId' in attachment
1475
+ ? { fileId: attachment.fileId }
1476
+ : {
1477
+ filename: attachment.filename,
1478
+ content: typeof attachment.content === 'string' ? attachment.content : ToBase64(attachment.content),
1479
+ ...(attachment.contentType === undefined ? {} : { contentType: attachment.contentType })
1480
+ };
1054
1481
  const EmailToWire = (body) => ({
1055
1482
  ...body,
1056
1483
  to: Many(body.to),
@@ -1068,12 +1495,47 @@ const TemplateSendToWire = (body) => ({
1068
1495
  });
1069
1496
  const ToInstant = Instant;
1070
1497
 
1071
- const Calendar = (transport) => ({
1072
- listEvents: (options) => FetchList(transport, PATHS.CALENDAR_EVENTS, options, {
1073
- [QUERY_KEYS.FROM]: ToInstant(options.from),
1074
- [QUERY_KEYS.TO]: ToInstant(options.to),
1075
- [QUERY_KEYS.TIMEZONE]: options.timezone
1498
+ const ListQuery$a = (options) => ({
1499
+ [QUERY_KEYS.AUDIENCE_ID]: options.audienceId
1500
+ });
1501
+ const Broadcasts = (transport) => ({
1502
+ preview: (body, options = {}) => transport.request(PATHS.BROADCASTS_PREVIEW, {
1503
+ method: HTTP_METHODS.POST,
1504
+ body: { audienceIds: body.audienceIds },
1505
+ repeatable: true,
1506
+ signal: options.signal,
1507
+ apiKey: options.apiKey
1076
1508
  }),
1509
+ send: (body, options = {}) => transport.request(PATHS.BROADCASTS, {
1510
+ method: HTTP_METHODS.POST,
1511
+ body: { ...body, scheduledAt: ToInstant(body.scheduledAt) },
1512
+ idempotent: true,
1513
+ idempotencyKey: options.idempotencyKey,
1514
+ repeatable: true,
1515
+ signal: options.signal,
1516
+ apiKey: options.apiKey
1517
+ }),
1518
+ list: (options = {}) => FetchPage(transport, PATHS.BROADCASTS, CURSOR_STYLES.CURSOR, options, ListQuery$a(options)),
1519
+ listAll: (options = {}) => CollectAll(transport, PATHS.BROADCASTS, CURSOR_STYLES.CURSOR, options, ListQuery$a(options)),
1520
+ iterate: (options = {}) => IteratePages(transport, PATHS.BROADCASTS, CURSOR_STYLES.CURSOR, options, ListQuery$a(options)),
1521
+ get: (id, options = {}) => transport.request(BroadcastPath(id), { signal: options.signal, apiKey: options.apiKey }),
1522
+ cancel: (id, options = {}) => transport.request(BroadcastChildPath(id, SEGMENTS.CANCEL), {
1523
+ method: HTTP_METHODS.POST,
1524
+ repeatable: true,
1525
+ signal: options.signal,
1526
+ apiKey: options.apiKey
1527
+ })
1528
+ });
1529
+
1530
+ const RangeQuery = (options) => ({
1531
+ [QUERY_KEYS.FROM]: ToInstant(options.from),
1532
+ [QUERY_KEYS.TO]: ToInstant(options.to),
1533
+ [QUERY_KEYS.TIMEZONE]: options.timezone
1534
+ });
1535
+ const Calendar = (transport) => ({
1536
+ listEvents: (options) => FetchPage(transport, PATHS.CALENDAR_EVENTS, CURSOR_STYLES.CURSOR, options, RangeQuery(options)),
1537
+ listAllEvents: (options) => CollectAll(transport, PATHS.CALENDAR_EVENTS, CURSOR_STYLES.CURSOR, options, RangeQuery(options)),
1538
+ iterateEvents: (options) => IteratePages(transport, PATHS.CALENDAR_EVENTS, CURSOR_STYLES.CURSOR, options, RangeQuery(options)),
1077
1539
  getEvent: (id, options = {}) => transport.request(CalendarEventPath(id), { signal: options.signal, apiKey: options.apiKey }),
1078
1540
  getEventIcs: (id, options = {}) => transport.request(CalendarEventIcsPath(id), {
1079
1541
  accept: CONTENT_TYPES.CALENDAR,
@@ -1082,21 +1544,150 @@ const Calendar = (transport) => ({
1082
1544
  })
1083
1545
  });
1084
1546
 
1547
+ const ListQuery$9 = (options) => ({
1548
+ [QUERY_KEYS.SOURCE]: options.source,
1549
+ [QUERY_KEYS.Q]: options.q
1550
+ });
1551
+ const PeopleQuery = (options) => ({
1552
+ [QUERY_KEYS.Q]: options.q,
1553
+ [QUERY_KEYS.EMAIL]: options.email,
1554
+ [QUERY_KEYS.SORT]: options.sort,
1555
+ [QUERY_KEYS.BLOCKED]: options.blocked === undefined ? undefined : String(options.blocked)
1556
+ });
1557
+ const ThreadQuery = (options) => ({
1558
+ [QUERY_KEYS.Q]: options.q,
1559
+ [QUERY_KEYS.SORT]: options.sort
1560
+ });
1561
+ const ActivityQuery = (options) => ({
1562
+ [QUERY_KEYS.MINUTES]: options.minutes,
1563
+ [QUERY_KEYS.GRAIN]: options.grain,
1564
+ [QUERY_KEYS.OFFSET_MINUTES]: options.offsetMinutes
1565
+ });
1566
+ const PhotoType = (data, options) => {
1567
+ if (options.contentType)
1568
+ return options.contentType;
1569
+ return typeof Blob !== 'undefined' && data instanceof Blob && data.type ? data.type : undefined;
1570
+ };
1085
1571
  const Contacts = (transport) => ({
1086
- list: (options = {}) => FetchList(transport, PATHS.CONTACTS, options, { [QUERY_KEYS.LIMIT]: options.limit }),
1087
- get: (email, options = {}) => transport.request(ContactPath(email), { signal: options.signal, apiKey: options.apiKey })
1572
+ list: (options = {}) => FetchPage(transport, PATHS.CONTACTS, CURSOR_STYLES.CURSOR, options, ListQuery$9(options)),
1573
+ listAll: (options = {}) => CollectAll(transport, PATHS.CONTACTS, CURSOR_STYLES.CURSOR, options, ListQuery$9(options)),
1574
+ iterate: (options = {}) => IteratePages(transport, PATHS.CONTACTS, CURSOR_STYLES.CURSOR, options, ListQuery$9(options)),
1575
+ get: (email, options = {}) => transport.request(ContactPath(email), { signal: options.signal, apiKey: options.apiKey }),
1576
+ create: (body, options = {}) => transport.request(PATHS.CONTACTS, {
1577
+ method: HTTP_METHODS.POST,
1578
+ body,
1579
+ signal: options.signal,
1580
+ apiKey: options.apiKey
1581
+ }),
1582
+ update: (email, patch, options = {}) => transport.request(ContactPath(email), {
1583
+ method: HTTP_METHODS.PATCH,
1584
+ body: patch,
1585
+ repeatable: true,
1586
+ signal: options.signal,
1587
+ apiKey: options.apiKey
1588
+ }),
1589
+ delete: (email, options = {}) => transport.request(ContactPath(email), {
1590
+ method: HTTP_METHODS.DELETE,
1591
+ signal: options.signal,
1592
+ apiKey: options.apiKey
1593
+ }),
1594
+ setAudiences: (email, body, options = {}) => transport.request(ContactChildPath(email, SEGMENTS.AUDIENCES), {
1595
+ method: HTTP_METHODS.PUT,
1596
+ body,
1597
+ repeatable: true,
1598
+ signal: options.signal,
1599
+ apiKey: options.apiKey
1600
+ }),
1601
+ listPeople: async (options = {}) => {
1602
+ const payload = await transport.request(PATHS.CONTACTS_PEOPLE, {
1603
+ query: {
1604
+ ...PeopleQuery(options),
1605
+ [QUERY_KEYS.LIMIT]: options.limit,
1606
+ [CURSOR_STYLES.CURSOR.PARAM]: options.cursor
1607
+ },
1608
+ signal: options.signal,
1609
+ apiKey: options.apiKey
1610
+ });
1611
+ const next = payload?.[CURSOR_STYLES.CURSOR.FIELD];
1612
+ const nextCursor = typeof next === 'string' && next.length > 0 ? next : null;
1613
+ return {
1614
+ items: (Array.isArray(payload?.data) ? payload.data : []),
1615
+ hasMore: typeof payload?.hasMore === 'boolean' ? payload.hasMore : nextCursor !== null,
1616
+ nextCursor,
1617
+ seen: payload?.seen === true
1618
+ };
1619
+ },
1620
+ listAllPeople: (options = {}) => CollectAll(transport, PATHS.CONTACTS_PEOPLE, CURSOR_STYLES.CURSOR, options, PeopleQuery(options)),
1621
+ iteratePeople: (options = {}) => IteratePages(transport, PATHS.CONTACTS_PEOPLE, CURSOR_STYLES.CURSOR, options, PeopleQuery(options)),
1622
+ save: (email, body = {}, options = {}) => transport.request(ContactPath(email), {
1623
+ method: HTTP_METHODS.PUT,
1624
+ body,
1625
+ repeatable: true,
1626
+ signal: options.signal,
1627
+ apiKey: options.apiKey
1628
+ }),
1629
+ deleteMany: (emails, options = {}) => transport.request(PATHS.CONTACTS_BATCH_DELETE, {
1630
+ method: HTTP_METHODS.POST,
1631
+ body: { emails },
1632
+ repeatable: true,
1633
+ signal: options.signal,
1634
+ apiKey: options.apiKey
1635
+ }),
1636
+ setPhoto: (email, data, options = {}) => transport.request(ContactChildPath(email, SEGMENTS.PHOTO), {
1637
+ method: HTTP_METHODS.PUT,
1638
+ raw: data,
1639
+ contentType: PhotoType(data, options),
1640
+ repeatable: true,
1641
+ signal: options.signal,
1642
+ apiKey: options.apiKey
1643
+ }),
1644
+ removePhoto: (email, options = {}) => transport.request(ContactChildPath(email, SEGMENTS.PHOTO), {
1645
+ method: HTTP_METHODS.DELETE,
1646
+ repeatable: true,
1647
+ signal: options.signal,
1648
+ apiKey: options.apiKey
1649
+ }),
1650
+ block: (email, options = {}) => transport.request(ContactChildPath(email, SEGMENTS.BLOCK), {
1651
+ method: HTTP_METHODS.POST,
1652
+ repeatable: true,
1653
+ signal: options.signal,
1654
+ apiKey: options.apiKey
1655
+ }),
1656
+ unblock: (email, options = {}) => transport.request(ContactChildPath(email, SEGMENTS.BLOCK), {
1657
+ method: HTTP_METHODS.DELETE,
1658
+ repeatable: true,
1659
+ signal: options.signal,
1660
+ apiKey: options.apiKey
1661
+ }),
1662
+ listThreads: (email, options = {}) => FetchPage(transport, ContactChildPath(email, SEGMENTS.THREADS), CURSOR_STYLES.CURSOR, options, ThreadQuery(options)),
1663
+ listAllThreads: (email, options = {}) => CollectAll(transport, ContactChildPath(email, SEGMENTS.THREADS), CURSOR_STYLES.CURSOR, options, ThreadQuery(options)),
1664
+ iterateThreads: (email, options = {}) => IteratePages(transport, ContactChildPath(email, SEGMENTS.THREADS), CURSOR_STYLES.CURSOR, options, ThreadQuery(options)),
1665
+ activity: (email, options = {}) => transport.request(ContactChildPath(email, SEGMENTS.ACTIVITY), {
1666
+ query: ActivityQuery(options),
1667
+ signal: options.signal,
1668
+ apiKey: options.apiKey
1669
+ })
1088
1670
  });
1089
1671
 
1090
1672
  const Domains = (transport) => ({
1091
- list: (options = {}) => FetchList(transport, PATHS.DOMAINS, options),
1092
- get: (id, options = {}) => transport.request(DomainPath(id), { signal: options.signal, apiKey: options.apiKey })
1673
+ list: (options = {}) => FetchPage(transport, PATHS.DOMAINS, CURSOR_STYLES.CURSOR, options),
1674
+ listAll: (options = {}) => CollectAll(transport, PATHS.DOMAINS, CURSOR_STYLES.CURSOR, options),
1675
+ iterate: (options = {}) => IteratePages(transport, PATHS.DOMAINS, CURSOR_STYLES.CURSOR, options),
1676
+ get: (id, options = {}) => transport.request(DomainPath(id), { signal: options.signal, apiKey: options.apiKey }),
1677
+ update: (id, patch, options = {}) => transport.request(DomainPath(id), {
1678
+ method: HTTP_METHODS.PATCH,
1679
+ body: patch,
1680
+ repeatable: true,
1681
+ signal: options.signal,
1682
+ apiKey: options.apiKey
1683
+ })
1093
1684
  });
1094
1685
 
1095
- const ListQuery$4 = (options) => ({ [QUERY_KEYS.QUERY]: options.query });
1686
+ const ListQuery$8 = (options) => ({ [QUERY_KEYS.QUERY]: options.query });
1096
1687
  const Drafts = (transport) => ({
1097
- list: (options = {}) => FetchPage(transport, PATHS.DRAFTS, CURSOR_STYLES.PAGE_TOKEN, options, ListQuery$4(options)),
1098
- listAll: (options = {}) => CollectAll(transport, PATHS.DRAFTS, CURSOR_STYLES.PAGE_TOKEN, options, ListQuery$4(options)),
1099
- iterate: (options = {}) => IteratePages(transport, PATHS.DRAFTS, CURSOR_STYLES.PAGE_TOKEN, options, ListQuery$4(options)),
1688
+ list: (options = {}) => FetchPage(transport, PATHS.DRAFTS, CURSOR_STYLES.PAGE_TOKEN, options, ListQuery$8(options)),
1689
+ listAll: (options = {}) => CollectAll(transport, PATHS.DRAFTS, CURSOR_STYLES.PAGE_TOKEN, options, ListQuery$8(options)),
1690
+ iterate: (options = {}) => IteratePages(transport, PATHS.DRAFTS, CURSOR_STYLES.PAGE_TOKEN, options, ListQuery$8(options)),
1100
1691
  get: (id, options = {}) => transport.request(DraftPath(id), { signal: options.signal, apiKey: options.apiKey }),
1101
1692
  create: (body, options = {}) => transport.request(PATHS.DRAFTS, {
1102
1693
  method: HTTP_METHODS.POST,
@@ -1117,9 +1708,10 @@ const Drafts = (transport) => ({
1117
1708
  })
1118
1709
  });
1119
1710
 
1120
- const ListQuery$3 = (options) => ({
1711
+ const ListQuery$7 = (options) => ({
1121
1712
  [QUERY_KEYS.STATUS]: Array.isArray(options.status) ? options.status.join(LIST_SEPARATOR) : options.status,
1122
- [QUERY_KEYS.FROM]: options.from
1713
+ [QUERY_KEYS.FROM]: options.from,
1714
+ [QUERY_KEYS.BROADCAST_ID]: options.broadcastId
1123
1715
  });
1124
1716
  const Emails = (transport) => ({
1125
1717
  send: (body, options = {}) => transport.request(PATHS.EMAILS, {
@@ -1149,11 +1741,13 @@ const Emails = (transport) => ({
1149
1741
  signal: options.signal,
1150
1742
  apiKey: options.apiKey
1151
1743
  }),
1152
- list: (options = {}) => FetchPage(transport, PATHS.EMAILS, CURSOR_STYLES.CURSOR, options, ListQuery$3(options)),
1153
- listAll: (options = {}) => CollectAll(transport, PATHS.EMAILS, CURSOR_STYLES.CURSOR, options, ListQuery$3(options)),
1154
- iterate: (options = {}) => IteratePages(transport, PATHS.EMAILS, CURSOR_STYLES.CURSOR, options, ListQuery$3(options)),
1744
+ list: (options = {}) => FetchPage(transport, PATHS.EMAILS, CURSOR_STYLES.CURSOR, options, ListQuery$7(options)),
1745
+ listAll: (options = {}) => CollectAll(transport, PATHS.EMAILS, CURSOR_STYLES.CURSOR, options, ListQuery$7(options)),
1746
+ iterate: (options = {}) => IteratePages(transport, PATHS.EMAILS, CURSOR_STYLES.CURSOR, options, ListQuery$7(options)),
1155
1747
  get: (id, options = {}) => transport.request(EmailPath(id), { signal: options.signal, apiKey: options.apiKey }),
1156
- listEvents: (id, options = {}) => FetchList(transport, EmailChildPath(id, SEGMENTS.EVENTS), options),
1748
+ listEvents: (id, options = {}) => FetchPage(transport, EmailChildPath(id, SEGMENTS.EVENTS), CURSOR_STYLES.CURSOR, options),
1749
+ listAllEvents: (id, options = {}) => CollectAll(transport, EmailChildPath(id, SEGMENTS.EVENTS), CURSOR_STYLES.CURSOR, options),
1750
+ iterateEvents: (id, options = {}) => IteratePages(transport, EmailChildPath(id, SEGMENTS.EVENTS), CURSOR_STYLES.CURSOR, options),
1157
1751
  getTracking: (id, options = {}) => transport.request(EmailChildPath(id, SEGMENTS.TRACKING), { signal: options.signal, apiKey: options.apiKey }),
1158
1752
  cancel: (id, options = {}) => transport.request(EmailChildPath(id, SEGMENTS.CANCEL), {
1159
1753
  method: HTTP_METHODS.POST,
@@ -1170,8 +1764,206 @@ const Emails = (transport) => ({
1170
1764
  })
1171
1765
  });
1172
1766
 
1767
+ const ListQuery$6 = (options) => ({
1768
+ [QUERY_KEYS.Q]: options.q,
1769
+ [QUERY_KEYS.KIND]: options.kind,
1770
+ [QUERY_KEYS.SORT]: options.sort
1771
+ });
1772
+ const Files = (transport) => ({
1773
+ list: (options = {}) => FetchPage(transport, PATHS.FILES, CURSOR_STYLES.CURSOR, options, ListQuery$6(options)),
1774
+ listAll: (options = {}) => CollectAll(transport, PATHS.FILES, CURSOR_STYLES.CURSOR, options, ListQuery$6(options)),
1775
+ iterate: (options = {}) => IteratePages(transport, PATHS.FILES, CURSOR_STYLES.CURSOR, options, ListQuery$6(options)),
1776
+ get: (id, options = {}) => transport.request(FilePath(id), { signal: options.signal, apiKey: options.apiKey }),
1777
+ download: (id, options = {}) => transport.request(FileChildPath(id, SEGMENTS.CONTENT), {
1778
+ binary: true,
1779
+ signal: options.signal,
1780
+ apiKey: options.apiKey
1781
+ }),
1782
+ listLinks: (id, options = {}) => FetchPage(transport, FileChildPath(id, SEGMENTS.LINKS), CURSOR_STYLES.CURSOR, options),
1783
+ listAllLinks: (id, options = {}) => CollectAll(transport, FileChildPath(id, SEGMENTS.LINKS), CURSOR_STYLES.CURSOR, options),
1784
+ iterateLinks: (id, options = {}) => IteratePages(transport, FileChildPath(id, SEGMENTS.LINKS), CURSOR_STYLES.CURSOR, options),
1785
+ delete: (id, options = {}) => transport.request(FilePath(id), {
1786
+ method: HTTP_METHODS.DELETE,
1787
+ signal: options.signal,
1788
+ apiKey: options.apiKey
1789
+ })
1790
+ });
1791
+
1792
+ const ListQuery$5 = (options) => ({ addressId: options.addressId });
1793
+ const SizeOf = (data) => data instanceof Blob ? data.size : data.byteLength;
1794
+ const SliceOf = (data, start, end) => {
1795
+ if (data instanceof Blob)
1796
+ return data.slice(start, end);
1797
+ if (data instanceof Uint8Array)
1798
+ return data.subarray(start, end);
1799
+ return new Uint8Array(data, start, end - start);
1800
+ };
1801
+ const Imports = (transport) => {
1802
+ const create = (body, options = {}) => transport.request(PATHS.IMPORTS, {
1803
+ method: HTTP_METHODS.POST,
1804
+ body,
1805
+ signal: options.signal,
1806
+ apiKey: options.apiKey
1807
+ });
1808
+ const uploadChunk = (id, file, chunk, data, options = {}) => transport.request(ImportChunkPath(id, file, chunk), {
1809
+ method: HTTP_METHODS.PUT,
1810
+ raw: data,
1811
+ repeatable: true,
1812
+ signal: options.signal,
1813
+ apiKey: options.apiKey
1814
+ });
1815
+ const start = (id, options = {}) => transport.request(ImportChildPath(id, SEGMENTS.START), {
1816
+ method: HTTP_METHODS.POST,
1817
+ repeatable: true,
1818
+ signal: options.signal,
1819
+ apiKey: options.apiKey
1820
+ });
1821
+ return {
1822
+ list: (options = {}) => FetchPage(transport, PATHS.IMPORTS, CURSOR_STYLES.CURSOR, options, ListQuery$5(options)),
1823
+ listAll: (options = {}) => CollectAll(transport, PATHS.IMPORTS, CURSOR_STYLES.CURSOR, options, ListQuery$5(options)),
1824
+ iterate: (options = {}) => IteratePages(transport, PATHS.IMPORTS, CURSOR_STYLES.CURSOR, options, ListQuery$5(options)),
1825
+ get: (id, options = {}) => transport.request(ImportPath(id), { signal: options.signal, apiKey: options.apiKey }),
1826
+ create,
1827
+ uploadState: (id, options = {}) => transport.request(ImportChildPath(id, SEGMENTS.UPLOAD), {
1828
+ signal: options.signal,
1829
+ apiKey: options.apiKey
1830
+ }),
1831
+ uploadChunk,
1832
+ start,
1833
+ cancel: (id, options = {}) => transport.request(ImportChildPath(id, SEGMENTS.CANCEL), {
1834
+ method: HTTP_METHODS.POST,
1835
+ signal: options.signal,
1836
+ apiKey: options.apiKey
1837
+ }),
1838
+ listFailures: (id, options = {}) => transport.request(ImportChildPath(id, SEGMENTS.FAILURES), {
1839
+ query: { after: options.after, limit: options.limit },
1840
+ signal: options.signal,
1841
+ apiKey: options.apiKey
1842
+ }),
1843
+ deleteUpload: (id, options = {}) => transport.request(ImportChildPath(id, SEGMENTS.UPLOAD), {
1844
+ method: HTTP_METHODS.DELETE,
1845
+ signal: options.signal,
1846
+ apiKey: options.apiKey
1847
+ }),
1848
+ importFiles: async (input, options = {}) => {
1849
+ const created = await create({
1850
+ addressId: input.addressId,
1851
+ files: input.files.map(file => ({ name: file.name, bytes: SizeOf(file.data) })),
1852
+ options: input.options
1853
+ }, options);
1854
+ if (input.files.length === 0)
1855
+ return created;
1856
+ const total = created.totalBytes;
1857
+ let uploaded = 0;
1858
+ for (const [index, file] of input.files.entries()) {
1859
+ const chunks = created.files[index]?.chunks ?? 1;
1860
+ for (let chunk = 0; chunk < chunks; chunk++) {
1861
+ const begin = chunk * created.chunkBytes;
1862
+ const end = Math.min(SizeOf(file.data), begin + created.chunkBytes);
1863
+ await uploadChunk(created.id, index, chunk, SliceOf(file.data, begin, end), options);
1864
+ uploaded += end - begin;
1865
+ input.onProgress?.(uploaded, total);
1866
+ }
1867
+ }
1868
+ return start(created.id, options);
1869
+ }
1870
+ };
1871
+ };
1872
+
1873
+ const WindowQuery$2 = (options) => ({
1874
+ [QUERY_KEYS.SINCE]: options.since === undefined ? undefined : ToInstant(options.since),
1875
+ [QUERY_KEYS.UNTIL]: options.until === undefined ? undefined : ToInstant(options.until)
1876
+ });
1877
+ const RequestQuery = (options) => ({
1878
+ ...WindowQuery$2(options),
1879
+ [QUERY_KEYS.FAILED_ONLY]: options.failedOnly === undefined ? undefined : String(options.failedOnly)
1880
+ });
1881
+ const WorkspaceRequestQuery = (options) => ({
1882
+ ...RequestQuery(options),
1883
+ [QUERY_KEYS.KEY_IDS]: options.keyIds?.join(LIST_SEPARATOR)
1884
+ });
1885
+ const WorkspaceActivityQuery$1 = (options) => ({
1886
+ ...WindowQuery$2(options),
1887
+ [QUERY_KEYS.KEY_IDS]: options.keyIds?.join(LIST_SEPARATOR)
1888
+ });
1889
+ const Keys = (transport) => ({
1890
+ list: (options = {}) => FetchPage(transport, PATHS.KEYS, CURSOR_STYLES.CURSOR, options),
1891
+ listAll: (options = {}) => CollectAll(transport, PATHS.KEYS, CURSOR_STYLES.CURSOR, options),
1892
+ iterate: (options = {}) => IteratePages(transport, PATHS.KEYS, CURSOR_STYLES.CURSOR, options),
1893
+ get: (id, options = {}) => transport.request(KeyPath(id), { signal: options.signal, apiKey: options.apiKey }),
1894
+ create: (body, options = {}) => transport.request(PATHS.KEYS, {
1895
+ method: HTTP_METHODS.POST,
1896
+ body,
1897
+ signal: options.signal,
1898
+ apiKey: options.apiKey
1899
+ }),
1900
+ update: (id, patch, options = {}) => transport.request(KeyPath(id), {
1901
+ method: HTTP_METHODS.PATCH,
1902
+ body: patch,
1903
+ repeatable: true,
1904
+ signal: options.signal,
1905
+ apiKey: options.apiKey
1906
+ }),
1907
+ delete: (id, options = {}) => transport.request(KeyPath(id), {
1908
+ method: HTTP_METHODS.DELETE,
1909
+ signal: options.signal,
1910
+ apiKey: options.apiKey
1911
+ }),
1912
+ rotate: (id, options = {}) => transport.request(KeyChildPath(id, SEGMENTS.ROTATE), {
1913
+ method: HTTP_METHODS.POST,
1914
+ signal: options.signal,
1915
+ apiKey: options.apiKey
1916
+ }),
1917
+ revoke: (id, body = {}, options = {}) => transport.request(KeyChildPath(id, SEGMENTS.REVOKE), {
1918
+ method: HTTP_METHODS.POST,
1919
+ body,
1920
+ repeatable: true,
1921
+ signal: options.signal,
1922
+ apiKey: options.apiKey
1923
+ }),
1924
+ listRequests: (id, options = {}) => FetchPage(transport, KeyChildPath(id, SEGMENTS.REQUESTS), CURSOR_STYLES.CURSOR, options, RequestQuery(options)),
1925
+ listAllRequests: (id, options = {}) => CollectAll(transport, KeyChildPath(id, SEGMENTS.REQUESTS), CURSOR_STYLES.CURSOR, options, RequestQuery(options)),
1926
+ iterateRequests: (id, options = {}) => IteratePages(transport, KeyChildPath(id, SEGMENTS.REQUESTS), CURSOR_STYLES.CURSOR, options, RequestQuery(options)),
1927
+ listActivity: (id, options = {}) => FetchPage(transport, KeyChildPath(id, SEGMENTS.ACTIVITY), CURSOR_STYLES.CURSOR, options, WindowQuery$2(options)),
1928
+ listAllActivity: (id, options = {}) => CollectAll(transport, KeyChildPath(id, SEGMENTS.ACTIVITY), CURSOR_STYLES.CURSOR, options, WindowQuery$2(options)),
1929
+ iterateActivity: (id, options = {}) => IteratePages(transport, KeyChildPath(id, SEGMENTS.ACTIVITY), CURSOR_STYLES.CURSOR, options, WindowQuery$2(options)),
1930
+ listWorkspaceRequests: (options = {}) => FetchPage(transport, PATHS.KEYS_REQUESTS, CURSOR_STYLES.CURSOR, options, WorkspaceRequestQuery(options)),
1931
+ listAllWorkspaceRequests: (options = {}) => CollectAll(transport, PATHS.KEYS_REQUESTS, CURSOR_STYLES.CURSOR, options, WorkspaceRequestQuery(options)),
1932
+ iterateWorkspaceRequests: (options = {}) => IteratePages(transport, PATHS.KEYS_REQUESTS, CURSOR_STYLES.CURSOR, options, WorkspaceRequestQuery(options)),
1933
+ listWorkspaceActivity: (options = {}) => FetchPage(transport, PATHS.KEYS_ACTIVITY, CURSOR_STYLES.CURSOR, options, WorkspaceActivityQuery$1(options)),
1934
+ listAllWorkspaceActivity: (options = {}) => CollectAll(transport, PATHS.KEYS_ACTIVITY, CURSOR_STYLES.CURSOR, options, WorkspaceActivityQuery$1(options)),
1935
+ iterateWorkspaceActivity: (options = {}) => IteratePages(transport, PATHS.KEYS_ACTIVITY, CURSOR_STYLES.CURSOR, options, WorkspaceActivityQuery$1(options))
1936
+ });
1937
+
1938
+ const ProviderImports = (transport) => ({
1939
+ inspect: (apiKey, options = {}) => transport.request(PATHS.PROVIDER_IMPORTS_INSPECT, {
1940
+ method: HTTP_METHODS.POST,
1941
+ body: { apiKey },
1942
+ signal: options.signal,
1943
+ apiKey: options.apiKey
1944
+ }),
1945
+ create: (body, options = {}) => transport.request(PATHS.PROVIDER_IMPORTS, {
1946
+ method: HTTP_METHODS.POST,
1947
+ body,
1948
+ signal: options.signal,
1949
+ apiKey: options.apiKey
1950
+ }),
1951
+ list: (options = {}) => FetchPage(transport, PATHS.PROVIDER_IMPORTS, CURSOR_STYLES.CURSOR, options),
1952
+ listAll: (options = {}) => CollectAll(transport, PATHS.PROVIDER_IMPORTS, CURSOR_STYLES.CURSOR, options),
1953
+ iterate: (options = {}) => IteratePages(transport, PATHS.PROVIDER_IMPORTS, CURSOR_STYLES.CURSOR, options),
1954
+ get: (id, options = {}) => transport.request(ProviderImportPath(id), { signal: options.signal, apiKey: options.apiKey }),
1955
+ cancel: (id, options = {}) => transport.request(ProviderImportChildPath(id, SEGMENTS.CANCEL), {
1956
+ method: HTTP_METHODS.POST,
1957
+ signal: options.signal,
1958
+ apiKey: options.apiKey
1959
+ })
1960
+ });
1961
+
1173
1962
  const Labels = (transport) => ({
1174
- list: (options = {}) => FetchList(transport, PATHS.LABELS, options),
1963
+ list: (options = {}) => FetchPage(transport, PATHS.LABELS, CURSOR_STYLES.CURSOR, options),
1964
+ listAll: (options = {}) => CollectAll(transport, PATHS.LABELS, CURSOR_STYLES.CURSOR, options),
1965
+ iterate: (options = {}) => IteratePages(transport, PATHS.LABELS, CURSOR_STYLES.CURSOR, options),
1966
+ listColors: (options = {}) => FetchList(transport, PATHS.LABELS_COLORS, options),
1175
1967
  get: (id, options = {}) => transport.request(LabelPath(id), { signal: options.signal, apiKey: options.apiKey }),
1176
1968
  create: (body, options = {}) => transport.request(PATHS.LABELS, {
1177
1969
  method: HTTP_METHODS.POST,
@@ -1179,9 +1971,9 @@ const Labels = (transport) => ({
1179
1971
  signal: options.signal,
1180
1972
  apiKey: options.apiKey
1181
1973
  }),
1182
- update: (id, body, options = {}) => transport.request(LabelPath(id), {
1974
+ update: (id, patch, options = {}) => transport.request(LabelPath(id), {
1183
1975
  method: HTTP_METHODS.PATCH,
1184
- body,
1976
+ body: patch,
1185
1977
  repeatable: true,
1186
1978
  signal: options.signal,
1187
1979
  apiKey: options.apiKey
@@ -1199,11 +1991,18 @@ const Languages = (transport) => ({
1199
1991
 
1200
1992
  const Me = (transport) => ({
1201
1993
  get: (options = {}) => transport.request(PATHS.KEYS_SELF, { signal: options.signal, apiKey: options.apiKey }),
1202
- ping: (options = {}) => transport.request(PATHS.PING, { signal: options.signal, apiKey: options.apiKey })
1994
+ ping: (options = {}) => transport.request(PATHS.PING, { signal: options.signal, apiKey: options.apiKey }),
1995
+ rotate: (options = {}) => transport.request(PATHS.KEYS_SELF_ROTATE, {
1996
+ method: HTTP_METHODS.POST,
1997
+ signal: options.signal,
1998
+ apiKey: options.apiKey
1999
+ })
1203
2000
  });
1204
2001
 
1205
2002
  const Members = (transport) => ({
1206
- list: (options = {}) => FetchList(transport, PATHS.MEMBERS, options),
2003
+ list: (options = {}) => FetchPage(transport, PATHS.MEMBERS, CURSOR_STYLES.CURSOR, options),
2004
+ listAll: (options = {}) => CollectAll(transport, PATHS.MEMBERS, CURSOR_STYLES.CURSOR, options),
2005
+ iterate: (options = {}) => IteratePages(transport, PATHS.MEMBERS, CURSOR_STYLES.CURSOR, options),
1207
2006
  get: (userId, options = {}) => transport.request(MemberPath(userId), { signal: options.signal, apiKey: options.apiKey }),
1208
2007
  add: (body, options = {}) => transport.request(PATHS.MEMBERS, {
1209
2008
  method: HTTP_METHODS.POST,
@@ -1234,11 +2033,26 @@ const Members = (transport) => ({
1234
2033
  method: HTTP_METHODS.DELETE,
1235
2034
  signal: options.signal,
1236
2035
  apiKey: options.apiKey
2036
+ }),
2037
+ listInvitations: (options = {}) => FetchPage(transport, PATHS.MEMBERS_INVITATIONS, CURSOR_STYLES.CURSOR, options),
2038
+ listAllInvitations: (options = {}) => CollectAll(transport, PATHS.MEMBERS_INVITATIONS, CURSOR_STYLES.CURSOR, options),
2039
+ iterateInvitations: (options = {}) => IteratePages(transport, PATHS.MEMBERS_INVITATIONS, CURSOR_STYLES.CURSOR, options),
2040
+ revokeInvitation: (invitationId, options = {}) => transport.request(MemberInvitationPath(invitationId), {
2041
+ method: HTTP_METHODS.DELETE,
2042
+ signal: options.signal,
2043
+ apiKey: options.apiKey
2044
+ }),
2045
+ resendInvitation: (invitationId, options = {}) => transport.request(MemberInvitationResendPath(invitationId), {
2046
+ method: HTTP_METHODS.POST,
2047
+ signal: options.signal,
2048
+ apiKey: options.apiKey
1237
2049
  })
1238
2050
  });
1239
2051
 
1240
2052
  const Roles = (transport) => ({
1241
- list: (options = {}) => FetchList(transport, PATHS.ROLES, options),
2053
+ list: (options = {}) => FetchPage(transport, PATHS.ROLES, CURSOR_STYLES.CURSOR, options),
2054
+ listAll: (options = {}) => CollectAll(transport, PATHS.ROLES, CURSOR_STYLES.CURSOR, options),
2055
+ iterate: (options = {}) => IteratePages(transport, PATHS.ROLES, CURSOR_STYLES.CURSOR, options),
1242
2056
  get: (id, options = {}) => transport.request(RolePath(id), { signal: options.signal, apiKey: options.apiKey }),
1243
2057
  create: (body, options = {}) => transport.request(PATHS.ROLES, {
1244
2058
  method: HTTP_METHODS.POST,
@@ -1262,7 +2076,7 @@ const Roles = (transport) => ({
1262
2076
  listPermissions: (options = {}) => FetchList(transport, PATHS.ROLES_PERMISSIONS, options)
1263
2077
  });
1264
2078
 
1265
- const ListQuery$2 = (options) => ({
2079
+ const ListQuery$4 = (options) => ({
1266
2080
  [QUERY_KEYS.ENABLED]: options.enabled === undefined ? undefined : String(options.enabled)
1267
2081
  });
1268
2082
  const RunsQuery = (options) => ({
@@ -1270,9 +2084,9 @@ const RunsQuery = (options) => ({
1270
2084
  [QUERY_KEYS.THREAD_ID]: options.threadId
1271
2085
  });
1272
2086
  const Rules = (transport) => ({
1273
- list: (options = {}) => FetchPage(transport, PATHS.RULES, CURSOR_STYLES.CURSOR, options, ListQuery$2(options)),
1274
- listAll: (options = {}) => CollectAll(transport, PATHS.RULES, CURSOR_STYLES.CURSOR, options, ListQuery$2(options)),
1275
- iterate: (options = {}) => IteratePages(transport, PATHS.RULES, CURSOR_STYLES.CURSOR, options, ListQuery$2(options)),
2087
+ list: (options = {}) => FetchPage(transport, PATHS.RULES, CURSOR_STYLES.CURSOR, options, ListQuery$4(options)),
2088
+ listAll: (options = {}) => CollectAll(transport, PATHS.RULES, CURSOR_STYLES.CURSOR, options, ListQuery$4(options)),
2089
+ iterate: (options = {}) => IteratePages(transport, PATHS.RULES, CURSOR_STYLES.CURSOR, options, ListQuery$4(options)),
1276
2090
  get: (id, options = {}) => transport.request(RulePath(id), { signal: options.signal, apiKey: options.apiKey }),
1277
2091
  create: (body, options = {}) => transport.request(PATHS.RULES, {
1278
2092
  method: HTTP_METHODS.POST,
@@ -1314,9 +2128,14 @@ const Rules = (transport) => ({
1314
2128
  });
1315
2129
 
1316
2130
  const Settings = (transport) => ({
1317
- get: (options = {}) => transport.request(PATHS.SETTINGS, { signal: options.signal, apiKey: options.apiKey }),
2131
+ get: (options = {}) => transport.request(PATHS.SETTINGS, {
2132
+ query: { [QUERY_KEYS.ADDRESS]: options.address },
2133
+ signal: options.signal,
2134
+ apiKey: options.apiKey
2135
+ }),
1318
2136
  update: (patch, options = {}) => transport.request(PATHS.SETTINGS, {
1319
2137
  method: HTTP_METHODS.PATCH,
2138
+ query: { [QUERY_KEYS.ADDRESS]: options.address },
1320
2139
  body: patch,
1321
2140
  repeatable: true,
1322
2141
  signal: options.signal,
@@ -1324,6 +2143,54 @@ const Settings = (transport) => ({
1324
2143
  })
1325
2144
  });
1326
2145
 
2146
+ const ListQuery$3 = (options) => ({
2147
+ [QUERY_KEYS.Q]: options.q,
2148
+ [QUERY_KEYS.REASON]: options.reason
2149
+ });
2150
+ const Suppressions = (transport) => ({
2151
+ list: (options = {}) => FetchPage(transport, PATHS.SUPPRESSIONS, CURSOR_STYLES.CURSOR, options, ListQuery$3(options)),
2152
+ listAll: (options = {}) => CollectAll(transport, PATHS.SUPPRESSIONS, CURSOR_STYLES.CURSOR, options, ListQuery$3(options)),
2153
+ iterate: (options = {}) => IteratePages(transport, PATHS.SUPPRESSIONS, CURSOR_STYLES.CURSOR, options, ListQuery$3(options)),
2154
+ get: (id, options = {}) => transport.request(SuppressionPath(id), { signal: options.signal, apiKey: options.apiKey }),
2155
+ add: (body, options = {}) => transport.request(PATHS.SUPPRESSIONS, {
2156
+ method: HTTP_METHODS.POST,
2157
+ body,
2158
+ repeatable: true,
2159
+ signal: options.signal,
2160
+ apiKey: options.apiKey
2161
+ }),
2162
+ remove: (id, options = {}) => transport.request(SuppressionPath(id), {
2163
+ method: HTTP_METHODS.DELETE,
2164
+ signal: options.signal,
2165
+ apiKey: options.apiKey
2166
+ })
2167
+ });
2168
+
2169
+ const MessagePage = async (transport, inboxId, options) => {
2170
+ const envelope = await transport.request(TempMessagesPath(inboxId), {
2171
+ query: { [QUERY_KEYS.LIMIT]: options.limit, [QUERY_KEYS.CURSOR]: options.cursor },
2172
+ inboxToken: options.inboxToken,
2173
+ signal: options.signal
2174
+ });
2175
+ const nextCursor = typeof envelope?.nextCursor === 'string' && envelope.nextCursor.length > 0 ? envelope.nextCursor : null;
2176
+ return {
2177
+ items: envelope?.data ?? [],
2178
+ hasMore: typeof envelope?.hasMore === 'boolean' ? envelope.hasMore : nextCursor !== null,
2179
+ nextCursor,
2180
+ expiresAt: envelope?.expiresAt
2181
+ };
2182
+ };
2183
+ const IterateMessages = async function* (transport, inboxId, options) {
2184
+ let cursor = options.cursor;
2185
+ for (;;) {
2186
+ const page = await MessagePage(transport, inboxId, { ...options, cursor });
2187
+ for (const item of page.items)
2188
+ yield item;
2189
+ if (!page.hasMore || !page.nextCursor || page.nextCursor === cursor)
2190
+ return;
2191
+ cursor = page.nextCursor;
2192
+ }
2193
+ };
1327
2194
  const TempMail = (transport) => ({
1328
2195
  listDomains: async (options = {}) => (await transport.request(PATHS.TEMP_MAIL_DOMAINS, {
1329
2196
  anonymous: true,
@@ -1349,14 +2216,14 @@ const TempMail = (transport) => ({
1349
2216
  inboxToken: options.inboxToken,
1350
2217
  signal: options.signal
1351
2218
  }),
1352
- listMessages: async (inboxId, options = {}) => {
1353
- const envelope = await transport.request(TempMessagesPath(inboxId), {
1354
- query: { [QUERY_KEYS.LIMIT]: options.limit },
1355
- inboxToken: options.inboxToken,
1356
- signal: options.signal
1357
- });
1358
- return { items: envelope?.data ?? [], expiresAt: envelope?.expiresAt };
2219
+ listMessages: (inboxId, options = {}) => MessagePage(transport, inboxId, options),
2220
+ listAllMessages: async (inboxId, options = {}) => {
2221
+ const all = [];
2222
+ for await (const message of IterateMessages(transport, inboxId, options))
2223
+ all.push(message);
2224
+ return all;
1359
2225
  },
2226
+ iterateMessages: (inboxId, options = {}) => IterateMessages(transport, inboxId, options),
1360
2227
  getMessage: (inboxId, messageId, options = {}) => transport.request(TempMessagePath(inboxId, messageId), {
1361
2228
  inboxToken: options.inboxToken,
1362
2229
  signal: options.signal
@@ -1372,11 +2239,32 @@ const TempMail = (transport) => ({
1372
2239
  }))?.data ?? []
1373
2240
  });
1374
2241
 
1375
- const ListQuery$1 = (options) => ({ [QUERY_KEYS.STATUS]: options.status });
2242
+ const ListQuery$2 = (options) => ({
2243
+ [QUERY_KEYS.STATUS]: options.status,
2244
+ [QUERY_KEYS.SEARCH]: options.search,
2245
+ [QUERY_KEYS.SORT]: options.sort
2246
+ });
2247
+ const Flag$1 = (value) => value === undefined ? undefined : String(value);
2248
+ const WindowQuery$1 = (options) => ({
2249
+ [QUERY_KEYS.DAYS]: options.days,
2250
+ [QUERY_KEYS.MINUTES]: options.minutes,
2251
+ [QUERY_KEYS.GRAIN]: options.grain,
2252
+ [QUERY_KEYS.OFFSET_MINUTES]: options.offsetMinutes
2253
+ });
1376
2254
  const Templates = (transport) => ({
1377
- list: (options = {}) => FetchPage(transport, PATHS.TEMPLATES, CURSOR_STYLES.CURSOR, options, ListQuery$1(options)),
1378
- listAll: (options = {}) => CollectAll(transport, PATHS.TEMPLATES, CURSOR_STYLES.CURSOR, options, ListQuery$1(options)),
1379
- iterate: (options = {}) => IteratePages(transport, PATHS.TEMPLATES, CURSOR_STYLES.CURSOR, options, ListQuery$1(options)),
2255
+ list: (options = {}) => FetchPage(transport, PATHS.TEMPLATES, CURSOR_STYLES.CURSOR, options, ListQuery$2(options)),
2256
+ listAll: (options = {}) => CollectAll(transport, PATHS.TEMPLATES, CURSOR_STYLES.CURSOR, options, ListQuery$2(options)),
2257
+ iterate: (options = {}) => IteratePages(transport, PATHS.TEMPLATES, CURSOR_STYLES.CURSOR, options, ListQuery$2(options)),
2258
+ listStarters: (options = {}) => FetchList(transport, PATHS.TEMPLATES_STARTERS, options),
2259
+ listFonts: (options = {}) => FetchList(transport, PATHS.TEMPLATES_FONTS, options),
2260
+ getStarter: (slug, options = {}) => transport.request(TemplateStarterPath(slug), { signal: options.signal, apiKey: options.apiKey }),
2261
+ render: (body, options = {}) => transport.request(PATHS.TEMPLATES_RENDER, {
2262
+ method: HTTP_METHODS.POST,
2263
+ body,
2264
+ repeatable: true,
2265
+ signal: options.signal,
2266
+ apiKey: options.apiKey
2267
+ }),
1380
2268
  get: (idOrSlug, options = {}) => transport.request(TemplatePath(idOrSlug), { signal: options.signal, apiKey: options.apiKey }),
1381
2269
  create: (body, options = {}) => transport.request(PATHS.TEMPLATES, {
1382
2270
  method: HTTP_METHODS.POST,
@@ -1395,7 +2283,33 @@ const Templates = (transport) => ({
1395
2283
  signal: options.signal,
1396
2284
  apiKey: options.apiKey
1397
2285
  }),
1398
- listVersions: (idOrSlug, options = {}) => FetchList(transport, TemplateChildPath(idOrSlug, SEGMENTS.VERSIONS), options),
2286
+ duplicate: (idOrSlug, body = {}, options = {}) => transport.request(TemplateChildPath(idOrSlug, SEGMENTS.DUPLICATE), {
2287
+ method: HTTP_METHODS.POST,
2288
+ body,
2289
+ signal: options.signal,
2290
+ apiKey: options.apiKey
2291
+ }),
2292
+ replaceContent: (idOrSlug, body, options = {}) => transport.request(TemplateChildPath(idOrSlug, SEGMENTS.CONTENT), {
2293
+ method: HTTP_METHODS.POST,
2294
+ body,
2295
+ signal: options.signal,
2296
+ apiKey: options.apiKey
2297
+ }),
2298
+ listVersions: (idOrSlug, options = {}) => FetchPage(transport, TemplateChildPath(idOrSlug, SEGMENTS.VERSIONS), CURSOR_STYLES.CURSOR, options),
2299
+ listAllVersions: (idOrSlug, options = {}) => CollectAll(transport, TemplateChildPath(idOrSlug, SEGMENTS.VERSIONS), CURSOR_STYLES.CURSOR, options),
2300
+ iterateVersions: (idOrSlug, options = {}) => IteratePages(transport, TemplateChildPath(idOrSlug, SEGMENTS.VERSIONS), CURSOR_STYLES.CURSOR, options),
2301
+ getVersion: (idOrSlug, version, options = {}) => transport.request(TemplateVersionPath(idOrSlug, version), { signal: options.signal, apiKey: options.apiKey }),
2302
+ deleteVersion: (idOrSlug, version, options = {}) => transport.request(TemplateVersionPath(idOrSlug, version), {
2303
+ method: HTTP_METHODS.DELETE,
2304
+ signal: options.signal,
2305
+ apiKey: options.apiKey
2306
+ }),
2307
+ restoreVersion: (idOrSlug, version, body = {}, options = {}) => transport.request(TemplateVersionChildPath(idOrSlug, version, SEGMENTS.RESTORE), {
2308
+ method: HTTP_METHODS.POST,
2309
+ body,
2310
+ signal: options.signal,
2311
+ apiKey: options.apiKey
2312
+ }),
1399
2313
  publish: (idOrSlug, options = {}) => transport.request(TemplateChildPath(idOrSlug, SEGMENTS.VERSIONS), {
1400
2314
  method: HTTP_METHODS.POST,
1401
2315
  repeatable: true,
@@ -1409,6 +2323,34 @@ const Templates = (transport) => ({
1409
2323
  signal: options.signal,
1410
2324
  apiKey: options.apiKey
1411
2325
  }),
2326
+ getAnalytics: (idOrSlug, options = {}) => transport.request(TemplateChildPath(idOrSlug, SEGMENTS.ANALYTICS), {
2327
+ query: WindowQuery$1(options),
2328
+ signal: options.signal,
2329
+ apiKey: options.apiKey
2330
+ }),
2331
+ listSends: async (idOrSlug, options = {}) => {
2332
+ const envelope = await transport.request(TemplateChildPath(idOrSlug, SEGMENTS.SENDS), {
2333
+ query: {
2334
+ ...WindowQuery$1(options),
2335
+ [QUERY_KEYS.PAGE]: options.page,
2336
+ [QUERY_KEYS.PAGE_SIZE]: options.pageSize,
2337
+ [QUERY_KEYS.SEARCH]: options.search,
2338
+ [QUERY_KEYS.SOURCE]: options.source,
2339
+ [QUERY_KEYS.VERSION]: options.version,
2340
+ [QUERY_KEYS.OPENED]: Flag$1(options.opened),
2341
+ [QUERY_KEYS.CLICKED]: Flag$1(options.clicked),
2342
+ [QUERY_KEYS.TRACKED]: Flag$1(options.tracked)
2343
+ },
2344
+ signal: options.signal,
2345
+ apiKey: options.apiKey
2346
+ });
2347
+ return {
2348
+ items: envelope?.data ?? [],
2349
+ total: envelope?.total ?? 0,
2350
+ page: envelope?.page ?? 1,
2351
+ pageSize: envelope?.pageSize ?? 0
2352
+ };
2353
+ },
1412
2354
  send: (idOrSlug, body, options = {}) => transport.request(TemplateChildPath(idOrSlug, SEGMENTS.SEND), {
1413
2355
  method: HTTP_METHODS.POST,
1414
2356
  body: TemplateSendToWire(body),
@@ -1420,15 +2362,19 @@ const Templates = (transport) => ({
1420
2362
  })
1421
2363
  });
1422
2364
 
1423
- const ListQuery = (options) => ({
2365
+ const ListQuery$1 = (options) => ({
1424
2366
  [QUERY_KEYS.FOLDER]: options.folder,
1425
2367
  [QUERY_KEYS.QUERY]: options.query,
1426
- [QUERY_KEYS.LABEL_IDS]: Array.isArray(options.labelIds) ? options.labelIds.join(LIST_SEPARATOR) : options.labelIds
2368
+ [QUERY_KEYS.LABEL_IDS]: Array.isArray(options.labelIds) ? options.labelIds.join(LIST_SEPARATOR) : options.labelIds,
2369
+ [QUERY_KEYS.SORT]: options.sort,
2370
+ [QUERY_KEYS.DATE_FROM]: options.dateFrom === undefined ? undefined : ToInstant(options.dateFrom),
2371
+ [QUERY_KEYS.DATE_TO]: options.dateTo === undefined ? undefined : ToInstant(options.dateTo),
2372
+ [QUERY_KEYS.FROM_CONTACTS]: options.fromContacts === undefined ? undefined : String(options.fromContacts)
1427
2373
  });
1428
2374
  const Threads = (transport) => ({
1429
- list: (options = {}) => FetchPage(transport, PATHS.THREADS, CURSOR_STYLES.PAGE_TOKEN, options, ListQuery(options)),
1430
- listAll: (options = {}) => CollectAll(transport, PATHS.THREADS, CURSOR_STYLES.PAGE_TOKEN, options, ListQuery(options)),
1431
- iterate: (options = {}) => IteratePages(transport, PATHS.THREADS, CURSOR_STYLES.PAGE_TOKEN, options, ListQuery(options)),
2375
+ list: (options = {}) => FetchPage(transport, PATHS.THREADS, CURSOR_STYLES.PAGE_TOKEN, options, ListQuery$1(options)),
2376
+ listAll: (options = {}) => CollectAll(transport, PATHS.THREADS, CURSOR_STYLES.PAGE_TOKEN, options, ListQuery$1(options)),
2377
+ iterate: (options = {}) => IteratePages(transport, PATHS.THREADS, CURSOR_STYLES.PAGE_TOKEN, options, ListQuery$1(options)),
1432
2378
  get: (id, options = {}) => transport.request(ThreadPath(id), { signal: options.signal, apiKey: options.apiKey }),
1433
2379
  update: (id, patch, options = {}) => transport.request(ThreadPath(id), {
1434
2380
  method: HTTP_METHODS.PATCH,
@@ -1461,18 +2407,19 @@ const Threads = (transport) => ({
1461
2407
 
1462
2408
  const Flag = (value) => value === undefined ? undefined : String(value);
1463
2409
  const HitQuery = (options) => ({
1464
- [QUERY_KEYS.INCLUDE_MACHINE]: Flag(options.includeMachine),
1465
- [QUERY_KEYS.LIMIT]: options.limit
2410
+ [QUERY_KEYS.INCLUDE_MACHINE]: Flag(options.includeMachine)
2411
+ });
2412
+ const ListQuery = (options) => ({
2413
+ [QUERY_KEYS.OPENED]: Flag(options.opened),
2414
+ [QUERY_KEYS.CLICKED]: Flag(options.clicked),
2415
+ [QUERY_KEYS.DAYS]: options.days,
2416
+ [QUERY_KEYS.MINUTES]: options.minutes,
2417
+ [QUERY_KEYS.GRAIN]: options.grain
1466
2418
  });
1467
2419
  const Tracking = (transport) => ({
1468
- list: (options = {}) => FetchList(transport, PATHS.TRACKING, options, {
1469
- [QUERY_KEYS.OPENED]: Flag(options.opened),
1470
- [QUERY_KEYS.CLICKED]: Flag(options.clicked),
1471
- [QUERY_KEYS.DAYS]: options.days,
1472
- [QUERY_KEYS.MINUTES]: options.minutes,
1473
- [QUERY_KEYS.GRAIN]: options.grain,
1474
- [QUERY_KEYS.LIMIT]: options.limit
1475
- }),
2420
+ list: (options = {}) => FetchPage(transport, PATHS.TRACKING, CURSOR_STYLES.CURSOR, options, ListQuery(options)),
2421
+ listAll: (options = {}) => CollectAll(transport, PATHS.TRACKING, CURSOR_STYLES.CURSOR, options, ListQuery(options)),
2422
+ iterate: (options = {}) => IteratePages(transport, PATHS.TRACKING, CURSOR_STYLES.CURSOR, options, ListQuery(options)),
1476
2423
  getStats: (options = {}) => transport.request(PATHS.TRACKING_STATS, {
1477
2424
  query: {
1478
2425
  [QUERY_KEYS.DAYS]: options.days,
@@ -1484,12 +2431,34 @@ const Tracking = (transport) => ({
1484
2431
  apiKey: options.apiKey
1485
2432
  }),
1486
2433
  get: (id, options = {}) => transport.request(TrackingPath(id), { signal: options.signal, apiKey: options.apiKey }),
1487
- listOpens: (id, options = {}) => FetchList(transport, TrackingChildPath(id, SEGMENTS.OPENS), options, HitQuery(options)),
1488
- listClicks: (id, options = {}) => FetchList(transport, TrackingChildPath(id, SEGMENTS.CLICKS), options, HitQuery(options))
2434
+ listOpens: (id, options = {}) => FetchPage(transport, TrackingChildPath(id, SEGMENTS.OPENS), CURSOR_STYLES.CURSOR, options, HitQuery(options)),
2435
+ listAllOpens: (id, options = {}) => CollectAll(transport, TrackingChildPath(id, SEGMENTS.OPENS), CURSOR_STYLES.CURSOR, options, HitQuery(options)),
2436
+ iterateOpens: (id, options = {}) => IteratePages(transport, TrackingChildPath(id, SEGMENTS.OPENS), CURSOR_STYLES.CURSOR, options, HitQuery(options)),
2437
+ listClicks: (id, options = {}) => FetchPage(transport, TrackingChildPath(id, SEGMENTS.CLICKS), CURSOR_STYLES.CURSOR, options, HitQuery(options)),
2438
+ listAllClicks: (id, options = {}) => CollectAll(transport, TrackingChildPath(id, SEGMENTS.CLICKS), CURSOR_STYLES.CURSOR, options, HitQuery(options)),
2439
+ iterateClicks: (id, options = {}) => IteratePages(transport, TrackingChildPath(id, SEGMENTS.CLICKS), CURSOR_STYLES.CURSOR, options, HitQuery(options))
1489
2440
  });
1490
2441
 
2442
+ const WindowQuery = (options) => ({
2443
+ [QUERY_KEYS.SINCE]: options.since === undefined ? undefined : ToInstant(options.since),
2444
+ [QUERY_KEYS.UNTIL]: options.until === undefined ? undefined : ToInstant(options.until)
2445
+ });
2446
+ const DeliveryQuery = (options) => ({
2447
+ ...WindowQuery(options),
2448
+ [QUERY_KEYS.STATUS]: options.status
2449
+ });
2450
+ const WorkspaceDeliveryQuery = (options) => ({
2451
+ ...DeliveryQuery(options),
2452
+ [QUERY_KEYS.ENDPOINT_IDS]: options.endpointIds?.join(LIST_SEPARATOR)
2453
+ });
2454
+ const WorkspaceActivityQuery = (options) => ({
2455
+ ...WindowQuery(options),
2456
+ [QUERY_KEYS.ENDPOINT_IDS]: options.endpointIds?.join(LIST_SEPARATOR)
2457
+ });
1491
2458
  const Webhooks = (transport) => ({
1492
- list: (options = {}) => FetchList(transport, PATHS.WEBHOOKS, options),
2459
+ list: (options = {}) => FetchPage(transport, PATHS.WEBHOOKS, CURSOR_STYLES.CURSOR, options),
2460
+ listAll: (options = {}) => CollectAll(transport, PATHS.WEBHOOKS, CURSOR_STYLES.CURSOR, options),
2461
+ iterate: (options = {}) => IteratePages(transport, PATHS.WEBHOOKS, CURSOR_STYLES.CURSOR, options),
1493
2462
  get: (id, options = {}) => transport.request(WebhookPath(id), { signal: options.signal, apiKey: options.apiKey }),
1494
2463
  create: (body, options = {}) => transport.request(PATHS.WEBHOOKS, {
1495
2464
  method: HTTP_METHODS.POST,
@@ -1519,13 +2488,34 @@ const Webhooks = (transport) => ({
1519
2488
  signal: options.signal,
1520
2489
  apiKey: options.apiKey
1521
2490
  }),
1522
- listDeliveries: (id, options = {}) => FetchList(transport, WebhookChildPath(id, SEGMENTS.DELIVERIES), options)
2491
+ listDeliveries: (id, options = {}) => FetchPage(transport, WebhookChildPath(id, SEGMENTS.DELIVERIES), CURSOR_STYLES.CURSOR, options, DeliveryQuery(options)),
2492
+ listAllDeliveries: (id, options = {}) => CollectAll(transport, WebhookChildPath(id, SEGMENTS.DELIVERIES), CURSOR_STYLES.CURSOR, options, DeliveryQuery(options)),
2493
+ iterateDeliveries: (id, options = {}) => IteratePages(transport, WebhookChildPath(id, SEGMENTS.DELIVERIES), CURSOR_STYLES.CURSOR, options, DeliveryQuery(options)),
2494
+ listWorkspaceDeliveries: (options = {}) => FetchPage(transport, PATHS.WEBHOOKS_DELIVERIES, CURSOR_STYLES.CURSOR, options, WorkspaceDeliveryQuery(options)),
2495
+ listAllWorkspaceDeliveries: (options = {}) => CollectAll(transport, PATHS.WEBHOOKS_DELIVERIES, CURSOR_STYLES.CURSOR, options, WorkspaceDeliveryQuery(options)),
2496
+ iterateWorkspaceDeliveries: (options = {}) => IteratePages(transport, PATHS.WEBHOOKS_DELIVERIES, CURSOR_STYLES.CURSOR, options, WorkspaceDeliveryQuery(options)),
2497
+ listActivity: (id, options = {}) => FetchPage(transport, WebhookChildPath(id, SEGMENTS.ACTIVITY), CURSOR_STYLES.CURSOR, options, WindowQuery(options)),
2498
+ listAllActivity: (id, options = {}) => CollectAll(transport, WebhookChildPath(id, SEGMENTS.ACTIVITY), CURSOR_STYLES.CURSOR, options, WindowQuery(options)),
2499
+ iterateActivity: (id, options = {}) => IteratePages(transport, WebhookChildPath(id, SEGMENTS.ACTIVITY), CURSOR_STYLES.CURSOR, options, WindowQuery(options)),
2500
+ listWorkspaceActivity: (options = {}) => FetchPage(transport, PATHS.WEBHOOKS_ACTIVITY, CURSOR_STYLES.CURSOR, options, WorkspaceActivityQuery(options)),
2501
+ listAllWorkspaceActivity: (options = {}) => CollectAll(transport, PATHS.WEBHOOKS_ACTIVITY, CURSOR_STYLES.CURSOR, options, WorkspaceActivityQuery(options)),
2502
+ iterateWorkspaceActivity: (options = {}) => IteratePages(transport, PATHS.WEBHOOKS_ACTIVITY, CURSOR_STYLES.CURSOR, options, WorkspaceActivityQuery(options)),
2503
+ getDelivery: (id, deliveryId, options = {}) => transport.request(WebhookDeliveryPath(id, deliveryId), {
2504
+ signal: options.signal,
2505
+ apiKey: options.apiKey
2506
+ }),
2507
+ replayDelivery: (id, deliveryId, options = {}) => transport.request(WebhookDeliveryReplayPath(id, deliveryId), {
2508
+ method: HTTP_METHODS.POST,
2509
+ signal: options.signal,
2510
+ apiKey: options.apiKey
2511
+ })
1523
2512
  });
1524
2513
 
1525
2514
  class OpenEmail {
1526
2515
  transport;
1527
2516
  mode;
1528
2517
  me;
2518
+ keys;
1529
2519
  addresses;
1530
2520
  languages;
1531
2521
  emails;
@@ -1535,13 +2525,19 @@ class OpenEmail {
1535
2525
  drafts;
1536
2526
  labels;
1537
2527
  contacts;
2528
+ audiences;
2529
+ broadcasts;
1538
2530
  domains;
1539
2531
  rules;
1540
2532
  webhooks;
2533
+ imports;
2534
+ providerImports;
1541
2535
  calendar;
1542
2536
  settings;
1543
2537
  roles;
1544
2538
  members;
2539
+ suppressions;
2540
+ files;
1545
2541
  tempMail;
1546
2542
  constructor(configuration) {
1547
2543
  const options = typeof configuration === 'string' ? { apiKey: configuration } : configuration;
@@ -1551,6 +2547,7 @@ class OpenEmail {
1551
2547
  this.transport = new Transport(options);
1552
2548
  this.mode = ModeOf(options.apiKey);
1553
2549
  this.me = Me(this.transport);
2550
+ this.keys = Keys(this.transport);
1554
2551
  this.addresses = Addresses(this.transport);
1555
2552
  this.languages = Languages(this.transport);
1556
2553
  this.emails = Emails(this.transport);
@@ -1560,13 +2557,19 @@ class OpenEmail {
1560
2557
  this.drafts = Drafts(this.transport);
1561
2558
  this.labels = Labels(this.transport);
1562
2559
  this.contacts = Contacts(this.transport);
2560
+ this.audiences = Audiences(this.transport);
2561
+ this.broadcasts = Broadcasts(this.transport);
1563
2562
  this.domains = Domains(this.transport);
1564
2563
  this.rules = Rules(this.transport);
1565
2564
  this.webhooks = Webhooks(this.transport);
2565
+ this.imports = Imports(this.transport);
2566
+ this.providerImports = ProviderImports(this.transport);
1566
2567
  this.calendar = Calendar(this.transport);
1567
2568
  this.settings = Settings(this.transport);
1568
2569
  this.roles = Roles(this.transport);
1569
2570
  this.members = Members(this.transport);
2571
+ this.suppressions = Suppressions(this.transport);
2572
+ this.files = Files(this.transport);
1570
2573
  this.tempMail = TempMail(this.transport);
1571
2574
  }
1572
2575
  get raw() {
@@ -1741,4 +2744,4 @@ const resolveLanguage = ResolveLanguage;
1741
2744
  const languageByCode = LanguageByCode;
1742
2745
  const isRtlLanguage = IsRtlLanguage;
1743
2746
 
1744
- export { API_SCOPES, ERROR_TYPES, LANGUAGES, MESSAGE_ENCRYPTION_FORMATS, OpenEmail, OpenEmailApiError, OpenEmailNetworkError, PAGE_LIMITS, RULE_ACTIONS, RULE_FIELDS, RULE_OPERATORS, VERSION, WEBHOOK_EVENTS, WEBHOOK_SIGNATURE_HEADERS, createClient, createOpenEmail, createTempMail, OpenEmail as default, getClient, init, isApiKey, isRtlLanguage, isSealed, languageByCode, openemail, resetClient, resolveLanguage, toBase64, verifyWebhookSignature };
2747
+ export { API_SCOPES, BROADCAST_STATUSES, CONTACT_BLOCK_LISTS, CONTACT_PHOTO_TYPES, CONTACT_THREAD_SORTS, ERROR_TYPES, FILE_DIRECTIONS, FILE_KINDS, FILE_SORTS, 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 };