@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
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
* @module
|
|
42
42
|
*/
|
|
43
43
|
|
|
44
|
-
import {
|
|
44
|
+
import { BdAccessRejectedError } from "../errors.js";
|
|
45
45
|
import { isReservedPagePath } from "../reserved-paths.js";
|
|
46
46
|
|
|
47
47
|
/** Where a kind of platform content lives on YOUR site. */
|
|
@@ -74,8 +74,11 @@ export type SitemapRoutes = {
|
|
|
74
74
|
export type SitemapEntry = {
|
|
75
75
|
/** Absolute URL. */
|
|
76
76
|
loc: string;
|
|
77
|
-
/** ISO 8601. Omitted when nothing meaningful is known.
|
|
78
|
-
|
|
77
|
+
/** ISO 8601. Omitted when nothing meaningful is known. The explicit
|
|
78
|
+
* `| undefined` matters under exactOptionalPropertyTypes: the real
|
|
79
|
+
* client's `sitemapEntries()` rows carry `lastmod?: string | undefined`,
|
|
80
|
+
* and without it the facade fails the SitemapClientLike contract. */
|
|
81
|
+
lastmod?: string | undefined;
|
|
79
82
|
};
|
|
80
83
|
|
|
81
84
|
export type BuildSitemapOptions = {
|
|
@@ -106,16 +109,21 @@ export type BuildSitemapOptions = {
|
|
|
106
109
|
onSkip?: (section: string, reason: string) => void;
|
|
107
110
|
};
|
|
108
111
|
|
|
109
|
-
/** The subset of the SDK client this needs.
|
|
112
|
+
/** The subset of the SDK client this needs. Shapes mirror the REAL
|
|
113
|
+
* client responses (`{ items, … }` — blogListPostsResponseSchema and
|
|
114
|
+
* storefrontListProductsResponseSchema): this type once said `posts`/
|
|
115
|
+
* `products`, so the destructure came back undefined, the loop threw,
|
|
116
|
+
* and every real sitemap silently reported its blog and product
|
|
117
|
+
* sections as "unreachable". */
|
|
110
118
|
export type SitemapClientLike = {
|
|
111
119
|
blog: {
|
|
112
120
|
listPosts(input?: { limit?: number }): Promise<{
|
|
113
|
-
|
|
121
|
+
items: Array<{ slug: string; updatedAt?: string | null }>;
|
|
114
122
|
}>;
|
|
115
123
|
};
|
|
116
124
|
storefront: {
|
|
117
125
|
listProducts(input?: { limit?: number }): Promise<{
|
|
118
|
-
|
|
126
|
+
items: Array<{ id: string; updatedAt?: string | null }>;
|
|
119
127
|
}>;
|
|
120
128
|
};
|
|
121
129
|
site(siteId: string): {
|
|
@@ -148,7 +156,7 @@ function escapeXml(value: string): string {
|
|
|
148
156
|
* gives up on an error page.
|
|
149
157
|
*/
|
|
150
158
|
function isExpectedAbsence(cause: unknown): boolean {
|
|
151
|
-
return cause instanceof
|
|
159
|
+
return cause instanceof BdAccessRejectedError;
|
|
152
160
|
}
|
|
153
161
|
|
|
154
162
|
/**
|
|
@@ -209,7 +217,7 @@ export async function collectSitemapEntries(
|
|
|
209
217
|
// 3. Blog — only when you told us where it lives.
|
|
210
218
|
if (routes.blog) {
|
|
211
219
|
try {
|
|
212
|
-
const { posts } = await client.blog.listPosts({
|
|
220
|
+
const { items: posts } = await client.blog.listPosts({
|
|
213
221
|
limit: options.blogLimit ?? 1000,
|
|
214
222
|
});
|
|
215
223
|
for (const post of posts) {
|
|
@@ -230,7 +238,7 @@ export async function collectSitemapEntries(
|
|
|
230
238
|
// 4. Products — same rule.
|
|
231
239
|
if (routes.product) {
|
|
232
240
|
try {
|
|
233
|
-
const { products } = await client.storefront.listProducts({
|
|
241
|
+
const { items: products } = await client.storefront.listProducts({
|
|
234
242
|
limit: options.productLimit ?? 1000,
|
|
235
243
|
});
|
|
236
244
|
for (const product of products) {
|
package/src/socials.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Canonical social-profile support.
|
|
3
3
|
*
|
|
4
4
|
* The company profile (`storefrontMeta().socials`) is a free-form record keyed
|
|
5
|
-
* by
|
|
6
|
-
* re-implementing the key→icon→href mapping by hand and getting
|
|
5
|
+
* by BD's field keys (`meta`, `twitterX`, `tikTok`, …). Consumers kept
|
|
6
|
+
* re-implementing the key→icon→href mapping by hand and getting BD's exact
|
|
7
7
|
* keys wrong (e.g. mapping `facebook`/`x` and silently dropping `meta`/`twitterX`).
|
|
8
|
-
* This module is the single source of truth: every platform
|
|
8
|
+
* This module is the single source of truth: every platform BD supports, in
|
|
9
9
|
* render order, with a stable icon slug + a handle→URL normalizer, plus alias
|
|
10
10
|
* resolution so older/lowercase spellings still match.
|
|
11
11
|
*
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* this for you, see `SocialLinks` in `@businessdash/sdk/react`.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
/** A social/profile platform key as stored on the
|
|
18
|
+
/** A social/profile platform key as stored on the BD company profile. */
|
|
19
19
|
export type SocialPlatformKey =
|
|
20
20
|
| "meta"
|
|
21
21
|
| "instagram"
|
|
@@ -59,7 +59,7 @@ export type SocialPlatformMeta = {
|
|
|
59
59
|
hrefPrefix?: string;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
/** Every platform
|
|
62
|
+
/** Every platform BD supports, in footer render order. */
|
|
63
63
|
export const SOCIAL_PLATFORMS: readonly SocialPlatformMeta[] = [
|
|
64
64
|
{
|
|
65
65
|
key: "meta",
|
|
@@ -167,7 +167,7 @@ function canonicalize(raw: string): string {
|
|
|
167
167
|
return raw.toLowerCase().replace(/[\s_-]+/g, "");
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
/** Resolve any incoming social key (
|
|
170
|
+
/** Resolve any incoming social key (BD key, alias, or loose spelling) to its platform meta. */
|
|
171
171
|
export function resolveSocialPlatform(key: string): SocialPlatformMeta | null {
|
|
172
172
|
const c = canonicalize(key);
|
|
173
173
|
const direct = PLATFORM_BY_KEY.get(c);
|
package/src/solid-compat.tsx
CHANGED
|
@@ -175,7 +175,7 @@ export function Show<T>(props: {
|
|
|
175
175
|
|
|
176
176
|
/** The marker a `Match` leaves behind for its enclosing `Switch`. */
|
|
177
177
|
type MatchMarker = {
|
|
178
|
-
readonly
|
|
178
|
+
readonly __bdMatch: true;
|
|
179
179
|
readonly when: unknown;
|
|
180
180
|
readonly children: SolidNode;
|
|
181
181
|
};
|
|
@@ -184,7 +184,7 @@ function isMatchMarker(value: unknown): value is MatchMarker {
|
|
|
184
184
|
return (
|
|
185
185
|
typeof value === "object" &&
|
|
186
186
|
value !== null &&
|
|
187
|
-
(value as {
|
|
187
|
+
(value as { __bdMatch?: unknown }).__bdMatch === true
|
|
188
188
|
);
|
|
189
189
|
}
|
|
190
190
|
|
|
@@ -197,7 +197,7 @@ function isMatchMarker(value: unknown): value is MatchMarker {
|
|
|
197
197
|
*/
|
|
198
198
|
export function Match(props: { when: unknown; children: SolidNode }): Node {
|
|
199
199
|
const marker: MatchMarker = {
|
|
200
|
-
|
|
200
|
+
__bdMatch: true,
|
|
201
201
|
get when() {
|
|
202
202
|
return props.when;
|
|
203
203
|
},
|
|
@@ -301,12 +301,12 @@ let uniqueIdCounter = 0;
|
|
|
301
301
|
* one document — they are not persisted, sent anywhere, or compared across
|
|
302
302
|
* renders.
|
|
303
303
|
*
|
|
304
|
-
* The `
|
|
304
|
+
* The `bd-` prefix keeps them from colliding with ids the consumer's own
|
|
305
305
|
* page already uses.
|
|
306
306
|
*/
|
|
307
307
|
export function createUniqueId(): string {
|
|
308
308
|
uniqueIdCounter += 1;
|
|
309
|
-
return `
|
|
309
|
+
return `bd-${uniqueIdCounter}`;
|
|
310
310
|
}
|
|
311
311
|
|
|
312
312
|
/**
|
package/src/solid-surfaces.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@businessdash/sdk/solid` — the product surfaces beyond forms.
|
|
3
3
|
*
|
|
4
|
-
* Solid used to stop at `<
|
|
4
|
+
* Solid used to stop at `<BdForm>` while React carried the whole product:
|
|
5
5
|
* storefront, cart, checkout, blog, the customer portal, chat, auth, followers
|
|
6
6
|
* and social links. This file closes most of that gap.
|
|
7
7
|
*
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
*
|
|
18
18
|
* The consequence worth stating plainly: these surfaces render BusinessDash's
|
|
19
19
|
* markup, not yours. They are the fastest path to a working store, not a
|
|
20
|
-
* design-system component. `<
|
|
21
|
-
* renders into your own DOM, and `
|
|
20
|
+
* design-system component. `<BdForm>` remains the only surface here that
|
|
21
|
+
* renders into your own DOM, and `BdClient` is always available if you want
|
|
22
22
|
* to build the UI yourself.
|
|
23
23
|
*
|
|
24
24
|
* ## Solid specifics
|
|
@@ -57,7 +57,7 @@ import { buildAuthHref } from "./auth-links.js";
|
|
|
57
57
|
import { createBlogController } from "./blog-core/index.js";
|
|
58
58
|
import { createChatController } from "./chat-core/index.js";
|
|
59
59
|
import { createCheckoutController } from "./checkout-core/index.js";
|
|
60
|
-
import {
|
|
60
|
+
import { BdApiClient } from "./client.js";
|
|
61
61
|
import type {
|
|
62
62
|
BlogCommentPostInput,
|
|
63
63
|
BlogSessionInput,
|
|
@@ -82,7 +82,7 @@ import type {
|
|
|
82
82
|
StorefrontSessionResponse,
|
|
83
83
|
} from "./contracts.js";
|
|
84
84
|
import {
|
|
85
|
-
type
|
|
85
|
+
type BdEmbedEvent,
|
|
86
86
|
DEFAULT_EMBED_SANDBOX,
|
|
87
87
|
DEFAULT_REFRESH_LEAD_MS,
|
|
88
88
|
type EmbedSessionState,
|
|
@@ -91,7 +91,7 @@ import {
|
|
|
91
91
|
} from "./embed-protocol.js";
|
|
92
92
|
import { createMarketingController } from "./marketing-core/index.js";
|
|
93
93
|
import { createPortalController } from "./portal-core/index.js";
|
|
94
|
-
import {
|
|
94
|
+
import { createBdClient } from "./sdk.js";
|
|
95
95
|
import {
|
|
96
96
|
resolveSocialLinks,
|
|
97
97
|
SOCIAL_FALLBACK_GLYPH,
|
|
@@ -112,7 +112,7 @@ import {
|
|
|
112
112
|
createVerifyController,
|
|
113
113
|
} from "./verify-core/index.js";
|
|
114
114
|
|
|
115
|
-
export type {
|
|
115
|
+
export type { BdEmbedEvent } from "./embed-protocol.js";
|
|
116
116
|
|
|
117
117
|
/** Package-API base URL used when a surface doesn't specify one. */
|
|
118
118
|
export const DEFAULT_PACKAGE_BASE_URL =
|
|
@@ -153,12 +153,12 @@ export type EmbedSessionOptions = {
|
|
|
153
153
|
export function createEmbedSession<
|
|
154
154
|
T extends { url: string; expiresAt: string },
|
|
155
155
|
>(
|
|
156
|
-
loader: (client:
|
|
156
|
+
loader: (client: BdApiClient) => Promise<T>,
|
|
157
157
|
options: () => EmbedSessionOptions,
|
|
158
158
|
) {
|
|
159
159
|
const client = createMemo(
|
|
160
160
|
() =>
|
|
161
|
-
new
|
|
161
|
+
new BdApiClient({
|
|
162
162
|
apiKey: options().apiKey,
|
|
163
163
|
baseUrl: options().baseUrl,
|
|
164
164
|
}),
|
|
@@ -220,7 +220,7 @@ type EmbedIframeProps<T extends { url: string }> = {
|
|
|
220
220
|
errorFallback?:
|
|
221
221
|
| ((error: Error, refresh: () => void) => SolidNode)
|
|
222
222
|
| undefined;
|
|
223
|
-
onEvent?: ((event:
|
|
223
|
+
onEvent?: ((event: BdEmbedEvent) => void) | undefined;
|
|
224
224
|
/** Extra `sandbox` tokens beyond the safe defaults. */
|
|
225
225
|
extraSandbox?: string | undefined;
|
|
226
226
|
};
|
|
@@ -297,7 +297,7 @@ type BaseEmbedProps = {
|
|
|
297
297
|
title?: string;
|
|
298
298
|
loadingFallback?: SolidNode;
|
|
299
299
|
errorFallback?: (error: Error, refresh: () => void) => SolidNode;
|
|
300
|
-
onEvent?: (event:
|
|
300
|
+
onEvent?: (event: BdEmbedEvent) => void;
|
|
301
301
|
refreshLeadMs?: number;
|
|
302
302
|
};
|
|
303
303
|
|
|
@@ -332,7 +332,7 @@ export function Storefront(props: StorefrontProps) {
|
|
|
332
332
|
loadingFallback={props.loadingFallback}
|
|
333
333
|
onEvent={(event) => {
|
|
334
334
|
props.onEvent?.(event);
|
|
335
|
-
if (event.type === "
|
|
335
|
+
if (event.type === "bd:cart:update") {
|
|
336
336
|
props.onCartChange?.(event.count, event.subtotalCents);
|
|
337
337
|
}
|
|
338
338
|
}}
|
|
@@ -368,7 +368,7 @@ export function Cart(props: CartProps) {
|
|
|
368
368
|
loadingFallback={props.loadingFallback}
|
|
369
369
|
onEvent={(event) => {
|
|
370
370
|
props.onEvent?.(event);
|
|
371
|
-
if (event.type === "
|
|
371
|
+
if (event.type === "bd:cart:update") {
|
|
372
372
|
props.onCartChange?.(event.count, event.subtotalCents);
|
|
373
373
|
}
|
|
374
374
|
}}
|
|
@@ -426,7 +426,7 @@ export type ChatbotProps = BaseEmbedProps & {
|
|
|
426
426
|
*
|
|
427
427
|
* This is the hosted chat UI. React additionally ships a headless
|
|
428
428
|
* `useChatbot` + `<ChatbotInline>` for hosts that render their own chat; that
|
|
429
|
-
* pair has no Solid equivalent yet, and `
|
|
429
|
+
* pair has no Solid equivalent yet, and `BdClient.chatbot` is the way to
|
|
430
430
|
* build one in the meantime.
|
|
431
431
|
*/
|
|
432
432
|
export function Chatbot(props: ChatbotProps) {
|
|
@@ -446,7 +446,7 @@ export function Chatbot(props: ChatbotProps) {
|
|
|
446
446
|
loadingFallback={props.loadingFallback}
|
|
447
447
|
onEvent={(event) => {
|
|
448
448
|
props.onEvent?.(event);
|
|
449
|
-
if (event.type === "
|
|
449
|
+
if (event.type === "bd:chatbot:assistant-message") {
|
|
450
450
|
props.onAssistantMessage?.(event.content, event.model);
|
|
451
451
|
}
|
|
452
452
|
}}
|
|
@@ -476,7 +476,7 @@ export type CheckoutProps = {
|
|
|
476
476
|
children?: SolidNode;
|
|
477
477
|
loadingFallback?: SolidNode;
|
|
478
478
|
errorFallback?: (error: Error, refresh: () => void) => SolidNode;
|
|
479
|
-
onEvent?: (event:
|
|
479
|
+
onEvent?: (event: BdEmbedEvent) => void;
|
|
480
480
|
onSuccess?: (sessionId: string) => void;
|
|
481
481
|
onCancel?: (sessionId: string) => void;
|
|
482
482
|
onError?: (error: Error) => void;
|
|
@@ -485,7 +485,7 @@ export type CheckoutProps = {
|
|
|
485
485
|
/** Start a Stripe checkout, as a button (default) or an embedded surface. */
|
|
486
486
|
export function Checkout(props: CheckoutProps) {
|
|
487
487
|
const client = createMemo(
|
|
488
|
-
() => new
|
|
488
|
+
() => new BdApiClient({ apiKey: props.apiKey, baseUrl: props.baseUrl }),
|
|
489
489
|
);
|
|
490
490
|
const [state, setState] = createSignal<
|
|
491
491
|
EmbedSessionState<CheckoutSessionResponse>
|
|
@@ -543,11 +543,11 @@ export function Checkout(props: CheckoutProps) {
|
|
|
543
543
|
loadingFallback={props.loadingFallback}
|
|
544
544
|
onEvent={(event) => {
|
|
545
545
|
props.onEvent?.(event);
|
|
546
|
-
if (event.type === "
|
|
546
|
+
if (event.type === "bd:checkout:success") {
|
|
547
547
|
props.onSuccess?.(event.sessionId);
|
|
548
|
-
} else if (event.type === "
|
|
548
|
+
} else if (event.type === "bd:checkout:cancel") {
|
|
549
549
|
props.onCancel?.(event.sessionId);
|
|
550
|
-
} else if (event.type === "
|
|
550
|
+
} else if (event.type === "bd:checkout:error") {
|
|
551
551
|
props.onError?.(new Error(event.message));
|
|
552
552
|
}
|
|
553
553
|
}}
|
|
@@ -1002,7 +1002,7 @@ export function createStorefront(options: () => CreateStorefrontOptions) {
|
|
|
1002
1002
|
const { controller, snapshot } = bridge(
|
|
1003
1003
|
() =>
|
|
1004
1004
|
createStoreController({
|
|
1005
|
-
client: new
|
|
1005
|
+
client: new BdApiClient({
|
|
1006
1006
|
apiKey: options().apiKey,
|
|
1007
1007
|
baseUrl: options().baseUrl,
|
|
1008
1008
|
}),
|
|
@@ -1042,7 +1042,7 @@ export type CreateChatOptions = { apiKey: string; baseUrl: string };
|
|
|
1042
1042
|
export function createChat(options: () => CreateChatOptions) {
|
|
1043
1043
|
const { controller, snapshot } = bridge(() =>
|
|
1044
1044
|
createChatController({
|
|
1045
|
-
client: new
|
|
1045
|
+
client: new BdApiClient({
|
|
1046
1046
|
apiKey: options().apiKey,
|
|
1047
1047
|
baseUrl: options().baseUrl,
|
|
1048
1048
|
}),
|
|
@@ -1082,7 +1082,7 @@ export function createBlog(options: () => CreateBlogOptions) {
|
|
|
1082
1082
|
const { controller, snapshot } = bridge(
|
|
1083
1083
|
() =>
|
|
1084
1084
|
createBlogController({
|
|
1085
|
-
client: new
|
|
1085
|
+
client: new BdApiClient({
|
|
1086
1086
|
apiKey: options().apiKey,
|
|
1087
1087
|
baseUrl: options().baseUrl,
|
|
1088
1088
|
}),
|
|
@@ -1112,7 +1112,7 @@ export type CreateCheckoutOptions = { apiKey: string; baseUrl: string };
|
|
|
1112
1112
|
export function createCheckout(options: () => CreateCheckoutOptions) {
|
|
1113
1113
|
const { controller, snapshot } = bridge(() =>
|
|
1114
1114
|
createCheckoutController({
|
|
1115
|
-
client: new
|
|
1115
|
+
client: new BdApiClient({
|
|
1116
1116
|
apiKey: options().apiKey,
|
|
1117
1117
|
baseUrl: options().baseUrl,
|
|
1118
1118
|
}),
|
|
@@ -1151,7 +1151,7 @@ export type CreateFollowersOptions = {
|
|
|
1151
1151
|
export function createFollowers(options: () => CreateFollowersOptions) {
|
|
1152
1152
|
const { controller, snapshot } = bridge(() =>
|
|
1153
1153
|
createFollowersController({
|
|
1154
|
-
client:
|
|
1154
|
+
client: createBdClient({
|
|
1155
1155
|
apiKey: options().token,
|
|
1156
1156
|
siteId: options().siteId,
|
|
1157
1157
|
...(options().baseUrl ? { baseUrl: options().baseUrl } : {}),
|
|
@@ -1181,7 +1181,7 @@ export function createMarketing(options: () => CreateMarketingOptions) {
|
|
|
1181
1181
|
const { controller, snapshot } = bridge(
|
|
1182
1182
|
() =>
|
|
1183
1183
|
createMarketingController({
|
|
1184
|
-
client:
|
|
1184
|
+
client: createBdClient({
|
|
1185
1185
|
apiKey: options().token,
|
|
1186
1186
|
siteId: options().siteId,
|
|
1187
1187
|
...(options().baseUrl ? { baseUrl: options().baseUrl } : {}),
|
|
@@ -1208,7 +1208,7 @@ export function createVerify(options: () => CreateVerifyOptions) {
|
|
|
1208
1208
|
const { controller, snapshot } = bridge(() => {
|
|
1209
1209
|
const { apiKey, baseUrl, ...rest } = options();
|
|
1210
1210
|
return createVerifyController({
|
|
1211
|
-
client: new
|
|
1211
|
+
client: new BdApiClient({ apiKey, baseUrl }),
|
|
1212
1212
|
...rest,
|
|
1213
1213
|
});
|
|
1214
1214
|
});
|
|
@@ -1244,7 +1244,7 @@ export function createPortal(options: () => CreatePortalOptions) {
|
|
|
1244
1244
|
const { controller, snapshot } = bridge(
|
|
1245
1245
|
() =>
|
|
1246
1246
|
createPortalController({
|
|
1247
|
-
client: new
|
|
1247
|
+
client: new BdApiClient({
|
|
1248
1248
|
apiKey: options().apiKey,
|
|
1249
1249
|
baseUrl: options().baseUrl,
|
|
1250
1250
|
}),
|