@conloca/content-api-client 0.1.15 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +190 -105
- package/dist/client.d.ts +92 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +435 -0
- package/dist/client.js.map +1 -0
- package/dist/data-bindings.d.ts +13 -0
- package/dist/data-bindings.d.ts.map +1 -0
- package/dist/data-bindings.js +71 -0
- package/dist/data-bindings.js.map +1 -0
- package/dist/hooks.d.ts +142 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +761 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/content-api-client.d.ts +2 -0
- package/dist/lib/content-api-client.d.ts.map +1 -0
- package/dist/lib/content-api-client.js +4 -0
- package/dist/lib/content-api-client.js.map +1 -0
- package/dist/test-helpers.d.ts +89 -0
- package/dist/test-helpers.d.ts.map +1 -0
- package/dist/test-helpers.js +236 -0
- package/dist/test-helpers.js.map +1 -0
- package/dist/testing.d.ts +8 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +8 -0
- package/dist/testing.js.map +1 -0
- package/package.json +64 -19
- package/src/client.ts +513 -0
- package/src/data-bindings.ts +104 -0
- package/src/hooks.tsx +959 -0
- package/src/index.ts +50 -0
- package/src/lib/content-api-client.ts +3 -0
- package/src/test-helpers.ts +282 -0
- package/src/testing.ts +8 -0
- package/dist/index.d.mts +0 -240
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -1105
- package/dist/index.mjs.map +0 -1
- package/dist/test-helpers-BJxZXOMi.d.mts +0 -94
- package/dist/test-helpers-BJxZXOMi.d.mts.map +0 -1
- package/dist/test-helpers-CRvDHjs2.mjs +0 -220
- package/dist/test-helpers-CRvDHjs2.mjs.map +0 -1
- package/dist/testing.d.mts +0 -2
- package/dist/testing.mjs +0 -3
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["ErrorCodes"],"sources":["../src/client.ts","../src/hooks.tsx"],"sourcesContent":["import type {\n APIError,\n AssetEntry,\n AssetUsage,\n BatchResult,\n ContentEntry,\n ContentListResult,\n ContentManifest,\n CreateContentInput,\n CreateResult,\n DataContext,\n DeleteResult,\n ErrorCode,\n FolderListing,\n FolderTreeNode,\n GitCommitResult,\n GitPullResult,\n GitPushResult,\n GitStatus,\n GlobalFilters,\n LocalizedEntry,\n MDXCompileResponse,\n MoveResult,\n SitesConfig,\n UpdateLocaleInput,\n UpdateResult,\n} from '@conloca/content-api';\nimport { ErrorCodes } from '@conloca/content-api';\n\nexport interface ContentAPIClientOptions {\n baseUrl?: string;\n fetch?: typeof fetch;\n}\n\nexport class ContentAPIClient {\n private baseUrl: string;\n private fetch: typeof fetch;\n\n constructor(options: ContentAPIClientOptions = {}) {\n // Bind fetch to maintain its context\n if (options.fetch) {\n this.fetch = options.fetch;\n } else if (typeof globalThis !== 'undefined' && globalThis.fetch) {\n // Use globalThis for better compatibility\n this.fetch = globalThis.fetch.bind(globalThis);\n } else {\n this.fetch = fetch;\n }\n this.baseUrl = options.baseUrl || '/__conloca/api';\n }\n\n private encodeAssetPath(filename: string): string {\n return filename\n .split('/')\n .map((s) => encodeURIComponent(s))\n .join('/');\n }\n\n private async fetchAPI<T>(url: string, options?: RequestInit): Promise<T> {\n const response = await this.fetch(url, {\n ...options,\n headers: {\n 'Content-Type': 'application/json',\n ...options?.headers,\n },\n });\n\n if (!response.ok) {\n let errorData: any;\n try {\n errorData = await response.json();\n } catch {\n // If JSON parsing fails, throw generic error\n throw new Error(`API error: ${response.status} ${response.statusText}`);\n }\n\n // Check if it's an APIError format\n if (errorData?.error?.code) {\n const apiError = errorData as APIError;\n\n // Special handling for stale writes\n if (apiError.error.code === ErrorCodes.STALE_WRITE) {\n throw new StaleWriteError({\n code: apiError.error.code,\n message: apiError.error.message,\n currentEtag: apiError.error.details?.currentEtag,\n });\n }\n\n // Create a proper error with code and details\n const error = new APIClientError(\n apiError.error.message,\n apiError.error.code as ErrorCode,\n apiError.error.details,\n );\n throw error;\n }\n\n // Fallback for non-standard error responses\n throw new Error(`API error: ${response.status} ${response.statusText}`);\n }\n\n return (await response.json()) as Promise<T>;\n }\n\n // Core content operations\n async getContent(id: string): Promise<ContentEntry | null> {\n try {\n const response = await this.fetch(`${this.baseUrl}/content/${id}`);\n if (response.status === 404) {\n return null;\n }\n if (!response.ok) {\n throw new Error(`Failed to fetch content: ${response.statusText}`);\n }\n return (await response.json()) as ContentEntry;\n } catch (error) {\n console.error('Error fetching content:', error);\n throw error;\n }\n }\n\n async getLocalized(id: string, locale: string): Promise<LocalizedEntry | null> {\n try {\n const response = await this.fetch(`${this.baseUrl}/content/${id}/${locale}`);\n if (response.status === 404) {\n return null;\n }\n if (!response.ok) {\n throw new Error(`Failed to fetch localized content: ${response.statusText}`);\n }\n return (await response.json()) as LocalizedEntry;\n } catch (error) {\n console.error('Error fetching localized content:', error);\n throw error;\n }\n }\n\n async createContent(data: CreateContentInput): Promise<CreateResult> {\n return this.fetchAPI<CreateResult>(`${this.baseUrl}/content`, {\n method: 'POST',\n body: JSON.stringify(data),\n });\n }\n\n async updateLocalized(input: UpdateLocaleInput): Promise<UpdateResult> {\n const { id, locale, data, etag } = input;\n const params = new URLSearchParams({ locale, etag });\n return this.fetchAPI<UpdateResult>(`${this.baseUrl}/content/${id}?${params}`, {\n method: 'PUT',\n body: JSON.stringify(data),\n });\n }\n\n async deleteContent(id: string, etag: string): Promise<DeleteResult> {\n return this.fetchAPI<DeleteResult>(`${this.baseUrl}/content/${id}`, {\n method: 'DELETE',\n headers: {\n 'If-Match': etag,\n },\n });\n }\n\n async deleteLocalized(input: { id: string; locale: string; etag: string }): Promise<DeleteResult> {\n return this.fetchAPI<DeleteResult>(`${this.baseUrl}/content/${input.id}?locale=${input.locale}`, {\n method: 'DELETE',\n headers: {\n 'If-Match': input.etag,\n },\n });\n }\n\n // Site operations\n async getSitePages(site: string, locale?: string): Promise<ContentListResult> {\n const url = locale ? `${this.baseUrl}/${site}/pages?locale=${locale}` : `${this.baseUrl}/${site}/pages`;\n return this.fetchAPI<ContentListResult>(url);\n }\n\n async getPageByPathname(site: string, pathname: string, locale?: string): Promise<ContentManifest | null> {\n try {\n const url = locale\n ? `${this.baseUrl}/sites/${site}/pathname${pathname}?locale=${locale}`\n : `${this.baseUrl}/sites/${site}/pathname${pathname}`;\n const response = await this.fetch(url);\n if (response.status === 404) {\n return null;\n }\n if (!response.ok) {\n throw new Error(`Failed to fetch page: ${response.statusText}`);\n }\n return (await response.json()) as ContentManifest;\n } catch (error) {\n console.error('Error fetching page by pathname:', error);\n throw error;\n }\n }\n\n async isPathnameAvailable(site: string, pathname: string, excludeId?: string): Promise<boolean> {\n const params = new URLSearchParams({\n pathname,\n ...(excludeId && { excludeId }),\n });\n\n const response = await this.fetch(`${this.baseUrl}/${site}/pathname-available?${params}`);\n if (!response.ok) {\n throw new Error(`Failed to check pathname availability: ${response.statusText}`);\n }\n\n const data = (await response.json()) as { available: boolean };\n return data.available;\n }\n\n async movePage(site: string, id: string, pathname: string, locale: string, etag: string): Promise<MoveResult> {\n return this.fetchAPI<MoveResult>(`${this.baseUrl}/${site}/move`, {\n method: 'POST',\n body: JSON.stringify({ id, pathname, locale, etag }),\n });\n }\n\n // Block operations\n async getBlocks(collection?: string, locale?: string): Promise<ContentListResult> {\n const params = new URLSearchParams();\n if (collection) params.set('collection', collection);\n if (locale) params.set('locale', locale);\n\n const url = `${this.baseUrl}/blocks${params.toString() ? `?${params}` : ''}`;\n return this.fetchAPI<ContentListResult>(url);\n }\n\n async getBlockByName(name: string, collection?: string, locale?: string): Promise<ContentManifest | null> {\n try {\n const params = new URLSearchParams();\n if (collection) params.set('collection', collection);\n if (locale) params.set('locale', locale);\n\n const url = `${this.baseUrl}/blocks/${name}${params.toString() ? `?${params}` : ''}`;\n const response = await this.fetch(url);\n if (response.status === 404) {\n return null;\n }\n if (!response.ok) {\n throw new Error(`Failed to fetch block: ${response.statusText}`);\n }\n return (await response.json()) as ContentManifest;\n } catch (error) {\n console.error('Error fetching block by name:', error);\n throw error;\n }\n }\n\n async compileMDX(mdxContent: string): Promise<MDXCompileResponse> {\n return this.fetchAPI<MDXCompileResponse>(`${this.baseUrl}/mdx/compile`, {\n method: 'POST',\n body: JSON.stringify({ mdxContent }),\n });\n }\n\n // Data operations\n async getData(collection?: string, locale?: string): Promise<ContentListResult> {\n const params = new URLSearchParams();\n if (collection) params.set('collection', collection);\n if (locale) params.set('locale', locale);\n\n const url = `${this.baseUrl}/data${params.toString() ? `?${params}` : ''}`;\n return this.fetchAPI<ContentListResult>(url);\n }\n\n async getDataByName(name: string, collection: string, locale?: string): Promise<ContentManifest | null> {\n try {\n const params = new URLSearchParams();\n params.set('collection', collection);\n if (locale) params.set('locale', locale);\n\n const url = `${this.baseUrl}/data/${name}?${params}`;\n const response = await this.fetch(url);\n if (response.status === 404) {\n return null;\n }\n if (!response.ok) {\n throw new Error(`Failed to fetch data entry: ${response.statusText}`);\n }\n return (await response.json()) as ContentManifest;\n } catch (error) {\n console.error('Error fetching data entry by name:', error);\n throw error;\n }\n }\n\n async isDataNameAvailable(name: string, collection: string, excludeId?: string): Promise<boolean> {\n const params = new URLSearchParams({\n name,\n collection,\n ...(excludeId && { excludeId }),\n });\n\n const response = await this.fetch(`${this.baseUrl}/data/name-available?${params}`);\n if (!response.ok) {\n throw new Error(`Failed to check data name availability: ${response.statusText}`);\n }\n\n const data = (await response.json()) as { available: boolean };\n return data.available;\n }\n\n async getDataCollections(): Promise<string[]> {\n const response = await this.fetchAPI<{ collections: string[] }>(`${this.baseUrl}/data/collections`);\n return response.collections;\n }\n\n // Data context operations\n async getDataContext(pageId: string): Promise<{ dataContext: DataContext }> {\n return this.fetchAPI<{ dataContext: DataContext }>(`${this.baseUrl}/data-context?pageId=${pageId}`);\n }\n\n // Global operations\n async listAllContent(filters?: GlobalFilters): Promise<ContentListResult> {\n const params = new URLSearchParams();\n if (filters?.site) params.set('site', filters.site);\n if (filters?.collection) params.set('collection', filters.collection);\n if (filters?.locales?.length) params.set('locales', filters.locales.join(','));\n if (filters?.type) params.set('type', filters.type);\n if (filters?.published !== undefined) params.set('published', String(filters.published));\n if (filters?.kind) params.set('kind', filters.kind);\n if (filters?.localization) params.set('localization', filters.localization);\n if (filters?.missingLocales?.length) params.set('missingLocales', filters.missingLocales.join(','));\n\n const url = `${this.baseUrl}/content${params.toString() ? `?${params}` : ''}`;\n return this.fetchAPI<ContentListResult>(url);\n }\n\n async findUntranslatedContent(\n targetLocale: string,\n excludeSites?: string[],\n includeUnpublished?: boolean,\n ): Promise<ContentListResult> {\n const params = new URLSearchParams();\n if (excludeSites?.length) params.set('excludeSites', excludeSites.join(','));\n if (includeUnpublished) params.set('includeUnpublished', 'true');\n\n const url = `${this.baseUrl}/untranslated/${targetLocale}${params.toString() ? `?${params}` : ''}`;\n return this.fetchAPI<ContentListResult>(url);\n }\n\n async getSitesConfig(): Promise<SitesConfig> {\n return this.fetchAPI<SitesConfig>(`${this.baseUrl}/sites`);\n }\n\n // Batch operations\n async batchUpdate(operations: UpdateLocaleInput[]): Promise<BatchResult> {\n return this.fetchAPI<BatchResult>(`${this.baseUrl}/content/batch`, {\n method: 'POST',\n body: JSON.stringify({ operations }),\n });\n }\n\n // Git operations\n async getGitStatus(): Promise<GitStatus> {\n return this.fetchAPI<GitStatus>(`${this.baseUrl}/git/status`);\n }\n\n async commitChanges(message?: string): Promise<GitCommitResult> {\n return this.fetchAPI<GitCommitResult>(`${this.baseUrl}/git/commit`, {\n method: 'POST',\n body: JSON.stringify(message ? { message } : {}),\n });\n }\n\n async pushChanges(): Promise<GitPushResult> {\n return this.fetchAPI<GitPushResult>(`${this.baseUrl}/git/push`, {\n method: 'POST',\n body: JSON.stringify({}),\n });\n }\n\n async pullChanges(): Promise<GitPullResult> {\n return this.fetchAPI<GitPullResult>(`${this.baseUrl}/git/pull`, {\n method: 'POST',\n body: JSON.stringify({}),\n });\n }\n\n // Asset operations\n async listAssets(): Promise<{ assets: AssetEntry[] }> {\n return this.fetchAPI<{ assets: AssetEntry[] }>(`${this.baseUrl}/assets`);\n }\n\n async getAsset(filename: string): Promise<AssetEntry | null> {\n try {\n const response = await this.fetch(`${this.baseUrl}/assets/meta/${this.encodeAssetPath(filename)}`);\n if (response.status === 404) {\n return null;\n }\n if (!response.ok) {\n throw new Error(`Failed to fetch asset: ${response.statusText}`);\n }\n return (await response.json()) as AssetEntry;\n } catch (error) {\n console.error('Error fetching asset:', error);\n throw error;\n }\n }\n\n async uploadAsset(formData: FormData): Promise<AssetEntry> {\n const response = await this.fetch(`${this.baseUrl}/assets/upload`, {\n method: 'POST',\n body: formData,\n // No Content-Type header — browser sets multipart boundary automatically\n });\n\n if (!response.ok) {\n let errorData: { error?: { message?: string } } | undefined;\n try {\n errorData = (await response.json()) as { error?: { message?: string } };\n } catch {\n // ignore\n }\n throw new Error(errorData?.error?.message || `Upload failed: ${response.status} ${response.statusText}`);\n }\n\n return (await response.json()) as AssetEntry;\n }\n\n async importAssetUrl(url: string, alt?: string, folder?: string): Promise<AssetEntry> {\n return this.fetchAPI<AssetEntry>(`${this.baseUrl}/assets/import-url`, {\n method: 'POST',\n body: JSON.stringify({ url, alt, folder }),\n });\n }\n\n async deleteAsset(filename: string): Promise<{ success: boolean }> {\n return this.fetchAPI<{ success: boolean }>(`${this.baseUrl}/assets/meta/${this.encodeAssetPath(filename)}`, {\n method: 'DELETE',\n });\n }\n\n // Folder operations\n async listFolder(path = '/'): Promise<FolderListing> {\n const params = new URLSearchParams({ path });\n return this.fetchAPI<FolderListing>(`${this.baseUrl}/assets/folders?${params}`);\n }\n\n async createFolder(path: string): Promise<void> {\n await this.fetch(`${this.baseUrl}/assets/folders`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ path }),\n });\n }\n\n // Asset metadata operations\n async updateAssetMetadata(filename: string, updates: { alt?: string; tags?: string[] }): Promise<AssetEntry> {\n return this.fetchAPI<AssetEntry>(`${this.baseUrl}/assets/meta/${this.encodeAssetPath(filename)}`, {\n method: 'PATCH',\n body: JSON.stringify(updates),\n });\n }\n\n // Asset usage tracking\n async getAssetUsage(filename: string): Promise<AssetUsage[]> {\n return this.fetchAPI<AssetUsage[]>(`${this.baseUrl}/assets/usage/${this.encodeAssetPath(filename)}`);\n }\n\n // Move assets between folders\n async moveAssets(\n filenames: string[],\n sourceFolder: string,\n targetFolder: string,\n ): Promise<{ success: boolean; moved?: number; error?: string }> {\n return this.fetchAPI<{ success: boolean; moved?: number; error?: string }>(`${this.baseUrl}/assets/move`, {\n method: 'POST',\n body: JSON.stringify({ filenames, sourceFolder, targetFolder }),\n });\n }\n\n // Get folder tree structure\n async getFolderTree(): Promise<{ tree: FolderTreeNode[] }> {\n return this.fetchAPI<{ tree: FolderTreeNode[] }>(`${this.baseUrl}/assets/folder-tree`);\n }\n\n // Auth operations\n async getCurrentUser(): Promise<{ authenticated: boolean; user?: { email: string; sub: string } }> {\n const response = await this.fetch(`${this.baseUrl}/auth/user`);\n if (!response.ok) {\n return { authenticated: false };\n }\n return response.json() as Promise<{ authenticated: boolean; user?: { email: string; sub: string } }>;\n }\n}\n\n// Custom error for API responses\nexport class APIClientError extends Error {\n constructor(\n message: string,\n public code: ErrorCode,\n public details?: any,\n ) {\n super(message);\n this.name = 'APIClientError';\n }\n}\n\n// Custom error for stale writes\nexport class StaleWriteError extends APIClientError {\n constructor(public data: { code: ErrorCode; message: string; currentEtag?: string }) {\n super(data.message, data.code, { currentEtag: data.currentEtag });\n this.name = 'StaleWriteError';\n }\n\n get currentEtag(): string | undefined {\n return this.details?.currentEtag;\n }\n}\n","import type {\n AssetEntry,\n AssetUsage,\n ContentEntry,\n ContentListResult,\n ContentManifest,\n CreateContentInput,\n DataContext,\n FolderListing,\n FolderTreeNode,\n GitCommitResult,\n GitPullResult,\n GitPushResult,\n GitStatus,\n GlobalFilters,\n LocalizedEntry,\n MDXCompileResponse,\n SitesConfig,\n UpdateLocaleInput,\n} from '@conloca/content-api';\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { APIClientError, ContentAPIClient, StaleWriteError } from './client';\n\n// Global client instance\nlet globalClient: ContentAPIClient | null = null;\n\nexport function getContentAPIClient(): ContentAPIClient {\n if (!globalClient) {\n globalClient = new ContentAPIClient();\n }\n return globalClient;\n}\n\nexport function setContentAPIClient(client: ContentAPIClient): void {\n globalClient = client;\n}\n\n// ===== Type Guards =====\nfunction isContentListResult(value: unknown): value is ContentListResult {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'items' in value &&\n 'total' in value &&\n Array.isArray((value as { items: unknown }).items) &&\n typeof (value as { total: unknown }).total === 'number'\n );\n}\n\nfunction hashString(value: string): string {\n let hash = 0;\n for (let index = 0; index < value.length; index++) {\n const char = value.charCodeAt(index);\n hash = (hash << 5) - hash + char;\n hash |= 0;\n }\n return hash.toString(36);\n}\n\n// ===== Query Keys =====\nconst queryKeys = {\n currentUser: () => ['auth', 'user'] as const,\n gitStatus: () => ['git', 'status'] as const,\n content: (id: string) => ['content', id] as const,\n localized: (id: string, locale: string) => ['content', id, locale] as const,\n sitePages: (site: string, locale?: string) => ['sites', site, 'pages', locale] as const,\n pageByPathname: (site: string, pathname: string, locale?: string) =>\n ['sites', site, 'pathname', pathname, locale] as const,\n pathnameAvailability: (site: string, pathname: string, excludeId?: string) =>\n ['sites', site, 'pathname-availability', pathname, excludeId] as const,\n blocks: (collection?: string, locale?: string) => ['blocks', collection, locale] as const,\n blockByName: (name: string, collection?: string, locale?: string) => ['blocks', name, collection, locale] as const,\n data: (collection?: string, locale?: string) => ['data', collection, locale] as const,\n dataByName: (name: string, collection: string, locale?: string) => ['data', name, collection, locale] as const,\n dataNameAvailability: (name: string, collection: string, excludeId?: string) =>\n ['data', 'name-availability', name, collection, excludeId] as const,\n dataCollections: () => ['data', 'collections'] as const,\n dataContext: (pageId?: string) => ['data-context', pageId] as const,\n allContent: (filters?: GlobalFilters) => ['content', 'all', filters] as const,\n untranslatedContent: (targetLocale: string, excludeSites?: string[], includeUnpublished?: boolean) =>\n ['content', 'untranslated', targetLocale, excludeSites, includeUnpublished] as const,\n sitesConfig: () => ['sites', 'config'] as const,\n assets: () => ['assets'] as const,\n asset: (filename: string) => ['assets', filename] as const,\n assetFolders: (path?: string) => ['asset-folders', path] as const,\n assetUsage: (filename: string | null) => ['asset-usage', filename] as const,\n folderTree: () => ['folder-tree'] as const,\n mdxCompile: (cacheKey: string) => ['mdx', 'compile', cacheKey] as const,\n};\n\n// ===== Core Content Hooks =====\n\nexport function useContent(id: string) {\n const client = getContentAPIClient();\n\n return useQuery<ContentEntry | null, Error>({\n queryKey: queryKeys.content(id),\n queryFn: () => client.getContent(id),\n enabled: !!id,\n });\n}\n\nexport function useLocalizedContent(id: string, locale: string) {\n const client = getContentAPIClient();\n\n return useQuery<LocalizedEntry | null, Error>({\n queryKey: queryKeys.localized(id, locale),\n queryFn: () => client.getLocalized(id, locale),\n enabled: !!id && !!locale,\n });\n}\n\nexport interface UseCompileMDXOptions {\n mdxContent: string | null;\n cacheKey?: string;\n}\n\nexport function useCompileMDX({ mdxContent, cacheKey }: UseCompileMDXOptions) {\n const client = getContentAPIClient();\n const resolvedCacheKey = cacheKey || (mdxContent ? `mdx-${hashString(mdxContent)}` : 'mdx-empty');\n\n return useQuery<MDXCompileResponse, Error>({\n queryKey: queryKeys.mdxCompile(resolvedCacheKey),\n queryFn: () => client.compileMDX(mdxContent!),\n enabled: !!mdxContent,\n retry: false,\n staleTime: Number.POSITIVE_INFINITY,\n });\n}\n\n// ===== Mutation Hooks =====\n\nexport function useCreateContent() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (data: CreateContentInput) => {\n const result = await client.createContent(data);\n if (result.success && result.id) {\n // Fetch the full content to get server-generated data\n const fullContent = await client.getContent(result.id);\n return { ...result, fullContent };\n }\n return result;\n },\n onSuccess: (result, variables) => {\n if (result.success && result.id && 'fullContent' in result && result.fullContent) {\n // Cache the server's response\n queryClient.setQueryData(queryKeys.content(result.id), result.fullContent);\n\n // Update list queries by adding the new item from server data\n const newManifest: ContentManifest = {\n id: result.fullContent.id,\n type: result.fullContent.type,\n kind: result.fullContent.kind,\n site: result.fullContent.site,\n collection: result.fullContent.collection,\n locales: Object.entries(result.fullContent.locales).reduce(\n (acc, [locale, localeData]) => {\n const { content, ...manifestData } = localeData;\n acc[locale] = manifestData;\n return acc;\n },\n {} as ContentManifest['locales'],\n ),\n };\n\n if (variables.kind === 'page' && variables.site) {\n queryClient.setQueriesData(\n { queryKey: queryKeys.sitePages(variables.site) },\n (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n return {\n ...old,\n items: [...old.items, newManifest],\n total: old.total + 1,\n };\n },\n );\n } else if (variables.kind === 'block') {\n // Invalidate all block queries to ensure the new block appears everywhere\n queryClient.invalidateQueries({ queryKey: ['blocks'] });\n } else if (variables.kind === 'data') {\n // Invalidate all data queries to ensure the new data entry appears everywhere\n queryClient.invalidateQueries({ queryKey: ['data'] });\n }\n }\n },\n });\n}\n\nexport function useUpdateLocalized() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (input: UpdateLocaleInput) => {\n const result = await client.updateLocalized(input);\n if (result.success) {\n // Fetch the updated localized content to get server-processed data\n const updatedContent = await client.getLocalized(input.id, input.locale);\n return { ...result, updatedContent };\n }\n return result;\n },\n onSuccess: (result, variables) => {\n if (result.success && 'updatedContent' in result && result.updatedContent) {\n // Update the localized content query with server data\n queryClient.setQueryData(queryKeys.localized(variables.id, variables.locale), result.updatedContent);\n\n // Update the full content entry\n queryClient.setQueryData(queryKeys.content(variables.id), (old: ContentEntry | null | undefined) => {\n if (!old) return old;\n return {\n ...old,\n locales: {\n ...old.locales,\n [variables.locale]: result.updatedContent!.localized,\n },\n };\n });\n\n // Update list queries to reflect the server data\n const updateListQueries = (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n return {\n ...old,\n items: old.items.map((item) =>\n item.id === variables.id\n ? {\n ...item,\n locales: {\n ...item.locales,\n [variables.locale]: {\n locale: result.updatedContent!.localized.locale,\n etag: result.updatedContent!.localized.etag,\n created: result.updatedContent!.localized.created,\n modified: result.updatedContent!.localized.modified,\n pathname: result.updatedContent!.localized.pathname,\n previousPathnames: result.updatedContent!.localized.previousPathnames,\n name: result.updatedContent!.localized.name,\n publishAt: result.updatedContent!.localized.publishAt,\n unpublishAt: result.updatedContent!.localized.unpublishAt,\n meta: result.updatedContent!.localized.meta,\n },\n },\n }\n : item,\n ),\n };\n };\n\n queryClient.setQueriesData({ queryKey: ['sites'], exact: false }, updateListQueries);\n\n queryClient.setQueriesData({ queryKey: ['blocks'], exact: false }, updateListQueries);\n\n queryClient.setQueriesData({ queryKey: ['data'], exact: false }, updateListQueries);\n }\n },\n });\n}\n\ninterface DeleteContentArgs {\n id: string;\n etag: string;\n locale?: string;\n}\n\nexport function useDeleteContent() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ id, etag, locale }: DeleteContentArgs) => {\n // If locale is provided, it's a locale-specific delete\n if (locale) {\n return client.deleteLocalized({ id, locale, etag });\n }\n // Otherwise, delete entire content\n return client.deleteContent(id, etag);\n },\n onSuccess: (result, variables) => {\n if (result.success) {\n if (variables.locale) {\n // For locale-specific deletion, update the content entry to remove the locale\n queryClient.setQueryData(queryKeys.content(variables.id), (old: ContentEntry | null | undefined) => {\n if (!old) return old;\n const locale = variables.locale!;\n const { [locale]: _, ...remainingLocales } = old.locales;\n return {\n ...old,\n locales: remainingLocales,\n };\n });\n\n // Update list queries to remove the locale from the item\n const updateListQueries = (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n const locale = variables.locale!;\n return {\n ...old,\n items: old.items\n .map((item) => {\n if (item.id === variables.id) {\n const { [locale]: _, ...remainingLocales } = item.locales;\n return {\n ...item,\n locales: remainingLocales,\n };\n }\n return item;\n })\n .filter((item) => Object.keys(item.locales).length > 0), // Remove items with no locales\n };\n };\n\n queryClient.setQueriesData({ queryKey: ['sites'], exact: false }, updateListQueries);\n queryClient.setQueriesData({ queryKey: ['blocks'], exact: false }, updateListQueries);\n queryClient.setQueriesData({ queryKey: ['data'], exact: false }, updateListQueries);\n queryClient.setQueriesData({ queryKey: ['content', 'all'], exact: false }, updateListQueries);\n } else {\n // For full deletion, remove from cache\n queryClient.removeQueries({ queryKey: queryKeys.content(variables.id) });\n queryClient.removeQueries({ queryKey: ['content', variables.id], exact: false });\n\n // Update list queries by removing the deleted item\n queryClient.setQueriesData({ queryKey: ['sites'], exact: false }, (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n const newItems = old.items.filter((item) => item.id !== variables.id);\n return {\n ...old,\n items: newItems,\n total: newItems.length < old.items.length ? old.total - 1 : old.total,\n };\n });\n\n // Update block lists\n queryClient.setQueriesData({ queryKey: ['blocks'], exact: false }, (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n const newItems = old.items.filter((item) => item.id !== variables.id);\n return {\n ...old,\n items: newItems,\n total: newItems.length < old.items.length ? old.total - 1 : old.total,\n };\n });\n\n // Update data lists\n queryClient.setQueriesData({ queryKey: ['data'], exact: false }, (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n const newItems = old.items.filter((item) => item.id !== variables.id);\n return {\n ...old,\n items: newItems,\n total: newItems.length < old.items.length ? old.total - 1 : old.total,\n };\n });\n\n // Update all content queries\n queryClient.setQueriesData(\n { queryKey: ['content', 'all'], exact: false },\n (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n const newItems = old.items.filter((item) => item.id !== variables.id);\n return {\n ...old,\n items: newItems,\n total: newItems.length < old.items.length ? old.total - 1 : old.total,\n };\n },\n );\n }\n }\n },\n });\n}\n\ninterface DeleteLocalizedArgs {\n id: string;\n locale: string;\n etag: string;\n}\n\nexport function useDeleteLocalized() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: ({ id, locale, etag }: DeleteLocalizedArgs) => client.deleteLocalized({ id, locale, etag }),\n onSuccess: (result, variables) => {\n if (result.success) {\n // Invalidate specific locale query\n queryClient.invalidateQueries({\n queryKey: queryKeys.localized(variables.id, variables.locale),\n });\n // Invalidate the full content query\n queryClient.invalidateQueries({ queryKey: queryKeys.content(variables.id) });\n }\n },\n });\n}\n\n// ===== Site Hooks =====\n\nexport function useSitePages(site: string, locale?: string) {\n const client = getContentAPIClient();\n\n return useQuery<ContentListResult, Error>({\n queryKey: queryKeys.sitePages(site, locale),\n queryFn: () => client.getSitePages(site, locale),\n });\n}\n\nexport function usePageByPathname(site: string, pathname: string, locale?: string) {\n const client = getContentAPIClient();\n\n return useQuery<ContentManifest | null, Error>({\n queryKey: queryKeys.pageByPathname(site, pathname, locale),\n queryFn: () => client.getPageByPathname(site, pathname, locale),\n enabled: !!pathname,\n });\n}\n\nexport function usePathnameAvailability(site: string, pathname: string, excludeId?: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.pathnameAvailability(site, pathname, excludeId),\n queryFn: async () => {\n const available = await client.isPathnameAvailable(site, pathname, excludeId);\n return { available };\n },\n enabled: !!site && !!pathname,\n // For pathname validation, we want immediate feedback\n staleTime: 0,\n gcTime: 0,\n });\n}\n\ninterface MovePageArgs {\n site: string;\n id: string;\n pathname: string;\n locale?: string;\n etag: string;\n}\n\nexport function useMovePage() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: ({ site, id, pathname, locale = 'en', etag }: MovePageArgs) =>\n client.movePage(site, id, pathname, locale, etag),\n onSuccess: (result, variables) => {\n if (result.moved) {\n // Invalidate site pages and content queries\n queryClient.invalidateQueries({ queryKey: ['sites', variables.site] });\n queryClient.invalidateQueries({ queryKey: queryKeys.content(variables.id) });\n }\n },\n });\n}\n\n// ===== Block Hooks =====\n\nexport function useBlocks(collection?: string, locale?: string) {\n const client = getContentAPIClient();\n\n return useQuery<ContentListResult, Error>({\n queryKey: queryKeys.blocks(collection, locale),\n queryFn: () => client.getBlocks(collection, locale),\n });\n}\n\nexport function useBlockByName(name: string, collection?: string, locale?: string) {\n const client = getContentAPIClient();\n\n return useQuery<ContentManifest | null, Error>({\n queryKey: queryKeys.blockByName(name, collection, locale),\n queryFn: () => client.getBlockByName(name, collection, locale),\n enabled: !!name,\n });\n}\n\n// ===== Data Hooks =====\n\nexport function useData(collection?: string, locale?: string) {\n const client = getContentAPIClient();\n\n return useQuery<ContentListResult, Error>({\n queryKey: queryKeys.data(collection, locale),\n queryFn: () => client.getData(collection, locale),\n });\n}\n\nexport function useDataByName(name: string, collection: string, locale?: string) {\n const client = getContentAPIClient();\n\n return useQuery<ContentManifest | null, Error>({\n queryKey: queryKeys.dataByName(name, collection, locale),\n queryFn: () => client.getDataByName(name, collection, locale),\n enabled: !!name && !!collection,\n });\n}\n\nexport function useDataNameAvailability(name: string, collection: string, excludeId?: string) {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.dataNameAvailability(name, collection, excludeId),\n queryFn: async () => {\n const available = await client.isDataNameAvailable(name, collection, excludeId);\n return { available };\n },\n enabled: !!name && !!collection,\n staleTime: 0,\n gcTime: 0,\n });\n}\n\nexport function useDataCollections() {\n const client = getContentAPIClient();\n\n return useQuery<string[], Error>({\n queryKey: queryKeys.dataCollections(),\n queryFn: () => client.getDataCollections(),\n });\n}\n\n// ===== Data Context Hooks =====\n\nexport function useDataContext(pageId?: string) {\n const client = getContentAPIClient();\n\n return useQuery<{ dataContext: DataContext }, Error>({\n queryKey: queryKeys.dataContext(pageId),\n queryFn: () => client.getDataContext(pageId!),\n enabled: !!pageId,\n });\n}\n\n// ===== Global Hooks =====\n\nexport function useAllContent(filters?: GlobalFilters) {\n const client = getContentAPIClient();\n\n return useQuery<ContentListResult, Error>({\n queryKey: queryKeys.allContent(filters),\n queryFn: () => client.listAllContent(filters),\n });\n}\n\nexport function useUntranslatedContent(targetLocale: string, excludeSites?: string[], includeUnpublished?: boolean) {\n const client = getContentAPIClient();\n\n return useQuery<ContentListResult, Error>({\n queryKey: queryKeys.untranslatedContent(targetLocale, excludeSites, includeUnpublished),\n queryFn: () => client.findUntranslatedContent(targetLocale, excludeSites, includeUnpublished),\n });\n}\n\nexport function useSitesConfig() {\n const client = getContentAPIClient();\n\n return useQuery<SitesConfig, Error>({\n queryKey: queryKeys.sitesConfig(),\n queryFn: () => client.getSitesConfig(),\n });\n}\n\n// ===== Auth Hooks =====\n\nexport function useCurrentUser() {\n const client = getContentAPIClient();\n\n return useQuery({\n queryKey: queryKeys.currentUser(),\n queryFn: () => client.getCurrentUser(),\n staleTime: 60000, // Cache for 1 minute (user doesn't change often)\n });\n}\n\n// ===== Batch Operations =====\n\nexport function useBatchUpdate() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (operations: UpdateLocaleInput[]) => {\n const result = await client.batchUpdate(operations);\n\n // Fetch updated content for successful operations\n if (result.operations && result.updated > 0) {\n const updatedContents = await Promise.all(\n result.operations.map(async (opResult, index) => {\n if (opResult.updated) {\n const op = operations[index];\n const updated = await client.getLocalized(op.id, op.locale);\n return { index, content: updated };\n }\n return null;\n }),\n );\n\n return {\n ...result,\n updatedContents: updatedContents.filter(\n (item): item is { index: number; content: LocalizedEntry } => item !== null,\n ),\n };\n }\n\n return result;\n },\n onSuccess: (result, variables) => {\n if ('updatedContents' in result && result.updatedContents) {\n // Update caches with the fetched server data\n result.updatedContents.forEach(({ index, content }) => {\n if (!content) return;\n\n const operation = variables[index!];\n\n // Update localized content\n queryClient.setQueryData(queryKeys.localized(operation.id, operation.locale), content);\n\n // Update full content entry\n queryClient.setQueryData(queryKeys.content(operation.id), (old: ContentEntry | null | undefined) => {\n if (!old) return old;\n return {\n ...old,\n locales: {\n ...old.locales,\n [operation.locale]: content.localized,\n },\n };\n });\n });\n\n // Update list queries with server data\n const updatedMap = new Map(\n result.updatedContents.map(({ index, content }) => {\n const op = variables[index!];\n return [op.id + ':' + op.locale, content];\n }),\n );\n\n const updateListQueries = (old: ContentListResult | undefined) => {\n if (!isContentListResult(old)) return old;\n return {\n ...old,\n items: old.items.map((item) => {\n const hasUpdate = Object.keys(item.locales).some((locale) => updatedMap.has(item.id + ':' + locale));\n\n if (hasUpdate) {\n const newLocales = { ...item.locales };\n Object.keys(newLocales).forEach((locale) => {\n const updated = updatedMap.get(item.id + ':' + locale);\n if (updated) {\n const { content, ...manifestData } = updated.localized;\n newLocales[locale] = manifestData;\n }\n });\n return { ...item, locales: newLocales };\n }\n\n return item;\n }),\n };\n };\n\n queryClient.setQueriesData({ queryKey: ['sites'], exact: false }, updateListQueries);\n\n queryClient.setQueriesData({ queryKey: ['blocks'], exact: false }, updateListQueries);\n\n queryClient.setQueriesData({ queryKey: ['data'], exact: false }, updateListQueries);\n }\n },\n });\n}\n\n// ===== Git Hooks =====\n\nexport function useGitStatus() {\n const client = getContentAPIClient();\n\n return useQuery<GitStatus, Error>({\n queryKey: queryKeys.gitStatus(),\n queryFn: () => client.getGitStatus(),\n refetchInterval: 10000,\n staleTime: 5000,\n });\n}\n\nexport function useCommitChanges() {\n const queryClient = useQueryClient();\n const client = getContentAPIClient();\n\n return useMutation({\n mutationFn: (message: string | undefined) => client.commitChanges(message),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.gitStatus() });\n },\n });\n}\n\nexport function usePushChanges() {\n const queryClient = useQueryClient();\n const client = getContentAPIClient();\n\n return useMutation({\n mutationFn: () => client.pushChanges(),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.gitStatus() });\n },\n });\n}\n\nexport function usePullChanges() {\n const queryClient = useQueryClient();\n const client = getContentAPIClient();\n\n return useMutation({\n mutationFn: () => client.pullChanges(),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.gitStatus() });\n },\n });\n}\n\n// ===== Asset Hooks =====\n\nexport function useAssets() {\n const client = getContentAPIClient();\n\n return useQuery<{ assets: AssetEntry[] }, Error>({\n queryKey: queryKeys.assets(),\n queryFn: () => client.listAssets(),\n });\n}\n\nexport function useAsset(filename: string) {\n const client = getContentAPIClient();\n\n return useQuery<AssetEntry | null, Error>({\n queryKey: queryKeys.asset(filename),\n queryFn: () => client.getAsset(filename),\n enabled: !!filename,\n });\n}\n\nexport function useUploadAsset() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (formData: FormData) => client.uploadAsset(formData),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.assets() });\n queryClient.invalidateQueries({ queryKey: ['asset-folders'] });\n },\n });\n}\n\nexport function useImportAssetUrl() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: ({ url, alt, folder }: { url: string; alt?: string; folder?: string }) =>\n client.importAssetUrl(url, alt, folder),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.assets() });\n queryClient.invalidateQueries({ queryKey: ['asset-folders'] });\n },\n });\n}\n\nexport function useDeleteAsset() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (filename: string) => client.deleteAsset(filename),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.assets() });\n queryClient.invalidateQueries({ queryKey: ['asset-folders'] });\n },\n });\n}\n\nexport function useBulkDeleteAssets() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (filenames: string[]) => {\n let successCount = 0;\n let failCount = 0;\n for (const filename of filenames) {\n try {\n await client.deleteAsset(filename);\n successCount++;\n } catch {\n failCount++;\n }\n }\n return { successCount, failCount };\n },\n onSettled: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.assets() });\n queryClient.invalidateQueries({ queryKey: ['asset-folders'] });\n },\n });\n}\n\n// ===== Media Library Hooks =====\n\nexport function useAssetFolders(path?: string) {\n const client = getContentAPIClient();\n\n return useQuery<FolderListing, Error>({\n queryKey: queryKeys.assetFolders(path),\n queryFn: () => client.listFolder(path),\n });\n}\n\nexport function useCreateFolder() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (path: string) => client.createFolder(path),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ['asset-folders'] });\n },\n });\n}\n\nexport function useUpdateAssetMetadata() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: ({ filename, updates }: { filename: string; updates: { alt?: string; tags?: string[] } }) =>\n client.updateAssetMetadata(filename, updates),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: queryKeys.assets() });\n queryClient.invalidateQueries({ queryKey: ['asset-folders'] });\n },\n });\n}\n\nexport function useAssetUsage(filename: string | null) {\n const client = getContentAPIClient();\n\n return useQuery<AssetUsage[], Error>({\n queryKey: queryKeys.assetUsage(filename),\n queryFn: () => client.getAssetUsage(filename!),\n enabled: !!filename,\n staleTime: 60_000, // Cache usage for 1 minute to avoid repeated VXJSON scans\n });\n}\n\nexport function useFolderTree() {\n const client = getContentAPIClient();\n\n return useQuery<{ tree: FolderTreeNode[] }, Error>({\n queryKey: queryKeys.folderTree(),\n queryFn: () => client.getFolderTree(),\n staleTime: 30_000, // Cache for 30 seconds\n });\n}\n\nexport function useMoveAssets() {\n const client = getContentAPIClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: ({\n filenames,\n sourceFolder,\n targetFolder,\n }: {\n filenames: string[];\n sourceFolder: string;\n targetFolder: string;\n }) => client.moveAssets(filenames, sourceFolder, targetFolder),\n onSuccess: () => {\n // Invalidate all folder-related queries to refresh counts and listings\n queryClient.invalidateQueries({ queryKey: queryKeys.assets() });\n queryClient.invalidateQueries({ queryKey: ['asset-folders'] });\n queryClient.invalidateQueries({ queryKey: queryKeys.folderTree() });\n },\n });\n}\n\nexport type { GitCommitResult, GitPullResult, GitPushResult, GitStatus };\n// Re-export for convenience\nexport { APIClientError, ContentAPIClient, StaleWriteError };\n"],"mappings":";;;;;AAkCA,IAAa,mBAAb,MAA8B;CAC5B,AAAQ;CACR,AAAQ;CAER,YAAY,UAAmC,EAAE,EAAE;AAEjD,MAAI,QAAQ,MACV,MAAK,QAAQ,QAAQ;WACZ,OAAO,eAAe,eAAe,WAAW,MAEzD,MAAK,QAAQ,WAAW,MAAM,KAAK,WAAW;MAE9C,MAAK,QAAQ;AAEf,OAAK,UAAU,QAAQ,WAAW;;CAGpC,AAAQ,gBAAgB,UAA0B;AAChD,SAAO,SACJ,MAAM,IAAI,CACV,KAAK,MAAM,mBAAmB,EAAE,CAAC,CACjC,KAAK,IAAI;;CAGd,MAAc,SAAY,KAAa,SAAmC;EACxE,MAAM,WAAW,MAAM,KAAK,MAAM,KAAK;GACrC,GAAG;GACH,SAAS;IACP,gBAAgB;IAChB,GAAG,SAAS;IACb;GACF,CAAC;AAEF,MAAI,CAAC,SAAS,IAAI;GAChB,IAAI;AACJ,OAAI;AACF,gBAAY,MAAM,SAAS,MAAM;WAC3B;AAEN,UAAM,IAAI,MAAM,cAAc,SAAS,OAAO,GAAG,SAAS,aAAa;;AAIzE,OAAI,WAAW,OAAO,MAAM;IAC1B,MAAM,WAAW;AAGjB,QAAI,SAAS,MAAM,SAASA,aAAW,YACrC,OAAM,IAAI,gBAAgB;KACxB,MAAM,SAAS,MAAM;KACrB,SAAS,SAAS,MAAM;KACxB,aAAa,SAAS,MAAM,SAAS;KACtC,CAAC;AASJ,UALc,IAAI,eAChB,SAAS,MAAM,SACf,SAAS,MAAM,MACf,SAAS,MAAM,QAChB;;AAKH,SAAM,IAAI,MAAM,cAAc,SAAS,OAAO,GAAG,SAAS,aAAa;;AAGzE,SAAQ,MAAM,SAAS,MAAM;;CAI/B,MAAM,WAAW,IAA0C;AACzD,MAAI;GACF,MAA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X,WAAW;EACZ,CAAC;;AAGJ,SAAgB,gBAAgB;CAC9B,MAAM,SAAS,qBAAqB;AAEpC,QAAO,SAA4C;EACjD,UAAU,UAAU,YAAY;EAChC,eAAe,OAAO,eAAe;EACrC,WAAW;EACZ,CAAC;;AAGJ,SAAgB,gBAAgB;CAC9B,MAAM,SAAS,qBAAqB;CACpC,MAAM,cAAc,gBAAgB;AAEpC,QAAO,YAAY;EACjB,aAAa,EACX,WACA,cACA,mBAKI,OAAO,WAAW,WAAW,cAAc,aAAa;EAC9D,iBAAiB;AAEf,eAAY,kBAAkB,EAAE,UAAU,UAAU,QAAQ,EAAE,CAAC;AAC/D,eAAY,kBAAkB,EAAE,UAAU,CAAC,gBAAgB,EAAE,CAAC;AAC9D,eAAY,kBAAkB,EAAE,UAAU,UAAU,YAAY,EAAE,CAAC;;EAEtE,CAAC"}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { BatchResult, ContentEntry, ContentManifest, CreateResult, DeleteResult, LocalizedEntry, UpdateResult } from "@conloca/content-api";
|
|
2
|
-
|
|
3
|
-
//#region src/test-helpers.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Test helpers for mocking Content API Client
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* API route patterns used by the content API
|
|
9
|
-
* These match the routes defined in content-api/src/middleware.ts
|
|
10
|
-
*/
|
|
11
|
-
declare const API_ROUTES: {
|
|
12
|
-
readonly SITES: "/sites";
|
|
13
|
-
readonly ALL_CONTENT: "/content";
|
|
14
|
-
readonly CONTENT_BY_ID: (id: string) => string;
|
|
15
|
-
readonly LOCALIZED_CONTENT: (id: string, locale: string) => string;
|
|
16
|
-
readonly SITE_PAGES: (site: string) => string;
|
|
17
|
-
readonly BLOCKS: "/blocks";
|
|
18
|
-
readonly COLLECTIONS: "/content/collections";
|
|
19
|
-
readonly BATCH_UPDATE: "/content/batch";
|
|
20
|
-
readonly FIND_UNTRANSLATED: (locale: string) => string;
|
|
21
|
-
readonly DATA_CONTEXT: "/data-context";
|
|
22
|
-
};
|
|
23
|
-
interface MockResponse {
|
|
24
|
-
status?: number;
|
|
25
|
-
headers?: Record<string, string>;
|
|
26
|
-
body?: any;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Creates a mock fetch function for testing
|
|
30
|
-
* Note: This requires a mock function from your test framework (e.g., bun:test, jest, vitest)
|
|
31
|
-
*/
|
|
32
|
-
declare function createMockFetch(mockFn: (impl?: any) => any): any;
|
|
33
|
-
/**
|
|
34
|
-
* Creates a Response object with JSON body
|
|
35
|
-
*/
|
|
36
|
-
declare function jsonResponse(body: any, options?: {
|
|
37
|
-
status?: number;
|
|
38
|
-
headers?: Record<string, string>;
|
|
39
|
-
}): Response;
|
|
40
|
-
/**
|
|
41
|
-
* Creates a mock ContentEntry
|
|
42
|
-
*/
|
|
43
|
-
declare function mockContentEntry(overrides?: Partial<ContentEntry>): ContentEntry;
|
|
44
|
-
/**
|
|
45
|
-
* Creates a mock ContentManifest
|
|
46
|
-
*/
|
|
47
|
-
declare function mockContentManifest(overrides?: Partial<ContentManifest>): ContentManifest;
|
|
48
|
-
/**
|
|
49
|
-
* Creates a mock LocalizedEntry
|
|
50
|
-
*/
|
|
51
|
-
declare function mockLocalizedEntry(overrides?: Partial<LocalizedEntry>): LocalizedEntry;
|
|
52
|
-
/**
|
|
53
|
-
* Creates a mock CreateResult
|
|
54
|
-
*/
|
|
55
|
-
declare function mockCreateResult(overrides?: Partial<CreateResult>): CreateResult;
|
|
56
|
-
/**
|
|
57
|
-
* Creates a mock UpdateResult
|
|
58
|
-
*/
|
|
59
|
-
declare function mockUpdateResult(overrides?: Partial<UpdateResult>): UpdateResult;
|
|
60
|
-
/**
|
|
61
|
-
* Creates a mock DeleteResult
|
|
62
|
-
*/
|
|
63
|
-
declare function mockDeleteResult(overrides?: Partial<DeleteResult>): DeleteResult;
|
|
64
|
-
/**
|
|
65
|
-
* Creates a mock BatchResult
|
|
66
|
-
*/
|
|
67
|
-
declare function mockBatchResult(overrides?: Partial<BatchResult>): BatchResult;
|
|
68
|
-
/**
|
|
69
|
-
* Mock helper for setting up common API responses
|
|
70
|
-
*/
|
|
71
|
-
declare class MockAPIResponses {
|
|
72
|
-
private fetchMock;
|
|
73
|
-
constructor(fetchMock: any);
|
|
74
|
-
mockGetContent(content: ContentEntry | null, status?: number): this;
|
|
75
|
-
mockGetLocalized(entry: LocalizedEntry | null, status?: number): this;
|
|
76
|
-
mockListContent(items: ContentManifest[], status?: number): this;
|
|
77
|
-
mockCreateContent(result: CreateResult, status?: number): this;
|
|
78
|
-
mockUpdateContent(result: UpdateResult, status?: number): this;
|
|
79
|
-
mockDeleteContent(result: DeleteResult, status?: number): this;
|
|
80
|
-
mockStaleWrite(currentEtag: string): this;
|
|
81
|
-
mockError(message: string, status?: number): this;
|
|
82
|
-
mockNetworkError(): this;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Setup fetch mock with helper
|
|
86
|
-
* @param mockFn - Mock function from your test framework (e.g., mock from bun:test)
|
|
87
|
-
*/
|
|
88
|
-
declare function setupFetchMock(mockFn: (impl?: any) => any): {
|
|
89
|
-
fetchMock: any;
|
|
90
|
-
responses: MockAPIResponses;
|
|
91
|
-
};
|
|
92
|
-
//#endregion
|
|
93
|
-
export { jsonResponse as a, mockContentManifest as c, mockLocalizedEntry as d, mockUpdateResult as f, createMockFetch as i, mockCreateResult as l, MockAPIResponses as n, mockBatchResult as o, setupFetchMock as p, MockResponse as r, mockContentEntry as s, API_ROUTES as t, mockDeleteResult as u };
|
|
94
|
-
//# sourceMappingURL=test-helpers-BJxZXOMi.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-helpers-BJxZXOMi.d.mts","names":[],"sources":["../src/test-helpers.ts"],"mappings":";;;;;AAkBA;;;;;cAAa,UAAA;EAAA;;;2CAImB,MAAA;EAAA;;;;;;;UASf,YAAA;EACf,MAAA;EACA,OAAA,GAAU,MAAA;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-
//#region src/test-helpers.ts
|
|
2
|
-
/**
|
|
3
|
-
* Test helpers for mocking Content API Client
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* API route patterns used by the content API
|
|
7
|
-
* These match the routes defined in content-api/src/middleware.ts
|
|
8
|
-
*/
|
|
9
|
-
const API_ROUTES = {
|
|
10
|
-
SITES: "/sites",
|
|
11
|
-
ALL_CONTENT: "/content",
|
|
12
|
-
CONTENT_BY_ID: (id) => `/content/${id}`,
|
|
13
|
-
LOCALIZED_CONTENT: (id, locale) => `/content/${id}/${locale}`,
|
|
14
|
-
SITE_PAGES: (site) => `/${site}/pages`,
|
|
15
|
-
BLOCKS: "/blocks",
|
|
16
|
-
COLLECTIONS: "/content/collections",
|
|
17
|
-
BATCH_UPDATE: "/content/batch",
|
|
18
|
-
FIND_UNTRANSLATED: (locale) => `/untranslated/${locale}`,
|
|
19
|
-
DATA_CONTEXT: "/data-context"
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Creates a mock fetch function for testing
|
|
23
|
-
* Note: This requires a mock function from your test framework (e.g., bun:test, jest, vitest)
|
|
24
|
-
*/
|
|
25
|
-
function createMockFetch(mockFn) {
|
|
26
|
-
return mockFn(() => Promise.resolve(new Response()));
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Creates a Response object with JSON body
|
|
30
|
-
*/
|
|
31
|
-
function jsonResponse(body, options = {}) {
|
|
32
|
-
return new Response(JSON.stringify(body), {
|
|
33
|
-
status: options.status || 200,
|
|
34
|
-
headers: {
|
|
35
|
-
"Content-Type": "application/json",
|
|
36
|
-
...options.headers
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Creates a mock ContentEntry
|
|
42
|
-
*/
|
|
43
|
-
function mockContentEntry(overrides) {
|
|
44
|
-
return {
|
|
45
|
-
id: "test-id",
|
|
46
|
-
site: "test-site",
|
|
47
|
-
collection: "pages",
|
|
48
|
-
type: "puck",
|
|
49
|
-
kind: "page",
|
|
50
|
-
locales: { en: {
|
|
51
|
-
locale: "en",
|
|
52
|
-
etag: "metaHash.contentHash",
|
|
53
|
-
created: "2024-01-01T00:00:00Z",
|
|
54
|
-
modified: "2024-01-01T00:00:00Z",
|
|
55
|
-
pathname: "/test",
|
|
56
|
-
meta: { title: "Test Page" },
|
|
57
|
-
content: { puckData: {} }
|
|
58
|
-
} },
|
|
59
|
-
...overrides
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Creates a mock ContentManifest
|
|
64
|
-
*/
|
|
65
|
-
function mockContentManifest(overrides) {
|
|
66
|
-
return {
|
|
67
|
-
id: "test-id",
|
|
68
|
-
site: "test-site",
|
|
69
|
-
collection: "pages",
|
|
70
|
-
type: "puck",
|
|
71
|
-
kind: "page",
|
|
72
|
-
locales: { en: {
|
|
73
|
-
locale: "en",
|
|
74
|
-
etag: "metaHash.contentHash",
|
|
75
|
-
created: "2024-01-01T00:00:00Z",
|
|
76
|
-
modified: "2024-01-01T00:00:00Z",
|
|
77
|
-
pathname: "/test",
|
|
78
|
-
meta: { title: "Test Page" }
|
|
79
|
-
} },
|
|
80
|
-
...overrides
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Creates a mock LocalizedEntry
|
|
85
|
-
*/
|
|
86
|
-
function mockLocalizedEntry(overrides) {
|
|
87
|
-
return {
|
|
88
|
-
id: "test-id",
|
|
89
|
-
site: "test-site",
|
|
90
|
-
collection: "pages",
|
|
91
|
-
type: "puck",
|
|
92
|
-
kind: "page",
|
|
93
|
-
localized: {
|
|
94
|
-
locale: "en",
|
|
95
|
-
etag: "metaHash.contentHash",
|
|
96
|
-
created: "2024-01-01T00:00:00Z",
|
|
97
|
-
modified: "2024-01-01T00:00:00Z",
|
|
98
|
-
pathname: "/test",
|
|
99
|
-
meta: { title: "Test Page" },
|
|
100
|
-
content: { puckData: {} }
|
|
101
|
-
},
|
|
102
|
-
...overrides
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Creates a mock CreateResult
|
|
107
|
-
*/
|
|
108
|
-
function mockCreateResult(overrides) {
|
|
109
|
-
return {
|
|
110
|
-
success: true,
|
|
111
|
-
id: "new-id",
|
|
112
|
-
etag: "newMetaHash.newContentHash",
|
|
113
|
-
created: /* @__PURE__ */ new Date("2024-01-01T00:00:00.000Z"),
|
|
114
|
-
...overrides
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Creates a mock UpdateResult
|
|
119
|
-
*/
|
|
120
|
-
function mockUpdateResult(overrides) {
|
|
121
|
-
return {
|
|
122
|
-
success: true,
|
|
123
|
-
etag: "updatedMetaHash.updatedContentHash",
|
|
124
|
-
modified: /* @__PURE__ */ new Date("2024-01-01T00:00:00.000Z"),
|
|
125
|
-
...overrides
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Creates a mock DeleteResult
|
|
130
|
-
*/
|
|
131
|
-
function mockDeleteResult(overrides) {
|
|
132
|
-
return {
|
|
133
|
-
success: true,
|
|
134
|
-
...overrides
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Creates a mock BatchResult
|
|
139
|
-
*/
|
|
140
|
-
function mockBatchResult(overrides) {
|
|
141
|
-
return {
|
|
142
|
-
operations: [],
|
|
143
|
-
success: true,
|
|
144
|
-
updated: 0,
|
|
145
|
-
failed: 0,
|
|
146
|
-
...overrides
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Mock helper for setting up common API responses
|
|
151
|
-
*/
|
|
152
|
-
var MockAPIResponses = class {
|
|
153
|
-
constructor(fetchMock) {
|
|
154
|
-
this.fetchMock = fetchMock;
|
|
155
|
-
}
|
|
156
|
-
mockGetContent(content, status = 200) {
|
|
157
|
-
if (content) this.fetchMock.mockResolvedValueOnce(jsonResponse(content, { status }));
|
|
158
|
-
else this.fetchMock.mockResolvedValueOnce(new Response("Not found", { status: 404 }));
|
|
159
|
-
return this;
|
|
160
|
-
}
|
|
161
|
-
mockGetLocalized(entry, status = 200) {
|
|
162
|
-
if (entry) this.fetchMock.mockResolvedValueOnce(jsonResponse(entry, { status }));
|
|
163
|
-
else this.fetchMock.mockResolvedValueOnce(new Response("Not found", { status: 404 }));
|
|
164
|
-
return this;
|
|
165
|
-
}
|
|
166
|
-
mockListContent(items, status = 200) {
|
|
167
|
-
this.fetchMock.mockResolvedValueOnce(jsonResponse({ items }, { status }));
|
|
168
|
-
return this;
|
|
169
|
-
}
|
|
170
|
-
mockCreateContent(result, status = 200) {
|
|
171
|
-
this.fetchMock.mockResolvedValueOnce(jsonResponse({
|
|
172
|
-
...result,
|
|
173
|
-
created: result.created?.toISOString()
|
|
174
|
-
}, { status }));
|
|
175
|
-
return this;
|
|
176
|
-
}
|
|
177
|
-
mockUpdateContent(result, status = 200) {
|
|
178
|
-
this.fetchMock.mockResolvedValueOnce(jsonResponse({
|
|
179
|
-
...result,
|
|
180
|
-
modified: result.modified?.toISOString()
|
|
181
|
-
}, { status }));
|
|
182
|
-
return this;
|
|
183
|
-
}
|
|
184
|
-
mockDeleteContent(result, status = 200) {
|
|
185
|
-
this.fetchMock.mockResolvedValueOnce(jsonResponse(result, { status }));
|
|
186
|
-
return this;
|
|
187
|
-
}
|
|
188
|
-
mockStaleWrite(currentEtag) {
|
|
189
|
-
this.fetchMock.mockResolvedValueOnce(jsonResponse({ error: {
|
|
190
|
-
code: "STALE_WRITE",
|
|
191
|
-
message: "Content has been modified",
|
|
192
|
-
details: { currentEtag }
|
|
193
|
-
} }, { status: 412 }));
|
|
194
|
-
return this;
|
|
195
|
-
}
|
|
196
|
-
mockError(message, status = 500) {
|
|
197
|
-
this.fetchMock.mockResolvedValueOnce(new Response(message, { status }));
|
|
198
|
-
return this;
|
|
199
|
-
}
|
|
200
|
-
mockNetworkError() {
|
|
201
|
-
this.fetchMock.mockRejectedValueOnce(/* @__PURE__ */ new Error("Network error"));
|
|
202
|
-
return this;
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
/**
|
|
206
|
-
* Setup fetch mock with helper
|
|
207
|
-
* @param mockFn - Mock function from your test framework (e.g., mock from bun:test)
|
|
208
|
-
*/
|
|
209
|
-
function setupFetchMock(mockFn) {
|
|
210
|
-
const fetchMock = createMockFetch(mockFn);
|
|
211
|
-
global.fetch = fetchMock;
|
|
212
|
-
return {
|
|
213
|
-
fetchMock,
|
|
214
|
-
responses: new MockAPIResponses(fetchMock)
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
//#endregion
|
|
219
|
-
export { mockBatchResult as a, mockCreateResult as c, mockUpdateResult as d, setupFetchMock as f, jsonResponse as i, mockDeleteResult as l, MockAPIResponses as n, mockContentEntry as o, createMockFetch as r, mockContentManifest as s, API_ROUTES as t, mockLocalizedEntry as u };
|
|
220
|
-
//# sourceMappingURL=test-helpers-CRvDHjs2.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-helpers-CRvDHjs2.mjs","names":[],"sources":["../src/test-helpers.ts"],"sourcesContent":["import type {\n BatchResult,\n ContentEntry,\n ContentManifest,\n CreateResult,\n DeleteResult,\n LocalizedEntry,\n UpdateResult,\n} from '@conloca/content-api';\n\n/**\n * Test helpers for mocking Content API Client\n */\n\n/**\n * API route patterns used by the content API\n * These match the routes defined in content-api/src/middleware.ts\n */\nexport const API_ROUTES = {\n SITES: '/sites',\n ALL_CONTENT: '/content',\n CONTENT_BY_ID: (id: string) => `/content/${id}`,\n LOCALIZED_CONTENT: (id: string, locale: string) => `/content/${id}/${locale}`,\n SITE_PAGES: (site: string) => `/${site}/pages`,\n BLOCKS: '/blocks',\n COLLECTIONS: '/content/collections',\n BATCH_UPDATE: '/content/batch',\n FIND_UNTRANSLATED: (locale: string) => `/untranslated/${locale}`,\n DATA_CONTEXT: '/data-context',\n} as const;\n\nexport interface MockResponse {\n status?: number;\n headers?: Record<string, string>;\n body?: any;\n}\n\n/**\n * Creates a mock fetch function for testing\n * Note: This requires a mock function from your test framework (e.g., bun:test, jest, vitest)\n */\nexport function createMockFetch(mockFn: (impl?: any) => any) {\n return mockFn(() => Promise.resolve(new Response()));\n}\n\n/**\n * Creates a Response object with JSON body\n */\nexport function jsonResponse(body: any, options: { status?: number; headers?: Record<string, string> } = {}): Response {\n return new Response(JSON.stringify(body), {\n status: options.status || 200,\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n });\n}\n\n/**\n * Creates a mock ContentEntry\n */\nexport function mockContentEntry(overrides?: Partial<ContentEntry>): ContentEntry {\n return {\n id: 'test-id',\n site: 'test-site',\n collection: 'pages',\n type: 'puck',\n kind: 'page',\n locales: {\n en: {\n locale: 'en',\n etag: 'metaHash.contentHash',\n created: '2024-01-01T00:00:00Z',\n modified: '2024-01-01T00:00:00Z',\n pathname: '/test',\n meta: {\n title: 'Test Page',\n },\n content: { puckData: {} },\n },\n },\n ...overrides,\n };\n}\n\n/**\n * Creates a mock ContentManifest\n */\nexport function mockContentManifest(overrides?: Partial<ContentManifest>): ContentManifest {\n return {\n id: 'test-id',\n site: 'test-site',\n collection: 'pages',\n type: 'puck',\n kind: 'page',\n locales: {\n en: {\n locale: 'en',\n etag: 'metaHash.contentHash',\n created: '2024-01-01T00:00:00Z',\n modified: '2024-01-01T00:00:00Z',\n pathname: '/test',\n meta: {\n title: 'Test Page',\n },\n },\n },\n ...overrides,\n };\n}\n\n/**\n * Creates a mock LocalizedEntry\n */\nexport function mockLocalizedEntry(overrides?: Partial<LocalizedEntry>): LocalizedEntry {\n return {\n id: 'test-id',\n site: 'test-site',\n collection: 'pages',\n type: 'puck',\n kind: 'page',\n localized: {\n locale: 'en',\n etag: 'metaHash.contentHash',\n created: '2024-01-01T00:00:00Z',\n modified: '2024-01-01T00:00:00Z',\n pathname: '/test',\n meta: {\n title: 'Test Page',\n },\n content: { puckData: {} },\n },\n ...overrides,\n };\n}\n\n/**\n * Creates a mock CreateResult\n */\nexport function mockCreateResult(overrides?: Partial<CreateResult>): CreateResult {\n return {\n success: true,\n id: 'new-id',\n etag: 'newMetaHash.newContentHash',\n created: new Date('2024-01-01T00:00:00.000Z'),\n ...overrides,\n };\n}\n\n/**\n * Creates a mock UpdateResult\n */\nexport function mockUpdateResult(overrides?: Partial<UpdateResult>): UpdateResult {\n return {\n success: true,\n etag: 'updatedMetaHash.updatedContentHash',\n modified: new Date('2024-01-01T00:00:00.000Z'),\n ...overrides,\n };\n}\n\n/**\n * Creates a mock DeleteResult\n */\nexport function mockDeleteResult(overrides?: Partial<DeleteResult>): DeleteResult {\n return {\n success: true,\n ...overrides,\n };\n}\n\n/**\n * Creates a mock BatchResult\n */\nexport function mockBatchResult(overrides?: Partial<BatchResult>): BatchResult {\n return {\n operations: [],\n success: true,\n updated: 0,\n failed: 0,\n ...overrides,\n };\n}\n\n/**\n * Mock helper for setting up common API responses\n */\nexport class MockAPIResponses {\n constructor(private fetchMock: any) {}\n\n mockGetContent(content: ContentEntry | null, status = 200) {\n if (content) {\n this.fetchMock.mockResolvedValueOnce(jsonResponse(content, { status }));\n } else {\n this.fetchMock.mockResolvedValueOnce(new Response('Not found', { status: 404 }));\n }\n return this;\n }\n\n mockGetLocalized(entry: LocalizedEntry | null, status = 200) {\n if (entry) {\n this.fetchMock.mockResolvedValueOnce(jsonResponse(entry, { status }));\n } else {\n this.fetchMock.mockResolvedValueOnce(new Response('Not found', { status: 404 }));\n }\n return this;\n }\n\n mockListContent(items: ContentManifest[], status = 200) {\n this.fetchMock.mockResolvedValueOnce(jsonResponse({ items }, { status }));\n return this;\n }\n\n mockCreateContent(result: CreateResult, status = 200) {\n this.fetchMock.mockResolvedValueOnce(\n jsonResponse(\n {\n ...result,\n created: result.created?.toISOString(),\n },\n { status },\n ),\n );\n return this;\n }\n\n mockUpdateContent(result: UpdateResult, status = 200) {\n this.fetchMock.mockResolvedValueOnce(\n jsonResponse(\n {\n ...result,\n modified: result.modified?.toISOString(),\n },\n { status },\n ),\n );\n return this;\n }\n\n mockDeleteContent(result: DeleteResult, status = 200) {\n this.fetchMock.mockResolvedValueOnce(jsonResponse(result, { status }));\n return this;\n }\n\n mockStaleWrite(currentEtag: string) {\n this.fetchMock.mockResolvedValueOnce(\n jsonResponse(\n {\n error: {\n code: 'STALE_WRITE',\n message: 'Content has been modified',\n details: { currentEtag },\n },\n },\n { status: 412 },\n ),\n );\n return this;\n }\n\n mockError(message: string, status = 500) {\n this.fetchMock.mockResolvedValueOnce(new Response(message, { status }));\n return this;\n }\n\n mockNetworkError() {\n this.fetchMock.mockRejectedValueOnce(new Error('Network error'));\n return this;\n }\n}\n\n/**\n * Setup fetch mock with helper\n * @param mockFn - Mock function from your test framework (e.g., mock from bun:test)\n */\nexport function setupFetchMock(mockFn: (impl?: any) => any) {\n const fetchMock = createMockFetch(mockFn);\n global.fetch = fetchMock as any;\n return {\n fetchMock,\n responses: new MockAPIResponses(fetchMock),\n };\n}\n"],"mappings":";;;;;;;;AAkBA,MAAa,aAAa;CACxB,OAAO;CACP,aAAa;CACb,gBAAgB,OAAe,YAAY;CAC3C,oBAAoB,IAAY,WAAmB,YAAY,GAAG,GAAG;CACrE,aAAa,SAAiB,IAAI,KAAK;CACvC,QAAQ;CACR,aAAa;CACb,cAAc;CACd,oBAAoB,WAAmB,iBAAiB;CACxD,cAAc;CACf;;;;;AAYD,SAAgB,gBAAgB,QAA6B;AAC3D,QAAO,aAAa,QAAQ,QAAQ,IAAI,UAAU,CAAC,CAAC;;;;;AAMtD,SAAgB,aAAa,MAAW,UAAiE,EAAE,EAAY;AACrH,QAAO,IAAI,SAAS,KAAK,UAAU,KAAK,EAAE;EACxC,QAAQ,QAAQ,UAAU;EAC1B,SAAS;GACP,gBAAgB;GAChB,GAAG,QAAQ;GACZ;EACF,CAAC;;;;;AAMJ,SAAgB,iBAAiB,WAAiD;AAChF,QAAO;EACL,IAAI;EACJ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B,CAAC;AAChE,SAAO;;;;;;;AAQX,SAAgB,eAAe,QAA6B;CAC1D,MAAM,YAAY,gBAAgB,OAAO;AACzC,QAAO,QAAQ;AACf,QAAO;EACL;EACA,WAAW,IAAI,iBAAiB,UAAU;EAC3C"}
|
package/dist/testing.d.mts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { a as jsonResponse, c as mockContentManifest, d as mockLocalizedEntry, f as mockUpdateResult, i as createMockFetch, l as mockCreateResult, n as MockAPIResponses, o as mockBatchResult, p as setupFetchMock, r as MockResponse, s as mockContentEntry, t as API_ROUTES, u as mockDeleteResult } from "./test-helpers-BJxZXOMi.mjs";
|
|
2
|
-
export { API_ROUTES, MockAPIResponses, MockResponse, createMockFetch, jsonResponse, mockBatchResult, mockContentEntry, mockContentManifest, mockCreateResult, mockDeleteResult, mockLocalizedEntry, mockUpdateResult, setupFetchMock };
|
package/dist/testing.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { a as mockBatchResult, c as mockCreateResult, d as mockUpdateResult, f as setupFetchMock, i as jsonResponse, l as mockDeleteResult, n as MockAPIResponses, o as mockContentEntry, r as createMockFetch, s as mockContentManifest, t as API_ROUTES, u as mockLocalizedEntry } from "./test-helpers-CRvDHjs2.mjs";
|
|
2
|
-
|
|
3
|
-
export { API_ROUTES, MockAPIResponses, createMockFetch, jsonResponse, mockBatchResult, mockContentEntry, mockContentManifest, mockCreateResult, mockDeleteResult, mockLocalizedEntry, mockUpdateResult, setupFetchMock };
|