@brainerce/mcp-server 3.7.0 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin/http.js CHANGED
@@ -2202,9 +2202,12 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
2202
2202
  const client = getServerClient();
2203
2203
  client.setLocale(locale);
2204
2204
  const product = await client.getProductBySlug(slug);
2205
+ // NEVER feed raw HTML into <meta name="description"> \u2014 product.description
2206
+ // is often rich-text HTML. Strip tags first, then truncate on a word
2207
+ // boundary. See buildMetaDescription() in lib/seo.ts.
2205
2208
  return {
2206
2209
  title: product.seoTitle || product.name,
2207
- description: product.seoDescription || product.description?.slice(0, 160),
2210
+ description: product.seoDescription || buildMetaDescription(product.description) || product.name,
2208
2211
  };
2209
2212
  }
2210
2213
  \`\`\`
@@ -2320,11 +2323,25 @@ Because the backend already overlays everything, UI code is just:
2320
2323
 
2321
2324
  ### RTL handling
2322
2325
 
2323
- For RTL locales (\`he\`, \`ar\`), set \`<html dir="rtl">\` in the root layout and
2324
- let flexbox reverse automatically. Do NOT add \`flex-row-reverse\` on top of
2325
- \`dir="rtl"\` \u2014 that's a double-swap. DO swap directional icons (chevrons,
2326
- arrows) manually. Use logical CSS properties (\`ms-*\`/\`me-*\`) instead of
2327
- \`ml-*\`/\`mr-*\`.
2326
+ Resolve direction with \`client.getStoreDirection(locale)\` \u2014 it returns
2327
+ \`'ltr' | 'rtl'\` for any BCP-47 tag (Arabic, Hebrew, Persian, Urdu, Yiddish
2328
+ today; future RTL locales added by the platform are picked up automatically).
2329
+ Do NOT maintain your own RTL locale set.
2330
+
2331
+ \`\`\`tsx
2332
+ // app/[locale]/layout.tsx
2333
+ const dir = client.getStoreDirection(locale);
2334
+ return <html lang={locale} dir={dir}>...</html>;
2335
+ \`\`\`
2336
+
2337
+ For static rendering, \`storeInfo.i18n.defaultDirection\` carries the store's
2338
+ default direction, and each entry in \`storeInfo.i18n.supportedLocaleObjects\`
2339
+ includes its own \`direction\`.
2340
+
2341
+ Let flexbox reverse automatically once \`<html dir="rtl">\` is set. Do NOT add
2342
+ \`flex-row-reverse\` on top \u2014 that's a double-swap. DO swap directional icons
2343
+ (chevrons, arrows) manually. Use logical CSS properties (\`ms-*\`/\`me-*\`)
2344
+ instead of \`ml-*\`/\`mr-*\`.
2328
2345
 
2329
2346
  ### Language switcher
2330
2347
 
@@ -2701,6 +2718,141 @@ and a \`newsletter\` form embedded in the footer), render each form from its
2701
2718
  own \`contactForms.get(key, locale)\` call. The \`formKey\` you pass to
2702
2719
  \`createInquiry\` must match.`;
2703
2720
  }
