@businessdash/sdk 0.9.70 → 0.9.81

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/src/sdk.ts CHANGED
@@ -33,12 +33,14 @@ import {
33
33
  BiabDevCouponsClient,
34
34
  BiabDevCustomerPortalClient,
35
35
  BiabDevFollowersClient,
36
+ BiabDevLegalClient,
36
37
  BiabDevMarketingClient,
37
38
  BiabDevMarketingPagesClient,
38
39
  BiabDevNotificationsClient,
39
40
  BiabDevParallelPagesClient,
40
41
  BiabDevReviewsClient,
41
42
  BiabDevShippingClient,
43
+ type BiabDevSiteClient,
42
44
  BiabDevStorefrontClient,
43
45
  BiabDevSubscriptionsClient,
44
46
  } from "./client.js";
@@ -1619,6 +1621,16 @@ export interface BiabClient {
1619
1621
  customerPortal: BiabDevCustomerPortalClient;
1620
1622
  notifications: BiabDevNotificationsClient;
1621
1623
  followers: BiabDevFollowersClient;
1624
+ // The org's published legal pages — what `@businessdash/sdk/legal`'s
1625
+ // resolver expects a client to carry, so the starters' catch-all
1626
+ // route works on THIS facade, not only on the raw BiabDevClient.
1627
+ legal: BiabDevLegalClient;
1628
+ // Site-scoped surfaces (collections, rows, data model, analytics,
1629
+ // scheduling, …). A METHOD mirroring `BiabDevClient.site(siteId)` —
1630
+ // `@businessdash/sdk/sitemap`'s collector calls
1631
+ // `client.site(siteId).sitemapEntries()`, so the starters' sitemap
1632
+ // route needs the same shape on this facade.
1633
+ site(siteId: string): BiabDevSiteClient;
1622
1634
  marketing: BiabDevMarketingClient;
1623
1635
  marketingPages: BiabDevMarketingPagesClient;
1624
1636
  parallelPages: BiabDevParallelPagesClient;
@@ -1664,8 +1676,30 @@ export function createBiabClient(opts: CreateBiabClientOptions): BiabClient {
1664
1676
  customerPortal: new BiabDevCustomerPortalClient(transport, null),
1665
1677
  notifications: new BiabDevNotificationsClient(transport, state.siteId),
1666
1678
  followers: new BiabDevFollowersClient(transport, state.siteId),
1679
+ legal: new BiabDevLegalClient(transport),
1680
+ site: (siteId: string) => transport.site(siteId),
1667
1681
  marketing: new BiabDevMarketingClient(transport, state.siteId),
1668
1682
  marketingPages: new BiabDevMarketingPagesClient(transport, state.siteId),
1669
1683
  parallelPages: new BiabDevParallelPagesClient(transport, state.siteId),
1670
1684
  };
1671
1685
  }
1686
+
1687
+ /* ── Facade ↔ helper-module contracts ──────────────────────────────────
1688
+ * The standalone helpers (`/legal`, `/sitemap`) accept "any client that
1689
+ * carries the right surface", and every file-routed starter hands them
1690
+ * THIS facade. 0.9.80 shipped without `legal` and `site`, and three
1691
+ * starters stopped typechecking against the published package — a drift
1692
+ * only the template fleet could see. These aliases move that failure
1693
+ * into `pnpm typecheck`: drop a required surface and the build breaks
1694
+ * here, before a release. Type-only; erased from the emitted JS. */
1695
+ type MustBeTrue<T extends true> = T;
1696
+ export type FacadeServesLegalRoutes = MustBeTrue<
1697
+ BiabClient extends import("./legal-core/index.js").LegalClientLike
1698
+ ? true
1699
+ : false
1700
+ >;
1701
+ export type FacadeServesSitemapRoutes = MustBeTrue<
1702
+ BiabClient extends import("./sitemap-core/index.js").SitemapClientLike
1703
+ ? true
1704
+ : false
1705
+ >;
@@ -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
- lastmod?: string;
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
- posts: Array<{ slug: string; updatedAt?: string | null }>;
121
+ items: Array<{ slug: string; updatedAt?: string | null }>;
114
122
  }>;
115
123
  };
116
124
  storefront: {
117
125
  listProducts(input?: { limit?: number }): Promise<{
118
- products: Array<{ id: string; updatedAt?: string | null }>;
126
+ items: Array<{ id: string; updatedAt?: string | null }>;
119
127
  }>;
120
128
  };
121
129
  site(siteId: string): {
@@ -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) {