@businessdash/sdk 0.9.80 → 0.9.90
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/README.md +133 -949
- package/assets/{biab-sw.js → bd-sw.js} +2 -2
- package/dist/account-core/index.d.ts +1 -1
- package/dist/account-core/index.d.ts.map +1 -1
- package/dist/adapters-revalidate.d.ts +2 -2
- package/dist/adapters-revalidate.js +2 -2
- package/dist/adapters-revalidate.js.map +1 -1
- package/dist/analytics-core.d.ts +6 -6
- package/dist/analytics-core.d.ts.map +1 -1
- package/dist/analytics-core.js +4 -4
- package/dist/analytics-core.js.map +1 -1
- package/dist/analytics-server.d.ts +6 -6
- package/dist/analytics-server.d.ts.map +1 -1
- package/dist/analytics-server.js +5 -5
- package/dist/auth-handler.d.ts +14 -14
- package/dist/auth-handler.d.ts.map +1 -1
- package/dist/auth-handler.js +16 -16
- package/dist/auth-handler.js.map +1 -1
- package/dist/auth-links.d.ts +2 -2
- package/dist/auth-links.d.ts.map +1 -1
- package/dist/auth-links.js +2 -2
- package/dist/auth-links.js.map +1 -1
- package/dist/{biab-forms.css → bd-forms.css} +158 -158
- package/dist/cli.d.ts +4 -4
- package/dist/cli.js +78 -78
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +158 -147
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +156 -137
- package/dist/client.js.map +1 -1
- package/dist/consent-core/index.cjs +2 -2
- package/dist/consent-core/index.d.ts +2 -2
- package/dist/consent-core/index.d.ts.map +1 -1
- package/dist/consent-core/index.js +10 -8
- package/dist/consent-core/index.js.map +1 -1
- package/dist/contracts.d.ts +411 -52
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +89 -15
- package/dist/contracts.js.map +1 -1
- package/dist/data-model-schema.d.ts +15 -15
- package/dist/data-model-schema.d.ts.map +1 -1
- package/dist/data-model-schema.js +19 -17
- package/dist/data-model-schema.js.map +1 -1
- package/dist/distribution.d.ts +5 -5
- package/dist/distribution.d.ts.map +1 -1
- package/dist/distribution.js +4 -4
- package/dist/element.d.ts +36 -36
- package/dist/element.d.ts.map +1 -1
- package/dist/element.js +43 -43
- package/dist/element.js.map +1 -1
- package/dist/embed-protocol.d.ts +11 -11
- package/dist/embed-protocol.d.ts.map +1 -1
- package/dist/embed-protocol.js +1 -1
- package/dist/embed-protocol.js.map +1 -1
- package/dist/errors.d.ts +15 -15
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +18 -18
- package/dist/errors.js.map +1 -1
- package/dist/forms-core/autocomplete.d.ts +3 -3
- package/dist/forms-core/autocomplete.d.ts.map +1 -1
- package/dist/forms-core/autocomplete.js +2 -2
- package/dist/forms-core/controller.d.ts +10 -10
- package/dist/forms-core/controller.d.ts.map +1 -1
- package/dist/forms-core/controller.js +4 -4
- package/dist/forms-core/controller.js.map +1 -1
- package/dist/forms-core/elements.d.ts +4 -4
- package/dist/forms-core/elements.d.ts.map +1 -1
- package/dist/forms-core/elements.js +7 -7
- package/dist/forms-core/elements.js.map +1 -1
- package/dist/forms-core/formula.d.ts +1 -1
- package/dist/forms-core/formula.js +1 -1
- package/dist/forms-core/index.d.ts +6 -6
- package/dist/forms-core/index.d.ts.map +1 -1
- package/dist/forms-core/index.js +5 -5
- package/dist/forms-core/index.js.map +1 -1
- package/dist/forms-core/units.d.ts +1 -1
- package/dist/forms-core/units.js +1 -1
- package/dist/forms-core/us-states.d.ts +1 -1
- package/dist/forms-core/us-states.js +1 -1
- package/dist/forms-core/validation.d.ts +12 -3
- package/dist/forms-core/validation.d.ts.map +1 -1
- package/dist/forms-core/validation.js +152 -17
- package/dist/forms-core/validation.js.map +1 -1
- package/dist/forms.d.ts +2 -2
- package/dist/forms.d.ts.map +1 -1
- package/dist/forms.js +2 -2
- package/dist/forms.js.map +1 -1
- package/dist/framework-support.js +1 -1
- package/dist/framework-support.js.map +1 -1
- package/dist/gallery-types.d.ts +1 -1
- package/dist/graphql.d.ts +3 -3
- package/dist/graphql.d.ts.map +1 -1
- package/dist/graphql.js +3 -3
- package/dist/graphql.js.map +1 -1
- package/dist/index.cjs +351 -272
- package/dist/index.d.cts +5 -5
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/legal-core/index.cjs +8 -8
- package/dist/legal-core/index.d.ts +3 -3
- package/dist/legal-core/index.d.ts.map +1 -1
- package/dist/legal-core/index.js +11 -11
- package/dist/legal-core/index.js.map +1 -1
- package/dist/marketing-core/index.d.ts +51 -1
- package/dist/marketing-core/index.d.ts.map +1 -1
- package/dist/marketing-core/index.js +35 -0
- package/dist/marketing-core/index.js.map +1 -1
- package/dist/marketing-schema.d.ts +9 -9
- package/dist/marketing-schema.d.ts.map +1 -1
- package/dist/marketing-schema.js +1 -1
- package/dist/mcp.d.ts +4 -4
- package/dist/mcp.js +4 -4
- package/dist/native.d.ts +6 -6
- package/dist/native.d.ts.map +1 -1
- package/dist/native.js +4 -4
- package/dist/native.js.map +1 -1
- package/dist/next-revalidate.d.ts +8 -8
- package/dist/next-revalidate.d.ts.map +1 -1
- package/dist/next-revalidate.js +7 -7
- package/dist/next-revalidate.js.map +1 -1
- package/dist/notifications-core/index.d.ts +1 -1
- package/dist/notifications-core/index.js +1 -1
- package/dist/parallel-pages.d.ts +4 -4
- package/dist/parallel-pages.d.ts.map +1 -1
- package/dist/parallel-pages.js +5 -5
- package/dist/parallel-pages.js.map +1 -1
- package/dist/portal-core/index.d.ts +1 -1
- package/dist/portal-core/index.js +1 -1
- package/dist/proxy.d.ts +18 -18
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js +10 -10
- package/dist/proxy.js.map +1 -1
- package/dist/push-core/index.cjs +6 -2
- package/dist/push-core/index.d.ts +1 -1
- package/dist/push-core/index.d.ts.map +1 -1
- package/dist/push-core/index.js +6 -2
- package/dist/push-core/index.js.map +1 -1
- package/dist/react-analytics.d.ts +14 -14
- package/dist/react-analytics.d.ts.map +1 -1
- package/dist/react-analytics.js +15 -15
- package/dist/react-analytics.js.map +1 -1
- package/dist/react-attribution.d.ts +2 -2
- package/dist/react-attribution.d.ts.map +1 -1
- package/dist/react-attribution.js +1 -1
- package/dist/react-marketing.js +5 -5
- package/dist/react-marketing.js.map +1 -1
- package/dist/react.d.ts +38 -61
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +247 -261
- package/dist/react.js.map +1 -1
- package/dist/reserved-paths.d.ts +2 -2
- package/dist/reserved-paths.js +3 -3
- package/dist/reserved-paths.js.map +1 -1
- package/dist/revalidate-verify.d.ts +3 -3
- package/dist/revalidate-verify.d.ts.map +1 -1
- package/dist/revalidate-verify.js +1 -1
- package/dist/revalidate-verify.js.map +1 -1
- package/dist/sdk.d.ts +51 -45
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +48 -50
- package/dist/sdk.js.map +1 -1
- package/dist/seed-core/index.js +8 -8
- package/dist/seed-core/index.js.map +1 -1
- package/dist/seo-core/blog.d.ts +1 -1
- package/dist/seo-core/blog.js +1 -1
- package/dist/seo-core/blog.js.map +1 -1
- package/dist/seo-core/index.cjs +2 -2
- package/dist/seo-core/index.js +1 -1
- package/dist/seo-core/index.js.map +1 -1
- package/dist/seo.d.ts +1 -1
- package/dist/seo.d.ts.map +1 -1
- package/dist/seo.js +1 -1
- package/dist/seo.js.map +1 -1
- package/dist/sitemap-core/index.cjs +5 -5
- package/dist/sitemap-core/index.d.ts +13 -5
- package/dist/sitemap-core/index.d.ts.map +1 -1
- package/dist/sitemap-core/index.js +4 -4
- package/dist/sitemap-core/index.js.map +1 -1
- package/dist/socials.d.ts +6 -6
- package/dist/socials.d.ts.map +1 -1
- package/dist/socials.js +5 -5
- package/dist/socials.js.map +1 -1
- package/dist/solid-compat.d.ts +1 -1
- package/dist/solid-compat.js +4 -4
- package/dist/solid-compat.js.map +1 -1
- package/dist/store-core/index.d.ts +1 -1
- package/dist/vanilla.d.ts +12 -12
- package/dist/vanilla.d.ts.map +1 -1
- package/dist/vanilla.js +192 -145
- package/dist/vanilla.js.map +1 -1
- package/openapi.json +264 -1
- package/package.json +8 -8
- package/src/account-core/index.ts +1 -1
- package/src/adapters-revalidate.ts +3 -3
- package/src/analytics-core.ts +8 -8
- package/src/analytics-server.ts +6 -6
- package/src/angular/{biab-form.component.ts → bd-form.component.ts} +269 -161
- package/src/angular/headless.ts +12 -12
- package/src/angular/index.ts +9 -9
- package/src/auth-handler.ts +22 -22
- package/src/auth-links.ts +2 -2
- package/src/cli.ts +81 -81
- package/src/client.ts +218 -193
- package/src/consent-core/index.ts +10 -8
- package/src/contracts.ts +99 -15
- package/src/data-model-schema.ts +29 -26
- package/src/distribution.ts +5 -5
- package/src/element.ts +54 -54
- package/src/embed-protocol.ts +14 -14
- package/src/errors.ts +27 -27
- package/src/forms-core/autocomplete.ts +3 -3
- package/src/forms-core/controller.ts +12 -12
- package/src/forms-core/elements.ts +7 -7
- package/src/forms-core/formula.ts +1 -1
- package/src/forms-core/index.ts +8 -8
- package/src/forms-core/units.ts +1 -1
- package/src/forms-core/us-states.ts +1 -1
- package/src/forms-core/validation.ts +158 -14
- package/src/forms.ts +2 -2
- package/src/framework-support.ts +1 -1
- package/src/gallery-types.ts +1 -1
- package/src/graphql.ts +4 -4
- package/src/index.ts +38 -38
- package/src/legal-core/index.ts +12 -12
- package/src/marketing-core/index.ts +62 -0
- package/src/marketing-schema.ts +9 -9
- package/src/mcp.ts +4 -4
- package/src/native.ts +14 -14
- package/src/next-revalidate.ts +10 -10
- package/src/notifications-core/index.ts +1 -1
- package/src/parallel-pages.ts +6 -6
- package/src/portal-core/index.ts +1 -1
- package/src/proxy.ts +28 -28
- package/src/push-core/index.ts +11 -5
- package/src/qwik.tsx +262 -166
- package/src/react-analytics.tsx +17 -17
- package/src/react-attribution.tsx +2 -2
- package/src/react-marketing.tsx +5 -5
- package/src/react.tsx +541 -500
- package/src/reserved-paths.ts +3 -3
- package/src/revalidate-verify.ts +5 -5
- package/src/sdk.ts +131 -101
- package/src/seed-core/index.ts +8 -8
- package/src/seo-core/blog.ts +2 -2
- package/src/seo-core/index.ts +1 -1
- package/src/seo.ts +1 -1
- package/src/sitemap-core/index.ts +17 -9
- package/src/socials.ts +6 -6
- package/src/solid-compat.tsx +5 -5
- package/src/solid-surfaces.tsx +28 -28
- package/src/solid.tsx +264 -175
- package/src/store-core/index.ts +1 -1
- package/src/styles/{biab-forms.css → bd-forms.css} +158 -158
- package/src/svelte/{BiabForm.svelte → BdForm.svelte} +240 -173
- package/src/svelte/context.ts +16 -16
- package/src/svelte/headless.ts +10 -10
- package/src/svelte/index.ts +16 -16
- package/src/vanilla.ts +250 -169
- package/src/vue/{BiabForm.vue → BdForm.vue} +270 -157
- package/src/vue/headless.ts +11 -11
- package/src/vue/index.ts +26 -26
package/src/client.ts
CHANGED
|
@@ -116,6 +116,8 @@ import {
|
|
|
116
116
|
type CustomerPortalUpdateProfileResponse,
|
|
117
117
|
type CustomerProductReviewCreated,
|
|
118
118
|
type CustomerProductReviewList,
|
|
119
|
+
type CustomerProposal,
|
|
120
|
+
type CustomerProposalListResponse,
|
|
119
121
|
type CustomerPushConfig,
|
|
120
122
|
type CustomerQuoteActionResponse,
|
|
121
123
|
type CustomerQuoteDetail,
|
|
@@ -210,6 +212,8 @@ import {
|
|
|
210
212
|
customerPortalUpdateProfileResponseSchema,
|
|
211
213
|
customerProductReviewCreatedSchema,
|
|
212
214
|
customerProductReviewListSchema,
|
|
215
|
+
customerProposalListResponseSchema,
|
|
216
|
+
customerProposalSchema,
|
|
213
217
|
customerPushConfigSchema,
|
|
214
218
|
customerQuoteActionResponseSchema,
|
|
215
219
|
customerQuoteDetailSchema,
|
|
@@ -397,14 +401,14 @@ import {
|
|
|
397
401
|
} from "./contracts.js";
|
|
398
402
|
import {
|
|
399
403
|
accessRejectionFromBody,
|
|
400
|
-
|
|
401
|
-
|
|
404
|
+
BdApiError,
|
|
405
|
+
isBdPlanGateBody,
|
|
402
406
|
} from "./errors.js";
|
|
403
407
|
|
|
404
408
|
export type FetchLike = typeof fetch;
|
|
405
409
|
|
|
406
|
-
/** Options for {@link
|
|
407
|
-
export type
|
|
410
|
+
/** Options for {@link BdApiClient} / {@link createBdApiClient}. */
|
|
411
|
+
export type BdApiClientOptions = {
|
|
408
412
|
baseUrl: string;
|
|
409
413
|
apiKey: string;
|
|
410
414
|
fetch?: FetchLike;
|
|
@@ -505,19 +509,19 @@ function extractErrorMessage(body: unknown, fallback: string) {
|
|
|
505
509
|
}
|
|
506
510
|
|
|
507
511
|
/**
|
|
508
|
-
* Typed client for the
|
|
512
|
+
* Typed client for the BD package HTTP API.
|
|
509
513
|
*
|
|
510
514
|
* @remarks
|
|
511
515
|
* **Alpha:** This SDK is in alpha. Surfaces and behavior may change without semver guarantees.
|
|
512
516
|
* Do not rely on it for production workloads—use development, staging, or experiments only.
|
|
513
517
|
*/
|
|
514
|
-
export class
|
|
518
|
+
export class BdApiClient {
|
|
515
519
|
private readonly baseUrl: string;
|
|
516
520
|
private readonly apiKey: string;
|
|
517
521
|
private readonly fetchImpl: FetchLike;
|
|
518
522
|
private readonly defaultHeaders: HeadersInit | undefined;
|
|
519
523
|
|
|
520
|
-
constructor(options:
|
|
524
|
+
constructor(options: BdApiClientOptions) {
|
|
521
525
|
// Trailing slash is required by the WHATWG URL parser so the relative
|
|
522
526
|
// `path` segments are appended to (rather than replacing) the base path.
|
|
523
527
|
this.baseUrl = options.baseUrl.endsWith("/")
|
|
@@ -539,60 +543,60 @@ export class BiabDevClient {
|
|
|
539
543
|
private readonly siteOrigin: string | undefined;
|
|
540
544
|
|
|
541
545
|
site(siteId: string) {
|
|
542
|
-
return new
|
|
546
|
+
return new BdSiteClient(this, siteId);
|
|
543
547
|
}
|
|
544
548
|
|
|
545
549
|
get emailTemplates() {
|
|
546
|
-
return new
|
|
550
|
+
return new BdEmailTemplatesClient(this);
|
|
547
551
|
}
|
|
548
552
|
|
|
549
553
|
get dashboard() {
|
|
550
|
-
return new
|
|
554
|
+
return new BdDashboardClient(this);
|
|
551
555
|
}
|
|
552
556
|
|
|
553
557
|
get storefront() {
|
|
554
|
-
return new
|
|
558
|
+
return new BdStorefrontClient(this);
|
|
555
559
|
}
|
|
556
560
|
|
|
557
561
|
get cart() {
|
|
558
|
-
return new
|
|
562
|
+
return new BdCartClient(this);
|
|
559
563
|
}
|
|
560
564
|
|
|
561
565
|
get checkout() {
|
|
562
|
-
return new
|
|
566
|
+
return new BdCheckoutClient(this);
|
|
563
567
|
}
|
|
564
568
|
|
|
565
569
|
get coupons() {
|
|
566
|
-
return new
|
|
570
|
+
return new BdCouponsClient(this);
|
|
567
571
|
}
|
|
568
572
|
|
|
569
573
|
get subscriptions() {
|
|
570
|
-
return new
|
|
574
|
+
return new BdSubscriptionsClient(this);
|
|
571
575
|
}
|
|
572
576
|
|
|
573
577
|
get shipping() {
|
|
574
|
-
return new
|
|
578
|
+
return new BdShippingClient(this);
|
|
575
579
|
}
|
|
576
580
|
|
|
577
581
|
/** Customer-portal invitations — currently resend. */
|
|
578
582
|
get customerInvites() {
|
|
579
|
-
return new
|
|
583
|
+
return new BdCustomerInvitesClient(this);
|
|
580
584
|
}
|
|
581
585
|
|
|
582
586
|
get notifications() {
|
|
583
|
-
return new
|
|
587
|
+
return new BdNotificationsClient(this);
|
|
584
588
|
}
|
|
585
589
|
|
|
586
590
|
get address() {
|
|
587
|
-
return new
|
|
591
|
+
return new BdAddressClient(this);
|
|
588
592
|
}
|
|
589
593
|
|
|
590
594
|
get blog() {
|
|
591
|
-
return new
|
|
595
|
+
return new BdBlogClient(this);
|
|
592
596
|
}
|
|
593
597
|
|
|
594
598
|
get reviews() {
|
|
595
|
-
return new
|
|
599
|
+
return new BdReviewsClient(this);
|
|
596
600
|
}
|
|
597
601
|
|
|
598
602
|
/**
|
|
@@ -602,12 +606,12 @@ export class BiabDevClient {
|
|
|
602
606
|
* and gives you a gate to check before starting analytics.
|
|
603
607
|
*/
|
|
604
608
|
get consent() {
|
|
605
|
-
return new
|
|
609
|
+
return new BdConsentClient(this);
|
|
606
610
|
}
|
|
607
611
|
|
|
608
612
|
/** Public job postings — build a careers page on your own domain. */
|
|
609
613
|
get hiring() {
|
|
610
|
-
return new
|
|
614
|
+
return new BdHiringClient(this);
|
|
611
615
|
}
|
|
612
616
|
|
|
613
617
|
/**
|
|
@@ -618,26 +622,26 @@ export class BiabDevClient {
|
|
|
618
622
|
* per document.
|
|
619
623
|
*/
|
|
620
624
|
get legal() {
|
|
621
|
-
return new
|
|
625
|
+
return new BdLegalClient(this);
|
|
622
626
|
}
|
|
623
627
|
|
|
624
628
|
get chatbot() {
|
|
625
|
-
return new
|
|
629
|
+
return new BdChatbotClient(this);
|
|
626
630
|
}
|
|
627
631
|
|
|
628
632
|
get auth() {
|
|
629
|
-
return new
|
|
633
|
+
return new BdAuthClient(this);
|
|
630
634
|
}
|
|
631
635
|
|
|
632
636
|
/**
|
|
633
|
-
* Customer-portal client. Pin to a specific
|
|
637
|
+
* Customer-portal client. Pin to a specific BD organization id so the
|
|
634
638
|
* caller never sees data from any other org (recommended). Omit
|
|
635
639
|
* `organizationId` to fall back to the user's currently-active session
|
|
636
640
|
* org — only use that on first-party hosts where the host already pins
|
|
637
641
|
* the org.
|
|
638
642
|
*/
|
|
639
643
|
customerPortal(organizationId?: string) {
|
|
640
|
-
return new
|
|
644
|
+
return new BdCustomerPortalClient(this, organizationId ?? null);
|
|
641
645
|
}
|
|
642
646
|
|
|
643
647
|
async introspect(): Promise<AuthIntrospectResponse> {
|
|
@@ -674,12 +678,12 @@ export class BiabDevClient {
|
|
|
674
678
|
|
|
675
679
|
// Access gate — 200 (reads, body-only signal) and 402 (writes)
|
|
676
680
|
// both surface as a typed error so consumer code is uniform.
|
|
677
|
-
// Three flavours: plan-required (
|
|
678
|
-
// payment-required (
|
|
679
|
-
// (
|
|
681
|
+
// Three flavours: plan-required (BdFeatureNotEntitledError),
|
|
682
|
+
// payment-required (BdPaymentLapsedError), service-suspended
|
|
683
|
+
// (BdServiceSuspendedError) — all extend BdAccessRejectedError
|
|
680
684
|
// for "catch any" patterns. `unwrapAccess()` is the opt-in
|
|
681
685
|
// Result-shape escape hatch.
|
|
682
|
-
if (
|
|
686
|
+
if (isBdPlanGateBody(body)) {
|
|
683
687
|
throw accessRejectionFromBody({
|
|
684
688
|
body,
|
|
685
689
|
path: url.pathname,
|
|
@@ -688,12 +692,12 @@ export class BiabDevClient {
|
|
|
688
692
|
}
|
|
689
693
|
|
|
690
694
|
if (!response.ok) {
|
|
691
|
-
throw new
|
|
695
|
+
throw new BdApiError({
|
|
692
696
|
status: response.status,
|
|
693
697
|
path: url.pathname,
|
|
694
698
|
message: extractErrorMessage(
|
|
695
699
|
body,
|
|
696
|
-
`
|
|
700
|
+
`BD API request failed with status ${response.status}.`,
|
|
697
701
|
),
|
|
698
702
|
body,
|
|
699
703
|
});
|
|
@@ -703,38 +707,38 @@ export class BiabDevClient {
|
|
|
703
707
|
}
|
|
704
708
|
}
|
|
705
709
|
|
|
706
|
-
export class
|
|
707
|
-
readonly collections:
|
|
708
|
-
readonly rows:
|
|
710
|
+
export class BdSiteClient {
|
|
711
|
+
readonly collections: BdCollectionsClient;
|
|
712
|
+
readonly rows: BdRowsClient;
|
|
709
713
|
/**
|
|
710
714
|
* The org's custom database — the tables from `defineDataModel()`.
|
|
711
715
|
* Distinct from `collections`/`rows`, which are Site Data. See
|
|
712
|
-
* {@link
|
|
716
|
+
* {@link BdDataModelClient}.
|
|
713
717
|
*/
|
|
714
|
-
readonly dataModel:
|
|
718
|
+
readonly dataModel: BdDataModelClient;
|
|
715
719
|
/**
|
|
716
720
|
* Read your site's visitor counts back (the counterpart to the
|
|
717
|
-
* `<
|
|
718
|
-
* {@link
|
|
721
|
+
* `<BDAnalytics/>` tracker, which only records). See
|
|
722
|
+
* {@link BdAnalyticsClient}.
|
|
719
723
|
*/
|
|
720
|
-
readonly analytics:
|
|
724
|
+
readonly analytics: BdAnalyticsClient;
|
|
721
725
|
/**
|
|
722
726
|
* The "Powered by BusinessDash" badge's policy + heartbeat. See
|
|
723
|
-
* {@link
|
|
727
|
+
* {@link BdAttributionClient}.
|
|
724
728
|
*/
|
|
725
|
-
readonly attribution:
|
|
726
|
-
readonly assets:
|
|
727
|
-
readonly actions:
|
|
728
|
-
readonly followers:
|
|
729
|
-
readonly marketingPages:
|
|
729
|
+
readonly attribution: BdAttributionClient;
|
|
730
|
+
readonly assets: BdAssetsClient;
|
|
731
|
+
readonly actions: BdActionsClient;
|
|
732
|
+
readonly followers: BdFollowersClient;
|
|
733
|
+
readonly marketingPages: BdMarketingPagesClient;
|
|
730
734
|
/**
|
|
731
735
|
* Schema-driven marketing flow (Phase 2). Pair with the SDK's
|
|
732
|
-
* `defineSiteMarketingSchema()` builder + the `
|
|
736
|
+
* `defineSiteMarketingSchema()` builder + the `bd sync-schema`
|
|
733
737
|
* CLI for the authoring side; this client is the live-site read
|
|
734
738
|
* path (`getPageBundle`) and the upload entry point for the CLI.
|
|
735
739
|
*/
|
|
736
|
-
readonly marketing:
|
|
737
|
-
readonly parallelPages:
|
|
740
|
+
readonly marketing: BdMarketingClient;
|
|
741
|
+
readonly parallelPages: BdParallelPagesClient;
|
|
738
742
|
/**
|
|
739
743
|
* Booking and conference calls.
|
|
740
744
|
*
|
|
@@ -742,24 +746,24 @@ export class BiabDevSiteClient {
|
|
|
742
746
|
* resource, which is why the OpenAPI generator — which reads this file —
|
|
743
747
|
* never saw it, and why no non-JS starter had scheduling at all.
|
|
744
748
|
*/
|
|
745
|
-
readonly scheduling:
|
|
749
|
+
readonly scheduling: BdSchedulingClient;
|
|
746
750
|
|
|
747
751
|
constructor(
|
|
748
|
-
readonly client:
|
|
752
|
+
readonly client: BdApiClient,
|
|
749
753
|
readonly siteId: string,
|
|
750
754
|
) {
|
|
751
|
-
this.collections = new
|
|
752
|
-
this.scheduling = new
|
|
753
|
-
this.rows = new
|
|
754
|
-
this.dataModel = new
|
|
755
|
-
this.analytics = new
|
|
756
|
-
this.attribution = new
|
|
757
|
-
this.assets = new
|
|
758
|
-
this.actions = new
|
|
759
|
-
this.followers = new
|
|
760
|
-
this.marketingPages = new
|
|
761
|
-
this.marketing = new
|
|
762
|
-
this.parallelPages = new
|
|
755
|
+
this.collections = new BdCollectionsClient(client, siteId);
|
|
756
|
+
this.scheduling = new BdSchedulingClient(client, siteId);
|
|
757
|
+
this.rows = new BdRowsClient(client, siteId);
|
|
758
|
+
this.dataModel = new BdDataModelClient(client, siteId);
|
|
759
|
+
this.analytics = new BdAnalyticsClient(client, siteId);
|
|
760
|
+
this.attribution = new BdAttributionClient(client, siteId);
|
|
761
|
+
this.assets = new BdAssetsClient(client, siteId);
|
|
762
|
+
this.actions = new BdActionsClient(client, siteId);
|
|
763
|
+
this.followers = new BdFollowersClient(client, siteId);
|
|
764
|
+
this.marketingPages = new BdMarketingPagesClient(client, siteId);
|
|
765
|
+
this.marketing = new BdMarketingClient(client, siteId);
|
|
766
|
+
this.parallelPages = new BdParallelPagesClient(client, siteId);
|
|
763
767
|
}
|
|
764
768
|
|
|
765
769
|
/**
|
|
@@ -888,9 +892,9 @@ export type ParallelPagesRenderResponse = z.infer<
|
|
|
888
892
|
* return <RenderTemplate bundle={bundle} />;
|
|
889
893
|
* }
|
|
890
894
|
*/
|
|
891
|
-
export class
|
|
895
|
+
export class BdParallelPagesClient {
|
|
892
896
|
constructor(
|
|
893
|
-
private readonly client:
|
|
897
|
+
private readonly client: BdApiClient,
|
|
894
898
|
private readonly siteId: string,
|
|
895
899
|
) {}
|
|
896
900
|
|
|
@@ -996,9 +1000,9 @@ export function clearMarketingCache(siteId: string): void {
|
|
|
996
1000
|
* checksum = `noop: true`).
|
|
997
1001
|
* - `getLocales()` — enabled locales + brand-token map.
|
|
998
1002
|
*/
|
|
999
|
-
export class
|
|
1003
|
+
export class BdMarketingClient {
|
|
1000
1004
|
constructor(
|
|
1001
|
-
private readonly client:
|
|
1005
|
+
private readonly client: BdApiClient,
|
|
1002
1006
|
private readonly siteId: string,
|
|
1003
1007
|
) {}
|
|
1004
1008
|
|
|
@@ -1080,15 +1084,15 @@ export class BiabDevMarketingClient {
|
|
|
1080
1084
|
}
|
|
1081
1085
|
|
|
1082
1086
|
/**
|
|
1083
|
-
* Bulk-upsert section values. Used by `
|
|
1084
|
-
* local JSON content to
|
|
1087
|
+
* Bulk-upsert section values. Used by `bd sync-content` to push
|
|
1088
|
+
* local JSON content to BD. Server caps each request at 256 items;
|
|
1085
1089
|
* larger imports are batched by the CLI. Per-item failures are
|
|
1086
1090
|
* reported in the response (`results[].ok === false`) without aborting
|
|
1087
1091
|
* the rest of the batch.
|
|
1088
1092
|
*
|
|
1089
1093
|
* The CLI's `--lax` flag sets `validate: false` for first-time imports
|
|
1090
1094
|
* of legacy content that doesn't yet match the published schema —
|
|
1091
|
-
* useful so writers can pull existing content into
|
|
1095
|
+
* useful so writers can pull existing content into BD and fix
|
|
1092
1096
|
* validation errors in the dashboard incrementally.
|
|
1093
1097
|
*/
|
|
1094
1098
|
async publishSections(
|
|
@@ -1121,7 +1125,7 @@ export class BiabDevMarketingClient {
|
|
|
1121
1125
|
|
|
1122
1126
|
/**
|
|
1123
1127
|
* Process-wide cache for marketing-page payloads, keyed by `(siteId, pageKey)`.
|
|
1124
|
-
* Shared across `
|
|
1128
|
+
* Shared across `BdMarketingPagesClient` instances so that
|
|
1125
1129
|
* `prefetch(pageKey)` warms the same store `get(pageKey)` reads on demand.
|
|
1126
1130
|
*
|
|
1127
1131
|
* Lives on a module-level `Map` rather than instance state because consumers
|
|
@@ -1166,9 +1170,9 @@ export function clearMarketingPageCache(
|
|
|
1166
1170
|
* `list()` (no payloads) with `get(pageKey)` / `prefetch(pageKey)` to load
|
|
1167
1171
|
* pages on demand instead of paying the full-content cost up front.
|
|
1168
1172
|
*/
|
|
1169
|
-
export class
|
|
1173
|
+
export class BdMarketingPagesClient {
|
|
1170
1174
|
constructor(
|
|
1171
|
-
private readonly client:
|
|
1175
|
+
private readonly client: BdApiClient,
|
|
1172
1176
|
private readonly siteId: string,
|
|
1173
1177
|
) {}
|
|
1174
1178
|
|
|
@@ -1234,9 +1238,9 @@ export class BiabDevMarketingPagesClient {
|
|
|
1234
1238
|
}
|
|
1235
1239
|
}
|
|
1236
1240
|
|
|
1237
|
-
export class
|
|
1241
|
+
export class BdCollectionsClient {
|
|
1238
1242
|
constructor(
|
|
1239
|
-
private readonly client:
|
|
1243
|
+
private readonly client: BdApiClient,
|
|
1240
1244
|
private readonly siteId: string,
|
|
1241
1245
|
) {}
|
|
1242
1246
|
|
|
@@ -1268,9 +1272,9 @@ export class BiabDevCollectionsClient {
|
|
|
1268
1272
|
}
|
|
1269
1273
|
}
|
|
1270
1274
|
|
|
1271
|
-
export class
|
|
1275
|
+
export class BdRowsClient {
|
|
1272
1276
|
constructor(
|
|
1273
|
-
private readonly client:
|
|
1277
|
+
private readonly client: BdApiClient,
|
|
1274
1278
|
private readonly siteId: string,
|
|
1275
1279
|
) {}
|
|
1276
1280
|
|
|
@@ -1318,11 +1322,11 @@ export class BiabDevRowsClient {
|
|
|
1318
1322
|
|
|
1319
1323
|
/**
|
|
1320
1324
|
* Read rows out of the org's CUSTOM DATABASE — the tables you declare with
|
|
1321
|
-
* `defineDataModel()` and push with `
|
|
1325
|
+
* `defineDataModel()` and push with `bd sync-data-model`.
|
|
1322
1326
|
*
|
|
1323
1327
|
* ⚠️ Not the same thing as `.collections` / `.rows`. Those read Site Data (the
|
|
1324
1328
|
* site builder's tables, `site_data_rows`). Rows seeded with
|
|
1325
|
-
* `
|
|
1329
|
+
* `bd sync-records` live in `org_object_records` and are reachable only
|
|
1326
1330
|
* through here — no `collections:*` call will ever return one.
|
|
1327
1331
|
*
|
|
1328
1332
|
* Requires the `metadata:read_records` scope. What a key can actually read is
|
|
@@ -1338,7 +1342,7 @@ export class BiabDevRowsClient {
|
|
|
1338
1342
|
* private one never is. Open a table by declaring `visibility` in your model.
|
|
1339
1343
|
*
|
|
1340
1344
|
* ```ts
|
|
1341
|
-
* const result = await
|
|
1345
|
+
* const result = await bd.site(siteId).dataModel.listRecords({
|
|
1342
1346
|
* object: TECH_OBJECT_ID, // the universalIdentifier from your config
|
|
1343
1347
|
* });
|
|
1344
1348
|
* if (!result.available) return <UpgradeCard feature={result.requiredFeature} />;
|
|
@@ -1348,9 +1352,9 @@ export class BiabDevRowsClient {
|
|
|
1348
1352
|
* }
|
|
1349
1353
|
* ```
|
|
1350
1354
|
*/
|
|
1351
|
-
export class
|
|
1355
|
+
export class BdDataModelClient {
|
|
1352
1356
|
constructor(
|
|
1353
|
-
private readonly client:
|
|
1357
|
+
private readonly client: BdApiClient,
|
|
1354
1358
|
private readonly siteId: string,
|
|
1355
1359
|
) {}
|
|
1356
1360
|
|
|
@@ -1407,20 +1411,20 @@ export class BiabDevDataModelClient {
|
|
|
1407
1411
|
/**
|
|
1408
1412
|
* Read your site's visitor counts back.
|
|
1409
1413
|
*
|
|
1410
|
-
* The `<
|
|
1414
|
+
* The `<BDAnalytics/>` tracker (`@businessdash/sdk/react-analytics`) RECORDS
|
|
1411
1415
|
* pageviews; this READS the totals, so you can put a number on the page instead
|
|
1412
1416
|
* of only feeding the dashboard.
|
|
1413
1417
|
*
|
|
1414
1418
|
* ```ts
|
|
1415
1419
|
* // Site-wide, all time
|
|
1416
|
-
* const all = await
|
|
1420
|
+
* const all = await bd.site(siteId).analytics.pageViews();
|
|
1417
1421
|
* if (all.available) console.log(`${all.total.views} views`);
|
|
1418
1422
|
*
|
|
1419
1423
|
* // One page, last 30 days
|
|
1420
|
-
* const home = await
|
|
1424
|
+
* const home = await bd.site(siteId).analytics.pageViews({ paths: ['/'], days: 30 });
|
|
1421
1425
|
*
|
|
1422
1426
|
* // A batch of pages in one round-trip
|
|
1423
|
-
* const list = await
|
|
1427
|
+
* const list = await bd.site(siteId).analytics.pageViews({
|
|
1424
1428
|
* paths: ['/tech/typescript', '/tech/rust'],
|
|
1425
1429
|
* });
|
|
1426
1430
|
* // list.paths → [{ path, views, visitors }, …], every requested path present
|
|
@@ -1430,9 +1434,9 @@ export class BiabDevDataModelClient {
|
|
|
1430
1434
|
* Requires the `analytics.web` entitlement — an org without it gets
|
|
1431
1435
|
* `{ available: false }`, so branch on `.available`.
|
|
1432
1436
|
*/
|
|
1433
|
-
export class
|
|
1437
|
+
export class BdAnalyticsClient {
|
|
1434
1438
|
constructor(
|
|
1435
|
-
private readonly client:
|
|
1439
|
+
private readonly client: BdApiClient,
|
|
1436
1440
|
private readonly siteId: string,
|
|
1437
1441
|
) {}
|
|
1438
1442
|
|
|
@@ -1465,7 +1469,7 @@ export class BiabDevAnalyticsClient {
|
|
|
1465
1469
|
* to a 30-day window.
|
|
1466
1470
|
*
|
|
1467
1471
|
* ```ts
|
|
1468
|
-
* const ai = await
|
|
1472
|
+
* const ai = await bd.site(siteId).analytics.aiVisibility({ days: 30 });
|
|
1469
1473
|
* if (ai.available) {
|
|
1470
1474
|
* for (const c of ai.crawlers)
|
|
1471
1475
|
* console.log(`${c.name}: ${c.fetches} fetches over ${c.distinctPages} pages`);
|
|
@@ -1495,9 +1499,9 @@ export class BiabDevAnalyticsClient {
|
|
|
1495
1499
|
* verifies the badge by fetching your live domain, not by trusting this call. So
|
|
1496
1500
|
* don't build logic on the heartbeat; do honor `policy().required`.
|
|
1497
1501
|
*/
|
|
1498
|
-
export class
|
|
1502
|
+
export class BdAttributionClient {
|
|
1499
1503
|
constructor(
|
|
1500
|
-
private readonly client:
|
|
1504
|
+
private readonly client: BdApiClient,
|
|
1501
1505
|
private readonly siteId: string,
|
|
1502
1506
|
) {}
|
|
1503
1507
|
|
|
@@ -1531,9 +1535,9 @@ export class BiabDevAttributionClient {
|
|
|
1531
1535
|
}
|
|
1532
1536
|
}
|
|
1533
1537
|
|
|
1534
|
-
export class
|
|
1538
|
+
export class BdAssetsClient {
|
|
1535
1539
|
constructor(
|
|
1536
|
-
private readonly client:
|
|
1540
|
+
private readonly client: BdApiClient,
|
|
1537
1541
|
private readonly siteId: string,
|
|
1538
1542
|
) {}
|
|
1539
1543
|
|
|
@@ -1549,9 +1553,9 @@ export class BiabDevAssetsClient {
|
|
|
1549
1553
|
}
|
|
1550
1554
|
}
|
|
1551
1555
|
|
|
1552
|
-
export class
|
|
1556
|
+
export class BdActionsClient {
|
|
1553
1557
|
constructor(
|
|
1554
|
-
private readonly client:
|
|
1558
|
+
private readonly client: BdApiClient,
|
|
1555
1559
|
private readonly siteId: string,
|
|
1556
1560
|
) {}
|
|
1557
1561
|
|
|
@@ -1570,8 +1574,8 @@ export class BiabDevActionsClient {
|
|
|
1570
1574
|
}
|
|
1571
1575
|
}
|
|
1572
1576
|
|
|
1573
|
-
export class
|
|
1574
|
-
constructor(private readonly client:
|
|
1577
|
+
export class BdEmailTemplatesClient {
|
|
1578
|
+
constructor(private readonly client: BdApiClient) {}
|
|
1575
1579
|
|
|
1576
1580
|
async list(
|
|
1577
1581
|
input: ListEmailTemplatesInput = {},
|
|
@@ -1620,9 +1624,9 @@ export class BiabDevEmailTemplatesClient {
|
|
|
1620
1624
|
}
|
|
1621
1625
|
}
|
|
1622
1626
|
|
|
1623
|
-
export class
|
|
1627
|
+
export class BdFollowersClient {
|
|
1624
1628
|
constructor(
|
|
1625
|
-
private readonly client:
|
|
1629
|
+
private readonly client: BdApiClient,
|
|
1626
1630
|
private readonly siteId: string,
|
|
1627
1631
|
) {}
|
|
1628
1632
|
|
|
@@ -1679,8 +1683,8 @@ export class BiabDevFollowersClient {
|
|
|
1679
1683
|
}
|
|
1680
1684
|
}
|
|
1681
1685
|
|
|
1682
|
-
export class
|
|
1683
|
-
constructor(private readonly client:
|
|
1686
|
+
export class BdDashboardClient {
|
|
1687
|
+
constructor(private readonly client: BdApiClient) {}
|
|
1684
1688
|
|
|
1685
1689
|
async createSession(): Promise<DashboardSessionResponse> {
|
|
1686
1690
|
return this.client.request({
|
|
@@ -1691,13 +1695,13 @@ export class BiabDevDashboardClient {
|
|
|
1691
1695
|
}
|
|
1692
1696
|
}
|
|
1693
1697
|
|
|
1694
|
-
export class
|
|
1695
|
-
constructor(private readonly client:
|
|
1698
|
+
export class BdStorefrontClient {
|
|
1699
|
+
constructor(private readonly client: BdApiClient) {}
|
|
1696
1700
|
|
|
1697
1701
|
/**
|
|
1698
1702
|
* Legacy embed-session mint (kept for iframe-widget consumers).
|
|
1699
1703
|
* The programmatic methods below let consumer sites render their
|
|
1700
|
-
* own native product catalog using
|
|
1704
|
+
* own native product catalog using BD as the data layer.
|
|
1701
1705
|
*/
|
|
1702
1706
|
async createSession(
|
|
1703
1707
|
input?: StorefrontSessionInput,
|
|
@@ -1731,7 +1735,7 @@ export class BiabDevStorefrontClient {
|
|
|
1731
1735
|
* ```ts
|
|
1732
1736
|
* let remaining = 1;
|
|
1733
1737
|
* while (remaining > 0) {
|
|
1734
|
-
* const res = await
|
|
1738
|
+
* const res = await bd.storefront.syncToStripe();
|
|
1735
1739
|
* remaining = res.remaining;
|
|
1736
1740
|
* }
|
|
1737
1741
|
* ```
|
|
@@ -1818,7 +1822,7 @@ export class BiabDevStorefrontClient {
|
|
|
1818
1822
|
|
|
1819
1823
|
/**
|
|
1820
1824
|
* Full product detail with variants + per-image rows. Returns 404
|
|
1821
|
-
* via `
|
|
1825
|
+
* via `BdApiError` if the product isn't live or doesn't belong
|
|
1822
1826
|
* to the org bound to the API key.
|
|
1823
1827
|
*/
|
|
1824
1828
|
/**
|
|
@@ -1833,7 +1837,7 @@ export class BiabDevStorefrontClient {
|
|
|
1833
1837
|
* The platform withholds the raw URL from every product payload on purpose:
|
|
1834
1838
|
* CAD files are the largest thing it serves and are the org's intellectual
|
|
1835
1839
|
* property, so a catalog of naked URLs is a design library published to
|
|
1836
|
-
* anyone willing to write a loop. This endpoint requires a `
|
|
1840
|
+
* anyone willing to write a loop. This endpoint requires a `bd_cad` cookie
|
|
1837
1841
|
* on the incoming request, rate-limits per IP, and re-checks the
|
|
1838
1842
|
* `ecommerce.product_3d` entitlement before answering.
|
|
1839
1843
|
*
|
|
@@ -1904,9 +1908,9 @@ export class BiabDevStorefrontClient {
|
|
|
1904
1908
|
}
|
|
1905
1909
|
}
|
|
1906
1910
|
|
|
1907
|
-
export class
|
|
1911
|
+
export class BdCartClient {
|
|
1908
1912
|
constructor(
|
|
1909
|
-
private readonly client:
|
|
1913
|
+
private readonly client: BdApiClient,
|
|
1910
1914
|
private readonly visitorToken: string | null = null,
|
|
1911
1915
|
private readonly sessionToken: string | null = null,
|
|
1912
1916
|
) {}
|
|
@@ -1916,8 +1920,8 @@ export class BiabDevCartClient {
|
|
|
1916
1920
|
* own httpOnly cookie). Same shopper across page loads, no
|
|
1917
1921
|
* sign-in required.
|
|
1918
1922
|
*/
|
|
1919
|
-
forVisitor(visitorToken: string):
|
|
1920
|
-
return new
|
|
1923
|
+
forVisitor(visitorToken: string): BdCartClient {
|
|
1924
|
+
return new BdCartClient(this.client, visitorToken, null);
|
|
1921
1925
|
}
|
|
1922
1926
|
|
|
1923
1927
|
/**
|
|
@@ -1925,14 +1929,14 @@ export class BiabDevCartClient {
|
|
|
1925
1929
|
* Carts are now keyed to the signed-in customer; persists
|
|
1926
1930
|
* across devices.
|
|
1927
1931
|
*/
|
|
1928
|
-
withSession(sessionToken: string):
|
|
1929
|
-
return new
|
|
1932
|
+
withSession(sessionToken: string): BdCartClient {
|
|
1933
|
+
return new BdCartClient(this.client, null, sessionToken);
|
|
1930
1934
|
}
|
|
1931
1935
|
|
|
1932
1936
|
private headers(): HeadersInit {
|
|
1933
1937
|
const out: Record<string, string> = {};
|
|
1934
|
-
if (this.visitorToken) out["X-
|
|
1935
|
-
if (this.sessionToken) out["X-
|
|
1938
|
+
if (this.visitorToken) out["X-BD-Cart-Visitor"] = this.visitorToken;
|
|
1939
|
+
if (this.sessionToken) out["X-BD-Session-Token"] = this.sessionToken;
|
|
1936
1940
|
return out;
|
|
1937
1941
|
}
|
|
1938
1942
|
|
|
@@ -2043,9 +2047,9 @@ export class BiabDevCartClient {
|
|
|
2043
2047
|
}
|
|
2044
2048
|
}
|
|
2045
2049
|
|
|
2046
|
-
export class
|
|
2050
|
+
export class BdCheckoutClient {
|
|
2047
2051
|
constructor(
|
|
2048
|
-
private readonly client:
|
|
2052
|
+
private readonly client: BdApiClient,
|
|
2049
2053
|
private readonly visitorToken: string | null = null,
|
|
2050
2054
|
private readonly sessionToken: string | null = null,
|
|
2051
2055
|
) {}
|
|
@@ -2054,8 +2058,8 @@ export class BiabDevCheckoutClient {
|
|
|
2054
2058
|
* Authenticate the start-from-cart call as an anonymous shopper
|
|
2055
2059
|
* (visitor-token cart). Same UUID you used with `client.cart.forVisitor(...)`.
|
|
2056
2060
|
*/
|
|
2057
|
-
forVisitor(visitorToken: string):
|
|
2058
|
-
return new
|
|
2061
|
+
forVisitor(visitorToken: string): BdCheckoutClient {
|
|
2062
|
+
return new BdCheckoutClient(this.client, visitorToken, null);
|
|
2059
2063
|
}
|
|
2060
2064
|
|
|
2061
2065
|
/**
|
|
@@ -2063,14 +2067,14 @@ export class BiabDevCheckoutClient {
|
|
|
2063
2067
|
* The Stripe Checkout Session will be created against this
|
|
2064
2068
|
* customer's saved cart.
|
|
2065
2069
|
*/
|
|
2066
|
-
withSession(sessionToken: string):
|
|
2067
|
-
return new
|
|
2070
|
+
withSession(sessionToken: string): BdCheckoutClient {
|
|
2071
|
+
return new BdCheckoutClient(this.client, null, sessionToken);
|
|
2068
2072
|
}
|
|
2069
2073
|
|
|
2070
2074
|
private headers(): HeadersInit {
|
|
2071
2075
|
const out: Record<string, string> = {};
|
|
2072
|
-
if (this.visitorToken) out["X-
|
|
2073
|
-
if (this.sessionToken) out["X-
|
|
2076
|
+
if (this.visitorToken) out["X-BD-Cart-Visitor"] = this.visitorToken;
|
|
2077
|
+
if (this.sessionToken) out["X-BD-Session-Token"] = this.sessionToken;
|
|
2074
2078
|
return out;
|
|
2075
2079
|
}
|
|
2076
2080
|
|
|
@@ -2092,7 +2096,7 @@ export class BiabDevCheckoutClient {
|
|
|
2092
2096
|
}
|
|
2093
2097
|
|
|
2094
2098
|
/**
|
|
2095
|
-
* Convert the caller's saved
|
|
2099
|
+
* Convert the caller's saved BD cart (resolved via visitor token
|
|
2096
2100
|
* or session token) into a Stripe Checkout Session. Returns the
|
|
2097
2101
|
* Stripe-hosted URL; redirect the browser there to collect payment.
|
|
2098
2102
|
*
|
|
@@ -2126,7 +2130,7 @@ export class BiabDevCheckoutClient {
|
|
|
2126
2130
|
}
|
|
2127
2131
|
|
|
2128
2132
|
/**
|
|
2129
|
-
* White-glove Google Places proxy.
|
|
2133
|
+
* White-glove Google Places proxy. BD owns the API key — consumer
|
|
2130
2134
|
* code never sees it. Use at the checkout delivery-address input
|
|
2131
2135
|
* to give shoppers text-search predictions + verify deliverability
|
|
2132
2136
|
* before submitting the order.
|
|
@@ -2151,7 +2155,7 @@ export class BiabDevCheckoutClient {
|
|
|
2151
2155
|
* // When user picks a prediction:
|
|
2152
2156
|
* const detail = await client.address.getDetails(prediction.place_id);
|
|
2153
2157
|
* if (detail.enabled && detail.address) {
|
|
2154
|
-
* const form =
|
|
2158
|
+
* const form = BdAddressClient.googleToFormValues(detail.address);
|
|
2155
2159
|
* reactHookForm.reset(form);
|
|
2156
2160
|
* }
|
|
2157
2161
|
*
|
|
@@ -2160,8 +2164,8 @@ export class BiabDevCheckoutClient {
|
|
|
2160
2164
|
* if (!v.isVerified) showDidYouMean(v.googleAddress);
|
|
2161
2165
|
* ```
|
|
2162
2166
|
*/
|
|
2163
|
-
export class
|
|
2164
|
-
constructor(private readonly client:
|
|
2167
|
+
export class BdAddressClient {
|
|
2168
|
+
constructor(private readonly client: BdApiClient) {}
|
|
2165
2169
|
|
|
2166
2170
|
async search(input: AddressSearchInput): Promise<AddressSearchResponse> {
|
|
2167
2171
|
const body = addressSearchInputSchema.parse(input);
|
|
@@ -2232,8 +2236,8 @@ export class BiabDevAddressClient {
|
|
|
2232
2236
|
* dashboard's "Sync to Stripe" action — otherwise `startCheckout`
|
|
2233
2237
|
* returns 409 `subscription_not_synced`.
|
|
2234
2238
|
*/
|
|
2235
|
-
export class
|
|
2236
|
-
constructor(private readonly client:
|
|
2239
|
+
export class BdSubscriptionsClient {
|
|
2240
|
+
constructor(private readonly client: BdApiClient) {}
|
|
2237
2241
|
|
|
2238
2242
|
async list(): Promise<SubscriptionOfferingsListResponse> {
|
|
2239
2243
|
return this.client.request({
|
|
@@ -2263,8 +2267,8 @@ export class BiabDevSubscriptionsClient {
|
|
|
2263
2267
|
}
|
|
2264
2268
|
}
|
|
2265
2269
|
|
|
2266
|
-
export class
|
|
2267
|
-
constructor(private readonly client:
|
|
2270
|
+
export class BdCouponsClient {
|
|
2271
|
+
constructor(private readonly client: BdApiClient) {}
|
|
2268
2272
|
|
|
2269
2273
|
/**
|
|
2270
2274
|
* Validate a coupon code against the org's Stripe-connected
|
|
@@ -2297,7 +2301,7 @@ export class BiabDevCouponsClient {
|
|
|
2297
2301
|
* Requires a SECRET key holding `storefront:write`.
|
|
2298
2302
|
*
|
|
2299
2303
|
* ```ts
|
|
2300
|
-
* const { coupon, stripeSynced } = await
|
|
2304
|
+
* const { coupon, stripeSynced } = await bd.coupons.create({
|
|
2301
2305
|
* code: 'WELCOME10',
|
|
2302
2306
|
* discountType: 'percent',
|
|
2303
2307
|
* value: 10,
|
|
@@ -2339,10 +2343,10 @@ export class BiabDevCouponsClient {
|
|
|
2339
2343
|
|
|
2340
2344
|
/**
|
|
2341
2345
|
* Shipping: rate lookups + on-demand tracking. White-glove model —
|
|
2342
|
-
*
|
|
2346
|
+
* BD owns the carrier integration; consumer code never sees the
|
|
2343
2347
|
* underlying provider name. Gated on `ecommerce.shipping` so calls
|
|
2344
2348
|
* from orgs on the Launch plan return the standard plan-gate body
|
|
2345
|
-
* via {@link
|
|
2349
|
+
* via {@link BdApiError} (status 403).
|
|
2346
2350
|
*
|
|
2347
2351
|
* @example
|
|
2348
2352
|
* ```ts
|
|
@@ -2359,25 +2363,25 @@ export class BiabDevCouponsClient {
|
|
|
2359
2363
|
* }
|
|
2360
2364
|
* ```
|
|
2361
2365
|
*/
|
|
2362
|
-
export class
|
|
2366
|
+
export class BdShippingClient {
|
|
2363
2367
|
constructor(
|
|
2364
|
-
private readonly client:
|
|
2368
|
+
private readonly client: BdApiClient,
|
|
2365
2369
|
private readonly visitorToken: string | null = null,
|
|
2366
2370
|
private readonly sessionToken: string | null = null,
|
|
2367
2371
|
) {}
|
|
2368
2372
|
|
|
2369
|
-
forVisitor(visitorToken: string):
|
|
2370
|
-
return new
|
|
2373
|
+
forVisitor(visitorToken: string): BdShippingClient {
|
|
2374
|
+
return new BdShippingClient(this.client, visitorToken, null);
|
|
2371
2375
|
}
|
|
2372
2376
|
|
|
2373
|
-
withSession(sessionToken: string):
|
|
2374
|
-
return new
|
|
2377
|
+
withSession(sessionToken: string): BdShippingClient {
|
|
2378
|
+
return new BdShippingClient(this.client, null, sessionToken);
|
|
2375
2379
|
}
|
|
2376
2380
|
|
|
2377
2381
|
private headers(): HeadersInit {
|
|
2378
2382
|
const out: Record<string, string> = {};
|
|
2379
|
-
if (this.visitorToken) out["X-
|
|
2380
|
-
if (this.sessionToken) out["X-
|
|
2383
|
+
if (this.visitorToken) out["X-BD-Cart-Visitor"] = this.visitorToken;
|
|
2384
|
+
if (this.sessionToken) out["X-BD-Session-Token"] = this.sessionToken;
|
|
2381
2385
|
return out;
|
|
2382
2386
|
}
|
|
2383
2387
|
|
|
@@ -2448,24 +2452,22 @@ export class BiabDevShippingClient {
|
|
|
2448
2452
|
* - `order.return_label_created`
|
|
2449
2453
|
*
|
|
2450
2454
|
* The webhook payload is JSON + signed with the customer's saved
|
|
2451
|
-
* `webhookSigningSecret` via `X-
|
|
2455
|
+
* `webhookSigningSecret` via `X-BD-Signature: <hex hmac-sha256>`.
|
|
2452
2456
|
* Consumer's receiver verifies via:
|
|
2453
2457
|
* crypto.createHmac('sha256', secret).update(rawBody).digest('hex')
|
|
2454
2458
|
*/
|
|
2455
|
-
export class
|
|
2459
|
+
export class BdNotificationsClient {
|
|
2456
2460
|
constructor(
|
|
2457
|
-
private readonly client:
|
|
2461
|
+
private readonly client: BdApiClient,
|
|
2458
2462
|
private readonly sessionToken: string | null = null,
|
|
2459
2463
|
) {}
|
|
2460
2464
|
|
|
2461
|
-
withSession(sessionToken: string):
|
|
2462
|
-
return new
|
|
2465
|
+
withSession(sessionToken: string): BdNotificationsClient {
|
|
2466
|
+
return new BdNotificationsClient(this.client, sessionToken);
|
|
2463
2467
|
}
|
|
2464
2468
|
|
|
2465
2469
|
private headers(): HeadersInit {
|
|
2466
|
-
return this.sessionToken
|
|
2467
|
-
? { "X-BIAB-Session-Token": this.sessionToken }
|
|
2468
|
-
: {};
|
|
2470
|
+
return this.sessionToken ? { "X-BD-Session-Token": this.sessionToken } : {};
|
|
2469
2471
|
}
|
|
2470
2472
|
|
|
2471
2473
|
async getPreferences(): Promise<CustomerNotificationPreferencesResponse> {
|
|
@@ -2529,9 +2531,9 @@ export class BiabDevNotificationsClient {
|
|
|
2529
2531
|
}
|
|
2530
2532
|
}
|
|
2531
2533
|
|
|
2532
|
-
export class
|
|
2534
|
+
export class BdBlogClient {
|
|
2533
2535
|
constructor(
|
|
2534
|
-
private readonly client:
|
|
2536
|
+
private readonly client: BdApiClient,
|
|
2535
2537
|
private readonly sessionToken: string | null = null,
|
|
2536
2538
|
) {}
|
|
2537
2539
|
|
|
@@ -2546,14 +2548,12 @@ export class BiabDevBlogClient {
|
|
|
2546
2548
|
* await client.blog().withSession(token).postComment(slug, { content });
|
|
2547
2549
|
* ```
|
|
2548
2550
|
*/
|
|
2549
|
-
withSession(sessionToken: string):
|
|
2550
|
-
return new
|
|
2551
|
+
withSession(sessionToken: string): BdBlogClient {
|
|
2552
|
+
return new BdBlogClient(this.client, sessionToken);
|
|
2551
2553
|
}
|
|
2552
2554
|
|
|
2553
2555
|
private headers(): HeadersInit {
|
|
2554
|
-
return this.sessionToken
|
|
2555
|
-
? { "X-BIAB-Session-Token": this.sessionToken }
|
|
2556
|
-
: {};
|
|
2556
|
+
return this.sessionToken ? { "X-BD-Session-Token": this.sessionToken } : {};
|
|
2557
2557
|
}
|
|
2558
2558
|
|
|
2559
2559
|
/**
|
|
@@ -2698,8 +2698,8 @@ export class BiabDevBlogClient {
|
|
|
2698
2698
|
* }
|
|
2699
2699
|
* ```
|
|
2700
2700
|
*/
|
|
2701
|
-
export class
|
|
2702
|
-
constructor(private readonly client:
|
|
2701
|
+
export class BdReviewsClient {
|
|
2702
|
+
constructor(private readonly client: BdApiClient) {}
|
|
2703
2703
|
|
|
2704
2704
|
/**
|
|
2705
2705
|
* One page of the org's public reviews, newest-first. `limit` defaults to
|
|
@@ -2741,8 +2741,8 @@ export class BiabDevReviewsClient {
|
|
|
2741
2741
|
* }
|
|
2742
2742
|
* ```
|
|
2743
2743
|
*/
|
|
2744
|
-
export class
|
|
2745
|
-
constructor(private readonly client:
|
|
2744
|
+
export class BdHiringClient {
|
|
2745
|
+
constructor(private readonly client: BdApiClient) {}
|
|
2746
2746
|
|
|
2747
2747
|
/**
|
|
2748
2748
|
* One page of open postings, newest-first. `limit` defaults to the server
|
|
@@ -2807,8 +2807,8 @@ export class BiabDevHiringClient {
|
|
|
2807
2807
|
* const privacy = await client.legal.get("privacy");
|
|
2808
2808
|
* ```
|
|
2809
2809
|
*/
|
|
2810
|
-
export class
|
|
2811
|
-
constructor(private readonly client:
|
|
2810
|
+
export class BdLegalClient {
|
|
2811
|
+
constructor(private readonly client: BdApiClient) {}
|
|
2812
2812
|
|
|
2813
2813
|
/**
|
|
2814
2814
|
* Every published document, plus the header/footer presentation.
|
|
@@ -2857,12 +2857,12 @@ const consentStateSchema = z.object({
|
|
|
2857
2857
|
* that could read or write another org's consent — consent is given to a
|
|
2858
2858
|
* controller, and one controller's record is not another's to act on.
|
|
2859
2859
|
*
|
|
2860
|
-
* The visitor is identified by an `x-
|
|
2860
|
+
* The visitor is identified by an `x-bd-visitor` header carrying an opaque id
|
|
2861
2861
|
* from the caller's own first-party cookie. `@businessdash/sdk/consent` manages
|
|
2862
2862
|
* that for you; these methods are the transport underneath it.
|
|
2863
2863
|
*/
|
|
2864
|
-
export class
|
|
2865
|
-
constructor(private readonly client:
|
|
2864
|
+
export class BdConsentClient {
|
|
2865
|
+
constructor(private readonly client: BdApiClient) {}
|
|
2866
2866
|
|
|
2867
2867
|
/** The notice to show, and what this visitor currently allows. */
|
|
2868
2868
|
async get(visitorKey?: string | null): Promise<{
|
|
@@ -2876,7 +2876,7 @@ export class BiabDevConsentClient {
|
|
|
2876
2876
|
return this.client.request({
|
|
2877
2877
|
path: "consent",
|
|
2878
2878
|
responseSchema: consentStateSchema,
|
|
2879
|
-
...(visitorKey ? { headers: { "x-
|
|
2879
|
+
...(visitorKey ? { headers: { "x-bd-visitor": visitorKey } } : {}),
|
|
2880
2880
|
});
|
|
2881
2881
|
}
|
|
2882
2882
|
|
|
@@ -2900,14 +2900,14 @@ export class BiabDevConsentClient {
|
|
|
2900
2900
|
noticeVersion: input.noticeVersion,
|
|
2901
2901
|
source: input.source ?? "banner",
|
|
2902
2902
|
},
|
|
2903
|
-
headers: { "x-
|
|
2903
|
+
headers: { "x-bd-visitor": input.visitorKey },
|
|
2904
2904
|
responseSchema: z.object({ ok: z.boolean() }),
|
|
2905
2905
|
});
|
|
2906
2906
|
}
|
|
2907
2907
|
}
|
|
2908
2908
|
|
|
2909
|
-
export class
|
|
2910
|
-
constructor(private readonly client:
|
|
2909
|
+
export class BdChatbotClient {
|
|
2910
|
+
constructor(private readonly client: BdApiClient) {}
|
|
2911
2911
|
|
|
2912
2912
|
/** Returns the iframe URL for `<Chatbot/>`. */
|
|
2913
2913
|
async createSession(): Promise<ChatbotSessionResponse> {
|
|
@@ -3180,7 +3180,7 @@ export class BiabDevChatbotClient {
|
|
|
3180
3180
|
*
|
|
3181
3181
|
* @remarks
|
|
3182
3182
|
* **Privacy:** When `organizationId` is set, every request is pinned to that
|
|
3183
|
-
* org via the `X-
|
|
3183
|
+
* org via the `X-BD-Customer-Portal-Org` header. The server-side
|
|
3184
3184
|
* `customerPortalProcedure` will reject any access to a different org, so a
|
|
3185
3185
|
* customer browsing a Dominoes-branded site can never accidentally see Pizza
|
|
3186
3186
|
* Hut data even if their account is linked to both. This is the recommended
|
|
@@ -3199,13 +3199,13 @@ function decodeBase64ToBytes(base64: string): Uint8Array {
|
|
|
3199
3199
|
return bytes;
|
|
3200
3200
|
}
|
|
3201
3201
|
|
|
3202
|
-
export class
|
|
3202
|
+
export class BdCustomerPortalClient {
|
|
3203
3203
|
constructor(
|
|
3204
|
-
private readonly client:
|
|
3204
|
+
private readonly client: BdApiClient,
|
|
3205
3205
|
private readonly organizationId: string | null,
|
|
3206
3206
|
/**
|
|
3207
3207
|
* Optional tenantAuth session token. When set, requests include
|
|
3208
|
-
* an `X-
|
|
3208
|
+
* an `X-BD-Session-Token` header and the BD customer-portal
|
|
3209
3209
|
* routes resolve the calling user via the session payload
|
|
3210
3210
|
* instead of the API key's user binding.
|
|
3211
3211
|
*
|
|
@@ -3234,8 +3234,8 @@ export class BiabDevCustomerPortalClient {
|
|
|
3234
3234
|
* .getWork();
|
|
3235
3235
|
* ```
|
|
3236
3236
|
*/
|
|
3237
|
-
withSession(sessionToken: string):
|
|
3238
|
-
return new
|
|
3237
|
+
withSession(sessionToken: string): BdCustomerPortalClient {
|
|
3238
|
+
return new BdCustomerPortalClient(
|
|
3239
3239
|
this.client,
|
|
3240
3240
|
this.organizationId,
|
|
3241
3241
|
sessionToken,
|
|
@@ -3245,10 +3245,10 @@ export class BiabDevCustomerPortalClient {
|
|
|
3245
3245
|
private headers(): HeadersInit {
|
|
3246
3246
|
const out: Record<string, string> = {};
|
|
3247
3247
|
if (this.organizationId) {
|
|
3248
|
-
out["X-
|
|
3248
|
+
out["X-BD-Customer-Portal-Org"] = this.organizationId;
|
|
3249
3249
|
}
|
|
3250
3250
|
if (this.sessionToken) {
|
|
3251
|
-
out["X-
|
|
3251
|
+
out["X-BD-Session-Token"] = this.sessionToken;
|
|
3252
3252
|
}
|
|
3253
3253
|
return out;
|
|
3254
3254
|
}
|
|
@@ -3393,6 +3393,31 @@ export class BiabDevCustomerPortalClient {
|
|
|
3393
3393
|
});
|
|
3394
3394
|
}
|
|
3395
3395
|
|
|
3396
|
+
/**
|
|
3397
|
+
* Designed proposals the customer has been sent.
|
|
3398
|
+
*
|
|
3399
|
+
* Separate from `listQuotes` because a proposal is the document built
|
|
3400
|
+
* around a quote, not the quote: `kind` decides whether a consumer offers
|
|
3401
|
+
* a download or frames a page, and a UI that guessed would get one of the
|
|
3402
|
+
* two wrong every time.
|
|
3403
|
+
*/
|
|
3404
|
+
async listProposals(): Promise<CustomerProposalListResponse> {
|
|
3405
|
+
return this.client.request({
|
|
3406
|
+
path: "customer-portal/proposals",
|
|
3407
|
+
responseSchema: customerProposalListResponseSchema,
|
|
3408
|
+
headers: this.headers(),
|
|
3409
|
+
});
|
|
3410
|
+
}
|
|
3411
|
+
|
|
3412
|
+
/** One proposal the customer owns. */
|
|
3413
|
+
async getProposal(proposalId: string): Promise<CustomerProposal> {
|
|
3414
|
+
return this.client.request({
|
|
3415
|
+
path: `customer-portal/proposals/${encodeURIComponent(proposalId)}`,
|
|
3416
|
+
responseSchema: customerProposalSchema,
|
|
3417
|
+
headers: this.headers(),
|
|
3418
|
+
});
|
|
3419
|
+
}
|
|
3420
|
+
|
|
3396
3421
|
/** Read a single quote the signed-in customer owns. */
|
|
3397
3422
|
async getQuote(quoteId: string): Promise<CustomerQuoteDetail> {
|
|
3398
3423
|
return this.client.request({
|
|
@@ -3513,7 +3538,7 @@ export class BiabDevCustomerPortalClient {
|
|
|
3513
3538
|
/**
|
|
3514
3539
|
* Begin signing a contract the customer owns. Returns a ready, absolute
|
|
3515
3540
|
* signing URL on the org's branded hostname — redirect the customer there
|
|
3516
|
-
* to
|
|
3541
|
+
* to BD's hosted e-sign page, which captures the signature and generates
|
|
3517
3542
|
* the executed PDF. No signature payload is collected client-side, so the
|
|
3518
3543
|
* legal record stays consistent across consumers.
|
|
3519
3544
|
*
|
|
@@ -4120,7 +4145,7 @@ export class BiabDevCustomerPortalClient {
|
|
|
4120
4145
|
/**
|
|
4121
4146
|
* List the digital downloads the customer is entitled to for a paid order
|
|
4122
4147
|
* (P10d). Each item is a ready-to-use URL — a short-lived presigned link for
|
|
4123
|
-
*
|
|
4148
|
+
* BD-hosted files (`expiresInSeconds` set) or the org's external link.
|
|
4124
4149
|
* Returns an empty list until the order's payment settles.
|
|
4125
4150
|
*
|
|
4126
4151
|
* @example
|
|
@@ -4284,14 +4309,14 @@ export class BiabDevCustomerPortalClient {
|
|
|
4284
4309
|
}
|
|
4285
4310
|
|
|
4286
4311
|
/**
|
|
4287
|
-
* Creates a {@link
|
|
4312
|
+
* Creates a {@link BdApiClient} for the given host `baseUrl` and package API key.
|
|
4288
4313
|
*
|
|
4289
4314
|
* @remarks
|
|
4290
4315
|
* **Alpha:** This package is still in alpha release. APIs may change; it is **not** intended
|
|
4291
4316
|
* for production use yet. Prefer non-production environments until a stable major is published.
|
|
4292
4317
|
*/
|
|
4293
|
-
export function
|
|
4294
|
-
return new
|
|
4318
|
+
export function createBdApiClient(options: BdApiClientOptions) {
|
|
4319
|
+
return new BdApiClient(options);
|
|
4295
4320
|
}
|
|
4296
4321
|
|
|
4297
4322
|
/**
|
|
@@ -4299,8 +4324,8 @@ export function createBiabDevClient(options: BiabDevClientOptions) {
|
|
|
4299
4324
|
* the API key. Used by the SDK's `createAuthHandler` (server) and
|
|
4300
4325
|
* `<SignIn />` / `<SignUp />` / `<SignOut />` components (client).
|
|
4301
4326
|
*/
|
|
4302
|
-
export class
|
|
4303
|
-
constructor(private readonly client:
|
|
4327
|
+
export class BdAuthClient {
|
|
4328
|
+
constructor(private readonly client: BdApiClient) {}
|
|
4304
4329
|
|
|
4305
4330
|
async start(input: TenantAuthStartInput): Promise<TenantAuthStartResponse> {
|
|
4306
4331
|
const body = tenantAuthStartInputSchema.parse(input);
|
|
@@ -4364,7 +4389,7 @@ export class BiabDevAuthClient {
|
|
|
4364
4389
|
return this.client.request({
|
|
4365
4390
|
method: "GET",
|
|
4366
4391
|
path: "auth/me",
|
|
4367
|
-
headers: { "x-
|
|
4392
|
+
headers: { "x-bd-session": input.sessionToken },
|
|
4368
4393
|
responseSchema: tenantAuthMeResponseSchema,
|
|
4369
4394
|
});
|
|
4370
4395
|
}
|
|
@@ -4429,8 +4454,8 @@ export class BiabDevAuthClient {
|
|
|
4429
4454
|
*
|
|
4430
4455
|
* For an org running its own admin tooling rather than the dashboard.
|
|
4431
4456
|
*/
|
|
4432
|
-
export class
|
|
4433
|
-
constructor(private readonly client:
|
|
4457
|
+
export class BdCustomerInvitesClient {
|
|
4458
|
+
constructor(private readonly client: BdApiClient) {}
|
|
4434
4459
|
|
|
4435
4460
|
/**
|
|
4436
4461
|
* Hand an invite link out again.
|
|
@@ -4468,9 +4493,9 @@ export class BiabDevCustomerInvitesClient {
|
|
|
4468
4493
|
}
|
|
4469
4494
|
}
|
|
4470
4495
|
|
|
4471
|
-
export class
|
|
4496
|
+
export class BdSchedulingClient {
|
|
4472
4497
|
constructor(
|
|
4473
|
-
private readonly client:
|
|
4498
|
+
private readonly client: BdApiClient,
|
|
4474
4499
|
private readonly siteId: string,
|
|
4475
4500
|
) {}
|
|
4476
4501
|
|