@superdurable/connector-intuit-mailchimp 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,355 @@
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
+ "maxResponseBytes": z.number().int().optional(),
29
+ "pollIntervalMs": z.number().int().optional()
30
+ });
31
+ function decodeCredentials(value) {
32
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("credential fields are invalid");
33
+ const fields = value;
34
+ const allowed = /* @__PURE__ */ new Set(["api_key"]);
35
+ if (Object.keys(fields).some((key) => !allowed.has(key))) throw new TypeError("stored credential does not match the connector credential fields");
36
+ if (fields["api_key"] != null && !(typeof fields["api_key"] === "string")) throw new TypeError("credential api_key has an invalid type");
37
+ const credentials = {};
38
+ if (!fields["api_key"]) throw new TypeError("credential api_key is required");
39
+ credentials.apiKey = new SecretString(fields["api_key"] ?? "");
40
+ return credentials;
41
+ }
42
+ var GetMemberInputSchema = z.strictObject({
43
+ "listId": z.string(),
44
+ "emailAddress": z.string()
45
+ });
46
+ var MemberSchema = z.strictObject({
47
+ "subscriberHash": z.string(),
48
+ "emailAddress": z.string(),
49
+ "contactId": z.string().optional(),
50
+ "fullName": z.string().optional(),
51
+ "status": z.string(),
52
+ "emailType": z.string().optional(),
53
+ "mergeFields": z.record(z.string(), z.unknown().nullable()).optional(),
54
+ "tags": z.array(z.string()).optional(),
55
+ "tagCount": z.number().int(),
56
+ "isVip": z.boolean().optional(),
57
+ "language": z.string().optional(),
58
+ "listId": z.string(),
59
+ "webId": z.number().int().optional(),
60
+ "signedUpAt": GoTimeJSONSchema.nullable().optional(),
61
+ "optedInAt": GoTimeJSONSchema.nullable().optional(),
62
+ "lastChangedAt": GoTimeJSONSchema.nullable().optional()
63
+ });
64
+ var ListMembersInputSchema = z.strictObject({
65
+ "listId": z.string(),
66
+ "status": z.string().optional(),
67
+ "changedSince": GoTimeJSONSchema.nullable().optional(),
68
+ "optedInSince": GoTimeJSONSchema.nullable().optional(),
69
+ "pageSize": z.number().int().optional(),
70
+ "offset": z.number().int().optional()
71
+ });
72
+ var ListMembersOutputSchema = z.strictObject({
73
+ "members": z.array(MemberSchema).nullable(),
74
+ "totalItems": z.number().int(),
75
+ "nextOffset": z.number().int().optional()
76
+ });
77
+ var MarketingPermissionInputSchema = z.strictObject({
78
+ "marketingPermissionId": z.string(),
79
+ "isEnabled": z.boolean()
80
+ });
81
+ var UpsertMemberInputSchema = z.strictObject({
82
+ "listId": z.string(),
83
+ "emailAddress": z.string(),
84
+ "statusIfNew": z.string(),
85
+ "status": z.string().optional(),
86
+ "isResubscribeAllowed": z.boolean().optional(),
87
+ "mergeFields": z.record(z.string(), z.unknown().nullable()).optional(),
88
+ "marketingPermissions": z.array(MarketingPermissionInputSchema).optional(),
89
+ "shouldSkipMergeValidation": z.boolean().optional()
90
+ });
91
+ var UpsertMemberOutputSchema = z.strictObject({
92
+ "member": MemberSchema
93
+ });
94
+ var UpdateMemberTagsInputSchema = z.strictObject({
95
+ "listId": z.string(),
96
+ "emailAddress": z.string(),
97
+ "addTags": z.array(z.string()).optional(),
98
+ "removeTags": z.array(z.string()).optional(),
99
+ "shouldSuppressAutomations": z.boolean().optional()
100
+ });
101
+ var UpdateMemberTagsOutputSchema = z.strictObject({
102
+ "subscriberHash": z.string(),
103
+ "activeTags": z.array(z.string()).optional(),
104
+ "inactiveTags": z.array(z.string()).optional()
105
+ });
106
+ var SendCampaignInputSchema = z.strictObject({
107
+ "campaignId": z.string(),
108
+ "expectedListId": z.string().optional()
109
+ });
110
+ var CampaignSchema = z.strictObject({
111
+ "id": z.string(),
112
+ "webId": z.number().int().optional(),
113
+ "type": z.string(),
114
+ "status": z.string(),
115
+ "title": z.string().optional(),
116
+ "subjectLine": z.string().optional(),
117
+ "listId": z.string().optional(),
118
+ "listName": z.string().optional(),
119
+ "recipientCount": z.number().int(),
120
+ "emailsSent": z.number().int(),
121
+ "createdAt": GoTimeJSONSchema.nullable().optional(),
122
+ "sentAt": GoTimeJSONSchema.nullable().optional()
123
+ });
124
+ var SendCampaignOutputSchema = z.strictObject({
125
+ "campaign": CampaignSchema
126
+ });
127
+
128
+ // src/generated/definitions.ts
129
+ var ConnectorID = "mailchimp";
130
+ var ProviderID = "mailchimp";
131
+ var GetMemberBranch = {
132
+ Found: "found",
133
+ NotFound: "notFound",
134
+ ProviderRejected: "providerRejected",
135
+ InvalidResponse: "invalidResponse",
136
+ Defect: "defect"
137
+ };
138
+ var GetMemberBranchFound = GetMemberBranch.Found;
139
+ var GetMemberBranchNotFound = GetMemberBranch.NotFound;
140
+ var GetMemberBranchProviderRejected = GetMemberBranch.ProviderRejected;
141
+ var GetMemberBranchInvalidResponse = GetMemberBranch.InvalidResponse;
142
+ var GetMemberBranchDefect = GetMemberBranch.Defect;
143
+ var GetMemberDefinition = {
144
+ operation: { connectorId: ConnectorID, operationId: "getMember" },
145
+ branches: [
146
+ { id: "found", description: "The contact exists in the audience, in any status including unsubscribed, cleaned, or archived." },
147
+ { id: "notFound", description: "The audience has no contact with that address, or the audience does not exist.", optional: true },
148
+ { id: "providerRejected", description: "Mailchimp conclusively rejected the read, such as an invalid or revoked API key or a role without access.", optional: true },
149
+ { id: "invalidResponse", description: "Mailchimp returned an invalid or oversized contact.", optional: true },
150
+ { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
151
+ ],
152
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
153
+ };
154
+ var GetMemberMetadata = { kind: "query", idempotency: "none", authorization: "required" };
155
+ var ListMembersBranch = {
156
+ Listed: "listed",
157
+ NotFound: "notFound",
158
+ ProviderRejected: "providerRejected",
159
+ InvalidResponse: "invalidResponse",
160
+ Defect: "defect"
161
+ };
162
+ var ListMembersBranchListed = ListMembersBranch.Listed;
163
+ var ListMembersBranchNotFound = ListMembersBranch.NotFound;
164
+ var ListMembersBranchProviderRejected = ListMembersBranch.ProviderRejected;
165
+ var ListMembersBranchInvalidResponse = ListMembersBranch.InvalidResponse;
166
+ var ListMembersBranchDefect = ListMembersBranch.Defect;
167
+ var ListMembersDefinition = {
168
+ operation: { connectorId: ConnectorID, operationId: "listMembers" },
169
+ branches: [
170
+ { id: "listed", description: "One page of the audience's contacts was read; it may be empty." },
171
+ { id: "notFound", description: "The audience does not exist.", optional: true },
172
+ { id: "providerRejected", description: "Mailchimp conclusively rejected the list, such as an invalid API key or a role without access.", optional: true },
173
+ { id: "invalidResponse", description: "Mailchimp returned an invalid or oversized page of contacts.", optional: true },
174
+ { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
175
+ ],
176
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
177
+ };
178
+ var ListMembersMetadata = { kind: "query", idempotency: "none", authorization: "required" };
179
+ var UpsertMemberBranch = {
180
+ Upserted: "upserted",
181
+ ProviderRejected: "providerRejected",
182
+ InvalidResponse: "invalidResponse",
183
+ Defect: "defect"
184
+ };
185
+ var UpsertMemberBranchUpserted = UpsertMemberBranch.Upserted;
186
+ var UpsertMemberBranchProviderRejected = UpsertMemberBranch.ProviderRejected;
187
+ var UpsertMemberBranchInvalidResponse = UpsertMemberBranch.InvalidResponse;
188
+ var UpsertMemberBranchDefect = UpsertMemberBranch.Defect;
189
+ var UpsertMemberDefinition = {
190
+ operation: { connectorId: ConnectorID, operationId: "upsertMember" },
191
+ branches: [
192
+ { id: "upserted", description: "Mailchimp holds the contact with the requested values, written now or by an earlier attempt, and returned it." },
193
+ { id: "providerRejected", description: "Mailchimp conclusively rejected the contact, such as an invalid merge field, a permanently deleted address, or a contact in a compliance state; nothing was written.", optional: true },
194
+ { id: "invalidResponse", description: "Mailchimp returned an invalid or oversized contact, so the change may have been applied.", optional: true },
195
+ { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
196
+ ],
197
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" },
198
+ repeatOnUnknown: "safe"
199
+ };
200
+ var UpsertMemberMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
201
+ var UpdateMemberTagsBranch = {
202
+ Updated: "updated",
203
+ NotFound: "notFound",
204
+ ProviderRejected: "providerRejected",
205
+ InvalidResponse: "invalidResponse",
206
+ Defect: "defect"
207
+ };
208
+ var UpdateMemberTagsBranchUpdated = UpdateMemberTagsBranch.Updated;
209
+ var UpdateMemberTagsBranchNotFound = UpdateMemberTagsBranch.NotFound;
210
+ var UpdateMemberTagsBranchProviderRejected = UpdateMemberTagsBranch.ProviderRejected;
211
+ var UpdateMemberTagsBranchInvalidResponse = UpdateMemberTagsBranch.InvalidResponse;
212
+ var UpdateMemberTagsBranchDefect = UpdateMemberTagsBranch.Defect;
213
+ var UpdateMemberTagsDefinition = {
214
+ operation: { connectorId: ConnectorID, operationId: "updateMemberTags" },
215
+ branches: [
216
+ { id: "updated", description: "Mailchimp accepted the tag changes, including tags the contact already had or already lacked." },
217
+ { id: "notFound", description: "The audience has no contact with that address, or the audience does not exist; nothing was changed.", optional: true },
218
+ { id: "providerRejected", description: "Mailchimp conclusively rejected the tag changes, such as an invalid API key or a role without access.", optional: true },
219
+ { id: "invalidResponse", description: "Mailchimp accepted the request but returned an oversized or credential-reflecting body, so the tags may have changed.", optional: true },
220
+ { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
221
+ ],
222
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" },
223
+ repeatOnUnknown: "safe"
224
+ };
225
+ var UpdateMemberTagsMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
226
+ var SendCampaignBranch = {
227
+ Sent: "sent",
228
+ AlreadySent: "alreadySent",
229
+ NotSendable: "notSendable",
230
+ NotFound: "notFound",
231
+ ProviderRejected: "providerRejected",
232
+ InvalidResponse: "invalidResponse",
233
+ Uncertain: "uncertain",
234
+ Defect: "defect"
235
+ };
236
+ var SendCampaignBranchSent = SendCampaignBranch.Sent;
237
+ var SendCampaignBranchAlreadySent = SendCampaignBranch.AlreadySent;
238
+ var SendCampaignBranchNotSendable = SendCampaignBranch.NotSendable;
239
+ var SendCampaignBranchNotFound = SendCampaignBranch.NotFound;
240
+ var SendCampaignBranchProviderRejected = SendCampaignBranch.ProviderRejected;
241
+ var SendCampaignBranchInvalidResponse = SendCampaignBranch.InvalidResponse;
242
+ var SendCampaignBranchUncertain = SendCampaignBranch.Uncertain;
243
+ var SendCampaignBranchDefect = SendCampaignBranch.Defect;
244
+ var SendCampaignDefinition = {
245
+ operation: { connectorId: ConnectorID, operationId: "sendCampaign" },
246
+ branches: [
247
+ { id: "sent", description: "Mailchimp accepted the send of the draft campaign this Step read." },
248
+ { id: "alreadySent", description: "Mailchimp reports the campaign as sending or sent, so this attempt sent nothing.", optional: true },
249
+ { id: "notSendable", description: "The campaign is not a draft that can be sent now, such as a scheduled, paused, canceled, or RSS campaign, or it targets another audience than expectedListId; nothing was sent.", optional: true },
250
+ { id: "notFound", description: "The campaign does not exist; nothing was sent.", optional: true },
251
+ { id: "providerRejected", description: "Mailchimp conclusively rejected the send, such as a campaign that fails its send checklist or a role that cannot send; nothing was sent.", optional: true },
252
+ { id: "invalidResponse", description: "Mailchimp returned an invalid or oversized campaign before the send; nothing was sent.", optional: true },
253
+ { id: "uncertain", description: "The send request was sent but its outcome cannot be confirmed, so the campaign may be sending; the connector never sends it again.", optional: true },
254
+ { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
255
+ ],
256
+ stepDefaults: { executeMethodTimeoutMs: 6e4, executeDurability: "sync" },
257
+ repeatOnUnknown: "limited",
258
+ maxSends: 3
259
+ };
260
+ var SendCampaignMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
261
+
262
+ // src/generated/connection.ts
263
+ import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
264
+ var Connection = class {
265
+ /** Stable provider and connection name. */
266
+ reference;
267
+ /** Bound provider operations. */
268
+ operations;
269
+ /** Validate a reference and bind operations. */
270
+ constructor(reference, operations) {
271
+ this.reference = ConnectionRefSchema.parse(reference);
272
+ if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
273
+ if (!operations) throw new TypeError("connector operations are required");
274
+ this.operations = operations;
275
+ }
276
+ };
277
+ function newConnection(client, reference) {
278
+ if (!client) throw new TypeError("connector client is required");
279
+ return new Connection(reference, client);
280
+ }
281
+ function newConnectionWithOperations(operations, reference) {
282
+ return new Connection(reference, operations);
283
+ }
284
+ function newProjectConnection(project, connectionName, createClient) {
285
+ if (!project) throw new TypeError("loaded project is required");
286
+ const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
287
+ const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
288
+ if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
289
+ return newConnection(createClient(project, connectionName), reference);
290
+ }
291
+
292
+ export {
293
+ ConfigSchema,
294
+ decodeCredentials,
295
+ GetMemberInputSchema,
296
+ MemberSchema,
297
+ ListMembersInputSchema,
298
+ ListMembersOutputSchema,
299
+ MarketingPermissionInputSchema,
300
+ UpsertMemberInputSchema,
301
+ UpsertMemberOutputSchema,
302
+ UpdateMemberTagsInputSchema,
303
+ UpdateMemberTagsOutputSchema,
304
+ SendCampaignInputSchema,
305
+ CampaignSchema,
306
+ SendCampaignOutputSchema,
307
+ ConnectorID,
308
+ ProviderID,
309
+ GetMemberBranch,
310
+ GetMemberBranchFound,
311
+ GetMemberBranchNotFound,
312
+ GetMemberBranchProviderRejected,
313
+ GetMemberBranchInvalidResponse,
314
+ GetMemberBranchDefect,
315
+ GetMemberDefinition,
316
+ GetMemberMetadata,
317
+ ListMembersBranch,
318
+ ListMembersBranchListed,
319
+ ListMembersBranchNotFound,
320
+ ListMembersBranchProviderRejected,
321
+ ListMembersBranchInvalidResponse,
322
+ ListMembersBranchDefect,
323
+ ListMembersDefinition,
324
+ ListMembersMetadata,
325
+ UpsertMemberBranch,
326
+ UpsertMemberBranchUpserted,
327
+ UpsertMemberBranchProviderRejected,
328
+ UpsertMemberBranchInvalidResponse,
329
+ UpsertMemberBranchDefect,
330
+ UpsertMemberDefinition,
331
+ UpsertMemberMetadata,
332
+ UpdateMemberTagsBranch,
333
+ UpdateMemberTagsBranchUpdated,
334
+ UpdateMemberTagsBranchNotFound,
335
+ UpdateMemberTagsBranchProviderRejected,
336
+ UpdateMemberTagsBranchInvalidResponse,
337
+ UpdateMemberTagsBranchDefect,
338
+ UpdateMemberTagsDefinition,
339
+ UpdateMemberTagsMetadata,
340
+ SendCampaignBranch,
341
+ SendCampaignBranchSent,
342
+ SendCampaignBranchAlreadySent,
343
+ SendCampaignBranchNotSendable,
344
+ SendCampaignBranchNotFound,
345
+ SendCampaignBranchProviderRejected,
346
+ SendCampaignBranchInvalidResponse,
347
+ SendCampaignBranchUncertain,
348
+ SendCampaignBranchDefect,
349
+ SendCampaignDefinition,
350
+ SendCampaignMetadata,
351
+ Connection,
352
+ newConnection,
353
+ newConnectionWithOperations,
354
+ newProjectConnection
355
+ };