@drawbridge/drawbridge-utils 0.0.152 → 0.0.154

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.
@@ -1192,10 +1192,16 @@ var attentive = {
1192
1192
  // `redact` marks a secret — never returned by the api, and blank on save means
1193
1193
  // keep the stored value. `required` drives the live check.
1194
1194
  provider : {
1195
- fields : [
1196
- { input : 'text', key : 'clientId', credential : 'ATTENTIVE_OAUTH_CLIENT_ID', label : 'Client ID', message : 'From our app\'s registration in the Attentive developer portal.', required : true },
1197
- { input : 'password', key : 'clientSecret', credential : 'ATTENTIVE_OAUTH_CLIENT_SECRET', label : 'Client secret', message : 'Beside the Client ID in the Attentive developer portal.', redact : true, required : true }
1198
- ]
1195
+ vendors : {
1196
+ attentive : {
1197
+ fields : [
1198
+ { input : 'text', key : 'clientId', credential : 'ATTENTIVE_OAUTH_CLIENT_ID', label : 'Client ID', message : 'From our app\'s registration in the Attentive developer portal.', required : true },
1199
+ { input : 'password', key : 'clientSecret', credential : 'ATTENTIVE_OAUTH_CLIENT_SECRET', label : 'Client secret', message : 'Beside the Client ID in the Attentive developer portal.', redact : true, required : true }
1200
+ ],
1201
+ icon: icon$4,
1202
+ name : 'Attentive'
1203
+ }
1204
+ }
1199
1205
  },
1200
1206
  requires : [
1201
1207
  'ATTENTIVE_OAUTH_CLIENT_ID',
@@ -1591,6 +1597,60 @@ var icon$3 = `<svg width="500" height="500" viewBox="0 0 500 500" fill="none" xm
1591
1597
  </defs>
1592
1598
  </svg>`;
1593
1599
 
1600
+ // HubSpot's sprocket, drawn by hand on the vendor's orange rather than exported
1601
+ // from a brand kit — there was no export to hand. Replace with the kit's own
1602
+ // mark when one is available; the shape and the fill are the recognisable
1603
+ // parts and both are here.
1604
+ //
1605
+ // A .js wrapper around otherwise untouched SVG so `node --test` can run against
1606
+ // lib/ directly. A bare .svg import would need a bundler loader and force the
1607
+ // tests onto dist/, which is a worse trade than one line of wrapper.
1608
+ var hubspotIcon = `<svg width="500" height="500" viewBox="0 0 500 500" fill="none" xmlns="http://www.w3.org/2000/svg">
1609
+ <rect width="500" height="500" fill="#FF7A59"/>
1610
+ <circle cx="290" cy="290" r="78" stroke="white" stroke-width="30"/>
1611
+ <circle cx="290" cy="290" r="18" fill="white"/>
1612
+ <path d="M290 212V150" stroke="white" stroke-width="30" stroke-linecap="round"/>
1613
+ <circle cx="290" cy="125" r="28" fill="white"/>
1614
+ <path d="M270 137L172 96" stroke="white" stroke-width="22" stroke-linecap="round"/>
1615
+ <circle cx="160" cy="91" r="20" fill="white"/>
1616
+ <path d="M233 347L184 396" stroke="white" stroke-width="26" stroke-linecap="round"/>
1617
+ <circle cx="172" cy="408" r="22" fill="white"/>
1618
+ </svg>`;
1619
+
1620
+ // Sendgrid, exported from the brand kit and left as authored — the
1621
+ // fills are the vendor's own mark, not a recolour.
1622
+ //
1623
+ // A .js wrapper around otherwise untouched SVG so `node --test` can run against
1624
+ // lib/ directly. A bare .svg import would need a bundler loader and force the
1625
+ // tests onto dist/, which is a worse trade than one line of wrapper.
1626
+ var sendgridIcon = `<svg width="500" height="500" viewBox="0 0 500 500" fill="none" xmlns="http://www.w3.org/2000/svg">
1627
+ <rect width="500" height="500" fill="#F1FAFF"/>
1628
+ <g clip-path="url(#clip0_1011_2743)">
1629
+ <path d="M366.676 134.534V289.172H289.203V366.487H134.258L134.258 289.171L134.256 289.172V211.851H211.729V134.534H366.676Z" fill="#9DD6E3"/>
1630
+ <path d="M134.258 366.488H211.731V289.169H134.258V366.488Z" fill="#3F72AB"/>
1631
+ <path d="M289.203 289.172H366.677V211.852H289.203V289.172Z" fill="#00A9D1"/>
1632
+ <path d="M211.729 211.853H289.202V134.534H211.729V211.853Z" fill="#00A9D1"/>
1633
+ <path d="M211.729 289.17H289.202V211.852H211.729V289.17Z" fill="#2191C4"/>
1634
+ <path d="M289.203 211.853H366.677V134.534H289.203V211.853Z" fill="#3F72AB"/>
1635
+ </g>
1636
+ <defs>
1637
+ <clipPath id="clip0_1011_2743">
1638
+ <rect width="232.42" height="231.956" fill="white" transform="translate(134.256 134.534)"/>
1639
+ </clipPath>
1640
+ </defs>
1641
+ </svg>`;
1642
+
1643
+ // Twilio, exported from the brand kit and left as authored — the
1644
+ // fills are the vendor's own mark, not a recolour.
1645
+ //
1646
+ // A .js wrapper around otherwise untouched SVG so `node --test` can run against
1647
+ // lib/ directly. A bare .svg import would need a bundler loader and force the
1648
+ // tests onto dist/, which is a worse trade than one line of wrapper.
1649
+ var twilioIcon = `<svg width="500" height="500" viewBox="0 0 500 500" fill="none" xmlns="http://www.w3.org/2000/svg">
1650
+ <rect width="500" height="500" fill="#F22F46"/>
1651
+ <path d="M250 134.954C186.341 134.954 134.954 186.341 134.954 250C134.954 313.659 186.341 365.047 250 365.047C313.659 365.047 365.047 313.659 365.047 250C365.047 186.341 313.659 134.954 250 134.954ZM250 334.368C203.215 334.368 165.633 296.786 165.633 250C165.633 203.215 203.215 165.633 250 165.633C296.786 165.633 334.368 203.215 334.368 250C334.368 296.786 296.786 334.368 250 334.368ZM302.155 221.622C302.155 234.661 291.417 245.399 278.378 245.399C265.34 245.399 254.602 234.661 254.602 221.622C254.602 208.584 265.34 197.846 278.378 197.846C291.417 197.846 302.155 208.584 302.155 221.622ZM302.155 278.378C302.155 291.417 291.417 302.155 278.378 302.155C265.34 302.155 254.602 291.417 254.602 278.378C254.602 265.34 265.34 254.602 278.378 254.602C291.417 254.602 302.155 265.34 302.155 278.378ZM245.399 278.378C245.399 291.417 234.661 302.155 221.622 302.155C208.584 302.155 197.846 291.417 197.846 278.378C197.846 265.34 208.584 254.602 221.622 254.602C234.661 254.602 245.399 265.34 245.399 278.378ZM245.399 221.622C245.399 234.661 234.661 245.399 221.622 245.399C208.584 245.399 197.846 234.661 197.846 221.622C197.846 208.584 208.584 197.846 221.622 197.846C234.661 197.846 245.399 208.584 245.399 221.622Z" fill="white"/>
1652
+ </svg>`;
1653
+
1594
1654
  // TWILIO'S OWN KEYWORD LISTS. STOP-family withdraws consent for the number —
1595
1655
  // platform-wide, because every organization sends from the same platform number,
1596
1656
  // so a withdrawal cannot be scoped narrower than the number it was sent to.
@@ -2396,37 +2456,56 @@ var drawbridge = {
2396
2456
  //
2397
2457
  // They belong on THIS manifest because this is the connection that sends: the
2398
2458
  // email, sms and segment hooks below are the only things that spend them, and
2399
- // a private connection is still where a vendor fact lives.
2459
+ // a private connection is still where a vendor fact lives. They are THREE
2460
+ // VENDORS, not one, and each is its own row and its own admin card — so
2461
+ // SendGrid reads live on a deployment that never configured Twilio, instead
2462
+ // of one card for all three that could only ever be as live as its weakest.
2400
2463
  //
2401
2464
  // UNLIKE every public vendor, none of these appear in `requires` — see the
2402
2465
  // comment there. Availability and configuration are different questions, and a
2403
2466
  // missing CRM token must not take every base workflow step away.
2467
+ //
2468
+ // ponytail: the field keys keep the names they had on the shared row
2469
+ // (smsSid, hubspotToken) so the readers destructuring vendorSettings() did
2470
+ // not move. Rename them to sid/token when those readers are next touched.
2404
2471
  provider : {
2405
- fields : [
2406
- { input : 'email', key : 'accountSender', credential : 'SENDGRID_FROM_ADDRESS', label : 'Account sender', message : 'Verification codes and security alerts send from here.', required : true },
2407
- { input : 'password', key : 'apiKey', credential : 'SENDGRID_API_KEY', label : 'SendGrid API key', message : 'SendGrid dashboard, Settings, API Keys — full access for sends.', redact : true, required : true },
2408
- // NOT required. The CRM sync is best-effort internal tooling and no-ops
2409
- // without a tokenrequiring it would make the whole drawbridge provider
2410
- // read not-live over something no merchant ever sees.
2411
- { input : 'password', key : 'hubspotToken', credential : 'HUBSPOT_ACCESS_TOKEN', label : 'HubSpot access token', message : 'Drawbridge\'s own CRM portal. Internal — no merchant sees this.', redact : true },
2412
- // Optional: SENDGRID_SEND_FROM_ADDRESS is not boot-required in sync
2413
- // either. Unset, it degrades to the account sender rather than
2414
- // refusing to start.
2415
- { input : 'email', key : 'leadSender', credential : 'SENDGRID_SEND_FROM_ADDRESS', label : 'Lead sender', message : 'The default for lead-facing mail when a merchant has not verified their own domain.' },
2416
- // NOT required, the three of them together. SendGrid alone is enough to
2417
- // run the platform — sign-in codes, notifications and every lead-facing
2418
- // mail are email. Requiring Twilio here made the whole drawbridge
2419
- // provider read not-live on a deployment that never sends SMS, over a
2420
- // channel it was not using.
2421
- //
2472
+ vendors : {
2473
+ sendgrid : {
2474
+ fields : [
2475
+ { input : 'email', key : 'accountSender', credential : 'SENDGRID_FROM_ADDRESS', label : 'Account sender', message : 'Verification codes and security alerts send from here.', required : true },
2476
+ { input : 'password', key : 'apiKey', credential : 'SENDGRID_API_KEY', label : 'SendGrid API key', message : 'SendGrid dashboard, Settings, API Keys full access for sends.', redact : true, required : true },
2477
+ // Optional: SENDGRID_SEND_FROM_ADDRESS is not boot-required in sync
2478
+ // either. Unset, it degrades to the account sender rather than
2479
+ // refusing to start.
2480
+ { input : 'email', key : 'leadSender', credential : 'SENDGRID_SEND_FROM_ADDRESS', label : 'Lead sender', message : 'The default for lead-facing mail when a merchant has not verified their own domain.' }
2481
+ ],
2482
+ icon : sendgridIcon,
2483
+ name : 'SendGrid'
2484
+ },
2422
2485
  // Missing, SMS is LOCKED DOWN rather than broken: every send path
2423
2486
  // refuses cleanly (queue/notification.js cancels, the otc stream skips
2424
2487
  // and logs), the number-purchase routes deny, and identityDefaults.sms
2425
- // hides the org's SMS settings entirely.
2426
- { input : 'text', key : 'smsFrom', credential : 'TWILIO_ACCOUNT_FROM', label : 'SMS number', message : 'Without Twilio credentials, SMS is disabled across the platform.' },
2427
- { input : 'password', key : 'smsSid', credential : 'TWILIO_ACCOUNT_SID', label : 'Twilio account SID', message : 'Twilio console home — the AC… identifier on the account dashboard.', redact : true },
2428
- { input : 'password', key : 'smsToken', credential : 'TWILIO_AUTH_TOKEN', label : 'Twilio auth token', message : 'Beside the account SID on the Twilio console dashboard.', redact : true }
2429
- ]
2488
+ // hides the org's SMS settings entirely. The card reads not live, which
2489
+ // is the truth about Twilio and says nothing about email.
2490
+ twilio : {
2491
+ fields : [
2492
+ { input : 'text', key : 'smsFrom', credential : 'TWILIO_ACCOUNT_FROM', label : 'SMS number', message : 'Without Twilio credentials, SMS is disabled across the platform.', required : true },
2493
+ { input : 'password', key : 'smsSid', credential : 'TWILIO_ACCOUNT_SID', label : 'Twilio account SID', message : 'Twilio console home — the AC… identifier on the account dashboard.', redact : true, required : true },
2494
+ { input : 'password', key : 'smsToken', credential : 'TWILIO_AUTH_TOKEN', label : 'Twilio auth token', message : 'Beside the account SID on the Twilio console dashboard.', redact : true, required : true }
2495
+ ],
2496
+ icon : twilioIcon,
2497
+ name : 'Twilio'
2498
+ },
2499
+ // The CRM sync is best-effort internal tooling and no-ops without a
2500
+ // token. Not live here costs nothing a merchant can see.
2501
+ hubspot : {
2502
+ fields : [
2503
+ { input : 'password', key : 'hubspotToken', credential : 'HUBSPOT_ACCESS_TOKEN', label : 'HubSpot access token', message : 'Drawbridge\'s own CRM portal. Internal — no merchant sees this.', redact : true, required : true }
2504
+ ],
2505
+ icon : hubspotIcon,
2506
+ name : 'HubSpot'
2507
+ }
2508
+ }
2430
2509
  },
2431
2510
  // NOTHING, and HUBSPOT_ACCESS_TOKEN in particular must not be here.
2432
2511
  //
@@ -3176,12 +3255,20 @@ var klaviyo = {
3176
3255
  // DRAWBRIDGE'S OWN CREDENTIALS for this vendor, as opposed to a merchant's —
3177
3256
  // what an admin types on the provider screen. Declared here rather than in a
3178
3257
  // table in lib/providers.js, so a vendor's credentials sit beside the
3179
- // `requires` that names the same variables.
3258
+ // `requires` that names the same variables. Keyed by the VENDOR that holds
3259
+ // them — here the vendor and the connection are the same thing, which is not
3260
+ // true of every manifest.
3180
3261
  provider : {
3181
- fields : [
3182
- { input : 'text', key : 'clientId', credential : 'KLAVIYO_OAUTH_CLIENT_ID', label : 'Client ID', message : 'From our app in the Klaviyo developer portal (developers.klaviyo.com).', required : true },
3183
- { input : 'password', key : 'clientSecret', credential : 'KLAVIYO_OAUTH_CLIENT_SECRET', label : 'Client secret', message : 'Beside the Client ID on the Klaviyo app.', redact : true, required : true }
3184
- ]
3262
+ vendors : {
3263
+ klaviyo : {
3264
+ fields : [
3265
+ { input : 'text', key : 'clientId', credential : 'KLAVIYO_OAUTH_CLIENT_ID', label : 'Client ID', message : 'From our app in the Klaviyo developer portal (developers.klaviyo.com).', required : true },
3266
+ { input : 'password', key : 'clientSecret', credential : 'KLAVIYO_OAUTH_CLIENT_SECRET', label : 'Client secret', message : 'Beside the Client ID on the Klaviyo app.', redact : true, required : true }
3267
+ ],
3268
+ icon: icon$2,
3269
+ name : 'Klaviyo'
3270
+ }
3271
+ }
3185
3272
  },
3186
3273
  requires : [
3187
3274
  'KLAVIYO_OAUTH_CLIENT_ID',
@@ -3642,10 +3729,16 @@ var mailchimp = {
3642
3729
  // what an admin types on the provider screen, beside the `requires` naming the
3643
3730
  // same variables.
3644
3731
  provider : {
3645
- fields : [
3646
- { input : 'text', key : 'clientId', credential : 'MAILCHIMP_OAUTH_CLIENT_ID', label : 'Client ID', message : 'From our registered app — Mailchimp account, Extras, Registered apps.', required : true },
3647
- { input : 'password', key : 'clientSecret', credential : 'MAILCHIMP_OAUTH_CLIENT_SECRET', label : 'Client secret', message : 'Beside the Client ID on the registered app.', redact : true, required : true }
3648
- ]
3732
+ vendors : {
3733
+ mailchimp : {
3734
+ fields : [
3735
+ { input : 'text', key : 'clientId', credential : 'MAILCHIMP_OAUTH_CLIENT_ID', label : 'Client ID', message : 'From our registered app — Mailchimp account, Extras, Registered apps.', required : true },
3736
+ { input : 'password', key : 'clientSecret', credential : 'MAILCHIMP_OAUTH_CLIENT_SECRET', label : 'Client secret', message : 'Beside the Client ID on the registered app.', redact : true, required : true }
3737
+ ],
3738
+ icon: icon$1,
3739
+ name : 'Mailchimp'
3740
+ }
3741
+ }
3649
3742
  },
3650
3743
  // The OAuth client this deployment registered. Without both, the vendor drops
3651
3744
  // out of availableConnections rather than offering a Connect button that
@@ -4735,7 +4828,9 @@ var shopify = {
4735
4828
  enqueues : [ {
4736
4829
  data : { product : productId, providerId, shop : connection.shop },
4737
4830
  name : 'workflow',
4738
- options : { jobId : 'product.workflow.shopify.' + providerId + '.' + Date.now() },
4831
+ // The numeric id, not the gid: BullMQ refuses a custom id with a
4832
+ // colon in it, and every gid carries two.
4833
+ options : { jobId : 'product.workflow.shopify.' + context.id + '.' + Date.now() },
4739
4834
  queue : 'product.shopify'
4740
4835
  } ],
4741
4836
  message : 'Product sync queued from Shopify webhook.',
@@ -5431,28 +5526,34 @@ var shopify = {
5431
5526
  // name required by the manifest and enterable nowhere is a vendor that can
5432
5527
  // never go live from the admin screen.
5433
5528
  provider : {
5434
- fields : [
5435
- { input : 'text', key : 'apiKey', credential : 'SHOPIFY_API_KEY', label : 'API key', message : 'The app\'s Client ID — Dev Dashboard, the app, Settings.', required : true },
5436
- { input : 'password', key : 'apiSecret', credential : 'SHOPIFY_API_SECRET', label : 'API secret', message : 'The app\'s Client secret, beside the Client ID in the app\'s settings.', redact : true, required : true },
5437
- { input : 'text', key : 'appHandle', credential : 'SHOPIFY_APP_HANDLE', label : 'App handle', message : 'The app\'s URL handle (for example drawbridge-development), from the app\'s configuration.', required : true },
5438
- { input : 'text', key : 'listingUrl', credential : 'SHOPIFY_APP_LISTING_URL', label : 'App listing URL', message : 'Where "View on the Shopify App Store" sends merchants — the public listing, or the Dev Dashboard install link for the dev app.', required : true },
5439
- // The usage meter's event handle, when the plan config's meter ever
5440
- // changes: stored value overrides the built-in default
5441
- // (events.order.handle) at the mint point, and `format : 'slug'`
5442
- // normalizes it on save a handle can carry no spaces or capitals,
5443
- // and classification against it is case-sensitive. Optional: empty
5444
- // means the default, and the sender still refuses any handle that
5445
- // disagrees with the transaction it minted.
5446
- { format : 'slug', input : 'text', key : 'orderEventHandle', label : 'Order event handle', message : 'Must match the usage meter\'s Handle field on the plan exactly — lowercase and hyphens. Leave empty to use drawbridge-orders.', required : false, setting : true },
5447
- // The Partner API credential set — the ONE place meter billing is
5448
- // observable (CHARGE_USAGE accrual events). Org id and numeric app
5449
- // id come from the Partner Dashboard; the token from Settings
5450
- // Partner API clients (Manage-apps permission). All optional: the
5451
- // accrual probe simply stays off until they exist.
5452
- { input : 'text', key : 'partnerOrgId', label : 'Partner organization ID', message : 'The number in the Partner Dashboard URL — partners.shopify.com/<this number>/… NOT the admin organization_id from the app listing link.', required : false, setting : true },
5453
- { input : 'text', key : 'partnerAppId', label : 'Partner app ID (numeric)', message : 'The numeric id in the app\'s Partner Dashboard URL — not the Client ID.', required : false, setting : true },
5454
- { input : 'password', key : 'partnerToken', label : 'Partner API token', message : 'Partner Dashboard, Settings, Partner API clientscreate one with Manage apps and paste the prtapi_ token.', redact : true, required : false, setting : true }
5455
- ]
5529
+ vendors : {
5530
+ shopify : {
5531
+ fields : [
5532
+ { input : 'text', key : 'apiKey', credential : 'SHOPIFY_API_KEY', label : 'API key', message : 'The app\'s Client ID Dev Dashboard, the app, Settings.', required : true },
5533
+ { input : 'password', key : 'apiSecret', credential : 'SHOPIFY_API_SECRET', label : 'API secret', message : 'The app\'s Client secret, beside the Client ID in the app\'s settings.', redact : true, required : true },
5534
+ { input : 'text', key : 'appHandle', credential : 'SHOPIFY_APP_HANDLE', label : 'App handle', message : 'The app\'s URL handle (for example drawbridge-development), from the app\'s configuration.', required : true },
5535
+ { input : 'text', key : 'listingUrl', credential : 'SHOPIFY_APP_LISTING_URL', label : 'App listing URL', message : 'Where "View on the Shopify App Store" sends merchants — the public listing, or the Dev Dashboard install link for the dev app.', required : true },
5536
+ // The usage meter's event handle, when the plan config's meter ever
5537
+ // changes: stored value overrides the built-in default
5538
+ // (events.order.handle) at the mint point, and `format : 'slug'`
5539
+ // normalizes it on save a handle can carry no spaces or capitals,
5540
+ // and classification against it is case-sensitive. Optional: empty
5541
+ // means the default, and the sender still refuses any handle that
5542
+ // disagrees with the transaction it minted.
5543
+ { format : 'slug', input : 'text', key : 'orderEventHandle', label : 'Order event handle', message : 'Must match the usage meter\'s Handle field on the plan exactly — lowercase and hyphens. Leave empty to use drawbridge-orders.', required : false, setting : true },
5544
+ // The Partner API credential set the ONE place meter billing is
5545
+ // observable (CHARGE_USAGE accrual events). Org id and numeric app
5546
+ // id come from the Partner Dashboard; the token from Settings →
5547
+ // Partner API clients (Manage-apps permission). All optional: the
5548
+ // accrual probe simply stays off until they exist.
5549
+ { input : 'text', key : 'partnerOrgId', label : 'Partner organization ID', message : 'The number in the Partner Dashboard URLpartners.shopify.com/<this number>/… NOT the admin organization_id from the app listing link.', required : false, setting : true },
5550
+ { input : 'text', key : 'partnerAppId', label : 'Partner app ID (numeric)', message : 'The numeric id in the app\'s Partner Dashboard URL — not the Client ID.', required : false, setting : true },
5551
+ { input : 'password', key : 'partnerToken', label : 'Partner API token', message : 'Partner Dashboard, Settings, Partner API clients — create one with Manage apps and paste the prtapi_ token.', redact : true, required : false, setting : true }
5552
+ ],
5553
+ icon,
5554
+ name : 'Shopify'
5555
+ }
5556
+ }
5456
5557
  },
5457
5558
  // A pre-launch integration: it only surfaces once the App Store listing
5458
5559
  // exists and the app is fully configured. Requiring all four means it can
@@ -5881,6 +5982,34 @@ const leaves = ( node, path = [] ) => Object.entries( node || {} ).flatMap(
5881
5982
  )
5882
5983
  );
5883
5984
 
5985
+ // Checked for the three things that actually break a card:
5986
+ // it must be an svg a filename here means the file is elsewhere again
5987
+ // it must carry a viewBox without one it will not scale into the 50px tile
5988
+ // it must not wrap a raster Figma exports a placed bitmap inside an <svg>
5989
+ // shell, which looks like a vector, weighs 90KB and
5990
+ // blurs exactly like the png it actually is
5991
+ const checkIcon = ( owner, icon ) => {
5992
+
5993
+ if( typeof icon !== 'string' || ! icon.includes( '<svg' ) ){
5994
+
5995
+ throw new Error( owner + ' needs an icon — the svg markup itself, not a path to one' );
5996
+
5997
+ }
5998
+
5999
+ if( ! icon.includes( 'viewBox' ) ){
6000
+
6001
+ throw new Error( owner + ' icon has no viewBox, so it cannot scale' );
6002
+
6003
+ }
6004
+
6005
+ if( icon.includes( '<image' ) ){
6006
+
6007
+ throw new Error( owner + ' icon wraps a raster — re-export it as vector shapes' );
6008
+
6009
+ }
6010
+
6011
+ };
6012
+
5884
6013
  // WHAT A CONNECTION MUST DECLARE. Thrown at import rather than discovered by a
5885
6014
  // merchant looking at a broken card, or by a workflow that accepted a step it
5886
6015
  // could never run.
@@ -5980,9 +6109,18 @@ const build = ( manifest ) => {
5980
6109
 
5981
6110
  }
5982
6111
 
5983
- // DRAWBRIDGE'S OWN CREDENTIALS for this vendor, if it has any. A connection
5984
- // with no third party behind it — webhook — declares no block at all, which is
5985
- // what keeps it off the provider screen.
6112
+ // DRAWBRIDGE'S OWN CREDENTIALS, declared under the VENDOR that holds them.
6113
+ //
6114
+ // A provider is a vendor Drawbridge has an account with; a connection is a
6115
+ // thing a merchant turns on. They are not one-to-one in either direction:
6116
+ // `drawbridge` spends SendGrid, Twilio and HubSpot, and a future Google row
6117
+ // would be spent by analytics, geocoding and whatever comes after. So a
6118
+ // manifest declares the fields IT spends, subkeyed by vendor, and mergeVendors
6119
+ // below unions every manifest's declarations into one vendor each. Nobody
6120
+ // owns a vendor — removing a manifest removes its fields and nothing else.
6121
+ //
6122
+ // A connection with no third party behind it — webhook — declares no block at
6123
+ // all, which is what keeps it off the provider screen.
5986
6124
  //
5987
6125
  // Every field is checked harder than a merchant field: it must be editable
5988
6126
  // (an admin cannot type into a read-only descriptor, and a credential nobody
@@ -5991,56 +6129,69 @@ const build = ( manifest ) => {
5991
6129
  // providerFields is what the api's redaction derives from, so a password field
5992
6130
  // that forgot `redact : true` is a platform secret handed back over the wire
5993
6131
  // to every admin screen that asks.
5994
- for( const field of manifest.provider?.fields || [] ){
6132
+ if( manifest.provider?.fields ){
5995
6133
 
5996
- if( ! field?.key || ! field?.label ){
6134
+ throw new Error( manifest.slug + ' declares provider.fields — fields live under provider.vendors.<vendor> now, keyed by the vendor that holds them' );
5997
6135
 
5998
- throw new Error( manifest.slug + ' declares a provider field with no key or label' );
6136
+ }
5999
6137
 
6000
- }
6138
+ const declaredKeys = new Set();
6001
6139
 
6002
- if( ! INPUTS.includes( field.input ) ){
6140
+ for( const [ vendor, declared ] of Object.entries( manifest.provider?.vendors || {} ) ){
6003
6141
 
6004
- throw new Error( manifest.slug + '.provider.' + field.key + ' needs an input the admin form can render — one of ' + INPUTS.join( ', ' ) );
6142
+ if( ! declared?.name ) throw new Error( manifest.slug + ' declares vendor ' + vendor + ' with no name' );
6005
6143
 
6006
- }
6144
+ // The admin card shows the vendor's own mark, which is not always the
6145
+ // connection's — SendGrid's card is not the Drawbridge logo.
6146
+ checkIcon( manifest.slug + ' vendor ' + vendor, declared.icon );
6007
6147
 
6008
- if( field.input === 'password' && ! field.redact ){
6148
+ if( ! Array.isArray( declared.fields ) || ! declared.fields.length ){
6009
6149
 
6010
- throw new Error( manifest.slug + '.provider.' + field.key + ' is a password and must declare redact : true the api would hand the value back' );
6150
+ throw new Error( manifest.slug + ' declares vendor ' + vendor + ' with no fields a vendor nothing is typed into holds nothing' );
6011
6151
 
6012
6152
  }
6013
6153
 
6014
- }
6154
+ for( const field of declared.fields ){
6015
6155
 
6016
- // THE ICON RIDES WITH THE MANIFEST, so a vendor cannot name an asset nobody
6017
- // added — which is what the old arrangement allowed, with the markup in one
6018
- // repo and the file in another.
6019
- //
6020
- // Checked for the three things that actually break a card:
6021
- // it must be an svg a filename here means the file is elsewhere again
6022
- // it must carry a viewBox without one it will not scale into the 50px tile
6023
- // it must not wrap a raster Figma exports a placed bitmap inside an <svg>
6024
- // shell, which looks like a vector, weighs 90KB and
6025
- // blurs exactly like the png it actually is
6026
- if( typeof manifest?.icon !== 'string' || ! manifest.icon.includes( '<svg' ) ){
6156
+ if( ! field?.key || ! field?.label ){
6027
6157
 
6028
- throw new Error( manifest.slug + ' needs an icon the svg markup itself, not a path to one' );
6158
+ throw new Error( manifest.slug + ' declares a provider field with no key or label' );
6029
6159
 
6030
- }
6160
+ }
6031
6161
 
6032
- if( ! manifest.icon.includes( 'viewBox' ) ){
6162
+ if( ! INPUTS.includes( field.input ) ){
6033
6163
 
6034
- throw new Error( manifest.slug + ' icon has no viewBox, so it cannot scale' );
6164
+ throw new Error( manifest.slug + '.provider.' + field.key + ' needs an input the admin form can render — one of ' + INPUTS.join( ', ' ) );
6035
6165
 
6036
- }
6166
+ }
6167
+
6168
+ if( field.input === 'password' && ! field.redact ){
6169
+
6170
+ throw new Error( manifest.slug + '.provider.' + field.key + ' is a password and must declare redact : true — the api would hand the value back' );
6171
+
6172
+ }
6173
+
6174
+ // ONE KEY PER CONNECTION across its vendors. vendorSettings() hands a
6175
+ // connection every vendor's settings merged into one object, so two
6176
+ // vendors on one manifest sharing a key would be one value silently
6177
+ // winning over the other.
6178
+ if( declaredKeys.has( field.key ) ){
6179
+
6180
+ throw new Error( manifest.slug + ' declares ' + field.key + ' under two vendors — vendorSettings() merges them and one would win' );
6181
+
6182
+ }
6037
6183
 
6038
- if( manifest.icon.includes( '<image' ) ){
6184
+ declaredKeys.add( field.key );
6039
6185
 
6040
- throw new Error( manifest.slug + ' icon wraps a raster — re-export it as vector shapes' );
6186
+ }
6041
6187
 
6042
6188
  }
6043
6189
 
6190
+ // THE ICON RIDES WITH THE MANIFEST, so a vendor cannot name an asset nobody
6191
+ // added — which is what the old arrangement allowed, with the markup in one
6192
+ // repo and the file in another.
6193
+ checkIcon( manifest.slug, manifest?.icon );
6194
+
6044
6195
  // `group` does the actual grouping on the connections page, and `category`
6045
6196
  // was a second word for the same fact — so it is gone rather than kept as an
6046
6197
  // alias nobody could tell apart from this one.
@@ -6317,6 +6468,96 @@ const connections = Object.freeze({
6317
6468
  webhook : build( webhook )
6318
6469
  });
6319
6470
 
6471
+ // A field declaration, with its keys in a fixed order, so two manifests that
6472
+ // declare the same field can be compared as strings whatever order they wrote
6473
+ // the keys in.
6474
+ const canonical = ( field ) => JSON.stringify( Object.fromEntries( Object.entries( field ).sort() ) );
6475
+
6476
+ // DRAWBRIDGE'S OWN VENDOR ACCOUNTS, one entry per vendor, unioned from every
6477
+ // manifest that spends one. This is what the provider screen lists and what
6478
+ // the `provider` collection is keyed by: one row per key here.
6479
+ //
6480
+ // Exported as a function over a catalog, and not only as the merged constant,
6481
+ // so the guards can be exercised against a catalog that breaks them — the real
6482
+ // one is built to pass.
6483
+ //
6484
+ // THREE GUARDS, and each one is a way two files could disagree about one fact:
6485
+ // the vendor's name and icon the same vendor drawn two ways is two cards
6486
+ // a field two manifests both the same key declared differently is a form
6487
+ // declare that renders whichever manifest loaded last
6488
+ // a credential name the join between `requires` and a row — two
6489
+ // fields answering one name is one value silently
6490
+ // winning, which is exactly the drift a row per
6491
+ // vendor exists to end
6492
+ const mergeVendors = ( catalog ) => {
6493
+
6494
+ const merged = {};
6495
+ const claimed = new Map();
6496
+
6497
+ for( const [ slug, manifest ] of Object.entries( catalog ) ){
6498
+
6499
+ for( const [ vendor, declared ] of Object.entries( manifest.provider?.vendors || {} ) ){
6500
+
6501
+ const held = merged[ vendor ] || ( merged[ vendor ] = { fields : [], icon : declared.icon, name : declared.name } );
6502
+
6503
+ if( held.name !== declared.name ){
6504
+
6505
+ throw new Error( slug + ' names vendor ' + vendor + ' "' + declared.name + '" but another manifest names it "' + held.name + '"' );
6506
+
6507
+ }
6508
+
6509
+ if( held.icon !== declared.icon ){
6510
+
6511
+ throw new Error( slug + ' declares a different icon for vendor ' + vendor + ' than another manifest — one vendor, one mark' );
6512
+
6513
+ }
6514
+
6515
+ for( const field of declared.fields ){
6516
+
6517
+ const existing = held.fields.find( ( entry ) => entry.key === field.key );
6518
+
6519
+ if( existing ){
6520
+
6521
+ if( canonical( existing ) !== canonical( field ) ){
6522
+
6523
+ throw new Error( slug + ' declares ' + vendor + '.' + field.key + ' differently from another manifest — a field two connections spend is declared identically in both' );
6524
+
6525
+ }
6526
+
6527
+ continue;
6528
+
6529
+ }
6530
+
6531
+ if( field.credential ){
6532
+
6533
+ const owner = claimed.get( field.credential );
6534
+
6535
+ if( owner ){
6536
+
6537
+ throw new Error( field.credential + ' is claimed by both ' + owner + ' and ' + vendor + '.' + field.key + ' — one would silently overwrite the other' );
6538
+
6539
+ }
6540
+
6541
+ claimed.set( field.credential, vendor + '.' + field.key );
6542
+
6543
+ }
6544
+
6545
+ held.fields.push( field );
6546
+
6547
+ }
6548
+
6549
+ }
6550
+
6551
+ }
6552
+
6553
+ return Object.freeze( Object.fromEntries(
6554
+ Object.entries( merged ).map( ( [ vendor, held ] ) => [ vendor, Object.freeze({ ...held, fields : Object.freeze( held.fields ) }) ] )
6555
+ ) );
6556
+
6557
+ };
6558
+
6559
+ const vendors = mergeVendors( connections );
6560
+
6320
6561
  // A STEP TYPE MAY BE SHARED, BUT NOT ITS QUEUE.
6321
6562
  //
6322
6563
  // A step type belongs to the CAPABILITY rather than to whoever implements it —
@@ -6719,4 +6960,4 @@ const resolveConnection = ( item, data, env = {} ) => {
6719
6960
 
6720
6961
  };
6721
6962
 
6722
- export { AUTH_TYPES, GROUPS, HOOKS, HOOK_EFFECTS, HOOK_NAMES, HOOK_OPTIONS, HOOK_PROPS, INPUTS, OAUTH_FIELDS, OUTCOMES, RETIRED, STATUSES, STEPS, STEP_TYPES, WRITE_OPERATIONS, accessToken, authToken, availableConnections, build, catalogConnections, connectFields, connectionSteps, connections, effectsOf, hookSupport, isStale, mergeSettings, projectConnection, publicConnectionKeys, publicSettingsBySlug, redactSettings, resolveConnection, runHook, scopesMessage, stepLabels, stepQueues, stepRoutes, tokenSettings };
6963
+ export { AUTH_TYPES, GROUPS, HOOKS, HOOK_EFFECTS, HOOK_NAMES, HOOK_OPTIONS, HOOK_PROPS, INPUTS, OAUTH_FIELDS, OUTCOMES, RETIRED, STATUSES, STEPS, STEP_TYPES, WRITE_OPERATIONS, accessToken, authToken, availableConnections, build, catalogConnections, connectFields, connectionSteps, connections, effectsOf, hookSupport, isStale, mergeSettings, mergeVendors, projectConnection, publicConnectionKeys, publicSettingsBySlug, redactSettings, resolveConnection, runHook, scopesMessage, stepLabels, stepQueues, stepRoutes, tokenSettings, vendors };