@drawbridge/drawbridge-utils 0.0.121 → 0.0.124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connections/index.cjs +447 -127
- package/dist/connections/index.d.cts +605 -137
- package/dist/connections/index.d.ts +605 -137
- package/dist/connections/index.js +440 -120
- package/dist/providers.cjs +452 -164
- package/dist/providers.d.cts +40 -60
- package/dist/providers.d.ts +40 -60
- package/dist/providers.js +445 -157
- package/package.json +1 -1
|
@@ -468,7 +468,47 @@ var attentive_default = `<svg width="500" height="500" viewBox="0 0 500 500" fil
|
|
|
468
468
|
<path d="M166.04 261.805C180.228 259.107 195.528 261.893 207.581 269.971C218.512 277.079 226.908 288.136 230.604 300.657C234.835 314.103 233.614 329.124 227.485 341.788C220.097 356.875 205.782 368.543 189.317 372.089C173.957 375.652 157.089 372.386 144.304 363.103C132.971 355.295 124.912 342.989 121.891 329.581C118.943 316.636 120.725 302.656 127.002 290.938C134.699 275.951 149.503 264.933 166.046 261.811" fill="#1E1C1C"/>
|
|
469
469
|
</svg>`;
|
|
470
470
|
|
|
471
|
+
// lib/phone.js
|
|
472
|
+
import { AsYouType, parsePhoneNumberFromString, isValidPhoneNumber } from "libphonenumber-js";
|
|
473
|
+
var toE164 = (value, country) => {
|
|
474
|
+
if (!value) return null;
|
|
475
|
+
try {
|
|
476
|
+
const parsed = parsePhoneNumberFromString(String(value), country);
|
|
477
|
+
return parsed ? parsed.number : null;
|
|
478
|
+
} catch {
|
|
479
|
+
return null;
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
var detectCountry = (value) => {
|
|
483
|
+
if (!value) return null;
|
|
484
|
+
try {
|
|
485
|
+
const parser = new AsYouType();
|
|
486
|
+
parser.input(String(value));
|
|
487
|
+
return parser.getCountry() || null;
|
|
488
|
+
} catch {
|
|
489
|
+
return null;
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
|
|
471
493
|
// lib/connections/providers/attentive.js
|
|
494
|
+
var api = async (path, { fetcher = fetch, method = "GET", payload, token }) => {
|
|
495
|
+
const response = await fetcher("https://api.attentivemobile.com" + path, {
|
|
496
|
+
...payload && { body: JSON.stringify(payload) },
|
|
497
|
+
headers: {
|
|
498
|
+
authorization: "Bearer " + token,
|
|
499
|
+
...payload && { "content-type": "application/json" }
|
|
500
|
+
},
|
|
501
|
+
method,
|
|
502
|
+
signal: AbortSignal.timeout(15e3)
|
|
503
|
+
});
|
|
504
|
+
if (!response.ok) {
|
|
505
|
+
throw Object.assign(
|
|
506
|
+
new Error("Attentive refused the request (" + response.status + ")"),
|
|
507
|
+
{ status: response.status }
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
return response.json().catch(() => null);
|
|
511
|
+
};
|
|
472
512
|
var attentive_default2 = {
|
|
473
513
|
auth: {
|
|
474
514
|
oauth: {
|
|
@@ -502,9 +542,10 @@ var attentive_default2 = {
|
|
|
502
542
|
// has to say so rather than let them believe otherwise.
|
|
503
543
|
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.",
|
|
504
544
|
description: [
|
|
505
|
-
"Attentive is where your SMS marketing lives, and this connection
|
|
545
|
+
"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.",
|
|
506
546
|
"You authorize Drawbridge from inside Attentive and can revoke that access there at any time. Drawbridge never sees or stores your Attentive password.",
|
|
507
|
-
"
|
|
547
|
+
"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.",
|
|
548
|
+
"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."
|
|
508
549
|
],
|
|
509
550
|
excerpt: "Sync your Drawbridge contacts into an Attentive segment.",
|
|
510
551
|
guide: [
|
|
@@ -525,6 +566,10 @@ var attentive_default2 = {
|
|
|
525
566
|
message: "Contacts your campaigns collect are synced into this segment.",
|
|
526
567
|
hook: "resources.audiences",
|
|
527
568
|
required: true
|
|
569
|
+
// CONSUMED BY THE MEMBERSHIP CALL, not by the subscribe. Attentive's
|
|
570
|
+
// /v1/subscriptions takes no segment id — subscription and segment
|
|
571
|
+
// membership are two operations here — so contacts.sync makes both calls
|
|
572
|
+
// and this value is the externalId the second one carries.
|
|
528
573
|
// No `search : false` here, and that is a first: /v2/segments takes a
|
|
529
574
|
// `name` filter (partial match, cited above), so this picker searches
|
|
530
575
|
// the ACCOUNT — Klaviyo and Mailchimp can only match the fetched page.
|
|
@@ -537,17 +582,25 @@ var attentive_default2 = {
|
|
|
537
582
|
// and contacts.sync are the first to flip.
|
|
538
583
|
hooks: {
|
|
539
584
|
auth: {
|
|
540
|
-
// The exchange already yields the tokens, and Attentive documents no
|
|
541
|
-
// account-identity endpoint to enrich them with — Klaviyo's connect
|
|
542
|
-
// reads the account name back; this has nothing cited to read. The
|
|
543
|
-
// callback stores the tokens and skips enrichment on `unimplemented`.
|
|
544
585
|
// FALSE, NOT {}. `{}` means "supported, implemented in the repo with the
|
|
545
|
-
// dependencies", and nothing anywhere implements either of these —
|
|
546
|
-
//
|
|
547
|
-
//
|
|
548
|
-
//
|
|
549
|
-
//
|
|
550
|
-
//
|
|
586
|
+
// dependencies", and nothing anywhere implements either of these — there
|
|
587
|
+
// is nothing for them to do. They document no revocation endpoint at all,
|
|
588
|
+
// so disconnect has nothing to call. Recorded as a decision rather than
|
|
589
|
+
// left as an unkept promise.
|
|
590
|
+
//
|
|
591
|
+
// STILL FALSE AFTER LOOKING AGAIN, and this is the reason written down so
|
|
592
|
+
// nobody re-derives it. Klaviyo's connect reads the account name back so
|
|
593
|
+
// the card is not blank; Attentive's card stays blank. There IS an
|
|
594
|
+
// endpoint — GET https://api.attentivemobile.com/v1/me, Bearer, described
|
|
595
|
+
// on docs.attentive.com/pages/authentication/ as returning "information
|
|
596
|
+
// specific to your company" — but its RESPONSE SCHEMA is published
|
|
597
|
+
// nowhere we can read: the docs show the curl and no body. Reading
|
|
598
|
+
// `body.name` would be a guess, and a guess here fails at the worst
|
|
599
|
+
// moment, in the callback, after the merchant has already consented.
|
|
600
|
+
//
|
|
601
|
+
// A live token settles it in one call, alongside the three registration
|
|
602
|
+
// checks in the header. Until then the honest state is a blank field, not
|
|
603
|
+
// a hopeful one.
|
|
551
604
|
connect: false,
|
|
552
605
|
disconnect: false,
|
|
553
606
|
probe: false,
|
|
@@ -569,7 +622,112 @@ var attentive_default2 = {
|
|
|
569
622
|
}
|
|
570
623
|
},
|
|
571
624
|
commerce: false,
|
|
572
|
-
|
|
625
|
+
// The verb the contacts.sync step points at.
|
|
626
|
+
contacts: {
|
|
627
|
+
// Not yet. Suppression syncs an opt-out as unsubscribed, which is a
|
|
628
|
+
// different thing from erasing the subscriber — Attentive's deletion sits
|
|
629
|
+
// behind their privacy-request API, which is a different grant.
|
|
630
|
+
remove: false,
|
|
631
|
+
// TWO CALLS, BECAUSE ATTENTIVE HAS TWO IDEAS.
|
|
632
|
+
//
|
|
633
|
+
// Subscribing and being in a segment are NOT the same operation here —
|
|
634
|
+
// unlike Klaviyo, where a subscription is created against the list itself.
|
|
635
|
+
// /v1/subscriptions takes no segment id at all, so the segment a merchant
|
|
636
|
+
// picked on this connection can only be honoured by the bulk segment
|
|
637
|
+
// membership API:
|
|
638
|
+
//
|
|
639
|
+
// subscribe POST /v1/subscriptions
|
|
640
|
+
// { user : { email, phone }, locale, subscriptionType } — the
|
|
641
|
+
// docs require EITHER signUpSourceId OR (locale +
|
|
642
|
+
// subscriptionType), and we hold no sign-up source. 202.
|
|
643
|
+
//
|
|
644
|
+
// membership POST /v2/bulk/segments/members
|
|
645
|
+
// { externalId, members : [ { email, phone } ] }, 1-10,000
|
|
646
|
+
// members, 202 with a batchJobId
|
|
647
|
+
// (docs.attentive.com/reference/postbulksegmentmembers).
|
|
648
|
+
//
|
|
649
|
+
// unsubscribe POST /v1/subscriptions/unsubscribe
|
|
650
|
+
// { user, subscriptions : [ { type, channel } ] }. 202.
|
|
651
|
+
//
|
|
652
|
+
// EVERY ONE OF THEM ANSWERS 202 ACCEPTED, which means Attentive took the
|
|
653
|
+
// job, not that it ran — the same distinction the Shopify usage charge
|
|
654
|
+
// makes between a 202 and a charge. The message below says accepted, and
|
|
655
|
+
// must keep saying accepted.
|
|
656
|
+
sync: async ({ lead, settings, suppressed, token }, { fetcher } = {}) => {
|
|
657
|
+
var _a, _b, _c, _d;
|
|
658
|
+
const segment = settings == null ? void 0 : settings.segment;
|
|
659
|
+
if (!segment) return { message: "No Attentive segment is chosen for this connection.", skipped: true };
|
|
660
|
+
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);
|
|
661
|
+
const phone = toE164(((_d = (_c = lead == null ? void 0 : lead.canonical) == null ? void 0 : _c.phone) == null ? void 0 : _d.value) || (lead == null ? void 0 : lead.phone));
|
|
662
|
+
if (!email && !phone) return { message: "That lead has no email address or phone number to sync.", skipped: true };
|
|
663
|
+
const user = {
|
|
664
|
+
...email && { email },
|
|
665
|
+
...phone && { phone }
|
|
666
|
+
};
|
|
667
|
+
if (suppressed) {
|
|
668
|
+
await api("/v1/subscriptions/unsubscribe", {
|
|
669
|
+
fetcher,
|
|
670
|
+
method: "POST",
|
|
671
|
+
payload: {
|
|
672
|
+
// One entry per channel we can actually name them by. MARKETING
|
|
673
|
+
// is the only type Drawbridge ever subscribed them to.
|
|
674
|
+
subscriptions: [
|
|
675
|
+
...phone ? [{ channel: "TEXT", type: "MARKETING" }] : [],
|
|
676
|
+
...email ? [{ channel: "EMAIL", type: "MARKETING" }] : []
|
|
677
|
+
],
|
|
678
|
+
user
|
|
679
|
+
},
|
|
680
|
+
token
|
|
681
|
+
});
|
|
682
|
+
return {
|
|
683
|
+
message: "Attentive accepted an unsubscribe for this contact \u2014 they have opted out.",
|
|
684
|
+
response: { accepted: true, unsubscribed: true }
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
await api("/v1/subscriptions", {
|
|
688
|
+
fetcher,
|
|
689
|
+
method: "POST",
|
|
690
|
+
payload: {
|
|
691
|
+
// LOCALE, because we hold no signUpSourceId and the docs require
|
|
692
|
+
// one or the other. The country is READ OFF the number when there
|
|
693
|
+
// is one — libphonenumber knows it from the calling code — rather
|
|
694
|
+
// than assumed; only the fallback pair below is a default, and it
|
|
695
|
+
// is the one value here that no vendor document dictates.
|
|
696
|
+
//
|
|
697
|
+
// ponytail: en/US default. A `signUpSourceId` field on the
|
|
698
|
+
// connection is the upgrade — Attentive's sign-up sources carry
|
|
699
|
+
// the consent language, which is a better answer than any locale
|
|
700
|
+
// we can infer — and it replaces this branch entirely.
|
|
701
|
+
locale: {
|
|
702
|
+
country: phone && detectCountry(phone) || "US",
|
|
703
|
+
language: "en"
|
|
704
|
+
},
|
|
705
|
+
subscriptionType: "MARKETING",
|
|
706
|
+
user
|
|
707
|
+
},
|
|
708
|
+
token
|
|
709
|
+
});
|
|
710
|
+
const membership = await api("/v2/bulk/segments/members", {
|
|
711
|
+
fetcher,
|
|
712
|
+
method: "POST",
|
|
713
|
+
payload: {
|
|
714
|
+
externalId: segment,
|
|
715
|
+
members: [user]
|
|
716
|
+
},
|
|
717
|
+
token
|
|
718
|
+
});
|
|
719
|
+
return {
|
|
720
|
+
// ACCEPTED, NOT LIVE. Both writes answered 202, which means Attentive
|
|
721
|
+
// queued them — a merchant who reads "synced" and looks for the person
|
|
722
|
+
// in Attentive a second later has been told the wrong thing.
|
|
723
|
+
message: "Attentive accepted this contact for the segment. Attentive processes these asynchronously, so it appears there shortly.",
|
|
724
|
+
response: {
|
|
725
|
+
accepted: true,
|
|
726
|
+
...(membership == null ? void 0 : membership.batchJobId) && { batchJobId: membership.batchJobId }
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
},
|
|
573
731
|
email: false,
|
|
574
732
|
inbound: false,
|
|
575
733
|
lifecycle: false,
|
|
@@ -582,26 +740,13 @@ var attentive_default2 = {
|
|
|
582
740
|
// show a picker quietly missing most of a real account. The response's
|
|
583
741
|
// only identifier is `externalId`, so an entry without one cannot be
|
|
584
742
|
// stored and is dropped.
|
|
585
|
-
audiences: async ({ cursor, limit = 100, search, token }, { fetcher
|
|
743
|
+
audiences: async ({ cursor, limit = 100, search, token }, { fetcher } = {}) => {
|
|
586
744
|
const query = new URLSearchParams({
|
|
587
745
|
limit: String(Math.min(limit, 1e3)),
|
|
588
746
|
...cursor && { cursor },
|
|
589
747
|
...(search == null ? void 0 : search.value) && { name: String(search.value).trim() }
|
|
590
748
|
});
|
|
591
|
-
const
|
|
592
|
-
"https://api.attentivemobile.com/v2/segments?" + query,
|
|
593
|
-
{
|
|
594
|
-
headers: { authorization: "Bearer " + token },
|
|
595
|
-
signal: AbortSignal.timeout(15e3)
|
|
596
|
-
}
|
|
597
|
-
);
|
|
598
|
-
if (!response.ok) {
|
|
599
|
-
throw Object.assign(
|
|
600
|
-
new Error("Attentive refused the request (" + response.status + ")"),
|
|
601
|
-
{ status: response.status }
|
|
602
|
-
);
|
|
603
|
-
}
|
|
604
|
-
const body = await response.json();
|
|
749
|
+
const body = await api("/v2/segments?" + query, { fetcher, token });
|
|
605
750
|
return {
|
|
606
751
|
items: ((body == null ? void 0 : body.segments) || []).filter((segment) => segment == null ? void 0 : segment.externalId).map((segment) => ({ id: segment.externalId, title: (segment == null ? void 0 : segment.name) || segment.externalId })),
|
|
607
752
|
pageInfo: {
|
|
@@ -619,33 +764,67 @@ var attentive_default2 = {
|
|
|
619
764
|
webhook: false
|
|
620
765
|
},
|
|
621
766
|
icon: attentive_default,
|
|
767
|
+
// DRAWBRIDGE'S OWN CREDENTIALS for this vendor, as opposed to a merchant's —
|
|
768
|
+
// what an admin types on the provider screen, and the only declaration of it.
|
|
769
|
+
// It lives beside `requires`, which names the same variables: the manifest
|
|
770
|
+
// says what it needs and this says how someone supplies it, so a credential
|
|
771
|
+
// cannot be required by a vendor that offers nowhere to enter it.
|
|
772
|
+
//
|
|
773
|
+
// `redact` marks a secret — never returned by the api, and blank on save means
|
|
774
|
+
// keep the stored value. `required` drives the live check.
|
|
775
|
+
provider: {
|
|
776
|
+
fields: [
|
|
777
|
+
{ input: "text", key: "clientId", credential: "ATTENTIVE_OAUTH_CLIENT_ID", label: "Client ID", required: true },
|
|
778
|
+
{ input: "password", key: "clientSecret", credential: "ATTENTIVE_OAUTH_CLIENT_SECRET", label: "Client secret", redact: true, required: true }
|
|
779
|
+
]
|
|
780
|
+
},
|
|
622
781
|
requires: [
|
|
623
782
|
"ATTENTIVE_OAUTH_CLIENT_ID",
|
|
624
783
|
"ATTENTIVE_OAUTH_CLIENT_SECRET"
|
|
625
784
|
],
|
|
626
785
|
slug: "attentive",
|
|
627
|
-
// A consent with no segment chosen is authenticated and inert — the sync
|
|
628
|
-
//
|
|
786
|
+
// A consent with no segment chosen is authenticated and inert — the sync needs
|
|
787
|
+
// somewhere to put people — so the card says Pending rather than Active over
|
|
788
|
+
// nothing.
|
|
629
789
|
status: (data2) => {
|
|
630
790
|
var _a;
|
|
631
791
|
return ((_a = data2 == null ? void 0 : data2.settings) == null ? void 0 : _a.segment) ? data2.status : "pending";
|
|
632
792
|
},
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
793
|
+
steps: {
|
|
794
|
+
contacts: {
|
|
795
|
+
// A DECLARATION, not the work. The nesting IS the name: this is
|
|
796
|
+
// `step.contacts.sync`, the string a workflow document stores. Klaviyo and
|
|
797
|
+
// Mailchimp declare the same type — a step belongs to the capability, not
|
|
798
|
+
// to whoever implements it — and the connection on the step document is
|
|
799
|
+
// what says which vendor runs.
|
|
800
|
+
sync: ({ data: data2 }) => ({
|
|
801
|
+
hook: "contacts.sync",
|
|
802
|
+
// NO ACCOUNT NAME TO INTERPOLATE, unlike Klaviyo: auth.connect is false
|
|
803
|
+
// because Attentive publishes no account-identity response we can read
|
|
804
|
+
// (see its comment), and settings.segment is an opaque externalId no
|
|
805
|
+
// merchant would recognise in a builder label.
|
|
806
|
+
key: "Sync contact to Attentive",
|
|
807
|
+
queue: "connection",
|
|
808
|
+
// Nothing for a merchant to configure on the step itself — the segment
|
|
809
|
+
// is chosen once on the connection. Declared empty rather than omitted,
|
|
810
|
+
// so "this step takes no settings" and "nobody thought about settings"
|
|
811
|
+
// stay different statements.
|
|
812
|
+
settings: {},
|
|
813
|
+
// BOTH triggers, for the same reason as Klaviyo: lead.insert alone only
|
|
814
|
+
// ever fires for someone with no history yet, and crossing into a
|
|
815
|
+
// segment is the other moment a contact is worth pushing.
|
|
816
|
+
triggers: ["lead.insert", "segment.contact.add"],
|
|
817
|
+
usage: { actions: 1 }
|
|
818
|
+
})
|
|
819
|
+
}
|
|
820
|
+
},
|
|
821
|
+
// WHY, in the merchant's words, and what to do about it.
|
|
636
822
|
tasks: (data2) => {
|
|
637
823
|
var _a;
|
|
638
|
-
return [
|
|
639
|
-
...((_a = data2 == null ? void 0 : data2.settings) == null ? void 0 : _a.segment) ? [] : [
|
|
640
|
-
{
|
|
641
|
-
message: "Choose which Attentive segment your contacts should sync into. Until you do, nothing is being synced.",
|
|
642
|
-
title: "Choose a segment"
|
|
643
|
-
}
|
|
644
|
-
],
|
|
824
|
+
return ((_a = data2 == null ? void 0 : data2.settings) == null ? void 0 : _a.segment) ? [] : [
|
|
645
825
|
{
|
|
646
|
-
message: "
|
|
647
|
-
title: "
|
|
648
|
-
type: "warning"
|
|
826
|
+
message: "Choose which Attentive segment your contacts should sync into. Until you do, nothing is being synced.",
|
|
827
|
+
title: "Choose a segment"
|
|
649
828
|
}
|
|
650
829
|
];
|
|
651
830
|
},
|
|
@@ -847,7 +1026,7 @@ var drawbridge_default = `<svg width="500" height="500" viewBox="0 0 500 500" fi
|
|
|
847
1026
|
<rect width="500" height="500" fill="#BAEC5F"/>
|
|
848
1027
|
<g clip-path="url(#clip0_2115_2832)">
|
|
849
1028
|
<path d="M140.224 127.586L174.803 188.73V311.176L140 372.32L176.084 392.031L216.111 321.753V178.278L176.341 108L140.224 127.586Z" fill="#0D1314"/>
|
|
850
|
-
<path d="M360.
|
|
1029
|
+
<path d="M360.002 127.523L323.694 108.282L284.949 178.498V321.596L322.924 391.749L359.394 372.79L326.225 311.52V188.73L360.002 127.523Z" fill="#0D1314"/>
|
|
851
1030
|
</g>
|
|
852
1031
|
<defs>
|
|
853
1032
|
<clipPath id="clip0_2115_2832">
|
|
@@ -1886,6 +2065,34 @@ var drawbridge_default2 = {
|
|
|
1886
2065
|
icon: drawbridge_default,
|
|
1887
2066
|
// PRIVATE: never in the catalog, always available to the builder.
|
|
1888
2067
|
private: true,
|
|
2068
|
+
// THE PLATFORM'S OWN SENDING CREDENTIALS — SendGrid, Twilio, and the internal
|
|
2069
|
+
// HubSpot portal. No merchant ever sees these; they are what an admin types on
|
|
2070
|
+
// the provider screen so that Drawbridge itself can send.
|
|
2071
|
+
//
|
|
2072
|
+
// They belong on THIS manifest because this is the connection that sends: the
|
|
2073
|
+
// email, sms and segment hooks below are the only things that spend them, and
|
|
2074
|
+
// a private connection is still where a vendor fact lives.
|
|
2075
|
+
//
|
|
2076
|
+
// UNLIKE every public vendor, none of these appear in `requires` — see the
|
|
2077
|
+
// comment there. Availability and configuration are different questions, and a
|
|
2078
|
+
// missing CRM token must not take every base workflow step away.
|
|
2079
|
+
provider: {
|
|
2080
|
+
fields: [
|
|
2081
|
+
{ input: "email", key: "accountSender", credential: "SENDGRID_FROM_ADDRESS", label: "Account sender", message: "Verification codes and security alerts send from here.", required: true },
|
|
2082
|
+
{ input: "password", key: "apiKey", credential: "SENDGRID_API_KEY", label: "SendGrid API key", redact: true, required: true },
|
|
2083
|
+
// NOT required. The CRM sync is best-effort internal tooling and no-ops
|
|
2084
|
+
// without a token — requiring it would make the whole drawbridge provider
|
|
2085
|
+
// read not-live over something no merchant ever sees.
|
|
2086
|
+
{ input: "password", key: "hubspotToken", credential: "HUBSPOT_ACCESS_TOKEN", label: "HubSpot access token", message: "Drawbridge's own CRM portal. Internal \u2014 no merchant sees this.", redact: true },
|
|
2087
|
+
// Optional: SENDGRID_SEND_FROM_ADDRESS is not boot-required in sync
|
|
2088
|
+
// either. Unset, it degrades to the account sender rather than
|
|
2089
|
+
// refusing to start.
|
|
2090
|
+
{ 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." },
|
|
2091
|
+
{ input: "text", key: "smsFrom", credential: "TWILIO_ACCOUNT_FROM", label: "SMS number", required: true },
|
|
2092
|
+
{ input: "password", key: "smsSid", credential: "TWILIO_ACCOUNT_SID", label: "Twilio account SID", redact: true, required: true },
|
|
2093
|
+
{ input: "password", key: "smsToken", credential: "TWILIO_AUTH_TOKEN", label: "Twilio auth token", redact: true, required: true }
|
|
2094
|
+
]
|
|
2095
|
+
},
|
|
1889
2096
|
// NOTHING, and HUBSPOT_ACCESS_TOKEN in particular must not be here.
|
|
1890
2097
|
//
|
|
1891
2098
|
// `requires` gates AVAILABILITY: a name in it that is unset removes the whole
|
|
@@ -2022,12 +2229,12 @@ var drawbridge_default2 = {
|
|
|
2022
2229
|
|
|
2023
2230
|
// lib/connections/icons/klaviyo.js
|
|
2024
2231
|
var klaviyo_default = `<svg width="500" height="500" viewBox="0 0 500 500" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2025
|
-
<rect width="500" height="500" fill="
|
|
2232
|
+
<rect width="500" height="500" fill="#FF4B32"/>
|
|
2026
2233
|
<path d="M365.047 327.038H134.954V172.964H365.047L316.856 250.001L365.047 327.038Z" fill="#232121"/>
|
|
2027
2234
|
</svg>`;
|
|
2028
2235
|
|
|
2029
2236
|
// lib/connections/providers/klaviyo.js
|
|
2030
|
-
var
|
|
2237
|
+
var api2 = async (path, { fetcher = fetch, method = "GET", payload, token }) => {
|
|
2031
2238
|
const response = await fetcher("https://a.klaviyo.com/api" + path, {
|
|
2032
2239
|
...payload && { body: JSON.stringify(payload) },
|
|
2033
2240
|
headers: {
|
|
@@ -2206,7 +2413,7 @@ var klaviyo_default2 = {
|
|
|
2206
2413
|
// decided it, and asking again would be a question we can answer.
|
|
2207
2414
|
connect: async ({ tokens }, { fetcher } = {}) => {
|
|
2208
2415
|
var _a, _b, _c;
|
|
2209
|
-
const body = await
|
|
2416
|
+
const body = await api2("/accounts", { fetcher, token: tokens.accessToken });
|
|
2210
2417
|
const account = (_a = body == null ? void 0 : body.data) == null ? void 0 : _a[0];
|
|
2211
2418
|
return {
|
|
2212
2419
|
account: ((_c = (_b = account == null ? void 0 : account.attributes) == null ? void 0 : _b.contact_information) == null ? void 0 : _c.organization_name) || (account == null ? void 0 : account.id) || null,
|
|
@@ -2283,7 +2490,7 @@ var klaviyo_default2 = {
|
|
|
2283
2490
|
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);
|
|
2284
2491
|
if (!email) return { message: "That lead has no email address to sync.", skipped: true };
|
|
2285
2492
|
const totals = (contact == null ? void 0 : contact.totals) || {};
|
|
2286
|
-
const profile = await
|
|
2493
|
+
const profile = await api2("/profiles/", {
|
|
2287
2494
|
fetcher,
|
|
2288
2495
|
method: "POST",
|
|
2289
2496
|
payload: {
|
|
@@ -2311,7 +2518,7 @@ var klaviyo_default2 = {
|
|
|
2311
2518
|
});
|
|
2312
2519
|
const profileId = (_c = profile == null ? void 0 : profile.data) == null ? void 0 : _c.id;
|
|
2313
2520
|
if (!profileId) return { message: "Klaviyo returned no profile id.", skipped: true };
|
|
2314
|
-
await
|
|
2521
|
+
await api2("/profile-subscription-bulk-create-jobs/", {
|
|
2315
2522
|
fetcher,
|
|
2316
2523
|
method: "POST",
|
|
2317
2524
|
payload: {
|
|
@@ -2374,7 +2581,7 @@ var klaviyo_default2 = {
|
|
|
2374
2581
|
let next = cursor ? "/lists?page%5Bsize%5D=10&page%5Bcursor%5D=" + encodeURIComponent(cursor) : "/lists?page%5Bsize%5D=10";
|
|
2375
2582
|
let pages = 0;
|
|
2376
2583
|
while (next && audiences.length < limit && pages < 20) {
|
|
2377
|
-
const body = await
|
|
2584
|
+
const body = await api2(next, { fetcher, token });
|
|
2378
2585
|
for (const list of (body == null ? void 0 : body.data) || []) {
|
|
2379
2586
|
audiences.push({ id: list.id, title: ((_a = list == null ? void 0 : list.attributes) == null ? void 0 : _a.name) || list.id });
|
|
2380
2587
|
}
|
|
@@ -2400,6 +2607,16 @@ var klaviyo_default2 = {
|
|
|
2400
2607
|
webhook: false
|
|
2401
2608
|
},
|
|
2402
2609
|
icon: klaviyo_default,
|
|
2610
|
+
// DRAWBRIDGE'S OWN CREDENTIALS for this vendor, as opposed to a merchant's —
|
|
2611
|
+
// what an admin types on the provider screen. Declared here rather than in a
|
|
2612
|
+
// table in lib/providers.js, so a vendor's credentials sit beside the
|
|
2613
|
+
// `requires` that names the same variables.
|
|
2614
|
+
provider: {
|
|
2615
|
+
fields: [
|
|
2616
|
+
{ input: "text", key: "clientId", credential: "KLAVIYO_OAUTH_CLIENT_ID", label: "Client ID", required: true },
|
|
2617
|
+
{ input: "password", key: "clientSecret", credential: "KLAVIYO_OAUTH_CLIENT_SECRET", label: "Client secret", redact: true, required: true }
|
|
2618
|
+
]
|
|
2619
|
+
},
|
|
2403
2620
|
requires: [
|
|
2404
2621
|
"KLAVIYO_OAUTH_CLIENT_ID",
|
|
2405
2622
|
"KLAVIYO_OAUTH_CLIENT_SECRET"
|
|
@@ -2473,6 +2690,9 @@ var klaviyo_default2 = {
|
|
|
2473
2690
|
title: "Klaviyo"
|
|
2474
2691
|
};
|
|
2475
2692
|
|
|
2693
|
+
// lib/connections/providers/mailchimp.js
|
|
2694
|
+
import { createHash as createHash2 } from "crypto";
|
|
2695
|
+
|
|
2476
2696
|
// lib/connections/icons/mailchimp.js
|
|
2477
2697
|
var mailchimp_default = `<svg width="500" height="500" viewBox="0 0 500 500" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2478
2698
|
<rect width="500" height="500" fill="#FFE01B"/>
|
|
@@ -2485,6 +2705,25 @@ var base = (dc) => {
|
|
|
2485
2705
|
if (!dc) throw new Error("This Mailchimp connection has no data centre stored, so there is no host to call");
|
|
2486
2706
|
return "https://" + dc + ".api.mailchimp.com/3.0";
|
|
2487
2707
|
};
|
|
2708
|
+
var api3 = async (path, { dc, fetcher = fetch, method = "GET", payload, token }) => {
|
|
2709
|
+
const response = await fetcher(base(dc) + path, {
|
|
2710
|
+
...payload && { body: JSON.stringify(payload) },
|
|
2711
|
+
headers: {
|
|
2712
|
+
authorization: "Bearer " + token,
|
|
2713
|
+
...payload && { "content-type": "application/json" }
|
|
2714
|
+
},
|
|
2715
|
+
method,
|
|
2716
|
+
signal: AbortSignal.timeout(15e3)
|
|
2717
|
+
});
|
|
2718
|
+
if (!response.ok) {
|
|
2719
|
+
throw Object.assign(
|
|
2720
|
+
new Error("Mailchimp refused the request (" + response.status + ")"),
|
|
2721
|
+
{ status: response.status }
|
|
2722
|
+
);
|
|
2723
|
+
}
|
|
2724
|
+
return response.json();
|
|
2725
|
+
};
|
|
2726
|
+
var subscriberHash = (email) => createHash2("md5").update(String(email).trim().toLowerCase()).digest("hex");
|
|
2488
2727
|
var mailchimp_default2 = {
|
|
2489
2728
|
// OAUTH 2, authorization code. Every url below is quoted from
|
|
2490
2729
|
// mailchimp.com/developer/marketing/guides/access-user-data-oauth-2/ rather
|
|
@@ -2527,7 +2766,9 @@ var mailchimp_default2 = {
|
|
|
2527
2766
|
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.",
|
|
2528
2767
|
description: [
|
|
2529
2768
|
"Drawbridge no longer sends email through Mailchimp. Notification email now sends from Drawbridge itself, and verifying a domain under Networking in your organization settings puts your own brand in the from line.",
|
|
2530
|
-
"
|
|
2769
|
+
"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.",
|
|
2770
|
+
"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.",
|
|
2771
|
+
"Someone who unsubscribed inside Mailchimp keeps that choice: a resync only sets the status of a subscriber Mailchimp has never seen before."
|
|
2531
2772
|
],
|
|
2532
2773
|
excerpt: "Sync your Drawbridge contacts into a Mailchimp audience.",
|
|
2533
2774
|
guide: [
|
|
@@ -2602,7 +2843,51 @@ var mailchimp_default2 = {
|
|
|
2602
2843
|
token: authToken
|
|
2603
2844
|
},
|
|
2604
2845
|
commerce: false,
|
|
2605
|
-
|
|
2846
|
+
// The verb the contacts.sync step points at.
|
|
2847
|
+
contacts: {
|
|
2848
|
+
// Not yet. Suppression syncs an opt-out as unsubscribed, which is a
|
|
2849
|
+
// different thing from deleting the member — and Mailchimp's own delete is
|
|
2850
|
+
// permanent, so the address can never be re-added.
|
|
2851
|
+
remove: false,
|
|
2852
|
+
// PUT /lists/{list_id}/members/{subscriber_hash} — an UPSERT, which is
|
|
2853
|
+
// why there is no create-or-update branch here. Quoted from Mailchimp's
|
|
2854
|
+
// Marketing API reference for the list-members resource.
|
|
2855
|
+
sync: async ({ lead, settings, suppressed, token }, { fetcher } = {}) => {
|
|
2856
|
+
var _a, _b;
|
|
2857
|
+
const audience = settings == null ? void 0 : settings.audience;
|
|
2858
|
+
if (!audience) return { message: "No Mailchimp audience is chosen for this connection.", skipped: true };
|
|
2859
|
+
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);
|
|
2860
|
+
if (!email) return { message: "That lead has no email address to sync.", skipped: true };
|
|
2861
|
+
const hash = subscriberHash(email);
|
|
2862
|
+
const member = await api3("/lists/" + audience + "/members/" + hash, {
|
|
2863
|
+
dc: settings == null ? void 0 : settings.dc,
|
|
2864
|
+
fetcher,
|
|
2865
|
+
method: "PUT",
|
|
2866
|
+
payload: {
|
|
2867
|
+
email_address: email,
|
|
2868
|
+
// FNAME ONLY. Unlike Klaviyo, Mailchimp's custom fields are not
|
|
2869
|
+
// schemaless — a merge tag that does not exist on the audience is
|
|
2870
|
+
// refused, taking the whole request with it — and FNAME is one of
|
|
2871
|
+
// the two tags every audience is created with. The Drawbridge
|
|
2872
|
+
// totals Klaviyo receives cannot travel until something registers
|
|
2873
|
+
// merge fields on the chosen audience, which is lifecycle.register's
|
|
2874
|
+
// job and is not built.
|
|
2875
|
+
...(lead == null ? void 0 : lead.name) && { merge_fields: { FNAME: String(lead.name).trim().split(/\s+/)[0] } },
|
|
2876
|
+
...suppressed && { status: "unsubscribed" },
|
|
2877
|
+
status_if_new: suppressed ? "unsubscribed" : "subscribed"
|
|
2878
|
+
},
|
|
2879
|
+
token
|
|
2880
|
+
});
|
|
2881
|
+
return {
|
|
2882
|
+
// Merged into `context` for later steps in this run.
|
|
2883
|
+
context: { mailchimpMemberId: (member == null ? void 0 : member.id) || hash },
|
|
2884
|
+
message: suppressed ? "Synced to Mailchimp as unsubscribed \u2014 this contact has opted out." : "Synced to the Mailchimp audience.",
|
|
2885
|
+
// Recorded on the run for support to read back, not a write
|
|
2886
|
+
// instruction — the hook has already written what it needed to.
|
|
2887
|
+
response: { mailchimpMemberId: (member == null ? void 0 : member.id) || hash }
|
|
2888
|
+
};
|
|
2889
|
+
}
|
|
2890
|
+
},
|
|
2606
2891
|
// Drawbridge sends its own notification email and SMS, and owns its own
|
|
2607
2892
|
// segments — see the private `drawbridge` manifest. A vendor answering
|
|
2608
2893
|
// these would be a second sender, which is the arrangement the platform
|
|
@@ -2621,24 +2906,13 @@ var mailchimp_default2 = {
|
|
|
2621
2906
|
// successful — the same silent truncation Klaviyo has, at a different
|
|
2622
2907
|
// number. Paged against total_items so an account past a thousand still
|
|
2623
2908
|
// resolves.
|
|
2624
|
-
audiences: async ({ cursor, limit = 100, search, settings, token }, { fetcher
|
|
2625
|
-
const dc = settings == null ? void 0 : settings.dc;
|
|
2909
|
+
audiences: async ({ cursor, limit = 100, search, settings, token }, { fetcher } = {}) => {
|
|
2626
2910
|
const count = Math.min(limit, 1e3);
|
|
2627
2911
|
const offset = Number(cursor || 0);
|
|
2628
|
-
const
|
|
2629
|
-
|
|
2630
|
-
{
|
|
2631
|
-
headers: { authorization: "Bearer " + token },
|
|
2632
|
-
signal: AbortSignal.timeout(15e3)
|
|
2633
|
-
}
|
|
2912
|
+
const body = await api3(
|
|
2913
|
+
"/lists?count=" + count + "&offset=" + offset + "&fields=lists.id,lists.name,total_items",
|
|
2914
|
+
{ dc: settings == null ? void 0 : settings.dc, fetcher, token }
|
|
2634
2915
|
);
|
|
2635
|
-
if (!response.ok) {
|
|
2636
|
-
throw Object.assign(
|
|
2637
|
-
new Error("Mailchimp refused the request (" + response.status + ")"),
|
|
2638
|
-
{ status: response.status }
|
|
2639
|
-
);
|
|
2640
|
-
}
|
|
2641
|
-
const body = await response.json();
|
|
2642
2916
|
const audiences = ((body == null ? void 0 : body.lists) || []).map((list) => ({ id: list.id, title: (list == null ? void 0 : list.name) || list.id }));
|
|
2643
2917
|
const term = String((search == null ? void 0 : search.value) || "").trim().toLowerCase();
|
|
2644
2918
|
const items = term ? audiences.filter((entry) => entry.title.toLowerCase().includes(term)) : audiences;
|
|
@@ -2660,6 +2934,15 @@ var mailchimp_default2 = {
|
|
|
2660
2934
|
webhook: false
|
|
2661
2935
|
},
|
|
2662
2936
|
icon: mailchimp_default,
|
|
2937
|
+
// DRAWBRIDGE'S OWN CREDENTIALS for this vendor, as opposed to a merchant's —
|
|
2938
|
+
// what an admin types on the provider screen, beside the `requires` naming the
|
|
2939
|
+
// same variables.
|
|
2940
|
+
provider: {
|
|
2941
|
+
fields: [
|
|
2942
|
+
{ input: "text", key: "clientId", credential: "MAILCHIMP_OAUTH_CLIENT_ID", label: "Client ID", required: true },
|
|
2943
|
+
{ input: "password", key: "clientSecret", credential: "MAILCHIMP_OAUTH_CLIENT_SECRET", label: "Client secret", redact: true, required: true }
|
|
2944
|
+
]
|
|
2945
|
+
},
|
|
2663
2946
|
// The OAuth client this deployment registered. Without both, the vendor drops
|
|
2664
2947
|
// out of availableConnections rather than offering a Connect button that
|
|
2665
2948
|
// cannot complete.
|
|
@@ -2668,32 +2951,54 @@ var mailchimp_default2 = {
|
|
|
2668
2951
|
"MAILCHIMP_OAUTH_CLIENT_SECRET"
|
|
2669
2952
|
],
|
|
2670
2953
|
slug: "mailchimp",
|
|
2671
|
-
// A
|
|
2672
|
-
//
|
|
2673
|
-
//
|
|
2674
|
-
//
|
|
2675
|
-
//
|
|
2954
|
+
// A grant with no audience chosen is authenticated and useless — the sync has
|
|
2955
|
+
// nowhere to put anyone — so the card must say Pending rather than Active over
|
|
2956
|
+
// nothing. Mailchimp also needs its merge fields created on that audience
|
|
2957
|
+
// before any Drawbridge total can be written to a member — unlike Klaviyo, its
|
|
2958
|
+
// custom fields are not schemaless — so the audience must be picked before
|
|
2959
|
+
// lifecycle.register has anything to register against.
|
|
2676
2960
|
status: (data2) => {
|
|
2677
2961
|
var _a;
|
|
2678
2962
|
return ((_a = data2 == null ? void 0 : data2.settings) == null ? void 0 : _a.audience) ? data2.status : "pending";
|
|
2679
2963
|
},
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2964
|
+
steps: {
|
|
2965
|
+
contacts: {
|
|
2966
|
+
// A DECLARATION, not the work. It names the hook that does the work, and
|
|
2967
|
+
// the nesting IS the name: this is `step.contacts.sync`, the string a
|
|
2968
|
+
// workflow document stores. Klaviyo and Attentive declare the same type —
|
|
2969
|
+
// a step belongs to the capability, not to whoever implements it — and the
|
|
2970
|
+
// connection on the step document is what says which vendor runs.
|
|
2971
|
+
sync: ({ data: data2 }) => ({
|
|
2972
|
+
hook: "contacts.sync",
|
|
2973
|
+
// NO ACCOUNT NAME TO INTERPOLATE, unlike Klaviyo. Mailchimp's
|
|
2974
|
+
// auth.connect deliberately stores only the data centre (a test pins
|
|
2975
|
+
// that), and settings.audience is an opaque list id no merchant would
|
|
2976
|
+
// recognise in a builder label — so the label names the vendor rather
|
|
2977
|
+
// than showing a string like a1b2c3d4e5.
|
|
2978
|
+
key: "Sync contact to Mailchimp",
|
|
2979
|
+
queue: "connection",
|
|
2980
|
+
// Nothing for a merchant to configure on the step itself — the audience
|
|
2981
|
+
// is chosen once on the connection. Declared empty rather than omitted,
|
|
2982
|
+
// so "this step takes no settings" and "nobody thought about settings"
|
|
2983
|
+
// stay different statements.
|
|
2984
|
+
settings: {},
|
|
2985
|
+
// BOTH triggers, for the same reason as Klaviyo: lead.insert alone only
|
|
2986
|
+
// ever fires for someone with no history yet, and crossing into a
|
|
2987
|
+
// segment is the other moment a contact is worth pushing.
|
|
2988
|
+
triggers: ["lead.insert", "segment.contact.add"],
|
|
2989
|
+
// One source for cost: what the builder discloses before a merchant
|
|
2990
|
+
// adds this step, and what is charged when it runs.
|
|
2991
|
+
usage: { actions: 1 }
|
|
2992
|
+
})
|
|
2993
|
+
}
|
|
2994
|
+
},
|
|
2995
|
+
// WHY, in the merchant's words, and what to do about it.
|
|
2684
2996
|
tasks: (data2) => {
|
|
2685
2997
|
var _a;
|
|
2686
|
-
return [
|
|
2687
|
-
...((_a = data2 == null ? void 0 : data2.settings) == null ? void 0 : _a.audience) ? [] : [
|
|
2688
|
-
{
|
|
2689
|
-
message: "Choose which Mailchimp audience your contacts should sync into. Until you do, nothing is being synced.",
|
|
2690
|
-
title: "Choose an audience"
|
|
2691
|
-
}
|
|
2692
|
-
],
|
|
2998
|
+
return ((_a = data2 == null ? void 0 : data2.settings) == null ? void 0 : _a.audience) ? [] : [
|
|
2693
2999
|
{
|
|
2694
|
-
message: "
|
|
2695
|
-
title: "
|
|
2696
|
-
type: "warning"
|
|
3000
|
+
message: "Choose which Mailchimp audience your contacts should sync into. Until you do, nothing is being synced.",
|
|
3001
|
+
title: "Choose an audience"
|
|
2697
3002
|
}
|
|
2698
3003
|
];
|
|
2699
3004
|
},
|
|
@@ -2706,10 +3011,9 @@ import { customAlphabet as customAlphabet2 } from "nanoid";
|
|
|
2706
3011
|
|
|
2707
3012
|
// lib/connections/icons/shopify.js
|
|
2708
3013
|
var shopify_default = `<svg width="500" height="500" viewBox="0 0 500 500" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2709
|
-
<rect width="500" height="500" fill="
|
|
2710
|
-
<path
|
|
2711
|
-
<path d="
|
|
2712
|
-
<path d="M258.993 193.019L249.103 230.052C249.103 230.052 238.079 225.023 225 225.85C205.833 227.059 205.628 239.171 205.824 242.21C206.865 258.756 250.376 262.381 252.821 301.171C254.745 331.688 236.656 352.574 210.592 354.21C179.313 356.19 162.089 337.711 162.089 337.711L168.716 309.472C168.716 309.472 186.052 322.569 199.921 321.686C208.993 321.119 212.228 313.738 211.903 308.514C210.536 286.921 175.102 288.185 172.862 252.695C170.985 222.811 190.57 192.554 233.803 189.821C250.46 188.762 258.993 193.028 258.993 193.028" fill="white"/>
|
|
3014
|
+
<rect width="500" height="500" fill="#95C049"/>
|
|
3015
|
+
<path d="M292.997 147.633C292.997 147.633 289.98 148.495 285.023 150.004C284.161 147.202 282.868 143.969 281.144 140.521C275.54 129.744 267.134 123.925 257.22 123.925C256.574 123.925 255.927 123.925 255.065 124.141C254.849 123.71 254.418 123.494 254.203 123.063C249.892 118.322 244.289 116.166 237.607 116.382C224.676 116.813 211.744 126.081 201.399 142.676C194.071 154.314 188.468 168.97 186.959 180.393C172.088 184.919 161.743 188.152 161.527 188.367C153.984 190.738 153.768 190.954 152.906 198.066C151.613 203.454 132 355.4 132 355.4L294.937 383.633V147.202C294.075 147.418 293.429 147.418 292.997 147.633ZM255.281 159.271C246.66 161.858 237.176 164.875 227.909 167.677C230.495 157.547 235.668 147.418 241.702 140.736C244.073 138.365 247.306 135.564 250.97 133.839C254.634 141.598 255.496 152.159 255.281 159.271ZM237.823 125.003C240.84 125.003 243.427 125.649 245.582 126.943C242.133 128.667 238.685 131.469 235.452 134.702C227.262 143.538 221.012 157.332 218.426 170.479C210.667 172.85 202.908 175.22 195.796 177.376C200.322 156.901 217.779 125.649 237.823 125.003ZM212.607 243.542C213.469 257.335 249.892 260.353 252.048 292.897C253.556 318.545 238.47 336.002 216.701 337.295C190.407 339.02 175.967 323.502 175.967 323.502L181.571 299.794C181.571 299.794 196.011 310.786 207.649 309.924C215.193 309.493 217.995 303.242 217.779 298.932C216.701 280.828 186.959 281.905 185.019 252.163C183.295 227.377 199.675 202.161 235.883 199.79C249.892 198.928 257.005 202.377 257.005 202.377L248.815 233.412C248.815 233.412 239.547 229.102 228.555 229.964C212.607 231.041 212.391 241.171 212.607 243.542ZM263.902 156.685C263.902 150.219 263.039 140.952 260.022 133.193C269.936 135.133 274.678 146.124 276.833 152.806C272.954 153.883 268.643 155.176 263.902 156.685Z" fill="white"/>
|
|
3016
|
+
<path d="M300.325 382.771L368 365.96C368 365.96 338.904 169.185 338.689 167.892C338.473 166.599 337.396 165.737 336.318 165.737C335.24 165.737 316.274 165.306 316.274 165.306C316.274 165.306 304.636 154.099 300.325 149.788V382.771Z" fill="white"/>
|
|
2713
3017
|
</svg>`;
|
|
2714
3018
|
|
|
2715
3019
|
// lib/connections/inbound.js
|
|
@@ -2748,18 +3052,6 @@ var toCanonicalEmail = (value) => {
|
|
|
2748
3052
|
return local + "@" + domain;
|
|
2749
3053
|
};
|
|
2750
3054
|
|
|
2751
|
-
// lib/phone.js
|
|
2752
|
-
import { AsYouType, parsePhoneNumberFromString, isValidPhoneNumber } from "libphonenumber-js";
|
|
2753
|
-
var toE164 = (value, country) => {
|
|
2754
|
-
if (!value) return null;
|
|
2755
|
-
try {
|
|
2756
|
-
const parsed = parsePhoneNumberFromString(String(value), country);
|
|
2757
|
-
return parsed ? parsed.number : null;
|
|
2758
|
-
} catch {
|
|
2759
|
-
return null;
|
|
2760
|
-
}
|
|
2761
|
-
};
|
|
2762
|
-
|
|
2763
3055
|
// lib/connections/providers/shopify.js
|
|
2764
3056
|
var toLine = ({
|
|
2765
3057
|
price,
|
|
@@ -2859,7 +3151,7 @@ var shopify_default2 = {
|
|
|
2859
3151
|
// the App Store listing, and the dashboard must never imply a store can be
|
|
2860
3152
|
// linked from inside it.
|
|
2861
3153
|
redirect: {
|
|
2862
|
-
|
|
3154
|
+
credential: "SHOPIFY_APP_LISTING_URL",
|
|
2863
3155
|
title: "View on the Shopify App Store"
|
|
2864
3156
|
}
|
|
2865
3157
|
},
|
|
@@ -3612,6 +3904,19 @@ var shopify_default2 = {
|
|
|
3612
3904
|
const shop = (data2 == null ? void 0 : data2.shop) || ((_a = data2 == null ? void 0 : data2.settings) == null ? void 0 : _a.domain);
|
|
3613
3905
|
return shop ? "https://admin.shopify.com/store/" + String(shop).replace(".myshopify.com", "") + "/apps/" + (env == null ? void 0 : env.SHOPIFY_APP_HANDLE) : void 0;
|
|
3614
3906
|
},
|
|
3907
|
+
// DRAWBRIDGE'S OWN CREDENTIALS for this vendor, as opposed to a merchant's —
|
|
3908
|
+
// what an admin types on the provider screen. The four names below are exactly
|
|
3909
|
+
// what `requires` gates on, which is the point of declaring them together: a
|
|
3910
|
+
// name required by the manifest and enterable nowhere is a vendor that can
|
|
3911
|
+
// never go live from the admin screen.
|
|
3912
|
+
provider: {
|
|
3913
|
+
fields: [
|
|
3914
|
+
{ input: "text", key: "apiKey", credential: "SHOPIFY_API_KEY", label: "API key", required: true },
|
|
3915
|
+
{ input: "password", key: "apiSecret", credential: "SHOPIFY_API_SECRET", label: "API secret", redact: true, required: true },
|
|
3916
|
+
{ input: "text", key: "appHandle", credential: "SHOPIFY_APP_HANDLE", label: "App handle", required: true },
|
|
3917
|
+
{ input: "text", key: "listingUrl", credential: "SHOPIFY_APP_LISTING_URL", label: "App listing URL", required: true }
|
|
3918
|
+
]
|
|
3919
|
+
},
|
|
3615
3920
|
// A pre-launch integration: it only surfaces once the App Store listing
|
|
3616
3921
|
// exists and the app is fully configured. Requiring all four means it can
|
|
3617
3922
|
// never render half-configured — and absence of any one excludes the
|
|
@@ -4053,7 +4358,7 @@ var leaves = (node, path = []) => Object.entries(node || {}).flatMap(
|
|
|
4053
4358
|
([key, value]) => typeof value === "function" ? [[[...path, key].join("."), value]] : value && typeof value === "object" ? leaves(value, [...path, key]) : []
|
|
4054
4359
|
);
|
|
4055
4360
|
var build = (manifest) => {
|
|
4056
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
4361
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
4057
4362
|
if (!(manifest == null ? void 0 : manifest.slug)) throw new Error("A connection needs a slug");
|
|
4058
4363
|
if (!(manifest == null ? void 0 : manifest.title)) throw new Error(manifest.slug + " needs a title");
|
|
4059
4364
|
if (!(manifest == null ? void 0 : manifest.private) && !(manifest == null ? void 0 : manifest.feature)) throw new Error(manifest.slug + " needs a plan feature key");
|
|
@@ -4083,6 +4388,17 @@ var build = (manifest) => {
|
|
|
4083
4388
|
}
|
|
4084
4389
|
}
|
|
4085
4390
|
}
|
|
4391
|
+
for (const field2 of ((_c = manifest.provider) == null ? void 0 : _c.fields) || []) {
|
|
4392
|
+
if (!(field2 == null ? void 0 : field2.key) || !(field2 == null ? void 0 : field2.label)) {
|
|
4393
|
+
throw new Error(manifest.slug + " declares a provider field with no key or label");
|
|
4394
|
+
}
|
|
4395
|
+
if (!INPUTS.includes(field2.input)) {
|
|
4396
|
+
throw new Error(manifest.slug + ".provider." + field2.key + " needs an input the admin form can render \u2014 one of " + INPUTS.join(", "));
|
|
4397
|
+
}
|
|
4398
|
+
if (field2.input === "password" && !field2.redact) {
|
|
4399
|
+
throw new Error(manifest.slug + ".provider." + field2.key + " is a password and must declare redact : true \u2014 the api would hand the value back");
|
|
4400
|
+
}
|
|
4401
|
+
}
|
|
4086
4402
|
if (typeof (manifest == null ? void 0 : manifest.icon) !== "string" || !manifest.icon.includes("<svg")) {
|
|
4087
4403
|
throw new Error(manifest.slug + " needs an icon \u2014 the svg markup itself, not a path to one");
|
|
4088
4404
|
}
|
|
@@ -4095,23 +4411,23 @@ var build = (manifest) => {
|
|
|
4095
4411
|
if (!GROUPS.includes(manifest == null ? void 0 : manifest.group)) {
|
|
4096
4412
|
throw new Error(manifest.slug + " needs a group \u2014 one of " + GROUPS.join(", "));
|
|
4097
4413
|
}
|
|
4098
|
-
if ((
|
|
4414
|
+
if ((_d = manifest == null ? void 0 : manifest.connect) == null ? void 0 : _d.type) {
|
|
4099
4415
|
throw new Error(manifest.slug + " declares connect.type \u2014 that is auth.type now");
|
|
4100
4416
|
}
|
|
4101
|
-
if (!AUTH_TYPES.includes((
|
|
4417
|
+
if (!AUTH_TYPES.includes((_e = manifest == null ? void 0 : manifest.auth) == null ? void 0 : _e.type)) {
|
|
4102
4418
|
throw new Error(manifest.slug + " needs auth.type \u2014 one of " + AUTH_TYPES.join(", "));
|
|
4103
4419
|
}
|
|
4104
4420
|
if (manifest.auth.type === "oauth") {
|
|
4105
4421
|
for (const field2 of OAUTH_FIELDS) {
|
|
4106
|
-
if (!((
|
|
4422
|
+
if (!((_f = manifest.auth.oauth) == null ? void 0 : _f[field2])) {
|
|
4107
4423
|
throw new Error(manifest.slug + " is oauth and must declare auth.oauth." + field2);
|
|
4108
4424
|
}
|
|
4109
4425
|
}
|
|
4110
|
-
if (typeof ((
|
|
4426
|
+
if (typeof ((_h = (_g = manifest.hooks) == null ? void 0 : _g.auth) == null ? void 0 : _h.token) !== "function") {
|
|
4111
4427
|
throw new Error(manifest.slug + " is oauth and must implement hooks.auth.token \u2014 point it at authToken() or wrap it");
|
|
4112
4428
|
}
|
|
4113
4429
|
for (const url of OAUTH_URLS) {
|
|
4114
|
-
if (!((
|
|
4430
|
+
if (!((_j = (_i = manifest.auth.oauth) == null ? void 0 : _i.urls) == null ? void 0 : _j[url])) {
|
|
4115
4431
|
throw new Error(manifest.slug + " is oauth and must declare auth.oauth.urls." + url);
|
|
4116
4432
|
}
|
|
4117
4433
|
}
|
|
@@ -4121,16 +4437,16 @@ var build = (manifest) => {
|
|
|
4121
4437
|
);
|
|
4122
4438
|
}
|
|
4123
4439
|
}
|
|
4124
|
-
if (implemented(manifest.hooks, "inbound.event") && !((
|
|
4440
|
+
if (implemented(manifest.hooks, "inbound.event") && !((_l = (_k = manifest.inbound) == null ? void 0 : _k.headers) == null ? void 0 : _l.event)) {
|
|
4125
4441
|
throw new Error(manifest.slug + " implements inbound.event but declares no inbound.headers.event");
|
|
4126
4442
|
}
|
|
4127
|
-
if (implemented(manifest.hooks, "inbound.verify") && !((
|
|
4443
|
+
if (implemented(manifest.hooks, "inbound.verify") && !((_n = (_m = manifest.inbound) == null ? void 0 : _m.headers) == null ? void 0 : _n.signature)) {
|
|
4128
4444
|
throw new Error(manifest.slug + " implements inbound.verify but declares no inbound.headers.signature");
|
|
4129
4445
|
}
|
|
4130
4446
|
if (typeof (manifest == null ? void 0 : manifest.status) !== "function") {
|
|
4131
4447
|
throw new Error(manifest.slug + " must declare status( data ) \u2014 return null to accept the connection's own status, or { message, status } to override it");
|
|
4132
4448
|
}
|
|
4133
|
-
if (!Array.isArray((
|
|
4449
|
+
if (!Array.isArray((_o = manifest == null ? void 0 : manifest.content) == null ? void 0 : _o.guide) || !manifest.content.guide.length) {
|
|
4134
4450
|
throw new Error(manifest.slug + " needs content.guide \u2014 an array of steps for its page");
|
|
4135
4451
|
}
|
|
4136
4452
|
if (typeof (manifest == null ? void 0 : manifest.status) !== "function") {
|
|
@@ -4142,8 +4458,8 @@ var build = (manifest) => {
|
|
|
4142
4458
|
}
|
|
4143
4459
|
for (const [domain, verbs] of Object.entries(HOOKS)) {
|
|
4144
4460
|
for (const verb of verbs) {
|
|
4145
|
-
const hook = (
|
|
4146
|
-
if (((
|
|
4461
|
+
const hook = (_q = (_p = manifest.hooks) == null ? void 0 : _p[domain]) == null ? void 0 : _q[verb];
|
|
4462
|
+
if (((_r = manifest.hooks) == null ? void 0 : _r[domain]) === false) continue;
|
|
4147
4463
|
if (hook !== false && !implemented({ [domain]: { [verb]: hook } }, domain + "." + verb)) {
|
|
4148
4464
|
throw new Error(manifest.slug + " must answer hooks." + domain + "." + verb + " \u2014 false, a function, or {} if another repo implements it");
|
|
4149
4465
|
}
|
|
@@ -4194,14 +4510,18 @@ var connections = Object.freeze({
|
|
|
4194
4510
|
webhook: build(webhook_default)
|
|
4195
4511
|
});
|
|
4196
4512
|
(() => {
|
|
4197
|
-
|
|
4513
|
+
var _a;
|
|
4514
|
+
const routes = {};
|
|
4198
4515
|
for (const [slug, manifest] of Object.entries(connections)) {
|
|
4199
|
-
for (const [name] of leaves(manifest.steps)) {
|
|
4516
|
+
for (const [name, step] of leaves(manifest.steps)) {
|
|
4200
4517
|
const type = "step." + name;
|
|
4201
|
-
|
|
4202
|
-
|
|
4518
|
+
const queue = (_a = step({})) == null ? void 0 : _a.queue;
|
|
4519
|
+
if (routes[type] && routes[type].queue !== queue) {
|
|
4520
|
+
throw new Error(
|
|
4521
|
+
"Step " + type + " routes to " + routes[type].queue + " for " + routes[type].slug + " and " + queue + " for " + slug + " \u2014 one of them would be enqueued nowhere"
|
|
4522
|
+
);
|
|
4203
4523
|
}
|
|
4204
|
-
|
|
4524
|
+
routes[type] = { queue, slug };
|
|
4205
4525
|
}
|
|
4206
4526
|
}
|
|
4207
4527
|
})();
|
|
@@ -4348,7 +4668,7 @@ var projectConnection = (record) => {
|
|
|
4348
4668
|
var resolveConnection = (item, data2, env = {}) => {
|
|
4349
4669
|
if (!item) return item;
|
|
4350
4670
|
return Object.fromEntries(
|
|
4351
|
-
Object.entries(item).filter(([key]) => !["auth", "enabled", "fields", "hooks", "inbound", "requires", "steps", "supports"].includes(key)).map(([key, value]) => [
|
|
4671
|
+
Object.entries(item).filter(([key]) => !["auth", "enabled", "fields", "hooks", "inbound", "provider", "requires", "steps", "supports"].includes(key)).map(([key, value]) => [
|
|
4352
4672
|
key,
|
|
4353
4673
|
typeof value === "function" ? value(data2, env) : value
|
|
4354
4674
|
])
|