@drawbridge/drawbridge-utils 0.0.168 → 0.0.170

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.
@@ -129,7 +129,20 @@ var HOOKS = Object.freeze({
129
129
  "digest"
130
130
  ]),
131
131
  sms: Object.freeze(["send"]),
132
- segment: Object.freeze(["sync"]),
132
+ segment: Object.freeze([
133
+ // Make this segment's object exist at the vendor, carrying the segment's
134
+ // current title, and describe the row that points at it. IDEMPOTENT: the
135
+ // same call creates it, renames it after an edit, and backfills a segment
136
+ // that predates the connection — so one hook serves every path and there
137
+ // is no create-vs-update branch to keep in step.
138
+ "register",
139
+ // Remove the vendor object this connection's row points at. Called with
140
+ // the pre-image on a segment delete, because by then the document is gone.
141
+ "remove",
142
+ // Recalculate Drawbridge-side membership. Private to the drawbridge
143
+ // manifest; a vendor does not own who is in a Drawbridge segment.
144
+ "sync"
145
+ ]),
133
146
  // OUTBOUND DELIVERY to an address the merchant owns, rather than to a vendor.
134
147
  // The Webhooks connection is the only thing here with no third party behind
135
148
  // it, and the destination is per STEP rather than per connection.
@@ -274,6 +287,8 @@ var STEPS = Object.freeze({
274
287
  "email.digest": "Digest",
275
288
  "email.notify": "Notification",
276
289
  "email.send": "Send email",
290
+ "segment.register": "Register segment",
291
+ "segment.remove": "Remove segment",
277
292
  "segment.sync": "Sync segment",
278
293
  "sms.send": "Send SMS",
279
294
  "webhook.send": "Send webhook"
@@ -437,7 +452,16 @@ var tokenSettings = ({ existing = {}, now = Date.now(), tokens }) => ({
437
452
  ...tokens.expiresIn && {
438
453
  expiresAt: new Date(now + tokens.expiresIn * 1e3).toISOString()
439
454
  },
440
- ...tokens.scope && { scope: tokens.scope }
455
+ // A VENDOR NEED NOT RETURN `scope` ON A REFRESH. Klaviyo documents it on the
456
+ // authorization_code response and documents no response body at all for the
457
+ // refresh grant, so taking the minted value alone drops the stored one. That
458
+ // matters because `scope` is load-bearing: the segment hooks gate on
459
+ // `segments:write` and answer `skipped` when it is absent, so a connection
460
+ // that dropped it disables its whole segment half without failing anything
461
+ // and shows a reconnect task that reconnecting has already fixed.
462
+ ...(tokens.scope || existing.scope) && {
463
+ scope: tokens.scope || existing.scope
464
+ }
441
465
  });
442
466
  var accessToken = async ({
443
467
  clientId,
@@ -500,6 +524,98 @@ var detectCountry = (value) => {
500
524
  }
501
525
  };
502
526
 
527
+ // lib/connections/segment-rows.js
528
+ import { randomUUID } from "crypto";
529
+ var row = ({ connection: connection2, data: data2, manifest, row: described }) => {
530
+ var _a, _b;
531
+ return {
532
+ connection: connection2 == null ? void 0 : connection2.id,
533
+ // ALWAYS A STRING. Mailchimp tag ids are integers, Klaviyo segment ids are
534
+ // strings, and one type in the schema is one comparison in the $or below.
535
+ id: String(described == null ? void 0 : described.id),
536
+ slug: connection2 == null ? void 0 : connection2.slug,
537
+ type: described == null ? void 0 : described.type,
538
+ // NULL, NEVER UNDEFINED: undefined drops the key, and the schema requires it.
539
+ // The url is built HERE, while the settings are decrypted and the vendor
540
+ // facts are in hand — an api reading the row later has neither.
541
+ url: ((_b = (_a = manifest == null ? void 0 : manifest.urls) == null ? void 0 : _a.segment) == null ? void 0 : _b.call(_a, { ...described, id: String(described == null ? void 0 : described.id) }, data2)) || null
542
+ };
543
+ };
544
+ var segmentRowWrites = ({ connection: connection2, data: data2, manifest, row: described, segment }) => {
545
+ const built = row({ connection: connection2, data: data2, manifest, row: described });
546
+ return [
547
+ // PUSH IF ABSENT. The $ne guard is what makes a second concurrent register
548
+ // add nothing rather than a duplicate row for one connection.
549
+ {
550
+ collection: "segment",
551
+ data: { $push: { connections: built } },
552
+ operation: "update",
553
+ query: {
554
+ id: segment == null ? void 0 : segment.id,
555
+ "connections.connection": { $ne: connection2 == null ? void 0 : connection2.id }
556
+ }
557
+ },
558
+ // SET IF DIFFERENT. $elemMatch selects this connection's row only when one
559
+ // of its three mutable fields disagrees, so the steady state — the same
560
+ // vendor object, the same url — matches nothing and writes nothing.
561
+ {
562
+ collection: "segment",
563
+ data: { $set: { "connections.$": built } },
564
+ operation: "update",
565
+ query: {
566
+ id: segment == null ? void 0 : segment.id,
567
+ connections: {
568
+ $elemMatch: {
569
+ connection: connection2 == null ? void 0 : connection2.id,
570
+ $or: [
571
+ { id: { $ne: built.id } },
572
+ { type: { $ne: built.type } },
573
+ { url: { $ne: built.url } }
574
+ ]
575
+ }
576
+ }
577
+ }
578
+ }
579
+ ];
580
+ };
581
+ var segmentRowRemoveWrites = ({ connection: connection2, segment }) => [
582
+ {
583
+ collection: "segment",
584
+ data: { $pull: { connections: { connection: connection2 == null ? void 0 : connection2.id } } },
585
+ operation: "update",
586
+ query: { id: segment == null ? void 0 : segment.id }
587
+ }
588
+ ];
589
+ var segmentRowFor = ({ connection: connection2, segment }) => ((segment == null ? void 0 : segment.connections) || []).find((entry) => (entry == null ? void 0 : entry.connection) === (connection2 == null ? void 0 : connection2.id));
590
+ var currentSegment = async ({ read, segment }) => {
591
+ if (!(read == null ? void 0 : read.get) || !(segment == null ? void 0 : segment.id)) return segment;
592
+ return read.get({
593
+ collection: "segment",
594
+ query: { id: segment.id }
595
+ });
596
+ };
597
+ var driftEnqueues = async ({ applied, read, segment, workflow }) => {
598
+ if (!(workflow == null ? void 0 : workflow.id)) return [];
599
+ const fresh = await currentSegment({ read, segment });
600
+ if (!(fresh == null ? void 0 : fresh.id) || fresh.title === applied) return [];
601
+ return [{
602
+ data: {
603
+ triggerData: {
604
+ organization: fresh.organization || (workflow == null ? void 0 : workflow.organization),
605
+ segment: fresh
606
+ },
607
+ workflowId: workflow == null ? void 0 : workflow.id
608
+ },
609
+ name: "execute",
610
+ options: {
611
+ jobId: "workflow.insert.execute." + (workflow == null ? void 0 : workflow.id) + ".segment.register." + fresh.id + ".drift." + Date.now() + "." + randomUUID().slice(0, 8),
612
+ removeOnComplete: true,
613
+ removeOnFail: true
614
+ },
615
+ queue: "workflow"
616
+ }];
617
+ };
618
+
503
619
  // lib/connections/providers/attentive.js
504
620
  var api = async (path, { fetcher = fetch, method = "GET", payload, token }) => {
505
621
  const response = await fetcher("https://api.attentivemobile.com" + path, {
@@ -552,7 +668,7 @@ var attentive_default2 = {
552
668
  // has to say so rather than let them believe otherwise.
553
669
  confirm: "Disconnecting removes Drawbridge's stored Attentive token. Attentive does not offer a way for us to revoke it, so remove the Drawbridge integration in Attentive as well if you want its access fully withdrawn. Your subscribers stay in both Attentive and Drawbridge \u2014 neither list is deleted.",
554
670
  description: [
555
- "Attentive is where your SMS marketing lives, and this connection syncs the contacts your campaigns collect into an Attentive segment \u2014 subscribed for marketing and added to the segment you choose.",
671
+ "This connection syncs the contacts your campaigns collect into your Attentive account \u2014 subscribed for marketing, and added to the segment you choose.",
556
672
  "You authorize Drawbridge from inside Attentive and can revoke that access there at any time. Drawbridge never sees or stores your Attentive password.",
557
673
  "Anyone who has opted out in Drawbridge is sent to Attentive as an unsubscribe rather than omitted, so a person who asked not to be contacted stays suppressed in both systems instead of quietly reappearing.",
558
674
  "Attentive accepts these updates and applies them in the background, so a contact appears in your segment shortly after the sync rather than the instant it runs."
@@ -594,10 +710,9 @@ var attentive_default2 = {
594
710
  }
595
711
  ],
596
712
  group: "contacts",
597
- // A HOOK'S VALUE IS ITS ANSWER. The consent is stored and can be revoked;
598
- // nothing else is built yet, because subscriber sync has not shipped. Every
599
- // false here is "not yet" rather than "never" — when the sync lands, probe
600
- // and contacts.sync are the first to flip.
713
+ // WHAT THIS VENDOR DOES AND DOES NOT DO is the value of each hook below, not
714
+ // a paragraph up here that goes stale the moment one of them is implemented
715
+ // which is exactly what happened to the note this replaces.
601
716
  hooks: {
602
717
  auth: {
603
718
  // FALSE, NOT {}. `{}` means "supported, implemented in the repo with the
@@ -610,7 +725,7 @@ var attentive_default2 = {
610
725
  // nobody re-derives it. Klaviyo's connect reads the account name back so
611
726
  // the card is not blank; Attentive's card stays blank. There IS an
612
727
  // endpoint — GET https://api.attentivemobile.com/v1/me, Bearer, described
613
- // on docs.attentive.com/pages/authentication/ as returning "information
728
+ // on docs.attentive.com/docs/authentication as returning "information
614
729
  // specific to your company" — but its RESPONSE SCHEMA is published
615
730
  // nowhere we can read: the docs show the curl and no body. Reading
616
731
  // `body.name` would be a guess, and a guess here fails at the worst
@@ -777,7 +892,62 @@ var attentive_default2 = {
777
892
  products: false,
778
893
  promotions: false
779
894
  },
780
- segment: false,
895
+ segment: {
896
+ // A FOUNDATION, AND HONEST ABOUT IT. Attentive's segments API can create
897
+ // one with an externalId we choose (docs.attentive.com/reference/
898
+ // createsegment.md, fetched 2026-09-11: POST /v2/segments, `name`
899
+ // required, `externalId` optional and "auto-generated if not supplied"),
900
+ // which would give a real per-segment object — but it takes
901
+ // segments:write, and scopes ride on the app registration, which does not
902
+ // exist yet.
903
+ //
904
+ // So the row points at the connection-level segment the merchant chose,
905
+ // `type` says so, and turning this into a per-segment object later is a
906
+ // change to this file and nothing else: create with
907
+ // externalId = segment.id, PATCH to rename, archive on remove. Their
908
+ // update and archive endpoints are BOTH keyed by external id
909
+ // (docs.attentive.com/reference/patchsegmentbyexternalid.md and
910
+ // /deletesegmentbyexternalid.md, fetched 2026-09-11), so the segment id we
911
+ // already hold addresses every one of the three calls.
912
+ //
913
+ // NO DRIFT CHECK, unlike the other two: the row points at the
914
+ // connection's own segment and the link is the index page, so nothing
915
+ // here depends on the Drawbridge segment's title — a rename has nothing
916
+ // to apply and nothing to race with. That comes back with the
917
+ // per-segment object.
918
+ //
919
+ // THE RE-READ STAYS ALL THE SAME. It changes nothing today, and this is
920
+ // the simplest of the three registers and therefore the one the next
921
+ // vendor gets copied from — one job id serves four dispatch sites, so a
922
+ // copy that trusts context.segment applies whichever trigger data won
923
+ // the race, at a vendor where the title does matter.
924
+ register: async ({ connection: connection2, context, manifest, settings }, { read } = {}) => {
925
+ const segment = await currentSegment({ read, segment: context == null ? void 0 : context.segment });
926
+ if (!(segment == null ? void 0 : segment.id) || segment.system) return { message: "That segment is not one this connection publishes.", skipped: true };
927
+ if (!(settings == null ? void 0 : settings.segment)) return { message: "No Attentive segment is chosen for this connection.", skipped: true };
928
+ return {
929
+ events: [{
930
+ event: "organization.segments",
931
+ payload: { id: segment.id },
932
+ room: "organization." + (connection2 == null ? void 0 : connection2.organization)
933
+ }],
934
+ message: "Contacts in this segment are added to the Attentive segment chosen on this connection.",
935
+ writes: segmentRowWrites({
936
+ connection: connection2,
937
+ data: { ...connection2, settings },
938
+ manifest,
939
+ row: { id: settings.segment, type: "segment" },
940
+ segment
941
+ })
942
+ };
943
+ },
944
+ // NOT OURS TO DELETE. The segment on this connection is the merchant's,
945
+ // and it is where every Drawbridge segment's contacts go — removing it
946
+ // because one Drawbridge segment was deleted would empty the others.
947
+ remove: false,
948
+ // Drawbridge-side membership belongs to the private manifest.
949
+ sync: false
950
+ },
781
951
  sms: false,
782
952
  webhook: false
783
953
  },
@@ -806,6 +976,21 @@ var attentive_default2 = {
806
976
  "ATTENTIVE_OAUTH_CLIENT_ID",
807
977
  "ATTENTIVE_OAUTH_CLIENT_SECRET"
808
978
  ],
979
+ // THE CHECKLIST'S RECEIPT — see drawbridge-docs reference/connection-hooks.md.
980
+ review: {
981
+ api: "https://docs.attentive.com/reference/listsegments",
982
+ dashboard: "https://docs.attentive.com/docs/segments",
983
+ // THIS PAGE DOES NOT LIST EVERY SCOPE. Its table names five —
984
+ // events:write, ecommerce:write, subscriptions:write, attributes:write,
985
+ // privacy_requests:write — and says nothing about segments:read or
986
+ // segments:write, which the segments API this manifest calls does take.
987
+ // The header at the top of this file carries that distinction; it is
988
+ // repeated here so a reviewer following the link is not misled by what the
989
+ // table omits (fetched 2026-09-11).
990
+ scopes: "https://docs.attentive.com/docs/authentication",
991
+ content: "2026-09-11",
992
+ verified: null
993
+ },
809
994
  slug: "attentive",
810
995
  // A consent with no segment chosen is authenticated and inert — the sync needs
811
996
  // somewhere to put people — so the card says Pending rather than Active over
@@ -843,6 +1028,24 @@ var attentive_default2 = {
843
1028
  triggers: ["lead.insert", "segment.contact.add"],
844
1029
  usage: { actions: 1 }
845
1030
  })
1031
+ },
1032
+ segment: {
1033
+ // SYSTEM, so the builder never offers it and a merchant POST refuses it:
1034
+ // this fires from the segment's own lifecycle, not from a workflow
1035
+ // somebody assembled. The trigger is declared here rather than hard-coded
1036
+ // in drawbridge-sync.
1037
+ //
1038
+ // REGISTER ONLY. There is no remove step because hooks.segment.remove is
1039
+ // declined, and build() refuses a step pointing at a hook this vendor does
1040
+ // not implement — so the two are one decision, enforced at import.
1041
+ register: () => ({
1042
+ description: "Records which Attentive segment a Drawbridge segment's contacts are added to.",
1043
+ hook: "segment.register",
1044
+ key: "Attentive Segment Register",
1045
+ queue: "connection",
1046
+ system: true,
1047
+ trigger: { event: "segment.register", type: "event" }
1048
+ })
846
1049
  }
847
1050
  },
848
1051
  // WHY, in the merchant's words, and what to do about it.
@@ -859,7 +1062,21 @@ var attentive_default2 = {
859
1062
  }
860
1063
  ];
861
1064
  },
862
- title: "Attentive"
1065
+ title: "Attentive",
1066
+ // ATTENTIVE'S SEGMENTS INDEX. There is no documented per-segment url, and the
1067
+ // only identifier we hold is the API's externalId, which their UI may not
1068
+ // path by — so this lands on the list, where the merchant finds it by name.
1069
+ // A per-segment link arrives with the per-segment object (see hooks.segment).
1070
+ //
1071
+ // THE PATH ITSELF IS NOT PUBLISHED ANYWHERE CITABLE, the same gap Klaviyo's
1072
+ // segment url carries. What is on record is that the segments area lives at
1073
+ // ui.attentivemobile.com/segments — its /segments/create/ and /segments/manual
1074
+ // sub-routes are publicly indexed pages (fetched 2026-09-11) — while the /all
1075
+ // tab is not, and Attentive's help centre refuses automated fetches. The dev
1076
+ // walk-through confirms this against a real account before promote.
1077
+ urls: {
1078
+ segment: () => "https://ui.attentivemobile.com/segments/all"
1079
+ }
863
1080
  };
864
1081
 
865
1082
  // lib/connections/providers/drawbridge.js
@@ -1979,7 +2196,7 @@ var drawbridge_default2 = {
1979
2196
  content: {
1980
2197
  confirm: "This connection is part of Drawbridge and cannot be disconnected.",
1981
2198
  description: [
1982
- "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."
2199
+ "Drawbridge sends your notification emails and your entrants' emails, and recalculates segment membership on a schedule. It is always on and needs nothing connected."
1983
2200
  ],
1984
2201
  excerpt: "The steps Drawbridge runs itself.",
1985
2202
  guide: [
@@ -2292,6 +2509,11 @@ var drawbridge_default2 = {
2292
2509
  promotions: false
2293
2510
  },
2294
2511
  segment: {
2512
+ // NOT DRAWBRIDGE'S. Registering a segment means creating an object at a
2513
+ // vendor, and this manifest has no vendor behind it — the three that do
2514
+ // implement these.
2515
+ register: false,
2516
+ remove: false,
2295
2517
  // RECALCULATE SEGMENT MEMBERSHIP. The one FAN-OUT hook: it evaluates every
2296
2518
  // contact in an organization against every segment, which is too much for
2297
2519
  // one job, so it returns chunks and the shell defers completion.
@@ -2567,6 +2789,33 @@ var drawbridge_default2 = {
2567
2789
  // caught exactly that: availableConnections({}) went from [ 'drawbridge' ] to
2568
2790
  // empty the moment this was added.
2569
2791
  requires: [],
2792
+ // PRIVATE, NOT VENDORLESS. SendGrid, Twilio and HubSpot are behind this
2793
+ // manifest, so `false` would be a lie about which reads were made.
2794
+ //
2795
+ // ONE ENTRY PER VENDOR, because three vendors are three reads. A single
2796
+ // citation here would evidence one of them and read as though it covered all
2797
+ // three, which is the omission this key exists to catch.
2798
+ review: {
2799
+ api: {
2800
+ // lib/hubspot.js posts to /crm/v3/objects/contacts.
2801
+ hubspot: "https://developers.hubspot.com/docs/reference/api/crm/objects/contacts",
2802
+ // lib/sendgrid.js posts to /v3/mail/send.
2803
+ sendgrid: "https://www.twilio.com/docs/sendgrid/api-reference/mail-send/mail-send",
2804
+ // lib/twilio.js posts to /2010-04-01/Accounts/{Sid}/Messages.json, and
2805
+ // hooks.inbound.verify reads the MessageStatus this resource documents.
2806
+ twilio: "https://www.twilio.com/docs/messaging/api/message-resource"
2807
+ },
2808
+ dashboard: {
2809
+ hubspot: "https://knowledge.hubspot.com/contacts/create-contacts",
2810
+ sendgrid: "https://www.twilio.com/docs/sendgrid/ui/analytics-and-reporting/email-activity-feed",
2811
+ twilio: "https://www.twilio.com/docs/messaging/guides/debugging-tools"
2812
+ },
2813
+ // An admin types these keys in; there is no merchant consent and no scope
2814
+ // model on any of the three.
2815
+ scopes: false,
2816
+ content: "2026-09-11",
2817
+ verified: null
2818
+ },
2570
2819
  slug: "drawbridge",
2571
2820
  // Always on. There is no credential that could go bad and no configuration a
2572
2821
  // merchant could leave half-finished.
@@ -2758,6 +3007,8 @@ var api2 = async (path, { fetcher = fetch, method = "GET", payload, token }) =>
2758
3007
  }
2759
3008
  return response.status === 204 ? null : response.json();
2760
3009
  };
3010
+ var segmentName = (title) => "Drawbridge: " + title;
3011
+ var canManageSegments = (settings) => String((settings == null ? void 0 : settings.scope) || "").split(/\s+/).includes("segments:write");
2761
3012
  var klaviyo_default2 = {
2762
3013
  // OAuth 2.1, and PKCE is REQUIRED rather than recommended: Klaviyo refuses an
2763
3014
  // exchange without a code_verifier matching the challenge the consent
@@ -2787,9 +3038,21 @@ var klaviyo_default2 = {
2787
3038
  // exchange, and a copy here would be a second answer that goes stale.
2788
3039
  expiry: 90 * 24 * 60 * 60,
2789
3040
  pkce: true,
3041
+ // EVERY SCOPE THE MANIFEST'S HOOKS NEED, not the ones today's hooks use.
3042
+ // Klaviyo holds scopes on the APP — "Pinpoint which scopes your app uses
3043
+ // and set them using a space-separated list"
3044
+ // (developers.klaviyo.com/en/docs/create_a_public_oauth_app, fetched
3045
+ // 2026-09-11) — and a merchant's token only ever carries what they
3046
+ // consented to, so a scope added later is a reconnect for every one of
3047
+ // them. That is what segments cost when they were left out here.
3048
+ //
2790
3049
  // Space separated. accounts:read is required by Klaviyo on every app
2791
- // and must stay in the list; the rest are what a contact sync needs.
2792
- scopes: "accounts:read lists:read lists:write profiles:read profiles:write",
3050
+ // and must stay in the list; the rest are what a contact sync and the
3051
+ // segment hooks need — Get Segments lists `segments:read`, Create,
3052
+ // Update and Delete Segment each list `segments:write`
3053
+ // (raw.githubusercontent.com/klaviyo/openapi/main/openapi/stable.json,
3054
+ // revision 2026-07-15, fetched 2026-09-11).
3055
+ scopes: "accounts:read lists:read lists:write profiles:read profiles:write segments:read segments:write",
2793
3056
  // EVERY VENDOR URL, in one place. `revoke` used to be a literal inside
2794
3057
  // the disconnect hook — three vendor addresses, two of them declared,
2795
3058
  // which is exactly the kind of split that goes unnoticed.
@@ -2838,9 +3101,10 @@ var klaviyo_default2 = {
2838
3101
  // Shown at disconnect, so it says what is lost and what is not.
2839
3102
  confirm: "Disconnecting revokes Drawbridge's access to your Klaviyo account. Your profiles and lists stay in both Klaviyo and Drawbridge \u2014 neither is deleted.",
2840
3103
  description: [
2841
- "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.",
3104
+ "Connecting Klaviyo lets Drawbridge sync the contacts your campaigns collect into a Klaviyo list, so you can market to the people who enter a giveaway alongside the rest of your audience.",
2842
3105
  "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.",
2843
- "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."
3106
+ "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.",
3107
+ "Drawbridge writes its own properties onto the profiles it syncs: how many of your campaigns someone entered, their entries, draws and orders, the revenue their orders attributed to your campaigns, and which Drawbridge segments they are in. You can build Klaviyo segments and flows on any of them."
2844
3108
  ],
2845
3109
  // KEYED BY WHAT FAILED, not nested inside it. Errors are the thing most
2846
3110
  // likely to grow — resources.* has already earned somewhere to put "we
@@ -2997,6 +3261,7 @@ var klaviyo_default2 = {
2997
3261
  if (!email) return { message: "That lead has no email address to sync.", skipped: true };
2998
3262
  const person = (context == null ? void 0 : context.contact) || null;
2999
3263
  const totals = (person == null ? void 0 : person.totals) || {};
3264
+ const count = (value) => typeof value === "number" ? value : (value == null ? void 0 : value.total) || 0;
3000
3265
  const profile = await api2("/profile-import", {
3001
3266
  fetcher,
3002
3267
  method: "POST",
@@ -3010,13 +3275,13 @@ var klaviyo_default2 = {
3010
3275
  drawbridge_campaigns: (person.campaigns || []).length,
3011
3276
  drawbridge_draws: totals.draws || 0,
3012
3277
  drawbridge_entries: totals.entries || 0,
3013
- drawbridge_orders: totals.orders || 0,
3278
+ drawbridge_orders: count(totals.orders),
3014
3279
  // Campaign-attributed, NOT lifetime. A merchant running
3015
3280
  // Shopify already has lifetime revenue in Klaviyo through
3016
3281
  // Klaviyo's own integration; what only we can say is how
3017
3282
  // much a campaign drove. Named so the two cannot be
3018
3283
  // mistaken for one another in a segment builder.
3019
- drawbridge_revenue: totals.gross || 0
3284
+ drawbridge_revenue: count(totals.gross)
3020
3285
  },
3021
3286
  // THE DRAWBRIDGE SEGMENTS THEY ARE IN, as a list property the
3022
3287
  // merchant builds Klaviyo segments on top of. Klaviyo owns no
@@ -3035,7 +3300,14 @@ var klaviyo_default2 = {
3035
3300
  // `segments` is null when the run carried no contact document,
3036
3301
  // meaning nobody looked — different from [], which means they
3037
3302
  // are in none. Null omits the key and merge leaves it alone.
3038
- ...segments && { drawbridge_segments: segments.map((entry) => entry.title).filter(Boolean) }
3303
+ ...segments && { drawbridge_segments: segments.map((entry) => entry.title).filter(Boolean) },
3304
+ // THE IDS, which is what a Drawbridge-made segment's definition
3305
+ // filters on. Ids rather than titles, so renaming a segment is a
3306
+ // name change at Klaviyo and not a resync of every profile.
3307
+ //
3308
+ // The titles stay beside them: merchants have been building
3309
+ // their own segments on that array since it shipped.
3310
+ ...segments && { drawbridge_segment_ids: segments.map((entry) => entry.id).filter(Boolean) }
3039
3311
  }
3040
3312
  },
3041
3313
  type: "profile"
@@ -3079,17 +3351,141 @@ var klaviyo_default2 = {
3079
3351
  };
3080
3352
  }
3081
3353
  },
3082
- // A WHOLE DOMAIN CAN DECLINE AT ONCE. Klaviyo sends us nothing and we
3083
- // register nothing with it, so listing four falses would be noise around a
3084
- // single decision. Still explicit absence would not say whether anybody
3085
- // considered it.
3086
- // Drawbridge sends its own notification email and SMS, and owns its own
3087
- // segments — see the private `drawbridge` manifest. A vendor answering
3088
- // these would be a second sender, which is the arrangement the platform
3089
- // sender replaced.
3354
+ // Drawbridge sends its own notification email. A vendor answering this
3355
+ // would be a second sender, which is the arrangement the platform sender
3356
+ // replaced. Declined as one line rather than one per verb, because the whole
3357
+ // domain is one decision — still explicit, since absence would not say
3358
+ // whether anybody considered it.
3090
3359
  email: false,
3091
- segment: false,
3360
+ // SEGMENTS ARE SHARED, not owned by one side. Drawbridge holds the
3361
+ // membership — see the private `drawbridge` manifest, and `sync : false`
3362
+ // below — while register and remove keep a Klaviyo segment standing for
3363
+ // each Drawbridge segment, so the merchant can target one in their own
3364
+ // flows.
3365
+ segment: {
3366
+ // THE KLAVIYO SEGMENT THIS DRAWBRIDGE SEGMENT BECOMES.
3367
+ //
3368
+ // Klaviyo owns no writable membership — its segments are computed from
3369
+ // rules — so the segment we create is DEFINED BY the profile property
3370
+ // contacts.sync writes. The definition filters on the Drawbridge
3371
+ // segment's ID, never its title, which is what makes a rename one PATCH
3372
+ // instead of a resync of every profile in it.
3373
+ register: async ({ connection: connection2, context, manifest, settings, token, workflow }, { fetcher, read } = {}) => {
3374
+ var _a, _b, _c, _d, _e;
3375
+ const segment = await currentSegment({ read, segment: context == null ? void 0 : context.segment });
3376
+ if (!(segment == null ? void 0 : segment.id) || segment.system) return { message: "That segment is not one this connection publishes.", skipped: true };
3377
+ if (!canManageSegments(settings)) {
3378
+ return {
3379
+ message: "Reconnect Klaviyo to let Drawbridge manage segments \u2014 this connection was made before that permission was asked for.",
3380
+ skipped: true
3381
+ };
3382
+ }
3383
+ const name = segmentName(segment.title);
3384
+ const existing = segmentRowFor({ connection: connection2, segment });
3385
+ let id = null;
3386
+ if (existing == null ? void 0 : existing.id) {
3387
+ try {
3388
+ const found = await api2("/segments/" + existing.id, { fetcher, token });
3389
+ id = ((_a = found == null ? void 0 : found.data) == null ? void 0 : _a.id) ?? existing.id;
3390
+ if (((_c = (_b = found == null ? void 0 : found.data) == null ? void 0 : _b.attributes) == null ? void 0 : _c.name) !== name) {
3391
+ await api2("/segments/" + existing.id, {
3392
+ fetcher,
3393
+ method: "PATCH",
3394
+ payload: { data: { attributes: { name }, id: existing.id, type: "segment" } },
3395
+ token
3396
+ });
3397
+ }
3398
+ } catch (error) {
3399
+ if (error.status !== 404) throw error;
3400
+ id = null;
3401
+ }
3402
+ }
3403
+ if (!id) {
3404
+ const search = await api2("/segments?filter=" + encodeURIComponent('equals(name,"' + name.replace(/"/g, '\\"') + '")'), { fetcher, token });
3405
+ id = ((_d = ((search == null ? void 0 : search.data) || []).find((entry) => {
3406
+ var _a2;
3407
+ return ((_a2 = entry == null ? void 0 : entry.attributes) == null ? void 0 : _a2.name) === name;
3408
+ })) == null ? void 0 : _d.id) ?? null;
3409
+ }
3410
+ if (!id) {
3411
+ const created = await api2("/segments", {
3412
+ fetcher,
3413
+ method: "POST",
3414
+ // THE DEFINITION IS THE MEMBERSHIP. Create Segment requires one
3415
+ // — `name` and `definition` are both required on its attributes
3416
+ // — and a custom profile property is addressed as
3417
+ // "properties['property name']", tested with a list filter whose
3418
+ // operator is `contains`
3419
+ // (raw.githubusercontent.com/klaviyo/openapi/main/openapi/stable.json,
3420
+ // revision 2026-07-15, fetched 2026-09-11).
3421
+ payload: {
3422
+ data: {
3423
+ attributes: {
3424
+ definition: {
3425
+ condition_groups: [{
3426
+ conditions: [{
3427
+ filter: { operator: "contains", type: "list", value: segment.id },
3428
+ property: "properties['drawbridge_segment_ids']",
3429
+ type: "profile-property"
3430
+ }]
3431
+ }]
3432
+ },
3433
+ name
3434
+ },
3435
+ type: "segment"
3436
+ }
3437
+ },
3438
+ token
3439
+ });
3440
+ id = (_e = created == null ? void 0 : created.data) == null ? void 0 : _e.id;
3441
+ }
3442
+ if (!id) return { message: "Klaviyo returned no segment id.", skipped: true };
3443
+ return {
3444
+ // A RENAME THAT ARRIVED WHILE THIS RAN was dropped by the
3445
+ // coalescing job id, so the last thing this does is look again.
3446
+ enqueues: await driftEnqueues({ applied: segment.title, read, segment, workflow }),
3447
+ events: [{
3448
+ event: "organization.segments",
3449
+ payload: { id: segment.id },
3450
+ room: "organization." + (connection2 == null ? void 0 : connection2.organization)
3451
+ }],
3452
+ message: 'Klaviyo is carrying this segment as "' + name + '".',
3453
+ writes: segmentRowWrites({
3454
+ connection: connection2,
3455
+ data: { ...connection2, settings },
3456
+ manifest,
3457
+ row: { id, type: "segment" },
3458
+ segment
3459
+ })
3460
+ };
3461
+ },
3462
+ // NO RE-READ. The segment is already deleted; the pre-image is the only
3463
+ // copy, and it carries the row naming what to delete.
3464
+ remove: async ({ connection: connection2, context, settings, token }, { fetcher } = {}) => {
3465
+ const segment = context == null ? void 0 : context.segment;
3466
+ const existing = segmentRowFor({ connection: connection2, segment });
3467
+ if (!(existing == null ? void 0 : existing.id)) return { message: "Klaviyo was never carrying this segment.", skipped: true };
3468
+ if (!canManageSegments(settings)) {
3469
+ return { message: "Reconnect Klaviyo to let Drawbridge manage segments.", skipped: true };
3470
+ }
3471
+ try {
3472
+ await api2("/segments/" + existing.id, { fetcher, method: "DELETE", token });
3473
+ } catch (error) {
3474
+ if (error.status !== 404) throw error;
3475
+ }
3476
+ return {
3477
+ message: "Klaviyo is no longer carrying this segment.",
3478
+ writes: segmentRowRemoveWrites({ connection: connection2, segment })
3479
+ };
3480
+ },
3481
+ // Drawbridge-side membership belongs to the private manifest.
3482
+ sync: false
3483
+ },
3484
+ // Declined for the same reason as `email` above: Drawbridge sends its own
3485
+ // notification SMS, and a vendor answering this would be a second sender.
3092
3486
  sms: false,
3487
+ // Klaviyo sends us nothing — no inbound message to receive, no signature
3488
+ // to verify.
3093
3489
  inbound: false,
3094
3490
  // Nothing to set up or tear down at the vendor: the grant is the whole
3095
3491
  // integration. What CAN rot is the grant itself, so health is the one
@@ -3210,6 +3606,18 @@ var klaviyo_default2 = {
3210
3606
  "KLAVIYO_OAUTH_CLIENT_ID",
3211
3607
  "KLAVIYO_OAUTH_CLIENT_SECRET"
3212
3608
  ],
3609
+ // THE CHECKLIST'S RECEIPT — see drawbridge-docs reference/connection-hooks.md.
3610
+ review: {
3611
+ api: "https://developers.klaviyo.com/en/reference/api_overview",
3612
+ dashboard: "https://help.klaviyo.com/hc/en-us/articles/115005078647",
3613
+ // THE SCOPE TABLE, not the OAuth walk-through. set_up_oauth carries one
3614
+ // example scope string and nothing to check a manifest against; this page
3615
+ // lists the scopes each API takes, segments:read and segments:write among
3616
+ // them (fetched 2026-09-11).
3617
+ scopes: "https://developers.klaviyo.com/en/docs/authenticate_",
3618
+ content: "2026-09-11",
3619
+ verified: null
3620
+ },
3213
3621
  slug: "klaviyo",
3214
3622
  // ONE OF THE FOUR STATES AND NOTHING ELSE — the reason sits in `tasks`, which
3215
3623
  // is already the merchant-facing copy channel and is already rendered.
@@ -3240,7 +3648,8 @@ var klaviyo_default2 = {
3240
3648
  hook: "lifecycle.health",
3241
3649
  key: "Klaviyo Connection Health",
3242
3650
  queue: "connection",
3243
- system: true
3651
+ system: true,
3652
+ trigger: { event: "day", type: "schedule" }
3244
3653
  })
3245
3654
  }
3246
3655
  },
@@ -3284,6 +3693,28 @@ var klaviyo_default2 = {
3284
3693
  usage: { actions: 1 }
3285
3694
  };
3286
3695
  }
3696
+ },
3697
+ segment: {
3698
+ // SYSTEM, so the builder never offers it and a merchant POST refuses it:
3699
+ // these fire from the segment's own lifecycle, not from a workflow
3700
+ // somebody assembled. The trigger is declared here rather than hard-coded
3701
+ // in drawbridge-sync.
3702
+ register: () => ({
3703
+ description: "Keeps a matching Klaviyo segment for each Drawbridge segment, built on the segment ids Drawbridge writes onto your profiles.",
3704
+ hook: "segment.register",
3705
+ key: "Klaviyo Segment Register",
3706
+ queue: "connection",
3707
+ system: true,
3708
+ trigger: { event: "segment.register", type: "event" }
3709
+ }),
3710
+ remove: () => ({
3711
+ description: "Deletes the Klaviyo segment for a Drawbridge segment when the segment is deleted.",
3712
+ hook: "segment.remove",
3713
+ key: "Klaviyo Segment Remove",
3714
+ queue: "connection",
3715
+ system: true,
3716
+ trigger: { event: "segment.remove", type: "event" }
3717
+ })
3287
3718
  }
3288
3719
  },
3289
3720
  // WHY, in the merchant's words, and what to do about it.
@@ -3293,14 +3724,32 @@ var klaviyo_default2 = {
3293
3724
  // moment: the grant is good and the list is the missing half.
3294
3725
  tasks: (data2) => {
3295
3726
  var _a;
3296
- return !["active", "pending"].includes(data2 == null ? void 0 : data2.status) || ((_a = data2 == null ? void 0 : data2.settings) == null ? void 0 : _a.list) ? [] : [
3297
- {
3727
+ if (!["active", "pending"].includes(data2 == null ? void 0 : data2.status)) return [];
3728
+ return [
3729
+ // A connection made before segments were requested is authenticated and
3730
+ // cannot manage them, and no error surfaces anywhere else — the register
3731
+ // runs skip rather than fail.
3732
+ ...canManageSegments(data2 == null ? void 0 : data2.settings) ? [] : [{
3733
+ message: "Drawbridge now keeps a Klaviyo segment in step with each of your Drawbridge segments. Reconnect Klaviyo to allow it.",
3734
+ title: "Reconnect Klaviyo"
3735
+ }],
3736
+ ...((_a = data2 == null ? void 0 : data2.settings) == null ? void 0 : _a.list) ? [] : [{
3298
3737
  message: "Choose which Klaviyo list your contacts should sync into. Until you do, nothing is being synced.",
3299
3738
  title: "Choose a list"
3300
- }
3739
+ }]
3301
3740
  ];
3302
3741
  },
3303
- title: "Klaviyo"
3742
+ title: "Klaviyo",
3743
+ // KLAVIYO PUBLISHES NO DASHBOARD URLS in its API reference. What is on record
3744
+ // is its own help centre on a list: "you can find a list's ID in the URL in
3745
+ // your browser when viewing this list"
3746
+ // (help.klaviyo.com/hc/en-us/articles/115005078647, fetched 2026-09-11), and a
3747
+ // segment's page is the sibling form of it. The path itself is NOT published
3748
+ // anywhere citable, so the dev walk-through confirms this against a real
3749
+ // account before promote.
3750
+ urls: {
3751
+ segment: (row2) => (row2 == null ? void 0 : row2.id) ? "https://www.klaviyo.com/segment/" + row2.id : null
3752
+ }
3304
3753
  };
3305
3754
 
3306
3755
  // lib/connections/providers/mailchimp.js
@@ -3337,6 +3786,8 @@ var api3 = async (path, { dc, fetcher = fetch, method = "GET", payload, token })
3337
3786
  return response.status === 204 ? null : response.json();
3338
3787
  };
3339
3788
  var subscriberHash = (email) => createHash2("md5").update(String(email).trim().toLowerCase()).digest("hex");
3789
+ var TAG_NAME_LIMIT = 100;
3790
+ var tagName = (title) => ("Drawbridge: " + title).slice(0, TAG_NAME_LIMIT);
3340
3791
  var mailchimp_default2 = {
3341
3792
  // OAUTH 2, authorization code. Every url below is quoted from
3342
3793
  // mailchimp.com/developer/marketing/guides/access-user-data-oauth-2/ rather
@@ -3379,7 +3830,7 @@ var mailchimp_default2 = {
3379
3830
  confirm: "Disconnecting removes Drawbridge's stored Mailchimp access. You can also remove Drawbridge from the Authorized Apps page in your Mailchimp account. Your contacts stay in both Drawbridge and Mailchimp \u2014 neither list is deleted.",
3380
3831
  description: [
3381
3832
  "Drawbridge no longer sends email through Mailchimp. Notification email now sends from Drawbridge itself, and verifying a domain under Messaging in your organization settings puts your own brand in the from line.",
3382
- "Connecting Mailchimp lets Drawbridge sync the contacts your campaigns collect into a Mailchimp audience, so the people who enter a giveaway can be marketed to alongside the rest of your list.",
3833
+ "Connecting Mailchimp lets Drawbridge sync the contacts your campaigns collect into a Mailchimp audience, so you can market to the people who enter a giveaway alongside the rest of your list.",
3383
3834
  "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.",
3384
3835
  "Someone who unsubscribed inside Mailchimp keeps that choice: a resync only sets the status of a subscriber Mailchimp has never seen before."
3385
3836
  ],
@@ -3392,6 +3843,7 @@ var mailchimp_default2 = {
3392
3843
  "Sign in to Mailchimp if you are not already, and choose the account to connect.",
3393
3844
  "You come back here to pick the audience your contacts should sync into.",
3394
3845
  "The connection shows Pending until you pick an audience, then Active.",
3846
+ 'Each of your Drawbridge segments appears in that audience as a tag named "Drawbridge: " plus the segment name. Renaming a segment in Drawbridge renames its tag, and deleting the segment deletes the tag.',
3395
3847
  "You can remove Drawbridge at any time from the Authorized Apps page in your Mailchimp account."
3396
3848
  ]
3397
3849
  },
@@ -3417,10 +3869,9 @@ var mailchimp_default2 = {
3417
3869
  }
3418
3870
  ],
3419
3871
  group: "contacts",
3420
- // A HOOK'S VALUE IS ITS ANSWER. A key is stored and can be removed; nothing
3421
- // else is built yet, because audience sync has not shipped. Every false here
3422
- // is "not yet" rather than "never" when the sync lands, probe and
3423
- // contacts.sync are the first to flip.
3872
+ // WHAT THIS VENDOR DOES AND DOES NOT DO is the value of each hook below, not
3873
+ // a paragraph up here that goes stale the moment one of them is implemented
3874
+ // which is exactly what happened to the note this replaces.
3424
3875
  hooks: {
3425
3876
  auth: {
3426
3877
  // WHERE THE ACCOUNT LIVES. Not enrichment — without this the connection
@@ -3474,26 +3925,32 @@ var mailchimp_default2 = {
3474
3925
  // why there is no create-or-update branch here. Quoted from Mailchimp's
3475
3926
  // Marketing API reference for the list-members resource.
3476
3927
  sync: async ({ connection: connection2, lead, segments, settings, suppressed, token }, { fetcher, read } = {}) => {
3477
- var _a, _b;
3928
+ var _a, _b, _c;
3478
3929
  const audience = settings == null ? void 0 : settings.audience;
3479
3930
  if (!audience) return { message: "No Mailchimp audience is chosen for this connection.", skipped: true };
3480
3931
  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);
3481
3932
  if (!email) return { message: "That lead has no email address to sync.", skipped: true };
3482
3933
  const hash = subscriberHash(email);
3934
+ const [firstName, ...restOfName] = String((lead == null ? void 0 : lead.name) || "").trim().split(/\s+/).filter(Boolean);
3935
+ const lastName = restOfName.join(" ");
3936
+ const phone = ((_c = lead == null ? void 0 : lead.phone) == null ? void 0 : _c.number) || null;
3937
+ const mergeFields = {
3938
+ ...firstName && { FNAME: firstName },
3939
+ ...lastName && { LNAME: lastName },
3940
+ ...phone && { PHONE: phone }
3941
+ };
3483
3942
  const member = await api3("/lists/" + audience + "/members/" + hash, {
3484
3943
  dc: settings == null ? void 0 : settings.dc,
3485
3944
  fetcher,
3486
3945
  method: "PUT",
3487
3946
  payload: {
3488
3947
  email_address: email,
3489
- // FNAME ONLY. Unlike Klaviyo, Mailchimp's custom fields are not
3490
- // schemaless a merge tag that does not exist on the audience is
3491
- // refused, taking the whole request with it and FNAME is one of
3492
- // the two tags every audience is created with. The Drawbridge
3493
- // totals Klaviyo receives cannot travel until something registers
3494
- // merge fields on the chosen audience, which is lifecycle.register's
3495
- // job and is not built.
3496
- ...(lead == null ? void 0 : lead.name) && { merge_fields: { FNAME: String(lead.name).trim().split(/\s+/)[0] } },
3948
+ // Built above. Omitted entirely when there is nothing to say, so a
3949
+ // lead with only an address does not send an empty object. The
3950
+ // Drawbridge totals Klaviyo receives still cannot travel this way
3951
+ // those are custom tags, and registering them on the chosen audience
3952
+ // is lifecycle.register's job and is not built.
3953
+ ...Object.keys(mergeFields).length > 0 && { merge_fields: mergeFields },
3497
3954
  ...suppressed && { status: "unsubscribed" },
3498
3955
  status_if_new: suppressed ? "unsubscribed" : "subscribed"
3499
3956
  },
@@ -3516,7 +3973,7 @@ var mailchimp_default2 = {
3516
3973
  });
3517
3974
  const joined = new Set(segments.map((entry) => entry.title));
3518
3975
  const tags = (owned || []).map((entry) => entry.title).filter(Boolean).map((title) => ({
3519
- name: "Drawbridge: " + title,
3976
+ name: tagName(title),
3520
3977
  status: joined.has(title) ? "active" : "inactive"
3521
3978
  }));
3522
3979
  if (tags.length > 0) {
@@ -3539,12 +3996,122 @@ var mailchimp_default2 = {
3539
3996
  };
3540
3997
  }
3541
3998
  },
3542
- // Drawbridge sends its own notification email and SMS, and owns its own
3543
- // segments see the private `drawbridge` manifest. A vendor answering
3544
- // these would be a second sender, which is the arrangement the platform
3545
- // sender replaced.
3999
+ // Drawbridge sends its own notification email. A vendor answering this
4000
+ // would be a second sender, which is the arrangement the platform sender
4001
+ // replaced.
3546
4002
  email: false,
3547
- segment: false,
4003
+ // SEGMENTS ARE SHARED, not owned by one side. Drawbridge holds the
4004
+ // membership — see the private `drawbridge` manifest, and `sync : false`
4005
+ // below — while register and remove keep a Mailchimp tag standing for each
4006
+ // Drawbridge segment, so the merchant can target one in their own audience.
4007
+ segment: {
4008
+ // THE TAG THIS SEGMENT IS, held by id at last.
4009
+ //
4010
+ // Tags ARE static segments in Mailchimp's model — same collection, same
4011
+ // ids — so this creates one through /segments and the member write goes
4012
+ // on attaching people to it by name. Both address the same object. The
4013
+ // segment schema says it outright: "The type of segment. Static segments
4014
+ // are now known as tags"
4015
+ // (api.mailchimp.com/schema/3.0/Definitions/Lists/Segments/Response.json,
4016
+ // fetched 2026-09-12 — the root Swagger.json carries no prose, only $refs
4017
+ // into fragment files like this one).
4018
+ //
4019
+ // IDEMPOTENT ON EVERY PATH: called on create, on rename, on a connection
4020
+ // finishing its configuration, and on the backfill migration, it converges. That is what lets one hook serve
4021
+ // all four without a create-vs-update branch anywhere else.
4022
+ register: async ({ connection: connection2, context, manifest, settings, token, workflow }, { fetcher, read } = {}) => {
4023
+ var _a;
4024
+ const audience = settings == null ? void 0 : settings.audience;
4025
+ if (!audience) return { message: "No Mailchimp audience is chosen for this connection.", skipped: true };
4026
+ const segment = await currentSegment({ read, segment: context == null ? void 0 : context.segment });
4027
+ if (!(segment == null ? void 0 : segment.id) || segment.system) return { message: "That segment is not one this connection publishes.", skipped: true };
4028
+ const name = tagName(segment.title);
4029
+ const existing = segmentRowFor({ connection: connection2, segment });
4030
+ let id = null;
4031
+ if (existing == null ? void 0 : existing.id) {
4032
+ try {
4033
+ const found = await api3("/lists/" + audience + "/segments/" + existing.id, { dc: settings == null ? void 0 : settings.dc, fetcher, token });
4034
+ id = (found == null ? void 0 : found.id) ?? existing.id;
4035
+ if ((found == null ? void 0 : found.name) !== name) {
4036
+ await api3("/lists/" + audience + "/segments/" + existing.id, {
4037
+ dc: settings == null ? void 0 : settings.dc,
4038
+ fetcher,
4039
+ method: "PATCH",
4040
+ payload: { name },
4041
+ token
4042
+ });
4043
+ }
4044
+ } catch (error) {
4045
+ if (error.status !== 404) throw error;
4046
+ id = null;
4047
+ }
4048
+ }
4049
+ if (!id) {
4050
+ const search = await api3("/lists/" + audience + "/tag-search?name=" + encodeURIComponent(name), { dc: settings == null ? void 0 : settings.dc, fetcher, token });
4051
+ id = ((_a = ((search == null ? void 0 : search.tags) || []).find((tag) => (tag == null ? void 0 : tag.name) === name)) == null ? void 0 : _a.id) ?? null;
4052
+ }
4053
+ if (!id) {
4054
+ const created = await api3("/lists/" + audience + "/segments", {
4055
+ dc: settings == null ? void 0 : settings.dc,
4056
+ fetcher,
4057
+ method: "POST",
4058
+ // STATIC WITH NO MEMBERS. The member sync attaches people by
4059
+ // name; this call only has to make the object exist. Mailchimp's
4060
+ // own wording for the empty array: "Passing an empty array will
4061
+ // create a static segment without any subscribers."
4062
+ payload: { name, static_segment: [] },
4063
+ token
4064
+ });
4065
+ id = created == null ? void 0 : created.id;
4066
+ }
4067
+ if (!id) return { message: "Mailchimp returned no tag id.", skipped: true };
4068
+ const audienceDetail = await api3("/lists/" + audience + "?fields=web_id", { dc: settings == null ? void 0 : settings.dc, fetcher, token });
4069
+ return {
4070
+ // A RENAME THAT ARRIVED WHILE THIS RAN was dropped by the
4071
+ // coalescing job id, so the last thing this does is look again.
4072
+ enqueues: await driftEnqueues({ applied: segment.title, read, segment, workflow }),
4073
+ events: [{
4074
+ event: "organization.segments",
4075
+ payload: { id: segment.id },
4076
+ room: "organization." + (connection2 == null ? void 0 : connection2.organization)
4077
+ }],
4078
+ message: 'Mailchimp is carrying this segment as the tag "' + name + '".',
4079
+ writes: segmentRowWrites({
4080
+ connection: connection2,
4081
+ data: { ...connection2, settings },
4082
+ manifest,
4083
+ row: { id, type: "tag", webId: audienceDetail == null ? void 0 : audienceDetail.web_id },
4084
+ segment
4085
+ })
4086
+ };
4087
+ },
4088
+ // THE TAG GOES WITH THE SEGMENT. Leaving it behind is the orphan this
4089
+ // whole pair exists to stop — every member would keep a label for a
4090
+ // segment that no longer exists.
4091
+ remove: async ({ connection: connection2, context, settings, token }, { fetcher } = {}) => {
4092
+ const segment = context == null ? void 0 : context.segment;
4093
+ const existing = segmentRowFor({ connection: connection2, segment });
4094
+ if (!(existing == null ? void 0 : existing.id)) return { message: "Mailchimp was never carrying this segment.", skipped: true };
4095
+ try {
4096
+ await api3("/lists/" + (settings == null ? void 0 : settings.audience) + "/segments/" + existing.id, {
4097
+ dc: settings == null ? void 0 : settings.dc,
4098
+ fetcher,
4099
+ method: "DELETE",
4100
+ token
4101
+ });
4102
+ } catch (error) {
4103
+ if (error.status !== 404) throw error;
4104
+ }
4105
+ return {
4106
+ message: "Mailchimp is no longer carrying this segment.",
4107
+ writes: segmentRowRemoveWrites({ connection: connection2, segment })
4108
+ };
4109
+ },
4110
+ // Drawbridge-side membership belongs to the private manifest.
4111
+ sync: false
4112
+ },
4113
+ // Declined for the same reason as `email` above: Drawbridge sends its own
4114
+ // notification SMS, and a vendor answering this would be a second sender.
3548
4115
  sms: false,
3549
4116
  inbound: false,
3550
4117
  lifecycle: false,
@@ -3607,6 +4174,16 @@ var mailchimp_default2 = {
3607
4174
  "MAILCHIMP_OAUTH_CLIENT_ID",
3608
4175
  "MAILCHIMP_OAUTH_CLIENT_SECRET"
3609
4176
  ],
4177
+ // THE CHECKLIST'S RECEIPT — see drawbridge-docs reference/connection-hooks.md.
4178
+ review: {
4179
+ api: "https://mailchimp.com/developer/marketing/guides/access-user-data-oauth-2/",
4180
+ dashboard: "https://mailchimp.com/help/manage-tags/",
4181
+ // NO SCOPES EXIST. Mailchimp's OAuth guide describes none, and a token is
4182
+ // account-wide — so there is nothing to request and nothing to re-consent.
4183
+ scopes: false,
4184
+ content: "2026-09-11",
4185
+ verified: null
4186
+ },
3610
4187
  slug: "mailchimp",
3611
4188
  // A grant with no audience chosen is authenticated and useless — the sync has
3612
4189
  // nowhere to put anyone — so the card must say Pending rather than Active over
@@ -3652,6 +4229,30 @@ var mailchimp_default2 = {
3652
4229
  // adds this step, and what is charged when it runs.
3653
4230
  usage: { actions: 1 }
3654
4231
  })
4232
+ },
4233
+ segment: {
4234
+ // SYSTEM, so the builder never offers it and a merchant POST refuses it:
4235
+ // these fire from the segment's own lifecycle, not from a workflow
4236
+ // somebody assembled.
4237
+ //
4238
+ // The trigger is declared HERE rather than hard-coded in drawbridge-sync,
4239
+ // which is what lets a vendor arrive with its own without a queue edit.
4240
+ register: () => ({
4241
+ description: "Keeps a matching tag in your Mailchimp audience for each Drawbridge segment, and renames it when the segment is renamed.",
4242
+ hook: "segment.register",
4243
+ key: "Mailchimp Segment Register",
4244
+ queue: "connection",
4245
+ system: true,
4246
+ trigger: { event: "segment.register", type: "event" }
4247
+ }),
4248
+ remove: () => ({
4249
+ description: "Deletes the Mailchimp tag for a Drawbridge segment when the segment is deleted.",
4250
+ hook: "segment.remove",
4251
+ key: "Mailchimp Segment Remove",
4252
+ queue: "connection",
4253
+ system: true,
4254
+ trigger: { event: "segment.remove", type: "event" }
4255
+ })
3655
4256
  }
3656
4257
  },
3657
4258
  // WHY, in the merchant's words, and what to do about it.
@@ -3668,11 +4269,27 @@ var mailchimp_default2 = {
3668
4269
  }
3669
4270
  ];
3670
4271
  },
3671
- title: "Mailchimp"
4272
+ title: "Mailchimp",
4273
+ // THE MERCHANT'S OWN ADMIN. Mailchimp's list schema states the shape outright:
4274
+ // the web_id field is "The ID used in the Mailchimp web application. View this
4275
+ // list in your Mailchimp account at
4276
+ // https://{dc}.admin.mailchimp.com/lists/members/?id={web_id}"
4277
+ // (api.mailchimp.com/schema/3.0/Definitions/Lists/Response.json, fetched
4278
+ // 2026-09-11).
4279
+ //
4280
+ // It lands on the audience's contacts, where the Drawbridge tag is one filter
4281
+ // away. Mailchimp documents no url that pre-selects a tag, so this stops one
4282
+ // click short rather than guessing at one that could break silently.
4283
+ urls: {
4284
+ segment: (row2, data2) => {
4285
+ var _a;
4286
+ return ((_a = data2 == null ? void 0 : data2.settings) == null ? void 0 : _a.dc) && (row2 == null ? void 0 : row2.webId) ? "https://" + data2.settings.dc + ".admin.mailchimp.com/lists/members/?id=" + row2.webId : null;
4287
+ }
4288
+ }
3672
4289
  };
3673
4290
 
3674
4291
  // lib/connections/providers/shopify.js
3675
- import { randomUUID } from "crypto";
4292
+ import { randomUUID as randomUUID2 } from "crypto";
3676
4293
  import { customAlphabet as customAlphabet2 } from "nanoid";
3677
4294
 
3678
4295
  // lib/connections/icons/shopify.js
@@ -3769,6 +4386,28 @@ var attributeLineItems = (lineItems = []) => lineItems.reduce(
3769
4386
  { attrMap: {}, attributedGross: 0, attributedLines: [] }
3770
4387
  );
3771
4388
  var generateDiscountCode = customAlphabet2("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", 8);
4389
+ var blockedReason = (discount) => {
4390
+ var _a;
4391
+ if ((discount == null ? void 0 : discount.status) === "EXPIRED") return "This discount has expired.";
4392
+ const buyers = (_a = discount == null ? void 0 : discount.context) == null ? void 0 : _a.__typename;
4393
+ if (buyers && buyers !== "DiscountBuyerSelectionAll") {
4394
+ return "This discount is limited to specific buyers in Shopify, so a code issued to an entrant won't work. Set it to all customers to use it here.";
4395
+ }
4396
+ ;
4397
+ if (typeof (discount == null ? void 0 : discount.usageLimit) === "number" && discount.usageLimit > 0 && ((discount == null ? void 0 : discount.asyncUsageCount) || 0) >= discount.usageLimit) {
4398
+ return "This discount has reached its total usage limit.";
4399
+ }
4400
+ ;
4401
+ return null;
4402
+ };
4403
+ var discountWarning = (discount) => {
4404
+ if ((discount == null ? void 0 : discount.status) === "SCHEDULED") {
4405
+ return "This discount hasn't started yet, so codes issued before it does won't work until then.";
4406
+ }
4407
+ ;
4408
+ if (discount == null ? void 0 : discount.appliesOncePerCustomer) return "Each customer can use this discount only once.";
4409
+ return null;
4410
+ };
3772
4411
  var ORDER_EVENT_HANDLE = slugify("drawbridge-orders");
3773
4412
  var REFRESH_TOKEN_FRESHNESS_BUFFER_MS = 5 * 24 * 60 * 60 * 1e3;
3774
4413
  var OAUTH_ERROR_SOURCE = "oauth";
@@ -3816,7 +4455,7 @@ var shopify_default2 = {
3816
4455
  description: [
3817
4456
  "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.",
3818
4457
  "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.",
3819
- "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."
4458
+ "Drawbridge reads your products, records orders placed through your campaigns, and can issue discount codes. Order and product updates reach Drawbridge through the app's own webhooks, which Shopify applies when the app is installed."
3820
4459
  ],
3821
4460
  errors: {
3822
4461
  connect: {
@@ -3830,7 +4469,7 @@ var shopify_default2 = {
3830
4469
  "Open the Drawbridge listing on the Shopify App Store.",
3831
4470
  "Install the app on the store you want to connect. It opens in Shopify admin and stays there.",
3832
4471
  "Approve the Drawbridge plan when prompted \u2014 during install, or from the connection page here. The connection shows Pending until you do, then Active.",
3833
- "Come back here \u2014 the connections list updates on its own once the install lands."
4472
+ "Come back here \u2014 the connections list updates on its own once the install finishes."
3834
4473
  ],
3835
4474
  // Names where the link GOES rather than what it does: installing happens on
3836
4475
  // the App Store listing, and the dashboard must never imply a store can be
@@ -4206,9 +4845,11 @@ var shopify_default2 = {
4206
4845
  phone: customerPhone
4207
4846
  } : null;
4208
4847
  const source = (connection2 == null ? void 0 : connection2.source) ? { domain: connection2.source.domain, id: connection2.source.id } : void 0;
4209
- const orderDocId = (existingOrder == null ? void 0 : existingOrder.id) || (isConversion && !backfill ? mintId() : null);
4848
+ const createsOrder = !backfill && (isConversion || Boolean(discount));
4849
+ const orderDocId = (existingOrder == null ? void 0 : existingOrder.id) || (createsOrder ? mintId() : null);
4850
+ const redemptionDocId = discount ? mintId() : null;
4210
4851
  const writes = [];
4211
- if (isConversion && !backfill) {
4852
+ if (createsOrder) {
4212
4853
  writes.push({
4213
4854
  collection: "order",
4214
4855
  data: {
@@ -4229,15 +4870,25 @@ var shopify_default2 = {
4229
4870
  provider: { id: String(orderId), slug: "shopify" },
4230
4871
  purchasedAt,
4231
4872
  rate,
4873
+ // Null on a conversion that matched no code of ours; the
4874
+ // backfill branch below sets it when one arrives later.
4875
+ redemption: redemptionDocId,
4232
4876
  source,
4233
- status: "completed"
4877
+ status: "completed",
4878
+ type: isConversion ? "conversion" : "redemption"
4234
4879
  },
4235
4880
  operation: "create"
4236
4881
  });
4237
4882
  if (org == null ? void 0 : org.usage) {
4238
4883
  writes.push({
4239
4884
  collection: "usage",
4240
- data: { $inc: { "totals.revenue": gross } },
4885
+ // TWO METERS, NOT ONE SUMMED. `revenue` has always meant
4886
+ // conversion revenue and is the figure the fee is charged
4887
+ // against, so redemption money gets its own key rather than
4888
+ // changing what an existing number means.
4889
+ data: {
4890
+ $inc: isConversion ? { "totals.revenue": gross } : { "totals.redemptionRevenue": gross }
4891
+ },
4241
4892
  operation: "update",
4242
4893
  query: { id: org.usage }
4243
4894
  });
@@ -4245,7 +4896,12 @@ var shopify_default2 = {
4245
4896
  if (leadId) {
4246
4897
  writes.push({
4247
4898
  collection: "lead",
4248
- data: { $inc: { "totals.orders": 1 } },
4899
+ // Same grouped shape the contact carries, so a lead and the
4900
+ // contact built from it cannot be read two different ways.
4901
+ data: { $inc: {
4902
+ "totals.orders.total": 1,
4903
+ ...isConversion ? { "totals.orders.conversions": 1 } : { "totals.orders.redemptions": 1 }
4904
+ } },
4249
4905
  operation: "update",
4250
4906
  options: { bypassDocumentValidation: true },
4251
4907
  query: { id: leadId }
@@ -4264,6 +4920,7 @@ var shopify_default2 = {
4264
4920
  customer,
4265
4921
  discount,
4266
4922
  gross,
4923
+ id: redemptionDocId,
4267
4924
  lead: leadId,
4268
4925
  order: orderDocId,
4269
4926
  organization: campaignOrganization,
@@ -4292,6 +4949,14 @@ var shopify_default2 = {
4292
4949
  query: { id: leadId }
4293
4950
  });
4294
4951
  }
4952
+ if (backfill && orderDocId && redemptionDocId) {
4953
+ writes.push({
4954
+ collection: "order",
4955
+ data: { $set: { redemption: redemptionDocId } },
4956
+ operation: "update",
4957
+ query: { id: orderDocId }
4958
+ });
4959
+ }
4295
4960
  }
4296
4961
  const billable = (org == null ? void 0 : org.billingProvider) === "shopify" && fee > 0 && !backfill;
4297
4962
  const providerRow = billable ? await read.get({ collection: "provider", query: { slug: "shopify" } }) : null;
@@ -4670,7 +5335,7 @@ var shopify_default2 = {
4670
5335
  event: "shopify.register.webhooks"
4671
5336
  },
4672
5337
  name: "register",
4673
- options: { jobId: "connection.update.register." + workflow.connection + "." + randomUUID() },
5338
+ options: { jobId: "connection.update.register." + workflow.connection + "." + randomUUID2() },
4674
5339
  queue: "connection"
4675
5340
  }],
4676
5341
  message: ((scopesMissing == null ? void 0 : scopesMissing.length) ? "Health check: ping ok, webhooks reconciled \u2014 connection errored, granted scopes are missing: " + scopesMissing.join(", ") + "." : refreshTokenRotated ? "Health check passed \u2014 refresh token rotated, ping ok, webhooks reconciled." : "Health check passed \u2014 ping ok, webhooks reconciled.") + (sourceRepaired ? " Billing source repaired from the live shop." : "") + (metered === null ? " No usage line on the store's approved plan \u2014 order billing needs the merchant to approve the updated plan." : ""),
@@ -4784,10 +5449,19 @@ var shopify_default2 = {
4784
5449
  // picker stores, which is why the tail is taken here rather than by
4785
5450
  // each caller that happened to remember.
4786
5451
  items: ((discounts == null ? void 0 : discounts.edges) || []).map((edge) => {
4787
- var _a2, _b2, _c;
5452
+ var _a2, _b2;
5453
+ const node = ((_a2 = edge == null ? void 0 : edge.node) == null ? void 0 : _a2.codeDiscount) || {};
4788
5454
  return {
4789
- id: String(((_a2 = edge == null ? void 0 : edge.node) == null ? void 0 : _a2.id) || "").split("/").pop(),
4790
- title: (_c = (_b2 = edge == null ? void 0 : edge.node) == null ? void 0 : _b2.codeDiscount) == null ? void 0 : _c.title
5455
+ // Null when the discount can be used, a sentence when it cannot.
5456
+ // The picker greys the row and shows this instead of hiding it:
5457
+ // a discount the merchant can see in Shopify admin, missing here
5458
+ // with no explanation, reads as a bug in us.
5459
+ blocked: blockedReason(node),
5460
+ id: String(((_b2 = edge == null ? void 0 : edge.node) == null ? void 0 : _b2.id) || "").split("/").pop(),
5461
+ // Usable, but not in the way the merchant probably expects.
5462
+ // Shown beside the row without stopping them.
5463
+ warning: discountWarning(node),
5464
+ title: node.title
4791
5465
  };
4792
5466
  }),
4793
5467
  pageInfo: {
@@ -4802,20 +5476,6 @@ var shopify_default2 = {
4802
5476
  },
4803
5477
  icon: shopify_default,
4804
5478
  inbound,
4805
- // THE DEEP LINK into this store's Drawbridge app inside Shopify admin.
4806
- //
4807
- // Here rather than in drawbridge-api, which had `slug === 'shopify' && {...}`
4808
- // in the shared resolver — a hardcoded vendor branch in code every vendor runs
4809
- // through, which is the arrangement these manifests exist to remove.
4810
- //
4811
- // Undefined until a shop is linked, so the Manage button only appears on a
4812
- // connected connection. The app handle is NAMED by `requires` and read from
4813
- // the env the resolver passes, never from process.env here.
4814
- manage: (data2, env) => {
4815
- var _a;
4816
- const shop = (data2 == null ? void 0 : data2.shop) || ((_a = data2 == null ? void 0 : data2.settings) == null ? void 0 : _a.domain);
4817
- return shop ? "https://admin.shopify.com/store/" + String(shop).replace(".myshopify.com", "") + "/apps/" + (env == null ? void 0 : env.SHOPIFY_APP_HANDLE) : void 0;
4818
- },
4819
5479
  // DRAWBRIDGE'S OWN CREDENTIALS for this vendor, as opposed to a merchant's —
4820
5480
  // what an admin types on the provider screen. The four names below are exactly
4821
5481
  // what `requires` gates on, which is the point of declaring them together: a
@@ -4861,6 +5521,14 @@ var shopify_default2 = {
4861
5521
  "SHOPIFY_APP_LISTING_URL",
4862
5522
  "SHOPIFY_APP_HANDLE"
4863
5523
  ],
5524
+ // THE CHECKLIST'S RECEIPT — see drawbridge-docs reference/connection-hooks.md.
5525
+ review: {
5526
+ api: "https://shopify.dev/docs/api/admin-graphql",
5527
+ dashboard: "https://help.shopify.com/en/manual/apps",
5528
+ scopes: "https://shopify.dev/docs/api/usage/access-scopes",
5529
+ content: "2026-09-11",
5530
+ verified: null
5531
+ },
4864
5532
  slug: "shopify",
4865
5533
  // The install is the whole configuration — Shopify hands back the shop and
4866
5534
  // there is nothing further to choose. `shop` absent means the install did not
@@ -4948,8 +5616,11 @@ var shopify_default2 = {
4948
5616
  })
4949
5617
  },
4950
5618
  // SYSTEM STEPS: dispatched by drawbridge-sync itself rather than offered
4951
- // in the builder, so they carry no trigger and no usage. Declared because
4952
- // the routing table and the system-workflow descriptions both read here.
5619
+ // in the builder, so they carry no usage. These two are fired by a webhook
5620
+ // arriving rather than by a workflow trigger, so they name none either —
5621
+ // and naming none is what stops a workflow being provisioned for them.
5622
+ // Declared because the routing table and the system-workflow descriptions
5623
+ // both read here.
4953
5624
  order: {
4954
5625
  record: () => ({
4955
5626
  description: "Records an order and billing charge when a purchase is made via a Drawbridge campaign link.",
@@ -4981,7 +5652,8 @@ var shopify_default2 = {
4981
5652
  hook: "lifecycle.health",
4982
5653
  key: "Shopify Connection Health",
4983
5654
  queue: "connection",
4984
- system: true
5655
+ system: true,
5656
+ trigger: { event: "day", type: "schedule" }
4985
5657
  })
4986
5658
  },
4987
5659
  // Audit-only. The "Shopify Token Activity" system workflow lists these
@@ -5042,7 +5714,30 @@ var shopify_default2 = {
5042
5714
  ] : []
5043
5715
  ];
5044
5716
  },
5045
- title: "Shopify"
5717
+ title: "Shopify",
5718
+ // THE VENDOR'S OWN ADMIN, one function per thing worth linking to. It lives
5719
+ // here rather than at the top level so a second link (a product, an order)
5720
+ // is a key in this object instead of a new manifest key nobody agreed on.
5721
+ //
5722
+ // AND HERE RATHER THAN IN drawbridge-api, which had `slug === 'shopify' &&
5723
+ // {...}` in the shared resolver — a hardcoded vendor branch in code every
5724
+ // vendor runs through, which is the arrangement these manifests exist to
5725
+ // remove.
5726
+ //
5727
+ // Never projected: the api composes connect.manage from it, and
5728
+ // resolveConnection drops the object, because a url built from settings is
5729
+ // built where the settings are already decrypted.
5730
+ urls: {
5731
+ // Undefined until a shop is linked, so the Manage button only appears on a
5732
+ // connected connection. The app handle is NAMED by `requires` and read from
5733
+ // the env its caller passes — the api's resolve() hands it the stored
5734
+ // credentials, never process.env.
5735
+ manage: (data2, env) => {
5736
+ var _a;
5737
+ const shop = (data2 == null ? void 0 : data2.shop) || ((_a = data2 == null ? void 0 : data2.settings) == null ? void 0 : _a.domain);
5738
+ return shop ? "https://admin.shopify.com/store/" + String(shop).replace(".myshopify.com", "") + "/apps/" + (env == null ? void 0 : env.SHOPIFY_APP_HANDLE) : void 0;
5739
+ }
5740
+ }
5046
5741
  };
5047
5742
 
5048
5743
  // lib/connections/providers/webhook.js
@@ -5222,7 +5917,7 @@ var webhook_default = {
5222
5917
  content: {
5223
5918
  confirm: "Disconnecting stops Drawbridge from sending signed webhook payloads to your endpoint.",
5224
5919
  description: [
5225
- "Drawbridge can POST event payloads to your endpoint as activity happens in your account, so your own systems can react in real time.",
5920
+ "Drawbridge can POST event payloads to your endpoint as activity happens in your account, so your own systems can react to it.",
5226
5921
  "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."
5227
5922
  ],
5228
5923
  excerpt: "Sign outgoing webhook payloads with an HMAC secret to verify authenticity.",
@@ -5323,6 +6018,9 @@ var webhook_default = {
5323
6018
  // Gated on the encryption secret: without it the signing secret could not be
5324
6019
  // stored safely, so the connection must not be offered at all.
5325
6020
  requires: ["ENCRYPT_CONNECTION_SECRET"],
6021
+ // NO THIRD PARTY AT ALL. There is no vendor reference to read, no dashboard
6022
+ // to link to and no scope to request: connecting mints a secret.
6023
+ review: false,
5326
6024
  // Outbound only. inbound.* is false because the direction is the point: we
5327
6025
  // sign and POST to the merchant's endpoint, they never call us. Every other
5328
6026
  // false follows from there being no third party to authenticate against —
@@ -5712,7 +6410,7 @@ var redactSettings = ({ slug: slug2, settings }) => {
5712
6410
  var publicConnectionKeys = Object.freeze([
5713
6411
  "actions",
5714
6412
  // API-COMPOSED, not manifest-declared: the api's resolve() builds it from
5715
- // auth.type, content.redirect and the manifest's manage() — the client reads
6413
+ // auth.type, content.redirect and the manifest's urls.manage() — the client reads
5716
6414
  // connect.type to choose entered-vs-installed, connect.redirect for the App
5717
6415
  // Store link, connect.manage for the admin deep link. It was dropped from
5718
6416
  // this list when the manifests stopped declaring it, which stripped the
@@ -5767,7 +6465,7 @@ var projectConnection = (record) => {
5767
6465
  var resolveConnection = (item, data2, env = {}) => {
5768
6466
  if (!item) return item;
5769
6467
  return Object.fromEntries(
5770
- Object.entries(item).filter(([key]) => !["auth", "enabled", "fields", "hooks", "inbound", "provider", "requires", "status", "steps", "supports"].includes(key)).map(([key, value]) => [
6468
+ Object.entries(item).filter(([key]) => !["auth", "enabled", "fields", "hooks", "inbound", "provider", "requires", "review", "status", "steps", "supports", "urls"].includes(key)).map(([key, value]) => [
5771
6469
  key,
5772
6470
  typeof value === "function" ? value(data2, env) : value
5773
6471
  ])