@zeno-cms/sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client.ts","../src/svelte/context.ts","../src/svelte/stores.ts"],"names":["ZENO_INTERNAL","createResponse","data","error","meta","errorMessage","ZenoCMS","config","apiKey","parsed","createClient","processEnvKeys","importMetaKeys","key","metaEnv","withoutPrefix","separatorIndex","projectSlug","token","projectId","result","params","page","limit","sortBy","sortOrder","offset","count","processedData","c","slug","collectionSlug","status","search","locale","fallback_locale","dateFrom","dateTo","dateField","effectiveFallback","query","collection","countQuery","normalized","row","fallbackUsed","entryIds","e","localeMap","loc","entry","localized","availableLocales","l","entryId","mimeType","assetId","asset","assetError","urlData","urlError","emailParams","response","ZENO_KEY","initZeno","options","client","setContext","useZeno","getContext","useAsyncQuery","fetcher","writable","loading","execute","err","onMount","useEntries","zeno","useEntry","useCollections","useCollection","useAssets","useAssetUrl","useProject","useLocales"],"mappings":"oHAiBA,IAAMA,CAAAA,CAAgB,CACpB,QAAA,CAAU,0CAAA,CACV,UAAW,kNACb,CAAA,CAEA,SAASC,CAAAA,CACPC,CAAAA,CACAC,CAAAA,CAAiB,IAAA,CACjBC,EACiB,CACjB,IAAIC,EAA8B,IAAA,CAClC,OAAIF,IACE,OAAOA,CAAAA,EAAU,QAAA,CAAUE,CAAAA,CAAeF,EACrCA,CAAAA,YAAiB,KAAA,CAAOE,EAAeF,CAAAA,CAAM,OAAA,CAC7C,OAAOA,CAAAA,EAAU,QAAA,EAAYA,CAAAA,GAAU,IAAA,EAAQ,YAAaA,CAAAA,GACnEE,CAAAA,CAAe,OAAQF,CAAAA,CAA+B,OAAO,IAI1D,CACL,IAAA,CAAAD,CAAAA,CACA,KAAA,CAAOG,EACP,IAAA,CAAM,CACJ,GAAGD,CAAAA,CACH,SAAA,CAAW,IAAI,IAAA,EAAK,CAAE,WAAA,EACxB,CACF,CACF,C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yB,CACzB,IAAMyD,CAAAA,CAAOV,CAAAA,EAAQ,CACrB,OAAOE,CAAAA,CAAc,IAAMQ,EAAK,SAAA,CAAUzD,CAAM,CAAC,CACnD,CAGO,SAAS8D,CAAAA,CAAY3B,CAAAA,CAA2C,CACrE,IAAMsB,CAAAA,CAAOV,CAAAA,GACb,OAAOE,CAAAA,CAAc,IAAMQ,CAAAA,CAAK,WAAA,CAAYtB,CAAO,CAAC,CACtD,CAGO,SAAS4B,CAAAA,EAAsC,CACpD,IAAMN,CAAAA,CAAOV,CAAAA,GACb,OAAOE,CAAAA,CAAc,IAAMQ,CAAAA,CAAK,UAAA,EAAY,CAC9C,CAGO,SAASO,GAAuC,CACrD,IAAMP,CAAAA,CAAOV,CAAAA,EAAQ,CACrB,OAAOE,EAAc,IAAMQ,CAAAA,CAAK,UAAA,EAAY,CAC9C","file":"svelte.js","sourcesContent":["import { createClient, type SupabaseClient } from '@supabase/supabase-js';\r\nimport type {\r\n ZenoConfig,\r\n ZenoResponse,\r\n PaginationParams,\r\n FilterParams,\r\n EmailParams,\r\n Collection,\r\n Entry,\r\n Asset,\r\n AssetUrl,\r\n Locale,\r\n Project,\r\n HealthStatus,\r\n} from './types';\r\n\r\n// Internal configuration - injected at build time from environment variables\r\nconst ZENO_INTERNAL = {\r\n endpoint: process.env.ZENO_ENDPOINT!,\r\n publicKey: process.env.ZENO_PUBLIC_KEY!,\r\n};\r\n\r\nfunction createResponse<T>(\r\n data: T | null,\r\n error: unknown = null,\r\n meta?: Omit<NonNullable<ZenoResponse<T>['meta']>, 'timestamp'>\r\n): ZenoResponse<T> {\r\n let errorMessage: string | null = null;\r\n if (error) {\r\n if (typeof error === 'string') errorMessage = error;\r\n else if (error instanceof Error) errorMessage = error.message;\r\n else if (typeof error === 'object' && error !== null && 'message' in error) {\r\n errorMessage = String((error as { message: unknown }).message);\r\n }\r\n }\r\n\r\n return {\r\n data,\r\n error: errorMessage,\r\n meta: {\r\n ...meta,\r\n timestamp: new Date().toISOString(),\r\n },\r\n };\r\n}\r\n\r\nexport class ZenoCMS {\r\n private supabase: SupabaseClient;\r\n private apiKey: string;\r\n private projectSlug: string;\r\n private apiToken: string;\r\n private projectId: string | null = null;\r\n private isValidated: boolean = false;\r\n private configDefaultLocale: string | undefined;\r\n private resolvedDefaultLocale: string | null = null;\r\n\r\n constructor(config: ZenoConfig = {}) {\r\n // Resolve API key: explicit config > environment variable\r\n const apiKey = config.apiKey || this.getEnvApiKey();\r\n\r\n if (!apiKey) {\r\n throw new Error(\r\n 'Missing API key. Provide it via config.apiKey or set an environment variable: ' +\r\n 'ZENO_API_KEY, VITE_ZENO_API_KEY, NEXT_PUBLIC_ZENO_API_KEY, or PUBLIC_ZENO_API_KEY.'\r\n );\r\n }\r\n\r\n // Parse and validate API key format: zeno_<projectSlug>_<token>\r\n const parsed = this.parseApiKey(apiKey);\r\n this.apiKey = apiKey;\r\n this.projectSlug = parsed.projectSlug;\r\n this.apiToken = parsed.token;\r\n this.configDefaultLocale = config.defaultLocale;\r\n\r\n this.supabase = createClient(ZENO_INTERNAL.endpoint, ZENO_INTERNAL.publicKey, {\r\n auth: {\r\n persistSession: false,\r\n autoRefreshToken: false,\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Reads the API key from environment variables.\r\n * Checks multiple naming conventions so each framework only needs one .env variable:\r\n * ZENO_API_KEY — Node.js / server-side\r\n * NEXT_PUBLIC_ZENO_API_KEY — Next.js client\r\n * VITE_ZENO_API_KEY — Vite (React, Vue, Svelte)\r\n * PUBLIC_ZENO_API_KEY — Astro client\r\n */\r\n private getEnvApiKey(): string | undefined {\r\n const processEnvKeys = [\r\n 'ZENO_API_KEY',\r\n 'NEXT_PUBLIC_ZENO_API_KEY',\r\n 'VITE_ZENO_API_KEY',\r\n 'PUBLIC_ZENO_API_KEY',\r\n ];\r\n\r\n const importMetaKeys = [\r\n 'ZENO_API_KEY',\r\n 'VITE_ZENO_API_KEY',\r\n 'PUBLIC_ZENO_API_KEY',\r\n 'NEXT_PUBLIC_ZENO_API_KEY',\r\n ];\r\n\r\n // Node.js / Next.js (process.env)\r\n if (typeof process !== 'undefined' && process.env) {\r\n for (const key of processEnvKeys) {\r\n if (process.env[key]) return process.env[key];\r\n }\r\n }\r\n\r\n // Vite / Astro / SvelteKit (import.meta.env)\r\n try {\r\n // @ts-expect-error - import.meta.env may not exist in all environments\r\n const metaEnv = import.meta?.env;\r\n if (metaEnv) {\r\n for (const key of importMetaKeys) {\r\n if (metaEnv[key]) return metaEnv[key];\r\n }\r\n }\r\n } catch {\r\n // import.meta not available\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Parse and validate the API key format.\r\n * Expected format: zeno_<projectSlug>_<token>\r\n */\r\n private parseApiKey(apiKey: string): { projectSlug: string; token: string } {\r\n if (!apiKey.startsWith('zeno_')) {\r\n throw new Error('Invalid API key format. Expected: zeno_<projectSlug>_<token>');\r\n }\r\n\r\n const withoutPrefix = apiKey.slice(5); // Remove 'zeno_'\r\n const separatorIndex = withoutPrefix.indexOf('_');\r\n\r\n if (separatorIndex === -1) {\r\n throw new Error('Invalid API key format. Expected: zeno_<projectSlug>_<token>');\r\n }\r\n\r\n const projectSlug = withoutPrefix.slice(0, separatorIndex);\r\n const token = withoutPrefix.slice(separatorIndex + 1);\r\n\r\n if (!projectSlug || !token) {\r\n throw new Error('Invalid API key format. Expected: zeno_<projectSlug>_<token>');\r\n }\r\n\r\n return { projectSlug, token };\r\n }\r\n\r\n /**\r\n * Returns the fallback locale to use.\r\n * Priority: config.defaultLocale > project's default locale from DB > 'en'.\r\n */\r\n private async getDefaultLocale(): Promise<string> {\r\n if (this.configDefaultLocale) return this.configDefaultLocale;\r\n if (this.resolvedDefaultLocale) return this.resolvedDefaultLocale;\r\n\r\n try {\r\n const projectId = await this.resolveProjectId();\r\n const { data } = await this.supabase\r\n .from('project_locales')\r\n .select('locale_code')\r\n .eq('project_id', projectId)\r\n .eq('is_default', true)\r\n .single();\r\n\r\n if (data?.locale_code) {\r\n this.resolvedDefaultLocale = data.locale_code;\r\n return data.locale_code;\r\n }\r\n } catch {\r\n // Fall through to 'en'\r\n }\r\n\r\n this.resolvedDefaultLocale = 'en';\r\n return 'en';\r\n }\r\n\r\n /**\r\n * Resolves and validates the project ID using the API key.\r\n * Validates the token server-side for security.\r\n */\r\n private async resolveProjectId(): Promise<string> {\r\n // Return cached project ID if already validated\r\n if (this.projectId && this.isValidated) return this.projectId;\r\n\r\n // Call server-side validation function\r\n const { data, error } = await this.supabase.rpc('validate_sdk_api_key', {\r\n p_project_slug: this.projectSlug,\r\n p_token: this.apiToken,\r\n });\r\n\r\n if (error) {\r\n throw new Error('API key validation failed: ' + error.message);\r\n }\r\n\r\n // The RPC returns a single row with project_id, is_valid, error_message\r\n const result = data?.[0];\r\n\r\n if (!result || !result.is_valid) {\r\n throw new Error(result?.error_message || 'Invalid API key or project not found');\r\n }\r\n\r\n this.projectId = result.project_id;\r\n this.isValidated = true;\r\n return result.project_id;\r\n }\r\n\r\n /** Get project information */\r\n async getProject(): Promise<ZenoResponse<Project>> {\r\n try {\r\n const projectId = await this.resolveProjectId();\r\n\r\n const { data, error } = await this.supabase\r\n .from('projects')\r\n .select('id, name, description, slug, status, created_at, updated_at')\r\n .eq('id', projectId)\r\n .single();\r\n\r\n return createResponse(data, error);\r\n } catch (error) {\r\n return createResponse<Project>(null, error);\r\n }\r\n }\r\n\r\n /** Get all collections for the project */\r\n async getCollections(params: PaginationParams = {}): Promise<ZenoResponse<Collection[]>> {\r\n try {\r\n const projectId = await this.resolveProjectId();\r\n const { page = 1, limit = 50, sortBy = 'created_at', sortOrder = 'desc' } = params;\r\n const offset = (page - 1) * limit;\r\n\r\n const { count } = await this.supabase\r\n .from('collections')\r\n .select('*', { count: 'exact', head: true })\r\n .eq('project_id', projectId);\r\n\r\n const { data, error } = await this.supabase\r\n .from('collections')\r\n .select('id, name, slug, description, fields, created_at, updated_at')\r\n .eq('project_id', projectId)\r\n .order(sortBy, { ascending: sortOrder === 'asc' })\r\n .range(offset, offset + limit - 1);\r\n\r\n const processedData = data?.map((c) => ({\r\n ...c,\r\n fields: typeof c.fields === 'string' ? JSON.parse(c.fields) : c.fields,\r\n }));\r\n\r\n return createResponse(processedData as Collection[] | null, error, {\r\n total: count || 0,\r\n page,\r\n limit,\r\n totalPages: Math.ceil((count || 0) / limit),\r\n });\r\n } catch (error) {\r\n return createResponse<Collection[]>(null, error);\r\n }\r\n }\r\n\r\n /** Get a single collection by slug */\r\n async getCollection(slug: string): Promise<ZenoResponse<Collection>> {\r\n try {\r\n const projectId = await this.resolveProjectId();\r\n\r\n const { data, error } = await this.supabase\r\n .from('collections')\r\n .select('id, name, slug, description, fields, created_at, updated_at')\r\n .eq('project_id', projectId)\r\n .eq('slug', slug)\r\n .single();\r\n\r\n const processedData = data\r\n ? { ...data, fields: typeof data.fields === 'string' ? JSON.parse(data.fields) : data.fields }\r\n : null;\r\n\r\n return createResponse(processedData as Collection | null, error);\r\n } catch (error) {\r\n return createResponse<Collection>(null, error);\r\n }\r\n }\r\n\r\n /** Get entries, optionally filtered by collection slug */\r\n async getEntries(\r\n collectionSlug?: string,\r\n params: PaginationParams & FilterParams = {}\r\n ): Promise<ZenoResponse<Entry[]>> {\r\n try {\r\n const projectId = await this.resolveProjectId();\r\n const {\r\n page = 1,\r\n limit = 50,\r\n sortBy = 'created_at',\r\n sortOrder = 'desc',\r\n status,\r\n search,\r\n locale,\r\n fallback_locale,\r\n dateFrom,\r\n dateTo,\r\n dateField,\r\n } = params;\r\n const effectiveFallback = fallback_locale || await this.getDefaultLocale();\r\n const offset = (page - 1) * limit;\r\n\r\n let query = this.supabase\r\n .from('entries')\r\n .select(`\r\n id, data, status, collection_id, project_id, created_at, updated_at,\r\n collections ( id, name, slug )\r\n `)\r\n .eq('project_id', projectId);\r\n\r\n // Filter by collection\r\n if (collectionSlug) {\r\n const { data: collection } = await this.supabase\r\n .from('collections')\r\n .select('id')\r\n .eq('project_id', projectId)\r\n .eq('slug', collectionSlug)\r\n .single();\r\n\r\n if (!collection) {\r\n return createResponse<Entry[]>(null, 'Collection not found');\r\n }\r\n query = query.eq('collection_id', collection.id);\r\n }\r\n\r\n if (status) query = query.eq('status', status);\r\n if (search) query = query.textSearch('data', search);\r\n\r\n // Date filtering: use dateField inside data if specified, otherwise use created_at\r\n if (dateFrom) {\r\n query = dateField\r\n ? query.gte(`data->${dateField}`, dateFrom)\r\n : query.gte('created_at', dateFrom);\r\n }\r\n if (dateTo) {\r\n query = dateField\r\n ? query.lte(`data->${dateField}`, dateTo)\r\n : query.lte('created_at', dateTo);\r\n }\r\n\r\n // Count query\r\n let countQuery = this.supabase\r\n .from('entries')\r\n .select('*', { count: 'exact', head: true })\r\n .eq('project_id', projectId);\r\n\r\n if (collectionSlug) {\r\n const { data: collection } = await this.supabase\r\n .from('collections')\r\n .select('id')\r\n .eq('project_id', projectId)\r\n .eq('slug', collectionSlug)\r\n .single();\r\n\r\n if (collection) countQuery = countQuery.eq('collection_id', collection.id);\r\n }\r\n if (status) countQuery = countQuery.eq('status', status);\r\n if (search) countQuery = countQuery.textSearch('data', search);\r\n\r\n // Date filtering for count query\r\n if (dateFrom) {\r\n countQuery = dateField\r\n ? countQuery.gte(`data->${dateField}`, dateFrom)\r\n : countQuery.gte('created_at', dateFrom);\r\n }\r\n if (dateTo) {\r\n countQuery = dateField\r\n ? countQuery.lte(`data->${dateField}`, dateTo)\r\n : countQuery.lte('created_at', dateTo);\r\n }\r\n\r\n const { count } = await countQuery;\r\n\r\n const { data, error } = await query\r\n .order(sortBy, { ascending: sortOrder === 'asc' })\r\n .range(offset, offset + limit - 1);\r\n\r\n if (error) throw error;\r\n\r\n // Normalize Supabase join (returns array for relations) and apply localization\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const rows = (data as any[]) ?? [];\r\n const normalized = rows.map((row) => ({\r\n ...row,\r\n collections: Array.isArray(row.collections) ? row.collections[0] : row.collections,\r\n }));\r\n\r\n let processedData = normalized;\r\n let fallbackUsed = false;\r\n\r\n if (locale && normalized.length > 0) {\r\n try {\r\n // Use batch function to avoid N+1 queries\r\n const entryIds = normalized.map((e) => e.id);\r\n const result = await this.supabase.rpc('get_localized_entries_batch', {\r\n entry_uuids: entryIds,\r\n locale,\r\n fallback_locale: effectiveFallback,\r\n });\r\n\r\n if (result.data && result.data.length > 0) {\r\n // Create a map for quick lookup\r\n const localeMap = new Map<string, { data: Record<string, unknown>; locale_code: string; is_fallback: boolean }>();\r\n for (const loc of result.data) {\r\n localeMap.set(loc.entry_id, {\r\n data: loc.data,\r\n locale_code: loc.locale_code,\r\n is_fallback: loc.is_fallback,\r\n });\r\n }\r\n\r\n // Merge localized data with entries\r\n processedData = normalized.map((entry) => {\r\n const localized = localeMap.get(entry.id);\r\n if (localized) {\r\n if (localized.is_fallback) fallbackUsed = true;\r\n return { ...entry, data: localized.data, locale_code: localized.locale_code };\r\n }\r\n return entry;\r\n });\r\n }\r\n } catch {\r\n // Fallback to base data if batch function fails\r\n }\r\n }\r\n\r\n // Available locales\r\n const { data: availableLocales } = await this.supabase\r\n .from('project_locales')\r\n .select('locale_code')\r\n .eq('project_id', projectId)\r\n .eq('is_active', true);\r\n\r\n return createResponse(processedData as Entry[] | null, null, {\r\n total: count || 0,\r\n page,\r\n limit,\r\n totalPages: Math.ceil((count || 0) / limit),\r\n locale: locale || effectiveFallback,\r\n fallback_used: fallbackUsed,\r\n available_locales: availableLocales?.map((l) => l.locale_code) || [],\r\n });\r\n } catch (error) {\r\n return createResponse<Entry[]>(null, error);\r\n }\r\n }\r\n\r\n /** Get a single entry by ID */\r\n async getEntry(\r\n entryId: string,\r\n params: { locale?: string; fallback_locale?: string } = {}\r\n ): Promise<ZenoResponse<Entry>> {\r\n try {\r\n const projectId = await this.resolveProjectId();\r\n const { locale, fallback_locale } = params;\r\n const effectiveFallback = fallback_locale || await this.getDefaultLocale();\r\n\r\n const { data, error } = await this.supabase\r\n .from('entries')\r\n .select(`\r\n id, data, status, collection_id, project_id, created_at, updated_at,\r\n collections ( id, name, slug, fields )\r\n `)\r\n .eq('project_id', projectId)\r\n .eq('id', entryId)\r\n .single();\r\n\r\n if (error) throw error;\r\n\r\n // Normalize Supabase join (returns array for relations)\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const row = data as any;\r\n const normalized = row ? {\r\n ...row,\r\n collections: Array.isArray(row.collections) ? row.collections[0] : row.collections,\r\n } : null;\r\n\r\n let processedData = normalized;\r\n let fallbackUsed = false;\r\n\r\n if (locale && normalized) {\r\n try {\r\n const result = await this.supabase.rpc('get_localized_entry', {\r\n entry_uuid: entryId,\r\n locale,\r\n fallback_locale: effectiveFallback,\r\n });\r\n\r\n if (result.data?.[0]) {\r\n const localized = result.data[0];\r\n if (localized.locale_code !== locale) fallbackUsed = true;\r\n processedData = { ...normalized, data: localized.data, locale_code: localized.locale_code };\r\n }\r\n } catch {\r\n // Fallback to base data\r\n }\r\n }\r\n\r\n const { data: availableLocales } = await this.supabase\r\n .from('project_locales')\r\n .select('locale_code')\r\n .eq('project_id', projectId)\r\n .eq('is_active', true);\r\n\r\n return createResponse(processedData as Entry | null, null, {\r\n locale: locale || effectiveFallback,\r\n fallback_used: fallbackUsed,\r\n available_locales: availableLocales?.map((l) => l.locale_code) || [],\r\n });\r\n } catch (error) {\r\n return createResponse<Entry>(null, error);\r\n }\r\n }\r\n\r\n /** Get assets for the project */\r\n async getAssets(\r\n params: PaginationParams & { mimeType?: string } = {}\r\n ): Promise<ZenoResponse<Asset[]>> {\r\n try {\r\n const projectId = await this.resolveProjectId();\r\n const { page = 1, limit = 50, sortBy = 'created_at', sortOrder = 'desc', mimeType } = params;\r\n const offset = (page - 1) * limit;\r\n\r\n let query = this.supabase\r\n .from('assets')\r\n .select('id, filename, original_filename, mime_type, size_bytes, metadata, created_at')\r\n .eq('project_id', projectId);\r\n\r\n if (mimeType) query = query.like('mime_type', `${mimeType}%`);\r\n\r\n let countQuery = this.supabase\r\n .from('assets')\r\n .select('*', { count: 'exact', head: true })\r\n .eq('project_id', projectId);\r\n\r\n if (mimeType) countQuery = countQuery.like('mime_type', `${mimeType}%`);\r\n\r\n const { count } = await countQuery;\r\n\r\n const { data, error } = await query\r\n .order(sortBy, { ascending: sortOrder === 'asc' })\r\n .range(offset, offset + limit - 1);\r\n\r\n return createResponse(data as Asset[] | null, error, {\r\n total: count || 0,\r\n page,\r\n limit,\r\n totalPages: Math.ceil((count || 0) / limit),\r\n });\r\n } catch (error) {\r\n return createResponse<Asset[]>(null, error);\r\n }\r\n }\r\n\r\n /** Get a signed download URL for an asset */\r\n async getAssetUrl(assetId: string): Promise<ZenoResponse<AssetUrl>> {\r\n try {\r\n const projectId = await this.resolveProjectId();\r\n\r\n const { data: asset, error: assetError } = await this.supabase\r\n .from('assets')\r\n .select('storage_path')\r\n .eq('project_id', projectId)\r\n .eq('id', assetId)\r\n .single();\r\n\r\n if (assetError || !asset) {\r\n return createResponse<AssetUrl>(null, 'Asset not found');\r\n }\r\n\r\n const { data: urlData, error: urlError } = await this.supabase\r\n .storage\r\n .from('assets')\r\n .createSignedUrl(asset.storage_path, 3600);\r\n\r\n if (urlError) {\r\n return createResponse<AssetUrl>(null, urlError);\r\n }\r\n\r\n return createResponse<AssetUrl>({\r\n downloadUrl: urlData.signedUrl,\r\n expiresIn: 3600,\r\n });\r\n } catch (error) {\r\n return createResponse<AssetUrl>(null, error);\r\n }\r\n }\r\n\r\n /** Send an email via the Zeno edge function */\r\n async sendEmail(emailParams: EmailParams): Promise<ZenoResponse<{ messageId: string }>> {\r\n try {\r\n const response = await fetch(`${ZENO_INTERNAL.endpoint}/functions/v1/api/email/send`, {\r\n method: 'POST',\r\n headers: {\r\n 'Authorization': `Bearer ${this.apiKey}`,\r\n 'X-API-Key': this.apiKey,\r\n 'Content-Type': 'application/json',\r\n },\r\n body: JSON.stringify(emailParams),\r\n });\r\n\r\n const result = await response.json();\r\n\r\n if (!response.ok) {\r\n return createResponse<{ messageId: string }>(null, result.error || 'Email sending failed');\r\n }\r\n\r\n return createResponse(result.data);\r\n } catch (error) {\r\n return createResponse<{ messageId: string }>(null, error);\r\n }\r\n }\r\n\r\n /** Get available locales for the project */\r\n async getLocales(): Promise<ZenoResponse<Locale[]>> {\r\n try {\r\n const projectId = await this.resolveProjectId();\r\n\r\n const { data, error } = await this.supabase\r\n .from('project_locales')\r\n .select('locale_code, locale_name, locale_native_name, is_default')\r\n .eq('project_id', projectId)\r\n .eq('is_active', true)\r\n .order('is_default', { ascending: false })\r\n .order('locale_name', { ascending: true });\r\n\r\n if (error) throw error;\r\n\r\n const processedData = data?.map((l) => ({\r\n code: l.locale_code,\r\n name: l.locale_name,\r\n native_name: l.locale_native_name,\r\n is_default: l.is_default,\r\n })) || [];\r\n\r\n return createResponse<Locale[]>(processedData);\r\n } catch (error) {\r\n return createResponse<Locale[]>(null, error);\r\n }\r\n }\r\n\r\n /** Health check */\r\n async health(): Promise<ZenoResponse<HealthStatus>> {\r\n return createResponse<HealthStatus>({\r\n status: 'healthy',\r\n version: '1.0.0',\r\n });\r\n }\r\n}\r\n","import { getContext, setContext } from 'svelte';\r\nimport { ZenoCMS } from '../client';\r\nimport type { ZenoContextOptions } from './types';\r\n\r\nconst ZENO_KEY = 'zeno-cms-client';\r\n\r\n/**\r\n * Initialize the Zeno SDK in a Svelte component tree.\r\n * Call this once in your root layout component.\r\n *\r\n * @example\r\n * ```svelte\r\n * <script>\r\n * import { initZeno } from '@zeno/sdk/svelte'\r\n * initZeno({ apiKey: import.meta.env.VITE_ZENO_API_KEY })\r\n * </script>\r\n * ```\r\n */\r\nexport function initZeno(options: ZenoContextOptions = {}): ZenoCMS {\r\n const client = new ZenoCMS({\r\n apiKey: options.apiKey,\r\n defaultLocale: options.defaultLocale,\r\n });\r\n setContext(ZENO_KEY, client);\r\n return client;\r\n}\r\n\r\n/**\r\n * Access the raw ZenoCMS client instance from Svelte context.\r\n * Requires `initZeno()` to be called in a parent component.\r\n *\r\n * @example\r\n * ```svelte\r\n * <script>\r\n * import { useZeno } from '@zeno/sdk/svelte'\r\n * const zeno = useZeno()\r\n * // zeno.sendEmail({ ... })\r\n * </script>\r\n * ```\r\n */\r\nexport function useZeno(): ZenoCMS {\r\n const client = getContext<ZenoCMS>(ZENO_KEY);\r\n if (!client) {\r\n throw new Error(\r\n 'useZeno() requires initZeno() to be called in a parent component.'\r\n );\r\n }\r\n return client;\r\n}\r\n","import { writable, derived, type Readable } from 'svelte/store';\r\nimport { onMount } from 'svelte';\r\nimport { useZeno } from './context';\r\nimport type { UseQueryResult } from './types';\r\nimport type {\r\n Entry,\r\n Collection,\r\n Asset,\r\n AssetUrl,\r\n Project,\r\n Locale,\r\n PaginationParams,\r\n FilterParams,\r\n} from '../types';\r\n\r\n/**\r\n * Internal helper: wraps an async SDK call with reactive Svelte stores.\r\n * Auto-fetches on creation and exposes a refresh function.\r\n */\r\nfunction useAsyncQuery<T>(\r\n fetcher: () => Promise<{ data: T | null; error: string | null }>\r\n): UseQueryResult<T> {\r\n const data = writable<T | null>(null);\r\n const error = writable<string | null>(null);\r\n const loading = writable(true);\r\n\r\n const execute = async () => {\r\n loading.set(true);\r\n error.set(null);\r\n try {\r\n const result = await fetcher();\r\n data.set(result.data);\r\n error.set(result.error);\r\n } catch (err) {\r\n error.set(err instanceof Error ? err.message : String(err));\r\n data.set(null);\r\n } finally {\r\n loading.set(false);\r\n }\r\n };\r\n\r\n onMount(() => {\r\n execute();\r\n });\r\n\r\n return {\r\n data: { subscribe: data.subscribe } as Readable<T | null>,\r\n error: { subscribe: error.subscribe } as Readable<string | null>,\r\n loading: { subscribe: loading.subscribe } as Readable<boolean>,\r\n refresh: execute,\r\n };\r\n}\r\n\r\n/** Fetch entries, optionally filtered by collection slug */\r\nexport function useEntries(\r\n collectionSlug?: string,\r\n params?: PaginationParams & FilterParams\r\n): UseQueryResult<Entry[]> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getEntries(collectionSlug, params));\r\n}\r\n\r\n/** Fetch a single entry by ID */\r\nexport function useEntry(\r\n entryId: string,\r\n params?: { locale?: string; fallback_locale?: string }\r\n): UseQueryResult<Entry> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getEntry(entryId, params));\r\n}\r\n\r\n/** Fetch all collections */\r\nexport function useCollections(\r\n params?: PaginationParams\r\n): UseQueryResult<Collection[]> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getCollections(params));\r\n}\r\n\r\n/** Fetch a single collection by slug */\r\nexport function useCollection(slug: string): UseQueryResult<Collection> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getCollection(slug));\r\n}\r\n\r\n/** Fetch assets */\r\nexport function useAssets(\r\n params?: PaginationParams & { mimeType?: string }\r\n): UseQueryResult<Asset[]> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getAssets(params));\r\n}\r\n\r\n/** Get a signed download URL for an asset */\r\nexport function useAssetUrl(assetId: string): UseQueryResult<AssetUrl> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getAssetUrl(assetId));\r\n}\r\n\r\n/** Fetch project information */\r\nexport function useProject(): UseQueryResult<Project> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getProject());\r\n}\r\n\r\n/** Fetch available locales */\r\nexport function useLocales(): UseQueryResult<Locale[]> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getLocales());\r\n}\r\n"]}
@@ -0,0 +1,2 @@
1
+ import {a}from'./chunk-4ROHQDX7.mjs';import {setContext,getContext,onMount}from'svelte';import {writable}from'svelte/store';var c="zeno-cms-client";function m(e={}){let t=new a({apiKey:e.apiKey,defaultLocale:e.defaultLocale});return setContext(c,t),t}function n(){let e=getContext(c);if(!e)throw new Error("useZeno() requires initZeno() to be called in a parent component.");return e}function r(e){let t=writable(null),s=writable(null),u=writable(true),i=async()=>{u.set(true),s.set(null);try{let o=await e();t.set(o.data),s.set(o.error);}catch(o){s.set(o instanceof Error?o.message:String(o)),t.set(null);}finally{u.set(false);}};return onMount(()=>{i();}),{data:{subscribe:t.subscribe},error:{subscribe:s.subscribe},loading:{subscribe:u.subscribe},refresh:i}}function g(e,t){let s=n();return r(()=>s.getEntries(e,t))}function b(e,t){let s=n();return r(()=>s.getEntry(e,t))}function x(e){let t=n();return r(()=>t.getCollections(e))}function C(e){let t=n();return r(()=>t.getCollection(e))}function P(e){let t=n();return r(()=>t.getAssets(e))}function U(e){let t=n();return r(()=>t.getAssetUrl(e))}function d(){let e=n();return r(()=>e.getProject())}function R(){let e=n();return r(()=>e.getLocales())}export{m as initZeno,U as useAssetUrl,P as useAssets,C as useCollection,x as useCollections,g as useEntries,b as useEntry,R as useLocales,d as useProject,n as useZeno};//# sourceMappingURL=svelte.mjs.map
2
+ //# sourceMappingURL=svelte.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/svelte/context.ts","../src/svelte/stores.ts"],"names":["ZENO_KEY","initZeno","options","client","ZenoCMS","setContext","useZeno","getContext","useAsyncQuery","fetcher","data","writable","error","loading","execute","result","err","onMount","useEntries","collectionSlug","params","zeno","useEntry","entryId","useCollections","useCollection","slug","useAssets","useAssetUrl","assetId","useProject","useLocales"],"mappings":"4HAIA,IAAMA,CAAAA,CAAW,iBAAA,CAcV,SAASC,CAAAA,CAASC,CAAAA,CAA8B,EAAC,CAAY,CAClE,IAAMC,CAAAA,CAAS,IAAIC,CAAAA,CAAQ,CACzB,MAAA,CAAQF,CAAAA,CAAQ,MAAA,CAChB,cAAeA,CAAAA,CAAQ,aACzB,CAAC,CAAA,CACD,OAAAG,UAAAA,CAAWL,CAAAA,CAAUG,CAAM,CAAA,CACpBA,CACT,CAeO,SAASG,CAAAA,EAAmB,CACjC,IAAMH,CAAAA,CAASI,UAAAA,CAAoBP,CAAQ,EAC3C,GAAI,CAACG,CAAAA,CACH,MAAM,IAAI,KAAA,CACR,mEACF,CAAA,CAEF,OAAOA,CACT,CC7BA,SAASK,CAAAA,CACPC,CAAAA,CACmB,CACnB,IAAM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ASH,CAAM,CAAC,CAC3D,CAGO,SAASI,EACdJ,CAAAA,CAC8B,CAC9B,IAAMC,CAAAA,CAAOf,CAAAA,EAAQ,CACrB,OAAOE,CAAAA,CAAc,IAAMa,CAAAA,CAAK,cAAA,CAAeD,CAAM,CAAC,CACxD,CAGO,SAASK,CAAAA,CAAcC,CAAAA,CAA0C,CACtE,IAAML,CAAAA,CAAOf,CAAAA,EAAQ,CACrB,OAAOE,CAAAA,CAAc,IAAMa,CAAAA,CAAK,cAAcK,CAAI,CAAC,CACrD,CAGO,SAASC,CAAAA,CACdP,CAAAA,CACyB,CACzB,IAAMC,CAAAA,CAAOf,CAAAA,EAAQ,CACrB,OAAOE,CAAAA,CAAc,IAAMa,CAAAA,CAAK,SAAA,CAAUD,CAAM,CAAC,CACnD,CAGO,SAASQ,EAAYC,CAAAA,CAA2C,CACrE,IAAMR,CAAAA,CAAOf,GAAQ,CACrB,OAAOE,CAAAA,CAAc,IAAMa,CAAAA,CAAK,WAAA,CAAYQ,CAAO,CAAC,CACtD,CAGO,SAASC,CAAAA,EAAsC,CACpD,IAAMT,CAAAA,CAAOf,CAAAA,EAAQ,CACrB,OAAOE,EAAc,IAAMa,CAAAA,CAAK,UAAA,EAAY,CAC9C,CAGO,SAASU,CAAAA,EAAuC,CACrD,IAAMV,CAAAA,CAAOf,CAAAA,EAAQ,CACrB,OAAOE,CAAAA,CAAc,IAAMa,CAAAA,CAAK,UAAA,EAAY,CAC9C","file":"svelte.mjs","sourcesContent":["import { getContext, setContext } from 'svelte';\r\nimport { ZenoCMS } from '../client';\r\nimport type { ZenoContextOptions } from './types';\r\n\r\nconst ZENO_KEY = 'zeno-cms-client';\r\n\r\n/**\r\n * Initialize the Zeno SDK in a Svelte component tree.\r\n * Call this once in your root layout component.\r\n *\r\n * @example\r\n * ```svelte\r\n * <script>\r\n * import { initZeno } from '@zeno/sdk/svelte'\r\n * initZeno({ apiKey: import.meta.env.VITE_ZENO_API_KEY })\r\n * </script>\r\n * ```\r\n */\r\nexport function initZeno(options: ZenoContextOptions = {}): ZenoCMS {\r\n const client = new ZenoCMS({\r\n apiKey: options.apiKey,\r\n defaultLocale: options.defaultLocale,\r\n });\r\n setContext(ZENO_KEY, client);\r\n return client;\r\n}\r\n\r\n/**\r\n * Access the raw ZenoCMS client instance from Svelte context.\r\n * Requires `initZeno()` to be called in a parent component.\r\n *\r\n * @example\r\n * ```svelte\r\n * <script>\r\n * import { useZeno } from '@zeno/sdk/svelte'\r\n * const zeno = useZeno()\r\n * // zeno.sendEmail({ ... })\r\n * </script>\r\n * ```\r\n */\r\nexport function useZeno(): ZenoCMS {\r\n const client = getContext<ZenoCMS>(ZENO_KEY);\r\n if (!client) {\r\n throw new Error(\r\n 'useZeno() requires initZeno() to be called in a parent component.'\r\n );\r\n }\r\n return client;\r\n}\r\n","import { writable, derived, type Readable } from 'svelte/store';\r\nimport { onMount } from 'svelte';\r\nimport { useZeno } from './context';\r\nimport type { UseQueryResult } from './types';\r\nimport type {\r\n Entry,\r\n Collection,\r\n Asset,\r\n AssetUrl,\r\n Project,\r\n Locale,\r\n PaginationParams,\r\n FilterParams,\r\n} from '../types';\r\n\r\n/**\r\n * Internal helper: wraps an async SDK call with reactive Svelte stores.\r\n * Auto-fetches on creation and exposes a refresh function.\r\n */\r\nfunction useAsyncQuery<T>(\r\n fetcher: () => Promise<{ data: T | null; error: string | null }>\r\n): UseQueryResult<T> {\r\n const data = writable<T | null>(null);\r\n const error = writable<string | null>(null);\r\n const loading = writable(true);\r\n\r\n const execute = async () => {\r\n loading.set(true);\r\n error.set(null);\r\n try {\r\n const result = await fetcher();\r\n data.set(result.data);\r\n error.set(result.error);\r\n } catch (err) {\r\n error.set(err instanceof Error ? err.message : String(err));\r\n data.set(null);\r\n } finally {\r\n loading.set(false);\r\n }\r\n };\r\n\r\n onMount(() => {\r\n execute();\r\n });\r\n\r\n return {\r\n data: { subscribe: data.subscribe } as Readable<T | null>,\r\n error: { subscribe: error.subscribe } as Readable<string | null>,\r\n loading: { subscribe: loading.subscribe } as Readable<boolean>,\r\n refresh: execute,\r\n };\r\n}\r\n\r\n/** Fetch entries, optionally filtered by collection slug */\r\nexport function useEntries(\r\n collectionSlug?: string,\r\n params?: PaginationParams & FilterParams\r\n): UseQueryResult<Entry[]> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getEntries(collectionSlug, params));\r\n}\r\n\r\n/** Fetch a single entry by ID */\r\nexport function useEntry(\r\n entryId: string,\r\n params?: { locale?: string; fallback_locale?: string }\r\n): UseQueryResult<Entry> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getEntry(entryId, params));\r\n}\r\n\r\n/** Fetch all collections */\r\nexport function useCollections(\r\n params?: PaginationParams\r\n): UseQueryResult<Collection[]> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getCollections(params));\r\n}\r\n\r\n/** Fetch a single collection by slug */\r\nexport function useCollection(slug: string): UseQueryResult<Collection> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getCollection(slug));\r\n}\r\n\r\n/** Fetch assets */\r\nexport function useAssets(\r\n params?: PaginationParams & { mimeType?: string }\r\n): UseQueryResult<Asset[]> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getAssets(params));\r\n}\r\n\r\n/** Get a signed download URL for an asset */\r\nexport function useAssetUrl(assetId: string): UseQueryResult<AssetUrl> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getAssetUrl(assetId));\r\n}\r\n\r\n/** Fetch project information */\r\nexport function useProject(): UseQueryResult<Project> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getProject());\r\n}\r\n\r\n/** Fetch available locales */\r\nexport function useLocales(): UseQueryResult<Locale[]> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getLocales());\r\n}\r\n"]}
package/dist/vue.d.mts ADDED
@@ -0,0 +1,72 @@
1
+ import { Ref, App } from 'vue';
2
+ import { ZenoCMS, PaginationParams, Asset, Collection, FilterParams, Entry, Locale } from './index.mjs';
3
+
4
+ /** Return type for all Zeno Vue composables */
5
+ interface UseQueryResult<T> {
6
+ /** The fetched data (reactive ref), or null if loading/error */
7
+ data: Ref<T | null>;
8
+ /** Error message (reactive ref), or null if success */
9
+ error: Ref<string | null>;
10
+ /** Whether the query is currently loading (reactive ref) */
11
+ loading: Ref<boolean>;
12
+ /** Re-execute the query */
13
+ refresh: () => void;
14
+ }
15
+ /** Options for the createZeno Vue plugin */
16
+ interface ZenoPluginOptions {
17
+ /** Zeno CMS API key (format: zeno_<projectSlug>_<token>). If omitted, reads from ZENO_API_KEY env variable. */
18
+ apiKey?: string;
19
+ /** Default fallback locale for localized content */
20
+ defaultLocale?: string;
21
+ }
22
+
23
+ /**
24
+ * Creates a Vue plugin that provides a ZenoCMS client to the entire app.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { createApp } from 'vue'
29
+ * import { createZeno } from '@zeno/sdk/vue'
30
+ * import App from './App.vue'
31
+ *
32
+ * const app = createApp(App)
33
+ * app.use(createZeno({ apiKey: 'zeno_myproject_token' }))
34
+ * app.mount('#app')
35
+ * ```
36
+ */
37
+ declare function createZeno(options?: ZenoPluginOptions): {
38
+ install(app: App): void;
39
+ };
40
+ /**
41
+ * Access the raw ZenoCMS client instance.
42
+ * Requires `createZeno` plugin to be installed.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * import { useZeno } from '@zeno/sdk/vue'
47
+ *
48
+ * const zeno = useZeno()
49
+ * await zeno.sendEmail({ ... })
50
+ * ```
51
+ */
52
+ declare function useZeno(): ZenoCMS;
53
+
54
+ /** Fetch entries, optionally filtered by collection slug */
55
+ declare function useEntries(collectionSlug?: string, params?: PaginationParams & FilterParams): UseQueryResult<Entry[]>;
56
+ /** Fetch a single entry by ID */
57
+ declare function useEntry(entryId: string, params?: {
58
+ locale?: string;
59
+ fallback_locale?: string;
60
+ }): UseQueryResult<Entry>;
61
+ /** Fetch all collections */
62
+ declare function useCollections(params?: PaginationParams): UseQueryResult<Collection[]>;
63
+ /** Fetch a single collection by slug */
64
+ declare function useCollection(slug: string): UseQueryResult<Collection>;
65
+ /** Fetch assets */
66
+ declare function useAssets(params?: PaginationParams & {
67
+ mimeType?: string;
68
+ }): UseQueryResult<Asset[]>;
69
+ /** Fetch available locales */
70
+ declare function useLocales(): UseQueryResult<Locale[]>;
71
+
72
+ export { type UseQueryResult, type ZenoPluginOptions, createZeno, useAssets, useCollection, useCollections, useEntries, useEntry, useLocales, useZeno };
package/dist/vue.d.ts ADDED
@@ -0,0 +1,72 @@
1
+ import { Ref, App } from 'vue';
2
+ import { ZenoCMS, PaginationParams, Asset, Collection, FilterParams, Entry, Locale } from './index.js';
3
+
4
+ /** Return type for all Zeno Vue composables */
5
+ interface UseQueryResult<T> {
6
+ /** The fetched data (reactive ref), or null if loading/error */
7
+ data: Ref<T | null>;
8
+ /** Error message (reactive ref), or null if success */
9
+ error: Ref<string | null>;
10
+ /** Whether the query is currently loading (reactive ref) */
11
+ loading: Ref<boolean>;
12
+ /** Re-execute the query */
13
+ refresh: () => void;
14
+ }
15
+ /** Options for the createZeno Vue plugin */
16
+ interface ZenoPluginOptions {
17
+ /** Zeno CMS API key (format: zeno_<projectSlug>_<token>). If omitted, reads from ZENO_API_KEY env variable. */
18
+ apiKey?: string;
19
+ /** Default fallback locale for localized content */
20
+ defaultLocale?: string;
21
+ }
22
+
23
+ /**
24
+ * Creates a Vue plugin that provides a ZenoCMS client to the entire app.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { createApp } from 'vue'
29
+ * import { createZeno } from '@zeno/sdk/vue'
30
+ * import App from './App.vue'
31
+ *
32
+ * const app = createApp(App)
33
+ * app.use(createZeno({ apiKey: 'zeno_myproject_token' }))
34
+ * app.mount('#app')
35
+ * ```
36
+ */
37
+ declare function createZeno(options?: ZenoPluginOptions): {
38
+ install(app: App): void;
39
+ };
40
+ /**
41
+ * Access the raw ZenoCMS client instance.
42
+ * Requires `createZeno` plugin to be installed.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * import { useZeno } from '@zeno/sdk/vue'
47
+ *
48
+ * const zeno = useZeno()
49
+ * await zeno.sendEmail({ ... })
50
+ * ```
51
+ */
52
+ declare function useZeno(): ZenoCMS;
53
+
54
+ /** Fetch entries, optionally filtered by collection slug */
55
+ declare function useEntries(collectionSlug?: string, params?: PaginationParams & FilterParams): UseQueryResult<Entry[]>;
56
+ /** Fetch a single entry by ID */
57
+ declare function useEntry(entryId: string, params?: {
58
+ locale?: string;
59
+ fallback_locale?: string;
60
+ }): UseQueryResult<Entry>;
61
+ /** Fetch all collections */
62
+ declare function useCollections(params?: PaginationParams): UseQueryResult<Collection[]>;
63
+ /** Fetch a single collection by slug */
64
+ declare function useCollection(slug: string): UseQueryResult<Collection>;
65
+ /** Fetch assets */
66
+ declare function useAssets(params?: PaginationParams & {
67
+ mimeType?: string;
68
+ }): UseQueryResult<Asset[]>;
69
+ /** Fetch available locales */
70
+ declare function useLocales(): UseQueryResult<Locale[]>;
71
+
72
+ export { type UseQueryResult, type ZenoPluginOptions, createZeno, useAssets, useCollection, useCollections, useEntries, useEntry, useLocales, useZeno };
package/dist/vue.js ADDED
@@ -0,0 +1,8 @@
1
+ 'use strict';var vue=require('vue'),supabaseJs=require('@supabase/supabase-js');var k={endpoint:"https://kvpowojjhuprhxdyzmml.supabase.co",publicKey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imt2cG93b2pqaHVwcmh4ZHl6bW1sIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTI3ODEwNzAsImV4cCI6MjA2ODM1NzA3MH0.cCPzDNdfTb3WBtYL79GBlw4hfypl4tjnqu7XfEvdKBg"};function r(n,t=null,a){let e=null;return t&&(typeof t=="string"?e=t:t instanceof Error?e=t.message:typeof t=="object"&&t!==null&&"message"in t&&(e=String(t.message))),{data:n,error:e,meta:{...a,timestamp:new Date().toISOString()}}}var A=class{constructor(t={}){this.projectId=null;this.isValidated=false;this.resolvedDefaultLocale=null;let a=t.apiKey||this.getEnvApiKey();if(!a)throw new Error("Missing API key. Provide it via config.apiKey or set an environment variable: ZENO_API_KEY, VITE_ZENO_API_KEY, NEXT_PUBLIC_ZENO_API_KEY, or PUBLIC_ZENO_API_KEY.");let e=this.parseApiKey(a);this.apiKey=a,this.projectSlug=e.projectSlug,this.apiToken=e.token,this.configDefaultLocale=t.defaultLocale,this.supabase=supabaseJs.createClient(k.endpoint,k.publicKey,{auth:{persistSession:false,autoRefreshToken:false}});}getEnvApiKey(){let t=["ZENO_API_KEY","NEXT_PUBLIC_ZENO_API_KEY","VITE_ZENO_API_KEY","PUBLIC_ZENO_API_KEY"],a=["ZENO_API_KEY","VITE_ZENO_API_KEY","PUBLIC_ZENO_API_KEY","NEXT_PUBLIC_ZENO_API_KEY"];if(typeof process<"u"&&process.env){for(let e of t)if(process.env[e])return process.env[e]}try{let e=undefined;if(e){for(let s of a)if(e[s])return e[s]}}catch{}}parseApiKey(t){if(!t.startsWith("zeno_"))throw new Error("Invalid API key format. Expected: zeno_<projectSlug>_<token>");let a=t.slice(5),e=a.indexOf("_");if(e===-1)throw new Error("Invalid API key format. Expected: zeno_<projectSlug>_<token>");let s=a.slice(0,e),o=a.slice(e+1);if(!s||!o)throw new Error("Invalid API key format. Expected: zeno_<projectSlug>_<token>");return {projectSlug:s,token:o}}async getDefaultLocale(){if(this.configDefaultLocale)return this.configDefaultLocale;if(this.resolvedDefaultLocale)return this.resolvedDefaultLocale;try{let t=await this.resolveProjectId(),{data:a}=await this.supabase.from("project_locales").select("locale_code").eq("project_id",t).eq("is_default",!0).single();if(a?.locale_code)return this.resolvedDefaultLocale=a.locale_code,a.locale_code}catch{}return this.resolvedDefaultLocale="en","en"}async resolveProjectId(){if(this.projectId&&this.isValidated)return this.projectId;let{data:t,error:a}=await this.supabase.rpc("validate_sdk_api_key",{p_project_slug:this.projectSlug,p_token:this.apiToken});if(a)throw new Error("API key validation failed: "+a.message);let e=t?.[0];if(!e||!e.is_valid)throw new Error(e?.error_message||"Invalid API key or project not found");return this.projectId=e.project_id,this.isValidated=true,e.project_id}async getProject(){try{let t=await this.resolveProjectId(),{data:a,error:e}=await this.supabase.from("projects").select("id, name, description, slug, status, created_at, updated_at").eq("id",t).single();return r(a,e)}catch(t){return r(null,t)}}async getCollections(t={}){try{let a=await this.resolveProjectId(),{page:e=1,limit:s=50,sortBy:o="created_at",sortOrder:g="desc"}=t,m=(e-1)*s,{count:u}=await this.supabase.from("collections").select("*",{count:"exact",head:!0}).eq("project_id",a),{data:l,error:d}=await this.supabase.from("collections").select("id, name, slug, description, fields, created_at, updated_at").eq("project_id",a).order(o,{ascending:g==="asc"}).range(m,m+s-1),h=l?.map(i=>({...i,fields:typeof i.fields=="string"?JSON.parse(i.fields):i.fields}));return r(h,d,{total:u||0,page:e,limit:s,totalPages:Math.ceil((u||0)/s)})}catch(a){return r(null,a)}}async getCollection(t){try{let a=await this.resolveProjectId(),{data:e,error:s}=await this.supabase.from("collections").select("id, name, slug, description, fields, created_at, updated_at").eq("project_id",a).eq("slug",t).single(),o=e?{...e,fields:typeof e.fields=="string"?JSON.parse(e.fields):e.fields}:null;return r(o,s)}catch(a){return r(null,a)}}async getEntries(t,a={}){try{let e=await this.resolveProjectId(),{page:s=1,limit:o=50,sortBy:g="created_at",sortOrder:m="desc",status:u,search:l,locale:d,fallback_locale:h,dateFrom:i,dateTo:y,dateField:p}=a,v=h||await this.getDefaultLocale(),L=(s-1)*o,f=this.supabase.from("entries").select(`
2
+ id, data, status, collection_id, project_id, created_at, updated_at,
3
+ collections ( id, name, slug )
4
+ `).eq("project_id",e);if(t){let{data:c}=await this.supabase.from("collections").select("id").eq("project_id",e).eq("slug",t).single();if(!c)return r(null,"Collection not found");f=f.eq("collection_id",c.id);}u&&(f=f.eq("status",u)),l&&(f=f.textSearch("data",l)),i&&(f=p?f.gte(`data->${p}`,i):f.gte("created_at",i)),y&&(f=p?f.lte(`data->${p}`,y):f.lte("created_at",y));let _=this.supabase.from("entries").select("*",{count:"exact",head:!0}).eq("project_id",e);if(t){let{data:c}=await this.supabase.from("collections").select("id").eq("project_id",e).eq("slug",t).single();c&&(_=_.eq("collection_id",c.id));}u&&(_=_.eq("status",u)),l&&(_=_.textSearch("data",l)),i&&(_=p?_.gte(`data->${p}`,i):_.gte("created_at",i)),y&&(_=p?_.lte(`data->${p}`,y):_.lte("created_at",y));let{count:K}=await _,{data:U,error:q}=await f.order(g,{ascending:m==="asc"}).range(L,L+o-1);if(q)throw q;let I=(U??[]).map(c=>({...c,collections:Array.isArray(c.collections)?c.collections[0]:c.collections})),O=I,N=!1;if(d&&I.length>0)try{let c=I.map(w=>w.id),Z=await this.supabase.rpc("get_localized_entries_batch",{entry_uuids:c,locale:d,fallback_locale:v});if(Z.data&&Z.data.length>0){let w=new Map;for(let P of Z.data)w.set(P.entry_id,{data:P.data,locale_code:P.locale_code,is_fallback:P.is_fallback});O=I.map(P=>{let b=w.get(P.id);return b?(b.is_fallback&&(N=!0),{...P,data:b.data,locale_code:b.locale_code}):P});}}catch{}let{data:T}=await this.supabase.from("project_locales").select("locale_code").eq("project_id",e).eq("is_active",!0);return r(O,null,{total:K||0,page:s,limit:o,totalPages:Math.ceil((K||0)/o),locale:d||v,fallback_used:N,available_locales:T?.map(c=>c.locale_code)||[]})}catch(e){return r(null,e)}}async getEntry(t,a={}){try{let e=await this.resolveProjectId(),{locale:s,fallback_locale:o}=a,g=o||await this.getDefaultLocale(),{data:m,error:u}=await this.supabase.from("entries").select(`
5
+ id, data, status, collection_id, project_id, created_at, updated_at,
6
+ collections ( id, name, slug, fields )
7
+ `).eq("project_id",e).eq("id",t).single();if(u)throw u;let l=m,d=l?{...l,collections:Array.isArray(l.collections)?l.collections[0]:l.collections}:null,h=d,i=!1;if(s&&d)try{let p=await this.supabase.rpc("get_localized_entry",{entry_uuid:t,locale:s,fallback_locale:g});if(p.data?.[0]){let v=p.data[0];v.locale_code!==s&&(i=!0),h={...d,data:v.data,locale_code:v.locale_code};}}catch{}let{data:y}=await this.supabase.from("project_locales").select("locale_code").eq("project_id",e).eq("is_active",!0);return r(h,null,{locale:s||g,fallback_used:i,available_locales:y?.map(p=>p.locale_code)||[]})}catch(e){return r(null,e)}}async getAssets(t={}){try{let a=await this.resolveProjectId(),{page:e=1,limit:s=50,sortBy:o="created_at",sortOrder:g="desc",mimeType:m}=t,u=(e-1)*s,l=this.supabase.from("assets").select("id, filename, original_filename, mime_type, size_bytes, metadata, created_at").eq("project_id",a);m&&(l=l.like("mime_type",`${m}%`));let d=this.supabase.from("assets").select("*",{count:"exact",head:!0}).eq("project_id",a);m&&(d=d.like("mime_type",`${m}%`));let{count:h}=await d,{data:i,error:y}=await l.order(o,{ascending:g==="asc"}).range(u,u+s-1);return r(i,y,{total:h||0,page:e,limit:s,totalPages:Math.ceil((h||0)/s)})}catch(a){return r(null,a)}}async getAssetUrl(t){try{let a=await this.resolveProjectId(),{data:e,error:s}=await this.supabase.from("assets").select("storage_path").eq("project_id",a).eq("id",t).single();if(s||!e)return r(null,"Asset not found");let{data:o,error:g}=await this.supabase.storage.from("assets").createSignedUrl(e.storage_path,3600);return g?r(null,g):r({downloadUrl:o.signedUrl,expiresIn:3600})}catch(a){return r(null,a)}}async sendEmail(t){try{let a=await fetch(`${k.endpoint}/functions/v1/api/email/send`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"X-API-Key":this.apiKey,"Content-Type":"application/json"},body:JSON.stringify(t)}),e=await a.json();return a.ok?r(e.data):r(null,e.error||"Email sending failed")}catch(a){return r(null,a)}}async getLocales(){try{let t=await this.resolveProjectId(),{data:a,error:e}=await this.supabase.from("project_locales").select("locale_code, locale_name, locale_native_name, is_default").eq("project_id",t).eq("is_active",!0).order("is_default",{ascending:!1}).order("locale_name",{ascending:!0});if(e)throw e;let s=a?.map(o=>({code:o.locale_code,name:o.locale_name,native_name:o.locale_native_name,is_default:o.is_default}))||[];return r(s)}catch(t){return r(null,t)}}async health(){return r({status:"healthy",version:"1.0.0"})}};var R=Symbol("zeno");function D(n={}){let t=new A({apiKey:n.apiKey,defaultLocale:n.defaultLocale});return {install(a){a.provide(R,t);}}}function E(){let n=vue.inject(R);if(!n)throw new Error("useZeno() requires the Zeno plugin. Call app.use(createZeno({ ... })) first.");return n}function j(n){let t=vue.ref(null),a=vue.ref(null),e=vue.ref(true),s=async()=>{e.value=true,a.value=null;try{let o=await n();t.value=o.data,a.value=o.error;}catch(o){a.value=o instanceof Error?o.message:String(o),t.value=null;}finally{e.value=false;}};return vue.onMounted(s),{data:t,error:a,loading:e,refresh:s}}function Y(n,t){let a=E();return j(()=>a.getEntries(n,t))}function Q(n,t){let a=E();return j(()=>a.getEntry(n,t))}function B(n){let t=E();return j(()=>t.getCollections(n))}function M(n){let t=E();return j(()=>t.getCollection(n))}function F(n){let t=E();return j(()=>t.getAssets(n))}function $(){let n=E();return j(()=>n.getLocales())}exports.createZeno=D;exports.useAssets=F;exports.useCollection=M;exports.useCollections=B;exports.useEntries=Y;exports.useEntry=Q;exports.useLocales=$;exports.useZeno=E;//# sourceMappingURL=vue.js.map
8
+ //# sourceMappingURL=vue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client.ts","../src/vue/plugin.ts","../src/vue/composables.ts"],"names":["ZENO_INTERNAL","createResponse","data","error","meta","errorMessage","ZenoCMS","config","apiKey","parsed","createClient","processEnvKeys","importMetaKeys","key","metaEnv","withoutPrefix","separatorIndex","projectSlug","token","projectId","result","params","page","limit","sortBy","sortOrder","offset","count","processedData","c","slug","collectionSlug","status","search","locale","fallback_locale","dateFrom","dateTo","dateField","effectiveFallback","query","collection","countQuery","normalized","row","fallbackUsed","entryIds","e","localeMap","loc","entry","localized","availableLocales","l","entryId","mimeType","assetId","asset","assetError","urlData","urlError","emailParams","response","ZENO_KEY","createZeno","options","client","app","useZeno","inject","useAsyncQuery","fetcher","ref","loading","execute","err","onMounted","useEntries","zeno","useEntry","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AMQ,CAAAA,CAAK,SAASxB,CAAAA,CAASjC,CAAM,CAAC,CAC3D,CAGO,SAAS2D,CAAAA,CACd3D,CAAAA,CAC8B,CAC9B,IAAMyD,CAAAA,CAAOV,GAAQ,CACrB,OAAOE,EAAc,IAAMQ,CAAAA,CAAK,cAAA,CAAezD,CAAM,CAAC,CACxD,CAGO,SAAS4D,CAAAA,CAAcnD,EAA0C,CACtE,IAAMgD,EAAOV,CAAAA,EAAQ,CACrB,OAAOE,CAAAA,CAAc,IAAMQ,EAAK,aAAA,CAAchD,CAAI,CAAC,CACrD,CAGO,SAASoD,CAAAA,CACd7D,CAAAA,CACyB,CACzB,IAAMyD,CAAAA,CAAOV,CAAAA,GACb,OAAOE,CAAAA,CAAc,IAAMQ,CAAAA,CAAK,SAAA,CAAUzD,CAAM,CAAC,CACnD,CAGO,SAAS8D,CAAAA,EAAuC,CACrD,IAAML,CAAAA,CAAOV,GAAQ,CACrB,OAAOE,EAAc,IAAMQ,CAAAA,CAAK,UAAA,EAAY,CAC9C","file":"vue.js","sourcesContent":["import { createClient, type SupabaseClient } from '@supabase/supabase-js';\r\nimport type {\r\n ZenoConfig,\r\n ZenoResponse,\r\n PaginationParams,\r\n FilterParams,\r\n EmailParams,\r\n Collection,\r\n Entry,\r\n Asset,\r\n AssetUrl,\r\n Locale,\r\n Project,\r\n HealthStatus,\r\n} from './types';\r\n\r\n// Internal configuration - injected at build time from environment variables\r\nconst ZENO_INTERNAL = {\r\n endpoint: process.env.ZENO_ENDPOINT!,\r\n publicKey: process.env.ZENO_PUBLIC_KEY!,\r\n};\r\n\r\nfunction createResponse<T>(\r\n data: T | null,\r\n error: unknown = null,\r\n meta?: Omit<NonNullable<ZenoResponse<T>['meta']>, 'timestamp'>\r\n): ZenoResponse<T> {\r\n let errorMessage: string | null = null;\r\n if (error) {\r\n if (typeof error === 'string') errorMessage = error;\r\n else if (error instanceof Error) errorMessage = error.message;\r\n else if (typeof error === 'object' && error !== null && 'message' in error) {\r\n errorMessage = String((error as { message: unknown }).message);\r\n }\r\n }\r\n\r\n return {\r\n data,\r\n error: errorMessage,\r\n meta: {\r\n ...meta,\r\n timestamp: new Date().toISOString(),\r\n },\r\n };\r\n}\r\n\r\nexport class ZenoCMS {\r\n private supabase: SupabaseClient;\r\n private apiKey: string;\r\n private projectSlug: string;\r\n private apiToken: string;\r\n private projectId: string | null = null;\r\n private isValidated: boolean = false;\r\n private configDefaultLocale: string | undefined;\r\n private resolvedDefaultLocale: string | null = null;\r\n\r\n constructor(config: ZenoConfig = {}) {\r\n // Resolve API key: explicit config > environment variable\r\n const apiKey = config.apiKey || this.getEnvApiKey();\r\n\r\n if (!apiKey) {\r\n throw new Error(\r\n 'Missing API key. Provide it via config.apiKey or set an environment variable: ' +\r\n 'ZENO_API_KEY, VITE_ZENO_API_KEY, NEXT_PUBLIC_ZENO_API_KEY, or PUBLIC_ZENO_API_KEY.'\r\n );\r\n }\r\n\r\n // Parse and validate API key format: zeno_<projectSlug>_<token>\r\n const parsed = this.parseApiKey(apiKey);\r\n this.apiKey = apiKey;\r\n this.projectSlug = parsed.projectSlug;\r\n this.apiToken = parsed.token;\r\n this.configDefaultLocale = config.defaultLocale;\r\n\r\n this.supabase = createClient(ZENO_INTERNAL.endpoint, ZENO_INTERNAL.publicKey, {\r\n auth: {\r\n persistSession: false,\r\n autoRefreshToken: false,\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Reads the API key from environment variables.\r\n * Checks multiple naming conventions so each framework only needs one .env variable:\r\n * ZENO_API_KEY — Node.js / server-side\r\n * NEXT_PUBLIC_ZENO_API_KEY — Next.js client\r\n * VITE_ZENO_API_KEY — Vite (React, Vue, Svelte)\r\n * PUBLIC_ZENO_API_KEY — Astro client\r\n */\r\n private getEnvApiKey(): string | undefined {\r\n const processEnvKeys = [\r\n 'ZENO_API_KEY',\r\n 'NEXT_PUBLIC_ZENO_API_KEY',\r\n 'VITE_ZENO_API_KEY',\r\n 'PUBLIC_ZENO_API_KEY',\r\n ];\r\n\r\n const importMetaKeys = [\r\n 'ZENO_API_KEY',\r\n 'VITE_ZENO_API_KEY',\r\n 'PUBLIC_ZENO_API_KEY',\r\n 'NEXT_PUBLIC_ZENO_API_KEY',\r\n ];\r\n\r\n // Node.js / Next.js (process.env)\r\n if (typeof process !== 'undefined' && process.env) {\r\n for (const key of processEnvKeys) {\r\n if (process.env[key]) return process.env[key];\r\n }\r\n }\r\n\r\n // Vite / Astro / SvelteKit (import.meta.env)\r\n try {\r\n // @ts-expect-error - import.meta.env may not exist in all environments\r\n const metaEnv = import.meta?.env;\r\n if (metaEnv) {\r\n for (const key of importMetaKeys) {\r\n if (metaEnv[key]) return metaEnv[key];\r\n }\r\n }\r\n } catch {\r\n // import.meta not available\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Parse and validate the API key format.\r\n * Expected format: zeno_<projectSlug>_<token>\r\n */\r\n private parseApiKey(apiKey: string): { projectSlug: string; token: string } {\r\n if (!apiKey.startsWith('zeno_')) {\r\n throw new Error('Invalid API key format. Expected: zeno_<projectSlug>_<token>');\r\n }\r\n\r\n const withoutPrefix = apiKey.slice(5); // Remove 'zeno_'\r\n const separatorIndex = withoutPrefix.indexOf('_');\r\n\r\n if (separatorIndex === -1) {\r\n throw new Error('Invalid API key format. Expected: zeno_<projectSlug>_<token>');\r\n }\r\n\r\n const projectSlug = withoutPrefix.slice(0, separatorIndex);\r\n const token = withoutPrefix.slice(separatorIndex + 1);\r\n\r\n if (!projectSlug || !token) {\r\n throw new Error('Invalid API key format. Expected: zeno_<projectSlug>_<token>');\r\n }\r\n\r\n return { projectSlug, token };\r\n }\r\n\r\n /**\r\n * Returns the fallback locale to use.\r\n * Priority: config.defaultLocale > project's default locale from DB > 'en'.\r\n */\r\n private async getDefaultLocale(): Promise<string> {\r\n if (this.configDefaultLocale) return this.configDefaultLocale;\r\n if (this.resolvedDefaultLocale) return this.resolvedDefaultLocale;\r\n\r\n try {\r\n const projectId = await this.resolveProjectId();\r\n const { data } = await this.supabase\r\n .from('project_locales')\r\n .select('locale_code')\r\n .eq('project_id', projectId)\r\n .eq('is_default', true)\r\n .single();\r\n\r\n if (data?.locale_code) {\r\n this.resolvedDefaultLocale = data.locale_code;\r\n return data.locale_code;\r\n }\r\n } catch {\r\n // Fall through to 'en'\r\n }\r\n\r\n this.resolvedDefaultLocale = 'en';\r\n return 'en';\r\n }\r\n\r\n /**\r\n * Resolves and validates the project ID using the API key.\r\n * Validates the token server-side for security.\r\n */\r\n private async resolveProjectId(): Promise<string> {\r\n // Return cached project ID if already validated\r\n if (this.projectId && this.isValidated) return this.projectId;\r\n\r\n // Call server-side validation function\r\n const { data, error } = await this.supabase.rpc('validate_sdk_api_key', {\r\n p_project_slug: this.projectSlug,\r\n p_token: this.apiToken,\r\n });\r\n\r\n if (error) {\r\n throw new Error('API key validation failed: ' + error.message);\r\n }\r\n\r\n // The RPC returns a single row with project_id, is_valid, error_message\r\n const result = data?.[0];\r\n\r\n if (!result || !result.is_valid) {\r\n throw new Error(result?.error_message || 'Invalid API key or project not found');\r\n }\r\n\r\n this.projectId = result.project_id;\r\n this.isValidated = true;\r\n return result.project_id;\r\n }\r\n\r\n /** Get project information */\r\n async getProject(): Promise<ZenoResponse<Project>> {\r\n try {\r\n const projectId = await this.resolveProjectId();\r\n\r\n const { data, error } = await this.supabase\r\n .from('projects')\r\n .select('id, name, description, slug, status, created_at, updated_at')\r\n .eq('id', projectId)\r\n .single();\r\n\r\n return createResponse(data, error);\r\n } catch (error) {\r\n return createResponse<Project>(null, error);\r\n }\r\n }\r\n\r\n /** Get all collections for the project */\r\n async getCollections(params: PaginationParams = {}): Promise<ZenoResponse<Collection[]>> {\r\n try {\r\n const projectId = await this.resolveProjectId();\r\n const { page = 1, limit = 50, sortBy = 'created_at', sortOrder = 'desc' } = params;\r\n const offset = (page - 1) * limit;\r\n\r\n const { count } = await this.supabase\r\n .from('collections')\r\n .select('*', { count: 'exact', head: true })\r\n .eq('project_id', projectId);\r\n\r\n const { data, error } = await this.supabase\r\n .from('collections')\r\n .select('id, name, slug, description, fields, created_at, updated_at')\r\n .eq('project_id', projectId)\r\n .order(sortBy, { ascending: sortOrder === 'asc' })\r\n .range(offset, offset + limit - 1);\r\n\r\n const processedData = data?.map((c) => ({\r\n ...c,\r\n fields: typeof c.fields === 'string' ? JSON.parse(c.fields) : c.fields,\r\n }));\r\n\r\n return createResponse(processedData as Collection[] | null, error, {\r\n total: count || 0,\r\n page,\r\n limit,\r\n totalPages: Math.ceil((count || 0) / limit),\r\n });\r\n } catch (error) {\r\n return createResponse<Collection[]>(null, error);\r\n }\r\n }\r\n\r\n /** Get a single collection by slug */\r\n async getCollection(slug: string): Promise<ZenoResponse<Collection>> {\r\n try {\r\n const projectId = await this.resolveProjectId();\r\n\r\n const { data, error } = await this.supabase\r\n .from('collections')\r\n .select('id, name, slug, description, fields, created_at, updated_at')\r\n .eq('project_id', projectId)\r\n .eq('slug', slug)\r\n .single();\r\n\r\n const processedData = data\r\n ? { ...data, fields: typeof data.fields === 'string' ? JSON.parse(data.fields) : data.fields }\r\n : null;\r\n\r\n return createResponse(processedData as Collection | null, error);\r\n } catch (error) {\r\n return createResponse<Collection>(null, error);\r\n }\r\n }\r\n\r\n /** Get entries, optionally filtered by collection slug */\r\n async getEntries(\r\n collectionSlug?: string,\r\n params: PaginationParams & FilterParams = {}\r\n ): Promise<ZenoResponse<Entry[]>> {\r\n try {\r\n const projectId = await this.resolveProjectId();\r\n const {\r\n page = 1,\r\n limit = 50,\r\n sortBy = 'created_at',\r\n sortOrder = 'desc',\r\n status,\r\n search,\r\n locale,\r\n fallback_locale,\r\n dateFrom,\r\n dateTo,\r\n dateField,\r\n } = params;\r\n const effectiveFallback = fallback_locale || await this.getDefaultLocale();\r\n const offset = (page - 1) * limit;\r\n\r\n let query = this.supabase\r\n .from('entries')\r\n .select(`\r\n id, data, status, collection_id, project_id, created_at, updated_at,\r\n collections ( id, name, slug )\r\n `)\r\n .eq('project_id', projectId);\r\n\r\n // Filter by collection\r\n if (collectionSlug) {\r\n const { data: collection } = await this.supabase\r\n .from('collections')\r\n .select('id')\r\n .eq('project_id', projectId)\r\n .eq('slug', collectionSlug)\r\n .single();\r\n\r\n if (!collection) {\r\n return createResponse<Entry[]>(null, 'Collection not found');\r\n }\r\n query = query.eq('collection_id', collection.id);\r\n }\r\n\r\n if (status) query = query.eq('status', status);\r\n if (search) query = query.textSearch('data', search);\r\n\r\n // Date filtering: use dateField inside data if specified, otherwise use created_at\r\n if (dateFrom) {\r\n query = dateField\r\n ? query.gte(`data->${dateField}`, dateFrom)\r\n : query.gte('created_at', dateFrom);\r\n }\r\n if (dateTo) {\r\n query = dateField\r\n ? query.lte(`data->${dateField}`, dateTo)\r\n : query.lte('created_at', dateTo);\r\n }\r\n\r\n // Count query\r\n let countQuery = this.supabase\r\n .from('entries')\r\n .select('*', { count: 'exact', head: true })\r\n .eq('project_id', projectId);\r\n\r\n if (collectionSlug) {\r\n const { data: collection } = await this.supabase\r\n .from('collections')\r\n .select('id')\r\n .eq('project_id', projectId)\r\n .eq('slug', collectionSlug)\r\n .single();\r\n\r\n if (collection) countQuery = countQuery.eq('collection_id', collection.id);\r\n }\r\n if (status) countQuery = countQuery.eq('status', status);\r\n if (search) countQuery = countQuery.textSearch('data', search);\r\n\r\n // Date filtering for count query\r\n if (dateFrom) {\r\n countQuery = dateField\r\n ? countQuery.gte(`data->${dateField}`, dateFrom)\r\n : countQuery.gte('created_at', dateFrom);\r\n }\r\n if (dateTo) {\r\n countQuery = dateField\r\n ? countQuery.lte(`data->${dateField}`, dateTo)\r\n : countQuery.lte('created_at', dateTo);\r\n }\r\n\r\n const { count } = await countQuery;\r\n\r\n const { data, error } = await query\r\n .order(sortBy, { ascending: sortOrder === 'asc' })\r\n .range(offset, offset + limit - 1);\r\n\r\n if (error) throw error;\r\n\r\n // Normalize Supabase join (returns array for relations) and apply localization\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const rows = (data as any[]) ?? [];\r\n const normalized = rows.map((row) => ({\r\n ...row,\r\n collections: Array.isArray(row.collections) ? row.collections[0] : row.collections,\r\n }));\r\n\r\n let processedData = normalized;\r\n let fallbackUsed = false;\r\n\r\n if (locale && normalized.length > 0) {\r\n try {\r\n // Use batch function to avoid N+1 queries\r\n const entryIds = normalized.map((e) => e.id);\r\n const result = await this.supabase.rpc('get_localized_entries_batch', {\r\n entry_uuids: entryIds,\r\n locale,\r\n fallback_locale: effectiveFallback,\r\n });\r\n\r\n if (result.data && result.data.length > 0) {\r\n // Create a map for quick lookup\r\n const localeMap = new Map<string, { data: Record<string, unknown>; locale_code: string; is_fallback: boolean }>();\r\n for (const loc of result.data) {\r\n localeMap.set(loc.entry_id, {\r\n data: loc.data,\r\n locale_code: loc.locale_code,\r\n is_fallback: loc.is_fallback,\r\n });\r\n }\r\n\r\n // Merge localized data with entries\r\n processedData = normalized.map((entry) => {\r\n const localized = localeMap.get(entry.id);\r\n if (localized) {\r\n if (localized.is_fallback) fallbackUsed = true;\r\n return { ...entry, data: localized.data, locale_code: localized.locale_code };\r\n }\r\n return entry;\r\n });\r\n }\r\n } catch {\r\n // Fallback to base data if batch function fails\r\n }\r\n }\r\n\r\n // Available locales\r\n const { data: availableLocales } = await this.supabase\r\n .from('project_locales')\r\n .select('locale_code')\r\n .eq('project_id', projectId)\r\n .eq('is_active', true);\r\n\r\n return createResponse(processedData as Entry[] | null, null, {\r\n total: count || 0,\r\n page,\r\n limit,\r\n totalPages: Math.ceil((count || 0) / limit),\r\n locale: locale || effectiveFallback,\r\n fallback_used: fallbackUsed,\r\n available_locales: availableLocales?.map((l) => l.locale_code) || [],\r\n });\r\n } catch (error) {\r\n return createResponse<Entry[]>(null, error);\r\n }\r\n }\r\n\r\n /** Get a single entry by ID */\r\n async getEntry(\r\n entryId: string,\r\n params: { locale?: string; fallback_locale?: string } = {}\r\n ): Promise<ZenoResponse<Entry>> {\r\n try {\r\n const projectId = await this.resolveProjectId();\r\n const { locale, fallback_locale } = params;\r\n const effectiveFallback = fallback_locale || await this.getDefaultLocale();\r\n\r\n const { data, error } = await this.supabase\r\n .from('entries')\r\n .select(`\r\n id, data, status, collection_id, project_id, created_at, updated_at,\r\n collections ( id, name, slug, fields )\r\n `)\r\n .eq('project_id', projectId)\r\n .eq('id', entryId)\r\n .single();\r\n\r\n if (error) throw error;\r\n\r\n // Normalize Supabase join (returns array for relations)\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const row = data as any;\r\n const normalized = row ? {\r\n ...row,\r\n collections: Array.isArray(row.collections) ? row.collections[0] : row.collections,\r\n } : null;\r\n\r\n let processedData = normalized;\r\n let fallbackUsed = false;\r\n\r\n if (locale && normalized) {\r\n try {\r\n const result = await this.supabase.rpc('get_localized_entry', {\r\n entry_uuid: entryId,\r\n locale,\r\n fallback_locale: effectiveFallback,\r\n });\r\n\r\n if (result.data?.[0]) {\r\n const localized = result.data[0];\r\n if (localized.locale_code !== locale) fallbackUsed = true;\r\n processedData = { ...normalized, data: localized.data, locale_code: localized.locale_code };\r\n }\r\n } catch {\r\n // Fallback to base data\r\n }\r\n }\r\n\r\n const { data: availableLocales } = await this.supabase\r\n .from('project_locales')\r\n .select('locale_code')\r\n .eq('project_id', projectId)\r\n .eq('is_active', true);\r\n\r\n return createResponse(processedData as Entry | null, null, {\r\n locale: locale || effectiveFallback,\r\n fallback_used: fallbackUsed,\r\n available_locales: availableLocales?.map((l) => l.locale_code) || [],\r\n });\r\n } catch (error) {\r\n return createResponse<Entry>(null, error);\r\n }\r\n }\r\n\r\n /** Get assets for the project */\r\n async getAssets(\r\n params: PaginationParams & { mimeType?: string } = {}\r\n ): Promise<ZenoResponse<Asset[]>> {\r\n try {\r\n const projectId = await this.resolveProjectId();\r\n const { page = 1, limit = 50, sortBy = 'created_at', sortOrder = 'desc', mimeType } = params;\r\n const offset = (page - 1) * limit;\r\n\r\n let query = this.supabase\r\n .from('assets')\r\n .select('id, filename, original_filename, mime_type, size_bytes, metadata, created_at')\r\n .eq('project_id', projectId);\r\n\r\n if (mimeType) query = query.like('mime_type', `${mimeType}%`);\r\n\r\n let countQuery = this.supabase\r\n .from('assets')\r\n .select('*', { count: 'exact', head: true })\r\n .eq('project_id', projectId);\r\n\r\n if (mimeType) countQuery = countQuery.like('mime_type', `${mimeType}%`);\r\n\r\n const { count } = await countQuery;\r\n\r\n const { data, error } = await query\r\n .order(sortBy, { ascending: sortOrder === 'asc' })\r\n .range(offset, offset + limit - 1);\r\n\r\n return createResponse(data as Asset[] | null, error, {\r\n total: count || 0,\r\n page,\r\n limit,\r\n totalPages: Math.ceil((count || 0) / limit),\r\n });\r\n } catch (error) {\r\n return createResponse<Asset[]>(null, error);\r\n }\r\n }\r\n\r\n /** Get a signed download URL for an asset */\r\n async getAssetUrl(assetId: string): Promise<ZenoResponse<AssetUrl>> {\r\n try {\r\n const projectId = await this.resolveProjectId();\r\n\r\n const { data: asset, error: assetError } = await this.supabase\r\n .from('assets')\r\n .select('storage_path')\r\n .eq('project_id', projectId)\r\n .eq('id', assetId)\r\n .single();\r\n\r\n if (assetError || !asset) {\r\n return createResponse<AssetUrl>(null, 'Asset not found');\r\n }\r\n\r\n const { data: urlData, error: urlError } = await this.supabase\r\n .storage\r\n .from('assets')\r\n .createSignedUrl(asset.storage_path, 3600);\r\n\r\n if (urlError) {\r\n return createResponse<AssetUrl>(null, urlError);\r\n }\r\n\r\n return createResponse<AssetUrl>({\r\n downloadUrl: urlData.signedUrl,\r\n expiresIn: 3600,\r\n });\r\n } catch (error) {\r\n return createResponse<AssetUrl>(null, error);\r\n }\r\n }\r\n\r\n /** Send an email via the Zeno edge function */\r\n async sendEmail(emailParams: EmailParams): Promise<ZenoResponse<{ messageId: string }>> {\r\n try {\r\n const response = await fetch(`${ZENO_INTERNAL.endpoint}/functions/v1/api/email/send`, {\r\n method: 'POST',\r\n headers: {\r\n 'Authorization': `Bearer ${this.apiKey}`,\r\n 'X-API-Key': this.apiKey,\r\n 'Content-Type': 'application/json',\r\n },\r\n body: JSON.stringify(emailParams),\r\n });\r\n\r\n const result = await response.json();\r\n\r\n if (!response.ok) {\r\n return createResponse<{ messageId: string }>(null, result.error || 'Email sending failed');\r\n }\r\n\r\n return createResponse(result.data);\r\n } catch (error) {\r\n return createResponse<{ messageId: string }>(null, error);\r\n }\r\n }\r\n\r\n /** Get available locales for the project */\r\n async getLocales(): Promise<ZenoResponse<Locale[]>> {\r\n try {\r\n const projectId = await this.resolveProjectId();\r\n\r\n const { data, error } = await this.supabase\r\n .from('project_locales')\r\n .select('locale_code, locale_name, locale_native_name, is_default')\r\n .eq('project_id', projectId)\r\n .eq('is_active', true)\r\n .order('is_default', { ascending: false })\r\n .order('locale_name', { ascending: true });\r\n\r\n if (error) throw error;\r\n\r\n const processedData = data?.map((l) => ({\r\n code: l.locale_code,\r\n name: l.locale_name,\r\n native_name: l.locale_native_name,\r\n is_default: l.is_default,\r\n })) || [];\r\n\r\n return createResponse<Locale[]>(processedData);\r\n } catch (error) {\r\n return createResponse<Locale[]>(null, error);\r\n }\r\n }\r\n\r\n /** Health check */\r\n async health(): Promise<ZenoResponse<HealthStatus>> {\r\n return createResponse<HealthStatus>({\r\n status: 'healthy',\r\n version: '1.0.0',\r\n });\r\n }\r\n}\r\n","import type { App, InjectionKey } from 'vue';\r\nimport { inject } from 'vue';\r\nimport { ZenoCMS } from '../client';\r\nimport type { ZenoPluginOptions } from './types';\r\n\r\nconst ZENO_KEY: InjectionKey<ZenoCMS> = Symbol('zeno');\r\n\r\n/**\r\n * Creates a Vue plugin that provides a ZenoCMS client to the entire app.\r\n *\r\n * @example\r\n * ```ts\r\n * import { createApp } from 'vue'\r\n * import { createZeno } from '@zeno/sdk/vue'\r\n * import App from './App.vue'\r\n *\r\n * const app = createApp(App)\r\n * app.use(createZeno({ apiKey: 'zeno_myproject_token' }))\r\n * app.mount('#app')\r\n * ```\r\n */\r\nexport function createZeno(options: ZenoPluginOptions = {}) {\r\n const client = new ZenoCMS({\r\n apiKey: options.apiKey,\r\n defaultLocale: options.defaultLocale,\r\n });\r\n\r\n return {\r\n install(app: App) {\r\n app.provide(ZENO_KEY, client);\r\n },\r\n };\r\n}\r\n\r\n/**\r\n * Access the raw ZenoCMS client instance.\r\n * Requires `createZeno` plugin to be installed.\r\n *\r\n * @example\r\n * ```ts\r\n * import { useZeno } from '@zeno/sdk/vue'\r\n *\r\n * const zeno = useZeno()\r\n * await zeno.sendEmail({ ... })\r\n * ```\r\n */\r\nexport function useZeno(): ZenoCMS {\r\n const client = inject(ZENO_KEY);\r\n if (!client) {\r\n throw new Error(\r\n 'useZeno() requires the Zeno plugin. Call app.use(createZeno({ ... })) first.'\r\n );\r\n }\r\n return client;\r\n}\r\n","import { ref, onMounted } from 'vue';\r\nimport type { Ref } from 'vue';\r\nimport { useZeno } from './plugin';\r\nimport type { UseQueryResult } from './types';\r\nimport type {\r\n Entry,\r\n Collection,\r\n Asset,\r\n Locale,\r\n PaginationParams,\r\n FilterParams,\r\n} from '../types';\r\n\r\n/**\r\n * Internal helper: wraps an async SDK call with reactive loading/error state.\r\n * Executes automatically on mount and exposes a refresh function.\r\n */\r\nfunction useAsyncQuery<T>(\r\n fetcher: () => Promise<{ data: T | null; error: string | null }>\r\n): UseQueryResult<T> {\r\n const data = ref<T | null>(null) as Ref<T | null>;\r\n const error = ref<string | null>(null);\r\n const loading = ref(true);\r\n\r\n const execute = async () => {\r\n loading.value = true;\r\n error.value = null;\r\n try {\r\n const result = await fetcher();\r\n data.value = result.data;\r\n error.value = result.error;\r\n } catch (err) {\r\n error.value = err instanceof Error ? err.message : String(err);\r\n data.value = null;\r\n } finally {\r\n loading.value = false;\r\n }\r\n };\r\n\r\n onMounted(execute);\r\n\r\n return { data, error, loading, refresh: execute };\r\n}\r\n\r\n/** Fetch entries, optionally filtered by collection slug */\r\nexport function useEntries(\r\n collectionSlug?: string,\r\n params?: PaginationParams & FilterParams\r\n): UseQueryResult<Entry[]> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getEntries(collectionSlug, params));\r\n}\r\n\r\n/** Fetch a single entry by ID */\r\nexport function useEntry(\r\n entryId: string,\r\n params?: { locale?: string; fallback_locale?: string }\r\n): UseQueryResult<Entry> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getEntry(entryId, params));\r\n}\r\n\r\n/** Fetch all collections */\r\nexport function useCollections(\r\n params?: PaginationParams\r\n): UseQueryResult<Collection[]> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getCollections(params));\r\n}\r\n\r\n/** Fetch a single collection by slug */\r\nexport function useCollection(slug: string): UseQueryResult<Collection> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getCollection(slug));\r\n}\r\n\r\n/** Fetch assets */\r\nexport function useAssets(\r\n params?: PaginationParams & { mimeType?: string }\r\n): UseQueryResult<Asset[]> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getAssets(params));\r\n}\r\n\r\n/** Fetch available locales */\r\nexport function useLocales(): UseQueryResult<Locale[]> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getLocales());\r\n}\r\n"]}
package/dist/vue.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import {a}from'./chunk-4ROHQDX7.mjs';import {inject,ref,onMounted}from'vue';var c=Symbol("zeno");function y(e={}){let t=new a({apiKey:e.apiKey,defaultLocale:e.defaultLocale});return {install(n){n.provide(c,t);}}}function o(){let e=inject(c);if(!e)throw new Error("useZeno() requires the Zeno plugin. Call app.use(createZeno({ ... })) first.");return e}function s(e){let t=ref(null),n=ref(null),l=ref(true),i=async()=>{l.value=true,n.value=null;try{let r=await e();t.value=r.data,n.value=r.error;}catch(r){n.value=r instanceof Error?r.message:String(r),t.value=null;}finally{l.value=false;}};return onMounted(i),{data:t,error:n,loading:l,refresh:i}}function m(e,t){let n=o();return s(()=>n.getEntries(e,t))}function g(e,t){let n=o();return s(()=>n.getEntry(e,t))}function Z(e){let t=o();return s(()=>t.getCollections(e))}function P(e){let t=o();return s(()=>t.getCollection(e))}function C(e){let t=o();return s(()=>t.getAssets(e))}function E(){let e=o();return s(()=>e.getLocales())}export{y as createZeno,C as useAssets,P as useCollection,Z as useCollections,m as useEntries,g as useEntry,E as useLocales,o as useZeno};//# sourceMappingURL=vue.mjs.map
2
+ //# sourceMappingURL=vue.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vue/plugin.ts","../src/vue/composables.ts"],"names":["ZENO_KEY","createZeno","options","client","ZenoCMS","app","useZeno","inject","useAsyncQuery","fetcher","data","ref","error","loading","execute","result","err","onMounted","useEntries","collectionSlug","params","zeno","useEntry","entryId","useCollections","useCollection","slug","useAssets","useLocales"],"mappings":"4EAKA,IAAMA,CAAAA,CAAkC,MAAA,CAAO,MAAM,CAAA,CAgB9C,SAASC,CAAAA,CAAWC,CAAAA,CAA6B,EAAC,CAAG,CAC1D,IAAMC,CAAAA,CAAS,IAAIC,CAAAA,CAAQ,CACzB,MAAA,CAAQF,CAAAA,CAAQ,MAAA,CAChB,aAAA,CAAeA,CAAAA,CAAQ,aACzB,CAAC,CAAA,CAED,OAAO,CACL,QAAQG,CAAAA,CAAU,CAChBA,CAAAA,CAAI,OAAA,CAAQL,CAAAA,CAAUG,CAAM,EAC9B,CACF,CACF,CAcO,SAASG,CAAAA,EAAmB,CACjC,IAAMH,CAAAA,CAASI,MAAAA,CAAOP,CAAQ,CAAA,CAC9B,GAAI,CAACG,CAAAA,CACH,MAAM,IAAI,KAAA,CACR,8EACF,CAAA,CAEF,OAAOA,CACT,CCrCA,SAASK,CAAAA,CACPC,CAAAA,CACmB,CACnB,IAAMC,CAAAA,CAAOC,GAAAA,CAAc,IAAI,CAAA,CACzBC,CAAAA,CAAQD,GAAAA,CAAmB,IAAI,CAAA,CAC/BE,CAAAA,CAAUF,GAAAA,CAAI,IAAI,CAAA,CAElBG,CAAAA,CAAU,SAAY,CAC1BD,CAAAA,CAAQ,KAAA,CAAQ,IAAA,CAChBD,CAAAA,CAAM,KAAA,CAAQ,I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cK,CAAI,CAAC,CACrD,CAGO,SAASC,CAAAA,CACdP,CAAAA,CACyB,CACzB,IAAMC,CAAAA,CAAOf,CAAAA,EAAQ,CACrB,OAAOE,CAAAA,CAAc,IAAMa,CAAAA,CAAK,SAAA,CAAUD,CAAM,CAAC,CACnD,CAGO,SAASQ,CAAAA,EAAuC,CACrD,IAAMP,CAAAA,CAAOf,CAAAA,EAAQ,CACrB,OAAOE,CAAAA,CAAc,IAAMa,CAAAA,CAAK,UAAA,EAAY,CAC9C","file":"vue.mjs","sourcesContent":["import type { App, InjectionKey } from 'vue';\r\nimport { inject } from 'vue';\r\nimport { ZenoCMS } from '../client';\r\nimport type { ZenoPluginOptions } from './types';\r\n\r\nconst ZENO_KEY: InjectionKey<ZenoCMS> = Symbol('zeno');\r\n\r\n/**\r\n * Creates a Vue plugin that provides a ZenoCMS client to the entire app.\r\n *\r\n * @example\r\n * ```ts\r\n * import { createApp } from 'vue'\r\n * import { createZeno } from '@zeno/sdk/vue'\r\n * import App from './App.vue'\r\n *\r\n * const app = createApp(App)\r\n * app.use(createZeno({ apiKey: 'zeno_myproject_token' }))\r\n * app.mount('#app')\r\n * ```\r\n */\r\nexport function createZeno(options: ZenoPluginOptions = {}) {\r\n const client = new ZenoCMS({\r\n apiKey: options.apiKey,\r\n defaultLocale: options.defaultLocale,\r\n });\r\n\r\n return {\r\n install(app: App) {\r\n app.provide(ZENO_KEY, client);\r\n },\r\n };\r\n}\r\n\r\n/**\r\n * Access the raw ZenoCMS client instance.\r\n * Requires `createZeno` plugin to be installed.\r\n *\r\n * @example\r\n * ```ts\r\n * import { useZeno } from '@zeno/sdk/vue'\r\n *\r\n * const zeno = useZeno()\r\n * await zeno.sendEmail({ ... })\r\n * ```\r\n */\r\nexport function useZeno(): ZenoCMS {\r\n const client = inject(ZENO_KEY);\r\n if (!client) {\r\n throw new Error(\r\n 'useZeno() requires the Zeno plugin. Call app.use(createZeno({ ... })) first.'\r\n );\r\n }\r\n return client;\r\n}\r\n","import { ref, onMounted } from 'vue';\r\nimport type { Ref } from 'vue';\r\nimport { useZeno } from './plugin';\r\nimport type { UseQueryResult } from './types';\r\nimport type {\r\n Entry,\r\n Collection,\r\n Asset,\r\n Locale,\r\n PaginationParams,\r\n FilterParams,\r\n} from '../types';\r\n\r\n/**\r\n * Internal helper: wraps an async SDK call with reactive loading/error state.\r\n * Executes automatically on mount and exposes a refresh function.\r\n */\r\nfunction useAsyncQuery<T>(\r\n fetcher: () => Promise<{ data: T | null; error: string | null }>\r\n): UseQueryResult<T> {\r\n const data = ref<T | null>(null) as Ref<T | null>;\r\n const error = ref<string | null>(null);\r\n const loading = ref(true);\r\n\r\n const execute = async () => {\r\n loading.value = true;\r\n error.value = null;\r\n try {\r\n const result = await fetcher();\r\n data.value = result.data;\r\n error.value = result.error;\r\n } catch (err) {\r\n error.value = err instanceof Error ? err.message : String(err);\r\n data.value = null;\r\n } finally {\r\n loading.value = false;\r\n }\r\n };\r\n\r\n onMounted(execute);\r\n\r\n return { data, error, loading, refresh: execute };\r\n}\r\n\r\n/** Fetch entries, optionally filtered by collection slug */\r\nexport function useEntries(\r\n collectionSlug?: string,\r\n params?: PaginationParams & FilterParams\r\n): UseQueryResult<Entry[]> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getEntries(collectionSlug, params));\r\n}\r\n\r\n/** Fetch a single entry by ID */\r\nexport function useEntry(\r\n entryId: string,\r\n params?: { locale?: string; fallback_locale?: string }\r\n): UseQueryResult<Entry> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getEntry(entryId, params));\r\n}\r\n\r\n/** Fetch all collections */\r\nexport function useCollections(\r\n params?: PaginationParams\r\n): UseQueryResult<Collection[]> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getCollections(params));\r\n}\r\n\r\n/** Fetch a single collection by slug */\r\nexport function useCollection(slug: string): UseQueryResult<Collection> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getCollection(slug));\r\n}\r\n\r\n/** Fetch assets */\r\nexport function useAssets(\r\n params?: PaginationParams & { mimeType?: string }\r\n): UseQueryResult<Asset[]> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getAssets(params));\r\n}\r\n\r\n/** Fetch available locales */\r\nexport function useLocales(): UseQueryResult<Locale[]> {\r\n const zeno = useZeno();\r\n return useAsyncQuery(() => zeno.getLocales());\r\n}\r\n"]}