@superdurable/connector-docusign 0.0.0-stage → 0.2.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.
@@ -0,0 +1,424 @@
1
+ // src/generated/models.ts
2
+ import { z } from "zod";
3
+ import { SecretString } from "@superdurable/connectors-sdk";
4
+ var goTimeJSONPattern = /^(\d{4})-(\d{2})-(\d{2})T(\d{1,2}):(\d{2}):(\d{2})(?:[.,](\d+))?(Z|([+-])(\d{2}):(\d{2}))$/;
5
+ function isGoTimeJSON(value) {
6
+ const match = goTimeJSONPattern.exec(value);
7
+ if (!match) return false;
8
+ const [, yearText, monthText, dayText, hourText, minuteText, secondText, , zone, , zoneHourText, zoneMinuteText] = match;
9
+ const year = Number(yearText);
10
+ const month = Number(monthText);
11
+ const day = Number(dayText);
12
+ const isLeap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
13
+ const monthDays = [31, isLeap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
14
+ return month >= 1 && month <= 12 && day >= 1 && day <= monthDays[month - 1] && Number(hourText) <= 23 && Number(minuteText) <= 59 && Number(secondText) <= 59 && (zone === "Z" || Number(zoneHourText) <= 24 && Number(zoneMinuteText) <= 60);
15
+ }
16
+ function canonicalGoTimeJSON(value) {
17
+ const match = goTimeJSONPattern.exec(value);
18
+ const [, year, month, day, hour, minute, second, fraction, zone, sign, zoneHour, zoneMinute] = match;
19
+ const clock = year + "-" + month + "-" + day + "T" + hour.padStart(2, "0") + ":" + minute + ":" + second;
20
+ const digits = (fraction ?? "").slice(0, 9).replace(/0+$/, "");
21
+ const offsetMinutes = zone === "Z" ? 0 : (Number(zoneHour) * 60 + Number(zoneMinute)) * (sign === "+" ? 1 : -1);
22
+ if (Math.abs(offsetMinutes) >= 1440) return value;
23
+ const offset = offsetMinutes === 0 ? "Z" : (offsetMinutes > 0 ? "+" : "-") + String(Math.floor(Math.abs(offsetMinutes) / 60)).padStart(2, "0") + ":" + String(Math.abs(offsetMinutes) % 60).padStart(2, "0");
24
+ return clock + (digits ? "." + digits : "") + offset;
25
+ }
26
+ var GoTimeJSONSchema = z.string().refine(isGoTimeJSON, "invalid Go time.Time JSON timestamp").transform(canonicalGoTimeJSON);
27
+ var ConfigSchema = z.object({
28
+ "accountId": z.string().optional(),
29
+ "maxResponseBytes": z.number().int().optional(),
30
+ "maxDocumentBytes": z.number().int().optional(),
31
+ "connectMaxBodyBytes": z.number().int().optional()
32
+ });
33
+ function decodeCredentials(value) {
34
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("credential fields are invalid");
35
+ const fields = value;
36
+ const allowed = /* @__PURE__ */ new Set(["auth_method", "access_token", "connect_hmac_key", "oauth_client_id", "oauth_client_secret", "refresh_token"]);
37
+ if (Object.keys(fields).some((key) => !allowed.has(key))) throw new TypeError("stored credential does not match the connector credential fields");
38
+ if (fields["access_token"] != null && !(typeof fields["access_token"] === "string")) throw new TypeError("credential access_token has an invalid type");
39
+ if (fields["connect_hmac_key"] != null && !(typeof fields["connect_hmac_key"] === "string")) throw new TypeError("credential connect_hmac_key has an invalid type");
40
+ if (fields["oauth_client_id"] != null && !(typeof fields["oauth_client_id"] === "string")) throw new TypeError("credential oauth_client_id has an invalid type");
41
+ if (fields["oauth_client_secret"] != null && !(typeof fields["oauth_client_secret"] === "string")) throw new TypeError("credential oauth_client_secret has an invalid type");
42
+ if (fields["refresh_token"] != null && !(typeof fields["refresh_token"] === "string")) throw new TypeError("credential refresh_token has an invalid type");
43
+ const selectedMethod = fields["auth_method"] ?? "";
44
+ if (typeof selectedMethod !== "string") throw new TypeError("credential auth_method is invalid");
45
+ const method = selectedMethod || "docusign-oauth";
46
+ const credentials = { authMethodId: method };
47
+ if (method === "docusign-oauth") {
48
+ if (!fields["oauth_client_id"]) throw new TypeError("credential oauth_client_id is required");
49
+ if (fields["oauth_client_id"]) credentials.oauthClientId = fields["oauth_client_id"];
50
+ if (!fields["oauth_client_secret"]) throw new TypeError("credential oauth_client_secret is required");
51
+ if (fields["oauth_client_secret"]) credentials.oauthClientSecret = new SecretString(fields["oauth_client_secret"]);
52
+ if (!fields["access_token"]) throw new TypeError("credential access_token is required");
53
+ if (fields["access_token"]) credentials.accessToken = new SecretString(fields["access_token"]);
54
+ if (!fields["refresh_token"]) throw new TypeError("credential refresh_token is required");
55
+ if (fields["refresh_token"]) credentials.refreshToken = new SecretString(fields["refresh_token"]);
56
+ credentials.connectHmacKey = new SecretString(fields["connect_hmac_key"] ?? "");
57
+ } else if (method === "docusign-developer-oauth") {
58
+ if (!fields["oauth_client_id"]) throw new TypeError("credential oauth_client_id is required");
59
+ if (fields["oauth_client_id"]) credentials.oauthClientId = fields["oauth_client_id"];
60
+ if (!fields["oauth_client_secret"]) throw new TypeError("credential oauth_client_secret is required");
61
+ if (fields["oauth_client_secret"]) credentials.oauthClientSecret = new SecretString(fields["oauth_client_secret"]);
62
+ if (!fields["access_token"]) throw new TypeError("credential access_token is required");
63
+ if (fields["access_token"]) credentials.accessToken = new SecretString(fields["access_token"]);
64
+ if (!fields["refresh_token"]) throw new TypeError("credential refresh_token is required");
65
+ if (fields["refresh_token"]) credentials.refreshToken = new SecretString(fields["refresh_token"]);
66
+ credentials.connectHmacKey = new SecretString(fields["connect_hmac_key"] ?? "");
67
+ } else {
68
+ throw new TypeError("credential auth_method is invalid");
69
+ }
70
+ return credentials;
71
+ }
72
+ function decodeSharedCredentials(value) {
73
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("credential fields are invalid");
74
+ const fields = value;
75
+ const allowed = /* @__PURE__ */ new Set(["auth_method", "access_token", "connect_hmac_key", "oauth_client_id", "oauth_client_secret", "refresh_token"]);
76
+ if (Object.keys(fields).some((key) => !allowed.has(key))) throw new TypeError("stored credential does not match the connector credential fields");
77
+ if (fields["access_token"] != null && !(typeof fields["access_token"] === "string")) throw new TypeError("credential access_token has an invalid type");
78
+ if (fields["connect_hmac_key"] != null && !(typeof fields["connect_hmac_key"] === "string")) throw new TypeError("credential connect_hmac_key has an invalid type");
79
+ if (fields["oauth_client_id"] != null && !(typeof fields["oauth_client_id"] === "string")) throw new TypeError("credential oauth_client_id has an invalid type");
80
+ if (fields["oauth_client_secret"] != null && !(typeof fields["oauth_client_secret"] === "string")) throw new TypeError("credential oauth_client_secret has an invalid type");
81
+ if (fields["refresh_token"] != null && !(typeof fields["refresh_token"] === "string")) throw new TypeError("credential refresh_token has an invalid type");
82
+ const selectedMethod = fields["auth_method"] ?? "";
83
+ if (typeof selectedMethod !== "string") throw new TypeError("credential auth_method is invalid");
84
+ const method = selectedMethod || "docusign-oauth";
85
+ const credentials = { authMethodId: method };
86
+ if (method === "docusign-oauth") {
87
+ if (!fields["oauth_client_id"]) throw new TypeError("credential oauth_client_id is required");
88
+ if (fields["oauth_client_id"]) credentials.oauthClientId = fields["oauth_client_id"];
89
+ if (fields["oauth_client_secret"]) credentials.oauthClientSecret = new SecretString(fields["oauth_client_secret"]);
90
+ if (!fields["access_token"]) throw new TypeError("credential access_token is required");
91
+ if (fields["access_token"]) credentials.accessToken = new SecretString(fields["access_token"]);
92
+ if (fields["refresh_token"]) credentials.refreshToken = new SecretString(fields["refresh_token"]);
93
+ credentials.connectHmacKey = new SecretString(fields["connect_hmac_key"] ?? "");
94
+ } else if (method === "docusign-developer-oauth") {
95
+ if (!fields["oauth_client_id"]) throw new TypeError("credential oauth_client_id is required");
96
+ if (fields["oauth_client_id"]) credentials.oauthClientId = fields["oauth_client_id"];
97
+ if (fields["oauth_client_secret"]) credentials.oauthClientSecret = new SecretString(fields["oauth_client_secret"]);
98
+ if (!fields["access_token"]) throw new TypeError("credential access_token is required");
99
+ if (fields["access_token"]) credentials.accessToken = new SecretString(fields["access_token"]);
100
+ if (fields["refresh_token"]) credentials.refreshToken = new SecretString(fields["refresh_token"]);
101
+ credentials.connectHmacKey = new SecretString(fields["connect_hmac_key"] ?? "");
102
+ } else {
103
+ throw new TypeError("credential auth_method is invalid");
104
+ }
105
+ return credentials;
106
+ }
107
+ var TemplateRoleSchema = z.strictObject({
108
+ "roleName": z.string(),
109
+ "name": z.string(),
110
+ "email": z.string(),
111
+ "routingOrder": z.number().int().optional()
112
+ });
113
+ var EnvelopeCustomFieldSchema = z.strictObject({
114
+ "name": z.string(),
115
+ "value": z.string()
116
+ });
117
+ var CreateEnvelopeFromTemplateInputSchema = z.strictObject({
118
+ "templateId": z.string(),
119
+ "templateRoles": z.array(TemplateRoleSchema).nullable(),
120
+ "emailSubject": z.string().optional(),
121
+ "emailBlurb": z.string().optional(),
122
+ "isDraft": z.boolean().optional(),
123
+ "customFields": z.array(EnvelopeCustomFieldSchema).optional()
124
+ });
125
+ var CreatedEnvelopeSchema = z.strictObject({
126
+ "envelopeId": z.string(),
127
+ "status": z.string(),
128
+ "statusChangedAt": GoTimeJSONSchema.nullable().optional(),
129
+ "wasRecovered": z.boolean().optional()
130
+ });
131
+ var GetEnvelopeInputSchema = z.strictObject({
132
+ "envelopeId": z.string()
133
+ });
134
+ var EnvelopeSchema = z.strictObject({
135
+ "envelopeId": z.string(),
136
+ "status": z.string(),
137
+ "emailSubject": z.string().optional(),
138
+ "createdAt": GoTimeJSONSchema.nullable().optional(),
139
+ "sentAt": GoTimeJSONSchema.nullable().optional(),
140
+ "deliveredAt": GoTimeJSONSchema.nullable().optional(),
141
+ "completedAt": GoTimeJSONSchema.nullable().optional(),
142
+ "declinedAt": GoTimeJSONSchema.nullable().optional(),
143
+ "voidedAt": GoTimeJSONSchema.nullable().optional(),
144
+ "statusChangedAt": GoTimeJSONSchema.nullable().optional(),
145
+ "expiresAt": GoTimeJSONSchema.nullable().optional(),
146
+ "voidedReason": z.string().optional(),
147
+ "customFields": z.array(EnvelopeCustomFieldSchema).optional()
148
+ });
149
+ var ListEnvelopeRecipientsInputSchema = z.strictObject({
150
+ "envelopeId": z.string()
151
+ });
152
+ var RecipientSchema = z.strictObject({
153
+ "recipientId": z.string(),
154
+ "type": z.string(),
155
+ "name": z.string().optional(),
156
+ "email": z.string().optional(),
157
+ "roleName": z.string().optional(),
158
+ "routingOrder": z.number().int(),
159
+ "status": z.string(),
160
+ "sentAt": GoTimeJSONSchema.nullable().optional(),
161
+ "deliveredAt": GoTimeJSONSchema.nullable().optional(),
162
+ "signedAt": GoTimeJSONSchema.nullable().optional(),
163
+ "declinedAt": GoTimeJSONSchema.nullable().optional(),
164
+ "declinedReason": z.string().optional()
165
+ });
166
+ var EnvelopeRecipientsSchema = z.strictObject({
167
+ "envelopeId": z.string(),
168
+ "currentRoutingOrder": z.number().int().optional(),
169
+ "recipients": z.array(RecipientSchema).nullable()
170
+ });
171
+ var VoidEnvelopeInputSchema = z.strictObject({
172
+ "envelopeId": z.string(),
173
+ "voidedReason": z.string()
174
+ });
175
+ var VoidedEnvelopeSchema = z.strictObject({
176
+ "envelopeId": z.string(),
177
+ "wasAlreadyVoided": z.boolean().optional(),
178
+ "status": z.string().optional(),
179
+ "voidedReason": z.string().optional()
180
+ });
181
+ var DownloadCombinedDocumentInputSchema = z.strictObject({
182
+ "envelopeId": z.string(),
183
+ "includeCertificate": z.boolean().optional()
184
+ });
185
+ var CombinedDocumentSchema = z.strictObject({
186
+ "envelopeId": z.string(),
187
+ "contentType": z.string(),
188
+ "byteCount": z.number().int(),
189
+ "sha256": z.string(),
190
+ "includesCertificate": z.boolean().optional(),
191
+ "storedLocation": z.string().optional()
192
+ });
193
+
194
+ // src/generated/definitions.ts
195
+ var ConnectorID = "docusign";
196
+ var ProviderID = "docusign";
197
+ var CreateEnvelopeFromTemplateBranch = {
198
+ Created: "created",
199
+ ProviderRejected: "providerRejected",
200
+ Uncertain: "uncertain",
201
+ Defect: "defect"
202
+ };
203
+ var CreateEnvelopeFromTemplateBranchCreated = CreateEnvelopeFromTemplateBranch.Created;
204
+ var CreateEnvelopeFromTemplateBranchProviderRejected = CreateEnvelopeFromTemplateBranch.ProviderRejected;
205
+ var CreateEnvelopeFromTemplateBranchUncertain = CreateEnvelopeFromTemplateBranch.Uncertain;
206
+ var CreateEnvelopeFromTemplateBranchDefect = CreateEnvelopeFromTemplateBranch.Defect;
207
+ var CreateEnvelopeFromTemplateDefinition = {
208
+ operation: { connectorId: ConnectorID, operationId: "createEnvelopeFromTemplate" },
209
+ branches: [
210
+ { id: "created", description: "DocuSign holds the envelope this Step execution created; wasRecovered tells whether a later attempt found it by its custom field after an interrupted one." },
211
+ { id: "providerRejected", description: "DocuSign conclusively rejected the envelope, such as an unknown template, an unfilled or unknown role, an invalid email address, an exhausted envelope allowance, or a user who may not send; nothing was created.", optional: true },
212
+ { id: "uncertain", description: "The create request was sent but DocuSign's answer was lost, a server error, or unreadable, and no envelope with this Step's custom field could be found, so an envelope may exist that this Result does not name; do not create another automatically.", optional: true },
213
+ { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
214
+ ],
215
+ stepDefaults: { executeMethodTimeoutMs: 6e4, executeDurability: "sync", executeRetry: { initialIntervalMs: 1e3, backoffCoefficient: 2, maximumIntervalMs: 6e4, maximumAttempts: 6, totalDurationMs: 39e5 } },
216
+ repeatOnUnknown: "limited",
217
+ maxSends: 3
218
+ };
219
+ var CreateEnvelopeFromTemplateMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
220
+ var GetEnvelopeBranch = {
221
+ Found: "found",
222
+ NotFound: "notFound",
223
+ ProviderRejected: "providerRejected",
224
+ InvalidResponse: "invalidResponse",
225
+ Defect: "defect"
226
+ };
227
+ var GetEnvelopeBranchFound = GetEnvelopeBranch.Found;
228
+ var GetEnvelopeBranchNotFound = GetEnvelopeBranch.NotFound;
229
+ var GetEnvelopeBranchProviderRejected = GetEnvelopeBranch.ProviderRejected;
230
+ var GetEnvelopeBranchInvalidResponse = GetEnvelopeBranch.InvalidResponse;
231
+ var GetEnvelopeBranchDefect = GetEnvelopeBranch.Defect;
232
+ var GetEnvelopeDefinition = {
233
+ operation: { connectorId: ConnectorID, operationId: "getEnvelope" },
234
+ branches: [
235
+ { id: "found", description: "DocuSign returned the envelope." },
236
+ { id: "notFound", description: "The envelope does not exist in the connection's account or the user may not see it.", optional: true },
237
+ { id: "providerRejected", description: "DocuSign conclusively rejected the read, such as a revoked consent or a user without access to the account.", optional: true },
238
+ { id: "invalidResponse", description: "DocuSign returned a malformed or oversized response.", optional: true },
239
+ { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
240
+ ],
241
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async", executeRetry: { initialIntervalMs: 1e3, backoffCoefficient: 2, maximumIntervalMs: 6e4, maximumAttempts: 0, totalDurationMs: 39e5 } }
242
+ };
243
+ var GetEnvelopeMetadata = { kind: "query", idempotency: "none", authorization: "required" };
244
+ var ListEnvelopeRecipientsBranch = {
245
+ Listed: "listed",
246
+ NotFound: "notFound",
247
+ ProviderRejected: "providerRejected",
248
+ InvalidResponse: "invalidResponse",
249
+ Defect: "defect"
250
+ };
251
+ var ListEnvelopeRecipientsBranchListed = ListEnvelopeRecipientsBranch.Listed;
252
+ var ListEnvelopeRecipientsBranchNotFound = ListEnvelopeRecipientsBranch.NotFound;
253
+ var ListEnvelopeRecipientsBranchProviderRejected = ListEnvelopeRecipientsBranch.ProviderRejected;
254
+ var ListEnvelopeRecipientsBranchInvalidResponse = ListEnvelopeRecipientsBranch.InvalidResponse;
255
+ var ListEnvelopeRecipientsBranchDefect = ListEnvelopeRecipientsBranch.Defect;
256
+ var ListEnvelopeRecipientsDefinition = {
257
+ operation: { connectorId: ConnectorID, operationId: "listEnvelopeRecipients" },
258
+ branches: [
259
+ { id: "listed", description: "DocuSign returned the envelope's recipients." },
260
+ { id: "notFound", description: "The envelope does not exist in the connection's account or the user may not see it.", optional: true },
261
+ { id: "providerRejected", description: "DocuSign conclusively rejected the read, such as a revoked consent or a user without access to the account.", optional: true },
262
+ { id: "invalidResponse", description: "DocuSign returned a malformed or oversized response.", optional: true },
263
+ { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
264
+ ],
265
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async", executeRetry: { initialIntervalMs: 1e3, backoffCoefficient: 2, maximumIntervalMs: 6e4, maximumAttempts: 0, totalDurationMs: 39e5 } }
266
+ };
267
+ var ListEnvelopeRecipientsMetadata = { kind: "query", idempotency: "none", authorization: "required" };
268
+ var VoidEnvelopeBranch = {
269
+ Voided: "voided",
270
+ NotVoidable: "notVoidable",
271
+ NotFound: "notFound",
272
+ ProviderRejected: "providerRejected",
273
+ InvalidResponse: "invalidResponse",
274
+ Defect: "defect"
275
+ };
276
+ var VoidEnvelopeBranchVoided = VoidEnvelopeBranch.Voided;
277
+ var VoidEnvelopeBranchNotVoidable = VoidEnvelopeBranch.NotVoidable;
278
+ var VoidEnvelopeBranchNotFound = VoidEnvelopeBranch.NotFound;
279
+ var VoidEnvelopeBranchProviderRejected = VoidEnvelopeBranch.ProviderRejected;
280
+ var VoidEnvelopeBranchInvalidResponse = VoidEnvelopeBranch.InvalidResponse;
281
+ var VoidEnvelopeBranchDefect = VoidEnvelopeBranch.Defect;
282
+ var VoidEnvelopeDefinition = {
283
+ operation: { connectorId: ConnectorID, operationId: "voidEnvelope" },
284
+ branches: [
285
+ { id: "voided", description: "The envelope is voided, by this call or earlier; wasAlreadyVoided tells which." },
286
+ { id: "notVoidable", description: "The envelope is completed, declined, or still a draft, which DocuSign does not void; status names which.", optional: true },
287
+ { id: "notFound", description: "The envelope does not exist in the connection's account or the user may not see it.", optional: true },
288
+ { id: "providerRejected", description: "DocuSign conclusively rejected the void, such as a user who is not the sender or lacks permission.", optional: true },
289
+ { id: "invalidResponse", description: "DocuSign returned a malformed or oversized response.", optional: true },
290
+ { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
291
+ ],
292
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async", executeRetry: { initialIntervalMs: 1e3, backoffCoefficient: 2, maximumIntervalMs: 6e4, maximumAttempts: 0, totalDurationMs: 39e5 } },
293
+ repeatOnUnknown: "limited",
294
+ maxSends: 3
295
+ };
296
+ var VoidEnvelopeMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
297
+ var DownloadCombinedDocumentBranch = {
298
+ Downloaded: "downloaded",
299
+ NotFound: "notFound",
300
+ TooLarge: "tooLarge",
301
+ ProviderRejected: "providerRejected",
302
+ InvalidResponse: "invalidResponse",
303
+ Defect: "defect"
304
+ };
305
+ var DownloadCombinedDocumentBranchDownloaded = DownloadCombinedDocumentBranch.Downloaded;
306
+ var DownloadCombinedDocumentBranchNotFound = DownloadCombinedDocumentBranch.NotFound;
307
+ var DownloadCombinedDocumentBranchTooLarge = DownloadCombinedDocumentBranch.TooLarge;
308
+ var DownloadCombinedDocumentBranchProviderRejected = DownloadCombinedDocumentBranch.ProviderRejected;
309
+ var DownloadCombinedDocumentBranchInvalidResponse = DownloadCombinedDocumentBranch.InvalidResponse;
310
+ var DownloadCombinedDocumentBranchDefect = DownloadCombinedDocumentBranch.Defect;
311
+ var DownloadCombinedDocumentDefinition = {
312
+ operation: { connectorId: ConnectorID, operationId: "downloadCombinedDocument" },
313
+ branches: [
314
+ { id: "downloaded", description: "DocuSign returned the combined PDF and its digest was recorded, and stored when the client has a CombinedDocumentStore." },
315
+ { id: "notFound", description: "The envelope does not exist in the connection's account or the user may not see it.", optional: true },
316
+ { id: "tooLarge", description: "The combined PDF exceeds the connection's maxDocumentBytes; nothing was stored.", optional: true },
317
+ { id: "providerRejected", description: "DocuSign conclusively rejected the download, such as a revoked consent or a user without access to the envelope.", optional: true },
318
+ { id: "invalidResponse", description: "DocuSign returned something other than a complete PDF, or the CombinedDocumentStore rejected it.", optional: true },
319
+ { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
320
+ ],
321
+ stepDefaults: { executeMethodTimeoutMs: 12e4, executeDurability: "async", executeRetry: { initialIntervalMs: 1e3, backoffCoefficient: 2, maximumIntervalMs: 6e4, maximumAttempts: 0, totalDurationMs: 39e5 } }
322
+ };
323
+ var DownloadCombinedDocumentMetadata = { kind: "query", idempotency: "none", authorization: "required" };
324
+
325
+ // src/generated/connection.ts
326
+ import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
327
+ import { newRefreshingCredentialProvider } from "@superdurable/connectors-sdk/projectconfig";
328
+ var Connection = class {
329
+ /** Stable provider and connection name. */
330
+ reference;
331
+ /** Bound provider operations. */
332
+ operations;
333
+ /** Validate a reference and bind operations. */
334
+ constructor(reference, operations) {
335
+ this.reference = ConnectionRefSchema.parse(reference);
336
+ if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
337
+ if (!operations) throw new TypeError("connector operations are required");
338
+ this.operations = operations;
339
+ }
340
+ };
341
+ function newConnection(client, reference) {
342
+ if (!client) throw new TypeError("connector client is required");
343
+ return new Connection(reference, client);
344
+ }
345
+ function newConnectionWithOperations(operations, reference) {
346
+ return new Connection(reference, operations);
347
+ }
348
+ function newProjectConnection(project, connectionName, createClient) {
349
+ if (!project) throw new TypeError("loaded project is required");
350
+ const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
351
+ const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
352
+ if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
353
+ return newConnection(createClient(project, connectionName), reference);
354
+ }
355
+ function newProjectCredentialProvider(project, connectionName, decode, encode, decodeShared) {
356
+ return newRefreshingCredentialProvider(project.connections, { connectorId: ConnectorID, connectionName }, decode, encode, decodeShared);
357
+ }
358
+
359
+ export {
360
+ ConfigSchema,
361
+ decodeCredentials,
362
+ decodeSharedCredentials,
363
+ TemplateRoleSchema,
364
+ EnvelopeCustomFieldSchema,
365
+ CreateEnvelopeFromTemplateInputSchema,
366
+ CreatedEnvelopeSchema,
367
+ GetEnvelopeInputSchema,
368
+ EnvelopeSchema,
369
+ ListEnvelopeRecipientsInputSchema,
370
+ RecipientSchema,
371
+ EnvelopeRecipientsSchema,
372
+ VoidEnvelopeInputSchema,
373
+ VoidedEnvelopeSchema,
374
+ DownloadCombinedDocumentInputSchema,
375
+ CombinedDocumentSchema,
376
+ ConnectorID,
377
+ ProviderID,
378
+ CreateEnvelopeFromTemplateBranch,
379
+ CreateEnvelopeFromTemplateBranchCreated,
380
+ CreateEnvelopeFromTemplateBranchProviderRejected,
381
+ CreateEnvelopeFromTemplateBranchUncertain,
382
+ CreateEnvelopeFromTemplateBranchDefect,
383
+ CreateEnvelopeFromTemplateDefinition,
384
+ CreateEnvelopeFromTemplateMetadata,
385
+ GetEnvelopeBranch,
386
+ GetEnvelopeBranchFound,
387
+ GetEnvelopeBranchNotFound,
388
+ GetEnvelopeBranchProviderRejected,
389
+ GetEnvelopeBranchInvalidResponse,
390
+ GetEnvelopeBranchDefect,
391
+ GetEnvelopeDefinition,
392
+ GetEnvelopeMetadata,
393
+ ListEnvelopeRecipientsBranch,
394
+ ListEnvelopeRecipientsBranchListed,
395
+ ListEnvelopeRecipientsBranchNotFound,
396
+ ListEnvelopeRecipientsBranchProviderRejected,
397
+ ListEnvelopeRecipientsBranchInvalidResponse,
398
+ ListEnvelopeRecipientsBranchDefect,
399
+ ListEnvelopeRecipientsDefinition,
400
+ ListEnvelopeRecipientsMetadata,
401
+ VoidEnvelopeBranch,
402
+ VoidEnvelopeBranchVoided,
403
+ VoidEnvelopeBranchNotVoidable,
404
+ VoidEnvelopeBranchNotFound,
405
+ VoidEnvelopeBranchProviderRejected,
406
+ VoidEnvelopeBranchInvalidResponse,
407
+ VoidEnvelopeBranchDefect,
408
+ VoidEnvelopeDefinition,
409
+ VoidEnvelopeMetadata,
410
+ DownloadCombinedDocumentBranch,
411
+ DownloadCombinedDocumentBranchDownloaded,
412
+ DownloadCombinedDocumentBranchNotFound,
413
+ DownloadCombinedDocumentBranchTooLarge,
414
+ DownloadCombinedDocumentBranchProviderRejected,
415
+ DownloadCombinedDocumentBranchInvalidResponse,
416
+ DownloadCombinedDocumentBranchDefect,
417
+ DownloadCombinedDocumentDefinition,
418
+ DownloadCombinedDocumentMetadata,
419
+ Connection,
420
+ newConnection,
421
+ newConnectionWithOperations,
422
+ newProjectConnection,
423
+ newProjectCredentialProvider
424
+ };