@lynkow/astro 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynkow/astro",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Astro adapter for Lynkow: configuration, locale routing, a tagged data cache, the revalidation webhook, the buyer session and page metadata, for a site built on the Lynkow SDK",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Lynkow",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../lynkow-next/src/cache.ts","../src/cache/policy.ts","../src/cache/hint.ts","../src/cache/store.ts","../src/cache/lynkow-cache.ts","../../lynkow-next/src/clients.ts"],"names":["REVALIDATE","TAGS","uncached"],"mappings":";;;;AA4BO,IAAM,UAAA,GAAa;AAAA;AAAA,EAExB,IAAA,EAAM,IAAA;AAAA;AAAA,EAEN,IAAA,EAAM,GAAA;AAAA;AAAA,EAEN,IAAA,EAAM,GAAA;AAAA;AAAA,EAEN,OAAA,EAAS,GAAA;AAAA;AAAA,EAET,KAAA,EAAO,IAAA;AAAA;AAAA,EAEP,OAAA,EAAS,IAAA;AAAA;AAAA,EAET,GAAA,EAAK,IAAA;AAAA;AAAA,EAEL,KAAA,EAAO,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASP,MAAA,EAAQ;AACV,CAAA;AAEO,IAAM,IAAA,GAAO;AAAA,EAClB,IAAA,EAAM,aAAA;AAAA,EACN,KAAA,EAAO,cAAA;AAAA,EACP,IAAA,EAAM,CAAC,IAAA,KAAiB,CAAA,YAAA,EAAe,IAAI,CAAA,CAAA;AAAA,EAC3C,QAAA,EAAU,iBAAA;AAAA,EACV,OAAA,EAAS,CAAC,IAAA,KAAiB,CAAA,eAAA,EAAkB,IAAI,CAAA,CAAA;AAAA,EACjD,UAAA,EAAY,mBAAA;AAAA,E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EAAA,OAAO,IACJ,KAAA,CAAM,GAAG,EACT,GAAA,CAAI,CAAC,QAAQ,KAAA,KAAU;AACtB,IAAA,IAAI,KAAA,KAAU,CAAA,EAAG,OAAO,MAAA,CAAO,WAAA,EAAY;AAC3C,IAAA,IAAI,MAAA,CAAO,MAAA,KAAW,CAAA,EAAG,OAAO,OAAO,WAAA,EAAY;AACnD,IAAA,IAAI,MAAA,CAAO,MAAA,KAAW,CAAA,EAAG,OAAO,OAAO,MAAA,CAAO,CAAC,CAAA,CAAE,WAAA,EAAY,GAAI,MAAA,CAAO,KAAA,CAAM,CAAC,EAAE,WAAA,EAAY;AAC7F,IAAA,OAAO,OAAO,WAAA,EAAY;AAAA,EAC5B,CAAC,CAAA,CACA,IAAA,CAAK,GAAG,CAAA;AACb","file":"chunk-OGQ25G7G.js","sourcesContent":["/**\n * The caching strategy of a Lynkow site on Next, in one file.\n *\n * Next 15 changed `fetch()` to be uncached by default, so nothing here is\n * inherited: a read that does not pass one of these option bags hits the Lynkow\n * API on every single request. Every data read in this app therefore goes\n * through `cached()`. The durations are defaults tuned for a content site; a\n * site that wants others passes its own number to `cached()`.\n *\n * Two mechanisms, deliberately combined:\n *\n * - `revalidate` is the ceiling. Even with no webhook wired, content is never\n * more than this many seconds stale.\n * - `tags` are the floor. The revalidation webhook calls `revalidateTag()` so\n * an edit in the admin appears in seconds rather than minutes.\n *\n * A tag is only useful if the webhook actually sends the matching event, so the\n * names here and the ones the revalidation handler maps MUST stay in step.\n */\nimport type { BaseRequestOptions } from 'lynkow'\n\n/**\n * `RequestInit` as Next extends it. Spelled out here because this entry\n * imports nothing from `next`, whose global types carry that extension.\n */\ntype NextRequestInit = RequestInit & { next?: { tags?: string[]; revalidate?: number | false } }\n\n/** Seconds. Tuned for a content site: rarely-changing structure lives longer. */\nexport const REVALIDATE = {\n /** Site config and global blocks: header, footer, branding. */\n site: 3600,\n /** Structural pages driven by site blocks. */\n page: 300,\n /** Blog articles, categories, tags. */\n blog: 300,\n /** Approved reviews. */\n reviews: 900,\n /** Form schemas. */\n forms: 3600,\n /** The cookie consent banner configuration. */\n consent: 3600,\n /** sitemap.xml, robots.txt, llms.txt. */\n seo: 3600,\n /** The path table used for static generation and redirect matching. */\n paths: 600,\n /**\n * One search result page.\n *\n * Short on purpose. Next keys its fetch cache on the full URL, so every\n * distinct query is its own entry and a long ceiling would pin a large,\n * unbounded set of them. The tag is what actually keeps results honest: a\n * publish evicts every cached query at once.\n */\n search: 60,\n} as const\n\nexport const TAGS = {\n site: 'lynkow:site',\n pages: 'lynkow:pages',\n page: (slug: string) => `lynkow:page:${slug}`,\n contents: 'lynkow:contents',\n content: (slug: string) => `lynkow:content:${slug}`,\n categories: 'lynkow:categories',\n tags: 'lynkow:tags',\n reviews: 'lynkow:reviews',\n forms: 'lynkow:forms',\n form: (slug: string) => `lynkow:form:${slug}`,\n consent: 'lynkow:consent',\n seo: 'lynkow:seo',\n paths: 'lynkow:paths',\n search: 'lynkow:search',\n} as const\n\n/**\n * Build the per-request options that put one Lynkow read into the Next cache.\n *\n * @example\n * const page = await lynkow(locale).pages.getBySlug('home', cached([TAGS.page('home')], REVALIDATE.page))\n */\nexport function cached(tags: string[], revalidate: number): BaseRequestOptions {\n const fetchOptions: NextRequestInit = { next: { tags, revalidate } }\n return { fetchOptions }\n}\n\n/**\n * For a read that must never be served from cache: a preview render, or a\n * form schema fetched at submit time.\n */\nexport function uncached(): BaseRequestOptions {\n return { fetchOptions: { cache: 'no-store' } }\n}\n","import { REVALIDATE as SHARED_REVALIDATE, TAGS as SHARED_TAGS } from '../../../lynkow-next/src/cache.js'\n\n/**\n * The default freshness ceilings of each kind of read, in seconds, for\n * `cached(tags, revalidate)`: the same values `@lynkow/next` uses. A site that\n * wants others passes its own number.\n */\nexport const REVALIDATE: typeof SHARED_REVALIDATE = SHARED_REVALIDATE\n\n/**\n * The cache tags the revalidation endpoint evicts for each webhook event. A\n * read tagged with one of them is evicted when that content changes, so the\n * names here and those the endpoint maps always stay in step.\n */\nexport const TAGS: typeof SHARED_TAGS = SHARED_TAGS\n","import type { BaseRequestOptions } from 'lynkow'\n\n/**\n * The key a read's options carry its cache policy under. A registered symbol,\n * so a second copy of this module, bundled into another entry, reads the same\n * key. It is a symbol so it never reaches a query string or a request body:\n * the client wrapper strips it before the SDK sees the options.\n */\nexport const CACHE_HINT: unique symbol = Symbol.for('@lynkow/astro/cache-hint')\n\n/** How long one read stays cached, and the tags that evict it. */\nexport interface CachePolicy {\n /** The tags a webhook event evicts this read by, such as `TAGS.page('home')`. */\n readonly tags: readonly string[]\n /** Seconds the result stays fresh. `0` never caches it. */\n readonly revalidate: number\n}\n\n/** Request options carrying a cache policy, or the explicit absence of one. */\ntype HintedOptions = BaseRequestOptions & { [CACHE_HINT]: CachePolicy | null }\n\n/**\n * The per-read options that put one Lynkow read into the Astro data cache.\n * Pass them to a read of a client from `createClients`, alone or spread into\n * the read's own options.\n *\n * @param tags - The tags a webhook event evicts this read by\n * @param revalidate - Seconds the result stays fresh; `0` never caches it\n * @throws {TypeError} When a tag is not a non-empty string.\n * @throws {RangeError} When `revalidate` is not a finite number of at least 0.\n *\n * @example\n * const page = await lynkow(locale).pages.getBySlug('home', cached([TAGS.page('home')], REVALIDATE.page))\n * // A commerce read takes a tag of your own: `TAGS` covers the content reads.\n * const { data } = await lynkow(locale).products.list(filters, { ...cached(['lynkow:products'], 300), market })\n */\nexport function cached(tags: readonly string[], revalidate: number): BaseRequestOptions {\n if (!Array.isArray(tags) || tags.some((tag) => typeof tag !== 'string' || tag === '')) {\n throw new TypeError('cached() takes an array of non-empty tag strings')\n }\n if (typeof revalidate !== 'number' || !Number.isFinite(revalidate) || revalidate < 0) {\n throw new RangeError(`cached() takes a number of seconds of at least 0, got ${String(revalidate)}`)\n }\n const options: HintedOptions = { [CACHE_HINT]: { tags: [...tags], revalidate } }\n return options\n}\n\n/**\n * For a read that must never be served from the cache: a preview render, or a\n * form schema read at submit time. A read with no `cached()` options is not\n * cached either; this one says so explicitly.\n */\nexport function uncached(): BaseRequestOptions {\n const options: HintedOptions = { [CACHE_HINT]: null }\n return options\n}\n\nfunction isPlainObject(value: unknown): value is Record<PropertyKey, unknown> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return false\n const proto = Object.getPrototypeOf(value)\n return proto === Object.prototype || proto === null\n}\n\n/**\n * The cache policy the arguments of one read carry, and the arguments with\n * the hint removed, ready for the SDK. `policy` is `null` for `uncached()`\n * and `undefined` when no argument carries a hint. When several arguments\n * carry one, the last wins.\n */\nexport function takeHint(args: readonly unknown[]): {\n policy: CachePolicy | null | undefined\n args: unknown[]\n} {\n let policy: CachePolicy | null | undefined\n const stripped = args.map((arg) => {\n if (!isPlainObject(arg) || !Object.prototype.hasOwnProperty.call(arg, CACHE_HINT)) return arg\n const { [CACHE_HINT]: hint, ...rest } = arg\n policy = (hint as CachePolicy | null) ?? null\n return rest\n })\n return { policy, args: stripped }\n}\n","/**\n * Where the data cache keeps its entries.\n *\n * The default store lives in the process's memory, which is right for one\n * Node server. A site running several instances behind a load balancer can\n * hand {@link createLynkowCache} a store shared between them; every method\n * may then answer asynchronously.\n */\n\n/** One cached read. */\nexport interface CacheEntry {\n /** The read's result, already detached from what any caller holds. */\n readonly value: unknown\n /** The tags a webhook event evicts this entry by. */\n readonly tags: readonly string[]\n /** When the result was loaded, in epoch milliseconds. */\n readonly storedAt: number\n /** Seconds the entry stays fresh. */\n readonly revalidate: number\n}\n\n/**\n * The storage behind {@link createLynkowCache}.\n *\n * Shared between instances, it has one limit: an eviction cancels the loads\n * in flight in the instance that receives the webhook only. A load another\n * instance started before the edit can still write its pre-edit result to the\n * shared store after the eviction, where it stays until its `revalidate`\n * elapses or the next eviction of one of its tags. Past its `revalidate`, it is\n * served once more as stale while the fresh copy loads, within the\n * `staleWhileRevalidate` window. Keep `revalidate` short on reads where that\n * window matters.\n */\nexport interface CacheStore {\n /** The entry under `key`, or undefined. A store may evict on its own terms. */\n get(key: string): CacheEntry | undefined | Promise<CacheEntry | undefined>\n /** Stores `entry` under `key`, replacing any entry already there. */\n set(key: string, entry: CacheEntry): void | Promise<void>\n /** Deletes every entry carrying at least one of `tags`. */\n deleteTags(tags: readonly string[]): void | Promise<void>\n}\n\n/** Options of {@link createMemoryStore}. */\nexport interface MemoryStoreOptions {\n /** The most entries kept; the least recently used one goes first. Defaults to 1000. */\n max?: number\n}\n\nexport const DEFAULT_MAX_ENTRIES = 1000\n\n/**\n * An in-process store: a least-recently-used map, bounded by entry count,\n * with an index from each tag to the keys that carry it so an eviction by tag\n * never scans the whole map.\n *\n * @throws {RangeError} When `max` is not a positive integer.\n */\nexport function createMemoryStore({ max = DEFAULT_MAX_ENTRIES }: MemoryStoreOptions = {}): CacheStore {\n if (!Number.isInteger(max) || max < 1) {\n throw new RangeError(`max must be a positive integer, got ${String(max)}`)\n }\n // A Map iterates in insertion order, so re-inserting on use keeps the least\n // recently used entry first.\n const entries = new Map<string, CacheEntry>()\n const byTag = new Map<string, Set<string>>()\n\n function unindex(key: string, entry: CacheEntry): void {\n for (const tag of entry.tags) {\n const keys = byTag.get(tag)\n if (!keys) continue\n keys.delete(key)\n if (keys.size === 0) byTag.delete(tag)\n }\n }\n\n function remove(key: string): void {\n const entry = entries.get(key)\n if (!entry) return\n entries.delete(key)\n unindex(key, entry)\n }\n\n return {\n get(key) {\n const entry = entries.get(key)\n if (!entry) return undefined\n entries.delete(key)\n entries.set(key, entry)\n return entry\n },\n set(key, entry) {\n remove(key)\n entries.set(key, entry)\n for (const tag of entry.tags) {\n let keys = byTag.get(tag)\n if (!keys) byTag.set(tag, (keys = new Set()))\n keys.add(key)\n }\n while (entries.size > max) {\n const oldest = entries.keys().next()\n if (oldest.done) break\n remove(oldest.value)\n }\n },\n deleteTags(tags) {\n for (const tag of tags) {\n const keys = byTag.get(tag)\n if (!keys) continue\n for (const key of [...keys]) remove(key)\n }\n },\n }\n}\n","import type { CachePolicy } from './hint.js'\nimport { createMemoryStore, type CacheStore } from './store.js'\n\n/**\n * Seconds a stale entry may still be served while a fresh copy loads in the\n * background, by default. Past that, the read waits for the fresh copy.\n */\nexport const DEFAULT_STALE_WHILE_REVALIDATE = 86_400\n\n/**\n * Milliseconds a key waits after a failed background refresh before another\n * one may start. The stale entry is served meanwhile, so an API outage costs\n * one upstream call per key per backoff rather than one per request.\n */\nexport const REFRESH_RETRY_BACKOFF_MS = 30_000\n\n/**\n * Milliseconds an eviction waits for the store writes already under way for\n * its tags before deleting. A write still under way after that is deleted\n * again once it settles, so a store that hangs never holds the webhook.\n */\nexport const STORE_WRITE_WAIT_MS = 5_000\n\n/** Options of {@link createLynkowCache}. */\nexport interface LynkowCacheOptions {\n /**\n * The most entries the default in-memory store keeps. Ignored when `store`\n * is given. Defaults to 1000.\n */\n max?: number\n /** Where entries live. Defaults to an in-process LRU store. */\n store?: CacheStore\n /**\n * Seconds past its `revalidate` an entry may still be served while a fresh\n * copy loads in the background. Defaults to one day. `0` makes every read\n * of an expired entry wait for the fresh copy.\n */\n staleWhileRevalidate?: number\n}\n\n/** A tagged data cache for Lynkow reads. */\nexport interface LynkowCache {\n /**\n * The result of `load`, cached under `key` with `policy`.\n *\n * A fresh entry is returned without calling `load`. An expired one is\n * returned too while it is within the stale window, and `load` then runs\n * once in the background to replace it. A missing entry, or one past that\n * window, waits for `load`. Concurrent reads of one key share a single\n * `load`. A failed `load` is never cached and rejects every read waiting on\n * it; a failed background refresh keeps the stale entry.\n *\n * Every caller gets its own copy (`structuredClone`), so mutating a result\n * never alters what the next request reads. A result that cannot be cloned\n * is returned as it is and not cached.\n */\n read<T>(key: string, policy: CachePolicy, load: () => Promise<T>): Promise<T>\n /**\n * Evicts every entry carrying one of `tags`, with no staleness allowed: the\n * next read of those keys waits for a fresh copy. A load already in flight\n * for one of them still answers the reads waiting on it, but its result is\n * not stored, and a write of it already under way is awaited, then deleted.\n * That wait lasts 5 seconds at most: a write still under way then is deleted\n * again once it settles, in the background, and until that second deletion\n * a read can get its pre-edit entry. Only the loads of this cache are\n * covered: with a store shared between instances, a load another instance\n * started before the eviction can still store its result after it (see\n * {@link CacheStore}).\n */\n invalidateTags(tags: readonly string[]): Promise<void>\n}\n\n/** One load in flight, shared by every read of its key. */\ninterface Flight {\n readonly tags: readonly string[]\n /** Set when one of the tags was invalidated while the load ran. */\n cancelled: boolean\n /** The write of the loaded entry to the store, once started. */\n storing?: Promise<void>\n readonly done: Promise<Loaded>\n}\n\n/** A loaded result, and whether it is a detached copy every reader may clone. */\ninterface Loaded {\n value: unknown\n detached: boolean\n}\n\nfunction hand<T>(loaded: Loaded): T {\n return (loaded.detached ? structuredClone(loaded.value) : loaded.value) as T\n}\n\n/** Whether `promise` settles within `ms`. The timer is always cleared. */\nasync function settlesWithin(promise: Promise<unknown>, ms: number): Promise<boolean> {\n let timer: ReturnType<typeof setTimeout> | undefined\n const elapsed = new Promise<false>((resolve) => {\n timer = setTimeout(resolve, ms, false)\n })\n try {\n return await Promise.race([promise.then(() => true), elapsed])\n } finally {\n clearTimeout(timer)\n }\n}\n\n/**\n * Creates a tagged data cache: tags for eviction by the revalidation webhook,\n * `revalidate` as the freshness ceiling, stale-while-revalidate, one load per\n * key at a time, and a detached copy for every reader.\n *\n * @throws {RangeError} When `max` is not a positive integer, or\n * `staleWhileRevalidate` is not a finite number of at least 0.\n */\nexport function createLynkowCache({\n max,\n store,\n staleWhileRevalidate = DEFAULT_STALE_WHILE_REVALIDATE,\n}: LynkowCacheOptions = {}): LynkowCache {\n if (!Number.isFinite(staleWhileRevalidate) || staleWhileRevalidate < 0) {\n throw new RangeError(\n `staleWhileRevalidate must be a number of seconds of at least 0, got ${String(staleWhileRevalidate)}`\n )\n }\n const entries = store ?? createMemoryStore(max === undefined ? {} : { max })\n const flights = new Map<string, Flight>()\n /** Keys whose last background refresh failed, with when the next may start. */\n const retryAt = new Map<string, number>()\n\n /** Starts the load of `key`, or joins the one already running. */\n function fly(key: string, policy: CachePolicy, load: () => Promise<unknown>): Flight {\n const running = flights.get(key)\n if (running) return running\n\n const tags = [...policy.tags]\n\n async function run(): Promise<Loaded> {\n // Yield first: `flight` is assigned, and registered, before `load` can settle or throw.\n await undefined\n try {\n const value = await load()\n retryAt.delete(key)\n let detached: unknown\n try {\n detached = structuredClone(value)\n } catch {\n // Not cloneable, so not shareable between requests: not cached.\n return { value, detached: false }\n }\n if (!flight.cancelled) {\n try {\n // Kept on the flight so an eviction arriving mid-write waits for it.\n flight.storing = Promise.resolve(\n entries.set(key, {\n value: detached,\n tags,\n storedAt: Date.now(),\n revalidate: policy.revalidate,\n })\n )\n await flight.storing\n } catch (error) {\n console.error('[lynkow] a cache entry could not be stored', error)\n }\n }\n return { value: detached, detached: true }\n } finally {\n if (flights.get(key) === flight) flights.delete(key)\n }\n }\n\n const flight: Flight = { tags, cancelled: false, done: run() }\n flights.set(key, flight)\n return flight\n }\n\n /** Holds off the next background refresh of `key`, dropping elapsed holds. */\n function backOff(key: string): void {\n const now = Date.now()\n for (const [held, until] of retryAt) if (until <= now) retryAt.delete(held)\n retryAt.set(key, now + REFRESH_RETRY_BACKOFF_MS)\n }\n\n async function read<T>(key: string, policy: CachePolicy, load: () => Promise<T>): Promise<T> {\n if (!(policy.revalidate > 0)) return load()\n\n let entry\n try {\n entry = await entries.get(key)\n } catch (error) {\n console.error('[lynkow] the cache store could not be read, loading instead', error)\n }\n if (entry) {\n const age = Date.now() - entry.storedAt\n const fresh = entry.revalidate * 1000\n if (age < fresh) return hand<T>({ value: entry.value, detached: true })\n if (age < fresh + staleWhileRevalidate * 1000) {\n // Only the read that starts the refresh handles its failure, so one\n // failure is logged and backed off once, however many reads see it.\n if (Date.now() >= (retryAt.get(key) ?? 0) && !flights.has(key)) {\n fly(key, policy, load).done.catch((error: unknown) => {\n backOff(key)\n console.error('[lynkow] a background refresh failed, the stale entry is kept', error)\n })\n }\n return hand<T>({ value: entry.value, detached: true })\n }\n }\n return hand<T>(await fly(key, policy, load).done)\n }\n\n async function invalidateTags(tags: readonly string[]): Promise<void> {\n const dropped = new Set(tags)\n const writes: Promise<void>[] = []\n for (const [key, flight] of flights) {\n if (flight.tags.some((tag) => dropped.has(tag))) {\n flight.cancelled = true\n if (flight.storing) writes.push(flight.storing)\n flights.delete(key)\n }\n }\n const evicted = [...dropped]\n if (writes.length > 0) {\n // A write already under way lands first, so the deletion below removes it.\n const pending = new Set(writes)\n const settled = Promise.allSettled(writes.map((write) => write.finally(() => pending.delete(write))))\n if (!(await settlesWithin(settled, STORE_WRITE_WAIT_MS))) {\n // Not waited for any longer: each write still under way is deleted\n // again once it lands, whatever the others do. That second deletion\n // may also drop an entry stored after the eviction, which costs one\n // more load, never a stale read.\n const evictLate = () => entries.deleteTags(evicted)\n for (const write of pending) {\n void write.then(evictLate, evictLate).catch((error: unknown) => {\n console.error('[lynkow] a cache tag could not be evicted after a late store write', error)\n })\n }\n }\n }\n await entries.deleteTags(evicted)\n }\n\n return { read, invalidateTags }\n}\n\nconst DEFAULT_CACHE = Symbol.for('@lynkow/astro/default-cache')\n\n/**\n * The process-wide cache `createClients` and `createRevalidateEndpoint` use\n * when given none. Kept on `globalThis`, so two copies of this package loaded\n * side by side still share one cache, and an eviction always reaches it.\n */\nexport const lynkowCache: LynkowCache = ((globalThis as Record<symbol, unknown>)[DEFAULT_CACHE] ??=\n createLynkowCache()) as LynkowCache\n","import { createClient, type Client, type ClientConfig } from 'lynkow'\nimport type { LynkowNextConfig } from './config.js'\nimport { createLocalePaths } from './locale-paths.js'\nimport type { SiteLocales } from './site-locales.js'\n\n/**\n * A language subtag, then optional script, region or variant subtags: `en`,\n * `fr`, `pt-BR`. The same shape `resolveConfig` accepts for a configured\n * locale, strict for the same reason: a locale becomes a path segment.\n */\nconst LOCALE_TAG = /^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/i\n\n/** Options of the client {@link LynkowClients} returns. */\nexport interface ClientOptions {\n /**\n * `false` returns a client that sends each read once instead of retrying a\n * 429 or a 503. Defaults to `true`.\n */\n retry?: boolean\n}\n\n/** Options of {@link createClients}, applied to every client it creates. */\nexport interface CreateClientsOptions {\n /**\n * The SDK's browser content enhancements, passed as they are to\n * `createClient({ enhancements })`. Set `{ activateScripts: false }` when the\n * site renders CMS HTML on the server, as a Next.js page usually does: the\n * browser has already run that HTML's inline scripts on page load, and the\n * SDK would run them a second time. Only a client created in the browser\n * uses it. Omitted, the SDK's default applies, which activates them.\n */\n enhancements?: ClientConfig['enhancements']\n /**\n * The site's languages read at runtime, from `createSiteLocales`. When the\n * configuration has no static locale list, a locale is checked against the\n * languages this source last loaded, and a call with no locale gets the\n * site's default. Ignored when the configuration has a static list.\n */\n siteLocales?: SiteLocales\n}\n\n/**\n * The `createClient` options every client of this package shares: the site,\n * the API origin, the publishable key and the locale when they are set, and\n * the SDK cache off. Each factory spreads it and adds its own fields.\n *\n * @internal Not re-exported from the package entries.\n */\nexport function baseClientConfig(config: LynkowNextConfig, locale?: string): ClientConfig {\n return {\n siteId: config.siteId,\n baseUrl: config.apiUrl,\n ...(config.publishableKey ? { publishableKey: config.publishableKey } : {}),\n ...(locale ? { locale } : {}),\n cache: false,\n }\n}\n\n/** Returns the Lynkow client of a locale, the default one when none is given. */\nexport type LynkowClients = (locale?: string, options?: ClientOptions) => Client\n\n/**\n * One Lynkow client per locale, reused across requests.\n *\n * The SDK's own cache stays OFF. On the server it is a process-global\n * unbounded `Map`, which would duplicate and outlive Next's data cache without\n * any of its invalidation. Caching is Next's job, expressed per read with\n * `cached()`.\n *\n * `{ retry: false }` gives a second client for the locale, because the SDK's\n * retry is a client setting rather than a per-read one. Only a read that\n * already knows what to do when it fails should ask for it.\n *\n * FOR READS THAT ARE THE SAME FOR EVERY VISITOR. The clients are shared by\n * every request the process serves, and the SDK keeps a buyer's state on the\n * client instance: the guest cart token and the signed-in customer session.\n * Calling `cart` or `customers` on one of these from server code would hand\n * one visitor's cart or session to the next. Buyer flows run in the browser,\n * or on a client created for that one request.\n *\n * A locale outside the site's languages throws a `RangeError` instead of\n * creating a client. The clients live as long as the process, so a locale\n * taken from a URL and passed through unchecked would grow that set without\n * bound. The languages are the configuration's static list when it has one,\n * otherwise those `options.siteLocales` last loaded. The locale is matched\n * case-insensitively and the client gets the site's spelling.\n *\n * Before `options.siteLocales` has loaded anything, there is no list to check\n * against, so any well-formed language tag is accepted and its client is\n * created, the tag written `pt-BR` whatever its case. Until that first load\n * the set of clients is bounded only by well-formedness, which is why the\n * source should be awaited before a locale from a URL reaches this function,\n * as the proxy does. A call with no locale gets the configuration's default\n * locale when it has a static list, otherwise the site's default once loaded,\n * and the configuration's default before then. With neither a static list nor\n * a configured default, a call with no locale before the first load gets a\n * client that names no locale, so the API answers in the site's default: that\n * is the client the runtime source reads the site's languages through, the\n * one read that cannot know them yet.\n *\n * The source reads the site through a client, and this function checks\n * locales through the source. The two are wired without a cycle by a closure\n * that reads the clients only when it is called:\n *\n * ```ts\n * const siteLocales = createSiteLocales({ client: (locale) => lynkow(locale) })\n * export const lynkow = createClients(config, { siteLocales })\n * ```\n *\n * `options` applies to every client; see {@link CreateClientsOptions}.\n *\n * @throws {RangeError} From the returned function, when a locale is given that\n * is not a well-formed language tag, or names none of the site's languages\n * once they are known.\n */\nexport function createClients(\n config: LynkowNextConfig,\n { enhancements, siteLocales }: CreateClientsOptions = {}\n): LynkowClients {\n const paths = createLocalePaths(config, siteLocales)\n const live = config.locales.length > 0 ? undefined : siteLocales\n const clients = new Map<string, Client>()\n\n /** Whether the site's languages are known: a static list, or a source that loaded once. */\n function loaded(): boolean {\n if (!live) return true\n try {\n live.current()\n return true\n } catch {\n return false\n }\n }\n\n /** The client of `locale`, created once per key; no locale lets the API pick the site's default. */\n function clientFor(locale: string | undefined, retry: boolean): Client {\n const key = `${locale ?? ''}${retry ? '' : ':no-retry'}`\n const existing = clients.get(key)\n if (existing) return existing\n\n const client = createClient({\n ...baseClientConfig(config, locale),\n ...(enhancements ? { enhancements } : {}),\n retry,\n })\n clients.set(key, client)\n return client\n }\n\n return function lynkow(locale?: string, { retry = true } = {}) {\n const known = loaded()\n const wanted = locale ?? (known && live ? paths.defaultLocale : config.defaultLocale)\n // No locale asked for, and none known yet: the bootstrap read of the\n // runtime source, which the API answers in the site's default locale.\n if (locale === undefined && !known && !wanted) return clientFor(undefined, retry)\n const canonical = known ? paths.toLocale(wanted) : LOCALE_TAG.test(wanted) ? normalizeTag(wanted) : null\n if (!canonical) {\n throw new RangeError(\n known\n ? `${JSON.stringify(wanted)} is not one of the site's locales (${paths.locales.join(', ')})`\n : `${JSON.stringify(wanted)} is not a well-formed locale, expected a code such as \"en\" or \"pt-BR\"`\n )\n }\n\n return clientFor(canonical, retry)\n }\n}\n\n/**\n * A well-formed tag written the way the API writes locales: the language in\n * lowercase, a four-letter script in title case and a two-letter region in\n * uppercase (`pt-BR`, `zh-Hant`), so two spellings of one locale share a\n * client.\n */\nfunction normalizeTag(tag: string): string {\n return tag\n .split('-')\n .map((subtag, index) => {\n if (index === 0) return subtag.toLowerCase()\n if (subtag.length === 2) return subtag.toUpperCase()\n if (subtag.length === 4) return subtag.charAt(0).toUpperCase() + subtag.slice(1).toLowerCase()\n return subtag.toLowerCase()\n })\n .join('-')\n}\n"]}