@8ux-co/eelzap 0.10.0 → 0.10.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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/utils.ts","../src/cache.ts","../src/errors.ts","../src/paths.ts","../src/retry.ts","../src/http.ts","../src/resources/resource-helpers.ts","../src/resources/collection-fields.ts","../src/resources/collection-sections.ts","../src/resources/collections.ts","../src/resources/comments.ts","../src/resources/document-versions.ts","../src/resources/document-fields.ts","../src/resources/document-sections.ts","../src/resources/document-seo.ts","../src/resources/document-values.ts","../src/resources/documents.ts","../src/resources/item-versions.ts","../src/query-builder.ts","../src/resources/item-seo.ts","../src/resources/items.ts","../src/resources/media.ts","../src/resources/preview-tokens.ts","../src/resources/site.ts","../src/resources/sites.ts","../src/client.ts","../src/media-url.ts","../src/stega.ts","../src/webhook.ts"],"sourcesContent":["export { cachedFetch, MemoryCacheAdapter } from './cache'\nexport type { CacheAdapter, CachedFetchOptions, CacheStrategy } from './cache'\nexport { createClient, EelZapClient } from './client'\nexport type { ClientConfig } from './client'\nexport { EelZapError, EelZapNetworkError, isEelZapError } from './errors'\nexport { getMediaUrl } from './media-url'\nexport { ItemQueryBuilder } from './query-builder'\nexport { CollectionFieldsResource } from './resources/collection-fields'\nexport { CollectionSectionsResource } from './resources/collection-sections'\nexport { CollectionsResource } from './resources/collections'\nexport { CommentsResource } from './resources/comments'\nexport { DocumentFieldsResource } from './resources/document-fields'\nexport { DocumentSectionsResource } from './resources/document-sections'\nexport { DocumentSeoResource } from './resources/document-seo'\nexport { DocumentValuesResource } from './resources/document-values'\nexport { DocumentVersionsResource } from './resources/document-versions'\nexport { DocumentsResource } from './resources/documents'\nexport { ItemSeoResource } from './resources/item-seo'\nexport { ItemVersionsResource } from './resources/item-versions'\nexport { MediaResource } from './resources/media'\nexport { PreviewTokensResource } from './resources/preview-tokens'\nexport { ItemsResource } from './resources/items'\nexport { SiteResource } from './resources/site'\nexport { SitesResource } from './resources/sites'\nexport type { RetryEvent, RetryOptions } from './retry'\nexport { cleanStega, hasStega } from './stega'\nexport {\n verifyWebhookSignature,\n webhookChanges,\n WEBHOOK_SIGNATURE_HEADER,\n WEBHOOK_TIMESTAMP_HEADER,\n WEBHOOK_TOLERANCE_SECONDS,\n} from './webhook'\nexport type { VerifyWebhookOptions, WebhookHeaders } from './webhook'\nexport * from './types'\n","import type {\n ClientDefaults,\n CommonRequestOptions,\n PreviewOption,\n QueryPrimitive,\n} from './types/common'\nimport type { ItemFilters } from './types/items'\n\nexport function normalizeBaseUrl(baseUrl: string): string {\n return baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`\n}\n\n/** A Zap preview token (`zpt_…`), minted for a draft-mode URL. */\nexport function isPreviewToken(apiKey: string): boolean {\n return apiKey.trim().startsWith('zpt_')\n}\n\n/**\n * `preview=1` when asked for, and NO key otherwise, so a request without\n * preview is exactly what it always was. `stega=0` only beside `preview=1`\n * and only when `stega` is exactly `false` (§2.4).\n */\nexport function previewParam(options: PreviewOption): { preview?: 1; stega?: 0 } {\n return options.preview\n ? options.stega === false\n ? { preview: 1, stega: 0 }\n : { preview: 1 }\n : {}\n}\n\n/**\n * Tags a parsed preview response so `cachedFetch` never stores it (§7.5).\n * `Symbol.for`, not a module-level symbol: the mark must survive the ESM/CJS\n * dual-package split, where the client and the cache can be two copies.\n * Non-enumerable, so it never shows in JSON or spreads.\n *\n * @internal\n */\nexport function markPreview<T>(value: T): T {\n if (value && typeof value === 'object') {\n Object.defineProperty(value, Symbol.for('eelzap.preview'), { value: true })\n }\n return value\n}\n\n/** Whether a value came from a preview response (see {@link markPreview}). */\nexport function isPreviewResult(value: unknown): boolean {\n return (\n !!value &&\n typeof value === 'object' &&\n (value as Record<symbol, unknown>)[Symbol.for('eelzap.preview')] === true\n )\n}\n\n/**\n * A fresh `Idempotency-Key`: `crypto.randomUUID()` where it exists (browsers,\n * edge runtimes, Node 19+), else a time-plus-random key, which is all a key\n * needs to be (unique, not secret).\n *\n * @internal\n */\nexport function newIdempotencyKey(): string {\n const crypto = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto\n return crypto?.randomUUID\n ? crypto.randomUUID()\n : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`\n}\n\nexport function toArrayParam(values: string[] | undefined): string | undefined {\n return values && values.length > 0 ? values.join(',') : undefined\n}\n\nexport function mergeRequestOptions<T extends CommonRequestOptions>(\n defaults: ClientDefaults,\n options?: T,\n): T {\n return {\n ...defaults,\n ...options,\n } as T\n}\n\nexport function cleanParams(\n params: Record<string, QueryPrimitive | undefined>,\n): Record<string, string> {\n return Object.fromEntries(\n Object.entries(params).flatMap(([key, value]) => {\n return value === undefined ? [] : [[key, String(value)]]\n }),\n )\n}\n\nexport function normalizeHeaderValue(value: string | null | undefined): string | undefined {\n if (value === undefined) {\n return undefined\n }\n\n if (value === null) {\n return undefined\n }\n\n const trimmed = value.trim()\n return trimmed.length > 0 ? trimmed : undefined\n}\n\nfunction isOperatorMap(\n value: ItemFilters[string],\n): value is Exclude<ItemFilters[string], QueryPrimitive> {\n return typeof value === 'object' && !Array.isArray(value)\n}\n\nexport function serializeFilters(filters?: ItemFilters): Record<string, string> {\n if (!filters) {\n return {}\n }\n\n return Object.entries(filters).reduce<Record<string, string>>((acc, [field, value]) => {\n if (!isOperatorMap(value)) {\n acc[`filter[${field}]`] = String(value)\n return acc\n }\n\n for (const [operator, operatorValue] of Object.entries(value)) {\n if (operatorValue === undefined) {\n continue\n }\n\n const serializedValue = Array.isArray(operatorValue)\n ? operatorValue.join(',')\n : String(operatorValue)\n acc[`filter[${field}][${operator}]`] = serializedValue\n }\n\n return acc\n }, {})\n}\n\nexport function maskApiKey(apiKey: string): string {\n if (apiKey.length <= 8) {\n return '***'\n }\n\n return `${apiKey.slice(0, 4)}...${apiKey.slice(-4)}`\n}\n","import { isPreviewResult } from './utils'\n\n/**\n * Pluggable storage interface for last-known-good caching.\n *\n * Implement this to persist content to any backend (KV, Redis,\n * filesystem, IndexedDB, etc.). The SDK ships a built-in\n * {@link MemoryCacheAdapter} for processes that stay alive.\n */\nexport interface CacheAdapter<T = unknown> {\n get(key: string): Promise<T | undefined> | T | undefined\n set(key: string, value: T): Promise<void> | void\n}\n\nexport type CacheStrategy = 'network-first' | 'cache-first'\n\nexport interface CachedFetchOptions<T = unknown> {\n key: string\n fetcher: () => Promise<T>\n adapter: CacheAdapter<T>\n strategy?: CacheStrategy\n}\n\n/**\n * Simple in-memory adapter. Suitable for long-lived server processes\n * or development. Data is lost when the process restarts.\n */\nexport class MemoryCacheAdapter implements CacheAdapter {\n readonly #store = new Map<string, unknown>()\n\n get(key: string): unknown {\n return this.#store.get(key)\n }\n\n set(key: string, value: unknown): void {\n this.#store.set(key, value)\n }\n\n /** Returns the number of cached entries. */\n get size(): number {\n return this.#store.size\n }\n\n /** Removes a specific key from the cache. */\n delete(key: string): boolean {\n return this.#store.delete(key)\n }\n\n /** Removes all cached entries. */\n clear(): void {\n this.#store.clear()\n }\n}\n\n/**\n * Caches content fetched from the CMS, with one of two strategies:\n *\n * - `network-first` (the default, and the only one the positional form\n * uses): runs `fetcher`, caches the result on success, and falls back to\n * the last cached value on failure.\n * - `cache-first` (options form): returns the cached value when there is\n * one, and fetches and caches only on a miss.\n *\n * If no cached value exists and the fetch fails, the original error is\n * re-thrown — there are no hardcoded fallbacks.\n *\n * A preview response (a read with `preview: true`, or any read with a `zpt_`\n * preview token) is returned but NEVER stored, under either strategy\n * (zap-cms-v2 §7.5): it carries drafts and stega markers, and a cache entry\n * would hand them to the next visitor.\n *\n * @param key - Stable cache key (e.g. `\"homepage\"`, `\"blog-posts:page-1\"`).\n * @param fetcher - An async function that fetches fresh content from the CMS.\n * @param adapter - Storage backend that persists last-known-good values.\n * @returns The fresh result or the last successfully cached value.\n *\n * @example\n * ```ts\n * const cache = new MemoryCacheAdapter();\n *\n * const homepage = await cachedFetch(\n * 'homepage',\n * () => cms.documents.get('homepage'),\n * cache,\n * );\n * ```\n */\nexport async function cachedFetch<T>(\n key: string,\n fetcher: () => Promise<T>,\n adapter: CacheAdapter<T>,\n): Promise<T>\nexport async function cachedFetch<T>(options: CachedFetchOptions<T>): Promise<T>\nexport async function cachedFetch<T>(\n keyOrOptions: string | CachedFetchOptions<T>,\n fetcher?: () => Promise<T>,\n adapter?: CacheAdapter<T>,\n): Promise<T> {\n const options =\n typeof keyOrOptions === 'string'\n ? {\n key: keyOrOptions,\n fetcher: fetcher as () => Promise<T>,\n adapter: adapter as CacheAdapter<T>,\n strategy: 'network-first' as CacheStrategy,\n }\n : {\n ...keyOrOptions,\n strategy: keyOrOptions.strategy ?? 'network-first',\n }\n\n if (options.strategy === 'cache-first') {\n const cached = await options.adapter.get(options.key)\n if (cached !== undefined) {\n return cached\n }\n\n return store(options.adapter, options.key, await options.fetcher())\n }\n\n try {\n return await store(options.adapter, options.key, await options.fetcher())\n } catch (error) {\n const cached = await options.adapter.get(options.key)\n if (cached !== undefined) {\n return cached\n }\n throw error\n }\n}\n\nasync function store<T>(adapter: CacheAdapter<T>, key: string, result: T): Promise<T> {\n if (!isPreviewResult(result)) await adapter.set(key, result)\n return result\n}\n","import type { ApiErrorDetail } from './types/common'\nimport type { EelZapErrorCode } from './types/errors'\n\n/**\n * Base error thrown by the SDK for API and transport failures.\n */\nexport class EelZapError extends Error {\n readonly code: EelZapErrorCode\n readonly status: number\n /** Per-field problems when the API refused the input; empty otherwise. */\n readonly details: readonly ApiErrorDetail[]\n\n constructor(\n code: EelZapErrorCode,\n message: string,\n status: number,\n details: readonly ApiErrorDetail[] = [],\n ) {\n super(message)\n this.name = 'EelZapError'\n this.code = code\n this.status = status\n this.details = details\n }\n}\n\n/**\n * Error thrown when a network failure or timeout prevents a response.\n */\nexport class EelZapNetworkError extends EelZapError {\n override readonly cause: unknown\n\n constructor(cause: unknown, message = 'Network request failed.') {\n super('NETWORK_ERROR', message, 0)\n this.name = 'EelZapNetworkError'\n this.cause = cause\n }\n}\n\n/**\n * Type guard for SDK errors.\n */\nexport function isEelZapError(error: unknown): error is EelZapError {\n return error instanceof EelZapError\n}\n","function trimSlashes(value: string): string {\n return value.replace(/^\\/+|\\/+$/g, '')\n}\n\n/**\n * Joins resource path segments without applying any API prefix.\n *\n * @internal\n */\nexport function buildResourcePath(...segments: string[]): string {\n const normalized = segments.map(trimSlashes).filter((segment) => segment.length > 0)\n return `/${normalized.join('/')}`\n}\n\n/**\n * Normalizes an SDK path prefix for URL joining.\n *\n * @internal\n */\nexport function normalizePathPrefix(pathPrefix: string): string {\n const trimmed = trimSlashes(pathPrefix)\n return trimmed.length > 0 ? `${trimmed}/` : ''\n}\n","/**\n * Retries of a refused request: `429 Too Many Requests` always, and `503\n * Service Unavailable` when it says when to come back (`Retry-After`).\n *\n * Only a request that is safe to repeat is retried: a read (`GET`, `HEAD`), or\n * a write that carries an `Idempotency-Key`, which the API deduplicates. Any\n * other write is never repeated, so a create can never land twice.\n */\nexport interface RetryOptions {\n /** Retries after the first attempt. Default `3`; `0` turns retrying off. */\n retries?: number\n /**\n * The longest single wait, in ms. Default `60000`, the API's rate window. A\n * `Retry-After` longer than this is not waited out: the refusal is thrown.\n */\n maxDelayMs?: number\n /** The first backoff step when the answer has no `Retry-After`, in ms. Default `500`. */\n baseDelayMs?: number\n /** Called before each wait, for logging. */\n onRetry?: (event: RetryEvent) => void\n}\n\n/** What {@link RetryOptions.onRetry} is told before a wait. */\nexport interface RetryEvent {\n /** The retry about to happen: `1` for the first. */\n attempt: number\n /** How long the client waits first, in ms. */\n delayMs: number\n /** The refused answer's status: `429` or `503`. */\n status: number\n method: string\n url: string\n}\n\n/** @internal */\nexport type ResolvedRetry = Required<Omit<RetryOptions, 'onRetry'>> & Pick<RetryOptions, 'onRetry'>\n\n/** @internal */\nexport function resolveRetry(retry: boolean | RetryOptions | undefined): ResolvedRetry | null {\n if (retry === false) return null\n const options = retry === true || retry === undefined ? {} : retry\n const resolved = {\n retries: options.retries ?? 3,\n maxDelayMs: options.maxDelayMs ?? 60_000,\n baseDelayMs: options.baseDelayMs ?? 500,\n onRetry: options.onRetry,\n }\n return resolved.retries > 0 ? resolved : null\n}\n\n/**\n * Whether the request may be sent again: a read, or a write the API\n * deduplicates by `Idempotency-Key` whose body can be sent twice.\n *\n * @internal\n */\nexport function isRepeatable(method: string, headers: Headers, body: unknown): boolean {\n if (method === 'GET' || method === 'HEAD') return true\n return headers.has('Idempotency-Key') && (body == null || typeof body === 'string')\n}\n\n/**\n * `Retry-After` in ms: delay-seconds or an HTTP-date. `null` when absent or\n * unreadable.\n *\n * @internal\n */\nexport function parseRetryAfter(value: string | null, now: number): number | null {\n if (value === null) return null\n const trimmed = value.trim()\n if (/^\\d+$/.test(trimmed)) return Number(trimmed) * 1000\n const date = Date.parse(trimmed)\n return Number.isNaN(date) ? null : Math.max(0, date - now)\n}\n\n/**\n * How long to wait before retry number `attempt` (from 1), or `null` to give\n * up and surface the answer.\n *\n * With `Retry-After`, that long plus up to a second of jitter, so clients\n * refused together do not come back together. Without it, a `429` backs off\n * exponentially from `baseDelayMs`, half fixed and half jitter; a `503` without\n * it is not retried, since nothing says the outage is brief.\n *\n * @internal\n */\nexport function retryDelay(\n response: Response,\n attempt: number,\n options: ResolvedRetry,\n now: number = Date.now(),\n random: () => number = Math.random,\n): number | null {\n if (attempt > options.retries) return null\n if (response.status !== 429 && response.status !== 503) return null\n\n const retryAfter = parseRetryAfter(response.headers.get('Retry-After'), now)\n if (retryAfter !== null) {\n if (retryAfter > options.maxDelayMs) return null\n return Math.min(options.maxDelayMs, retryAfter + Math.floor(random() * 1000))\n }\n if (response.status === 503) return null\n\n const step = Math.min(options.maxDelayMs, options.baseDelayMs * 2 ** (attempt - 1))\n return Math.floor(step / 2 + random() * (step / 2))\n}\n","import { EelZapError, EelZapNetworkError } from './errors'\nimport { normalizePathPrefix } from './paths'\nimport { isRepeatable, retryDelay, type ResolvedRetry } from './retry'\nimport { cleanParams, isPreviewToken, markPreview } from './utils'\nimport type { ApiErrorPayload, QueryPrimitive } from './types/common'\n\nexport interface HttpClientConfig {\n apiKey: string\n baseUrl: string\n pathPrefix: string\n fetch: typeof globalThis.fetch\n defaultHeaders?: HeadersInit\n timeout: number\n /** Retries of a `429`/`503`; `null` or absent turns them off. */\n retry?: ResolvedRetry | null\n}\n\nexport interface HttpRequestOptions {\n params?: Record<string, QueryPrimitive | undefined>\n headers?: HeadersInit\n body?: BodyInit | null\n contentType?: string\n}\n\n/**\n * Minimal fetch-based HTTP client for the delivery API.\n *\n * @internal\n */\nexport class HttpClient {\n readonly #config: HttpClientConfig\n\n constructor(config: HttpClientConfig) {\n this.#config = config\n }\n\n async get<T>(\n path: string,\n options?: Omit<HttpRequestOptions, 'body' | 'contentType'>,\n ): Promise<T> {\n return this.#request<T>('GET', path, options)\n }\n\n async post<T>(\n path: string,\n body?: unknown,\n options?: Omit<HttpRequestOptions, 'body'>,\n ): Promise<T> {\n return this.#request<T>('POST', path, this.#withJsonBody(body, options))\n }\n\n async patch<T>(\n path: string,\n body?: unknown,\n options?: Omit<HttpRequestOptions, 'body'>,\n ): Promise<T> {\n return this.#request<T>('PATCH', path, this.#withJsonBody(body, options))\n }\n\n async put<T>(\n path: string,\n body?: unknown,\n options?: Omit<HttpRequestOptions, 'body'>,\n ): Promise<T> {\n return this.#request<T>('PUT', path, this.#withJsonBody(body, options))\n }\n\n async delete<T>(\n path: string,\n body?: unknown,\n options?: Omit<HttpRequestOptions, 'body'>,\n ): Promise<T> {\n return this.#request<T>('DELETE', path, this.#withJsonBody(body, options))\n }\n\n async upload(url: string, body: BodyInit, headers?: HeadersInit): Promise<void> {\n const controller = new AbortController()\n const timeoutId = setTimeout(() => {\n controller.abort()\n }, this.#config.timeout)\n\n try {\n const response = await this.#config.fetch(url, {\n method: 'PUT',\n body,\n headers,\n signal: controller.signal,\n })\n\n if (!response.ok) {\n throw await this.toEelZapError(response)\n }\n } catch (error) {\n if (error instanceof EelZapError) {\n throw error\n }\n\n throw new EelZapNetworkError(\n error,\n error instanceof Error ? error.message : 'Network request failed.',\n )\n } finally {\n clearTimeout(timeoutId)\n }\n }\n\n async request<T>(path: string, options?: HttpRequestOptions): Promise<T> {\n return this.get<T>(path, options)\n }\n\n async #request<T>(method: string, path: string, options?: HttpRequestOptions): Promise<T> {\n const prefix = normalizePathPrefix(this.#config.pathPrefix)\n const normalizedPath = path.replace(/^\\/+/, '')\n const url = new URL(`${prefix}${normalizedPath}`, this.#config.baseUrl)\n for (const [key, value] of Object.entries(cleanParams(options?.params ?? {}))) {\n url.searchParams.set(key, value)\n }\n\n const headers = new Headers(this.#config.defaultHeaders)\n for (const [key, value] of new Headers(options?.headers).entries()) {\n headers.set(key, value)\n }\n headers.set('Authorization', `Bearer ${this.#config.apiKey}`)\n if (options?.contentType) {\n headers.set('Content-Type', options.contentType)\n } else if (!headers.has('Content-Type') && options?.body !== undefined) {\n headers.set('Content-Type', 'application/json')\n }\n\n const retry = this.#config.retry\n const repeatable = retry ? isRepeatable(method, headers, options?.body) : false\n for (let attempt = 1; ; attempt++) {\n const controller = new AbortController()\n const timeoutId = setTimeout(() => {\n controller.abort()\n }, this.#config.timeout)\n let delayMs: number | null\n let status: number\n\n try {\n const response = await this.#config.fetch(url.toString(), {\n method,\n body: options?.body,\n headers,\n signal: controller.signal,\n })\n\n delayMs = repeatable && retry ? retryDelay(response, attempt, retry) : null\n if (delayMs === null) {\n return await this.#read<T>(url, response)\n }\n status = response.status\n // Free the refused answer's connection before waiting.\n await response.body?.cancel().catch(() => undefined)\n } catch (error) {\n if (error instanceof EelZapError) {\n throw error\n }\n\n throw new EelZapNetworkError(\n error,\n error instanceof Error ? error.message : 'Network request failed.',\n )\n } finally {\n clearTimeout(timeoutId)\n }\n\n retry?.onRetry?.({ attempt, delayMs, status, method, url: url.toString() })\n await new Promise((resolve) => setTimeout(resolve, delayMs))\n }\n }\n\n async #read<T>(url: URL, response: Response): Promise<T> {\n // No body to parse. 204 is what `DELETE …/versions/draft` answers on\n // success; reading it as JSON would throw and surface as a network error.\n if (response.status === 304 || response.status === 204) {\n return undefined as T\n }\n\n if (!response.ok) {\n throw await this.toEelZapError(response)\n }\n\n const data = (await response.json()) as T\n // A preview answer (`preview=1`, or any read with a `zpt_` token, which\n // the API always answers as preview) is tagged so `cachedFetch` never\n // stores it: drafts and stega markers must not outlive the request.\n return url.searchParams.get('preview') === '1' || isPreviewToken(this.#config.apiKey)\n ? markPreview(data)\n : data\n }\n\n #withJsonBody(\n body: unknown,\n options?: Omit<HttpRequestOptions, 'body'>,\n ): HttpRequestOptions | undefined {\n if (body === undefined) {\n return options\n }\n\n return {\n ...options,\n body: JSON.stringify(body),\n contentType: 'application/json',\n }\n }\n\n private async toEelZapError(response: Response): Promise<EelZapError> {\n const contentType = response.headers.get('Content-Type') ?? ''\n\n if (contentType.includes('application/json')) {\n const payload = (await response.json()) as Partial<ApiErrorPayload>\n const code = payload.error?.code ?? 'INTERNAL_ERROR'\n const message =\n payload.error?.message ?? `Request failed with status ${String(response.status)}.`\n const status = payload.error?.status ?? response.status\n const details = Array.isArray(payload.error?.details) ? payload.error.details : []\n return new EelZapError(code, message, status, details)\n }\n\n return new EelZapError(\n 'INTERNAL_ERROR',\n `Request failed with status ${String(response.status)}.`,\n response.status,\n )\n }\n}\n","import type { IdempotencyOptions } from '../types/common'\nimport type { DeleteOptions } from '../types/common'\nimport { newIdempotencyKey } from '../utils'\nimport type { CreateFieldInput, UpdateFieldInput } from '../types/collections'\n\nexport function normalizeFieldInput<T extends CreateFieldInput | UpdateFieldInput>(input: T): T {\n if (input.label || !input.name) {\n return input\n }\n\n return {\n ...input,\n label: input.name,\n }\n}\n\nexport function toDeleteBody(options?: DeleteOptions): DeleteOptions | undefined {\n if (!options?.deleteMediaIds || options.deleteMediaIds.length === 0) {\n return undefined\n }\n\n return {\n deleteMediaIds: options.deleteMediaIds,\n }\n}\n\n/**\n * The `Idempotency-Key` header of a write the API deduplicates: the caller's\n * key, or a fresh one. Suite bearers are refused without it.\n */\nexport function idempotent(options?: IdempotencyOptions): { headers: Record<string, string> } {\n return { headers: { 'Idempotency-Key': options?.idempotencyKey ?? newIdempotencyKey() } }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type {\n CollectionFieldListResponse,\n CreateFieldInput,\n FieldInfo,\n UpdateFieldInput,\n} from '../types/collections'\nimport type { IdempotencyOptions } from '../types/common'\nimport { idempotent, normalizeFieldInput } from './resource-helpers'\n\n/**\n * Collection field management endpoints.\n */\nexport class CollectionFieldsResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Lists all fields in a collection.\n */\n async list(collectionKey: string): Promise<FieldInfo[]> {\n const response = await this.#http.get<CollectionFieldListResponse>(\n buildResourcePath('collections', collectionKey, 'fields'),\n )\n return response.fields\n }\n\n /**\n * Creates a field in a collection.\n *\n * Sends an `Idempotency-Key` (required of suite bearers): a fresh one per\n * call, or `options.idempotencyKey` to make your own retry safe.\n */\n async create(\n collectionKey: string,\n input: CreateFieldInput,\n options?: IdempotencyOptions,\n ): Promise<FieldInfo> {\n const response = await this.#http.post<{ field: FieldInfo }>(\n buildResourcePath('collections', collectionKey, 'fields'),\n normalizeFieldInput(input),\n idempotent(options),\n )\n return response.field\n }\n\n /**\n * Updates a field in a collection.\n */\n async update(\n collectionKey: string,\n fieldId: string,\n input: UpdateFieldInput,\n ): Promise<FieldInfo> {\n const response = await this.#http.patch<{ field: FieldInfo }>(\n buildResourcePath('collections', collectionKey, 'fields', fieldId),\n normalizeFieldInput(input),\n )\n return response.field\n }\n\n /**\n * Deletes a field from a collection.\n */\n async delete(collectionKey: string, fieldId: string): Promise<{ success: true }> {\n return this.#http.delete<{ success: true }>(\n buildResourcePath('collections', collectionKey, 'fields', fieldId),\n )\n }\n\n /**\n * Lists the collection's archived (soft-deleted) fields, most recently\n * deleted first. Their values are kept, which is what makes `restore` work.\n *\n * `GET /collections/{collectionKey}/fields/deleted`. Secret key, or suite\n * bearer with `zap:content:read`.\n */\n async listDeleted(collectionKey: string): Promise<FieldInfo[]> {\n const response = await this.#http.get<CollectionFieldListResponse>(\n buildResourcePath('collections', collectionKey, 'fields', 'deleted'),\n )\n return response.fields\n }\n\n /**\n * Brings an archived field back with every value it held, at the end of the\n * root list (outside any section).\n *\n * `POST /collections/{collectionKey}/fields/{fieldId}/restore`. Secret key,\n * or suite bearer with `zap:schema:write` and the Zap ADMIN role.\n */\n async restore(collectionKey: string, fieldId: string): Promise<FieldInfo> {\n const response = await this.#http.post<{ field: FieldInfo }>(\n buildResourcePath('collections', collectionKey, 'fields', fieldId, 'restore'),\n )\n return response.field\n }\n\n /**\n * Reorders collection fields.\n */\n async reorder(collectionKey: string, fieldIds: string[]): Promise<{ success: true }> {\n return this.#http.put<{ success: true }>(\n buildResourcePath('collections', collectionKey, 'fields', 'reorder'),\n { fieldIds },\n )\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type {\n CollectionSectionListResponse,\n CreateSectionInput,\n SectionInfo,\n UpdateSectionInput,\n} from '../types/collections'\nimport type { IdempotencyOptions } from '../types/common'\nimport { idempotent } from './resource-helpers'\n\n/**\n * Collection section management endpoints.\n */\nexport class CollectionSectionsResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Lists all sections in a collection.\n */\n async list(collectionKey: string): Promise<SectionInfo[]> {\n const response = await this.#http.get<CollectionSectionListResponse>(\n buildResourcePath('collections', collectionKey, 'sections'),\n )\n return response.sections\n }\n\n /**\n * Gets a single section from a collection.\n */\n async get(collectionKey: string, sectionId: string): Promise<SectionInfo> {\n const response = await this.#http.get<{ section: SectionInfo }>(\n buildResourcePath('collections', collectionKey, 'sections', sectionId),\n )\n return response.section\n }\n\n /**\n * Creates a section in a collection.\n *\n * Sends an `Idempotency-Key` (required of suite bearers): a fresh one per\n * call, or `options.idempotencyKey` to make your own retry safe.\n */\n async create(\n collectionKey: string,\n input: CreateSectionInput,\n options?: IdempotencyOptions,\n ): Promise<SectionInfo> {\n const response = await this.#http.post<{ section: SectionInfo }>(\n buildResourcePath('collections', collectionKey, 'sections'),\n input,\n idempotent(options),\n )\n return response.section\n }\n\n /**\n * Updates a section in a collection.\n */\n async update(\n collectionKey: string,\n sectionId: string,\n input: UpdateSectionInput,\n ): Promise<SectionInfo> {\n const response = await this.#http.patch<{ section: SectionInfo }>(\n buildResourcePath('collections', collectionKey, 'sections', sectionId),\n input,\n )\n return response.section\n }\n\n /**\n * Deletes a section from a collection.\n */\n async delete(collectionKey: string, sectionId: string): Promise<{ success: true }> {\n return this.#http.delete<{ success: true }>(\n buildResourcePath('collections', collectionKey, 'sections', sectionId),\n )\n }\n}\n","import type {\n CollectionDetail,\n CollectionListResponse,\n CreateCollectionInput,\n UpdateCollectionInput,\n} from '../types/collections'\nimport type {\n ClientDefaults,\n DeleteOptions,\n DeliveryStatus,\n IdempotencyOptions,\n} from '../types/common'\nimport { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport { CollectionFieldsResource } from './collection-fields'\nimport { CollectionSectionsResource } from './collection-sections'\nimport { idempotent, toDeleteBody } from './resource-helpers'\n\n/**\n * Read-only collection endpoints.\n */\nexport class CollectionsResource {\n readonly fields: CollectionFieldsResource\n readonly sections: CollectionSectionsResource\n readonly #http: HttpClient\n readonly #defaults: ClientDefaults\n\n /**\n * @internal\n */\n constructor(http: HttpClient, defaults: ClientDefaults) {\n this.#http = http\n this.#defaults = defaults\n this.fields = new CollectionFieldsResource(http)\n this.sections = new CollectionSectionsResource(http)\n }\n\n /**\n * Lists all collections available to the current API key.\n */\n async list(options?: { status?: DeliveryStatus }): Promise<CollectionListResponse> {\n return this.#http.get<CollectionListResponse>(buildResourcePath('collections'), {\n params: {\n status: options?.status ?? this.#defaults.status,\n },\n })\n }\n\n /**\n * Retrieves the schema for a single collection.\n */\n async get(\n collectionKey: string,\n options?: { status?: DeliveryStatus },\n ): Promise<CollectionDetail> {\n return this.#http.get<CollectionDetail>(buildResourcePath('collections', collectionKey), {\n params: {\n status: options?.status ?? this.#defaults.status,\n },\n })\n }\n\n /**\n * Creates a collection.\n *\n * Sends an `Idempotency-Key` (required of suite bearers): a fresh one per\n * call, or `options.idempotencyKey` to make your own retry safe.\n */\n async create(\n input: CreateCollectionInput,\n options?: IdempotencyOptions,\n ): Promise<CollectionDetail> {\n const response = await this.#http.post<{ collection: CollectionDetail }>(\n buildResourcePath('collections'),\n input,\n idempotent(options),\n )\n return response.collection\n }\n\n /**\n * Updates a collection.\n */\n async update(collectionKey: string, input: UpdateCollectionInput): Promise<CollectionDetail> {\n const response = await this.#http.patch<{ collection: CollectionDetail }>(\n buildResourcePath('collections', collectionKey),\n input,\n )\n return response.collection\n }\n\n /**\n * Deletes a collection.\n */\n async delete(collectionKey: string, options?: DeleteOptions): Promise<{ success: true }> {\n return this.#http.delete<{ success: true }>(\n buildResourcePath('collections', collectionKey),\n toDeleteBody(options),\n )\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type {\n CommentDraftAnswer,\n CommentListOptions,\n CommentListResponse,\n CommentReplyAnswer,\n CommentThreadAnswer,\n CreateCommentInput,\n OnPageComments,\n ReplyCommentInput,\n SaveCommentToDraftInput,\n UpdateCommentInput,\n} from '../types/comments'\nimport type { IdempotencyOptions } from '../types/common'\nimport { idempotent } from './resource-helpers'\n\n/**\n * «Comentarios» (`/comments`): comment threads on an entry or a document, a\n * thread flagged `isChangeRequest` carrying an assignee and proposed values.\n *\n * Suite bearers only (`eel_sk_…` / `eel_at_…`, with `X-Eel-Site`): a comment\n * has a person behind it, so site keys are refused. Reads need\n * `zap:content:read`; writes `zap:content:write`, and `create`, `reply` and\n * `saveToDraft` also take `zap:suggest:write`.\n */\nexport class CommentsResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Lists the site's threads, newest first, optionally on one record (an\n * entry by `collection` + `slug`, or a `document`). `counts` covers both\n * statuses whatever `status` filters.\n *\n * `GET /comments`.\n */\n async list(options?: CommentListOptions): Promise<CommentListResponse> {\n return this.#http.get<CommentListResponse>('/comments', {\n // Named one by one: the route's query is strict, so a stray key would be a 400.\n params: {\n collection: options?.collection,\n slug: options?.slug,\n document: options?.document,\n isChangeRequest: options?.isChangeRequest,\n status: options?.status,\n resolution: options?.resolution,\n pageUrl: options?.pageUrl,\n assignee: options?.assignee,\n page: options?.page,\n pageSize: options?.pageSize,\n },\n })\n }\n\n /**\n * Retrieves a thread and its comments, oldest first.\n *\n * `GET /comments/{id}`.\n */\n async get(id: string): Promise<CommentThreadAnswer> {\n return this.#http.get<CommentThreadAnswer>(buildResourcePath('comments', id))\n }\n\n /**\n * Opens a thread with its first comment. Anchors and proposed values name\n * fields by key. Sends an `Idempotency-Key`. 404 for an unknown record, 422\n * `INVALID_ANCHOR` / `INVALID_PROPOSED_VALUE` / `ASSIGNEE_NO_SEAT`, 429\n * `RATE_LIMITED`.\n *\n * `POST /comments`.\n *\n * @example\n * ```ts\n * await zap.comments.create({\n * collection: 'blog',\n * slug: 'hello-world',\n * isChangeRequest: true,\n * body: 'Shorter title?',\n * proposedValues: [{ fieldKey: 'title', value: 'Hello' }],\n * })\n * ```\n */\n async create(\n input: CreateCommentInput,\n options?: IdempotencyOptions,\n ): Promise<CommentThreadAnswer> {\n return this.#http.post<CommentThreadAnswer>('/comments', input, idempotent(options))\n }\n\n /**\n * Changes a thread: `status` (resolve, reopen), a change request's\n * `resolution`, the `isChangeRequest` flag, the assignee, or the first\n * comment's text. 409 `STATUS_CONFLICT`, `INVALID_TRANSITION`,\n * `HAS_PROPOSAL`; 422 `NOT_A_CHANGE_REQUEST`, `HAS_LINKED_TASKS` (turning\n * the flag off while a Swarm task is linked).\n *\n * `PATCH /comments/{id}`.\n */\n async update(id: string, input: UpdateCommentInput): Promise<CommentThreadAnswer> {\n return this.#http.patch<CommentThreadAnswer>(buildResourcePath('comments', id), input)\n }\n\n /**\n * Replies on a thread. Sends an `Idempotency-Key`.\n *\n * `POST /comments/{id}/replies`.\n */\n async reply(\n id: string,\n input: ReplyCommentInput,\n options?: IdempotencyOptions,\n ): Promise<CommentReplyAnswer> {\n return this.#http.post<CommentReplyAnswer>(\n buildResourcePath('comments', id, 'replies'),\n input,\n idempotent(options),\n )\n }\n\n /**\n * «Aplicar al borrador»: writes an open change request's proposed values\n * into the record's draft and resolves it as APPLIED. 409 `NO_PROPOSAL` /\n * `NOT_OPEN`.\n *\n * `POST /comments/{id}/apply`.\n */\n async apply(id: string): Promise<CommentDraftAnswer> {\n return this.#http.post<CommentDraftAnswer>(buildResourcePath('comments', id, 'apply'))\n }\n\n /**\n * Writes proposed values straight into the record's draft, recorded as a\n * change request already resolved as APPLIED; nobody is notified. 403 when\n * the site has live editing off. Sends an `Idempotency-Key`.\n *\n * `POST /comments/save-to-draft`.\n */\n async saveToDraft(\n input: SaveCommentToDraftInput,\n options?: IdempotencyOptions,\n ): Promise<CommentDraftAnswer> {\n return this.#http.post<CommentDraftAnswer>(\n buildResourcePath('comments', 'save-to-draft'),\n input,\n idempotent(options),\n )\n }\n\n /**\n * What the site's suggestion client shows on one page: the viewer, whether\n * live editing is on, the field types of the records tagged there and the\n * page's open threads. `refs` are `data-zap-ref` values (`collection/slug`\n * or `doc:key`); at most 20 are read.\n *\n * `GET /comments/on-page`. Answers only the site's own suggestion client.\n */\n async onPage(url: string, refs: readonly string[] = []): Promise<OnPageComments> {\n return this.#http.get<OnPageComments>(buildResourcePath('comments', 'on-page'), {\n params: { url, refs: refs.length > 0 ? refs.join(',') : undefined },\n })\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type {\n CreateDraftInput,\n DocumentVersionDetail,\n DocumentVersionSummary,\n UpdateDocumentDraftInput,\n VersionListResponse,\n} from '../types/versions'\n\n/**\n * Version history, drafts and rollbacks for documents\n * (`/documents/{documentKey}/versions…`).\n *\n * A document has at most one open draft. Writing needs a secret key;\n * publishing and rolling back need one with publish rights.\n */\nexport class DocumentVersionsResource {\n readonly #http: HttpClient\n\n /** @internal */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Lists a document's versions, newest first.\n */\n async list(documentKey: string): Promise<VersionListResponse<DocumentVersionSummary>> {\n return this.#http.get<VersionListResponse<DocumentVersionSummary>>(\n buildResourcePath('documents', documentKey, 'versions'),\n )\n }\n\n /**\n * Gets one version with its snapshot (values and SEO).\n */\n async get(documentKey: string, versionId: string): Promise<DocumentVersionDetail> {\n const response = await this.#http.get<{ version: DocumentVersionDetail }>(\n buildResourcePath('documents', documentKey, 'versions', versionId),\n )\n return response.version\n }\n\n /**\n * Opens a draft from the document's live state. Fails with `DUPLICATE_KEY`\n * (409) when the document already has one.\n */\n async createDraft(\n documentKey: string,\n input?: CreateDraftInput,\n ): Promise<DocumentVersionSummary> {\n const response = await this.#http.post<{ version: DocumentVersionSummary }>(\n buildResourcePath('documents', documentKey, 'versions'),\n input,\n )\n return response.version\n }\n\n /**\n * Stages values on the open draft without touching the live document.\n * Fails with `VALIDATION_ERROR` (400) when there is no open draft.\n */\n async updateDraft(\n documentKey: string,\n input: UpdateDocumentDraftInput,\n ): Promise<DocumentVersionDetail> {\n const response = await this.#http.put<{ version: DocumentVersionDetail }>(\n buildResourcePath('documents', documentKey, 'versions', 'draft'),\n input,\n )\n return response.version\n }\n\n /**\n * Discards the open draft. Fails with `NOT_FOUND` (404) when there is none.\n */\n async discardDraft(documentKey: string): Promise<void> {\n await this.#http.delete<unknown>(\n buildResourcePath('documents', documentKey, 'versions', 'draft'),\n )\n }\n\n /**\n * Publishes the open draft: its values go live and it becomes the\n * document's published version. Fails with `NOT_FOUND` (404) when there is\n * no draft.\n */\n async publishDraft(documentKey: string): Promise<DocumentVersionSummary> {\n const response = await this.#http.post<{ version: DocumentVersionSummary }>(\n buildResourcePath('documents', documentKey, 'versions', 'draft', 'publish'),\n )\n return response.version\n }\n\n /**\n * Restores a past version over the live document and records the restore\n * as a NEW published version (history is never rewritten). Refused (409)\n * for a draft version, or while the document has an open draft.\n */\n async rollback(documentKey: string, versionId: string): Promise<DocumentVersionSummary> {\n const response = await this.#http.post<{ version: DocumentVersionSummary }>(\n buildResourcePath('documents', documentKey, 'versions', versionId, 'rollback'),\n )\n return response.version\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type {\n CreateDocumentFieldInput,\n DocumentFieldListResponse,\n UpdateDocumentFieldInput,\n} from '../types/documents'\nimport type { FieldInfo } from '../types/collections'\nimport type { IdempotencyOptions } from '../types/common'\nimport { idempotent, normalizeFieldInput } from './resource-helpers'\n\n/**\n * Document field management endpoints.\n */\nexport class DocumentFieldsResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Lists all fields in a document.\n */\n async list(documentKey: string): Promise<FieldInfo[]> {\n const response = await this.#http.get<DocumentFieldListResponse>(\n buildResourcePath('documents', documentKey, 'fields'),\n )\n return response.fields\n }\n\n /**\n * Gets a single field in a document.\n */\n async get(documentKey: string, fieldId: string): Promise<FieldInfo> {\n const response = await this.#http.get<{ field: FieldInfo }>(\n buildResourcePath('documents', documentKey, 'fields', fieldId),\n )\n return response.field\n }\n\n /**\n * Creates a field in a document.\n *\n * Sends an `Idempotency-Key` (required of suite bearers): a fresh one per\n * call, or `options.idempotencyKey` to make your own retry safe.\n */\n async create(\n documentKey: string,\n input: CreateDocumentFieldInput,\n options?: IdempotencyOptions,\n ): Promise<FieldInfo> {\n const response = await this.#http.post<{ field: FieldInfo }>(\n buildResourcePath('documents', documentKey, 'fields'),\n normalizeFieldInput(input),\n idempotent(options),\n )\n return response.field\n }\n\n /**\n * Updates a field in a document.\n */\n async update(\n documentKey: string,\n fieldId: string,\n input: UpdateDocumentFieldInput,\n ): Promise<FieldInfo> {\n const response = await this.#http.patch<{ field: FieldInfo }>(\n buildResourcePath('documents', documentKey, 'fields', fieldId),\n normalizeFieldInput(input),\n )\n return response.field\n }\n\n /**\n * Deletes a field from a document.\n */\n async delete(documentKey: string, fieldId: string): Promise<{ success: true }> {\n return this.#http.delete<{ success: true }>(\n buildResourcePath('documents', documentKey, 'fields', fieldId),\n )\n }\n\n /**\n * Lists the document's archived (soft-deleted) fields, most recently\n * deleted first. Their values are kept, which is what makes `restore` work.\n *\n * `GET /documents/{documentKey}/fields/deleted`. Secret key, or suite bearer\n * with `zap:content:read`.\n */\n async listDeleted(documentKey: string): Promise<FieldInfo[]> {\n const response = await this.#http.get<DocumentFieldListResponse>(\n buildResourcePath('documents', documentKey, 'fields', 'deleted'),\n )\n return response.fields\n }\n\n /**\n * Brings an archived field back with every value it held, at the end of the\n * root list (outside any section).\n *\n * `POST /documents/{documentKey}/fields/{fieldId}/restore`. Secret key, or\n * suite bearer with `zap:schema:write` and the Zap ADMIN role.\n */\n async restore(documentKey: string, fieldId: string): Promise<FieldInfo> {\n const response = await this.#http.post<{ field: FieldInfo }>(\n buildResourcePath('documents', documentKey, 'fields', fieldId, 'restore'),\n )\n return response.field\n }\n\n /**\n * Reorders document fields.\n */\n async reorder(documentKey: string, fieldIds: string[]): Promise<{ success: true }> {\n return this.#http.post<{ success: true }>(\n buildResourcePath('documents', documentKey, 'fields', 'reorder'),\n { fieldIds },\n )\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type { SectionInfo, CreateSectionInput, UpdateSectionInput } from '../types/collections'\nimport type { IdempotencyOptions } from '../types/common'\nimport type { DocumentSectionListResponse } from '../types/documents'\nimport { idempotent } from './resource-helpers'\n\n/**\n * Document section management endpoints.\n */\nexport class DocumentSectionsResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Lists all sections in a document.\n */\n async list(documentKey: string): Promise<SectionInfo[]> {\n const response = await this.#http.get<DocumentSectionListResponse>(\n buildResourcePath('documents', documentKey, 'sections'),\n )\n return response.sections\n }\n\n /**\n * Gets a single section from a document.\n */\n async get(documentKey: string, sectionId: string): Promise<SectionInfo> {\n const response = await this.#http.get<{ section: SectionInfo }>(\n buildResourcePath('documents', documentKey, 'sections', sectionId),\n )\n return response.section\n }\n\n /**\n * Creates a section in a document.\n *\n * Sends an `Idempotency-Key` (required of suite bearers): a fresh one per\n * call, or `options.idempotencyKey` to make your own retry safe.\n */\n async create(\n documentKey: string,\n input: CreateSectionInput,\n options?: IdempotencyOptions,\n ): Promise<SectionInfo> {\n const response = await this.#http.post<{ section: SectionInfo }>(\n buildResourcePath('documents', documentKey, 'sections'),\n input,\n idempotent(options),\n )\n return response.section\n }\n\n /**\n * Updates a section in a document.\n */\n async update(\n documentKey: string,\n sectionId: string,\n input: UpdateSectionInput,\n ): Promise<SectionInfo> {\n const response = await this.#http.patch<{ section: SectionInfo }>(\n buildResourcePath('documents', documentKey, 'sections', sectionId),\n input,\n )\n return response.section\n }\n\n /**\n * Deletes a section from a document.\n */\n async delete(documentKey: string, sectionId: string): Promise<{ success: true }> {\n return this.#http.delete<{ success: true }>(\n buildResourcePath('documents', documentKey, 'sections', sectionId),\n )\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type { SeoInput } from '../types/common'\nimport type { DocumentSeo, DocumentSeoResponse } from '../types/documents'\n\n/**\n * Document SEO management endpoints.\n */\nexport class DocumentSeoResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Gets SEO metadata for a document.\n */\n async get(documentKey: string, options?: { locale?: string }): Promise<DocumentSeo> {\n const response = await this.#http.get<DocumentSeoResponse>(\n buildResourcePath('documents', documentKey, 'seo'),\n {\n params: {\n locale: options?.locale,\n },\n },\n )\n return response.seo\n }\n\n /**\n * Updates SEO metadata for a document.\n */\n async update(documentKey: string, input: SeoInput): Promise<DocumentSeo> {\n const response = await this.#http.put<DocumentSeoResponse>(\n buildResourcePath('documents', documentKey, 'seo'),\n input,\n )\n return response.seo\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type { DocumentValuesResponse } from '../types/documents'\n\n/**\n * Document value management endpoints.\n */\nexport class DocumentValuesResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Gets all document values.\n */\n async get(documentKey: string): Promise<Record<string, unknown>> {\n const response = await this.#http.get<DocumentValuesResponse>(\n buildResourcePath('documents', documentKey, 'values'),\n )\n return response.values\n }\n\n /**\n * Updates document values by field key.\n */\n async update(\n documentKey: string,\n values: Record<string, unknown>,\n options?: { locale?: string },\n ): Promise<Record<string, unknown>> {\n const response = await this.#http.put<DocumentValuesResponse>(\n buildResourcePath('documents', documentKey, 'values'),\n {\n locale: options?.locale,\n values,\n },\n )\n return response.values\n }\n}\n","import { HttpClient } from '../http'\nimport type { ClientDefaults, IdempotencyOptions } from '../types/common'\nimport type {\n CreateDocumentInput,\n DeleteDocumentOptions,\n DocumentDetail,\n DocumentGetOptions,\n DocumentListOptions,\n DocumentListResponse,\n UpdateDocumentInput,\n} from '../types/documents'\nimport { buildResourcePath } from '../paths'\nimport { DocumentFieldsResource } from './document-fields'\nimport { DocumentSectionsResource } from './document-sections'\nimport { DocumentSeoResource } from './document-seo'\nimport { DocumentValuesResource } from './document-values'\nimport { idempotent, toDeleteBody } from './resource-helpers'\nimport { mergeRequestOptions, previewParam, toArrayParam } from '../utils'\n\n/**\n * Read-only document endpoints.\n */\nexport class DocumentsResource {\n readonly fields: DocumentFieldsResource\n readonly sections: DocumentSectionsResource\n readonly values: DocumentValuesResource\n readonly seo: DocumentSeoResource\n readonly #http: HttpClient\n readonly #defaults: ClientDefaults\n\n /**\n * @internal\n */\n constructor(http: HttpClient, defaults: ClientDefaults) {\n this.#http = http\n this.#defaults = defaults\n this.fields = new DocumentFieldsResource(http)\n this.sections = new DocumentSectionsResource(http)\n this.values = new DocumentValuesResource(http)\n this.seo = new DocumentSeoResource(http)\n }\n\n /**\n * Lists all documents available to the current API key.\n */\n async list(options?: DocumentListOptions): Promise<DocumentListResponse> {\n const merged = mergeRequestOptions(this.#defaults, options)\n\n return this.#http.get<DocumentListResponse>(buildResourcePath('documents'), {\n params: {\n locale: merged.locale,\n status: merged.status,\n ...previewParam(merged),\n },\n })\n }\n\n /**\n * Retrieves a single document by key.\n */\n async get<TContent = Record<string, unknown>>(\n documentKey: string,\n options?: DocumentGetOptions,\n ): Promise<DocumentDetail<TContent>> {\n const merged = mergeRequestOptions(this.#defaults, options)\n\n return this.#http.get<DocumentDetail<TContent>>(buildResourcePath('documents', documentKey), {\n params: {\n locale: merged.locale,\n status: merged.status,\n fields: toArrayParam(merged.fields),\n ...previewParam(merged),\n },\n })\n }\n\n /**\n * Creates a document.\n *\n * Sends an `Idempotency-Key` (required of suite bearers): a fresh one per\n * call, or `options.idempotencyKey` to make your own retry safe.\n */\n async create<TContent = Record<string, unknown>>(\n input: CreateDocumentInput,\n options?: IdempotencyOptions,\n ): Promise<DocumentDetail<TContent>> {\n const response = await this.#http.post<{ document: DocumentDetail<TContent> }>(\n buildResourcePath('documents'),\n input,\n idempotent(options),\n )\n return response.document\n }\n\n /**\n * Updates a document.\n */\n async update<TContent = Record<string, unknown>>(\n documentKey: string,\n input: UpdateDocumentInput,\n ): Promise<DocumentDetail<TContent>> {\n const response = await this.#http.patch<{ document: DocumentDetail<TContent> }>(\n buildResourcePath('documents', documentKey),\n input,\n )\n return response.document\n }\n\n /**\n * Deletes a document.\n */\n async delete(documentKey: string, options?: DeleteDocumentOptions): Promise<{ success: true }> {\n return this.#http.delete<{ success: true }>(\n buildResourcePath('documents', documentKey),\n toDeleteBody(options),\n )\n }\n\n /**\n * Publishes a document.\n */\n async publish<TContent = Record<string, unknown>>(\n documentKey: string,\n ): Promise<DocumentDetail<TContent>> {\n const response = await this.#http.post<{ document: DocumentDetail<TContent> }>(\n buildResourcePath('documents', documentKey, 'publish'),\n )\n return response.document\n }\n\n /**\n * Unpublishes a document.\n */\n async unpublish<TContent = Record<string, unknown>>(\n documentKey: string,\n ): Promise<DocumentDetail<TContent>> {\n const response = await this.#http.post<{ document: DocumentDetail<TContent> }>(\n buildResourcePath('documents', documentKey, 'unpublish'),\n )\n return response.document\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type {\n CreateDraftInput,\n ItemVersionDetail,\n ItemVersionSummary,\n UpdateItemDraftInput,\n VersionListResponse,\n} from '../types/versions'\n\n/**\n * Version history, drafts and rollbacks for collection items\n * (`/collections/{collectionKey}/items/{slug}/versions…`).\n *\n * An item has at most one open draft. Writing needs a secret key; publishing\n * and rolling back need one with publish rights.\n */\nexport class ItemVersionsResource {\n readonly #http: HttpClient\n\n /** @internal */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Lists an item's versions, newest first.\n */\n async list(\n collectionKey: string,\n slug: string,\n ): Promise<VersionListResponse<ItemVersionSummary>> {\n return this.#http.get<VersionListResponse<ItemVersionSummary>>(\n buildResourcePath('collections', collectionKey, 'items', slug, 'versions'),\n )\n }\n\n /**\n * Gets one version with its snapshot (values, SEO and slugs).\n */\n async get(collectionKey: string, slug: string, versionId: string): Promise<ItemVersionDetail> {\n const response = await this.#http.get<{ version: ItemVersionDetail }>(\n buildResourcePath('collections', collectionKey, 'items', slug, 'versions', versionId),\n )\n return response.version\n }\n\n /**\n * Opens a draft from the item's live state. Fails with `DUPLICATE_KEY` (409)\n * when the item already has one.\n */\n async createDraft(\n collectionKey: string,\n slug: string,\n input?: CreateDraftInput,\n ): Promise<ItemVersionSummary> {\n const response = await this.#http.post<{ version: ItemVersionSummary }>(\n buildResourcePath('collections', collectionKey, 'items', slug, 'versions'),\n input,\n )\n return response.version\n }\n\n /**\n * Stages values (and optionally a new slug) on the open draft without\n * touching the live item. Fails with `VALIDATION_ERROR` (400) when there is\n * no open draft.\n */\n async updateDraft(\n collectionKey: string,\n slug: string,\n input: UpdateItemDraftInput,\n ): Promise<ItemVersionDetail> {\n const response = await this.#http.put<{ version: ItemVersionDetail }>(\n buildResourcePath('collections', collectionKey, 'items', slug, 'versions', 'draft'),\n input,\n )\n return response.version\n }\n\n /**\n * Discards the open draft. Fails with `NOT_FOUND` (404) when there is none.\n */\n async discardDraft(collectionKey: string, slug: string): Promise<void> {\n await this.#http.delete<unknown>(\n buildResourcePath('collections', collectionKey, 'items', slug, 'versions', 'draft'),\n )\n }\n\n /**\n * Publishes the open draft: its values go live and it becomes the item's\n * published version. Fails with `NOT_FOUND` (404) when there is no draft.\n */\n async publishDraft(collectionKey: string, slug: string): Promise<ItemVersionSummary> {\n const response = await this.#http.post<{ version: ItemVersionSummary }>(\n buildResourcePath(\n 'collections',\n collectionKey,\n 'items',\n slug,\n 'versions',\n 'draft',\n 'publish',\n ),\n )\n return response.version\n }\n\n /**\n * Restores a past version over the live item and records the restore as a\n * NEW published version (history is never rewritten). Refused (409) for a\n * draft version, or while the item has an open draft.\n */\n async rollback(\n collectionKey: string,\n slug: string,\n versionId: string,\n ): Promise<ItemVersionSummary> {\n const response = await this.#http.post<{ version: ItemVersionSummary }>(\n buildResourcePath(\n 'collections',\n collectionKey,\n 'items',\n slug,\n 'versions',\n versionId,\n 'rollback',\n ),\n )\n return response.version\n }\n}\n","import { HttpClient } from './http'\nimport type { ClientDefaults } from './types/common'\nimport type { FilterValue, ItemDetail, ItemListOptions, ItemListResponse } from './types/items'\nimport { ItemsResource } from './resources/items'\n\n/**\n * Lazy fluent query builder for item list requests.\n */\nexport class ItemQueryBuilder {\n readonly #http: HttpClient\n readonly #defaults: ClientDefaults\n readonly #collectionKey: string\n readonly #options: ItemListOptions\n\n /**\n * @internal\n */\n constructor(\n http: HttpClient,\n defaults: ClientDefaults,\n collectionKey: string,\n options: ItemListOptions = {},\n ) {\n this.#http = http\n this.#defaults = defaults\n this.#collectionKey = collectionKey\n this.#options = options\n }\n\n /**\n * Overrides the request locale.\n */\n locale(locale: string): ItemQueryBuilder {\n return this.clone({ locale })\n }\n\n /**\n * Overrides the delivery status filter.\n */\n status(status: NonNullable<ItemListOptions['status']>): ItemQueryBuilder {\n return this.clone({ status })\n }\n\n /**\n * Adds or replaces a field filter.\n */\n filter(field: string, value: FilterValue): ItemQueryBuilder {\n return this.clone({\n filter: {\n ...(this.#options.filter ?? {}),\n [field]: value,\n },\n })\n }\n\n /**\n * Sets the sort expression.\n */\n sort(sort: string): ItemQueryBuilder {\n return this.clone({ sort })\n }\n\n /**\n * Selects a sparse set of content fields.\n */\n fields(fields: string[]): ItemQueryBuilder {\n return this.clone({ fields })\n }\n\n /**\n * Sets the current page.\n */\n page(page: number): ItemQueryBuilder {\n return this.clone({ page })\n }\n\n /**\n * Sets the page size.\n */\n pageSize(pageSize: number): ItemQueryBuilder {\n return this.clone({ pageSize })\n }\n\n /**\n * Executes the built request.\n */\n async get<TContent = Record<string, unknown>>(): Promise<ItemListResponse<TContent>> {\n const resource = new ItemsResource(this.#http, this.#defaults)\n return resource.list<TContent>(this.#collectionKey, this.#options)\n }\n\n /**\n * Returns the current request options as a plain object.\n */\n toJSON(): ItemListOptions {\n return {\n ...this.#options,\n filter: this.#options.filter ? { ...this.#options.filter } : undefined,\n fields: this.#options.fields ? [...this.#options.fields] : undefined,\n }\n }\n\n private clone(partial: Partial<ItemListOptions>): ItemQueryBuilder {\n return new ItemQueryBuilder(this.#http, this.#defaults, this.#collectionKey, {\n ...this.#options,\n ...partial,\n })\n }\n}\n\nexport type { ItemDetail }\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type { SeoInput } from '../types/common'\nimport type { ItemSeo, ItemSeoResponse } from '../types/items'\n\n/**\n * Item SEO management endpoints.\n */\nexport class ItemSeoResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Gets SEO metadata for an item.\n */\n async get(collectionKey: string, slug: string, options?: { locale?: string }): Promise<ItemSeo> {\n const response = await this.#http.get<ItemSeoResponse>(\n buildResourcePath('collections', collectionKey, 'items', slug, 'seo'),\n {\n params: {\n locale: options?.locale,\n },\n },\n )\n return response.seo\n }\n\n /**\n * Updates SEO metadata for an item.\n */\n async update(collectionKey: string, slug: string, input: SeoInput): Promise<ItemSeo> {\n const response = await this.#http.patch<ItemSeoResponse>(\n buildResourcePath('collections', collectionKey, 'items', slug, 'seo'),\n input,\n )\n return response.seo\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport { ItemQueryBuilder } from '../query-builder'\nimport type { ClientDefaults, IdempotencyOptions } from '../types/common'\nimport type {\n CreateItemInput,\n DeleteItemOptions,\n ItemDetail,\n ItemGetOptions,\n ItemListOptions,\n ItemListResponse,\n UpdateItemInput,\n} from '../types/items'\nimport { mergeRequestOptions, previewParam, serializeFilters, toArrayParam } from '../utils'\nimport { ItemSeoResource } from './item-seo'\nimport { idempotent, toDeleteBody } from './resource-helpers'\n\n/**\n * Read-only collection item endpoints.\n */\nexport class ItemsResource {\n readonly seo: ItemSeoResource\n readonly #http: HttpClient\n readonly #defaults: ClientDefaults\n\n /**\n * @internal\n */\n constructor(http: HttpClient, defaults: ClientDefaults) {\n this.#http = http\n this.#defaults = defaults\n this.seo = new ItemSeoResource(http)\n }\n\n /**\n * Lists items in a collection.\n */\n async list<TContent = Record<string, unknown>>(\n collectionKey: string,\n options?: ItemListOptions,\n ): Promise<ItemListResponse<TContent>> {\n const merged = mergeRequestOptions(this.#defaults, options)\n\n return this.#http.get<ItemListResponse<TContent>>(\n buildResourcePath('collections', collectionKey, 'items'),\n {\n params: {\n locale: merged.locale,\n status: merged.status,\n fields: toArrayParam(merged.fields),\n page: merged.page,\n pageSize: merged.pageSize,\n sort: merged.sort,\n ...serializeFilters(merged.filter),\n ...previewParam(merged),\n },\n },\n )\n }\n\n /**\n * Retrieves a single item by slug.\n */\n async get<TContent = Record<string, unknown>>(\n collectionKey: string,\n slug: string,\n options?: ItemGetOptions,\n ): Promise<ItemDetail<TContent>> {\n const merged = mergeRequestOptions(this.#defaults, options)\n\n return this.#http.get<ItemDetail<TContent>>(\n buildResourcePath('collections', collectionKey, 'items', slug),\n {\n params: {\n locale: merged.locale,\n status: merged.status,\n fields: toArrayParam(merged.fields),\n ...previewParam(merged),\n },\n },\n )\n }\n\n /**\n * Starts a lazy fluent query builder for a collection.\n */\n collection(collectionKey: string): ItemQueryBuilder {\n return new ItemQueryBuilder(this.#http, this.#defaults, collectionKey)\n }\n\n /**\n * Creates an item in a collection.\n *\n * Sends an `Idempotency-Key` (required of suite bearers): a fresh one per\n * call, or `options.idempotencyKey` to make your own retry safe.\n */\n async create<TContent = Record<string, unknown>>(\n collectionKey: string,\n input: CreateItemInput,\n options?: IdempotencyOptions,\n ): Promise<ItemDetail<TContent>> {\n const response = await this.#http.post<{ item: ItemDetail<TContent> }>(\n buildResourcePath('collections', collectionKey, 'items'),\n input,\n idempotent(options),\n )\n return response.item\n }\n\n /**\n * Updates an item by slug.\n */\n async update<TContent = Record<string, unknown>>(\n collectionKey: string,\n slug: string,\n input: UpdateItemInput,\n ): Promise<ItemDetail<TContent>> {\n const response = await this.#http.patch<{ item: ItemDetail<TContent> }>(\n buildResourcePath('collections', collectionKey, 'items', slug),\n input,\n )\n return response.item\n }\n\n /**\n * Deletes an item by slug.\n */\n async delete(\n collectionKey: string,\n slug: string,\n options?: DeleteItemOptions,\n ): Promise<{ success: true }> {\n return this.#http.delete<{ success: true }>(\n buildResourcePath('collections', collectionKey, 'items', slug),\n toDeleteBody(options),\n )\n }\n\n /**\n * Publishes an item by slug.\n */\n async publish<TContent = Record<string, unknown>>(\n collectionKey: string,\n slug: string,\n ): Promise<ItemDetail<TContent>> {\n const response = await this.#http.post<{ item: ItemDetail<TContent> }>(\n buildResourcePath('collections', collectionKey, 'items', slug, 'publish'),\n )\n return response.item\n }\n\n /**\n * Unpublishes an item by slug.\n */\n async unpublish<TContent = Record<string, unknown>>(\n collectionKey: string,\n slug: string,\n ): Promise<ItemDetail<TContent>> {\n const response = await this.#http.post<{ item: ItemDetail<TContent> }>(\n buildResourcePath('collections', collectionKey, 'items', slug, 'unpublish'),\n )\n return response.item\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type { IdempotencyOptions } from '../types/common'\nimport { normalizeHeaderValue } from '../utils'\nimport { idempotent } from './resource-helpers'\nimport type {\n ConfirmUploadInput,\n CreateUploadUrlInput,\n MediaDetail,\n MediaFromUrlInput,\n MediaListParams,\n MediaListResponse,\n MediaUploadInput,\n UpdateMediaInput,\n UploadFile,\n UploadUrlResponse,\n} from '../types/media'\n\nfunction isBlobFile(file: UploadFile): file is Blob {\n return typeof Blob !== 'undefined' && file instanceof Blob\n}\n\nfunction toUploadBody(file: UploadFile): BodyInit {\n if (isBlobFile(file)) {\n return file\n }\n\n if (ArrayBuffer.isView(file)) {\n const bytes =\n file.buffer instanceof ArrayBuffer\n ? file.buffer.slice(file.byteOffset, file.byteOffset + file.byteLength)\n : new Uint8Array(file.buffer, file.byteOffset, file.byteLength).slice().buffer\n return new Blob([bytes])\n }\n\n return file\n}\n\nfunction getUploadSize(file: UploadFile): number {\n if (isBlobFile(file)) {\n return file.size\n }\n\n if (ArrayBuffer.isView(file)) {\n return file.byteLength\n }\n\n return file instanceof ArrayBuffer ? file.byteLength : 0\n}\n\n/**\n * Media management endpoints.\n */\nexport class MediaResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Lists media for the current site.\n */\n async list(params?: MediaListParams): Promise<MediaListResponse> {\n return this.#http.get<MediaListResponse>(buildResourcePath('media'), {\n params: {\n search: params?.search,\n page: params?.page,\n pageSize: params?.pageSize,\n sort: params?.sort,\n type: params?.type,\n status: params?.status,\n usage: params?.usage,\n },\n })\n }\n\n /**\n * Gets a single media item.\n */\n async get(id: string): Promise<MediaDetail> {\n return this.#http.get<MediaDetail>(buildResourcePath('media', id))\n }\n\n /**\n * Updates media metadata.\n */\n async update(id: string, input: UpdateMediaInput): Promise<MediaDetail> {\n const response = await this.#http.patch<{ media: MediaDetail }>(\n buildResourcePath('media', id),\n input,\n )\n return response.media\n }\n\n /**\n * Deletes media.\n */\n async delete(id: string): Promise<{ success: true }> {\n return this.#http.delete<{ success: true }>(buildResourcePath('media', id))\n }\n\n /**\n * Publishes media.\n */\n async publish(id: string): Promise<MediaDetail> {\n const response = await this.#http.post<{ media: MediaDetail }>(\n buildResourcePath('media', id, 'publish'),\n )\n return response.media\n }\n\n /**\n * Unpublishes media.\n */\n async unpublish(id: string): Promise<MediaDetail> {\n const response = await this.#http.post<{ media: MediaDetail }>(\n buildResourcePath('media', id, 'unpublish'),\n )\n return response.media\n }\n\n /**\n * Requests a presigned upload URL.\n */\n async createUploadUrl(input: CreateUploadUrlInput): Promise<UploadUrlResponse> {\n return this.#http.post<UploadUrlResponse>(buildResourcePath('media', 'upload-url'), input)\n }\n\n /**\n * Confirms a completed upload.\n */\n async confirmUpload(input: ConfirmUploadInput): Promise<MediaDetail> {\n const response = await this.#http.post<{ media: MediaDetail }>(\n buildResourcePath('media', 'confirm'),\n input,\n )\n return response.media\n }\n\n /**\n * Fetches a file from a URL into the media library, server-side (SSRF\n * guarded, type allowlist, size ceiling). The file starts private (`DRAFT`):\n * the answer carries a 15-minute `signedUrl` and no `url` until `publish`.\n *\n * `POST /media/from-url`. Secret key, or suite bearer with\n * `zap:media:write`. Sends an `Idempotency-Key` (required of suite bearers;\n * a retry with the same key replays the first answer without downloading\n * again). Server-side only: the API's general CORS does not allow that\n * header from a browser.\n */\n async fromUrl(input: MediaFromUrlInput, options?: IdempotencyOptions): Promise<MediaDetail> {\n return this.#http.post<MediaDetail>(\n buildResourcePath('media', 'from-url'),\n input,\n idempotent(options),\n )\n }\n\n /**\n * Uploads media using the public presigned URL flow.\n */\n async upload(input: MediaUploadInput): Promise<MediaDetail> {\n const upload = await this.createUploadUrl({\n filename: input.filename,\n contentType: input.contentType,\n size: getUploadSize(input.file),\n width: input.width,\n height: input.height,\n })\n\n await this.#http.upload(upload.uploadUrl, toUploadBody(input.file), {\n 'Content-Type': input.contentType,\n })\n\n const media = await this.confirmUpload({\n mediaId: upload.mediaId,\n key: upload.key,\n filename: input.filename,\n contentType: input.contentType,\n size: getUploadSize(input.file),\n width: input.width,\n height: input.height,\n })\n\n const alt = normalizeHeaderValue(input.alt)\n const title = normalizeHeaderValue(input.title)\n const description = normalizeHeaderValue(input.description)\n\n if (!alt && !title && !description) {\n return media\n }\n\n return this.update(media.id, {\n alt: alt ?? null,\n title: title ?? null,\n description: description ?? null,\n })\n }\n}\n","import { HttpClient } from '../http'\nimport type { PreviewTokenValidation } from '../types/common'\n\n/**\n * Preview tokens (`zpt_…`, zap-cms-v2 §3.5): ten minutes, one site, read-only.\n */\nexport class PreviewTokensResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Checks that the client's preview token is live AND was minted for the\n * site `siteApiKey` belongs to, before trusting it (what a draft-mode route\n * does before turning draft mode on). Rejects with `EelZapError` 401 for an\n * unknown, revoked or expired token, 403 `WRONG_SITE` for another site's.\n *\n * `GET /preview/token`. The client's `apiKey` must be the `zpt_` token\n * itself (any other bearer is 403); `siteApiKey` is one of the site's own\n * API keys (public or secret), sent as `X-Zap-Site-Api-Key`.\n *\n * @example\n * ```ts\n * const zap = createClient({ apiKey: token })\n * const { site, expiresAt } = await zap.previewTokens.validate(process.env.ZAP_PUBLIC_KEY!)\n * ```\n */\n async validate(siteApiKey: string): Promise<PreviewTokenValidation> {\n return this.#http.get<PreviewTokenValidation>('/preview/token', {\n headers: { 'X-Zap-Site-Api-Key': siteApiKey },\n })\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type { SiteInfo, UpdateSiteInput } from '../types/common'\n\n/**\n * The site the API key belongs to: read it, and set where it lives.\n */\nexport class SiteResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Resolves the current site from the authenticated API key.\n */\n async get(): Promise<SiteInfo> {\n return this.#http.get<SiteInfo>(buildResourcePath('site'))\n }\n\n /**\n * Sets the site's URL and «Otros dominios» (`PATCH /site`), under the same\n * rules as the site's settings page, and resolves to the updated site.\n * Server code only: it needs a `secret_` key or an ADMIN suite credential.\n */\n async update(input: UpdateSiteInput): Promise<SiteInfo> {\n return this.#http.patch<SiteInfo>(buildResourcePath('site'), input)\n }\n}\n","import { HttpClient } from '../http'\nimport type { SiteListEntry } from '../types/common'\n\n/**\n * The credential's workspace's sites.\n */\nexport class SitesResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Lists the workspace's sites, newest first. Each one's `key` or `id` is a\n * valid `X-Eel-Site` for every other call; this is how a suite client\n * learns which sites it can address.\n *\n * `GET /sites`. Suite bearer only (`eel_sk_` / `eel_at_`), `zap:sites:read`;\n * needs no `X-Eel-Site`. Site keys are refused: a site key is one site.\n */\n async list(): Promise<SiteListEntry[]> {\n const response = await this.#http.get<{ sites: SiteListEntry[] }>('/sites')\n return response.sites\n }\n}\n","import { HttpClient } from './http'\nimport { CollectionsResource } from './resources/collections'\nimport { CommentsResource } from './resources/comments'\nimport { DocumentVersionsResource } from './resources/document-versions'\nimport { DocumentsResource } from './resources/documents'\nimport { ItemVersionsResource } from './resources/item-versions'\nimport { ItemsResource } from './resources/items'\nimport { MediaResource } from './resources/media'\nimport { PreviewTokensResource } from './resources/preview-tokens'\nimport { resolveRetry, type RetryOptions } from './retry'\nimport { SiteResource } from './resources/site'\nimport { SitesResource } from './resources/sites'\nimport type { ClientDefaults, DeliveryStatus } from './types/common'\nimport { isPreviewToken, maskApiKey, normalizeBaseUrl } from './utils'\n\nexport interface ClientConfig {\n /**\n * The bearer: a site API key (`secret_…` / `public_…`), or a preview token\n * (`zpt_…`) from a draft-mode URL — which turns `preview` on by default.\n */\n apiKey: string\n baseUrl?: string\n pathPrefix?: string\n locale?: string\n status?: DeliveryStatus\n /** Default for the item and document reads' `preview` option. */\n preview?: boolean\n fetch?: typeof globalThis.fetch\n defaultHeaders?: HeadersInit\n /** Per attempt, in ms. Default `30000`. */\n timeout?: number\n /**\n * Retries of a `429`, and of a `503` with `Retry-After`, honouring\n * `Retry-After` with exponential backoff and jitter. On by default for reads\n * and for writes that carry an `Idempotency-Key`; other writes are never\n * retried. `false` turns it off.\n */\n retry?: boolean | RetryOptions\n}\n\n/**\n * Main SDK client for the EelZap Content Delivery API.\n */\nexport class EelZapClient {\n readonly site: SiteResource\n readonly sites: SitesResource\n readonly collections: CollectionsResource\n readonly items: ItemsResource\n readonly documents: DocumentsResource\n readonly media: MediaResource\n readonly itemVersions: ItemVersionsResource\n readonly documentVersions: DocumentVersionsResource\n readonly previewTokens: PreviewTokensResource\n readonly comments: CommentsResource\n readonly #http: HttpClient\n readonly #defaults: ClientDefaults\n readonly #config: Required<Pick<ClientConfig, 'apiKey' | 'baseUrl' | 'pathPrefix' | 'timeout'>> &\n Pick<ClientConfig, 'defaultHeaders'>\n\n constructor(config: ClientConfig) {\n if (!config.apiKey.trim()) {\n throw new TypeError('apiKey is required.')\n }\n\n const fetchImpl = config.fetch ?? globalThis.fetch\n if (typeof fetchImpl !== 'function') {\n throw new TypeError('A fetch implementation is required.')\n }\n\n this.#defaults = {\n locale: config.locale,\n status: config.status,\n // A preview token only ever reads previews; say so on the wire too.\n preview: config.preview ?? (isPreviewToken(config.apiKey) || undefined),\n }\n\n this.#config = {\n apiKey: config.apiKey,\n baseUrl: normalizeBaseUrl(config.baseUrl ?? 'https://api.eelzap.com'),\n pathPrefix: config.pathPrefix ?? '/v1',\n defaultHeaders: config.defaultHeaders,\n timeout: config.timeout ?? 30_000,\n }\n\n this.#http = new HttpClient({\n apiKey: this.#config.apiKey,\n baseUrl: this.#config.baseUrl,\n pathPrefix: this.#config.pathPrefix,\n fetch: fetchImpl,\n defaultHeaders: this.#config.defaultHeaders,\n timeout: this.#config.timeout,\n retry: resolveRetry(config.retry),\n })\n\n this.site = new SiteResource(this.#http)\n this.sites = new SitesResource(this.#http)\n this.collections = new CollectionsResource(this.#http, this.#defaults)\n this.items = new ItemsResource(this.#http, this.#defaults)\n this.documents = new DocumentsResource(this.#http, this.#defaults)\n this.media = new MediaResource(this.#http)\n this.itemVersions = new ItemVersionsResource(this.#http)\n this.documentVersions = new DocumentVersionsResource(this.#http)\n this.previewTokens = new PreviewTokensResource(this.#http)\n this.comments = new CommentsResource(this.#http)\n }\n\n /**\n * Returns a masked string representation safe for logs.\n */\n toString(): string {\n return `EelZapClient(baseUrl=${this.#config.baseUrl}, pathPrefix=${this.#config.pathPrefix}, apiKey=${maskApiKey(this.#config.apiKey)})`\n }\n}\n\n/**\n * Creates a configured EelZap Delivery SDK client.\n */\nexport function createClient(config: ClientConfig): EelZapClient {\n return new EelZapClient(config)\n}\n","import type { MediaValue } from './types/common'\n\n/**\n * The URL to render a media value with: the public `url` of a published file,\n * else the short-lived `signedUrl` a draft carries when the key may read\n * drafts. `null` when there is neither — an unpublished file read with a key\n * that cannot see drafts (`mediaAccess: 'none'`), or no media at all.\n *\n * A signed URL expires (`signedUrlExpiresAt`), so never cache it in a page\n * that outlives that time.\n */\nexport function getMediaUrl(\n media: Pick<MediaValue, 'url' | 'signedUrl'> | null | undefined,\n): string | null {\n return media?.url ?? media?.signedUrl ?? null\n}\n","/**\n * Stega: invisible field markers on prose values read in preview\n * (`.docs/proposals/zap-cms-v2.md` §2.4, §7.5).\n *\n * Zap appends a marker to TEXT and LONG_TEXT values, and to the last text\n * node of each RICH_TEXT block, ONLY in `preview=1` delivery responses. The\n * preview overlay finds the marker in the page's text nodes and so knows\n * which element renders which field, with no manual tag. Published responses\n * never carry one.\n *\n * ## Format (eelzap stega v1)\n *\n * A marker is the tag the overlay would read from a `data-zap` attribute,\n * `recordRef#fieldKey`, plus `@locale` when the value belongs to a locale:\n *\n * blog-posts/mi-primer-post#title@es\n * doc:home#hero_title@es\n *\n * written as zero-width characters:\n *\n * - four digits, base 4: U+200B (0), U+200C (1), U+200D (2), U+2060 (3);\n * - a prefix of 8 digits, the bytes 0xE5 0xA7 (`3211 2213`);\n * - then every byte of the ASCII payload as 4 digits, most significant first.\n *\n * The payload is printable ASCII (the tag grammar allows nothing else), so\n * every payload byte starts with digit 0 or 1 and the prefix, which starts\n * with 3, can never be read inside a payload. A decoder reads groups of four\n * after the prefix until a group is not a payload byte, then validates the\n * result against the tag grammar; anything that does not parse is ignored. A\n * value never carries two markers (`stegaEncode` refuses to add a second).\n *\n * Why not `@vercel/stega`'s format: it encodes a JSON object (a URL and\n * origin in Sanity's and Vercel's use) and uses U+FEFF, which some tools strip\n * as a byte order mark. Here the decoded marker IS the tag grammar\n * (`data-zap`), so one parser serves both, and U+FEFF is avoided. No\n * dependency either way.\n *\n * Zero dependencies, no side effects: `.` re-exports `cleanStega` and\n * `hasStega`; the encoder is internal (Zap's delivery imports it); the\n * decoder serves `./preview`.\n */\n\nconst DIGITS = ['​', '‌', '‍', '⁠'] as const\nconst PREFIX = '⁠‍‌‌‍‍‌⁠'\n/** Longest payload a marker may carry, in bytes (ref 300 + field 128 + locale). */\nconst MAX_PAYLOAD = 512\n\n/** `recordRef#fieldKey` with an optional `@locale`: the tag grammar (`refs.ts`). */\nconst PAYLOAD_RE =\n /^(doc:[a-z0-9]+(?:-[a-z0-9]+)*|[a-z0-9]+(?:-[a-z0-9]+)*\\/[a-z0-9]+(?:-[a-z0-9]+)*)#([a-z][a-z0-9_]{0,127})(?:@([A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8}){0,3}))?$/\n/** The prefix, then whole payload bytes (first digit 0 or 1). */\nconst MARKER_RE = /⁠‍‌‌‍‍‌⁠(?:[​‌][​‌‍⁠]{3})*/g\n\n/** What one marker says: the record, the field, and the locale when known. */\nexport interface StegaInfo {\n /** `collectionKey/slug` or `doc:documentKey`. */\n recordRef: string\n fieldKey: string\n locale?: string | null\n}\n\nexport interface DecodedStega {\n recordRef: string\n fieldKey: string\n locale: string | null\n /** `recordRef#fieldKey`, the `data-zap` tag. */\n tag: string\n}\n\n/** The marker for one field, or `''` when the info does not fit the tag grammar. */\nexport function stegaMarker(info: StegaInfo): string {\n const payload = `${info.recordRef}#${info.fieldKey}${info.locale ? `@${info.locale}` : ''}`\n if (payload.length > MAX_PAYLOAD || !PAYLOAD_RE.test(payload)) return ''\n let out = PREFIX\n for (let i = 0; i < payload.length; i++) {\n const byte = payload.charCodeAt(i)\n out +=\n DIGITS[(byte >> 6) & 3]! +\n DIGITS[(byte >> 4) & 3]! +\n DIGITS[(byte >> 2) & 3]! +\n DIGITS[byte & 3]!\n }\n return out\n}\n\n/**\n * `text` with the field's marker appended. A string that already carries a\n * marker, or info outside the grammar, comes back unchanged.\n */\nexport function stegaEncode(text: string, info: StegaInfo): string {\n if (hasStega(text)) return text\n return text + stegaMarker(info)\n}\n\n/** True when `value` is a string carrying at least one marker. */\nexport function hasStega(value: unknown): boolean {\n return typeof value === 'string' && value.includes(PREFIX)\n}\n\n/** Every valid marker in `text`, in order. Invalid ones are skipped. */\nexport function stegaDecode(text: string): DecodedStega[] {\n if (!text.includes(PREFIX)) return []\n const found: DecodedStega[] = []\n for (const match of text.match(MARKER_RE) ?? []) {\n let payload = ''\n for (let i = PREFIX.length; i + 4 <= match.length; i += 4) {\n let byte = 0\n for (let j = 0; j < 4; j++) byte = byte * 4 + DIGITS.indexOf(match[i + j] as never)\n payload += String.fromCharCode(byte)\n }\n const parsed = PAYLOAD_RE.exec(payload)\n if (!parsed) continue\n found.push({\n recordRef: parsed[1]!,\n fieldKey: parsed[2]!,\n locale: parsed[3] ?? null,\n tag: `${parsed[1]}#${parsed[2]}`,\n })\n }\n return found\n}\n\n/** `text` split into its visible part and the markers it carries, in order. */\nexport function splitStega(text: string): { text: string; markers: string } {\n if (!text.includes(PREFIX)) return { text, markers: '' }\n return { text: text.replace(MARKER_RE, ''), markers: (text.match(MARKER_RE) ?? []).join('') }\n}\n\n/** `text` without any marker. */\nfunction cleanString(text: string): string {\n return text.includes(PREFIX) ? text.replace(MARKER_RE, '') : text\n}\n\n/**\n * `value` with every stega marker removed: a string is cleaned, an array or a\n * plain object is cleaned deeply (into new objects), anything else is\n * returned as is. Use it where a preview value is compared, parsed or put in\n * an attribute, a URL or `<head>`; outside preview it changes nothing.\n */\nexport function cleanStega<T>(value: T): T {\n if (typeof value === 'string') return cleanString(value) as T\n if (Array.isArray(value)) return value.map((item) => cleanStega(item)) as T\n if (value && typeof value === 'object' && Object.getPrototypeOf(value) === Object.prototype) {\n const out: Record<string, unknown> = {}\n for (const [key, item] of Object.entries(value)) out[key] = cleanStega(item)\n return out as T\n }\n return value\n}\n","import type {\n WebhookAction,\n WebhookChange,\n WebhookDocumentEventData,\n WebhookEventType,\n WebhookItemEventData,\n WebhookMediaEventData,\n WebhookPayload,\n} from './types/webhook'\n\n/*\n * Webhook signature verification, written against WebCrypto only\n * (`globalThis.crypto.subtle`) so the same code runs in Node 20+, edge\n * runtimes, workers and browsers. This module must not import anything at\n * runtime — not `node:crypto`, not another SDK module — so it stays in the\n * root entry without tying it to Node. The edge test evaluates it in a bare\n * VM context to keep it that way.\n *\n * The scheme is the suite's (ADR 031 §4.1, `@eel/webhooks` sign.ts):\n *\n * X-Eel-Timestamp: <unix seconds>\n * X-Eel-Signature: v1=<hex HMAC-SHA256(`${timestamp}.${rawBody}`)>\n *\n * keyed with the UTF-8 bytes of the endpoint secret minus its `whsec_` prefix.\n * The timestamp is inside the MAC, so a captured delivery cannot be replayed\n * outside the tolerance window by changing the header.\n */\n\n/** Header carrying `v1=<hex>`. Header lookups are case-insensitive. */\nexport const WEBHOOK_SIGNATURE_HEADER = 'X-Eel-Signature'\n/** Header carrying the unix-second timestamp that is part of the signed content. */\nexport const WEBHOOK_TIMESTAMP_HEADER = 'X-Eel-Timestamp'\n/** Deliveries older or newer than this, in seconds, are refused: 5 minutes. */\nexport const WEBHOOK_TOLERANCE_SECONDS = 300\n\nconst SECRET_PREFIX = 'whsec_'\nconst SIGNATURE_PREFIX = 'v1='\nconst HMAC_SHA256_HEX_LENGTH = 64\n\n/**\n * The request headers: a Fetch `Headers` (Next.js route handlers, workers), or\n * a plain object such as Node's `IncomingHttpHeaders` (Express).\n */\nexport type WebhookHeaders =\n | Pick<Headers, 'get'>\n | Record<string, string | readonly string[] | undefined>\n\nexport interface VerifyWebhookOptions {\n /** Maximum clock difference in seconds. Default {@link WEBHOOK_TOLERANCE_SECONDS}. */\n toleranceSeconds?: number\n /** The current time. Default `new Date()`. */\n now?: Date\n}\n\nfunction readHeader(headers: WebhookHeaders, name: string): string | null {\n if (typeof (headers as Pick<Headers, 'get'>).get === 'function') {\n return (headers as Pick<Headers, 'get'>).get(name)\n }\n const wanted = name.toLowerCase()\n for (const [key, value] of Object.entries(headers)) {\n if (key.toLowerCase() !== wanted || value === undefined) continue\n // A repeated header is ambiguous: refuse rather than pick one.\n if (typeof value === 'string') return value\n return value.length === 1 ? (value[0] ?? null) : null\n }\n return null\n}\n\nfunction hexToBytes(value: string): Uint8Array<ArrayBuffer> | null {\n if (value.length !== HMAC_SHA256_HEX_LENGTH || !/^[0-9a-f]+$/i.test(value)) {\n return null\n }\n const bytes = new Uint8Array(value.length / 2)\n for (let index = 0; index < bytes.length; index += 1) {\n bytes[index] = Number.parseInt(value.slice(index * 2, index * 2 + 2), 16)\n }\n return bytes\n}\n\nfunction getSubtle(): SubtleCrypto {\n const subtle = (globalThis as { crypto?: Crypto }).crypto?.subtle\n if (!subtle) {\n // A misconfigured runtime is not a forged request, so it is not `false`.\n throw new Error(\n 'verifyWebhookSignature needs WebCrypto (globalThis.crypto.subtle). ' +\n 'Node 18 does not expose it by default: use Node 20+, or set ' +\n \"globalThis.crypto to node:crypto's webcrypto at startup.\",\n )\n }\n return subtle\n}\n\n/**\n * Verifies a webhook delivery: the signature over the raw body and the\n * timestamp, and that the timestamp is within the tolerance window.\n *\n * Pass the body exactly as received (`await request.text()`), never a\n * re-serialised parse: the MAC covers the bytes that were sent.\n *\n * @returns `true` only for an authentic, fresh delivery. Any missing or\n * malformed header, wrong secret, altered body or stale timestamp is `false`.\n * @throws When the runtime has no WebCrypto.\n *\n * @example\n * ```ts\n * const payload = await request.text()\n * if (!(await verifyWebhookSignature(payload, request.headers, process.env.EELZAP_WEBHOOK_SECRET!))) {\n * return new Response('Invalid signature', { status: 401 })\n * }\n * ```\n */\nexport async function verifyWebhookSignature(\n payload: string,\n headers: WebhookHeaders,\n secret: string,\n options: VerifyWebhookOptions = {},\n): Promise<boolean> {\n if (\n typeof payload !== 'string' ||\n typeof secret !== 'string' ||\n !headers ||\n typeof headers !== 'object'\n ) {\n return false\n }\n\n const key = secret.startsWith(SECRET_PREFIX) ? secret.slice(SECRET_PREFIX.length) : secret\n if (!key) {\n return false\n }\n\n const timestamp = readHeader(headers, WEBHOOK_TIMESTAMP_HEADER)?.trim()\n if (!timestamp || !/^\\d+$/.test(timestamp)) {\n return false\n }\n const nowSeconds = (options.now ?? new Date()).getTime() / 1000\n const tolerance = options.toleranceSeconds ?? WEBHOOK_TOLERANCE_SECONDS\n if (!(Math.abs(nowSeconds - Number(timestamp)) <= tolerance)) {\n return false\n }\n\n const signature = readHeader(headers, WEBHOOK_SIGNATURE_HEADER)?.trim()\n if (!signature?.startsWith(SIGNATURE_PREFIX)) {\n return false\n }\n const signatureBytes = hexToBytes(signature.slice(SIGNATURE_PREFIX.length))\n if (!signatureBytes) {\n return false\n }\n\n const subtle = getSubtle()\n const encoder = new TextEncoder()\n const hmacKey = await subtle.importKey(\n 'raw',\n encoder.encode(key),\n { name: 'HMAC', hash: 'SHA-256' },\n false,\n ['verify'],\n )\n // `verify` compares in constant time, unlike comparing two hex strings.\n return subtle.verify('HMAC', hmacKey, signatureBytes, encoder.encode(`${timestamp}.${payload}`))\n}\n\nconst CHANGE_ACTIONS: ReadonlySet<string> = new Set<WebhookAction>([\n 'created',\n 'updated',\n 'draft_updated',\n 'published',\n 'unpublished',\n 'deleted',\n 'rolled_back',\n 'uploaded',\n])\n\n/**\n * Flattens a Zap content event into one {@link WebhookChange} per item,\n * document or file it names — what a site walks to invalidate its cache.\n * Every other event (`ping`, schema, site, SEO, assignment, comment\n * events) yields an empty list.\n */\nexport function webhookChanges(payload: WebhookPayload): WebhookChange[] {\n const match = /^zap\\.(item|document|media)\\.([a-z_]+)$/.exec(payload.type)\n if (!match || !CHANGE_ACTIONS.has(match[2]!)) {\n return []\n }\n const type = match[1] as WebhookEventType\n const action = match[2] as WebhookAction\n\n if (type === 'item') {\n const data = payload.data as WebhookItemEventData\n return (data.items ?? []).map((item) => ({\n type,\n action,\n id: item.id,\n resourceKey: item.slug,\n collectionKey: data.collection.key,\n siteKey: data.site.key,\n }))\n }\n if (type === 'document') {\n const data = payload.data as WebhookDocumentEventData\n return (data.documents ?? []).map((document) => ({\n type,\n action,\n id: document.id,\n resourceKey: document.key,\n siteKey: data.site.key,\n }))\n }\n const data = payload.data as WebhookMediaEventData\n return (data.media ?? []).map((media) => ({\n type,\n action,\n id: media.id,\n resourceKey: media.id,\n siteKey: data.site.key,\n }))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQO,SAAS,iBAAiB,SAAyB;AACxD,SAAO,QAAQ,SAAS,GAAG,IAAI,UAAU,GAAG,OAAO;AACrD;AAGO,SAAS,eAAe,QAAyB;AACtD,SAAO,OAAO,KAAK,EAAE,WAAW,MAAM;AACxC;AAOO,SAAS,aAAa,SAAoD;AAC/E,SAAO,QAAQ,UACX,QAAQ,UAAU,QAChB,EAAE,SAAS,GAAG,OAAO,EAAE,IACvB,EAAE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BAAsC,oBAAI,IAAmB;AAAA,EACjE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAQM,SAAS,eAAe,SAA0C;AACvE,QAAM,QAAQ,0CAA0C,KAAK,QAAQ,IAAI;AACzE,MAAI,CAAC,SAAS,CAAC,eAAe,IAAI,MAAM,CAAC,CAAE,GAAG;AAC5C,WAAO,CAAC;AAAA,EACV;AACA,QAAM,OAAO,MAAM,CAAC;AACpB,QAAM,SAAS,MAAM,CAAC;AAEtB,MAAI,SAAS,QAAQ;AACnB,UAAMC,QAAO,QAAQ;AACrB,YAAQA,MAAK,SAAS,CAAC,GAAG,IAAI,CAAC,UAAU;AAAA,MACvC;AAAA,MACA;AAAA,MACA,IAAI,KAAK;AAAA,MACT,aAAa,KAAK;AAAA,MAClB,eAAeA,MAAK,WAAW;AAAA,MAC/B,SAASA,MAAK,KAAK;AAAA,IACrB,EAAE;AAAA,EACJ;AACA,MAAI,SAAS,YAAY;AACvB,UAAMA,QAAO,QAAQ;AACrB,YAAQA,MAAK,aAAa,CAAC,GAAG,IAAI,CAAC,cAAc;AAAA,MAC/C;AAAA,MACA;AAAA,MACA,IAAI,SAAS;AAAA,MACb,aAAa,SAAS;AAAA,MACtB,SAASA,MAAK,KAAK;AAAA,IACrB,EAAE;AAAA,EACJ;AACA,QAAM,OAAO,QAAQ;AACrB,UAAQ,KAAK,SAAS,CAAC,GAAG,IAAI,CAAC,WAAW;AAAA,IACxC;AAAA,IACA;AAAA,IACA,IAAI,MAAM;AAAA,IACV,aAAa,MAAM;AAAA,IACnB,SAAS,KAAK,KAAK;AAAA,EACrB,EAAE;AACJ;","names":["_http","_http","_http","_http","_http","_http","_http","_http","_http","_defaults","_http","_http","_defaults","_http","_http","_defaults","_http","_http","_http","_http","_http","_defaults","_config","data"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/utils.ts","../src/cache.ts","../src/errors.ts","../src/paths.ts","../src/retry.ts","../src/http.ts","../src/resources/resource-helpers.ts","../src/resources/collection-fields.ts","../src/resources/collection-sections.ts","../src/resources/collections.ts","../src/resources/comments.ts","../src/resources/document-versions.ts","../src/resources/document-fields.ts","../src/resources/document-sections.ts","../src/resources/document-seo.ts","../src/resources/document-values.ts","../src/resources/documents.ts","../src/resources/item-versions.ts","../src/query-builder.ts","../src/resources/item-seo.ts","../src/resources/items.ts","../src/resources/media.ts","../src/resources/preview-tokens.ts","../src/resources/site.ts","../src/resources/sites.ts","../src/client.ts","../src/media-url.ts","../src/stega.ts","../src/webhook.ts"],"sourcesContent":["export { cachedFetch, MemoryCacheAdapter } from './cache'\nexport type { CacheAdapter, CachedFetchOptions, CacheStrategy } from './cache'\nexport { createClient, EelZapClient } from './client'\nexport type { ClientConfig } from './client'\nexport { EelZapError, EelZapNetworkError, isEelZapError } from './errors'\nexport { getMediaUrl } from './media-url'\nexport { ItemQueryBuilder } from './query-builder'\nexport { CollectionFieldsResource } from './resources/collection-fields'\nexport { CollectionSectionsResource } from './resources/collection-sections'\nexport { CollectionsResource } from './resources/collections'\nexport { CommentsResource } from './resources/comments'\nexport { DocumentFieldsResource } from './resources/document-fields'\nexport { DocumentSectionsResource } from './resources/document-sections'\nexport { DocumentSeoResource } from './resources/document-seo'\nexport { DocumentValuesResource } from './resources/document-values'\nexport { DocumentVersionsResource } from './resources/document-versions'\nexport { DocumentsResource } from './resources/documents'\nexport { ItemSeoResource } from './resources/item-seo'\nexport { ItemVersionsResource } from './resources/item-versions'\nexport { MediaResource } from './resources/media'\nexport { PreviewTokensResource } from './resources/preview-tokens'\nexport { ItemsResource } from './resources/items'\nexport { SiteResource } from './resources/site'\nexport { SitesResource } from './resources/sites'\nexport type { RetryEvent, RetryOptions } from './retry'\nexport { cleanStega, hasStega } from './stega'\nexport {\n verifyWebhookSignature,\n webhookChanges,\n WEBHOOK_SIGNATURE_HEADER,\n WEBHOOK_TIMESTAMP_HEADER,\n WEBHOOK_TOLERANCE_SECONDS,\n} from './webhook'\nexport type { VerifyWebhookOptions, WebhookHeaders } from './webhook'\nexport * from './types'\n","import type {\n ClientDefaults,\n CommonRequestOptions,\n PreviewOption,\n QueryPrimitive,\n} from './types/common'\nimport type { ItemFilters } from './types/items'\n\nexport function normalizeBaseUrl(baseUrl: string): string {\n return baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`\n}\n\n/** A Zap preview token (`zpt_…`), minted for a draft-mode URL. */\nexport function isPreviewToken(apiKey: string): boolean {\n return apiKey.trim().startsWith('zpt_')\n}\n\n/**\n * `preview=1` when asked for, and NO key otherwise, so a request without\n * preview is exactly what it always was. `stega=0` only beside `preview=1`\n * and only when `stega` is exactly `false` (§2.4).\n */\nexport function previewParam(options: PreviewOption): { preview?: 1; stega?: 0 } {\n return options.preview\n ? options.stega === false\n ? { preview: 1, stega: 0 }\n : { preview: 1 }\n : {}\n}\n\n/**\n * Tags a parsed preview response so `cachedFetch` never stores it (§7.5).\n * `Symbol.for`, not a module-level symbol: the mark must survive the ESM/CJS\n * dual-package split, where the client and the cache can be two copies.\n * Non-enumerable, so it never shows in JSON or spreads.\n *\n * @internal\n */\nexport function markPreview<T>(value: T): T {\n if (value && typeof value === 'object') {\n Object.defineProperty(value, Symbol.for('eelzap.preview'), { value: true })\n }\n return value\n}\n\n/** Whether a value came from a preview response (see {@link markPreview}). */\nexport function isPreviewResult(value: unknown): boolean {\n return (\n !!value &&\n typeof value === 'object' &&\n (value as Record<symbol, unknown>)[Symbol.for('eelzap.preview')] === true\n )\n}\n\n/**\n * A fresh `Idempotency-Key`: `crypto.randomUUID()` where it exists (browsers,\n * edge runtimes, Node 19+), else a time-plus-random key, which is all a key\n * needs to be (unique, not secret).\n *\n * @internal\n */\nexport function newIdempotencyKey(): string {\n const crypto = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto\n return crypto?.randomUUID\n ? crypto.randomUUID()\n : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`\n}\n\nexport function toArrayParam(values: string[] | undefined): string | undefined {\n return values && values.length > 0 ? values.join(',') : undefined\n}\n\nexport function mergeRequestOptions<T extends CommonRequestOptions>(\n defaults: ClientDefaults,\n options?: T,\n): T {\n return {\n ...defaults,\n ...options,\n } as T\n}\n\nexport function cleanParams(\n params: Record<string, QueryPrimitive | undefined>,\n): Record<string, string> {\n return Object.fromEntries(\n Object.entries(params).flatMap(([key, value]) => {\n return value === undefined ? [] : [[key, String(value)]]\n }),\n )\n}\n\nexport function normalizeHeaderValue(value: string | null | undefined): string | undefined {\n if (value === undefined) {\n return undefined\n }\n\n if (value === null) {\n return undefined\n }\n\n const trimmed = value.trim()\n return trimmed.length > 0 ? trimmed : undefined\n}\n\nfunction isOperatorMap(\n value: ItemFilters[string],\n): value is Exclude<ItemFilters[string], QueryPrimitive> {\n return typeof value === 'object' && !Array.isArray(value)\n}\n\nexport function serializeFilters(filters?: ItemFilters): Record<string, string> {\n if (!filters) {\n return {}\n }\n\n return Object.entries(filters).reduce<Record<string, string>>((acc, [field, value]) => {\n if (!isOperatorMap(value)) {\n acc[`filter[${field}]`] = String(value)\n return acc\n }\n\n for (const [operator, operatorValue] of Object.entries(value)) {\n if (operatorValue === undefined) {\n continue\n }\n\n const serializedValue = Array.isArray(operatorValue)\n ? operatorValue.join(',')\n : String(operatorValue)\n acc[`filter[${field}][${operator}]`] = serializedValue\n }\n\n return acc\n }, {})\n}\n\nexport function maskApiKey(apiKey: string): string {\n if (apiKey.length <= 8) {\n return '***'\n }\n\n return `${apiKey.slice(0, 4)}...${apiKey.slice(-4)}`\n}\n","import { isPreviewResult } from './utils'\n\n/**\n * Pluggable storage interface for last-known-good caching.\n *\n * Implement this to persist content to any backend (KV, Redis,\n * filesystem, IndexedDB, etc.). The SDK ships a built-in\n * {@link MemoryCacheAdapter} for processes that stay alive.\n */\nexport interface CacheAdapter<T = unknown> {\n get(key: string): Promise<T | undefined> | T | undefined\n set(key: string, value: T): Promise<void> | void\n}\n\nexport type CacheStrategy = 'network-first' | 'cache-first'\n\nexport interface CachedFetchOptions<T = unknown> {\n key: string\n fetcher: () => Promise<T>\n adapter: CacheAdapter<T>\n strategy?: CacheStrategy\n}\n\n/**\n * Simple in-memory adapter. Suitable for long-lived server processes\n * or development. Data is lost when the process restarts.\n */\nexport class MemoryCacheAdapter implements CacheAdapter {\n readonly #store = new Map<string, unknown>()\n\n get(key: string): unknown {\n return this.#store.get(key)\n }\n\n set(key: string, value: unknown): void {\n this.#store.set(key, value)\n }\n\n /** Returns the number of cached entries. */\n get size(): number {\n return this.#store.size\n }\n\n /** Removes a specific key from the cache. */\n delete(key: string): boolean {\n return this.#store.delete(key)\n }\n\n /** Removes all cached entries. */\n clear(): void {\n this.#store.clear()\n }\n}\n\n/**\n * Caches content fetched from the CMS, with one of two strategies:\n *\n * - `network-first` (the default, and the only one the positional form\n * uses): runs `fetcher`, caches the result on success, and falls back to\n * the last cached value on failure.\n * - `cache-first` (options form): returns the cached value when there is\n * one, and fetches and caches only on a miss.\n *\n * If no cached value exists and the fetch fails, the original error is\n * re-thrown — there are no hardcoded fallbacks.\n *\n * A preview response (a read with `preview: true`, or any read with a `zpt_`\n * preview token) is returned but NEVER stored, under either strategy\n * (zap-cms-v2 §7.5): it carries drafts and stega markers, and a cache entry\n * would hand them to the next visitor.\n *\n * @param key - Stable cache key (e.g. `\"homepage\"`, `\"blog-posts:page-1\"`).\n * @param fetcher - An async function that fetches fresh content from the CMS.\n * @param adapter - Storage backend that persists last-known-good values.\n * @returns The fresh result or the last successfully cached value.\n *\n * @example\n * ```ts\n * const cache = new MemoryCacheAdapter();\n *\n * const homepage = await cachedFetch(\n * 'homepage',\n * () => cms.documents.get('homepage'),\n * cache,\n * );\n * ```\n */\nexport async function cachedFetch<T>(\n key: string,\n fetcher: () => Promise<T>,\n adapter: CacheAdapter<T>,\n): Promise<T>\nexport async function cachedFetch<T>(options: CachedFetchOptions<T>): Promise<T>\nexport async function cachedFetch<T>(\n keyOrOptions: string | CachedFetchOptions<T>,\n fetcher?: () => Promise<T>,\n adapter?: CacheAdapter<T>,\n): Promise<T> {\n const options =\n typeof keyOrOptions === 'string'\n ? {\n key: keyOrOptions,\n fetcher: fetcher as () => Promise<T>,\n adapter: adapter as CacheAdapter<T>,\n strategy: 'network-first' as CacheStrategy,\n }\n : {\n ...keyOrOptions,\n strategy: keyOrOptions.strategy ?? 'network-first',\n }\n\n if (options.strategy === 'cache-first') {\n const cached = await options.adapter.get(options.key)\n if (cached !== undefined) {\n return cached\n }\n\n return store(options.adapter, options.key, await options.fetcher())\n }\n\n try {\n return await store(options.adapter, options.key, await options.fetcher())\n } catch (error) {\n const cached = await options.adapter.get(options.key)\n if (cached !== undefined) {\n return cached\n }\n throw error\n }\n}\n\nasync function store<T>(adapter: CacheAdapter<T>, key: string, result: T): Promise<T> {\n if (!isPreviewResult(result)) await adapter.set(key, result)\n return result\n}\n","import type { ApiErrorDetail } from './types/common'\nimport type { EelZapErrorCode } from './types/errors'\n\n/**\n * Base error thrown by the SDK for API and transport failures.\n */\nexport class EelZapError extends Error {\n readonly code: EelZapErrorCode\n readonly status: number\n /** Per-field problems when the API refused the input; empty otherwise. */\n readonly details: readonly ApiErrorDetail[]\n\n constructor(\n code: EelZapErrorCode,\n message: string,\n status: number,\n details: readonly ApiErrorDetail[] = [],\n ) {\n super(message)\n this.name = 'EelZapError'\n this.code = code\n this.status = status\n this.details = details\n }\n}\n\n/**\n * Error thrown when a network failure or timeout prevents a response.\n */\nexport class EelZapNetworkError extends EelZapError {\n override readonly cause: unknown\n\n constructor(cause: unknown, message = 'Network request failed.') {\n super('NETWORK_ERROR', message, 0)\n this.name = 'EelZapNetworkError'\n this.cause = cause\n }\n}\n\n/**\n * Type guard for SDK errors.\n */\nexport function isEelZapError(error: unknown): error is EelZapError {\n return error instanceof EelZapError\n}\n","function trimSlashes(value: string): string {\n return value.replace(/^\\/+|\\/+$/g, '')\n}\n\n/**\n * Joins resource path segments without applying any API prefix.\n *\n * @internal\n */\nexport function buildResourcePath(...segments: string[]): string {\n const normalized = segments.map(trimSlashes).filter((segment) => segment.length > 0)\n return `/${normalized.join('/')}`\n}\n\n/**\n * Normalizes an SDK path prefix for URL joining.\n *\n * @internal\n */\nexport function normalizePathPrefix(pathPrefix: string): string {\n const trimmed = trimSlashes(pathPrefix)\n return trimmed.length > 0 ? `${trimmed}/` : ''\n}\n","/**\n * Retries of a refused request: `429 Too Many Requests` always, and `503\n * Service Unavailable` when it says when to come back (`Retry-After`).\n *\n * Only a request that is safe to repeat is retried: a read (`GET`, `HEAD`), or\n * a write that carries an `Idempotency-Key`, which the API deduplicates. Any\n * other write is never repeated, so a create can never land twice.\n */\nexport interface RetryOptions {\n /** Retries after the first attempt. Default `3`; `0` turns retrying off. */\n retries?: number\n /**\n * The longest single wait, in ms. Default `60000`, the API's rate window. A\n * `Retry-After` longer than this is not waited out: the refusal is thrown.\n */\n maxDelayMs?: number\n /** The first backoff step when the answer has no `Retry-After`, in ms. Default `500`. */\n baseDelayMs?: number\n /** Called before each wait, for logging. */\n onRetry?: (event: RetryEvent) => void\n}\n\n/** What {@link RetryOptions.onRetry} is told before a wait. */\nexport interface RetryEvent {\n /** The retry about to happen: `1` for the first. */\n attempt: number\n /** How long the client waits first, in ms. */\n delayMs: number\n /** The refused answer's status: `429` or `503`. */\n status: number\n method: string\n url: string\n}\n\n/** @internal */\nexport type ResolvedRetry = Required<Omit<RetryOptions, 'onRetry'>> & Pick<RetryOptions, 'onRetry'>\n\n/** @internal */\nexport function resolveRetry(retry: boolean | RetryOptions | undefined): ResolvedRetry | null {\n if (retry === false) return null\n const options = retry === true || retry === undefined ? {} : retry\n const resolved = {\n retries: options.retries ?? 3,\n maxDelayMs: options.maxDelayMs ?? 60_000,\n baseDelayMs: options.baseDelayMs ?? 500,\n onRetry: options.onRetry,\n }\n return resolved.retries > 0 ? resolved : null\n}\n\n/**\n * Whether the request may be sent again: a read, or a write the API\n * deduplicates by `Idempotency-Key` whose body can be sent twice.\n *\n * @internal\n */\nexport function isRepeatable(method: string, headers: Headers, body: unknown): boolean {\n if (method === 'GET' || method === 'HEAD') return true\n return headers.has('Idempotency-Key') && (body == null || typeof body === 'string')\n}\n\n/**\n * `Retry-After` in ms: delay-seconds or an HTTP-date. `null` when absent or\n * unreadable.\n *\n * @internal\n */\nexport function parseRetryAfter(value: string | null, now: number): number | null {\n if (value === null) return null\n const trimmed = value.trim()\n if (/^\\d+$/.test(trimmed)) return Number(trimmed) * 1000\n const date = Date.parse(trimmed)\n return Number.isNaN(date) ? null : Math.max(0, date - now)\n}\n\n/**\n * How long to wait before retry number `attempt` (from 1), or `null` to give\n * up and surface the answer.\n *\n * With `Retry-After`, that long plus up to a second of jitter, so clients\n * refused together do not come back together. Without it, a `429` backs off\n * exponentially from `baseDelayMs`, half fixed and half jitter; a `503` without\n * it is not retried, since nothing says the outage is brief.\n *\n * @internal\n */\nexport function retryDelay(\n response: Response,\n attempt: number,\n options: ResolvedRetry,\n now: number = Date.now(),\n random: () => number = Math.random,\n): number | null {\n if (attempt > options.retries) return null\n if (response.status !== 429 && response.status !== 503) return null\n\n const retryAfter = parseRetryAfter(response.headers.get('Retry-After'), now)\n if (retryAfter !== null) {\n if (retryAfter > options.maxDelayMs) return null\n return Math.min(options.maxDelayMs, retryAfter + Math.floor(random() * 1000))\n }\n if (response.status === 503) return null\n\n const step = Math.min(options.maxDelayMs, options.baseDelayMs * 2 ** (attempt - 1))\n return Math.floor(step / 2 + random() * (step / 2))\n}\n","import { EelZapError, EelZapNetworkError } from './errors'\nimport { normalizePathPrefix } from './paths'\nimport { isRepeatable, retryDelay, type ResolvedRetry } from './retry'\nimport { cleanParams, isPreviewToken, markPreview } from './utils'\nimport type { ApiErrorPayload, QueryPrimitive } from './types/common'\n\nexport interface HttpClientConfig {\n apiKey: string\n baseUrl: string\n pathPrefix: string\n fetch: typeof globalThis.fetch\n defaultHeaders?: HeadersInit\n timeout: number\n /** Retries of a `429`/`503`; `null` or absent turns them off. */\n retry?: ResolvedRetry | null\n}\n\nexport interface HttpRequestOptions {\n params?: Record<string, QueryPrimitive | undefined>\n headers?: HeadersInit\n body?: BodyInit | null\n contentType?: string\n}\n\n/**\n * Minimal fetch-based HTTP client for the delivery API.\n *\n * @internal\n */\nexport class HttpClient {\n readonly #config: HttpClientConfig\n\n constructor(config: HttpClientConfig) {\n this.#config = config\n }\n\n async get<T>(\n path: string,\n options?: Omit<HttpRequestOptions, 'body' | 'contentType'>,\n ): Promise<T> {\n return this.#request<T>('GET', path, options)\n }\n\n async post<T>(\n path: string,\n body?: unknown,\n options?: Omit<HttpRequestOptions, 'body'>,\n ): Promise<T> {\n return this.#request<T>('POST', path, this.#withJsonBody(body, options))\n }\n\n async patch<T>(\n path: string,\n body?: unknown,\n options?: Omit<HttpRequestOptions, 'body'>,\n ): Promise<T> {\n return this.#request<T>('PATCH', path, this.#withJsonBody(body, options))\n }\n\n async put<T>(\n path: string,\n body?: unknown,\n options?: Omit<HttpRequestOptions, 'body'>,\n ): Promise<T> {\n return this.#request<T>('PUT', path, this.#withJsonBody(body, options))\n }\n\n async delete<T>(\n path: string,\n body?: unknown,\n options?: Omit<HttpRequestOptions, 'body'>,\n ): Promise<T> {\n return this.#request<T>('DELETE', path, this.#withJsonBody(body, options))\n }\n\n async upload(url: string, body: BodyInit, headers?: HeadersInit): Promise<void> {\n const controller = new AbortController()\n const timeoutId = setTimeout(() => {\n controller.abort()\n }, this.#config.timeout)\n\n try {\n const response = await this.#config.fetch(url, {\n method: 'PUT',\n body,\n headers,\n signal: controller.signal,\n })\n\n if (!response.ok) {\n throw await this.toEelZapError(response)\n }\n } catch (error) {\n if (error instanceof EelZapError) {\n throw error\n }\n\n throw new EelZapNetworkError(\n error,\n error instanceof Error ? error.message : 'Network request failed.',\n )\n } finally {\n clearTimeout(timeoutId)\n }\n }\n\n async request<T>(path: string, options?: HttpRequestOptions): Promise<T> {\n return this.get<T>(path, options)\n }\n\n async #request<T>(method: string, path: string, options?: HttpRequestOptions): Promise<T> {\n const prefix = normalizePathPrefix(this.#config.pathPrefix)\n const normalizedPath = path.replace(/^\\/+/, '')\n const url = new URL(`${prefix}${normalizedPath}`, this.#config.baseUrl)\n for (const [key, value] of Object.entries(cleanParams(options?.params ?? {}))) {\n url.searchParams.set(key, value)\n }\n\n const headers = new Headers(this.#config.defaultHeaders)\n for (const [key, value] of new Headers(options?.headers).entries()) {\n headers.set(key, value)\n }\n headers.set('Authorization', `Bearer ${this.#config.apiKey}`)\n if (options?.contentType) {\n headers.set('Content-Type', options.contentType)\n } else if (!headers.has('Content-Type') && options?.body !== undefined) {\n headers.set('Content-Type', 'application/json')\n }\n\n const retry = this.#config.retry\n const repeatable = retry ? isRepeatable(method, headers, options?.body) : false\n for (let attempt = 1; ; attempt++) {\n const controller = new AbortController()\n const timeoutId = setTimeout(() => {\n controller.abort()\n }, this.#config.timeout)\n let delayMs: number | null\n let status: number\n\n try {\n const response = await this.#config.fetch(url.toString(), {\n method,\n body: options?.body,\n headers,\n signal: controller.signal,\n })\n\n delayMs = repeatable && retry ? retryDelay(response, attempt, retry) : null\n if (delayMs === null) {\n return await this.#read<T>(url, response)\n }\n status = response.status\n // Free the refused answer's connection before waiting.\n await response.body?.cancel().catch(() => undefined)\n } catch (error) {\n if (error instanceof EelZapError) {\n throw error\n }\n\n throw new EelZapNetworkError(\n error,\n error instanceof Error ? error.message : 'Network request failed.',\n )\n } finally {\n clearTimeout(timeoutId)\n }\n\n retry?.onRetry?.({ attempt, delayMs, status, method, url: url.toString() })\n await new Promise((resolve) => setTimeout(resolve, delayMs))\n }\n }\n\n async #read<T>(url: URL, response: Response): Promise<T> {\n // No body to parse. 204 is what `DELETE …/versions/draft` answers on\n // success; reading it as JSON would throw and surface as a network error.\n if (response.status === 304 || response.status === 204) {\n return undefined as T\n }\n\n if (!response.ok) {\n throw await this.toEelZapError(response)\n }\n\n const data = (await response.json()) as T\n // A preview answer (`preview=1`, or any read with a `zpt_` token, which\n // the API always answers as preview) is tagged so `cachedFetch` never\n // stores it: drafts and stega markers must not outlive the request.\n return url.searchParams.get('preview') === '1' || isPreviewToken(this.#config.apiKey)\n ? markPreview(data)\n : data\n }\n\n #withJsonBody(\n body: unknown,\n options?: Omit<HttpRequestOptions, 'body'>,\n ): HttpRequestOptions | undefined {\n if (body === undefined) {\n return options\n }\n\n return {\n ...options,\n body: JSON.stringify(body),\n contentType: 'application/json',\n }\n }\n\n private async toEelZapError(response: Response): Promise<EelZapError> {\n const contentType = response.headers.get('Content-Type') ?? ''\n\n if (contentType.includes('application/json')) {\n const payload = (await response.json()) as Partial<ApiErrorPayload>\n const code = payload.error?.code ?? 'INTERNAL_ERROR'\n const message =\n payload.error?.message ?? `Request failed with status ${String(response.status)}.`\n const status = payload.error?.status ?? response.status\n const details = Array.isArray(payload.error?.details) ? payload.error.details : []\n return new EelZapError(code, message, status, details)\n }\n\n return new EelZapError(\n 'INTERNAL_ERROR',\n `Request failed with status ${String(response.status)}.`,\n response.status,\n )\n }\n}\n","import type { IdempotencyOptions } from '../types/common'\nimport type { DeleteOptions } from '../types/common'\nimport { newIdempotencyKey } from '../utils'\nimport type { CreateFieldInput, UpdateFieldInput } from '../types/collections'\n\nexport function normalizeFieldInput<T extends CreateFieldInput | UpdateFieldInput>(input: T): T {\n if (input.label || !input.name) {\n return input\n }\n\n return {\n ...input,\n label: input.name,\n }\n}\n\nexport function toDeleteBody(options?: DeleteOptions): DeleteOptions | undefined {\n if (!options?.deleteMediaIds || options.deleteMediaIds.length === 0) {\n return undefined\n }\n\n return {\n deleteMediaIds: options.deleteMediaIds,\n }\n}\n\n/**\n * The `Idempotency-Key` header of a write the API deduplicates: the caller's\n * key, or a fresh one. Suite bearers are refused without it.\n */\nexport function idempotent(options?: IdempotencyOptions): { headers: Record<string, string> } {\n return { headers: { 'Idempotency-Key': options?.idempotencyKey ?? newIdempotencyKey() } }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type {\n CollectionFieldListResponse,\n CreateFieldInput,\n FieldInfo,\n UpdateFieldInput,\n} from '../types/collections'\nimport type { IdempotencyOptions } from '../types/common'\nimport { idempotent, normalizeFieldInput } from './resource-helpers'\n\n/**\n * Collection field management endpoints.\n */\nexport class CollectionFieldsResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Lists all fields in a collection.\n */\n async list(collectionKey: string): Promise<FieldInfo[]> {\n const response = await this.#http.get<CollectionFieldListResponse>(\n buildResourcePath('collections', collectionKey, 'fields'),\n )\n return response.fields\n }\n\n /**\n * Creates a field in a collection.\n *\n * Sends an `Idempotency-Key` (required of suite bearers): a fresh one per\n * call, or `options.idempotencyKey` to make your own retry safe.\n */\n async create(\n collectionKey: string,\n input: CreateFieldInput,\n options?: IdempotencyOptions,\n ): Promise<FieldInfo> {\n const response = await this.#http.post<{ field: FieldInfo }>(\n buildResourcePath('collections', collectionKey, 'fields'),\n normalizeFieldInput(input),\n idempotent(options),\n )\n return response.field\n }\n\n /**\n * Updates a field in a collection.\n */\n async update(\n collectionKey: string,\n fieldId: string,\n input: UpdateFieldInput,\n ): Promise<FieldInfo> {\n const response = await this.#http.patch<{ field: FieldInfo }>(\n buildResourcePath('collections', collectionKey, 'fields', fieldId),\n normalizeFieldInput(input),\n )\n return response.field\n }\n\n /**\n * Deletes a field from a collection.\n */\n async delete(collectionKey: string, fieldId: string): Promise<{ success: true }> {\n return this.#http.delete<{ success: true }>(\n buildResourcePath('collections', collectionKey, 'fields', fieldId),\n )\n }\n\n /**\n * Lists the collection's archived (soft-deleted) fields, most recently\n * deleted first. Their values are kept, which is what makes `restore` work.\n *\n * `GET /collections/{collectionKey}/fields/deleted`. Secret key, or suite\n * bearer with `zap:content:read`.\n */\n async listDeleted(collectionKey: string): Promise<FieldInfo[]> {\n const response = await this.#http.get<CollectionFieldListResponse>(\n buildResourcePath('collections', collectionKey, 'fields', 'deleted'),\n )\n return response.fields\n }\n\n /**\n * Brings an archived field back with every value it held, at the end of the\n * root list (outside any section).\n *\n * `POST /collections/{collectionKey}/fields/{fieldId}/restore`. Secret key,\n * or suite bearer with `zap:schema:write` and the Zap ADMIN role.\n */\n async restore(collectionKey: string, fieldId: string): Promise<FieldInfo> {\n const response = await this.#http.post<{ field: FieldInfo }>(\n buildResourcePath('collections', collectionKey, 'fields', fieldId, 'restore'),\n )\n return response.field\n }\n\n /**\n * Reorders collection fields.\n */\n async reorder(collectionKey: string, fieldIds: string[]): Promise<{ success: true }> {\n return this.#http.put<{ success: true }>(\n buildResourcePath('collections', collectionKey, 'fields', 'reorder'),\n { fieldIds },\n )\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type {\n CollectionSectionListResponse,\n CreateSectionInput,\n SectionInfo,\n UpdateSectionInput,\n} from '../types/collections'\nimport type { IdempotencyOptions } from '../types/common'\nimport { idempotent } from './resource-helpers'\n\n/**\n * Collection section management endpoints.\n */\nexport class CollectionSectionsResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Lists all sections in a collection.\n */\n async list(collectionKey: string): Promise<SectionInfo[]> {\n const response = await this.#http.get<CollectionSectionListResponse>(\n buildResourcePath('collections', collectionKey, 'sections'),\n )\n return response.sections\n }\n\n /**\n * Gets a single section from a collection.\n */\n async get(collectionKey: string, sectionId: string): Promise<SectionInfo> {\n const response = await this.#http.get<{ section: SectionInfo }>(\n buildResourcePath('collections', collectionKey, 'sections', sectionId),\n )\n return response.section\n }\n\n /**\n * Creates a section in a collection.\n *\n * Sends an `Idempotency-Key` (required of suite bearers): a fresh one per\n * call, or `options.idempotencyKey` to make your own retry safe.\n */\n async create(\n collectionKey: string,\n input: CreateSectionInput,\n options?: IdempotencyOptions,\n ): Promise<SectionInfo> {\n const response = await this.#http.post<{ section: SectionInfo }>(\n buildResourcePath('collections', collectionKey, 'sections'),\n input,\n idempotent(options),\n )\n return response.section\n }\n\n /**\n * Updates a section in a collection.\n */\n async update(\n collectionKey: string,\n sectionId: string,\n input: UpdateSectionInput,\n ): Promise<SectionInfo> {\n const response = await this.#http.patch<{ section: SectionInfo }>(\n buildResourcePath('collections', collectionKey, 'sections', sectionId),\n input,\n )\n return response.section\n }\n\n /**\n * Deletes a section from a collection.\n */\n async delete(collectionKey: string, sectionId: string): Promise<{ success: true }> {\n return this.#http.delete<{ success: true }>(\n buildResourcePath('collections', collectionKey, 'sections', sectionId),\n )\n }\n}\n","import type {\n CollectionDetail,\n CollectionListResponse,\n CreateCollectionInput,\n UpdateCollectionInput,\n} from '../types/collections'\nimport type {\n ClientDefaults,\n DeleteOptions,\n DeliveryStatus,\n IdempotencyOptions,\n} from '../types/common'\nimport { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport { CollectionFieldsResource } from './collection-fields'\nimport { CollectionSectionsResource } from './collection-sections'\nimport { idempotent, toDeleteBody } from './resource-helpers'\n\n/**\n * Read-only collection endpoints.\n */\nexport class CollectionsResource {\n readonly fields: CollectionFieldsResource\n readonly sections: CollectionSectionsResource\n readonly #http: HttpClient\n readonly #defaults: ClientDefaults\n\n /**\n * @internal\n */\n constructor(http: HttpClient, defaults: ClientDefaults) {\n this.#http = http\n this.#defaults = defaults\n this.fields = new CollectionFieldsResource(http)\n this.sections = new CollectionSectionsResource(http)\n }\n\n /**\n * Lists all collections available to the current API key.\n */\n async list(options?: { status?: DeliveryStatus }): Promise<CollectionListResponse> {\n return this.#http.get<CollectionListResponse>(buildResourcePath('collections'), {\n params: {\n status: options?.status ?? this.#defaults.status,\n },\n })\n }\n\n /**\n * Retrieves the schema for a single collection.\n */\n async get(\n collectionKey: string,\n options?: { status?: DeliveryStatus },\n ): Promise<CollectionDetail> {\n return this.#http.get<CollectionDetail>(buildResourcePath('collections', collectionKey), {\n params: {\n status: options?.status ?? this.#defaults.status,\n },\n })\n }\n\n /**\n * Creates a collection.\n *\n * Sends an `Idempotency-Key` (required of suite bearers): a fresh one per\n * call, or `options.idempotencyKey` to make your own retry safe.\n */\n async create(\n input: CreateCollectionInput,\n options?: IdempotencyOptions,\n ): Promise<CollectionDetail> {\n const response = await this.#http.post<{ collection: CollectionDetail }>(\n buildResourcePath('collections'),\n input,\n idempotent(options),\n )\n return response.collection\n }\n\n /**\n * Updates a collection.\n */\n async update(collectionKey: string, input: UpdateCollectionInput): Promise<CollectionDetail> {\n const response = await this.#http.patch<{ collection: CollectionDetail }>(\n buildResourcePath('collections', collectionKey),\n input,\n )\n return response.collection\n }\n\n /**\n * Deletes a collection.\n */\n async delete(collectionKey: string, options?: DeleteOptions): Promise<{ success: true }> {\n return this.#http.delete<{ success: true }>(\n buildResourcePath('collections', collectionKey),\n toDeleteBody(options),\n )\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type {\n CommentDraftAnswer,\n CommentListOptions,\n CommentListResponse,\n CommentReplyAnswer,\n CommentThreadAnswer,\n CreateCommentInput,\n OnPageComments,\n ReplyCommentInput,\n SaveCommentToDraftInput,\n UpdateCommentInput,\n} from '../types/comments'\nimport type { IdempotencyOptions } from '../types/common'\nimport { idempotent } from './resource-helpers'\n\n/**\n * «Comentarios» (`/comments`): comment threads on an entry or a document, a\n * thread flagged `isChangeRequest` carrying an assignee and proposed values.\n *\n * Suite bearers only (`eel_sk_…` / `eel_at_…`, with `X-Eel-Site`): a comment\n * has a person behind it, so site keys are refused. Reads need\n * `zap:content:read`; writes `zap:content:write`, and `create`, `reply` and\n * `saveToDraft` also take `zap:suggest:write`.\n */\nexport class CommentsResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Lists the site's threads, newest first, optionally on one record (an\n * entry by `collection` + `slug`, or a `document`). `counts` covers both\n * statuses whatever `status` filters.\n *\n * `GET /comments`.\n */\n async list(options?: CommentListOptions): Promise<CommentListResponse> {\n return this.#http.get<CommentListResponse>('/comments', {\n // Named one by one: the route's query is strict, so a stray key would be a 400.\n params: {\n collection: options?.collection,\n slug: options?.slug,\n document: options?.document,\n isChangeRequest: options?.isChangeRequest,\n status: options?.status,\n resolution: options?.resolution,\n pageUrl: options?.pageUrl,\n assignee: options?.assignee,\n page: options?.page,\n pageSize: options?.pageSize,\n },\n })\n }\n\n /**\n * Retrieves a thread and its comments, oldest first.\n *\n * `GET /comments/{id}`.\n */\n async get(id: string): Promise<CommentThreadAnswer> {\n return this.#http.get<CommentThreadAnswer>(buildResourcePath('comments', id))\n }\n\n /**\n * Opens a thread with its first comment. Anchors and proposed values name\n * fields by key. Sends an `Idempotency-Key`. 404 for an unknown record, 422\n * `INVALID_ANCHOR` / `INVALID_PROPOSED_VALUE` / `ASSIGNEE_NO_SEAT`, 429\n * `RATE_LIMITED`.\n *\n * `POST /comments`.\n *\n * @example\n * ```ts\n * await zap.comments.create({\n * collection: 'blog',\n * slug: 'hello-world',\n * isChangeRequest: true,\n * body: 'Shorter title?',\n * proposedValues: [{ fieldKey: 'title', value: 'Hello' }],\n * })\n * ```\n */\n async create(\n input: CreateCommentInput,\n options?: IdempotencyOptions,\n ): Promise<CommentThreadAnswer> {\n return this.#http.post<CommentThreadAnswer>('/comments', input, idempotent(options))\n }\n\n /**\n * Changes a thread: `status` (resolve, reopen), a change request's\n * `resolution`, the `isChangeRequest` flag, the assignee, or the first\n * comment's text. 409 `STATUS_CONFLICT`, `INVALID_TRANSITION`,\n * `HAS_PROPOSAL`; 422 `NOT_A_CHANGE_REQUEST`, `HAS_LINKED_TASKS` (turning\n * the flag off while a Swarm task is linked).\n *\n * `PATCH /comments/{id}`.\n */\n async update(id: string, input: UpdateCommentInput): Promise<CommentThreadAnswer> {\n return this.#http.patch<CommentThreadAnswer>(buildResourcePath('comments', id), input)\n }\n\n /**\n * Replies on a thread. Sends an `Idempotency-Key`.\n *\n * `POST /comments/{id}/replies`.\n */\n async reply(\n id: string,\n input: ReplyCommentInput,\n options?: IdempotencyOptions,\n ): Promise<CommentReplyAnswer> {\n return this.#http.post<CommentReplyAnswer>(\n buildResourcePath('comments', id, 'replies'),\n input,\n idempotent(options),\n )\n }\n\n /**\n * «Aplicar al borrador»: writes an open change request's proposed values\n * into the record's draft and resolves it as APPLIED. 409 `NO_PROPOSAL` /\n * `NOT_OPEN`.\n *\n * `POST /comments/{id}/apply`.\n */\n async apply(id: string): Promise<CommentDraftAnswer> {\n return this.#http.post<CommentDraftAnswer>(buildResourcePath('comments', id, 'apply'))\n }\n\n /**\n * Writes proposed values straight into the record's draft, recorded as a\n * change request already resolved as APPLIED; nobody is notified. 403 when\n * the site has live editing off. Sends an `Idempotency-Key`.\n *\n * `POST /comments/save-to-draft`.\n */\n async saveToDraft(\n input: SaveCommentToDraftInput,\n options?: IdempotencyOptions,\n ): Promise<CommentDraftAnswer> {\n return this.#http.post<CommentDraftAnswer>(\n buildResourcePath('comments', 'save-to-draft'),\n input,\n idempotent(options),\n )\n }\n\n /**\n * What the site's suggestion client shows on one page: the viewer, whether\n * live editing is on, the field types of the records tagged there and the\n * page's open threads. `refs` are `data-zap-ref` values (`collection/slug`\n * or `doc:key`); at most 20 are read.\n *\n * `GET /comments/on-page`. Answers only the site's own suggestion client.\n */\n async onPage(url: string, refs: readonly string[] = []): Promise<OnPageComments> {\n return this.#http.get<OnPageComments>(buildResourcePath('comments', 'on-page'), {\n params: { url, refs: refs.length > 0 ? refs.join(',') : undefined },\n })\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type {\n CreateDraftInput,\n DocumentVersionDetail,\n DocumentVersionSummary,\n UpdateDocumentDraftInput,\n VersionListResponse,\n} from '../types/versions'\n\n/**\n * Version history, drafts and rollbacks for documents\n * (`/documents/{documentKey}/versions…`).\n *\n * A document has at most one open draft. Writing needs a secret key;\n * publishing and rolling back need one with publish rights.\n */\nexport class DocumentVersionsResource {\n readonly #http: HttpClient\n\n /** @internal */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Lists a document's versions, newest first.\n */\n async list(documentKey: string): Promise<VersionListResponse<DocumentVersionSummary>> {\n return this.#http.get<VersionListResponse<DocumentVersionSummary>>(\n buildResourcePath('documents', documentKey, 'versions'),\n )\n }\n\n /**\n * Gets one version with its snapshot (values and SEO).\n */\n async get(documentKey: string, versionId: string): Promise<DocumentVersionDetail> {\n const response = await this.#http.get<{ version: DocumentVersionDetail }>(\n buildResourcePath('documents', documentKey, 'versions', versionId),\n )\n return response.version\n }\n\n /**\n * Opens a draft from the document's live state. Fails with `DUPLICATE_KEY`\n * (409) when the document already has one.\n */\n async createDraft(\n documentKey: string,\n input?: CreateDraftInput,\n ): Promise<DocumentVersionSummary> {\n const response = await this.#http.post<{ version: DocumentVersionSummary }>(\n buildResourcePath('documents', documentKey, 'versions'),\n input,\n )\n return response.version\n }\n\n /**\n * Stages values on the open draft without touching the live document.\n * Fails with `VALIDATION_ERROR` (400) when there is no open draft.\n */\n async updateDraft(\n documentKey: string,\n input: UpdateDocumentDraftInput,\n ): Promise<DocumentVersionDetail> {\n const response = await this.#http.put<{ version: DocumentVersionDetail }>(\n buildResourcePath('documents', documentKey, 'versions', 'draft'),\n input,\n )\n return response.version\n }\n\n /**\n * Discards the open draft. Fails with `NOT_FOUND` (404) when there is none.\n */\n async discardDraft(documentKey: string): Promise<void> {\n await this.#http.delete<unknown>(\n buildResourcePath('documents', documentKey, 'versions', 'draft'),\n )\n }\n\n /**\n * Publishes the open draft: its values go live and it becomes the\n * document's published version. Fails with `NOT_FOUND` (404) when there is\n * no draft.\n */\n async publishDraft(documentKey: string): Promise<DocumentVersionSummary> {\n const response = await this.#http.post<{ version: DocumentVersionSummary }>(\n buildResourcePath('documents', documentKey, 'versions', 'draft', 'publish'),\n )\n return response.version\n }\n\n /**\n * Restores a past version over the live document and records the restore\n * as a NEW published version (history is never rewritten). Refused (409)\n * for a draft version, or while the document has an open draft.\n */\n async rollback(documentKey: string, versionId: string): Promise<DocumentVersionSummary> {\n const response = await this.#http.post<{ version: DocumentVersionSummary }>(\n buildResourcePath('documents', documentKey, 'versions', versionId, 'rollback'),\n )\n return response.version\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type {\n CreateDocumentFieldInput,\n DocumentFieldListResponse,\n UpdateDocumentFieldInput,\n} from '../types/documents'\nimport type { FieldInfo } from '../types/collections'\nimport type { IdempotencyOptions } from '../types/common'\nimport { idempotent, normalizeFieldInput } from './resource-helpers'\n\n/**\n * Document field management endpoints.\n */\nexport class DocumentFieldsResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Lists all fields in a document.\n */\n async list(documentKey: string): Promise<FieldInfo[]> {\n const response = await this.#http.get<DocumentFieldListResponse>(\n buildResourcePath('documents', documentKey, 'fields'),\n )\n return response.fields\n }\n\n /**\n * Gets a single field in a document.\n */\n async get(documentKey: string, fieldId: string): Promise<FieldInfo> {\n const response = await this.#http.get<{ field: FieldInfo }>(\n buildResourcePath('documents', documentKey, 'fields', fieldId),\n )\n return response.field\n }\n\n /**\n * Creates a field in a document.\n *\n * Sends an `Idempotency-Key` (required of suite bearers): a fresh one per\n * call, or `options.idempotencyKey` to make your own retry safe.\n */\n async create(\n documentKey: string,\n input: CreateDocumentFieldInput,\n options?: IdempotencyOptions,\n ): Promise<FieldInfo> {\n const response = await this.#http.post<{ field: FieldInfo }>(\n buildResourcePath('documents', documentKey, 'fields'),\n normalizeFieldInput(input),\n idempotent(options),\n )\n return response.field\n }\n\n /**\n * Updates a field in a document.\n */\n async update(\n documentKey: string,\n fieldId: string,\n input: UpdateDocumentFieldInput,\n ): Promise<FieldInfo> {\n const response = await this.#http.patch<{ field: FieldInfo }>(\n buildResourcePath('documents', documentKey, 'fields', fieldId),\n normalizeFieldInput(input),\n )\n return response.field\n }\n\n /**\n * Deletes a field from a document.\n */\n async delete(documentKey: string, fieldId: string): Promise<{ success: true }> {\n return this.#http.delete<{ success: true }>(\n buildResourcePath('documents', documentKey, 'fields', fieldId),\n )\n }\n\n /**\n * Lists the document's archived (soft-deleted) fields, most recently\n * deleted first. Their values are kept, which is what makes `restore` work.\n *\n * `GET /documents/{documentKey}/fields/deleted`. Secret key, or suite bearer\n * with `zap:content:read`.\n */\n async listDeleted(documentKey: string): Promise<FieldInfo[]> {\n const response = await this.#http.get<DocumentFieldListResponse>(\n buildResourcePath('documents', documentKey, 'fields', 'deleted'),\n )\n return response.fields\n }\n\n /**\n * Brings an archived field back with every value it held, at the end of the\n * root list (outside any section).\n *\n * `POST /documents/{documentKey}/fields/{fieldId}/restore`. Secret key, or\n * suite bearer with `zap:schema:write` and the Zap ADMIN role.\n */\n async restore(documentKey: string, fieldId: string): Promise<FieldInfo> {\n const response = await this.#http.post<{ field: FieldInfo }>(\n buildResourcePath('documents', documentKey, 'fields', fieldId, 'restore'),\n )\n return response.field\n }\n\n /**\n * Reorders document fields.\n */\n async reorder(documentKey: string, fieldIds: string[]): Promise<{ success: true }> {\n return this.#http.post<{ success: true }>(\n buildResourcePath('documents', documentKey, 'fields', 'reorder'),\n { fieldIds },\n )\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type { SectionInfo, CreateSectionInput, UpdateSectionInput } from '../types/collections'\nimport type { IdempotencyOptions } from '../types/common'\nimport type { DocumentSectionListResponse } from '../types/documents'\nimport { idempotent } from './resource-helpers'\n\n/**\n * Document section management endpoints.\n */\nexport class DocumentSectionsResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Lists all sections in a document.\n */\n async list(documentKey: string): Promise<SectionInfo[]> {\n const response = await this.#http.get<DocumentSectionListResponse>(\n buildResourcePath('documents', documentKey, 'sections'),\n )\n return response.sections\n }\n\n /**\n * Gets a single section from a document.\n */\n async get(documentKey: string, sectionId: string): Promise<SectionInfo> {\n const response = await this.#http.get<{ section: SectionInfo }>(\n buildResourcePath('documents', documentKey, 'sections', sectionId),\n )\n return response.section\n }\n\n /**\n * Creates a section in a document.\n *\n * Sends an `Idempotency-Key` (required of suite bearers): a fresh one per\n * call, or `options.idempotencyKey` to make your own retry safe.\n */\n async create(\n documentKey: string,\n input: CreateSectionInput,\n options?: IdempotencyOptions,\n ): Promise<SectionInfo> {\n const response = await this.#http.post<{ section: SectionInfo }>(\n buildResourcePath('documents', documentKey, 'sections'),\n input,\n idempotent(options),\n )\n return response.section\n }\n\n /**\n * Updates a section in a document.\n */\n async update(\n documentKey: string,\n sectionId: string,\n input: UpdateSectionInput,\n ): Promise<SectionInfo> {\n const response = await this.#http.patch<{ section: SectionInfo }>(\n buildResourcePath('documents', documentKey, 'sections', sectionId),\n input,\n )\n return response.section\n }\n\n /**\n * Deletes a section from a document.\n */\n async delete(documentKey: string, sectionId: string): Promise<{ success: true }> {\n return this.#http.delete<{ success: true }>(\n buildResourcePath('documents', documentKey, 'sections', sectionId),\n )\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type { SeoInput } from '../types/common'\nimport type { DocumentSeo, DocumentSeoResponse } from '../types/documents'\n\n/**\n * Document SEO management endpoints.\n */\nexport class DocumentSeoResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Gets SEO metadata for a document.\n */\n async get(documentKey: string, options?: { locale?: string }): Promise<DocumentSeo> {\n const response = await this.#http.get<DocumentSeoResponse>(\n buildResourcePath('documents', documentKey, 'seo'),\n {\n params: {\n locale: options?.locale,\n },\n },\n )\n return response.seo\n }\n\n /**\n * Updates SEO metadata for a document.\n */\n async update(documentKey: string, input: SeoInput): Promise<DocumentSeo> {\n const response = await this.#http.put<DocumentSeoResponse>(\n buildResourcePath('documents', documentKey, 'seo'),\n input,\n )\n return response.seo\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type { DocumentValuesResponse } from '../types/documents'\n\n/**\n * Document value management endpoints.\n */\nexport class DocumentValuesResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Gets all document values.\n */\n async get(documentKey: string): Promise<Record<string, unknown>> {\n const response = await this.#http.get<DocumentValuesResponse>(\n buildResourcePath('documents', documentKey, 'values'),\n )\n return response.values\n }\n\n /**\n * Updates document values by field key.\n */\n async update(\n documentKey: string,\n values: Record<string, unknown>,\n options?: { locale?: string },\n ): Promise<Record<string, unknown>> {\n const response = await this.#http.put<DocumentValuesResponse>(\n buildResourcePath('documents', documentKey, 'values'),\n {\n locale: options?.locale,\n values,\n },\n )\n return response.values\n }\n}\n","import { HttpClient } from '../http'\nimport type { ClientDefaults, IdempotencyOptions } from '../types/common'\nimport type {\n CreateDocumentInput,\n DeleteDocumentOptions,\n DocumentDetail,\n DocumentGetOptions,\n DocumentListOptions,\n DocumentListResponse,\n UpdateDocumentInput,\n} from '../types/documents'\nimport { buildResourcePath } from '../paths'\nimport { DocumentFieldsResource } from './document-fields'\nimport { DocumentSectionsResource } from './document-sections'\nimport { DocumentSeoResource } from './document-seo'\nimport { DocumentValuesResource } from './document-values'\nimport { idempotent, toDeleteBody } from './resource-helpers'\nimport { mergeRequestOptions, previewParam, toArrayParam } from '../utils'\n\n/**\n * Read-only document endpoints.\n */\nexport class DocumentsResource {\n readonly fields: DocumentFieldsResource\n readonly sections: DocumentSectionsResource\n readonly values: DocumentValuesResource\n readonly seo: DocumentSeoResource\n readonly #http: HttpClient\n readonly #defaults: ClientDefaults\n\n /**\n * @internal\n */\n constructor(http: HttpClient, defaults: ClientDefaults) {\n this.#http = http\n this.#defaults = defaults\n this.fields = new DocumentFieldsResource(http)\n this.sections = new DocumentSectionsResource(http)\n this.values = new DocumentValuesResource(http)\n this.seo = new DocumentSeoResource(http)\n }\n\n /**\n * Lists all documents available to the current API key.\n */\n async list(options?: DocumentListOptions): Promise<DocumentListResponse> {\n const merged = mergeRequestOptions(this.#defaults, options)\n\n return this.#http.get<DocumentListResponse>(buildResourcePath('documents'), {\n params: {\n locale: merged.locale,\n status: merged.status,\n ...previewParam(merged),\n },\n })\n }\n\n /**\n * Retrieves a single document by key.\n */\n async get<TContent = Record<string, unknown>>(\n documentKey: string,\n options?: DocumentGetOptions,\n ): Promise<DocumentDetail<TContent>> {\n const merged = mergeRequestOptions(this.#defaults, options)\n\n return this.#http.get<DocumentDetail<TContent>>(buildResourcePath('documents', documentKey), {\n params: {\n locale: merged.locale,\n status: merged.status,\n fields: toArrayParam(merged.fields),\n ...previewParam(merged),\n },\n })\n }\n\n /**\n * Creates a document.\n *\n * Sends an `Idempotency-Key` (required of suite bearers): a fresh one per\n * call, or `options.idempotencyKey` to make your own retry safe.\n */\n async create<TContent = Record<string, unknown>>(\n input: CreateDocumentInput,\n options?: IdempotencyOptions,\n ): Promise<DocumentDetail<TContent>> {\n const response = await this.#http.post<{ document: DocumentDetail<TContent> }>(\n buildResourcePath('documents'),\n input,\n idempotent(options),\n )\n return response.document\n }\n\n /**\n * Updates a document.\n */\n async update<TContent = Record<string, unknown>>(\n documentKey: string,\n input: UpdateDocumentInput,\n ): Promise<DocumentDetail<TContent>> {\n const response = await this.#http.patch<{ document: DocumentDetail<TContent> }>(\n buildResourcePath('documents', documentKey),\n input,\n )\n return response.document\n }\n\n /**\n * Deletes a document.\n */\n async delete(documentKey: string, options?: DeleteDocumentOptions): Promise<{ success: true }> {\n return this.#http.delete<{ success: true }>(\n buildResourcePath('documents', documentKey),\n toDeleteBody(options),\n )\n }\n\n /**\n * Publishes a document.\n */\n async publish<TContent = Record<string, unknown>>(\n documentKey: string,\n ): Promise<DocumentDetail<TContent>> {\n const response = await this.#http.post<{ document: DocumentDetail<TContent> }>(\n buildResourcePath('documents', documentKey, 'publish'),\n )\n return response.document\n }\n\n /**\n * Unpublishes a document.\n */\n async unpublish<TContent = Record<string, unknown>>(\n documentKey: string,\n ): Promise<DocumentDetail<TContent>> {\n const response = await this.#http.post<{ document: DocumentDetail<TContent> }>(\n buildResourcePath('documents', documentKey, 'unpublish'),\n )\n return response.document\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type {\n CreateDraftInput,\n ItemVersionDetail,\n ItemVersionSummary,\n UpdateItemDraftInput,\n VersionListResponse,\n} from '../types/versions'\n\n/**\n * Version history, drafts and rollbacks for collection items\n * (`/collections/{collectionKey}/items/{slug}/versions…`).\n *\n * An item has at most one open draft. Writing needs a secret key; publishing\n * and rolling back need one with publish rights.\n */\nexport class ItemVersionsResource {\n readonly #http: HttpClient\n\n /** @internal */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Lists an item's versions, newest first.\n */\n async list(\n collectionKey: string,\n slug: string,\n ): Promise<VersionListResponse<ItemVersionSummary>> {\n return this.#http.get<VersionListResponse<ItemVersionSummary>>(\n buildResourcePath('collections', collectionKey, 'items', slug, 'versions'),\n )\n }\n\n /**\n * Gets one version with its snapshot (values, SEO and slugs).\n */\n async get(collectionKey: string, slug: string, versionId: string): Promise<ItemVersionDetail> {\n const response = await this.#http.get<{ version: ItemVersionDetail }>(\n buildResourcePath('collections', collectionKey, 'items', slug, 'versions', versionId),\n )\n return response.version\n }\n\n /**\n * Opens a draft from the item's live state. Fails with `DUPLICATE_KEY` (409)\n * when the item already has one.\n */\n async createDraft(\n collectionKey: string,\n slug: string,\n input?: CreateDraftInput,\n ): Promise<ItemVersionSummary> {\n const response = await this.#http.post<{ version: ItemVersionSummary }>(\n buildResourcePath('collections', collectionKey, 'items', slug, 'versions'),\n input,\n )\n return response.version\n }\n\n /**\n * Stages values (and optionally a new slug) on the open draft without\n * touching the live item. Fails with `VALIDATION_ERROR` (400) when there is\n * no open draft.\n */\n async updateDraft(\n collectionKey: string,\n slug: string,\n input: UpdateItemDraftInput,\n ): Promise<ItemVersionDetail> {\n const response = await this.#http.put<{ version: ItemVersionDetail }>(\n buildResourcePath('collections', collectionKey, 'items', slug, 'versions', 'draft'),\n input,\n )\n return response.version\n }\n\n /**\n * Discards the open draft. Fails with `NOT_FOUND` (404) when there is none.\n */\n async discardDraft(collectionKey: string, slug: string): Promise<void> {\n await this.#http.delete<unknown>(\n buildResourcePath('collections', collectionKey, 'items', slug, 'versions', 'draft'),\n )\n }\n\n /**\n * Publishes the open draft: its values go live and it becomes the item's\n * published version. Fails with `NOT_FOUND` (404) when there is no draft.\n */\n async publishDraft(collectionKey: string, slug: string): Promise<ItemVersionSummary> {\n const response = await this.#http.post<{ version: ItemVersionSummary }>(\n buildResourcePath(\n 'collections',\n collectionKey,\n 'items',\n slug,\n 'versions',\n 'draft',\n 'publish',\n ),\n )\n return response.version\n }\n\n /**\n * Restores a past version over the live item and records the restore as a\n * NEW published version (history is never rewritten). Refused (409) for a\n * draft version, or while the item has an open draft.\n */\n async rollback(\n collectionKey: string,\n slug: string,\n versionId: string,\n ): Promise<ItemVersionSummary> {\n const response = await this.#http.post<{ version: ItemVersionSummary }>(\n buildResourcePath(\n 'collections',\n collectionKey,\n 'items',\n slug,\n 'versions',\n versionId,\n 'rollback',\n ),\n )\n return response.version\n }\n}\n","import { HttpClient } from './http'\nimport type { ClientDefaults } from './types/common'\nimport type { FilterValue, ItemDetail, ItemListOptions, ItemListResponse } from './types/items'\nimport { ItemsResource } from './resources/items'\n\n/**\n * Lazy fluent query builder for item list requests.\n */\nexport class ItemQueryBuilder {\n readonly #http: HttpClient\n readonly #defaults: ClientDefaults\n readonly #collectionKey: string\n readonly #options: ItemListOptions\n\n /**\n * @internal\n */\n constructor(\n http: HttpClient,\n defaults: ClientDefaults,\n collectionKey: string,\n options: ItemListOptions = {},\n ) {\n this.#http = http\n this.#defaults = defaults\n this.#collectionKey = collectionKey\n this.#options = options\n }\n\n /**\n * Overrides the request locale.\n */\n locale(locale: string): ItemQueryBuilder {\n return this.clone({ locale })\n }\n\n /**\n * Overrides the delivery status filter.\n */\n status(status: NonNullable<ItemListOptions['status']>): ItemQueryBuilder {\n return this.clone({ status })\n }\n\n /**\n * Adds or replaces a field filter.\n */\n filter(field: string, value: FilterValue): ItemQueryBuilder {\n return this.clone({\n filter: {\n ...(this.#options.filter ?? {}),\n [field]: value,\n },\n })\n }\n\n /**\n * Sets the sort expression.\n */\n sort(sort: string): ItemQueryBuilder {\n return this.clone({ sort })\n }\n\n /**\n * Selects a sparse set of content fields.\n */\n fields(fields: string[]): ItemQueryBuilder {\n return this.clone({ fields })\n }\n\n /**\n * Sets the current page.\n */\n page(page: number): ItemQueryBuilder {\n return this.clone({ page })\n }\n\n /**\n * Sets the page size.\n */\n pageSize(pageSize: number): ItemQueryBuilder {\n return this.clone({ pageSize })\n }\n\n /**\n * Executes the built request.\n */\n async get<TContent = Record<string, unknown>>(): Promise<ItemListResponse<TContent>> {\n const resource = new ItemsResource(this.#http, this.#defaults)\n return resource.list<TContent>(this.#collectionKey, this.#options)\n }\n\n /**\n * Returns the current request options as a plain object.\n */\n toJSON(): ItemListOptions {\n return {\n ...this.#options,\n filter: this.#options.filter ? { ...this.#options.filter } : undefined,\n fields: this.#options.fields ? [...this.#options.fields] : undefined,\n }\n }\n\n private clone(partial: Partial<ItemListOptions>): ItemQueryBuilder {\n return new ItemQueryBuilder(this.#http, this.#defaults, this.#collectionKey, {\n ...this.#options,\n ...partial,\n })\n }\n}\n\nexport type { ItemDetail }\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type { SeoInput } from '../types/common'\nimport type { ItemSeo, ItemSeoResponse } from '../types/items'\n\n/**\n * Item SEO management endpoints.\n */\nexport class ItemSeoResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Gets SEO metadata for an item.\n */\n async get(collectionKey: string, slug: string, options?: { locale?: string }): Promise<ItemSeo> {\n const response = await this.#http.get<ItemSeoResponse>(\n buildResourcePath('collections', collectionKey, 'items', slug, 'seo'),\n {\n params: {\n locale: options?.locale,\n },\n },\n )\n return response.seo\n }\n\n /**\n * Updates SEO metadata for an item.\n */\n async update(collectionKey: string, slug: string, input: SeoInput): Promise<ItemSeo> {\n const response = await this.#http.patch<ItemSeoResponse>(\n buildResourcePath('collections', collectionKey, 'items', slug, 'seo'),\n input,\n )\n return response.seo\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport { ItemQueryBuilder } from '../query-builder'\nimport type { ClientDefaults, IdempotencyOptions } from '../types/common'\nimport type {\n CreateItemInput,\n DeleteItemOptions,\n ItemDetail,\n ItemGetOptions,\n ItemListOptions,\n ItemListResponse,\n UpdateItemInput,\n} from '../types/items'\nimport { mergeRequestOptions, previewParam, serializeFilters, toArrayParam } from '../utils'\nimport { ItemSeoResource } from './item-seo'\nimport { idempotent, toDeleteBody } from './resource-helpers'\n\n/**\n * Read-only collection item endpoints.\n */\nexport class ItemsResource {\n readonly seo: ItemSeoResource\n readonly #http: HttpClient\n readonly #defaults: ClientDefaults\n\n /**\n * @internal\n */\n constructor(http: HttpClient, defaults: ClientDefaults) {\n this.#http = http\n this.#defaults = defaults\n this.seo = new ItemSeoResource(http)\n }\n\n /**\n * Lists items in a collection.\n */\n async list<TContent = Record<string, unknown>>(\n collectionKey: string,\n options?: ItemListOptions,\n ): Promise<ItemListResponse<TContent>> {\n const merged = mergeRequestOptions(this.#defaults, options)\n\n return this.#http.get<ItemListResponse<TContent>>(\n buildResourcePath('collections', collectionKey, 'items'),\n {\n params: {\n locale: merged.locale,\n status: merged.status,\n fields: toArrayParam(merged.fields),\n page: merged.page,\n pageSize: merged.pageSize,\n sort: merged.sort,\n ...serializeFilters(merged.filter),\n ...previewParam(merged),\n },\n },\n )\n }\n\n /**\n * Retrieves a single item by slug.\n */\n async get<TContent = Record<string, unknown>>(\n collectionKey: string,\n slug: string,\n options?: ItemGetOptions,\n ): Promise<ItemDetail<TContent>> {\n const merged = mergeRequestOptions(this.#defaults, options)\n\n return this.#http.get<ItemDetail<TContent>>(\n buildResourcePath('collections', collectionKey, 'items', slug),\n {\n params: {\n locale: merged.locale,\n status: merged.status,\n fields: toArrayParam(merged.fields),\n ...previewParam(merged),\n },\n },\n )\n }\n\n /**\n * Starts a lazy fluent query builder for a collection.\n */\n collection(collectionKey: string): ItemQueryBuilder {\n return new ItemQueryBuilder(this.#http, this.#defaults, collectionKey)\n }\n\n /**\n * Creates an item in a collection.\n *\n * Sends an `Idempotency-Key` (required of suite bearers): a fresh one per\n * call, or `options.idempotencyKey` to make your own retry safe.\n */\n async create<TContent = Record<string, unknown>>(\n collectionKey: string,\n input: CreateItemInput,\n options?: IdempotencyOptions,\n ): Promise<ItemDetail<TContent>> {\n const response = await this.#http.post<{ item: ItemDetail<TContent> }>(\n buildResourcePath('collections', collectionKey, 'items'),\n input,\n idempotent(options),\n )\n return response.item\n }\n\n /**\n * Updates an item by slug.\n */\n async update<TContent = Record<string, unknown>>(\n collectionKey: string,\n slug: string,\n input: UpdateItemInput,\n ): Promise<ItemDetail<TContent>> {\n const response = await this.#http.patch<{ item: ItemDetail<TContent> }>(\n buildResourcePath('collections', collectionKey, 'items', slug),\n input,\n )\n return response.item\n }\n\n /**\n * Deletes an item by slug.\n */\n async delete(\n collectionKey: string,\n slug: string,\n options?: DeleteItemOptions,\n ): Promise<{ success: true }> {\n return this.#http.delete<{ success: true }>(\n buildResourcePath('collections', collectionKey, 'items', slug),\n toDeleteBody(options),\n )\n }\n\n /**\n * Publishes an item by slug.\n */\n async publish<TContent = Record<string, unknown>>(\n collectionKey: string,\n slug: string,\n ): Promise<ItemDetail<TContent>> {\n const response = await this.#http.post<{ item: ItemDetail<TContent> }>(\n buildResourcePath('collections', collectionKey, 'items', slug, 'publish'),\n )\n return response.item\n }\n\n /**\n * Unpublishes an item by slug.\n */\n async unpublish<TContent = Record<string, unknown>>(\n collectionKey: string,\n slug: string,\n ): Promise<ItemDetail<TContent>> {\n const response = await this.#http.post<{ item: ItemDetail<TContent> }>(\n buildResourcePath('collections', collectionKey, 'items', slug, 'unpublish'),\n )\n return response.item\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type { IdempotencyOptions } from '../types/common'\nimport { normalizeHeaderValue } from '../utils'\nimport { idempotent } from './resource-helpers'\nimport type {\n ConfirmUploadInput,\n CreateUploadUrlInput,\n MediaDetail,\n MediaFromUrlInput,\n MediaListParams,\n MediaListResponse,\n MediaUploadInput,\n UpdateMediaInput,\n UploadFile,\n UploadUrlResponse,\n} from '../types/media'\n\nfunction isBlobFile(file: UploadFile): file is Blob {\n return typeof Blob !== 'undefined' && file instanceof Blob\n}\n\nfunction toUploadBody(file: UploadFile): BodyInit {\n if (isBlobFile(file)) {\n return file\n }\n\n if (ArrayBuffer.isView(file)) {\n const bytes =\n file.buffer instanceof ArrayBuffer\n ? file.buffer.slice(file.byteOffset, file.byteOffset + file.byteLength)\n : new Uint8Array(file.buffer, file.byteOffset, file.byteLength).slice().buffer\n return new Blob([bytes])\n }\n\n return file\n}\n\nfunction getUploadSize(file: UploadFile): number {\n if (isBlobFile(file)) {\n return file.size\n }\n\n if (ArrayBuffer.isView(file)) {\n return file.byteLength\n }\n\n return file instanceof ArrayBuffer ? file.byteLength : 0\n}\n\n/**\n * Media management endpoints.\n */\nexport class MediaResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Lists media for the current site.\n */\n async list(params?: MediaListParams): Promise<MediaListResponse> {\n return this.#http.get<MediaListResponse>(buildResourcePath('media'), {\n params: {\n search: params?.search,\n page: params?.page,\n pageSize: params?.pageSize,\n sort: params?.sort,\n type: params?.type,\n status: params?.status,\n usage: params?.usage,\n },\n })\n }\n\n /**\n * Gets a single media item.\n */\n async get(id: string): Promise<MediaDetail> {\n return this.#http.get<MediaDetail>(buildResourcePath('media', id))\n }\n\n /**\n * Updates media metadata.\n */\n async update(id: string, input: UpdateMediaInput): Promise<MediaDetail> {\n const response = await this.#http.patch<{ media: MediaDetail }>(\n buildResourcePath('media', id),\n input,\n )\n return response.media\n }\n\n /**\n * Deletes media.\n */\n async delete(id: string): Promise<{ success: true }> {\n return this.#http.delete<{ success: true }>(buildResourcePath('media', id))\n }\n\n /**\n * Publishes media.\n */\n async publish(id: string): Promise<MediaDetail> {\n const response = await this.#http.post<{ media: MediaDetail }>(\n buildResourcePath('media', id, 'publish'),\n )\n return response.media\n }\n\n /**\n * Unpublishes media.\n */\n async unpublish(id: string): Promise<MediaDetail> {\n const response = await this.#http.post<{ media: MediaDetail }>(\n buildResourcePath('media', id, 'unpublish'),\n )\n return response.media\n }\n\n /**\n * Requests a presigned upload URL.\n */\n async createUploadUrl(input: CreateUploadUrlInput): Promise<UploadUrlResponse> {\n return this.#http.post<UploadUrlResponse>(buildResourcePath('media', 'upload-url'), input)\n }\n\n /**\n * Confirms a completed upload.\n */\n async confirmUpload(input: ConfirmUploadInput): Promise<MediaDetail> {\n const response = await this.#http.post<{ media: MediaDetail }>(\n buildResourcePath('media', 'confirm'),\n input,\n )\n return response.media\n }\n\n /**\n * Fetches a file from a URL into the media library, server-side (SSRF\n * guarded, type allowlist, size ceiling). The file starts private (`DRAFT`):\n * the answer carries a 15-minute `signedUrl` and no `url` until `publish`.\n *\n * `POST /media/from-url`. Secret key, or suite bearer with\n * `zap:media:write`. Sends an `Idempotency-Key` (required of suite bearers;\n * a retry with the same key replays the first answer without downloading\n * again). Server-side only: the API's general CORS does not allow that\n * header from a browser.\n */\n async fromUrl(input: MediaFromUrlInput, options?: IdempotencyOptions): Promise<MediaDetail> {\n return this.#http.post<MediaDetail>(\n buildResourcePath('media', 'from-url'),\n input,\n idempotent(options),\n )\n }\n\n /**\n * Uploads media using the public presigned URL flow.\n */\n async upload(input: MediaUploadInput): Promise<MediaDetail> {\n const upload = await this.createUploadUrl({\n filename: input.filename,\n contentType: input.contentType,\n size: getUploadSize(input.file),\n width: input.width,\n height: input.height,\n })\n\n await this.#http.upload(upload.uploadUrl, toUploadBody(input.file), {\n 'Content-Type': input.contentType,\n })\n\n const media = await this.confirmUpload({\n mediaId: upload.mediaId,\n key: upload.key,\n filename: input.filename,\n contentType: input.contentType,\n size: getUploadSize(input.file),\n width: input.width,\n height: input.height,\n })\n\n const alt = normalizeHeaderValue(input.alt)\n const title = normalizeHeaderValue(input.title)\n const description = normalizeHeaderValue(input.description)\n\n if (!alt && !title && !description) {\n return media\n }\n\n return this.update(media.id, {\n alt: alt ?? null,\n title: title ?? null,\n description: description ?? null,\n })\n }\n}\n","import { HttpClient } from '../http'\nimport type { PreviewTokenValidation } from '../types/common'\n\n/**\n * Preview tokens (`zpt_…`, zap-cms-v2 §3.5): ten minutes, one site, read-only.\n */\nexport class PreviewTokensResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Checks that the client's preview token is live AND was minted for the\n * site `siteApiKey` belongs to, before trusting it (what a draft-mode route\n * does before turning draft mode on). Rejects with `EelZapError` 401 for an\n * unknown, revoked or expired token, 403 `WRONG_SITE` for another site's.\n *\n * `GET /preview/token`. The client's `apiKey` must be the `zpt_` token\n * itself (any other bearer is 403); `siteApiKey` is one of the site's own\n * API keys (public or secret), sent as `X-Zap-Site-Api-Key`.\n *\n * @example\n * ```ts\n * const zap = createClient({ apiKey: token })\n * const { site, expiresAt } = await zap.previewTokens.validate(process.env.ZAP_PUBLIC_KEY!)\n * ```\n */\n async validate(siteApiKey: string): Promise<PreviewTokenValidation> {\n return this.#http.get<PreviewTokenValidation>('/preview/token', {\n headers: { 'X-Zap-Site-Api-Key': siteApiKey },\n })\n }\n}\n","import { HttpClient } from '../http'\nimport { buildResourcePath } from '../paths'\nimport type { SiteInfo, UpdateSiteInput } from '../types/common'\n\n/**\n * The site the API key belongs to: read it, and set where it lives.\n */\nexport class SiteResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Resolves the current site from the authenticated API key.\n */\n async get(): Promise<SiteInfo> {\n return this.#http.get<SiteInfo>(buildResourcePath('site'))\n }\n\n /**\n * Sets the site's URL and «Otros dominios» (`PATCH /site`), under the same\n * rules as the site's settings page, and resolves to the updated site.\n * Server code only: it needs a `secret_` key or an ADMIN suite credential.\n */\n async update(input: UpdateSiteInput): Promise<SiteInfo> {\n return this.#http.patch<SiteInfo>(buildResourcePath('site'), input)\n }\n}\n","import { HttpClient } from '../http'\nimport type { SiteListEntry } from '../types/common'\n\n/**\n * The credential's workspace's sites.\n */\nexport class SitesResource {\n readonly #http: HttpClient\n\n /**\n * @internal\n */\n constructor(http: HttpClient) {\n this.#http = http\n }\n\n /**\n * Lists the workspace's sites, newest first. Each one's `key` or `id` is a\n * valid `X-Eel-Site` for every other call; this is how a suite client\n * learns which sites it can address.\n *\n * `GET /sites`. Suite bearer only (`eel_sk_` / `eel_at_`), `zap:sites:read`;\n * needs no `X-Eel-Site`. Site keys are refused: a site key is one site.\n */\n async list(): Promise<SiteListEntry[]> {\n const response = await this.#http.get<{ sites: SiteListEntry[] }>('/sites')\n return response.sites\n }\n}\n","import { HttpClient } from './http'\nimport { CollectionsResource } from './resources/collections'\nimport { CommentsResource } from './resources/comments'\nimport { DocumentVersionsResource } from './resources/document-versions'\nimport { DocumentsResource } from './resources/documents'\nimport { ItemVersionsResource } from './resources/item-versions'\nimport { ItemsResource } from './resources/items'\nimport { MediaResource } from './resources/media'\nimport { PreviewTokensResource } from './resources/preview-tokens'\nimport { resolveRetry, type RetryOptions } from './retry'\nimport { SiteResource } from './resources/site'\nimport { SitesResource } from './resources/sites'\nimport type { ClientDefaults, DeliveryStatus } from './types/common'\nimport { isPreviewToken, maskApiKey, normalizeBaseUrl } from './utils'\n\nexport interface ClientConfig {\n /**\n * The bearer: a site API key (`secret_…` / `public_…`), or a preview token\n * (`zpt_…`) from a draft-mode URL — which turns `preview` on by default.\n */\n apiKey: string\n baseUrl?: string\n pathPrefix?: string\n locale?: string\n status?: DeliveryStatus\n /** Default for the item and document reads' `preview` option. */\n preview?: boolean\n fetch?: typeof globalThis.fetch\n defaultHeaders?: HeadersInit\n /** Per attempt, in ms. Default `30000`. */\n timeout?: number\n /**\n * Retries of a `429`, and of a `503` with `Retry-After`, honouring\n * `Retry-After` with exponential backoff and jitter. On by default for reads\n * and for writes that carry an `Idempotency-Key`; other writes are never\n * retried. `false` turns it off.\n */\n retry?: boolean | RetryOptions\n}\n\n/**\n * Main SDK client for the EelZap Content Delivery API.\n */\nexport class EelZapClient {\n readonly site: SiteResource\n readonly sites: SitesResource\n readonly collections: CollectionsResource\n readonly items: ItemsResource\n readonly documents: DocumentsResource\n readonly media: MediaResource\n readonly itemVersions: ItemVersionsResource\n readonly documentVersions: DocumentVersionsResource\n readonly previewTokens: PreviewTokensResource\n readonly comments: CommentsResource\n readonly #http: HttpClient\n readonly #defaults: ClientDefaults\n readonly #config: Required<Pick<ClientConfig, 'apiKey' | 'baseUrl' | 'pathPrefix' | 'timeout'>> &\n Pick<ClientConfig, 'defaultHeaders'>\n\n constructor(config: ClientConfig) {\n if (!config.apiKey.trim()) {\n throw new TypeError('apiKey is required.')\n }\n\n const fetchImpl = config.fetch ?? globalThis.fetch\n if (typeof fetchImpl !== 'function') {\n throw new TypeError('A fetch implementation is required.')\n }\n\n this.#defaults = {\n locale: config.locale,\n status: config.status,\n // A preview token only ever reads previews; say so on the wire too.\n preview: config.preview ?? (isPreviewToken(config.apiKey) || undefined),\n }\n\n this.#config = {\n apiKey: config.apiKey,\n baseUrl: normalizeBaseUrl(config.baseUrl ?? 'https://api.eelzap.com'),\n pathPrefix: config.pathPrefix ?? '/v1',\n defaultHeaders: config.defaultHeaders,\n timeout: config.timeout ?? 30_000,\n }\n\n this.#http = new HttpClient({\n apiKey: this.#config.apiKey,\n baseUrl: this.#config.baseUrl,\n pathPrefix: this.#config.pathPrefix,\n fetch: fetchImpl,\n defaultHeaders: this.#config.defaultHeaders,\n timeout: this.#config.timeout,\n retry: resolveRetry(config.retry),\n })\n\n this.site = new SiteResource(this.#http)\n this.sites = new SitesResource(this.#http)\n this.collections = new CollectionsResource(this.#http, this.#defaults)\n this.items = new ItemsResource(this.#http, this.#defaults)\n this.documents = new DocumentsResource(this.#http, this.#defaults)\n this.media = new MediaResource(this.#http)\n this.itemVersions = new ItemVersionsResource(this.#http)\n this.documentVersions = new DocumentVersionsResource(this.#http)\n this.previewTokens = new PreviewTokensResource(this.#http)\n this.comments = new CommentsResource(this.#http)\n }\n\n /**\n * Returns a masked string representation safe for logs.\n */\n toString(): string {\n return `EelZapClient(baseUrl=${this.#config.baseUrl}, pathPrefix=${this.#config.pathPrefix}, apiKey=${maskApiKey(this.#config.apiKey)})`\n }\n}\n\n/**\n * Creates a configured EelZap Delivery SDK client.\n */\nexport function createClient(config: ClientConfig): EelZapClient {\n return new EelZapClient(config)\n}\n","import type { MediaValue } from './types/common'\n\n/**\n * The URL to render a media value with: the public `url` of a published file,\n * else the short-lived `signedUrl` a draft carries when the key may read\n * drafts. `null` when there is neither — an unpublished file read with a key\n * that cannot see drafts (`mediaAccess: 'none'`), or no media at all.\n *\n * A signed URL expires (`signedUrlExpiresAt`), so never cache it in a page\n * that outlives that time.\n */\nexport function getMediaUrl(\n media: Pick<MediaValue, 'url' | 'signedUrl'> | null | undefined,\n): string | null {\n return media?.url ?? media?.signedUrl ?? null\n}\n","/**\n * Stega: invisible field markers on prose values read in preview\n * (`.docs/proposals/zap-cms-v2.md` §2.4, §7.5).\n *\n * Zap appends a marker to TEXT and LONG_TEXT values, and to the last text\n * node of each RICH_TEXT block, ONLY in `preview=1` delivery responses. The\n * preview overlay finds the marker in the page's text nodes and so knows\n * which element renders which field, with no manual tag. Published responses\n * never carry one.\n *\n * ## Format (eelzap stega v1)\n *\n * A marker is the tag the overlay would read from a `data-zap` attribute,\n * `recordRef#fieldKey`, plus `@locale` when the value belongs to a locale:\n *\n * blog-posts/mi-primer-post#title@es\n * doc:home#hero_title@es\n *\n * written as zero-width characters:\n *\n * - four digits, base 4: U+200B (0), U+200C (1), U+200D (2), U+2060 (3);\n * - a prefix of 8 digits, the bytes 0xE5 0xA7 (`3211 2213`);\n * - then every byte of the ASCII payload as 4 digits, most significant first.\n *\n * The payload is printable ASCII (the tag grammar allows nothing else), so\n * every payload byte starts with digit 0 or 1 and the prefix, which starts\n * with 3, can never be read inside a payload. A decoder reads groups of four\n * after the prefix until a group is not a payload byte, then validates the\n * result against the tag grammar; anything that does not parse is ignored. A\n * value never carries two markers (`stegaEncode` refuses to add a second).\n *\n * Why not `@vercel/stega`'s format: it encodes a JSON object (a URL and\n * origin in Sanity's and Vercel's use) and uses U+FEFF, which some tools strip\n * as a byte order mark. Here the decoded marker IS the tag grammar\n * (`data-zap`), so one parser serves both, and U+FEFF is avoided. No\n * dependency either way.\n *\n * Zero dependencies, no side effects: `.` re-exports `cleanStega` and\n * `hasStega`; the encoder is internal (Zap's delivery imports it); the\n * decoder serves `./preview`.\n */\n\nconst DIGITS = ['​', '‌', '‍', '⁠'] as const\nconst PREFIX = '⁠‍‌‌‍‍‌⁠'\n/** Longest payload a marker may carry, in bytes (ref 300 + field 128 + locale). */\nconst MAX_PAYLOAD = 512\n\n/** `recordRef#fieldKey` with an optional `@locale`: the tag grammar (`refs.ts`). */\nconst PAYLOAD_RE =\n /^(doc:[a-z0-9]+(?:-[a-z0-9]+)*|[a-z0-9]+(?:-[a-z0-9]+)*\\/[a-z0-9]+(?:-[a-z0-9]+)*)#([a-z][a-z0-9_]{0,127})(?:@([A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8}){0,3}))?$/\n/** The prefix, then whole payload bytes (first digit 0 or 1). */\nconst MARKER_RE = /⁠‍‌‌‍‍‌⁠(?:[​‌][​‌‍⁠]{3})*/g\n\n/** What one marker says: the record, the field, and the locale when known. */\nexport interface StegaInfo {\n /** `collectionKey/slug` or `doc:documentKey`. */\n recordRef: string\n fieldKey: string\n locale?: string | null\n}\n\nexport interface DecodedStega {\n recordRef: string\n fieldKey: string\n locale: string | null\n /** `recordRef#fieldKey`, the `data-zap` tag. */\n tag: string\n}\n\n/** The marker for one field, or `''` when the info does not fit the tag grammar. */\nexport function stegaMarker(info: StegaInfo): string {\n const payload = `${info.recordRef}#${info.fieldKey}${info.locale ? `@${info.locale}` : ''}`\n if (payload.length > MAX_PAYLOAD || !PAYLOAD_RE.test(payload)) return ''\n let out = PREFIX\n for (let i = 0; i < payload.length; i++) {\n const byte = payload.charCodeAt(i)\n out +=\n DIGITS[(byte >> 6) & 3]! +\n DIGITS[(byte >> 4) & 3]! +\n DIGITS[(byte >> 2) & 3]! +\n DIGITS[byte & 3]!\n }\n return out\n}\n\n/**\n * `text` with the field's marker appended. A string that already carries a\n * marker, or info outside the grammar, comes back unchanged.\n */\nexport function stegaEncode(text: string, info: StegaInfo): string {\n if (hasStega(text)) return text\n return text + stegaMarker(info)\n}\n\n/** True when `value` is a string carrying at least one marker. */\nexport function hasStega(value: unknown): boolean {\n return typeof value === 'string' && value.includes(PREFIX)\n}\n\n/** Every valid marker in `text`, in order. Invalid ones are skipped. */\nexport function stegaDecode(text: string): DecodedStega[] {\n if (!text.includes(PREFIX)) return []\n const found: DecodedStega[] = []\n for (const match of text.match(MARKER_RE) ?? []) {\n let payload = ''\n for (let i = PREFIX.length; i + 4 <= match.length; i += 4) {\n let byte = 0\n for (let j = 0; j < 4; j++) byte = byte * 4 + DIGITS.indexOf(match[i + j] as never)\n payload += String.fromCharCode(byte)\n }\n const parsed = PAYLOAD_RE.exec(payload)\n if (!parsed) continue\n found.push({\n recordRef: parsed[1]!,\n fieldKey: parsed[2]!,\n locale: parsed[3] ?? null,\n tag: `${parsed[1]}#${parsed[2]}`,\n })\n }\n return found\n}\n\n/** `text` split into its visible part and the markers it carries, in order. */\nexport function splitStega(text: string): { text: string; markers: string } {\n if (!text.includes(PREFIX)) return { text, markers: '' }\n return { text: text.replace(MARKER_RE, ''), markers: (text.match(MARKER_RE) ?? []).join('') }\n}\n\n/** `text` without any marker. */\nfunction cleanString(text: string): string {\n return text.includes(PREFIX) ? text.replace(MARKER_RE, '') : text\n}\n\n/**\n * `value` with every stega marker removed: a string is cleaned, an array or a\n * plain object is cleaned deeply (into new objects), anything else is\n * returned as is. Use it where a preview value is compared, parsed or put in\n * an attribute, a URL or `<head>`; outside preview it changes nothing.\n */\nexport function cleanStega<T>(value: T): T {\n if (typeof value === 'string') return cleanString(value) as T\n if (Array.isArray(value)) return value.map((item) => cleanStega(item)) as T\n if (value && typeof value === 'object' && Object.getPrototypeOf(value) === Object.prototype) {\n const out: Record<string, unknown> = {}\n for (const [key, item] of Object.entries(value)) out[key] = cleanStega(item)\n return out as T\n }\n return value\n}\n","import type {\n WebhookAction,\n WebhookChange,\n WebhookCollectionEventData,\n WebhookDocumentEventData,\n WebhookEventType,\n WebhookItemEventData,\n WebhookMediaEventData,\n WebhookPayload,\n WebhookSchemaEventData,\n WebhookSeoEventData,\n WebhookSiteEventData,\n WebhookSiteRef,\n} from './types/webhook'\n\n/*\n * Webhook signature verification, written against WebCrypto only\n * (`globalThis.crypto.subtle`) so the same code runs in Node 20+, edge\n * runtimes, workers and browsers. This module must not import anything at\n * runtime — not `node:crypto`, not another SDK module — so it stays in the\n * root entry without tying it to Node. The edge test evaluates it in a bare\n * VM context to keep it that way.\n *\n * The scheme is the suite's (ADR 031 §4.1, `@eel/webhooks` sign.ts):\n *\n * X-Eel-Timestamp: <unix seconds>\n * X-Eel-Signature: v1=<hex HMAC-SHA256(`${timestamp}.${rawBody}`)>\n *\n * keyed with the UTF-8 bytes of the endpoint secret minus its `whsec_` prefix.\n * The timestamp is inside the MAC, so a captured delivery cannot be replayed\n * outside the tolerance window by changing the header.\n */\n\n/** Header carrying `v1=<hex>`. Header lookups are case-insensitive. */\nexport const WEBHOOK_SIGNATURE_HEADER = 'X-Eel-Signature'\n/** Header carrying the unix-second timestamp that is part of the signed content. */\nexport const WEBHOOK_TIMESTAMP_HEADER = 'X-Eel-Timestamp'\n/** Deliveries older or newer than this, in seconds, are refused: 5 minutes. */\nexport const WEBHOOK_TOLERANCE_SECONDS = 300\n\nconst SECRET_PREFIX = 'whsec_'\nconst SIGNATURE_PREFIX = 'v1='\nconst HMAC_SHA256_HEX_LENGTH = 64\n\n/**\n * The request headers: a Fetch `Headers` (Next.js route handlers, workers), or\n * a plain object such as Node's `IncomingHttpHeaders` (Express).\n */\nexport type WebhookHeaders =\n | Pick<Headers, 'get'>\n | Record<string, string | readonly string[] | undefined>\n\nexport interface VerifyWebhookOptions {\n /** Maximum clock difference in seconds. Default {@link WEBHOOK_TOLERANCE_SECONDS}. */\n toleranceSeconds?: number\n /** The current time. Default `new Date()`. */\n now?: Date\n}\n\nfunction readHeader(headers: WebhookHeaders, name: string): string | null {\n if (typeof (headers as Pick<Headers, 'get'>).get === 'function') {\n return (headers as Pick<Headers, 'get'>).get(name)\n }\n const wanted = name.toLowerCase()\n for (const [key, value] of Object.entries(headers)) {\n if (key.toLowerCase() !== wanted || value === undefined) continue\n // A repeated header is ambiguous: refuse rather than pick one.\n if (typeof value === 'string') return value\n return value.length === 1 ? (value[0] ?? null) : null\n }\n return null\n}\n\nfunction hexToBytes(value: string): Uint8Array<ArrayBuffer> | null {\n if (value.length !== HMAC_SHA256_HEX_LENGTH || !/^[0-9a-f]+$/i.test(value)) {\n return null\n }\n const bytes = new Uint8Array(value.length / 2)\n for (let index = 0; index < bytes.length; index += 1) {\n bytes[index] = Number.parseInt(value.slice(index * 2, index * 2 + 2), 16)\n }\n return bytes\n}\n\nfunction getSubtle(): SubtleCrypto {\n const subtle = (globalThis as { crypto?: Crypto }).crypto?.subtle\n if (!subtle) {\n // A misconfigured runtime is not a forged request, so it is not `false`.\n throw new Error(\n 'verifyWebhookSignature needs WebCrypto (globalThis.crypto.subtle). ' +\n 'Node 18 does not expose it by default: use Node 20+, or set ' +\n \"globalThis.crypto to node:crypto's webcrypto at startup.\",\n )\n }\n return subtle\n}\n\n/**\n * Verifies a webhook delivery: the signature over the raw body and the\n * timestamp, and that the timestamp is within the tolerance window.\n *\n * Pass the body exactly as received (`await request.text()`), never a\n * re-serialised parse: the MAC covers the bytes that were sent.\n *\n * @returns `true` only for an authentic, fresh delivery. Any missing or\n * malformed header, wrong secret, altered body or stale timestamp is `false`.\n * @throws When the runtime has no WebCrypto.\n *\n * @example\n * ```ts\n * const payload = await request.text()\n * if (!(await verifyWebhookSignature(payload, request.headers, process.env.EELZAP_WEBHOOK_SECRET!))) {\n * return new Response('Invalid signature', { status: 401 })\n * }\n * ```\n */\nexport async function verifyWebhookSignature(\n payload: string,\n headers: WebhookHeaders,\n secret: string,\n options: VerifyWebhookOptions = {},\n): Promise<boolean> {\n if (\n typeof payload !== 'string' ||\n typeof secret !== 'string' ||\n !headers ||\n typeof headers !== 'object'\n ) {\n return false\n }\n\n const key = secret.startsWith(SECRET_PREFIX) ? secret.slice(SECRET_PREFIX.length) : secret\n if (!key) {\n return false\n }\n\n const timestamp = readHeader(headers, WEBHOOK_TIMESTAMP_HEADER)?.trim()\n if (!timestamp || !/^\\d+$/.test(timestamp)) {\n return false\n }\n const nowSeconds = (options.now ?? new Date()).getTime() / 1000\n const tolerance = options.toleranceSeconds ?? WEBHOOK_TOLERANCE_SECONDS\n if (!(Math.abs(nowSeconds - Number(timestamp)) <= tolerance)) {\n return false\n }\n\n const signature = readHeader(headers, WEBHOOK_SIGNATURE_HEADER)?.trim()\n if (!signature?.startsWith(SIGNATURE_PREFIX)) {\n return false\n }\n const signatureBytes = hexToBytes(signature.slice(SIGNATURE_PREFIX.length))\n if (!signatureBytes) {\n return false\n }\n\n const subtle = getSubtle()\n const encoder = new TextEncoder()\n const hmacKey = await subtle.importKey(\n 'raw',\n encoder.encode(key),\n { name: 'HMAC', hash: 'SHA-256' },\n false,\n ['verify'],\n )\n // `verify` compares in constant time, unlike comparing two hex strings.\n return subtle.verify('HMAC', hmacKey, signatureBytes, encoder.encode(`${timestamp}.${payload}`))\n}\n\n/**\n * The verbs of the content events that change what the live site serves.\n * Not `draft_updated` (a draft is not live) and not `assigned`.\n */\nconst CHANGE_ACTIONS: ReadonlySet<string> = new Set<WebhookAction>([\n 'created',\n 'updated',\n 'published',\n 'unpublished',\n 'deleted',\n 'rolled_back',\n 'uploaded',\n])\n\n/**\n * Flattens a Zap event into the {@link WebhookChange}s a site invalidates its\n * cache by:\n *\n * - `zap.item.*`, `zap.document.*`, `zap.media.*`: one change per item,\n * document or file.\n * - `zap.seo.updated`: one `item` or `document` change (action `updated`) per\n * entry or document whose SEO changed.\n * - `zap.collection.*`: one `collection` change.\n * - `zap.schema.field_changed` (action `field_changed`): one `collection`\n * change per collection whose fields changed, and one `document` change per\n * document whose fields changed, each named by its key. An older payload\n * without the keys names a collection by id (`resourceKey` is the id, no\n * `collectionKey`) and widens a document's fields to one `site` change.\n * - `zap.site.updated`: one `site` change.\n *\n * Every other event yields an empty list: `ping`, drafts (`draft_updated`),\n * assignments, comments, API keys, and sites created or deleted.\n */\nexport function webhookChanges(payload: WebhookPayload): WebhookChange[] {\n switch (payload.type) {\n case 'zap.seo.updated':\n return seoChanges(payload.data as WebhookSeoEventData)\n case 'zap.collection.created':\n case 'zap.collection.updated':\n case 'zap.collection.deleted':\n return collectionChanges(\n payload.type.slice('zap.collection.'.length) as WebhookAction,\n payload.data as WebhookCollectionEventData,\n )\n case 'zap.schema.field_changed':\n return schemaChanges(payload.data as WebhookSchemaEventData)\n case 'zap.site.updated':\n return siteChanges('updated', payload.data as WebhookSiteEventData)\n }\n\n const match = /^zap\\.(item|document|media)\\.([a-z_]+)$/.exec(payload.type)\n if (!match || !CHANGE_ACTIONS.has(match[2]!)) {\n return []\n }\n const type = match[1] as WebhookEventType\n const action = match[2] as WebhookAction\n\n if (type === 'item') {\n const data = payload.data as WebhookItemEventData\n return (data.items ?? []).map((item) => ({\n type,\n action,\n id: item.id,\n resourceKey: item.slug,\n collectionKey: data.collection.key,\n siteKey: data.site.key,\n }))\n }\n if (type === 'document') {\n const data = payload.data as WebhookDocumentEventData\n return (data.documents ?? []).map((document) => ({\n type,\n action,\n id: document.id,\n resourceKey: document.key,\n siteKey: data.site.key,\n }))\n }\n const data = payload.data as WebhookMediaEventData\n return (data.media ?? []).map((media) => ({\n type,\n action,\n id: media.id,\n resourceKey: media.id,\n siteKey: data.site.key,\n }))\n}\n\n/** An SEO change is a change to the entry or document it is on. */\nfunction seoChanges(data: WebhookSeoEventData): WebhookChange[] {\n return (data.targets ?? []).map((target): WebhookChange => {\n if (target.kind === 'item') {\n return {\n type: 'item',\n action: 'updated',\n id: target.id,\n resourceKey: target.key,\n ...(data.collection ? { collectionKey: data.collection.key } : {}),\n siteKey: data.site.key,\n }\n }\n return {\n type: 'document',\n action: 'updated',\n id: target.id,\n resourceKey: target.key,\n siteKey: data.site.key,\n }\n })\n}\n\nfunction collectionChanges(\n action: WebhookAction,\n data: WebhookCollectionEventData,\n): WebhookChange[] {\n if (!data.collection || !data.site) return []\n return [\n {\n type: 'collection',\n action,\n id: data.collection.id,\n resourceKey: data.collection.key,\n collectionKey: data.collection.key,\n siteKey: data.site.key,\n },\n ]\n}\n\n/**\n * One change per owner, however many fields changed: a collection by its key,\n * a document by its key. Payloads from before the keys were added name the\n * owner by id only: a collection keeps its id, and fields of a document widen\n * to the site.\n */\nfunction schemaChanges(data: WebhookSchemaEventData): WebhookChange[] {\n const changes: WebhookChange[] = []\n const seen = new Set<string>()\n for (const change of data.changes ?? []) {\n if (change.collection_id) {\n if (seen.has(`collection:${change.collection_id}`)) continue\n seen.add(`collection:${change.collection_id}`)\n const key = change.collection_key\n changes.push({\n type: 'collection',\n action: 'field_changed',\n id: change.collection_id,\n resourceKey: key ?? change.collection_id,\n ...(key ? { collectionKey: key } : {}),\n siteKey: data.site.key,\n })\n } else if (change.document_id && change.document_key) {\n if (seen.has(`document:${change.document_id}`)) continue\n seen.add(`document:${change.document_id}`)\n changes.push({\n type: 'document',\n action: 'field_changed',\n id: change.document_id,\n resourceKey: change.document_key,\n siteKey: data.site.key,\n })\n } else if (change.document_id && !seen.has('site')) {\n seen.add('site')\n changes.push(...siteChanges('field_changed', data))\n }\n }\n return changes\n}\n\nfunction siteChanges(action: WebhookAction, data: { site?: WebhookSiteRef }): WebhookChange[] {\n if (!data.site) return []\n return [\n {\n type: 'site',\n action,\n id: data.site.id,\n resourceKey: data.site.key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AAC5F,MAAI,CAAC,KAAK,KAAM,QAAO,CAAC;AACxB,SAAO;AAAA,IACL;AAAA,MACE,MAAM;AAAA,MACN;AAAA,MACA,IAAI,KAAK,KAAK;AAAA,MACd,aAAa,KAAK,KAAK;AAAA,MACvB,SAAS,KAAK,KAAK;AAAA,IACrB;AAAA,EACF;AACF;","names":["_http","_http","_http","_http","_http","_http","_http","_http","_http","_defaults","_http","_http","_defaults","_http","_http","_defaults","_http","_http","_http","_http","_http","_defaults","_config","data"]}