@superdurable/connector-zoom 0.0.0-stage → 0.1.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.js ADDED
@@ -0,0 +1,980 @@
1
+ import {
2
+ ConfigSchema,
3
+ Connection,
4
+ ConnectorID,
5
+ CreateMeetingBranch,
6
+ CreateMeetingBranchCreated,
7
+ CreateMeetingBranchDefect,
8
+ CreateMeetingBranchProviderRejected,
9
+ CreateMeetingBranchUncertain,
10
+ CreateMeetingDefinition,
11
+ CreateMeetingInputSchema,
12
+ CreateMeetingMetadata,
13
+ GetMeetingBranch,
14
+ GetMeetingBranchDefect,
15
+ GetMeetingBranchFound,
16
+ GetMeetingBranchInvalidResponse,
17
+ GetMeetingBranchNotFound,
18
+ GetMeetingBranchProviderRejected,
19
+ GetMeetingDefinition,
20
+ GetMeetingInputSchema,
21
+ GetMeetingMetadata,
22
+ ListMeetingsBranch,
23
+ ListMeetingsBranchDefect,
24
+ ListMeetingsBranchInvalidResponse,
25
+ ListMeetingsBranchListed,
26
+ ListMeetingsBranchProviderRejected,
27
+ ListMeetingsDefinition,
28
+ ListMeetingsInputSchema,
29
+ ListMeetingsMetadata,
30
+ ListPastMeetingParticipantsBranch,
31
+ ListPastMeetingParticipantsBranchDefect,
32
+ ListPastMeetingParticipantsBranchInvalidResponse,
33
+ ListPastMeetingParticipantsBranchListed,
34
+ ListPastMeetingParticipantsBranchNotFound,
35
+ ListPastMeetingParticipantsBranchProviderRejected,
36
+ ListPastMeetingParticipantsDefinition,
37
+ ListPastMeetingParticipantsInputSchema,
38
+ ListPastMeetingParticipantsMetadata,
39
+ MeetingPageSchema,
40
+ MeetingParticipantSchema,
41
+ MeetingSchema,
42
+ MeetingSettingsInputSchema,
43
+ MeetingSettingsSchema,
44
+ MeetingSummarySchema,
45
+ ParticipantPageSchema,
46
+ ProviderID,
47
+ UpdateMeetingBranch,
48
+ UpdateMeetingBranchDefect,
49
+ UpdateMeetingBranchNotFound,
50
+ UpdateMeetingBranchProviderRejected,
51
+ UpdateMeetingBranchUpdated,
52
+ UpdateMeetingDefinition,
53
+ UpdateMeetingInputSchema,
54
+ UpdateMeetingMetadata,
55
+ UpdatedMeetingSchema,
56
+ decodeCredentials,
57
+ decodeSharedCredentials,
58
+ newConnection,
59
+ newConnectionWithOperations,
60
+ newProjectConnection,
61
+ newProjectCredentialProvider
62
+ } from "./chunk-IOSXDBUC.js";
63
+
64
+ // src/generated/steps.ts
65
+ import { goToBranch, newMutationStep, newQueryStep } from "@superdurable/connectors-sdk";
66
+ function newListMeetingsStep(configuration) {
67
+ const { connection, connectionName, listed, providerRejected, invalidResponse, defect: defect2, ...stepConfiguration } = configuration;
68
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
69
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.listMeetings(), connection: connection.reference, branches: [
70
+ goToBranch("listed", listed),
71
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
72
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
73
+ ...defect2 ? [goToBranch("defect", defect2)] : []
74
+ ] });
75
+ }
76
+ function newGetMeetingStep(configuration) {
77
+ const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect: defect2, ...stepConfiguration } = configuration;
78
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
79
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.getMeeting(), connection: connection.reference, branches: [
80
+ goToBranch("found", found),
81
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
82
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
83
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
84
+ ...defect2 ? [goToBranch("defect", defect2)] : []
85
+ ] });
86
+ }
87
+ function newCreateMeetingStep(configuration) {
88
+ const { connection, connectionName, created, providerRejected, uncertain, defect: defect2, ...stepConfiguration } = configuration;
89
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
90
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.createMeeting(), connection: connection.reference, branches: [
91
+ goToBranch("created", created),
92
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
93
+ ...uncertain ? [goToBranch("uncertain", uncertain)] : [],
94
+ ...defect2 ? [goToBranch("defect", defect2)] : []
95
+ ] });
96
+ }
97
+ function newUpdateMeetingStep(configuration) {
98
+ const { connection, connectionName, updated, notFound, providerRejected, defect: defect2, ...stepConfiguration } = configuration;
99
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
100
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.updateMeeting(), connection: connection.reference, branches: [
101
+ goToBranch("updated", updated),
102
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
103
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
104
+ ...defect2 ? [goToBranch("defect", defect2)] : []
105
+ ] });
106
+ }
107
+ function newListPastMeetingParticipantsStep(configuration) {
108
+ const { connection, connectionName, listed, notFound, providerRejected, invalidResponse, defect: defect2, ...stepConfiguration } = configuration;
109
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
110
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.listPastMeetingParticipants(), connection: connection.reference, branches: [
111
+ goToBranch("listed", listed),
112
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
113
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
114
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
115
+ ...defect2 ? [goToBranch("defect", defect2)] : []
116
+ ] });
117
+ }
118
+
119
+ // src/client.ts
120
+ import { ReauthorizationRequiredError, resolveCredential, resolveCredentialAfterRejection } from "@superdurable/connectors-sdk";
121
+ import { AddressRefusal, BodyTooLargeError, MaxErrorBodyBytes, ProviderTransportError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
122
+ import { ManifestCredentialRefreshDriver } from "@superdurable/connectors-sdk/oauthtoken";
123
+
124
+ // src/generated/refresh.ts
125
+ var Authorization = {
126
+ "fields": [
127
+ {
128
+ "name": "oauth_client_id",
129
+ "required": true,
130
+ "type": "string"
131
+ },
132
+ {
133
+ "name": "oauth_client_secret",
134
+ "required": true,
135
+ "type": "secretString"
136
+ },
137
+ {
138
+ "name": "access_token",
139
+ "required": true,
140
+ "type": "secretString"
141
+ },
142
+ {
143
+ "name": "refresh_token",
144
+ "required": true,
145
+ "type": "secretString"
146
+ }
147
+ ],
148
+ "oauth2": {
149
+ "clientIDCredential": "oauth_client_id",
150
+ "clientSecretCredential": "oauth_client_secret",
151
+ "credentialMappings": [
152
+ {
153
+ "credential": "access_token",
154
+ "source": "access_token"
155
+ },
156
+ {
157
+ "credential": "refresh_token",
158
+ "source": "refresh_token"
159
+ }
160
+ ],
161
+ "refresh": {
162
+ "missingExpiry": "reject",
163
+ "scopeSeparators": "whitespaceAndComma",
164
+ "storedMissingExpiry": "refresh",
165
+ "terminalErrorCodes": [
166
+ "invalid_request",
167
+ "invalid_client",
168
+ "invalid_grant",
169
+ "unauthorized_client"
170
+ ]
171
+ },
172
+ "scopes": [
173
+ "meeting:read:list_meetings",
174
+ "meeting:read:meeting",
175
+ "meeting:write:meeting",
176
+ "meeting:update:meeting",
177
+ "meeting:read:list_past_participants"
178
+ ],
179
+ "tokenEndpoint": "https://zoom.us/oauth/token",
180
+ "tokenEndpointAuthMethod": "client_secret_basic"
181
+ },
182
+ "refreshable": true,
183
+ "type": "oauth2"
184
+ };
185
+ var CredentialFields = {
186
+ "access_token": "accessToken",
187
+ "oauth_client_id": "oauthClientId",
188
+ "oauth_client_secret": "oauthClientSecret",
189
+ "refresh_token": "refreshToken"
190
+ };
191
+
192
+ // src/operations.ts
193
+ import { newMutationBranch, newMutationRetry, newMutationUncertain, newQueryBranch, newQueryRetry, zeroReceipt } from "@superdurable/connectors-sdk";
194
+ import { newFence, CheckpointError, InsufficientTimeError } from "@superdurable/connectors-sdk/singledispatch";
195
+
196
+ // src/meeting.ts
197
+ var timestampPattern = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:[.,](\d+))?(Z|([+-])(\d{2}):(\d{2}))$/;
198
+ var emptyMeeting = { id: 0, topic: "", settings: { hostVideo: false, participantVideo: false, joinBeforeHost: false, muteUponEntry: false, waitingRoom: false } };
199
+ var emptyMeetingPage = { meetings: [], totalRecords: 0 };
200
+ function object(value) {
201
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("Zoom returned an unusable object");
202
+ return value;
203
+ }
204
+ function responseObject(body) {
205
+ const rawJSON = JSON.rawJSON;
206
+ const parseWithSource = JSON.parse;
207
+ return object(parseWithSource(Buffer.from(body).toString("utf8"), (_key, value, context) => typeof value === "number" ? rawJSON(context.source) : value));
208
+ }
209
+ function string(value) {
210
+ if (value === void 0 || value === null) return "";
211
+ if (typeof value !== "string") throw new TypeError("Zoom returned a non-string field");
212
+ return value;
213
+ }
214
+ function integer(value) {
215
+ if (value === void 0 || value === null) return 0;
216
+ const literal = value && typeof value === "object" && "rawJSON" in value ? String(value.rawJSON) : "";
217
+ if (!/^-?(0|[1-9][0-9]*)$/.test(literal)) throw new TypeError("Zoom returned a non-integer field");
218
+ const number = Number(literal);
219
+ if (!Number.isSafeInteger(number)) throw new TypeError("Zoom returned a non-integer field");
220
+ return number;
221
+ }
222
+ function boolean(value) {
223
+ if (value === void 0 || value === null) return false;
224
+ if (typeof value !== "boolean") throw new TypeError("Zoom returned a non-boolean field");
225
+ return value;
226
+ }
227
+ function zoomTime(value) {
228
+ const raw = string(value);
229
+ if (!raw) return void 0;
230
+ const match = timestampPattern.exec(raw);
231
+ if (!match) throw new TypeError("Zoom returned an invalid timestamp");
232
+ const [, yearText, monthText, dayText, hourText, minuteText, secondText, fraction, zone2, sign, zoneHourText, zoneMinuteText] = match;
233
+ const year = Number(yearText), month = Number(monthText), day = Number(dayText);
234
+ const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
235
+ const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
236
+ if (month < 1 || month > 12 || day < 1 || day > days[month - 1] || Number(hourText) > 23 || Number(minuteText) > 59 || Number(secondText) > 59 || zone2 !== "Z" && (Number(zoneHourText) > 24 || Number(zoneMinuteText) > 60)) throw new TypeError("Zoom returned an invalid timestamp");
237
+ const offset = zone2 === "Z" ? 0 : (Number(zoneHourText) * 60 + Number(zoneMinuteText)) * (sign === "+" ? 1 : -1);
238
+ const calendar = /* @__PURE__ */ new Date(0);
239
+ calendar.setUTCFullYear(year, month - 1, day);
240
+ calendar.setUTCHours(Number(hourText), Number(minuteText), Number(secondText), 0);
241
+ const milliseconds = calendar.getTime() - offset * 6e4;
242
+ const instant = new Date(milliseconds);
243
+ if (!Number.isFinite(milliseconds)) throw new TypeError("Zoom returned an invalid timestamp");
244
+ const nanoseconds = (fraction ?? "").slice(0, 9).padEnd(9, "0");
245
+ const trimmed = nanoseconds.replace(/0+$/, "");
246
+ return instant.toISOString().replace(/\.\d{3}Z$/, "") + (trimmed ? `.${trimmed}` : "") + "Z";
247
+ }
248
+ function meetingID(value) {
249
+ if (!Number.isSafeInteger(value) || value < 1) throw new TypeError("meetingId must be Zoom's positive numeric meeting ID");
250
+ }
251
+ function pageToken(value = "") {
252
+ if (Buffer.byteLength(value) > 1024 || !/^[!-~]*$/.test(value)) throw new TypeError("pageToken must be printable ASCII without spaces and at most 1024 bytes");
253
+ }
254
+ function pageSize(value = 0) {
255
+ if (value === 0) return 30;
256
+ if (!Number.isSafeInteger(value) || value < 1 || value > 300) throw new TypeError("pageSize must be between 1 and 300");
257
+ return value;
258
+ }
259
+ function topic(value) {
260
+ if (!value.trim()) throw new TypeError("topic is required");
261
+ if ([...value].length > 200) throw new TypeError("topic must be valid UTF-8 of at most 200 characters");
262
+ }
263
+ function agenda(value) {
264
+ if ([...value].length > 2e3) throw new TypeError("agenda must be valid UTF-8 of at most 2000 characters");
265
+ }
266
+ function duration(value) {
267
+ if (!Number.isSafeInteger(value) || value < 1 || value > 1440) throw new TypeError("durationMinutes must be between 1 and 1440");
268
+ }
269
+ function zone(value) {
270
+ if (!value || value !== value.trim() || value === "Local") throw new TypeError("timeZone must be an IANA time zone name");
271
+ try {
272
+ new Intl.DateTimeFormat("en-US", { timeZone: value });
273
+ } catch {
274
+ throw new TypeError("timeZone is not a known IANA time zone name");
275
+ }
276
+ }
277
+ function start(value, timeZone) {
278
+ zone(timeZone);
279
+ const instant = zoomTime(value);
280
+ if (!instant || !timestampPattern.test(value) || (timestampPattern.exec(value)?.[7] ?? "").replace(/0/g, "") !== "") throw new TypeError("startTime must be a whole-second RFC 3339 instant with an explicit offset");
281
+ return instant;
282
+ }
283
+ function settings(input) {
284
+ if (!input) return void 0;
285
+ if (input.autoRecording && !["none", "local", "cloud"].includes(input.autoRecording)) throw new TypeError("settings.autoRecording must be none, local, or cloud");
286
+ const value = {
287
+ ...input.hostVideo !== void 0 ? { host_video: input.hostVideo } : {},
288
+ ...input.participantVideo !== void 0 ? { participant_video: input.participantVideo } : {},
289
+ ...input.joinBeforeHost !== void 0 ? { join_before_host: input.joinBeforeHost } : {},
290
+ ...input.muteUponEntry !== void 0 ? { mute_upon_entry: input.muteUponEntry } : {},
291
+ ...input.waitingRoom !== void 0 ? { waiting_room: input.waitingRoom } : {},
292
+ ...input.autoRecording ? { auto_recording: input.autoRecording } : {}
293
+ };
294
+ return Object.keys(value).length ? value : void 0;
295
+ }
296
+ function createRequest(input) {
297
+ topic(input.topic);
298
+ duration(input.durationMinutes);
299
+ agenda(input.agenda ?? "");
300
+ const instant = start(input.startTime, input.timeZone);
301
+ const override = settings(input.settings);
302
+ return {
303
+ payload: {
304
+ topic: input.topic,
305
+ type: 2,
306
+ start_time: instant,
307
+ duration: input.durationMinutes,
308
+ timezone: input.timeZone,
309
+ ...input.agenda ? { agenda: input.agenda } : {},
310
+ ...override ? { settings: override } : {}
311
+ },
312
+ requested: {
313
+ id: 0,
314
+ topic: input.topic,
315
+ type: 2,
316
+ startTime: instant,
317
+ durationMinutes: input.durationMinutes,
318
+ timeZone: input.timeZone,
319
+ ...input.agenda ? { agenda: input.agenda } : {},
320
+ settings: emptyMeeting.settings
321
+ }
322
+ };
323
+ }
324
+ function updateRequest(input, now) {
325
+ meetingID(input.meetingId);
326
+ const payload = {};
327
+ if (input.topic) {
328
+ topic(input.topic);
329
+ payload.topic = input.topic;
330
+ }
331
+ if (input.agenda !== void 0) {
332
+ agenda(input.agenda);
333
+ payload.agenda = input.agenda;
334
+ }
335
+ if (input.startTime) {
336
+ const instant = start(input.startTime, input.timeZone ?? "");
337
+ if (Date.parse(instant) <= now.getTime()) throw new TypeError("startTime is not in the future");
338
+ payload.start_time = instant;
339
+ payload.timezone = input.timeZone;
340
+ } else if (input.timeZone) throw new TypeError("timeZone requires startTime");
341
+ if (input.durationMinutes) {
342
+ duration(input.durationMinutes);
343
+ payload.duration = input.durationMinutes;
344
+ }
345
+ const override = settings(input.settings);
346
+ if (override) payload.settings = override;
347
+ if (!Object.keys(payload).length) throw new TypeError("updateMeeting needs at least one change");
348
+ return payload;
349
+ }
350
+ function decodeMeeting(value) {
351
+ const raw = object(value);
352
+ const id = integer(raw.id), length = integer(raw.duration);
353
+ if (id < 1 || length < 0) throw new TypeError("Zoom returned an unusable meeting");
354
+ const joinUrl = string(raw.join_url);
355
+ if (joinUrl) {
356
+ const url = new URL(joinUrl);
357
+ if (url.protocol !== "https:" || !url.hostname || url.username || url.password) throw new TypeError("Zoom returned an unusable meeting");
358
+ }
359
+ const rawSettings = raw.settings == null ? {} : object(raw.settings);
360
+ const meeting = { id, topic: string(raw.topic), settings: {
361
+ hostVideo: boolean(rawSettings.host_video),
362
+ participantVideo: boolean(rawSettings.participant_video),
363
+ joinBeforeHost: boolean(rawSettings.join_before_host),
364
+ muteUponEntry: boolean(rawSettings.mute_upon_entry),
365
+ waitingRoom: boolean(rawSettings.waiting_room),
366
+ ...string(rawSettings.auto_recording) ? { autoRecording: string(rawSettings.auto_recording) } : {}
367
+ } };
368
+ const fields = [["uuid", raw.uuid], ["hostId", raw.host_id], ["hostEmail", raw.host_email], ["status", raw.status], ["timeZone", raw.timezone], ["agenda", raw.agenda], ["joinUrl", raw.join_url]];
369
+ for (const [key, rawValue] of fields) {
370
+ const value2 = string(rawValue);
371
+ if (value2) meeting[key] = value2;
372
+ }
373
+ const type = integer(raw.type);
374
+ if (type) meeting.type = type;
375
+ if (length) meeting.durationMinutes = length;
376
+ const startTime = zoomTime(raw.start_time);
377
+ if (startTime) meeting.startTime = startTime;
378
+ const createdAt = zoomTime(raw.created_at);
379
+ if (createdAt) meeting.createdAt = createdAt;
380
+ return meeting;
381
+ }
382
+ function meetingSummary(meeting) {
383
+ const { id, uuid, hostId, topic: topic2, type, startTime, durationMinutes, timeZone, agenda: agenda2, joinUrl, createdAt } = meeting;
384
+ return {
385
+ id,
386
+ topic: topic2,
387
+ ...uuid ? { uuid } : {},
388
+ ...hostId ? { hostId } : {},
389
+ ...type ? { type } : {},
390
+ ...startTime ? { startTime } : {},
391
+ ...durationMinutes ? { durationMinutes } : {},
392
+ ...timeZone ? { timeZone } : {},
393
+ ...agenda2 ? { agenda: agenda2 } : {},
394
+ ...joinUrl ? { joinUrl } : {},
395
+ ...createdAt ? { createdAt } : {}
396
+ };
397
+ }
398
+ function participantPage(value, id) {
399
+ const raw = object(value), total = integer(raw.total_records), token = string(raw.next_page_token);
400
+ if (total < 0 || raw.participants !== void 0 && raw.participants !== null && !Array.isArray(raw.participants)) throw new TypeError("Zoom returned an unusable participant page");
401
+ pageToken(token);
402
+ const participants = (raw.participants ?? []).map((value2) => {
403
+ const item = object(value2), durationSeconds = integer(item.duration);
404
+ if (durationSeconds < 0) throw new TypeError("Zoom returned an unusable participant page");
405
+ const joinTime = zoomTime(item.join_time), leaveTime = zoomTime(item.leave_time);
406
+ return {
407
+ durationSeconds,
408
+ isInternalUser: boolean(item.internal_user),
409
+ ...string(item.id) ? { id: string(item.id) } : {},
410
+ ...string(item.name) ? { name: string(item.name) } : {},
411
+ ...string(item.user_email) ? { email: string(item.user_email) } : {},
412
+ ...joinTime ? { joinTime } : {},
413
+ ...leaveTime ? { leaveTime } : {},
414
+ ...string(item.status) ? { status: string(item.status) } : {}
415
+ };
416
+ });
417
+ return { meetingId: id, participants, totalRecords: total, ...token ? { nextPageToken: token } : {} };
418
+ }
419
+
420
+ // src/operations.ts
421
+ var emptyParticipants = { meetingId: 0, participants: [], totalRecords: 0 };
422
+ var emptyUpdate = { meetingId: 0 };
423
+ var successful = (status) => status >= 200 && status < 300;
424
+ function code(body) {
425
+ try {
426
+ const value = integer(responseObject(body).code);
427
+ return value >= 0 && value <= 4294967295 ? String(value) : "";
428
+ } catch {
429
+ return "";
430
+ }
431
+ }
432
+ function statusMessage(message, status, errorCode) {
433
+ return `${message} with HTTP ${status}${errorCode ? ` (code ${errorCode})` : ""}`;
434
+ }
435
+ function classify(client, operation, exchange) {
436
+ if ("error" in exchange) return { outcome: "retry", failure: zoomFailure(operation, "TRANSPORT", "Zoom could not be reached"), errorCode: "", retryAfter: 0 };
437
+ const { response, isTooLarge, reflectsCredential } = exchange, status = response.status;
438
+ const errorCode = code(response.body), retryAfter = client.retryAfter(response.headers);
439
+ if (successful(status)) {
440
+ if (isTooLarge) return { outcome: "invalid", failure: zoomFailure(operation, "RESPONSE_TOO_LARGE", "Zoom response exceeds the configured size limit"), errorCode: "", retryAfter: 0 };
441
+ if (reflectsCredential) return { outcome: "invalid", failure: zoomFailure(operation, "PROTOCOL", "Zoom response contained the connection credential"), errorCode: "", retryAfter: 0 };
442
+ return { outcome: "usable", errorCode: "", retryAfter: 0 };
443
+ }
444
+ if (status >= 300 && status < 400) return { outcome: "invalid", failure: zoomFailure(operation, "PROTOCOL", statusMessage("Zoom redirected the request", status, "")), errorCode: "", retryAfter: 0 };
445
+ if (status === 404) return { outcome: "notFound", failure: zoomFailure(operation, "NOT_FOUND", statusMessage("Zoom reported the resource missing", status, errorCode)), errorCode, retryAfter: 0 };
446
+ if (status === 429) {
447
+ let daily = false;
448
+ try {
449
+ const message = object(JSON.parse(Buffer.from(response.body).toString())).message;
450
+ daily = typeof message === "string" && message.trim().toLowerCase().startsWith("you have reached the maximum daily rate limit for this api.");
451
+ } catch {
452
+ }
453
+ return { outcome: daily ? "rejected" : "retry", failure: zoomFailure(operation, "RATE_LIMIT", statusMessage(daily ? "Zoom daily API rate limit reached" : "Zoom rate limited the request", status, errorCode)), errorCode, retryAfter: daily ? 0 : retryAfter };
454
+ }
455
+ if (status === 409) return { outcome: "retry", failure: zoomFailure(operation, "CONFLICT", statusMessage("Zoom reported a conflict", status, errorCode)), errorCode, retryAfter: 0 };
456
+ if (status === 408 || status >= 500) return { outcome: "retry", failure: zoomFailure(operation, "AVAILABILITY", statusMessage("Zoom is temporarily unavailable", status, errorCode)), errorCode, retryAfter };
457
+ const kind = status === 401 ? "AUTHENTICATION" : status === 403 ? "AUTHORIZATION" : status === 412 ? "CONFLICT" : "PROVIDER_REJECTION";
458
+ return { outcome: "rejected", failure: zoomFailure(operation, kind, statusMessage("Zoom rejected the request", status, errorCode)), errorCode, retryAfter: 0 };
459
+ }
460
+ function defect(operation, error) {
461
+ return zoomFailure(operation, "VALIDATION", error instanceof Error ? error.message : String(error));
462
+ }
463
+ function queryCredential(resolved, empty) {
464
+ return resolved.retry ? newQueryRetry(resolved.failure, 0) : newQueryBranch("defect", empty, zeroReceipt(), resolved.failure);
465
+ }
466
+ function mutationCredential(resolved, empty) {
467
+ return resolved.retry ? newMutationRetry(resolved.failure, 0) : newMutationBranch("defect", empty, zeroReceipt(), resolved.failure);
468
+ }
469
+ var ListMeetingsOperation = class {
470
+ /** Bind one Zoom client. */
471
+ constructor(client) {
472
+ this.client = client;
473
+ }
474
+ client;
475
+ /** Return the manifest definition. */
476
+ definition() {
477
+ return ListMeetingsDefinition;
478
+ }
479
+ /** Invoke one bounded meeting-list request. */
480
+ async invoke(call, input) {
481
+ let query;
482
+ try {
483
+ const type = input.type || "upcoming";
484
+ if (!["upcoming", "scheduled", "live", "previous_meetings"].includes(type)) throw new TypeError("type must be upcoming, scheduled, live, or previous_meetings");
485
+ pageToken(input.pageToken);
486
+ query = new URLSearchParams({ type, page_size: String(pageSize(input.pageSize)) });
487
+ if (input.pageToken) query.set("next_page_token", input.pageToken);
488
+ } catch (error) {
489
+ return newQueryBranch("defect", emptyMeetingPage, zeroReceipt(), defect("listMeetings", error));
490
+ }
491
+ const resolved = await this.client.resolveCredentials(call, "listMeetings");
492
+ if ("failure" in resolved) return queryCredential(resolved, emptyMeetingPage);
493
+ const exchange = await this.client.exchange(call, resolved.credentials, "GET", "/users/me/meetings", query);
494
+ if ("error" in exchange) return exchange.error === "notBuilt" ? newQueryBranch("defect", emptyMeetingPage, zeroReceipt(), zoomFailure("listMeetings", "LOCAL_DEFECT", "Zoom request could not be built")) : newQueryRetry(zoomFailure("listMeetings", "TRANSPORT", "Zoom could not be reached"), 0);
495
+ const result = classify(this.client, "listMeetings", exchange), receipt = this.client.receipt(call, "", result.errorCode);
496
+ if (result.outcome === "retry") return newQueryRetry(result.failure, result.retryAfter);
497
+ if (result.outcome === "invalid") return newQueryBranch("invalidResponse", emptyMeetingPage, receipt, result.failure);
498
+ if (result.outcome !== "usable") return newQueryBranch("providerRejected", emptyMeetingPage, receipt, result.failure);
499
+ try {
500
+ const raw = responseObject(exchange.response.body), total = integer(raw.total_records), next = raw.next_page_token ?? "";
501
+ if (total < 0 || typeof next !== "string" || raw.meetings !== void 0 && raw.meetings !== null && !Array.isArray(raw.meetings)) throw new TypeError("invalid page");
502
+ pageToken(next);
503
+ const meetings = (raw.meetings ?? []).map((item) => meetingSummary(decodeMeeting(item)));
504
+ return newQueryBranch("listed", { meetings, totalRecords: total, ...next ? { nextPageToken: next } : {} }, receipt);
505
+ } catch {
506
+ return newQueryBranch("invalidResponse", emptyMeetingPage, receipt, zoomFailure("listMeetings", "PROTOCOL", "Zoom returned an unusable meeting page"));
507
+ }
508
+ }
509
+ };
510
+ var GetMeetingOperation = class {
511
+ /** Bind one Zoom client. */
512
+ constructor(client) {
513
+ this.client = client;
514
+ }
515
+ client;
516
+ /** Return the manifest definition. */
517
+ definition() {
518
+ return GetMeetingDefinition;
519
+ }
520
+ /** Invoke one bounded meeting read. */
521
+ async invoke(call, input) {
522
+ try {
523
+ meetingID(input.meetingId);
524
+ } catch (error) {
525
+ return newQueryBranch("defect", emptyMeeting, zeroReceipt(), defect("getMeeting", error));
526
+ }
527
+ const resolved = await this.client.resolveCredentials(call, "getMeeting");
528
+ if ("failure" in resolved) return queryCredential(resolved, emptyMeeting);
529
+ const id = String(input.meetingId), exchange = await this.client.exchange(call, resolved.credentials, "GET", `/meetings/${id}`);
530
+ if ("error" in exchange) return exchange.error === "notBuilt" ? newQueryBranch("defect", emptyMeeting, zeroReceipt(), zoomFailure("getMeeting", "LOCAL_DEFECT", "Zoom request could not be built")) : newQueryRetry(zoomFailure("getMeeting", "TRANSPORT", "Zoom could not be reached"), 0);
531
+ const result = classify(this.client, "getMeeting", exchange), receipt = this.client.receipt(call, id, result.errorCode);
532
+ if (result.outcome === "retry") return newQueryRetry(result.failure, result.retryAfter);
533
+ if (result.outcome === "notFound") return newQueryBranch("notFound", { ...emptyMeeting, id: input.meetingId }, receipt, result.failure);
534
+ if (result.outcome === "invalid") return newQueryBranch("invalidResponse", emptyMeeting, receipt, result.failure);
535
+ if (result.outcome !== "usable") return newQueryBranch("providerRejected", emptyMeeting, receipt, result.failure);
536
+ try {
537
+ const meeting = decodeMeeting(responseObject(exchange.response.body));
538
+ if (meeting.id !== input.meetingId) throw new TypeError("wrong meeting");
539
+ return newQueryBranch("found", meeting, receipt);
540
+ } catch {
541
+ return newQueryBranch("invalidResponse", emptyMeeting, receipt, zoomFailure("getMeeting", "PROTOCOL", "Zoom returned an unusable meeting"));
542
+ }
543
+ }
544
+ };
545
+ var UpdateMeetingOperation = class {
546
+ /** Bind one Zoom client. */
547
+ constructor(client) {
548
+ this.client = client;
549
+ }
550
+ client;
551
+ /** Return the manifest definition. */
552
+ definition() {
553
+ return UpdateMeetingDefinition;
554
+ }
555
+ /** Derive the receipt key from Dex's Call ID. */
556
+ idempotencyKey(callId) {
557
+ return callId;
558
+ }
559
+ /** Invoke one repeat-safe meeting patch. */
560
+ async invoke(call, input) {
561
+ let payload;
562
+ try {
563
+ payload = updateRequest(input, /* @__PURE__ */ new Date());
564
+ } catch (error) {
565
+ return newMutationBranch("defect", emptyUpdate, zeroReceipt(), defect("updateMeeting", error));
566
+ }
567
+ const resolved = await this.client.resolveCredentials(call, "updateMeeting");
568
+ if ("failure" in resolved) return mutationCredential(resolved, emptyUpdate);
569
+ const id = String(input.meetingId), updated = { meetingId: input.meetingId };
570
+ const exchange = await this.client.exchange(call, resolved.credentials, "PATCH", `/meetings/${id}`, void 0, payload);
571
+ if ("error" in exchange) return exchange.error === "notBuilt" ? newMutationBranch("defect", emptyUpdate, zeroReceipt(), zoomFailure("updateMeeting", "LOCAL_DEFECT", "Zoom request could not be built")) : newMutationRetry(zoomFailure("updateMeeting", "TRANSPORT", "Zoom could not be reached"), 0);
572
+ if (successful(exchange.response.status)) return newMutationBranch("updated", updated, this.client.receipt(call, id));
573
+ const result = classify(this.client, "updateMeeting", exchange), receipt = this.client.receipt(call, id, result.errorCode);
574
+ if (result.outcome === "retry") return newMutationRetry(result.failure, result.retryAfter);
575
+ return newMutationBranch(result.outcome === "notFound" ? "notFound" : "providerRejected", updated, receipt, result.failure);
576
+ }
577
+ };
578
+ var ListPastMeetingParticipantsOperation = class {
579
+ /** Bind one Zoom client. */
580
+ constructor(client) {
581
+ this.client = client;
582
+ }
583
+ client;
584
+ /** Return the manifest definition. */
585
+ definition() {
586
+ return ListPastMeetingParticipantsDefinition;
587
+ }
588
+ /** Invoke one bounded participant-list request. */
589
+ async invoke(call, input) {
590
+ let query;
591
+ try {
592
+ meetingID(input.meetingId);
593
+ pageToken(input.pageToken);
594
+ query = new URLSearchParams({ page_size: String(pageSize(input.pageSize)) });
595
+ if (input.pageToken) query.set("next_page_token", input.pageToken);
596
+ } catch (error) {
597
+ return newQueryBranch("defect", emptyParticipants, zeroReceipt(), defect("listPastMeetingParticipants", error));
598
+ }
599
+ const resolved = await this.client.resolveCredentials(call, "listPastMeetingParticipants");
600
+ if ("failure" in resolved) return queryCredential(resolved, emptyParticipants);
601
+ const id = String(input.meetingId), empty = { ...emptyParticipants, meetingId: input.meetingId };
602
+ const exchange = await this.client.exchange(call, resolved.credentials, "GET", `/past_meetings/${id}/participants`, query);
603
+ if ("error" in exchange) return exchange.error === "notBuilt" ? newQueryBranch("defect", emptyParticipants, zeroReceipt(), zoomFailure("listPastMeetingParticipants", "LOCAL_DEFECT", "Zoom request could not be built")) : newQueryRetry(zoomFailure("listPastMeetingParticipants", "TRANSPORT", "Zoom could not be reached"), 0);
604
+ const result = classify(this.client, "listPastMeetingParticipants", exchange), receipt = this.client.receipt(call, id, result.errorCode);
605
+ if (result.outcome === "retry") return newQueryRetry(result.failure, result.retryAfter);
606
+ if (result.outcome === "notFound") return newQueryBranch("notFound", empty, receipt, result.failure);
607
+ if (result.outcome === "invalid") return newQueryBranch("invalidResponse", empty, receipt, result.failure);
608
+ if (result.outcome !== "usable") return newQueryBranch("providerRejected", empty, receipt, result.failure);
609
+ try {
610
+ return newQueryBranch("listed", participantPage(responseObject(exchange.response.body), input.meetingId), receipt);
611
+ } catch {
612
+ return newQueryBranch("invalidResponse", empty, receipt, zoomFailure("listPastMeetingParticipants", "PROTOCOL", "Zoom returned an unusable participant page"));
613
+ }
614
+ }
615
+ };
616
+ var CreateMeetingOperation = class {
617
+ /** Bind one Zoom client. */
618
+ constructor(client) {
619
+ this.client = client;
620
+ }
621
+ client;
622
+ /** Return the manifest definition. */
623
+ definition() {
624
+ return CreateMeetingDefinition;
625
+ }
626
+ /** Derive the receipt key from Dex's Call ID. */
627
+ idempotencyKey(callId) {
628
+ return callId;
629
+ }
630
+ /** Invoke one fenced create attempt. */
631
+ async invoke(call, input) {
632
+ let built;
633
+ try {
634
+ built = createRequest(input);
635
+ } catch (error) {
636
+ return newMutationBranch("defect", emptyMeeting, zeroReceipt(), defect("createMeeting", error));
637
+ }
638
+ let fence;
639
+ try {
640
+ fence = newFence(call, 3e4);
641
+ } catch {
642
+ return newMutationBranch("defect", emptyMeeting, zeroReceipt(), zoomFailure("createMeeting", "LOCAL_DEFECT", "Zoom create dispatch fence could not be initialized"));
643
+ }
644
+ const decision = fence.decide();
645
+ if (decision.kind === "failClosed") return newMutationUncertain(built.requested, zoomFailure("createMeeting", "TRANSPORT", "the Zoom create checkpoint could not be trusted"), this.client.receipt(call));
646
+ if (decision.kind === "readBackRequired") {
647
+ const providerId = decision.marker?.providerId;
648
+ if (!providerId || decision.marker?.callId !== call.id) return newMutationUncertain(built.requested, zoomFailure("createMeeting", "TRANSPORT", "an earlier Zoom create may have succeeded without a confirmed meeting ID"), this.client.receipt(call));
649
+ return this.readBack(call, built.requested, providerId);
650
+ }
651
+ if (Date.parse(built.requested.startTime) <= Date.now()) {
652
+ try {
653
+ await fence.recordNotSent();
654
+ } catch {
655
+ return newMutationRetry(zoomFailure("createMeeting", "AVAILABILITY", "Zoom create not-sent checkpoint was unavailable"), 0);
656
+ }
657
+ return newMutationBranch("defect", emptyMeeting, zeroReceipt(), zoomFailure("createMeeting", "VALIDATION", "startTime is not in the future, and Zoom would replace it with the current time"));
658
+ }
659
+ const resolved = await this.client.resolveCredentials(call, "createMeeting");
660
+ if ("failure" in resolved) {
661
+ try {
662
+ await fence.recordNotSent();
663
+ } catch {
664
+ return newMutationRetry(zoomFailure("createMeeting", "AVAILABILITY", "Zoom credentials and the not-sent checkpoint were unavailable"), 0);
665
+ }
666
+ return mutationCredential(resolved, emptyMeeting);
667
+ }
668
+ let exchange;
669
+ try {
670
+ exchange = await fence.dispatch((signal) => this.client.exchange(call, resolved.credentials, "POST", "/users/me/meetings", void 0, built.payload, true, signal));
671
+ } catch (error) {
672
+ if (error instanceof CheckpointError || error instanceof InsufficientTimeError) return newMutationRetry(zoomFailure("createMeeting", "AVAILABILITY", "Zoom create was not sent before the attempt deadline or checkpoint"), 0);
673
+ return newMutationUncertain(built.requested, zoomFailure("createMeeting", "TRANSPORT", "Zoom meeting outcome is unknown"), this.client.receipt(call));
674
+ }
675
+ if ("error" in exchange) {
676
+ if (exchange.error === "notBuilt") return newMutationBranch("defect", emptyMeeting, zeroReceipt(), zoomFailure("createMeeting", "LOCAL_DEFECT", "Zoom request could not be built"));
677
+ if (exchange.error === "beforeSend") {
678
+ try {
679
+ await fence.recordCanResend();
680
+ } catch {
681
+ return newMutationRetry(zoomFailure("createMeeting", "AVAILABILITY", "Zoom was not reached but the resend checkpoint failed"), 0);
682
+ }
683
+ return newMutationRetry(zoomFailure("createMeeting", "TRANSPORT", "Zoom could not be reached, so no meeting was created"), 0);
684
+ }
685
+ return newMutationUncertain(built.requested, zoomFailure("createMeeting", "TRANSPORT", "Zoom meeting outcome is unknown"), this.client.receipt(call));
686
+ }
687
+ if (successful(exchange.response.status)) {
688
+ if (exchange.isTooLarge) return newMutationUncertain(built.requested, zoomFailure("createMeeting", "RESPONSE_TOO_LARGE", "Zoom accepted the request but its response exceeds the configured size limit"), this.client.receipt(call));
689
+ if (exchange.reflectsCredential) return newMutationUncertain(built.requested, zoomFailure("createMeeting", "PROTOCOL", "Zoom accepted the request but its response contained the connection credential"), this.client.receipt(call));
690
+ let meeting;
691
+ try {
692
+ meeting = decodeMeeting(responseObject(exchange.response.body));
693
+ } catch {
694
+ return newMutationUncertain(built.requested, zoomFailure("createMeeting", "PROTOCOL", "Zoom accepted the request but returned an unusable meeting"), this.client.receipt(call));
695
+ }
696
+ try {
697
+ await fence.recordProviderId(String(meeting.id));
698
+ } catch {
699
+ }
700
+ return newMutationBranch("created", meeting, this.client.receipt(call, String(meeting.id)));
701
+ }
702
+ const result = classify(this.client, "createMeeting", exchange), receipt = this.client.receipt(call, "", result.errorCode), status = exchange.response.status;
703
+ if (status === 401) {
704
+ const refreshed = await this.client.refreshAfterRejection(call, resolved.credentials.accessToken.reveal());
705
+ if (refreshed === "unsupported") return newMutationBranch(
706
+ "providerRejected",
707
+ built.requested,
708
+ receipt,
709
+ zoomFailure("createMeeting", "AUTHENTICATION", "Zoom rejected the connection credential; reconnect the connection")
710
+ );
711
+ if (refreshed === "replaced") {
712
+ try {
713
+ await fence.recordCanResend();
714
+ } catch {
715
+ return newMutationRetry(zoomFailure("createMeeting", "AVAILABILITY", "Zoom rejected the credential but the resend checkpoint failed"), 0);
716
+ }
717
+ return newMutationRetry(result.failure, 0);
718
+ }
719
+ return newMutationBranch(
720
+ "providerRejected",
721
+ built.requested,
722
+ receipt,
723
+ zoomFailure(
724
+ "createMeeting",
725
+ refreshed === "reauthorize" ? "AUTHENTICATION" : "AVAILABILITY",
726
+ refreshed === "reauthorize" ? "Zoom connection requires reauthorization; reconnect the connection" : "Zoom credential refresh is temporarily unavailable"
727
+ )
728
+ );
729
+ }
730
+ if (status === 429 && result.outcome === "rejected") return newMutationBranch("providerRejected", built.requested, receipt, result.failure);
731
+ if (status === 429 || status === 503) {
732
+ try {
733
+ await fence.recordCanResend();
734
+ } catch {
735
+ return newMutationRetry(zoomFailure("createMeeting", "AVAILABILITY", "Zoom rejected the create but the resend checkpoint failed"), 0);
736
+ }
737
+ return newMutationRetry(result.failure, result.retryAfter);
738
+ }
739
+ if (status === 409 || status >= 500 || status === 408) return newMutationUncertain(built.requested, result.failure, receipt);
740
+ if (status >= 400 && status < 500) return newMutationBranch("providerRejected", built.requested, receipt, result.failure);
741
+ return newMutationUncertain(built.requested, result.failure, receipt);
742
+ }
743
+ async readBack(call, requested, providerId) {
744
+ const id = Number(providerId);
745
+ if (!Number.isSafeInteger(id) || id < 1) return newMutationUncertain(requested, zoomFailure("createMeeting", "PROTOCOL", "the accepted Zoom meeting ID could not be read back"), this.client.receipt(call, providerId));
746
+ const resolved = await this.client.resolveCredentials(call, "createMeeting");
747
+ if ("failure" in resolved) return resolved.retry ? newMutationRetry(resolved.failure, 0) : newMutationUncertain(requested, resolved.failure, this.client.receipt(call, providerId));
748
+ const exchange = await this.client.exchange(call, resolved.credentials, "GET", `/meetings/${providerId}`);
749
+ if ("error" in exchange) return newMutationRetry(zoomFailure("createMeeting", "TRANSPORT", "Zoom meeting read-back could not be reached"), 0);
750
+ const result = classify(this.client, "createMeeting", exchange);
751
+ if (result.outcome === "retry") return newMutationRetry(result.failure, result.retryAfter);
752
+ if (result.outcome === "usable") {
753
+ try {
754
+ const meeting = decodeMeeting(responseObject(exchange.response.body));
755
+ if (meeting.id === id) return newMutationBranch("created", meeting, this.client.receipt(call, providerId));
756
+ } catch {
757
+ }
758
+ }
759
+ return newMutationUncertain(requested, zoomFailure("createMeeting", "PROTOCOL", "Zoom could not confirm the accepted meeting"), this.client.receipt(call, providerId));
760
+ }
761
+ };
762
+
763
+ // src/client.ts
764
+ var defaultEndpoint = "https://api.zoom.us/v2";
765
+ var ZoomClient2 = class {
766
+ /** Validate connection settings before a Step resolves credentials. */
767
+ constructor(config, credentials, options = {}) {
768
+ this.credentials = credentials;
769
+ if (!credentials) throw new TypeError("Zoom credential provider is required");
770
+ this.endpoint = validateBaseURL(config.endpoint || defaultEndpoint);
771
+ this.maxResponseBytes = config.maxResponseBytes || 2097152;
772
+ if (!Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes < 1) throw new TypeError("Zoom maxResponseBytes must be positive");
773
+ this.send = options.send ?? sendProviderRequest;
774
+ this.now = options.now ?? (() => /* @__PURE__ */ new Date());
775
+ }
776
+ credentials;
777
+ endpoint;
778
+ maxResponseBytes;
779
+ send;
780
+ now;
781
+ refreshDriver = new ManifestCredentialRefreshDriver({ providerName: "Zoom", auth: Authorization, credentialFields: CredentialFields });
782
+ /** Bind the meeting list query. */
783
+ listMeetings() {
784
+ return new ListMeetingsOperation(this);
785
+ }
786
+ /** Bind the meeting detail query. */
787
+ getMeeting() {
788
+ return new GetMeetingOperation(this);
789
+ }
790
+ /** Bind the fenced meeting create mutation. */
791
+ createMeeting() {
792
+ return new CreateMeetingOperation(this);
793
+ }
794
+ /** Bind the meeting patch mutation. */
795
+ updateMeeting() {
796
+ return new UpdateMeetingOperation(this);
797
+ }
798
+ /** Bind the participant list query. */
799
+ listPastMeetingParticipants() {
800
+ return new ListPastMeetingParticipantsOperation(this);
801
+ }
802
+ /** Resolve generated renewable credentials and preserve terminal versus retryable failures. */
803
+ async resolveCredentials(call, operation) {
804
+ try {
805
+ const credentials = await resolveCredential(this.credentials, call, this.refreshDriver, call.context.cancellationSignal);
806
+ if (!credentials.accessToken || !isHeaderSafeCredential(credentials.accessToken.reveal()))
807
+ return { failure: zoomFailure(operation, "AUTHENTICATION", "Zoom connection credentials are unavailable; reconnect the connection"), retry: false };
808
+ return { credentials };
809
+ } catch (error) {
810
+ if (error instanceof ReauthorizationRequiredError) return { failure: zoomFailure(operation, "AUTHENTICATION", "Zoom connection requires reauthorization; reconnect the connection"), retry: false };
811
+ return { failure: zoomFailure(operation, "AVAILABILITY", "Zoom connection credentials could not be refreshed"), retry: true };
812
+ }
813
+ }
814
+ /** Force one generated refresh after Zoom rejects a fenced create credential. */
815
+ async refreshAfterRejection(call, previousAccessToken) {
816
+ if (!("resolveAfterRejection" in this.credentials)) return "unsupported";
817
+ try {
818
+ const replacement = await resolveCredentialAfterRejection(this.credentials, call, this.refreshDriver, call.context.cancellationSignal);
819
+ return replacement.accessToken?.reveal() && replacement.accessToken.reveal() !== previousAccessToken ? "replaced" : "reauthorize";
820
+ } catch (error) {
821
+ return error instanceof ReauthorizationRequiredError ? "reauthorize" : "retryable";
822
+ }
823
+ }
824
+ /** Send one bounded request and refresh once after a rejected credential when allowed. */
825
+ async exchange(call, credentials, method, path, query, payload, isFencedWrite = false, signal) {
826
+ const queryString = query ? encodeGoQuery(query) : "";
827
+ const url = `${this.endpoint}${path}${queryString ? `?${queryString}` : ""}`;
828
+ for (let attempt = 0; attempt < 2; attempt++) {
829
+ const accessToken = credentials.accessToken.reveal();
830
+ const request = {
831
+ url,
832
+ method,
833
+ headers: { Authorization: `Bearer ${accessToken}`, Accept: "application/json", ...payload === void 0 ? {} : { "Content-Type": "application/json" } },
834
+ ...payload === void 0 ? {} : { body: Buffer.from(JSON.stringify(payload), "utf8") },
835
+ maxResponseBytes: Math.max(this.maxResponseBytes, MaxErrorBodyBytes),
836
+ maxErrorResponseBytes: MaxErrorBodyBytes,
837
+ ignoreErrorBodyReadFailure: true,
838
+ timeoutMs: 2e4,
839
+ addressPolicy: "unrestricted",
840
+ signal: signal ?? call.context.cancellationSignal
841
+ };
842
+ let result;
843
+ try {
844
+ const response = await this.send(request);
845
+ const isTooLarge = response.status >= 200 && response.status < 300 && response.body.length > this.maxResponseBytes;
846
+ result = {
847
+ response: { ...response, body: isTooLarge ? new Uint8Array() : response.body },
848
+ isTooLarge,
849
+ reflectsCredential: !isTooLarge && accessToken !== "" && Buffer.from(response.body).includes(Buffer.from(accessToken))
850
+ };
851
+ } catch (error) {
852
+ if (error instanceof BodyTooLargeError && error.status !== void 0) result = { response: { status: error.status, headers: error.headers ?? {}, body: new Uint8Array() }, isTooLarge: error.status >= 200 && error.status < 300, reflectsCredential: false };
853
+ else if (error instanceof ProviderTransportError) return { error: error.isProvablyNotSent ? "beforeSend" : "afterSend" };
854
+ else if (error instanceof AddressRefusal || error instanceof TypeError) return { error: "notBuilt" };
855
+ else return { error: "afterSend" };
856
+ }
857
+ if (result.response.status !== 401 || attempt !== 0 || isFencedWrite || !("resolveAfterRejection" in this.credentials)) return result;
858
+ try {
859
+ credentials = await resolveCredentialAfterRejection(this.credentials, call, this.refreshDriver, call.context.cancellationSignal);
860
+ if (!credentials.accessToken?.reveal()) return result;
861
+ } catch {
862
+ return result;
863
+ }
864
+ }
865
+ return { error: "afterSend" };
866
+ }
867
+ /** Build a secret-free receipt containing only the provider meeting ID and numeric error code. */
868
+ receipt(call, objectId = "", errorCode = "") {
869
+ return {
870
+ callId: call.id,
871
+ ...call.idempotencyKey ? { idempotencyKey: call.idempotencyKey } : {},
872
+ provider: "zoom",
873
+ ...objectId ? { providerObjectId: objectId } : {},
874
+ observedAt: this.now().toISOString(),
875
+ ...errorCode ? { metadata: { zoomErrorCode: errorCode } } : {}
876
+ };
877
+ }
878
+ /** Parse Retry-After with the SDK's bounded rules. */
879
+ retryAfter(headers) {
880
+ const value = headers["retry-after"];
881
+ return parseRetryAfter(typeof value === "string" ? value : "", this.now());
882
+ }
883
+ };
884
+ function zoomFailure(operation, kind, message) {
885
+ return { kind, provider: "zoom", operation, message };
886
+ }
887
+ function encodeGoQuery(query) {
888
+ const escape = (value) => encodeURIComponent(value).replace(/%20/g, "+").replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);
889
+ return [...query].sort(([left], [right]) => Buffer.compare(Buffer.from(left), Buffer.from(right))).map(([key, value]) => `${escape(key)}=${escape(value)}`).join("&");
890
+ }
891
+
892
+ // src/project.ts
893
+ function encodeCredentials(credentials) {
894
+ return {
895
+ oauth_client_id: credentials.oauthClientId,
896
+ oauth_client_secret: credentials.oauthClientSecret.reveal(),
897
+ access_token: credentials.accessToken.reveal(),
898
+ refresh_token: credentials.refreshToken.reveal()
899
+ };
900
+ }
901
+ function newProjectConnection2(project, connectionName, options = {}) {
902
+ return newProjectConnection(project, connectionName, (loadedProject, name) => {
903
+ const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "zoom" && entry.connectionName === name);
904
+ if (!selected) throw new TypeError("Zoom project connection is not configured");
905
+ const config = ConfigSchema.parse(selected.configuration);
906
+ return new ZoomClient2({ ...config.endpoint !== void 0 ? { endpoint: config.endpoint } : {}, ...config.maxResponseBytes !== void 0 ? { maxResponseBytes: config.maxResponseBytes } : {} }, newProjectCredentialProvider(loadedProject, name, decodeCredentials, encodeCredentials, decodeSharedCredentials), options);
907
+ });
908
+ }
909
+ export {
910
+ ConfigSchema,
911
+ Connection,
912
+ ConnectorID,
913
+ CreateMeetingBranch,
914
+ CreateMeetingBranchCreated,
915
+ CreateMeetingBranchDefect,
916
+ CreateMeetingBranchProviderRejected,
917
+ CreateMeetingBranchUncertain,
918
+ CreateMeetingDefinition,
919
+ CreateMeetingInputSchema,
920
+ CreateMeetingMetadata,
921
+ CreateMeetingOperation,
922
+ GetMeetingBranch,
923
+ GetMeetingBranchDefect,
924
+ GetMeetingBranchFound,
925
+ GetMeetingBranchInvalidResponse,
926
+ GetMeetingBranchNotFound,
927
+ GetMeetingBranchProviderRejected,
928
+ GetMeetingDefinition,
929
+ GetMeetingInputSchema,
930
+ GetMeetingMetadata,
931
+ GetMeetingOperation,
932
+ ListMeetingsBranch,
933
+ ListMeetingsBranchDefect,
934
+ ListMeetingsBranchInvalidResponse,
935
+ ListMeetingsBranchListed,
936
+ ListMeetingsBranchProviderRejected,
937
+ ListMeetingsDefinition,
938
+ ListMeetingsInputSchema,
939
+ ListMeetingsMetadata,
940
+ ListMeetingsOperation,
941
+ ListPastMeetingParticipantsBranch,
942
+ ListPastMeetingParticipantsBranchDefect,
943
+ ListPastMeetingParticipantsBranchInvalidResponse,
944
+ ListPastMeetingParticipantsBranchListed,
945
+ ListPastMeetingParticipantsBranchNotFound,
946
+ ListPastMeetingParticipantsBranchProviderRejected,
947
+ ListPastMeetingParticipantsDefinition,
948
+ ListPastMeetingParticipantsInputSchema,
949
+ ListPastMeetingParticipantsMetadata,
950
+ ListPastMeetingParticipantsOperation,
951
+ MeetingPageSchema,
952
+ MeetingParticipantSchema,
953
+ MeetingSchema,
954
+ MeetingSettingsInputSchema,
955
+ MeetingSettingsSchema,
956
+ MeetingSummarySchema,
957
+ ParticipantPageSchema,
958
+ ProviderID,
959
+ UpdateMeetingBranch,
960
+ UpdateMeetingBranchDefect,
961
+ UpdateMeetingBranchNotFound,
962
+ UpdateMeetingBranchProviderRejected,
963
+ UpdateMeetingBranchUpdated,
964
+ UpdateMeetingDefinition,
965
+ UpdateMeetingInputSchema,
966
+ UpdateMeetingMetadata,
967
+ UpdateMeetingOperation,
968
+ UpdatedMeetingSchema,
969
+ ZoomClient2 as ZoomClient,
970
+ decodeCredentials,
971
+ decodeSharedCredentials,
972
+ newConnection,
973
+ newConnectionWithOperations,
974
+ newCreateMeetingStep,
975
+ newGetMeetingStep,
976
+ newListMeetingsStep,
977
+ newListPastMeetingParticipantsStep,
978
+ newProjectConnection2 as newProjectConnection,
979
+ newUpdateMeetingStep
980
+ };