@pidgeon-ai/sdk 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -412,6 +412,10 @@ type Identity = {
412
412
  * Your own opaque grouping for this address. Never parsed here.
413
413
  */
414
414
  tenant_id: string | null;
415
+ /**
416
+ * The pod this address is in. Every workspace has one to start with and every address is in one, so this is never null.
417
+ */
418
+ pod_id: string;
415
419
  };
416
420
  type Message = {
417
421
  id: string;
@@ -461,6 +465,20 @@ type Message = {
461
465
  reply_text: string;
462
466
  is_read: boolean;
463
467
  is_spam: boolean;
468
+ /**
469
+ * The headers we keep, lowercased: `message-id`, `in-reply-to`, `references`, `date`, `reply-to`, `return-path`, `list-id`, `list-unsubscribe`, `precedence`, `auto-submitted`, `x-auto-response-suppress`, `x-mailer` and `x-priority`. Not the whole envelope — that is `GET /messages/{id}/raw`. Empty when none were present.
470
+ */
471
+ headers: {
472
+ [key: string]: string;
473
+ };
474
+ /**
475
+ * What the receiving transport said about the sending domain. Null means it did not report, not that the check failed — normal on outbound, and on inbound it is the difference between unknown and forged.
476
+ */
477
+ authentication: {
478
+ spf: string | null;
479
+ dkim: string | null;
480
+ dmarc: string | null;
481
+ };
464
482
  attachments: Array<{
465
483
  id: string;
466
484
  filename: string;
@@ -524,6 +542,20 @@ type Thread = {
524
542
  assignee_id: string | null;
525
543
  assigned_at: string | null;
526
544
  message_count: number;
545
+ /**
546
+ * Where the newest message is filed. Null on a thread with no messages.
547
+ */
548
+ folder: 'inbox' | 'starred' | 'sent' | 'drafts' | 'scheduled' | 'snoozed' | 'archive' | 'spam' | 'trash' | 'unauthenticated' | null;
549
+ /**
550
+ * Who sent the newest message.
551
+ */
552
+ from: string | null;
553
+ from_name: string | null;
554
+ /**
555
+ * The first line of the newest message.
556
+ */
557
+ preview: string | null;
558
+ has_attachments: boolean;
527
559
  last_message_at: string | null;
528
560
  /**
529
561
  * ISO-8601, UTC.
@@ -1259,6 +1291,26 @@ type SearchHit = {
1259
1291
  */
1260
1292
  identity: string | null;
1261
1293
  };
1294
+ type Pod = {
1295
+ id: string;
1296
+ name: string;
1297
+ /**
1298
+ * Your own id for this pod — a customer id, whatever your side calls it.
1299
+ */
1300
+ client_id: string | null;
1301
+ /**
1302
+ * Where an address lands when a create call names no pod. Exactly one per account.
1303
+ */
1304
+ is_default: boolean;
1305
+ /**
1306
+ * Addresses in it.
1307
+ */
1308
+ identity_count: number;
1309
+ /**
1310
+ * ISO-8601, UTC.
1311
+ */
1312
+ created_at: string;
1313
+ };
1262
1314
  type Label = {
1263
1315
  id: string;
1264
1316
  identity_id: string;
@@ -1419,6 +1471,7 @@ type IdentitiesListData = {
1419
1471
  */
1420
1472
  cursor?: string;
1421
1473
  tenant_id?: string;
1474
+ pod_id?: string;
1422
1475
  };
1423
1476
  url: '/identities';
1424
1477
  };
@@ -1497,6 +1550,10 @@ type IdentitiesCreateData = {
1497
1550
  * Your own opaque grouping — a customer id, whatever your side calls it. Never parsed here.
1498
1551
  */
1499
1552
  tenant_id?: string | null;
1553
+ /**
1554
+ * The pod this belongs to. Your account’s default when you name none. A container, not a boundary: it does not change what an address can do, and no key is scoped to one.
1555
+ */
1556
+ pod_id?: string | null;
1500
1557
  };
1501
1558
  path?: never;
1502
1559
  query?: never;
@@ -1616,6 +1673,10 @@ type IdentitiesUpdateData = {
1616
1673
  * Your own opaque grouping — a customer id, whatever your side calls it. Never parsed here.
1617
1674
  */
1618
1675
  tenant_id?: string | null;
1676
+ /**
1677
+ * The pod this belongs to. Your account’s default when you name none. A container, not a boundary: it does not change what an address can do, and no key is scoped to one.
1678
+ */
1679
+ pod_id?: string | null;
1619
1680
  };
1620
1681
  path: {
1621
1682
  id: string;
@@ -1990,6 +2051,147 @@ type IdentitiesSuspendTenantResponses = {
1990
2051
  };
1991
2052
  };
1992
2053
  type IdentitiesSuspendTenantResponse = IdentitiesSuspendTenantResponses[keyof IdentitiesSuspendTenantResponses];
2054
+ type PodsListData = {
2055
+ body?: never;
2056
+ path?: never;
2057
+ query?: never;
2058
+ url: '/pods';
2059
+ };
2060
+ type PodsListErrors = {
2061
+ /**
2062
+ * No API key, or one that is not valid.
2063
+ */
2064
+ 401: Error;
2065
+ /**
2066
+ * No such resource, or one this key cannot reach. The two answer the same, so treat a 404 as “not available to you” rather than “does not exist”.
2067
+ */
2068
+ 404: Error;
2069
+ /**
2070
+ * Rate limited. `X-RateLimit-Reset` says when to retry.
2071
+ */
2072
+ 429: Error;
2073
+ };
2074
+ type PodsListError = PodsListErrors[keyof PodsListErrors];
2075
+ type PodsListResponses = {
2076
+ /**
2077
+ * Every pod.
2078
+ */
2079
+ 200: {
2080
+ data: Array<Pod>;
2081
+ has_more: boolean;
2082
+ /**
2083
+ * Pass as `cursor` to continue. Null on the last page.
2084
+ */
2085
+ next_cursor: string | null;
2086
+ };
2087
+ };
2088
+ type PodsListResponse = PodsListResponses[keyof PodsListResponses];
2089
+ type PodsCreateData = {
2090
+ body: {
2091
+ name: string;
2092
+ /**
2093
+ * Your own id for this pod. Carried and returned, never parsed.
2094
+ */
2095
+ client_id?: string | null;
2096
+ };
2097
+ path?: never;
2098
+ query?: never;
2099
+ url: '/pods';
2100
+ };
2101
+ type PodsCreateErrors = {
2102
+ /**
2103
+ * No API key, or one that is not valid.
2104
+ */
2105
+ 401: Error;
2106
+ /**
2107
+ * No such resource, or one this key cannot reach. The two answer the same, so treat a 404 as “not available to you” rather than “does not exist”.
2108
+ */
2109
+ 404: Error;
2110
+ /**
2111
+ * Rate limited. `X-RateLimit-Reset` says when to retry.
2112
+ */
2113
+ 429: Error;
2114
+ };
2115
+ type PodsCreateError = PodsCreateErrors[keyof PodsCreateErrors];
2116
+ type PodsCreateResponses = {
2117
+ /**
2118
+ * The pod.
2119
+ */
2120
+ 201: {
2121
+ data: Pod;
2122
+ };
2123
+ };
2124
+ type PodsCreateResponse = PodsCreateResponses[keyof PodsCreateResponses];
2125
+ type PodsGetData = {
2126
+ body?: never;
2127
+ path: {
2128
+ id: string;
2129
+ };
2130
+ query?: never;
2131
+ url: '/pods/{id}';
2132
+ };
2133
+ type PodsGetErrors = {
2134
+ /**
2135
+ * No API key, or one that is not valid.
2136
+ */
2137
+ 401: Error;
2138
+ /**
2139
+ * No such resource, or one this key cannot reach. The two answer the same, so treat a 404 as “not available to you” rather than “does not exist”.
2140
+ */
2141
+ 404: Error;
2142
+ /**
2143
+ * Rate limited. `X-RateLimit-Reset` says when to retry.
2144
+ */
2145
+ 429: Error;
2146
+ };
2147
+ type PodsGetError = PodsGetErrors[keyof PodsGetErrors];
2148
+ type PodsGetResponses = {
2149
+ /**
2150
+ * The pod.
2151
+ */
2152
+ 200: {
2153
+ data: Pod;
2154
+ };
2155
+ };
2156
+ type PodsGetResponse = PodsGetResponses[keyof PodsGetResponses];
2157
+ type PodsUpdateData = {
2158
+ body: {
2159
+ name?: string;
2160
+ /**
2161
+ * Your own id for this pod. Carried and returned, never parsed.
2162
+ */
2163
+ client_id?: string | null;
2164
+ };
2165
+ path: {
2166
+ id: string;
2167
+ };
2168
+ query?: never;
2169
+ url: '/pods/{id}';
2170
+ };
2171
+ type PodsUpdateErrors = {
2172
+ /**
2173
+ * No API key, or one that is not valid.
2174
+ */
2175
+ 401: Error;
2176
+ /**
2177
+ * No such resource, or one this key cannot reach. The two answer the same, so treat a 404 as “not available to you” rather than “does not exist”.
2178
+ */
2179
+ 404: Error;
2180
+ /**
2181
+ * Rate limited. `X-RateLimit-Reset` says when to retry.
2182
+ */
2183
+ 429: Error;
2184
+ };
2185
+ type PodsUpdateError = PodsUpdateErrors[keyof PodsUpdateErrors];
2186
+ type PodsUpdateResponses = {
2187
+ /**
2188
+ * The pod.
2189
+ */
2190
+ 200: {
2191
+ data: Pod;
2192
+ };
2193
+ };
2194
+ type PodsUpdateResponse = PodsUpdateResponses[keyof PodsUpdateResponses];
1993
2195
  type LabelsListData = {
1994
2196
  body?: never;
1995
2197
  path?: never;
@@ -2403,6 +2605,9 @@ type MessagesSearchResponse = MessagesSearchResponses[keyof MessagesSearchRespon
2403
2605
  type MessagesActData = {
2404
2606
  body: {
2405
2607
  message_ids: Array<string>;
2608
+ /**
2609
+ * `read` and `unread` are refused for an API key: read state belongs to a person and a key is not one. Every other action works.
2610
+ */
2406
2611
  action: 'read' | 'unread' | 'star' | 'unstar' | 'archive' | 'unarchive' | 'delete' | 'restore' | 'spam' | 'not_spam' | 'delete_forever';
2407
2612
  };
2408
2613
  path?: never;
@@ -2499,6 +2704,9 @@ type MessagesGetResponses = {
2499
2704
  type MessagesGetResponse = MessagesGetResponses[keyof MessagesGetResponses];
2500
2705
  type MessagesUpdateData = {
2501
2706
  body: {
2707
+ /**
2708
+ * Refused for an API key: read state belongs to a person and a key is not one. Archive the message, or track what you have seen with `GET /v1/mailboxes/changes`. A person signed in to the dashboard sets this.
2709
+ */
2502
2710
  is_read?: boolean;
2503
2711
  is_starred?: boolean;
2504
2712
  folder?: 'inbox' | 'archive' | 'spam' | 'trash';
@@ -5311,6 +5519,32 @@ declare const identitiesReceiveRulesCreate: <ThrowOnError extends boolean = fals
5311
5519
  * Suspends every address carrying that `tenant_id`. **Suspends, never deletes** — the mail, the threads and the grants all stay, and each address emits `identity.suspended`. Deleting them is still one call each. Idempotent: it changes what is active and reports how many, so a retry is safe. It reaches only addresses you could have suspended one at a time.
5312
5520
  */
5313
5521
  declare const identitiesSuspendTenant: <ThrowOnError extends boolean = false>(options: Options<IdentitiesSuspendTenantData, ThrowOnError>) => RequestResult<IdentitiesSuspendTenantResponses, IdentitiesSuspendTenantErrors, ThrowOnError>;
5522
+ /**
5523
+ * List pods
5524
+ *
5525
+ * The containers in this account, the default first. A pod holds addresses and domains — a customer of yours, a client, or just test apart from production.
5526
+ *
5527
+ * **It is organisational, not a boundary.** A pod carries no sending reputation of its own, and a key is still a list of address ids rather than something scoped to a pod. Saying so plainly because the alternative is a reader assuming an isolation that is not there.
5528
+ *
5529
+ * Not paged: this is a menu somebody switches with, and a product where that menu needs a cursor is one where the menu was the wrong shape.
5530
+ */
5531
+ declare const podsList: <ThrowOnError extends boolean = false>(options?: Options<PodsListData, ThrowOnError>) => RequestResult<PodsListResponses, PodsListErrors, ThrowOnError>;
5532
+ /**
5533
+ * Create a pod
5534
+ *
5535
+ * Name it after whatever it holds — a customer, an environment. `client_id` is your own id for it, carried and never parsed, and has to be unique within the account so that looking one up by it has an answer.
5536
+ */
5537
+ declare const podsCreate: <ThrowOnError extends boolean = false>(options: Options<PodsCreateData, ThrowOnError>) => RequestResult<PodsCreateResponses, PodsCreateErrors, ThrowOnError>;
5538
+ /**
5539
+ * Fetch one pod
5540
+ */
5541
+ declare const podsGet: <ThrowOnError extends boolean = false>(options: Options<PodsGetData, ThrowOnError>) => RequestResult<PodsGetResponses, PodsGetErrors, ThrowOnError>;
5542
+ /**
5543
+ * Rename a pod, or change its client id
5544
+ *
5545
+ * There is no delete. A container holding mailboxes is not a thing to remove with one call, and nothing yet moves addresses between pods — so the verb would either refuse every non-empty pod or destroy mail. Suspend the addresses instead.
5546
+ */
5547
+ declare const podsUpdate: <ThrowOnError extends boolean = false>(options: Options<PodsUpdateData, ThrowOnError>) => RequestResult<PodsUpdateResponses, PodsUpdateErrors, ThrowOnError>;
5314
5548
  /**
5315
5549
  * List labels
5316
5550
  *
@@ -5356,7 +5590,7 @@ declare const messagesListInThread: <ThrowOnError extends boolean = false>(optio
5356
5590
  /**
5357
5591
  * Send a message
5358
5592
  *
5359
- * Idempotent with an `Idempotency-Key` header. Answers `202` with the id, the thread and anything **rejected** — a recipient the address is not allowed to write to is refused here rather than failing later, so read `rejected` before assuming it went.
5593
+ * Idempotent with an `Idempotency-Key` header. Answers `202` with the id, the thread and anything **rejected** — addresses the provider would not accept at hand-off, so read it before assuming every recipient got it. A recipient this address is not allowed to write to is a different thing and refuses the whole send: `403` with `blocked` when a rule says no, `not_permitted` when the send policy does. Nothing is sent to anybody in that case.
5360
5594
  */
5361
5595
  declare const messagesSend: <ThrowOnError extends boolean = false>(options: Options<MessagesSendData, ThrowOnError>) => RequestResult<MessagesSendResponses, MessagesSendErrors, ThrowOnError>;
5362
5596
  /**
@@ -5594,6 +5828,8 @@ declare const workspaceMembers: <ThrowOnError extends boolean = false>(options?:
5594
5828
  *
5595
5829
  * **Two directions.** `cursor` pages backwards through history, newest first, which is what a dashboard shows. `after` tails the log forwards, oldest first, which is what a caller that cannot receive a webhook does: ask for everything since the last event you saw, act on it, and keep the last `created_at` as the next cursor. Naming both is refused — they are different reads.
5596
5830
  *
5831
+ * **Starting from nothing: pass `after=1970-01-01T00:00:00Z`.** With neither parameter this answers newest first, so a first-time consumer that takes the last row as its high-water mark stores the *oldest* event in the log and never advances. Any timestamp at or before the oldest event you hold will do; the epoch is the one nobody has to think about.
5832
+ *
5597
5833
  * A forward page is ordered oldest first precisely so its **last** row is the high-water mark to resume from; `next_cursor` is that row either way.
5598
5834
  */
5599
5835
  declare const eventsList: <ThrowOnError extends boolean = false>(options?: Options<EventsListData, ThrowOnError>) => RequestResult<EventsListResponses, EventsListErrors, ThrowOnError>;
@@ -5843,4 +6079,78 @@ declare function verifyWebhook(input: {
5843
6079
  now?: Date;
5844
6080
  }): Promise<WebhookEnvelope>;
5845
6081
 
5846
- export { type Address, type AgentAttachHumanData, type AgentAttachHumanError, type AgentAttachHumanErrors, type AgentAttachHumanResponse, type AgentAttachHumanResponses, type AgentSignUpData, type AgentSignUpError, type AgentSignUpErrors, type AgentSignUpResponse, type AgentSignUpResponses, type AgentSignup, type AgentVerified, type AgentVerifyData, type AgentVerifyError, type AgentVerifyErrors, type AgentVerifyResponse, type AgentVerifyResponses, type ApiKey, type AppPassword, type AppPasswordsCreateData, type AppPasswordsCreateError, type AppPasswordsCreateErrors, type AppPasswordsCreateResponse, type AppPasswordsCreateResponses, type AppPasswordsListData, type AppPasswordsListError, type AppPasswordsListErrors, type AppPasswordsListResponse, type AppPasswordsListResponses, type AppPasswordsRevokeData, type AppPasswordsRevokeError, type AppPasswordsRevokeErrors, type AppPasswordsRevokeResponse, type AppPasswordsRevokeResponses, type Attachment, type AttachmentUrl, type AttachmentsDownloadUrlData, type AttachmentsDownloadUrlError, type AttachmentsDownloadUrlErrors, type AttachmentsDownloadUrlResponse, type AttachmentsDownloadUrlResponses, type AttachmentsUploadData, type AttachmentsUploadError, type AttachmentsUploadErrors, type AttachmentsUploadResponse, type AttachmentsUploadResponses, type Calendar, type CalendarCreateEventData, type CalendarCreateEventError, type CalendarCreateEventErrors, type CalendarCreateEventResponse, type CalendarCreateEventResponses, type CalendarDeleteEventData, type CalendarDeleteEventError, type CalendarDeleteEventErrors, type CalendarDeleteEventResponse, type CalendarDeleteEventResponses, type CalendarEvent, type CalendarGetAgendaData, type CalendarGetAgendaError, type CalendarGetAgendaErrors, type CalendarGetAgendaResponse, type CalendarGetAgendaResponses, type CalendarGetData, type CalendarGetError, type CalendarGetErrors, type CalendarGetEventData, type CalendarGetEventError, type CalendarGetEventErrors, type CalendarGetEventResponse, type CalendarGetEventResponses, type CalendarGetResponse, type CalendarGetResponses, type CalendarListEventInstancesData, type CalendarListEventInstancesError, type CalendarListEventInstancesErrors, type CalendarListEventInstancesResponse, type CalendarListEventInstancesResponses, type CalendarListEventsData, type CalendarListEventsError, type CalendarListEventsErrors, type CalendarListEventsResponse, type CalendarListEventsResponses, type CalendarRespondToEventData, type CalendarRespondToEventError, type CalendarRespondToEventErrors, type CalendarRespondToEventResponse, type CalendarRespondToEventResponses, type CalendarUpdateData, type CalendarUpdateError, type CalendarUpdateErrors, type CalendarUpdateEventData, type CalendarUpdateEventError, type CalendarUpdateEventErrors, type CalendarUpdateEventResponse, type CalendarUpdateEventResponses, type CalendarUpdateResponse, type CalendarUpdateResponses, type ClientOptions, type CreateClientConfig, type Deleted, type Delivery, type DnsRecord, type Domain, type DomainDetail, type DomainsCreateData, type DomainsCreateError, type DomainsCreateErrors, type DomainsCreateResponse, type DomainsCreateResponses, type DomainsDeleteData, type DomainsDeleteError, type DomainsDeleteErrors, type DomainsDeleteResponse, type DomainsDeleteResponses, type DomainsGetData, type DomainsGetError, type DomainsGetErrors, type DomainsGetResponse, type DomainsGetResponses, type DomainsGetSetupLinkData, type DomainsGetSetupLinkError, type DomainsGetSetupLinkErrors, type DomainsGetSetupLinkResponse, type DomainsGetSetupLinkResponses, type DomainsListData, type DomainsListError, type DomainsListErrors, type DomainsListResponse, type DomainsListResponses, type DomainsUpdateData, type DomainsUpdateError, type DomainsUpdateErrors, type DomainsUpdateResponse, type DomainsUpdateResponses, type DomainsVerifyData, type DomainsVerifyError, type DomainsVerifyErrors, type DomainsVerifyResponse, type DomainsVerifyResponses, type DomainsZoneFileData, type DomainsZoneFileError, type DomainsZoneFileErrors, type DomainsZoneFileResponse, type DomainsZoneFileResponses, type Draft, type DraftsCancelScheduleData, type DraftsCancelScheduleError, type DraftsCancelScheduleErrors, type DraftsCancelScheduleResponse, type DraftsCancelScheduleResponses, type DraftsCreateData, type DraftsCreateError, type DraftsCreateErrors, type DraftsCreateResponse, type DraftsCreateResponses, type DraftsDeleteData, type DraftsDeleteError, type DraftsDeleteErrors, type DraftsDeleteResponse, type DraftsDeleteResponses, type DraftsGetData, type DraftsGetError, type DraftsGetErrors, type DraftsGetResponse, type DraftsGetResponses, type DraftsListData, type DraftsListError, type DraftsListErrors, type DraftsListResponse, type DraftsListResponses, type DraftsRemoveAttachmentData, type DraftsRemoveAttachmentError, type DraftsRemoveAttachmentErrors, type DraftsRemoveAttachmentResponse, type DraftsRemoveAttachmentResponses, type DraftsScheduleData, type DraftsScheduleError, type DraftsScheduleErrors, type DraftsScheduleResponse, type DraftsScheduleResponses, type DraftsSendData, type DraftsSendError, type DraftsSendErrors, type DraftsSendResponse, type DraftsSendResponses, type DraftsUpdateData, type DraftsUpdateError, type DraftsUpdateErrors, type DraftsUpdateResponse, type DraftsUpdateResponses, type Emptied, type Error, type Event, type EventResponse, type EventsGetData, type EventsGetError, type EventsGetErrors, type EventsGetResponse, type EventsGetResponses, type EventsListData, type EventsListError, type EventsListErrors, type EventsListResponse, type EventsListResponses, type EventsStreamData, type EventsStreamError, type EventsStreamErrors, type EventsStreamResponse, type EventsStreamResponses, type IdentitiesAccessCreateData, type IdentitiesAccessCreateError, type IdentitiesAccessCreateErrors, type IdentitiesAccessCreateResponse, type IdentitiesAccessCreateResponses, type IdentitiesAccessDeleteData, type IdentitiesAccessDeleteError, type IdentitiesAccessDeleteErrors, type IdentitiesAccessDeleteResponse, type IdentitiesAccessDeleteResponses, type IdentitiesAccessGetData, type IdentitiesAccessGetError, type IdentitiesAccessGetErrors, type IdentitiesAccessGetResponse, type IdentitiesAccessGetResponses, type IdentitiesCreateData, type IdentitiesCreateError, type IdentitiesCreateErrors, type IdentitiesCreateResponse, type IdentitiesCreateResponses, type IdentitiesDeleteData, type IdentitiesDeleteError, type IdentitiesDeleteErrors, type IdentitiesDeleteResponse, type IdentitiesDeleteResponses, type IdentitiesGetData, type IdentitiesGetError, type IdentitiesGetErrors, type IdentitiesGetResponse, type IdentitiesGetResponses, type IdentitiesListData, type IdentitiesListError, type IdentitiesListErrors, type IdentitiesListResponse, type IdentitiesListResponses, type IdentitiesReceiveRulesCreateData, type IdentitiesReceiveRulesCreateError, type IdentitiesReceiveRulesCreateErrors, type IdentitiesReceiveRulesCreateResponse, type IdentitiesReceiveRulesCreateResponses, type IdentitiesReceiveRulesDeleteData, type IdentitiesReceiveRulesDeleteError, type IdentitiesReceiveRulesDeleteErrors, type IdentitiesReceiveRulesDeleteResponse, type IdentitiesReceiveRulesDeleteResponses, type IdentitiesReceiveRulesGetData, type IdentitiesReceiveRulesGetError, type IdentitiesReceiveRulesGetErrors, type IdentitiesReceiveRulesGetResponse, type IdentitiesReceiveRulesGetResponses, type IdentitiesSendRulesCreateData, type IdentitiesSendRulesCreateError, type IdentitiesSendRulesCreateErrors, type IdentitiesSendRulesCreateResponse, type IdentitiesSendRulesCreateResponses, type IdentitiesSendRulesDeleteData, type IdentitiesSendRulesDeleteError, type IdentitiesSendRulesDeleteErrors, type IdentitiesSendRulesDeleteResponse, type IdentitiesSendRulesDeleteResponses, type IdentitiesSendRulesGetData, type IdentitiesSendRulesGetError, type IdentitiesSendRulesGetErrors, type IdentitiesSendRulesGetResponse, type IdentitiesSendRulesGetResponses, type IdentitiesSuspendTenantData, type IdentitiesSuspendTenantError, type IdentitiesSuspendTenantErrors, type IdentitiesSuspendTenantResponse, type IdentitiesSuspendTenantResponses, type IdentitiesUpdateData, type IdentitiesUpdateError, type IdentitiesUpdateErrors, type IdentitiesUpdateResponse, type IdentitiesUpdateResponses, type Identity, type Invitation, type InvitationResponse, type KeysCreateData, type KeysCreateError, type KeysCreateErrors, type KeysCreateResponse, type KeysCreateResponses, type KeysGetData, type KeysGetError, type KeysGetErrors, type KeysGetResponse, type KeysGetResponses, type KeysListData, type KeysListError, type KeysListErrors, type KeysListResponse, type KeysListResponses, type KeysRevokeData, type KeysRevokeError, type KeysRevokeErrors, type KeysRevokeResponse, type KeysRevokeResponses, type KeysUpdateData, type KeysUpdateError, type KeysUpdateErrors, type KeysUpdateResponse, type KeysUpdateResponses, type Label, type LabelRemoved, type LabelsCreateData, type LabelsCreateError, type LabelsCreateErrors, type LabelsCreateResponse, type LabelsCreateResponses, type LabelsDeleteData, type LabelsDeleteError, type LabelsDeleteErrors, type LabelsDeleteResponse, type LabelsDeleteResponses, type LabelsListData, type LabelsListError, type LabelsListErrors, type LabelsListResponse, type LabelsListResponses, type LabelsUpdateData, type LabelsUpdateError, type LabelsUpdateErrors, type LabelsUpdateResponse, type LabelsUpdateResponses, type Mailbox, type MailboxAccess, type MailboxChange, type MailboxesChangesData, type MailboxesChangesError, type MailboxesChangesErrors, type MailboxesChangesResponse, type MailboxesChangesResponses, type MailboxesEmptyTrashData, type MailboxesEmptyTrashError, type MailboxesEmptyTrashErrors, type MailboxesEmptyTrashResponse, type MailboxesEmptyTrashResponses, type MailboxesListData, type MailboxesListError, type MailboxesListErrors, type MailboxesListFolderData, type MailboxesListFolderError, type MailboxesListFolderErrors, type MailboxesListFolderResponse, type MailboxesListFolderResponses, type MailboxesListResponse, type MailboxesListResponses, type Me, type MeGetData, type MeGetError, type MeGetErrors, type MeGetResponse, type MeGetResponses, type Member, type Message, type MessageListItem, type MessagesActData, type MessagesActError, type MessagesActErrors, type MessagesActResponse, type MessagesActResponses, type MessagesForwardData, type MessagesForwardError, type MessagesForwardErrors, type MessagesForwardResponse, type MessagesForwardResponses, type MessagesGetData, type MessagesGetError, type MessagesGetErrors, type MessagesGetResponse, type MessagesGetResponses, type MessagesListInThreadData, type MessagesListInThreadError, type MessagesListInThreadErrors, type MessagesListInThreadResponse, type MessagesListInThreadResponses, type MessagesRawData, type MessagesRawError, type MessagesRawErrors, type MessagesRawResponse, type MessagesRawResponses, type MessagesReplyAllData, type MessagesReplyAllError, type MessagesReplyAllErrors, type MessagesReplyAllResponse, type MessagesReplyAllResponses, type MessagesReplyData, type MessagesReplyError, type MessagesReplyErrors, type MessagesReplyResponse, type MessagesReplyResponses, type MessagesRespondToInvitationData, type MessagesRespondToInvitationError, type MessagesRespondToInvitationErrors, type MessagesRespondToInvitationResponse, type MessagesRespondToInvitationResponses, type MessagesSearchData, type MessagesSearchError, type MessagesSearchErrors, type MessagesSearchResponse, type MessagesSearchResponses, type MessagesSendData, type MessagesSendError, type MessagesSendErrors, type MessagesSendResponse, type MessagesSendResponses, type MessagesUndoData, type MessagesUndoError, type MessagesUndoErrors, type MessagesUndoResponse, type MessagesUndoResponses, type MessagesUpdateData, type MessagesUpdateError, type MessagesUpdateErrors, type MessagesUpdateResponse, type MessagesUpdateResponses, type Metrics, type MetricsQueryData, type MetricsQueryError, type MetricsQueryErrors, type MetricsQueryResponse, type MetricsQueryResponses, type Options, type ReceiveRuleRemoved, type ReceiveRules, type Replayed, type Restored, type Revoked, type RoutingCreateData, type RoutingCreateError, type RoutingCreateErrors, type RoutingCreateResponse, type RoutingCreateResponses, type RoutingDeleteData, type RoutingDeleteError, type RoutingDeleteErrors, type RoutingDeleteResponse, type RoutingDeleteResponses, type RoutingListData, type RoutingListError, type RoutingListErrors, type RoutingListResponse, type RoutingListResponses, type RoutingRule, type RoutingUpdateData, type RoutingUpdateError, type RoutingUpdateErrors, type RoutingUpdateResponse, type RoutingUpdateResponses, SIGNATURE_HEADER, type SearchHit, type SendRuleRemoved, type SendRules, type Sent, type SetupLink, TIMESTAMP_HEADER, type TenantSuspended, type Thread, type ThreadsGetData, type ThreadsGetError, type ThreadsGetErrors, type ThreadsGetResponse, type ThreadsGetResponses, type ThreadsLabelsCreateData, type ThreadsLabelsCreateError, type ThreadsLabelsCreateErrors, type ThreadsLabelsCreateResponse, type ThreadsLabelsCreateResponses, type ThreadsLabelsDeleteData, type ThreadsLabelsDeleteError, type ThreadsLabelsDeleteErrors, type ThreadsLabelsDeleteResponse, type ThreadsLabelsDeleteResponses, type ThreadsLabelsGetData, type ThreadsLabelsGetError, type ThreadsLabelsGetErrors, type ThreadsLabelsGetResponse, type ThreadsLabelsGetResponses, type ThreadsListData, type ThreadsListError, type ThreadsListErrors, type ThreadsListResponse, type ThreadsListResponses, type ThreadsUpdateData, type ThreadsUpdateError, type ThreadsUpdateErrors, type ThreadsUpdateResponse, type ThreadsUpdateResponses, type Undo, type UploadedAttachment, type Verification, type Webhook, type WebhookCreated, type WebhookEnvelope, type WebhookHeaders, type WebhooksCreateData, type WebhooksCreateError, type WebhooksCreateErrors, type WebhooksCreateResponse, type WebhooksCreateResponses, type WebhooksDeleteData, type WebhooksDeleteError, type WebhooksDeleteErrors, type WebhooksDeleteResponse, type WebhooksDeleteResponses, type WebhooksDeliveriesData, type WebhooksDeliveriesError, type WebhooksDeliveriesErrors, type WebhooksDeliveriesResponse, type WebhooksDeliveriesResponses, type WebhooksGetData, type WebhooksGetError, type WebhooksGetErrors, type WebhooksGetHeadersData, type WebhooksGetHeadersError, type WebhooksGetHeadersErrors, type WebhooksGetHeadersResponse, type WebhooksGetHeadersResponses, type WebhooksGetResponse, type WebhooksGetResponses, type WebhooksListData, type WebhooksListError, type WebhooksListErrors, type WebhooksListResponse, type WebhooksListResponses, type WebhooksReplayData, type WebhooksReplayError, type WebhooksReplayErrors, type WebhooksReplayResponse, type WebhooksReplayResponses, type WebhooksUpdateData, type WebhooksUpdateError, type WebhooksUpdateErrors, type WebhooksUpdateHeadersData, type WebhooksUpdateHeadersError, type WebhooksUpdateHeadersErrors, type WebhooksUpdateHeadersResponse, type WebhooksUpdateHeadersResponses, type WebhooksUpdateResponse, type WebhooksUpdateResponses, type Workspace, type WorkspaceGetData, type WorkspaceGetError, type WorkspaceGetErrors, type WorkspaceGetResponse, type WorkspaceGetResponses, type WorkspaceMembersData, type WorkspaceMembersError, type WorkspaceMembersErrors, type WorkspaceMembersResponse, type WorkspaceMembersResponses, agentAttachHuman, agentSignUp, agentVerify, appPasswordsCreate, appPasswordsList, appPasswordsRevoke, attachmentsDownloadUrl, attachmentsUpload, calendarCreateEvent, calendarDeleteEvent, calendarGet, calendarGetAgenda, calendarGetEvent, calendarListEventInstances, calendarListEvents, calendarRespondToEvent, calendarUpdate, calendarUpdateEvent, client, createClient, createConfig, domainsCreate, domainsDelete, domainsGet, domainsGetSetupLink, domainsList, domainsUpdate, domainsVerify, domainsZoneFile, draftsCancelSchedule, draftsCreate, draftsDelete, draftsGet, draftsList, draftsRemoveAttachment, draftsSchedule, draftsSend, draftsUpdate, eventsGet, eventsList, eventsStream, identitiesAccessCreate, identitiesAccessDelete, identitiesAccessGet, identitiesCreate, identitiesDelete, identitiesGet, identitiesList, identitiesReceiveRulesCreate, identitiesReceiveRulesDelete, identitiesReceiveRulesGet, identitiesSendRulesCreate, identitiesSendRulesDelete, identitiesSendRulesGet, identitiesSuspendTenant, identitiesUpdate, keysCreate, keysGet, keysList, keysRevoke, keysUpdate, labelsCreate, labelsDelete, labelsList, labelsUpdate, mailboxesChanges, mailboxesEmptyTrash, mailboxesList, mailboxesListFolder, meGet, messagesAct, messagesForward, messagesGet, messagesListInThread, messagesRaw, messagesReply, messagesReplyAll, messagesRespondToInvitation, messagesSearch, messagesSend, messagesUndo, messagesUpdate, metricsQuery, routingCreate, routingDelete, routingList, routingUpdate, threadsGet, threadsLabelsCreate, threadsLabelsDelete, threadsLabelsGet, threadsList, threadsUpdate, verifyWebhook, webhooksCreate, webhooksDelete, webhooksDeliveries, webhooksGet, webhooksGetHeaders, webhooksList, webhooksReplay, webhooksUpdate, webhooksUpdateHeaders, workspaceGet, workspaceMembers };
6082
+ /**
6083
+ * Holding the event log open.
6084
+ *
6085
+ * **The second thing a generator cannot produce**, for the same reason as
6086
+ * `webhooks.ts`: `GET /events/stream` answers `text/event-stream` and
6087
+ * `openapi-ts` builds a typed `fetch` that resolves once with a body. There
6088
+ * is nowhere in a generated client to put a connection that stays open, so
6089
+ * `eventsStream` exists in the types and does nothing useful, and the
6090
+ * endpoint the documentation recommends for *"a caller that cannot host a
6091
+ * webhook endpoint — a script on a laptop, a notebook, an agent runtime with
6092
+ * no public address"* was the one endpoint every customer hand-rolled.
6093
+ *
6094
+ * A field test on 15 October wrote forty lines of it and they worked first
6095
+ * try, which is the argument both ways: the protocol is simple, and nobody
6096
+ * should write it twice. These are those forty lines, once.
6097
+ *
6098
+ * `EventSource` is not used. It cannot send an `Authorization` header — the
6099
+ * browser API takes a URL and nothing else — and putting an API key in a
6100
+ * query string is the one place it must never go. So this is `fetch` with a
6101
+ * reader, which also works unchanged in Node, Bun, Deno, Workers and Vercel
6102
+ * functions.
6103
+ */
6104
+ /** A row of `GET /events`, delivered as it happens. The same shape either way. */
6105
+ interface StreamedEvent {
6106
+ id: string;
6107
+ type: string;
6108
+ identity: string | null;
6109
+ message_id: string | null;
6110
+ thread_id: string | null;
6111
+ data: Record<string, unknown>;
6112
+ created_at: string;
6113
+ }
6114
+ interface StreamOptions {
6115
+ /** `https://pidgeon.ai/api/v1` unless you are pointing at something else. */
6116
+ baseUrl?: string;
6117
+ apiKey: string;
6118
+ /** Narrow to one mailbox. Omitted, the stream spans every one the key reaches. */
6119
+ identityId?: string;
6120
+ /** A comma-separated list, exactly as `GET /events` takes it. */
6121
+ type?: string;
6122
+ /**
6123
+ * Where to start, as an ISO timestamp.
6124
+ *
6125
+ * **`1970-01-01T00:00:00Z` reads the whole log from the beginning**, which
6126
+ * is the answer to a question the API otherwise makes you guess at: with
6127
+ * no cursor at all the plain listing pages *backwards*, so a first-time
6128
+ * consumer that stores its last row stores the oldest event and never
6129
+ * advances. Omit this and the stream starts from now.
6130
+ */
6131
+ after?: string;
6132
+ /** Stop the stream. Aborting mid-event drops that event rather than half of it. */
6133
+ signal?: AbortSignal;
6134
+ }
6135
+ /**
6136
+ * Every event, as it happens, until you stop asking.
6137
+ *
6138
+ * ```ts
6139
+ * for await (const event of streamEvents({ apiKey })) {
6140
+ * if (event.type === 'message.received' && !event.data.from_self) {
6141
+ * await answer(event.data.message_id as string);
6142
+ * }
6143
+ * }
6144
+ * ```
6145
+ *
6146
+ * **Reconnection is this function's job and it is lossless.** The server
6147
+ * closes the connection itself after about 280 seconds so that the last
6148
+ * thing you receive is a cursor rather than a socket error; this reconnects
6149
+ * with `Last-Event-ID`, which the server prefers over `after`, so there is
6150
+ * no gap and no repeat. A network failure is retried the same way with a
6151
+ * short backoff. The loop ends when `signal` aborts and in no other case —
6152
+ * a stream that gave up quietly would be worse than one that never started.
6153
+ */
6154
+ declare function streamEvents(options: StreamOptions): AsyncGenerator<StreamedEvent>;
6155
+
6156
+ export { type Address, type AgentAttachHumanData, type AgentAttachHumanError, type AgentAttachHumanErrors, type AgentAttachHumanResponse, type AgentAttachHumanResponses, type AgentSignUpData, type AgentSignUpError, type AgentSignUpErrors, type AgentSignUpResponse, type AgentSignUpResponses, type AgentSignup, type AgentVerified, type AgentVerifyData, type AgentVerifyError, type AgentVerifyErrors, type AgentVerifyResponse, type AgentVerifyResponses, type ApiKey, type AppPassword, type AppPasswordsCreateData, type AppPasswordsCreateError, type AppPasswordsCreateErrors, type AppPasswordsCreateResponse, type AppPasswordsCreateResponses, type AppPasswordsListData, type AppPasswordsListError, type AppPasswordsListErrors, type AppPasswordsListResponse, type AppPasswordsListResponses, type AppPasswordsRevokeData, type AppPasswordsRevokeError, type AppPasswordsRevokeErrors, type AppPasswordsRevokeResponse, type AppPasswordsRevokeResponses, type Attachment, type AttachmentUrl, type AttachmentsDownloadUrlData, type AttachmentsDownloadUrlError, type AttachmentsDownloadUrlErrors, type AttachmentsDownloadUrlResponse, type AttachmentsDownloadUrlResponses, type AttachmentsUploadData, type AttachmentsUploadError, type AttachmentsUploadErrors, type AttachmentsUploadResponse, type AttachmentsUploadResponses, type Calendar, type CalendarCreateEventData, type CalendarCreateEventError, type CalendarCreateEventErrors, type CalendarCreateEventResponse, type CalendarCreateEventResponses, type CalendarDeleteEventData, type CalendarDeleteEventError, type CalendarDeleteEventErrors, type CalendarDeleteEventResponse, type CalendarDeleteEventResponses, type CalendarEvent, type CalendarGetAgendaData, type CalendarGetAgendaError, type CalendarGetAgendaErrors, type CalendarGetAgendaResponse, type CalendarGetAgendaResponses, type CalendarGetData, type CalendarGetError, type CalendarGetErrors, type CalendarGetEventData, type CalendarGetEventError, type CalendarGetEventErrors, type CalendarGetEventResponse, type CalendarGetEventResponses, type CalendarGetResponse, type CalendarGetResponses, type CalendarListEventInstancesData, type CalendarListEventInstancesError, type CalendarListEventInstancesErrors, type CalendarListEventInstancesResponse, type CalendarListEventInstancesResponses, type CalendarListEventsData, type CalendarListEventsError, type CalendarListEventsErrors, type CalendarListEventsResponse, type CalendarListEventsResponses, type CalendarRespondToEventData, type CalendarRespondToEventError, type CalendarRespondToEventErrors, type CalendarRespondToEventResponse, type CalendarRespondToEventResponses, type CalendarUpdateData, type CalendarUpdateError, type CalendarUpdateErrors, type CalendarUpdateEventData, type CalendarUpdateEventError, type CalendarUpdateEventErrors, type CalendarUpdateEventResponse, type CalendarUpdateEventResponses, type CalendarUpdateResponse, type CalendarUpdateResponses, type ClientOptions, type CreateClientConfig, type Deleted, type Delivery, type DnsRecord, type Domain, type DomainDetail, type DomainsCreateData, type DomainsCreateError, type DomainsCreateErrors, type DomainsCreateResponse, type DomainsCreateResponses, type DomainsDeleteData, type DomainsDeleteError, type DomainsDeleteErrors, type DomainsDeleteResponse, type DomainsDeleteResponses, type DomainsGetData, type DomainsGetError, type DomainsGetErrors, type DomainsGetResponse, type DomainsGetResponses, type DomainsGetSetupLinkData, type DomainsGetSetupLinkError, type DomainsGetSetupLinkErrors, type DomainsGetSetupLinkResponse, type DomainsGetSetupLinkResponses, type DomainsListData, type DomainsListError, type DomainsListErrors, type DomainsListResponse, type DomainsListResponses, type DomainsUpdateData, type DomainsUpdateError, type DomainsUpdateErrors, type DomainsUpdateResponse, type DomainsUpdateResponses, type DomainsVerifyData, type DomainsVerifyError, type DomainsVerifyErrors, type DomainsVerifyResponse, type DomainsVerifyResponses, type DomainsZoneFileData, type DomainsZoneFileError, type DomainsZoneFileErrors, type DomainsZoneFileResponse, type DomainsZoneFileResponses, type Draft, type DraftsCancelScheduleData, type DraftsCancelScheduleError, type DraftsCancelScheduleErrors, type DraftsCancelScheduleResponse, type DraftsCancelScheduleResponses, type DraftsCreateData, type DraftsCreateError, type DraftsCreateErrors, type DraftsCreateResponse, type DraftsCreateResponses, type DraftsDeleteData, type DraftsDeleteError, type DraftsDeleteErrors, type DraftsDeleteResponse, type DraftsDeleteResponses, type DraftsGetData, type DraftsGetError, type DraftsGetErrors, type DraftsGetResponse, type DraftsGetResponses, type DraftsListData, type DraftsListError, type DraftsListErrors, type DraftsListResponse, type DraftsListResponses, type DraftsRemoveAttachmentData, type DraftsRemoveAttachmentError, type DraftsRemoveAttachmentErrors, type DraftsRemoveAttachmentResponse, type DraftsRemoveAttachmentResponses, type DraftsScheduleData, type DraftsScheduleError, type DraftsScheduleErrors, type DraftsScheduleResponse, type DraftsScheduleResponses, type DraftsSendData, type DraftsSendError, type DraftsSendErrors, type DraftsSendResponse, type DraftsSendResponses, type DraftsUpdateData, type DraftsUpdateError, type DraftsUpdateErrors, type DraftsUpdateResponse, type DraftsUpdateResponses, type Emptied, type Error, type Event, type EventResponse, type EventsGetData, type EventsGetError, type EventsGetErrors, type EventsGetResponse, type EventsGetResponses, type EventsListData, type EventsListError, type EventsListErrors, type EventsListResponse, type EventsListResponses, type EventsStreamData, type EventsStreamError, type EventsStreamErrors, type EventsStreamResponse, type EventsStreamResponses, type IdentitiesAccessCreateData, type IdentitiesAccessCreateError, type IdentitiesAccessCreateErrors, type IdentitiesAccessCreateResponse, type IdentitiesAccessCreateResponses, type IdentitiesAccessDeleteData, type IdentitiesAccessDeleteError, type IdentitiesAccessDeleteErrors, type IdentitiesAccessDeleteResponse, type IdentitiesAccessDeleteResponses, type IdentitiesAccessGetData, type IdentitiesAccessGetError, type IdentitiesAccessGetErrors, type IdentitiesAccessGetResponse, type IdentitiesAccessGetResponses, type IdentitiesCreateData, type IdentitiesCreateError, type IdentitiesCreateErrors, type IdentitiesCreateResponse, type IdentitiesCreateResponses, type IdentitiesDeleteData, type IdentitiesDeleteError, type IdentitiesDeleteErrors, type IdentitiesDeleteResponse, type IdentitiesDeleteResponses, type IdentitiesGetData, type IdentitiesGetError, type IdentitiesGetErrors, type IdentitiesGetResponse, type IdentitiesGetResponses, type IdentitiesListData, type IdentitiesListError, type IdentitiesListErrors, type IdentitiesListResponse, type IdentitiesListResponses, type IdentitiesReceiveRulesCreateData, type IdentitiesReceiveRulesCreateError, type IdentitiesReceiveRulesCreateErrors, type IdentitiesReceiveRulesCreateResponse, type IdentitiesReceiveRulesCreateResponses, type IdentitiesReceiveRulesDeleteData, type IdentitiesReceiveRulesDeleteError, type IdentitiesReceiveRulesDeleteErrors, type IdentitiesReceiveRulesDeleteResponse, type IdentitiesReceiveRulesDeleteResponses, type IdentitiesReceiveRulesGetData, type IdentitiesReceiveRulesGetError, type IdentitiesReceiveRulesGetErrors, type IdentitiesReceiveRulesGetResponse, type IdentitiesReceiveRulesGetResponses, type IdentitiesSendRulesCreateData, type IdentitiesSendRulesCreateError, type IdentitiesSendRulesCreateErrors, type IdentitiesSendRulesCreateResponse, type IdentitiesSendRulesCreateResponses, type IdentitiesSendRulesDeleteData, type IdentitiesSendRulesDeleteError, type IdentitiesSendRulesDeleteErrors, type IdentitiesSendRulesDeleteResponse, type IdentitiesSendRulesDeleteResponses, type IdentitiesSendRulesGetData, type IdentitiesSendRulesGetError, type IdentitiesSendRulesGetErrors, type IdentitiesSendRulesGetResponse, type IdentitiesSendRulesGetResponses, type IdentitiesSuspendTenantData, type IdentitiesSuspendTenantError, type IdentitiesSuspendTenantErrors, type IdentitiesSuspendTenantResponse, type IdentitiesSuspendTenantResponses, type IdentitiesUpdateData, type IdentitiesUpdateError, type IdentitiesUpdateErrors, type IdentitiesUpdateResponse, type IdentitiesUpdateResponses, type Identity, type Invitation, type InvitationResponse, type KeysCreateData, type KeysCreateError, type KeysCreateErrors, type KeysCreateResponse, type KeysCreateResponses, type KeysGetData, type KeysGetError, type KeysGetErrors, type KeysGetResponse, type KeysGetResponses, type KeysListData, type KeysListError, type KeysListErrors, type KeysListResponse, type KeysListResponses, type KeysRevokeData, type KeysRevokeError, type KeysRevokeErrors, type KeysRevokeResponse, type KeysRevokeResponses, type KeysUpdateData, type KeysUpdateError, type KeysUpdateErrors, type KeysUpdateResponse, type KeysUpdateResponses, type Label, type LabelRemoved, type LabelsCreateData, type LabelsCreateError, type LabelsCreateErrors, type LabelsCreateResponse, type LabelsCreateResponses, type LabelsDeleteData, type LabelsDeleteError, type LabelsDeleteErrors, type LabelsDeleteResponse, type LabelsDeleteResponses, type LabelsListData, type LabelsListError, type LabelsListErrors, type LabelsListResponse, type LabelsListResponses, type LabelsUpdateData, type LabelsUpdateError, type LabelsUpdateErrors, type LabelsUpdateResponse, type LabelsUpdateResponses, type Mailbox, type MailboxAccess, type MailboxChange, type MailboxesChangesData, type MailboxesChangesError, type MailboxesChangesErrors, type MailboxesChangesResponse, type MailboxesChangesResponses, type MailboxesEmptyTrashData, type MailboxesEmptyTrashError, type MailboxesEmptyTrashErrors, type MailboxesEmptyTrashResponse, type MailboxesEmptyTrashResponses, type MailboxesListData, type MailboxesListError, type MailboxesListErrors, type MailboxesListFolderData, type MailboxesListFolderError, type MailboxesListFolderErrors, type MailboxesListFolderResponse, type MailboxesListFolderResponses, type MailboxesListResponse, type MailboxesListResponses, type Me, type MeGetData, type MeGetError, type MeGetErrors, type MeGetResponse, type MeGetResponses, type Member, type Message, type MessageListItem, type MessagesActData, type MessagesActError, type MessagesActErrors, type MessagesActResponse, type MessagesActResponses, type MessagesForwardData, type MessagesForwardError, type MessagesForwardErrors, type MessagesForwardResponse, type MessagesForwardResponses, type MessagesGetData, type MessagesGetError, type MessagesGetErrors, type MessagesGetResponse, type MessagesGetResponses, type MessagesListInThreadData, type MessagesListInThreadError, type MessagesListInThreadErrors, type MessagesListInThreadResponse, type MessagesListInThreadResponses, type MessagesRawData, type MessagesRawError, type MessagesRawErrors, type MessagesRawResponse, type MessagesRawResponses, type MessagesReplyAllData, type MessagesReplyAllError, type MessagesReplyAllErrors, type MessagesReplyAllResponse, type MessagesReplyAllResponses, type MessagesReplyData, type MessagesReplyError, type MessagesReplyErrors, type MessagesReplyResponse, type MessagesReplyResponses, type MessagesRespondToInvitationData, type MessagesRespondToInvitationError, type MessagesRespondToInvitationErrors, type MessagesRespondToInvitationResponse, type MessagesRespondToInvitationResponses, type MessagesSearchData, type MessagesSearchError, type MessagesSearchErrors, type MessagesSearchResponse, type MessagesSearchResponses, type MessagesSendData, type MessagesSendError, type MessagesSendErrors, type MessagesSendResponse, type MessagesSendResponses, type MessagesUndoData, type MessagesUndoError, type MessagesUndoErrors, type MessagesUndoResponse, type MessagesUndoResponses, type MessagesUpdateData, type MessagesUpdateError, type MessagesUpdateErrors, type MessagesUpdateResponse, type MessagesUpdateResponses, type Metrics, type MetricsQueryData, type MetricsQueryError, type MetricsQueryErrors, type MetricsQueryResponse, type MetricsQueryResponses, type Options, type Pod, type PodsCreateData, type PodsCreateError, type PodsCreateErrors, type PodsCreateResponse, type PodsCreateResponses, type PodsGetData, type PodsGetError, type PodsGetErrors, type PodsGetResponse, type PodsGetResponses, type PodsListData, type PodsListError, type PodsListErrors, type PodsListResponse, type PodsListResponses, type PodsUpdateData, type PodsUpdateError, type PodsUpdateErrors, type PodsUpdateResponse, type PodsUpdateResponses, type ReceiveRuleRemoved, type ReceiveRules, type Replayed, type Restored, type Revoked, type RoutingCreateData, type RoutingCreateError, type RoutingCreateErrors, type RoutingCreateResponse, type RoutingCreateResponses, type RoutingDeleteData, type RoutingDeleteError, type RoutingDeleteErrors, type RoutingDeleteResponse, type RoutingDeleteResponses, type RoutingListData, type RoutingListError, type RoutingListErrors, type RoutingListResponse, type RoutingListResponses, type RoutingRule, type RoutingUpdateData, type RoutingUpdateError, type RoutingUpdateErrors, type RoutingUpdateResponse, type RoutingUpdateResponses, SIGNATURE_HEADER, type SearchHit, type SendRuleRemoved, type SendRules, type Sent, type SetupLink, type StreamOptions, type StreamedEvent, TIMESTAMP_HEADER, type TenantSuspended, type Thread, type ThreadsGetData, type ThreadsGetError, type ThreadsGetErrors, type ThreadsGetResponse, type ThreadsGetResponses, type ThreadsLabelsCreateData, type ThreadsLabelsCreateError, type ThreadsLabelsCreateErrors, type ThreadsLabelsCreateResponse, type ThreadsLabelsCreateResponses, type ThreadsLabelsDeleteData, type ThreadsLabelsDeleteError, type ThreadsLabelsDeleteErrors, type ThreadsLabelsDeleteResponse, type ThreadsLabelsDeleteResponses, type ThreadsLabelsGetData, type ThreadsLabelsGetError, type ThreadsLabelsGetErrors, type ThreadsLabelsGetResponse, type ThreadsLabelsGetResponses, type ThreadsListData, type ThreadsListError, type ThreadsListErrors, type ThreadsListResponse, type ThreadsListResponses, type ThreadsUpdateData, type ThreadsUpdateError, type ThreadsUpdateErrors, type ThreadsUpdateResponse, type ThreadsUpdateResponses, type Undo, type UploadedAttachment, type Verification, type Webhook, type WebhookCreated, type WebhookEnvelope, type WebhookHeaders, type WebhooksCreateData, type WebhooksCreateError, type WebhooksCreateErrors, type WebhooksCreateResponse, type WebhooksCreateResponses, type WebhooksDeleteData, type WebhooksDeleteError, type WebhooksDeleteErrors, type WebhooksDeleteResponse, type WebhooksDeleteResponses, type WebhooksDeliveriesData, type WebhooksDeliveriesError, type WebhooksDeliveriesErrors, type WebhooksDeliveriesResponse, type WebhooksDeliveriesResponses, type WebhooksGetData, type WebhooksGetError, type WebhooksGetErrors, type WebhooksGetHeadersData, type WebhooksGetHeadersError, type WebhooksGetHeadersErrors, type WebhooksGetHeadersResponse, type WebhooksGetHeadersResponses, type WebhooksGetResponse, type WebhooksGetResponses, type WebhooksListData, type WebhooksListError, type WebhooksListErrors, type WebhooksListResponse, type WebhooksListResponses, type WebhooksReplayData, type WebhooksReplayError, type WebhooksReplayErrors, type WebhooksReplayResponse, type WebhooksReplayResponses, type WebhooksUpdateData, type WebhooksUpdateError, type WebhooksUpdateErrors, type WebhooksUpdateHeadersData, type WebhooksUpdateHeadersError, type WebhooksUpdateHeadersErrors, type WebhooksUpdateHeadersResponse, type WebhooksUpdateHeadersResponses, type WebhooksUpdateResponse, type WebhooksUpdateResponses, type Workspace, type WorkspaceGetData, type WorkspaceGetError, type WorkspaceGetErrors, type WorkspaceGetResponse, type WorkspaceGetResponses, type WorkspaceMembersData, type WorkspaceMembersError, type WorkspaceMembersErrors, type WorkspaceMembersResponse, type WorkspaceMembersResponses, agentAttachHuman, agentSignUp, agentVerify, appPasswordsCreate, appPasswordsList, appPasswordsRevoke, attachmentsDownloadUrl, attachmentsUpload, calendarCreateEvent, calendarDeleteEvent, calendarGet, calendarGetAgenda, calendarGetEvent, calendarListEventInstances, calendarListEvents, calendarRespondToEvent, calendarUpdate, calendarUpdateEvent, client, createClient, createConfig, domainsCreate, domainsDelete, domainsGet, domainsGetSetupLink, domainsList, domainsUpdate, domainsVerify, domainsZoneFile, draftsCancelSchedule, draftsCreate, draftsDelete, draftsGet, draftsList, draftsRemoveAttachment, draftsSchedule, draftsSend, draftsUpdate, eventsGet, eventsList, eventsStream, identitiesAccessCreate, identitiesAccessDelete, identitiesAccessGet, identitiesCreate, identitiesDelete, identitiesGet, identitiesList, identitiesReceiveRulesCreate, identitiesReceiveRulesDelete, identitiesReceiveRulesGet, identitiesSendRulesCreate, identitiesSendRulesDelete, identitiesSendRulesGet, identitiesSuspendTenant, identitiesUpdate, keysCreate, keysGet, keysList, keysRevoke, keysUpdate, labelsCreate, labelsDelete, labelsList, labelsUpdate, mailboxesChanges, mailboxesEmptyTrash, mailboxesList, mailboxesListFolder, meGet, messagesAct, messagesForward, messagesGet, messagesListInThread, messagesRaw, messagesReply, messagesReplyAll, messagesRespondToInvitation, messagesSearch, messagesSend, messagesUndo, messagesUpdate, metricsQuery, podsCreate, podsGet, podsList, podsUpdate, routingCreate, routingDelete, routingList, routingUpdate, streamEvents, threadsGet, threadsLabelsCreate, threadsLabelsDelete, threadsLabelsGet, threadsList, threadsUpdate, verifyWebhook, webhooksCreate, webhooksDelete, webhooksDeliveries, webhooksGet, webhooksGetHeaders, webhooksList, webhooksReplay, webhooksUpdate, webhooksUpdateHeaders, workspaceGet, workspaceMembers };
package/dist/index.js CHANGED
@@ -43,7 +43,7 @@ function createSseClient({
43
43
  ...options
44
44
  }) {
45
45
  let lastEventId;
46
- const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
46
+ const sleep2 = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
47
47
  const createStream = async function* () {
48
48
  let retryDelay = sseDefaultRetryDelay ?? 3e3;
49
49
  let attempt = 0;
@@ -147,7 +147,7 @@ function createSseClient({
147
147
  break;
148
148
  }
149
149
  const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
150
- await sleep(backoff);
150
+ await sleep2(backoff);
151
151
  }
152
152
  }
153
153
  };
@@ -926,6 +926,34 @@ var identitiesSuspendTenant = (options) => (options.client ?? client).post({
926
926
  url: "/tenants/{id}/suspend",
927
927
  ...options
928
928
  });
929
+ var podsList = (options) => (options?.client ?? client).get({
930
+ security: [{ scheme: "bearer", type: "http" }],
931
+ url: "/pods",
932
+ ...options
933
+ });
934
+ var podsCreate = (options) => (options.client ?? client).post({
935
+ security: [{ scheme: "bearer", type: "http" }],
936
+ url: "/pods",
937
+ ...options,
938
+ headers: {
939
+ "Content-Type": "application/json",
940
+ ...options.headers
941
+ }
942
+ });
943
+ var podsGet = (options) => (options.client ?? client).get({
944
+ security: [{ scheme: "bearer", type: "http" }],
945
+ url: "/pods/{id}",
946
+ ...options
947
+ });
948
+ var podsUpdate = (options) => (options.client ?? client).patch({
949
+ security: [{ scheme: "bearer", type: "http" }],
950
+ url: "/pods/{id}",
951
+ ...options,
952
+ headers: {
953
+ "Content-Type": "application/json",
954
+ ...options.headers
955
+ }
956
+ });
929
957
  var labelsList = (options) => (options.client ?? client).get({
930
958
  security: [{ scheme: "bearer", type: "http" }],
931
959
  url: "/labels",
@@ -1515,6 +1543,105 @@ function constantTimeEqual(a, b) {
1515
1543
  }
1516
1544
  return difference === 0;
1517
1545
  }
1546
+
1547
+ // src/stream.ts
1548
+ async function* streamEvents(options) {
1549
+ const base = (options.baseUrl ?? "https://pidgeon.ai/api/v1").replace(/\/$/, "");
1550
+ let lastEventId;
1551
+ let backoffMs = 1e3;
1552
+ while (!options.signal?.aborted) {
1553
+ const url = new URL(`${base}/events/stream`);
1554
+ if (options.identityId) url.searchParams.set("identity_id", options.identityId);
1555
+ if (options.type) url.searchParams.set("type", options.type);
1556
+ if (options.after && !lastEventId) url.searchParams.set("after", options.after);
1557
+ let response;
1558
+ try {
1559
+ response = await fetch(url, {
1560
+ headers: {
1561
+ authorization: `Bearer ${options.apiKey}`,
1562
+ accept: "text/event-stream",
1563
+ ...lastEventId ? { "last-event-id": lastEventId } : {}
1564
+ },
1565
+ signal: options.signal
1566
+ });
1567
+ } catch {
1568
+ if (options.signal?.aborted) return;
1569
+ await sleep(backoffMs, options.signal);
1570
+ backoffMs = Math.min(backoffMs * 2, 3e4);
1571
+ continue;
1572
+ }
1573
+ if (response.status === 401 || response.status === 403 || response.status === 404) {
1574
+ throw new Error(
1575
+ `Pidgeon refused the stream: ${response.status} ${await response.text().catch(() => "")}`.trim()
1576
+ );
1577
+ }
1578
+ if (!response.ok || !response.body) {
1579
+ await sleep(backoffMs, options.signal);
1580
+ backoffMs = Math.min(backoffMs * 2, 3e4);
1581
+ continue;
1582
+ }
1583
+ backoffMs = 1e3;
1584
+ for await (const frame of frames(response.body, options.signal)) {
1585
+ if (frame.id) lastEventId = frame.id;
1586
+ if (!frame.data) continue;
1587
+ if (frame.event === "error") continue;
1588
+ let parsed;
1589
+ try {
1590
+ parsed = JSON.parse(frame.data);
1591
+ } catch {
1592
+ continue;
1593
+ }
1594
+ yield parsed;
1595
+ }
1596
+ }
1597
+ }
1598
+ async function* frames(body, signal) {
1599
+ const reader = body.getReader();
1600
+ const decoder = new TextDecoder();
1601
+ let buffer = "";
1602
+ try {
1603
+ while (!signal?.aborted) {
1604
+ const { done, value } = await reader.read();
1605
+ if (done) return;
1606
+ buffer += decoder.decode(value, { stream: true });
1607
+ let boundary = buffer.indexOf("\n\n");
1608
+ while (boundary !== -1) {
1609
+ const block = buffer.slice(0, boundary);
1610
+ buffer = buffer.slice(boundary + 2);
1611
+ boundary = buffer.indexOf("\n\n");
1612
+ const frame = {};
1613
+ const data = [];
1614
+ for (const line of block.split("\n")) {
1615
+ if (line.startsWith(":")) continue;
1616
+ const colon = line.indexOf(":");
1617
+ if (colon === -1) continue;
1618
+ const field = line.slice(0, colon);
1619
+ const value2 = line.slice(colon + 1).replace(/^ /, "");
1620
+ if (field === "id") frame.id = value2;
1621
+ else if (field === "event") frame.event = value2;
1622
+ else if (field === "data") data.push(value2);
1623
+ }
1624
+ if (data.length > 0) frame.data = data.join("\n");
1625
+ if (frame.id || frame.data) yield frame;
1626
+ }
1627
+ }
1628
+ } finally {
1629
+ await reader.cancel().catch(() => void 0);
1630
+ }
1631
+ }
1632
+ function sleep(ms, signal) {
1633
+ return new Promise((resolve) => {
1634
+ const timer = setTimeout(resolve, ms);
1635
+ signal?.addEventListener(
1636
+ "abort",
1637
+ () => {
1638
+ clearTimeout(timer);
1639
+ resolve();
1640
+ },
1641
+ { once: true }
1642
+ );
1643
+ });
1644
+ }
1518
1645
  export {
1519
1646
  SIGNATURE_HEADER,
1520
1647
  TIMESTAMP_HEADER,
@@ -1601,10 +1728,15 @@ export {
1601
1728
  messagesUndo,
1602
1729
  messagesUpdate,
1603
1730
  metricsQuery,
1731
+ podsCreate,
1732
+ podsGet,
1733
+ podsList,
1734
+ podsUpdate,
1604
1735
  routingCreate,
1605
1736
  routingDelete,
1606
1737
  routingList,
1607
1738
  routingUpdate,
1739
+ streamEvents,
1608
1740
  threadsGet,
1609
1741
  threadsLabelsCreate,
1610
1742
  threadsLabelsDelete,