@misiki/gocommerce-connector 0.1.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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/services/base.ts","../../src/services/static-store.ts","../../src/services/money.ts","../../src/services/mappers.ts","../../src/services/checkout-details.ts","../../src/services/address-book.ts","../../src/services/catalog.ts","../../src/services/cart.ts","../../src/services/checkout.ts","../../src/services/orders.ts","../../src/services/store.ts","../../src/services/unsupported.ts"],"names":["storage","products","meta","res","CART_ID_KEY","readStoredCartId","window"],"mappings":";AAgBO,IAAM,gBAAA,GAAmB;AAYzB,IAAM,eAAA,GAAN,cAA8B,KAAA,CAAM;AAAA,EAC1C,IAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EAEA,YAAY,OAAA,EAAiB,IAAA,GAAO,gBAAA,EAAkB,MAAA,GAAS,GAAG,OAAA,EAAmB;AACpF,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,iBAAA;AACZ,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAAA,EAChB;AACD;AAEO,IAAM,WAAA,GAAN,MAAM,YAAA,CAAY;AAAA,EAChB,MAAA;AAAA,EACR,OAAe,eAA4B,EAAC;AAAA,EAC5C,OAAe,aAAA;AAAA,EAEf,YAAY,OAAA,EAAwB;AAEnC,IAAA,IAAA,CAAK,SAAS,OAAA,KAAY,CAAA,GAAI,SAAmC,UAAA,CAAW,KAAA,CAAM,GAAG,IAAI,CAAA,CAAA;AAAA,EAC1F;AAAA,EAEA,SAAS,OAAA,EAA6B;AACrC,IAAA,IAAA,CAAK,MAAA,GAAS,OAAA;AACd,IAAA,OAAO,IAAA;AAAA,EACR;AAAA,EAEA,QAAA,GAAyB;AACxB,IAAA,OAAO,IA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EAC1D,OAAO,WAAA,GAAc,SAAA,CAAU,0BAAyB,CAAA;AAAA,EAExD,MAAM,wBAAwB,KAAA,EAAgB;AAC7C,IAAA,OAAO,EAAE,IAAA,EAAM,EAAC,EAAG,KAAA,EAAO,CAAA,EAAG,QAAA,EAAU,SAAA,EAAW,QAAA,EAAU,CAAA,EAAG,IAAA,EAAM,CAAA,EAAE;AAAA,EACxE;AAAA,EAEA,MAAM,sBAAsB,UAAA,EAAoC;AAC/D,IAAA,MAAM,YAAY,qBAAqB,CAAA;AAAA,EACxC;AAAA,EAEA,MAAM,4BAAA,CAA6B,OAAA,EAAiB,OAAA,EAAiB,QAAA,EAAkC;AACtG,IAAA,MAAM,YAAY,qBAAqB,CAAA;AAAA,EACxC;AACD;AAEO,IAAM,yBAAA,GAA4B,0BAA0B,WAAA","file":"index.js","sourcesContent":["// The transport every GoCommerce service shares.\n//\n// Two request paths live here and the difference matters. `api()` builds an ABSOLUTE url against\n// PUBLIC_GOCOMMERCE_API_URL and is what the services actually call. `get/post/put/patch/delete`\n// keep the raw-url signature the storefront's Litekart-era call sites use\n// (`storeService.get('/api/stores/public-details')`) and are left relative on purpose: rest-guard.ts\n// wraps exactly those and answers them from local data. GoCommerce's own paths also start with\n// `/api/`, so routing service calls through `api()` is what keeps the guard from swallowing them.\n\nimport type { ListMeta } from './types'\n\n/**\n * The storefront route that forwards to the GoCommerce server, and the only path the browser is\n * ever pointed at. It must not start with `/api/`: rest-guard.ts intercepts that prefix as a\n * Litekart REST path and would answer these calls itself.\n */\nexport const API_PROXY_PREFIX = '/proxy/gocommerce'\n\nexport type Credentials = {\n\t/** Base url of the GoCommerce server, e.g. `http://127.0.0.1:8080`. */\n\tapiUrl?: string\n\t[key: string]: string | undefined\n}\n\n/** `{ data, meta }` — the envelope every GoCommerce endpoint answers with. */\nexport type Envelope<T> = { data: T; meta?: ListMeta }\n\n/** What the storefront shows when a request fails: GoCommerce's own message, not a status code. */\nexport class GoCommerceError extends Error {\n\tcode: string\n\tdetails: unknown\n\tstatus: number\n\n\tconstructor(message: string, code = 'internal_error', status = 0, details?: unknown) {\n\t\tsuper(message)\n\t\tthis.name = 'GoCommerceError'\n\t\tthis.code = code\n\t\tthis.status = status\n\t\tthis.details = details\n\t}\n}\n\nexport class BaseService {\n\tprivate _fetch: typeof fetch\n\tprivate static _credentials: Credentials = {}\n\tprivate static _languageCode?: string\n\n\tconstructor(fetchFn?: typeof fetch) {\n\t\t// Bound to globalThis: an unbound `fetch` throws \"Illegal invocation\" in the browser.\n\t\tthis._fetch = fetchFn || ((...args: Parameters<typeof fetch>) => globalThis.fetch(...args))\n\t}\n\n\tsetFetch(fetchFn: typeof fetch): this {\n\t\tthis._fetch = fetchFn\n\t\treturn this\n\t}\n\n\tgetFetch(): typeof fetch {\n\t\treturn this._fetch\n\t}\n\n\t/**\n\t * The fetch a GoCommerce call actually goes out on.\n\t *\n\t * In the browser it is whatever was handed in, against this storefront's own origin. On the\n\t * server it is deliberately the platform's, not SvelteKit's: a universal `+page.ts` load is\n\t * given a `fetch` that simulates a browser's CORS check, and GoCommerce sends no\n\t * `Access-Control-Allow-Origin`, so the same product page that renders from a `+page.server.ts`\n\t * would throw from a `+page.ts`. Nothing is lost by stepping around it — SvelteKit's fetch adds\n\t * cookie forwarding and internal routing, and both are about this storefront's own origin, not\n\t * a separate API host.\n\t */\n\tprivate transport(): typeof fetch {\n\t\treturn BaseService.isBrowser() ? this._fetch : (...args: Parameters<typeof fetch>) => globalThis.fetch(...args)\n\t}\n\n\t/**\n\t * The hook the storefront's `src/lib/core/connectors/init.ts` calls with `PUBLIC_GOCOMMERCE_*`. Merges, so a\n\t * later call with a subset never erases the base url an earlier one established.\n\t */\n\tstatic setCredentials(creds: Credentials) {\n\t\tBaseService._credentials = { ...BaseService._credentials, ...creds }\n\t}\n\n\tstatic getCredentials(): Credentials {\n\t\treturn BaseService._credentials\n\t}\n\n\tstatic setBaseUrl(url?: string) {\n\t\tif (url) BaseService._credentials.apiUrl = url\n\t}\n\n\t/** Trailing slashes stripped so `${base}/api/products` never doubles up. */\n\tstatic getBaseUrl(): string {\n\t\treturn (BaseService._credentials.apiUrl || '').replace(/\\/+$/, '')\n\t}\n\n\tstatic setLanguageCode(code?: string) {\n\t\tBaseService._languageCode = code\n\t}\n\n\tstatic getLanguageCode(): string | undefined {\n\t\treturn BaseService._languageCode\n\t}\n\n\tsetBaseUrl(url?: string): this {\n\t\tBaseService.setBaseUrl(url)\n\t\treturn this\n\t}\n\n\tgetBaseUrl(): string {\n\t\treturn BaseService.getBaseUrl()\n\t}\n\n\t/**\n\t * Where a request for `path` actually goes.\n\t *\n\t * GoCommerce sends no CORS headers and answers a preflight with 405, so a browser cannot reach\n\t * it cross-origin at all — and neither can a universal `+page.ts` load, because SvelteKit\n\t * simulates the same CORS check server-side for consistency. So anything the browser issues goes\n\t * through this storefront's own origin (`src/routes/proxy/gocommerce/[...path]`), which is\n\t * same-origin and needs no headers from the API.\n\t *\n\t * On the server there is no such rule, and the extra hop through the storefront's own handler\n\t * would be a request the process makes to itself, so it calls the API directly.\n\t */\n\tstatic apiUrl(path: string): string {\n\t\tif (/^https?:\\/\\//i.test(path)) return path\n\t\tconst suffix = path.startsWith('/') ? path : `/${path}`\n\t\tif (BaseService.isBrowser()) return `${API_PROXY_PREFIX}${suffix}`\n\t\tconst base = BaseService.getBaseUrl()\n\t\tif (!base) {\n\t\t\tthrow new GoCommerceError('PUBLIC_GOCOMMERCE_API_URL is not configured — add it to .env (see docs/GOCOMMERCE.md).', 'not_ready')\n\t\t}\n\t\treturn `${base}${suffix}`\n\t}\n\n\t/**\n\t * Where an `<img>` points.\n\t *\n\t * Media urls come back site-relative for files this store holds (`/media/42.jpg`). Unlike an API\n\t * call, the consumer is always the browser — a server-rendered `<img src>` is still fetched by\n\t * it — so this always resolves through the proxy, and the picture loads wherever the API happens\n\t * to be reachable from. A url that is already absolute belongs to someone else's host and is\n\t * left exactly as it is.\n\t */\n\tstatic mediaUrl(path: string): string {\n\t\tif (/^https?:\\/\\//i.test(path)) return path\n\t\treturn `${API_PROXY_PREFIX}${path.startsWith('/') ? path : `/${path}`}`\n\t}\n\n\tstatic isBrowser(): boolean {\n\t\treturn typeof window !== 'undefined' && typeof window.document !== 'undefined'\n\t}\n\n\t/**\n\t * One request against the GoCommerce API.\n\t *\n\t * Unwraps `{ data, meta }` and turns `{ error: { code, message } }` into a thrown\n\t * GoCommerceError carrying the server's own wording — a 409 at checkout says which line went\n\t * stale, and that sentence is what the shopper needs to see.\n\t */\n\tprotected async api<T>(\n\t\tmethod: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',\n\t\tpath: string,\n\t\tbody?: unknown,\n\t\theaders: Record<string, string> = {}\n\t): Promise<Envelope<T>> {\n\t\tconst url = BaseService.apiUrl(path)\n\t\tconst lang = BaseService.getLanguageCode()\n\n\t\tlet res: Response\n\t\ttry {\n\t\t\tres = await this.transport()(url, {\n\t\t\t\tmethod,\n\t\t\t\theaders: {\n\t\t\t\t\tAccept: 'application/json',\n\t\t\t\t\t...(body === undefined ? {} : { 'Content-Type': 'application/json' }),\n\t\t\t\t\t...(lang ? { 'Accept-Language': lang } : {}),\n\t\t\t\t\t...headers\n\t\t\t\t},\n\t\t\t\t...(body === undefined ? {} : { body: JSON.stringify(body) })\n\t\t\t})\n\t\t} catch (cause) {\n\t\t\t// The server-side path talks to the API directly, so a stopped backend surfaces here as\n\t\t\t// Node's bare \"fetch failed\" with nothing naming what it tried to reach. Say it, the way\n\t\t\t// the proxy does for the browser's half.\n\t\t\tconst reason = (cause as { cause?: { code?: string } })?.cause?.code ?? (cause as Error)?.message ?? 'unknown error'\n\t\t\tthrow new GoCommerceError(\n\t\t\t\t`Could not reach the GoCommerce server at ${BaseService.getBaseUrl() || url} — ${reason}. Is it running?`,\n\t\t\t\t'not_ready',\n\t\t\t\t0,\n\t\t\t\tcause\n\t\t\t)\n\t\t}\n\n\t\t// 204 and friends carry no envelope; a DELETE that removed the last line is one.\n\t\tconst text = await res.text()\n\t\tlet parsed: unknown = undefined\n\t\tif (text) {\n\t\t\ttry {\n\t\t\t\tparsed = JSON.parse(text)\n\t\t\t} catch {\n\t\t\t\tthrow new GoCommerceError(`GoCommerce returned a non-JSON response for ${method} ${path} (${res.status}).`, 'internal_error', res.status)\n\t\t\t}\n\t\t}\n\n\t\tconst envelope = (parsed ?? {}) as {\n\t\t\tdata?: T\n\t\t\tmeta?: ListMeta\n\t\t\terror?: { code?: string; message?: string; details?: unknown }\n\t\t\t/** Not GoCommerce's shape — what something between here and it answered with. */\n\t\t\tmessage?: string\n\t\t}\n\n\t\tif (!res.ok || envelope.error) {\n\t\t\tconst error = envelope.error\n\t\t\t// A failure need not come from GoCommerce: the proxy in front of it answers with\n\t\t\t// SvelteKit's `{ message }` when the server cannot be reached at all. Preferring the\n\t\t\t// generic sentence over that message is how a stopped backend reads as an unexplained\n\t\t\t// 502 rather than \"could not reach the GoCommerce server at …\".\n\t\t\tthrow new GoCommerceError(\n\t\t\t\terror?.message || envelope.message || `GoCommerce request failed: ${method} ${path} (${res.status}).`,\n\t\t\t\terror?.code || 'internal_error',\n\t\t\t\tres.status,\n\t\t\t\terror?.details\n\t\t\t)\n\t\t}\n\n\t\treturn { data: envelope.data as T, meta: envelope.meta }\n\t}\n\n\t/**\n\t * Litekart-era raw-url reads. Deliberately not routed to GoCommerce: a bare `/api/...` here means\n\t * a path from the storefront's own REST API, which rest-guard.ts answers from local data or\n\t * reports. Absolute urls pass straight through.\n\t */\n\tasync get<T>(url: string): Promise<T> {\n\t\tconst res = await this._fetch(url, { headers: { Accept: 'application/json' } })\n\t\treturn (await res.json()) as T\n\t}\n\n\tasync post<T>(url: string, data: unknown): Promise<T> {\n\t\tconst res = await this._fetch(url, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: { 'Content-Type': 'application/json', Accept: 'application/json' },\n\t\t\tbody: JSON.stringify(data)\n\t\t})\n\t\treturn (await res.json()) as T\n\t}\n\n\tasync put<T>(url: string, data: unknown): Promise<T> {\n\t\tconst res = await this._fetch(url, {\n\t\t\tmethod: 'PUT',\n\t\t\theaders: { 'Content-Type': 'application/json', Accept: 'application/json' },\n\t\t\tbody: JSON.stringify(data)\n\t\t})\n\t\treturn (await res.json()) as T\n\t}\n\n\tasync patch<T>(url: string, data: unknown): Promise<T> {\n\t\tconst res = await this._fetch(url, {\n\t\t\tmethod: 'PATCH',\n\t\t\theaders: { 'Content-Type': 'application/json', Accept: 'application/json' },\n\t\t\tbody: JSON.stringify(data)\n\t\t})\n\t\treturn (await res.json()) as T\n\t}\n\n\tasync delete<T>(url: string): Promise<T> {\n\t\tconst res = await this._fetch(url, { method: 'DELETE', headers: { Accept: 'application/json' } })\n\t\treturn (await res.json()) as T\n\t}\n}\n","// Store identity — name, logo, favicon, currency, menus, plugin toggles, theme variables — has no\n// GoCommerce equivalent: the API is a commerce engine, not a CMS. The storefront registers its own\n// provider at module load (the storefront's connectors/gocommerce.ts module) and every service that needs the store record\n// reads it from here.\n\nexport type StaticStoreProvider = () => Promise<Record<string, unknown>> | Record<string, unknown>\n\nlet provider: StaticStoreProvider | undefined\n\nexport const setStaticStore = (fn: StaticStoreProvider) => {\n\tprovider = fn\n}\n\nexport const hasStaticStore = () => Boolean(provider)\n\n/**\n * Features this backend cannot perform, whatever the store record says.\n *\n * The storefront shows or hides a feature from `plugins.*.active` — it is how the search icon and\n * the wishlist button already hide themselves. GoCommerce has no accounts, no discount engine, no\n * wishlist, no reviews and one vendor, so offering any of them produces a control whose only\n * possible answer is \"not available on this store\": the shopper types a promo code, or opens a\n * sign-in, and is refused. Not offering it is the better answer.\n *\n * `accounts` is the storefront's own toggle, read by src/lib/components/auth/auth-button.svelte — every\n * login, signup and password-reset entry point renders through that component.\n */\nconst IMPOSSIBLE_FEATURES = {\n\taccounts: { active: false },\n\tisDiscountCoupons: { active: false },\n\tisWishlist: { active: false },\n\tisProductReviewsAndRatings: { active: false },\n\tisMultiVendor: { active: false }\n} as const\n\n/**\n * Applied on read rather than by wrapping the registered provider, because the provider is not ours\n * to keep: the storefront's `src/lib/core/connectors/init.ts` calls `setStaticStore(staticStoreConfig)` for whatever\n * connector is active, at boot, which lands after this module has loaded and replaces anything\n * registered here. Forcing at the point of use is immune to who registered last.\n */\nexport const readStaticStore = async (): Promise<Record<string, any> | undefined> => {\n\tif (!provider) return undefined\n\tconst store = (await provider()) as Record<string, any>\n\tif (!store) return store\n\treturn {\n\t\t...store,\n\t\tplugins: { ...(store.plugins ?? {}), ...IMPOSSIBLE_FEATURES }\n\t}\n}\n\nexport const readStaticStoreDetails = readStaticStore\n","// GoCommerce sends money as an integer count of the currency's minor unit plus its code, because\r\n// binary floating point cannot represent 0.10 and the number of decimals belongs to the currency\r\n// (USD has 2, JPY has 0, KWD has 3). The storefront's components take a plain number in major\r\n// units, so the conversion happens once, here, against the currency the amount arrived with.\r\n\r\nimport type { Money } from './types'\r\n\r\nconst DEFAULT_FRACTION_DIGITS = 2\r\nconst fractionDigitsCache = new Map<string, number>()\r\n\r\nexport const currencyFractionDigits = (currencyCode?: string): number => {\r\n\tif (!currencyCode) return DEFAULT_FRACTION_DIGITS\r\n\tconst code = currencyCode.toUpperCase()\r\n\tconst cached = fractionDigitsCache.get(code)\r\n\tif (cached !== undefined) return cached\r\n\r\n\tlet digits = DEFAULT_FRACTION_DIGITS\r\n\ttry {\r\n\t\tconst resolved = new Intl.NumberFormat('en', { style: 'currency', currency: code }).resolvedOptions().maximumFractionDigits\r\n\t\tif (typeof resolved === 'number') digits = resolved\r\n\t} catch {\r\n\t\t// An unknown code keeps the two-decimal default rather than failing the render.\r\n\t}\r\n\tfractionDigitsCache.set(code, digits)\r\n\treturn digits\r\n}\r\n\r\n/** `{ amount_minor: 2500, currency: 'USD' }` -> `25`. */\r\nexport const fromMoney = (money?: Money | null): number => {\r\n\tif (!money || typeof money.amount_minor !== 'number' || !Number.isFinite(money.amount_minor)) return 0\r\n\tconst digits = currencyFractionDigits(money.currency)\r\n\treturn digits === 0 ? money.amount_minor : money.amount_minor / 10 ** digits\r\n}\r\n","// GoCommerce's wire shapes translated into the ones this storefront's components read. The target\n// shape is Litekart's — every @misiki/*-connector maps onto it, which is what lets the same\n// components render on any backend. Fields GoCommerce has no notion of are filled with the neutral\n// value the component expects rather than left undefined, because `undefined` is what makes a card\n// render a blank price or a broken image.\n\nimport { BaseService } from './base'\nimport { currencyFractionDigits, fromMoney } from './money'\nimport type { GcAddress, GcCart, GcCartLine, GcCategory, GcCollection, GcOrder, GcProduct, GcVariant, ListMeta } from './types'\n\n/** The page size this storefront's grids and lists are built around. */\nexport const PAGE_SIZE = 20\n\n/** The API's maximum `limit`. Also the ceiling on what one request can be filtered or sorted over. */\nexport const MAX_LIMIT = 200\n\n/** A variant that does not track inventory is always buyable; the number just has to be positive. */\nconst UNTRACKED_STOCK = 999\n\nexport type Paginated<T> = {\n\tdata: T[]\n\tcount: number\n\tpageSize: number\n\tnoOfPage: number\n\tpage: number\n}\n\nexport const paginated = <T>(data: T[], count: number, page = 1, pageSize = PAGE_SIZE): Paginated<T> => ({\n\tdata,\n\tcount,\n\tpageSize,\n\tnoOfPage: Math.ceil(count / pageSize) || (count ? 1 : 0),\n\tpage\n})\n\nexport const emptyPage = <T>(page = 1, pageSize = PAGE_SIZE): Paginated<T> => ({\n\tdata: [],\n\tcount: 0,\n\tpageSize,\n\tnoOfPage: 0,\n\tpage\n})\n\n/** Meta the API returns for a window, translated into the page numbers the storefront prints. */\nexport const fromListMeta = <T>(data: T[], meta?: ListMeta, fallbackPage = 1): Paginated<T> => {\n\tconst count = meta?.total ?? data.length\n\tconst pageSize = meta?.limit || data.length || PAGE_SIZE\n\treturn {\n\t\tdata,\n\t\tcount,\n\t\tpageSize,\n\t\tnoOfPage: meta?.total_pages ?? (Math.ceil(count / pageSize) || (count ? 1 : 0)),\n\t\tpage: meta?.page ?? fallbackPage\n\t}\n}\n\n/** Media urls arrive site-relative for files the store holds; see `BaseService.mediaUrl`. */\nexport const absoluteMedia = (url?: string | null): string | null => (url ? BaseService.mediaUrl(url) : null)\n\nconst activeVariants = (product?: GcProduct | null): GcVariant[] => (product?.variants || []).filter((v) => v?.active !== false)\n\n/** The variant a card prices and a PDP opens on: the first active one, in the operator's order. */\nconst primaryVariant = (product?: GcProduct | null): GcVariant | undefined => activeVariants(product)[0] || (product?.variants || [])[0]\n\nconst variantStock = (variant?: GcVariant | null): number => {\n\tif (!variant) return 0\n\tif (variant.track_inventory === false) return UNTRACKED_STOCK\n\tconst available = Math.max(0, variant.available ?? 0)\n\t// `continue_selling` takes the order after the count runs out, so the item is still buyable.\n\treturn available === 0 && variant.continue_selling ? UNTRACKED_STOCK : available\n}\n\n/**\n * Every image the storefront can show for a product.\n *\n * Two sources, in the order a gallery should show them: the product's own `image_url` first, then\n * whatever image each variant nominates — what a storefront swaps to when a shopper picks a colour.\n * De-duplicated, because a variant may nominate the picture the product already leads with.\n *\n * Both are read defensively. `image_url` is undocumented in `/doc` yet is the only image this\n * catalogue actually has, while `Variant.image` is the documented field and is empty here; a server\n * on either side of that change has to render. A product with neither has no image, and the\n * components fall back to their own placeholder.\n */\nexport const productImages = (product?: GcProduct | null): string[] => {\n\tconst seen = new Set<string>()\n\tconst featured = absoluteMedia(product?.image_url)\n\tif (featured) seen.add(featured)\n\tfor (const variant of product?.variants || []) {\n\t\tconst url = absoluteMedia(variant?.image?.url)\n\t\tif (url) seen.add(url)\n\t}\n\treturn [...seen]\n}\n\n/**\n * Product metadata, flattened for display.\n *\n * GoCommerce namespaces it by whichever module wrote it — `{ category: { material: ['Cork'] } }` —\n * while the storefront's spec block prints each entry's value straight into the page, so a nested\n * object arrives as the literal text \"[object Object]\". Only the leaves say anything to a shopper,\n * so those are lifted out under their own names, and a name claimed twice keeps its namespace to\n * stay distinguishable.\n */\nexport const flattenMetadata = (metadata?: Record<string, unknown> | null): Record<string, string> | null => {\n\tif (!metadata || typeof metadata !== 'object') return null\n\tconst out: Record<string, string> = {}\n\n\tconst printable = (value: unknown): string | undefined => {\n\t\tif (value === null || value === undefined || value === '') return undefined\n\t\tif (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') return String(value)\n\t\tif (Array.isArray(value)) {\n\t\t\tconst items = value.map(printable).filter(Boolean)\n\t\t\treturn items.length ? items.join(', ') : undefined\n\t\t}\n\t\treturn undefined\n\t}\n\n\tconst walk = (node: Record<string, unknown>, namespace = '') => {\n\t\tfor (const [key, value] of Object.entries(node)) {\n\t\t\tconst text = printable(value)\n\t\t\tif (text !== undefined) {\n\t\t\t\tout[key in out && namespace ? `${namespace} ${key}` : key] = text\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (value && typeof value === 'object' && !Array.isArray(value)) walk(value as Record<string, unknown>, key)\n\t\t}\n\t}\n\n\twalk(metadata)\n\treturn Object.keys(out).length ? out : null\n}\n\nconst optionValueId = (product: GcProduct | undefined, optionIndex: number, value: string) =>\n\tproduct?.options?.[optionIndex]?.values?.find((v) => v.value === value)?.id ?? `${optionIndex}-${value}`\n\nconst mapVariant = (product: GcProduct, variant: GcVariant) => {\n\tconst price = fromMoney(variant.price)\n\tconst compareAt = fromMoney(variant.compare_at_price)\n\t// A variant that nominates no image of its own is shown under the product's picture rather than\n\t// none — which is every variant on a catalogue that only sets `image_url`.\n\tconst image = absoluteMedia(variant.image?.url) || absoluteMedia(product.image_url)\n\treturn {\n\t\tid: variant.id,\n\t\t// The PDP prints this as the heading whenever it is not 'default'. GoCommerce labels a variant\n\t\t// by its options (\"M / Black\") and leaves that empty for a product that has none — where the\n\t\t// product's own title is the right heading, and the SKU would be a code shown to a shopper.\n\t\ttitle: variant.label || (variant.options || []).join(' / ') || product.title || 'default',\n\t\tproductId: product.id,\n\t\tsku: variant.sku || null,\n\t\tbarcode: variant.barcode || null,\n\t\tbatchNo: null,\n\t\tstock: variantStock(variant),\n\t\tallowBackorder: Boolean(variant.continue_selling),\n\t\tmanageInventory: variant.track_inventory !== false,\n\t\thsCode: variant.hs_code || null,\n\t\toriginCountry: variant.origin_country || null,\n\t\tmidCode: null,\n\t\tmaterial: null,\n\t\tweight: variant.weight ?? null,\n\t\tlength: null,\n\t\theight: null,\n\t\twidth: null,\n\t\tprice,\n\t\tcostPerItem: 0,\n\t\tmfgDate: null,\n\t\texpiryDate: null,\n\t\treturnAllowed: false,\n\t\treplaceAllowed: false,\n\t\t// No compare-at price recorded means nothing is on sale; mrp equals price so the components\n\t\t// print one number instead of a struck-through duplicate.\n\t\tmrp: compareAt > price ? compareAt : price,\n\t\timg: image,\n\t\tdescription: null,\n\t\tstoreId: null,\n\t\tlen: null,\n\t\trank: variant.position ?? 0,\n\t\tshippingWeight: null,\n\t\tshippingHeight: null,\n\t\tshippingLen: null,\n\t\tshippingWidth: null,\n\t\tshippingCost: null,\n\t\tmetadata: variant.metadata ?? null,\n\t\tvariantRank: variant.position ?? 0,\n\t\t// A variant's `options` are the VALUES, positionally aligned with the product's option list.\n\t\toptions: (variant.options || []).map((value, index) => ({\n\t\t\tid: optionValueId(product, index, value),\n\t\t\toptionId: product.options?.[index]?.id ?? index,\n\t\t\tvalue,\n\t\t\tvariantId: variant.id\n\t\t}))\n\t}\n}\n\nexport const mapProduct = (product?: GcProduct | null) => {\n\tif (!product) return null\n\n\tconst variants = activeVariants(product)\n\tconst priced = variants.length ? variants : product.variants || []\n\tconst prices = priced.map((v) => fromMoney(v.price)).filter((n) => Number.isFinite(n))\n\tconst price = prices.length ? Math.min(...prices) : 0\n\tconst compareAtPrices = priced.map((v) => fromMoney(v.compare_at_price)).filter((n) => n > 0)\n\tconst mrp = compareAtPrices.length ? Math.max(...compareAtPrices) : price\n\n\tconst images = productImages(product)\n\tconst featured = images[0] || null\n\tconst first = primaryVariant(product)\n\n\treturn {\n\t\tid: product.id,\n\t\ttitle: product.title,\n\t\tslug: product.slug,\n\t\tdescription: product.description || '',\n\t\tprice,\n\t\tmrp,\n\t\tfeaturedImage: featured,\n\t\tactive: product.status === 'active',\n\t\tstatus: product.status === 'active' ? 'published' : product.status || 'draft',\n\t\ttype: 'physical',\n\t\tvendorId: product.vendor || '',\n\t\tcategoryId: product.category?.id ?? null,\n\t\tcurrency: product.currency || null,\n\t\tinstructions: null,\n\t\thsnCode: first?.hs_code || null,\n\t\t// The components read this as a comma-joined list, the way Litekart serves it.\n\t\timages: images.join(','),\n\t\tthumbnail: featured,\n\t\tkeywords: (product.tags || []).join(',') || null,\n\t\tlink: null,\n\t\tmetaTitle: product.seo_title || null,\n\t\tmetaDescription: product.seo_description || null,\n\t\tsubtitle: product.product_type || null,\n\t\tpopularity: 0,\n\t\trank: 0,\n\t\texpiryDate: null,\n\t\tweight: first?.weight ?? null,\n\t\tmfgDate: null,\n\t\tcostPerItem: 0,\n\t\tsku: first?.sku || null,\n\t\tstock: priced.reduce((sum, v) => sum + variantStock(v), 0),\n\t\tallowBackorder: Boolean(first?.continue_selling),\n\t\tmanageInventory: first?.track_inventory !== false,\n\t\tshippingWeight: null,\n\t\tshippingHeight: null,\n\t\tshippingLen: null,\n\t\tshippingWidth: null,\n\t\theight: null,\n\t\twidth: null,\n\t\tlen: null,\n\t\tbarcode: first?.barcode || null,\n\t\tshippingCost: null,\n\t\treturnAllowed: false,\n\t\treplaceAllowed: false,\n\t\toriginCountry: first?.origin_country || null,\n\t\tweightUnit: first?.weight_unit || 'g',\n\t\tdimensionUnit: 'cm',\n\t\tmetadata: flattenMetadata(product.metadata),\n\t\tcollectionId: product.collections?.[0]?.id ?? null,\n\t\ttags: product.tags || [],\n\t\tvendor: product.vendor || null,\n\t\tcategories: product.category ? [{ category: { id: product.category.id, name: product.category.title, slug: product.category.slug } }] : [],\n\t\tcreatedAt: product.created_at || null,\n\t\tupdatedAt: product.updated_at || null,\n\t\toptions: (product.options || []).map((option) => ({\n\t\t\tid: option.id,\n\t\t\ttitle: option.name,\n\t\t\ttype: 'radio',\n\t\t\tvalues: (option.values || []).map((v) => ({ id: v.id, value: v.value }))\n\t\t})),\n\t\tvariants: priced.map((variant) => mapVariant(product, variant))\n\t}\n}\n\nexport const mapCategory = (category?: GcCategory | null) => {\n\tif (!category) return null\n\treturn {\n\t\tid: category.id,\n\t\tisActive: true,\n\t\tisInternal: false,\n\t\tisMegamenu: false,\n\t\tthumbnail: null,\n\t\tpath: category.full_name || null,\n\t\tlevel: category.depth ?? 0,\n\t\tdescription: null,\n\t\tisFeatured: false,\n\t\tkeywords: null,\n\t\trank: category.position ?? 0,\n\t\tlink: null,\n\t\tmetaDescription: null,\n\t\tmetaKeywords: null,\n\t\tmetaTitle: null,\n\t\tname: category.title,\n\t\t// The storefront's filter composable rebuilds the tree from this field.\n\t\tparentCategoryId: category.parent_id ?? null,\n\t\tstore: null,\n\t\tslug: category.slug,\n\t\tuserId: '',\n\t\tactiveProducts: 0,\n\t\tinactiveProducts: 0,\n\t\tcreatedAt: category.created_at || null,\n\t\tupdatedAt: category.updated_at || null\n\t}\n}\n\n/**\n * `collectionvalues[].products` is the shape the collection components read — Litekart's, where each\n * value points at one product.\n */\nexport const mapCollection = (collection?: (GcCollection & { products?: GcProduct[] }) | null) => {\n\tif (!collection) return null\n\tconst products = collection.products || []\n\treturn {\n\t\tid: collection.id,\n\t\tname: collection.title,\n\t\tslug: collection.slug,\n\t\tdescription: collection.description || null,\n\t\tisActive: true,\n\t\tisFeatured: false,\n\t\tuserId: '',\n\t\tthumbnail: productImages(products[0])[0] || null,\n\t\tmetaTitle: null,\n\t\tmetaDescription: null,\n\t\trank: collection.position ?? 0,\n\t\tcollectionvalues: products.map((product) => {\n\t\t\tconst mapped = mapProduct(product)\n\t\t\treturn {\n\t\t\t\tproducts: {\n\t\t\t\t\tid: product.id,\n\t\t\t\t\tname: product.title,\n\t\t\t\t\ttitle: product.title,\n\t\t\t\t\tslug: product.slug,\n\t\t\t\t\tthumbnail: mapped?.thumbnail || null,\n\t\t\t\t\tprice: mapped?.price ?? 0,\n\t\t\t\t\tmrp: mapped?.mrp ?? 0\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t\tproductCount: products.length,\n\t\tcreatedAt: collection.created_at || null,\n\t\tupdatedAt: collection.updated_at || null\n\t}\n}\n\n/** Whatever the storefront collected at the address step; GoCommerce has no cart field to hold it. */\nexport type CheckoutDetails = {\n\temail?: string\n\tphone?: string\n\tname?: string\n\tshippingAddress?: Record<string, any> | null\n\tbillingAddress?: Record<string, any> | null\n}\n\n/** A product lookup used to fill in what a cart or order line does not carry: slug and image. */\nexport type ProductIndex = Map<number, GcProduct>\n\nconst lineProduct = (index: ProductIndex | undefined, productId?: number | null) => (productId == null ? undefined : index?.get(productId))\n\nconst mapCartLine = (line: GcCartLine, index?: ProductIndex) => {\n\tconst product = lineProduct(index, line.product_id)\n\tconst mapped = product ? mapProduct(product) : null\n\tconst variant = product?.variants?.find((v) => v.id === line.variant_id)\n\tconst price = fromMoney(line.unit_price)\n\tconst compareAt = fromMoney(variant?.compare_at_price)\n\tconst thumbnail = absoluteMedia(variant?.image?.url) || mapped?.thumbnail || null\n\n\treturn {\n\t\tid: line.id,\n\t\tproductId: line.product_id,\n\t\tvariantId: line.variant_id,\n\t\tqty: line.quantity,\n\t\tsubtotal: fromMoney(line.total),\n\t\tdiscount: 0,\n\t\ttax: 0,\n\t\tshippingCharges: 0,\n\t\ttotal: fromMoney(line.total),\n\t\tprice,\n\t\tmrp: compareAt > price ? compareAt : price,\n\t\ttitle: line.title || mapped?.title || '',\n\t\tslug: mapped?.slug || '',\n\t\tsku: line.sku || '',\n\t\tdescription: null,\n\t\tthumbnail,\n\t\tmetadata: null,\n\t\tvendorId: null,\n\t\tweight: null,\n\t\tdimensionUnit: 'cm',\n\t\theight: null,\n\t\twidth: null,\n\t\tlen: null,\n\t\tshippingWeight: null,\n\t\tshippingHeight: null,\n\t\tshippingLen: null,\n\t\tshippingWidth: null,\n\t\tisSelectedForCheckout: true,\n\t\t// Surfaced so the cart can warn, instead of letting checkout refuse the whole order later.\n\t\tpriceChanged: Boolean(line.price_changed),\n\t\tinStock: line.in_stock !== false,\n\t\tcreatedAt: null,\n\t\tproduct: {\n\t\t\tid: line.product_id,\n\t\t\ttitle: line.title || mapped?.title || '',\n\t\t\tthumbnail,\n\t\t\tslug: mapped?.slug || '',\n\t\t\tsku: line.sku || '',\n\t\t\tcategories: mapped?.categories || []\n\t\t},\n\t\tvariant: {\n\t\t\tid: line.variant_id,\n\t\t\tprice,\n\t\t\tmrp: compareAt > price ? compareAt : price,\n\t\t\tweight: null,\n\t\t\theight: null,\n\t\t\twidth: null,\n\t\t\tlen: null,\n\t\t\tshippingWeight: null,\n\t\t\tshippingHeight: null,\n\t\t\tshippingLen: null,\n\t\t\tshippingWidth: null,\n\t\t\tsku: line.sku || '',\n\t\t\ttitle: line.variant_label || variant?.label || 'default',\n\t\t\toptions: variant && product ? mapVariant(product, variant).options : []\n\t\t}\n\t}\n}\n\nexport const mapCart = (cart: GcCart | null | undefined, details: CheckoutDetails = {}, index?: ProductIndex, store?: Record<string, any>) => {\n\tif (!cart) return {}\n\tconst currency = cart.currency || store?.currency?.code || 'USD'\n\tconst lines = cart.line_items || []\n\tconst subtotal = fromMoney(cart.subtotal)\n\tconst shippingAddress = details.shippingAddress || null\n\tconst billingAddress = details.billingAddress || shippingAddress\n\n\treturn {\n\t\tid: cart.id,\n\t\temail: cart.email || details.email || null,\n\t\tphone: details.phone || shippingAddress?.phone || null,\n\t\tname: details.name || null,\n\t\t// The payment step gates on an id as well as the address itself. There is no address record\n\t\t// in GoCommerce to have an id of its own, so the cart it belongs to names it.\n\t\tbillingAddressId: billingAddress ? `${cart.id}-billing` : null,\n\t\tshippingAddressId: shippingAddress ? `${cart.id}-shipping` : null,\n\t\tregionId: null,\n\t\tuserId: null,\n\t\tcouponCode: null,\n\t\tdiscountAmount: 0,\n\t\tcouponAppliedDate: null,\n\t\tneedAddress: !shippingAddress,\n\t\tisCodAvailable: true,\n\t\tpaymentId: null,\n\t\ttype: null,\n\t\tcompletedAt: cart.status === 'converted' ? cart.updated_at || null : null,\n\t\tpaymentAuthorizedAt: null,\n\t\tidempotencyKey: null,\n\t\tsalesChannelId: null,\n\t\tqty: cart.item_count ?? lines.reduce((sum, l) => sum + (l.quantity || 0), 0),\n\t\t// GoCommerce prices shipping at checkout, not on the cart, so there is nothing honest to put\n\t\t// here yet — and a fabricated number is the one the shopper would check the total against.\n\t\tshippingCharges: 0,\n\t\tpaymentMethod: null,\n\t\tshippingMethod: null,\n\t\tsubtotal,\n\t\tcodCharges: 0,\n\t\ttax: 0,\n\t\ttotal: subtotal,\n\t\tsavingAmount: 0,\n\t\tuserAuthToken: null,\n\t\tcurrencyCode: currency,\n\t\tcurrencySymbol: store?.currency?.symbol || '',\n\t\tshippingRateId: null,\n\t\tcurrencyDecimalDigits: currencyFractionDigits(currency),\n\t\tstoreId: store?.id ?? null,\n\t\tstatus: cart.status || 'open',\n\t\tcreatedAt: cart.created_at || null,\n\t\tupdatedAt: cart.updated_at || null,\n\t\tdeletedAt: null,\n\t\tlineItems: lines.map((line) => mapCartLine(line, index)),\n\t\tshippingAddress,\n\t\tbillingAddress\n\t}\n}\n\nconst splitName = (name?: string) => {\n\tconst parts = (name || '').trim().split(/\\s+/).filter(Boolean)\n\treturn { firstName: parts[0] || '', lastName: parts.slice(1).join(' ') }\n}\n\n/** GoCommerce's address shape -> the one the address form and order pages read. */\nexport const toStorefrontAddress = (address?: GcAddress | null, email?: string, phone?: string) => {\n\tif (!address) return null\n\tconst { firstName, lastName } = splitName(address.name)\n\treturn {\n\t\tid: null,\n\t\tfirstName,\n\t\tlastName,\n\t\temail: email || null,\n\t\tphone: address.phone || phone || '',\n\t\taddress_1: address.line1 || '',\n\t\taddress_2: address.line2 || '',\n\t\tcity: address.city || '',\n\t\tstate: address.state || '',\n\t\tzip: address.postal_code || '',\n\t\tcountry: address.country || '',\n\t\tcountryCode: address.country || '',\n\t\tisPrimary: false,\n\t\tisResidential: true,\n\t\tdeliveryInstructions: null\n\t}\n}\n\n/** The storefront's address form -> GoCommerce's `Address`, which checkout requires. */\nexport const toGoCommerceAddress = (address?: Record<string, any> | null, fallbackPhone?: string): GcAddress | null => {\n\tif (!address) return null\n\tconst name = [address.firstName, address.lastName].filter(Boolean).join(' ').trim() || address.name || ''\n\tconst line1 = address.address_1 || address.line1 || ''\n\tconst city = address.city || ''\n\tconst postal = address.zip || address.postal_code || ''\n\tconst country = address.countryCode || address.country_code || address.country || ''\n\tif (!line1 || !city || !postal || !country) return null\n\treturn {\n\t\tname,\n\t\tphone: address.phone || fallbackPhone || '',\n\t\tline1,\n\t\tline2: address.address_2 || address.line2 || '',\n\t\tcity,\n\t\tstate: address.state || '',\n\t\tpostal_code: postal,\n\t\t// GoCommerce wants ISO 3166-1 alpha-2; the form may hold a full country name alongside it.\n\t\tcountry: String(country).length === 2 ? String(country).toUpperCase() : String(country)\n\t}\n}\n\nexport const mapOrder = (order?: GcOrder | null, index?: ProductIndex) => {\n\tif (!order) return null\n\tconst shippingAddress = toStorefrontAddress(order.address, order.email, order.phone)\n\n\treturn {\n\t\tid: order.id,\n\t\torderNo: order.number,\n\t\torder_no: order.number,\n\t\t// The orders list links a detail page by parentOrderNo; the number is the handle here.\n\t\tparentOrderNo: order.number,\n\t\tstatus: order.status || 'pending',\n\t\tpaymentStatus: order.payment_status || 'pending',\n\t\tpaymentMethod: order.payment_provider || null,\n\t\tcreatedAt: order.created_at || null,\n\t\tupdatedAt: order.updated_at || null,\n\t\tuserEmail: order.email || '',\n\t\tphone: order.phone || '',\n\t\tsubtotal: fromMoney(order.subtotal),\n\t\tshippingCharges: fromMoney(order.shipping),\n\t\tdiscount: fromMoney(order.discount),\n\t\ttotal: fromMoney(order.total),\n\t\tcurrencyCode: order.currency,\n\t\tcurrencyDecimalDigits: currencyFractionDigits(order.currency),\n\t\tshippingRate: null,\n\t\tfulfillments: (order.fulfillments || []).map((f) => ({\n\t\t\tid: f.id,\n\t\t\tstatus: f.status || '',\n\t\t\tprovider: f.provider || '',\n\t\t\ttrackingNumber: f.tracking || '',\n\t\t\tlabelUrl: f.label_url || '',\n\t\t\tcreatedAt: f.created_at || null\n\t\t})),\n\t\tshippingAddress,\n\t\tbillingAddress: shippingAddress,\n\t\tlineItems: (order.line_items || []).map((line) => {\n\t\t\tconst product = lineProduct(index, line.product_id)\n\t\t\tconst mapped = product ? mapProduct(product) : null\n\t\t\tconst variant = product?.variants?.find((v) => v.id === line.variant_id)\n\t\t\treturn {\n\t\t\t\tid: line.id,\n\t\t\t\tproductId: line.product_id,\n\t\t\t\tvariantId: line.variant_id,\n\t\t\t\ttitle: line.title || mapped?.title || '',\n\t\t\t\tvariantTitle: line.variant_label || line.sku || '',\n\t\t\t\tslug: mapped?.slug || '',\n\t\t\t\tsku: line.sku || '',\n\t\t\t\tthumbnail: absoluteMedia(variant?.image?.url) || mapped?.thumbnail || null,\n\t\t\t\tqty: line.quantity,\n\t\t\t\tprice: fromMoney(line.unit_price),\n\t\t\t\t// The orders list prints `total`; the confirmation page prints `subtotal`.\n\t\t\t\tsubtotal: fromMoney(line.total),\n\t\t\t\ttotal: fromMoney(line.total)\n\t\t\t}\n\t\t})\n\t}\n}\n","// What the checkout needs but a GoCommerce cart cannot hold.\r\n//\r\n// A GoCommerce cart is a token, a currency, an email and its lines. There is no endpoint to change\r\n// it after it is opened and no address on it at all: the shopper's name, phone and delivery address\r\n// are arguments to `POST /api/checkout/{code}`, and they exist nowhere before that call. The\r\n// storefront collects them a step earlier, so they are held here — in this browser, against this\r\n// cart id — and handed over when the order is actually placed.\r\n//\r\n// Order access tokens live here too. Guest checkout is permanent in GoCommerce, so the token\r\n// returned once at checkout is the only credential that reads the order back; losing it means the\r\n// shopper cannot see what they just bought.\r\n\r\nimport type { CheckoutDetails } from './mappers'\r\n\r\nconst DETAILS_PREFIX = 'gocommerce_checkout_'\r\nconst ORDER_TOKENS_KEY = 'gocommerce_order_tokens'\r\n\r\n/** Server-side rendering has no localStorage, and no shopper to have typed anything into it. */\r\nconst storage = (): Storage | undefined => {\r\n\ttry {\r\n\t\treturn typeof window !== 'undefined' && window.localStorage ? window.localStorage : undefined\r\n\t} catch {\r\n\t\t// Blocked site data (private windows, strict browser settings) throws on access, not on read.\r\n\t\treturn undefined\r\n\t}\r\n}\r\n\r\nconst readJson = <T>(key: string): T | undefined => {\r\n\tconst store = storage()\r\n\tif (!store) return undefined\r\n\ttry {\r\n\t\tconst raw = store.getItem(key)\r\n\t\treturn raw ? (JSON.parse(raw) as T) : undefined\r\n\t} catch {\r\n\t\treturn undefined\r\n\t}\r\n}\r\n\r\nconst writeJson = (key: string, value: unknown) => {\r\n\tconst store = storage()\r\n\tif (!store) return\r\n\ttry {\r\n\t\tstore.setItem(key, JSON.stringify(value))\r\n\t} catch {\r\n\t\t// A full or unavailable quota must not break the checkout step that triggered the write.\r\n\t}\r\n}\r\n\r\nexport const readCheckoutDetails = (cartId?: string | null): CheckoutDetails => {\r\n\tif (!cartId) return {}\r\n\treturn readJson<CheckoutDetails>(`${DETAILS_PREFIX}${cartId}`) ?? {}\r\n}\r\n\r\n/** Merges, so setting an address later never erases the email collected before it. */\r\nexport const writeCheckoutDetails = (cartId: string | null | undefined, patch: CheckoutDetails): CheckoutDetails => {\r\n\tif (!cartId) return patch\r\n\tconst merged = { ...readCheckoutDetails(cartId), ...patch }\r\n\twriteJson(`${DETAILS_PREFIX}${cartId}`, merged)\r\n\treturn merged\r\n}\r\n\r\nexport const clearCheckoutDetails = (cartId?: string | null) => {\r\n\tconst store = storage()\r\n\tif (!store || !cartId) return\r\n\ttry {\r\n\t\tstore.removeItem(`${DETAILS_PREFIX}${cartId}`)\r\n\t} catch {\r\n\t\t// Nothing to recover from: the entry expires with the cart either way.\r\n\t}\r\n}\r\n\r\ntype OrderTokens = Record<string, string>\r\n\r\n/** The credential a guest reads their own order back with. Returned once, at checkout. */\r\nexport const rememberOrderToken = (orderNumber?: string, token?: string) => {\r\n\tif (!orderNumber || !token) return\r\n\tconst tokens = readJson<OrderTokens>(ORDER_TOKENS_KEY) ?? {}\r\n\ttokens[orderNumber] = token\r\n\twriteJson(ORDER_TOKENS_KEY, tokens)\r\n}\r\n\r\nexport const readOrderToken = (orderNumber?: string | null): string | undefined => {\r\n\tif (!orderNumber) return undefined\r\n\treturn (readJson<OrderTokens>(ORDER_TOKENS_KEY) ?? {})[orderNumber]\r\n}\r\n\r\n/** Every order this browser has placed, newest last — the shopper's own order history. */\r\nexport const readOrderNumbers = (): string[] => Object.keys(readJson<OrderTokens>(ORDER_TOKENS_KEY) ?? {})\r\n","// The address book.\r\n//\r\n// GoCommerce has no such thing — there are no accounts to hang addresses off, and a delivery address\r\n// exists only as an argument to `POST /api/checkout/{code}`. But the storefront's checkout needs one:\r\n// when it believes a shopper is signed in it saves the address to the book, lists it, and only then\r\n// copies the selection onto the cart. Refusing that write does not degrade gracefully, it dead-ends\r\n// checkout with \"Saved addresses is not available on this store\".\r\n//\r\n// So the book is real, and local to this browser: the same place the checkout details already live\r\n// (checkout-details.ts), under the same rule — the shopper's own data, on the shopper's own device,\r\n// sent to GoCommerce only when the order is placed. Nothing here reaches the server, and clearing\r\n// site data clears it.\r\n\r\nconst ADDRESSES_KEY = 'gocommerce_addresses'\r\n\r\nexport type StoredAddress = Record<string, unknown> & { id: string }\r\n\r\nconst storage = (): Storage | undefined => {\r\n\ttry {\r\n\t\treturn typeof window !== 'undefined' && window.localStorage ? window.localStorage : undefined\r\n\t} catch {\r\n\t\t// Blocked site data (private windows, strict browser settings) throws on access.\r\n\t\treturn undefined\r\n\t}\r\n}\r\n\r\nconst readAll = (): StoredAddress[] => {\r\n\tconst store = storage()\r\n\tif (!store) return []\r\n\ttry {\r\n\t\tconst raw = store.getItem(ADDRESSES_KEY)\r\n\t\tconst parsed = raw ? JSON.parse(raw) : []\r\n\t\treturn Array.isArray(parsed) ? parsed : []\r\n\t} catch {\r\n\t\treturn []\r\n\t}\r\n}\r\n\r\nconst writeAll = (addresses: StoredAddress[]) => {\r\n\tconst store = storage()\r\n\tif (!store) return\r\n\ttry {\r\n\t\tstore.setItem(ADDRESSES_KEY, JSON.stringify(addresses))\r\n\t} catch {\r\n\t\t// A full or unavailable quota must not fail the checkout step that triggered the write.\r\n\t}\r\n}\r\n\r\n/** `'new'` is the placeholder the form opens with, so it never identifies a saved record. */\r\nconst isSavedId = (id: unknown): id is string => typeof id === 'string' && id.length > 0 && id !== 'new'\r\n\r\nconst newId = () => `addr_${Math.random().toString(36).slice(2, 10)}${Date.now().toString(36)}`\r\n\r\nexport const listAddresses = (): StoredAddress[] => readAll()\r\n\r\nexport const findAddress = (id: string): StoredAddress | undefined => readAll().find((a) => a.id === id)\r\n\r\n/**\r\n * Adds an address, or replaces the one it already names.\r\n *\r\n * The form hands back the record it was opened with, so an edit arrives carrying its own id while a\r\n * new address arrives with the `'new'` placeholder.\r\n */\r\nexport const putAddress = (address: Record<string, unknown>): StoredAddress => {\r\n\tconst addresses = readAll()\r\n\tconst id = isSavedId(address.id) ? address.id : newId()\r\n\tconst saved: StoredAddress = { ...address, id }\r\n\tconst index = addresses.findIndex((a) => a.id === id)\r\n\tif (index >= 0) addresses[index] = saved\r\n\telse addresses.push(saved)\r\n\twriteAll(addresses)\r\n\treturn saved\r\n}\r\n\r\nexport const patchAddress = (id: string, patch: Record<string, unknown>): StoredAddress | undefined => {\r\n\tconst existing = findAddress(id)\r\n\tif (!existing) return undefined\r\n\treturn putAddress({ ...existing, ...patch, id })\r\n}\r\n\r\nexport const removeAddress = (id: string) => {\r\n\twriteAll(readAll().filter((a) => a.id !== id))\r\n}\r\n\r\n/**\r\n * Cookies naming a signed-in shopper, which on GoCommerce can only be leftovers.\r\n *\r\n * `connect.sid` and `me` are how the shared user store decides who is signed in — it reads them from\r\n * `document.cookie` directly. GoCommerce has no accounts and sets neither, so a pair sitting in the\r\n * browser came from running this storefront against a different backend. Left alone they make the\r\n * storefront believe a guest is signed in, which routes checkout down the saved-address path and, on\r\n * a store with no address book, dead-ends it.\r\n */\r\nconst SESSION_COOKIES = ['connect.sid', 'me']\r\n\r\nexport const clearPhantomSession = () => {\r\n\tif (typeof document === 'undefined') return\r\n\tfor (const name of SESSION_COOKIES) {\r\n\t\t// Expire on the current path and on the root, since we did not set them and cannot know which.\r\n\t\tdocument.cookie = `${name}=; Max-Age=0; path=/`\r\n\t\tdocument.cookie = `${name}=; Max-Age=0`\r\n\t}\r\n}\r\n\r\n/** True when this browser is carrying a session from some other backend. */\r\nexport const hasPhantomSession = () =>\r\n\ttypeof document !== 'undefined' && SESSION_COOKIES.some((name) => new RegExp(`(^|;\\\\s*)${name.replace('.', '\\\\.')}=`).test(document.cookie))\r\n","// Catalogue: products, categories, collections, and the listing search built on them.\r\n//\r\n// GoCommerce's shopper-facing catalogue is deliberately small — `q`, `limit`, `page`, and a category\r\n// or collection slug. It has no sort parameter, no tag filter and no price range, so the listing\r\n// page's sort control and facet filters are applied here, over one window of the catalogue\r\n// (`MAX_LIMIT` products, the API's own ceiling). That is exact for a catalogue up to that size and\r\n// is the honest limit of what one request can answer; see docs/GOCOMMERCE.md.\r\n\r\nimport { BaseService, type GoCommerceError } from './base'\r\nimport { currencyFractionDigits as currencyDigits } from './money'\r\nimport { MAX_LIMIT, PAGE_SIZE, emptyPage, fromListMeta, mapCategory, mapCollection, mapProduct, paginated } from './mappers'\r\nimport type { ProductIndex } from './mappers'\r\nimport type { GcCategory, GcCategoryPage, GcCollection, GcCollectionPage, GcProduct, GcVariant, ListMeta } from './types'\r\n\r\n/**\r\n * Products this connector has already read, so a cart or order line can show a slug and an image\r\n * without a request per line. Bounded: a storefront session touches a handful of products, and the\r\n * entries are refreshed whenever a listing reads them again.\r\n */\r\nconst productCache = new Map<number, GcProduct>()\r\n\r\n/** `listRelatedProducts` is handed a category id, but the API is keyed on slug. */\r\nconst categorySlugById = new Map<number, string>()\r\n\r\nconst remember = (products: GcProduct[]) => {\r\n\tfor (const product of products) {\r\n\t\tif (product?.id != null) productCache.set(product.id, product)\r\n\t\tif (product?.category?.id != null && product.category.slug) categorySlugById.set(product.category.id, product.category.slug)\r\n\t}\r\n\treturn products\r\n}\r\n\r\nconst rememberCategories = (categories: GcCategory[]) => {\r\n\tfor (const category of categories) {\r\n\t\tif (category?.id != null && category.slug) categorySlugById.set(category.id, category.slug)\r\n\t\tif (category?.children?.length) rememberCategories(category.children)\r\n\t}\r\n\treturn categories\r\n}\r\n\r\nconst query = (params: Record<string, string | number | undefined>) => {\r\n\tconst search = new URLSearchParams()\r\n\tfor (const [key, value] of Object.entries(params)) {\r\n\t\tif (value === undefined || value === '') continue\r\n\t\tsearch.set(key, String(value))\r\n\t}\r\n\tconst qs = search.toString()\r\n\treturn qs ? `?${qs}` : ''\r\n}\r\n\r\nexport class ProductService extends BaseService {\r\n\tprivate static instance: ProductService\r\n\r\n\tstatic getInstance(): ProductService {\r\n\t\tif (!ProductService.instance) ProductService.instance = new ProductService()\r\n\t\treturn ProductService.instance\r\n\t}\r\n\r\n\t/** One window of the catalogue, raw. Everything else in this file is built on it. */\r\n\tasync fetchProducts({ q, page = 1, limit = PAGE_SIZE }: { q?: string; page?: number; limit?: number } = {}) {\r\n\t\tconst res = await this.api<GcProduct[]>('GET', `/api/products${query({ q, page, limit })}`)\r\n\t\treturn { products: remember(res.data || []), meta: res.meta }\r\n\t}\r\n\r\n\t/** A product by its numeric id — how a cart line names what is in it. */\r\n\tasync fetchProductById(id: number): Promise<GcProduct | null> {\r\n\t\tconst cached = productCache.get(id)\r\n\t\tif (cached) return cached\r\n\t\ttry {\r\n\t\t\tconst res = await this.api<GcProduct>('GET', `/api/products/${id}`)\r\n\t\t\tif (res.data) remember([res.data])\r\n\t\t\treturn res.data ?? null\r\n\t\t} catch {\r\n\t\t\t// A line whose product went inactive still has to render; it just renders without a slug.\r\n\t\t\treturn null\r\n\t\t}\r\n\t}\r\n\r\n\tasync fetchProductBySlug(slug: string): Promise<GcProduct | null> {\r\n\t\tconst res = await this.api<GcProduct>('GET', `/api/products/slug/${encodeURIComponent(slug)}`)\r\n\t\tif (res.data) remember([res.data])\r\n\t\treturn res.data ?? null\r\n\t}\r\n\r\n\tasync list({ page = 1, search = '', sort = '' }: { page?: number; search?: string; sort?: string } = {}) {\r\n\t\tif (sortNeedsWholeCatalogue(sort)) {\r\n\t\t\tconst { products, meta } = await this.fetchProducts({ q: search, page: 1, limit: MAX_LIMIT })\r\n\t\t\tconst sorted = sortProducts(products, sort)\r\n\t\t\tconst start = (page - 1) * PAGE_SIZE\r\n\t\t\treturn paginated(sorted.slice(start, start + PAGE_SIZE).map(mapProduct), meta?.total ?? sorted.length, page)\r\n\t\t}\r\n\t\tconst { products, meta } = await this.fetchProducts({ q: search, page, limit: PAGE_SIZE })\r\n\t\treturn fromListMeta(products.map(mapProduct), meta, page)\r\n\t}\r\n\r\n\t// GoCommerce records no \"featured\" or \"trending\" flag, and inventing one would rank the catalogue\r\n\t// by nothing. Newest first is the honest reading of both, and it is what the homepage asks for.\r\n\tasync listFeaturedProducts({ page = 1, sort = '-createdAt' }: { page?: number; sort?: string } = {}) {\r\n\t\treturn this.list({ page, sort })\r\n\t}\r\n\r\n\tasync listTrendingProducts({ page = 1, search = '', sort = '-createdAt' }: { page?: number; search?: string; sort?: string } = {}) {\r\n\t\treturn this.list({ page, search, sort })\r\n\t}\r\n\r\n\t/** The \"you may also like\" rail: the rest of the product's own category. */\r\n\tasync listRelatedProducts({ page = 1, categoryId = '' }: { page?: number; categoryId?: string | number; sort?: string } = {}) {\r\n\t\tconst slug = await resolveCategorySlug(categoryId)\r\n\t\tif (!slug) return emptyPage(page)\r\n\t\tconst { products, meta } = await categoryService.fetchCategoryPage(slug, { limit: MAX_LIMIT })\r\n\t\tconst start = (page - 1) * PAGE_SIZE\r\n\t\treturn paginated(products.slice(start, start + PAGE_SIZE).map(mapProduct), meta?.total ?? products.length, page)\r\n\t}\r\n\r\n\tasync getOne(slug: string) {\r\n\t\treturn mapProduct(await this.fetchProductBySlug(slug))\r\n\t}\r\n\r\n\t/** A product's variants, for a PDP that wants them without re-reading the product. */\r\n\tasync listVariants(productId: number | string) {\r\n\t\tconst res = await this.api<GcVariant[]>('GET', `/api/variants${query({ product_id: productId, limit: MAX_LIMIT })}`)\r\n\t\treturn fromListMeta(res.data || [], res.meta)\r\n\t}\r\n\r\n\t// GoCommerce ships no review API, and a silent success would tell the shopper their review was\r\n\t// saved when nothing left the browser.\r\n\tasync addReview(_params: unknown): Promise<never> {\r\n\t\tthrow new Error('Product reviews are not available on this store.')\r\n\t}\r\n\r\n\tasync fetchReels() {\r\n\t\treturn { data: [], count: 0 }\r\n\t}\r\n}\r\n\r\nexport const productService = ProductService.getInstance()\r\n\r\nexport class CategoryService extends BaseService {\r\n\tprivate static instance: CategoryService\r\n\r\n\tstatic getInstance(): CategoryService {\r\n\t\tif (!CategoryService.instance) CategoryService.instance = new CategoryService()\r\n\t\treturn CategoryService.instance\r\n\t}\r\n\r\n\t/**\r\n\t * `use-category-filters` in @misiki/kitcommerce-core fetches the tree by raw Litekart REST path\r\n\t * rather than a typed method. On a GoCommerce store that url resolves against the storefront's\r\n\t * own origin, so route that one path to the real tree; `fetchAllCategories` already returns the\r\n\t * `{ data }` shape it reads.\r\n\t */\r\n\tasync get<T>(url: string): Promise<T> {\r\n\t\tif (typeof url === 'string' && url.startsWith('/api/categories/all')) {\r\n\t\t\treturn (await this.fetchAllCategories()) as T\r\n\t\t}\r\n\t\treturn super.get<T>(url)\r\n\t}\r\n\r\n\t/**\r\n\t * The taxonomy, flattened.\r\n\t *\r\n\t * `GET /api/categories` answers with one fixed window and ignores `limit`/`page`, so this is\r\n\t * every category the storefront can see — roots plus what fits beneath them. A store that has\r\n\t * imported a full retail taxonomy has far more nodes than that; the ones a shopper reaches are\r\n\t * still reachable, because a listing page looks its category up by slug directly.\r\n\t */\r\n\tasync fetchAllCategories() {\r\n\t\tconst res = await this.api<GcCategory[]>('GET', `/api/categories${query({ flat: 'true' })}`)\r\n\t\tconst categories = rememberCategories(res.data || [])\r\n\t\treturn paginated(categories.map(mapCategory), categories.length, 1, categories.length || PAGE_SIZE)\r\n\t}\r\n\r\n\t/** A category and the active products filed under it or anything beneath it. */\r\n\tasync fetchCategoryPage(slug: string, { limit = MAX_LIMIT, offset = 0 }: { limit?: number; offset?: number } = {}) {\r\n\t\tconst res = await this.api<GcCategoryPage>('GET', `/api/categories/${encodeURIComponent(slug)}${query({ limit, offset })}`)\r\n\t\tconst category = res.data\r\n\t\tif (category) rememberCategories([category])\r\n\t\tconst products = remember(category?.products || [])\r\n\t\treturn { category, products, meta: res.meta }\r\n\t}\r\n\r\n\tasync fetchCategory(slugOrId: string) {\r\n\t\tconst { category } = await this.fetchCategoryPage(String(slugOrId), { limit: 1 })\r\n\t\treturn mapCategory(category)\r\n\t}\r\n\r\n\tasync fetchFooterCategories({ page = 1, q = '' }: { page?: number; q?: string; sort?: string } = {}) {\r\n\t\tconst all = await this.fetchAllCategories()\r\n\t\tconst filtered = q ? all.data.filter((c) => c?.name?.toLowerCase().includes(q.toLowerCase())) : all.data\r\n\t\tconst start = (page - 1) * PAGE_SIZE\r\n\t\treturn paginated(filtered.slice(start, start + PAGE_SIZE), filtered.length, page)\r\n\t}\r\n\r\n\t/** The homepage grid: the roots of the taxonomy, which is what a shopper navigates from. */\r\n\tasync fetchFeaturedCategories({ limit = 18 }: { limit?: number } = {}) {\r\n\t\tconst all = await this.fetchAllCategories()\r\n\t\tconst roots = all.data.filter((c) => c && c.parentCategoryId == null)\r\n\t\tconst picked = (roots.length ? roots : all.data).slice(0, limit)\r\n\t\treturn paginated(picked, picked.length, 1, limit)\r\n\t}\r\n\r\n\tasync fetchAllProductsOfCategories(slugOrId: string) {\r\n\t\tconst slug = (await resolveCategorySlug(slugOrId)) || String(slugOrId)\r\n\t\tconst { products, meta } = await this.fetchCategoryPage(slug)\r\n\t\treturn fromListMeta(products.map(mapProduct), meta)\r\n\t}\r\n\r\n\tasync getMegamenu() {\r\n\t\treturn this.fetchFeaturedCategories({ limit: 50 })\r\n\t}\r\n}\r\n\r\nexport const categoryService = CategoryService.getInstance()\r\n\r\n/** Turns the numeric category id carried on a product into the slug the API is keyed on. */\r\nconst resolveCategorySlug = async (categoryId: string | number | undefined | null): Promise<string | undefined> => {\r\n\tif (categoryId === undefined || categoryId === null || categoryId === '') return undefined\r\n\tconst asNumber = Number(categoryId)\r\n\tif (!Number.isFinite(asNumber)) return String(categoryId)\r\n\tconst known = categorySlugById.get(asNumber)\r\n\tif (known) return known\r\n\tawait categoryService.fetchAllCategories()\r\n\treturn categorySlugById.get(asNumber)\r\n}\r\n\r\nexport class CollectionService extends BaseService {\r\n\tprivate static instance: CollectionService\r\n\r\n\tstatic getInstance(): CollectionService {\r\n\t\tif (!CollectionService.instance) CollectionService.instance = new CollectionService()\r\n\t\treturn CollectionService.instance\r\n\t}\r\n\r\n\tasync list({ page = 1, q = '' }: { page?: number; q?: string; sort?: string } = {}) {\r\n\t\tconst res = await this.api<GcCollection[]>('GET', `/api/collections${query({ page, limit: PAGE_SIZE })}`)\r\n\t\tconst items = res.data || []\r\n\t\tconst filtered = q ? items.filter((c) => c.title?.toLowerCase().includes(q.toLowerCase())) : items\r\n\t\treturn fromListMeta(\r\n\t\t\tfiltered.map((c) => mapCollection(c)),\r\n\t\t\tres.meta,\r\n\t\t\tpage\r\n\t\t)\r\n\t}\r\n\r\n\t/**\r\n\t * A collection with its products. GoCommerce is keyed on slug; the storefront sometimes has only\r\n\t * an id, and there is no id lookup, so that case reads the list and matches there.\r\n\t */\r\n\tasync getOne(idOrSlug: string) {\r\n\t\tconst looksLikeId = /^[0-9]+$/.test(String(idOrSlug))\r\n\t\tlet slug = String(idOrSlug)\r\n\t\tif (looksLikeId) {\r\n\t\t\tconst res = await this.api<GcCollection[]>('GET', `/api/collections${query({ limit: MAX_LIMIT })}`)\r\n\t\t\tconst match = (res.data || []).find((c) => String(c.id) === String(idOrSlug))\r\n\t\t\tif (!match) throw new Error(`Collection ${idOrSlug} not found`)\r\n\t\t\tslug = match.slug\r\n\t\t}\r\n\t\tconst res = await this.api<GcCollectionPage>('GET', `/api/collections/${encodeURIComponent(slug)}${query({ limit: MAX_LIMIT })}`)\r\n\t\tif (!res.data) throw new Error(`Collection ${idOrSlug} not found`)\r\n\t\tremember(res.data.products || [])\r\n\t\treturn mapCollection(res.data)\r\n\t}\r\n\r\n\t// GoCommerce records no ratings, so there is no \"all ratings\" collection to serve.\r\n\tasync getAllRatings() {\r\n\t\treturn {\r\n\t\t\tid: null,\r\n\t\t\tname: 'All Ratings',\r\n\t\t\tslug: 'all-ratings',\r\n\t\t\tdescription: null,\r\n\t\t\tisActive: true,\r\n\t\t\tisFeatured: false,\r\n\t\t\tuserId: '',\r\n\t\t\tproductCount: 0,\r\n\t\t\tthumbnail: null,\r\n\t\t\tmetaTitle: null,\r\n\t\t\tmetaDescription: null,\r\n\t\t\tcollectionvalues: [],\r\n\t\t\tcreatedAt: null,\r\n\t\t\tupdatedAt: null\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport const collectionService = CollectionService.getInstance()\r\n\r\n// ---------------------------------------------------------------------------------------------\r\n// Listing search\r\n// ---------------------------------------------------------------------------------------------\r\n\r\nexport type ProductSearchResult = {\r\n\tdata: unknown[]\r\n\tcount: number\r\n\ttotalPages: number\r\n\tcategoryHierarchy: { name: string; slug?: string }[]\r\n\tfacets: {\r\n\t\tpriceStat: { min?: number; max?: number }\r\n\t\tcategories: { name: string; slug?: string; count: number }[]\r\n\t\ttags: { name: string; slug?: string; count: number }[]\r\n\t\tallFilters: Record<string, unknown>\r\n\t}\r\n}\r\n\r\n/** `popularity` has no GoCommerce equivalent, so it means \"the operator's own order\" — no re-sort. */\r\nconst sortNeedsWholeCatalogue = (sort?: string) => {\r\n\tif (!sort) return false\r\n\tconst key = sort.replace(/^-/, '').split(':')[0]\r\n\treturn key === 'price' || key === 'updatedAt' || key === 'createdAt'\r\n}\r\n\r\nconst sortProducts = (products: GcProduct[], sort?: string): GcProduct[] => {\r\n\tif (!sortNeedsWholeCatalogue(sort)) return products\r\n\t// Both spellings reach here: `price:asc` from the sort control, `-createdAt` from the homepage.\r\n\tconst leadingMinus = sort!.startsWith('-')\r\n\tconst [rawKey, rawDirection] = sort!.replace(/^-/, '').split(':')\r\n\tconst descending = leadingMinus || rawDirection === 'desc'\r\n\r\n\tconst value = (product: GcProduct) => {\r\n\t\tif (rawKey === 'price') {\r\n\t\t\tconst prices = (product.variants || []).filter((v) => v.active !== false).map((v) => v.price?.amount_minor ?? 0)\r\n\t\t\treturn prices.length ? Math.min(...prices) : 0\r\n\t\t}\r\n\t\tconst stamp = rawKey === 'createdAt' ? product.created_at : product.updated_at\r\n\t\treturn stamp ? Date.parse(stamp) : 0\r\n\t}\r\n\r\n\treturn [...products].sort((a, b) => (descending ? value(b) - value(a) : value(a) - value(b)))\r\n}\r\n\r\nconst productPrice = (product: GcProduct) => {\r\n\tconst prices = (product.variants || []).filter((v) => v.active !== false).map((v) => v.price?.amount_minor ?? 0)\r\n\treturn prices.length ? Math.min(...prices) : 0\r\n}\r\n\r\nconst countBy = <T>(items: T[], key: (item: T) => { name: string; slug?: string } | undefined) => {\r\n\tconst counts = new Map<string, { name: string; slug?: string; count: number }>()\r\n\tfor (const item of items) {\r\n\t\tconst entry = key(item)\r\n\t\tif (!entry?.name) continue\r\n\t\tconst id = entry.slug || entry.name\r\n\t\tconst existing = counts.get(id)\r\n\t\tif (existing) existing.count += 1\r\n\t\telse counts.set(id, { ...entry, count: 1 })\r\n\t}\r\n\treturn [...counts.values()].sort((a, b) => b.count - a.count)\r\n}\r\n\r\nexport class SearchService extends BaseService {\r\n\tprivate static instance: SearchService\r\n\r\n\tstatic getInstance(): SearchService {\r\n\t\tif (!SearchService.instance) SearchService.instance = new SearchService()\r\n\t\treturn SearchService.instance\r\n\t}\r\n\r\n\temptyResult(): ProductSearchResult {\r\n\t\treturn {\r\n\t\t\tdata: [],\r\n\t\t\tcount: 0,\r\n\t\t\ttotalPages: 0,\r\n\t\t\tcategoryHierarchy: [],\r\n\t\t\tfacets: { priceStat: { min: undefined, max: undefined }, categories: [], tags: [], allFilters: {} }\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * The listing page: `/products`, `/[slug]` for a category, and every filter the sidebar sets.\r\n\t *\r\n\t * Term and category are pushed to the API. Tags, the price range and the sort control are\r\n\t * applied here, because GoCommerce has no parameter for them — so when any of those is active\r\n\t * the request asks for the whole window rather than one page, and the result is paged locally.\r\n\t */\r\n\tasync searchWithUrl(url: URL, slug?: string): Promise<ProductSearchResult> {\r\n\t\ttry {\r\n\t\t\tconst params = new URLSearchParams(url.search)\r\n\t\t\tconst term = params.get('search') || params.get('q') || ''\r\n\t\t\tconst page = Math.max(1, Number(params.get('page') || 1) || 1)\r\n\t\t\tconst sort = params.get('sort') || ''\r\n\t\t\tconst tags = (params.get('tags') || '')\r\n\t\t\t\t.split(',')\r\n\t\t\t\t.map((t) => decodeURIComponent(t).trim().toLowerCase())\r\n\t\t\t\t.filter(Boolean)\r\n\t\t\tconst priceFrom = params.get('priceFrom') ? Number(params.get('priceFrom')) : undefined\r\n\t\t\tconst priceTo = params.get('priceTo') ? Number(params.get('priceTo')) : undefined\r\n\r\n\t\t\t// `/products` is the catalogue root, not a category; anything else in that slot is one.\r\n\t\t\tconst categorySlug = slug && slug !== 'products' ? slug : params.get('categories') || undefined\r\n\r\n\t\t\tconst localFilters = tags.length > 0 || priceFrom !== undefined || priceTo !== undefined\r\n\t\t\tconst needsWholeWindow = localFilters || sortNeedsWholeCatalogue(sort) || Boolean(categorySlug)\r\n\r\n\t\t\tlet products: GcProduct[] = []\r\n\t\t\tlet meta: ListMeta | undefined\r\n\t\t\tlet category: GcCategory | undefined\r\n\r\n\t\t\tif (categorySlug) {\r\n\t\t\t\tconst res = await categoryService.fetchCategoryPage(categorySlug, { limit: MAX_LIMIT })\r\n\t\t\t\tproducts = res.products\r\n\t\t\t\tmeta = res.meta\r\n\t\t\t\tcategory = res.category\r\n\t\t\t\tif (term) {\r\n\t\t\t\t\tconst needle = term.toLowerCase()\r\n\t\t\t\t\tproducts = products.filter((p) => `${p.title} ${p.description || ''}`.toLowerCase().includes(needle))\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tconst res = await productService.fetchProducts({\r\n\t\t\t\t\tq: term,\r\n\t\t\t\t\tpage: needsWholeWindow ? 1 : page,\r\n\t\t\t\t\tlimit: needsWholeWindow ? MAX_LIMIT : PAGE_SIZE\r\n\t\t\t\t})\r\n\t\t\t\tproducts = res.products\r\n\t\t\t\tmeta = res.meta\r\n\t\t\t}\r\n\r\n\t\t\t// Facets describe what came back, so they are computed before the local filters narrow it.\r\n\t\t\tconst facetSource = products\r\n\t\t\tconst priceMinor = facetSource.map(productPrice).filter((n) => Number.isFinite(n))\r\n\t\t\tconst currency = facetSource[0]?.variants?.[0]?.price?.currency || facetSource[0]?.currency\r\n\t\t\tconst digits = currency ? 10 ** currencyDigits(currency) : 100\r\n\r\n\t\t\tlet filtered = products\r\n\t\t\tif (tags.length) {\r\n\t\t\t\tfiltered = filtered.filter((p) => (p.tags || []).some((tag) => tags.includes(tag.toLowerCase())))\r\n\t\t\t}\r\n\t\t\tif (priceFrom !== undefined) filtered = filtered.filter((p) => productPrice(p) / digits >= priceFrom)\r\n\t\t\tif (priceTo !== undefined) filtered = filtered.filter((p) => productPrice(p) / digits <= priceTo)\r\n\r\n\t\t\tfiltered = sortProducts(filtered, sort)\r\n\r\n\t\t\t// One page of the API's own window is already the page; anything narrowed here is not.\r\n\t\t\tconst paged = needsWholeWindow ? filtered.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE) : filtered\r\n\t\t\tconst count = needsWholeWindow ? filtered.length : (meta?.total ?? filtered.length)\r\n\r\n\t\t\treturn {\r\n\t\t\t\tdata: paged.map(mapProduct),\r\n\t\t\t\tcount,\r\n\t\t\t\ttotalPages: Math.ceil(count / PAGE_SIZE) || (count ? 1 : 0),\r\n\t\t\t\t// Only the category itself: its ancestors are named in `full_name` but their slugs are\r\n\t\t\t\t// not served to a storefront, and a breadcrumb link with no destination is worse than\r\n\t\t\t\t// no crumb.\r\n\t\t\t\tcategoryHierarchy: category ? [{ name: category.title, slug: category.slug }] : [],\r\n\t\t\t\tfacets: {\r\n\t\t\t\t\tpriceStat: priceMinor.length\r\n\t\t\t\t\t\t? { min: Math.min(...priceMinor) / digits, max: Math.max(...priceMinor) / digits }\r\n\t\t\t\t\t\t: { min: undefined, max: undefined },\r\n\t\t\t\t\tcategories: countBy(facetSource, (p) => (p.category ? { name: p.category.title, slug: p.category.slug } : undefined)),\r\n\t\t\t\t\ttags: countBy(\r\n\t\t\t\t\t\tfacetSource.flatMap((p) => (p.tags || []).map((tag) => ({ tag }))),\r\n\t\t\t\t\t\t({ tag }) => ({ name: tag, slug: tag })\r\n\t\t\t\t\t),\r\n\t\t\t\t\tallFilters: {}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t} catch (error) {\r\n\t\t\t// `(www)/[slug]` is the storefront's catch-all, so every unmatched path arrives here as a\r\n\t\t\t// category lookup. A slug that names no category is that route doing its job, not a\r\n\t\t\t// failure worth a stack trace — anything else is.\r\n\t\t\tif ((error as GoCommerceError)?.code !== 'not_found') console.error('[gocommerce] search failed', error)\r\n\t\t\treturn this.emptyResult()\r\n\t\t}\r\n\t}\r\n\r\n\tasync searchWithQuery(queryString: string): Promise<ProductSearchResult> {\r\n\t\tconst url = new URL('https://storefront.local/products')\r\n\t\tif (queryString) url.searchParams.set('search', queryString)\r\n\t\treturn this.searchWithUrl(url)\r\n\t}\r\n}\r\n\r\nexport const searchService = SearchService.getInstance()\r\n\r\n/**\r\n * The site-wide search box. Litekart backs this with Meilisearch; GoCommerce answers the same\r\n * question with `?q=` on the catalogue, so the shape is translated rather than the engine replaced.\r\n */\r\nexport class MeilisearchService extends BaseService {\r\n\tprivate static instance: MeilisearchService\r\n\r\n\tstatic getInstance(): MeilisearchService {\r\n\t\tif (!MeilisearchService.instance) MeilisearchService.instance = new MeilisearchService()\r\n\t\treturn MeilisearchService.instance\r\n\t}\r\n\r\n\tasync search(params: { q?: string; page?: number; limit?: number } = {}) {\r\n\t\tconst page = Math.max(1, Number(params.page || 1) || 1)\r\n\t\tconst { products, meta } = await productService.fetchProducts({\r\n\t\t\tq: params.q || '',\r\n\t\t\tpage,\r\n\t\t\tlimit: params.limit || PAGE_SIZE\r\n\t\t})\r\n\t\tconst hits = products.map(mapProduct)\r\n\t\treturn {\r\n\t\t\thits,\r\n\t\t\tdata: hits,\r\n\t\t\testimatedTotalHits: meta?.total ?? hits.length,\r\n\t\t\tcount: meta?.total ?? hits.length,\r\n\t\t\tpage,\r\n\t\t\ttotalPages: meta?.total_pages ?? 1,\r\n\t\t\thitsPerPage: meta?.limit ?? PAGE_SIZE,\r\n\t\t\tfacetDistribution: {},\r\n\t\t\tprocessingTimeMs: 0,\r\n\t\t\tquery: params.q || ''\r\n\t\t}\r\n\t}\r\n\r\n\tasync searchAutoComplete(params: { q?: string; limit?: number } = {}) {\r\n\t\tconst { products } = await productService.fetchProducts({ q: params.q || '', page: 1, limit: params.limit || 8 })\r\n\t\tconst hits = products.map((product) => ({\r\n\t\t\tid: product.id,\r\n\t\t\tname: product.title,\r\n\t\t\ttitle: product.title,\r\n\t\t\tslug: product.slug,\r\n\t\t\tthumbnail: mapProduct(product)?.thumbnail || null\r\n\t\t}))\r\n\t\treturn { hits, data: hits, count: hits.length, query: params.q || '' }\r\n\t}\r\n}\r\n\r\nexport const meilisearchService = MeilisearchService.getInstance()\r\n\r\nexport class AutocompleteService extends BaseService {\r\n\tprivate static instance: AutocompleteService\r\n\r\n\tstatic getInstance(): AutocompleteService {\r\n\t\tif (!AutocompleteService.instance) AutocompleteService.instance = new AutocompleteService()\r\n\t\treturn AutocompleteService.instance\r\n\t}\r\n\r\n\tasync list({ page = 1, q = '' }: { page?: number; q?: string; sort?: string } = {}) {\r\n\t\tconst { products, meta } = await productService.fetchProducts({ q, page, limit: 10 })\r\n\t\treturn fromListMeta(\r\n\t\t\tproducts.map((product) => ({ id: product.id, name: product.title, slug: product.slug })),\r\n\t\t\tmeta,\r\n\t\t\tpage\r\n\t\t)\r\n\t}\r\n}\r\n\r\nexport const autocompleteService = AutocompleteService.getInstance()\r\n\r\n/**\r\n * A product index for the ids a cart or order line names, so those lines can show a slug and an\r\n * image. Everything already read is served from the cache; the rest is fetched once, in parallel.\r\n */\r\nexport const resolveProductIndex = async (ids: (number | null | undefined)[], fetchFn?: typeof fetch): Promise<ProductIndex> => {\r\n\tconst wanted = [...new Set(ids.filter((id): id is number => typeof id === 'number'))]\r\n\tconst service = fetchFn ? new ProductService(fetchFn) : productService\r\n\tawait Promise.all(wanted.filter((id) => !productCache.has(id)).map((id) => service.fetchProductById(id)))\r\n\tconst index: ProductIndex = new Map()\r\n\tfor (const id of wanted) {\r\n\t\tconst product = productCache.get(id)\r\n\t\tif (product) index.set(id, product)\r\n\t}\r\n\treturn index\r\n}\r\n","// The cart.\r\n//\r\n// A GoCommerce cart is an opaque token and possessing it is the whole authorisation — there is no\r\n// account, and there never has to be. So the token is what this storefront persists as `cart_id`,\r\n// exactly where the shared cart store already looks for it.\r\n\r\nimport { BaseService } from './base'\r\nimport { resolveProductIndex } from './catalog'\r\nimport { readCheckoutDetails, writeCheckoutDetails } from './checkout-details'\r\nimport { mapCart } from './mappers'\r\nimport { readStaticStore } from './static-store'\r\nimport type { GcCart } from './types'\r\n\r\n/** The shared cart store's \"remove this line\" signal, sent as a quantity. */\r\nconst REMOVE_LINE = -9999999\r\n\r\nconst CART_ID_KEY = 'cart_id'\r\n\r\nconst readStoredCartId = (): string | null => {\r\n\ttry {\r\n\t\treturn typeof window !== 'undefined' ? window.localStorage?.getItem(CART_ID_KEY) || null : null\r\n\t} catch {\r\n\t\treturn null\r\n\t}\r\n}\r\n\r\nconst storeCartId = (cartId?: string | null) => {\r\n\tif (!cartId) return\r\n\ttry {\r\n\t\twindow?.localStorage?.setItem(CART_ID_KEY, cartId)\r\n\t} catch {\r\n\t\t// Without storage the cart lives for one page view; the checkout still works within it.\r\n\t}\r\n}\r\n\r\nconst forgetCartId = () => {\r\n\ttry {\r\n\t\twindow?.localStorage?.removeItem(CART_ID_KEY)\r\n\t} catch {\r\n\t\t// Nothing to clean up if storage is unavailable — there was no id to remember either.\r\n\t}\r\n}\r\n\r\n/** `'undefined'` reaches here as a string from call sites that interpolate a missing id. */\r\nconst usableId = (cartId?: string | null) => (cartId && cartId !== 'undefined' && cartId !== 'null' ? cartId : null)\r\n\r\nexport class CartService extends BaseService {\r\n\tprivate static instance: CartService\r\n\r\n\tstatic getInstance(): CartService {\r\n\t\tif (!CartService.instance) CartService.instance = new CartService()\r\n\t\treturn CartService.instance\r\n\t}\r\n\r\n\t/** Turns a GoCommerce cart into the shape the storefront's cart, drawer and checkout read. */\r\n\tprivate async present(cart: GcCart | null | undefined) {\r\n\t\tif (!cart) return {}\r\n\t\tstoreCartId(cart.id)\r\n\t\tconst [index, store] = await Promise.all([\r\n\t\t\t// Cart lines name a product by id only, so slug and image are filled in from the catalogue.\r\n\t\t\tresolveProductIndex(\r\n\t\t\t\t(cart.line_items || []).map((line) => line.product_id),\r\n\t\t\t\tthis.getFetch()\r\n\t\t\t),\r\n\t\t\treadStaticStore()\r\n\t\t])\r\n\t\treturn mapCart(cart, readCheckoutDetails(cart.id), index, store)\r\n\t}\r\n\r\n\t/** Opens a cart. The email is optional here and is the only field `POST /api/carts` accepts. */\r\n\tprivate async openCart(email?: string): Promise<GcCart> {\r\n\t\tconst res = await this.api<GcCart>('POST', '/api/carts', email ? { email } : {})\r\n\t\tstoreCartId(res.data?.id)\r\n\t\treturn res.data\r\n\t}\r\n\r\n\tprivate async readCart(cartId: string): Promise<GcCart | null> {\r\n\t\tlet cart: GcCart | null = null\r\n\t\ttry {\r\n\t\t\tconst res = await this.api<GcCart>('GET', `/api/carts/${encodeURIComponent(cartId)}`)\r\n\t\t\tcart = res.data ?? null\r\n\t\t} catch {\r\n\t\t\t// An expired or unknown token is not an error the shopper can act on — it is an empty bag.\r\n\t\t\treturn null\r\n\t\t}\r\n\r\n\t\t// A checked-out cart keeps its lines forever — that is what makes it readable as a receipt on\r\n\t\t// the confirmation page. It is no longer a bag, though, so forget the token here: otherwise\r\n\t\t// the shopper lands back on the store with the thing they just bought still sitting in it, and\r\n\t\t// every attempt to change it is refused by the API.\r\n\t\tif (cart && cart.status && cart.status !== 'open') {\r\n\t\t\tforgetCartId()\r\n\t\t\treturn null\r\n\t\t}\r\n\t\treturn cart\r\n\t}\r\n\r\n\t/**\r\n\t * Is the cart behind this token gone for good — expired, unknown, or already checked out?\r\n\t *\r\n\t * Asked by re-reading the cart rather than by matching the failure's wording, because the API\r\n\t * reports several unrelated things the same way: a dead cart and an unknown payment code are both\r\n\t * `404 not_found`. The status is the fact; the message is prose.\r\n\t */\r\n\tasync cartIsSpent(cartId: string): Promise<boolean> {\r\n\t\ttry {\r\n\t\t\tconst res = await this.api<GcCart>('GET', `/api/carts/${encodeURIComponent(cartId)}`)\r\n\t\t\treturn !res.data || (Boolean(res.data.status) && res.data.status !== 'open')\r\n\t\t} catch {\r\n\t\t\t// The token names nothing.\r\n\t\t\treturn true\r\n\t\t}\r\n\t}\r\n\r\n\t/** One line-item write against a cart that exists. Returns the cart the write left behind. */\r\n\tprivate async writeLine(\r\n\t\tcartId: string,\r\n\t\t{ variantId, qty, lineId, removing }: { variantId?: string | number; qty: number; lineId?: string | number | null; removing: boolean }\r\n\t): Promise<GcCart | null> {\r\n\t\tconst cart = encodeURIComponent(cartId)\r\n\r\n\t\tif (lineId) {\r\n\t\t\tconst line = encodeURIComponent(String(lineId))\r\n\t\t\tconst res = removing\r\n\t\t\t\t? await this.api<GcCart>('DELETE', `/api/carts/${cart}/line-items/${line}`)\r\n\t\t\t\t: await this.api<GcCart>('PATCH', `/api/carts/${cart}/line-items/${line}`, { quantity: qty })\r\n\t\t\treturn res.data ?? null\r\n\t\t}\r\n\r\n\t\t// Nothing was named to remove, so leave the cart exactly as it is.\r\n\t\tif (removing) return this.readCart(cartId)\r\n\r\n\t\tconst res = await this.api<GcCart>('POST', `/api/carts/${cart}/line-items`, {\r\n\t\t\tvariant_id: Number(variantId),\r\n\t\t\tquantity: qty\r\n\t\t})\r\n\t\treturn res.data ?? null\r\n\t}\r\n\r\n\tasync getCartByCartId(cartId: string) {\r\n\t\tconst id = usableId(cartId) || readStoredCartId()\r\n\t\tif (!id) return {}\r\n\t\treturn this.present(await this.readCart(id))\r\n\t}\r\n\r\n\tasync fetchCartData() {\r\n\t\tconst id = readStoredCartId()\r\n\t\tif (!id) return {}\r\n\t\treturn this.present(await this.readCart(id))\r\n\t}\r\n\r\n\tasync refereshCart() {\r\n\t\treturn this.fetchCartData()\r\n\t}\r\n\r\n\t/**\r\n\t * Add, change or remove a line.\r\n\t *\r\n\t * `qty` is the line's new quantity, not a delta — which is how the shared cart store calls it\r\n\t * (its stepper sends `qty ± 1`), and what `PATCH .../line-items/{lineId}` takes. A quantity of\r\n\t * zero removes the line, and so does the store's `REMOVE_LINE` sentinel.\r\n\t *\r\n\t * A cart token in this browser can be dead — expired, wiped server-side, or already checked out —\r\n\t * and the API then answers \"cart not found\", which is what the shopper was shown when they\r\n\t * clicked Add to bag. That is a token this storefront is holding, not anything they did, so a\r\n\t * dead one is dropped and the item is added to a fresh cart instead of reporting it.\r\n\t */\r\n\tasync addToCart({\r\n\t\tvariantId,\r\n\t\tqty,\r\n\t\tcartId,\r\n\t\tlineId\r\n\t}: {\r\n\t\tproductId?: string | number\r\n\t\tvariantId?: string | number\r\n\t\tqty: number\r\n\t\tcartId?: string | null\r\n\t\tlineId?: string | number | null\r\n\t}) {\r\n\t\tconst removing = qty === REMOVE_LINE || qty <= 0\r\n\t\tif (!removing && !variantId) throw new Error('A variant is required to add an item to the cart.')\r\n\r\n\t\tlet id = usableId(cartId) || readStoredCartId()\r\n\r\n\t\tif (id) {\r\n\t\t\tlet cart: GcCart | null = null\r\n\t\t\tlet spent = false\r\n\t\t\ttry {\r\n\t\t\t\tcart = await this.writeLine(id, { variantId, qty, lineId, removing })\r\n\t\t\t} catch (error) {\r\n\t\t\t\t// Only a dead cart is recovered from. A refusal the cart is alive for — a price that\r\n\t\t\t\t// moved, stock that ran out — is the shopper's to see, and must not be swallowed by\r\n\t\t\t\t// silently starting a new bag.\r\n\t\t\t\tif (!(await this.cartIsSpent(id))) throw error\r\n\t\t\t\tspent = true\r\n\t\t\t}\r\n\t\t\tif (!spent) return this.present(cart)\r\n\t\t\tforgetCartId()\r\n\t\t\tid = null\r\n\t\t}\r\n\r\n\t\t// No cart, or the one this browser held is gone. Removing a line from a cart that no longer\r\n\t\t// exists has already happened, as far as the shopper is concerned.\r\n\t\tif (removing) return {}\r\n\r\n\t\tconst opened = await this.openCart(readCheckoutDetails(null).email)\r\n\t\tif (!opened?.id) throw new Error('Could not open a cart on this store.')\r\n\t\t// `lineId` named a line in the cart that just died, so this is a plain add.\r\n\t\treturn this.present(await this.writeLine(opened.id, { variantId, qty, lineId: null, removing: false }))\r\n\t}\r\n\r\n\tasync updateCart({\r\n\t\tqty,\r\n\t\tcartId,\r\n\t\tlineId = null,\r\n\t\tproductId,\r\n\t\tvariantId\r\n\t}: {\r\n\t\tqty: number\r\n\t\tcartId?: string | null\r\n\t\tlineId?: string | number | null\r\n\t\tproductId?: string | number\r\n\t\tvariantId?: string | number\r\n\t\tisSelectedForCheckout?: boolean\r\n\t}) {\r\n\t\treturn this.addToCart({ productId, variantId, qty, cartId, lineId })\r\n\t}\r\n\r\n\tasync removeCart({ cartId, lineId = null }: { cartId?: string | null; lineId?: string | number | null }) {\r\n\t\treturn this.addToCart({ qty: REMOVE_LINE, cartId, lineId })\r\n\t}\r\n\r\n\t/**\r\n\t * The address step's write.\r\n\t *\r\n\t * GoCommerce has no endpoint that changes a cart after it is opened, and no address on it: these\r\n\t * fields are arguments to checkout. They are kept against this cart id in the browser and sent\r\n\t * when the order is placed — see checkout-details.ts. The email additionally seeds a cart that\r\n\t * has not been opened yet, which is the one moment GoCommerce does accept it.\r\n\t */\r\n\tasync updateCart2({\r\n\t\tcartId,\r\n\t\temail,\r\n\t\tphone,\r\n\t\tbillingAddress,\r\n\t\tshippingAddress,\r\n\t\tisBillingAddressSameAsShipping\r\n\t}: {\r\n\t\tstoreId?: string\r\n\t\tcartId?: string | null\r\n\t\temail?: string\r\n\t\tphone?: string\r\n\t\tcustomer_id?: string\r\n\t\tbillingAddress?: Record<string, any> | null\r\n\t\tshippingAddress?: Record<string, any> | null\r\n\t\tisBillingAddressSameAsShipping?: boolean\r\n\t}) {\r\n\t\t// Read before writing: a token that has expired or already checked out must not be the one the\r\n\t\t// address is filed under, or checkout would refuse it and send the shopper back to a step they\r\n\t\t// had already finished.\r\n\t\tlet id = usableId(cartId) || readStoredCartId()\r\n\t\tlet cart = id ? await this.readCart(id) : null\r\n\t\tif (!cart) {\r\n\t\t\tcart = await this.openCart(email)\r\n\t\t\tid = cart?.id ?? null\r\n\t\t}\r\n\t\tif (!id) throw new Error('Could not open a cart on this store.')\r\n\r\n\t\tconst name =\r\n\t\t\t[shippingAddress?.firstName, shippingAddress?.lastName].filter(Boolean).join(' ').trim() ||\r\n\t\t\t[billingAddress?.firstName, billingAddress?.lastName].filter(Boolean).join(' ').trim() ||\r\n\t\t\tundefined\r\n\r\n\t\twriteCheckoutDetails(id, {\r\n\t\t\t...(email ? { email } : {}),\r\n\t\t\t...(phone || shippingAddress?.phone ? { phone: phone || shippingAddress?.phone } : {}),\r\n\t\t\t...(name ? { name } : {}),\r\n\t\t\t...(shippingAddress ? { shippingAddress } : {}),\r\n\t\t\t...(billingAddress && !isBillingAddressSameAsShipping ? { billingAddress } : shippingAddress ? { billingAddress: shippingAddress } : {})\r\n\t\t})\r\n\r\n\t\treturn this.present(cart)\r\n\t}\r\n\r\n\t/** Nothing to reserve ahead of payment: `POST /api/checkout/{code}` is one transaction. */\r\n\tasync completeCart(cartId: string) {\r\n\t\treturn this.getCartByCartId(cartId)\r\n\t}\r\n\r\n\t/** Remembered so the payment step can re-select it; GoCommerce takes the code at checkout. */\r\n\tasync updateCartPaymentMethod({ cartId, paymentMethod }: { cartId?: string | null; paymentMethod?: string }) {\r\n\t\tconst id = usableId(cartId) || readStoredCartId()\r\n\t\tif (!id) return {}\r\n\t\tconst cart = await this.readCart(id)\r\n\t\tconst presented = (await this.present(cart)) as Record<string, unknown>\r\n\t\tif (presented && paymentMethod) presented.paymentMethod = paymentMethod\r\n\t\treturn presented\r\n\t}\r\n\r\n\t// GoCommerce has no discount engine, so there is no code to accept. Saying so beats a silent\r\n\t// no-op that leaves the shopper waiting for a discount that is never coming.\r\n\tasync applyCoupon(_params: { cartId?: string | null; couponCode?: string }): Promise<never> {\r\n\t\tthrow new Error('Discount codes are not available on this store.')\r\n\t}\r\n\r\n\tasync removeCoupon() {\r\n\t\treturn this.fetchCartData()\r\n\t}\r\n\r\n\t/** Shipping is priced by the store at checkout; there are no rates for a shopper to choose. */\r\n\tasync updateShippingRate({ cartId }: { cartId?: string | null; shippingRateId?: string }) {\r\n\t\treturn this.getCartByCartId(cartId || '')\r\n\t}\r\n}\r\n\r\nexport const cartService = CartService.getInstance()\r\n","// Checkout and payment methods.\r\n//\r\n// `POST /api/checkout/{code}` is the whole thing: it validates the cart, reserves inventory and\r\n// creates the order in one transaction, then starts payment outside it. There is no multi-step\r\n// checkout object to build up first — which is why the address step's answers are carried in\r\n// checkout-details.ts and spent here.\r\n\r\nimport { BaseService } from './base'\r\nimport { cartService } from './cart'\r\nimport { clearCheckoutDetails, readCheckoutDetails, rememberOrderToken } from './checkout-details'\r\nimport { mapOrder, toGoCommerceAddress } from './mappers'\r\nimport { resolveProductIndex } from './catalog'\r\nimport type { GcCheckoutMethods, GcCheckoutResult } from './types'\r\n\r\nconst CART_ID_KEY = 'cart_id'\r\n\r\nconst readStoredCartId = (): string | null => {\r\n\ttry {\r\n\t\treturn typeof window !== 'undefined' ? window.localStorage?.getItem(CART_ID_KEY) || null : null\r\n\t} catch {\r\n\t\treturn null\r\n\t}\r\n}\r\n\r\n/** A shopper-readable name for a payment code the store installed. */\r\nconst METHOD_NAMES: Record<string, string> = {\r\n\tcod: 'Cash on delivery',\r\n\tstripe: 'Card',\r\n\trazorpay: 'Razorpay',\r\n\tcashfree: 'Cashfree',\r\n\tpaypal: 'PayPal',\r\n\tphonepe: 'PhonePe',\r\n\tmanual: 'Manual payment'\r\n}\r\n\r\n/** The codes GoCommerce reported, so a checkout call can send back the exact spelling. */\r\nlet installedCodes: string[] = []\r\n\r\nconst goCommerceCode = (storefrontCode: string): string => {\r\n\tconst match = installedCodes.find((code) => code.toLowerCase() === storefrontCode.toLowerCase())\r\n\treturn match || storefrontCode.toLowerCase()\r\n}\r\n\r\nconst titleCase = (code: string) => code.charAt(0).toUpperCase() + code.slice(1)\r\n\r\nexport class PaymentMethodService extends BaseService {\r\n\tprivate static instance: PaymentMethodService\r\n\r\n\tstatic getInstance(): PaymentMethodService {\r\n\t\tif (!PaymentMethodService.instance) PaymentMethodService.instance = new PaymentMethodService()\r\n\t\treturn PaymentMethodService.instance\r\n\t}\r\n\r\n\t/**\r\n\t * What this store accepts, from `GET /api/checkout`.\r\n\t *\r\n\t * The storefront branches on an uppercase code (`COD`, `STRIPE`, …) while GoCommerce installs\r\n\t * them lowercase, so the code is uppercased for the UI and the original kept for the API call.\r\n\t */\r\n\tasync list(_params: { page?: number; q?: string; sort?: string } = {}) {\r\n\t\tconst res = await this.api<GcCheckoutMethods>('GET', '/api/checkout')\r\n\t\tconst codes = res.data?.payment_methods || []\r\n\t\tinstalledCodes = codes\r\n\t\tconst data = codes.map((code, index) => ({\r\n\t\t\tid: code,\r\n\t\t\tcode: code.toUpperCase(),\r\n\t\t\tname: METHOD_NAMES[code.toLowerCase()] || titleCase(code),\r\n\t\t\tdescription: '',\r\n\t\t\tactive: true,\r\n\t\t\tisTest: false,\r\n\t\t\timg: null,\r\n\t\t\trank: index,\r\n\t\t\tcurrency: res.data?.currency || null\r\n\t\t}))\r\n\t\treturn { data, count: data.length, pageSize: data.length, noOfPage: data.length ? 1 : 0, page: 1 }\r\n\t}\r\n}\r\n\r\nexport const paymentMethodService = PaymentMethodService.getInstance()\r\n\r\nexport class CheckoutService extends BaseService {\r\n\tprivate static instance: CheckoutService\r\n\r\n\tstatic getInstance(): CheckoutService {\r\n\t\tif (!CheckoutService.instance) CheckoutService.instance = new CheckoutService()\r\n\t\treturn CheckoutService.instance\r\n\t}\r\n\r\n\t/**\r\n\t * Places the order.\r\n\t *\r\n\t * Everything the API requires and the cart cannot hold — email, name, phone, delivery address —\r\n\t * comes from what the address step recorded against this cart. Missing pieces are named in the\r\n\t * error rather than sent as blanks, because GoCommerce's own validation message (\"address.line1\r\n\t * is required\") does not tell a shopper which screen to go back to.\r\n\t */\r\n\tprivate async place(storefrontCode: string, { cartId, origin, returnUrl }: { cartId?: string | null; origin?: string; returnUrl?: string }) {\r\n\t\tconst id = cartId && cartId !== 'undefined' ? cartId : readStoredCartId()\r\n\t\tif (!id) throw new Error('There is no cart to check out.')\r\n\r\n\t\tconst details = readCheckoutDetails(id)\r\n\t\tconst address = toGoCommerceAddress(details.shippingAddress, details.phone)\r\n\r\n\t\tif (!details.email) throw new Error('An email address is required to place this order — add one at the address step.')\r\n\t\tif (!address) throw new Error('A complete delivery address is required to place this order — add one at the address step.')\r\n\r\n\t\tconst code = goCommerceCode(storefrontCode)\r\n\t\tlet res\r\n\t\ttry {\r\n\t\t\tres = await this.api<GcCheckoutResult>(\r\n\t\t\t\t'POST',\r\n\t\t\t\t`/api/checkout/${encodeURIComponent(code)}`,\r\n\t\t\t\t{\r\n\t\t\t\t\tcart_id: id,\r\n\t\t\t\t\temail: details.email,\r\n\t\t\t\t\t...(details.name ? { name: details.name } : {}),\r\n\t\t\t\t\t...(details.phone ? { phone: details.phone } : {}),\r\n\t\t\t\t\taddress,\r\n\t\t\t\t\t...(returnUrl || origin ? { return_url: returnUrl || `${origin}/checkout/process` } : {})\r\n\t\t\t\t},\r\n\t\t\t\t// A double-submitted Place Order must not become two orders and two inventory holds.\r\n\t\t\t\t{ 'Idempotency-Key': `${id}:${code}` }\r\n\t\t\t)\r\n\t\t} catch (error) {\r\n\t\t\t// A dead cart and an unknown payment code are both reported as `404 not_found` here, so the\r\n\t\t\t// cart is re-read rather than the message matched. \"cart not found\" at the last step tells a\r\n\t\t\t// shopper nothing they can act on; naming the expiry, and what to do about it, does.\r\n\t\t\tif (await cartService.cartIsSpent(id)) {\r\n\t\t\t\tthrow new Error('This cart is no longer available — it has expired or was already checked out. Add the items to a new bag and try again.')\r\n\t\t\t}\r\n\t\t\tthrow error\r\n\t\t}\r\n\r\n\t\tconst order = res.data?.order\r\n\t\tconst payment = res.data?.payment\r\n\t\trememberOrderToken(order?.number, order?.access_token)\r\n\t\t// The cart is converted now; its address is spent and must not seed the next one.\r\n\t\tclearCheckoutDetails(id)\r\n\r\n\t\tconst index = await resolveProductIndex(\r\n\t\t\t(order?.line_items || []).map((line) => line.product_id),\r\n\t\t\tthis.getFetch()\r\n\t\t)\r\n\r\n\t\treturn {\r\n\t\t\t...(mapOrder(order, index) ?? {}),\r\n\t\t\t// The order number, under every name the storefront's payment step reads it by.\r\n\t\t\torder_no: order?.number,\r\n\t\t\torderNo: order?.number,\r\n\t\t\tcode: order?.number,\r\n\t\t\tpayment: payment ?? null,\r\n\t\t\tpaymentKind: payment?.kind ?? 'none',\r\n\t\t\t// A gateway's own fields (a Razorpay order id, a Stripe client secret, a redirect url)\r\n\t\t\t// ride on `client_data`; spreading them is what lets the storefront's per-gateway\r\n\t\t\t// branches find what they look for without this connector naming each gateway.\r\n\t\t\t...(payment?.client_data ?? {})\r\n\t\t}\r\n\t}\r\n\r\n\tasync checkoutCOD({ cartId, origin }: { cartId?: string | null; origin?: string }) {\r\n\t\treturn this.place('cod', { cartId, origin })\r\n\t}\r\n\r\n\tasync checkoutPOS({ cartId, origin }: { cartId?: string | null; origin?: string }) {\r\n\t\treturn this.place('pos', { cartId, origin })\r\n\t}\r\n\r\n\tasync checkoutRazorpay({ cartId, origin }: { cartId?: string | null; origin?: string }) {\r\n\t\treturn this.place('razorpay', { cartId, origin })\r\n\t}\r\n\r\n\tasync checkoutStripe({ cartId, origin }: { cartId?: string | null; origin?: string }) {\r\n\t\treturn this.place('stripe', { cartId, origin })\r\n\t}\r\n\r\n\tasync checkoutCashfree({ cartId, origin }: { cartId?: string | null; email?: string; origin?: string }) {\r\n\t\treturn this.place('cashfree', { cartId, origin })\r\n\t}\r\n\r\n\tasync checkoutPaypal({ cartId, origin, return_url }: { cartId?: string | null; origin?: string; return_url?: string }) {\r\n\t\treturn this.place('paypal', { cartId, origin, returnUrl: return_url })\r\n\t}\r\n\r\n\tasync checkoutPhonepe({ cartId, origin }: { cartId?: string | null; email?: string; phone?: string; origin?: string }) {\r\n\t\treturn this.place('phonepe', { cartId, origin })\r\n\t}\r\n\r\n\tasync createAffirmPayOrder({\r\n\t\tcartId,\r\n\t\torigin\r\n\t}: {\r\n\t\tcartId?: string | null\r\n\t\torigin?: string\r\n\t\taddressId?: string\r\n\t\tstoreId?: string\r\n\t\tpaymentMethodId?: string\r\n\t}) {\r\n\t\treturn this.place('affirm', { cartId, origin })\r\n\t}\r\n\r\n\t// GoCommerce reconciles a payment through `POST /api/checkout/{code}/webhook`, which the gateway\r\n\t// calls server to server. There is nothing for the browser to capture afterwards, so these keep\r\n\t// the storefront's redirect moving with the order number it already has rather than pretending\r\n\t// to perform a capture that this API does not offer.\r\n\tprivate settled(orderNo?: string) {\r\n\t\treturn { order_no: orderNo || '', orderNo: orderNo || '', captured: false }\r\n\t}\r\n\r\n\tasync captureRazorpayPayment({ razorpay_order_id }: { razorpay_order_id?: string; razorpay_payment_id?: string }) {\r\n\t\treturn this.settled(razorpay_order_id)\r\n\t}\r\n\r\n\tasync capturePhonepePayment({ phonepe_order_id }: { phonepe_order_id?: string; phonepe_payment_id?: string }) {\r\n\t\treturn this.settled(phonepe_order_id)\r\n\t}\r\n\r\n\tasync captureCashfreePayment({ order_no }: { order_no?: string }) {\r\n\t\treturn this.settled(order_no)\r\n\t}\r\n\r\n\tasync checkoutStripeCapture({ order_no }: { order_no?: string; pg?: string; payment_session_id?: string; storeId?: string }) {\r\n\t\treturn this.settled(order_no)\r\n\t}\r\n\r\n\tasync confirmAffirmOrder({ orderId }: { affirmToken?: string; orderId?: string; storeId?: string; origin?: string }) {\r\n\t\treturn this.settled(orderId)\r\n\t}\r\n\r\n\tasync cancelAffirmOrder({ orderId }: { orderId?: string; storeId?: string; origin?: string }): Promise<never> {\r\n\t\tthrow new Error(`Cancelling order ${orderId || ''} is not available on this store.`)\r\n\t}\r\n\r\n\t/**\r\n\t * GoCommerce prices shipping when it creates the order — there is no rate list for a shopper to\r\n\t * choose from. An empty list is the accurate answer, and the payment step renders no rate picker\r\n\t * for it rather than an empty one.\r\n\t */\r\n\tasync getShippingRates(_params: { cartId?: string | null }) {\r\n\t\treturn { message: 'This store does not offer selectable shipping rates', success: true, error: null, data: [] }\r\n\t}\r\n}\r\n\r\nexport const checkoutService = CheckoutService.getInstance()\r\n","// Orders.\r\n//\r\n// Guest checkout is permanent in GoCommerce: there is no account, and the order's access token —\r\n// returned once at checkout — is the credential that reads it back. This browser holds those\r\n// tokens (checkout-details.ts), which is what makes \"my orders\" work at all here.\r\n//\r\n// The confirmation page is the exception, because it renders on the server, where no token exists.\r\n// It arrives with `cart_id` in the url, and a converted cart stays readable by its own token, so\r\n// the order is reconstructed from the cart that became it. The number comes from the url; the items\r\n// and totals come from the cart — all of it the shopper's own data, reached with the shopper's own\r\n// credential.\r\n\r\nimport { BaseService } from './base'\r\nimport { resolveProductIndex } from './catalog'\r\nimport { readOrderNumbers, readOrderToken } from './checkout-details'\r\nimport { PAGE_SIZE, absoluteMedia, emptyPage, mapOrder, mapProduct, paginated } from './mappers'\r\nimport { fromMoney } from './money'\r\nimport type { GcCart, GcOrder } from './types'\r\n\r\nconst usable = (value?: string | null) => (value && value !== 'undefined' && value !== 'null' ? value : null)\r\n\r\nexport class OrderService extends BaseService {\r\n\tprivate static instance: OrderService\r\n\r\n\tstatic getInstance(): OrderService {\r\n\t\tif (!OrderService.instance) OrderService.instance = new OrderService()\r\n\t\treturn OrderService.instance\r\n\t}\r\n\r\n\tprivate async readOrder(orderNumber: string, token: string): Promise<GcOrder | null> {\r\n\t\ttry {\r\n\t\t\tconst res = await this.api<GcOrder>('GET', `/api/orders/${encodeURIComponent(orderNumber)}?token=${encodeURIComponent(token)}`)\r\n\t\t\treturn res.data ?? null\r\n\t\t} catch {\r\n\t\t\t// A wrong or missing token is reported as not found, so this cannot be used to discover\r\n\t\t\t// which order numbers exist. Nothing to show is the correct outcome either way.\r\n\t\t\treturn null\r\n\t\t}\r\n\t}\r\n\r\n\tprivate async present(order: GcOrder | null) {\r\n\t\tif (!order) return null\r\n\t\tconst index = await resolveProductIndex(\r\n\t\t\t(order.line_items || []).map((line) => line.product_id),\r\n\t\t\tthis.getFetch()\r\n\t\t)\r\n\t\treturn mapOrder(order, index)\r\n\t}\r\n\r\n\t/**\r\n\t * The confirmation view, rebuilt from the cart that became the order.\r\n\t *\r\n\t * Everything a receipt needs is on the converted cart except the address, which was never stored\r\n\t * on it — so that block is simply absent rather than invented.\r\n\t */\r\n\tprivate async orderFromCart(cartId: string, orderNumber: string) {\r\n\t\tlet cart: GcCart | null = null\r\n\t\ttry {\r\n\t\t\tconst res = await this.api<GcCart>('GET', `/api/carts/${encodeURIComponent(cartId)}`)\r\n\t\t\tcart = res.data ?? null\r\n\t\t} catch {\r\n\t\t\treturn null\r\n\t\t}\r\n\t\tif (!cart) return null\r\n\r\n\t\tconst lines = cart.line_items || []\r\n\t\tconst index = await resolveProductIndex(\r\n\t\t\tlines.map((line) => line.product_id),\r\n\t\t\tthis.getFetch()\r\n\t\t)\r\n\t\tconst subtotal = fromMoney(cart.subtotal)\r\n\r\n\t\treturn {\r\n\t\t\tid: null,\r\n\t\t\torderNo: orderNumber,\r\n\t\t\torder_no: orderNumber,\r\n\t\t\tparentOrderNo: orderNumber,\r\n\t\t\tstatus: cart.status === 'converted' ? 'confirmed' : 'pending',\r\n\t\t\tpaymentStatus: 'pending',\r\n\t\t\tpaymentMethod: null,\r\n\t\t\tcreatedAt: cart.updated_at || cart.created_at || null,\r\n\t\t\tupdatedAt: cart.updated_at || null,\r\n\t\t\tuserEmail: cart.email || '',\r\n\t\t\tphone: '',\r\n\t\t\tsubtotal,\r\n\t\t\tshippingCharges: 0,\r\n\t\t\tdiscount: 0,\r\n\t\t\ttotal: subtotal,\r\n\t\t\tcurrencyCode: cart.currency,\r\n\t\t\tshippingRate: null,\r\n\t\t\tfulfillments: [],\r\n\t\t\tshippingAddress: null,\r\n\t\t\tbillingAddress: null,\r\n\t\t\tlineItems: lines.map((line) => {\r\n\t\t\t\tconst product = line.product_id == null ? undefined : index.get(line.product_id)\r\n\t\t\t\tconst mapped = product ? mapProduct(product) : null\r\n\t\t\t\tconst variant = product?.variants?.find((v) => v.id === line.variant_id)\r\n\t\t\t\treturn {\r\n\t\t\t\t\tid: line.id,\r\n\t\t\t\t\tproductId: line.product_id,\r\n\t\t\t\t\tvariantId: line.variant_id,\r\n\t\t\t\t\ttitle: line.title || mapped?.title || '',\r\n\t\t\t\t\tvariantTitle: line.variant_label || line.sku || '',\r\n\t\t\t\t\tslug: mapped?.slug || '',\r\n\t\t\t\t\tsku: line.sku || '',\r\n\t\t\t\t\tthumbnail: absoluteMedia(variant?.image?.url) || mapped?.thumbnail || null,\r\n\t\t\t\t\tqty: line.quantity,\r\n\t\t\t\t\tprice: fromMoney(line.unit_price),\r\n\t\t\t\t\tsubtotal: fromMoney(line.total),\r\n\t\t\t\t\ttotal: fromMoney(line.total)\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * The shopper's orders. Without an account there is no server-side list to ask for, so this is\r\n\t * every order placed from this browser, newest first — which is exactly what it can know.\r\n\t */\r\n\tasync list({ page = 1 }: { page?: number; q?: string; sort?: string } = {}) {\r\n\t\tconst numbers = readOrderNumbers().reverse()\r\n\t\tif (!numbers.length) return emptyPage(page)\r\n\t\tconst start = (page - 1) * PAGE_SIZE\r\n\t\tconst window = numbers.slice(start, start + PAGE_SIZE)\r\n\t\tconst orders = await Promise.all(\r\n\t\t\twindow.map(async (number) => {\r\n\t\t\t\tconst token = readOrderToken(number)\r\n\t\t\t\treturn token ? this.present(await this.readOrder(number, token)) : null\r\n\t\t\t})\r\n\t\t)\r\n\t\treturn paginated(orders.filter(Boolean), numbers.length, page)\r\n\t}\r\n\r\n\t/** What the confirmation page loads with, server-side, straight after checkout. */\r\n\tasync listOrdersByParent({ orderNo, cartId }: { orderNo?: string | null; cartId?: string | null }) {\r\n\t\tconst number = usable(orderNo)\r\n\t\tif (!number) return emptyPage()\r\n\r\n\t\tconst token = readOrderToken(number)\r\n\t\tif (token) {\r\n\t\t\tconst order = await this.present(await this.readOrder(number, token))\r\n\t\t\tif (order) return paginated([order], 1, 1, 1)\r\n\t\t}\r\n\r\n\t\tconst cart = usable(cartId)\r\n\t\tif (cart) {\r\n\t\t\tconst reconstructed = await this.orderFromCart(cart, number)\r\n\t\t\tif (reconstructed) return paginated([reconstructed], 1, 1, 1)\r\n\t\t}\r\n\r\n\t\treturn emptyPage()\r\n\t}\r\n\r\n\tasync getOrder(orderNo: string) {\r\n\t\tconst number = usable(orderNo)\r\n\t\tif (!number) return {}\r\n\t\tconst token = readOrderToken(number)\r\n\t\tif (!token) return {}\r\n\t\treturn (await this.present(await this.readOrder(number, token))) ?? {}\r\n\t}\r\n\r\n\tasync fetchOrder(id: string) {\r\n\t\treturn this.getOrder(id)\r\n\t}\r\n\r\n\tasync fetchTrackOrder(id: string) {\r\n\t\treturn this.listOrdersByParent({ orderNo: id, cartId: null })\r\n\t}\r\n\r\n\tasync paySuccessPageHit(orderId: string) {\r\n\t\treturn this.getOrder(orderId)\r\n\t}\r\n\r\n\t// GoCommerce has no email+OTP lookup: an order is reached by its number and access token.\r\n\tasync getOrderByEmailAndOTP(_params: { email?: string; otp?: string }) {\r\n\t\treturn emptyPage()\r\n\t}\r\n\r\n\t// No server-side order feed exists to reorder from; `list()` is the shopper's own history.\r\n\tasync buyAgain() {\r\n\t\treturn emptyPage()\r\n\t}\r\n\r\n\tasync listPublic() {\r\n\t\treturn emptyPage()\r\n\t}\r\n\r\n\tasync submitReview(_params: unknown): Promise<never> {\r\n\t\tthrow new Error('Product reviews are not available on this store.')\r\n\t}\r\n\r\n\t// Checkout runs through CheckoutService here; these Litekart-era entry points have no equivalent\r\n\t// and must not fall back to an API a GoCommerce store does not run.\r\n\tasync codCheckout(_params: unknown): Promise<never> {\r\n\t\tthrow new Error('Use checkoutService.checkoutCOD() on GoCommerce.')\r\n\t}\r\n\r\n\tasync razorpayCheckout(_params: unknown): Promise<never> {\r\n\t\tthrow new Error('Use checkoutService.checkoutRazorpay() on GoCommerce.')\r\n\t}\r\n\r\n\tasync stripeCheckout(_params: unknown): Promise<never> {\r\n\t\tthrow new Error('Use checkoutService.checkoutStripe() on GoCommerce.')\r\n\t}\r\n\r\n\tasync cashfreeCheckout(_params: unknown): Promise<never> {\r\n\t\tthrow new Error('Use checkoutService.checkoutCashfree() on GoCommerce.')\r\n\t}\r\n\r\n\tasync razorCapture(_params: unknown): Promise<never> {\r\n\t\tthrow new Error('Use checkoutService.captureRazorpayPayment() on GoCommerce.')\r\n\t}\r\n}\r\n\r\nexport const orderService = OrderService.getInstance()\r\n","// Store identity and the settings that hang off it.\n//\n// GoCommerce is a commerce engine, not a CMS: it has no store record, no menus, no country list and\n// no plugin toggles. All of that is the storefront's own configuration, registered through\n// static-store.ts (default-store.json merged under the kitcommerce.config.ts default export), and\n// these services read it from there rather than asking an API that has no such endpoint.\n\nimport { BaseService } from './base'\nimport { PAGE_SIZE, paginated } from './mappers'\nimport { readStaticStore, readStaticStoreDetails } from './static-store'\n\nconst listOf = <T>(items: T[]) => paginated(items, items.length, 1, items.length || PAGE_SIZE)\n\nexport class StoreService extends BaseService {\n\tprivate static instance: StoreService\n\n\tstatic getInstance(): StoreService {\n\t\tif (!StoreService.instance) StoreService.instance = new StoreService()\n\t\treturn StoreService.instance\n\t}\n\n\tasync getStoreByIdOrDomain(_params: { storeId?: string; domain?: string } = {}) {\n\t\tconst store = await readStaticStoreDetails()\n\t\tif (!store) {\n\t\t\tthrow new Error('No store configuration is registered — check kitcommerce.config.ts (see docs/GOCOMMERCE.md).')\n\t\t}\n\t\treturn store\n\t}\n\n\t/** The settings store asks for the record by id; there is only ever the configured one. */\n\tasync getStore(_storeId?: string) {\n\t\treturn this.getStoreByIdOrDomain({})\n\t}\n}\n\nexport const storeService = StoreService.getInstance()\n\nexport class MenuService extends BaseService {\n\tprivate static instance: MenuService\n\n\tstatic getInstance(): MenuService {\n\t\tif (!MenuService.instance) MenuService.instance = new MenuService()\n\t\treturn MenuService.instance\n\t}\n\n\t/** The nav reads `response.data` and filters it on `menuId`, the way the Litekart API served it. */\n\tasync list() {\n\t\tconst store = await readStaticStore()\n\t\treturn { data: (store?.menu ?? []) as unknown[] }\n\t}\n}\n\nexport const menuService = MenuService.getInstance()\n\nexport class CountryService extends BaseService {\n\tprivate static instance: CountryService\n\n\tstatic getInstance(): CountryService {\n\t\tif (!CountryService.instance) CountryService.instance = new CountryService()\n\t\treturn CountryService.instance\n\t}\n\n\t/** The address form's country dropdown. Empty here means a shopper cannot enter an address. */\n\tasync list() {\n\t\tconst store = await readStaticStore()\n\t\treturn listOf((store?.countries ?? []) as unknown[])\n\t}\n}\n\nexport const countryService = CountryService.getInstance()\n\nexport class StateService extends BaseService {\n\tprivate static instance: StateService\n\n\tstatic getInstance(): StateService {\n\t\tif (!StateService.instance) StateService.instance = new StateService()\n\t\treturn StateService.instance\n\t}\n\n\t// No state list ships with the store record, and GoCommerce takes the state as free text.\n\tasync list() {\n\t\treturn listOf([])\n\t}\n}\n\nexport const stateService = StateService.getInstance()\n\nexport class CurrencyService extends BaseService {\n\tprivate static instance: CurrencyService\n\n\tstatic getInstance(): CurrencyService {\n\t\tif (!CurrencyService.instance) CurrencyService.instance = new CurrencyService()\n\t\treturn CurrencyService.instance\n\t}\n\n\t/** One currency: GoCommerce prices a store in the currency its catalogue is recorded in. */\n\tasync listCurrencies() {\n\t\tconst store = await readStaticStore()\n\t\treturn listOf(store?.currency ? [store.currency] : [])\n\t}\n}\n\nexport const currencyService = CurrencyService.getInstance()\n\nexport class RegionService extends BaseService {\n\tprivate static instance: RegionService\n\n\tstatic getInstance(): RegionService {\n\t\tif (!RegionService.instance) RegionService.instance = new RegionService()\n\t\treturn RegionService.instance\n\t}\n\n\t// GoCommerce has no regions; one store, one currency, one price list.\n\tasync getRegionByRegionId(_id: string) {\n\t\treturn {}\n\t}\n}\n\nexport const regionService = RegionService.getInstance()\n\nexport class PluginService extends BaseService {\n\tprivate static instance: PluginService\n\n\tstatic getInstance(): PluginService {\n\t\tif (!PluginService.instance) PluginService.instance = new PluginService()\n\t\treturn PluginService.instance\n\t}\n\n\tasync list(_params: { page?: number; q?: string; sort?: string } = {}) {\n\t\tconst store = await readStaticStore()\n\t\treturn listOf((store?.plugins ?? []) as unknown[])\n\t}\n}\n\nexport const pluginService = PluginService.getInstance()\nexport const pluginsService = pluginService\n\nexport class SettingService extends BaseService {\n\tprivate static instance: SettingService\n\n\tstatic getInstance(): SettingService {\n\t\tif (!SettingService.instance) SettingService.instance = new SettingService()\n\t\treturn SettingService.instance\n\t}\n\n\tasync fetchSetting() {\n\t\tconst store = await readStaticStore()\n\t\treturn store ? [store] : []\n\t}\n\n\t// Settings are the storefront's own configuration; a storefront must not write them back.\n\tasync saveSettings(_setting: unknown): Promise<never> {\n\t\tthrow new Error('Store settings are configured in kitcommerce.config.ts, not from the storefront.')\n\t}\n\n\tasync updateSettings(_id: string, _setting: unknown): Promise<never> {\n\t\tthrow new Error('Store settings are configured in kitcommerce.config.ts, not from the storefront.')\n\t}\n}\n\nexport const settingService = SettingService.getInstance()\nexport const settingsService = settingService\n\nexport class InitService extends BaseService {\n\tprivate static instance: InitService\n\n\tstatic getInstance(): InitService {\n\t\tif (!InitService.instance) InitService.instance = new InitService()\n\t\treturn InitService.instance\n\t}\n\n\tasync fetchInit() {\n\t\tconst store = await readStaticStore()\n\t\treturn store ? [store] : []\n\t}\n}\n\nexport const initService = InitService.getInstance()\n\nexport class HomeService extends BaseService {\n\tprivate static instance: HomeService\n\n\tstatic getInstance(): HomeService {\n\t\tif (!HomeService.instance) HomeService.instance = new HomeService()\n\t\treturn HomeService.instance\n\t}\n\n\t// The homepage is composed from the storefront's own blocks; GoCommerce stores no page layouts.\n\tasync getHome() {\n\t\treturn [] as unknown[]\n\t}\n}\n\nexport const homeService = HomeService.getInstance()\n\nexport class PopularSearchService extends BaseService {\n\tprivate static instance: PopularSearchService\n\n\tstatic getInstance(): PopularSearchService {\n\t\tif (!PopularSearchService.instance) PopularSearchService.instance = new PopularSearchService()\n\t\treturn PopularSearchService.instance\n\t}\n\n\t// GoCommerce records no search analytics, so there are no popular searches to report.\n\tasync listPopularSearch(_params: { page?: number; q?: string; sort?: string } = {}) {\n\t\treturn listOf([])\n\t}\n}\n\nexport const popularSearchService = PopularSearchService.getInstance()\n\nexport class PopularityService extends BaseService {\n\tprivate static instance: PopularityService\n\n\tstatic getInstance(): PopularityService {\n\t\tif (!PopularityService.instance) PopularityService.instance = new PopularityService()\n\t\treturn PopularityService.instance\n\t}\n\n\t/** Nothing to record against: a view counter is not part of this API. Accepted and dropped. */\n\tasync updatePopularity(_params: { product_id?: string; sid?: string } = {}) {\n\t\treturn { success: true }\n\t}\n}\n\nexport const popularityService = PopularityService.getInstance()\n","// What GoCommerce deliberately does not have.\n//\n// It is a commerce engine: catalogue, cart, checkout, orders. There are no shopper accounts (guest\n// checkout is permanent by design), no CMS, no reviews, no wishlist, no marketplace vendors.\n//\n// The rule these follow is the one rest-guard.ts states: a collection resolves empty, because an\n// empty list is a legitimate state a page can render; a single record and every write throw, because\n// a blank detail page reads as broken and a silent success would tell the shopper their review,\n// enquiry or upload was saved when nothing left the browser.\n\nimport { BaseService } from './base'\nimport { PAGE_SIZE, emptyPage, paginated } from './mappers'\nimport { clearPhantomSession, findAddress, listAddresses, patchAddress, putAddress, removeAddress } from './address-book'\n\nconst unavailable = (what: string) => new Error(`${what} is not available on this store.`)\n\nconst singleton = <T>(Ctor: new () => T) => {\n\tlet instance: T | undefined\n\treturn () => (instance ??= new Ctor())\n}\n\n// --- Accounts -----------------------------------------------------------------------------------\n// Guest checkout is permanent in GoCommerce: a shopper needs a cart token and an email, never an\n// account. The API's only credentials are the admin ones, which a storefront must never hold.\n\nconst NO_ACCOUNTS = 'Accounts are not available on this store — checkout does not need one'\n\nexport class UserService extends BaseService {\n\tstatic getInstance = singleton(UserService)\n\n\t/** No session to report. `null` is what the header and guards check for. */\n\tasync getMe() {\n\t\treturn null\n\t}\n\n\tasync getUser(_id: string) {\n\t\treturn null\n\t}\n\n\tasync login(_params: unknown): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}.`)\n\t}\n\n\tasync signup(_params: unknown): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}.`)\n\t}\n\n\tasync joinAsVendor(_params: unknown): Promise<never> {\n\t\tthrow unavailable('Vendor signup')\n\t}\n\n\tasync forgotPassword(_params: unknown): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}.`)\n\t}\n\n\tasync resetPassword(_params: unknown): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}.`)\n\t}\n\n\tasync changePassword(_params: unknown): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}.`)\n\t}\n\n\tasync getOtp(_params: unknown): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}.`)\n\t}\n\n\tasync verifyOtp(_params: unknown): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}.`)\n\t}\n\n\tasync updateProfile(_params: unknown): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}.`)\n\t}\n\n\tasync checkEmail(_email: string) {\n\t\t// Nothing to collide with, so every address is free to use at checkout.\n\t\treturn { exists: false }\n\t}\n\n\tasync deleteUser(_id: string): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}.`)\n\t}\n\n\t/**\n\t * Clears the session this storefront thinks it has.\n\t *\n\t * There is no session on GoCommerce to end, so it would be easy to make this a no-op — and that\n\t * is a trap. The shared user store decides who is signed in by reading the `connect.sid` and `me`\n\t * cookies straight from `document.cookie`, not by asking a service. A pair left behind by running\n\t * this storefront against a backend that does have accounts therefore makes GoCommerce look\n\t * signed-in, which sends the checkout down the saved-address path instead of the guest one. The\n\t * checkout page already knows to call `logout()` and retry when that happens — so this has to\n\t * actually clear them, or that recovery does nothing.\n\t */\n\tasync logout() {\n\t\tclearPhantomSession()\n\t\treturn { success: true }\n\t}\n}\n\nexport const userService = UserService.getInstance()\n\nexport class AuthService extends UserService {\n\tstatic getInstance = singleton(AuthService)\n\n\tasync verifyEmail(_email: string, _token: string): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}, so there is no address to verify.`)\n\t}\n\n\tasync joinAsAdmin(_params: unknown): Promise<never> {\n\t\tthrow unavailable('Admin signup')\n\t}\n}\n\nexport const authService = AuthService.getInstance()\n\nexport class ProfileService extends BaseService {\n\tstatic getInstance = singleton(ProfileService)\n\n\tasync getOne() {\n\t\treturn null\n\t}\n\n\tasync save(_profile: unknown): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}.`)\n\t}\n}\n\nexport const profileService = ProfileService.getInstance()\n\n/**\n * The saved-address book. GoCommerce has none, so it is kept in this browser — see\n * ./address-book.ts for why refusing the write is not an option.\n */\nexport class AddressService extends BaseService {\n\tstatic getInstance = singleton(AddressService)\n\n\tasync list(params: { page?: number } = {}) {\n\t\tconst addresses = listAddresses()\n\t\tconst page = Math.max(1, Number(params.page || 1) || 1)\n\t\tconst start = (page - 1) * PAGE_SIZE\n\t\treturn paginated(addresses.slice(start, start + PAGE_SIZE), addresses.length, page)\n\t}\n\n\tasync fetchAddress(id: string) {\n\t\tconst address = findAddress(id)\n\t\tif (!address) throw new Error('That address is no longer saved on this device.')\n\t\treturn address\n\t}\n\n\tasync saveAddress(address: Record<string, unknown>) {\n\t\treturn putAddress(address)\n\t}\n\n\tasync editAddress(id: string, address: Record<string, unknown>) {\n\t\tconst saved = patchAddress(id, address)\n\t\tif (!saved) throw new Error('That address is no longer saved on this device.')\n\t\treturn saved\n\t}\n\n\tasync deleteAddress(id: string) {\n\t\tremoveAddress(id)\n\t}\n}\n\nexport const addressService = AddressService.getInstance()\n\n// --- Merchandising extras -----------------------------------------------------------------------\n\nexport class WishlistService extends BaseService {\n\tstatic getInstance = singleton(WishlistService)\n\n\tasync fetchWishlist(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n\n\tasync checkWishlist(_params: unknown = {}) {\n\t\treturn { data: false }\n\t}\n\n\t/** The product grid asks about many ids at once; nothing is on a list that cannot exist. */\n\tasync checkWishlistInBulk(_ids: unknown) {\n\t\treturn { data: [] }\n\t}\n\n\tasync toggleWishlist(_params: unknown): Promise<never> {\n\t\tthrow unavailable('Wishlists')\n\t}\n}\n\nexport const wishlistService = WishlistService.getInstance()\n\nexport class CouponService extends BaseService {\n\tstatic getInstance = singleton(CouponService)\n\n\t// No discount engine, so the payment step renders no coupon box rather than an empty one.\n\tasync listCoupons(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n\n\tasync searchCoupons(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n\n\tasync getCoupon(_id: string): Promise<never> {\n\t\tthrow unavailable('Discount codes')\n\t}\n\n\tasync createCoupon(_coupon: unknown): Promise<never> {\n\t\tthrow unavailable('Discount codes')\n\t}\n\n\tasync patchCoupon(_id: string, _coupon: unknown): Promise<never> {\n\t\tthrow unavailable('Discount codes')\n\t}\n\n\tasync deleteCoupon(_id: string): Promise<never> {\n\t\tthrow unavailable('Discount codes')\n\t}\n}\n\nexport const couponService = CouponService.getInstance()\n\nexport class DealService extends BaseService {\n\tstatic getInstance = singleton(DealService)\n\n\tasync fetchDeals() {\n\t\treturn emptyPage()\n\t}\n}\n\nexport const dealService = DealService.getInstance()\n\nexport class ReviewService extends BaseService {\n\tstatic getInstance = singleton(ReviewService)\n\n\tasync fetchReviews(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n\n\tasync allReviews(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n\n\tasync fetchProducrReviews(_productId: string) {\n\t\treturn emptyPage()\n\t}\n\n\tasync saveReview(_review: unknown): Promise<never> {\n\t\tthrow unavailable('Product reviews')\n\t}\n}\n\nexport const reviewService = ReviewService.getInstance()\n\n// --- Content ------------------------------------------------------------------------------------\n// GoCommerce stores no pages, posts, banners or galleries. This storefront's own content lives in\n// the repo; anything asked for by slug here genuinely does not exist.\n\nexport class PageService extends BaseService {\n\tstatic getInstance = singleton(PageService)\n\n\tasync list(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n\n\tasync listLatestPages(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n\n\t/**\n\t * Every caller asks for a fixed, optional slug — `products`, `about-us`, `privacy-policy` — to\n\t * dress a page the storefront already renders. So an absent page is the normal state, not a dead\n\t * link: answer empty and let the route show its own content, rather than log a failure on every\n\t * request for something that was never required.\n\t */\n\tasync getOne(_id: string) {\n\t\treturn {}\n\t}\n}\n\nexport const pageService = PageService.getInstance()\n\nexport class BlogService extends BaseService {\n\tstatic getInstance = singleton(BlogService)\n\n\tasync list(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n\n\tasync getOne(id: string): Promise<never> {\n\t\tthrow new Error(`The post \"${id}\" does not exist on this store.`)\n\t}\n}\n\nexport const blogService = BlogService.getInstance()\n\nexport class BannerService extends BaseService {\n\tstatic getInstance = singleton(BannerService)\n\n\tasync list() {\n\t\treturn emptyPage()\n\t}\n\n\tasync fetchBannersGroup() {\n\t\treturn emptyPage()\n\t}\n}\n\nexport const bannerService = BannerService.getInstance()\n\nexport class GalleryService extends BaseService {\n\tstatic getInstance = singleton(GalleryService)\n\n\tasync fetchGallery() {\n\t\treturn [] as unknown[]\n\t}\n}\n\nexport const galleryService = GalleryService.getInstance()\n\nexport class ReelsService extends BaseService {\n\tstatic getInstance = singleton(ReelsService)\n\n\tasync list() {\n\t\treturn emptyPage()\n\t}\n}\n\nexport const reelsService = ReelsService.getInstance()\n\nexport class FaqService extends BaseService {\n\tstatic getInstance = singleton(FaqService)\n\n\tasync listFaqs(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n}\n\nexport const faqService = FaqService.getInstance()\n\nexport class FeedbackService extends BaseService {\n\tstatic getInstance = singleton(FeedbackService)\n\n\tasync listFeedbacks(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n}\n\nexport const feedbackService = FeedbackService.getInstance()\n\n// --- Inbound messages ---------------------------------------------------------------------------\n// Each of these hands the shopper's words to a backend that has no inbox for them. A resolved\n// promise would render \"thanks, we'll be in touch\" over a message nobody will ever read.\n\nexport class ContactService extends BaseService {\n\tstatic getInstance = singleton(ContactService)\n\n\tasync submitContactUsForm(_params: unknown): Promise<never> {\n\t\tthrow unavailable('The contact form')\n\t}\n}\n\nexport const contactService = ContactService.getInstance()\n\nexport class EnquiryService extends BaseService {\n\tstatic getInstance = singleton(EnquiryService)\n\n\tasync create(_params: unknown): Promise<never> {\n\t\tthrow unavailable('Product enquiries')\n\t}\n}\n\nexport const enquiryService = EnquiryService.getInstance()\n\nexport class ChatService extends BaseService {\n\tstatic getInstance = singleton(ChatService)\n\n\tasync list() {\n\t\treturn [] as Record<string, unknown>[]\n\t}\n\n\tasync chats() {\n\t\treturn [] as Record<string, unknown>[]\n\t}\n\n\tasync save(_message: unknown): Promise<never> {\n\t\tthrow unavailable('Messaging')\n\t}\n}\n\nexport const chatService = ChatService.getInstance()\n\nexport class UploadService extends BaseService {\n\tstatic getInstance = singleton(UploadService)\n\n\t// Media in GoCommerce is an operator's, uploaded through the admin API. A storefront holds no\n\t// admin credential and must not act as though it does.\n\tasync uploadToS3(_params: unknown): Promise<never> {\n\t\tthrow unavailable('File uploads')\n\t}\n\n\tasync uploadMultipleToS3(_params: unknown): Promise<never> {\n\t\tthrow unavailable('File uploads')\n\t}\n\n\tasync deleteFromS3(_params: unknown): Promise<never> {\n\t\tthrow unavailable('File uploads')\n\t}\n}\n\nexport const uploadService = UploadService.getInstance()\n\n// --- Marketplace --------------------------------------------------------------------------------\n// GoCommerce is single-vendor: one operator, one catalogue.\n\nexport class VendorService extends BaseService {\n\tstatic getInstance = singleton(VendorService)\n\n\tasync list(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n\n\tasync getVendor(_id: string): Promise<never> {\n\t\tthrow unavailable('Vendor pages')\n\t}\n\n\tasync fetchMyVendorDetails(): Promise<never> {\n\t\tthrow unavailable('Vendor accounts')\n\t}\n\n\tasync fetchDashboard(): Promise<never> {\n\t\tthrow unavailable('Vendor accounts')\n\t}\n\n\tasync fetchProductsOfVendor(_vendorId: string) {\n\t\treturn [] as unknown[]\n\t}\n\n\tasync getAllVendorRatings(_vendorId: string) {\n\t\treturn [] as unknown[]\n\t}\n\n\tasync save(_data: unknown): Promise<never> {\n\t\tthrow unavailable('Vendor accounts')\n\t}\n\n\tasync update(_data: unknown): Promise<never> {\n\t\tthrow unavailable('Vendor accounts')\n\t}\n}\n\nexport const vendorService = VendorService.getInstance()\n\n// --- Storefront-specific add-ons ----------------------------------------------------------------\n// Custom-design ordering is a Litekart-side feature with its own backend; there is no GoCommerce\n// counterpart to route it to.\n\nexport class VarniCustomDesignService extends BaseService {\n\tstatic getInstance = singleton(VarniCustomDesignService)\n\n\tasync submitForm(_formDetails: unknown): Promise<never> {\n\t\tthrow unavailable('Custom design requests')\n\t}\n}\n\nexport const varniCustomDesignService = VarniCustomDesignService.getInstance()\n\nexport class VarniCustomProductService extends BaseService {\n\tstatic getInstance = singleton(VarniCustomProductService)\n\n\tasync checkForCombinationWith(_args: unknown) {\n\t\treturn { data: [], count: 0, pageSize: PAGE_SIZE, noOfPage: 0, page: 1 }\n\t}\n\n\tasync createCustomOrderChat(_productId: string): Promise<never> {\n\t\tthrow unavailable('Custom product chat')\n\t}\n\n\tasync sendMessageToCustomOrderChat(_chatId: string, _vendor: string, _message: string): Promise<never> {\n\t\tthrow unavailable('Custom product chat')\n\t}\n}\n\nexport const varniCustomProductService = VarniCustomProductService.getInstance()\n"]}
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@misiki/gocommerce-connector",
3
+ "version": "0.1.0",
4
+ "description": "API Connector for GoCommerce with Svelte Commerce",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ },
15
+ "./services": {
16
+ "types": "./dist/services/index.d.ts",
17
+ "import": "./dist/services/index.js",
18
+ "require": "./dist/services/index.cjs"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "scripts": {
28
+ "build": "tsup",
29
+ "dev": "tsup --watch",
30
+ "typecheck": "tsc --noEmit",
31
+ "prepublishOnly": "npm run build",
32
+ "p": "tsup && npm publish --access public"
33
+ },
34
+ "keywords": [
35
+ "gocommerce",
36
+ "litekart",
37
+ "connector",
38
+ "ecommerce",
39
+ "headless",
40
+ "storefront",
41
+ "api",
42
+ "integration",
43
+ "typescript",
44
+ "svelte"
45
+ ],
46
+ "author": "misiki-in",
47
+ "license": "MIT",
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "git+https://github.com/misiki-in/gocommerce-connector.git"
51
+ },
52
+ "homepage": "https://github.com/misiki-in/gocommerce-connector#readme",
53
+ "devDependencies": {
54
+ "@types/node": "^22.13.1",
55
+ "tsup": "^8.4.0",
56
+ "typescript": "^5.7.3"
57
+ },
58
+ "packageManager": "bun@1.2.2"
59
+ }