@drawbridge/drawbridge-utils 0.0.112 → 0.0.115

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.
@@ -13,10 +13,25 @@ var HOOKS = Object.freeze({
13
13
  // the credential can be valid and the grant still be too narrow.
14
14
  "scopes",
15
15
  // Revoke at the vendor and drop what we hold.
16
- "disconnect"
16
+ "disconnect",
17
+ // MINT A TOKEN — from a consent code, or from a stored refresh token. Both
18
+ // are the same POST, so they are one hook.
19
+ //
20
+ // The default body is authToken() in oauth.js and most vendors point
21
+ // straight at it. It is a hook rather than a declared flag because the
22
+ // vendors that differ, differ in ways config cannot express: Klaviyo needs
23
+ // HTTP Basic where others want body fields, and Mailchimp cannot use the
24
+ // token it receives until a second call tells it which data centre the
25
+ // account is behind.
26
+ "token"
17
27
  ]),
18
28
  // What happens around connecting and disconnecting, beyond the credential.
19
29
  lifecycle: Object.freeze([
30
+ // KEEP ACCESS WORKING. Rotate a credential before its window closes, prove
31
+ // it still works, and reconcile whatever the vendor has changed underneath
32
+ // — scopes, webhooks. Distinct from auth.probe, which only answers "is this
33
+ // still good": this one FIXES what it can and reports what it cannot.
34
+ "health",
20
35
  // Post-connect setup: register the vendor's webhooks, create the system
21
36
  // workflows that describe them.
22
37
  "register",
@@ -70,9 +85,63 @@ var HOOKS = Object.freeze({
70
85
  // carry them. The declaration is what proves the implementation exists.
71
86
  "process"
72
87
  ]),
73
- // Vendor data a campaign draws on. Named for what every store platform has,
74
- // not for what Shopify calls it: Shopify says discounts, Stripe says coupons
75
- // and promotion codes, BigCommerce says coupons and promotions.
88
+ // WHAT A WORKFLOW STEP DOES, as a verb like any other. Step handlers used to
89
+ // live in drawbridge-sync keyed by step type, which meant a vendor's logic sat
90
+ // in a repo the vendor file could not see — the split this whole exercise
91
+ // exists to close.
92
+ //
93
+ // A `steps` entry points at one of these; the step says when it runs and what
94
+ // it costs, the hook does the work.
95
+ contacts: Object.freeze([
96
+ // Forget a contact at the vendor. Distinct from suppression, which keeps the
97
+ // record and marks it unsubscribed: this is deletion, for account closure.
98
+ "remove",
99
+ // Push one contact into the audience the merchant chose, honouring
100
+ // suppression rather than omitting an opted-out person — omission lets them
101
+ // quietly reappear on the next sync.
102
+ "sync"
103
+ ]),
104
+ commerce: Object.freeze([
105
+ // Mint a discount code against this merchant's store, mapped to one lead.
106
+ "code",
107
+ // Create the buyer at the vendor, so an order can be attributed to them.
108
+ "customer",
109
+ // An order arrived at the vendor: attribute it, record it, update totals.
110
+ "order",
111
+ // Pull product data across on a vendor update.
112
+ "product"
113
+ ]),
114
+ // WHAT DRAWBRIDGE ITSELF DOES. These are not a third party's verbs — nobody
115
+ // connects an account to send email through Drawbridge — but they are steps a
116
+ // workflow runs, and a step points at a hook. So they live on a PRIVATE
117
+ // connection: one that contributes steps and never appears in the catalog.
118
+ //
119
+ // Without it the base steps stay the exception the shell has to know about,
120
+ // and "every step is a declaration pointing at a hook" stops being true the
121
+ // moment somebody looks at the six most common ones.
122
+ email: Object.freeze([
123
+ // To a lead. Suppression applies, and the send is billed.
124
+ "send",
125
+ // To organization members. Never suppressed — an entrant's opt-out must not
126
+ // silence an alert to staff — and never billed.
127
+ "notify",
128
+ // A batched summary to members.
129
+ "digest"
130
+ ]),
131
+ sms: Object.freeze(["send"]),
132
+ segment: Object.freeze(["sync"]),
133
+ // OUTBOUND DELIVERY to an address the merchant owns, rather than to a vendor.
134
+ // The Webhooks connection is the only thing here with no third party behind
135
+ // it, and the destination is per STEP rather than per connection.
136
+ webhook: Object.freeze(["send"]),
137
+ // Vendor data we READ — the things a merchant picks from. Named `resources`
138
+ // rather than `catalog` because it also holds audiences, and a catalog is a
139
+ // commerce word for something that is not only commerce. It matches the
140
+ // pickers that render it, too: InputResource and ListResource.
141
+ //
142
+ // The verbs are named for what every vendor has, not for what one calls it:
143
+ // Shopify says discounts, Stripe says coupons and promotion codes,
144
+ // BigCommerce says coupons and promotions.
76
145
  //
77
146
  // ONE SHAPE FOR ALL OF THEM — searchable and cursor-paged:
78
147
  //
@@ -92,7 +161,7 @@ var HOOKS = Object.freeze({
92
161
  // Shopify pushes the term into its GraphQL query, Klaviyo has a filter
93
162
  // parameter, and Mailchimp's /lists has no name filter at all so its hook
94
163
  // matches against what it fetched. The caller never learns which.
95
- catalog: Object.freeze([
164
+ resources: Object.freeze([
96
165
  // The named groups a contact can be synced INTO. Klaviyo calls them lists,
97
166
  // Mailchimp calls them audiences; `audiences` is the industry-generic term
98
167
  // and belongs to neither vendor's API. Read at form time, so a merchant
@@ -107,6 +176,37 @@ var HOOKS = Object.freeze({
107
176
  "promotions"
108
177
  ])
109
178
  });
179
+ var STEPS = Object.freeze({
180
+ "commerce.code.issue": "Issue discount code",
181
+ "commerce.customer.insert": "Create customer",
182
+ "commerce.order.record": "Record order",
183
+ "commerce.product.sync": "Sync product",
184
+ // Not commerce at all — connection lifecycle, and they generalise to any
185
+ // vendor holding a rotating credential.
186
+ "connection.health.check": "Connection health check",
187
+ "connection.token.exchange": "Exchange token",
188
+ "connection.token.refresh": "Refresh token",
189
+ "contacts.sync": "Sync contact",
190
+ "email.digest": "Digest",
191
+ "email.notify": "Notification",
192
+ "email.send": "Send email",
193
+ "segment.sync": "Sync segment",
194
+ "sms.send": "Send SMS",
195
+ "webhook.send": "Send webhook"
196
+ });
197
+ var RETIRED = Object.freeze({
198
+ "step.shopify.customer.insert": "step.commerce.customer.insert",
199
+ "step.shopify.discount.update": "step.commerce.code.issue",
200
+ "step.shopify.health.check": "step.connection.health.check",
201
+ "step.shopify.order.record": "step.commerce.order.record",
202
+ "step.shopify.product.sync": "step.commerce.product.sync",
203
+ "step.shopify.token.exchange": "step.connection.token.exchange",
204
+ "step.shopify.token.refresh": "step.connection.token.refresh"
205
+ });
206
+ var STEP_TYPES = Object.freeze(Object.keys(STEPS).map((name) => "step." + name));
207
+ var STEP_LABELS = Object.freeze(Object.fromEntries(
208
+ Object.entries(STEPS).map(([name, label]) => ["step." + name, label])
209
+ ));
110
210
  var HOOK_NAMES = Object.freeze(
111
211
  Object.entries(HOOKS).flatMap(([domain, verbs]) => verbs.map((verb) => domain + "." + verb))
112
212
  );
@@ -120,9 +220,11 @@ var OUTCOMES = Object.freeze({
120
220
  unimplemented: "unimplemented",
121
221
  unsupported: "unsupported"
122
222
  });
123
- var AUTH_TYPES = Object.freeze(["generated", "install", "keys", "oauth"]);
124
- var CATEGORIES = Object.freeze(["commerce", "contacts", "developer", "messaging"]);
125
- var OAUTH_FIELDS = Object.freeze(["authorize", "client", "redirect", "token"]);
223
+ var STATUSES = Object.freeze(["active", "disconnected", "error", "pending"]);
224
+ var AUTH_TYPES = Object.freeze(["generated", "install", "keys", "none", "oauth"]);
225
+ var GROUPS = Object.freeze(["commerce", "contacts", "developer", "messaging"]);
226
+ var OAUTH_FIELDS = Object.freeze(["client"]);
227
+ var OAUTH_URLS = Object.freeze(["authorize", "redirect", "token"]);
126
228
  var INPUTS = Object.freeze([
127
229
  "checkbox",
128
230
  "email",
@@ -136,12 +238,12 @@ var INPUTS = Object.freeze([
136
238
 
137
239
  // lib/connections/oauth.js
138
240
  import { createHash, randomBytes } from "crypto";
139
- var credentials = ({ clientId, clientSecret, descriptor }) => (descriptor == null ? void 0 : descriptor.clientAuth) === "basic" ? {
140
- headers: { authorization: "Basic " + Buffer.from(clientId + ":" + clientSecret).toString("base64") },
141
- body: {}
241
+ var credentials = ({ basic, clientId, clientSecret }) => basic ? {
242
+ body: {},
243
+ headers: { authorization: "Basic " + Buffer.from(clientId + ":" + clientSecret).toString("base64") }
142
244
  } : {
143
- headers: {},
144
- body: { client_id: clientId, client_secret: clientSecret }
245
+ body: { client_id: clientId, client_secret: clientSecret },
246
+ headers: {}
145
247
  };
146
248
  var pkcePair = () => {
147
249
  const verifier = randomBytes(32).toString("base64url");
@@ -152,10 +254,11 @@ var pkcePair = () => {
152
254
  };
153
255
  };
154
256
  var consentUrl = ({ challenge, clientId, descriptor, redirect, state } = {}) => {
257
+ var _a;
155
258
  if (!clientId) throw new Error("This deployment has no OAuth client configured, so there is nothing to consent through");
156
- if (!(descriptor == null ? void 0 : descriptor.authorize)) throw new Error("This connection declares no authorize url");
259
+ if (!((_a = descriptor == null ? void 0 : descriptor.urls) == null ? void 0 : _a.authorize)) throw new Error("This connection declares no authorize url");
157
260
  if (descriptor.pkce && !challenge) throw new Error("This connection requires PKCE, so a code challenge is not optional");
158
- return descriptor.authorize + "?" + new URLSearchParams({
261
+ return descriptor.urls.authorize + "?" + new URLSearchParams({
159
262
  // The descriptor's own params go FIRST, so a vendor quirk cannot quietly
160
263
  // overwrite one of the fields below that every consent carries.
161
264
  ...descriptor.params || {},
@@ -170,17 +273,33 @@ var consentUrl = ({ challenge, clientId, descriptor, redirect, state } = {}) =>
170
273
  state
171
274
  });
172
275
  };
173
- var exchange = async ({ clientId, clientSecret, code, descriptor, fetcher = fetch, redirect, verifier } = {}) => {
174
- if (!(descriptor == null ? void 0 : descriptor.token)) throw new Error("This connection declares no token url");
175
- if (descriptor.pkce && !verifier) throw new Error("This connection requires PKCE, so the code verifier is not optional");
176
- const client = credentials({ clientId, clientSecret, descriptor });
177
- const response = await fetcher(descriptor.token, {
276
+ var authToken = async ({
277
+ basic,
278
+ clientId,
279
+ clientSecret,
280
+ code: code2,
281
+ descriptor,
282
+ fetcher = fetch,
283
+ redirect,
284
+ refreshToken,
285
+ verifier
286
+ } = {}) => {
287
+ var _a;
288
+ if (!clientId || !clientSecret) throw new Error("This deployment has no OAuth client configured, so no token can be minted");
289
+ if (!((_a = descriptor == null ? void 0 : descriptor.urls) == null ? void 0 : _a.token)) throw new Error("This connection declares no token url");
290
+ const renewing = !code2;
291
+ if (renewing && !refreshToken) throw new Error("Nothing has been consented to yet, so there is no refresh token to spend");
292
+ if (!renewing && descriptor.pkce && !verifier) throw new Error("This connection requires PKCE, so the code verifier is not optional");
293
+ const client = credentials({ basic, clientId, clientSecret });
294
+ const response = await fetcher(descriptor.urls.token, {
178
295
  body: new URLSearchParams({
179
296
  ...client.body,
180
- code: decodeURIComponent(String(code || "").trim()),
181
- grant_type: "authorization_code",
182
- redirect_uri: redirect,
183
- ...descriptor.pkce && { code_verifier: verifier }
297
+ ...renewing ? { grant_type: "refresh_token", refresh_token: refreshToken } : {
298
+ code: decodeURIComponent(String(code2 || "").trim()),
299
+ grant_type: "authorization_code",
300
+ redirect_uri: redirect,
301
+ ...descriptor.pkce && { code_verifier: verifier }
302
+ }
184
303
  }),
185
304
  headers: { "content-type": "application/x-www-form-urlencoded", ...client.headers },
186
305
  method: "POST",
@@ -188,42 +307,26 @@ var exchange = async ({ clientId, clientSecret, code, descriptor, fetcher = fetc
188
307
  });
189
308
  const body = await response.json().catch(() => ({}));
190
309
  if (!response.ok) {
191
- throw new Error("The vendor refused the exchange (" + response.status + ")" + ((body == null ? void 0 : body.error) ? ": " + body.error : ""));
310
+ throw new Error(
311
+ renewing ? "The vendor refused the refresh token (" + response.status + ") \u2014 reconnect the connection" : "The vendor refused the exchange (" + response.status + ")" + ((body == null ? void 0 : body.error) ? ": " + body.error : "")
312
+ );
192
313
  }
193
- if (!body.access_token) throw new Error("The vendor returned no access token");
314
+ if (!renewing && !body.access_token) throw new Error("The vendor returned no access token");
194
315
  return {
195
316
  accessToken: body.access_token,
196
317
  expiresIn: body.expires_in || null,
318
+ // A REFRESH TOKEN IS NOT UNIVERSAL. Google returns one only with
319
+ // access_type=offline; Mailchimp's tokens do not expire and it returns none
320
+ // at all, so its absence cannot be an error here.
321
+ //
322
+ // On a RENEWAL the same null matters for the opposite reason: a vendor that
323
+ // rotates returns a new one, and dropping it silently invalidates the stored
324
+ // grant on the NEXT refresh — a failure a day late and nowhere near its
325
+ // cause. tokenSettings() keeps the existing one when this is null.
197
326
  refreshToken: body.refresh_token || null,
198
327
  scope: body.scope || null
199
328
  };
200
329
  };
201
- var refresh = async ({ clientId, clientSecret, descriptor, fetcher = fetch, refreshToken } = {}) => {
202
- if (!clientId || !clientSecret) throw new Error("This deployment has no OAuth client configured, so no token can be minted");
203
- if (!refreshToken) throw new Error("Nothing has been consented to yet, so there is no refresh token to spend");
204
- if (!(descriptor == null ? void 0 : descriptor.token)) throw new Error("This connection declares no token url");
205
- const client = credentials({ clientId, clientSecret, descriptor });
206
- const response = await fetcher(descriptor.token, {
207
- body: new URLSearchParams({
208
- ...client.body,
209
- grant_type: "refresh_token",
210
- refresh_token: refreshToken
211
- }),
212
- headers: { "content-type": "application/x-www-form-urlencoded", ...client.headers },
213
- method: "POST",
214
- signal: AbortSignal.timeout(15e3)
215
- });
216
- if (!response.ok) throw new Error("The vendor refused the refresh token (" + response.status + ") \u2014 reconnect the connection");
217
- const body = await response.json();
218
- return {
219
- accessToken: body.access_token,
220
- expiresIn: body.expires_in || null,
221
- // A vendor that rotates its refresh token returns a new one, and dropping
222
- // it silently invalidates the stored grant on the NEXT refresh rather
223
- // than this one — a failure a day late and nowhere near its cause.
224
- refreshToken: body.refresh_token || null
225
- };
226
- };
227
330
 
228
331
  // lib/connections/token.js
229
332
  var SKEW_SECONDS = 120;
@@ -263,7 +366,7 @@ var accessToken = async ({
263
366
  if (!settings.refreshToken) {
264
367
  throw new Error("This connection has expired and cannot be renewed automatically. Reconnect it.");
265
368
  }
266
- const minted = await refresh({
369
+ const minted = await manifest.hooks.auth.token({
267
370
  clientId,
268
371
  clientSecret,
269
372
  descriptor: manifest.auth.oauth,
@@ -275,6 +378,1211 @@ var accessToken = async ({
275
378
  return next.accessToken;
276
379
  };
277
380
 
381
+ // lib/connections/icons/attentive.js
382
+ var attentive_default = `<svg width="500" height="500" viewBox="0 0 500 500" fill="none" xmlns="http://www.w3.org/2000/svg">
383
+ <rect width="500" height="500" fill="#FFD967"/>
384
+ <path d="M239.369 127.404C260.863 122.013 284.964 132.569 295.576 152.039C321.796 201.286 347.928 250.567 374.131 299.825C380.149 311.989 381.244 326.564 376.733 339.41C371.446 355.097 358.039 367.69 342.107 372.089C326.274 376.67 308.351 372.871 295.741 362.255C288.865 356.892 284.161 349.359 280.354 341.629C261.869 306.95 243.478 272.217 225.071 237.501C214.409 218.614 187.221 212.656 169.622 225.315C168.104 227.309 164.159 226.857 164.72 223.796C176.911 202.569 189.361 181.497 201.662 160.331C205.183 154.428 208.214 148.129 212.967 143.091C219.844 135.272 229.263 129.782 239.374 127.404" fill="#1E1C1C"/>
385
+ <path d="M166.04 261.805C180.228 259.107 195.528 261.893 207.581 269.971C218.512 277.079 226.908 288.136 230.604 300.657C234.835 314.103 233.614 329.124 227.485 341.788C220.097 356.875 205.782 368.543 189.317 372.089C173.957 375.652 157.089 372.386 144.304 363.103C132.971 355.295 124.912 342.989 121.891 329.581C118.943 316.636 120.725 302.656 127.002 290.938C134.699 275.951 149.503 264.933 166.046 261.811" fill="#1E1C1C"/>
386
+ </svg>`;
387
+
388
+ // lib/connections/attentive.js
389
+ var attentive_default2 = {
390
+ auth: {
391
+ oauth: {
392
+ // NAMES of the env vars holding OUR app's client — set at registration,
393
+ // never before. No `headers` on the client: Attentive takes credentials
394
+ // as form fields, which is the runner's default.
395
+ client: {
396
+ id: "ATTENTIVE_OAUTH_CLIENT_ID",
397
+ secret: "ATTENTIVE_OAUTH_CLIENT_SECRET"
398
+ },
399
+ urls: {
400
+ authorize: "https://ui.attentivemobile.com/integrations/oauth-install",
401
+ redirect: "/api/connection/attentive/callback",
402
+ token: "https://api.attentivemobile.com/v1/authorization-codes/tokens"
403
+ }
404
+ },
405
+ type: "oauth"
406
+ },
407
+ // EVERYTHING A MERCHANT READS. `errors` would live in here too — the
408
+ // connection DOCUMENT carries its own `errors` array and is spread OVER the
409
+ // resolved manifest downstream, so a top-level one would never render.
410
+ content: {
411
+ confirm: "Disconnecting revokes Drawbridge's access to your Attentive account. Your subscribers stay in both Attentive and Drawbridge \u2014 neither list is deleted.",
412
+ description: [
413
+ "Attentive is where your SMS marketing lives, and this connection is becoming the way your Drawbridge contacts sync into an Attentive segment.",
414
+ "You authorize Drawbridge from inside Attentive and can revoke that access there at any time. Drawbridge never sees or stores your Attentive password.",
415
+ "Subscriber syncing is not live yet, so connecting today does nothing except choose the segment it will use when it ships."
416
+ ],
417
+ excerpt: "Sync your Drawbridge contacts into an Attentive segment.",
418
+ guide: [
419
+ "Press Connect. Drawbridge sends you to Attentive to approve access.",
420
+ "Sign in to Attentive if you are not already, and authorize the permissions listed.",
421
+ "You are returned here \u2014 choose which Attentive segment your contacts should sync into."
422
+ ]
423
+ },
424
+ // A contact destination, like Klaviyo and Mailchimp — a merchant could
425
+ // reasonably keep several up to date at once.
426
+ exclusive: false,
427
+ feature: "organization:connection:attentive",
428
+ fields: [
429
+ {
430
+ input: "select",
431
+ key: "segment",
432
+ label: "Attentive segment",
433
+ message: "Contacts your campaigns collect are synced into this segment.",
434
+ hook: "resources.audiences",
435
+ required: true
436
+ // No `search : false` here, and that is a first: /v2/segments takes a
437
+ // `name` filter (partial match, cited above), so this picker searches
438
+ // the ACCOUNT — Klaviyo and Mailchimp can only match the fetched page.
439
+ }
440
+ ],
441
+ group: "contacts",
442
+ // A HOOK'S VALUE IS ITS ANSWER. The consent is stored and can be revoked;
443
+ // nothing else is built yet, because subscriber sync has not shipped. Every
444
+ // false here is "not yet" rather than "never" — when the sync lands, probe
445
+ // and contacts.sync are the first to flip.
446
+ hooks: {
447
+ auth: {
448
+ // The exchange already yields the tokens, and Attentive documents no
449
+ // account-identity endpoint to enrich them with — Klaviyo's connect
450
+ // reads the account name back; this has nothing cited to read. The
451
+ // callback stores the tokens and skips enrichment on `unimplemented`.
452
+ connect: {},
453
+ disconnect: {},
454
+ probe: false,
455
+ scopes: false,
456
+ // THE ONE THING WRAPPED, and it is about the response rather than the
457
+ // request. Attentive's token reply carries expires_in : 900 while their
458
+ // auth overview says access tokens "do not expire" — and no refresh
459
+ // token exists to renew with. Storing that expiry would have
460
+ // accessToken() declaring the credential spent fifteen minutes after
461
+ // consent, with nothing to renew it: every connection would demand
462
+ // reconnecting four times an hour.
463
+ //
464
+ // The overview's answer is modelled — the expiry is dropped, so the
465
+ // token is treated as long-lived. Registration item 1 in the header is
466
+ // the live exchange that proves this right or wrong.
467
+ token: async (args) => {
468
+ const minted = await authToken(args);
469
+ return { ...minted, expiresIn: null };
470
+ }
471
+ },
472
+ commerce: false,
473
+ contacts: { remove: false, sync: false },
474
+ email: false,
475
+ inbound: false,
476
+ lifecycle: false,
477
+ resources: {
478
+ // The segments a merchant can sync into, for the picker on their
479
+ // connection.
480
+ //
481
+ // GET /v2/segments (cited in the header). `limit` caps at 1000 in their
482
+ // own spec, defaulting to 20 — low enough that leaving it unset would
483
+ // show a picker quietly missing most of a real account. The response's
484
+ // only identifier is `externalId`, so an entry without one cannot be
485
+ // stored and is dropped.
486
+ audiences: async ({ cursor, fetcher = fetch, limit = 100, search, token }) => {
487
+ const query = new URLSearchParams({
488
+ limit: String(Math.min(limit, 1e3)),
489
+ ...cursor && { cursor },
490
+ ...(search == null ? void 0 : search.value) && { name: String(search.value).trim() }
491
+ });
492
+ const response = await fetcher(
493
+ "https://api.attentivemobile.com/v2/segments?" + query,
494
+ {
495
+ headers: { authorization: "Bearer " + token },
496
+ signal: AbortSignal.timeout(15e3)
497
+ }
498
+ );
499
+ if (!response.ok) {
500
+ throw Object.assign(
501
+ new Error("Attentive refused the request (" + response.status + ")"),
502
+ { status: response.status }
503
+ );
504
+ }
505
+ const body = await response.json();
506
+ return {
507
+ items: ((body == null ? void 0 : body.segments) || []).filter((segment) => segment == null ? void 0 : segment.externalId).map((segment) => ({ id: segment.externalId, title: (segment == null ? void 0 : segment.name) || segment.externalId })),
508
+ pageInfo: {
509
+ endCursor: (body == null ? void 0 : body.hasMore) ? (body == null ? void 0 : body.cursor) || null : null,
510
+ hasNextPage: Boolean(body == null ? void 0 : body.hasMore)
511
+ }
512
+ };
513
+ },
514
+ prices: false,
515
+ products: false,
516
+ promotions: false
517
+ },
518
+ segment: false,
519
+ sms: false,
520
+ webhook: false
521
+ },
522
+ icon: attentive_default,
523
+ requires: [
524
+ "ATTENTIVE_OAUTH_CLIENT_ID",
525
+ "ATTENTIVE_OAUTH_CLIENT_SECRET"
526
+ ],
527
+ slug: "attentive",
528
+ // A consent with no segment chosen is authenticated and inert — the sync,
529
+ // when it ships, needs somewhere to put people.
530
+ status: (data2) => {
531
+ var _a;
532
+ return ((_a = data2 == null ? void 0 : data2.settings) == null ? void 0 : _a.segment) ? data2.status : "pending";
533
+ },
534
+ // No steps: subscriber sync has not shipped, so this vendor contributes
535
+ // nothing to a workflow yet. An empty steps object is the honest declaration.
536
+ steps: {},
537
+ tasks: (data2) => {
538
+ var _a;
539
+ return [
540
+ ...((_a = data2 == null ? void 0 : data2.settings) == null ? void 0 : _a.segment) ? [] : [
541
+ {
542
+ message: "Choose which Attentive segment your contacts should sync into. Until you do, nothing is being synced.",
543
+ title: "Choose a segment"
544
+ }
545
+ ],
546
+ {
547
+ message: "Contact syncing to Attentive segments has not shipped yet. Nothing is being sent to Attentive right now.",
548
+ title: "Subscriber sync not available yet",
549
+ type: "warning"
550
+ }
551
+ ];
552
+ },
553
+ title: "Attentive"
554
+ };
555
+
556
+ // lib/connections/icons/drawbridge.js
557
+ var drawbridge_default = `<svg width="500" height="500" viewBox="0 0 500 500" fill="none" xmlns="http://www.w3.org/2000/svg">
558
+ <rect width="500" height="500" fill="#BAEC5F"/>
559
+ <g clip-path="url(#clip0_2115_2832)">
560
+ <path d="M140.224 127.586L174.803 188.73V311.176L140 372.32L176.084 392.031L216.111 321.753V178.278L176.341 108L140.224 127.586Z" fill="#0D1314"/>
561
+ <path d="M360.001 127.523L323.693 108.282L284.948 178.498V321.596L322.923 391.749L359.393 372.79L326.224 311.52V188.73L360.001 127.523Z" fill="#0D1314"/>
562
+ </g>
563
+ <defs>
564
+ <clipPath id="clip0_2115_2832">
565
+ <rect width="220" height="284" fill="white" transform="translate(140 108)"/>
566
+ </clipPath>
567
+ </defs>
568
+ </svg>`;
569
+
570
+ // lib/features.js
571
+ var page = {
572
+ qrcode: {
573
+ key: "page:qrcode",
574
+ error: "Plan does not include qrcodes",
575
+ feature: "Page qrcode management"
576
+ },
577
+ shortcode: {
578
+ key: "page:shortcode",
579
+ error: "Plan does not include shortcodes",
580
+ feature: "Page shortcode management"
581
+ },
582
+ slug: {
583
+ key: "page:slug",
584
+ error: "Plan does not include url customization",
585
+ feature: "Page slug customization"
586
+ }
587
+ };
588
+ var fields = {
589
+ additional: {
590
+ key: "campaign:fields:additional",
591
+ error: "Plan does not include additional fields",
592
+ feature: "Campaign additional fields"
593
+ },
594
+ lead: {
595
+ key: "campaign:fields:lead",
596
+ error: "Plan does not include lead fields",
597
+ feature: "Campaign lead fields"
598
+ }
599
+ };
600
+ var field = {
601
+ email: {
602
+ key: "campaign:field:email",
603
+ error: "Plan does not include email field",
604
+ feature: "Campaign email field"
605
+ },
606
+ name: {
607
+ key: "campaign:field:name",
608
+ error: "Plan does not include name field",
609
+ feature: "Campaign name field"
610
+ },
611
+ number: {
612
+ key: "campaign:field:number",
613
+ error: "Plan does not include number field",
614
+ feature: "Campaign number field"
615
+ },
616
+ phone: {
617
+ key: "campaign:field:phone",
618
+ error: "Plan does not include phone field",
619
+ feature: "Campaign phone field"
620
+ },
621
+ select: {
622
+ key: "campaign:field:select",
623
+ error: "Plan does not include dropdown field",
624
+ feature: "Campaign dropdown field"
625
+ },
626
+ text: {
627
+ key: "campaign:field:text",
628
+ error: "Plan does not include short text field",
629
+ feature: "Campaign short text field"
630
+ },
631
+ textarea: {
632
+ key: "campaign:field:textarea",
633
+ error: "Plan does not include long text field",
634
+ feature: "Campaign long text field"
635
+ }
636
+ };
637
+ var connection = {
638
+ attentive: {
639
+ key: "organization:connection:attentive",
640
+ error: "Plan does not include Attentive connection",
641
+ feature: "Attentive connection"
642
+ },
643
+ // Klaviyo shipped without an entry here, which meant no plan GRANTED its
644
+ // key and the feature gate denied every non-admin request — a latent 403
645
+ // found while adding Attentive. getPlanFeature answers granted:false for a
646
+ // key absent from the plan's map, so a manifest feature key that appears in
647
+ // no plan list is a connection only admins can manage.
648
+ klaviyo: {
649
+ key: "organization:connection:klaviyo",
650
+ error: "Plan does not include Klaviyo connection",
651
+ feature: "Klaviyo connection"
652
+ },
653
+ mailchimp: {
654
+ key: "organization:connection:mailchimp",
655
+ error: "Plan does not include Mailchimp connection",
656
+ feature: "Mailchimp connection"
657
+ },
658
+ sendgrid: {
659
+ key: "organization:connection:sendgrid",
660
+ error: "Plan does not include SendGrid connection",
661
+ feature: "SendGrid connection"
662
+ },
663
+ shopify: {
664
+ key: "organization:connection:shopify",
665
+ error: "Plan does not include Shopify connection",
666
+ feature: "Shopify connection"
667
+ },
668
+ twilio: {
669
+ key: "organization:connection:twilio",
670
+ error: "Plan does not include Twilio connection",
671
+ feature: "Twilio connection"
672
+ },
673
+ webhook: {
674
+ key: "organization:connection:webhook",
675
+ error: "Plan does not include Webhook connection",
676
+ feature: "Webhook connection"
677
+ }
678
+ };
679
+ var organization = {
680
+ advertisements: {
681
+ key: "organization:advertisements",
682
+ error: "Your plan does not include advertisements",
683
+ feature: "Organization advertisement management"
684
+ },
685
+ affiliates: {
686
+ key: "organization:affiliates",
687
+ error: "Your plan does not include affiliates",
688
+ feature: "Organization affiliates management"
689
+ },
690
+ analytics: {
691
+ key: "organization:analytics",
692
+ error: "Your plan does not include analytics",
693
+ feature: "Organization analytics management"
694
+ },
695
+ brands: {
696
+ key: "organization:brands",
697
+ error: "Your plan does not include brands",
698
+ feature: "Organization brands management"
699
+ },
700
+ // Gates the Networking section as a whole — a verified sending domain today,
701
+ // the SMS number and a custom page domain as they land. One key rather than
702
+ // one per type: they are the same capability to a merchant, and splitting
703
+ // them would mean a plan could grant half a section.
704
+ //
705
+ // It replaces `connection.sender`, which named a connection this stopped
706
+ // being. Free organizations cannot send lead-facing email at all, so a
707
+ // sending identity there is one they could never send from.
708
+ networking: {
709
+ key: "organization:networking",
710
+ error: "Your plan does not include a custom sending identity",
711
+ feature: "Organization networking"
712
+ },
713
+ members: {
714
+ key: "organization:members",
715
+ error: "Your plan does not include team members",
716
+ feature: "Organization members management"
717
+ },
718
+ reports: {
719
+ key: "organization:report",
720
+ error: "Plan does not include report generation",
721
+ feature: "Organization report generation"
722
+ },
723
+ subdomain: {
724
+ key: "organization:subdomain",
725
+ error: "Plan does not include subdomain customization",
726
+ feature: "Organization subdomain customization"
727
+ }
728
+ };
729
+
730
+ // index.js
731
+ import { code, data } from "currency-codes";
732
+ import { customAlphabet } from "nanoid";
733
+
734
+ // lib/color.js
735
+ import tinycolor from "tinycolor2";
736
+ var colorFormatted = (value) => {
737
+ const color = tinycolor(value);
738
+ const attributes = {
739
+ brightness: color.getBrightness(),
740
+ dark: color.isDark(),
741
+ light: color.isLight(),
742
+ luminance: color.getLuminance()
743
+ };
744
+ return {
745
+ attributes,
746
+ hex: color.toHexString(),
747
+ hsl: color.toHsl(),
748
+ hsv: color.toHsv(),
749
+ rgb: color.toRgbString()
750
+ };
751
+ };
752
+ var colorAccessible = (background2) => {
753
+ const white = "#ffffff";
754
+ const black = "#000000";
755
+ return tinycolor.isReadable(
756
+ background2,
757
+ white,
758
+ {
759
+ level: "AA",
760
+ size: "normal"
761
+ }
762
+ ) ? white : black;
763
+ };
764
+
765
+ // lib/constants.js
766
+ var font = {
767
+ family: "Roboto Flex",
768
+ transform: "none",
769
+ weight: "regular"
770
+ };
771
+ var background = "#ffffff";
772
+ var style = {
773
+ background: {
774
+ color: colorFormatted(background)
775
+ },
776
+ body: font,
777
+ button: {
778
+ background: {
779
+ color: colorFormatted(background)
780
+ },
781
+ radius: 0,
782
+ text: {
783
+ color: colorFormatted(colorAccessible(background))
784
+ }
785
+ },
786
+ heading: font,
787
+ input: {
788
+ radius: 0
789
+ },
790
+ text: {
791
+ color: colorFormatted(colorAccessible(background))
792
+ }
793
+ };
794
+
795
+ // index.js
796
+ var nanoid = customAlphabet("0123456789abcdefghijklmnopqrstuvwxyz", 8);
797
+ var infinite = 1e300;
798
+ var megabyte = 1024 * 1024;
799
+ var gigabyte = megabyte * 1024;
800
+ var currencies = data.map((item) => ({
801
+ ...item,
802
+ key: item.currency,
803
+ value: item.code
804
+ }));
805
+
806
+ // lib/plans.js
807
+ var featuresFor = (array = []) => Object.values({
808
+ ...connection,
809
+ ...organization,
810
+ ...fields,
811
+ ...field,
812
+ ...page
813
+ }).reduce(
814
+ (accumulator, { key, error, feature }) => {
815
+ if (array.includes(key)) {
816
+ accumulator.granted[key] = feature;
817
+ } else {
818
+ accumulator.denied[key] = error;
819
+ }
820
+ return accumulator;
821
+ },
822
+ { denied: {}, granted: {} }
823
+ );
824
+ var overage = (actionCents) => ({
825
+ actionCents,
826
+ overages: { actions: String(actionCents) }
827
+ });
828
+ var all = {
829
+ features: (array = []) => featuresFor([
830
+ connection.attentive.key,
831
+ connection.klaviyo.key,
832
+ connection.mailchimp.key,
833
+ connection.sendgrid.key,
834
+ connection.shopify.key,
835
+ connection.twilio.key,
836
+ connection.webhook.key,
837
+ organization.affiliates.key,
838
+ organization.brands.key,
839
+ fields.additional.key,
840
+ fields.lead.key,
841
+ field.email.key,
842
+ field.name.key,
843
+ field.number.key,
844
+ field.phone.key,
845
+ field.select.key,
846
+ field.text.key,
847
+ field.textarea.key,
848
+ page.qrcode.key,
849
+ page.shortcode.key,
850
+ ...array
851
+ ]),
852
+ // `members` and `storage` default to infinite so an unnamed term on a custom
853
+ // plan reads as UNLIMITED rather than absent. Storage used to have no
854
+ // default, so a deal that did not name it resolved to undefined and the
855
+ // organization's usage card simply omitted the row — the same blank field
856
+ // that showed "Unlimited" for members showed nothing at all for storage.
857
+ // Every catalog plan names both, so the defaults only ever apply to a
858
+ // custom plan. `actions` has no default on purpose: an unnamed allowance
859
+ // bills nothing, which is why the availability switch refuses to flip
860
+ // without one.
861
+ limits: ({ actions, members = infinite, storage = infinite }) => ({
862
+ campaign: {
863
+ advertisements: infinite,
864
+ links: infinite,
865
+ fields: infinite,
866
+ pages: infinite
867
+ },
868
+ organization: {
869
+ actions,
870
+ affiliates: infinite,
871
+ brands: infinite,
872
+ campaigns: infinite,
873
+ members,
874
+ storage
875
+ }
876
+ })
877
+ };
878
+ var free = {
879
+ conversion: 3,
880
+ features: all.features(),
881
+ limits: all.limits({
882
+ actions: 200,
883
+ members: 0,
884
+ storage: gigabyte * 5
885
+ }),
886
+ title: "Free"
887
+ };
888
+ var plans = {
889
+ DB00002: {
890
+ // A verified sending domain is a PAID capability: free plans cannot send
891
+ // lead-facing email at all (the send path gates on an active
892
+ // subscription), so granting it there would offer a domain that can
893
+ // never send from.
894
+ features: all.features([organization.networking.key, organization.members.key]),
895
+ limits: all.limits({ actions: 5e3, members: 3, storage: gigabyte * 10 }),
896
+ marketing: {
897
+ description: "Tools to fine-tune campaigns and improve lead quality.",
898
+ features: [],
899
+ limits: [
900
+ ["Actions per month", "5,000"],
901
+ ["Affiliates", "Unlimited"],
902
+ ["Brands", "Unlimited"],
903
+ ["Campaigns", "Unlimited"],
904
+ ["Pages", "Unlimited"],
905
+ ["Members", "3"],
906
+ ["Storage", "10GB"]
907
+ ]
908
+ },
909
+ ...overage(2.5),
910
+ title: "Starter",
911
+ conversion: 2
912
+ },
913
+ DB00003: {
914
+ features: all.features([
915
+ organization.networking.key,
916
+ organization.advertisements.key,
917
+ organization.analytics.key,
918
+ organization.members.key,
919
+ organization.subdomain.key,
920
+ page.slug.key
921
+ ]),
922
+ limits: all.limits({ actions: 15e3, members: 5, storage: gigabyte * 20 }),
923
+ marketing: {
924
+ description: "Expand your reach and grow your lead pipeline.",
925
+ features: [
926
+ "Analytics",
927
+ "Custom subdomain / URLs",
928
+ "Confirmation page ads"
929
+ ],
930
+ limits: [
931
+ ["Actions per month", "15,000"],
932
+ ["Affiliates", "Unlimited"],
933
+ ["Brands", "Unlimited"],
934
+ ["Campaigns", "Unlimited"],
935
+ ["Pages", "Unlimited"],
936
+ ["Members", "5"],
937
+ ["Storage", "20GB"]
938
+ ]
939
+ },
940
+ ...overage(2),
941
+ title: "Pro",
942
+ conversion: 1.5
943
+ },
944
+ DB00004: {
945
+ features: all.features([
946
+ organization.networking.key,
947
+ organization.advertisements.key,
948
+ organization.analytics.key,
949
+ organization.members.key,
950
+ organization.subdomain.key,
951
+ page.slug.key
952
+ ]),
953
+ limits: all.limits({ actions: 4e4, members: 10, storage: gigabyte * 50 }),
954
+ marketing: {
955
+ description: "Accelerate acquisition with more power and flexibility.",
956
+ features: [
957
+ "Analytics",
958
+ "Custom subdomain / URLs",
959
+ "Confirmation page ads"
960
+ ],
961
+ limits: [
962
+ ["Actions per month", "40,000"],
963
+ ["Affiliates", "Unlimited"],
964
+ ["Brands", "Unlimited"],
965
+ ["Campaigns", "Unlimited"],
966
+ ["Pages", "Unlimited"],
967
+ ["Members", "10"],
968
+ ["Storage", "50GB"]
969
+ ]
970
+ },
971
+ ...overage(1.85),
972
+ title: "Premium",
973
+ conversion: 1
974
+ },
975
+ DB00005: {
976
+ features: all.features([
977
+ organization.networking.key,
978
+ organization.advertisements.key,
979
+ organization.analytics.key,
980
+ organization.members.key,
981
+ organization.subdomain.key,
982
+ page.slug.key
983
+ ]),
984
+ limits: all.limits({ actions: 1e5, members: infinite, storage: gigabyte * 100 }),
985
+ marketing: {
986
+ description: "Built for brands focused on results.",
987
+ features: [
988
+ "Analytics",
989
+ "Custom subdomain / URLs",
990
+ "Confirmation page ads"
991
+ ],
992
+ limits: [
993
+ ["Actions per month", "100,000"],
994
+ ["Affiliates", "Unlimited"],
995
+ ["Brands", "Unlimited"],
996
+ ["Campaigns", "Unlimited"],
997
+ ["Pages", "Unlimited"],
998
+ ["Members", "Unlimited"],
999
+ ["Storage", "100GB"]
1000
+ ]
1001
+ },
1002
+ ...overage(1.5),
1003
+ title: "Elite",
1004
+ conversion: 0.5
1005
+ }
1006
+ };
1007
+
1008
+ // lib/transactions.js
1009
+ import { currentTraceId } from "@drawbridge/drawbridge-telemetry";
1010
+
1011
+ // lib/billing.js
1012
+ import { createLogger } from "@drawbridge/drawbridge-telemetry";
1013
+ var logger = createLogger();
1014
+ var MARKUP = 1.3;
1015
+ var cost = {
1016
+ // gemini-3.5-flash — verified against Google's pricing page 2026-07-09:
1017
+ // $0.15 cached / $1.50 input / $9.00 output per 1M tokens (thinking billed at
1018
+ // output). ~3.6x the retired 2.5-flash output rate.
1019
+ "gemini-3.5-flash": {
1020
+ cached: 15,
1021
+ input: 150,
1022
+ output: 900
1023
+ },
1024
+ // gemini-3.5-flash-lite — verified against Google's pricing page 2026-08-20:
1025
+ // $0.03 cached / $0.30 input / $2.50 output per 1M tokens (thinking billed at
1026
+ // output). A fifth of flash on input, ~a quarter on output. Growth's assistant
1027
+ // ranks the feed on this tier — one call per page — so its rows were the
1028
+ // unpriced ones until now.
1029
+ "gemini-3.5-flash-lite": {
1030
+ cached: 3,
1031
+ input: 30,
1032
+ output: 250
1033
+ },
1034
+ "gemini-2.5-flash": {
1035
+ cached: 3,
1036
+ input: 30,
1037
+ output: 250
1038
+ },
1039
+ "gemini-2.5-flash-image": {
1040
+ cached: 3,
1041
+ input: 30,
1042
+ output: 3e3
1043
+ },
1044
+ // gemini-3-pro-image-preview — verified against Google's pricing page
1045
+ // 2026-08-12: $2.00 input / $12.00 text output per 1M, and image output
1046
+ // tokens at ~$120/1M (a 1K-2K image is 1120 tokens = $0.134, a 4K image
1047
+ // 2000 tokens = $0.24). Encoded the flash-image way: one flat output rate
1048
+ // that reproduces the per-image price from the tokens usageMetadata
1049
+ // reports. Growth's hero generation runs this model today.
1050
+ "gemini-3-pro-image-preview": {
1051
+ cached: 20,
1052
+ input: 200,
1053
+ output: 12e3
1054
+ }
1055
+ };
1056
+ var toolCost = {
1057
+ search: 3.5
1058
+ };
1059
+ var toolPricing = Object.fromEntries(
1060
+ Object.entries(toolCost).map(([tool, value]) => [
1061
+ tool,
1062
+ Math.ceil(value * MARKUP)
1063
+ ])
1064
+ );
1065
+ var pricing = Object.fromEntries(
1066
+ Object.entries(cost).map(([model, rates]) => [
1067
+ model,
1068
+ {
1069
+ cached: Math.round(rates.cached * MARKUP),
1070
+ input: Math.round(rates.input * MARKUP),
1071
+ output: Math.round(rates.output * MARKUP)
1072
+ }
1073
+ ])
1074
+ );
1075
+
1076
+ // lib/pricing.js
1077
+ var emailPlans = {
1078
+ essentials50k: {
1079
+ included: 5e4,
1080
+ // The plan's own price is not shown in the console once you are on it —
1081
+ // it reads "Your Current Plan" where the price would be. Left null rather
1082
+ // than guessed; fill from an invoice. Nothing derives from it yet, and an
1083
+ // invented figure would quietly become the basis of an upgrade decision.
1084
+ monthly: null,
1085
+ overageCents: 0.133,
1086
+ title: "Essentials 50K"
1087
+ },
1088
+ essentials100k: {
1089
+ included: 1e5,
1090
+ monthly: 3495,
1091
+ overageCents: 0.09,
1092
+ title: "Essentials 100K"
1093
+ },
1094
+ pro100k: {
1095
+ included: 1e5,
1096
+ monthly: 8995,
1097
+ overageCents: 0.11,
1098
+ title: "Pro 100K"
1099
+ },
1100
+ pro300k: {
1101
+ included: 3e5,
1102
+ monthly: 24900,
1103
+ overageCents: 0.091,
1104
+ title: "Pro 300K"
1105
+ },
1106
+ pro700k: {
1107
+ included: 7e5,
1108
+ monthly: 49900,
1109
+ overageCents: 0.078,
1110
+ title: "Pro 700K"
1111
+ },
1112
+ pro1500k: {
1113
+ included: 15e5,
1114
+ monthly: 79900,
1115
+ overageCents: 0.059,
1116
+ title: "Pro 1.5 Million"
1117
+ },
1118
+ pro2500k: {
1119
+ included: 25e5,
1120
+ monthly: 109900,
1121
+ overageCents: 0.047,
1122
+ title: "Pro 2.5 Million"
1123
+ }
1124
+ };
1125
+ var emailPlan = "essentials50k";
1126
+ var sending = {
1127
+ email: {
1128
+ // Fraction of the included volume that raises the alarm. Far enough ahead
1129
+ // to act on, high enough not to fire on ordinary growth.
1130
+ //
1131
+ // Crossing it is NOT an outage. The provider bills overage rather than
1132
+ // stopping sends, so the alarm is a COST signal: past the included volume
1133
+ // every email is charged at overageCents, and at some run rate the next
1134
+ // plan up is cheaper than the overage. That is the decision it exists to
1135
+ // prompt, and it is why nobody should be woken by it.
1136
+ alertThreshold: 0.8,
1137
+ // Emails per calendar month included, PLATFORM-WIDE and across every send
1138
+ // path: lead-facing mail, workflow steps, and the sign-in codes and
1139
+ // account mail that no plan allowance meters.
1140
+ monthlyCeiling: emailPlans[emailPlan].included,
1141
+ overageCents: emailPlans[emailPlan].overageCents,
1142
+ plan: emailPlan,
1143
+ plans: emailPlans,
1144
+ title: emailPlans[emailPlan].title
1145
+ }
1146
+ };
1147
+ var channels = {
1148
+ email: {
1149
+ actionsPerSend: 1,
1150
+ includedInAllowance: true
1151
+ },
1152
+ sms: {
1153
+ // Two actions PER SEGMENT (a long message is several segments), billed from
1154
+ // the FIRST segment and never drawn from the plan's included allowance —
1155
+ // carrier cost is real from message one, so there is no free tier of it.
1156
+ actionsPerSegment: 2,
1157
+ includedInAllowance: false
1158
+ }
1159
+ };
1160
+
1161
+ // lib/connections/drawbridge.js
1162
+ var drawbridge_default2 = {
1163
+ auth: {
1164
+ type: "none"
1165
+ },
1166
+ content: {
1167
+ confirm: "This connection is part of Drawbridge and cannot be disconnected.",
1168
+ description: [
1169
+ "Drawbridge sends your notification email and SMS, keeps your segments in sync, and posts to your own endpoints. These are built in rather than connected, so there is nothing here to set up."
1170
+ ],
1171
+ excerpt: "The steps Drawbridge runs itself.",
1172
+ guide: [
1173
+ "Nothing to do. These steps are available in every workflow builder."
1174
+ ]
1175
+ },
1176
+ exclusive: false,
1177
+ fields: [],
1178
+ group: "developer",
1179
+ // EVERY BODY LIVES IN drawbridge-sync. Sending needs the provider clients, the
1180
+ // suppression collection and the queues; segment sync needs the streams. A
1181
+ // published package carrying those makes every consumer carry them, which is
1182
+ // the reason `{}` exists as an answer.
1183
+ hooks: {
1184
+ auth: {
1185
+ // Nothing to connect, revoke, probe or re-scope.
1186
+ connect: false,
1187
+ disconnect: false,
1188
+ probe: false,
1189
+ scopes: false,
1190
+ token: false
1191
+ },
1192
+ commerce: false,
1193
+ contacts: { remove: false, sync: false },
1194
+ email: {
1195
+ digest: {},
1196
+ // To organization members. NEVER suppressed and never billed: an
1197
+ // entrant's opt-out must not silence an alert to staff, and staff mail is
1198
+ // not a metered send.
1199
+ notify: {},
1200
+ // To a lead. Suppression applies and the send is billed.
1201
+ send: {}
1202
+ },
1203
+ inbound: false,
1204
+ lifecycle: false,
1205
+ resources: {
1206
+ audiences: false,
1207
+ prices: false,
1208
+ products: false,
1209
+ promotions: false
1210
+ },
1211
+ segment: { sync: {} },
1212
+ sms: { send: {} },
1213
+ webhook: false
1214
+ },
1215
+ icon: drawbridge_default,
1216
+ // PRIVATE: never in the catalog, always available to the builder.
1217
+ private: true,
1218
+ requires: [],
1219
+ slug: "drawbridge",
1220
+ // Always on. There is no credential that could go bad and no configuration a
1221
+ // merchant could leave half-finished.
1222
+ status: () => "active",
1223
+ // DERIVED FROM drawbridge-api/lib/workflows.js, not invented. Every value
1224
+ // below — trigger, billable, settings — is what that catalog and the workflow
1225
+ // route already enforce today, because this replaces them rather than
1226
+ // competing with them.
1227
+ //
1228
+ // NOT HERE, deliberately:
1229
+ //
1230
+ // step.segment.sync a SYSTEM step, dispatched by drawbridge-sync rather
1231
+ // than offered in the builder. It fans out, so the shell
1232
+ // opens its step document and the chunks close it.
1233
+ steps: {
1234
+ email: {
1235
+ // SCHEDULE-TRIGGERED, not lead-triggered: it is offered under Daily,
1236
+ // Weekly and Monthly. Those triggers had offered no steps at all, so a
1237
+ // scheduled workflow was selectable and inert until this landed.
1238
+ digest: () => ({
1239
+ hook: "email.digest",
1240
+ key: "Email \u2014 Digest",
1241
+ queue: "notification",
1242
+ settings: {
1243
+ // The organization OWNER is always a recipient, resolved in sync,
1244
+ // so this is additional recipients rather than the list. It cannot
1245
+ // be required: the members endpoint is owner-gated and the owner is
1246
+ // not a member document, so a solo merchant has nothing to pick and
1247
+ // could never save the step.
1248
+ members: { of: "string", type: "array" },
1249
+ message: { required: true, type: "string" },
1250
+ subject: { required: true, type: "string" }
1251
+ },
1252
+ triggers: ["schedule.day", "schedule.week", "schedule.month"],
1253
+ usage: { actions: 0 }
1254
+ }),
1255
+ // To organization MEMBERS. Never suppressed — an entrant's opt-out must
1256
+ // not silence an alert to staff — and not billed.
1257
+ notify: () => ({
1258
+ hook: "email.notify",
1259
+ key: "Email \u2014 Notification",
1260
+ queue: "notification",
1261
+ settings: {
1262
+ members: { of: "string", type: "array" },
1263
+ message: { required: true, type: "string" },
1264
+ subject: { required: true, type: "string" }
1265
+ },
1266
+ triggers: ["lead.insert"],
1267
+ // Zero is a PRICE, and a deliberate one. Declared rather than omitted
1268
+ // so "this is free" and "nobody decided" stay different statements;
1269
+ // completeStep bills only when actions > 0.
1270
+ usage: { actions: 0 }
1271
+ }),
1272
+ // To a LEAD. Suppression applies and the send is billed.
1273
+ send: () => ({
1274
+ hook: "email.send",
1275
+ key: "Email \u2014 Send email",
1276
+ queue: "notification",
1277
+ settings: {
1278
+ message: { required: true, type: "string" },
1279
+ subject: { required: true, type: "string" }
1280
+ },
1281
+ triggers: ["lead.insert"],
1282
+ // ONE SOURCE FOR THE PRICE. lib/pricing.js is the index of every
1283
+ // customer-facing number; the handler read it too, so the same fact
1284
+ // was stated in two places and only one of them was reviewed.
1285
+ usage: { actions: channels.email.actionsPerSend }
1286
+ })
1287
+ },
1288
+ // WITHDRAWN, which is a third thing from builder and system: declared,
1289
+ // routed and runnable, but never offered.
1290
+ //
1291
+ // It went when the twilio connection did — a connection-gated step with no
1292
+ // connection to gate on could only ever render permanently disabled. Stored
1293
+ // workflows still carry it, so it must keep running, and enums.step.type
1294
+ // keeps it for the same reason.
1295
+ //
1296
+ // NO TRIGGERS is what keeps it out of the builder: the catalog derives from
1297
+ // triggers, so a step with none is unreachable by a merchant without a
1298
+ // second list saying so.
1299
+ //
1300
+ // Platform SMS returns as a base step the way email did. That is this entry
1301
+ // gaining triggers, not a new one.
1302
+ sms: {
1303
+ send: () => ({
1304
+ hook: "sms.send",
1305
+ key: "Send an SMS",
1306
+ queue: "notification",
1307
+ settings: {
1308
+ message: { required: true, type: "string" },
1309
+ subject: { required: true, type: "string" }
1310
+ },
1311
+ // Priced per SEGMENT and billed from the first, which the send
1312
+ // resolves from the message length. This is the floor.
1313
+ usage: { actions: channels.sms.actionsPerSegment },
1314
+ withdrawn: true
1315
+ })
1316
+ },
1317
+ segment: {
1318
+ // FANS OUT. It evaluates every contact in the organization against every
1319
+ // segment, which is too much for one job — so the hook returns chunks and
1320
+ // the shell defers completion: openStep writes the document with a slot
1321
+ // per chunk, and whichever chunk lands last closes it and resumes the
1322
+ // chain.
1323
+ //
1324
+ // It carries a hook like every other step. An earlier version declared
1325
+ // none, on the theory that fan-out was a second protocol the shell could
1326
+ // not run; it is the same protocol with the ending deferred, and a step
1327
+ // declaring no hook is silently SKIPPED by the runner.
1328
+ sync: () => ({
1329
+ description: "Recalculates segment membership on a daily schedule.",
1330
+ hook: "segment.sync",
1331
+ key: "Segment Sync",
1332
+ queue: "segment",
1333
+ system: true
1334
+ })
1335
+ }
1336
+ },
1337
+ tasks: () => [],
1338
+ title: "Drawbridge"
1339
+ };
1340
+
1341
+ // lib/http.js
1342
+ var DEFAULT_TIMEOUT_MS = 15e3;
1343
+ var request = async ({
1344
+ body,
1345
+ headers = {},
1346
+ method = "GET",
1347
+ query,
1348
+ timeout = DEFAULT_TIMEOUT_MS,
1349
+ type = "json",
1350
+ url
1351
+ }) => {
1352
+ const fullUrl = new URL(url);
1353
+ if (query) {
1354
+ Object.entries(query).forEach(([k, v]) => fullUrl.searchParams.set(k, v));
1355
+ }
1356
+ ;
1357
+ const isForm = type === "form";
1358
+ const response = await fetch(fullUrl.toString(), {
1359
+ method,
1360
+ headers: {
1361
+ "Content-Type": isForm ? "application/x-www-form-urlencoded" : "application/json",
1362
+ ...headers
1363
+ },
1364
+ signal: AbortSignal.timeout(timeout),
1365
+ ...body !== void 0 && {
1366
+ body: isForm ? new URLSearchParams(body).toString() : JSON.stringify(body)
1367
+ }
1368
+ });
1369
+ if (!response.ok) {
1370
+ const text2 = await response.text().catch(() => "");
1371
+ const error = new Error(text2 || response.statusText);
1372
+ error.status = response.status;
1373
+ throw error;
1374
+ }
1375
+ ;
1376
+ const text = await response.text();
1377
+ try {
1378
+ return text ? JSON.parse(text) : null;
1379
+ } catch {
1380
+ return null;
1381
+ }
1382
+ };
1383
+
1384
+ // lib/connections/hubspot.js
1385
+ var HUBSPOT_BASE = "https://api.hubapi.com";
1386
+ var hubspotRequest = ({ body, fetcher, method, path, query, token }) => {
1387
+ return (fetcher || request)({
1388
+ body,
1389
+ headers: {
1390
+ "Authorization": "Bearer " + (token || process.env.HUBSPOT_ACCESS_TOKEN)
1391
+ },
1392
+ method,
1393
+ query,
1394
+ url: HUBSPOT_BASE + path
1395
+ });
1396
+ };
1397
+ var UTM_PROPERTIES = {
1398
+ campaign: "utm_campaign",
1399
+ content: "utm_content",
1400
+ id: "utm_id",
1401
+ medium: "utm_medium",
1402
+ source: "utm_source",
1403
+ term: "utm_term"
1404
+ };
1405
+ var CLICK_PROPERTIES = {
1406
+ fbclid: "hs_facebook_click_id",
1407
+ gclid: "hs_google_click_id",
1408
+ liFatId: "hs_linkedin_click_id",
1409
+ msclkid: "hs_bing_click_id",
1410
+ ttclid: "hs_tiktok_click_id"
1411
+ };
1412
+ var DROPPABLE = new Set(Object.values(UTM_PROPERTIES));
1413
+ var isUtmProperty = (key) => DROPPABLE.has(key);
1414
+ var toProperties = ({ email, firstName, lastName, utm }) => {
1415
+ var _a;
1416
+ const properties = {};
1417
+ if (email !== void 0) properties.email = email;
1418
+ if (firstName !== void 0) properties.firstname = firstName;
1419
+ if (lastName !== void 0) properties.lastname = lastName;
1420
+ if (utm) {
1421
+ for (const [key, property] of Object.entries(UTM_PROPERTIES)) {
1422
+ if (utm[key]) properties[property] = utm[key];
1423
+ }
1424
+ ;
1425
+ for (const [key, property] of Object.entries(CLICK_PROPERTIES)) {
1426
+ if ((_a = utm.click) == null ? void 0 : _a[key]) properties[property] = utm.click[key];
1427
+ }
1428
+ ;
1429
+ }
1430
+ ;
1431
+ return properties;
1432
+ };
1433
+ var send = async ({ doc, fetcher, method, path, token }) => {
1434
+ const properties = toProperties(doc);
1435
+ try {
1436
+ return await hubspotRequest({
1437
+ body: { properties },
1438
+ fetcher,
1439
+ method,
1440
+ path,
1441
+ token
1442
+ });
1443
+ } catch (error) {
1444
+ const enriched = Object.keys(properties).some(isUtmProperty);
1445
+ if ((error == null ? void 0 : error.status) !== 400 || !enriched) throw error;
1446
+ return await hubspotRequest({
1447
+ body: {
1448
+ properties: Object.fromEntries(
1449
+ Object.entries(properties).filter(([key]) => !isUtmProperty(key))
1450
+ )
1451
+ },
1452
+ fetcher,
1453
+ method,
1454
+ path,
1455
+ token
1456
+ });
1457
+ }
1458
+ };
1459
+ var lookup = async ({ email, fetcher, token }) => {
1460
+ var _a, _b;
1461
+ if (!token || !email) return;
1462
+ try {
1463
+ const body = await hubspotRequest({
1464
+ body: {
1465
+ filterGroups: [
1466
+ {
1467
+ filters: [
1468
+ {
1469
+ operator: "EQ",
1470
+ propertyName: "email",
1471
+ value: email
1472
+ }
1473
+ ]
1474
+ }
1475
+ ],
1476
+ limit: 1,
1477
+ properties: ["email"]
1478
+ },
1479
+ fetcher,
1480
+ method: "POST",
1481
+ path: "/crm/v3/objects/contacts/search",
1482
+ token
1483
+ });
1484
+ return (_b = (_a = body == null ? void 0 : body.results) == null ? void 0 : _a[0]) == null ? void 0 : _b.id;
1485
+ } catch (error) {
1486
+ }
1487
+ };
1488
+ var hubspot_default = {
1489
+ auth: {
1490
+ // A Private App token from our own portal. Nothing to connect, nothing to
1491
+ // consent to, and no merchant involved.
1492
+ type: "none"
1493
+ },
1494
+ content: {
1495
+ confirm: "This connection is part of Drawbridge and cannot be disconnected.",
1496
+ description: [
1497
+ "Drawbridge keeps its own HubSpot portal in step with account signups, so the campaign a customer arrived on is on their contact record."
1498
+ ],
1499
+ excerpt: "Drawbridge's own CRM sync.",
1500
+ guide: [
1501
+ "Nothing to do. This is internal to Drawbridge."
1502
+ ]
1503
+ },
1504
+ exclusive: false,
1505
+ fields: [],
1506
+ group: "contacts",
1507
+ hooks: {
1508
+ auth: {
1509
+ connect: false,
1510
+ disconnect: false,
1511
+ probe: false,
1512
+ scopes: false,
1513
+ token: false
1514
+ },
1515
+ commerce: false,
1516
+ contacts: {
1517
+ // FORGET A CONTACT, by id or by email. Account deletion — the caller had
1518
+ // to search then remove, which is one round trip it should not have to
1519
+ // know about.
1520
+ remove: async ({ email, fetcher, id, token }) => {
1521
+ const key = token || process.env.HUBSPOT_ACCESS_TOKEN;
1522
+ if (!key) return;
1523
+ const contact = id || await lookup({ email, fetcher, token: key });
1524
+ if (!contact) return;
1525
+ return hubspotRequest({
1526
+ fetcher,
1527
+ method: "DELETE",
1528
+ path: "/crm/v3/objects/contacts/" + contact,
1529
+ token: key
1530
+ });
1531
+ },
1532
+ // Connect an account to its contact by email, creating it if absent, and
1533
+ // return the contact id. Unlike SendGrid, HubSpot renames a contact's
1534
+ // email in place, so an email change is a plain PATCH on the cached id —
1535
+ // no delete-old-then-create-new.
1536
+ //
1537
+ // Prefer the cached hubspotId; fall back to a search; create last.
1538
+ sync: async ({ doc, fetcher, token }) => {
1539
+ var _a, _b;
1540
+ const key = token || process.env.HUBSPOT_ACCESS_TOKEN;
1541
+ if (!key) return;
1542
+ if (doc == null ? void 0 : doc.hubspotId) {
1543
+ try {
1544
+ return (_a = await send({ doc, fetcher, method: "PATCH", path: "/crm/v3/objects/contacts/" + doc.hubspotId, token: key })) == null ? void 0 : _a.id;
1545
+ } catch (error) {
1546
+ if ((error == null ? void 0 : error.status) !== 404) throw error;
1547
+ }
1548
+ }
1549
+ const existing = await lookup({ email: doc == null ? void 0 : doc.email, fetcher, token: key });
1550
+ return (_b = await send({
1551
+ doc,
1552
+ fetcher,
1553
+ method: existing ? "PATCH" : "POST",
1554
+ path: existing ? "/crm/v3/objects/contacts/" + existing : "/crm/v3/objects/contacts",
1555
+ token: key
1556
+ })) == null ? void 0 : _b.id;
1557
+ }
1558
+ },
1559
+ email: false,
1560
+ inbound: false,
1561
+ lifecycle: false,
1562
+ resources: {
1563
+ audiences: false,
1564
+ prices: false,
1565
+ products: false,
1566
+ promotions: false
1567
+ },
1568
+ segment: false,
1569
+ sms: false,
1570
+ webhook: false
1571
+ },
1572
+ icon: drawbridge_default,
1573
+ // Borrowed: the Drawbridge mark, because this is ours and never rendered.
1574
+ private: true,
1575
+ // Absent the token the hooks no-op, so a deployment without a portal simply
1576
+ // contributes nothing rather than failing.
1577
+ requires: ["HUBSPOT_ACCESS_TOKEN"],
1578
+ slug: "hubspot",
1579
+ status: () => "active",
1580
+ // No workflow steps. The hooks are called by the user stream, not the builder.
1581
+ steps: {},
1582
+ tasks: () => [],
1583
+ title: "HubSpot"
1584
+ };
1585
+
278
1586
  // lib/connections/icons/klaviyo.js
279
1587
  var klaviyo_default = `<svg width="500" height="500" viewBox="0 0 500 500" fill="none" xmlns="http://www.w3.org/2000/svg">
280
1588
  <rect width="500" height="500" fill="white"/>
@@ -282,16 +1590,22 @@ var klaviyo_default = `<svg width="500" height="500" viewBox="0 0 500 500" fill=
282
1590
  </svg>`;
283
1591
 
284
1592
  // lib/connections/klaviyo.js
285
- var REVISION = "2026-07-15";
286
- var api = async (path, { fetcher = fetch, token }) => {
1593
+ var api = async (path, { fetcher = fetch, method = "GET", payload, token }) => {
287
1594
  const response = await fetcher("https://a.klaviyo.com/api" + path, {
1595
+ ...payload && { body: JSON.stringify(payload) },
288
1596
  headers: {
289
1597
  // Bearer, not Klaviyo-API-Key — that header is for private keys, and
290
1598
  // sending it with an OAuth token fails in a way that reads like a bad
291
1599
  // token rather than a bad scheme.
292
1600
  authorization: "Bearer " + token,
293
- revision: REVISION
1601
+ ...payload && { "content-type": "application/json" },
1602
+ // Klaviyo pins its API by DATE. A request without this header is
1603
+ // refused, and one with an old date keeps the response shape that date
1604
+ // shipped with — which is the point: bumping it is a deliberate act
1605
+ // with a changelog to read, not something that drifts under us.
1606
+ revision: "2026-07-15"
294
1607
  },
1608
+ method,
295
1609
  signal: AbortSignal.timeout(15e3)
296
1610
  });
297
1611
  if (!response.ok) {
@@ -300,7 +1614,7 @@ var api = async (path, { fetcher = fetch, token }) => {
300
1614
  { status: response.status }
301
1615
  );
302
1616
  }
303
- return response.json();
1617
+ return response.status === 204 ? null : response.json();
304
1618
  };
305
1619
  var klaviyo_default2 = {
306
1620
  // OAuth 2.1, and PKCE is REQUIRED rather than recommended: Klaviyo refuses an
@@ -308,234 +1622,417 @@ var klaviyo_default2 = {
308
1622
  // carried. Most vendors treat it as optional hardening; this one does not,
309
1623
  // which is why it is a descriptor flag and not a global.
310
1624
  //
311
- // clientAuth is the other thing Klaviyo does differently. The token endpoint
312
- // wants HTTP Basic base64( client_id : client_secret ) in an Authorization
313
- // header — and rejects the same pair sent as form fields, which is how every
314
- // Google product wants it.
1625
+ // HTTP Basic on the token endpoint is the other thing Klaviyo does
1626
+ // differently, and it says so in hooks.auth.token rather than as a flag here.
315
1627
  auth: {
316
1628
  oauth: {
317
- // TWO DIFFERENT HOSTS, and swapping them fails in opposite directions.
318
- //
319
- // authorize is a page a HUMAN loads, and it lives on www. Pointing it at
320
- // a.klaviyo.com -- their API host -- sends the merchant somewhere that
321
- // never renders a consent screen, so the journey stalls with no error
322
- // anybody can see.
323
- //
324
- // token is a server call and must stay on a.klaviyo.com: Klaviyo began
325
- // blocking OAuth token traffic through www on 2025-03-31, so the mirror
326
- // image of this mistake breaks the exchange instead of the consent.
327
- authorize: "https://www.klaviyo.com/oauth/authorize",
328
1629
  // NAMES the env vars holding OUR application's client. One identity,
329
1630
  // every merchant — the token is the merchant's and arrives from their
330
1631
  // own consent, which is what stops one organization reading another's
331
1632
  // data.
1633
+ //
332
1634
  client: {
333
1635
  id: "KLAVIYO_OAUTH_CLIENT_ID",
334
1636
  secret: "KLAVIYO_OAUTH_CLIENT_SECRET"
335
1637
  },
336
- clientAuth: "basic",
337
- pkce: true,
338
- // DECLARED, never derived from the slug. It is registered in Klaviyo's
339
- // app settings and they refuse anything that does not byte-match, so
340
- // it is a fact about someone else's records rather than a string this
341
- // code computes. Deriving one from a provider key produced
342
- // redirect_uri_mismatch on a connection nobody had touched.
343
1638
  // Klaviyo drops a refresh token after 90 days of NON-USE. The vendor
344
1639
  // never mentions this at runtime — you discover it when a refresh fails
345
1640
  // on a connection nobody touched — so it is declared, and it is why
346
1641
  // auth.probe has to run on a schedule rather than only before a call.
347
- idleExpiry: 90 * 24 * 60 * 60,
348
- redirect: "/api/connection/klaviyo/callback",
1642
+ //
1643
+ // Token lifetime is NOT declared: the vendor states it on every
1644
+ // exchange, and a copy here would be a second answer that goes stale.
1645
+ expiry: 90 * 24 * 60 * 60,
1646
+ pkce: true,
349
1647
  // Space separated. accounts:read is required by Klaviyo on every app
350
1648
  // and must stay in the list; the rest are what a contact sync needs.
351
1649
  scopes: "accounts:read lists:read lists:write profiles:read profiles:write",
352
- token: "https://a.klaviyo.com/oauth/token"
1650
+ // EVERY VENDOR URL, in one place. `revoke` used to be a literal inside
1651
+ // the disconnect hook — three vendor addresses, two of them declared,
1652
+ // which is exactly the kind of split that goes unnoticed.
1653
+ urls: {
1654
+ // TWO DIFFERENT HOSTS, and swapping them fails in opposite ways.
1655
+ //
1656
+ // authorize is a page a HUMAN loads, and it lives on www. Pointing it
1657
+ // at a.klaviyo.com — their API host — sends the merchant somewhere
1658
+ // that never renders a consent screen, so the journey stalls with no
1659
+ // error anybody can see.
1660
+ //
1661
+ // token and revoke are server calls and must stay on a.klaviyo.com:
1662
+ // Klaviyo began blocking OAuth token traffic through www on
1663
+ // 2025-03-31, so the mirror image of this mistake breaks the exchange
1664
+ // instead of the consent.
1665
+ authorize: "https://www.klaviyo.com/oauth/authorize",
1666
+ // WHERE THE MERCHANT LANDS — the dashboard, not drawbridge-api. The
1667
+ // `/api/` segment is Next's route-handler convention, which reads as
1668
+ // the api service to everyone who sees it; it is not, and the route
1669
+ // has never moved. build() pins it against the one callback route
1670
+ // that exists, because declared-but-wrong fails AFTER consent — a
1671
+ // 404 for someone who has already granted access.
1672
+ //
1673
+ // Registered in Klaviyo's own app settings, and they refuse anything
1674
+ // that does not byte-match, so it is a fact about someone else's
1675
+ // records rather than a string this code computes.
1676
+ redirect: "/api/connection/klaviyo/callback",
1677
+ revoke: "https://a.klaviyo.com/oauth/revoke",
1678
+ token: "https://a.klaviyo.com/oauth/token"
1679
+ }
353
1680
  },
354
1681
  type: "oauth"
355
1682
  },
356
- category: "contacts",
357
- confirm: "Disconnecting revokes Drawbridge's access to your Klaviyo account. Your profiles and lists stay in both Klaviyo and Drawbridge \u2014 neither is deleted.",
358
- connect: {
1683
+ // EVERYTHING A MERCHANT READS. Grouped by who it is for rather than by what
1684
+ // kind of sentence it is, so the question on the next vendor is "does a person
1685
+ // read this", which nobody gets wrong, instead of "is this marketing", which
1686
+ // someone will.
1687
+ //
1688
+ // `errors` is in here rather than at the top level, and that is not a
1689
+ // preference. The connection DOCUMENT carries its own `errors` array of
1690
+ // scope-drift entries, and the document is spread OVER the resolved manifest
1691
+ // downstream — so a top-level `errors` here would be silently replaced by that
1692
+ // array and this copy would never render. `fields`/`settings` already carry a
1693
+ // comment about the same collision.
1694
+ content: {
1695
+ // Shown at disconnect, so it says what is lost and what is not.
1696
+ confirm: "Disconnecting revokes Drawbridge's access to your Klaviyo account. Your profiles and lists stay in both Klaviyo and Drawbridge \u2014 neither is deleted.",
1697
+ description: [
1698
+ "Connecting Klaviyo lets Drawbridge sync the contacts your campaigns collect into a Klaviyo list, so the people who enter a giveaway can be marketed to alongside the rest of your audience.",
1699
+ "You authorize Drawbridge from inside Klaviyo and can revoke that access there at any time. Drawbridge never sees or stores your Klaviyo password, and only asks for the permissions listed on the consent screen.",
1700
+ "Anyone who has opted out in Drawbridge is synced as unsubscribed rather than omitted, so a person who asked not to be contacted stays suppressed in both systems instead of quietly reappearing."
1701
+ ],
1702
+ // KEYED BY WHAT FAILED, not nested inside it. Errors are the thing most
1703
+ // likely to grow — resources.* has already earned somewhere to put "we
1704
+ // could not load your lists" — so a new area adds a key here rather than a
1705
+ // second errors object somewhere else.
1706
+ //
1707
+ // `connect` no longer exists as a container above: its only other member
1708
+ // was `redirect`, which moved to auth.oauth.urls with the rest of the
1709
+ // vendor's addresses.
359
1710
  errors: {
360
- denied: "The Klaviyo authorization was declined, so nothing was connected.",
361
- invalid: "We couldn't complete the Klaviyo connection. Try connecting again."
362
- }
1711
+ connect: {
1712
+ denied: "The Klaviyo authorization was declined, so nothing was connected.",
1713
+ invalid: "We couldn't complete the Klaviyo connection. Try connecting again."
1714
+ }
1715
+ },
1716
+ excerpt: "Sync the contacts your campaigns collect into a Klaviyo list.",
1717
+ // HOW TO CONNECT, in the merchant's words. Was `setup`, which nothing
1718
+ // rendered — four useful instructions no component displayed.
1719
+ guide: [
1720
+ "Press Connect. Drawbridge sends you to Klaviyo to approve access.",
1721
+ "Sign in to Klaviyo if you are not already, and choose the account to connect.",
1722
+ "Approve the permissions Klaviyo lists. You are returned here and the connection shows Active.",
1723
+ "You can revoke access at any time from Klaviyo, under Integrations."
1724
+ ]
363
1725
  },
364
- description: [
365
- "Connecting Klaviyo lets Drawbridge sync the contacts your campaigns collect into a Klaviyo list, so the people who enter a giveaway can be marketed to alongside the rest of your audience.",
366
- "You authorize Drawbridge from inside Klaviyo and can revoke that access there at any time. Drawbridge never sees or stores your Klaviyo password, and only asks for the permissions listed on the consent screen.",
367
- "Anyone who has opted out in Drawbridge is synced as unsubscribed rather than omitted, so a person who asked not to be contacted stays suppressed in both systems instead of quietly reappearing."
368
- ],
369
- excerpt: "Sync the contacts your campaigns collect into a Klaviyo list.",
1726
+ // CAN A MERCHANT KEEP TWO OF THESE AT ONCE?
1727
+ //
1728
+ // Required, and false is a decision rather than a default. Shopify is
1729
+ // exclusive because a store maps to exactly one organization. Contact syncs
1730
+ // are destinations — someone can reasonably keep Klaviyo and Mailchimp both
1731
+ // current — so the exclusivity that once applied when these were SENDERS is
1732
+ // deliberately gone. That was removed once already; declaring it out loud is
1733
+ // what stops it coming back by inference.
1734
+ exclusive: false,
370
1735
  feature: "organization:connection:klaviyo",
371
- // Nothing typed. The consent returns the grant, and the account it belongs to
372
- // is read back from Klaviyo rather than asked for.
373
1736
  fields: [
374
1737
  {
375
1738
  key: "account",
376
1739
  label: "Klaviyo account"
377
1740
  },
378
1741
  {
1742
+ // The choices come from the merchant's own account, so the field names
1743
+ // the capability and the client composes the url.
1744
+ hook: "resources.audiences",
379
1745
  input: "select",
380
1746
  key: "list",
381
1747
  label: "Klaviyo list",
382
1748
  message: "Contacts your campaigns collect are synced into this list.",
383
1749
  required: true,
384
- // The choices come from the merchant's own account, not from here see
385
- // catalog.audiences below. Static options would mean asking somebody to
386
- // paste a list id copied out of another browser tab.
387
- source: "catalog.audiences"
1750
+ // Klaviyo's list endpoint carries no name filter, so the hook can only
1751
+ // match what it already fetched. A search box that searches one page is
1752
+ // worse than none, so the picker does not offer one.
1753
+ search: false
388
1754
  }
389
1755
  ],
390
- // The three auth hooks, all pure HTTP against Klaviyowhich is why they
391
- // live here rather than in sync. A vendor's own protocol belongs beside the
392
- // vendor.
1756
+ // WHAT KIND OF THING THIS IS. One field, not two `category` said the same
1757
+ // thing and was read by nothing, while `group` was quietly doing double duty
1758
+ // as the mutual-exclusion key. The exclusion moved to `exclusive` above, so
1759
+ // this is purely how a connection is grouped and labelled.
1760
+ group: "contacts",
1761
+ // Nothing typed at connect. The consent returns the grant, and the account it
1762
+ // belongs to is read back from Klaviyo rather than asked for.
393
1763
  hooks: {
394
- // Turn a fresh grant into settings worth showing. Without this the card
395
- // renders an empty "Klaviyo account" field, because the merchant is never
396
- // asked which account they connected the consent already decided it and
397
- // asking again would be a question we can answer ourselves.
398
- "auth.connect": async ({ fetcher, tokens }) => {
399
- var _a, _b, _c;
400
- const body = await api("/accounts", { fetcher, token: tokens.accessToken });
401
- const account = (_a = body == null ? void 0 : body.data) == null ? void 0 : _a[0];
402
- return {
403
- account: ((_c = (_b = account == null ? void 0 : account.attributes) == null ? void 0 : _b.contact_information) == null ? void 0 : _c.organization_name) || (account == null ? void 0 : account.id) || null,
404
- accountId: (account == null ? void 0 : account.id) || null
405
- };
1764
+ auth: {
1765
+ // Turn a fresh grant into settings worth showing. Without this the card
1766
+ // renders an empty "Klaviyo account" field, because the merchant is
1767
+ // never asked which account they connected the consent already
1768
+ // decided it, and asking again would be a question we can answer.
1769
+ connect: async ({ fetcher, tokens }) => {
1770
+ var _a, _b, _c;
1771
+ const body = await api("/accounts", { fetcher, token: tokens.accessToken });
1772
+ const account = (_a = body == null ? void 0 : body.data) == null ? void 0 : _a[0];
1773
+ return {
1774
+ account: ((_c = (_b = account == null ? void 0 : account.attributes) == null ? void 0 : _b.contact_information) == null ? void 0 : _c.organization_name) || (account == null ? void 0 : account.id) || null,
1775
+ accountId: (account == null ? void 0 : account.id) || null
1776
+ };
1777
+ },
1778
+ // Revoke at KLAVIYO, not just locally. Forgetting our copy leaves the
1779
+ // grant live in the merchant's account, so a disconnect that looks
1780
+ // complete here still shows Drawbridge with access over there.
1781
+ //
1782
+ // Basic auth with our client, exactly like the token exchange — the
1783
+ // token being revoked is the subject, not the credential.
1784
+ disconnect: async ({ clientId, clientSecret, fetcher = fetch, manifest, settings }) => {
1785
+ const token = (settings == null ? void 0 : settings.refreshToken) || (settings == null ? void 0 : settings.accessToken);
1786
+ if (!token) return { revoked: false };
1787
+ const response = await fetcher(manifest.auth.oauth.urls.revoke, {
1788
+ body: new URLSearchParams({
1789
+ token,
1790
+ token_type_hint: (settings == null ? void 0 : settings.refreshToken) ? "refresh_token" : "access_token"
1791
+ }),
1792
+ headers: {
1793
+ authorization: "Basic " + Buffer.from(clientId + ":" + clientSecret).toString("base64"),
1794
+ "content-type": "application/x-www-form-urlencoded"
1795
+ },
1796
+ method: "POST",
1797
+ signal: AbortSignal.timeout(15e3)
1798
+ });
1799
+ return { revoked: response.ok };
1800
+ },
1801
+ // THE MINT IS THE PROBE. Asking "is this token still good" by
1802
+ // inspecting what we stored answers the wrong question — a grant
1803
+ // revoked inside Klaviyo still looks perfect in our database. Spending
1804
+ // the refresh token is the only thing that asks Klaviyo.
1805
+ //
1806
+ // It also keeps the grant warm against the 90-day idle window above.
1807
+ probe: async ({ clientId, clientSecret, fetcher, manifest, settings }) => {
1808
+ const token = await accessToken({
1809
+ clientId,
1810
+ clientSecret,
1811
+ fetcher,
1812
+ // Mint even if the stored token still looks good — a probe that
1813
+ // short-circuits never reaches Klaviyo and reports healthy on a
1814
+ // grant revoked an hour ago.
1815
+ force: true,
1816
+ manifest,
1817
+ settings
1818
+ });
1819
+ return { ok: Boolean(token) };
1820
+ },
1821
+ // Klaviyo scopes are fixed at app level and re-consented, not drifted.
1822
+ scopes: false,
1823
+ // KLAVIYO REQUIRES HTTP BASIC on the token endpoint and rejects the same
1824
+ // client_id/client_secret pair as body fields. Everything else about the
1825
+ // request is standard, so this is the shared implementation told the one
1826
+ // thing that differs — in Klaviyo's own file, beside the rest of what
1827
+ // makes Klaviyo unusual, rather than as a flag a caller has to know to
1828
+ // read.
1829
+ token: (args) => authToken({ ...args, basic: true })
406
1830
  },
407
- // Revoke at KLAVIYO, not just locally. Forgetting our copy leaves the
408
- // grant live in the merchant's account, so a disconnect that looks
409
- // complete here still shows Drawbridge with access over there.
410
- //
411
- // Basic auth with our client, exactly like the token exchange — the token
412
- // being revoked is the subject, not the credential.
413
- // The lists a merchant can sync into, for the picker on their connection.
414
- //
415
- // PAGINATED DELIBERATELY. Klaviyo caps page[size] at 10 and defaults to it,
416
- // so a single call quietly returns the first ten lists and an account with
417
- // more would show a picker missing the one they wanted — with nothing to
418
- // indicate anything was cut. Follows links.next, bounded so a runaway
419
- // cursor cannot spin forever.
420
- "catalog.audiences": async ({ cursor, fetcher, limit = 100, search, token }) => {
421
- var _a, _b;
422
- const audiences = [];
423
- let next = cursor ? "/lists?page%5Bsize%5D=10&page%5Bcursor%5D=" + encodeURIComponent(cursor) : "/lists?page%5Bsize%5D=10";
424
- let pages = 0;
425
- while (next && audiences.length < limit && pages < 20) {
426
- const body = await api(next, { fetcher, token });
427
- for (const list of (body == null ? void 0 : body.data) || []) {
428
- audiences.push({ id: list.id, title: ((_a = list == null ? void 0 : list.attributes) == null ? void 0 : _a.name) || list.id });
429
- }
430
- const link = (_b = body == null ? void 0 : body.links) == null ? void 0 : _b.next;
431
- next = link ? String(link).replace(/^https:\/\/a\.klaviyo\.com\/api/, "") : null;
432
- pages = pages + 1;
1831
+ // No commerce here. Klaviyo tracks orders, but Drawbridge's order data comes
1832
+ // from the store that took the money a second source for the same event
1833
+ // is two answers to "did this person buy", and the one we can bill from is
1834
+ // the store's.
1835
+ commerce: false,
1836
+ // The verb the contacts.sync step points at. It does the work — including
1837
+ // writing the profile id back onto the lead and returns what happened.
1838
+ contacts: {
1839
+ // Not yet. Suppression syncs an opt-out as unsubscribed, which is a
1840
+ // different thing from deleting the profile.
1841
+ remove: false,
1842
+ sync: async ({ contact, fetcher, lead, settings, suppressed, token }) => {
1843
+ var _a, _b, _c;
1844
+ const list = settings == null ? void 0 : settings.list;
1845
+ if (!list) return { message: "No Klaviyo list is chosen for this connection.", skipped: true };
1846
+ const email = ((_b = (_a = lead == null ? void 0 : lead.canonical) == null ? void 0 : _a.email) == null ? void 0 : _b.value) || (lead == null ? void 0 : lead.email);
1847
+ if (!email) return { message: "That lead has no email address to sync.", skipped: true };
1848
+ const totals = (contact == null ? void 0 : contact.totals) || {};
1849
+ const profile = await api("/profiles/", {
1850
+ fetcher,
1851
+ method: "POST",
1852
+ payload: {
1853
+ data: {
1854
+ attributes: {
1855
+ email,
1856
+ ...(lead == null ? void 0 : lead.name) && { first_name: String(lead.name).trim().split(/\s+/)[0] },
1857
+ properties: {
1858
+ drawbridge_campaigns: ((contact == null ? void 0 : contact.campaigns) || []).length,
1859
+ drawbridge_draws: totals.draws || 0,
1860
+ drawbridge_entries: totals.entries || 0,
1861
+ drawbridge_orders: totals.orders || 0,
1862
+ // Campaign-attributed, NOT lifetime. A merchant running
1863
+ // Shopify already has lifetime revenue in Klaviyo through
1864
+ // Klaviyo's own integration; what only we can say is how
1865
+ // much a campaign drove. Named so the two cannot be
1866
+ // mistaken for one another in a segment builder.
1867
+ drawbridge_revenue: totals.gross || 0
1868
+ }
1869
+ },
1870
+ type: "profile"
1871
+ }
1872
+ },
1873
+ token
1874
+ });
1875
+ const profileId = (_c = profile == null ? void 0 : profile.data) == null ? void 0 : _c.id;
1876
+ if (!profileId) return { message: "Klaviyo returned no profile id.", skipped: true };
1877
+ await api("/profile-subscription-bulk-create-jobs/", {
1878
+ fetcher,
1879
+ method: "POST",
1880
+ payload: {
1881
+ data: {
1882
+ attributes: {
1883
+ profiles: {
1884
+ data: [{
1885
+ attributes: {
1886
+ email,
1887
+ subscriptions: {
1888
+ email: { marketing: { consent: suppressed ? "UNSUBSCRIBED" : "SUBSCRIBED" } }
1889
+ }
1890
+ },
1891
+ type: "profile"
1892
+ }]
1893
+ }
1894
+ },
1895
+ relationships: { list: { data: { id: list, type: "list" } } },
1896
+ type: "profile-subscription-bulk-create-job"
1897
+ }
1898
+ },
1899
+ token
1900
+ });
1901
+ return {
1902
+ // Merged into `context` for later steps in this run.
1903
+ context: { klaviyoProfileId: profileId },
1904
+ message: suppressed ? "Synced to Klaviyo as unsubscribed \u2014 this contact has opted out." : "Synced to the Klaviyo list.",
1905
+ // Recorded on the run for support to read back, not a write
1906
+ // instruction — the hook has already written what it needed to.
1907
+ response: { klaviyoProfileId: profileId }
1908
+ };
433
1909
  }
434
- const term = String((search == null ? void 0 : search.value) || "").trim().toLowerCase();
435
- const items = term ? audiences.filter((entry) => entry.title.toLowerCase().includes(term)) : audiences;
436
- return {
437
- items,
438
- pageInfo: {
439
- endCursor: next,
440
- hasNextPage: Boolean(next)
441
- }
442
- };
443
1910
  },
444
- "auth.disconnect": async ({ clientId, clientSecret, fetcher = fetch, settings }) => {
445
- const token = (settings == null ? void 0 : settings.refreshToken) || (settings == null ? void 0 : settings.accessToken);
446
- if (!token) return { revoked: false };
447
- const response = await fetcher("https://a.klaviyo.com/oauth/revoke", {
448
- body: new URLSearchParams({
449
- token,
450
- token_type_hint: (settings == null ? void 0 : settings.refreshToken) ? "refresh_token" : "access_token"
451
- }),
452
- headers: {
453
- authorization: "Basic " + Buffer.from(clientId + ":" + clientSecret).toString("base64"),
454
- "content-type": "application/x-www-form-urlencoded"
455
- },
456
- method: "POST",
457
- signal: AbortSignal.timeout(15e3)
458
- });
459
- return { revoked: response.ok };
1911
+ // A WHOLE DOMAIN CAN DECLINE AT ONCE. Klaviyo sends us nothing and we
1912
+ // register nothing with it, so listing four falses would be noise around a
1913
+ // single decision. Still explicit absence would not say whether anybody
1914
+ // considered it.
1915
+ // Drawbridge sends its own notification email and SMS, and owns its own
1916
+ // segments — see the private `drawbridge` manifest. A vendor answering
1917
+ // these would be a second sender, which is the arrangement the platform
1918
+ // sender replaced.
1919
+ email: false,
1920
+ segment: false,
1921
+ sms: false,
1922
+ inbound: false,
1923
+ // Nothing to set up or tear down at the vendor: the grant is the whole
1924
+ // integration, and revoking it is auth.disconnect's job.
1925
+ lifecycle: false,
1926
+ resources: {
1927
+ // The lists a merchant can sync into, for the picker on their
1928
+ // connection.
1929
+ //
1930
+ // PAGINATED DELIBERATELY. Klaviyo caps page[size] at 10 and defaults to
1931
+ // it, so one call quietly returns the first ten lists and an account
1932
+ // with more shows a picker missing the one they wanted, with nothing to
1933
+ // indicate anything was cut.
1934
+ audiences: async ({ cursor, fetcher, limit = 100, search, token }) => {
1935
+ var _a, _b;
1936
+ const audiences = [];
1937
+ let next = cursor ? "/lists?page%5Bsize%5D=10&page%5Bcursor%5D=" + encodeURIComponent(cursor) : "/lists?page%5Bsize%5D=10";
1938
+ let pages = 0;
1939
+ while (next && audiences.length < limit && pages < 20) {
1940
+ const body = await api(next, { fetcher, token });
1941
+ for (const list of (body == null ? void 0 : body.data) || []) {
1942
+ audiences.push({ id: list.id, title: ((_a = list == null ? void 0 : list.attributes) == null ? void 0 : _a.name) || list.id });
1943
+ }
1944
+ const link = (_b = body == null ? void 0 : body.links) == null ? void 0 : _b.next;
1945
+ next = link ? String(link).replace(/^https:\/\/a\.klaviyo\.com\/api/, "") : null;
1946
+ pages = pages + 1;
1947
+ }
1948
+ const term = String((search == null ? void 0 : search.value) || "").trim().toLowerCase();
1949
+ return {
1950
+ items: term ? audiences.filter((entry) => entry.title.toLowerCase().includes(term)) : audiences,
1951
+ pageInfo: {
1952
+ endCursor: next,
1953
+ hasNextPage: Boolean(next)
1954
+ }
1955
+ };
1956
+ },
1957
+ // Klaviyo sells no products and mints no discount codes.
1958
+ prices: false,
1959
+ products: false,
1960
+ promotions: false
460
1961
  },
461
- // THE MINT IS THE PROBE. Asking "is this token still good" by inspecting
462
- // what we stored answers the wrong question — a grant revoked inside
463
- // Klaviyo still looks perfect in our database. Spending the refresh token
464
- // is the only thing that asks Klaviyo.
465
- //
466
- // It also keeps the grant warm: Klaviyo expires a refresh token after 90
467
- // days of NON-USE, so a connection nobody touches dies silently without
468
- // this running.
469
- "auth.probe": async ({ clientId, clientSecret, fetcher, manifest, settings }) => {
470
- const token = await accessToken({
471
- clientId,
472
- clientSecret,
473
- fetcher,
474
- // Mint even if the stored token still looks good — a probe that
475
- // short-circuits never reaches Klaviyo and reports healthy on a
476
- // grant revoked an hour ago.
477
- force: true,
478
- manifest,
479
- settings
480
- });
481
- return { ok: Boolean(token) };
482
- }
1962
+ // Drawbridge posts to a merchant's own endpoint, never through a vendor.
1963
+ webhook: false
483
1964
  },
484
1965
  icon: klaviyo_default,
485
- // A grant with no list chosen is authenticated and useless. The list cannot
486
- // be part of the consent flow — enumerating lists needs the token the consent
487
- // returns — so it is always a second step, and the card must say so rather
488
- // than showing Active over nothing.
489
- incomplete: (data) => {
490
- var _a;
491
- return ((_a = data == null ? void 0 : data.settings) == null ? void 0 : _a.list) ? null : "Choose which Klaviyo list your contacts should sync into.";
492
- },
493
- label: "klaviyo",
494
1966
  requires: [
495
1967
  "KLAVIYO_OAUTH_CLIENT_ID",
496
1968
  "KLAVIYO_OAUTH_CLIENT_SECRET"
497
1969
  ],
498
- setup: [
499
- "Press Connect. Drawbridge sends you to Klaviyo to approve access.",
500
- "Sign in to Klaviyo if you are not already, and choose the account to connect.",
501
- "Approve the permissions Klaviyo lists. You are returned here and the connection shows Active.",
502
- "You can revoke access at any time from Klaviyo, under Integrations."
503
- ],
504
1970
  slug: "klaviyo",
505
- // No steps yet. The sync itself is unbuilt, and a step offered in the builder
506
- // that nothing runs is worse than no step at all the merchant configures it
507
- // and waits for something that never happens.
508
- steps: {},
509
- supports: {
510
- "auth.connect": true,
511
- "auth.disconnect": true,
512
- // The refresh mint IS the probe: a revoked or rotated grant fails there in
513
- // Klaviyo's own words rather than as an empty sync three steps later.
514
- "auth.probe": true,
515
- // Klaviyo scopes are fixed at app level and re-consented, not drifted.
516
- "auth.scopes": false,
517
- "catalog.audiences": true,
518
- "catalog.prices": false,
519
- "catalog.products": false,
520
- "catalog.promotions": false,
521
- "inbound.event": false,
522
- "inbound.process": false,
523
- "inbound.receive": false,
524
- "inbound.verify": false,
525
- "lifecycle.cleanup": false,
526
- "lifecycle.register": false,
527
- "lifecycle.rehydrate": false
528
- },
529
- tasks: () => [
530
- // Mailchimp carries the same warning, deliberately worded the same way. A
531
- // merchant who connects either one and is told nothing reasonably assumes
532
- // contacts are flowing, and finds out weeks later that they are not.
533
- {
534
- message: "Contact syncing to Klaviyo lists has not shipped yet. Connecting stores your authorization so it is ready, but nothing is being sent to Klaviyo right now.",
535
- title: "List sync not available yet",
536
- type: "warning"
1971
+ // ONE OF THE FOUR STATES AND NOTHING ELSE the reason sits in `tasks`, which
1972
+ // is already the merchant-facing copy channel and is already rendered.
1973
+ //
1974
+ // A grant with no list chosen is authenticated and useless. The list cannot be
1975
+ // part of the consent flow — enumerating lists needs the token the consent
1976
+ // returns — so it is always a second step, and the card must say Pending
1977
+ // rather than Active over nothing.
1978
+ //
1979
+ // Otherwise the credential's own verdict stands. A manifest can only ever
1980
+ // DOWNGRADE: it can see the settings, and it cannot see whether the grant was
1981
+ // revoked at Klaviyo an hour ago.
1982
+ //
1983
+ // Computed at read time rather than written, for the same reason
1984
+ // shopifyMissingScopes is: it becomes true the moment a merchant clears the
1985
+ // list, without waiting for something to notice and write it down.
1986
+ status: (data2) => {
1987
+ var _a;
1988
+ return ((_a = data2 == null ? void 0 : data2.settings) == null ? void 0 : _a.list) ? data2.status : "pending";
1989
+ },
1990
+ steps: {
1991
+ contacts: {
1992
+ // A DECLARATION, not the work. It names the hook that does the work, and
1993
+ // says where that hook's values belong. Nested like the hooks, and the
1994
+ // nesting IS the name: this is `step.contacts.sync`, which is what a
1995
+ // workflow document stores.
1996
+ //
1997
+ // A function, so it can depend on what this deployment or this
1998
+ // merchant's connection knows a static object would have to be true
1999
+ // for every deployment at publish time.
2000
+ sync: ({ data: data2 }) => {
2001
+ var _a;
2002
+ return {
2003
+ hook: "contacts.sync",
2004
+ // The account the merchant actually connected, read back by
2005
+ // auth.connect. The builder reads "Sync contact to Acme Co" rather
2006
+ // than a label that could be any of their Klaviyo accounts.
2007
+ key: "Sync contact to " + (((_a = data2 == null ? void 0 : data2.settings) == null ? void 0 : _a.account) || "Klaviyo"),
2008
+ queue: "connection",
2009
+ // Nothing for a merchant to configure on the step itself — the list
2010
+ // is chosen once on the connection. Declared empty rather than
2011
+ // omitted, so "this step takes no settings" and "nobody thought about
2012
+ // settings" are different statements.
2013
+ settings: {},
2014
+ // BOTH triggers. lead.insert alone only ever fires for someone with
2015
+ // no history yet — a brand-new entrant has no orders and no revenue,
2016
+ // so a profile written then carries an email and nothing else.
2017
+ // Crossing into a segment is the moment the ranking data exists.
2018
+ triggers: ["lead.insert", "segment.contact.add"],
2019
+ // One source for cost: what the builder discloses before a merchant
2020
+ // adds this step, and what is charged when it runs.
2021
+ usage: { actions: 1 }
2022
+ };
2023
+ }
537
2024
  }
538
- ],
2025
+ },
2026
+ // WHY, in the merchant's words, and what to do about it.
2027
+ tasks: (data2) => {
2028
+ var _a;
2029
+ return ((_a = data2 == null ? void 0 : data2.settings) == null ? void 0 : _a.list) ? [] : [
2030
+ {
2031
+ message: "Choose which Klaviyo list your contacts should sync into. Until you do, nothing is being synced.",
2032
+ title: "Choose a list"
2033
+ }
2034
+ ];
2035
+ },
539
2036
  title: "Klaviyo"
540
2037
  };
541
2038
 
@@ -572,13 +2069,28 @@ var mailchimp_default2 = {
572
2069
  auth: {
573
2070
  type: "keys"
574
2071
  },
575
- category: "contacts",
576
- confirm: "Disconnecting removes your stored Mailchimp key. Your contacts stay in both Drawbridge and Mailchimp \u2014 neither list is deleted.",
577
- description: [
578
- "Drawbridge no longer sends email through Mailchimp. Notification email now sends from Drawbridge itself, and verifying a domain under Networking in your organization settings puts your own brand in the from line.",
579
- "This connection is becoming the way your Drawbridge contacts sync into a Mailchimp audience. Audience syncing is not live yet, so a key stored here does nothing today."
580
- ],
581
- excerpt: "Sync your Drawbridge contacts into a Mailchimp audience.",
2072
+ // EVERYTHING A MERCHANT READS. `errors` belongs in here rather than at the
2073
+ // top level because the connection DOCUMENT carries its own `errors` array
2074
+ // and the document is spread OVER the resolved manifest downstream — a
2075
+ // top-level one would be replaced by that array and never render.
2076
+ content: {
2077
+ confirm: "Disconnecting removes your stored Mailchimp key. Your contacts stay in both Drawbridge and Mailchimp \u2014 neither list is deleted.",
2078
+ description: [
2079
+ "Drawbridge no longer sends email through Mailchimp. Notification email now sends from Drawbridge itself, and verifying a domain under Networking in your organization settings puts your own brand in the from line.",
2080
+ "This connection is becoming the way your Drawbridge contacts sync into a Mailchimp audience. Audience syncing is not live yet, so a key stored here does nothing today."
2081
+ ],
2082
+ excerpt: "Sync your Drawbridge contacts into a Mailchimp audience.",
2083
+ guide: [
2084
+ "In Mailchimp, open Account & billing, then Extras, then API keys.",
2085
+ "Create a key and copy it.",
2086
+ "Paste it here. The key ends in a data-centre suffix like -us19, which tells Drawbridge which Mailchimp server your account is on."
2087
+ ]
2088
+ },
2089
+ // Mailchimp and SendGrid shared a group while they were SENDERS, where an org
2090
+ // picking two providers to send the same mail was meaningless. As contact
2091
+ // syncs they are destinations, and a merchant could reasonably keep several
2092
+ // up to date, so the exclusivity is gone.
2093
+ exclusive: false,
582
2094
  feature: "organization:connection:mailchimp",
583
2095
  fields: [
584
2096
  {
@@ -595,99 +2107,120 @@ var mailchimp_default2 = {
595
2107
  key: "audience",
596
2108
  label: "Mailchimp audience",
597
2109
  message: "Contacts your campaigns collect are synced into this audience.",
2110
+ hook: "resources.audiences",
598
2111
  required: true,
599
- source: "catalog.audiences"
2112
+ // Mailchimp's /lists takes no name filter either — same reason.
2113
+ search: false
600
2114
  }
601
2115
  ],
602
- // The audiences a merchant can sync into, for the picker on their connection.
603
- //
604
- // count DEFAULTS TO 10 and maxes at 1000 (their own OpenAPI spec), so leaving
605
- // it unset returns the first ten audiences and looks entirely successful
606
- // the same silent truncation Klaviyo has, at a different number. Paged
607
- // against total_items so an account past a thousand still resolves.
2116
+ group: "contacts",
2117
+ // A HOOK'S VALUE IS ITS ANSWER. A key is stored and can be removed; nothing
2118
+ // else is built yet, because audience sync has not shipped. Every false here
2119
+ // is "not yet" rather than "never" when the sync lands, probe and
2120
+ // contacts.sync are the first to flip.
608
2121
  hooks: {
609
- "catalog.audiences": async ({ cursor, fetcher = fetch, limit = 100, search, settings }) => {
610
- const key = settings == null ? void 0 : settings.apiKey;
611
- const count = Math.min(limit, 1e3);
612
- const offset = Number(cursor || 0);
613
- const response = await fetcher(
614
- base(key) + "/lists?count=" + count + "&offset=" + offset + "&fields=lists.id,lists.name,total_items",
615
- {
616
- // Basic with any username Mailchimp reads only the password half.
617
- headers: { authorization: "Basic " + Buffer.from("drawbridge:" + key).toString("base64") },
618
- signal: AbortSignal.timeout(15e3)
619
- }
620
- );
621
- if (!response.ok) {
622
- throw Object.assign(
623
- new Error("Mailchimp refused the request (" + response.status + ")"),
624
- { status: response.status }
2122
+ auth: {
2123
+ // Implemented outside this package: storing a typed key needs no vendor
2124
+ // call, so the api's own form handler does it.
2125
+ connect: {},
2126
+ disconnect: {},
2127
+ probe: false,
2128
+ scopes: false,
2129
+ // Keys today. When Mailchimp's OAuth lands this becomes a wrapper that
2130
+ // follows the exchange with /oauth2/metadata the data-centre call that
2131
+ // is the whole reason its OAuth cannot be pure configuration.
2132
+ token: false
2133
+ },
2134
+ commerce: false,
2135
+ contacts: { remove: false, sync: false },
2136
+ // Drawbridge sends its own notification email and SMS, and owns its own
2137
+ // segments — see the private `drawbridge` manifest. A vendor answering
2138
+ // these would be a second sender, which is the arrangement the platform
2139
+ // sender replaced.
2140
+ email: false,
2141
+ segment: false,
2142
+ sms: false,
2143
+ inbound: false,
2144
+ lifecycle: false,
2145
+ resources: {
2146
+ // The audiences a merchant can sync into, for the picker on their
2147
+ // connection.
2148
+ //
2149
+ // count DEFAULTS TO 10 and maxes at 1000 (Mailchimp's own OpenAPI spec),
2150
+ // so leaving it unset returns the first ten audiences and looks entirely
2151
+ // successful — the same silent truncation Klaviyo has, at a different
2152
+ // number. Paged against total_items so an account past a thousand still
2153
+ // resolves.
2154
+ audiences: async ({ cursor, fetcher = fetch, limit = 100, search, settings }) => {
2155
+ const key = settings == null ? void 0 : settings.apiKey;
2156
+ const count = Math.min(limit, 1e3);
2157
+ const offset = Number(cursor || 0);
2158
+ const response = await fetcher(
2159
+ base(key) + "/lists?count=" + count + "&offset=" + offset + "&fields=lists.id,lists.name,total_items",
2160
+ {
2161
+ // Basic with any username — Mailchimp reads only the password half.
2162
+ headers: { authorization: "Basic " + Buffer.from("drawbridge:" + key).toString("base64") },
2163
+ signal: AbortSignal.timeout(15e3)
2164
+ }
625
2165
  );
626
- }
627
- const body = await response.json();
628
- const audiences = ((body == null ? void 0 : body.lists) || []).map((list) => ({ id: list.id, title: (list == null ? void 0 : list.name) || list.id }));
629
- const term = String((search == null ? void 0 : search.value) || "").trim().toLowerCase();
630
- const items = term ? audiences.filter((entry) => entry.title.toLowerCase().includes(term)) : audiences;
631
- const nextOffset = offset + count;
632
- const more = nextOffset < Number((body == null ? void 0 : body.total_items) || 0);
633
- return {
634
- items,
635
- pageInfo: {
636
- endCursor: more ? String(nextOffset) : null,
637
- hasNextPage: more
2166
+ if (!response.ok) {
2167
+ throw Object.assign(
2168
+ new Error("Mailchimp refused the request (" + response.status + ")"),
2169
+ { status: response.status }
2170
+ );
638
2171
  }
639
- };
640
- }
2172
+ const body = await response.json();
2173
+ const audiences = ((body == null ? void 0 : body.lists) || []).map((list) => ({ id: list.id, title: (list == null ? void 0 : list.name) || list.id }));
2174
+ const term = String((search == null ? void 0 : search.value) || "").trim().toLowerCase();
2175
+ const items = term ? audiences.filter((entry) => entry.title.toLowerCase().includes(term)) : audiences;
2176
+ const nextOffset = offset + count;
2177
+ const more = nextOffset < Number((body == null ? void 0 : body.total_items) || 0);
2178
+ return {
2179
+ items,
2180
+ pageInfo: {
2181
+ endCursor: more ? String(nextOffset) : null,
2182
+ hasNextPage: more
2183
+ }
2184
+ };
2185
+ },
2186
+ prices: false,
2187
+ products: false,
2188
+ promotions: false
2189
+ },
2190
+ // Drawbridge posts to a merchant's own endpoint, never through a vendor.
2191
+ webhook: false
641
2192
  },
642
2193
  icon: mailchimp_default,
2194
+ slug: "mailchimp",
643
2195
  // A key with no audience chosen is authenticated and inert. Mailchimp also
644
2196
  // needs its merge fields created on that audience before any Drawbridge total
645
2197
  // can be written to a member — unlike Klaviyo, its custom fields are not
646
2198
  // schemaless — so the audience must be picked before lifecycle.register has
647
2199
  // anything to register against.
648
- incomplete: (data) => {
2200
+ status: (data2) => {
649
2201
  var _a;
650
- return ((_a = data == null ? void 0 : data.settings) == null ? void 0 : _a.audience) ? null : "Choose which Mailchimp audience your contacts should sync into.";
2202
+ return ((_a = data2 == null ? void 0 : data2.settings) == null ? void 0 : _a.audience) ? data2.status : "pending";
651
2203
  },
652
- label: "mailchimp",
653
- // Uniform surface, honest answers. A key is stored and can be removed; nothing
654
- // else is built yet, because audience sync has not shipped. Every false here
655
- // is "not yet", not "never" — when the sync lands, probe and catalog become
656
- // the first two to flip.
657
- supports: {
658
- "auth.connect": true,
659
- "auth.disconnect": true,
660
- "auth.probe": false,
661
- "auth.scopes": false,
662
- "catalog.audiences": true,
663
- "catalog.prices": false,
664
- "catalog.products": false,
665
- "catalog.promotions": false,
666
- "inbound.event": false,
667
- "inbound.process": false,
668
- "inbound.receive": false,
669
- "inbound.verify": false,
670
- "lifecycle.cleanup": false,
671
- "lifecycle.register": false,
672
- "lifecycle.rehydrate": false
673
- },
674
- setup: [
675
- "In Mailchimp, open Account & billing, then Extras, then API keys.",
676
- "Create a key and copy it.",
677
- "Paste it here. The key ends in a data-centre suffix like -us19, which tells Drawbridge which Mailchimp server your account is on."
678
- ],
679
- slug: "mailchimp",
680
2204
  // No steps: audience sync has not shipped, so this vendor contributes nothing
681
2205
  // to a workflow yet. An empty steps object is the honest declaration — the
682
2206
  // catalog renders the connection, and no builder offers a step it cannot run.
683
2207
  steps: {},
684
- tasks: () => [
685
- {
686
- message: "Contact syncing to Mailchimp audiences has not shipped yet, and this connection no longer sends your email. Nothing is being sent to Mailchimp right now.",
687
- title: "Audience sync not available yet",
688
- type: "warning"
689
- }
690
- ],
2208
+ tasks: (data2) => {
2209
+ var _a;
2210
+ return [
2211
+ ...((_a = data2 == null ? void 0 : data2.settings) == null ? void 0 : _a.audience) ? [] : [
2212
+ {
2213
+ message: "Choose which Mailchimp audience your contacts should sync into. Until you do, nothing is being synced.",
2214
+ title: "Choose an audience"
2215
+ }
2216
+ ],
2217
+ {
2218
+ message: "Contact syncing to Mailchimp audiences has not shipped yet, and this connection no longer sends your email. Nothing is being sent to Mailchimp right now.",
2219
+ title: "Audience sync not available yet",
2220
+ type: "warning"
2221
+ }
2222
+ ];
2223
+ },
691
2224
  title: "Mailchimp"
692
2225
  };
693
2226
 
@@ -743,31 +2276,48 @@ var shopify_default2 = {
743
2276
  auth: {
744
2277
  type: "install"
745
2278
  },
746
- category: "commerce",
747
- confirm: "Disconnecting deactivates all products from this store, drafts any advertisements that use them, disables Shopify steps in your workflows until you reconnect, and stops revenue tracking for this organization.",
748
- // How connecting is DESCRIBED the copy and destination. What kind of connect
749
- // it is lives in auth.type, once, so the two cannot disagree.
2279
+ // EVERYTHING A MERCHANT READS.
2280
+ //
2281
+ // `errors` is in here rather than at the top level, and that is not a
2282
+ // preference: the connection DOCUMENT carries its own `errors` array of
2283
+ // scope-drift entries, and the document is spread OVER the resolved manifest
2284
+ // downstream — a top-level one would be replaced by that array and never
2285
+ // render.
750
2286
  //
751
- // The redirect title is copy: it names where the link GOES rather than what it
752
- // does, since installing happens on the App Store listing and the dashboard
753
- // must never imply a store can be linked from inside it.
754
- connect: {
2287
+ // `connect` no longer exists as a container. Its other member was `redirect`,
2288
+ // which is a URL and now sits with the vendor's other addresses.
2289
+ content: {
2290
+ confirm: "Disconnecting deactivates all products from this store, drafts any advertisements that use them, disables Shopify steps in your workflows until you reconnect, and stops revenue tracking for this organization.",
2291
+ description: [
2292
+ "Installing the Drawbridge app from the Shopify App Store links your store to a single Drawbridge organization and makes your product catalog available inside Drawbridge, so you can feature products in your campaigns and advertisements.",
2293
+ "Drawbridge attributes orders that originate from your campaigns \u2014 matched through cart parameters and lead-mapped discount codes \u2014 so you can see the revenue each campaign drives.",
2294
+ "On connect, Drawbridge registers webhooks for product and order updates to keep your catalog and revenue in sync. Disconnecting removes those webhooks and unlinks the resources."
2295
+ ],
755
2296
  errors: {
756
- conflict: "This store is already connected to another Drawbridge organization.",
757
- currency: "This store settles in a currency we can't bill yet. Connect a store with a supported settlement currency.",
758
- invalid: "We couldn't verify the install. Please try connecting again from the Shopify App Store."
2297
+ connect: {
2298
+ conflict: "This store is already connected to another Drawbridge organization.",
2299
+ currency: "This store settles in a currency we can't bill yet. Connect a store with a supported settlement currency.",
2300
+ invalid: "We couldn't verify the install. Please try connecting again from the Shopify App Store."
2301
+ }
759
2302
  },
2303
+ excerpt: "Connect your Shopify store to feature products in your campaigns and track conversions.",
2304
+ guide: [
2305
+ "Open the Drawbridge listing on the Shopify App Store.",
2306
+ "Install the app on the store you want to connect. It opens in Shopify admin and stays there.",
2307
+ "Choose a plan when Shopify asks. The connection shows Pending until you do, then Active.",
2308
+ "Come back here \u2014 the connections list updates on its own once the install lands."
2309
+ ],
2310
+ // Names where the link GOES rather than what it does: installing happens on
2311
+ // the App Store listing, and the dashboard must never imply a store can be
2312
+ // linked from inside it.
760
2313
  redirect: {
761
2314
  env: "SHOPIFY_APP_LISTING_URL",
762
2315
  title: "View on the Shopify App Store"
763
2316
  }
764
2317
  },
765
- description: [
766
- "Installing the Drawbridge app from the Shopify App Store links your store to a single Drawbridge organization and makes your product catalog available inside Drawbridge, so you can feature products in your campaigns and advertisements.",
767
- "Drawbridge attributes orders that originate from your campaigns \u2014 matched through cart parameters and lead-mapped discount codes \u2014 so you can see the revenue each campaign drives.",
768
- "On connect, Drawbridge registers webhooks for product and order updates to keep your catalog and revenue in sync. Disconnecting removes those webhooks and unlinks the catalog."
769
- ],
770
- excerpt: "Connect your Shopify store to feature products in your campaigns and track conversions.",
2318
+ // ONE STORE PER ORGANIZATION. Two Shopify stores on one org would give every
2319
+ // attributed order two possible sources.
2320
+ exclusive: true,
771
2321
  feature: "organization:connection:shopify",
772
2322
  fields: [
773
2323
  {
@@ -778,12 +2328,9 @@ var shopify_default2 = {
778
2328
  label: "Store domain"
779
2329
  }
780
2330
  ],
781
- group: "ecommerce",
782
- // The install is the whole configuration Shopify hands back the shop and
783
- // there is nothing further to choose. `shop` absent means the install did not
784
- // finish, which is a credential problem rather than a setup one, so the
785
- // stored status already says so.
786
- incomplete: () => null,
2331
+ // Was `category : 'commerce'` AND `group : 'ecommerce'` — two words for one
2332
+ // fact, which left nobody able to say which one a page read.
2333
+ group: "commerce",
787
2334
  // verify and event lean entirely on the shared HMAC helper — Shopify's scheme
788
2335
  // is exactly the shape it covers, so there is nothing vendor-specific to
789
2336
  // write for either. receive is the one hook that genuinely differs by
@@ -791,25 +2338,148 @@ var shopify_default2 = {
791
2338
  // /compliance enforces the topic allowlist above, because answering one late
792
2339
  // is a legal deadline rather than a retry.
793
2340
  hooks: {
794
- "inbound.event": (args) => readEventHeader({ ...args, descriptor: inbound }),
795
- "inbound.receive": ({ channel, event, headers, payload }) => {
796
- if (channel === "compliance" && !COMPLIANCE_TOPICS.has(event)) {
797
- throw Object.assign(new Error("Unrecognized compliance topic: " + event), { status: 401 });
2341
+ auth: {
2342
+ // The install completes inside Shopify admin; the api's callback stores
2343
+ // what it hands back. auth.probe is false deliberately: the health check
2344
+ // re-registers rather than answering "is this token still good", and
2345
+ // scope drift is its own hook because a token can be perfectly valid
2346
+ // while the grant is too narrow.
2347
+ connect: {},
2348
+ disconnect: {},
2349
+ probe: false,
2350
+ scopes: {},
2351
+ // Shopify's install grant is exchanged inside its own app flow, not
2352
+ // through the shared OAuth runner.
2353
+ token: false
2354
+ },
2355
+ // Implemented in drawbridge-sync, which owns the attribution and the
2356
+ // controllers it needs. Declared here so the steps below can point at them:
2357
+ // a step naming a hook the vendor does not implement is a workflow that
2358
+ // accepts the step and then silently does nothing.
2359
+ commerce: {
2360
+ code: {},
2361
+ customer: {},
2362
+ order: {},
2363
+ product: {}
2364
+ },
2365
+ contacts: { remove: false, sync: false },
2366
+ // verify and event lean entirely on the shared HMAC helper — Shopify's
2367
+ // scheme is exactly the shape it covers, so there is nothing vendor-specific
2368
+ // to write for either. receive is the one hook that genuinely differs by
2369
+ // channel: /events buffers whatever arrives with the shop domain stamped on;
2370
+ // /compliance enforces the topic allowlist above, because answering one late
2371
+ // is a legal deadline rather than a retry.
2372
+ // Drawbridge sends its own notification email and SMS, and owns its own
2373
+ // segments — see the private `drawbridge` manifest. A vendor answering
2374
+ // these would be a second sender, which is the arrangement the platform
2375
+ // sender replaced.
2376
+ email: false,
2377
+ segment: false,
2378
+ sms: false,
2379
+ inbound: {
2380
+ event: (args) => readEventHeader({ ...args, descriptor: inbound }),
2381
+ process: {},
2382
+ receive: ({ channel, event, headers, payload }) => {
2383
+ if (channel === "compliance" && !COMPLIANCE_TOPICS.has(event)) {
2384
+ throw Object.assign(new Error("Unrecognized compliance topic: " + event), { status: 401 });
2385
+ }
2386
+ return {
2387
+ // Compliance payloads already carry shop_domain in the body — Shopify's
2388
+ // own GDPR shape. The app-level event stream does not; that domain
2389
+ // lives only in the header, so it is stamped on here rather than left
2390
+ // for drawbridge-sync to reach into headers nobody hands it.
2391
+ data: channel === "compliance" ? payload : { ...payload, shop_domain: headers[inbound.headers.shop] || null },
2392
+ provider: { id: headers[inbound.headers.id] || null }
2393
+ };
2394
+ },
2395
+ verify: (args) => verifySignature({ ...args, descriptor: inbound })
2396
+ },
2397
+ lifecycle: { cleanup: {}, health: {}, register: {}, rehydrate: {} },
2398
+ resources: {
2399
+ audiences: false,
2400
+ // Shopify has no separate price resource — a price belongs to a product
2401
+ // variant and arrives with it, so there is nothing for prices to answer
2402
+ // that products does not already.
2403
+ prices: false,
2404
+ // WHAT THE VENDOR ANSWERS, shaped for a picker. Both of these were api
2405
+ // ROUTES — /organization/:organization/shopify/products and
2406
+ // .../connection/:id/shopify/discounts — vendor-named urls in a service
2407
+ // that is supposed to have none, reachable only by knowing the path.
2408
+ // They are the same two questions every other vendor answers through
2409
+ // resources.*, so they answer them the same way now.
2410
+ //
2411
+ // `shopify` is INJECTED: this package cannot import @drawbridge/shopify,
2412
+ // which depends on it. What arrives is the SDK's pure HTTP namespaces
2413
+ // and nothing else — no controller, no collection access. Resolving the
2414
+ // credential is the caller's job because it is Drawbridge's job: the
2415
+ // admin token refreshes and writes itself back, which is service work,
2416
+ // not vendor work.
2417
+ products: async ({ cursor, limit = 100, search, settings, shopify, sort }) => {
2418
+ var _a, _b, _c, _d;
2419
+ const products = await shopify.storefront.getProducts({
2420
+ cursor,
2421
+ domain: settings == null ? void 0 : settings.domain,
2422
+ limit: Number(limit),
2423
+ search: (search == null ? void 0 : search.value) || null,
2424
+ sort,
2425
+ storefrontAccessToken: settings == null ? void 0 : settings.storefrontAccessToken
2426
+ });
2427
+ return {
2428
+ items: ((products == null ? void 0 : products.edges) || []).map((edge) => edge.node),
2429
+ pageInfo: {
2430
+ endCursor: ((_a = products == null ? void 0 : products.pageInfo) == null ? void 0 : _a.endCursor) || null,
2431
+ hasNextPage: Boolean((_b = products == null ? void 0 : products.pageInfo) == null ? void 0 : _b.hasNextPage),
2432
+ hasPreviousPage: Boolean((_c = products == null ? void 0 : products.pageInfo) == null ? void 0 : _c.hasPreviousPage),
2433
+ startCursor: ((_d = products == null ? void 0 : products.pageInfo) == null ? void 0 : _d.startCursor) || null
2434
+ }
2435
+ };
2436
+ },
2437
+ promotions: async ({ cursor, limit = 100, search, settings, shopify }) => {
2438
+ var _a, _b;
2439
+ const discounts = await shopify.admin.getDiscounts({
2440
+ adminAccessToken: settings == null ? void 0 : settings.adminAccessToken,
2441
+ cursor,
2442
+ domain: settings == null ? void 0 : settings.domain,
2443
+ limit: Number(limit),
2444
+ search: (search == null ? void 0 : search.value) || null
2445
+ });
2446
+ return {
2447
+ // The GLOBAL id is what Shopify returns and the bare id is what a
2448
+ // picker stores, which is why the tail is taken here rather than by
2449
+ // each caller that happened to remember.
2450
+ items: ((discounts == null ? void 0 : discounts.edges) || []).map((edge) => {
2451
+ var _a2, _b2, _c;
2452
+ return {
2453
+ id: String(((_a2 = edge == null ? void 0 : edge.node) == null ? void 0 : _a2.id) || "").split("/").pop(),
2454
+ title: (_c = (_b2 = edge == null ? void 0 : edge.node) == null ? void 0 : _b2.codeDiscount) == null ? void 0 : _c.title
2455
+ };
2456
+ }),
2457
+ pageInfo: {
2458
+ endCursor: ((_a = discounts == null ? void 0 : discounts.pageInfo) == null ? void 0 : _a.endCursor) || null,
2459
+ hasNextPage: Boolean((_b = discounts == null ? void 0 : discounts.pageInfo) == null ? void 0 : _b.hasNextPage)
2460
+ }
2461
+ };
798
2462
  }
799
- return {
800
- // Compliance payloads already carry shop_domain in the body — Shopify's
801
- // own GDPR shape. The app-level event stream does not; that domain
802
- // lives only in the header, so it is stamped on here rather than left
803
- // for drawbridge-sync to reach into headers nobody hands it.
804
- data: channel === "compliance" ? payload : { ...payload, shop_domain: headers[inbound.headers.shop] || null },
805
- provider: { id: headers[inbound.headers.id] || null }
806
- };
807
2463
  },
808
- "inbound.verify": (args) => verifySignature({ ...args, descriptor: inbound })
2464
+ // Drawbridge posts to a merchant's own endpoint, never through a vendor.
2465
+ webhook: false
809
2466
  },
810
2467
  icon: shopify_default,
811
2468
  inbound,
812
- label: "shopify",
2469
+ // THE DEEP LINK into this store's Drawbridge app inside Shopify admin.
2470
+ //
2471
+ // Here rather than in drawbridge-api, which had `slug === 'shopify' && {...}`
2472
+ // in the shared resolver — a hardcoded vendor branch in code every vendor runs
2473
+ // through, which is the arrangement these manifests exist to remove.
2474
+ //
2475
+ // Undefined until a shop is linked, so the Manage button only appears on a
2476
+ // connected connection. The app handle is NAMED by `requires` and read from
2477
+ // the env the resolver passes, never from process.env here.
2478
+ manage: (data2, env) => {
2479
+ var _a;
2480
+ const shop = (data2 == null ? void 0 : data2.shop) || ((_a = data2 == null ? void 0 : data2.settings) == null ? void 0 : _a.domain);
2481
+ return shop ? "https://admin.shopify.com/store/" + String(shop).replace(".myshopify.com", "") + "/apps/" + (env == null ? void 0 : env.SHOPIFY_APP_HANDLE) : void 0;
2482
+ },
813
2483
  // A pre-launch integration: it only surfaces once the App Store listing
814
2484
  // exists and the app is fully configured. Requiring all four means it can
815
2485
  // never render half-configured — and absence of any one excludes the
@@ -820,133 +2490,273 @@ var shopify_default2 = {
820
2490
  "SHOPIFY_APP_LISTING_URL",
821
2491
  "SHOPIFY_APP_HANDLE"
822
2492
  ],
823
- // The only vendor implementing most of the surface, which is why it was the
824
- // one every slug branch in three repos was written for.
825
- //
826
- // auth.probe is false deliberately: the health check re-registers webhooks
827
- // rather than answering "is this token still good", and scope drift is its own
828
- // hook because a token can be perfectly valid while the grant is too narrow.
829
- supports: {
830
- "auth.connect": true,
831
- "auth.disconnect": true,
832
- "auth.probe": false,
833
- "auth.scopes": true,
834
- // Shopify has no separate price resource — a price belongs to a product
835
- // variant and arrives with it, so there is nothing for prices to answer
836
- // that products does not already.
837
- "catalog.audiences": false,
838
- "catalog.prices": false,
839
- "catalog.products": true,
840
- "catalog.promotions": true,
841
- "inbound.event": true,
842
- "inbound.process": true,
843
- "inbound.receive": true,
844
- "inbound.verify": true,
845
- "lifecycle.cleanup": true,
846
- "lifecycle.register": true,
847
- "lifecycle.rehydrate": true
848
- },
849
- setup: [
850
- "Open the Drawbridge listing on the Shopify App Store.",
851
- "Install the app on the store you want to connect. It opens in Shopify admin and stays there.",
852
- "Choose a plan when Shopify asks. The connection shows Pending until you do, then Active.",
853
- "Come back here \u2014 the connections list updates on its own once the install lands."
854
- ],
855
2493
  slug: "shopify",
2494
+ // The install is the whole configuration — Shopify hands back the shop and
2495
+ // there is nothing further to choose. `shop` absent means the install did not
2496
+ // finish, which is a credential problem rather than a setup one, so the
2497
+ // stored status already says so.
2498
+ // Nothing to add — no setting can make this connection unusable, so the
2499
+ // credential's own verdict stands.
2500
+ status: (data2) => data2 == null ? void 0 : data2.status,
856
2501
  // Step types name the CAPABILITY, not this vendor. A second store platform
857
2502
  // implements the same four commerce steps, and the connection on the step
858
2503
  // says which store it runs against — so a merchant sees one "Create
859
2504
  // customer", not one per platform. The three connection.* steps are not
860
2505
  // commerce at all: any vendor holding a rotating credential needs them.
2506
+ // Step types name the CAPABILITY, not this vendor. A second store platform
2507
+ // implements the same commerce steps, and the connection on the step says
2508
+ // which store it runs against — so a merchant sees one "Create customer", not
2509
+ // one per platform.
2510
+ //
2511
+ // Nested for readability and flattened to the stored name, at whatever depth:
2512
+ // steps.commerce.customer.insert is `step.commerce.customer.insert` on a
2513
+ // workflow document, and those strings cannot be renamed without a backfill.
2514
+ //
2515
+ // EVERY LEAF IS A FUNCTION so a step can read the merchant's own connection.
2516
+ // The bodies these point at still live in drawbridge-sync; moving them is the
2517
+ // next unit, and commerce.order.record is the one that decides whether the
2518
+ // shape holds — 569 lines and 15 controller calls.
861
2519
  steps: {
862
- "step.commerce.customer.insert": {
863
- billable: true,
864
- key: "Create customer",
865
- queue: "connection",
866
- returns: [
867
- { key: "shopifyCustomerId", label: "Shopify Customer ID" }
868
- ],
869
- settings: {},
870
- triggers: ["lead.insert"]
871
- },
872
- "step.commerce.code.issue": {
873
- billable: true,
874
- key: "Issue a discount code",
875
- queue: "connection",
876
- returns: [
877
- { key: "shopifyDiscountCode", label: "Shopify Discount Code" },
878
- { key: "shopifyDiscountId", label: "Shopify Discount ID" }
879
- ],
880
- settings: {
881
- discount: {
882
- required: true,
883
- shape: {
884
- id: { required: true, type: "string" }
2520
+ commerce: {
2521
+ code: {
2522
+ issue: () => ({
2523
+ hook: "commerce.code",
2524
+ key: "Issue a discount code",
2525
+ queue: "connection",
2526
+ settings: {
2527
+ discount: {
2528
+ required: true,
2529
+ shape: {
2530
+ id: { required: true, type: "string" }
2531
+ },
2532
+ type: "object"
2533
+ }
885
2534
  },
886
- type: "object"
887
- }
2535
+ triggers: ["lead.insert"],
2536
+ usage: { actions: 1 }
2537
+ })
888
2538
  },
889
- triggers: ["lead.insert"]
890
- },
891
- // System steps: dispatched by sync itself rather than offered in the
892
- // builder, so they carry no trigger. They are declared because the
893
- // routing table and the system-workflow descriptions both read from here.
894
- // Not a webhook monitor, despite the name it carried. Webhooks are
895
- // declarative — declared in the app's toml, applied by Shopify to every
896
- // install so nothing registers or checks them here. This rotates the
897
- // access token before Shopify's idle window closes, and reconciles the
898
- // scopes the store granted against the ones the app now needs.
899
- "step.connection.health.check": {
900
- description: "Keeps store access working \u2014 refreshes the access token before it goes stale and reports when the store's approved permissions fall behind.",
901
- key: "Shopify Connection Health",
902
- queue: "connection",
903
- system: true
904
- },
905
- "step.commerce.order.record": {
906
- description: "Records an order and billing charge when a purchase is made via a Drawbridge campaign link.",
907
- key: "Shopify Order Tracking",
908
- queue: "connection",
909
- system: true
910
- },
911
- "step.commerce.product.sync": {
912
- description: "Syncs Shopify product data on webhook updates.",
913
- key: "Shopify Product Sync",
914
- queue: "connection",
915
- system: true
916
- },
917
- // Audit-only. The "Shopify Token Activity" system workflow lists these for
918
- // descriptive grouping, but its audit step docs are written manually at
919
- // OAuth time — the workflow is never dispatched. Routing is declared
920
- // defensively so that if it ever IS dispatched, the job lands on a real
921
- // queue and the handler lookup misses cleanly instead of throwing
922
- // "Unknown step type".
923
- "step.connection.token.exchange": {
924
- key: "Shopify Token Exchange",
925
- queue: "connection",
926
- system: true
2539
+ customer: {
2540
+ insert: () => ({
2541
+ hook: "commerce.customer",
2542
+ key: "Create customer",
2543
+ queue: "connection",
2544
+ settings: {},
2545
+ triggers: ["lead.insert"],
2546
+ usage: { actions: 1 }
2547
+ })
2548
+ },
2549
+ // SYSTEM STEPS: dispatched by drawbridge-sync itself rather than offered
2550
+ // in the builder, so they carry no trigger and no usage. Declared because
2551
+ // the routing table and the system-workflow descriptions both read here.
2552
+ order: {
2553
+ record: () => ({
2554
+ description: "Records an order and billing charge when a purchase is made via a Drawbridge campaign link.",
2555
+ hook: "commerce.order",
2556
+ key: "Shopify Order Tracking",
2557
+ queue: "connection",
2558
+ system: true
2559
+ })
2560
+ },
2561
+ product: {
2562
+ sync: () => ({
2563
+ description: "Syncs Shopify product data on webhook updates.",
2564
+ hook: "commerce.product",
2565
+ key: "Shopify Product Sync",
2566
+ queue: "connection",
2567
+ system: true
2568
+ })
2569
+ }
927
2570
  },
928
- "step.connection.token.refresh": {
929
- key: "Shopify Token Refresh",
930
- queue: "connection",
931
- system: true
2571
+ connection: {
2572
+ // Not a webhook monitor, despite the name it once carried. Webhooks are
2573
+ // declarative — declared in the app's toml, applied by Shopify to every
2574
+ // install — so nothing registers or checks them here. This rotates the
2575
+ // access token before Shopify's idle window closes, and reconciles the
2576
+ // scopes the store granted against the ones the app now needs.
2577
+ health: {
2578
+ check: () => ({
2579
+ description: "Keeps store access working \u2014 refreshes the access token before it goes stale and reports when the store's approved permissions fall behind.",
2580
+ hook: "lifecycle.health",
2581
+ key: "Shopify Connection Health",
2582
+ queue: "connection",
2583
+ system: true
2584
+ })
2585
+ },
2586
+ // Audit-only. The "Shopify Token Activity" system workflow lists these
2587
+ // for descriptive grouping, but its audit step docs are written manually
2588
+ // at OAuth time — the workflow is never dispatched. Routing is declared
2589
+ // defensively so that if it ever IS dispatched, the job lands on a real
2590
+ // queue and the handler lookup misses cleanly instead of throwing
2591
+ // "Unknown step type".
2592
+ token: {
2593
+ exchange: () => ({
2594
+ description: "Records the token exchange that completed an install. Audit only \u2014 never dispatched.",
2595
+ key: "Shopify Token Exchange",
2596
+ queue: "connection",
2597
+ system: true
2598
+ }),
2599
+ refresh: () => ({
2600
+ description: "Records a token rotation. Audit only \u2014 never dispatched.",
2601
+ key: "Shopify Token Refresh",
2602
+ queue: "connection",
2603
+ system: true
2604
+ })
2605
+ }
932
2606
  }
933
2607
  },
2608
+ // Shopify sits pending between the install landing and the merchant choosing a
2609
+ // plan, and nothing on our side can move it — so the card says what they need
2610
+ // to go and do rather than showing Pending with no next step.
2611
+ //
2612
+ // Scope drift is NOT here: drawbridge-sync writes it onto the connection
2613
+ // document, and the document's own warnings render beside these.
2614
+ tasks: (data2) => (data2 == null ? void 0 : data2.status) === "pending" ? [
2615
+ {
2616
+ message: "Open the Drawbridge app in your Shopify admin and choose a plan. The connection activates once Shopify confirms it.",
2617
+ title: "Choose a plan in Shopify"
2618
+ }
2619
+ ] : [],
934
2620
  title: "Shopify"
935
2621
  };
936
2622
 
937
- // lib/connections/icons/drawbridge.js
938
- var drawbridge_default = `<svg width="500" height="500" viewBox="0 0 500 500" fill="none" xmlns="http://www.w3.org/2000/svg">
939
- <rect width="500" height="500" fill="#BAEC5F"/>
940
- <g clip-path="url(#clip0_2115_2832)">
941
- <path d="M140.224 127.586L174.803 188.73V311.176L140 372.32L176.084 392.031L216.111 321.753V178.278L176.341 108L140.224 127.586Z" fill="#0D1314"/>
942
- <path d="M360.001 127.523L323.693 108.282L284.948 178.498V321.596L322.923 391.749L359.393 372.79L326.224 311.52V188.73L360.001 127.523Z" fill="#0D1314"/>
943
- </g>
944
- <defs>
945
- <clipPath id="clip0_2115_2832">
946
- <rect width="220" height="284" fill="white" transform="translate(140 108)"/>
947
- </clipPath>
948
- </defs>
949
- </svg>`;
2623
+ // lib/connections/webhook.js
2624
+ import crypto from "crypto";
2625
+
2626
+ // lib/safe-http.js
2627
+ import dns2 from "dns";
2628
+ import * as http2 from "http";
2629
+ import * as https2 from "https";
2630
+
2631
+ // lib/axios.js
2632
+ import axiosLib from "axios";
2633
+ import dns from "dns";
2634
+ import * as http from "http";
2635
+ import * as https from "https";
2636
+ import net from "net";
2637
+ var dnsLookup = dns.promises.lookup;
2638
+ var isBlockedIPv4 = (ip) => {
2639
+ const parts = ip.split(".").map(Number);
2640
+ if (parts.length !== 4 || parts.some((n) => Number.isNaN(n) || n < 0 || n > 255)) return true;
2641
+ const [a, b] = parts;
2642
+ if (a === 0) return true;
2643
+ if (a === 10) return true;
2644
+ if (a === 127) return true;
2645
+ if (a === 169 && b === 254) return true;
2646
+ if (a === 172 && b >= 16 && b <= 31) return true;
2647
+ if (a === 192 && b === 168) return true;
2648
+ if (a === 100 && b >= 64 && b <= 127) return true;
2649
+ if (a === 192 && b === 0) return true;
2650
+ if (a === 198 && (b === 18 || b === 19)) return true;
2651
+ if (a === 198 && b === 51) return true;
2652
+ if (a === 203 && b === 0) return true;
2653
+ if (a >= 224) return true;
2654
+ return false;
2655
+ };
2656
+ var isBlockedIPv6 = (ip) => {
2657
+ const lower = ip.toLowerCase();
2658
+ if (lower === "::1" || lower === "::") return true;
2659
+ if (lower.startsWith("fc") || lower.startsWith("fd")) return true;
2660
+ if (/^fe[89ab]/.test(lower)) return true;
2661
+ if (lower.startsWith("ff")) return true;
2662
+ if (lower.startsWith("::ffff:")) {
2663
+ const v4 = lower.slice(7);
2664
+ return isBlockedIPv4(v4);
2665
+ }
2666
+ ;
2667
+ return false;
2668
+ };
2669
+ var isBlockedIP = (ip) => {
2670
+ const version = net.isIP(ip);
2671
+ if (version === 4) return isBlockedIPv4(ip);
2672
+ if (version === 6) return isBlockedIPv6(ip);
2673
+ return true;
2674
+ };
2675
+ var axios = axiosLib.create({
2676
+ timeout: 3e4,
2677
+ httpAgent: new http.Agent({ keepAlive: true, maxSockets: 128 }),
2678
+ httpsAgent: new https.Agent({ keepAlive: true, maxSockets: 128 })
2679
+ });
2680
+
2681
+ // lib/safe-http.js
2682
+ var DEFAULT_TIMEOUT_MS2 = 15e3;
2683
+ var resolveSafeHost = async (url) => {
2684
+ const parsed = new URL(url);
2685
+ if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
2686
+ throw new Error("Only http(s) URLs are allowed");
2687
+ }
2688
+ const records = await dns2.promises.lookup(parsed.hostname, { all: true });
2689
+ if (!(records == null ? void 0 : records.length)) {
2690
+ throw new Error("Host could not be resolved");
2691
+ }
2692
+ for (const record of records) {
2693
+ if (isBlockedIP(record.address)) {
2694
+ throw new Error("Host resolves to a blocked IP range");
2695
+ }
2696
+ }
2697
+ return { parsed, records };
2698
+ };
2699
+ var pinnedAgent = async (url) => {
2700
+ const { parsed, records } = await resolveSafeHost(url);
2701
+ const pinned = records[0];
2702
+ const lookup2 = (hostname, options, callback) => {
2703
+ if (options == null ? void 0 : options.all) {
2704
+ callback(null, [{ address: pinned.address, family: pinned.family }]);
2705
+ } else {
2706
+ callback(null, pinned.address, pinned.family);
2707
+ }
2708
+ };
2709
+ return {
2710
+ protocol: parsed.protocol,
2711
+ agent: parsed.protocol === "https:" ? new https2.Agent({ lookup: lookup2 }) : new http2.Agent({ lookup: lookup2 })
2712
+ };
2713
+ };
2714
+ var safeRequest = async ({
2715
+ body,
2716
+ headers = {},
2717
+ method = "GET",
2718
+ query,
2719
+ timeout = DEFAULT_TIMEOUT_MS2,
2720
+ type = "json",
2721
+ url
2722
+ }) => {
2723
+ const full = new URL(url);
2724
+ if (query) {
2725
+ Object.entries(query).forEach(([key, value]) => full.searchParams.set(key, value));
2726
+ }
2727
+ const { protocol, agent } = await pinnedAgent(full.toString());
2728
+ const isForm = type === "form";
2729
+ try {
2730
+ const response = await axios({
2731
+ method,
2732
+ url: full.toString(),
2733
+ headers: {
2734
+ "Content-Type": isForm ? "application/x-www-form-urlencoded" : "application/json",
2735
+ ...headers
2736
+ },
2737
+ ...body !== void 0 && {
2738
+ data: isForm ? new URLSearchParams(body).toString() : body
2739
+ },
2740
+ timeout,
2741
+ maxRedirects: 0,
2742
+ httpAgent: protocol === "http:" ? agent : void 0,
2743
+ httpsAgent: protocol === "https:" ? agent : void 0,
2744
+ responseType: "json",
2745
+ validateStatus: (status) => status >= 200 && status < 300
2746
+ });
2747
+ return response.data || null;
2748
+ } catch (error) {
2749
+ if (error == null ? void 0 : error.response) {
2750
+ const normalized = new Error(
2751
+ typeof error.response.data === "string" ? error.response.data : error.message || "Request failed"
2752
+ );
2753
+ normalized.status = error.response.status;
2754
+ normalized.response = error.response.data;
2755
+ throw normalized;
2756
+ }
2757
+ throw error;
2758
+ }
2759
+ };
950
2760
 
951
2761
  // lib/connections/webhook.js
952
2762
  var webhook_default = {
@@ -961,13 +2771,26 @@ var webhook_default = {
961
2771
  auth: {
962
2772
  type: "generated"
963
2773
  },
964
- category: "developer",
965
- confirm: "Disconnecting stops Drawbridge from sending signed webhook payloads to your endpoint.",
966
- description: [
967
- "Drawbridge can POST event payloads to your endpoint as activity happens in your account, so your own systems can react in real time.",
968
- "Generate a signing secret and Drawbridge signs every request with it. Your endpoint recomputes the signature to confirm each payload genuinely came from Drawbridge before acting on it."
969
- ],
970
- excerpt: "Sign outgoing webhook payloads with an HMAC secret to verify authenticity.",
2774
+ // EVERYTHING A MERCHANT READS. `errors` would belong here too — the
2775
+ // connection DOCUMENT carries its own `errors` array and is spread OVER the
2776
+ // resolved manifest downstream, so a top-level one is replaced by that array.
2777
+ content: {
2778
+ confirm: "Disconnecting stops Drawbridge from sending signed webhook payloads to your endpoint.",
2779
+ description: [
2780
+ "Drawbridge can POST event payloads to your endpoint as activity happens in your account, so your own systems can react in real time.",
2781
+ "Generate a signing secret and Drawbridge signs every request with it. Your endpoint recomputes the signature to confirm each payload genuinely came from Drawbridge before acting on it."
2782
+ ],
2783
+ excerpt: "Sign outgoing webhook payloads with an HMAC secret to verify authenticity.",
2784
+ guide: [
2785
+ "Press Connect. Drawbridge generates a signing secret and shows it here.",
2786
+ "Copy the secret into your own endpoint.",
2787
+ "On each request, compute HMAC-SHA256 of the raw body using the secret and compare it against the X-Drawbridge-Signature header before acting on the payload."
2788
+ ]
2789
+ },
2790
+ // Nothing to be exclusive with — there is no second webhook vendor, and a
2791
+ // merchant with two endpoints is a step-level choice rather than a second
2792
+ // connection.
2793
+ exclusive: false,
971
2794
  feature: "organization:connection:webhook",
972
2795
  fields: [
973
2796
  {
@@ -980,14 +2803,66 @@ var webhook_default = {
980
2803
  label: "Signing secret"
981
2804
  }
982
2805
  ],
2806
+ group: "developer",
2807
+ // OUTBOUND ONLY. inbound.* is false because the direction is the point: we
2808
+ // sign and POST to the merchant's endpoint, they never call us. Every other
2809
+ // false follows from there being no third party to authenticate against —
2810
+ // connect generates a secret rather than proving a credential.
2811
+ hooks: {
2812
+ auth: {
2813
+ // Minting and clearing a secret needs no vendor call, so the api's own
2814
+ // handler does both.
2815
+ connect: {},
2816
+ disconnect: {},
2817
+ probe: false,
2818
+ scopes: false,
2819
+ // Nothing to mint. Connecting generates a secret; there is no vendor.
2820
+ token: false
2821
+ },
2822
+ commerce: false,
2823
+ contacts: { remove: false, sync: false },
2824
+ // Drawbridge sends its own notification email and SMS, and owns its own
2825
+ // segments — see the private `drawbridge` manifest. A vendor answering
2826
+ // these would be a second sender, which is the arrangement the platform
2827
+ // sender replaced.
2828
+ email: false,
2829
+ segment: false,
2830
+ sms: false,
2831
+ inbound: false,
2832
+ lifecycle: false,
2833
+ resources: {
2834
+ audiences: false,
2835
+ prices: false,
2836
+ products: false,
2837
+ promotions: false
2838
+ },
2839
+ // THE BODY IS HERE, not in drawbridge-sync. It needs `crypto` and an HTTP
2840
+ // client and nothing else — no controller, no queue, no database — so
2841
+ // there was never a reason for it to live in another repo.
2842
+ //
2843
+ // That is the rule the whole split runs on: a hook lives in sync only if it
2844
+ // needs Drawbridge's own database, sockets or queues. This one does not.
2845
+ webhook: {
2846
+ send: async ({ context, controller, request: send2 = safeRequest, settings, step }) => {
2847
+ const { headers = {}, method = "POST", url } = step.settings || {};
2848
+ const request2 = { method, url: url || null };
2849
+ if (!url) return { message: "Outgoing webhook URL is not configured for this step.", request: request2, response: { skipped: true }, skipped: true };
2850
+ const lead = (context == null ? void 0 : context.lead) ? await controller.get({ collection: "lead", query: { id: context.lead } }) : null;
2851
+ const body = lead || context;
2852
+ request2.body = body;
2853
+ const outgoing = { ...headers };
2854
+ if (settings == null ? void 0 : settings.secret) {
2855
+ outgoing["X-Drawbridge-Signature"] = "sha256=" + crypto.createHmac("sha256", settings.secret).update(JSON.stringify(body)).digest("hex");
2856
+ }
2857
+ const response = await send2({ body, headers: outgoing, method, url });
2858
+ return { message: "Webhook POSTed to " + url + ".", request: request2, response: response || { delivered: true } };
2859
+ }
2860
+ }
2861
+ },
983
2862
  // Borrowed: this is the Drawbridge mark, because Webhooks has none of its own.
984
2863
  // It is the one card that reads wrong — our logo among vendor logos — and it
985
2864
  // wants a mark of its own when there is one.
986
2865
  icon: drawbridge_default,
987
- // The destination url is supplied per step, not per connection, so there is
988
- // nothing to finish here — generating the secret IS connecting.
989
- incomplete: () => null,
990
- label: "webhook",
991
2866
  // Gated on the encryption secret: without it the signing secret could not be
992
2867
  // stored safely, so the connection must not be offered at all.
993
2868
  requires: ["ENCRYPT_CONNECTION_SECRET"],
@@ -995,39 +2870,28 @@ var webhook_default = {
995
2870
  // sign and POST to the merchant's endpoint, they never call us. Every other
996
2871
  // false follows from there being no third party to authenticate against —
997
2872
  // connect generates a secret rather than proving a credential.
998
- supports: {
999
- "auth.connect": true,
1000
- "auth.disconnect": true,
1001
- "auth.probe": false,
1002
- "auth.scopes": false,
1003
- "catalog.audiences": false,
1004
- "catalog.prices": false,
1005
- "catalog.products": false,
1006
- "catalog.promotions": false,
1007
- "inbound.event": false,
1008
- "inbound.process": false,
1009
- "inbound.receive": false,
1010
- "inbound.verify": false,
1011
- "lifecycle.cleanup": false,
1012
- "lifecycle.register": false,
1013
- "lifecycle.rehydrate": false
1014
- },
1015
- setup: [
1016
- "Press Connect. Drawbridge generates a signing secret and shows it here.",
1017
- "Copy the secret into your own endpoint.",
1018
- "On each request, compute HMAC-SHA256 of the raw body using the secret and compare it against the X-Drawbridge-Signature header before acting on the payload."
1019
- ],
1020
2873
  slug: "webhook",
2874
+ // The destination url is supplied per step, not per connection, so there is
2875
+ // nothing to finish here — generating the secret IS connecting, and no
2876
+ // setting can make this connection unusable. The credential's own verdict
2877
+ // stands.
2878
+ status: (data2) => data2 == null ? void 0 : data2.status,
1021
2879
  steps: {
1022
- "step.webhook.send": {
1023
- billable: true,
1024
- key: "Send webhook",
1025
- queue: "webhook",
1026
- returns: [],
1027
- settings: {
1028
- url: { format: "url", required: true, type: "string" }
1029
- },
1030
- triggers: ["lead.insert", "lead.delete"]
2880
+ webhook: {
2881
+ send: () => ({
2882
+ hook: "webhook.send",
2883
+ key: "Send webhook",
2884
+ queue: "webhook",
2885
+ settings: {
2886
+ url: { format: "url", required: true, type: "string" }
2887
+ },
2888
+ triggers: ["lead.insert", "lead.delete"],
2889
+ // Replaces `billable : true`, which fed BILLABLE_STEP_TYPES, which set
2890
+ // workflow.billable at save, which sync then checked against a usage
2891
+ // the handler returned — three hops for one fact, two of which could
2892
+ // disagree silently.
2893
+ usage: { actions: 1 }
2894
+ })
1031
2895
  }
1032
2896
  },
1033
2897
  // The card the connection page raises. Before connecting it explains what
@@ -1051,31 +2915,41 @@ var webhook_default = {
1051
2915
 
1052
2916
  // lib/connections/index.js
1053
2917
  var QUEUES = ["connection", "notification", "segment", "webhook"];
2918
+ var implemented = (hooks, path) => {
2919
+ const hook = path.split(".").reduce((node, key) => node == null ? void 0 : node[key], hooks);
2920
+ return typeof hook === "function" || !!hook && typeof hook === "object";
2921
+ };
2922
+ var leaves = (node, path = []) => Object.entries(node || {}).flatMap(
2923
+ ([key, value]) => typeof value === "function" ? [[[...path, key].join("."), value]] : value && typeof value === "object" ? leaves(value, [...path, key]) : []
2924
+ );
1054
2925
  var build = (manifest) => {
1055
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2926
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
1056
2927
  if (!(manifest == null ? void 0 : manifest.slug)) throw new Error("A connection needs a slug");
1057
2928
  if (!(manifest == null ? void 0 : manifest.title)) throw new Error(manifest.slug + " needs a title");
1058
- if (!(manifest == null ? void 0 : manifest.feature)) throw new Error(manifest.slug + " needs a plan feature key");
1059
- if (!(manifest == null ? void 0 : manifest.excerpt)) throw new Error(manifest.slug + " needs an excerpt for its card");
1060
- if (!Array.isArray(manifest == null ? void 0 : manifest.description) || !manifest.description.length) {
1061
- throw new Error(manifest.slug + " needs a description \u2014 an array of paragraphs for its page");
2929
+ if (!(manifest == null ? void 0 : manifest.private) && !(manifest == null ? void 0 : manifest.feature)) throw new Error(manifest.slug + " needs a plan feature key");
2930
+ if (!((_a = manifest == null ? void 0 : manifest.content) == null ? void 0 : _a.excerpt)) throw new Error(manifest.slug + " needs content.excerpt for its card");
2931
+ if (!Array.isArray((_b = manifest == null ? void 0 : manifest.content) == null ? void 0 : _b.description) || !manifest.content.description.length) {
2932
+ throw new Error(manifest.slug + " needs content.description \u2014 an array of paragraphs for its page");
1062
2933
  }
1063
- for (const field of manifest.fields || []) {
1064
- if (!(field == null ? void 0 : field.key) || !(field == null ? void 0 : field.label)) {
2934
+ for (const field2 of manifest.fields || []) {
2935
+ if (!(field2 == null ? void 0 : field2.key) || !(field2 == null ? void 0 : field2.label)) {
1065
2936
  throw new Error(manifest.slug + " declares a field with no key or label");
1066
2937
  }
1067
- if (field.input && !INPUTS.includes(field.input)) {
1068
- throw new Error(manifest.slug + "." + field.key + " declares an unknown input: " + field.input + " \u2014 one of " + INPUTS.join(", "));
2938
+ if (field2.input && !INPUTS.includes(field2.input)) {
2939
+ throw new Error(manifest.slug + "." + field2.key + " declares an unknown input: " + field2.input + " \u2014 one of " + INPUTS.join(", "));
1069
2940
  }
1070
- if (field.input === "select" && !(field.options || []).length && !field.source) {
1071
- throw new Error(manifest.slug + "." + field.key + " is a select and must declare options or a source");
2941
+ if (field2.input === "select" && !(field2.options || []).length && !field2.hook) {
2942
+ throw new Error(manifest.slug + "." + field2.key + " is a select and must declare options or a hook");
1072
2943
  }
1073
- if (field.source) {
1074
- if (!HOOK_NAMES.includes(field.source)) {
1075
- throw new Error(manifest.slug + "." + field.key + " sources options from an unknown hook: " + field.source);
2944
+ if (field2.hook) {
2945
+ if (!HOOK_NAMES.includes(field2.hook)) {
2946
+ throw new Error(manifest.slug + "." + field2.key + " names an unknown hook: " + field2.hook);
1076
2947
  }
1077
- if (((_a = manifest.supports) == null ? void 0 : _a[field.source]) !== true) {
1078
- throw new Error(manifest.slug + "." + field.key + " sources options from " + field.source + ", which it declares unsupported");
2948
+ if (!field2.hook.startsWith("resources.")) {
2949
+ throw new Error(manifest.slug + "." + field2.key + " reads from " + field2.hook + " \u2014 a picker may only read resources.*");
2950
+ }
2951
+ if (!implemented(manifest.hooks, field2.hook)) {
2952
+ throw new Error(manifest.slug + "." + field2.key + " reads " + field2.hook + ", which this vendor does not implement");
1079
2953
  }
1080
2954
  }
1081
2955
  }
@@ -1088,82 +2962,103 @@ var build = (manifest) => {
1088
2962
  if (manifest.icon.includes("<image")) {
1089
2963
  throw new Error(manifest.slug + " icon wraps a raster \u2014 re-export it as vector shapes");
1090
2964
  }
1091
- if (!CATEGORIES.includes(manifest == null ? void 0 : manifest.category)) {
1092
- throw new Error(manifest.slug + " needs a category \u2014 one of " + CATEGORIES.join(", "));
2965
+ if (!GROUPS.includes(manifest == null ? void 0 : manifest.group)) {
2966
+ throw new Error(manifest.slug + " needs a group \u2014 one of " + GROUPS.join(", "));
1093
2967
  }
1094
- if ((_b = manifest == null ? void 0 : manifest.connect) == null ? void 0 : _b.type) {
2968
+ if ((_c = manifest == null ? void 0 : manifest.connect) == null ? void 0 : _c.type) {
1095
2969
  throw new Error(manifest.slug + " declares connect.type \u2014 that is auth.type now");
1096
2970
  }
1097
- if (!AUTH_TYPES.includes((_c = manifest == null ? void 0 : manifest.auth) == null ? void 0 : _c.type)) {
2971
+ if (!AUTH_TYPES.includes((_d = manifest == null ? void 0 : manifest.auth) == null ? void 0 : _d.type)) {
1098
2972
  throw new Error(manifest.slug + " needs auth.type \u2014 one of " + AUTH_TYPES.join(", "));
1099
2973
  }
1100
2974
  if (manifest.auth.type === "oauth") {
1101
- for (const field of OAUTH_FIELDS) {
1102
- if (!((_d = manifest.auth.oauth) == null ? void 0 : _d[field])) {
1103
- throw new Error(manifest.slug + " is oauth and must declare auth.oauth." + field);
2975
+ for (const field2 of OAUTH_FIELDS) {
2976
+ if (!((_e = manifest.auth.oauth) == null ? void 0 : _e[field2])) {
2977
+ throw new Error(manifest.slug + " is oauth and must declare auth.oauth." + field2);
1104
2978
  }
1105
2979
  }
1106
- if (manifest.auth.oauth.redirect !== "/api/connection/" + manifest.slug + "/callback") {
2980
+ if (typeof ((_g = (_f = manifest.hooks) == null ? void 0 : _f.auth) == null ? void 0 : _g.token) !== "function") {
2981
+ throw new Error(manifest.slug + " is oauth and must implement hooks.auth.token \u2014 point it at authToken() or wrap it");
2982
+ }
2983
+ for (const url of OAUTH_URLS) {
2984
+ if (!((_i = (_h = manifest.auth.oauth) == null ? void 0 : _h.urls) == null ? void 0 : _i[url])) {
2985
+ throw new Error(manifest.slug + " is oauth and must declare auth.oauth.urls." + url);
2986
+ }
2987
+ }
2988
+ if (manifest.auth.oauth.urls.redirect !== "/api/connection/" + manifest.slug + "/callback") {
1107
2989
  throw new Error(
1108
- manifest.slug + " declares auth.oauth.redirect " + manifest.auth.oauth.redirect + " but the only callback route is /api/connection/" + manifest.slug + "/callback"
2990
+ manifest.slug + " declares auth.oauth.urls.redirect " + manifest.auth.oauth.urls.redirect + " but the only callback route is /api/connection/" + manifest.slug + "/callback"
1109
2991
  );
1110
2992
  }
1111
2993
  }
1112
- if (((_e = manifest.supports) == null ? void 0 : _e["inbound.event"]) && !((_g = (_f = manifest.inbound) == null ? void 0 : _f.headers) == null ? void 0 : _g.event)) {
1113
- throw new Error(manifest.slug + " supports inbound.event but declares no inbound.headers.event");
2994
+ if (implemented(manifest.hooks, "inbound.event") && !((_k = (_j = manifest.inbound) == null ? void 0 : _j.headers) == null ? void 0 : _k.event)) {
2995
+ throw new Error(manifest.slug + " implements inbound.event but declares no inbound.headers.event");
1114
2996
  }
1115
- if (((_h = manifest.supports) == null ? void 0 : _h["inbound.verify"]) && !((_j = (_i = manifest.inbound) == null ? void 0 : _i.headers) == null ? void 0 : _j.signature)) {
1116
- throw new Error(manifest.slug + " supports inbound.verify but declares no inbound.headers.signature");
2997
+ if (implemented(manifest.hooks, "inbound.verify") && !((_m = (_l = manifest.inbound) == null ? void 0 : _l.headers) == null ? void 0 : _m.signature)) {
2998
+ throw new Error(manifest.slug + " implements inbound.verify but declares no inbound.headers.signature");
1117
2999
  }
1118
- if (typeof (manifest == null ? void 0 : manifest.incomplete) !== "function") {
1119
- throw new Error(manifest.slug + " must declare incomplete( data ) \u2014 return null when the connection is usable, or the reason it is not");
3000
+ if (typeof (manifest == null ? void 0 : manifest.status) !== "function") {
3001
+ throw new Error(manifest.slug + " must declare status( data ) \u2014 return null to accept the connection's own status, or { message, status } to override it");
1120
3002
  }
1121
- if (!Array.isArray(manifest == null ? void 0 : manifest.setup) || !manifest.setup.length) {
1122
- throw new Error(manifest.slug + " needs a setup guide \u2014 an array of steps for its page");
3003
+ if (!Array.isArray((_n = manifest == null ? void 0 : manifest.content) == null ? void 0 : _n.guide) || !manifest.content.guide.length) {
3004
+ throw new Error(manifest.slug + " needs content.guide \u2014 an array of steps for its page");
1123
3005
  }
1124
- for (const [name, hook] of Object.entries(manifest.hooks || {})) {
1125
- if (!HOOK_NAMES.includes(name)) {
1126
- throw new Error(manifest.slug + " implements an unknown hook: " + name);
1127
- }
1128
- if (typeof hook !== "function") {
1129
- throw new Error(manifest.slug + " declares hook " + name + " but it is not a function");
1130
- }
1131
- if (((_k = manifest.supports) == null ? void 0 : _k[name]) !== true) {
1132
- throw new Error(manifest.slug + " implements " + name + " but declares supports[ '" + name + "' ] false");
1133
- }
3006
+ if (typeof (manifest == null ? void 0 : manifest.status) !== "function") {
3007
+ throw new Error(manifest.slug + " must declare status( data ) \u2014 one of " + STATUSES.join(", "));
1134
3008
  }
1135
- const supports = manifest.supports || {};
1136
- for (const name of HOOK_NAMES) {
1137
- if (typeof supports[name] !== "boolean") {
1138
- throw new Error(manifest.slug + " must declare supports[ '" + name + "' ] as true or false");
3009
+ const status = manifest.status({});
3010
+ if (status != null && !STATUSES.includes(status)) {
3011
+ throw new Error(manifest.slug + " status() returned " + status + " \u2014 must be one of " + STATUSES.join(", "));
3012
+ }
3013
+ for (const [domain, verbs] of Object.entries(HOOKS)) {
3014
+ for (const verb of verbs) {
3015
+ const hook = (_p = (_o = manifest.hooks) == null ? void 0 : _o[domain]) == null ? void 0 : _p[verb];
3016
+ if (((_q = manifest.hooks) == null ? void 0 : _q[domain]) === false) continue;
3017
+ if (hook !== false && !implemented({ [domain]: { [verb]: hook } }, domain + "." + verb)) {
3018
+ throw new Error(manifest.slug + " must answer hooks." + domain + "." + verb + " \u2014 false, a function, or {} if another repo implements it");
3019
+ }
1139
3020
  }
1140
3021
  }
1141
- for (const name of Object.keys(supports)) {
1142
- if (!HOOK_NAMES.includes(name)) {
1143
- throw new Error(manifest.slug + " declares an unknown hook: " + name);
3022
+ for (const [domain, verbs] of Object.entries(manifest.hooks || {})) {
3023
+ if (!HOOKS[domain]) throw new Error(manifest.slug + " implements an unknown hook domain: " + domain);
3024
+ for (const verb of Object.keys(verbs === false ? {} : verbs)) {
3025
+ if (!HOOKS[domain].includes(verb)) {
3026
+ throw new Error(manifest.slug + " implements an unknown hook: " + domain + "." + verb);
3027
+ }
1144
3028
  }
1145
3029
  }
1146
- for (const [type, step] of Object.entries(manifest.steps || {})) {
1147
- if (!type.startsWith("step.")) {
1148
- throw new Error(manifest.slug + " declares a step type that is not step.<domain>.<verb>: " + type);
3030
+ for (const [name, step] of leaves(manifest.steps)) {
3031
+ const type = "step." + name;
3032
+ if (!STEPS[name]) {
3033
+ throw new Error(manifest.slug + " declares an unknown step: " + type + " \u2014 add it to STEPS in contract.js");
1149
3034
  }
1150
- if (!(step == null ? void 0 : step.key)) throw new Error(manifest.slug + " step " + type + " needs a key \u2014 the label the builder shows");
1151
- if (!QUEUES.includes(step == null ? void 0 : step.queue)) {
3035
+ const declared = step({});
3036
+ if (!(declared == null ? void 0 : declared.key)) throw new Error(manifest.slug + " step " + type + " needs a key \u2014 the label the builder shows");
3037
+ if (!QUEUES.includes(declared == null ? void 0 : declared.queue)) {
1152
3038
  throw new Error(manifest.slug + " step " + type + " needs a queue \u2014 one of " + QUEUES.join(", "));
1153
3039
  }
3040
+ if (declared.hook && !implemented(manifest.hooks, declared.hook)) {
3041
+ throw new Error(manifest.slug + " step " + type + " points at hook " + declared.hook + ", which this vendor does not implement");
3042
+ }
1154
3043
  }
1155
3044
  return Object.freeze({
1156
3045
  ...manifest,
1157
3046
  fields: Object.freeze(manifest.fields || []),
1158
3047
  hooks: Object.freeze(manifest.hooks || {}),
1159
3048
  inbound: Object.freeze(manifest.inbound || {}),
1160
- setup: Object.freeze(manifest.setup || []),
1161
- supports: Object.freeze(supports),
1162
3049
  requires: Object.freeze(manifest.requires || []),
1163
3050
  steps: Object.freeze(manifest.steps || {})
1164
3051
  });
1165
3052
  };
3053
+ var stepLabels = (catalog = connections) => Object.fromEntries(
3054
+ Object.values(catalog).flatMap(
3055
+ (vendor) => leaves(vendor.steps).map(([name]) => ["step." + name, STEP_LABELS["step." + name]])
3056
+ )
3057
+ );
1166
3058
  var connections = Object.freeze({
3059
+ attentive: build(attentive_default2),
3060
+ drawbridge: build(drawbridge_default2),
3061
+ hubspot: build(hubspot_default),
1167
3062
  klaviyo: build(klaviyo_default2),
1168
3063
  mailchimp: build(mailchimp_default2),
1169
3064
  shopify: build(shopify_default2),
@@ -1172,7 +3067,8 @@ var connections = Object.freeze({
1172
3067
  (() => {
1173
3068
  const owners = {};
1174
3069
  for (const [slug, manifest] of Object.entries(connections)) {
1175
- for (const type of Object.keys(manifest.steps)) {
3070
+ for (const [name] of leaves(manifest.steps)) {
3071
+ const type = "step." + name;
1176
3072
  if (owners[type]) {
1177
3073
  throw new Error("Step " + type + " is declared by both " + owners[type] + " and " + slug);
1178
3074
  }
@@ -1185,23 +3081,27 @@ var availableConnections = (env = {}) => Object.fromEntries(
1185
3081
  ([, manifest]) => manifest.requires.every((name) => Boolean(env[name]))
1186
3082
  )
1187
3083
  );
3084
+ var catalogConnections = (env = {}) => Object.fromEntries(
3085
+ Object.entries(availableConnections(env)).filter(([, manifest]) => !manifest.private)
3086
+ );
1188
3087
  var publicSettingsBySlug = Object.fromEntries(
1189
3088
  Object.entries(connections).map(([slug, manifest]) => [
1190
3089
  slug,
1191
- manifest.fields.filter((field) => !field.redact).map((field) => field.key)
3090
+ manifest.fields.filter((field2) => !field2.redact).map((field2) => field2.key)
1192
3091
  ])
1193
3092
  );
1194
3093
  var connectionSteps = (env = {}) => Object.entries(availableConnections(env)).flatMap(
1195
- ([slug, manifest]) => Object.entries(manifest.steps).map(([type, step]) => ({ ...step, slug, type }))
3094
+ ([slug, manifest]) => leaves(manifest.steps).map(([name, step]) => ({ ...step({}), slug, type: "step." + name }))
1196
3095
  );
1197
3096
  var hookSupport = (name) => ({
1198
- no: Object.keys(connections).filter((slug) => !connections[slug].supports[name]),
1199
- yes: Object.keys(connections).filter((slug) => connections[slug].supports[name])
3097
+ no: Object.keys(connections).filter((slug) => !implemented(connections[slug].hooks, name)),
3098
+ yes: Object.keys(connections).filter((slug) => implemented(connections[slug].hooks, name))
1200
3099
  });
1201
3100
  var connectFields = (slug) => {
1202
3101
  var _a;
1203
- return (((_a = connections[slug]) == null ? void 0 : _a.fields) || []).map(({ copy, from, input, key, label, message, options, placeholder, redact, required }) => ({
3102
+ return (((_a = connections[slug]) == null ? void 0 : _a.fields) || []).map(({ copy, from, hook, input, key, label, message, options, placeholder, redact, required, search }) => ({
1204
3103
  ...copy && { copy: true },
3104
+ ...hook && { hook },
1205
3105
  ...from && { from },
1206
3106
  ...input && { input },
1207
3107
  key,
@@ -1209,6 +3109,9 @@ var connectFields = (slug) => {
1209
3109
  ...message && { message },
1210
3110
  ...options && { options },
1211
3111
  ...placeholder && { placeholder },
3112
+ // Declared false only where the vendor cannot filter, so a picker does not
3113
+ // offer a search box that quietly searches one page.
3114
+ ...search === false && { search: false },
1212
3115
  required: Boolean(required),
1213
3116
  // A UI hint, not a leak: the form uses it to stop requiring the field once
1214
3117
  // the connection exists, and to say "leave blank to keep" — because the GET
@@ -1217,16 +3120,17 @@ var connectFields = (slug) => {
1217
3120
  }));
1218
3121
  };
1219
3122
  var runHook = async (slug, name, args = {}) => {
1220
- var _a, _b;
1221
3123
  const manifest = connections[slug];
1222
3124
  if (!manifest) return { outcome: OUTCOMES.unsupported, reason: "no such connection: " + slug };
1223
- if (!((_a = manifest.supports) == null ? void 0 : _a[name])) return { outcome: OUTCOMES.unsupported, reason: slug + " does not implement " + name };
1224
- const hook = (_b = manifest.hooks) == null ? void 0 : _b[name];
3125
+ const hook = name.split(".").reduce((node, key) => node == null ? void 0 : node[key], manifest.hooks);
3126
+ if (hook === false || hook == null) {
3127
+ return { outcome: OUTCOMES.unsupported, reason: slug + " does not implement " + name };
3128
+ }
1225
3129
  if (typeof hook !== "function") {
1226
3130
  return { outcome: OUTCOMES.unimplemented, reason: slug + " implements " + name + " outside this package" };
1227
3131
  }
1228
3132
  try {
1229
- return { outcome: OUTCOMES.answered, result: await hook(args) };
3133
+ return { outcome: OUTCOMES.answered, result: await hook({ ...args, manifest }) };
1230
3134
  } catch (error) {
1231
3135
  return { error: (error == null ? void 0 : error.message) || "failed", outcome: OUTCOMES.failed, status: (error == null ? void 0 : error.status) || null };
1232
3136
  }
@@ -1234,6 +3138,15 @@ var runHook = async (slug, name, args = {}) => {
1234
3138
  var stepQueues = (env = {}) => Object.fromEntries(
1235
3139
  connectionSteps(env).map((step) => [step.type, step.queue])
1236
3140
  );
3141
+ var stepRoutes = (env = {}) => {
3142
+ const live = stepQueues(env);
3143
+ return Object.freeze({
3144
+ ...live,
3145
+ ...Object.fromEntries(
3146
+ Object.entries(RETIRED).filter(([, replacement]) => live[replacement]).map(([retired, replacement]) => [retired, live[replacement]])
3147
+ )
3148
+ });
3149
+ };
1237
3150
  var scopesMessage = "Shopify permissions are out of date. Open the Drawbridge app in your Shopify admin to approve the updated permissions.";
1238
3151
  var mergeSettings = ({ existing, incoming }) => {
1239
3152
  if (!existing || typeof existing !== "object") return incoming;
@@ -1256,22 +3169,26 @@ var redactSettings = ({ slug, settings }) => {
1256
3169
  };
1257
3170
  var publicConnectionKeys = Object.freeze([
1258
3171
  "actions",
1259
- "category",
1260
- "confirm",
3172
+ // API-COMPOSED, not manifest-declared: the api's resolve() builds it from
3173
+ // auth.type, content.redirect and the manifest's manage() — the client reads
3174
+ // connect.type to choose entered-vs-installed, connect.redirect for the App
3175
+ // Store link, connect.manage for the admin deep link. It was dropped from
3176
+ // this list when the manifests stopped declaring it, which stripped the
3177
+ // composed object from every response and broke all three.
1261
3178
  "connect",
3179
+ // EVERYTHING A MERCHANT READS, in one key: confirm, description, errors,
3180
+ // excerpt, guide, and any vendor redirect copy.
3181
+ "content",
1262
3182
  "createdAt",
3183
+ // The connection DOCUMENT's own errors array — scope-drift entries written by
3184
+ // drawbridge-sync. NOT the manifest's error copy, which is content.errors:
3185
+ // the document is spread OVER the resolved manifest downstream, so the two
3186
+ // sharing this key means the array silently wins.
1263
3187
  "errors",
1264
- "description",
1265
- "excerpt",
1266
3188
  "fields",
1267
3189
  "group",
1268
3190
  "id",
1269
3191
  "image",
1270
- // The reason a connected vendor still is not usable — a Klaviyo grant with no
1271
- // list chosen. Public because the card that shows Pending has to say why.
1272
- "incomplete",
1273
- "label",
1274
- "setup",
1275
3192
  "settings",
1276
3193
  "shop",
1277
3194
  "slug",
@@ -1294,31 +3211,36 @@ var projectConnection = (record) => {
1294
3211
  {}
1295
3212
  );
1296
3213
  };
1297
- var resolveConnection = (item, data) => {
3214
+ var resolveConnection = (item, data2, env = {}) => {
1298
3215
  if (!item) return item;
1299
3216
  return Object.fromEntries(
1300
3217
  Object.entries(item).filter(([key]) => !["auth", "enabled", "fields", "hooks", "inbound", "requires", "steps", "supports"].includes(key)).map(([key, value]) => [
1301
3218
  key,
1302
- typeof value === "function" ? value(data) : value
3219
+ typeof value === "function" ? value(data2, env) : value
1303
3220
  ])
1304
3221
  );
1305
3222
  };
1306
3223
  export {
1307
3224
  AUTH_TYPES,
1308
- CATEGORIES,
3225
+ GROUPS,
1309
3226
  HOOKS,
1310
3227
  HOOK_NAMES,
1311
3228
  INPUTS,
1312
3229
  OAUTH_FIELDS,
1313
3230
  OUTCOMES,
3231
+ RETIRED,
3232
+ STATUSES,
3233
+ STEPS,
3234
+ STEP_TYPES,
1314
3235
  accessToken,
3236
+ authToken,
1315
3237
  availableConnections,
1316
3238
  build,
3239
+ catalogConnections,
1317
3240
  connectFields,
1318
3241
  connectionSteps,
1319
3242
  connections,
1320
3243
  consentUrl,
1321
- exchange,
1322
3244
  hookSupport,
1323
3245
  isStale,
1324
3246
  mergeSettings,
@@ -1327,10 +3249,11 @@ export {
1327
3249
  publicConnectionKeys,
1328
3250
  publicSettingsBySlug,
1329
3251
  redactSettings,
1330
- refresh,
1331
3252
  resolveConnection,
1332
3253
  runHook,
1333
3254
  scopesMessage,
3255
+ stepLabels,
1334
3256
  stepQueues,
3257
+ stepRoutes,
1335
3258
  tokenSettings
1336
3259
  };