@superdurable/connector-constantcontact 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.
package/dist/index.js ADDED
@@ -0,0 +1,1691 @@
1
+ import {
2
+ ActivitiesPageSchema,
3
+ ActivityMetadataSchema,
4
+ ConfigSchema,
5
+ Connection,
6
+ ConnectorID,
7
+ ContactListMetadataSchema,
8
+ ContactListsPageSchema,
9
+ ContactMetadataSchema,
10
+ ContactsPageSchema,
11
+ CreateContactBranch,
12
+ CreateContactBranchAlreadyExists,
13
+ CreateContactBranchCreated,
14
+ CreateContactBranchDefect,
15
+ CreateContactBranchProviderRejected,
16
+ CreateContactBranchUncertain,
17
+ CreateContactDefinition,
18
+ CreateContactInputSchema,
19
+ CreateContactListBranch,
20
+ CreateContactListBranchAlreadyExists,
21
+ CreateContactListBranchCreated,
22
+ CreateContactListBranchDefect,
23
+ CreateContactListBranchProviderRejected,
24
+ CreateContactListBranchUncertain,
25
+ CreateContactListDefinition,
26
+ CreateContactListInputSchema,
27
+ CreateContactListMetadata,
28
+ CreateContactMetadata,
29
+ CreateSegmentBranch,
30
+ CreateSegmentBranchAlreadyExists,
31
+ CreateSegmentBranchCreated,
32
+ CreateSegmentBranchDefect,
33
+ CreateSegmentBranchProviderRejected,
34
+ CreateSegmentBranchUncertain,
35
+ CreateSegmentDefinition,
36
+ CreateSegmentInputSchema,
37
+ CreateSegmentMetadata,
38
+ CredentialMaterialError,
39
+ DeleteContactBranch,
40
+ DeleteContactBranchDefect,
41
+ DeleteContactBranchDeleted,
42
+ DeleteContactBranchNotFound,
43
+ DeleteContactBranchProviderRejected,
44
+ DeleteContactDefinition,
45
+ DeleteContactInputSchema,
46
+ DeleteContactListBranch,
47
+ DeleteContactListBranchAccepted,
48
+ DeleteContactListBranchDefect,
49
+ DeleteContactListBranchNotFound,
50
+ DeleteContactListBranchProviderRejected,
51
+ DeleteContactListDefinition,
52
+ DeleteContactListInputSchema,
53
+ DeleteContactListMetadata,
54
+ DeleteContactListOutputSchema,
55
+ DeleteContactMetadata,
56
+ DeleteContactOutputSchema,
57
+ DeleteSegmentBranch,
58
+ DeleteSegmentBranchDefect,
59
+ DeleteSegmentBranchDeleted,
60
+ DeleteSegmentBranchNotFound,
61
+ DeleteSegmentBranchProviderRejected,
62
+ DeleteSegmentDefinition,
63
+ DeleteSegmentInputSchema,
64
+ DeleteSegmentMetadata,
65
+ DeleteSegmentOutputSchema,
66
+ GetActivityBranch,
67
+ GetActivityBranchDefect,
68
+ GetActivityBranchFound,
69
+ GetActivityBranchInvalidResponse,
70
+ GetActivityBranchNotFound,
71
+ GetActivityBranchProviderRejected,
72
+ GetActivityDefinition,
73
+ GetActivityInputSchema,
74
+ GetActivityMetadata,
75
+ GetContactBranch,
76
+ GetContactBranchDefect,
77
+ GetContactBranchFound,
78
+ GetContactBranchInvalidResponse,
79
+ GetContactBranchNotFound,
80
+ GetContactBranchProviderRejected,
81
+ GetContactDefinition,
82
+ GetContactInputSchema,
83
+ GetContactListBranch,
84
+ GetContactListBranchDefect,
85
+ GetContactListBranchFound,
86
+ GetContactListBranchInvalidResponse,
87
+ GetContactListBranchNotFound,
88
+ GetContactListBranchProviderRejected,
89
+ GetContactListDefinition,
90
+ GetContactListInputSchema,
91
+ GetContactListMetadata,
92
+ GetContactMetadata,
93
+ GetSegmentBranch,
94
+ GetSegmentBranchDefect,
95
+ GetSegmentBranchFound,
96
+ GetSegmentBranchInvalidResponse,
97
+ GetSegmentBranchNotFound,
98
+ GetSegmentBranchProviderRejected,
99
+ GetSegmentDefinition,
100
+ GetSegmentInputSchema,
101
+ GetSegmentMetadata,
102
+ ListActivitiesBranch,
103
+ ListActivitiesBranchDefect,
104
+ ListActivitiesBranchInvalidResponse,
105
+ ListActivitiesBranchListed,
106
+ ListActivitiesBranchProviderRejected,
107
+ ListActivitiesDefinition,
108
+ ListActivitiesInputSchema,
109
+ ListActivitiesMetadata,
110
+ ListContactListsBranch,
111
+ ListContactListsBranchDefect,
112
+ ListContactListsBranchInvalidResponse,
113
+ ListContactListsBranchListed,
114
+ ListContactListsBranchProviderRejected,
115
+ ListContactListsDefinition,
116
+ ListContactListsInputSchema,
117
+ ListContactListsMetadata,
118
+ ListContactsBranch,
119
+ ListContactsBranchDefect,
120
+ ListContactsBranchInvalidResponse,
121
+ ListContactsBranchListed,
122
+ ListContactsBranchProviderRejected,
123
+ ListContactsDefinition,
124
+ ListContactsInputSchema,
125
+ ListContactsMetadata,
126
+ ListSegmentsBranch,
127
+ ListSegmentsBranchDefect,
128
+ ListSegmentsBranchInvalidResponse,
129
+ ListSegmentsBranchListed,
130
+ ListSegmentsBranchProviderRejected,
131
+ ListSegmentsDefinition,
132
+ ListSegmentsInputSchema,
133
+ ListSegmentsMetadata,
134
+ ProviderID,
135
+ SegmentMetadataSchema,
136
+ SegmentsPageSchema,
137
+ UpdateContactBranch,
138
+ UpdateContactBranchDefect,
139
+ UpdateContactBranchInvalidResponse,
140
+ UpdateContactBranchNotFound,
141
+ UpdateContactBranchProviderRejected,
142
+ UpdateContactBranchUpdated,
143
+ UpdateContactDefinition,
144
+ UpdateContactInputSchema,
145
+ UpdateContactListBranch,
146
+ UpdateContactListBranchDefect,
147
+ UpdateContactListBranchNotFound,
148
+ UpdateContactListBranchProviderRejected,
149
+ UpdateContactListBranchUpdated,
150
+ UpdateContactListDefinition,
151
+ UpdateContactListInputSchema,
152
+ UpdateContactListMetadata,
153
+ UpdateContactMetadata,
154
+ UpdateSegmentBranch,
155
+ UpdateSegmentBranchDefect,
156
+ UpdateSegmentBranchInvalidResponse,
157
+ UpdateSegmentBranchNotFound,
158
+ UpdateSegmentBranchProviderRejected,
159
+ UpdateSegmentBranchUpdated,
160
+ UpdateSegmentDefinition,
161
+ UpdateSegmentInputSchema,
162
+ UpdateSegmentMetadata,
163
+ decodeCredentials,
164
+ decodeSharedCredentials,
165
+ decodeSignedInteger,
166
+ exactIntegerJSONCodec,
167
+ isCredentialMaterialError,
168
+ newConnection,
169
+ newConnectionWithOperations,
170
+ newProjectCredentialProvider,
171
+ parseExactIntegerJSON,
172
+ parseJSONNumberTokens
173
+ } from "./chunk-65ID4QLZ.js";
174
+
175
+ // src/client.ts
176
+ import {
177
+ ReauthorizationRequiredError,
178
+ SecretString,
179
+ newQueryBranch as newQueryBranch2,
180
+ newQueryRetry as newQueryRetry2,
181
+ resolveCredential
182
+ } from "@superdurable/connectors-sdk";
183
+ import { ManifestCredentialRefreshDriver } from "@superdurable/connectors-sdk/oauthtoken";
184
+ import {
185
+ BodyTooLargeError,
186
+ ProviderTransportError,
187
+ isHeaderSafeCredential,
188
+ parseRetryAfter,
189
+ sendProviderRequest,
190
+ validateBaseURL
191
+ } from "@superdurable/connectors-sdk/providerhttp";
192
+
193
+ // src/management.ts
194
+ import { isIP } from "net";
195
+ import {
196
+ definitionMaxSends,
197
+ newMutationBranch,
198
+ newMutationRetry,
199
+ newMutationUncertain,
200
+ newQueryBranch,
201
+ newQueryRetry
202
+ } from "@superdurable/connectors-sdk";
203
+ import { CheckpointError, DispatchNotAllowedError, InsufficientTimeError, newFence } from "@superdurable/connectors-sdk/singledispatch";
204
+
205
+ // src/wire.ts
206
+ var contactIDPattern = /^[a-fA-F0-9]{8}-(?:[a-fA-F0-9]{4}-){3}[a-fA-F0-9]{12}$(?![\s\S])/;
207
+ function isObject(value) {
208
+ return typeof value === "object" && value !== null && !Array.isArray(value);
209
+ }
210
+ function optionalString(value) {
211
+ return value === void 0 || value === null || value === "" ? void 0 : typeof value === "string" ? value : void 0;
212
+ }
213
+ function decodeContactDocument(raw) {
214
+ if (!isObject(raw) || typeof raw.contact_id !== "string" || !contactIDPattern.test(raw.contact_id)) return void 0;
215
+ const email = raw.email_address ?? {};
216
+ if (!isObject(email)) return void 0;
217
+ const fields = [raw.first_name, raw.last_name, email.address, email.permission_to_send];
218
+ if (fields.some((value) => value !== void 0 && value !== null && typeof value !== "string")) return void 0;
219
+ const result = { contactId: raw.contact_id };
220
+ const address = optionalString(email.address);
221
+ const firstName = optionalString(raw.first_name);
222
+ const lastName = optionalString(raw.last_name);
223
+ const permission = optionalString(email.permission_to_send);
224
+ if (address) result.emailAddress = address;
225
+ if (firstName) result.firstName = firstName;
226
+ if (lastName) result.lastName = lastName;
227
+ if (permission) result.emailPermission = permission;
228
+ return result;
229
+ }
230
+
231
+ // src/management.ts
232
+ var Operation = class {
233
+ constructor(client) {
234
+ this.client = client;
235
+ }
236
+ client;
237
+ failure(outcome) {
238
+ return { provider: "constantcontact", operation: this.operation, kind: outcome.kind, message: outcome.message };
239
+ }
240
+ };
241
+ var ReadOperation = class extends Operation {
242
+ /** Return the manifest-generated Query definition. */
243
+ definition() {
244
+ return this.contract;
245
+ }
246
+ defect(empty, message) {
247
+ return newQueryBranch("defect", empty, {}, this.failure({ kind: "VALIDATION", message }));
248
+ }
249
+ async read(call, path, branch, empty, decode) {
250
+ const exchange = await this.client.request(call, "GET", path);
251
+ let outcome = responseFailure(this.operation, exchange, branch === "found");
252
+ if (!outcome) {
253
+ if (exchange.status !== 200) outcome = rejected(exchange.status, branch === "found");
254
+ else {
255
+ try {
256
+ return newQueryBranch(branch, decode(parseProviderJSON(exchange)));
257
+ } catch {
258
+ outcome = { branch: "invalidResponse", kind: "PROTOCOL", message: "Constant Contact response is invalid" };
259
+ }
260
+ }
261
+ }
262
+ return outcome.branch ? newQueryBranch(outcome.branch, empty, {}, this.failure(outcome)) : newQueryRetry(this.failure(outcome), outcome.delay);
263
+ }
264
+ };
265
+ var WriteOperation = class extends Operation {
266
+ /** Return the manifest-generated Mutation definition. */
267
+ definition() {
268
+ return this.contract;
269
+ }
270
+ /** Correlate every attempt with its original call. */
271
+ idempotencyKey(callId) {
272
+ return callId;
273
+ }
274
+ outcome(empty, outcome) {
275
+ if (outcome.branch === "uncertain") return newMutationUncertain(empty, this.failure(outcome));
276
+ if (outcome.branch) return newMutationBranch(outcome.branch, empty, {}, this.failure(outcome));
277
+ return newMutationRetry(this.failure(outcome), outcome.delay);
278
+ }
279
+ defect(empty, message) {
280
+ return this.outcome(empty, { branch: "defect", kind: "VALIDATION", message });
281
+ }
282
+ async write(call, request) {
283
+ const exchange = await this.client.request(call, request.method, request.path, request.payload);
284
+ let outcome = responseFailure(this.operation, exchange, true, true);
285
+ if (!outcome) {
286
+ if (!request.statuses.includes(exchange.status)) outcome = {
287
+ kind: "AVAILABILITY",
288
+ message: "Constant Contact write outcome is unknown",
289
+ delay: exchange.retryAfterMs
290
+ };
291
+ else {
292
+ try {
293
+ const raw = exchange.status === 204 ? void 0 : parseProviderJSON(exchange);
294
+ return newMutationBranch(request.branch, request.decode(raw));
295
+ } catch {
296
+ outcome = {
297
+ kind: "PROTOCOL",
298
+ message: "Constant Contact write response is invalid",
299
+ delay: request.protocolDelay ? exchange.retryAfterMs : 0
300
+ };
301
+ }
302
+ }
303
+ }
304
+ return this.outcome(request.empty, outcome);
305
+ }
306
+ async create(call, request) {
307
+ const { empty, subject } = request;
308
+ const maxSends = call.maxSendsOverride ?? definitionMaxSends(this.contract);
309
+ let fence;
310
+ try {
311
+ fence = newFence(call, this.contract.stepDefaults.executeMethodTimeoutMs, { maxSends });
312
+ } catch {
313
+ return this.outcome(empty, { branch: "defect", kind: "LOCAL_DEFECT", message: "dispatch fence unavailable" });
314
+ }
315
+ const decision = await fence.decide();
316
+ const checkpoint = { kind: "AVAILABILITY", message: "dispatch checkpoint unavailable" };
317
+ const uncertain = { branch: "uncertain", kind: "TRANSPORT", message: `previous ${subject} creation cannot be confirmed` };
318
+ if (decision.kind === "failClosed") return this.outcome(empty, checkpoint);
319
+ const priorSends = decision.priorSendUpperBound ?? 0;
320
+ if (priorSends || decision.kind !== "sendAllowed") {
321
+ let recovered;
322
+ try {
323
+ recovered = await request.readBack(this.client, call, request.input);
324
+ } catch {
325
+ return this.outcome(empty, { kind: "AVAILABILITY", message: `${subject} read-back unavailable` });
326
+ }
327
+ if (recovered !== void 0 && request.identify(recovered) === decision.marker?.providerId)
328
+ return newMutationBranch("created", recovered);
329
+ if (decision.kind === "readBackRequired") return this.outcome(empty, uncertain);
330
+ }
331
+ const dispatch = await this.client.prepareRequest(call, "POST", request.path, request.payload);
332
+ if (typeof dispatch !== "function") {
333
+ try {
334
+ await fence.recordNotSent();
335
+ } catch {
336
+ if (subject === "segment") return this.outcome(empty, checkpoint);
337
+ }
338
+ if (dispatch.error === "credential" && !priorSends) return this.outcome(empty, {
339
+ branch: "defect",
340
+ kind: "AUTHENTICATION",
341
+ message: "Constant Contact credentials are unavailable or invalid"
342
+ });
343
+ return this.outcome(empty, { kind: "AVAILABILITY", message: "Constant Contact credentials could not be refreshed" });
344
+ }
345
+ let exchange;
346
+ try {
347
+ exchange = await fence.dispatch(dispatch);
348
+ } catch (error) {
349
+ if (error instanceof CheckpointError || error instanceof DispatchNotAllowedError || error instanceof InsufficientTimeError)
350
+ return this.outcome(empty, checkpoint);
351
+ return this.outcome(empty, { kind: "TRANSPORT", message: `${subject} creation outcome is unknown` });
352
+ }
353
+ if (exchange.status === 429 || exchange.status === 503) {
354
+ if (!await recordRefusal(fence)) return this.outcome(empty, checkpoint);
355
+ return this.outcome(empty, {
356
+ kind: exchange.status === 429 ? "RATE_LIMIT" : "AVAILABILITY",
357
+ message: `Constant Contact did not create the ${subject}`,
358
+ delay: exchange.retryAfterMs
359
+ });
360
+ }
361
+ if (exchange.error || exchange.status === 408 || exchange.status >= 500)
362
+ return this.outcome(empty, { kind: "TRANSPORT", message: `${subject} creation outcome is unknown` });
363
+ if (exchange.status >= 400) {
364
+ if (priorSends || !definiteRefusal(exchange)) return this.outcome(empty, priorSends + 1 >= maxSends ? uncertain : { kind: "AVAILABILITY", message: `${subject} creation outcome is unknown` });
365
+ if (!await recordRefusal(fence)) return this.outcome(empty, checkpoint);
366
+ return this.outcome(empty, rejected(exchange.status, false, "PROVIDER_REJECTION"));
367
+ }
368
+ let output;
369
+ try {
370
+ if (exchange.status !== 200 && exchange.status !== 201) throw new Error("unexpected creation status");
371
+ output = request.decode(parseProviderJSON(exchange));
372
+ } catch {
373
+ return this.outcome(empty, { kind: "PROTOCOL", message: `${subject} creation response is invalid` });
374
+ }
375
+ try {
376
+ await fence.recordProviderId(request.identify(output));
377
+ } catch {
378
+ if (subject === "segment") return this.outcome(empty, checkpoint);
379
+ }
380
+ return newMutationBranch("created", output);
381
+ }
382
+ };
383
+ var GetSegmentOperation = class extends ReadOperation {
384
+ contract = GetSegmentDefinition;
385
+ operation = "getSegment";
386
+ /** Bind the provider client. */
387
+ constructor(client) {
388
+ super(client);
389
+ }
390
+ /** Read a segment and its complete selection criteria. */
391
+ async invoke(call, input) {
392
+ const empty = { segmentId: 0, name: "" };
393
+ const id = segmentID(input.segmentId);
394
+ if (!id) return this.defect(empty, "segment ID must be positive");
395
+ return this.read(call, "/segments/" + id, "found", empty, fullSegment);
396
+ }
397
+ };
398
+ var ListSegmentsOperation = class extends ReadOperation {
399
+ contract = ListSegmentsDefinition;
400
+ operation = "listSegments";
401
+ /** Bind the provider client. */
402
+ constructor(client) {
403
+ super(client);
404
+ }
405
+ /** Read a bounded page of segments. */
406
+ async invoke(call, input) {
407
+ const empty = { segments: [] };
408
+ const { limit = 0, cursor: next = "", sortBy = "" } = input;
409
+ if (!range(limit, 1e3) || !["", "date", "name"].includes(sortBy) || !bounded(next, 4096))
410
+ return this.defect(empty, "invalid segment page options");
411
+ return this.read(call, pathWith("/segments", { limit, next, sort_by: sortBy }), "listed", empty, segmentsPage);
412
+ }
413
+ };
414
+ var CreateSegmentOperation = class extends WriteOperation {
415
+ contract = CreateSegmentDefinition;
416
+ operation = "createSegment";
417
+ /** Bind the provider client. */
418
+ constructor(client) {
419
+ super(client);
420
+ }
421
+ /** Create a uniquely named segment with complete selection criteria. */
422
+ async invoke(call, input) {
423
+ const empty = { segmentId: 0, name: "" };
424
+ if (!validSegment(input.name, input.segmentCriteria)) return this.defect(empty, "invalid segment settings");
425
+ return this.create(call, {
426
+ path: "/segments",
427
+ payload: segmentPayload(input),
428
+ empty,
429
+ decode: fullSegment,
430
+ input,
431
+ readBack: findSegment,
432
+ identify: (value) => segmentID(value.segmentId),
433
+ subject: "segment"
434
+ });
435
+ }
436
+ };
437
+ var UpdateSegmentOperation = class extends WriteOperation {
438
+ contract = UpdateSegmentDefinition;
439
+ operation = "updateSegment";
440
+ /** Bind the provider client. */
441
+ constructor(client) {
442
+ super(client);
443
+ }
444
+ /** Replace one segment's name and complete criteria. */
445
+ async invoke(call, input) {
446
+ const empty = { segmentId: 0, name: "" };
447
+ const id = segmentID(input.segmentId);
448
+ if (!id || !validSegment(input.name, input.segmentCriteria)) return this.defect(empty, "invalid segment settings");
449
+ return this.write(call, {
450
+ method: "PUT",
451
+ path: "/segments/" + id,
452
+ branch: "updated",
453
+ empty,
454
+ decode: fullSegment,
455
+ statuses: [200],
456
+ payload: segmentPayload(input),
457
+ protocolDelay: true
458
+ });
459
+ }
460
+ };
461
+ var DeleteSegmentOperation = class extends WriteOperation {
462
+ contract = DeleteSegmentDefinition;
463
+ operation = "deleteSegment";
464
+ /** Bind the provider client. */
465
+ constructor(client) {
466
+ super(client);
467
+ }
468
+ /** Remove one segment from the active collection. */
469
+ async invoke(call, input) {
470
+ const empty = { segmentId: 0 };
471
+ const id = segmentID(input.segmentId);
472
+ if (!id) return this.defect(empty, "segment ID must be positive");
473
+ return this.write(call, {
474
+ method: "DELETE",
475
+ path: "/segments/" + id,
476
+ branch: "deleted",
477
+ empty,
478
+ decode: () => ({ segmentId: input.segmentId }),
479
+ statuses: [204]
480
+ });
481
+ }
482
+ };
483
+ var GetActivityOperation = class extends ReadOperation {
484
+ contract = GetActivityDefinition;
485
+ operation = "getActivity";
486
+ /** Bind the provider client. */
487
+ constructor(client) {
488
+ super(client);
489
+ }
490
+ /** Read the current state and progress of one recent bulk activity. */
491
+ async invoke(call, input) {
492
+ const empty = { activityId: "", state: "", percentDone: 0 };
493
+ if (!contactIDPattern.test(input.activityId)) return this.defect(empty, "activity ID must be a UUID");
494
+ return this.read(call, "/activities/" + input.activityId, "found", empty, activity);
495
+ }
496
+ };
497
+ var ListActivitiesOperation = class extends ReadOperation {
498
+ contract = ListActivitiesDefinition;
499
+ operation = "listActivities";
500
+ /** Bind the provider client. */
501
+ constructor(client) {
502
+ super(client);
503
+ }
504
+ /** Read recent bulk activity states retained for ten days. */
505
+ async invoke(call, input) {
506
+ const empty = { activities: [] };
507
+ const maximum = input.maxItems ?? 0;
508
+ if (!range(maximum, 1e3)) return this.defect(empty, "maxItems must be 1 through 1000");
509
+ return this.read(call, "/activities", "listed", empty, (raw) => {
510
+ const activities = collection(raw, "activities").map(activity);
511
+ return { activities: maximum ? activities.slice(0, maximum) : activities };
512
+ });
513
+ }
514
+ };
515
+ var CreateContactOperation = class extends WriteOperation {
516
+ contract = CreateContactDefinition;
517
+ operation = "createContact";
518
+ /** Bind the provider client. */
519
+ constructor(client) {
520
+ super(client);
521
+ }
522
+ /** Create an email contact with its documented permission and source. */
523
+ async invoke(call, input) {
524
+ const empty = { contactId: "" };
525
+ const { emailAddress, firstName = "", lastName = "", emailPermission, createSource } = input;
526
+ if (!validEmail(emailAddress) || !bounded(firstName, 50) || !bounded(lastName, 50) || !["explicit", "implicit", "not_set"].includes(emailPermission) || !["Account", "Contact"].includes(createSource))
527
+ return this.defect(empty, "invalid contact email, name, permission, or source");
528
+ const payload = {
529
+ email_address: { address: emailAddress, permission_to_send: emailPermission },
530
+ create_source: createSource
531
+ };
532
+ if (firstName) payload.first_name = firstName;
533
+ if (lastName) payload.last_name = lastName;
534
+ return this.create(call, {
535
+ path: "/contacts",
536
+ payload,
537
+ empty,
538
+ decode: contact,
539
+ input,
540
+ readBack: findContact,
541
+ identify: (value) => value.contactId,
542
+ subject: "contact"
543
+ });
544
+ }
545
+ };
546
+ var ListContactsOperation = class extends ReadOperation {
547
+ contract = ListContactsDefinition;
548
+ operation = "listContacts";
549
+ /** Bind the provider client. */
550
+ constructor(client) {
551
+ super(client);
552
+ }
553
+ /** Search contacts by exact email or page through the contact collection. */
554
+ async invoke(call, input) {
555
+ const empty = { contacts: [] };
556
+ const { cursor: cursor2 = "", emailAddress: email = "", limit = 0 } = input;
557
+ if (!range(limit, 500) || !bounded(cursor2, 4096) || !bounded(email, 254))
558
+ return this.defect(empty, "invalid contact search input");
559
+ return this.read(call, pathWith("/contacts", { cursor: cursor2, email, limit }), "listed", empty, contactsPage);
560
+ }
561
+ };
562
+ var UpdateContactOperation = class extends WriteOperation {
563
+ contract = UpdateContactDefinition;
564
+ operation = "updateContact";
565
+ /** Bind the provider client. */
566
+ constructor(client) {
567
+ super(client);
568
+ }
569
+ /** Update selected contact name and company fields while preserving other core fields. */
570
+ async invoke(call, input) {
571
+ const empty = { contactId: "" };
572
+ const fields = {
573
+ first_name: input.firstName,
574
+ last_name: input.lastName,
575
+ company_name: input.companyName,
576
+ job_title: input.jobTitle
577
+ };
578
+ const changes = Object.values(fields);
579
+ if (!contactIDPattern.test(input.contactId) || !["Account", "Contact"].includes(input.updateSource) || changes.every((value) => value == null) || changes.some((value) => value != null && !bounded(value, 50)))
580
+ return this.defect(empty, "invalid contact ID, source, or changed fields");
581
+ const path = "/contacts/" + input.contactId;
582
+ const exchange = await this.client.request(call, "GET", path);
583
+ const failure2 = responseFailure(this.operation, exchange, true);
584
+ if (failure2) return this.outcome(empty, failure2);
585
+ if (exchange.status !== 200) return this.outcome(empty, rejected(exchange.status, true));
586
+ let payload;
587
+ try {
588
+ payload = contactUpdate(parseProviderJSON(exchange), input, fields);
589
+ } catch {
590
+ return this.outcome(empty, { branch: "invalidResponse", kind: "PROTOCOL", message: "invalid contact core fields" });
591
+ }
592
+ return this.write(call, {
593
+ method: "PUT",
594
+ path,
595
+ branch: "updated",
596
+ empty,
597
+ statuses: [200],
598
+ payload,
599
+ decode: (raw) => {
600
+ const updated = contact(raw);
601
+ if (updated.contactId !== input.contactId) throw new Error("updated contact ID differs");
602
+ return updated;
603
+ }
604
+ });
605
+ }
606
+ };
607
+ var DeleteContactOperation = class extends WriteOperation {
608
+ contract = DeleteContactDefinition;
609
+ operation = "deleteContact";
610
+ /** Bind the provider client. */
611
+ constructor(client) {
612
+ super(client);
613
+ }
614
+ /** Delete one contact and its list memberships by contact UUID. */
615
+ async invoke(call, input) {
616
+ const empty = { contactId: "" };
617
+ if (!contactIDPattern.test(input.contactId)) return this.defect(empty, "contact ID must be a UUID");
618
+ return this.write(call, {
619
+ method: "DELETE",
620
+ path: "/contacts/" + input.contactId,
621
+ branch: "deleted",
622
+ empty,
623
+ decode: () => ({ contactId: input.contactId }),
624
+ statuses: [204]
625
+ });
626
+ }
627
+ };
628
+ var GetContactListOperation = class extends ReadOperation {
629
+ contract = GetContactListDefinition;
630
+ operation = "getContactList";
631
+ /** Bind the provider client. */
632
+ constructor(client) {
633
+ super(client);
634
+ }
635
+ /** Read one contact list by UUID. */
636
+ async invoke(call, input) {
637
+ const empty = { listId: "", name: "", favorite: false };
638
+ if (!contactIDPattern.test(input.listId)) return this.defect(empty, "list ID must be a UUID");
639
+ return this.read(call, "/contact_lists/" + input.listId, "found", empty, contactList);
640
+ }
641
+ };
642
+ var ListContactListsOperation = class extends ReadOperation {
643
+ contract = ListContactListsDefinition;
644
+ operation = "listContactLists";
645
+ /** Bind the provider client. */
646
+ constructor(client) {
647
+ super(client);
648
+ }
649
+ /** Read a bounded collection of contact lists, optionally by exact name. */
650
+ async invoke(call, input) {
651
+ const empty = { lists: [] };
652
+ const { limit = 0, name = "" } = input;
653
+ if (!range(limit, 1e3) || !bounded(name, 255)) return this.defect(empty, "invalid list page input");
654
+ return this.read(
655
+ call,
656
+ pathWith("/contact_lists", { limit, name }),
657
+ "listed",
658
+ empty,
659
+ (raw) => ({ lists: collection(raw, "lists").map(contactList) })
660
+ );
661
+ }
662
+ };
663
+ var CreateContactListOperation = class extends WriteOperation {
664
+ contract = CreateContactListDefinition;
665
+ operation = "createContactList";
666
+ /** Bind the provider client. */
667
+ constructor(client) {
668
+ super(client);
669
+ }
670
+ /** Create one named contact list. */
671
+ async invoke(call, input) {
672
+ const empty = { listId: "", name: "", favorite: false };
673
+ if (!validList(input.name, input.description ?? "")) return this.defect(empty, "invalid list name or description");
674
+ return this.create(call, {
675
+ path: "/contact_lists",
676
+ payload: listPayload(input),
677
+ empty,
678
+ decode: contactList,
679
+ input,
680
+ readBack: findList,
681
+ identify: (value) => value.listId,
682
+ subject: "list"
683
+ });
684
+ }
685
+ };
686
+ var UpdateContactListOperation = class extends WriteOperation {
687
+ contract = UpdateContactListDefinition;
688
+ operation = "updateContactList";
689
+ /** Bind the provider client. */
690
+ constructor(client) {
691
+ super(client);
692
+ }
693
+ /** Replace the name, description, and favorite state of one list. */
694
+ async invoke(call, input) {
695
+ const empty = { listId: "", name: "", favorite: false };
696
+ if (!contactIDPattern.test(input.listId) || !validList(input.name, input.description))
697
+ return this.defect(empty, "invalid list ID, name, or description");
698
+ return this.write(call, {
699
+ method: "PUT",
700
+ path: "/contact_lists/" + input.listId,
701
+ branch: "updated",
702
+ empty,
703
+ decode: contactList,
704
+ statuses: [200],
705
+ payload: listPayload(input)
706
+ });
707
+ }
708
+ };
709
+ var DeleteContactListOperation = class extends WriteOperation {
710
+ contract = DeleteContactListDefinition;
711
+ operation = "deleteContactList";
712
+ /** Bind the provider client. */
713
+ constructor(client) {
714
+ super(client);
715
+ }
716
+ /** Request asynchronous deletion of one contact list. */
717
+ async invoke(call, input) {
718
+ const empty = { listId: "", activityId: "" };
719
+ if (!contactIDPattern.test(input.listId)) return this.defect(empty, "list ID must be a UUID");
720
+ return this.write(call, {
721
+ method: "DELETE",
722
+ path: "/contact_lists/" + input.listId,
723
+ branch: "accepted",
724
+ empty,
725
+ decode: (raw) => ({ listId: input.listId, activityId: uuid(object(raw), "activity_id") }),
726
+ statuses: [200, 202]
727
+ });
728
+ }
729
+ };
730
+ async function recordRefusal(fence) {
731
+ try {
732
+ await fence.recordCanResend();
733
+ return true;
734
+ } catch {
735
+ return false;
736
+ }
737
+ }
738
+ function rejected(status, allowNotFound, kind = status === 404 ? "NOT_FOUND" : "PROVIDER_REJECTION") {
739
+ return {
740
+ branch: status === 404 && allowNotFound ? "notFound" : "providerRejected",
741
+ kind,
742
+ message: `Constant Contact rejected HTTP ${status}`
743
+ };
744
+ }
745
+ function responseFailure(operation, exchange, allowNotFound, write = false) {
746
+ const { status, error, retryAfterMs: delay } = exchange;
747
+ if (error === "credential") return { branch: "defect", kind: "AUTHENTICATION", message: "Constant Contact credentials are unavailable or invalid" };
748
+ if (error === "refresh") return { kind: "AVAILABILITY", message: "Constant Contact credentials could not be refreshed" };
749
+ if (error === "request") return { kind: "TRANSPORT", message: "Constant Contact request failed" };
750
+ if (status === 429) return { kind: "RATE_LIMIT", message: "Constant Contact rate limited the request", delay };
751
+ if (status === 408 || status >= 500 || operation === "listContacts" && status === 202)
752
+ return { kind: "AVAILABILITY", message: "Constant Contact is temporarily unavailable", delay };
753
+ if (operation === "deleteContact") {
754
+ if (status === 204) return void 0;
755
+ if (definiteRefusal(exchange)) return rejected(status, true);
756
+ return { kind: "AVAILABILITY", message: "contact deletion outcome is unknown", delay };
757
+ }
758
+ if (operation === "listContacts" && status !== 200) return rejected(status, false, "PROVIDER_REJECTION");
759
+ if (write && (error === "tooLarge" || status >= 400 && !error && !definiteRefusal(exchange)))
760
+ return { kind: "AVAILABILITY", message: "Constant Contact write outcome is unknown", delay };
761
+ if (error === "tooLarge")
762
+ return { branch: "invalidResponse", kind: "RESPONSE_TOO_LARGE", message: "Constant Contact response exceeded the configured limit" };
763
+ if (error) return { kind: "TRANSPORT", message: "Constant Contact response was interrupted", delay: operation === "listContacts" ? 0 : delay };
764
+ return status >= 400 ? rejected(status, allowNotFound) : void 0;
765
+ }
766
+ function definiteRefusal(exchange) {
767
+ if (exchange.error || ![400, 401, 403, 404, 411, 413, 414, 415, 422].includes(exchange.status)) return false;
768
+ let fields;
769
+ try {
770
+ fields = Object.entries(object(parseProviderJSON(exchange))).map(([key, value]) => [key.toLowerCase(), value]);
771
+ } catch {
772
+ return false;
773
+ }
774
+ if (fields.some(([key]) => key.endsWith("id") || ["contacts", "lists", "segments"].includes(key))) return false;
775
+ return fields.some(([key, value]) => key.startsWith("error") && value !== null && value !== "" && (typeof value !== "object" || Object.keys(value).length > 0));
776
+ }
777
+ function pathWith(base, parameters) {
778
+ const query = new URLSearchParams(Object.entries(parameters).filter(([, value]) => value !== 0 && value !== "").map(([key, value]) => [key, String(value)]));
779
+ query.sort();
780
+ const encoded = query.toString().replaceAll("*", "%2A").replaceAll("%7E", "~");
781
+ return encoded ? base + "?" + encoded : base;
782
+ }
783
+ function parseProviderJSON(exchange) {
784
+ return parseJSONNumberTokens(Buffer.from(exchange.body).toString("utf8"));
785
+ }
786
+ function bounded(value, limit) {
787
+ return Buffer.byteLength(value) <= limit && !/[\r\n]/.test(value);
788
+ }
789
+ function range(value, maximum) {
790
+ return Number.isInteger(value) && value >= 0 && value <= maximum;
791
+ }
792
+ function validEmail(value) {
793
+ if (Buffer.byteLength(value) > 80 || /[\uD800-\uDFFF]/u.test(value)) return false;
794
+ const separator = value.indexOf("@");
795
+ if (separator < 1 || !emailAtom(value.slice(0, separator))) return false;
796
+ const domain = value.slice(separator + 1);
797
+ if (domain.startsWith("[") && domain.endsWith("]")) {
798
+ const literal = domain.slice(1, -1);
799
+ return !literal.includes("%") && isIP(literal) !== 0;
800
+ }
801
+ return emailAtom(domain);
802
+ }
803
+ function emailAtom(value) {
804
+ const excluded = '()<>[]:;@\\,"';
805
+ return value.length > 0 && !value.startsWith(".") && !value.endsWith(".") && !value.includes("..") && [...value].every((character) => character.charCodeAt(0) >= 128 || character >= "!" && character <= "~" && !excluded.includes(character));
806
+ }
807
+ function integerValue(value) {
808
+ return BigInt(typeof value === "number" ? value : value.rawJSON);
809
+ }
810
+ function segmentID(value) {
811
+ try {
812
+ const integer2 = decodeSignedInteger(value);
813
+ const signed = integerValue(integer2);
814
+ return signed > 0n ? signed.toString() : "";
815
+ } catch {
816
+ return "";
817
+ }
818
+ }
819
+ function validList(name, description) {
820
+ return !!name.trim() && Buffer.byteLength(name) <= 255 && Buffer.byteLength(description) <= 255;
821
+ }
822
+ function validSegment(name, criteria) {
823
+ if (!name.trim() || Buffer.byteLength(name) > 255 || Buffer.byteLength(criteria) > 16384) return false;
824
+ try {
825
+ return Object.keys(object(JSON.parse(criteria))).length > 0;
826
+ } catch {
827
+ return false;
828
+ }
829
+ }
830
+ function object(value) {
831
+ if (value === null || typeof value !== "object" || Array.isArray(value) || JSON.isRawJSON(value))
832
+ throw new Error("expected provider object");
833
+ return value;
834
+ }
835
+ function text(wire, key) {
836
+ const value = wire[key];
837
+ if (value === null || value === void 0) return "";
838
+ if (typeof value !== "string") throw new Error(`expected text field ${key}`);
839
+ return value;
840
+ }
841
+ function integer(wire, key) {
842
+ return decodeSignedInteger(wire[key] ?? 0);
843
+ }
844
+ function smallInteger(wire, key) {
845
+ const value = integer(wire, key);
846
+ if (typeof value !== "number") throw new Error(`unsafe integer field ${key}`);
847
+ return value;
848
+ }
849
+ function uuid(wire, key) {
850
+ const value = text(wire, key);
851
+ if (!contactIDPattern.test(value)) throw new Error(`expected UUID field ${key}`);
852
+ return value;
853
+ }
854
+ function collection(raw, key) {
855
+ const items = object(raw)[key];
856
+ if (!Array.isArray(items)) throw new Error(`expected collection ${key}`);
857
+ return items;
858
+ }
859
+ function cursor(raw, key) {
860
+ const links = object(raw)._links;
861
+ if (links == null) return "";
862
+ const next = object(links).next;
863
+ const href = next == null ? "" : text(object(next), "href");
864
+ if (!href) return "";
865
+ const matched = /^((?:[A-Za-z][A-Za-z0-9+.-]*:)?)(?:(\/\/[^/?#]*))?([^?#]*)(?:\?([^#]*))?/.exec(href);
866
+ if (!matched || [...href].some((character) => character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127) || /%(?![A-Fa-f0-9]{2})/u.test(matched[3] ?? ""))
867
+ throw new Error("invalid page link");
868
+ const [, scheme, authority, pathname = "", query = ""] = matched;
869
+ const value = new URLSearchParams(query).get(key);
870
+ if (!value || key === "cursor" && (authority || !decodeURI(pathname).endsWith("/contacts")) || key === "next" && (scheme || !bounded(value, 4096)))
871
+ throw new Error("invalid page cursor");
872
+ return value;
873
+ }
874
+ function segment(raw) {
875
+ const wire = object(raw);
876
+ const id = integer(wire, "segment_id");
877
+ const name = text(wire, "name");
878
+ const criteria = text(wire, "segment_criteria");
879
+ if (!segmentID(id) || !name.trim()) throw new Error("invalid segment");
880
+ return { segmentId: id, name, ...criteria ? { segmentCriteria: criteria } : {} };
881
+ }
882
+ function fullSegment(raw) {
883
+ const value = segment(raw);
884
+ if (!validSegment(value.name, value.segmentCriteria ?? "")) throw new Error("invalid segment criteria");
885
+ return value;
886
+ }
887
+ function segmentsPage(raw) {
888
+ const nextCursor = cursor(raw, "next");
889
+ return { segments: collection(raw, "segments").map(segment), ...nextCursor ? { nextCursor } : {} };
890
+ }
891
+ function contact(raw) {
892
+ const value = decodeContactDocument(raw);
893
+ if (!value) throw new Error("invalid contact");
894
+ return value;
895
+ }
896
+ function contactsPage(raw) {
897
+ const nextCursor = cursor(raw, "cursor");
898
+ return { contacts: collection(raw, "contacts").map(contact), ...nextCursor ? { nextCursor } : {} };
899
+ }
900
+ function contactList(raw) {
901
+ const wire = object(raw);
902
+ const name = text(wire, "name");
903
+ const description = text(wire, "description");
904
+ const favorite = wire.favorite ?? false;
905
+ if (!name.trim() || typeof favorite !== "boolean") throw new Error("invalid contact list");
906
+ return { listId: uuid(wire, "list_id"), name, favorite, ...description ? { description } : {} };
907
+ }
908
+ function activity(raw) {
909
+ const wire = object(raw);
910
+ const state = text(wire, "state");
911
+ const percentDone = smallInteger(wire, "percent_done");
912
+ const status = wire.status == null ? {} : object(wire.status);
913
+ const itemsTotalCount = integer(status, "items_total_count");
914
+ const itemsCompletedCount = integer(status, "items_completed_count");
915
+ if (!state.trim() || !range(percentDone, 100) || integerValue(itemsTotalCount) < 0 || integerValue(itemsCompletedCount) < 0)
916
+ throw new Error("invalid activity");
917
+ return {
918
+ activityId: uuid(wire, "activity_id"),
919
+ state,
920
+ percentDone,
921
+ ...itemsTotalCount ? { itemsTotalCount } : {},
922
+ ...itemsCompletedCount ? { itemsCompletedCount } : {}
923
+ };
924
+ }
925
+ function contactUpdate(raw, input, fields) {
926
+ const wire = object(raw);
927
+ if (text(wire, "contact_id") !== input.contactId) throw new Error("contact ID differs");
928
+ const payload = { update_source: input.updateSource };
929
+ for (const [key, replacement] of Object.entries(fields)) {
930
+ const current = text(wire, key);
931
+ payload[key] = replacement ?? current;
932
+ }
933
+ if (wire.email_address != null) {
934
+ const email = object(wire.email_address);
935
+ const address = text(email, "address");
936
+ const permission = text(email, "permission_to_send");
937
+ if (!address || !permission) throw new Error("invalid email channel");
938
+ payload.email_address = { address, permission_to_send: permission };
939
+ }
940
+ for (const key of ["birthday_month", "birthday_day"]) {
941
+ if (wire[key] != null) payload[key] = integer(wire, key);
942
+ }
943
+ const anniversary = text(wire, "anniversary");
944
+ if (anniversary) payload.anniversary = anniversary;
945
+ return payload;
946
+ }
947
+ function segmentPayload(input) {
948
+ return { name: input.name, segment_criteria: input.segmentCriteria };
949
+ }
950
+ function listPayload(input) {
951
+ return { name: input.name, description: input.description ?? "", favorite: input.favorite };
952
+ }
953
+ async function readBack(client, call, path) {
954
+ const exchange = await client.request(call, "GET", path);
955
+ if (exchange.error || exchange.status === 429 || exchange.status >= 500) throw new Error("provider read-back unavailable");
956
+ return exchange.status === 200 ? parseProviderJSON(exchange) : void 0;
957
+ }
958
+ async function findContact(client, call, input) {
959
+ const raw = await readBack(client, call, pathWith("/contacts", { email: input.emailAddress }));
960
+ if (raw === void 0) return void 0;
961
+ for (const item of collection(raw, "contacts")) {
962
+ const found = contact(item);
963
+ if (found.emailAddress?.toLowerCase() === input.emailAddress.toLowerCase() && (found.firstName ?? "") === (input.firstName ?? "") && (found.lastName ?? "") === (input.lastName ?? "") && found.emailPermission === input.emailPermission) return found;
964
+ }
965
+ return void 0;
966
+ }
967
+ async function findList(client, call, input) {
968
+ const raw = await readBack(client, call, pathWith("/contact_lists", { name: input.name }));
969
+ if (raw === void 0) return void 0;
970
+ for (const item of collection(raw, "lists")) {
971
+ const list = contactList(item);
972
+ if (list.name === input.name && (list.description ?? "") === (input.description ?? "") && list.favorite === input.favorite)
973
+ return list;
974
+ }
975
+ return void 0;
976
+ }
977
+ async function findSegment(client, call, input) {
978
+ const raw = await readBack(client, call, "/segments?limit=1000");
979
+ if (raw === void 0) return void 0;
980
+ const candidate = segmentsPage(raw).segments?.find((value) => value.name === input.name);
981
+ if (!candidate) return void 0;
982
+ const details = fullSegment(await readBack(client, call, "/segments/" + segmentID(candidate.segmentId)));
983
+ return details.segmentCriteria === input.segmentCriteria ? details : void 0;
984
+ }
985
+
986
+ // src/generated/refresh.ts
987
+ var Authorization = {
988
+ "fields": [
989
+ {
990
+ "name": "oauth_client_id",
991
+ "required": true,
992
+ "type": "string"
993
+ },
994
+ {
995
+ "name": "oauth_client_secret",
996
+ "required": true,
997
+ "type": "secretString"
998
+ },
999
+ {
1000
+ "name": "access_token",
1001
+ "required": true,
1002
+ "type": "secretString"
1003
+ },
1004
+ {
1005
+ "name": "refresh_token",
1006
+ "required": true,
1007
+ "type": "secretString"
1008
+ }
1009
+ ],
1010
+ "oauth2": {
1011
+ "clientIDCredential": "oauth_client_id",
1012
+ "clientSecretCredential": "oauth_client_secret",
1013
+ "credentialMappings": [
1014
+ {
1015
+ "credential": "access_token",
1016
+ "source": "access_token"
1017
+ },
1018
+ {
1019
+ "credential": "refresh_token",
1020
+ "source": "refresh_token"
1021
+ }
1022
+ ],
1023
+ "refresh": {
1024
+ "missingExpiry": "reject",
1025
+ "requiredScopes": [
1026
+ "contact_data"
1027
+ ],
1028
+ "scopeSeparators": "whitespaceAndComma",
1029
+ "storedMissingExpiry": "refresh",
1030
+ "terminalErrorCodes": [
1031
+ "invalid_grant",
1032
+ "invalid_client",
1033
+ "unauthorized_client"
1034
+ ],
1035
+ "tokenExchangeTimeout": "15s"
1036
+ },
1037
+ "scopes": [
1038
+ "contact_data",
1039
+ "offline_access"
1040
+ ],
1041
+ "tokenEndpoint": "https://authz.constantcontact.com/oauth2/default/v1/token",
1042
+ "tokenEndpointAuthMethod": "client_secret_basic"
1043
+ },
1044
+ "refreshable": true,
1045
+ "type": "oauth2"
1046
+ };
1047
+ var CredentialFields = {
1048
+ "access_token": "accessToken",
1049
+ "oauth_client_id": "oauthClientId",
1050
+ "oauth_client_secret": "oauthClientSecret",
1051
+ "refresh_token": "refreshToken"
1052
+ };
1053
+
1054
+ // src/client.ts
1055
+ var defaultBaseURL = "https://api.cc.email/v3";
1056
+ var emptyContact = () => ({ contactId: "" });
1057
+ var ConstantContactClient = class {
1058
+ /** Validate configuration without contacting the provider. */
1059
+ constructor(config, credentials, options = {}) {
1060
+ this.credentials = credentials;
1061
+ if (!config || !credentials) throw new TypeError("Constant Contact configuration and credentials are required");
1062
+ this.baseURL = validateBaseURL(config.baseUrl || defaultBaseURL);
1063
+ this.timeoutMs = config.timeoutMs || 15e3;
1064
+ this.maxResponseBytes = config.maxResponseBytes || 1048576;
1065
+ if (!Number.isSafeInteger(this.timeoutMs) || this.timeoutMs <= 0 || !Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes <= 0)
1066
+ throw new TypeError("Constant Contact request limits must be positive integers");
1067
+ this.refreshDriver = options.refreshDriver ?? new ManifestCredentialRefreshDriver({
1068
+ providerName: "Constant Contact",
1069
+ auth: Authorization,
1070
+ credentialFields: CredentialFields
1071
+ });
1072
+ this.send = options.send ?? sendProviderRequest;
1073
+ }
1074
+ credentials;
1075
+ baseURL;
1076
+ timeoutMs;
1077
+ maxResponseBytes;
1078
+ refreshDriver;
1079
+ send;
1080
+ /** Bind the getContact Query. */
1081
+ getContact() {
1082
+ return new GetContactOperation(this);
1083
+ }
1084
+ /** Bind the getSegment operation. */
1085
+ getSegment() {
1086
+ return new GetSegmentOperation(this);
1087
+ }
1088
+ /** Bind the listSegments operation. */
1089
+ listSegments() {
1090
+ return new ListSegmentsOperation(this);
1091
+ }
1092
+ /** Bind the createSegment operation. */
1093
+ createSegment() {
1094
+ return new CreateSegmentOperation(this);
1095
+ }
1096
+ /** Bind the updateSegment operation. */
1097
+ updateSegment() {
1098
+ return new UpdateSegmentOperation(this);
1099
+ }
1100
+ /** Bind the deleteSegment operation. */
1101
+ deleteSegment() {
1102
+ return new DeleteSegmentOperation(this);
1103
+ }
1104
+ /** Bind the getActivity operation. */
1105
+ getActivity() {
1106
+ return new GetActivityOperation(this);
1107
+ }
1108
+ /** Bind the listActivities operation. */
1109
+ listActivities() {
1110
+ return new ListActivitiesOperation(this);
1111
+ }
1112
+ /** Bind the createContact operation. */
1113
+ createContact() {
1114
+ return new CreateContactOperation(this);
1115
+ }
1116
+ /** Bind the listContacts operation. */
1117
+ listContacts() {
1118
+ return new ListContactsOperation(this);
1119
+ }
1120
+ /** Bind the updateContact operation. */
1121
+ updateContact() {
1122
+ return new UpdateContactOperation(this);
1123
+ }
1124
+ /** Bind the deleteContact operation. */
1125
+ deleteContact() {
1126
+ return new DeleteContactOperation(this);
1127
+ }
1128
+ /** Bind the getContactList operation. */
1129
+ getContactList() {
1130
+ return new GetContactListOperation(this);
1131
+ }
1132
+ /** Bind the listContactLists operation. */
1133
+ listContactLists() {
1134
+ return new ListContactListsOperation(this);
1135
+ }
1136
+ /** Bind the createContactList operation. */
1137
+ createContactList() {
1138
+ return new CreateContactListOperation(this);
1139
+ }
1140
+ /** Bind the updateContactList operation. */
1141
+ updateContactList() {
1142
+ return new UpdateContactListOperation(this);
1143
+ }
1144
+ /** Bind the deleteContactList operation. */
1145
+ deleteContactList() {
1146
+ return new DeleteContactListOperation(this);
1147
+ }
1148
+ /** Resolve the authorization token before a provider request. */
1149
+ async resolveToken(call) {
1150
+ try {
1151
+ const credentials = await resolveCredential(this.credentials, call, this.refreshDriver, call.context.cancellationSignal);
1152
+ const token = credentials.accessToken instanceof SecretString ? credentials.accessToken.reveal() : "";
1153
+ return token && isHeaderSafeCredential(token) ? token : emptyExchange("credential");
1154
+ } catch (error) {
1155
+ return emptyExchange(error instanceof ReauthorizationRequiredError ? "credential" : "refresh");
1156
+ }
1157
+ }
1158
+ /** Resolve a token and send one bounded contact read. */
1159
+ get(call, contactID) {
1160
+ return this.request(call, "GET", "/contacts/" + contactID);
1161
+ }
1162
+ /** Send a bounded Constant Contact V3 request. */
1163
+ async request(call, method, path, payload) {
1164
+ const send = await this.prepareRequest(call, method, path, payload);
1165
+ return typeof send === "function" ? send(call.context.cancellationSignal) : send;
1166
+ }
1167
+ /** Resolve credentials before a dispatch fence and bind them to one request. */
1168
+ async prepareRequest(call, method, path, payload) {
1169
+ if (!path.startsWith("/")) return emptyExchange("request");
1170
+ const token = await this.resolveToken(call);
1171
+ return typeof token === "string" ? (signal) => this.sendAuthorized(method, path, token, signal, payload) : token;
1172
+ }
1173
+ async sendAuthorized(method, path, token, signal, payload) {
1174
+ const headers = { Accept: "application/json", Authorization: `Bearer ${token}` };
1175
+ if (payload !== void 0) headers["Content-Type"] = "application/json";
1176
+ const request = {
1177
+ url: this.baseURL + path,
1178
+ method,
1179
+ headers,
1180
+ ...payload === void 0 ? {} : { body: Buffer.from(JSON.stringify(payload)) },
1181
+ maxResponseBytes: this.maxResponseBytes,
1182
+ timeoutMs: this.timeoutMs,
1183
+ addressPolicy: this.baseURL === defaultBaseURL ? "publicHTTPS" : "privateNetworkHTTP",
1184
+ signal
1185
+ };
1186
+ let response;
1187
+ let isTooLarge = false;
1188
+ try {
1189
+ response = await this.send(request);
1190
+ } catch (error) {
1191
+ if (error instanceof BodyTooLargeError && error.status !== void 0) {
1192
+ response = { status: error.status, headers: error.headers ?? {}, body: new Uint8Array() };
1193
+ isTooLarge = true;
1194
+ } else if (error instanceof ProviderTransportError && error.status !== void 0) {
1195
+ return { status: error.status, body: new Uint8Array(), retryAfterMs: parseRetryAfter(header(error.headers ?? {}, "retry-after")), error: "read" };
1196
+ } else return emptyExchange("request");
1197
+ }
1198
+ const retryAfterMs = parseRetryAfter(header(response.headers, "retry-after"));
1199
+ if (isTooLarge || response.body.length > this.maxResponseBytes)
1200
+ return { status: response.status, body: new Uint8Array(), retryAfterMs, error: "tooLarge" };
1201
+ return { status: response.status, body: response.body, retryAfterMs };
1202
+ }
1203
+ };
1204
+ var GetContactOperation = class {
1205
+ /** Bind the provider client. */
1206
+ constructor(client) {
1207
+ this.client = client;
1208
+ }
1209
+ client;
1210
+ /** Return the generated Query definition. */
1211
+ definition() {
1212
+ return GetContactDefinition;
1213
+ }
1214
+ /** Classify the provider outcome exactly as the Go implementation does. */
1215
+ async invoke(call, input) {
1216
+ if (!input || !contactIDPattern.test(input.contactId))
1217
+ return terminal("defect", "VALIDATION", "contact ID must be a UUID");
1218
+ const exchange = await this.client.get(call, input.contactId);
1219
+ if (exchange.error === "credential") return terminal("defect", "AUTHENTICATION", "Constant Contact credentials are unavailable or invalid");
1220
+ if (exchange.error === "refresh") return retry("AVAILABILITY", "Constant Contact credentials could not be refreshed");
1221
+ if (exchange.error === "request") return retry("TRANSPORT", "Constant Contact request failed");
1222
+ if (exchange.status === 429) return retry("RATE_LIMIT", "Constant Contact rate limited the request", exchange.retryAfterMs);
1223
+ if (exchange.status === 408 || exchange.status >= 500)
1224
+ return retry("AVAILABILITY", "Constant Contact is temporarily unavailable", exchange.retryAfterMs);
1225
+ if (exchange.status === 404) return terminal("notFound", "NOT_FOUND", "Constant Contact did not find the contact");
1226
+ if (exchange.status !== 200) return terminal("providerRejected", "PROVIDER_REJECTION", `Constant Contact rejected HTTP ${exchange.status}`);
1227
+ if (exchange.error === "tooLarge") return terminal("invalidResponse", "RESPONSE_TOO_LARGE", "Constant Contact response exceeded the configured limit");
1228
+ if (exchange.error) return retry("TRANSPORT", "Constant Contact response was interrupted");
1229
+ const contact2 = decodeContact(exchange.body);
1230
+ if (!contact2) return terminal("invalidResponse", "PROTOCOL", "Constant Contact returned invalid JSON");
1231
+ return newQueryBranch2("found", contact2);
1232
+ }
1233
+ };
1234
+ function emptyExchange(error) {
1235
+ return { status: 0, body: new Uint8Array(), retryAfterMs: 0, error };
1236
+ }
1237
+ function failure(kind, message) {
1238
+ return { provider: "constantcontact", operation: "getContact", kind, message };
1239
+ }
1240
+ function terminal(branch, kind, message) {
1241
+ return newQueryBranch2(branch, emptyContact(), {}, failure(kind, message));
1242
+ }
1243
+ function retry(kind, message, delay = 0) {
1244
+ return newQueryRetry2(failure(kind, message), delay);
1245
+ }
1246
+ function header(headers, name) {
1247
+ const entry = Object.entries(headers).find(([key]) => key.toLowerCase() === name.toLowerCase())?.[1];
1248
+ return Array.isArray(entry) ? entry[0] ?? "" : entry ?? "";
1249
+ }
1250
+ function decodeContact(body) {
1251
+ let raw;
1252
+ try {
1253
+ raw = JSON.parse(Buffer.from(body).toString("utf8"));
1254
+ } catch {
1255
+ return void 0;
1256
+ }
1257
+ return decodeContactDocument(raw);
1258
+ }
1259
+
1260
+ // src/project.ts
1261
+ import { z } from "zod";
1262
+ function encodeCredentials(credentials) {
1263
+ return {
1264
+ oauth_client_id: credentials.oauthClientId,
1265
+ oauth_client_secret: credentials.oauthClientSecret.reveal(),
1266
+ access_token: credentials.accessToken.reveal(),
1267
+ refresh_token: credentials.refreshToken.reveal()
1268
+ };
1269
+ }
1270
+ function newProjectConnection(project, connectionName, options = {}) {
1271
+ if (!project) throw new TypeError("Constant Contact project is required");
1272
+ const selected = project.configuration.connections.find((entry) => entry.connectorId === "constantcontact" && entry.connectionName === connectionName);
1273
+ if (!selected || selected.provider !== "constantcontact") throw new TypeError("Constant Contact project connection is not configured");
1274
+ const fields = z.strictObject({
1275
+ baseUrl: z.string().optional(),
1276
+ timeout: z.union([z.string(), z.number().int()]).optional(),
1277
+ maxResponseBytes: z.number().int().optional()
1278
+ }).parse(selected.configuration);
1279
+ const timeoutMs = typeof fields.timeout === "number" ? Math.ceil(fields.timeout / 1e6) : fields.timeout ? parseDurationMilliseconds(fields.timeout) : void 0;
1280
+ const config = {
1281
+ ...fields.baseUrl !== void 0 ? { baseUrl: fields.baseUrl } : {},
1282
+ ...timeoutMs !== void 0 ? { timeoutMs } : {},
1283
+ ...fields.maxResponseBytes !== void 0 ? { maxResponseBytes: fields.maxResponseBytes } : {}
1284
+ };
1285
+ const provider = newProjectCredentialProvider(project, connectionName, decodeCredentials, encodeCredentials, decodeSharedCredentials);
1286
+ return newConnection(new ConstantContactClient(config, provider, options), { provider: "constantcontact", name: connectionName });
1287
+ }
1288
+ function parseDurationMilliseconds(value) {
1289
+ let remaining = value;
1290
+ let milliseconds = 0;
1291
+ const units = { ns: 1e-6, us: 1e-3, "\xB5s": 1e-3, ms: 1, s: 1e3, m: 6e4, h: 36e5 };
1292
+ while (remaining) {
1293
+ const part = /^(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/.exec(remaining);
1294
+ if (!part) throw new TypeError("Constant Contact timeout must be a positive Go duration");
1295
+ milliseconds += Number(part[1]) * (units[part[2] ?? ""] ?? NaN);
1296
+ remaining = remaining.slice(part[0].length);
1297
+ }
1298
+ if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0)
1299
+ throw new TypeError("Constant Contact timeout must resolve to positive whole milliseconds");
1300
+ return milliseconds;
1301
+ }
1302
+
1303
+ // src/generated/steps.ts
1304
+ import { goToBranch, newMutationStep, newQueryStep } from "@superdurable/connectors-sdk";
1305
+ function newGetSegmentStep(configuration) {
1306
+ const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
1307
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
1308
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.getSegment(), connection: connection.reference, branches: [
1309
+ goToBranch("found", found),
1310
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
1311
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
1312
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
1313
+ ...defect ? [goToBranch("defect", defect)] : []
1314
+ ] });
1315
+ }
1316
+ function newListSegmentsStep(configuration) {
1317
+ const { connection, connectionName, listed, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
1318
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
1319
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.listSegments(), connection: connection.reference, branches: [
1320
+ goToBranch("listed", listed),
1321
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
1322
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
1323
+ ...defect ? [goToBranch("defect", defect)] : []
1324
+ ] });
1325
+ }
1326
+ function newCreateSegmentStep(configuration) {
1327
+ const { connection, connectionName, created, uncertain, alreadyExists, providerRejected, defect, ...stepConfiguration } = configuration;
1328
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
1329
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.createSegment(), connection: connection.reference, branches: [
1330
+ goToBranch("created", created),
1331
+ ...uncertain ? [goToBranch("uncertain", uncertain)] : [],
1332
+ ...alreadyExists ? [goToBranch("alreadyExists", alreadyExists)] : [],
1333
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
1334
+ ...defect ? [goToBranch("defect", defect)] : []
1335
+ ] });
1336
+ }
1337
+ function newUpdateSegmentStep(configuration) {
1338
+ const { connection, connectionName, updated, notFound, providerRejected, invalidResponse, defect, maxSends, ...stepConfiguration } = configuration;
1339
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
1340
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.updateSegment(), connection: connection.reference, branches: [
1341
+ goToBranch("updated", updated),
1342
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
1343
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
1344
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
1345
+ ...defect ? [goToBranch("defect", defect)] : []
1346
+ ] });
1347
+ }
1348
+ function newDeleteSegmentStep(configuration) {
1349
+ const { connection, connectionName, deleted, notFound, providerRejected, defect, maxSends, ...stepConfiguration } = configuration;
1350
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
1351
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.deleteSegment(), connection: connection.reference, branches: [
1352
+ goToBranch("deleted", deleted),
1353
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
1354
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
1355
+ ...defect ? [goToBranch("defect", defect)] : []
1356
+ ] });
1357
+ }
1358
+ function newGetActivityStep(configuration) {
1359
+ const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
1360
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
1361
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.getActivity(), connection: connection.reference, branches: [
1362
+ goToBranch("found", found),
1363
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
1364
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
1365
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
1366
+ ...defect ? [goToBranch("defect", defect)] : []
1367
+ ] });
1368
+ }
1369
+ function newListActivitiesStep(configuration) {
1370
+ const { connection, connectionName, listed, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
1371
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
1372
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.listActivities(), connection: connection.reference, branches: [
1373
+ goToBranch("listed", listed),
1374
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
1375
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
1376
+ ...defect ? [goToBranch("defect", defect)] : []
1377
+ ] });
1378
+ }
1379
+ function newCreateContactStep(configuration) {
1380
+ const { connection, connectionName, created, uncertain, alreadyExists, providerRejected, defect, ...stepConfiguration } = configuration;
1381
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
1382
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.createContact(), connection: connection.reference, branches: [
1383
+ goToBranch("created", created),
1384
+ ...uncertain ? [goToBranch("uncertain", uncertain)] : [],
1385
+ ...alreadyExists ? [goToBranch("alreadyExists", alreadyExists)] : [],
1386
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
1387
+ ...defect ? [goToBranch("defect", defect)] : []
1388
+ ] });
1389
+ }
1390
+ function newListContactsStep(configuration) {
1391
+ const { connection, connectionName, listed, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
1392
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
1393
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.listContacts(), connection: connection.reference, branches: [
1394
+ goToBranch("listed", listed),
1395
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
1396
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
1397
+ ...defect ? [goToBranch("defect", defect)] : []
1398
+ ] });
1399
+ }
1400
+ function newUpdateContactStep(configuration) {
1401
+ const { connection, connectionName, updated, notFound, providerRejected, invalidResponse, defect, maxSends, ...stepConfiguration } = configuration;
1402
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
1403
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.updateContact(), connection: connection.reference, branches: [
1404
+ goToBranch("updated", updated),
1405
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
1406
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
1407
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
1408
+ ...defect ? [goToBranch("defect", defect)] : []
1409
+ ] });
1410
+ }
1411
+ function newDeleteContactStep(configuration) {
1412
+ const { connection, connectionName, deleted, notFound, providerRejected, defect, maxSends, ...stepConfiguration } = configuration;
1413
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
1414
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.deleteContact(), connection: connection.reference, branches: [
1415
+ goToBranch("deleted", deleted),
1416
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
1417
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
1418
+ ...defect ? [goToBranch("defect", defect)] : []
1419
+ ] });
1420
+ }
1421
+ function newGetContactStep(configuration) {
1422
+ const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
1423
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
1424
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.getContact(), connection: connection.reference, branches: [
1425
+ goToBranch("found", found),
1426
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
1427
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
1428
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
1429
+ ...defect ? [goToBranch("defect", defect)] : []
1430
+ ] });
1431
+ }
1432
+ function newGetContactListStep(configuration) {
1433
+ const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
1434
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
1435
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.getContactList(), connection: connection.reference, branches: [
1436
+ goToBranch("found", found),
1437
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
1438
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
1439
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
1440
+ ...defect ? [goToBranch("defect", defect)] : []
1441
+ ] });
1442
+ }
1443
+ function newListContactListsStep(configuration) {
1444
+ const { connection, connectionName, listed, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
1445
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
1446
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.listContactLists(), connection: connection.reference, branches: [
1447
+ goToBranch("listed", listed),
1448
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
1449
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
1450
+ ...defect ? [goToBranch("defect", defect)] : []
1451
+ ] });
1452
+ }
1453
+ function newCreateContactListStep(configuration) {
1454
+ const { connection, connectionName, created, uncertain, alreadyExists, providerRejected, defect, ...stepConfiguration } = configuration;
1455
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
1456
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.createContactList(), connection: connection.reference, branches: [
1457
+ goToBranch("created", created),
1458
+ ...uncertain ? [goToBranch("uncertain", uncertain)] : [],
1459
+ ...alreadyExists ? [goToBranch("alreadyExists", alreadyExists)] : [],
1460
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
1461
+ ...defect ? [goToBranch("defect", defect)] : []
1462
+ ] });
1463
+ }
1464
+ function newUpdateContactListStep(configuration) {
1465
+ const { connection, connectionName, updated, notFound, providerRejected, defect, maxSends, ...stepConfiguration } = configuration;
1466
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
1467
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.updateContactList(), connection: connection.reference, branches: [
1468
+ goToBranch("updated", updated),
1469
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
1470
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
1471
+ ...defect ? [goToBranch("defect", defect)] : []
1472
+ ] });
1473
+ }
1474
+ function newDeleteContactListStep(configuration) {
1475
+ const { connection, connectionName, accepted, notFound, providerRejected, defect, maxSends, ...stepConfiguration } = configuration;
1476
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
1477
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.deleteContactList(), connection: connection.reference, branches: [
1478
+ goToBranch("accepted", accepted),
1479
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
1480
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
1481
+ ...defect ? [goToBranch("defect", defect)] : []
1482
+ ] });
1483
+ }
1484
+ export {
1485
+ ActivitiesPageSchema,
1486
+ ActivityMetadataSchema,
1487
+ ConfigSchema,
1488
+ Connection,
1489
+ ConnectorID,
1490
+ ConstantContactClient,
1491
+ ContactListMetadataSchema,
1492
+ ContactListsPageSchema,
1493
+ ContactMetadataSchema,
1494
+ ContactsPageSchema,
1495
+ CreateContactBranch,
1496
+ CreateContactBranchAlreadyExists,
1497
+ CreateContactBranchCreated,
1498
+ CreateContactBranchDefect,
1499
+ CreateContactBranchProviderRejected,
1500
+ CreateContactBranchUncertain,
1501
+ CreateContactDefinition,
1502
+ CreateContactInputSchema,
1503
+ CreateContactListBranch,
1504
+ CreateContactListBranchAlreadyExists,
1505
+ CreateContactListBranchCreated,
1506
+ CreateContactListBranchDefect,
1507
+ CreateContactListBranchProviderRejected,
1508
+ CreateContactListBranchUncertain,
1509
+ CreateContactListDefinition,
1510
+ CreateContactListInputSchema,
1511
+ CreateContactListMetadata,
1512
+ CreateContactListOperation,
1513
+ CreateContactMetadata,
1514
+ CreateContactOperation,
1515
+ CreateSegmentBranch,
1516
+ CreateSegmentBranchAlreadyExists,
1517
+ CreateSegmentBranchCreated,
1518
+ CreateSegmentBranchDefect,
1519
+ CreateSegmentBranchProviderRejected,
1520
+ CreateSegmentBranchUncertain,
1521
+ CreateSegmentDefinition,
1522
+ CreateSegmentInputSchema,
1523
+ CreateSegmentMetadata,
1524
+ CreateSegmentOperation,
1525
+ CredentialMaterialError,
1526
+ DeleteContactBranch,
1527
+ DeleteContactBranchDefect,
1528
+ DeleteContactBranchDeleted,
1529
+ DeleteContactBranchNotFound,
1530
+ DeleteContactBranchProviderRejected,
1531
+ DeleteContactDefinition,
1532
+ DeleteContactInputSchema,
1533
+ DeleteContactListBranch,
1534
+ DeleteContactListBranchAccepted,
1535
+ DeleteContactListBranchDefect,
1536
+ DeleteContactListBranchNotFound,
1537
+ DeleteContactListBranchProviderRejected,
1538
+ DeleteContactListDefinition,
1539
+ DeleteContactListInputSchema,
1540
+ DeleteContactListMetadata,
1541
+ DeleteContactListOperation,
1542
+ DeleteContactListOutputSchema,
1543
+ DeleteContactMetadata,
1544
+ DeleteContactOperation,
1545
+ DeleteContactOutputSchema,
1546
+ DeleteSegmentBranch,
1547
+ DeleteSegmentBranchDefect,
1548
+ DeleteSegmentBranchDeleted,
1549
+ DeleteSegmentBranchNotFound,
1550
+ DeleteSegmentBranchProviderRejected,
1551
+ DeleteSegmentDefinition,
1552
+ DeleteSegmentInputSchema,
1553
+ DeleteSegmentMetadata,
1554
+ DeleteSegmentOperation,
1555
+ DeleteSegmentOutputSchema,
1556
+ GetActivityBranch,
1557
+ GetActivityBranchDefect,
1558
+ GetActivityBranchFound,
1559
+ GetActivityBranchInvalidResponse,
1560
+ GetActivityBranchNotFound,
1561
+ GetActivityBranchProviderRejected,
1562
+ GetActivityDefinition,
1563
+ GetActivityInputSchema,
1564
+ GetActivityMetadata,
1565
+ GetActivityOperation,
1566
+ GetContactBranch,
1567
+ GetContactBranchDefect,
1568
+ GetContactBranchFound,
1569
+ GetContactBranchInvalidResponse,
1570
+ GetContactBranchNotFound,
1571
+ GetContactBranchProviderRejected,
1572
+ GetContactDefinition,
1573
+ GetContactInputSchema,
1574
+ GetContactListBranch,
1575
+ GetContactListBranchDefect,
1576
+ GetContactListBranchFound,
1577
+ GetContactListBranchInvalidResponse,
1578
+ GetContactListBranchNotFound,
1579
+ GetContactListBranchProviderRejected,
1580
+ GetContactListDefinition,
1581
+ GetContactListInputSchema,
1582
+ GetContactListMetadata,
1583
+ GetContactListOperation,
1584
+ GetContactMetadata,
1585
+ GetContactOperation,
1586
+ GetSegmentBranch,
1587
+ GetSegmentBranchDefect,
1588
+ GetSegmentBranchFound,
1589
+ GetSegmentBranchInvalidResponse,
1590
+ GetSegmentBranchNotFound,
1591
+ GetSegmentBranchProviderRejected,
1592
+ GetSegmentDefinition,
1593
+ GetSegmentInputSchema,
1594
+ GetSegmentMetadata,
1595
+ GetSegmentOperation,
1596
+ ListActivitiesBranch,
1597
+ ListActivitiesBranchDefect,
1598
+ ListActivitiesBranchInvalidResponse,
1599
+ ListActivitiesBranchListed,
1600
+ ListActivitiesBranchProviderRejected,
1601
+ ListActivitiesDefinition,
1602
+ ListActivitiesInputSchema,
1603
+ ListActivitiesMetadata,
1604
+ ListActivitiesOperation,
1605
+ ListContactListsBranch,
1606
+ ListContactListsBranchDefect,
1607
+ ListContactListsBranchInvalidResponse,
1608
+ ListContactListsBranchListed,
1609
+ ListContactListsBranchProviderRejected,
1610
+ ListContactListsDefinition,
1611
+ ListContactListsInputSchema,
1612
+ ListContactListsMetadata,
1613
+ ListContactListsOperation,
1614
+ ListContactsBranch,
1615
+ ListContactsBranchDefect,
1616
+ ListContactsBranchInvalidResponse,
1617
+ ListContactsBranchListed,
1618
+ ListContactsBranchProviderRejected,
1619
+ ListContactsDefinition,
1620
+ ListContactsInputSchema,
1621
+ ListContactsMetadata,
1622
+ ListContactsOperation,
1623
+ ListSegmentsBranch,
1624
+ ListSegmentsBranchDefect,
1625
+ ListSegmentsBranchInvalidResponse,
1626
+ ListSegmentsBranchListed,
1627
+ ListSegmentsBranchProviderRejected,
1628
+ ListSegmentsDefinition,
1629
+ ListSegmentsInputSchema,
1630
+ ListSegmentsMetadata,
1631
+ ListSegmentsOperation,
1632
+ ProviderID,
1633
+ SegmentMetadataSchema,
1634
+ SegmentsPageSchema,
1635
+ UpdateContactBranch,
1636
+ UpdateContactBranchDefect,
1637
+ UpdateContactBranchInvalidResponse,
1638
+ UpdateContactBranchNotFound,
1639
+ UpdateContactBranchProviderRejected,
1640
+ UpdateContactBranchUpdated,
1641
+ UpdateContactDefinition,
1642
+ UpdateContactInputSchema,
1643
+ UpdateContactListBranch,
1644
+ UpdateContactListBranchDefect,
1645
+ UpdateContactListBranchNotFound,
1646
+ UpdateContactListBranchProviderRejected,
1647
+ UpdateContactListBranchUpdated,
1648
+ UpdateContactListDefinition,
1649
+ UpdateContactListInputSchema,
1650
+ UpdateContactListMetadata,
1651
+ UpdateContactListOperation,
1652
+ UpdateContactMetadata,
1653
+ UpdateContactOperation,
1654
+ UpdateSegmentBranch,
1655
+ UpdateSegmentBranchDefect,
1656
+ UpdateSegmentBranchInvalidResponse,
1657
+ UpdateSegmentBranchNotFound,
1658
+ UpdateSegmentBranchProviderRejected,
1659
+ UpdateSegmentBranchUpdated,
1660
+ UpdateSegmentDefinition,
1661
+ UpdateSegmentInputSchema,
1662
+ UpdateSegmentMetadata,
1663
+ UpdateSegmentOperation,
1664
+ decodeCredentials,
1665
+ decodeSharedCredentials,
1666
+ decodeSignedInteger,
1667
+ exactIntegerJSONCodec,
1668
+ isCredentialMaterialError,
1669
+ newConnection,
1670
+ newConnectionWithOperations,
1671
+ newCreateContactListStep,
1672
+ newCreateContactStep,
1673
+ newCreateSegmentStep,
1674
+ newDeleteContactListStep,
1675
+ newDeleteContactStep,
1676
+ newDeleteSegmentStep,
1677
+ newGetActivityStep,
1678
+ newGetContactListStep,
1679
+ newGetContactStep,
1680
+ newGetSegmentStep,
1681
+ newListActivitiesStep,
1682
+ newListContactListsStep,
1683
+ newListContactsStep,
1684
+ newListSegmentsStep,
1685
+ newProjectConnection,
1686
+ newUpdateContactListStep,
1687
+ newUpdateContactStep,
1688
+ newUpdateSegmentStep,
1689
+ parseExactIntegerJSON,
1690
+ parseJSONNumberTokens
1691
+ };