@pidgeon-ai/sdk 1.3.0 → 1.4.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/CHANGELOG.md +64 -0
- package/dist/index.cjs +103 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +112 -2
- package/dist/index.d.ts +112 -2
- package/dist/index.js +102 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -461,6 +461,20 @@ type Message = {
|
|
|
461
461
|
reply_text: string;
|
|
462
462
|
is_read: boolean;
|
|
463
463
|
is_spam: boolean;
|
|
464
|
+
/**
|
|
465
|
+
* 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.
|
|
466
|
+
*/
|
|
467
|
+
headers: {
|
|
468
|
+
[key: string]: string;
|
|
469
|
+
};
|
|
470
|
+
/**
|
|
471
|
+
* 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.
|
|
472
|
+
*/
|
|
473
|
+
authentication: {
|
|
474
|
+
spf: string | null;
|
|
475
|
+
dkim: string | null;
|
|
476
|
+
dmarc: string | null;
|
|
477
|
+
};
|
|
464
478
|
attachments: Array<{
|
|
465
479
|
id: string;
|
|
466
480
|
filename: string;
|
|
@@ -524,6 +538,20 @@ type Thread = {
|
|
|
524
538
|
assignee_id: string | null;
|
|
525
539
|
assigned_at: string | null;
|
|
526
540
|
message_count: number;
|
|
541
|
+
/**
|
|
542
|
+
* Where the newest message is filed. Null on a thread with no messages.
|
|
543
|
+
*/
|
|
544
|
+
folder: 'inbox' | 'starred' | 'sent' | 'drafts' | 'scheduled' | 'snoozed' | 'archive' | 'spam' | 'trash' | 'unauthenticated' | null;
|
|
545
|
+
/**
|
|
546
|
+
* Who sent the newest message.
|
|
547
|
+
*/
|
|
548
|
+
from: string | null;
|
|
549
|
+
from_name: string | null;
|
|
550
|
+
/**
|
|
551
|
+
* The first line of the newest message.
|
|
552
|
+
*/
|
|
553
|
+
preview: string | null;
|
|
554
|
+
has_attachments: boolean;
|
|
527
555
|
last_message_at: string | null;
|
|
528
556
|
/**
|
|
529
557
|
* ISO-8601, UTC.
|
|
@@ -2403,6 +2431,9 @@ type MessagesSearchResponse = MessagesSearchResponses[keyof MessagesSearchRespon
|
|
|
2403
2431
|
type MessagesActData = {
|
|
2404
2432
|
body: {
|
|
2405
2433
|
message_ids: Array<string>;
|
|
2434
|
+
/**
|
|
2435
|
+
* `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.
|
|
2436
|
+
*/
|
|
2406
2437
|
action: 'read' | 'unread' | 'star' | 'unstar' | 'archive' | 'unarchive' | 'delete' | 'restore' | 'spam' | 'not_spam' | 'delete_forever';
|
|
2407
2438
|
};
|
|
2408
2439
|
path?: never;
|
|
@@ -2499,6 +2530,9 @@ type MessagesGetResponses = {
|
|
|
2499
2530
|
type MessagesGetResponse = MessagesGetResponses[keyof MessagesGetResponses];
|
|
2500
2531
|
type MessagesUpdateData = {
|
|
2501
2532
|
body: {
|
|
2533
|
+
/**
|
|
2534
|
+
* 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.
|
|
2535
|
+
*/
|
|
2502
2536
|
is_read?: boolean;
|
|
2503
2537
|
is_starred?: boolean;
|
|
2504
2538
|
folder?: 'inbox' | 'archive' | 'spam' | 'trash';
|
|
@@ -5356,7 +5390,7 @@ declare const messagesListInThread: <ThrowOnError extends boolean = false>(optio
|
|
|
5356
5390
|
/**
|
|
5357
5391
|
* Send a message
|
|
5358
5392
|
*
|
|
5359
|
-
* Idempotent with an `Idempotency-Key` header. Answers `202` with the id, the thread and anything **rejected** —
|
|
5393
|
+
* 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
5394
|
*/
|
|
5361
5395
|
declare const messagesSend: <ThrowOnError extends boolean = false>(options: Options<MessagesSendData, ThrowOnError>) => RequestResult<MessagesSendResponses, MessagesSendErrors, ThrowOnError>;
|
|
5362
5396
|
/**
|
|
@@ -5594,6 +5628,8 @@ declare const workspaceMembers: <ThrowOnError extends boolean = false>(options?:
|
|
|
5594
5628
|
*
|
|
5595
5629
|
* **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
5630
|
*
|
|
5631
|
+
* **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.
|
|
5632
|
+
*
|
|
5597
5633
|
* 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
5634
|
*/
|
|
5599
5635
|
declare const eventsList: <ThrowOnError extends boolean = false>(options?: Options<EventsListData, ThrowOnError>) => RequestResult<EventsListResponses, EventsListErrors, ThrowOnError>;
|
|
@@ -5843,4 +5879,78 @@ declare function verifyWebhook(input: {
|
|
|
5843
5879
|
now?: Date;
|
|
5844
5880
|
}): Promise<WebhookEnvelope>;
|
|
5845
5881
|
|
|
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 };
|
|
5882
|
+
/**
|
|
5883
|
+
* Holding the event log open.
|
|
5884
|
+
*
|
|
5885
|
+
* **The second thing a generator cannot produce**, for the same reason as
|
|
5886
|
+
* `webhooks.ts`: `GET /events/stream` answers `text/event-stream` and
|
|
5887
|
+
* `openapi-ts` builds a typed `fetch` that resolves once with a body. There
|
|
5888
|
+
* is nowhere in a generated client to put a connection that stays open, so
|
|
5889
|
+
* `eventsStream` exists in the types and does nothing useful, and the
|
|
5890
|
+
* endpoint the documentation recommends for *"a caller that cannot host a
|
|
5891
|
+
* webhook endpoint — a script on a laptop, a notebook, an agent runtime with
|
|
5892
|
+
* no public address"* was the one endpoint every customer hand-rolled.
|
|
5893
|
+
*
|
|
5894
|
+
* A field test on 15 October wrote forty lines of it and they worked first
|
|
5895
|
+
* try, which is the argument both ways: the protocol is simple, and nobody
|
|
5896
|
+
* should write it twice. These are those forty lines, once.
|
|
5897
|
+
*
|
|
5898
|
+
* `EventSource` is not used. It cannot send an `Authorization` header — the
|
|
5899
|
+
* browser API takes a URL and nothing else — and putting an API key in a
|
|
5900
|
+
* query string is the one place it must never go. So this is `fetch` with a
|
|
5901
|
+
* reader, which also works unchanged in Node, Bun, Deno, Workers and Vercel
|
|
5902
|
+
* functions.
|
|
5903
|
+
*/
|
|
5904
|
+
/** A row of `GET /events`, delivered as it happens. The same shape either way. */
|
|
5905
|
+
interface StreamedEvent {
|
|
5906
|
+
id: string;
|
|
5907
|
+
type: string;
|
|
5908
|
+
identity: string | null;
|
|
5909
|
+
message_id: string | null;
|
|
5910
|
+
thread_id: string | null;
|
|
5911
|
+
data: Record<string, unknown>;
|
|
5912
|
+
created_at: string;
|
|
5913
|
+
}
|
|
5914
|
+
interface StreamOptions {
|
|
5915
|
+
/** `https://pidgeon.ai/api/v1` unless you are pointing at something else. */
|
|
5916
|
+
baseUrl?: string;
|
|
5917
|
+
apiKey: string;
|
|
5918
|
+
/** Narrow to one mailbox. Omitted, the stream spans every one the key reaches. */
|
|
5919
|
+
identityId?: string;
|
|
5920
|
+
/** A comma-separated list, exactly as `GET /events` takes it. */
|
|
5921
|
+
type?: string;
|
|
5922
|
+
/**
|
|
5923
|
+
* Where to start, as an ISO timestamp.
|
|
5924
|
+
*
|
|
5925
|
+
* **`1970-01-01T00:00:00Z` reads the whole log from the beginning**, which
|
|
5926
|
+
* is the answer to a question the API otherwise makes you guess at: with
|
|
5927
|
+
* no cursor at all the plain listing pages *backwards*, so a first-time
|
|
5928
|
+
* consumer that stores its last row stores the oldest event and never
|
|
5929
|
+
* advances. Omit this and the stream starts from now.
|
|
5930
|
+
*/
|
|
5931
|
+
after?: string;
|
|
5932
|
+
/** Stop the stream. Aborting mid-event drops that event rather than half of it. */
|
|
5933
|
+
signal?: AbortSignal;
|
|
5934
|
+
}
|
|
5935
|
+
/**
|
|
5936
|
+
* Every event, as it happens, until you stop asking.
|
|
5937
|
+
*
|
|
5938
|
+
* ```ts
|
|
5939
|
+
* for await (const event of streamEvents({ apiKey })) {
|
|
5940
|
+
* if (event.type === 'message.received' && !event.data.from_self) {
|
|
5941
|
+
* await answer(event.data.message_id as string);
|
|
5942
|
+
* }
|
|
5943
|
+
* }
|
|
5944
|
+
* ```
|
|
5945
|
+
*
|
|
5946
|
+
* **Reconnection is this function's job and it is lossless.** The server
|
|
5947
|
+
* closes the connection itself after about 280 seconds so that the last
|
|
5948
|
+
* thing you receive is a cursor rather than a socket error; this reconnects
|
|
5949
|
+
* with `Last-Event-ID`, which the server prefers over `after`, so there is
|
|
5950
|
+
* no gap and no repeat. A network failure is retried the same way with a
|
|
5951
|
+
* short backoff. The loop ends when `signal` aborts and in no other case —
|
|
5952
|
+
* a stream that gave up quietly would be worse than one that never started.
|
|
5953
|
+
*/
|
|
5954
|
+
declare function streamEvents(options: StreamOptions): AsyncGenerator<StreamedEvent>;
|
|
5955
|
+
|
|
5956
|
+
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, 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, 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.d.ts
CHANGED
|
@@ -461,6 +461,20 @@ type Message = {
|
|
|
461
461
|
reply_text: string;
|
|
462
462
|
is_read: boolean;
|
|
463
463
|
is_spam: boolean;
|
|
464
|
+
/**
|
|
465
|
+
* 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.
|
|
466
|
+
*/
|
|
467
|
+
headers: {
|
|
468
|
+
[key: string]: string;
|
|
469
|
+
};
|
|
470
|
+
/**
|
|
471
|
+
* 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.
|
|
472
|
+
*/
|
|
473
|
+
authentication: {
|
|
474
|
+
spf: string | null;
|
|
475
|
+
dkim: string | null;
|
|
476
|
+
dmarc: string | null;
|
|
477
|
+
};
|
|
464
478
|
attachments: Array<{
|
|
465
479
|
id: string;
|
|
466
480
|
filename: string;
|
|
@@ -524,6 +538,20 @@ type Thread = {
|
|
|
524
538
|
assignee_id: string | null;
|
|
525
539
|
assigned_at: string | null;
|
|
526
540
|
message_count: number;
|
|
541
|
+
/**
|
|
542
|
+
* Where the newest message is filed. Null on a thread with no messages.
|
|
543
|
+
*/
|
|
544
|
+
folder: 'inbox' | 'starred' | 'sent' | 'drafts' | 'scheduled' | 'snoozed' | 'archive' | 'spam' | 'trash' | 'unauthenticated' | null;
|
|
545
|
+
/**
|
|
546
|
+
* Who sent the newest message.
|
|
547
|
+
*/
|
|
548
|
+
from: string | null;
|
|
549
|
+
from_name: string | null;
|
|
550
|
+
/**
|
|
551
|
+
* The first line of the newest message.
|
|
552
|
+
*/
|
|
553
|
+
preview: string | null;
|
|
554
|
+
has_attachments: boolean;
|
|
527
555
|
last_message_at: string | null;
|
|
528
556
|
/**
|
|
529
557
|
* ISO-8601, UTC.
|
|
@@ -2403,6 +2431,9 @@ type MessagesSearchResponse = MessagesSearchResponses[keyof MessagesSearchRespon
|
|
|
2403
2431
|
type MessagesActData = {
|
|
2404
2432
|
body: {
|
|
2405
2433
|
message_ids: Array<string>;
|
|
2434
|
+
/**
|
|
2435
|
+
* `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.
|
|
2436
|
+
*/
|
|
2406
2437
|
action: 'read' | 'unread' | 'star' | 'unstar' | 'archive' | 'unarchive' | 'delete' | 'restore' | 'spam' | 'not_spam' | 'delete_forever';
|
|
2407
2438
|
};
|
|
2408
2439
|
path?: never;
|
|
@@ -2499,6 +2530,9 @@ type MessagesGetResponses = {
|
|
|
2499
2530
|
type MessagesGetResponse = MessagesGetResponses[keyof MessagesGetResponses];
|
|
2500
2531
|
type MessagesUpdateData = {
|
|
2501
2532
|
body: {
|
|
2533
|
+
/**
|
|
2534
|
+
* 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.
|
|
2535
|
+
*/
|
|
2502
2536
|
is_read?: boolean;
|
|
2503
2537
|
is_starred?: boolean;
|
|
2504
2538
|
folder?: 'inbox' | 'archive' | 'spam' | 'trash';
|
|
@@ -5356,7 +5390,7 @@ declare const messagesListInThread: <ThrowOnError extends boolean = false>(optio
|
|
|
5356
5390
|
/**
|
|
5357
5391
|
* Send a message
|
|
5358
5392
|
*
|
|
5359
|
-
* Idempotent with an `Idempotency-Key` header. Answers `202` with the id, the thread and anything **rejected** —
|
|
5393
|
+
* 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
5394
|
*/
|
|
5361
5395
|
declare const messagesSend: <ThrowOnError extends boolean = false>(options: Options<MessagesSendData, ThrowOnError>) => RequestResult<MessagesSendResponses, MessagesSendErrors, ThrowOnError>;
|
|
5362
5396
|
/**
|
|
@@ -5594,6 +5628,8 @@ declare const workspaceMembers: <ThrowOnError extends boolean = false>(options?:
|
|
|
5594
5628
|
*
|
|
5595
5629
|
* **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
5630
|
*
|
|
5631
|
+
* **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.
|
|
5632
|
+
*
|
|
5597
5633
|
* 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
5634
|
*/
|
|
5599
5635
|
declare const eventsList: <ThrowOnError extends boolean = false>(options?: Options<EventsListData, ThrowOnError>) => RequestResult<EventsListResponses, EventsListErrors, ThrowOnError>;
|
|
@@ -5843,4 +5879,78 @@ declare function verifyWebhook(input: {
|
|
|
5843
5879
|
now?: Date;
|
|
5844
5880
|
}): Promise<WebhookEnvelope>;
|
|
5845
5881
|
|
|
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 };
|
|
5882
|
+
/**
|
|
5883
|
+
* Holding the event log open.
|
|
5884
|
+
*
|
|
5885
|
+
* **The second thing a generator cannot produce**, for the same reason as
|
|
5886
|
+
* `webhooks.ts`: `GET /events/stream` answers `text/event-stream` and
|
|
5887
|
+
* `openapi-ts` builds a typed `fetch` that resolves once with a body. There
|
|
5888
|
+
* is nowhere in a generated client to put a connection that stays open, so
|
|
5889
|
+
* `eventsStream` exists in the types and does nothing useful, and the
|
|
5890
|
+
* endpoint the documentation recommends for *"a caller that cannot host a
|
|
5891
|
+
* webhook endpoint — a script on a laptop, a notebook, an agent runtime with
|
|
5892
|
+
* no public address"* was the one endpoint every customer hand-rolled.
|
|
5893
|
+
*
|
|
5894
|
+
* A field test on 15 October wrote forty lines of it and they worked first
|
|
5895
|
+
* try, which is the argument both ways: the protocol is simple, and nobody
|
|
5896
|
+
* should write it twice. These are those forty lines, once.
|
|
5897
|
+
*
|
|
5898
|
+
* `EventSource` is not used. It cannot send an `Authorization` header — the
|
|
5899
|
+
* browser API takes a URL and nothing else — and putting an API key in a
|
|
5900
|
+
* query string is the one place it must never go. So this is `fetch` with a
|
|
5901
|
+
* reader, which also works unchanged in Node, Bun, Deno, Workers and Vercel
|
|
5902
|
+
* functions.
|
|
5903
|
+
*/
|
|
5904
|
+
/** A row of `GET /events`, delivered as it happens. The same shape either way. */
|
|
5905
|
+
interface StreamedEvent {
|
|
5906
|
+
id: string;
|
|
5907
|
+
type: string;
|
|
5908
|
+
identity: string | null;
|
|
5909
|
+
message_id: string | null;
|
|
5910
|
+
thread_id: string | null;
|
|
5911
|
+
data: Record<string, unknown>;
|
|
5912
|
+
created_at: string;
|
|
5913
|
+
}
|
|
5914
|
+
interface StreamOptions {
|
|
5915
|
+
/** `https://pidgeon.ai/api/v1` unless you are pointing at something else. */
|
|
5916
|
+
baseUrl?: string;
|
|
5917
|
+
apiKey: string;
|
|
5918
|
+
/** Narrow to one mailbox. Omitted, the stream spans every one the key reaches. */
|
|
5919
|
+
identityId?: string;
|
|
5920
|
+
/** A comma-separated list, exactly as `GET /events` takes it. */
|
|
5921
|
+
type?: string;
|
|
5922
|
+
/**
|
|
5923
|
+
* Where to start, as an ISO timestamp.
|
|
5924
|
+
*
|
|
5925
|
+
* **`1970-01-01T00:00:00Z` reads the whole log from the beginning**, which
|
|
5926
|
+
* is the answer to a question the API otherwise makes you guess at: with
|
|
5927
|
+
* no cursor at all the plain listing pages *backwards*, so a first-time
|
|
5928
|
+
* consumer that stores its last row stores the oldest event and never
|
|
5929
|
+
* advances. Omit this and the stream starts from now.
|
|
5930
|
+
*/
|
|
5931
|
+
after?: string;
|
|
5932
|
+
/** Stop the stream. Aborting mid-event drops that event rather than half of it. */
|
|
5933
|
+
signal?: AbortSignal;
|
|
5934
|
+
}
|
|
5935
|
+
/**
|
|
5936
|
+
* Every event, as it happens, until you stop asking.
|
|
5937
|
+
*
|
|
5938
|
+
* ```ts
|
|
5939
|
+
* for await (const event of streamEvents({ apiKey })) {
|
|
5940
|
+
* if (event.type === 'message.received' && !event.data.from_self) {
|
|
5941
|
+
* await answer(event.data.message_id as string);
|
|
5942
|
+
* }
|
|
5943
|
+
* }
|
|
5944
|
+
* ```
|
|
5945
|
+
*
|
|
5946
|
+
* **Reconnection is this function's job and it is lossless.** The server
|
|
5947
|
+
* closes the connection itself after about 280 seconds so that the last
|
|
5948
|
+
* thing you receive is a cursor rather than a socket error; this reconnects
|
|
5949
|
+
* with `Last-Event-ID`, which the server prefers over `after`, so there is
|
|
5950
|
+
* no gap and no repeat. A network failure is retried the same way with a
|
|
5951
|
+
* short backoff. The loop ends when `signal` aborts and in no other case —
|
|
5952
|
+
* a stream that gave up quietly would be worse than one that never started.
|
|
5953
|
+
*/
|
|
5954
|
+
declare function streamEvents(options: StreamOptions): AsyncGenerator<StreamedEvent>;
|
|
5955
|
+
|
|
5956
|
+
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, 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, 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
|
|
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
|
|
150
|
+
await sleep2(backoff);
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
};
|
|
@@ -1515,6 +1515,105 @@ function constantTimeEqual(a, b) {
|
|
|
1515
1515
|
}
|
|
1516
1516
|
return difference === 0;
|
|
1517
1517
|
}
|
|
1518
|
+
|
|
1519
|
+
// src/stream.ts
|
|
1520
|
+
async function* streamEvents(options) {
|
|
1521
|
+
const base = (options.baseUrl ?? "https://pidgeon.ai/api/v1").replace(/\/$/, "");
|
|
1522
|
+
let lastEventId;
|
|
1523
|
+
let backoffMs = 1e3;
|
|
1524
|
+
while (!options.signal?.aborted) {
|
|
1525
|
+
const url = new URL(`${base}/events/stream`);
|
|
1526
|
+
if (options.identityId) url.searchParams.set("identity_id", options.identityId);
|
|
1527
|
+
if (options.type) url.searchParams.set("type", options.type);
|
|
1528
|
+
if (options.after && !lastEventId) url.searchParams.set("after", options.after);
|
|
1529
|
+
let response;
|
|
1530
|
+
try {
|
|
1531
|
+
response = await fetch(url, {
|
|
1532
|
+
headers: {
|
|
1533
|
+
authorization: `Bearer ${options.apiKey}`,
|
|
1534
|
+
accept: "text/event-stream",
|
|
1535
|
+
...lastEventId ? { "last-event-id": lastEventId } : {}
|
|
1536
|
+
},
|
|
1537
|
+
signal: options.signal
|
|
1538
|
+
});
|
|
1539
|
+
} catch {
|
|
1540
|
+
if (options.signal?.aborted) return;
|
|
1541
|
+
await sleep(backoffMs, options.signal);
|
|
1542
|
+
backoffMs = Math.min(backoffMs * 2, 3e4);
|
|
1543
|
+
continue;
|
|
1544
|
+
}
|
|
1545
|
+
if (response.status === 401 || response.status === 403 || response.status === 404) {
|
|
1546
|
+
throw new Error(
|
|
1547
|
+
`Pidgeon refused the stream: ${response.status} ${await response.text().catch(() => "")}`.trim()
|
|
1548
|
+
);
|
|
1549
|
+
}
|
|
1550
|
+
if (!response.ok || !response.body) {
|
|
1551
|
+
await sleep(backoffMs, options.signal);
|
|
1552
|
+
backoffMs = Math.min(backoffMs * 2, 3e4);
|
|
1553
|
+
continue;
|
|
1554
|
+
}
|
|
1555
|
+
backoffMs = 1e3;
|
|
1556
|
+
for await (const frame of frames(response.body, options.signal)) {
|
|
1557
|
+
if (frame.id) lastEventId = frame.id;
|
|
1558
|
+
if (!frame.data) continue;
|
|
1559
|
+
if (frame.event === "error") continue;
|
|
1560
|
+
let parsed;
|
|
1561
|
+
try {
|
|
1562
|
+
parsed = JSON.parse(frame.data);
|
|
1563
|
+
} catch {
|
|
1564
|
+
continue;
|
|
1565
|
+
}
|
|
1566
|
+
yield parsed;
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
async function* frames(body, signal) {
|
|
1571
|
+
const reader = body.getReader();
|
|
1572
|
+
const decoder = new TextDecoder();
|
|
1573
|
+
let buffer = "";
|
|
1574
|
+
try {
|
|
1575
|
+
while (!signal?.aborted) {
|
|
1576
|
+
const { done, value } = await reader.read();
|
|
1577
|
+
if (done) return;
|
|
1578
|
+
buffer += decoder.decode(value, { stream: true });
|
|
1579
|
+
let boundary = buffer.indexOf("\n\n");
|
|
1580
|
+
while (boundary !== -1) {
|
|
1581
|
+
const block = buffer.slice(0, boundary);
|
|
1582
|
+
buffer = buffer.slice(boundary + 2);
|
|
1583
|
+
boundary = buffer.indexOf("\n\n");
|
|
1584
|
+
const frame = {};
|
|
1585
|
+
const data = [];
|
|
1586
|
+
for (const line of block.split("\n")) {
|
|
1587
|
+
if (line.startsWith(":")) continue;
|
|
1588
|
+
const colon = line.indexOf(":");
|
|
1589
|
+
if (colon === -1) continue;
|
|
1590
|
+
const field = line.slice(0, colon);
|
|
1591
|
+
const value2 = line.slice(colon + 1).replace(/^ /, "");
|
|
1592
|
+
if (field === "id") frame.id = value2;
|
|
1593
|
+
else if (field === "event") frame.event = value2;
|
|
1594
|
+
else if (field === "data") data.push(value2);
|
|
1595
|
+
}
|
|
1596
|
+
if (data.length > 0) frame.data = data.join("\n");
|
|
1597
|
+
if (frame.id || frame.data) yield frame;
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
} finally {
|
|
1601
|
+
await reader.cancel().catch(() => void 0);
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
function sleep(ms, signal) {
|
|
1605
|
+
return new Promise((resolve) => {
|
|
1606
|
+
const timer = setTimeout(resolve, ms);
|
|
1607
|
+
signal?.addEventListener(
|
|
1608
|
+
"abort",
|
|
1609
|
+
() => {
|
|
1610
|
+
clearTimeout(timer);
|
|
1611
|
+
resolve();
|
|
1612
|
+
},
|
|
1613
|
+
{ once: true }
|
|
1614
|
+
);
|
|
1615
|
+
});
|
|
1616
|
+
}
|
|
1518
1617
|
export {
|
|
1519
1618
|
SIGNATURE_HEADER,
|
|
1520
1619
|
TIMESTAMP_HEADER,
|
|
@@ -1605,6 +1704,7 @@ export {
|
|
|
1605
1704
|
routingDelete,
|
|
1606
1705
|
routingList,
|
|
1607
1706
|
routingUpdate,
|
|
1707
|
+
streamEvents,
|
|
1608
1708
|
threadsGet,
|
|
1609
1709
|
threadsLabelsCreate,
|
|
1610
1710
|
threadsLabelsDelete,
|