2721
+ function getContentSection() {
2722
+ return `## Content \u2014 typed merchant content store
2723
+
2724
+ Brainerce ships a typed content store so merchants can edit site chrome, FAQ,
2725
+ static pages, and inline rich-text blocks in the dashboard \u2014 without
2726
+ re-prompting the AI that built their storefront. Every row has a \`type\` +
2727
+ \`key\` + typed \`data\` payload + free-form \`customFields\`.
2728
+
2729
+ **Six content types.** Each one has a fixed \`data\` shape; the SDK's TypeScript
2730
+ generics keep them in lockstep:
2731
+
2732
+ | Type | Use for | \`data\` shape (abbreviated) |
2733
+ | -------------- | -------------------------------------- | --------------------------- |
2734
+ | \`FAQ\` | Q/A accordions | \`{ items: { question, answer }[] }\` |
2735
+ | \`FOOTER\` | Site footer (chrome) | \`{ columns, copyright?, social? }\` |
2736
+ | \`HEADER\` | Top nav + logo + CTA (chrome) | \`{ logo?, navItems, cta? }\` |
2737
+ | \`ANNOUNCEMENT\`| Banners; time-bound by \`startsAt/endsAt\` | \`{ message, severity, dismissible, ... }\` |
2738
+ | \`RICH_TEXT\` | Free-form HTML blocks embedded inline | \`{ html }\` |
2739
+ | \`PAGE\` | Static pages with slug + SEO | \`{ slug, title, html, seo? }\` |
2740
+
2741
+ Run \`get-type-definitions\` with \`domain: 'content'\` for the full interfaces.
2742
+
2743
+ ### Default key
2744
+
2745
+ Every type has \`'main'\` as its universal default key. \`client.content.faq.get()\`
2746
+ with no arguments resolves to \`key='main'\`. Topical keys (\`'shipping'\`,
2747
+ \`'holiday-2026'\`, \`'about'\`) are merchant-named.
2748
+
2749
+ ### Reading content (any SDK mode)
2750
+
2751
+ Public reads work in vibe-coded mode, storefront mode, and admin mode. They
2752
+ return \`null\` on 404 \u2014 render hard-coded fallbacks so the page never crashes
2753
+ when the merchant hasn't seeded yet.
2754
+
2755
+ \`\`\`ts
2756
+ // Single entry, default key 'main', resolved to a locale
2757
+ const faq = await client.content.faq.get('main', locale);
2758
+ if (faq) {
2759
+ faq.data.items.forEach(({ question, answer }) => {
2760
+ // Render question + sanitize(answer)
2761
+ });
2762
+ }
2763
+
2764
+ // All entries of a type
2765
+ const allFaqs = await client.content.faq.list(locale);
2766
+
2767
+ // Page by URL slug \u2014 for app/[slug]/page.tsx
2768
+ const page = await client.content.page.getBySlug(slug, locale);
2769
+ if (!page) notFound();
2770
+ \`\`\`
2771
+
2772
+ ### Security \u2014 sanitize HTML before rendering
2773
+
2774
+ \`FAQ.items[i].answer\`, \`RICH_TEXT.html\`, and \`PAGE.html\` carry
2775
+ MERCHANT-AUTHORED HTML. The server does NOT pre-sanitize \u2014 some merchants
2776
+ embed iframes (e.g. YouTube) which strict sanitizers would strip. ALWAYS
2777
+ sanitize on the storefront before injecting:
2778
+
2779
+ \`\`\`ts
2780
+ // Recommended: isomorphic-dompurify
2781
+ import DOMPurify from 'isomorphic-dompurify';
2782
+ const safe = DOMPurify.sanitize(rawHtml);
2783
+ <div dangerouslySetInnerHTML={{ __html: safe }} />;
2784
+ \`\`\`
2785
+
2786
+ Skipping this is XSS.
2787
+
2788
+ ### Custom fields
2789
+
2790
+ Every Content row carries a free-form \`customFields: Record<string, string>\`.
2791
+ Merchants add arbitrary key-value extras (\`helpEmail\`, \`phoneNumber\`,
2792
+ \`foundedYear\`) that you can opt into reading:
2793
+
2794
+ \`\`\`ts
2795
+ const faq = await client.content.faq.get('shipping');
2796
+ <a href={\`mailto:\${faq.customFields.helpEmail}\`}>Need help?</a>
2797
+ \`\`\`
2798
+
2799
+ The shape is whatever the merchant entered. Read keys you expect; ignore the rest.
2800
+
2801
+ ### Locale resolution
2802
+
2803
+ All public reads accept a \`locale\` argument. The server resolves
2804
+ \`translations[locale]\` server-side and returns the resolved \`data\` payload \u2014
2805
+ the storefront does NOT need to do its own overlay. Empty / missing translations
2806
+ fall through to the default-locale value.
2807
+
2808
+ ### Cache
2809
+
2810
+ Public reads carry \`Cache-Control: public, max-age=300, stale-while-revalidate=60\`.
2811
+ Merchant edits propagate within ~5 minutes. Don't layer extra client-side
2812
+ caching beyond Next.js's default fetch cache.
2813
+
2814
+ ### Admin writes (apiKey mode)
2815
+
2816
+ \`\`\`ts
2817
+ const adminClient = new BrainerceClient({ apiKey: process.env.BRAINERCE_API_KEY });
2818
+
2819
+ // Create \u2014 always starts in DRAFT
2820
+ const faq = await adminClient.content.faq.create({
2821
+ key: 'shipping',
2822
+ name: 'Shipping FAQ',
2823
+ data: { items: [{ question: 'How long?', answer: 'Most orders ship in 2 days.' }] },
2824
+ });
2825
+
2826
+ // Update (data replaces wholesale; last-write-wins on the data field)
2827
+ await adminClient.content.update(faq.id, {
2828
+ data: { items: [{ question: 'How long?', answer: 'Updated answer.' }] },
2829
+ });
2830
+
2831
+ // Publish / unpublish
2832
+ await adminClient.content.publish(faq.id);
2833
+ await adminClient.content.unpublish(faq.id);
2834
+
2835
+ // Hard delete
2836
+ await adminClient.content.remove(faq.id);
2837
+ \`\`\`
2838
+
2839
+ Write operations throw if called from vibe-coded or storefront mode.
2840
+
2841
+ ### Reserved key convention
2842
+
2843
+ \`'main'\` is reserved as the universal default. Don't use it for topical
2844
+ entries \u2014 pick a descriptive slug (\`'shipping'\`, \`'returns'\`, \`'about'\`,
2845
+ \`'holiday-2026'\`). The validation rule is \`^[a-z][a-z0-9-]*$\`, max 64 chars.
2846
+
2847
+ ### See also
2848
+
2849
+ - \`get-business-flows\` with \`flow: 'content-bootstrap'\` for the full
2850
+ layout / FAQ / page recipe.
2851
+ - \`get-required-features\` lists each Content surface (\`site-header\`,
2852
+ \`site-footer\`, \`announcement-bar\`, \`faq-page\`, \`static-pages\`).
2853
+ - \`get-type-definitions\` with \`domain: 'content'\` for the TypeScript
2854
+ interfaces.`;
2855
+ }
2704
2856
  function getSectionByTopic(topic, connectionId, currency) {
2705
2857
  const cid = connectionId || "vc_YOUR_CONNECTION_ID";
2706
2858
  const cur = currency || "USD";
@@ -2747,6 +2899,8 @@ function getSectionByTopic(topic, connectionId, currency) {
2747
2899
  return getAdminApiSection();
2748
2900
  case "inquiries":
2749
2901
  return getContactInquiriesSection();
2902
+ case "content":
2903
+ return getContentSection();
2750
2904
  case "all":
2751
2905
  return [
2752
2906
  "# Brainerce SDK \u2014 full topic dump",
@@ -2835,10 +2989,14 @@ function getSectionByTopic(topic, connectionId, currency) {
2835
2989
  "",
2836
2990
  "---",
2837
2991
  "",
2838
- getContactInquiriesSection()
2992
+ getContactInquiriesSection(),
2993
+ "",
2994
+ "---",
2995
+ "",
2996
+ getContentSection()
2839
2997
  ].join("\n");
2840
2998
  default:
2841
- return `Unknown topic: "${topic}". Available topics: setup, products, cart, checkout, checkout-custom-fields, payment, auth, order-confirmation, inventory, discounts, recommendations, product-customization-fields, tax, i18n, critical-rules, type-reference, admin, inquiries, all`;
2999
+ return `Unknown topic: "${topic}". Available topics: setup, products, cart, checkout, checkout-custom-fields, payment, auth, order-confirmation, inventory, discounts, recommendations, product-customization-fields, tax, i18n, critical-rules, type-reference, admin, inquiries, content, all`;
2842
3000
  }
2843
3001
  }
2844
3002
 
@@ -2866,6 +3024,7 @@ var GET_SDK_DOCS_SCHEMA = {
2866
3024
  "i18n",
2867
3025
  "admin",
2868
3026
  "inquiries",
3027
+ "content",
2869
3028
  "all"
2870
3029
  ]).describe("The SDK documentation topic to retrieve"),
