@pidgeon-ai/sdk 1.68.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs DELETED
@@ -1,2239 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- SIGNATURE_HEADER: () => SIGNATURE_HEADER,
24
- TIMESTAMP_HEADER: () => TIMESTAMP_HEADER,
25
- agentAttachHuman: () => agentAttachHuman,
26
- agentConnect: () => agentConnect,
27
- agentSetup: () => agentSetup,
28
- agentSignUp: () => agentSignUp,
29
- agentVerify: () => agentVerify,
30
- appPasswordsCreate: () => appPasswordsCreate,
31
- appPasswordsList: () => appPasswordsList,
32
- appPasswordsRevoke: () => appPasswordsRevoke,
33
- attachmentsCompleteUpload: () => attachmentsCompleteUpload,
34
- attachmentsCreateUpload: () => attachmentsCreateUpload,
35
- attachmentsDownloadUrl: () => attachmentsDownloadUrl,
36
- attachmentsText: () => attachmentsText,
37
- attachmentsUpload: () => attachmentsUpload,
38
- calendarCreateEvent: () => calendarCreateEvent,
39
- calendarDeleteEvent: () => calendarDeleteEvent,
40
- calendarFreeTime: () => calendarFreeTime,
41
- calendarGet: () => calendarGet,
42
- calendarGetAgenda: () => calendarGetAgenda,
43
- calendarGetEvent: () => calendarGetEvent,
44
- calendarListEventInstances: () => calendarListEventInstances,
45
- calendarListEvents: () => calendarListEvents,
46
- calendarRespondToEvent: () => calendarRespondToEvent,
47
- calendarUpdate: () => calendarUpdate,
48
- calendarUpdateEvent: () => calendarUpdateEvent,
49
- cardsGet: () => cardsGet,
50
- client: () => client,
51
- contactsBlock: () => contactsBlock,
52
- contactsCreate: () => contactsCreate,
53
- contactsDelete: () => contactsDelete,
54
- contactsGet: () => contactsGet,
55
- contactsList: () => contactsList,
56
- contactsUnblock: () => contactsUnblock,
57
- contactsUpdate: () => contactsUpdate,
58
- createClient: () => createClient,
59
- createConfig: () => createConfig,
60
- domainsCreate: () => domainsCreate,
61
- domainsDelete: () => domainsDelete,
62
- domainsGet: () => domainsGet,
63
- domainsGetSetupLink: () => domainsGetSetupLink,
64
- domainsList: () => domainsList,
65
- domainsUpdate: () => domainsUpdate,
66
- domainsVerify: () => domainsVerify,
67
- domainsZoneFile: () => domainsZoneFile,
68
- draftsApproval: () => draftsApproval,
69
- draftsCancelSchedule: () => draftsCancelSchedule,
70
- draftsCreate: () => draftsCreate,
71
- draftsDelete: () => draftsDelete,
72
- draftsGet: () => draftsGet,
73
- draftsList: () => draftsList,
74
- draftsRemoveAttachment: () => draftsRemoveAttachment,
75
- draftsSchedule: () => draftsSchedule,
76
- draftsSend: () => draftsSend,
77
- draftsUpdate: () => draftsUpdate,
78
- eventsGet: () => eventsGet,
79
- eventsList: () => eventsList,
80
- eventsSocket: () => eventsSocket,
81
- eventsStream: () => eventsStream,
82
- exportMail: () => exportMail,
83
- grantsCreate: () => grantsCreate,
84
- grantsGet: () => grantsGet,
85
- grantsList: () => grantsList,
86
- grantsRevoke: () => grantsRevoke,
87
- grantsStatus: () => grantsStatus,
88
- grantsTemplatesCreate: () => grantsTemplatesCreate,
89
- grantsTemplatesDelete: () => grantsTemplatesDelete,
90
- grantsTemplatesList: () => grantsTemplatesList,
91
- identitiesAccessCreate: () => identitiesAccessCreate,
92
- identitiesAccessDelete: () => identitiesAccessDelete,
93
- identitiesAccessGet: () => identitiesAccessGet,
94
- identitiesCard: () => identitiesCard,
95
- identitiesCreate: () => identitiesCreate,
96
- identitiesDelete: () => identitiesDelete,
97
- identitiesGet: () => identitiesGet,
98
- identitiesList: () => identitiesList,
99
- identitiesReceiveRulesCreate: () => identitiesReceiveRulesCreate,
100
- identitiesReceiveRulesDelete: () => identitiesReceiveRulesDelete,
101
- identitiesReceiveRulesGet: () => identitiesReceiveRulesGet,
102
- identitiesSendRulesCreate: () => identitiesSendRulesCreate,
103
- identitiesSendRulesDelete: () => identitiesSendRulesDelete,
104
- identitiesSendRulesGet: () => identitiesSendRulesGet,
105
- identitiesSuspendTenant: () => identitiesSuspendTenant,
106
- identitiesUpdate: () => identitiesUpdate,
107
- keysCreate: () => keysCreate,
108
- keysGet: () => keysGet,
109
- keysList: () => keysList,
110
- keysRevoke: () => keysRevoke,
111
- keysRotate: () => keysRotate,
112
- keysUpdate: () => keysUpdate,
113
- labelsCreate: () => labelsCreate,
114
- labelsDelete: () => labelsDelete,
115
- labelsList: () => labelsList,
116
- labelsUpdate: () => labelsUpdate,
117
- logCheckpoint: () => logCheckpoint,
118
- logConsistency: () => logConsistency,
119
- logEntries: () => logEntries,
120
- logHead: () => logHead,
121
- logMonitorsCreate: () => logMonitorsCreate,
122
- logMonitorsDelete: () => logMonitorsDelete,
123
- logMonitorsList: () => logMonitorsList,
124
- logProof: () => logProof,
125
- mailboxesChanges: () => mailboxesChanges,
126
- mailboxesEmptyTrash: () => mailboxesEmptyTrash,
127
- mailboxesList: () => mailboxesList,
128
- mailboxesListFolder: () => mailboxesListFolder,
129
- meGet: () => meGet,
130
- messagesAct: () => messagesAct,
131
- messagesAwait: () => messagesAwait,
132
- messagesCheck: () => messagesCheck,
133
- messagesForward: () => messagesForward,
134
- messagesGet: () => messagesGet,
135
- messagesListInThread: () => messagesListInThread,
136
- messagesRaw: () => messagesRaw,
137
- messagesReply: () => messagesReply,
138
- messagesReplyAll: () => messagesReplyAll,
139
- messagesRespondToInvitation: () => messagesRespondToInvitation,
140
- messagesSearch: () => messagesSearch,
141
- messagesSend: () => messagesSend,
142
- messagesUndo: () => messagesUndo,
143
- messagesUpdate: () => messagesUpdate,
144
- metricsQuery: () => metricsQuery,
145
- podsCreate: () => podsCreate,
146
- podsDelete: () => podsDelete,
147
- podsGet: () => podsGet,
148
- podsList: () => podsList,
149
- podsUpdate: () => podsUpdate,
150
- routingCreate: () => routingCreate,
151
- routingDelete: () => routingDelete,
152
- routingList: () => routingList,
153
- routingUpdate: () => routingUpdate,
154
- signInsApprove: () => signInsApprove,
155
- streamEvents: () => streamEvents,
156
- testInbound: () => testInbound,
157
- threadsGet: () => threadsGet,
158
- threadsLabelsCreate: () => threadsLabelsCreate,
159
- threadsLabelsDelete: () => threadsLabelsDelete,
160
- threadsLabelsGet: () => threadsLabelsGet,
161
- threadsList: () => threadsList,
162
- threadsUpdate: () => threadsUpdate,
163
- verifySender: () => verifySender,
164
- verifyWebhook: () => verifyWebhook,
165
- webhooksCreate: () => webhooksCreate,
166
- webhooksDelete: () => webhooksDelete,
167
- webhooksDeliveries: () => webhooksDeliveries,
168
- webhooksGet: () => webhooksGet,
169
- webhooksGetHeaders: () => webhooksGetHeaders,
170
- webhooksList: () => webhooksList,
171
- webhooksReplay: () => webhooksReplay,
172
- webhooksUpdate: () => webhooksUpdate,
173
- webhooksUpdateHeaders: () => webhooksUpdateHeaders,
174
- workspaceGet: () => workspaceGet,
175
- workspaceMembers: () => workspaceMembers
176
- });
177
- module.exports = __toCommonJS(index_exports);
178
-
179
- // src/generated/core/bodySerializer.gen.ts
180
- var serializeFormDataPair = (data, key, value) => {
181
- if (typeof value === "string" || value instanceof Blob) {
182
- data.append(key, value);
183
- } else if (value instanceof Date) {
184
- data.append(key, value.toISOString());
185
- } else {
186
- data.append(key, JSON.stringify(value));
187
- }
188
- };
189
- var formDataBodySerializer = {
190
- bodySerializer: (body) => {
191
- const data = new FormData();
192
- Object.entries(body).forEach(([key, value]) => {
193
- if (value === void 0 || value === null) {
194
- return;
195
- }
196
- if (Array.isArray(value)) {
197
- value.forEach((v) => serializeFormDataPair(data, key, v));
198
- } else {
199
- serializeFormDataPair(data, key, value);
200
- }
201
- });
202
- return data;
203
- }
204
- };
205
- var jsonBodySerializer = {
206
- bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
207
- };
208
-
209
- // src/generated/core/serverSentEvents.gen.ts
210
- function createSseClient({
211
- onRequest,
212
- onSseError,
213
- onSseEvent,
214
- responseTransformer,
215
- responseValidator,
216
- sseDefaultRetryDelay,
217
- sseMaxRetryAttempts,
218
- sseMaxRetryDelay,
219
- sseSleepFn,
220
- url,
221
- ...options
222
- }) {
223
- let lastEventId;
224
- const sleep2 = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
225
- const createStream = async function* () {
226
- let retryDelay = sseDefaultRetryDelay ?? 3e3;
227
- let attempt = 0;
228
- const signal = options.signal ?? new AbortController().signal;
229
- while (true) {
230
- if (signal.aborted) break;
231
- attempt++;
232
- const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
233
- if (lastEventId !== void 0) {
234
- headers.set("Last-Event-ID", lastEventId);
235
- }
236
- try {
237
- const requestInit = {
238
- redirect: "follow",
239
- ...options,
240
- body: options.serializedBody,
241
- headers,
242
- signal
243
- };
244
- let request = new Request(url, requestInit);
245
- if (onRequest) {
246
- request = await onRequest(url, requestInit);
247
- }
248
- const _fetch = options.fetch ?? globalThis.fetch;
249
- const response = await _fetch(request);
250
- if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
251
- if (!response.body) throw new Error("No body in SSE response");
252
- const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
253
- let buffer = "";
254
- const abortHandler = () => {
255
- try {
256
- reader.cancel();
257
- } catch {
258
- }
259
- };
260
- signal.addEventListener("abort", abortHandler);
261
- try {
262
- while (true) {
263
- const { done, value } = await reader.read();
264
- if (done) break;
265
- buffer += value;
266
- buffer = buffer.replace(/\r\n?/g, "\n");
267
- const chunks = buffer.split("\n\n");
268
- buffer = chunks.pop() ?? "";
269
- for (const chunk of chunks) {
270
- const lines = chunk.split("\n");
271
- const dataLines = [];
272
- let eventName;
273
- for (const line of lines) {
274
- if (line.startsWith("data:")) {
275
- dataLines.push(line.replace(/^data:\s*/, ""));
276
- } else if (line.startsWith("event:")) {
277
- eventName = line.replace(/^event:\s*/, "");
278
- } else if (line.startsWith("id:")) {
279
- lastEventId = line.replace(/^id:\s*/, "");
280
- } else if (line.startsWith("retry:")) {
281
- const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
282
- if (!Number.isNaN(parsed)) {
283
- retryDelay = parsed;
284
- }
285
- }
286
- }
287
- let data;
288
- let parsedJson = false;
289
- if (dataLines.length) {
290
- const rawData = dataLines.join("\n");
291
- try {
292
- data = JSON.parse(rawData);
293
- parsedJson = true;
294
- } catch {
295
- data = rawData;
296
- }
297
- }
298
- if (parsedJson) {
299
- if (responseValidator) {
300
- await responseValidator(data);
301
- }
302
- if (responseTransformer) {
303
- data = await responseTransformer(data);
304
- }
305
- }
306
- onSseEvent?.({
307
- data,
308
- event: eventName,
309
- id: lastEventId,
310
- retry: retryDelay
311
- });
312
- if (dataLines.length) {
313
- yield data;
314
- }
315
- }
316
- }
317
- } finally {
318
- signal.removeEventListener("abort", abortHandler);
319
- reader.releaseLock();
320
- }
321
- break;
322
- } catch (error) {
323
- onSseError?.(error);
324
- if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
325
- break;
326
- }
327
- const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
328
- await sleep2(backoff);
329
- }
330
- }
331
- };
332
- const stream = createStream();
333
- return { stream };
334
- }
335
-
336
- // src/generated/core/pathSerializer.gen.ts
337
- var separatorArrayExplode = (style) => {
338
- switch (style) {
339
- case "label":
340
- return ".";
341
- case "matrix":
342
- return ";";
343
- case "simple":
344
- return ",";
345
- default:
346
- return "&";
347
- }
348
- };
349
- var separatorArrayNoExplode = (style) => {
350
- switch (style) {
351
- case "form":
352
- return ",";
353
- case "pipeDelimited":
354
- return "|";
355
- case "spaceDelimited":
356
- return "%20";
357
- default:
358
- return ",";
359
- }
360
- };
361
- var separatorObjectExplode = (style) => {
362
- switch (style) {
363
- case "label":
364
- return ".";
365
- case "matrix":
366
- return ";";
367
- case "simple":
368
- return ",";
369
- default:
370
- return "&";
371
- }
372
- };
373
- var serializeArrayParam = ({
374
- allowReserved,
375
- explode,
376
- name,
377
- style,
378
- value
379
- }) => {
380
- if (!explode) {
381
- const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
382
- switch (style) {
383
- case "label":
384
- return `.${joinedValues2}`;
385
- case "matrix":
386
- return `;${name}=${joinedValues2}`;
387
- case "simple":
388
- return joinedValues2;
389
- default:
390
- return `${name}=${joinedValues2}`;
391
- }
392
- }
393
- const separator = separatorArrayExplode(style);
394
- const joinedValues = value.map((v) => {
395
- if (style === "label" || style === "simple") {
396
- return allowReserved ? v : encodeURIComponent(v);
397
- }
398
- return serializePrimitiveParam({
399
- allowReserved,
400
- name,
401
- value: v
402
- });
403
- }).join(separator);
404
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
405
- };
406
- var serializePrimitiveParam = ({
407
- allowReserved,
408
- name,
409
- value
410
- }) => {
411
- if (value === void 0 || value === null) {
412
- return "";
413
- }
414
- if (typeof value === "object") {
415
- throw new Error(
416
- "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
417
- );
418
- }
419
- return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
420
- };
421
- var serializeObjectParam = ({
422
- allowReserved,
423
- explode,
424
- name,
425
- style,
426
- value,
427
- valueOnly
428
- }) => {
429
- if (value instanceof Date) {
430
- return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
431
- }
432
- if (style !== "deepObject" && !explode) {
433
- let values = [];
434
- Object.entries(value).forEach(([key, v]) => {
435
- values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
436
- });
437
- const joinedValues2 = values.join(",");
438
- switch (style) {
439
- case "form":
440
- return `${name}=${joinedValues2}`;
441
- case "label":
442
- return `.${joinedValues2}`;
443
- case "matrix":
444
- return `;${name}=${joinedValues2}`;
445
- default:
446
- return joinedValues2;
447
- }
448
- }
449
- const separator = separatorObjectExplode(style);
450
- const joinedValues = Object.entries(value).map(
451
- ([key, v]) => serializePrimitiveParam({
452
- allowReserved,
453
- name: style === "deepObject" ? `${name}[${key}]` : key,
454
- value: v
455
- })
456
- ).join(separator);
457
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
458
- };
459
-
460
- // src/generated/core/utils.gen.ts
461
- var PATH_PARAM_RE = /\{[^{}]+\}/g;
462
- var defaultPathSerializer = ({ path, url: _url }) => {
463
- let url = _url;
464
- const matches = _url.match(PATH_PARAM_RE);
465
- if (matches) {
466
- for (const match of matches) {
467
- let explode = false;
468
- let name = match.substring(1, match.length - 1);
469
- let style = "simple";
470
- if (name.endsWith("*")) {
471
- explode = true;
472
- name = name.substring(0, name.length - 1);
473
- }
474
- if (name.startsWith(".")) {
475
- name = name.substring(1);
476
- style = "label";
477
- } else if (name.startsWith(";")) {
478
- name = name.substring(1);
479
- style = "matrix";
480
- }
481
- const value = path[name];
482
- if (value === void 0 || value === null) {
483
- continue;
484
- }
485
- if (Array.isArray(value)) {
486
- url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
487
- continue;
488
- }
489
- if (typeof value === "object") {
490
- url = url.replace(
491
- match,
492
- serializeObjectParam({
493
- explode,
494
- name,
495
- style,
496
- value,
497
- valueOnly: true
498
- })
499
- );
500
- continue;
501
- }
502
- if (style === "matrix") {
503
- url = url.replace(
504
- match,
505
- `;${serializePrimitiveParam({
506
- name,
507
- value
508
- })}`
509
- );
510
- continue;
511
- }
512
- const replaceValue = encodeURIComponent(
513
- style === "label" ? `.${value}` : value
514
- );
515
- url = url.replace(match, replaceValue);
516
- }
517
- }
518
- return url;
519
- };
520
- var getUrl = ({
521
- baseUrl,
522
- path,
523
- query,
524
- querySerializer,
525
- url: _url
526
- }) => {
527
- const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
528
- let url = (baseUrl ?? "") + pathUrl;
529
- if (path) {
530
- url = defaultPathSerializer({ path, url });
531
- }
532
- let search = query ? querySerializer(query) : "";
533
- if (search.startsWith("?")) {
534
- search = search.substring(1);
535
- }
536
- if (search) {
537
- url += `?${search}`;
538
- }
539
- return url;
540
- };
541
- function getValidRequestBody(options) {
542
- const hasBody = options.body !== void 0;
543
- const isSerializedBody = hasBody && options.bodySerializer;
544
- if (isSerializedBody) {
545
- if ("serializedBody" in options) {
546
- const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
547
- return hasSerializedBody ? options.serializedBody : null;
548
- }
549
- return options.body !== "" ? options.body : null;
550
- }
551
- if (hasBody) {
552
- return options.body;
553
- }
554
- return void 0;
555
- }
556
-
557
- // src/generated/core/auth.gen.ts
558
- var getAuthToken = async (auth, callback) => {
559
- const token = typeof callback === "function" ? await callback(auth) : callback;
560
- if (!token) {
561
- return;
562
- }
563
- if (auth.scheme === "bearer") {
564
- return `Bearer ${token}`;
565
- }
566
- if (auth.scheme === "basic") {
567
- return `Basic ${btoa(token)}`;
568
- }
569
- return token;
570
- };
571
-
572
- // src/generated/client/utils.gen.ts
573
- var createQuerySerializer = ({
574
- parameters = {},
575
- ...args
576
- } = {}) => {
577
- const querySerializer = (queryParams) => {
578
- const search = [];
579
- if (queryParams && typeof queryParams === "object") {
580
- for (const name in queryParams) {
581
- const value = queryParams[name];
582
- if (value === void 0 || value === null) {
583
- continue;
584
- }
585
- const options = parameters[name] || args;
586
- if (Array.isArray(value)) {
587
- const serializedArray = serializeArrayParam({
588
- allowReserved: options.allowReserved,
589
- explode: true,
590
- name,
591
- style: "form",
592
- value,
593
- ...options.array
594
- });
595
- if (serializedArray) search.push(serializedArray);
596
- } else if (typeof value === "object") {
597
- const serializedObject = serializeObjectParam({
598
- allowReserved: options.allowReserved,
599
- explode: true,
600
- name,
601
- style: "deepObject",
602
- value,
603
- ...options.object
604
- });
605
- if (serializedObject) search.push(serializedObject);
606
- } else {
607
- const serializedPrimitive = serializePrimitiveParam({
608
- allowReserved: options.allowReserved,
609
- name,
610
- value
611
- });
612
- if (serializedPrimitive) search.push(serializedPrimitive);
613
- }
614
- }
615
- }
616
- return search.join("&");
617
- };
618
- return querySerializer;
619
- };
620
- var getParseAs = (contentType) => {
621
- if (!contentType) {
622
- return "stream";
623
- }
624
- const cleanContent = contentType.split(";")[0]?.trim();
625
- if (!cleanContent) {
626
- return;
627
- }
628
- if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
629
- return "json";
630
- }
631
- if (cleanContent === "multipart/form-data") {
632
- return "formData";
633
- }
634
- if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
635
- return "blob";
636
- }
637
- if (cleanContent.startsWith("text/")) {
638
- return "text";
639
- }
640
- return;
641
- };
642
- var checkForExistence = (options, name) => {
643
- if (!name) {
644
- return false;
645
- }
646
- if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
647
- return true;
648
- }
649
- return false;
650
- };
651
- async function setAuthParams(options) {
652
- for (const auth of options.security ?? []) {
653
- if (checkForExistence(options, auth.name)) {
654
- continue;
655
- }
656
- const token = await getAuthToken(auth, options.auth);
657
- if (!token) {
658
- continue;
659
- }
660
- const name = auth.name ?? "Authorization";
661
- switch (auth.in) {
662
- case "query":
663
- if (!options.query) {
664
- options.query = {};
665
- }
666
- options.query[name] = token;
667
- break;
668
- case "cookie":
669
- options.headers.append("Cookie", `${name}=${token}`);
670
- break;
671
- case "header":
672
- default:
673
- options.headers.set(name, token);
674
- break;
675
- }
676
- }
677
- }
678
- var buildUrl = (options) => getUrl({
679
- baseUrl: options.baseUrl,
680
- path: options.path,
681
- query: options.query,
682
- querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
683
- url: options.url
684
- });
685
- var mergeConfigs = (a, b) => {
686
- const config = { ...a, ...b };
687
- if (config.baseUrl?.endsWith("/")) {
688
- config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
689
- }
690
- config.headers = mergeHeaders(a.headers, b.headers);
691
- return config;
692
- };
693
- var headersEntries = (headers) => {
694
- const entries = [];
695
- headers.forEach((value, key) => {
696
- entries.push([key, value]);
697
- });
698
- return entries;
699
- };
700
- var mergeHeaders = (...headers) => {
701
- const mergedHeaders = new Headers();
702
- for (const header of headers) {
703
- if (!header) {
704
- continue;
705
- }
706
- const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
707
- for (const [key, value] of iterator) {
708
- if (value === null) {
709
- mergedHeaders.delete(key);
710
- } else if (Array.isArray(value)) {
711
- for (const v of value) {
712
- mergedHeaders.append(key, v);
713
- }
714
- } else if (value !== void 0) {
715
- mergedHeaders.set(
716
- key,
717
- typeof value === "object" ? JSON.stringify(value) : value
718
- );
719
- }
720
- }
721
- }
722
- return mergedHeaders;
723
- };
724
- var Interceptors = class {
725
- fns = [];
726
- clear() {
727
- this.fns = [];
728
- }
729
- eject(id) {
730
- const index = this.getInterceptorIndex(id);
731
- if (this.fns[index]) {
732
- this.fns[index] = null;
733
- }
734
- }
735
- exists(id) {
736
- const index = this.getInterceptorIndex(id);
737
- return Boolean(this.fns[index]);
738
- }
739
- getInterceptorIndex(id) {
740
- if (typeof id === "number") {
741
- return this.fns[id] ? id : -1;
742
- }
743
- return this.fns.indexOf(id);
744
- }
745
- update(id, fn) {
746
- const index = this.getInterceptorIndex(id);
747
- if (this.fns[index]) {
748
- this.fns[index] = fn;
749
- return id;
750
- }
751
- return false;
752
- }
753
- use(fn) {
754
- this.fns.push(fn);
755
- return this.fns.length - 1;
756
- }
757
- };
758
- var createInterceptors = () => ({
759
- error: new Interceptors(),
760
- request: new Interceptors(),
761
- response: new Interceptors()
762
- });
763
- var defaultQuerySerializer = createQuerySerializer({
764
- allowReserved: false,
765
- array: {
766
- explode: true,
767
- style: "form"
768
- },
769
- object: {
770
- explode: true,
771
- style: "deepObject"
772
- }
773
- });
774
- var defaultHeaders = {
775
- "Content-Type": "application/json"
776
- };
777
- var createConfig = (override = {}) => ({
778
- ...jsonBodySerializer,
779
- headers: defaultHeaders,
780
- parseAs: "auto",
781
- querySerializer: defaultQuerySerializer,
782
- ...override
783
- });
784
-
785
- // src/generated/client/client.gen.ts
786
- var createClient = (config = {}) => {
787
- let _config = mergeConfigs(createConfig(), config);
788
- const getConfig = () => ({ ..._config });
789
- const setConfig = (config2) => {
790
- _config = mergeConfigs(_config, config2);
791
- return getConfig();
792
- };
793
- const interceptors = createInterceptors();
794
- const beforeRequest = async (options) => {
795
- const opts = {
796
- ..._config,
797
- ...options,
798
- fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
799
- headers: mergeHeaders(_config.headers, options.headers),
800
- serializedBody: void 0
801
- };
802
- if (opts.security) {
803
- await setAuthParams(opts);
804
- }
805
- if (opts.requestValidator) {
806
- await opts.requestValidator(opts);
807
- }
808
- if (opts.body !== void 0 && opts.bodySerializer) {
809
- opts.serializedBody = opts.bodySerializer(opts.body);
810
- }
811
- if (opts.body === void 0 || opts.serializedBody === "") {
812
- opts.headers.delete("Content-Type");
813
- }
814
- const resolvedOpts = opts;
815
- const url = buildUrl(resolvedOpts);
816
- return { opts: resolvedOpts, url };
817
- };
818
- const request = async (options) => {
819
- const throwOnError = options.throwOnError ?? _config.throwOnError;
820
- const responseStyle = options.responseStyle ?? _config.responseStyle;
821
- let request2;
822
- let response;
823
- try {
824
- const { opts, url } = await beforeRequest(options);
825
- const requestInit = {
826
- redirect: "follow",
827
- ...opts,
828
- body: getValidRequestBody(opts)
829
- };
830
- request2 = new Request(url, requestInit);
831
- for (const fn of interceptors.request.fns) {
832
- if (fn) {
833
- request2 = await fn(request2, opts);
834
- }
835
- }
836
- const _fetch = opts.fetch;
837
- response = await _fetch(request2);
838
- for (const fn of interceptors.response.fns) {
839
- if (fn) {
840
- response = await fn(response, request2, opts);
841
- }
842
- }
843
- const result = {
844
- request: request2,
845
- response
846
- };
847
- if (response.ok) {
848
- const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
849
- if (response.status === 204 || response.headers.get("Content-Length") === "0") {
850
- let emptyData;
851
- switch (parseAs) {
852
- case "arrayBuffer":
853
- case "blob":
854
- case "text":
855
- emptyData = await response[parseAs]();
856
- break;
857
- case "formData":
858
- emptyData = new FormData();
859
- break;
860
- case "stream":
861
- emptyData = response.body;
862
- break;
863
- case "json":
864
- default:
865
- emptyData = {};
866
- break;
867
- }
868
- return opts.responseStyle === "data" ? emptyData : {
869
- data: emptyData,
870
- ...result
871
- };
872
- }
873
- let data;
874
- switch (parseAs) {
875
- case "arrayBuffer":
876
- case "blob":
877
- case "formData":
878
- case "text":
879
- data = await response[parseAs]();
880
- break;
881
- case "json": {
882
- const text = await response.text();
883
- data = text ? JSON.parse(text) : {};
884
- break;
885
- }
886
- case "stream":
887
- return opts.responseStyle === "data" ? response.body : {
888
- data: response.body,
889
- ...result
890
- };
891
- }
892
- if (parseAs === "json") {
893
- if (opts.responseValidator) {
894
- await opts.responseValidator(data);
895
- }
896
- if (opts.responseTransformer) {
897
- data = await opts.responseTransformer(data);
898
- }
899
- }
900
- return opts.responseStyle === "data" ? data : {
901
- data,
902
- ...result
903
- };
904
- }
905
- const textError = await response.text();
906
- let jsonError;
907
- try {
908
- jsonError = JSON.parse(textError);
909
- } catch {
910
- }
911
- throw jsonError ?? textError;
912
- } catch (error) {
913
- let finalError = error;
914
- for (const fn of interceptors.error.fns) {
915
- if (fn) {
916
- finalError = await fn(finalError, response, request2, options);
917
- }
918
- }
919
- finalError = finalError || {};
920
- if (throwOnError) {
921
- throw finalError;
922
- }
923
- return responseStyle === "data" ? void 0 : {
924
- error: finalError,
925
- request: request2,
926
- response
927
- };
928
- }
929
- };
930
- const makeMethodFn = (method) => (options) => request({ ...options, method });
931
- const makeSseFn = (method) => async (options) => {
932
- const { opts, url } = await beforeRequest(options);
933
- return createSseClient({
934
- ...opts,
935
- body: opts.body,
936
- method,
937
- onRequest: async (url2, init) => {
938
- let request2 = new Request(url2, init);
939
- for (const fn of interceptors.request.fns) {
940
- if (fn) {
941
- request2 = await fn(request2, opts);
942
- }
943
- }
944
- return request2;
945
- },
946
- serializedBody: getValidRequestBody(opts),
947
- url
948
- });
949
- };
950
- const _buildUrl = (options) => buildUrl({ ..._config, ...options });
951
- return {
952
- buildUrl: _buildUrl,
953
- connect: makeMethodFn("CONNECT"),
954
- delete: makeMethodFn("DELETE"),
955
- get: makeMethodFn("GET"),
956
- getConfig,
957
- head: makeMethodFn("HEAD"),
958
- interceptors,
959
- options: makeMethodFn("OPTIONS"),
960
- patch: makeMethodFn("PATCH"),
961
- post: makeMethodFn("POST"),
962
- put: makeMethodFn("PUT"),
963
- request,
964
- setConfig,
965
- sse: {
966
- connect: makeSseFn("CONNECT"),
967
- delete: makeSseFn("DELETE"),
968
- get: makeSseFn("GET"),
969
- head: makeSseFn("HEAD"),
970
- options: makeSseFn("OPTIONS"),
971
- patch: makeSseFn("PATCH"),
972
- post: makeSseFn("POST"),
973
- put: makeSseFn("PUT"),
974
- trace: makeSseFn("TRACE")
975
- },
976
- trace: makeMethodFn("TRACE")
977
- };
978
- };
979
-
980
- // src/runtime-config.ts
981
- var USER_AGENT = "@pidgeon-ai/sdk";
982
- var createClientConfig = (config) => ({
983
- ...config,
984
- ...typeof window === "undefined" ? { headers: { "User-Agent": USER_AGENT, ...plain(config?.headers) } } : {}
985
- });
986
- function plain(headers) {
987
- return headers && typeof headers === "object" && !(headers instanceof Headers) ? headers : {};
988
- }
989
-
990
- // src/generated/client.gen.ts
991
- var client = createClient(
992
- createClientConfig(createConfig({ baseUrl: "https://pidgeon.ai/api/v1" }))
993
- );
994
-
995
- // src/generated/sdk.gen.ts
996
- var agentSignUp = (options) => (options.client ?? client).post({
997
- url: "/agent/signup",
998
- ...options,
999
- headers: {
1000
- "Content-Type": "application/json",
1001
- ...options.headers
1002
- }
1003
- });
1004
- var agentAttachHuman = (options) => (options.client ?? client).post({
1005
- url: "/agent/human",
1006
- ...options,
1007
- headers: {
1008
- "Content-Type": "application/json",
1009
- ...options.headers
1010
- }
1011
- });
1012
- var agentVerify = (options) => (options.client ?? client).post({
1013
- url: "/agent/verify",
1014
- ...options,
1015
- headers: {
1016
- "Content-Type": "application/json",
1017
- ...options.headers
1018
- }
1019
- });
1020
- var cardsGet = (options) => (options.client ?? client).get({
1021
- url: "/cards/{id}",
1022
- ...options
1023
- });
1024
- var verifySender = (options) => (options.client ?? client).post({
1025
- url: "/verify",
1026
- ...options,
1027
- headers: {
1028
- "Content-Type": "application/json",
1029
- ...options.headers
1030
- }
1031
- });
1032
- var logHead = (options) => (options?.client ?? client).get({
1033
- url: "/log/head",
1034
- ...options
1035
- });
1036
- var logCheckpoint = (options) => (options?.client ?? client).get({
1037
- url: "/log/checkpoint",
1038
- ...options
1039
- });
1040
- var logEntries = (options) => (options?.client ?? client).get({
1041
- url: "/log/entries",
1042
- ...options
1043
- });
1044
- var logProof = (options) => (options?.client ?? client).get({
1045
- url: "/log/proof",
1046
- ...options
1047
- });
1048
- var logConsistency = (options) => (options.client ?? client).get({
1049
- url: "/log/consistency",
1050
- ...options
1051
- });
1052
- var logMonitorsList = (options) => (options?.client ?? client).get({
1053
- security: [{ scheme: "bearer", type: "http" }],
1054
- url: "/log/monitors",
1055
- ...options
1056
- });
1057
- var logMonitorsCreate = (options) => (options.client ?? client).post({
1058
- security: [{ scheme: "bearer", type: "http" }],
1059
- url: "/log/monitors",
1060
- ...options,
1061
- headers: {
1062
- "Content-Type": "application/json",
1063
- ...options.headers
1064
- }
1065
- });
1066
- var logMonitorsDelete = (options) => (options.client ?? client).delete({
1067
- security: [{ scheme: "bearer", type: "http" }],
1068
- url: "/log/monitors/{id}",
1069
- ...options
1070
- });
1071
- var grantsStatus = (options) => (options.client ?? client).get({
1072
- url: "/grants/{id}/status",
1073
- ...options
1074
- });
1075
- var agentConnect = (options) => (options.client ?? client).post({
1076
- url: "/agent/connect",
1077
- ...options,
1078
- headers: {
1079
- "Content-Type": "application/json",
1080
- ...options.headers
1081
- }
1082
- });
1083
- var agentSetup = (options) => (options?.client ?? client).get({
1084
- security: [{ scheme: "bearer", type: "http" }],
1085
- url: "/agent/setup",
1086
- ...options
1087
- });
1088
- var identitiesList = (options) => (options?.client ?? client).get({
1089
- security: [{ scheme: "bearer", type: "http" }],
1090
- url: "/identities",
1091
- ...options
1092
- });
1093
- var identitiesCreate = (options) => (options.client ?? client).post({
1094
- security: [{ scheme: "bearer", type: "http" }],
1095
- url: "/identities",
1096
- ...options,
1097
- headers: {
1098
- "Content-Type": "application/json",
1099
- ...options.headers
1100
- }
1101
- });
1102
- var identitiesDelete = (options) => (options.client ?? client).delete({
1103
- security: [{ scheme: "bearer", type: "http" }],
1104
- url: "/identities/{id}",
1105
- ...options
1106
- });
1107
- var identitiesGet = (options) => (options.client ?? client).get({
1108
- security: [{ scheme: "bearer", type: "http" }],
1109
- url: "/identities/{id}",
1110
- ...options
1111
- });
1112
- var identitiesUpdate = (options) => (options.client ?? client).patch(
1113
- {
1114
- security: [{ scheme: "bearer", type: "http" }],
1115
- url: "/identities/{id}",
1116
- ...options,
1117
- headers: {
1118
- "Content-Type": "application/json",
1119
- ...options.headers
1120
- }
1121
- }
1122
- );
1123
- var identitiesCard = (options) => (options.client ?? client).get({
1124
- security: [{ scheme: "bearer", type: "http" }],
1125
- url: "/identities/{id}/card",
1126
- ...options
1127
- });
1128
- var identitiesAccessDelete = (options) => (options.client ?? client).delete({
1129
- security: [{ scheme: "bearer", type: "http" }],
1130
- url: "/identities/{id}/access",
1131
- ...options
1132
- });
1133
- var identitiesAccessGet = (options) => (options.client ?? client).get({
1134
- security: [{ scheme: "bearer", type: "http" }],
1135
- url: "/identities/{id}/access",
1136
- ...options
1137
- });
1138
- var identitiesAccessCreate = (options) => (options.client ?? client).post({
1139
- security: [{ scheme: "bearer", type: "http" }],
1140
- url: "/identities/{id}/access",
1141
- ...options,
1142
- headers: {
1143
- "Content-Type": "application/json",
1144
- ...options.headers
1145
- }
1146
- });
1147
- var identitiesSendRulesDelete = (options) => (options.client ?? client).delete({
1148
- security: [{ scheme: "bearer", type: "http" }],
1149
- url: "/identities/{id}/send-rules",
1150
- ...options
1151
- });
1152
- var identitiesSendRulesGet = (options) => (options.client ?? client).get({
1153
- security: [{ scheme: "bearer", type: "http" }],
1154
- url: "/identities/{id}/send-rules",
1155
- ...options
1156
- });
1157
- var identitiesSendRulesCreate = (options) => (options.client ?? client).post({
1158
- security: [{ scheme: "bearer", type: "http" }],
1159
- url: "/identities/{id}/send-rules",
1160
- ...options,
1161
- headers: {
1162
- "Content-Type": "application/json",
1163
- ...options.headers
1164
- }
1165
- });
1166
- var identitiesReceiveRulesDelete = (options) => (options.client ?? client).delete({
1167
- security: [{ scheme: "bearer", type: "http" }],
1168
- url: "/identities/{id}/receive-rules",
1169
- ...options
1170
- });
1171
- var identitiesReceiveRulesGet = (options) => (options.client ?? client).get({
1172
- security: [{ scheme: "bearer", type: "http" }],
1173
- url: "/identities/{id}/receive-rules",
1174
- ...options
1175
- });
1176
- var identitiesReceiveRulesCreate = (options) => (options.client ?? client).post({
1177
- security: [{ scheme: "bearer", type: "http" }],
1178
- url: "/identities/{id}/receive-rules",
1179
- ...options,
1180
- headers: {
1181
- "Content-Type": "application/json",
1182
- ...options.headers
1183
- }
1184
- });
1185
- var identitiesSuspendTenant = (options) => (options.client ?? client).post({
1186
- security: [{ scheme: "bearer", type: "http" }],
1187
- url: "/tenants/{id}/suspend",
1188
- ...options
1189
- });
1190
- var podsList = (options) => (options?.client ?? client).get({
1191
- security: [{ scheme: "bearer", type: "http" }],
1192
- url: "/pods",
1193
- ...options
1194
- });
1195
- var podsCreate = (options) => (options.client ?? client).post({
1196
- security: [{ scheme: "bearer", type: "http" }],
1197
- url: "/pods",
1198
- ...options,
1199
- headers: {
1200
- "Content-Type": "application/json",
1201
- ...options.headers
1202
- }
1203
- });
1204
- var podsDelete = (options) => (options.client ?? client).delete({
1205
- security: [{ scheme: "bearer", type: "http" }],
1206
- url: "/pods/{id}",
1207
- ...options
1208
- });
1209
- var podsGet = (options) => (options.client ?? client).get({
1210
- security: [{ scheme: "bearer", type: "http" }],
1211
- url: "/pods/{id}",
1212
- ...options
1213
- });
1214
- var podsUpdate = (options) => (options.client ?? client).patch({
1215
- security: [{ scheme: "bearer", type: "http" }],
1216
- url: "/pods/{id}",
1217
- ...options,
1218
- headers: {
1219
- "Content-Type": "application/json",
1220
- ...options.headers
1221
- }
1222
- });
1223
- var labelsList = (options) => (options.client ?? client).get({
1224
- security: [{ scheme: "bearer", type: "http" }],
1225
- url: "/labels",
1226
- ...options
1227
- });
1228
- var labelsCreate = (options) => (options.client ?? client).post({
1229
- security: [{ scheme: "bearer", type: "http" }],
1230
- url: "/labels",
1231
- ...options,
1232
- headers: {
1233
- "Content-Type": "application/json",
1234
- ...options.headers
1235
- }
1236
- });
1237
- var labelsDelete = (options) => (options.client ?? client).delete({
1238
- security: [{ scheme: "bearer", type: "http" }],
1239
- url: "/labels/{id}",
1240
- ...options
1241
- });
1242
- var labelsUpdate = (options) => (options.client ?? client).patch({
1243
- security: [{ scheme: "bearer", type: "http" }],
1244
- url: "/labels/{id}",
1245
- ...options,
1246
- headers: {
1247
- "Content-Type": "application/json",
1248
- ...options.headers
1249
- }
1250
- });
1251
- var grantsTemplatesList = (options) => (options?.client ?? client).get({
1252
- security: [{ scheme: "bearer", type: "http" }],
1253
- url: "/grant-templates",
1254
- ...options
1255
- });
1256
- var grantsTemplatesCreate = (options) => (options.client ?? client).post({
1257
- security: [{ scheme: "bearer", type: "http" }],
1258
- url: "/grant-templates",
1259
- ...options,
1260
- headers: {
1261
- "Content-Type": "application/json",
1262
- ...options.headers
1263
- }
1264
- });
1265
- var grantsTemplatesDelete = (options) => (options.client ?? client).delete({
1266
- security: [{ scheme: "bearer", type: "http" }],
1267
- url: "/grant-templates/{id}",
1268
- ...options
1269
- });
1270
- var grantsList = (options) => (options.client ?? client).get({
1271
- security: [{ scheme: "bearer", type: "http" }],
1272
- url: "/grants",
1273
- ...options
1274
- });
1275
- var grantsCreate = (options) => (options.client ?? client).post({
1276
- security: [{ scheme: "bearer", type: "http" }],
1277
- url: "/grants",
1278
- ...options,
1279
- headers: {
1280
- "Content-Type": "application/json",
1281
- ...options.headers
1282
- }
1283
- });
1284
- var grantsRevoke = (options) => (options.client ?? client).delete({
1285
- security: [{ scheme: "bearer", type: "http" }],
1286
- url: "/grants/{id}",
1287
- ...options
1288
- });
1289
- var grantsGet = (options) => (options.client ?? client).get({
1290
- security: [{ scheme: "bearer", type: "http" }],
1291
- url: "/grants/{id}",
1292
- ...options
1293
- });
1294
- var contactsList = (options) => (options?.client ?? client).get({
1295
- security: [{ scheme: "bearer", type: "http" }],
1296
- url: "/contacts",
1297
- ...options
1298
- });
1299
- var contactsCreate = (options) => (options.client ?? client).post({
1300
- security: [{ scheme: "bearer", type: "http" }],
1301
- url: "/contacts",
1302
- ...options,
1303
- headers: {
1304
- "Content-Type": "application/json",
1305
- ...options.headers
1306
- }
1307
- });
1308
- var contactsDelete = (options) => (options.client ?? client).delete({
1309
- security: [{ scheme: "bearer", type: "http" }],
1310
- url: "/contacts/{id}",
1311
- ...options
1312
- });
1313
- var contactsGet = (options) => (options.client ?? client).get({
1314
- security: [{ scheme: "bearer", type: "http" }],
1315
- url: "/contacts/{id}",
1316
- ...options
1317
- });
1318
- var contactsUpdate = (options) => (options.client ?? client).patch({
1319
- security: [{ scheme: "bearer", type: "http" }],
1320
- url: "/contacts/{id}",
1321
- ...options,
1322
- headers: {
1323
- "Content-Type": "application/json",
1324
- ...options.headers
1325
- }
1326
- });
1327
- var contactsUnblock = (options) => (options.client ?? client).delete({
1328
- security: [{ scheme: "bearer", type: "http" }],
1329
- url: "/contacts/{id}/block",
1330
- ...options
1331
- });
1332
- var contactsBlock = (options) => (options.client ?? client).post({
1333
- security: [{ scheme: "bearer", type: "http" }],
1334
- url: "/contacts/{id}/block",
1335
- ...options
1336
- });
1337
- var threadsLabelsDelete = (options) => (options.client ?? client).delete({
1338
- security: [{ scheme: "bearer", type: "http" }],
1339
- url: "/threads/{id}/labels",
1340
- ...options
1341
- });
1342
- var threadsLabelsGet = (options) => (options.client ?? client).get({
1343
- security: [{ scheme: "bearer", type: "http" }],
1344
- url: "/threads/{id}/labels",
1345
- ...options
1346
- });
1347
- var threadsLabelsCreate = (options) => (options.client ?? client).post({
1348
- security: [{ scheme: "bearer", type: "http" }],
1349
- url: "/threads/{id}/labels",
1350
- ...options,
1351
- headers: {
1352
- "Content-Type": "application/json",
1353
- ...options.headers
1354
- }
1355
- });
1356
- var messagesListInThread = (options) => (options.client ?? client).get({
1357
- security: [{ scheme: "bearer", type: "http" }],
1358
- url: "/messages",
1359
- ...options
1360
- });
1361
- var messagesSend = (options) => (options.client ?? client).post({
1362
- security: [{ scheme: "bearer", type: "http" }],
1363
- url: "/messages",
1364
- ...options,
1365
- headers: {
1366
- "Content-Type": "application/json",
1367
- ...options.headers
1368
- }
1369
- });
1370
- var messagesCheck = (options) => (options.client ?? client).post({
1371
- security: [{ scheme: "bearer", type: "http" }],
1372
- url: "/messages/check",
1373
- ...options,
1374
- headers: {
1375
- "Content-Type": "application/json",
1376
- ...options.headers
1377
- }
1378
- });
1379
- var signInsApprove = (options) => (options.client ?? client).post({
1380
- security: [{ scheme: "bearer", type: "http" }],
1381
- url: "/sign-ins",
1382
- ...options,
1383
- headers: {
1384
- "Content-Type": "application/json",
1385
- ...options.headers
1386
- }
1387
- });
1388
- var messagesSearch = (options) => (options?.client ?? client).get({
1389
- security: [{ scheme: "bearer", type: "http" }],
1390
- url: "/messages/search",
1391
- ...options
1392
- });
1393
- var messagesAct = (options) => (options.client ?? client).post({
1394
- security: [{ scheme: "bearer", type: "http" }],
1395
- url: "/messages/actions",
1396
- ...options,
1397
- headers: {
1398
- "Content-Type": "application/json",
1399
- ...options.headers
1400
- }
1401
- });
1402
- var messagesUndo = (options) => (options.client ?? client).post({
1403
- security: [{ scheme: "bearer", type: "http" }],
1404
- url: "/messages/undo",
1405
- ...options,
1406
- headers: {
1407
- "Content-Type": "application/json",
1408
- ...options.headers
1409
- }
1410
- });
1411
- var messagesAwait = (options) => (options.client ?? client).get({
1412
- security: [{ scheme: "bearer", type: "http" }],
1413
- url: "/messages/await",
1414
- ...options
1415
- });
1416
- var messagesGet = (options) => (options.client ?? client).get({
1417
- security: [{ scheme: "bearer", type: "http" }],
1418
- url: "/messages/{id}",
1419
- ...options
1420
- });
1421
- var messagesUpdate = (options) => (options.client ?? client).patch({
1422
- security: [{ scheme: "bearer", type: "http" }],
1423
- url: "/messages/{id}",
1424
- ...options,
1425
- headers: {
1426
- "Content-Type": "application/json",
1427
- ...options.headers
1428
- }
1429
- });
1430
- var messagesReply = (options) => (options.client ?? client).post({
1431
- security: [{ scheme: "bearer", type: "http" }],
1432
- url: "/messages/{id}/reply",
1433
- ...options,
1434
- headers: {
1435
- "Content-Type": "application/json",
1436
- ...options.headers
1437
- }
1438
- });
1439
- var messagesReplyAll = (options) => (options.client ?? client).post({
1440
- security: [{ scheme: "bearer", type: "http" }],
1441
- url: "/messages/{id}/reply-all",
1442
- ...options,
1443
- headers: {
1444
- "Content-Type": "application/json",
1445
- ...options.headers
1446
- }
1447
- });
1448
- var messagesForward = (options) => (options.client ?? client).post({
1449
- security: [{ scheme: "bearer", type: "http" }],
1450
- url: "/messages/{id}/forward",
1451
- ...options,
1452
- headers: {
1453
- "Content-Type": "application/json",
1454
- ...options.headers
1455
- }
1456
- });
1457
- var messagesRaw = (options) => (options.client ?? client).get({
1458
- security: [{ scheme: "bearer", type: "http" }],
1459
- url: "/messages/{id}/raw",
1460
- ...options
1461
- });
1462
- var exportMail = (options) => (options?.client ?? client).get({
1463
- security: [{ scheme: "bearer", type: "http" }],
1464
- url: "/export",
1465
- ...options
1466
- });
1467
- var threadsList = (options) => (options?.client ?? client).get({
1468
- security: [{ scheme: "bearer", type: "http" }],
1469
- url: "/threads",
1470
- ...options
1471
- });
1472
- var threadsGet = (options) => (options.client ?? client).get({
1473
- security: [{ scheme: "bearer", type: "http" }],
1474
- url: "/threads/{id}",
1475
- ...options
1476
- });
1477
- var threadsUpdate = (options) => (options.client ?? client).patch({
1478
- security: [{ scheme: "bearer", type: "http" }],
1479
- url: "/threads/{id}",
1480
- ...options,
1481
- headers: {
1482
- "Content-Type": "application/json",
1483
- ...options.headers
1484
- }
1485
- });
1486
- var domainsList = (options) => (options?.client ?? client).get({
1487
- security: [{ scheme: "bearer", type: "http" }],
1488
- url: "/domains",
1489
- ...options
1490
- });
1491
- var domainsCreate = (options) => (options.client ?? client).post({
1492
- security: [{ scheme: "bearer", type: "http" }],
1493
- url: "/domains",
1494
- ...options,
1495
- headers: {
1496
- "Content-Type": "application/json",
1497
- ...options.headers
1498
- }
1499
- });
1500
- var domainsZoneFile = (options) => (options.client ?? client).get({
1501
- security: [{ scheme: "bearer", type: "http" }],
1502
- url: "/domains/{id}/zone-file",
1503
- ...options
1504
- });
1505
- var domainsGetSetupLink = (options) => (options.client ?? client).get({
1506
- security: [{ scheme: "bearer", type: "http" }],
1507
- url: "/domains/{id}/setup-link",
1508
- ...options
1509
- });
1510
- var domainsVerify = (options) => (options.client ?? client).post({
1511
- security: [{ scheme: "bearer", type: "http" }],
1512
- url: "/domains/{id}/verify",
1513
- ...options
1514
- });
1515
- var domainsDelete = (options) => (options.client ?? client).delete({
1516
- security: [{ scheme: "bearer", type: "http" }],
1517
- url: "/domains/{id}",
1518
- ...options
1519
- });
1520
- var domainsGet = (options) => (options.client ?? client).get({
1521
- security: [{ scheme: "bearer", type: "http" }],
1522
- url: "/domains/{id}",
1523
- ...options
1524
- });
1525
- var domainsUpdate = (options) => (options.client ?? client).patch({
1526
- security: [{ scheme: "bearer", type: "http" }],
1527
- url: "/domains/{id}",
1528
- ...options,
1529
- headers: {
1530
- "Content-Type": "application/json",
1531
- ...options.headers
1532
- }
1533
- });
1534
- var routingList = (options) => (options?.client ?? client).get({
1535
- security: [{ scheme: "bearer", type: "http" }],
1536
- url: "/routing-rules",
1537
- ...options
1538
- });
1539
- var routingCreate = (options) => (options.client ?? client).post({
1540
- security: [{ scheme: "bearer", type: "http" }],
1541
- url: "/routing-rules",
1542
- ...options,
1543
- headers: {
1544
- "Content-Type": "application/json",
1545
- ...options.headers
1546
- }
1547
- });
1548
- var routingDelete = (options) => (options.client ?? client).delete({
1549
- security: [{ scheme: "bearer", type: "http" }],
1550
- url: "/routing-rules/{id}",
1551
- ...options
1552
- });
1553
- var routingUpdate = (options) => (options.client ?? client).patch({
1554
- security: [{ scheme: "bearer", type: "http" }],
1555
- url: "/routing-rules/{id}",
1556
- ...options,
1557
- headers: {
1558
- "Content-Type": "application/json",
1559
- ...options.headers
1560
- }
1561
- });
1562
- var mailboxesList = (options) => (options.client ?? client).get({
1563
- security: [{ scheme: "bearer", type: "http" }],
1564
- url: "/mailboxes",
1565
- ...options
1566
- });
1567
- var mailboxesChanges = (options) => (options.client ?? client).get({
1568
- security: [{ scheme: "bearer", type: "http" }],
1569
- url: "/mailboxes/changes",
1570
- ...options
1571
- });
1572
- var mailboxesEmptyTrash = (options) => (options.client ?? client).delete({
1573
- security: [{ scheme: "bearer", type: "http" }],
1574
- url: "/mailboxes/{folder}",
1575
- ...options
1576
- });
1577
- var mailboxesListFolder = (options) => (options.client ?? client).get({
1578
- security: [{ scheme: "bearer", type: "http" }],
1579
- url: "/mailboxes/{folder}",
1580
- ...options
1581
- });
1582
- var keysList = (options) => (options?.client ?? client).get({
1583
- security: [{ scheme: "bearer", type: "http" }],
1584
- url: "/api-keys",
1585
- ...options
1586
- });
1587
- var keysCreate = (options) => (options.client ?? client).post({
1588
- security: [{ scheme: "bearer", type: "http" }],
1589
- url: "/api-keys",
1590
- ...options,
1591
- headers: {
1592
- "Content-Type": "application/json",
1593
- ...options.headers
1594
- }
1595
- });
1596
- var keysRevoke = (options) => (options.client ?? client).delete({
1597
- security: [{ scheme: "bearer", type: "http" }],
1598
- url: "/api-keys/{id}",
1599
- ...options
1600
- });
1601
- var keysGet = (options) => (options.client ?? client).get({
1602
- security: [{ scheme: "bearer", type: "http" }],
1603
- url: "/api-keys/{id}",
1604
- ...options
1605
- });
1606
- var keysUpdate = (options) => (options.client ?? client).patch({
1607
- security: [{ scheme: "bearer", type: "http" }],
1608
- url: "/api-keys/{id}",
1609
- ...options,
1610
- headers: {
1611
- "Content-Type": "application/json",
1612
- ...options.headers
1613
- }
1614
- });
1615
- var keysRotate = (options) => (options.client ?? client).post({
1616
- security: [{ scheme: "bearer", type: "http" }],
1617
- url: "/api-keys/{id}/rotate",
1618
- ...options,
1619
- headers: {
1620
- "Content-Type": "application/json",
1621
- ...options.headers
1622
- }
1623
- });
1624
- var testInbound = (options) => (options.client ?? client).post({
1625
- security: [{ scheme: "bearer", type: "http" }],
1626
- url: "/test/inbound",
1627
- ...options,
1628
- headers: {
1629
- "Content-Type": "application/json",
1630
- ...options.headers
1631
- }
1632
- });
1633
- var appPasswordsList = (options) => (options.client ?? client).get({
1634
- security: [{ scheme: "bearer", type: "http" }],
1635
- url: "/app-passwords",
1636
- ...options
1637
- });
1638
- var appPasswordsCreate = (options) => (options.client ?? client).post({
1639
- security: [{ scheme: "bearer", type: "http" }],
1640
- url: "/app-passwords",
1641
- ...options,
1642
- headers: {
1643
- "Content-Type": "application/json",
1644
- ...options.headers
1645
- }
1646
- });
1647
- var appPasswordsRevoke = (options) => (options.client ?? client).delete({
1648
- security: [{ scheme: "bearer", type: "http" }],
1649
- url: "/app-passwords/{id}",
1650
- ...options
1651
- });
1652
- var meGet = (options) => (options?.client ?? client).get({
1653
- security: [{ scheme: "bearer", type: "http" }],
1654
- url: "/me",
1655
- ...options
1656
- });
1657
- var workspaceGet = (options) => (options?.client ?? client).get({
1658
- security: [{ scheme: "bearer", type: "http" }],
1659
- url: "/workspace",
1660
- ...options
1661
- });
1662
- var workspaceMembers = (options) => (options?.client ?? client).get({
1663
- security: [{ scheme: "bearer", type: "http" }],
1664
- url: "/workspace/members",
1665
- ...options
1666
- });
1667
- var eventsList = (options) => (options?.client ?? client).get({
1668
- security: [{ scheme: "bearer", type: "http" }],
1669
- url: "/events",
1670
- ...options
1671
- });
1672
- var eventsSocket = (options) => (options?.client ?? client).get({
1673
- security: [{ scheme: "bearer", type: "http" }],
1674
- url: "/events/socket",
1675
- ...options
1676
- });
1677
- var eventsStream = (options) => (options?.client ?? client).sse.get({
1678
- security: [{ scheme: "bearer", type: "http" }],
1679
- url: "/events/stream",
1680
- ...options
1681
- });
1682
- var eventsGet = (options) => (options.client ?? client).get({
1683
- security: [{ scheme: "bearer", type: "http" }],
1684
- url: "/events/{id}",
1685
- ...options
1686
- });
1687
- var webhooksList = (options) => (options?.client ?? client).get({
1688
- security: [{ scheme: "bearer", type: "http" }],
1689
- url: "/webhooks",
1690
- ...options
1691
- });
1692
- var webhooksCreate = (options) => (options.client ?? client).post({
1693
- security: [{ scheme: "bearer", type: "http" }],
1694
- url: "/webhooks",
1695
- ...options,
1696
- headers: {
1697
- "Content-Type": "application/json",
1698
- ...options.headers
1699
- }
1700
- });
1701
- var webhooksDelete = (options) => (options.client ?? client).delete({
1702
- security: [{ scheme: "bearer", type: "http" }],
1703
- url: "/webhooks/{id}",
1704
- ...options
1705
- });
1706
- var webhooksGet = (options) => (options.client ?? client).get({
1707
- security: [{ scheme: "bearer", type: "http" }],
1708
- url: "/webhooks/{id}",
1709
- ...options
1710
- });
1711
- var webhooksUpdate = (options) => (options.client ?? client).patch({
1712
- security: [{ scheme: "bearer", type: "http" }],
1713
- url: "/webhooks/{id}",
1714
- ...options,
1715
- headers: {
1716
- "Content-Type": "application/json",
1717
- ...options.headers
1718
- }
1719
- });
1720
- var webhooksGetHeaders = (options) => (options.client ?? client).get({
1721
- security: [{ scheme: "bearer", type: "http" }],
1722
- url: "/webhooks/{id}/headers",
1723
- ...options
1724
- });
1725
- var webhooksUpdateHeaders = (options) => (options.client ?? client).put({
1726
- security: [{ scheme: "bearer", type: "http" }],
1727
- url: "/webhooks/{id}/headers",
1728
- ...options,
1729
- headers: {
1730
- "Content-Type": "application/json",
1731
- ...options.headers
1732
- }
1733
- });
1734
- var webhooksDeliveries = (options) => (options.client ?? client).get({
1735
- security: [{ scheme: "bearer", type: "http" }],
1736
- url: "/deliveries",
1737
- ...options
1738
- });
1739
- var webhooksReplay = (options) => (options.client ?? client).post({
1740
- security: [{ scheme: "bearer", type: "http" }],
1741
- url: "/deliveries/{id}/replay",
1742
- ...options
1743
- });
1744
- var messagesRespondToInvitation = (options) => (options.client ?? client).post({
1745
- security: [{ scheme: "bearer", type: "http" }],
1746
- url: "/messages/{id}/invitation/respond",
1747
- ...options,
1748
- headers: {
1749
- "Content-Type": "application/json",
1750
- ...options.headers
1751
- }
1752
- });
1753
- var calendarGet = (options) => (options.client ?? client).get({
1754
- security: [{ scheme: "bearer", type: "http" }],
1755
- url: "/identities/{id}/calendar",
1756
- ...options
1757
- });
1758
- var calendarUpdate = (options) => (options.client ?? client).patch({
1759
- security: [{ scheme: "bearer", type: "http" }],
1760
- url: "/identities/{id}/calendar",
1761
- ...options,
1762
- headers: {
1763
- "Content-Type": "application/json",
1764
- ...options.headers
1765
- }
1766
- });
1767
- var calendarListEvents = (options) => (options.client ?? client).get({
1768
- security: [{ scheme: "bearer", type: "http" }],
1769
- url: "/identities/{id}/calendar/events",
1770
- ...options
1771
- });
1772
- var calendarCreateEvent = (options) => (options.client ?? client).post({
1773
- security: [{ scheme: "bearer", type: "http" }],
1774
- url: "/identities/{id}/calendar/events",
1775
- ...options,
1776
- headers: {
1777
- "Content-Type": "application/json",
1778
- ...options.headers
1779
- }
1780
- });
1781
- var calendarRespondToEvent = (options) => (options.client ?? client).post({
1782
- security: [{ scheme: "bearer", type: "http" }],
1783
- url: "/identities/{id}/calendar/events/{eventId}/respond",
1784
- ...options,
1785
- headers: {
1786
- "Content-Type": "application/json",
1787
- ...options.headers
1788
- }
1789
- });
1790
- var calendarListEventInstances = (options) => (options.client ?? client).get({
1791
- security: [{ scheme: "bearer", type: "http" }],
1792
- url: "/identities/{id}/calendar/events/{eventId}/instances",
1793
- ...options
1794
- });
1795
- var calendarGetAgenda = (options) => (options.client ?? client).get(
1796
- {
1797
- security: [{ scheme: "bearer", type: "http" }],
1798
- url: "/identities/{id}/calendar/agenda",
1799
- ...options
1800
- }
1801
- );
1802
- var calendarFreeTime = (options) => (options.client ?? client).get({
1803
- security: [{ scheme: "bearer", type: "http" }],
1804
- url: "/calendar/free-time",
1805
- ...options
1806
- });
1807
- var calendarDeleteEvent = (options) => (options.client ?? client).delete({
1808
- security: [{ scheme: "bearer", type: "http" }],
1809
- url: "/identities/{id}/calendar/events/{eventId}",
1810
- ...options
1811
- });
1812
- var calendarGetEvent = (options) => (options.client ?? client).get({
1813
- security: [{ scheme: "bearer", type: "http" }],
1814
- url: "/identities/{id}/calendar/events/{eventId}",
1815
- ...options
1816
- });
1817
- var calendarUpdateEvent = (options) => (options.client ?? client).patch({
1818
- security: [{ scheme: "bearer", type: "http" }],
1819
- url: "/identities/{id}/calendar/events/{eventId}",
1820
- ...options,
1821
- headers: {
1822
- "Content-Type": "application/json",
1823
- ...options.headers
1824
- }
1825
- });
1826
- var draftsList = (options) => (options.client ?? client).get({
1827
- security: [{ scheme: "bearer", type: "http" }],
1828
- url: "/drafts",
1829
- ...options
1830
- });
1831
- var draftsCreate = (options) => (options.client ?? client).post({
1832
- security: [{ scheme: "bearer", type: "http" }],
1833
- url: "/drafts",
1834
- ...options,
1835
- headers: {
1836
- "Content-Type": "application/json",
1837
- ...options.headers
1838
- }
1839
- });
1840
- var draftsDelete = (options) => (options.client ?? client).delete({
1841
- security: [{ scheme: "bearer", type: "http" }],
1842
- url: "/drafts/{id}",
1843
- ...options
1844
- });
1845
- var draftsGet = (options) => (options.client ?? client).get({
1846
- security: [{ scheme: "bearer", type: "http" }],
1847
- url: "/drafts/{id}",
1848
- ...options
1849
- });
1850
- var draftsUpdate = (options) => (options.client ?? client).patch({
1851
- security: [{ scheme: "bearer", type: "http" }],
1852
- url: "/drafts/{id}",
1853
- ...options,
1854
- headers: {
1855
- "Content-Type": "application/json",
1856
- ...options.headers
1857
- }
1858
- });
1859
- var draftsSend = (options) => (options.client ?? client).post({
1860
- security: [{ scheme: "bearer", type: "http" }],
1861
- url: "/drafts/{id}/send",
1862
- ...options
1863
- });
1864
- var draftsApproval = (options) => (options.client ?? client).get({
1865
- security: [{ scheme: "bearer", type: "http" }],
1866
- url: "/drafts/{id}/approval",
1867
- ...options
1868
- });
1869
- var draftsCancelSchedule = (options) => (options.client ?? client).delete({
1870
- security: [{ scheme: "bearer", type: "http" }],
1871
- url: "/drafts/{id}/schedule",
1872
- ...options
1873
- });
1874
- var draftsSchedule = (options) => (options.client ?? client).post({
1875
- security: [{ scheme: "bearer", type: "http" }],
1876
- url: "/drafts/{id}/schedule",
1877
- ...options,
1878
- headers: {
1879
- "Content-Type": "application/json",
1880
- ...options.headers
1881
- }
1882
- });
1883
- var draftsRemoveAttachment = (options) => (options.client ?? client).delete({
1884
- security: [{ scheme: "bearer", type: "http" }],
1885
- url: "/drafts/{id}/attachments/{attachmentId}",
1886
- ...options
1887
- });
1888
- var metricsQuery = (options) => (options?.client ?? client).get({
1889
- security: [{ scheme: "bearer", type: "http" }],
1890
- url: "/metrics",
1891
- ...options
1892
- });
1893
- var attachmentsUpload = (options) => (options.client ?? client).post({
1894
- ...formDataBodySerializer,
1895
- security: [{ scheme: "bearer", type: "http" }],
1896
- url: "/attachments",
1897
- ...options,
1898
- headers: {
1899
- "Content-Type": null,
1900
- ...options.headers
1901
- }
1902
- });
1903
- var attachmentsCreateUpload = (options) => (options.client ?? client).post({
1904
- security: [{ scheme: "bearer", type: "http" }],
1905
- url: "/attachments/uploads",
1906
- ...options,
1907
- headers: {
1908
- "Content-Type": "application/json",
1909
- ...options.headers
1910
- }
1911
- });
1912
- var attachmentsCompleteUpload = (options) => (options.client ?? client).post({
1913
- security: [{ scheme: "bearer", type: "http" }],
1914
- url: "/attachments/{id}/complete",
1915
- ...options
1916
- });
1917
- var attachmentsDownloadUrl = (options) => (options.client ?? client).get({
1918
- security: [{ scheme: "bearer", type: "http" }],
1919
- url: "/attachments/{id}",
1920
- ...options
1921
- });
1922
- var attachmentsText = (options) => (options.client ?? client).get({
1923
- security: [{ scheme: "bearer", type: "http" }],
1924
- url: "/attachments/{id}/text",
1925
- ...options
1926
- });
1927
-
1928
- // src/webhooks.ts
1929
- var SIGNATURE_HEADER = "x-pidgeon-signature";
1930
- var TIMESTAMP_HEADER = "x-pidgeon-timestamp";
1931
- async function verifyWebhook(input) {
1932
- const get = (name) => {
1933
- if (input.headers instanceof Headers) return input.headers.get(name) ?? void 0;
1934
- const direct = input.headers[name];
1935
- if (direct !== void 0) return direct;
1936
- const wanted = name.toLowerCase();
1937
- for (const [key2, value] of Object.entries(input.headers)) {
1938
- if (key2.toLowerCase() === wanted) return value;
1939
- }
1940
- return void 0;
1941
- };
1942
- const timestamp = get(TIMESTAMP_HEADER);
1943
- const signature = get(SIGNATURE_HEADER);
1944
- if (!timestamp || !signature) throw new Error("This request is not signed.");
1945
- const seconds = Number(timestamp);
1946
- if (!Number.isFinite(seconds)) throw new Error("The signature timestamp is not a number.");
1947
- const now = Math.floor((input.now ?? /* @__PURE__ */ new Date()).getTime() / 1e3);
1948
- const tolerance = input.toleranceSeconds ?? 300;
1949
- if (Math.abs(now - seconds) > tolerance) {
1950
- throw new Error("This request is too old to trust. It may be a replay.");
1951
- }
1952
- const key = await crypto.subtle.importKey(
1953
- "raw",
1954
- new TextEncoder().encode(input.secret),
1955
- { name: "HMAC", hash: "SHA-256" },
1956
- false,
1957
- ["sign"]
1958
- );
1959
- const mac = await crypto.subtle.sign(
1960
- "HMAC",
1961
- key,
1962
- new TextEncoder().encode(`${seconds}.${input.rawBody}`)
1963
- );
1964
- const expected = `v1=${[...new Uint8Array(mac)].map((byte) => byte.toString(16).padStart(2, "0")).join("")}`;
1965
- if (!constantTimeEqual(expected, signature)) {
1966
- throw new Error("The signature does not match.");
1967
- }
1968
- return JSON.parse(input.rawBody);
1969
- }
1970
- function constantTimeEqual(a, b) {
1971
- if (a.length !== b.length) return false;
1972
- let difference = 0;
1973
- for (let index = 0; index < a.length; index += 1) {
1974
- difference |= a.charCodeAt(index) ^ b.charCodeAt(index);
1975
- }
1976
- return difference === 0;
1977
- }
1978
-
1979
- // src/stream.ts
1980
- async function* streamEvents(options) {
1981
- const base = (options.baseUrl ?? "https://pidgeon.ai/api/v1").replace(/\/$/, "");
1982
- let lastEventId;
1983
- let backoffMs = 1e3;
1984
- while (!options.signal?.aborted) {
1985
- const url = new URL(`${base}/events/stream`);
1986
- if (options.identityId) url.searchParams.set("identity_id", options.identityId);
1987
- if (options.type) url.searchParams.set("type", options.type);
1988
- if (options.after && !lastEventId) url.searchParams.set("after", options.after);
1989
- let response;
1990
- try {
1991
- response = await fetch(url, {
1992
- headers: {
1993
- authorization: `Bearer ${options.apiKey}`,
1994
- accept: "text/event-stream",
1995
- ...lastEventId ? { "last-event-id": lastEventId } : {}
1996
- },
1997
- signal: options.signal
1998
- });
1999
- } catch {
2000
- if (options.signal?.aborted) return;
2001
- await sleep(backoffMs, options.signal);
2002
- backoffMs = Math.min(backoffMs * 2, 3e4);
2003
- continue;
2004
- }
2005
- if (response.status === 401 || response.status === 403 || response.status === 404) {
2006
- throw new Error(
2007
- `Pidgeon refused the stream: ${response.status} ${await response.text().catch(() => "")}`.trim()
2008
- );
2009
- }
2010
- if (!response.ok || !response.body) {
2011
- await sleep(backoffMs, options.signal);
2012
- backoffMs = Math.min(backoffMs * 2, 3e4);
2013
- continue;
2014
- }
2015
- backoffMs = 1e3;
2016
- try {
2017
- for await (const frame of frames(response.body, options.signal)) {
2018
- if (frame.id) lastEventId = frame.id;
2019
- if (!frame.data) continue;
2020
- if (frame.event === "error") continue;
2021
- let parsed;
2022
- try {
2023
- parsed = JSON.parse(frame.data);
2024
- } catch {
2025
- continue;
2026
- }
2027
- yield parsed;
2028
- }
2029
- } catch {
2030
- if (options.signal?.aborted) return;
2031
- await sleep(backoffMs, options.signal);
2032
- backoffMs = Math.min(backoffMs * 2, 3e4);
2033
- }
2034
- }
2035
- }
2036
- async function* frames(body, signal) {
2037
- const reader = body.getReader();
2038
- const decoder = new TextDecoder();
2039
- let buffer = "";
2040
- try {
2041
- while (!signal?.aborted) {
2042
- const { done, value } = await reader.read();
2043
- if (done) return;
2044
- buffer += decoder.decode(value, { stream: true });
2045
- let boundary = buffer.indexOf("\n\n");
2046
- while (boundary !== -1) {
2047
- const block = buffer.slice(0, boundary);
2048
- buffer = buffer.slice(boundary + 2);
2049
- boundary = buffer.indexOf("\n\n");
2050
- const frame = {};
2051
- const data = [];
2052
- for (const line of block.split("\n")) {
2053
- if (line.startsWith(":")) continue;
2054
- const colon = line.indexOf(":");
2055
- if (colon === -1) continue;
2056
- const field = line.slice(0, colon);
2057
- const value2 = line.slice(colon + 1).replace(/^ /, "");
2058
- if (field === "id") frame.id = value2;
2059
- else if (field === "event") frame.event = value2;
2060
- else if (field === "data") data.push(value2);
2061
- }
2062
- if (data.length > 0) frame.data = data.join("\n");
2063
- if (frame.id || frame.data) yield frame;
2064
- }
2065
- }
2066
- } finally {
2067
- await reader.cancel().catch(() => void 0);
2068
- }
2069
- }
2070
- function sleep(ms, signal) {
2071
- return new Promise((resolve) => {
2072
- const timer = setTimeout(resolve, ms);
2073
- signal?.addEventListener(
2074
- "abort",
2075
- () => {
2076
- clearTimeout(timer);
2077
- resolve();
2078
- },
2079
- { once: true }
2080
- );
2081
- });
2082
- }
2083
- // Annotate the CommonJS export names for ESM import in node:
2084
- 0 && (module.exports = {
2085
- SIGNATURE_HEADER,
2086
- TIMESTAMP_HEADER,
2087
- agentAttachHuman,
2088
- agentConnect,
2089
- agentSetup,
2090
- agentSignUp,
2091
- agentVerify,
2092
- appPasswordsCreate,
2093
- appPasswordsList,
2094
- appPasswordsRevoke,
2095
- attachmentsCompleteUpload,
2096
- attachmentsCreateUpload,
2097
- attachmentsDownloadUrl,
2098
- attachmentsText,
2099
- attachmentsUpload,
2100
- calendarCreateEvent,
2101
- calendarDeleteEvent,
2102
- calendarFreeTime,
2103
- calendarGet,
2104
- calendarGetAgenda,
2105
- calendarGetEvent,
2106
- calendarListEventInstances,
2107
- calendarListEvents,
2108
- calendarRespondToEvent,
2109
- calendarUpdate,
2110
- calendarUpdateEvent,
2111
- cardsGet,
2112
- client,
2113
- contactsBlock,
2114
- contactsCreate,
2115
- contactsDelete,
2116
- contactsGet,
2117
- contactsList,
2118
- contactsUnblock,
2119
- contactsUpdate,
2120
- createClient,
2121
- createConfig,
2122
- domainsCreate,
2123
- domainsDelete,
2124
- domainsGet,
2125
- domainsGetSetupLink,
2126
- domainsList,
2127
- domainsUpdate,
2128
- domainsVerify,
2129
- domainsZoneFile,
2130
- draftsApproval,
2131
- draftsCancelSchedule,
2132
- draftsCreate,
2133
- draftsDelete,
2134
- draftsGet,
2135
- draftsList,
2136
- draftsRemoveAttachment,
2137
- draftsSchedule,
2138
- draftsSend,
2139
- draftsUpdate,
2140
- eventsGet,
2141
- eventsList,
2142
- eventsSocket,
2143
- eventsStream,
2144
- exportMail,
2145
- grantsCreate,
2146
- grantsGet,
2147
- grantsList,
2148
- grantsRevoke,
2149
- grantsStatus,
2150
- grantsTemplatesCreate,
2151
- grantsTemplatesDelete,
2152
- grantsTemplatesList,
2153
- identitiesAccessCreate,
2154
- identitiesAccessDelete,
2155
- identitiesAccessGet,
2156
- identitiesCard,
2157
- identitiesCreate,
2158
- identitiesDelete,
2159
- identitiesGet,
2160
- identitiesList,
2161
- identitiesReceiveRulesCreate,
2162
- identitiesReceiveRulesDelete,
2163
- identitiesReceiveRulesGet,
2164
- identitiesSendRulesCreate,
2165
- identitiesSendRulesDelete,
2166
- identitiesSendRulesGet,
2167
- identitiesSuspendTenant,
2168
- identitiesUpdate,
2169
- keysCreate,
2170
- keysGet,
2171
- keysList,
2172
- keysRevoke,
2173
- keysRotate,
2174
- keysUpdate,
2175
- labelsCreate,
2176
- labelsDelete,
2177
- labelsList,
2178
- labelsUpdate,
2179
- logCheckpoint,
2180
- logConsistency,
2181
- logEntries,
2182
- logHead,
2183
- logMonitorsCreate,
2184
- logMonitorsDelete,
2185
- logMonitorsList,
2186
- logProof,
2187
- mailboxesChanges,
2188
- mailboxesEmptyTrash,
2189
- mailboxesList,
2190
- mailboxesListFolder,
2191
- meGet,
2192
- messagesAct,
2193
- messagesAwait,
2194
- messagesCheck,
2195
- messagesForward,
2196
- messagesGet,
2197
- messagesListInThread,
2198
- messagesRaw,
2199
- messagesReply,
2200
- messagesReplyAll,
2201
- messagesRespondToInvitation,
2202
- messagesSearch,
2203
- messagesSend,
2204
- messagesUndo,
2205
- messagesUpdate,
2206
- metricsQuery,
2207
- podsCreate,
2208
- podsDelete,
2209
- podsGet,
2210
- podsList,
2211
- podsUpdate,
2212
- routingCreate,
2213
- routingDelete,
2214
- routingList,
2215
- routingUpdate,
2216
- signInsApprove,
2217
- streamEvents,
2218
- testInbound,
2219
- threadsGet,
2220
- threadsLabelsCreate,
2221
- threadsLabelsDelete,
2222
- threadsLabelsGet,
2223
- threadsList,
2224
- threadsUpdate,
2225
- verifySender,
2226
- verifyWebhook,
2227
- webhooksCreate,
2228
- webhooksDelete,
2229
- webhooksDeliveries,
2230
- webhooksGet,
2231
- webhooksGetHeaders,
2232
- webhooksList,
2233
- webhooksReplay,
2234
- webhooksUpdate,
2235
- webhooksUpdateHeaders,
2236
- workspaceGet,
2237
- workspaceMembers
2238
- });
2239
- //# sourceMappingURL=index.cjs.map