@asstio-dev/storefront 0.51.1 → 0.52.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/account/index.js +2 -0
- package/dist/client-header.d.ts +3 -0
- package/dist/client-header.js +6 -0
- package/dist/index.js +2 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +2 -0
- package/package.json +5 -3
package/dist/account/index.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import createClient from "openapi-fetch";
|
|
9
9
|
import { commerceHeaders } from "../context.js";
|
|
10
|
+
import { CLIENT_HEADER, clientHeaderValue } from "../client-header.js";
|
|
10
11
|
/**
|
|
11
12
|
* A request-scoped client: every call carries the server key, the commerce context, the shopper IP and (when given) the session, and
|
|
12
13
|
* every fetch is `cache: "no-store"` — an account answer is never shared or cached (spec §10.1).
|
|
@@ -24,6 +25,7 @@ export function createShopperClient(opts) {
|
|
|
24
25
|
const headers = {
|
|
25
26
|
onRequest({ request }) {
|
|
26
27
|
request.headers.set("X-Site-Key", opts.serverKey);
|
|
28
|
+
request.headers.set(CLIENT_HEADER, clientHeaderValue());
|
|
27
29
|
for (const [name, value] of context)
|
|
28
30
|
request.headers.set(name, value);
|
|
29
31
|
if (opts.shopperIp)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SDK_VERSION } from "./version.js";
|
|
2
|
+
/** Request header naming the SDK build that made the call; the API's access log recognizes the value. */
|
|
3
|
+
export const CLIENT_HEADER = "X-Storefront-Client";
|
|
4
|
+
export function clientHeaderValue() {
|
|
5
|
+
return "@asstio-dev/storefront/" + SDK_VERSION;
|
|
6
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import createClient from "openapi-fetch";
|
|
2
2
|
import { commerceHeaders } from "./context.js";
|
|
3
3
|
import { encodeFilterValues } from "./filters.js";
|
|
4
|
+
import { CLIENT_HEADER, clientHeaderValue } from "./client-header.js";
|
|
4
5
|
/** Thin typed client: every call carries X-Site-Key and the context (X-Market / X-Country / X-Locale) fixed here: one client per context.
|
|
5
6
|
* Works in browsers and on the server. */
|
|
6
7
|
export function createStorefrontClient(opts) {
|
|
@@ -9,6 +10,7 @@ export function createStorefrontClient(opts) {
|
|
|
9
10
|
const headers = {
|
|
10
11
|
onRequest({ request }) {
|
|
11
12
|
request.headers.set("X-Site-Key", opts.siteKey);
|
|
13
|
+
request.headers.set(CLIENT_HEADER, clientHeaderValue());
|
|
12
14
|
for (const [name, value] of context)
|
|
13
15
|
request.headers.set(name, value);
|
|
14
16
|
return request;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SDK_VERSION = "0.52.0";
|
package/dist/version.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asstio-dev/storefront",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.0",
|
|
4
4
|
"description": "Typed client for the Asstio Storefront API (generated from OpenAPI).",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -46,12 +46,14 @@
|
|
|
46
46
|
"src/schema.d.ts"
|
|
47
47
|
],
|
|
48
48
|
"scripts": {
|
|
49
|
+
"version-file": "node scripts/version-file.mjs",
|
|
49
50
|
"generate": "openapi-typescript ../../tests/Storefront.Api.Tests/Snapshots/openapi-v1.json -o src/schema.d.ts",
|
|
50
51
|
"typecheck-examples": "tsc -p tsconfig.examples.json",
|
|
51
|
-
"build": "npm run generate && tsc -p tsconfig.json && node -e \"require('node:fs').copyFileSync('src/schema.d.ts','dist/schema.d.ts')\" && npm run typecheck-examples && npm run smoke",
|
|
52
|
+
"build": "npm run version-file && npm run generate && tsc -p tsconfig.json && node -e \"require('node:fs').copyFileSync('src/schema.d.ts','dist/schema.d.ts')\" && npm run typecheck-examples && npm run smoke",
|
|
53
|
+
"pretest": "npm run version-file",
|
|
52
54
|
"test": "vitest run",
|
|
53
55
|
"test:browser": "playwright test -c browser/playwright.config.ts",
|
|
54
|
-
"check": "npm run generate && npm run typecheck-examples && npm test && git diff --exit-code -- src/schema.d.ts && test -z \"$(git status --porcelain -- src/schema.d.ts)\"",
|
|
56
|
+
"check": "npm run version-file && npm run generate && npm run typecheck-examples && npm test && git diff --exit-code -- src/schema.d.ts && test -z \"$(git status --porcelain -- src/schema.d.ts)\"",
|
|
55
57
|
"smoke": "node --input-type=module -e \"import(\\\"./dist/index.js\\\").then(m => { for (const f of [\\\"createStorefrontClient\\\", \\\"filterQuery\\\", \\\"encodeFilterValues\\\", \\\"decodeFilterValues\\\", \\\"pictureSources\\\", \\\"mediaUrl\\\", \\\"formatImage\\\", \\\"styleToCss\\\", \\\"startCheckout\\\", \\\"syncCheckout\\\", \\\"completeCheckout\\\", \\\"getCheckoutStatus\\\", \\\"liveShippingFor\\\", \\\"getOrder\\\", \\\"awaitCompletion\\\", \\\"mountCheckout\\\", \\\"productJsonLd\\\", \\\"gtinJsonLd\\\", \\\"breadcrumbJsonLd\\\", \\\"productHead\\\", \\\"collectionHead\\\", \\\"brandHead\\\", \\\"toNextMetadata\\\", \\\"sitemapEntries\\\", \\\"toNextSitemap\\\", \\\"jsonLdScript\\\", \\\"SeoError\\\", \\\"productFacts\\\", \\\"toGa4Item\\\", \\\"toGa4Ecommerce\\\", \\\"longestCategory\\\", \\\"AnalyticsError\\\", \\\"trackSearchEvents\\\", \\\"variantUrl\\\", \\\"readVariantParam\\\", \\\"variantQueryForApi\\\", \\\"redirectTarget\\\", \\\"displayPrice\\\", \\\"isPriceVisible\\\", \\\"isBuyable\\\", \\\"requireBinding\\\", \\\"hreflangFor\\\", \\\"isCheckoutContextMismatch\\\", \\\"consentNotice\\\"]) if (typeof m[f] !== \\\"function\\\") throw new Error(\\\"missing export \\\" + f) })\" && npm run smoke:account && npm run smoke:consent && npm run smoke:shopper",
|
|
56
58
|
"smoke:consent": "node --input-type=module -e \"const checks = { \\\"./dist/consent/index.js\\\": [\\\"parseConsent\\\", \\\"parseRefusal\\\", \\\"serializeConsent\\\", \\\"serializeRefusal\\\", \\\"ConsentCookieTooLarge\\\", \\\"withEntry\\\", \\\"withoutEntries\\\", \\\"withoutOwner\\\", \\\"grantedFor\\\", \\\"fold\\\", \\\"refusalBlocks\\\", \\\"refusalMark\\\", \\\"isFallback\\\", \\\"consentCookieNames\\\", \\\"consentNotice\\\", \\\"createConsentCoordinator\\\"], \\\"./dist/consent/server.js\\\": [\\\"readConsentCookie\\\", \\\"consentOwner\\\", \\\"tokenOwner\\\", \\\"accountOwner\\\"] }; for (const [file, names] of Object.entries(checks)) { const m = await import(file); for (const f of names) if (typeof m[f] !== \\\"function\\\") throw new Error(\\\"missing export \\\" + f + \\\" in \\\" + file); } const c = await import(\\\"./dist/consent/index.js\\\"); for (const n of [\\\"MAX_UNSYNCED\\\", \\\"MAX_UNSYNCED_READ\\\", \\\"PENDING_TTL_MS\\\", \\\"PUT_TIMEOUT_MS\\\"]) if (typeof c[n] !== \\\"number\\\") throw new Error(\\\"missing constant \\\" + n);\"",
|
|
57
59
|
"smoke:shopper": "node --input-type=module -e \"import(\\\"./dist/shopper/index.js\\\").then(m => { if (typeof m.cancelWatchByToken !== \\\"function\\\") throw new Error(\\\"missing export cancelWatchByToken\\\") })\"",
|