2871
3030
  salesChannelId: import_zod.z.string().optional().describe("Sales channel ID (starts with vc_). Used to personalize setup code."),
@@ -3858,6 +4017,156 @@ export interface ModifierValidationError {
3858
4017
  // The cart line then carries:
3859
4018
  // cart.items[i].modifiers \u2014 CartItemModifierLine[]
3860
4019
  // cart.items[i].modifiersTotal \u2014 decimal string of the paid (non-free) deltas`;
4020
+ var CONTENT_TYPES = `// ---- Content (typed merchant content store) ----
4021
+ // Brainerce ships a typed content store so merchants can edit FAQ, footer,
4022
+ // header, announcements, rich text, and static pages in the dashboard
4023
+ // without re-prompting the AI that built the storefront. Every row has a
4024
+ // 'type' + 'key' + typed 'data' payload + free-form 'customFields'.
4025
+ //
4026
+ // SECURITY (read carefully):
4027
+ // RICH_TEXT.html, PAGE.html, and FAQ answers are MERCHANT-AUTHORED HTML.
4028
+ // ALWAYS sanitize with isomorphic-dompurify (or equivalent) before
4029
+ // injecting via dangerouslySetInnerHTML. The server does NOT pre-sanitize
4030
+ // because some merchants embed iframes (e.g. YouTube) which strict
4031
+ // sanitizers would strip; the storefront chooses the policy.
4032
+ //
4033
+ // 404 contract: client.content.<type>.get(key) returns null when no
4034
+ // PUBLISHED row exists. Always render a hard-coded fallback on null so
4035
+ // the page never crashes when the merchant hasn't seeded yet.
4036
+ //
4037
+ // Default key: every type has 'main' as its universal default. Pass no
4038
+ // argument to fetch the main entry; pass a custom key ('shipping',
4039
+ // 'holiday-2026', 'about') for topical entries.
4040
+
4041
+ export type ContentType = 'FAQ' | 'FOOTER' | 'HEADER' | 'ANNOUNCEMENT' | 'RICH_TEXT' | 'PAGE';
4042
+ export type ContentStatus = 'DRAFT' | 'PUBLISHED';
4043
+
4044
+ export interface FaqItem {
4045
+ question: string;
4046
+ /** Sanitized HTML \u2014 sanitize before rendering. */
4047
+ answer: string;
4048
+ }
4049
+ export interface FaqContent { items: FaqItem[] }
4050
+
4051
+ export interface FooterLink { label: string; url: string }
4052
+ export interface FooterColumn { title: string; links: FooterLink[] }
4053
+ export interface FooterSocialLink { platform: string; url: string } // 'instagram' | 'facebook' | 'x' | ...
4054
+ export interface FooterContent {
4055
+ columns: FooterColumn[];
4056
+ copyright?: string;
4057
+ social?: FooterSocialLink[];
4058
+ }
4059
+
4060
+ export interface HeaderLogo { src: string; alt: string }
4061
+ export interface HeaderNavItem { label: string; url: string }
4062
+ export interface HeaderCta { label: string; url: string }
4063
+ export interface HeaderContent {
4064
+ logo?: HeaderLogo;
4065
+ navItems: HeaderNavItem[];
4066
+ cta?: HeaderCta;
4067
+ }
4068
+
4069
+ export type AnnouncementSeverity = 'info' | 'warning' | 'success';
4070
+ export interface AnnouncementContent {
4071
+ message: string;
4072
+ severity: AnnouncementSeverity;
4073
+ dismissible: boolean;
4074
+ /** ISO 8601 \u2014 filter client-side. */
4075
+ startsAt?: string;
4076
+ endsAt?: string;
4077
+ ctaLabel?: string;
4078
+ ctaHref?: string;
4079
+ }
4080
+
4081
+ export interface RichTextContent {
4082
+ /** Raw HTML \u2014 sanitize before rendering. */
4083
+ html: string;
4084
+ }
4085
+
4086
+ export interface PageSeo {
4087
+ title?: string;
4088
+ description?: string;
4089
+ ogImage?: string;
4090
+ }
4091
+ export interface PageContent {
4092
+ /** URL slug, lower-kebab. */
4093
+ slug: string;
4094
+ title: string;
4095
+ /** Raw HTML \u2014 sanitize before rendering. */
4096
+ html: string;
4097
+ seo?: PageSeo;
4098
+ }
4099
+
4100
+ export interface ContentSummary {
4101
+ id: string;
4102
+ type: ContentType;
4103
+ key: string;
4104
+ name: string;
4105
+ status: ContentStatus;
4106
+ position: number;
4107
+ updatedAt: string;
4108
+ }
4109
+
4110
+ export interface Content<T extends ContentType = ContentType> extends ContentSummary {
4111
+ type: T;
4112
+ data: T extends 'FAQ' ? FaqContent
4113
+ : T extends 'FOOTER' ? FooterContent
4114
+ : T extends 'HEADER' ? HeaderContent
4115
+ : T extends 'ANNOUNCEMENT' ? AnnouncementContent
4116
+ : T extends 'RICH_TEXT' ? RichTextContent
4117
+ : T extends 'PAGE' ? PageContent
4118
+ : never;
4119
+ /** Free-form merchant-defined extras. Read keys the merchant told you to expect. */
4120
+ customFields: Record<string, string>;
4121
+ salesChannelIds: string[];
4122
+ }
4123
+
4124
+ // ---- SDK usage examples ----
4125
+ //
4126
+ // FAQ \u2014 render an accordion from the main FAQ (or a topical one):
4127
+ // const faq = await client.content.faq.get('main', locale); // 'shipping', 'returns', ...
4128
+ // if (faq) {
4129
+ // faq.data.items.forEach(({ question, answer }) => {
4130
+ // // Render question + sanitize(answer) \u2014 never inject raw HTML.
4131
+ // });
4132
+ // }
4133
+ //
4134
+ // Footer \u2014 server component in root layout:
4135
+ // const footer = await client.content.footer.get('main', locale);
4136
+ // if (!footer) return <Fallback />;
4137
+ // // Render footer.data.columns, footer.data.social, footer.data.copyright
4138
+ //
4139
+ // Header \u2014 same pattern as footer:
4140
+ // const header = await client.content.header.get('main', locale);
4141
+ //
4142
+ // Announcement \u2014 multiple may be active; filter by date client-side:
4143
+ // const announcements = await client.content.announcement.list(locale);
4144
+ // const now = Date.now();
4145
+ // const active = announcements.filter((a) => {
4146
+ // const startOk = !a.data.startsAt || new Date(a.data.startsAt).getTime() <= now;
4147
+ // const endOk = !a.data.endsAt || new Date(a.data.endsAt).getTime() >= now;
4148
+ // return startOk && endOk;
4149
+ // });
4150
+ //
4151
+ // Rich text \u2014 inline block anywhere on a page:
4152
+ // const block = await client.content.richText.get('about-intro', locale);
4153
+ // <div dangerouslySetInnerHTML={{ __html: sanitize(block.data.html) }} />
4154
+ //
4155
+ // Page \u2014 catch-all route by slug (e.g. /about, /terms, /privacy):
4156
+ // // app/[slug]/page.tsx
4157
+ // const page = await client.content.page.getBySlug(params.slug, locale);
4158
+ // if (!page) notFound();
4159
+ // // page.data.title, page.data.html, page.data.seo
4160
+ // return <article dangerouslySetInnerHTML={{ __html: sanitize(page.data.html) }} />;
4161
+ //
4162
+ // Custom fields \u2014 every Content row carries a free-form Record<string, string>:
4163
+ // const faq = await client.content.faq.get('shipping');
4164
+ // <a href={\`mailto:\${faq.customFields.helpEmail}\`}>Need help?</a>
4165
+ //
4166
+ // Cache \u2014 public reads carry Cache-Control: public, max-age=300,
4167
+ // stale-while-revalidate=60. Storefront changes propagate within ~5 min
4168
+ // of the merchant publishing. Do not add extra client-side caching
4169
+ // beyond Next.js's default fetch cache.`;
3861
4170
  var TYPES_BY_DOMAIN = {
3862
4171
  products: PRODUCTS_TYPES,
3863
4172
  cart: CART_TYPES,
@@ -3868,7 +4177,8 @@ var TYPES_BY_DOMAIN = {
3868
4177
  helpers: HELPERS_TYPES,
3869
4178
  inquiries: INQUIRIES_TYPES,
3870
4179
  reviews: REVIEWS_TYPES,
3871
- "modifier-groups": MODIFIER_GROUPS_TYPES
4180
+ "modifier-groups": MODIFIER_GROUPS_TYPES,
4181
+ content: CONTENT_TYPES
3872
4182
  };
3873
4183
  function getTypesByDomain(domain) {
3874
4184
  if (domain === "all") {
@@ -3899,9 +4209,10 @@ var GET_TYPE_DEFINITIONS_SCHEMA = {
3899
4209
  "helpers",
3900
4210
  "inquiries",
3901
4211
  "reviews",
4212
+ "content",
3902
4213
  "all"
3903
4214
  ]).describe(
3904
- 'The domain of types to retrieve. Use "helpers" for helper function signatures and common types like StoreInfo, PaginatedResponse.'
4215
+ 'The domain of types to retrieve. Use "helpers" for helper function signatures and common types like StoreInfo, PaginatedResponse. Use "content" for FAQ / Footer / Header / Announcement / RichText / Page.'
3905
4216
  )
3906
4217
  };
3907
4218
  async function handleGetTypeDefinitions(args) {
@@ -4448,8 +4759,10 @@ client.setLocale(locale);
4448
4759
  // order bumps, search suggestions, discount banners, nudges,
4449
4760
  // badges, order history.
4450
4761
 
4451
- // For RTL locales (he, ar), set the document direction.
4452
- // Framework-neutral: document.documentElement.setAttribute('dir', 'rtl');`,
4762
+ // For RTL direction, do not hardcode the locale list. Ask the SDK:
4763
+ // const dir = client.getStoreDirection(currentLocale); // 'ltr' | 'rtl'
4764
+ // document.documentElement.setAttribute('dir', dir);
4765
+ // (Or in React: <html dir={dir}>...</html>.)`,
4453
4766
  "order-history-full": `// Full "My Orders" account page. Render every piece of data the server
4454
4767
  // already returns \u2014 not just order number / total / status.
4455
4768
  //
@@ -5541,7 +5854,7 @@ var RULES = {
5541
5854
  body: `- NEVER hardcode currency, locale, or language strings. Read them from \`get-store-info\` / \`get-store-capabilities\` and use the configured values.
5542
5855
  - NEVER format prices with \`toFixed(2)\` or custom logic. Use \`formatPrice()\` from the SDK \u2014 it honors the store's currency and locale.
5543
5856
  - When the store has i18n enabled (\`capabilities.store.i18n.enabled === true\`), you MUST call \`client.setLocale(locale)\` at app init and include a language switcher. All SDK reads will then return localized content automatically.
5544
- - For RTL locales (\`he\`, \`ar\`), set the document direction to RTL. Do not manually reverse flex layouts \u2014 the platform's CSS reversal handles it.`
5857
+ - For RTL direction, do NOT maintain a local list of RTL locales. Call \`client.getStoreDirection(locale)\` \u2014 it returns \`'ltr' | 'rtl'\` for any BCP-47 tag (covers Arabic, Hebrew, Persian, Urdu, Yiddish, and any future RTL locales the platform adds). Set \`<html dir={...}>\` from this value. The platform's CSS reversal handles flex layouts \u2014 do not manually swap them.`
5545
5858
  },
5546
5859
  types: {
5547
5860
  title: "Type safety",
@@ -5589,6 +5902,7 @@ var GET_BUSINESS_FLOWS_SCHEMA = {
5589
5902
  "cart-persistence",
5590
5903
  "inventory-reservation",
5591
5904
  "product-customization",
5905
+ "content-bootstrap",
5592
5906
  "all"
5593
5907
  ]).describe('Which flow to retrieve. Use "all" to get every flow.')
5594
5908
  };
@@ -5779,6 +6093,76 @@ Server-side guardrails that WILL reject bad requests (so validate client-side to
5779
6093
  - More than 10 uploads per IP per minute \u2192 429.
5780
6094
 
5781
6095
  Never render customization fields without also wiring the upload + metadata flow \u2014 a form that submits nothing is worse than no form at all.`
6096
+ },
6097
+ "content-bootstrap": {
6098
+ title: "Content Bootstrap \u2014 site chrome & static content",
6099
+ body: `Every Brainerce storefront should render merchant-defined site chrome (header, footer, announcements, FAQ, static pages) from the Content API. The merchant edits these in the Brainerce dashboard; storefronts pick up changes within ~5 minutes (public reads carry \`Cache-Control: public, max-age=300, stale-while-revalidate=60\`).
6100
+
6101
+ 1. **Fetch chrome at the root layout** (server component if Next.js). All three return \`null\` on 404 \u2014 render hard-coded fallbacks so the page never crashes when the merchant hasn't seeded yet.
6102
+ \`\`\`ts
6103
+ const [header, footer, announcements] = await Promise.all([
6104
+ client.content.header.get('main', locale),
6105
+ client.content.footer.get('main', locale),
6106
+ client.content.announcement.list(locale),
6107
+ ]);
6108
+ \`\`\`
6109
+
6110
+ 2. **FAQ \u2014 fetch lazily on the FAQ page.** Default key is \`'main'\`; pass a topical key (\`'shipping'\`, \`'returns'\`) for sub-FAQs.
6111
+ \`\`\`ts
6112
+ const faq = await client.content.faq.get('main', locale);
6113
+ if (faq) {
6114
+ faq.data.items.forEach(({ question, answer }) => {
6115
+ // sanitize(answer) \u2014 see step 4
6116
+ });
6117
+ }
6118
+ \`\`\`
6119
+
6120
+ 3. **Static pages \u2014 catch-all route by slug:**
6121
+ \`\`\`tsx
6122
+ // app/[slug]/page.tsx
6123
+ export default async function Page({ params }) {
6124
+ const page = await client.content.page.getBySlug(params.slug, locale);
6125
+ if (!page) notFound();
6126
+ return (
6127
+ <article dangerouslySetInnerHTML={{ __html: sanitize(page.data.html) }} />
6128
+ );
6129
+ }
6130
+ \`\`\`
6131
+
6132
+ 4. **SECURITY \u2014 sanitize HTML before rendering.** \`FAQ.items[i].answer\`, \`PAGE.html\`, and \`RICH_TEXT.html\` are merchant-authored HTML. The server does NOT pre-sanitize because some merchants embed iframes (e.g. YouTube). Always sanitize at the edge of your render:
6133
+ \`\`\`ts
6134
+ import DOMPurify from 'isomorphic-dompurify';
6135
+ const safe = DOMPurify.sanitize(rawHtml);
6136
+ <div dangerouslySetInnerHTML={{ __html: safe }} />;
6137
+ \`\`\`
6138
+ Skipping this is XSS.
6139
+
6140
+ 5. **Announcements \u2014 multiple may be active; filter by date client-side:**
6141
+ \`\`\`ts
6142
+ const now = Date.now();
6143
+ const visible = announcements.filter((a) => {
6144
+ const startOk = !a.data.startsAt || new Date(a.data.startsAt).getTime() <= now;
6145
+ const endOk = !a.data.endsAt || new Date(a.data.endsAt).getTime() >= now;
6146
+ return startOk && endOk;
6147
+ });
6148
+ \`\`\`
6149
+
6150
+ 6. **RTL direction \u2014 call \`client.getStoreDirection(locale)\`:**
6151
+ \`\`\`tsx
6152
+ const dir = client.getStoreDirection(locale);
6153
+ <html lang={locale} dir={dir}>...</html>
6154
+ \`\`\`
6155
+ Do NOT maintain a local RTL locale set \u2014 the SDK helper covers Arabic / Hebrew / Persian / Urdu / Yiddish today and picks up any future RTL locale automatically.
6156
+
6157
+ 7. **Custom fields \u2014 every Content row has free-form \`customFields: Record<string, string>\`.** Read keys the merchant told you to expect:
6158
+ \`\`\`ts
6159
+ const faq = await client.content.faq.get('shipping');
6160
+ <a href={\`mailto:\${faq.customFields.helpEmail}\`}>Need help?</a>
6161
+ \`\`\`
6162
+
6163
+ 8. **Cache:** public reads carry \`Cache-Control: public, max-age=300, stale-while-revalidate=60\`. Don't add extra client-side caching beyond Next.js's default fetch cache \u2014 merchants expect their edits to appear within ~5 minutes.
6164
+
6165
+ **Translations.** All public reads accept a \`locale\` argument; the server resolves \`translations[locale]\` server-side. Empty / missing overlays fall through to the default-locale value. The storefront does NOT need to do its own per-field overlay \u2014 call with the active locale and render what comes back.`
5782
6166
  }
5783
6167
  };
5784
6168
  var FLOW_ORDER = [
@@ -5790,7 +6174,8 @@ var FLOW_ORDER = [
5790
6174
  "order-confirmation",
5791
6175
  "cart-persistence",
5792
6176
  "inventory-reservation",
5793
- "product-customization"
6177
+ "product-customization",
6178
+ "content-bootstrap"
5794
6179
  ];
5795
6180
  async function handleGetBusinessFlows(args) {
5796
6181
  const header = "# Brainerce Business Flows\n\nThese sequences are framework-neutral and non-negotiable. Your framework and file layout are your choice \u2014 the order of SDK calls and the error handling is not.";
@@ -6002,11 +6387,57 @@ var FEATURES = [
6002
6387
  {
6003
6388
  id: "i18n",
6004
6389
  title: "Serve multiple languages with a language switcher",
6005
- description: "When i18n is enabled, the experience routes by locale, sets the SDK locale (client.setLocale), includes a language switcher in the header, and renders RTL locales (he, ar) with the correct document direction.",
6006
- sdk: "client.setLocale(locale). Read supported locales from get-store-capabilities.store.i18n.",
6390
+ description: "When i18n is enabled, the experience routes by locale, sets the SDK locale (client.setLocale), includes a language switcher in the header, and renders the correct document direction by reading client.getStoreDirection(locale) \u2014 do not hardcode an RTL locale set.",
6391
+ sdk: "client.setLocale(locale). client.getStoreDirection(locale) for <html dir>. Read supported locales from get-store-capabilities.store.i18n.",
6007
6392
  mandatory: "conditional",
6008
6393
  capabilityFlag: "i18n",
6009
6394
  whenDisabledNote: "This store is single-language. Do not build the language switcher."
6395
+ },
6396
+ {
6397
+ id: "site-header",
6398
+ title: "Site header from merchant content (logo + nav + CTA)",
6399
+ description: 'Fetch client.content.header.get("main", locale) in the root layout. Returns null when the merchant has not seeded yet \u2014 render a hard-coded fallback so the page never crashes. Renders header.data.logo, header.data.navItems[], header.data.cta if present.',
6400
+ sdk: 'client.content.header.get("main", locale)',
6401
+ flowRef: "content-bootstrap",
6402
+ mandatory: "mandatory"
6403
+ },
6404
+ {
6405
+ id: "site-footer",
6406
+ title: "Site footer from merchant content (columns + social + copyright)",
6407
+ description: 'Fetch client.content.footer.get("main", locale) in the root layout. Returns null when unseeded \u2014 render a hard-coded fallback. Render footer.data.columns[].links, footer.data.social[], footer.data.copyright.',
6408
+ sdk: 'client.content.footer.get("main", locale)',
6409
+ flowRef: "content-bootstrap",
6410
+ mandatory: "mandatory"
6411
+ },
6412
+ {
6413
+ id: "announcement-bar",
6414
+ title: "Announcement bar at the top of every page",
6415
+ description: "Fetch client.content.announcement.list(locale) in the root layout. Filter by data.startsAt / data.endsAt client-side. Render a dismissible bar when data.dismissible=true. Build the UI anyway \u2014 it auto-hides when no announcements exist.",
6416
+ sdk: "client.content.announcement.list(locale)",
6417
+ flowRef: "content-bootstrap",
6418
+ mandatory: "conditional",
6419
+ capabilityFlag: "hasContent",
6420
+ whenDisabledNote: "Store has no published Content rows yet. Build the announcement bar anyway \u2014 it auto-hides on empty."
6421
+ },
6422
+ {
6423
+ id: "faq-page",
6424
+ title: "FAQ page rendered from merchant content",
6425
+ description: 'Build /faq as an accordion fed by client.content.faq.get("main", locale). For topical FAQs, use a key parameter (shipping, returns, ...). Always sanitize answer HTML before injecting via dangerouslySetInnerHTML. Build the page anyway \u2014 it auto-hides or 404s when no FAQ rows exist.',
6426
+ sdk: 'client.content.faq.get("main", locale), client.content.faq.list(locale)',
6427
+ flowRef: "content-bootstrap",
6428
+ mandatory: "conditional",
6429
+ capabilityFlag: "hasContent",
6430
+ whenDisabledNote: "No FAQ content yet. Build /faq anyway \u2014 it auto-hides on empty."
6431
+ },
6432
+ {
6433
+ id: "static-pages",
6434
+ title: "Static pages from merchant content (About, Terms, Privacy, \u2026)",
6435
+ description: "Mount a catch-all app/[slug]/page.tsx route. Inside, call client.content.page.getBySlug(params.slug, locale). On null \u2192 notFound(). On hit, sanitize page.data.html before injecting via dangerouslySetInnerHTML. Generate <Metadata> from page.data.seo. Build the route anyway \u2014 it 404s on unknown slugs.",
6436
+ sdk: "client.content.page.getBySlug(slug, locale), client.content.page.list(locale)",
6437
+ flowRef: "content-bootstrap",
6438
+ mandatory: "conditional",
6439
+ capabilityFlag: "hasContent",
6440
+ whenDisabledNote: "No static pages yet. Build the catch-all route anyway \u2014 it 404s on unknown slugs."
6010
6441
  }
6011
6442
  ];
6012
6443
  function isFeatureActive(feature, caps) {
@@ -6057,6 +6488,7 @@ function renderCapabilitiesSummary(caps) {
6057
6488
  );
6058
6489
  lines.push(`- Downloadable products: ${caps.features.hasDownloadableProducts ? "yes" : "no"}`);
6059
6490
  lines.push(`- Checkout custom fields: ${caps.features.hasCheckoutCustomFields ? "yes" : "no"}`);
6491
+ lines.push(`- Content (FAQ/footer/header/announcements/pages): ${caps.features.hasContent ? "seeded" : "none \u2014 build chrome UI with fallbacks"}`);
6060
6492
  lines.push(
6061
6493
  `- Email verification: ${caps.connection.requireEmailVerification ? "required" : "not required (still build the verify-email flow)"}`
6062
6494
  );