@brainerce/mcp-server 3.9.0 → 3.11.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 +290 -4
- package/dist/bin/stdio.js +290 -4
- package/dist/index.d.mts +0 -3
- package/dist/index.d.ts +0 -3
- package/dist/index.js +290 -4
- package/dist/index.mjs +290 -4
- package/package.json +1 -1
package/dist/bin/http.js
CHANGED
|
@@ -712,7 +712,7 @@ const growProvider = providers.find(p => p.provider === 'grow');
|
|
|
712
712
|
const paypalProvider = providers.find(p => p.provider === 'paypal');
|
|
713
713
|
\`\`\`
|
|
714
714
|
|
|
715
|
-
Each provider has: \`id\`, \`provider\` (flexible string \u2014 \`'stripe'\`, \`'grow'\`, \`'paypal'\`, \`'cardcom'\`, \`'sandbox'\`, and future providers), \`name\`, \`publicKey\`, \`stripeAccountId\` (Stripe only), \`supportedMethods\`, \`testMode\`, \`isDefault\`.
|
|
715
|
+
Each provider has: \`id\`, \`provider\` (flexible string \u2014 \`'stripe'\`, \`'grow'\`, \`'paypal'\`, \`'cardcom'\`, \`'morning'\`, \`'takbull'\`, \`'sandbox'\`, and future providers), \`name\`, \`publicKey\`, \`stripeAccountId\` (Stripe only), \`supportedMethods\`, \`testMode\`, \`isDefault\`.
|
|
716
716
|
|
|
717
717
|
The payment intent returned from \`createPaymentIntent()\` includes a \`clientSdk\` object whose \`renderType\` tells you exactly how to render \u2014 **branch on THAT, not on the provider name**:
|
|
718
718
|
|
|
@@ -2371,6 +2371,67 @@ Read \`storeInfo.i18n.supportedLocales\` and render a switcher in the header
|
|
|
2371
2371
|
that navigates to \`/{otherLocale}/{currentPathWithoutLocale}\`. The middleware
|
|
2372
2372
|
handles the canonical redirect when the user picks the default locale.`;
|
|
2373
2373
|
}
|
|
2374
|
+
function getMultilingualSeoSection() {
|
|
2375
|
+
return `## Multilingual SEO
|
|
2376
|
+
|
|
2377
|
+
### Slugs per locale (IMPORTANT)
|
|
2378
|
+
|
|
2379
|
+
Brainerce stores per-locale slugs in \`Product.translations[locale].slug\`.
|
|
2380
|
+
The API exposes them as \`product.localeSlugs\` \u2014 a flat \`Record<string, string>\`.
|
|
2381
|
+
|
|
2382
|
+
\`\`\`typescript
|
|
2383
|
+
// product.localeSlugs = { he: '\u05DE\u05D6\u05E8\u05DF-\u05D9\u05D5\u05D2\u05D4', en: 'yoga-mattress', ar: '\u062D\u0635\u064A\u0631\u0629-\u064A\u0648\u063A\u0627' }
|
|
2384
|
+
const locSlug = product.localeSlugs?.[locale] ?? product.slug;
|
|
2385
|
+
\`\`\`
|
|
2386
|
+
|
|
2387
|
+
Use AI translation (\`translateEntities\` / the AI Translate button in the admin) to populate
|
|
2388
|
+
locale-specific slugs automatically. Until translated, all locales fall back to the base slug
|
|
2389
|
+
(which Google still accepts \u2014 it resolves to the correct locale content via Accept-Language).
|
|
2390
|
+
|
|
2391
|
+
### hreflang tags
|
|
2392
|
+
|
|
2393
|
+
Every product page in a multi-locale store MUST emit bidirectional hreflang tags or Google
|
|
2394
|
+
ignores them entirely. The scaffolded template generates them automatically when
|
|
2395
|
+
\`NEXT_PUBLIC_BRAINERCE_LOCALES=he,en\` is set.
|
|
2396
|
+
|
|
2397
|
+
\`\`\`html
|
|
2398
|
+
<!-- Example output for /en/products/yoga-mattress -->
|
|
2399
|
+
<link rel="alternate" hreflang="he" href="https://store.com/products/\u05DE\u05D6\u05E8\u05DF-\u05D9\u05D5\u05D2\u05D4" />
|
|
2400
|
+
<link rel="alternate" hreflang="en" href="https://store.com/en/products/yoga-mattress" />
|
|
2401
|
+
<link rel="alternate" hreflang="x-default" href="https://store.com/products/\u05DE\u05D6\u05E8\u05DF-\u05D9\u05D5\u05D2\u05D4" />
|
|
2402
|
+
\`\`\`
|
|
2403
|
+
|
|
2404
|
+
If building a custom storefront, add to \`generateMetadata()\`:
|
|
2405
|
+
\`\`\`typescript
|
|
2406
|
+
alternates: {
|
|
2407
|
+
canonical: locale === defaultLoc ? \`/products/\${slug}\` : \`/\${locale}/products/\${slug}\`,
|
|
2408
|
+
languages: {
|
|
2409
|
+
he: \`\${baseUrl}/products/\${localeSlugs.he ?? baseSlug}\`,
|
|
2410
|
+
en: \`\${baseUrl}/en/products/\${localeSlugs.en ?? baseSlug}\`,
|
|
2411
|
+
'x-default': \`\${baseUrl}/products/\${localeSlugs[defaultLoc] ?? baseSlug}\`,
|
|
2412
|
+
},
|
|
2413
|
+
},
|
|
2414
|
+
\`\`\`
|
|
2415
|
+
|
|
2416
|
+
### URL structure
|
|
2417
|
+
|
|
2418
|
+
Google-recommended for headless storefronts:
|
|
2419
|
+
- Default locale: \`/products/\u05DE\u05D6\u05E8\u05DF-\u05D9\u05D5\u05D2\u05D4\` (no prefix)
|
|
2420
|
+
- Other locales: \`/en/products/yoga-mattress\` (prefixed)
|
|
2421
|
+
- \u274C Never: \`?locale=he\` query params (Google rates these as "Not recommended")
|
|
2422
|
+
|
|
2423
|
+
### Sitemap
|
|
2424
|
+
|
|
2425
|
+
The scaffolded \`sitemap.ts\` generates per-locale entries automatically:
|
|
2426
|
+
\`\`\`
|
|
2427
|
+
/products/\u05DE\u05D6\u05E8\u05DF-\u05D9\u05D5\u05D2\u05D4 (he \u2014 default, no prefix)
|
|
2428
|
+
/en/products/yoga-mattress (en)
|
|
2429
|
+
/ar/products/\u062D\u0635\u064A\u0631\u0629-\u064A\u0648\u063A\u0627 (ar)
|
|
2430
|
+
\`\`\`
|
|
2431
|
+
|
|
2432
|
+
Hebrew, Arabic, and other non-Latin slugs are fully supported \u2014 Google recommends
|
|
2433
|
+
using the audience's language in URLs and indexes non-ASCII characters correctly.`;
|
|
2434
|
+
}
|
|
2374
2435
|
function getAdminApiSection() {
|
|
2375
2436
|
return `## Admin API (v0.19.0+)
|
|
2376
2437
|
|
|
@@ -2454,6 +2515,20 @@ await admin.mergeTaxClasses(food.id, standardClassId);
|
|
|
2454
2515
|
Storefront (public, no apiKey \u2014 \`storeId\` mode): \`getStoreTaxClasses()\` lists
|
|
2455
2516
|
the store's classes (storefront-safe fields only) for a transparency badge.
|
|
2456
2517
|
|
|
2518
|
+
For a buyer-facing tax preview on PDP / PLP / cart, \`estimateTax({ country,
|
|
2519
|
+
subtotal })\` returns the tax portion at the Standard rate for the buyer's
|
|
2520
|
+
country. **Non-binding** \u2014 the authoritative tax still runs at checkout with
|
|
2521
|
+
the full shipping address (state / postal / per-class). Always render with an
|
|
2522
|
+
"Estimate" affordance.
|
|
2523
|
+
|
|
2524
|
+
\`\`\`typescript
|
|
2525
|
+
const { estimatedTax, rate, currency, note } = await store.estimateTax({
|
|
2526
|
+
country: 'IT', subtotal: 100,
|
|
2527
|
+
});
|
|
2528
|
+
// \u2192 { appliesTax: true, rate: 22, estimatedTax: 22, currency: 'EUR',
|
|
2529
|
+
// note: 'Estimate \u2014 final tax calculated at checkout\u2026' }
|
|
2530
|
+
\`\`\`
|
|
2531
|
+
|
|
2457
2532
|
### Regions (multi-currency / per-region providers)
|
|
2458
2533
|
|
|
2459
2534
|
A region binds countries \u2192 currency + tax-display mode + enabled payment
|
|
@@ -2484,6 +2559,19 @@ const { data: regions } = await store.getStoreRegions();
|
|
|
2484
2559
|
const region = await store.getStoreRegion(regions[0].id);
|
|
2485
2560
|
\`\`\`
|
|
2486
2561
|
|
|
2562
|
+
For a single round trip, \`getAutoRegion(country)\` resolves a buyer's country
|
|
2563
|
+
to a region server-side. Brainerce does NOT derive the country from the request
|
|
2564
|
+
IP (the storefront server is what reaches the backend, not the end-customer) \u2014
|
|
2565
|
+
your storefront extracts the country from its edge runtime (Cloudflare
|
|
2566
|
+
\`CF-IPCountry\`, Vercel \`request.geo?.country\`, Fastly \`client-geo-country\`,
|
|
2567
|
+
etc.) and forwards it. Returns \`matched=true\` on explicit country hit, \`false\`
|
|
2568
|
+
when falling back to the default region.
|
|
2569
|
+
|
|
2570
|
+
\`\`\`typescript
|
|
2571
|
+
const country = headers.get('cf-ipcountry') ?? 'US';
|
|
2572
|
+
const { region, matched } = await store.getAutoRegion(country);
|
|
2573
|
+
\`\`\`
|
|
2574
|
+
|
|
2487
2575
|
A shipping zone can be limited to regions via \`regionIds\` \u2014 the zone is then
|
|
2488
2576
|
only offered to checkouts that resolved to one of those regions. Empty/omitted =
|
|
2489
2577
|
available for any region (default); each id must belong to the same store.
|
|
@@ -2947,6 +3035,146 @@ entries \u2014 pick a descriptive slug (\`'shipping'\`, \`'returns'\`, \`'about'
|
|
|
2947
3035
|
- \`get-type-definitions\` with \`domain: 'content'\` for the TypeScript
|
|
2948
3036
|
interfaces.`;
|
|
2949
3037
|
}
|
|
3038
|
+
function getBlogSection() {
|
|
3039
|
+
return `## Blog
|
|
3040
|
+
|
|
3041
|
+
Merchants write and schedule blog posts in **Content \u2192 Blog** in the dashboard.
|
|
3042
|
+
Storefronts choose their own URL scheme \u2014 render posts at \`/blog/[slug]\`,
|
|
3043
|
+
\`/articles/[slug]\`, or whatever fits the brand.
|
|
3044
|
+
|
|
3045
|
+
Public reads carry \`Cache-Control: public, max-age=300, stale-while-revalidate=60\`.
|
|
3046
|
+
|
|
3047
|
+
**Scheduling:** A post is visible once \`status === 'PUBLISHED'\` and
|
|
3048
|
+
\`publishedAt <= now()\`. Set a future \`publishedAt\` while publishing to
|
|
3049
|
+
schedule \u2014 no cron needed; visibility is computed at query time.
|
|
3050
|
+
|
|
3051
|
+
### Reading posts (any SDK mode)
|
|
3052
|
+
|
|
3053
|
+
\`\`\`typescript
|
|
3054
|
+
// List published posts
|
|
3055
|
+
const { data: posts, meta } = await client.blog.getPosts({ page: 1, limit: 10 });
|
|
3056
|
+
|
|
3057
|
+
// Filter by category or tag
|
|
3058
|
+
const { data: news } = await client.blog.getPosts({ category: 'news' });
|
|
3059
|
+
const { data: tips } = await client.blog.getPosts({ tag: 'tutorial' });
|
|
3060
|
+
|
|
3061
|
+
// Fetch one by slug (returns null on 404)
|
|
3062
|
+
const post = await client.blog.getPost('my-first-post');
|
|
3063
|
+
if (post) {
|
|
3064
|
+
console.log(post.title); // string
|
|
3065
|
+
console.log(post.content); // HTML string from rich-text editor
|
|
3066
|
+
console.log(post.excerpt); // optional short summary
|
|
3067
|
+
console.log(post.tags); // string[]
|
|
3068
|
+
console.log(post.coverImageUrl, post.coverImageAlt);
|
|
3069
|
+
console.log(post.publishedAt); // ISO 8601 or undefined
|
|
3070
|
+
}
|
|
3071
|
+
\`\`\`
|
|
3072
|
+
|
|
3073
|
+
### BlogPost fields
|
|
3074
|
+
|
|
3075
|
+
| Field | Type | Notes |
|
|
3076
|
+
| ----------------- | ----------- | ------------------------------------- |
|
|
3077
|
+
| \`id\` | string | |
|
|
3078
|
+
| \`title\` | string | |
|
|
3079
|
+
| \`slug\` | string | Unique per store, URL-safe |
|
|
3080
|
+
| \`category\` | string? | Free-form (e.g. \`'news'\`) |
|
|
3081
|
+
| \`content\` | string | HTML from rich-text editor |
|
|
3082
|
+
| \`excerpt\` | string? | Short summary for listing cards |
|
|
3083
|
+
| \`coverImageUrl\` | string? | |
|
|
3084
|
+
| \`coverImageAlt\` | string? | |
|
|
3085
|
+
| \`author\` | string? | |
|
|
3086
|
+
| \`tags\` | string[] | |
|
|
3087
|
+
| \`publishedAt\` | string? | ISO 8601; null = publish immediately |
|
|
3088
|
+
| \`seoTitle\` | string? | |
|
|
3089
|
+
| \`seoDescription\`| string? | |
|
|
3090
|
+
| \`ogImageUrl\` | string? | |
|
|
3091
|
+
|
|
3092
|
+
### Rendering blog content
|
|
3093
|
+
|
|
3094
|
+
\`\`\`tsx
|
|
3095
|
+
// app/blog/[slug]/page.tsx
|
|
3096
|
+
import DOMPurify from 'isomorphic-dompurify';
|
|
3097
|
+
|
|
3098
|
+
const post = await brainerce.blog.getPost(params.slug);
|
|
3099
|
+
if (!post) notFound();
|
|
3100
|
+
|
|
3101
|
+
// Always sanitize before rendering HTML \u2014 treat external-origin content as untrusted
|
|
3102
|
+
const safeHtml = DOMPurify.sanitize(post.content);
|
|
3103
|
+
return <div dangerouslySetInnerHTML={{ __html: safeHtml }} className="prose" />;
|
|
3104
|
+
\`\`\`
|
|
3105
|
+
|
|
3106
|
+
The \`content\` field is HTML produced by the Lexical rich-text editor.
|
|
3107
|
+
**Always sanitize with DOMPurify (or equivalent) before rendering via
|
|
3108
|
+
\`dangerouslySetInnerHTML\`** \u2014 even though the content originates from your
|
|
3109
|
+
own editor, defense-in-depth prevents any stored-XSS path if content is ever
|
|
3110
|
+
migrated or imported from an external source.
|
|
3111
|
+
Apply a \`prose\` class (Tailwind Typography) for automatic styling.
|
|
3112
|
+
|
|
3113
|
+
### REST endpoints
|
|
3114
|
+
|
|
3115
|
+
| Method | Path | Returns |
|
|
3116
|
+
|--------|------|---------|
|
|
3117
|
+
| GET | \`/api/stores/:storeId/blog/posts\` | \`BlogPostListResponse\` |
|
|
3118
|
+
| GET | \`/api/stores/:storeId/blog/posts/:slug\` | \`BlogPost\` or 404 |
|
|
3119
|
+
| GET | \`/api/vc/:connectionId/blog/posts\` | Same, channel-scoped |
|
|
3120
|
+
| GET | \`/api/vc/:connectionId/blog/posts/:slug\` | \`BlogPost\` or 404 |
|
|
3121
|
+
`;
|
|
3122
|
+
}
|
|
3123
|
+
function getStorefrontBotSection(connectionId) {
|
|
3124
|
+
return `## Storefront Bot (AI chat widget)
|
|
3125
|
+
|
|
3126
|
+
The store's AI shopping assistant. ALL configuration (name, avatar, colors,
|
|
3127
|
+
greeting, starter questions, capabilities, guardrails) lives in the merchant
|
|
3128
|
+
dashboard \u2014 the embed never decides behavior, and the widget renders nothing
|
|
3129
|
+
until the merchant switches the bot Live.
|
|
3130
|
+
|
|
3131
|
+
### Zero-code embed (any site)
|
|
3132
|
+
|
|
3133
|
+
\`\`\`html
|
|
3134
|
+
<script src="https://cdn.brainerce.com/bot.js" data-connection-id="${connectionId}" defer></script>
|
|
3135
|
+
\`\`\`
|
|
3136
|
+
|
|
3137
|
+
Keep the tag exactly this bare \u2014 do NOT add \`integrity\` or \`crossorigin\`
|
|
3138
|
+
(the bootstrap is intentionally mutable; it is origin-pinned by CSP instead).
|
|
3139
|
+
|
|
3140
|
+
### SDK mount (React / Next.js / any bundler)
|
|
3141
|
+
|
|
3142
|
+
\`\`\`ts
|
|
3143
|
+
import { BrainerceBot } from 'brainerce/bot';
|
|
3144
|
+
|
|
3145
|
+
// client-side only (e.g. in a useEffect) \u2014 mounts a floating chat bubble
|
|
3146
|
+
const bot = await BrainerceBot.mount({ connectionId: '${connectionId}' });
|
|
3147
|
+
bot?.destroy(); // optional teardown
|
|
3148
|
+
\`\`\`
|
|
3149
|
+
|
|
3150
|
+
\`mount\` resolves to \`null\` when the bot is disabled (FREE plan, switched
|
|
3151
|
+
off, or unconfigured) \u2014 safe to call unconditionally. Options: \`connectionId\`
|
|
3152
|
+
(required), \`baseUrl\` (API origin override), \`target\` (mount element),
|
|
3153
|
+
\`onAddToCart\` (\`({ productId, variantId, quantity }) => boolean | Promise<boolean>\`
|
|
3154
|
+
\u2014 route the widget's cart adds through the site's own cart; \`variantId\` is
|
|
3155
|
+
null for simple products; return false to fall back to the product page).
|
|
3156
|
+
|
|
3157
|
+
Behavior: persists an anonymous session in localStorage, restores the
|
|
3158
|
+
conversation on revisit, streams answers, and shows product recommendation
|
|
3159
|
+
cards (image, price, add-to-cart / view). Multi-variant products get an
|
|
3160
|
+
in-card variant picker; shoppers can also ask the assistant to add an item
|
|
3161
|
+
and it goes through the same cart chain. Zero-result searches feed the
|
|
3162
|
+
merchant's "unmet demand" analytics. Aside from shopper-initiated cart adds,
|
|
3163
|
+
the bot is read-only.
|
|
3164
|
+
|
|
3165
|
+
Add-to-cart resolution chain: \`onAddToCart\` option \u2192 cancelable
|
|
3166
|
+
\`brainerce:bot:add-to-cart\` CustomEvent on window
|
|
3167
|
+
(\`detail: { productId, variantId, quantity, connectionId }\`; call
|
|
3168
|
+
preventDefault() after handling) \u2192 navigate to the product page.
|
|
3169
|
+
|
|
3170
|
+
Rules:
|
|
3171
|
+
- Mount once per page; do not pass any visual config \u2014 the dashboard owns it.
|
|
3172
|
+
- Do not wrap or restyle the widget; it renders in its own Shadow DOM.
|
|
3173
|
+
- Product card links expect the conventional \`/products/<slug>\` route.
|
|
3174
|
+
- Wire \`onAddToCart\` to the site's cart (see the cart section) so the header
|
|
3175
|
+
count updates when the bot adds items.
|
|
3176
|
+
`;
|
|
3177
|
+
}
|
|
2950
3178
|
function getSectionByTopic(topic, connectionId, currency) {
|
|
2951
3179
|
const cid = connectionId || "vc_YOUR_CONNECTION_ID";
|
|
2952
3180
|
const cur = currency || "USD";
|
|
@@ -2985,6 +3213,10 @@ function getSectionByTopic(topic, connectionId, currency) {
|
|
|
2985
3213
|
return getTaxDisplaySection(cur);
|
|
2986
3214
|
case "i18n":
|
|
2987
3215
|
return getI18nSection();
|
|
3216
|
+
case "multilingual-seo":
|
|
3217
|
+
case "hreflang":
|
|
3218
|
+
case "seo-i18n":
|
|
3219
|
+
return getMultilingualSeoSection();
|
|
2988
3220
|
case "critical-rules":
|
|
2989
3221
|
return getCriticalRulesSection() + "\n\n" + getTypeQuickReference();
|
|
2990
3222
|
case "type-reference":
|
|
@@ -2995,6 +3227,10 @@ function getSectionByTopic(topic, connectionId, currency) {
|
|
|
2995
3227
|
return getContactInquiriesSection();
|
|
2996
3228
|
case "content":
|
|
2997
3229
|
return getContentSection();
|
|
3230
|
+
case "blog":
|
|
3231
|
+
return getBlogSection();
|
|
3232
|
+
case "storefront-bot":
|
|
3233
|
+
return getStorefrontBotSection(cid);
|
|
2998
3234
|
case "all":
|
|
2999
3235
|
return [
|
|
3000
3236
|
"# Brainerce SDK \u2014 full topic dump",
|
|
@@ -3079,6 +3315,10 @@ function getSectionByTopic(topic, connectionId, currency) {
|
|
|
3079
3315
|
"",
|
|
3080
3316
|
"---",
|
|
3081
3317
|
"",
|
|
3318
|
+
getMultilingualSeoSection(),
|
|
3319
|
+
"",
|
|
3320
|
+
"---",
|
|
3321
|
+
"",
|
|
3082
3322
|
getAdminApiSection(),
|
|
3083
3323
|
"",
|
|
3084
3324
|
"---",
|
|
@@ -3087,10 +3327,18 @@ function getSectionByTopic(topic, connectionId, currency) {
|
|
|
3087
3327
|
"",
|
|
3088
3328
|
"---",
|
|
3089
3329
|
"",
|
|
3090
|
-
getContentSection()
|
|
3330
|
+
getContentSection(),
|
|
3331
|
+
"",
|
|
3332
|
+
"---",
|
|
3333
|
+
"",
|
|
3334
|
+
getBlogSection(),
|
|
3335
|
+
"",
|
|
3336
|
+
"---",
|
|
3337
|
+
"",
|
|
3338
|
+
getStorefrontBotSection(cid)
|
|
3091
3339
|
].join("\n");
|
|
3092
3340
|
default:
|
|
3093
|
-
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`;
|
|
3341
|
+
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, blog, all`;
|
|
3094
3342
|
}
|
|
3095
3343
|
}
|
|
3096
3344
|
|
|
@@ -3119,6 +3367,7 @@ var GET_SDK_DOCS_SCHEMA = {
|
|
|
3119
3367
|
"admin",
|
|
3120
3368
|
"inquiries",
|
|
3121
3369
|
"content",
|
|
3370
|
+
"storefront-bot",
|
|
3122
3371
|
"all"
|
|
3123
3372
|
]).describe("The SDK documentation topic to retrieve"),
|
|
3124
3373
|
salesChannelId: import_zod.z.string().optional().describe("Sales channel ID (starts with vc_). Used to personalize setup code."),
|
|
@@ -3156,6 +3405,12 @@ interface Product {
|
|
|
3156
3405
|
priceMin?: string | null; // Lowest variant price (VARIABLE products) \u2014 same as basePrice for VARIABLE, kept for back-compat and JSON-LD range display.
|
|
3157
3406
|
priceMax?: string | null; // Highest variant price (VARIABLE products). Use with priceMin for "\u20AA49 \u2013 \u20AA199" range.
|
|
3158
3407
|
priceVaries?: boolean; // true when variant prices differ \u2014 show "\u20AA49 \u2013 \u20AA199" range.
|
|
3408
|
+
// FX DISPLAY overlay (PRD \xA723). Set only when getProducts({ regionId }) was called AND region.currency !== store.currency. basePrice/salePrice above stay in store currency \u2014 these are additive, display-only. The buyer is still charged in store currency at checkout; payment provider handles customer-side FX.
|
|
3409
|
+
displayPrice?: string; // basePrice \xD7 daily FX rate, in displayCurrency.
|
|
3410
|
+
displaySalePrice?: string; // salePrice \xD7 rate (if salePrice present).
|
|
3411
|
+
displayPriceMin?: string; // priceMin \xD7 rate (VARIABLE products).
|
|
3412
|
+
displayPriceMax?: string; // priceMax \xD7 rate (VARIABLE products).
|
|
3413
|
+
displayCurrency?: string; // ISO 4217 of the region \u2014 e.g. "EUR".
|
|
3159
3414
|
status: string;
|
|
3160
3415
|
type: 'SIMPLE' | 'VARIABLE';
|
|
3161
3416
|
isDownloadable?: boolean;
|
|
@@ -3199,6 +3454,10 @@ interface ProductVariant {
|
|
|
3199
3454
|
name?: string | null;
|
|
3200
3455
|
price?: string | null;
|
|
3201
3456
|
salePrice?: string | null;
|
|
3457
|
+
// FX DISPLAY overlay (PRD \xA723) \u2014 same semantics as on the parent Product.
|
|
3458
|
+
displayPrice?: string;
|
|
3459
|
+
displaySalePrice?: string;
|
|
3460
|
+
displayCurrency?: string;
|
|
3202
3461
|
attributes?: Record<string, string> | null;
|
|
3203
3462
|
options?: Array<{ name: string; value: string }>;
|
|
3204
3463
|
inventory?: InventoryInfo | null;
|
|
@@ -4328,6 +4587,15 @@ interface PublicRegionDetail extends PublicRegion {
|
|
|
4328
4587
|
}
|
|
4329
4588
|
// getStoreRegions(): { data: PublicRegion[] } \u2014 active regions, default first.
|
|
4330
4589
|
// getStoreRegion(regionId): PublicRegionDetail \u2014 one region + its providers.
|
|
4590
|
+
interface AutoRegionResponse {
|
|
4591
|
+
region: PublicRegion | null;
|
|
4592
|
+
matched: boolean; // true=country was in a region's list; false=fell back to default
|
|
4593
|
+
country: string; // upper-cased ISO-3166-1 alpha-2; '' when caller omitted it
|
|
4594
|
+
}
|
|
4595
|
+
// getAutoRegion(country): AutoRegionResponse \u2014 server-side resolution in one
|
|
4596
|
+
// round trip. Pair with the country your edge runtime extracts
|
|
4597
|
+
// (CF-IPCountry / request.geo.country / etc.) \u2014 Brainerce does NOT derive the
|
|
4598
|
+
// country from the request IP server-side (storefront != end-customer).
|
|
4331
4599
|
|
|
4332
4600
|
// ---- Tax Classes ---- (scopes: tax-classes:read / tax-classes:write)
|
|
4333
4601
|
// Charge differential rates by product type. A TaxRate may target a class via
|
|
@@ -4359,7 +4627,25 @@ interface AssignTaxClassDto { productIds?: string[]; variantIds?: string[]; cate
|
|
|
4359
4627
|
// getRegionCompatibleProviders(id), detectRegion(country, regions)
|
|
4360
4628
|
// Tax classes: getTaxClasses(), getTaxClass(id), createTaxClass(dto), updateTaxClass(id, dto),
|
|
4361
4629
|
// deleteTaxClass(id), setDefaultTaxClass(id), assignTaxClass(id, dto),
|
|
4362
|
-
// mergeTaxClasses(id, targetId)
|
|
4630
|
+
// mergeTaxClasses(id, targetId)
|
|
4631
|
+
//
|
|
4632
|
+
// SDK methods (storefront, public \u2014 storeId mode, no apiKey):
|
|
4633
|
+
// getStoreRegions(), getStoreRegion(id), getAutoRegion(country)
|
|
4634
|
+
// getStoreTaxClasses(), estimateTax({ country?, subtotal })
|
|
4635
|
+
//
|
|
4636
|
+
// estimateTax returns:
|
|
4637
|
+
interface TaxEstimateResponse {
|
|
4638
|
+
appliesTax: boolean;
|
|
4639
|
+
rate: number | null; // percent (18 = 18%) \u2014 null when no matching rule
|
|
4640
|
+
rateName: string | null;
|
|
4641
|
+
estimatedTax: number; // tax portion of subtotal in store currency
|
|
4642
|
+
pricesIncludeTax: boolean;
|
|
4643
|
+
currency: string; // store currency (cart/order currency)
|
|
4644
|
+
note: string; // disclaimer \u2014 preview is non-binding
|
|
4645
|
+
}
|
|
4646
|
+
// Non-binding by design: the authoritative tax runs at checkout against the
|
|
4647
|
+
// full shipping address. The country comes from your edge runtime
|
|
4648
|
+
// (CF-IPCountry / request.geo.country / etc.), NOT the request IP.`;
|
|
4363
4649
|
var TYPES_BY_DOMAIN = {
|
|
4364
4650
|
products: PRODUCTS_TYPES,
|
|
4365
4651
|
cart: CART_TYPES,
|