@htlkg/data 0.0.21 → 0.0.22

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.
Files changed (59) hide show
  1. package/dist/hooks/index.d.ts +601 -94
  2. package/dist/hooks/index.js +682 -73
  3. package/dist/hooks/index.js.map +1 -1
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.js +691 -82
  6. package/dist/index.js.map +1 -1
  7. package/dist/mutations/index.js +4 -4
  8. package/dist/mutations/index.js.map +1 -1
  9. package/dist/queries/index.js +5 -5
  10. package/dist/queries/index.js.map +1 -1
  11. package/package.json +11 -12
  12. package/src/hooks/accounts/index.ts +2 -0
  13. package/src/hooks/{useAccounts.ts → accounts/useAccounts.ts} +48 -5
  14. package/src/hooks/accounts/usePaginatedAccounts.ts +166 -0
  15. package/src/hooks/brands/index.ts +2 -0
  16. package/src/hooks/{useBrands.ts → brands/useBrands.ts} +1 -1
  17. package/src/hooks/brands/usePaginatedBrands.ts +206 -0
  18. package/src/hooks/createPaginatedDataHook.ts +359 -0
  19. package/src/hooks/data-hook-errors.property.test.ts +4 -4
  20. package/src/hooks/data-hook-filters.property.test.ts +4 -4
  21. package/src/hooks/data-hooks.property.test.ts +4 -4
  22. package/src/hooks/index.ts +96 -8
  23. package/src/hooks/productInstances/index.ts +1 -0
  24. package/src/hooks/{useProductInstances.ts → productInstances/useProductInstances.ts} +9 -6
  25. package/src/hooks/products/index.ts +1 -0
  26. package/src/hooks/{useProducts.ts → products/useProducts.ts} +4 -5
  27. package/src/hooks/reservations/index.ts +2 -0
  28. package/src/hooks/reservations/usePaginatedReservations.ts +258 -0
  29. package/src/hooks/{useReservations.ts → reservations/useReservations.ts} +65 -10
  30. package/src/hooks/users/index.ts +2 -0
  31. package/src/hooks/users/usePaginatedUsers.ts +213 -0
  32. package/src/hooks/{useUsers.ts → users/useUsers.ts} +1 -1
  33. package/src/mutations/accounts/accounts.test.ts +287 -0
  34. package/src/mutations/{accounts.ts → accounts/accounts.ts} +2 -2
  35. package/src/mutations/accounts/index.ts +1 -0
  36. package/src/mutations/brands/brands.test.ts +292 -0
  37. package/src/mutations/{brands.ts → brands/brands.ts} +2 -2
  38. package/src/mutations/brands/index.ts +1 -0
  39. package/src/mutations/reservations/index.ts +1 -0
  40. package/src/mutations/{reservations.test.ts → reservations/reservations.test.ts} +1 -1
  41. package/src/mutations/{reservations.ts → reservations/reservations.ts} +2 -2
  42. package/src/mutations/users/index.ts +1 -0
  43. package/src/mutations/users/users.test.ts +289 -0
  44. package/src/mutations/{users.ts → users/users.ts} +2 -2
  45. package/src/queries/accounts/accounts.test.ts +228 -0
  46. package/src/queries/accounts/index.ts +1 -0
  47. package/src/queries/brands/brands.test.ts +288 -0
  48. package/src/queries/brands/index.ts +1 -0
  49. package/src/queries/products/index.ts +1 -0
  50. package/src/queries/products/products.test.ts +347 -0
  51. package/src/queries/reservations/index.ts +1 -0
  52. package/src/queries/users/index.ts +1 -0
  53. package/src/queries/users/users.test.ts +301 -0
  54. /package/src/queries/{accounts.ts → accounts/accounts.ts} +0 -0
  55. /package/src/queries/{brands.ts → brands/brands.ts} +0 -0
  56. /package/src/queries/{products.ts → products/products.ts} +0 -0
  57. /package/src/queries/{reservations.test.ts → reservations/reservations.test.ts} +0 -0
  58. /package/src/queries/{reservations.ts → reservations/reservations.ts} +0 -0
  59. /package/src/queries/{users.ts → users/users.ts} +0 -0
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client/index.ts","../src/client/server.ts","../src/client/proxy.ts","../src/queries/brands.ts","../src/queries/accounts.ts","../src/queries/users.ts","../src/queries/products.ts","../src/queries/server-helpers.ts","../src/queries/systemSettings.ts","../src/queries/reservations.ts","../src/queries/contacts.ts","../src/mutations/brands.ts","../src/mutations/accounts.ts","../src/mutations/users.ts","../src/mutations/productInstances/productInstances.ts","../src/mutations/systemSettings.ts","../src/mutations/reservations.ts","../src/mutations/contacts.ts","../src/hooks/createDataHook.ts","../src/hooks/useBrands.ts","../src/hooks/useAccounts.ts","../src/hooks/useUsers.ts","../src/hooks/useProducts.ts","../src/hooks/useProductInstances.ts","../src/hooks/useReservations.ts","../src/hooks/useContacts.ts","../../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/clean-stores/index.js","../../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/atom/index.js","../src/stores/createStores.ts"],"sourcesContent":["/**\n * GraphQL Client for @htlkg/data\n *\n * Provides both client-side and server-side GraphQL capabilities using AWS Amplify Data.\n * The server-side functions use the Amplify Astro adapter for proper SSR support.\n *\n * For server-side usage, use `Astro.locals.amplifyClient` (zero-config, injected by middleware).\n */\n\nimport { generateClient as generateDataClient } from \"aws-amplify/data\";\nimport { Amplify } from \"aws-amplify\";\nimport type { ResourcesConfig } from \"aws-amplify\";\nimport { generateServerClientUsingCookies } from \"./server\";\n\n// Re-export server-side client generation (used internally by middleware)\nexport { generateServerClientUsingCookies } from \"./server\";\n\n// Re-export proxy functions for authenticated client-side operations\nexport {\n\tmutate,\n\tquery,\n\thasErrors,\n\tgetErrorMessage,\n\ttype Operation,\n\ttype GraphQLResponse,\n\ttype ProxyOptions,\n} from \"./proxy\";\n\n// Re-export type-safe client-side Reservation operations\nexport {\n\tcreateReservation,\n\tupdateReservation,\n\tsoftDeleteReservation,\n\trestoreReservation,\n\tdeleteReservation,\n\tgetReservation,\n\tlistReservations,\n\tupdateReservationStatus,\n\tbulkSoftDeleteReservations,\n\tbulkRestoreReservations,\n\tbulkDeleteReservations,\n\tbulkUpdateReservationStatus,\n\ttype Reservation,\n\ttype ReservationStatus,\n} from \"./reservations\";\n\n/**\n * Type for the server-side Amplify client (for use in type declarations)\n * This represents the client returned by generateServerClientUsingCookies\n */\nexport type AmplifyServerClient<TSchema extends Record<string, unknown> = Record<string, unknown>> =\n\tReturnType<typeof generateServerClientUsingCookies<TSchema>>;\n\n// Singleton client instance for client-side fetching\nlet sharedClientInstance: any = null;\n\n/**\n * Get or create the shared GraphQL client instance (singleton pattern)\n * Use this for client-side fetching to avoid creating multiple client instances.\n *\n * @example\n * ```typescript\n * const client = getSharedClient<Schema>();\n * const { data } = await client.models.Account.list();\n * ```\n */\nexport function getSharedClient<\n\tTSchema extends Record<string, unknown> = Record<string, unknown>,\n>(): ReturnType<typeof generateDataClient<TSchema>> {\n\tif (!sharedClientInstance) {\n\t\tsharedClientInstance = generateDataClient<TSchema>();\n\t}\n\treturn sharedClientInstance;\n}\n\n/**\n * Reset the shared client instance (useful for testing or auth state changes)\n */\nexport function resetSharedClient(): void {\n\tsharedClientInstance = null;\n}\n\n/**\n * Generate a client-side GraphQL client for use in Vue components and browser contexts\n * This is SSR-safe and should be called within a component's setup function or after hydration\n *\n * @example\n * ```typescript\n * import type { Schema } from '@backend/data/resource';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const { data: brands } = await client.models.Brand.list();\n * ```\n */\nexport function generateClient<\n\tTSchema extends Record<string, unknown> = Record<string, unknown>,\n>(): ReturnType<typeof generateDataClient<TSchema>> {\n\treturn generateDataClient<TSchema>();\n}\n\n/**\n * Configuration for Amplify (matches amplify_outputs.json format)\n */\nexport type AstroAmplifyConfig = ResourcesConfig;\n\n/**\n * Authentication mode for server-side GraphQL client\n */\nexport type ServerAuthMode = 'userPool' | 'apiKey';\n\n/**\n * Options for generating a server-side GraphQL client\n */\nexport interface GenerateServerClientOptions {\n\t/** Authentication mode - 'userPool' (default) uses JWT from cookies, 'apiKey' uses API key */\n\tauthMode?: ServerAuthMode;\n}\n\n/**\n * Generate a server-side GraphQL client for use within runWithAmplifyServerContext\n * \n * This function creates a GraphQL client that can be used for server-side data fetching in Astro.\n * It MUST be called within runWithAmplifyServerContext to access JWT tokens from cookies.\n * \n * The client supports two authentication modes:\n * - 'userPool' (default): Uses JWT tokens from cookies (requires runWithAmplifyServerContext)\n * - 'apiKey': Uses API key for public/unauthenticated requests\n *\n * **Important**: \n * - Amplify.configure() must be called once at app startup (e.g., in amplify-server.ts)\n * - This function must be called INSIDE the operation function of runWithAmplifyServerContext\n * - The context automatically provides the token provider that reads JWT tokens from cookies\n *\n * @example\n * ```typescript\n * // In your Astro page\n * import type { Schema } from '../amplify/data/resource';\n * import { generateServerClient } from '@htlkg/data/client';\n * import { createRunWithAmplifyServerContext } from '@htlkg/core/amplify-astro-adapter';\n * import outputs from '../amplify_outputs.json';\n *\n * const runWithAmplifyServerContext = createRunWithAmplifyServerContext({ config: outputs });\n *\n * // Fetch data with authentication\n * const result = await runWithAmplifyServerContext({\n * astroServerContext: {\n * cookies: Astro.cookies,\n * request: Astro.request\n * },\n * operation: async (contextSpec) => {\n * // Generate client INSIDE the operation\n * const client = generateServerClient<Schema>({ authMode: 'userPool' });\n * return await client.models.User.list();\n * }\n * });\n * \n * const users = result.data || [];\n * ```\n * \n * @example Using API key for public data\n * ```typescript\n * const result = await runWithAmplifyServerContext({\n * astroServerContext: {\n * cookies: Astro.cookies,\n * request: Astro.request\n * },\n * operation: async (contextSpec) => {\n * const client = generateServerClient<Schema>({ authMode: 'apiKey' });\n * return await client.models.Brand.list();\n * }\n * });\n * ```\n */\nexport function generateServerClient<\n\tTSchema extends Record<string, unknown> = Record<string, unknown>,\n>(_options?: GenerateServerClientOptions): ReturnType<typeof generateDataClient<TSchema>> {\n\t// Generate the client without authMode parameter\n\t// When called within runWithAmplifyServerContext, it will automatically use the token provider\n\t// from the context (which reads JWT tokens from cookies)\n\t// The authMode should be specified per-operation, not at client creation\n\tconst client = generateDataClient<TSchema>();\n\n\treturn client;\n}\n\n/**\n * Context required for getting a server client in API routes\n */\nexport interface ServerClientContext {\n\tlocals: { amplifyClient?: any; user?: any };\n\tcookies: any;\n\trequest: Request;\n}\n\n/**\n * Get the server client from Astro context\n *\n * Uses locals.amplifyClient if available (set by middleware),\n * otherwise creates a new client using Amplify's global config.\n * No config parameter needed - uses the config set by the middleware.\n *\n * @example\n * ```typescript\n * import { getServerClient } from '@htlkg/data/client';\n *\n * export const POST: APIRoute = async (context) => {\n * const client = getServerClient(context);\n * if (!client) return new Response('Not authenticated', { status: 401 });\n *\n * const result = await client.models.User.list();\n * };\n * ```\n */\nexport function getServerClient<TSchema extends Record<string, unknown> = Record<string, unknown>>(\n\tcontext: ServerClientContext,\n): ReturnType<typeof generateServerClientUsingCookies<TSchema>> | null {\n\t// Try to use client from middleware first\n\tif (context.locals.amplifyClient) {\n\t\treturn context.locals.amplifyClient as ReturnType<typeof generateServerClientUsingCookies<TSchema>>;\n\t}\n\n\t// If no client from middleware and user is authenticated, create one using global Amplify config\n\tif (context.locals.user) {\n\t\ttry {\n\t\t\t// Get config from Amplify (set by middleware)\n\t\t\tconst amplifyConfig = Amplify.getConfig();\n\t\t\tif (amplifyConfig) {\n\t\t\t\treturn generateServerClientUsingCookies<TSchema>({\n\t\t\t\t\tconfig: amplifyConfig,\n\t\t\t\t\tcookies: context.cookies,\n\t\t\t\t\trequest: context.request,\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tconsole.error('[getServerClient] Failed to get Amplify config:', e);\n\t\t}\n\t}\n\n\t// No authentication available\n\treturn null;\n}\n","/**\n * Server-side data client for Astro\n *\n * Provides a client generator similar to Next.js's generateServerClientUsingCookies\n * using generateClientWithAmplifyInstance for proper server context integration.\n */\n\nimport type { AstroGlobal } from \"astro\";\nimport type { ResourcesConfig } from \"aws-amplify\";\nimport {\n\tCommonPublicClientOptions,\n\tDefaultCommonClientOptions,\n\tV6ClientSSRCookies,\n\tgenerateClientWithAmplifyInstance,\n} from \"aws-amplify/api/internals\";\nimport { getAmplifyServerContext } from \"aws-amplify/adapter-core/internals\";\nimport { createRunWithAmplifyServerContext, createLogger } from \"@htlkg/core/amplify-astro-adapter\";\n\nconst log = createLogger('server-client');\n\ninterface AstroCookiesClientParams {\n\tcookies: AstroGlobal[\"cookies\"];\n\trequest: AstroGlobal[\"request\"];\n\tconfig: ResourcesConfig;\n}\n\n/**\n * Generates a server-side data client for Astro (matches Next.js implementation)\n *\n * This function creates a client that automatically wraps all operations in the Amplify server context,\n * ensuring that authentication tokens from cookies are properly used.\n *\n * @example\n * ```typescript\n * import type { Schema } from '../amplify/data/resource';\n * import { generateServerClientUsingCookies } from '@htlkg/data/client';\n * import { parseAmplifyConfig } from 'aws-amplify/utils';\n * import outputs from '../amplify_outputs.json';\n *\n * const amplifyConfig = parseAmplifyConfig(outputs);\n *\n * const client = generateServerClientUsingCookies<Schema>({\n * config: amplifyConfig,\n * cookies: Astro.cookies,\n * request: Astro.request,\n * });\n *\n * // Use the client directly - operations are automatically wrapped\n * const result = await client.models.User.list({\n * selectionSet: ['id', 'email'],\n * limit: 100,\n * });\n * ```\n */\nexport function generateServerClientUsingCookies<\n\tT extends Record<any, any> = never,\n\tOptions extends CommonPublicClientOptions &\n\t\tAstroCookiesClientParams = DefaultCommonClientOptions &\n\t\tAstroCookiesClientParams,\n>(options: Options): V6ClientSSRCookies<T, Options> {\n\tconst runWithAmplifyServerContext = createRunWithAmplifyServerContext({\n\t\tconfig: options.config,\n\t});\n\n\tconst resourcesConfig = options.config;\n\n\t// This function reference gets passed down to InternalGraphQLAPI.ts.graphql\n\t// where this._graphql is passed in as the `fn` argument\n\t// causing it to always get invoked inside `runWithAmplifyServerContext`\n\tconst getAmplify = (fn: (amplify: any) => Promise<any>) => {\n\t\treturn runWithAmplifyServerContext({\n\t\t\tastroServerContext: {\n\t\t\t\tcookies: options.cookies,\n\t\t\t\trequest: options.request,\n\t\t\t},\n\t\t\toperation: async (contextSpec: any) => {\n\t\t\t\tconst amplifyInstance = getAmplifyServerContext(contextSpec).amplify;\n\t\t\t\t\n\t\t\t\t// Debug logging (only when DEBUG=true)\n\t\t\t\ttry {\n\t\t\t\t\tconst config = amplifyInstance.getConfig();\n\t\t\t\t\tlog.debug('Amplify config from instance:', {\n\t\t\t\t\t\thasAPI: !!config.API,\n\t\t\t\t\t\thasGraphQL: !!config.API?.GraphQL,\n\t\t\t\t\t\tendpoint: config.API?.GraphQL?.endpoint,\n\t\t\t\t\t\tdefaultAuthMode: config.API?.GraphQL?.defaultAuthMode,\n\t\t\t\t\t\tregion: config.API?.GraphQL?.region,\n\t\t\t\t\t});\n\t\t\t\t\t\n\t\t\t\t\tconst session = await amplifyInstance.Auth.fetchAuthSession();\n\t\t\t\t\tlog.debug('Auth session:', {\n\t\t\t\t\t\thasTokens: !!session.tokens,\n\t\t\t\t\t\thasAccessToken: !!session.tokens?.accessToken,\n\t\t\t\t\t\thasIdToken: !!session.tokens?.idToken,\n\t\t\t\t\t\thasCredentials: !!session.credentials,\n\t\t\t\t\t});\n\t\t\t\t} catch (e: any) {\n\t\t\t\t\tlog.debug('Error fetching session:', e.message);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn fn(amplifyInstance);\n\t\t\t},\n\t\t});\n\t};\n\n\tconst {\n\t\tcookies: _cookies,\n\t\trequest: _request,\n\t\tconfig: _config,\n\t\t...params\n\t} = options;\n\n\treturn generateClientWithAmplifyInstance<T, V6ClientSSRCookies<T, Options>>({\n\t\tamplify: getAmplify,\n\t\tconfig: resourcesConfig,\n\t\t...params,\n\t} as any);\n}\n","/**\n * GraphQL Proxy Client\n *\n * Client-side helper for making authenticated GraphQL operations through\n * the server-side proxy. This allows Vue components to perform mutations\n * while keeping auth cookies httpOnly for security.\n *\n * @module @htlkg/data/proxy\n */\n\n/**\n * Valid GraphQL operations\n */\nexport type Operation = \"create\" | \"update\" | \"delete\" | \"get\" | \"list\";\n\n/**\n * Response type from GraphQL operations\n */\nexport interface GraphQLResponse<T = any> {\n\tdata: T | null;\n\terrors?: Array<{ message: string; [key: string]: any }>;\n}\n\n/**\n * Options for proxy requests\n */\nexport interface ProxyOptions {\n\t/** Custom API endpoint (default: /api/graphql) */\n\tendpoint?: string;\n\t/** Additional fetch options */\n\tfetchOptions?: RequestInit;\n}\n\n/**\n * Default proxy endpoint\n */\nconst DEFAULT_ENDPOINT = \"/api/graphql\";\n\n/**\n * Execute a GraphQL mutation through the server proxy\n *\n * @param model - The model name (e.g., 'User', 'Brand', 'Account')\n * @param operation - The operation type ('create', 'update', 'delete')\n * @param data - The operation data/input\n * @param options - Optional configuration\n * @returns Promise with the operation result\n *\n * @example Create\n * ```typescript\n * const result = await mutate('User', 'create', {\n * email: 'user@example.com',\n * accountId: '123',\n * });\n * ```\n *\n * @example Update\n * ```typescript\n * const result = await mutate('User', 'update', {\n * id: 'user-id',\n * status: 'deleted',\n * deletedAt: new Date().toISOString(),\n * });\n * ```\n *\n * @example Delete\n * ```typescript\n * const result = await mutate('User', 'delete', { id: 'user-id' });\n * ```\n */\nexport async function mutate<T = any>(\n\tmodel: string,\n\toperation: \"create\" | \"update\" | \"delete\",\n\tdata: Record<string, any>,\n\toptions?: ProxyOptions,\n): Promise<GraphQLResponse<T>> {\n\treturn proxyRequest<T>(model, operation, data, options);\n}\n\n/**\n * Execute a GraphQL query through the server proxy\n *\n * @param model - The model name (e.g., 'User', 'Brand', 'Account')\n * @param operation - The operation type ('get', 'list')\n * @param data - The query parameters (id for get, filter/limit for list)\n * @param options - Optional configuration\n * @returns Promise with the query result\n *\n * @example Get by ID\n * ```typescript\n * const result = await query('User', 'get', { id: 'user-id' });\n * ```\n *\n * @example List with filter\n * ```typescript\n * const result = await query('User', 'list', {\n * filter: { status: { eq: 'active' } },\n * limit: 100,\n * });\n * ```\n */\nexport async function query<T = any>(\n\tmodel: string,\n\toperation: \"get\" | \"list\",\n\tdata?: Record<string, any>,\n\toptions?: ProxyOptions,\n): Promise<GraphQLResponse<T>> {\n\treturn proxyRequest<T>(model, operation, data, options);\n}\n\n/**\n * Internal function to make proxy requests\n */\nasync function proxyRequest<T>(\n\tmodel: string,\n\toperation: Operation,\n\tdata?: Record<string, any>,\n\toptions?: ProxyOptions,\n): Promise<GraphQLResponse<T>> {\n\tconst endpoint = options?.endpoint ?? DEFAULT_ENDPOINT;\n\n\ttry {\n\t\tconst response = await fetch(endpoint, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t},\n\t\t\tcredentials: \"include\", // Important: include cookies\n\t\t\t...options?.fetchOptions,\n\t\t\tbody: JSON.stringify({ model, operation, data }),\n\t\t});\n\n\t\tconst result: GraphQLResponse<T> = await response.json();\n\n\t\t// Handle auth errors\n\t\tif (response.status === 401) {\n\t\t\tconsole.error(\"[GraphQL Proxy] Unauthorized - session may have expired\");\n\t\t\t// Optionally trigger a redirect to login\n\t\t\t// window.location.href = '/login';\n\t\t}\n\n\t\treturn result;\n\t} catch (error) {\n\t\tconsole.error(\"[GraphQL Proxy] Request failed:\", error);\n\t\treturn {\n\t\t\tdata: null,\n\t\t\terrors: [\n\t\t\t\t{\n\t\t\t\t\tmessage: error instanceof Error ? error.message : \"Network error\",\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}\n}\n\n/**\n * Helper to check if a response has errors\n */\nexport function hasErrors(response: GraphQLResponse): boolean {\n\treturn !!response.errors && response.errors.length > 0;\n}\n\n/**\n * Helper to get the first error message from a response\n */\nexport function getErrorMessage(response: GraphQLResponse): string | null {\n\tif (!response.errors || response.errors.length === 0) {\n\t\treturn null;\n\t}\n\treturn response.errors[0].message;\n}\n","/**\n * Brand Query Functions\n *\n * Provides query functions for fetching brand data from the GraphQL API.\n */\n\nimport type { Brand } from \"@htlkg/core/types\";\n\n/**\n * Get a single brand by ID\n *\n * @example\n * ```typescript\n * import { getBrand } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brand = await getBrand(client, 'brand-123');\n * ```\n */\nexport async function getBrand<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Brand | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Brand.get({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getBrand] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Brand;\n\t} catch (error) {\n\t\tconsole.error(\"[getBrand] Error fetching brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List all brands with optional filtering\n *\n * @example\n * ```typescript\n * import { listBrands } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brands = await listBrands(client, {\n * filter: { status: { eq: 'active' } }\n * });\n * ```\n */\nexport async function listBrands<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Brand[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (client as any).models.Brand.list(\n\t\t\toptions,\n\t\t);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listBrands] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as Brand[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[listBrands] Error fetching brands:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get a brand with its product instances\n *\n * @example\n * ```typescript\n * import { getBrandWithProducts } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brand = await getBrandWithProducts(client, 'brand-123');\n * ```\n */\nexport async function getBrandWithProducts<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Brand | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Brand.get(\n\t\t\t{ id },\n\t\t\t{\n\t\t\t\tselectionSet: [\n\t\t\t\t\t\"id\",\n\t\t\t\t\t\"name\",\n\t\t\t\t\t\"accountId\",\n\t\t\t\t\t\"logo\",\n\t\t\t\t\t\"timezone\",\n\t\t\t\t\t\"status\",\n\t\t\t\t\t\"settings\",\n\t\t\t\t\t\"productInstances.*\",\n\t\t\t\t],\n\t\t\t},\n\t\t);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getBrandWithProducts] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Brand;\n\t} catch (error) {\n\t\tconsole.error(\"[getBrandWithProducts] Error fetching brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List brands by account ID\n *\n * @example\n * ```typescript\n * import { listBrandsByAccount } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brands = await listBrandsByAccount(client, 'account-123');\n * ```\n */\nexport async function listBrandsByAccount<TClient = any>(\n\tclient: TClient,\n\taccountId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Brand[]; nextToken?: string }> {\n\treturn listBrands(client, {\n\t\tfilter: { accountId: { eq: accountId } },\n\t\t...options,\n\t});\n}\n\n/**\n * List active brands\n *\n * @example\n * ```typescript\n * import { listActiveBrands } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brands = await listActiveBrands(client);\n * ```\n */\nexport async function listActiveBrands<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Brand[]; nextToken?: string }> {\n\treturn listBrands(client, {\n\t\tfilter: { status: { eq: \"active\" } },\n\t\t...options,\n\t});\n}\n","/**\n * Account Query Functions\n *\n * Provides query functions for fetching account data from the GraphQL API.\n */\n\nimport type { Account } from \"@htlkg/core/types\";\n\n/**\n * Get a single account by ID\n *\n * @example\n * ```typescript\n * import { getAccount } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const account = await getAccount(client, 'account-123');\n * ```\n */\nexport async function getAccount<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Account | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Account.get({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getAccount] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Account;\n\t} catch (error) {\n\t\tconsole.error(\"[getAccount] Error fetching account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List all accounts with optional filtering\n *\n * @example\n * ```typescript\n * import { listAccounts } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const accounts = await listAccounts(client);\n * ```\n */\nexport async function listAccounts<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Account[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.Account.list(options);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listAccounts] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as Account[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[listAccounts] Error fetching accounts:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get an account with its brands\n *\n * @example\n * ```typescript\n * import { getAccountWithBrands } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const account = await getAccountWithBrands(client, 'account-123');\n * ```\n */\nexport async function getAccountWithBrands<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Account | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Account.get(\n\t\t\t{ id },\n\t\t\t{\n\t\t\t\tselectionSet: [\n\t\t\t\t\t\"id\",\n\t\t\t\t\t\"name\",\n\t\t\t\t\t\"logo\",\n\t\t\t\t\t\"subscription\",\n\t\t\t\t\t\"settings\",\n\t\t\t\t\t\"brands.*\",\n\t\t\t\t],\n\t\t\t},\n\t\t);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getAccountWithBrands] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Account;\n\t} catch (error) {\n\t\tconsole.error(\"[getAccountWithBrands] Error fetching account:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * User Query Functions\n *\n * Provides query functions for fetching user data from the GraphQL API.\n */\n\nimport type { User } from \"@htlkg/core/types\";\n\n/**\n * Get a single user by ID\n *\n * @example\n * ```typescript\n * import { getUser } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await getUser(client, 'user-123');\n * ```\n */\nexport async function getUser<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.get({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getUser] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as User;\n\t} catch (error) {\n\t\tconsole.error(\"[getUser] Error fetching user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get a user by Cognito ID\n *\n * @example\n * ```typescript\n * import { getUserByCognitoId } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await getUserByCognitoId(client, 'cognito-id-123');\n * ```\n */\nexport async function getUserByCognitoId<TClient = any>(\n\tclient: TClient,\n\tcognitoId: string,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.list({\n\t\t\tfilter: { cognitoId: { eq: cognitoId } },\n\t\t\tlimit: 1,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getUserByCognitoId] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data?.[0] as User | null;\n\t} catch (error) {\n\t\tconsole.error(\"[getUserByCognitoId] Error fetching user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get a user by email\n *\n * @example\n * ```typescript\n * import { getUserByEmail } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await getUserByEmail(client, 'user@example.com');\n * ```\n */\nexport async function getUserByEmail<TClient = any>(\n\tclient: TClient,\n\temail: string,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.list({\n\t\t\tfilter: { email: { eq: email } },\n\t\t\tlimit: 1,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getUserByEmail] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data?.[0] as User | null;\n\t} catch (error) {\n\t\tconsole.error(\"[getUserByEmail] Error fetching user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List all users with optional filtering\n *\n * @example\n * ```typescript\n * import { listUsers } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const users = await listUsers(client, {\n * filter: { status: { eq: 'active' } }\n * });\n * ```\n */\nexport async function listUsers<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: User[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (client as any).models.User.list(\n\t\t\toptions,\n\t\t);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listUsers] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as User[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[listUsers] Error fetching users:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List users by account ID\n *\n * @example\n * ```typescript\n * import { listUsersByAccount } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const users = await listUsersByAccount(client, 'account-123');\n * ```\n */\nexport async function listUsersByAccount<TClient = any>(\n\tclient: TClient,\n\taccountId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: User[]; nextToken?: string }> {\n\treturn listUsers(client, {\n\t\tfilter: { accountId: { eq: accountId } },\n\t\t...options,\n\t});\n}\n\n/**\n * List active users\n *\n * @example\n * ```typescript\n * import { listActiveUsers } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const users = await listActiveUsers(client);\n * ```\n */\nexport async function listActiveUsers<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: User[]; nextToken?: string }> {\n\treturn listUsers(client, {\n\t\tfilter: { status: { eq: \"active\" } },\n\t\t...options,\n\t});\n}\n","/**\n * Product Query Functions\n *\n * Provides query functions for fetching product and product instance data from the GraphQL API.\n */\n\nimport type { Product, ProductInstance } from \"@htlkg/core/types\";\n\n/**\n * Get a single product by ID\n *\n * @example\n * ```typescript\n * import { getProduct } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const product = await getProduct(client, 'product-123');\n * ```\n */\nexport async function getProduct<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Product | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Product.get({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getProduct] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Product;\n\t} catch (error) {\n\t\tconsole.error(\"[getProduct] Error fetching product:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List all products with optional filtering\n *\n * @example\n * ```typescript\n * import { listProducts } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const products = await listProducts(client, {\n * filter: { isActive: { eq: true } }\n * });\n * ```\n */\nexport async function listProducts<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Product[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.Product.list(options);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listProducts] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as Product[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[listProducts] Error fetching products:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List active products\n *\n * @example\n * ```typescript\n * import { listActiveProducts } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const products = await listActiveProducts(client);\n * ```\n */\nexport async function listActiveProducts<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Product[]; nextToken?: string }> {\n\treturn listProducts(client, {\n\t\tfilter: { isActive: { eq: true } },\n\t\t...options,\n\t});\n}\n\n/**\n * Get a single product instance by ID\n *\n * @example\n * ```typescript\n * import { getProductInstance } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instance = await getProductInstance(client, 'instance-123');\n * ```\n */\nexport async function getProductInstance<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<ProductInstance | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.ProductInstance.get({\n\t\t\tid,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getProductInstance] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as ProductInstance;\n\t} catch (error) {\n\t\tconsole.error(\"[getProductInstance] Error fetching product instance:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List product instances by brand ID\n *\n * @example\n * ```typescript\n * import { listProductInstancesByBrand } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instances = await listProductInstancesByBrand(client, 'brand-123');\n * ```\n */\nexport async function listProductInstancesByBrand<TClient = any>(\n\tclient: TClient,\n\tbrandId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: ProductInstance[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.ProductInstance.list({\n\t\t\tfilter: { brandId: { eq: brandId } },\n\t\t\t...options,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listProductInstancesByBrand] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as ProductInstance[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t\"[listProductInstancesByBrand] Error fetching product instances:\",\n\t\t\terror,\n\t\t);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List product instances by account ID\n *\n * @example\n * ```typescript\n * import { listProductInstancesByAccount } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instances = await listProductInstancesByAccount(client, 'account-123');\n * ```\n */\nexport async function listProductInstancesByAccount<TClient = any>(\n\tclient: TClient,\n\taccountId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: ProductInstance[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.ProductInstance.list({\n\t\t\tfilter: { accountId: { eq: accountId } },\n\t\t\t...options,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listProductInstancesByAccount] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as ProductInstance[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t\"[listProductInstancesByAccount] Error fetching product instances:\",\n\t\t\terror,\n\t\t);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List enabled product instances by brand ID\n *\n * @example\n * ```typescript\n * import { listEnabledProductInstancesByBrand } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instances = await listEnabledProductInstancesByBrand(client, 'brand-123');\n * ```\n */\nexport async function listEnabledProductInstancesByBrand<TClient = any>(\n\tclient: TClient,\n\tbrandId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: ProductInstance[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.ProductInstance.list({\n\t\t\tfilter: {\n\t\t\t\tbrandId: { eq: brandId },\n\t\t\t\tenabled: { eq: true },\n\t\t\t},\n\t\t\t...options,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\n\t\t\t\t\"[listEnabledProductInstancesByBrand] GraphQL errors:\",\n\t\t\t\terrors,\n\t\t\t);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as ProductInstance[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t\"[listEnabledProductInstancesByBrand] Error fetching product instances:\",\n\t\t\terror,\n\t\t);\n\t\tthrow error;\n\t}\n}\n","/**\n * Server-Side Query Helpers\n *\n * Convenience functions for executing server-side queries in Astro pages.\n * These helpers simplify the common pattern of using runWithAmplifyServerContext.\n */\n\nimport type { AstroGlobal } from \"astro\";\nimport { generateServerClient } from \"../client\";\n\n/**\n * Type for the runWithAmplifyServerContext function\n */\ntype RunWithAmplifyServerContext = (options: {\n\tastroServerContext: {\n\t\tcookies: AstroGlobal[\"cookies\"];\n\t\trequest: AstroGlobal[\"request\"];\n\t};\n\toperation: (contextSpec: unknown) => Promise<unknown>;\n}) => Promise<unknown>;\n\n/**\n * Helper to execute server-side queries in Astro pages\n *\n * This function wraps the common pattern of using runWithAmplifyServerContext\n * with generateServerClient, making it easier to fetch data server-side.\n *\n * **Note**: This requires `createRunWithAmplifyServerContext` from `@htlkg/core/amplify-astro-adapter`.\n * If you need more control, use the full pattern directly.\n *\n * @example\n * ```typescript\n * import type { Schema } from '../amplify/data/resource';\n * import { executeServerQuery } from '@htlkg/data/queries/server-helpers';\n * import { createRunWithAmplifyServerContext } from '@htlkg/core/amplify-astro-adapter';\n * import outputs from '../amplify_outputs.json';\n *\n * const runWithAmplifyServerContext = createRunWithAmplifyServerContext({ config: outputs });\n *\n * const users = await executeServerQuery<Schema>(\n * Astro,\n * runWithAmplifyServerContext,\n * async (client) => {\n * const result = await client.models.User.list();\n * return result.data || [];\n * }\n * );\n * ```\n */\nexport async function executeServerQuery<\n\tTSchema extends Record<string, unknown>,\n\tTResult,\n>(\n\tastro: AstroGlobal,\n\trunWithAmplifyServerContext: RunWithAmplifyServerContext,\n\toperation: (client: ReturnType<typeof generateServerClient<TSchema>>) => Promise<TResult>,\n): Promise<TResult> {\n\tconst result = await runWithAmplifyServerContext({\n\t\tastroServerContext: {\n\t\t\tcookies: astro.cookies,\n\t\t\trequest: astro.request,\n\t\t},\n\t\toperation: async (contextSpec: unknown) => {\n\t\t\tconst client = generateServerClient<TSchema>();\n\t\t\treturn await operation(client);\n\t\t},\n\t});\n\treturn result as TResult;\n}\n\n/**\n * Helper to execute server-side queries with API key authentication (public data)\n *\n * Use this for fetching public data that doesn't require user authentication.\n *\n * @example\n * ```typescript\n * import type { Schema } from '../amplify/data/resource';\n * import { executePublicQuery } from '@htlkg/data/queries/server-helpers';\n * import { createRunWithAmplifyServerContext } from '@htlkg/core/amplify-astro-adapter';\n * import outputs from '../amplify_outputs.json';\n *\n * const runWithAmplifyServerContext = createRunWithAmplifyServerContext({ config: outputs });\n *\n * const brands = await executePublicQuery<Schema>(\n * Astro,\n * runWithAmplifyServerContext,\n * async (client) => {\n * const result = await client.models.Brand.list();\n * return result.data || [];\n * }\n * );\n * ```\n */\nexport async function executePublicQuery<\n\tTSchema extends Record<string, unknown>,\n\tTResult,\n>(\n\tastro: AstroGlobal,\n\trunWithAmplifyServerContext: RunWithAmplifyServerContext,\n\toperation: (client: ReturnType<typeof generateServerClient<TSchema>>) => Promise<TResult>,\n): Promise<TResult> {\n\tconst result = await runWithAmplifyServerContext({\n\t\tastroServerContext: {\n\t\t\tcookies: astro.cookies,\n\t\t\trequest: astro.request,\n\t\t},\n\t\toperation: async (_contextSpec: unknown) => {\n\t\t\tconst client = generateServerClient<TSchema>({ authMode: \"apiKey\" });\n\t\t\treturn await operation(client);\n\t\t},\n\t});\n\treturn result as TResult;\n}\n","/**\n * SystemSettings Query Functions\n *\n * Provides query functions for fetching system settings from the GraphQL API.\n */\n\nimport type { SystemSettings } from \"@htlkg/core/types\";\n\n/** Default retention days if no settings exist */\nexport const DEFAULT_SOFT_DELETE_RETENTION_DAYS = 30;\n\n/** The key used for global system settings */\nexport const SYSTEM_SETTINGS_KEY = \"GLOBAL\";\n\n/**\n * Get system settings\n *\n * @example\n * ```typescript\n * import { getSystemSettings } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const settings = await getSystemSettings(client);\n * ```\n */\nexport async function getSystemSettings<TClient = any>(\n\tclient: TClient,\n): Promise<SystemSettings | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.SystemSettings.get({\n\t\t\tkey: SYSTEM_SETTINGS_KEY,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getSystemSettings] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as SystemSettings;\n\t} catch (error) {\n\t\tconsole.error(\"[getSystemSettings] Error fetching system settings:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get the soft delete retention days from system settings\n * Returns the default (30 days) if settings don't exist\n *\n * @example\n * ```typescript\n * import { getSoftDeleteRetentionDays } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const days = await getSoftDeleteRetentionDays(client);\n * ```\n */\nexport async function getSoftDeleteRetentionDays<TClient = any>(\n\tclient: TClient,\n): Promise<number> {\n\tconst settings = await getSystemSettings(client);\n\treturn settings?.softDeleteRetentionDays ?? DEFAULT_SOFT_DELETE_RETENTION_DAYS;\n}\n\n/**\n * Check if a soft-deleted item can still be restored based on retention period\n *\n * @param deletedAt - The ISO date string when the item was deleted\n * @param retentionDays - Number of days items can be restored\n * @returns Object with canRestore flag and daysRemaining/daysExpired\n */\nexport function checkRestoreEligibility(\n\tdeletedAt: string | undefined | null,\n\tretentionDays: number,\n): {\n\tcanRestore: boolean;\n\tdaysRemaining: number;\n\tdaysExpired: number;\n\texpiresAt: Date | null;\n} {\n\tif (!deletedAt) {\n\t\treturn {\n\t\t\tcanRestore: false,\n\t\t\tdaysRemaining: 0,\n\t\t\tdaysExpired: 0,\n\t\t\texpiresAt: null,\n\t\t};\n\t}\n\n\tconst deletedDate = new Date(deletedAt);\n\tconst expiresAt = new Date(deletedDate);\n\texpiresAt.setDate(expiresAt.getDate() + retentionDays);\n\n\tconst now = new Date();\n\tconst msRemaining = expiresAt.getTime() - now.getTime();\n\tconst daysRemaining = Math.ceil(msRemaining / (1000 * 60 * 60 * 24));\n\n\tif (daysRemaining <= 0) {\n\t\treturn {\n\t\t\tcanRestore: false,\n\t\t\tdaysRemaining: 0,\n\t\t\tdaysExpired: Math.abs(daysRemaining),\n\t\t\texpiresAt,\n\t\t};\n\t}\n\n\treturn {\n\t\tcanRestore: true,\n\t\tdaysRemaining,\n\t\tdaysExpired: 0,\n\t\texpiresAt,\n\t};\n}\n","/**\n * Reservation Query Functions\n *\n * Provides query functions for fetching reservation data from the GraphQL API.\n */\n\n/**\n * Reservation type for query results\n */\nexport interface Reservation {\n\tid: string;\n\tbrandId: string;\n\tvisitId: string;\n\tconfirmationCode: string;\n\tcheckIn: string;\n\tcheckOut: string;\n\tstatus: \"confirmed\" | \"checked_in\" | \"checked_out\" | \"cancelled\" | \"no_show\";\n\tsource?: string;\n\tchannel?: string;\n\troomType?: string;\n\troom?: string;\n\ttotalAmount?: number;\n\tcurrency?: string;\n\tnights?: number;\n\tcreatedAt?: string;\n\tcreatedBy?: string;\n\tupdatedAt?: string;\n\tupdatedBy?: string;\n\tdeletedAt?: string | null;\n\tdeletedBy?: string | null;\n}\n\n/**\n * Get a single reservation by ID\n *\n * @example\n * ```typescript\n * import { getReservation } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const reservation = await getReservation(client, 'reservation-123');\n * ```\n */\nexport async function getReservation<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Reservation | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Reservation.get({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getReservation] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Reservation;\n\t} catch (error) {\n\t\tconsole.error(\"[getReservation] Error fetching reservation:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List all reservations with optional filtering and pagination\n *\n * @example\n * ```typescript\n * import { listReservations } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const reservations = await listReservations(client, {\n * filter: { status: { eq: 'confirmed' } },\n * limit: 50\n * });\n * ```\n */\nexport async function listReservations<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Reservation[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (client as any).models.Reservation.list(\n\t\t\toptions,\n\t\t);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listReservations] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as Reservation[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[listReservations] Error fetching reservations:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List reservations by brand ID\n *\n * @example\n * ```typescript\n * import { listReservationsByBrand } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const reservations = await listReservationsByBrand(client, 'brand-123', {\n * limit: 100\n * });\n * ```\n */\nexport async function listReservationsByBrand<TClient = any>(\n\tclient: TClient,\n\tbrandId: string,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Reservation[]; nextToken?: string }> {\n\tconst filter = options?.filter\n\t\t? { and: [{ brandId: { eq: brandId } }, options.filter] }\n\t\t: { brandId: { eq: brandId } };\n\n\treturn listReservations(client, {\n\t\tfilter,\n\t\tlimit: options?.limit,\n\t\tnextToken: options?.nextToken,\n\t});\n}\n\n/**\n * List reservations by contact/visit ID\n *\n * @example\n * ```typescript\n * import { listReservationsByContact } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const reservations = await listReservationsByContact(client, 'contact-123');\n * ```\n */\nexport async function listReservationsByContact<TClient = any>(\n\tclient: TClient,\n\tcontactId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Reservation[]; nextToken?: string }> {\n\treturn listReservations(client, {\n\t\tfilter: { visitId: { eq: contactId } },\n\t\t...options,\n\t});\n}\n\n/**\n * List reservations by date range for a specific brand\n *\n * Filters reservations where check-in date falls within the specified range.\n *\n * @example\n * ```typescript\n * import { listReservationsByDateRange } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const reservations = await listReservationsByDateRange(\n * client,\n * 'brand-123',\n * '2024-01-01',\n * '2024-01-31'\n * );\n * ```\n */\nexport async function listReservationsByDateRange<TClient = any>(\n\tclient: TClient,\n\tbrandId: string,\n\tstartDate: string,\n\tendDate: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Reservation[]; nextToken?: string }> {\n\treturn listReservations(client, {\n\t\tfilter: {\n\t\t\tand: [\n\t\t\t\t{ brandId: { eq: brandId } },\n\t\t\t\t{ checkIn: { ge: startDate } },\n\t\t\t\t{ checkIn: { le: endDate } },\n\t\t\t],\n\t\t},\n\t\t...options,\n\t});\n}\n\n/**\n * Get a reservation by confirmation code and brand ID\n *\n * Returns the first matching reservation or null if not found.\n *\n * @example\n * ```typescript\n * import { getReservationByConfirmation } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const reservation = await getReservationByConfirmation(\n * client,\n * 'ABC123',\n * 'brand-123'\n * );\n * ```\n */\nexport async function getReservationByConfirmation<TClient = any>(\n\tclient: TClient,\n\tconfirmationCode: string,\n\tbrandId: string,\n): Promise<Reservation | null> {\n\ttry {\n\t\tconst { items } = await listReservations(client, {\n\t\t\tfilter: {\n\t\t\t\tand: [\n\t\t\t\t\t{ confirmationCode: { eq: confirmationCode } },\n\t\t\t\t\t{ brandId: { eq: brandId } },\n\t\t\t\t],\n\t\t\t},\n\t\t\tlimit: 1,\n\t\t});\n\n\t\treturn items.length > 0 ? items[0] : null;\n\t} catch (error) {\n\t\tconsole.error(\"[getReservationByConfirmation] Error fetching reservation:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * Contact Query Functions\n *\n * Provides query functions for fetching contact data from the GraphQL API.\n */\n\nimport type { Contact } from \"@htlkg/core/types\";\n\n/**\n * Get a single contact by ID\n *\n * @example\n * ```typescript\n * import { getContact } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const contact = await getContact(client, 'contact-123');\n * ```\n */\nexport async function getContact<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Contact | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Contact.get({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getContact] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Contact;\n\t} catch (error) {\n\t\tconsole.error(\"[getContact] Error fetching contact:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List all contacts with optional filtering\n *\n * @example\n * ```typescript\n * import { listContacts } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const contacts = await listContacts(client, {\n * filter: { gdprConsent: { eq: true } },\n * limit: 50\n * });\n * ```\n */\nexport async function listContacts<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Contact[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.Contact.list(options);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listContacts] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as Contact[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[listContacts] Error fetching contacts:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List contacts by brand ID\n *\n * @example\n * ```typescript\n * import { listContactsByBrand } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const contacts = await listContactsByBrand(client, 'brand-123');\n * ```\n */\nexport async function listContactsByBrand<TClient = any>(\n\tclient: TClient,\n\tbrandId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Contact[]; nextToken?: string }> {\n\treturn listContacts(client, {\n\t\tfilter: { brandId: { eq: brandId } },\n\t\t...options,\n\t});\n}\n\n/**\n * Get a contact by email within a brand\n *\n * @example\n * ```typescript\n * import { getContactByEmail } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const contact = await getContactByEmail(client, 'guest@example.com', 'brand-123');\n * ```\n */\nexport async function getContactByEmail<TClient = any>(\n\tclient: TClient,\n\temail: string,\n\tbrandId: string,\n): Promise<Contact | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Contact.list({\n\t\t\tfilter: {\n\t\t\t\tand: [{ email: { eq: email } }, { brandId: { eq: brandId } }],\n\t\t\t},\n\t\t\tlimit: 1,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getContactByEmail] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data?.[0] as Contact | null;\n\t} catch (error) {\n\t\tconsole.error(\"[getContactByEmail] Error fetching contact:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get a contact by phone within a brand\n *\n * @example\n * ```typescript\n * import { getContactByPhone } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const contact = await getContactByPhone(client, '+1234567890', 'brand-123');\n * ```\n */\nexport async function getContactByPhone<TClient = any>(\n\tclient: TClient,\n\tphone: string,\n\tbrandId: string,\n): Promise<Contact | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Contact.list({\n\t\t\tfilter: {\n\t\t\t\tand: [{ phone: { eq: phone } }, { brandId: { eq: brandId } }],\n\t\t\t},\n\t\t\tlimit: 1,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getContactByPhone] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data?.[0] as Contact | null;\n\t} catch (error) {\n\t\tconsole.error(\"[getContactByPhone] Error fetching contact:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Search contacts by query string within a brand\n * Searches across email, firstName, and lastName fields\n *\n * @example\n * ```typescript\n * import { searchContacts } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const contacts = await searchContacts(client, 'john', 'brand-123');\n * ```\n */\nexport async function searchContacts<TClient = any>(\n\tclient: TClient,\n\tquery: string,\n\tbrandId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Contact[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.Contact.list({\n\t\t\tfilter: {\n\t\t\t\tand: [\n\t\t\t\t\t{ brandId: { eq: brandId } },\n\t\t\t\t\t{\n\t\t\t\t\t\tor: [\n\t\t\t\t\t\t\t{ email: { contains: query } },\n\t\t\t\t\t\t\t{ firstName: { contains: query } },\n\t\t\t\t\t\t\t{ lastName: { contains: query } },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t...options,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[searchContacts] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as Contact[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[searchContacts] Error searching contacts:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * Brand Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting brands.\n */\n\nimport type { Brand } from \"@htlkg/core/types\";\nimport {\n\tcheckRestoreEligibility,\n\tDEFAULT_SOFT_DELETE_RETENTION_DAYS,\n} from \"../queries/systemSettings\";\nimport type { CreateAuditFields, UpdateWithSoftDeleteFields } from \"./common\";\n\n/**\n * Input type for creating a brand\n */\nexport interface CreateBrandInput extends CreateAuditFields {\n\taccountId: string;\n\tname: string;\n\tlogo?: string;\n\ttimezone?: string;\n\tstatus?: \"active\" | \"inactive\" | \"maintenance\" | \"suspended\" | \"deleted\";\n\tsettings?: Record<string, any>;\n}\n\n/**\n * Input type for updating a brand\n */\nexport interface UpdateBrandInput extends UpdateWithSoftDeleteFields {\n\tid: string;\n\tname?: string;\n\tlogo?: string;\n\ttimezone?: string;\n\tstatus?: \"active\" | \"inactive\" | \"maintenance\" | \"suspended\" | \"deleted\";\n\tsettings?: Record<string, any>;\n}\n\n/**\n * Create a new brand\n *\n * @example\n * ```typescript\n * import { createBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brand = await createBrand(client, {\n * accountId: 'account-123',\n * name: 'My Brand',\n * timezone: 'America/New_York',\n * status: 'active'\n * });\n * ```\n */\nexport async function createBrand<TClient = any>(\n\tclient: TClient,\n\tinput: CreateBrandInput,\n): Promise<Brand | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Brand.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createBrand] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Brand;\n\t} catch (error) {\n\t\tconsole.error(\"[createBrand] Error creating brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing brand\n *\n * @example\n * ```typescript\n * import { updateBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brand = await updateBrand(client, {\n * id: 'brand-123',\n * name: 'Updated Brand Name',\n * status: 'maintenance'\n * });\n * ```\n */\nexport async function updateBrand<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateBrandInput,\n): Promise<Brand | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Brand.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateBrand] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Brand;\n\t} catch (error) {\n\t\tconsole.error(\"[updateBrand] Error updating brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Soft delete a brand (sets status to \"deleted\" instead of removing)\n *\n * @example\n * ```typescript\n * import { softDeleteBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await softDeleteBrand(client, 'brand-123', 'admin@example.com');\n * ```\n */\nexport async function softDeleteBrand<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tdeletedBy: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Brand.update({\n\t\t\tid,\n\t\t\tstatus: \"deleted\",\n\t\t\tdeletedAt: new Date().toISOString(),\n\t\t\tdeletedBy,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[softDeleteBrand] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[softDeleteBrand] Error soft-deleting brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Restore a soft-deleted brand (sets status back to \"active\")\n * Checks retention period before allowing restoration\n *\n * @example\n * ```typescript\n * import { restoreBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await restoreBrand(client, 'brand-123');\n * // Or with custom retention days:\n * await restoreBrand(client, 'brand-123', 60);\n * ```\n */\nexport async function restoreBrand<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tretentionDays: number = DEFAULT_SOFT_DELETE_RETENTION_DAYS,\n): Promise<{ success: boolean; error?: string }> {\n\ttry {\n\t\t// First, get the brand to check its deletedAt timestamp\n\t\tconst { data: brand, errors: getErrors } = await (\n\t\t\tclient as any\n\t\t).models.Brand.get({ id });\n\n\t\tif (getErrors || !brand) {\n\t\t\tconsole.error(\"[restoreBrand] Error fetching brand:\", getErrors);\n\t\t\treturn { success: false, error: \"Brand not found\" };\n\t\t}\n\n\t\t// Check if restoration is allowed based on retention period\n\t\tconst eligibility = checkRestoreEligibility(brand.deletedAt, retentionDays);\n\n\t\tif (!eligibility.canRestore) {\n\t\t\tconst errorMsg = `Cannot restore brand. Retention period of ${retentionDays} days has expired. Item was deleted ${eligibility.daysExpired} days ago.`;\n\t\t\tconsole.error(\"[restoreBrand]\", errorMsg);\n\t\t\treturn { success: false, error: errorMsg };\n\t\t}\n\n\t\tconst { errors } = await (client as any).models.Brand.update({\n\t\t\tid,\n\t\t\tstatus: \"active\",\n\t\t\tdeletedAt: null,\n\t\t\tdeletedBy: null,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[restoreBrand] GraphQL errors:\", errors);\n\t\t\treturn { success: false, error: \"Failed to restore brand\" };\n\t\t}\n\n\t\treturn { success: true };\n\t} catch (error) {\n\t\tconsole.error(\"[restoreBrand] Error restoring brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Hard delete a brand (permanently removes from database)\n * Use with caution - prefer softDeleteBrand for recoverable deletion\n *\n * @example\n * ```typescript\n * import { deleteBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteBrand(client, 'brand-123');\n * ```\n */\nexport async function deleteBrand<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Brand.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteBrand] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteBrand] Error deleting brand:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * Account Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting accounts.\n */\n\nimport type { Account } from \"@htlkg/core/types\";\nimport {\n\tcheckRestoreEligibility,\n\tDEFAULT_SOFT_DELETE_RETENTION_DAYS,\n} from \"../queries/systemSettings\";\nimport type { CreateAuditFields, UpdateWithSoftDeleteFields } from \"./common\";\n\n/**\n * Input type for creating an account\n */\nexport interface CreateAccountInput extends CreateAuditFields {\n\tname: string;\n\tlogo?: string;\n\tsubscription?: Record<string, any>;\n\tsettings?: Record<string, any>;\n\tstatus?: \"active\" | \"inactive\" | \"deleted\";\n}\n\n/**\n * Input type for updating an account\n */\nexport interface UpdateAccountInput extends UpdateWithSoftDeleteFields {\n\tid: string;\n\tname?: string;\n\tlogo?: string;\n\tsubscription?: Record<string, any>;\n\tsettings?: Record<string, any>;\n\tstatus?: \"active\" | \"inactive\" | \"deleted\";\n}\n\n/**\n * Create a new account\n *\n * @example\n * ```typescript\n * import { createAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const account = await createAccount(client, {\n * name: 'My Account',\n * subscription: { plan: 'premium' }\n * });\n * ```\n */\nexport async function createAccount<TClient = any>(\n\tclient: TClient,\n\tinput: CreateAccountInput,\n): Promise<Account | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Account.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createAccount] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Account;\n\t} catch (error) {\n\t\tconsole.error(\"[createAccount] Error creating account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing account\n *\n * @example\n * ```typescript\n * import { updateAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const account = await updateAccount(client, {\n * id: 'account-123',\n * name: 'Updated Account Name'\n * });\n * ```\n */\nexport async function updateAccount<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateAccountInput,\n): Promise<Account | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Account.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateAccount] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Account;\n\t} catch (error) {\n\t\tconsole.error(\"[updateAccount] Error updating account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Soft delete an account (sets status to \"deleted\" instead of removing)\n *\n * @example\n * ```typescript\n * import { softDeleteAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await softDeleteAccount(client, 'account-123', 'admin@example.com');\n * ```\n */\nexport async function softDeleteAccount<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tdeletedBy: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Account.update({\n\t\t\tid,\n\t\t\tstatus: \"deleted\",\n\t\t\tdeletedAt: new Date().toISOString(),\n\t\t\tdeletedBy,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[softDeleteAccount] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[softDeleteAccount] Error soft-deleting account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Restore a soft-deleted account (sets status back to \"active\")\n * Checks retention period before allowing restoration\n *\n * @example\n * ```typescript\n * import { restoreAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await restoreAccount(client, 'account-123');\n * // Or with custom retention days:\n * await restoreAccount(client, 'account-123', 60);\n * ```\n */\nexport async function restoreAccount<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tretentionDays: number = DEFAULT_SOFT_DELETE_RETENTION_DAYS,\n): Promise<{ success: boolean; error?: string }> {\n\ttry {\n\t\t// First, get the account to check its deletedAt timestamp\n\t\tconst { data: account, errors: getErrors } = await (\n\t\t\tclient as any\n\t\t).models.Account.get({ id });\n\n\t\tif (getErrors || !account) {\n\t\t\tconsole.error(\"[restoreAccount] Error fetching account:\", getErrors);\n\t\t\treturn { success: false, error: \"Account not found\" };\n\t\t}\n\n\t\t// Check if restoration is allowed based on retention period\n\t\tconst eligibility = checkRestoreEligibility(account.deletedAt, retentionDays);\n\n\t\tif (!eligibility.canRestore) {\n\t\t\tconst errorMsg = `Cannot restore account. Retention period of ${retentionDays} days has expired. Item was deleted ${eligibility.daysExpired} days ago.`;\n\t\t\tconsole.error(\"[restoreAccount]\", errorMsg);\n\t\t\treturn { success: false, error: errorMsg };\n\t\t}\n\n\t\tconst { errors } = await (client as any).models.Account.update({\n\t\t\tid,\n\t\t\tstatus: \"active\",\n\t\t\tdeletedAt: null,\n\t\t\tdeletedBy: null,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[restoreAccount] GraphQL errors:\", errors);\n\t\t\treturn { success: false, error: \"Failed to restore account\" };\n\t\t}\n\n\t\treturn { success: true };\n\t} catch (error) {\n\t\tconsole.error(\"[restoreAccount] Error restoring account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Hard delete an account (permanently removes from database)\n * Use with caution - prefer softDeleteAccount for recoverable deletion\n *\n * @example\n * ```typescript\n * import { deleteAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteAccount(client, 'account-123');\n * ```\n */\nexport async function deleteAccount<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Account.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteAccount] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteAccount] Error deleting account:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * User Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting users.\n */\n\nimport type { User } from \"@htlkg/core/types\";\nimport {\n\tcheckRestoreEligibility,\n\tDEFAULT_SOFT_DELETE_RETENTION_DAYS,\n} from \"../queries/systemSettings\";\nimport type { CreateAuditFields, UpdateWithSoftDeleteFields } from \"./common\";\n\n/**\n * Input type for creating a user\n */\nexport interface CreateUserInput extends CreateAuditFields {\n\tcognitoId: string;\n\temail: string;\n\taccountId: string;\n\tbrandIds?: string[];\n\troles?: string[];\n\tpermissions?: Record<string, any>;\n\tstatus?: \"active\" | \"inactive\" | \"pending\" | \"suspended\" | \"deleted\";\n}\n\n/**\n * Input type for updating a user\n */\nexport interface UpdateUserInput extends UpdateWithSoftDeleteFields {\n\tid: string;\n\temail?: string;\n\tbrandIds?: string[];\n\troles?: string[];\n\tpermissions?: Record<string, any>;\n\tlastLogin?: string;\n\tstatus?: \"active\" | \"inactive\" | \"pending\" | \"suspended\" | \"deleted\";\n}\n\n/**\n * Create a new user\n *\n * @example\n * ```typescript\n * import { createUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await createUser(client, {\n * cognitoId: 'cognito-123',\n * email: 'user@example.com',\n * accountId: 'account-123',\n * roles: ['BRAND_ADMIN'],\n * status: 'active'\n * });\n * ```\n */\nexport async function createUser<TClient = any>(\n\tclient: TClient,\n\tinput: CreateUserInput,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createUser] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as User;\n\t} catch (error) {\n\t\tconsole.error(\"[createUser] Error creating user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing user\n *\n * @example\n * ```typescript\n * import { updateUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await updateUser(client, {\n * id: 'user-123',\n * roles: ['BRAND_ADMIN', 'ACCOUNT_ADMIN'],\n * status: 'active'\n * });\n * ```\n */\nexport async function updateUser<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateUserInput,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateUser] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as User;\n\t} catch (error) {\n\t\tconsole.error(\"[updateUser] Error updating user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Soft delete a user (sets status to \"deleted\" instead of removing)\n *\n * @example\n * ```typescript\n * import { softDeleteUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await softDeleteUser(client, 'user-123', 'admin@example.com');\n * ```\n */\nexport async function softDeleteUser<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tdeletedBy: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.User.update({\n\t\t\tid,\n\t\t\tstatus: \"deleted\",\n\t\t\tdeletedAt: new Date().toISOString(),\n\t\t\tdeletedBy,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[softDeleteUser] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[softDeleteUser] Error soft-deleting user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Restore a soft-deleted user (sets status back to \"active\")\n * Checks retention period before allowing restoration\n *\n * @example\n * ```typescript\n * import { restoreUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await restoreUser(client, 'user-123');\n * // Or with custom retention days:\n * await restoreUser(client, 'user-123', 60);\n * ```\n */\nexport async function restoreUser<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tretentionDays: number = DEFAULT_SOFT_DELETE_RETENTION_DAYS,\n): Promise<{ success: boolean; error?: string }> {\n\ttry {\n\t\t// First, get the user to check its deletedAt timestamp\n\t\tconst { data: user, errors: getErrors } = await (\n\t\t\tclient as any\n\t\t).models.User.get({ id });\n\n\t\tif (getErrors || !user) {\n\t\t\tconsole.error(\"[restoreUser] Error fetching user:\", getErrors);\n\t\t\treturn { success: false, error: \"User not found\" };\n\t\t}\n\n\t\t// Check if restoration is allowed based on retention period\n\t\tconst eligibility = checkRestoreEligibility(user.deletedAt, retentionDays);\n\n\t\tif (!eligibility.canRestore) {\n\t\t\tconst errorMsg = `Cannot restore user. Retention period of ${retentionDays} days has expired. Item was deleted ${eligibility.daysExpired} days ago.`;\n\t\t\tconsole.error(\"[restoreUser]\", errorMsg);\n\t\t\treturn { success: false, error: errorMsg };\n\t\t}\n\n\t\tconst { errors } = await (client as any).models.User.update({\n\t\t\tid,\n\t\t\tstatus: \"active\",\n\t\t\tdeletedAt: null,\n\t\t\tdeletedBy: null,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[restoreUser] GraphQL errors:\", errors);\n\t\t\treturn { success: false, error: \"Failed to restore user\" };\n\t\t}\n\n\t\treturn { success: true };\n\t} catch (error) {\n\t\tconsole.error(\"[restoreUser] Error restoring user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Hard delete a user (permanently removes from database)\n * Use with caution - prefer softDeleteUser for recoverable deletion\n *\n * @example\n * ```typescript\n * import { deleteUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteUser(client, 'user-123');\n * ```\n */\nexport async function deleteUser<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.User.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteUser] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteUser] Error deleting user:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * ProductInstance Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting product instances.\n * Product instances represent enabled products for a specific brand with their configuration.\n */\n\nimport type { ProductInstance } from \"@htlkg/core/types\";\nimport { getClientUser } from \"@htlkg/core/auth\";\nimport { getCurrentTimestamp } from \"@htlkg/core/utils\";\nimport { AppError } from \"@htlkg/core/errors\";\nimport type { CreateAuditFields, UpdateAuditFields } from \"../common\";\n\n/**\n * Get current user identifier for audit trails\n * Uses getClientUser() and returns email or username, falling back to \"system\"\n */\nasync function getUserIdentifier(fallback = \"system\"): Promise<string> {\n\ttry {\n\t\tconst user = await getClientUser();\n\t\tif (user) {\n\t\t\treturn user.email || user.username || fallback;\n\t\t}\n\t\treturn fallback;\n\t} catch {\n\t\treturn fallback;\n\t}\n}\n\n/**\n * Input type for creating a product instance\n */\nexport interface CreateProductInstanceInput extends CreateAuditFields {\n\tproductId: string;\n\tbrandId: string;\n\taccountId: string;\n\tproductName: string;\n\tenabled: boolean;\n\tconfig?: Record<string, any>;\n\tversion?: string;\n}\n\n/**\n * Input type for updating a product instance\n */\nexport interface UpdateProductInstanceInput extends UpdateAuditFields {\n\tid: string;\n\tenabled?: boolean;\n\tconfig?: Record<string, any>;\n\tversion?: string;\n}\n\n/**\n * Create a new product instance\n *\n * @example\n * ```typescript\n * import { createProductInstance } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instance = await createProductInstance(client, {\n * productId: 'product-123',\n * brandId: 'brand-456',\n * accountId: 'account-789',\n * enabled: true,\n * config: { apiKey: 'xxx', maxRequests: 100 }\n * });\n * ```\n */\nexport async function createProductInstance<TClient = any>(\n\tclient: TClient,\n\tinput: CreateProductInstanceInput,\n): Promise<ProductInstance | null> {\n\ttry {\n\t\t// Get user identifier for audit trail\n\t\tconst userIdentifier = input.createdBy || input.updatedBy || await getUserIdentifier();\n\n\t\t// Build input - manually construct to avoid Vue Proxy issues\n\t\tconst timestamp = input.createdAt || getCurrentTimestamp();\n\t\tconst createInput: any = {\n\t\t\tproductId: input.productId,\n\t\t\tproductName: input.productName,\n\t\t\tbrandId: input.brandId,\n\t\t\taccountId: input.accountId,\n\t\t\tenabled: input.enabled,\n\t\t\tversion: input.version,\n\t\t\tcreatedAt: timestamp,\n\t\t\tcreatedBy: userIdentifier,\n\t\t\tupdatedAt: input.updatedAt || timestamp,\n\t\t\tupdatedBy: userIdentifier,\n\t\t};\n\n\t\t// AWSJSON type requires JSON STRING\n\t\tif (input.config) {\n\t\t\t// Double stringify: first to strip Vue Proxy, second to create JSON string\n\t\t\tcreateInput.config = JSON.stringify(JSON.parse(JSON.stringify(input.config)));\n\t\t}\n\n\t\tconsole.log(\"[createProductInstance] Config as string:\", createInput.config);\n\t\tconsole.log(\"[createProductInstance] Config type:\", typeof createInput.config);\n\n\t\tconst { data, errors } = await (client as any).models.ProductInstance.create(createInput);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createProductInstance] GraphQL errors:\", errors);\n\t\t\tthrow new AppError(\n\t\t\t\t\"Failed to create product instance\",\n\t\t\t\t\"PRODUCT_INSTANCE_CREATE_ERROR\",\n\t\t\t\t500,\n\t\t\t\t{ errors }\n\t\t\t);\n\t\t}\n\n\t\treturn data as ProductInstance;\n\t} catch (error) {\n\t\tconsole.error(\"[createProductInstance] Error creating product instance:\", error);\n\t\tif (error instanceof AppError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new AppError(\n\t\t\t\"Failed to create product instance\",\n\t\t\t\"PRODUCT_INSTANCE_CREATE_ERROR\",\n\t\t\t500,\n\t\t\t{ originalError: error }\n\t\t);\n\t}\n}\n\n/**\n * Update an existing product instance\n *\n * @example\n * ```typescript\n * import { updateProductInstance } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instance = await updateProductInstance(client, {\n * id: 'instance-123',\n * enabled: false,\n * config: { apiKey: 'new-key', maxRequests: 200 }\n * });\n * ```\n */\nexport async function updateProductInstance<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateProductInstanceInput,\n): Promise<ProductInstance | null> {\n\ttry {\n\t\t// Add timestamp and user metadata if not provided\n\t\t// Convert config from Vue Proxy to plain object\n\t\tconst updateInput: any = {\n\t\t\t...input,\n\t\t\tupdatedAt: input.updatedAt || getCurrentTimestamp(),\n\t\t\tupdatedBy: input.updatedBy || await getUserIdentifier(),\n\t\t};\n\n\t\t// AWSJSON type requires JSON STRING\n\t\tif (input.config) {\n\t\t\tupdateInput.config = JSON.stringify(JSON.parse(JSON.stringify(input.config)));\n\t\t}\n\n\t\tconst { data, errors } = await (client as any).models.ProductInstance.update(updateInput);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateProductInstance] GraphQL errors:\", errors);\n\t\t\tthrow new AppError(\n\t\t\t\t\"Failed to update product instance\",\n\t\t\t\t\"PRODUCT_INSTANCE_UPDATE_ERROR\",\n\t\t\t\t500,\n\t\t\t\t{ errors }\n\t\t\t);\n\t\t}\n\n\t\treturn data as ProductInstance;\n\t} catch (error) {\n\t\tconsole.error(\"[updateProductInstance] Error updating product instance:\", error);\n\t\tif (error instanceof AppError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new AppError(\n\t\t\t\"Failed to update product instance\",\n\t\t\t\"PRODUCT_INSTANCE_UPDATE_ERROR\",\n\t\t\t500,\n\t\t\t{ originalError: error }\n\t\t);\n\t}\n}\n\n/**\n * Delete a product instance\n *\n * @example\n * ```typescript\n * import { deleteProductInstance } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteProductInstance(client, 'instance-123');\n * ```\n */\nexport async function deleteProductInstance<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.ProductInstance.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteProductInstance] GraphQL errors:\", errors);\n\t\t\tthrow new AppError(\n\t\t\t\t\"Failed to delete product instance\",\n\t\t\t\t\"PRODUCT_INSTANCE_DELETE_ERROR\",\n\t\t\t\t500,\n\t\t\t\t{ errors }\n\t\t\t);\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteProductInstance] Error deleting product instance:\", error);\n\t\tif (error instanceof AppError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new AppError(\n\t\t\t\"Failed to delete product instance\",\n\t\t\t\"PRODUCT_INSTANCE_DELETE_ERROR\",\n\t\t\t500,\n\t\t\t{ originalError: error }\n\t\t);\n\t}\n}\n\n/**\n * Toggle the enabled status of a product instance\n *\n * @example\n * ```typescript\n * import { toggleProductInstanceEnabled } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instance = await toggleProductInstanceEnabled(client, 'instance-123', true);\n * ```\n */\nexport async function toggleProductInstanceEnabled<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tenabled: boolean,\n): Promise<ProductInstance | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.ProductInstance.update({\n\t\t\tid,\n\t\t\tenabled,\n\t\t\tlastUpdated: getCurrentTimestamp(),\n\t\t\tupdatedBy: await getUserIdentifier(),\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[toggleProductInstanceEnabled] GraphQL errors:\", errors);\n\t\t\tthrow new AppError(\n\t\t\t\t\"Failed to toggle product instance\",\n\t\t\t\t\"PRODUCT_INSTANCE_TOGGLE_ERROR\",\n\t\t\t\t500,\n\t\t\t\t{ errors }\n\t\t\t);\n\t\t}\n\n\t\treturn data as ProductInstance;\n\t} catch (error) {\n\t\tconsole.error(\"[toggleProductInstanceEnabled] Error toggling product instance:\", error);\n\t\tif (error instanceof AppError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new AppError(\n\t\t\t\"Failed to toggle product instance\",\n\t\t\t\"PRODUCT_INSTANCE_TOGGLE_ERROR\",\n\t\t\t500,\n\t\t\t{ originalError: error }\n\t\t);\n\t}\n}\n","/**\n * SystemSettings Mutation Functions\n *\n * Provides mutation functions for managing system settings.\n */\n\nimport type { SystemSettings } from \"@htlkg/core/types\";\nimport {\n\tSYSTEM_SETTINGS_KEY,\n\tDEFAULT_SOFT_DELETE_RETENTION_DAYS,\n} from \"../queries/systemSettings\";\n\n/**\n * Input type for updating system settings\n */\nexport interface UpdateSystemSettingsInput {\n\tsoftDeleteRetentionDays: number;\n\tupdatedBy: string;\n}\n\n/**\n * Update or create system settings\n * Only SUPER_ADMINS can update system settings\n *\n * @example\n * ```typescript\n * import { updateSystemSettings } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const settings = await updateSystemSettings(client, {\n * softDeleteRetentionDays: 60,\n * updatedBy: 'admin@example.com'\n * });\n * ```\n */\nexport async function updateSystemSettings<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateSystemSettingsInput,\n): Promise<SystemSettings | null> {\n\ttry {\n\t\t// Validate retention days (minimum 1 day, maximum 365 days)\n\t\tif (input.softDeleteRetentionDays < 1 || input.softDeleteRetentionDays > 365) {\n\t\t\tconsole.error(\n\t\t\t\t\"[updateSystemSettings] Invalid retention days. Must be between 1 and 365.\",\n\t\t\t);\n\t\t\treturn null;\n\t\t}\n\n\t\t// First, try to get existing settings\n\t\tconst { data: existing } = await (client as any).models.SystemSettings.get({\n\t\t\tkey: SYSTEM_SETTINGS_KEY,\n\t\t});\n\n\t\tconst settingsData = {\n\t\t\tkey: SYSTEM_SETTINGS_KEY,\n\t\t\tsoftDeleteRetentionDays: input.softDeleteRetentionDays,\n\t\t\tupdatedAt: new Date().toISOString(),\n\t\t\tupdatedBy: input.updatedBy,\n\t\t};\n\n\t\tlet result;\n\t\tif (existing) {\n\t\t\t// Update existing settings\n\t\t\tresult = await (client as any).models.SystemSettings.update(settingsData);\n\t\t} else {\n\t\t\t// Create new settings\n\t\t\tresult = await (client as any).models.SystemSettings.create(settingsData);\n\t\t}\n\n\t\tif (result.errors) {\n\t\t\tconsole.error(\"[updateSystemSettings] GraphQL errors:\", result.errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn result.data as SystemSettings;\n\t} catch (error) {\n\t\tconsole.error(\"[updateSystemSettings] Error updating system settings:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Initialize system settings with default values if they don't exist\n *\n * @example\n * ```typescript\n * import { initializeSystemSettings } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const settings = await initializeSystemSettings(client, 'system@hotelinking.com');\n * ```\n */\nexport async function initializeSystemSettings<TClient = any>(\n\tclient: TClient,\n\tinitializedBy: string,\n): Promise<SystemSettings | null> {\n\ttry {\n\t\t// Check if settings already exist\n\t\tconst { data: existing } = await (client as any).models.SystemSettings.get({\n\t\t\tkey: SYSTEM_SETTINGS_KEY,\n\t\t});\n\n\t\tif (existing) {\n\t\t\treturn existing as SystemSettings;\n\t\t}\n\n\t\t// Create default settings\n\t\tconst { data, errors } = await (client as any).models.SystemSettings.create({\n\t\t\tkey: SYSTEM_SETTINGS_KEY,\n\t\t\tsoftDeleteRetentionDays: DEFAULT_SOFT_DELETE_RETENTION_DAYS,\n\t\t\tupdatedAt: new Date().toISOString(),\n\t\t\tupdatedBy: initializedBy,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[initializeSystemSettings] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as SystemSettings;\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t\"[initializeSystemSettings] Error initializing system settings:\",\n\t\t\terror,\n\t\t);\n\t\tthrow error;\n\t}\n}\n","/**\n * Reservation Mutation Functions\n *\n * Provides type-safe mutation functions for creating, updating, and deleting reservations.\n * Includes date validation and status transition rules.\n */\n\nimport {\n\tcheckRestoreEligibility,\n\tDEFAULT_SOFT_DELETE_RETENTION_DAYS,\n} from \"../queries/systemSettings\";\nimport type { CreateAuditFields, UpdateWithSoftDeleteFields } from \"./common\";\n\n/**\n * Reservation status type\n */\nexport type ReservationStatus = \"confirmed\" | \"checked_in\" | \"checked_out\" | \"cancelled\" | \"no_show\";\n\n/**\n * Valid status transitions for reservations\n * Maps current status -> allowed next statuses\n */\nconst STATUS_TRANSITIONS: Record<ReservationStatus, ReservationStatus[]> = {\n\tconfirmed: [\"checked_in\", \"cancelled\", \"no_show\"],\n\tchecked_in: [\"checked_out\", \"cancelled\"],\n\tchecked_out: [], // Terminal state - no transitions allowed\n\tcancelled: [], // Terminal state - no transitions allowed\n\tno_show: [], // Terminal state - no transitions allowed\n};\n\n/**\n * Validation error class for reservation operations\n */\nexport class ReservationValidationError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"ReservationValidationError\";\n\t}\n}\n\n/**\n * Validate check-in and check-out dates\n * @throws {ReservationValidationError} if dates are invalid\n */\nfunction validateDates(checkIn: string, checkOut: string): void {\n\tconst checkInDate = new Date(checkIn);\n\tconst checkOutDate = new Date(checkOut);\n\n\t// Check if dates are valid\n\tif (isNaN(checkInDate.getTime())) {\n\t\tthrow new ReservationValidationError(\"Invalid check-in date\");\n\t}\n\n\tif (isNaN(checkOutDate.getTime())) {\n\t\tthrow new ReservationValidationError(\"Invalid check-out date\");\n\t}\n\n\t// Check-out must be after check-in\n\tif (checkOutDate <= checkInDate) {\n\t\tthrow new ReservationValidationError(\n\t\t\t\"Check-out date must be after check-in date\"\n\t\t);\n\t}\n\n\t// Calculate minimum stay (at least a few hours)\n\tconst minStayHours = 4;\n\tconst stayDuration = checkOutDate.getTime() - checkInDate.getTime();\n\tconst hoursDiff = stayDuration / (1000 * 60 * 60);\n\n\tif (hoursDiff < minStayHours) {\n\t\tthrow new ReservationValidationError(\n\t\t\t`Minimum stay is ${minStayHours} hours`\n\t\t);\n\t}\n}\n\n/**\n * Validate status transition\n * @throws {ReservationValidationError} if transition is not allowed\n */\nfunction validateStatusTransition(\n\tcurrentStatus: ReservationStatus,\n\tnewStatus: ReservationStatus\n): void {\n\tconst allowedTransitions = STATUS_TRANSITIONS[currentStatus];\n\n\tif (!allowedTransitions.includes(newStatus)) {\n\t\tthrow new ReservationValidationError(\n\t\t\t`Invalid status transition from '${currentStatus}' to '${newStatus}'. ` +\n\t\t\t`Allowed transitions: ${allowedTransitions.length > 0 ? allowedTransitions.join(\", \") : \"none (terminal state)\"}`\n\t\t);\n\t}\n}\n\n/**\n * Input type for creating a reservation\n */\nexport interface CreateReservationInput extends CreateAuditFields {\n\tbrandId: string;\n\tvisitId: string;\n\tconfirmationCode: string;\n\tcheckIn: string;\n\tcheckOut: string;\n\tstatus?: \"confirmed\" | \"checked_in\" | \"checked_out\" | \"cancelled\" | \"no_show\";\n\tsource?: string;\n\tchannel?: string;\n\troomType?: string;\n\troom?: string;\n\ttotalAmount?: number;\n\tcurrency?: string;\n\tnights?: number;\n}\n\n/**\n * Input type for updating a reservation\n */\nexport interface UpdateReservationInput extends UpdateWithSoftDeleteFields {\n\tid: string;\n\tbrandId?: string;\n\tvisitId?: string;\n\tconfirmationCode?: string;\n\tcheckIn?: string;\n\tcheckOut?: string;\n\tstatus?: \"confirmed\" | \"checked_in\" | \"checked_out\" | \"cancelled\" | \"no_show\";\n\tsource?: string;\n\tchannel?: string;\n\troomType?: string;\n\troom?: string;\n\ttotalAmount?: number;\n\tcurrency?: string;\n\tnights?: number;\n}\n\n/**\n * Create a new reservation with date validation\n *\n * @throws {ReservationValidationError} if dates are invalid\n *\n * @example\n * ```typescript\n * import { createReservation } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const reservation = await createReservation(client, {\n * brandId: 'brand-123',\n * visitId: 'visit-456',\n * confirmationCode: 'ABC123',\n * checkIn: '2024-01-01',\n * checkOut: '2024-01-05',\n * status: 'confirmed'\n * });\n * ```\n */\nexport async function createReservation<TClient = any>(\n\tclient: TClient,\n\tinput: CreateReservationInput,\n): Promise<any | null> {\n\ttry {\n\t\t// Validate dates before creating\n\t\tvalidateDates(input.checkIn, input.checkOut);\n\n\t\t// Calculate nights if not provided\n\t\tif (!input.nights) {\n\t\t\tconst checkInDate = new Date(input.checkIn);\n\t\t\tconst checkOutDate = new Date(input.checkOut);\n\t\t\tconst diffTime = checkOutDate.getTime() - checkInDate.getTime();\n\t\t\tconst diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));\n\t\t\tinput.nights = diffDays;\n\t\t}\n\n\t\tconst { data, errors } = await (client as any).models.Reservation.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createReservation] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data;\n\t} catch (error) {\n\t\tif (error instanceof ReservationValidationError) {\n\t\t\tconsole.error(\"[createReservation] Validation error:\", error.message);\n\t\t\tthrow error;\n\t\t}\n\t\tconsole.error(\"[createReservation] Error creating reservation:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing reservation with validation\n *\n * @throws {ReservationValidationError} if dates or status transition is invalid\n *\n * @example\n * ```typescript\n * import { updateReservation } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const reservation = await updateReservation(client, {\n * id: 'reservation-123',\n * status: 'checked_in',\n * room: '201'\n * });\n * ```\n */\nexport async function updateReservation<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateReservationInput,\n): Promise<any | null> {\n\ttry {\n\t\t// If both dates are being updated, validate them\n\t\tif (input.checkIn && input.checkOut) {\n\t\t\tvalidateDates(input.checkIn, input.checkOut);\n\n\t\t\t// Recalculate nights if dates changed\n\t\t\tconst checkInDate = new Date(input.checkIn);\n\t\t\tconst checkOutDate = new Date(input.checkOut);\n\t\t\tconst diffTime = checkOutDate.getTime() - checkInDate.getTime();\n\t\t\tconst diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));\n\t\t\tinput.nights = diffDays;\n\t\t}\n\n\t\t// If status is being updated, validate the transition\n\t\tif (input.status) {\n\t\t\t// Get current reservation to check current status\n\t\t\tconst { data: currentReservation, errors: getErrors } = await (\n\t\t\t\tclient as any\n\t\t\t).models.Reservation.get({ id: input.id });\n\n\t\t\tif (getErrors || !currentReservation) {\n\t\t\t\tconsole.error(\"[updateReservation] Error fetching current reservation:\", getErrors);\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst currentStatus = currentReservation.status as ReservationStatus;\n\t\t\tvalidateStatusTransition(currentStatus, input.status as ReservationStatus);\n\t\t}\n\n\t\tconst { data, errors } = await (client as any).models.Reservation.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateReservation] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data;\n\t} catch (error) {\n\t\tif (error instanceof ReservationValidationError) {\n\t\t\tconsole.error(\"[updateReservation] Validation error:\", error.message);\n\t\t\tthrow error;\n\t\t}\n\t\tconsole.error(\"[updateReservation] Error updating reservation:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Soft delete a reservation (sets deletedAt/deletedBy instead of removing)\n *\n * @example\n * ```typescript\n * import { softDeleteReservation } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await softDeleteReservation(client, 'reservation-123', 'admin@example.com');\n * ```\n */\nexport async function softDeleteReservation<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tdeletedBy: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Reservation.update({\n\t\t\tid,\n\t\t\tdeletedAt: new Date().toISOString(),\n\t\t\tdeletedBy,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[softDeleteReservation] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[softDeleteReservation] Error soft-deleting reservation:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Restore a soft-deleted reservation\n * Checks retention period before allowing restoration\n *\n * @example\n * ```typescript\n * import { restoreReservation } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await restoreReservation(client, 'reservation-123');\n * // Or with custom retention days:\n * await restoreReservation(client, 'reservation-123', 60);\n * ```\n */\nexport async function restoreReservation<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tretentionDays: number = DEFAULT_SOFT_DELETE_RETENTION_DAYS,\n): Promise<{ success: boolean; error?: string }> {\n\ttry {\n\t\t// First, get the reservation to check its deletedAt timestamp\n\t\tconst { data: reservation, errors: getErrors } = await (\n\t\t\tclient as any\n\t\t).models.Reservation.get({ id });\n\n\t\tif (getErrors || !reservation) {\n\t\t\tconsole.error(\"[restoreReservation] Error fetching reservation:\", getErrors);\n\t\t\treturn { success: false, error: \"Reservation not found\" };\n\t\t}\n\n\t\t// Check if restoration is allowed based on retention period\n\t\tconst eligibility = checkRestoreEligibility(reservation.deletedAt, retentionDays);\n\n\t\tif (!eligibility.canRestore) {\n\t\t\tconst errorMsg = `Cannot restore reservation. Retention period of ${retentionDays} days has expired. Item was deleted ${eligibility.daysExpired} days ago.`;\n\t\t\tconsole.error(\"[restoreReservation]\", errorMsg);\n\t\t\treturn { success: false, error: errorMsg };\n\t\t}\n\n\t\tconst { errors } = await (client as any).models.Reservation.update({\n\t\t\tid,\n\t\t\tdeletedAt: null,\n\t\t\tdeletedBy: null,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[restoreReservation] GraphQL errors:\", errors);\n\t\t\treturn { success: false, error: \"Failed to restore reservation\" };\n\t\t}\n\n\t\treturn { success: true };\n\t} catch (error) {\n\t\tconsole.error(\"[restoreReservation] Error restoring reservation:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Hard delete a reservation (permanently removes from database)\n * Use with caution - prefer softDeleteReservation for recoverable deletion\n *\n * @example\n * ```typescript\n * import { deleteReservation } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteReservation(client, 'reservation-123');\n * ```\n */\nexport async function deleteReservation<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Reservation.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteReservation] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteReservation] Error deleting reservation:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update reservation status with validation\n *\n * Validates that the status transition is allowed based on current status.\n * Status transition rules:\n * - confirmed → checked_in, cancelled, no_show\n * - checked_in → checked_out, cancelled\n * - checked_out → (terminal state, no transitions)\n * - cancelled → (terminal state, no transitions)\n * - no_show → (terminal state, no transitions)\n *\n * @throws {ReservationValidationError} if status transition is invalid\n *\n * @example\n * ```typescript\n * import { updateReservationStatus } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const reservation = await updateReservationStatus(\n * client,\n * 'reservation-123',\n * 'checked_in'\n * );\n * ```\n */\nexport async function updateReservationStatus<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tnewStatus: ReservationStatus,\n): Promise<any | null> {\n\ttry {\n\t\t// Get current reservation to check current status\n\t\tconst { data: currentReservation, errors: getErrors } = await (\n\t\t\tclient as any\n\t\t).models.Reservation.get({ id });\n\n\t\tif (getErrors || !currentReservation) {\n\t\t\tconsole.error(\"[updateReservationStatus] Error fetching reservation:\", getErrors);\n\t\t\treturn null;\n\t\t}\n\n\t\tconst currentStatus = currentReservation.status as ReservationStatus;\n\n\t\t// Validate status transition\n\t\tvalidateStatusTransition(currentStatus, newStatus);\n\n\t\t// Perform the update\n\t\tconst { data, errors } = await (client as any).models.Reservation.update({\n\t\t\tid,\n\t\t\tstatus: newStatus,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateReservationStatus] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data;\n\t} catch (error) {\n\t\tif (error instanceof ReservationValidationError) {\n\t\t\tconsole.error(\"[updateReservationStatus] Validation error:\", error.message);\n\t\t\tthrow error;\n\t\t}\n\t\tconsole.error(\"[updateReservationStatus] Error updating status:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * Contact Mutation Functions\n *\n * Provides type-safe mutation functions for creating, updating, and deleting contacts.\n * Includes Zod validation for input data before mutations.\n */\n\nimport { z } from \"zod\";\nimport type { Contact } from \"@htlkg/core/types\";\nimport {\n\tcheckRestoreEligibility,\n\tDEFAULT_SOFT_DELETE_RETENTION_DAYS,\n} from \"../queries/systemSettings\";\nimport { getContact } from \"../queries/contacts\";\nimport type { CreateAuditFields, UpdateWithSoftDeleteFields } from \"./common\";\n\n// ============================================\n// Added Zod Validation Schemas\n// ============================================\n\n/**\n * Zod schema for creating a contact \n */\nexport const createContactSchema = z.object({\n\tbrandId: z.string().min(1, \"Brand ID is required\"),\n\temail: z.string().email(\"Invalid email address\"),\n\tphone: z.string().optional(),\n\tfirstName: z.string().min(1, \"First name is required\"),\n\tlastName: z.string().min(1, \"Last name is required\"),\n\tlocale: z.string().optional(),\n\tgdprConsent: z.boolean(),\n\tgdprConsentDate: z.string().optional(),\n\tmarketingOptIn: z.boolean().optional(),\n\tpreferences: z.record(z.any()).optional(),\n\ttags: z.array(z.string()).optional(),\n\ttotalVisits: z.number().int().min(0).optional(),\n\tlastVisitDate: z.string().optional(),\n\tfirstVisitDate: z.string().optional(),\n\tlegacyId: z.string().optional(),\n\t// Audit fields\n\tcreatedAt: z.string().optional(),\n\tcreatedBy: z.string().optional(),\n\tupdatedAt: z.string().optional(),\n\tupdatedBy: z.string().optional(),\n});\n\n/**\n * Zod schema for updating a contact\n */\nexport const updateContactSchema = z.object({\n\tid: z.string().min(1, \"Contact ID is required\"),\n\tbrandId: z.string().min(1).optional(),\n\temail: z.string().email(\"Invalid email address\").optional(),\n\tphone: z.string().optional(),\n\tfirstName: z.string().min(1).optional(),\n\tlastName: z.string().min(1).optional(),\n\tlocale: z.string().optional(),\n\tgdprConsent: z.boolean().optional(),\n\tgdprConsentDate: z.string().optional(),\n\tmarketingOptIn: z.boolean().optional(),\n\tpreferences: z.record(z.any()).optional(),\n\ttags: z.array(z.string()).optional(),\n\ttotalVisits: z.number().int().min(0).optional(),\n\tlastVisitDate: z.string().optional(),\n\tfirstVisitDate: z.string().optional(),\n\tlegacyId: z.string().optional(),\n\t// Audit fields\n\tupdatedAt: z.string().optional(),\n\tupdatedBy: z.string().optional(),\n\tdeletedAt: z.string().nullable().optional(),\n\tdeletedBy: z.string().nullable().optional(),\n});\n\n/**\n * Zod schema for merging contacts\n */\nexport const mergeContactsSchema = z.object({\n\tprimaryId: z.string().min(1, \"Primary contact ID is required\"),\n\tduplicateIds: z.array(z.string().min(1)).min(1, \"At least one duplicate ID is required\"),\n});\n\n// ============================================\n// Validation Error Class\n// ============================================\n\n/**\n * Validation error class for contact operations\n */\nexport class ContactValidationError extends Error {\n\tpublic readonly issues: z.ZodIssue[];\n\n\tconstructor(message: string, issues: z.ZodIssue[] = []) {\n\t\tsuper(message);\n\t\tthis.name = \"ContactValidationError\";\n\t\tthis.issues = issues;\n\t}\n}\n\n// ============================================\n// Input Types\n// ============================================\n\n/**\n * Input type for creating a contact\n */\nexport interface CreateContactInput extends CreateAuditFields {\n\tbrandId: string;\n\temail: string;\n\tphone?: string;\n\tfirstName: string;\n\tlastName: string;\n\tlocale?: string;\n\tgdprConsent: boolean;\n\tgdprConsentDate?: string;\n\tmarketingOptIn?: boolean;\n\tpreferences?: Record<string, any>;\n\ttags?: string[];\n\ttotalVisits?: number;\n\tlastVisitDate?: string;\n\tfirstVisitDate?: string;\n\tlegacyId?: string;\n}\n\n/**\n * Input type for updating a contact\n */\nexport interface UpdateContactInput extends UpdateWithSoftDeleteFields {\n\tid: string;\n\tbrandId?: string;\n\temail?: string;\n\tphone?: string;\n\tfirstName?: string;\n\tlastName?: string;\n\tlocale?: string;\n\tgdprConsent?: boolean;\n\tgdprConsentDate?: string;\n\tmarketingOptIn?: boolean;\n\tpreferences?: Record<string, any>;\n\ttags?: string[];\n\ttotalVisits?: number;\n\tlastVisitDate?: string;\n\tfirstVisitDate?: string;\n\tlegacyId?: string;\n}\n\n/**\n * Input type for merging contacts\n */\nexport interface MergeContactsInput {\n\tprimaryId: string;\n\tduplicateIds: string[];\n}\n\n/**\n * Result type for merge operation\n */\nexport interface MergeContactsResult {\n\tsuccess: boolean;\n\tmergedContact?: Contact;\n\tdeletedIds?: string[];\n\terror?: string;\n}\n\n// ============================================\n// Mutation Functions\n// ============================================\n\n/**\n * Create a new contact with Zod validation\n *\n * @throws {ContactValidationError} if input validation fails\n *\n * @example\n * ```typescript\n * import { createContact } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const contact = await createContact(client, {\n * brandId: 'brand-123',\n * email: 'guest@example.com',\n * firstName: 'John',\n * lastName: 'Doe',\n * gdprConsent: true,\n * gdprConsentDate: new Date().toISOString()\n * });\n * ```\n */\nexport async function createContact<TClient = any>(\n\tclient: TClient,\n\tinput: CreateContactInput,\n): Promise<Contact | null> {\n\ttry {\n\t\t// Validate input with Zod\n\t\tconst validationResult = createContactSchema.safeParse(input);\n\n\t\tif (!validationResult.success) {\n\t\t\tconst errorMessage = validationResult.error.issues\n\t\t\t\t.map((issue) => `${issue.path.join(\".\")}: ${issue.message}`)\n\t\t\t\t.join(\", \");\n\t\t\tthrow new ContactValidationError(\n\t\t\t\t`Validation failed: ${errorMessage}`,\n\t\t\t\tvalidationResult.error.issues\n\t\t\t);\n\t\t}\n\n\t\tconst { data, errors } = await (client as any).models.Contact.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createContact] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Contact;\n\t} catch (error) {\n\t\tif (error instanceof ContactValidationError) {\n\t\t\tconsole.error(\"[createContact] Validation error:\", error.message);\n\t\t\tthrow error;\n\t\t}\n\t\tconsole.error(\"[createContact] Error creating contact:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing contact with Zod validation\n *\n * @throws {ContactValidationError} if input validation fails\n *\n * @example\n * ```typescript\n * import { updateContact } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const contact = await updateContact(client, {\n * id: 'contact-123',\n * firstName: 'Jane',\n * marketingOptIn: true\n * });\n * ```\n */\nexport async function updateContact<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateContactInput,\n): Promise<Contact | null> {\n\ttry {\n\t\t// Validate input with Zod\n\t\tconst validationResult = updateContactSchema.safeParse(input);\n\n\t\tif (!validationResult.success) {\n\t\t\tconst errorMessage = validationResult.error.issues\n\t\t\t\t.map((issue) => `${issue.path.join(\".\")}: ${issue.message}`)\n\t\t\t\t.join(\", \");\n\t\t\tthrow new ContactValidationError(\n\t\t\t\t`Validation failed: ${errorMessage}`,\n\t\t\t\tvalidationResult.error.issues\n\t\t\t);\n\t\t}\n\n\t\tconst { data, errors } = await (client as any).models.Contact.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateContact] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Contact;\n\t} catch (error) {\n\t\tif (error instanceof ContactValidationError) {\n\t\t\tconsole.error(\"[updateContact] Validation error:\", error.message);\n\t\t\tthrow error;\n\t\t}\n\t\tconsole.error(\"[updateContact] Error updating contact:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Soft delete a contact (sets deletedAt/deletedBy instead of removing)\n *\n * @example\n * ```typescript\n * import { softDeleteContact } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await softDeleteContact(client, 'contact-123', 'admin@example.com');\n * ```\n */\nexport async function softDeleteContact<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tdeletedBy: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Contact.update({\n\t\t\tid,\n\t\t\tdeletedAt: new Date().toISOString(),\n\t\t\tdeletedBy,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[softDeleteContact] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[softDeleteContact] Error soft-deleting contact:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Restore a soft-deleted contact\n * Checks retention period before allowing restoration\n *\n * @example\n * ```typescript\n * import { restoreContact } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await restoreContact(client, 'contact-123');\n * // Or with custom retention days:\n * await restoreContact(client, 'contact-123', 60);\n * ```\n */\nexport async function restoreContact<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tretentionDays: number = DEFAULT_SOFT_DELETE_RETENTION_DAYS,\n): Promise<{ success: boolean; error?: string }> {\n\ttry {\n\t\t// First, get the contact to check its deletedAt timestamp\n\t\tconst contact = await getContact(client, id);\n\n\t\tif (!contact) {\n\t\t\tconsole.error(\"[restoreContact] Contact not found\");\n\t\t\treturn { success: false, error: \"Contact not found\" };\n\t\t}\n\n\t\t// Check if restoration is allowed based on retention period\n\t\tconst eligibility = checkRestoreEligibility(\n\t\t\t(contact as any).deletedAt,\n\t\t\tretentionDays\n\t\t);\n\n\t\tif (!eligibility.canRestore) {\n\t\t\tconst errorMsg = `Cannot restore contact. Retention period of ${retentionDays} days has expired. Item was deleted ${eligibility.daysExpired} days ago.`;\n\t\t\tconsole.error(\"[restoreContact]\", errorMsg);\n\t\t\treturn { success: false, error: errorMsg };\n\t\t}\n\n\t\tconst { errors } = await (client as any).models.Contact.update({\n\t\t\tid,\n\t\t\tdeletedAt: null,\n\t\t\tdeletedBy: null,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[restoreContact] GraphQL errors:\", errors);\n\t\t\treturn { success: false, error: \"Failed to restore contact\" };\n\t\t}\n\n\t\treturn { success: true };\n\t} catch (error) {\n\t\tconsole.error(\"[restoreContact] Error restoring contact:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Hard delete a contact (permanently removes from database)\n * Use with caution - prefer softDeleteContact for recoverable deletion\n *\n * @example\n * ```typescript\n * import { deleteContact } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteContact(client, 'contact-123');\n * ```\n */\nexport async function deleteContact<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Contact.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteContact] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteContact] Error deleting contact:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Merge duplicate contacts into a primary contact\n *\n * This function:\n * 1. Validates all contact IDs exist\n * 2. Aggregates data from duplicates into the primary contact\n * 3. Soft deletes the duplicate contacts\n * 4. Returns the updated primary contact\n *\n * Merge strategy:\n * - totalVisits: Sum of all contacts\n * - firstVisitDate: Earliest date across all contacts\n * - lastVisitDate: Latest date across all contacts\n * - tags: Merged unique tags from all contacts\n * - preferences: Primary contact preferences take precedence\n * - Other fields: Primary contact values are preserved\n *\n * @throws {ContactValidationError} if input validation fails\n *\n * @example\n * ```typescript\n * import { mergeContacts } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const result = await mergeContacts(client, {\n * primaryId: 'contact-primary',\n * duplicateIds: ['contact-dup-1', 'contact-dup-2']\n * }, 'admin@example.com');\n * ```\n */\nexport async function mergeContacts<TClient = any>(\n\tclient: TClient,\n\tinput: MergeContactsInput,\n\tmergedBy: string,\n): Promise<MergeContactsResult> {\n\ttry {\n\t\t// Validate input with Zod\n\t\tconst validationResult = mergeContactsSchema.safeParse(input);\n\n\t\tif (!validationResult.success) {\n\t\t\tconst errorMessage = validationResult.error.issues\n\t\t\t\t.map((issue) => `${issue.path.join(\".\")}: ${issue.message}`)\n\t\t\t\t.join(\", \");\n\t\t\tthrow new ContactValidationError(\n\t\t\t\t`Validation failed: ${errorMessage}`,\n\t\t\t\tvalidationResult.error.issues\n\t\t\t);\n\t\t}\n\n\t\tconst { primaryId, duplicateIds } = input;\n\n\t\t// Fetch primary contact\n\t\tconst primaryContact = await getContact(client, primaryId);\n\t\tif (!primaryContact) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: `Primary contact not found: ${primaryId}`,\n\t\t\t};\n\t\t}\n\n\t\t// Fetch all duplicate contacts\n\t\tconst duplicateContacts: Contact[] = [];\n\t\tfor (const duplicateId of duplicateIds) {\n\t\t\tconst duplicate = await getContact(client, duplicateId);\n\t\t\tif (!duplicate) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: `Duplicate contact not found: ${duplicateId}`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tduplicateContacts.push(duplicate);\n\t\t}\n\n\t\t// Aggregate data from duplicates\n\t\tlet totalVisits = primaryContact.totalVisits || 0;\n\t\tlet firstVisitDate = primaryContact.firstVisitDate;\n\t\tlet lastVisitDate = primaryContact.lastVisitDate;\n\t\tconst allTags = new Set<string>(primaryContact.tags || []);\n\n\t\tfor (const duplicate of duplicateContacts) {\n\t\t\t// Sum total visits\n\t\t\ttotalVisits += duplicate.totalVisits || 0;\n\n\t\t\t// Find earliest first visit date\n\t\t\tif (duplicate.firstVisitDate) {\n\t\t\t\tif (!firstVisitDate || duplicate.firstVisitDate < firstVisitDate) {\n\t\t\t\t\tfirstVisitDate = duplicate.firstVisitDate;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Find latest last visit date\n\t\t\tif (duplicate.lastVisitDate) {\n\t\t\t\tif (!lastVisitDate || duplicate.lastVisitDate > lastVisitDate) {\n\t\t\t\t\tlastVisitDate = duplicate.lastVisitDate;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Merge tags\n\t\t\tif (duplicate.tags) {\n\t\t\t\tduplicate.tags.forEach((tag) => allTags.add(tag));\n\t\t\t}\n\t\t}\n\n\t\t// Update primary contact with aggregated data\n\t\tconst updateInput: UpdateContactInput = {\n\t\t\tid: primaryId,\n\t\t\ttotalVisits,\n\t\t\tfirstVisitDate,\n\t\t\tlastVisitDate,\n\t\t\ttags: Array.from(allTags),\n\t\t\tupdatedAt: new Date().toISOString(),\n\t\t\tupdatedBy: mergedBy,\n\t\t};\n\n\t\tconst updatedPrimary = await updateContact(client, updateInput);\n\n\t\tif (!updatedPrimary) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: \"Failed to update primary contact with merged data\",\n\t\t\t};\n\t\t}\n\n\t\t// Soft delete all duplicate contacts\n\t\tconst deletedIds: string[] = [];\n\t\tfor (const duplicateId of duplicateIds) {\n\t\t\tconst deleted = await softDeleteContact(client, duplicateId, mergedBy);\n\t\t\tif (deleted) {\n\t\t\t\tdeletedIds.push(duplicateId);\n\t\t\t} else {\n\t\t\t\tconsole.error(`[mergeContacts] Failed to soft-delete duplicate: ${duplicateId}`);\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tmergedContact: updatedPrimary,\n\t\t\tdeletedIds,\n\t\t};\n\t} catch (error) {\n\t\tif (error instanceof ContactValidationError) {\n\t\t\tconsole.error(\"[mergeContacts] Validation error:\", error.message);\n\t\t\tthrow error;\n\t\t}\n\t\tconsole.error(\"[mergeContacts] Error merging contacts:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * Data Hook Factory\n *\n * Creates reusable Vue composables for fetching data from GraphQL models.\n * Provides a DRY approach to data fetching with consistent patterns.\n */\n\nimport { ref, computed, onMounted, type Ref, type ComputedRef } from \"vue\";\nimport { query, hasErrors, getErrorMessage } from \"../client/proxy\";\n\n/**\n * Configuration options for creating a data hook\n */\nexport interface CreateDataHookOptions<T, TOptions extends BaseHookOptions = BaseHookOptions> {\n\t/** The GraphQL model name (e.g., 'Account', 'User', 'Brand') */\n\tmodel: string;\n\t/** Default limit for queries */\n\tdefaultLimit?: number;\n\t/** Selection set for the query (fields to fetch) */\n\tselectionSet?: string[];\n\t/** Transform function to apply to fetched data */\n\ttransform?: (item: any) => T;\n\t/** Build filter from hook options */\n\tbuildFilter?: (options: TOptions) => any;\n\t/** Define computed properties based on the data */\n\tcomputedProperties?: Record<string, (data: T[]) => any>;\n\t/** Plural name for the data property (e.g., 'accounts', 'users') */\n\tdataPropertyName?: string;\n}\n\n/**\n * Base options available to all hooks\n */\nexport interface BaseHookOptions {\n\t/** Filter criteria */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n}\n\n/**\n * Return type for data hooks\n */\nexport interface DataHookReturn<T, TComputed extends Record<string, any> = Record<string, never>> {\n\t/** Reactive array of data */\n\tdata: Ref<T[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch data */\n\trefetch: () => Promise<void>;\n\t/** Computed properties */\n\tcomputed: { [K in keyof TComputed]: ComputedRef<TComputed[K]> };\n}\n\n// Reset function for testing convenience (no-op with proxy-based approach)\nexport function resetClientInstance(): void {\n\t// No-op: proxy-based approach doesn't need client reset\n}\n\n/**\n * Creates a reusable data hook for a specific model\n *\n * @example\n * ```typescript\n * // Create a simple hook\n * export const useAccounts = createDataHook<Account>({\n * model: 'Account',\n * dataPropertyName: 'accounts',\n * });\n *\n * // Usage\n * const { data: accounts, loading, error, refetch } = useAccounts();\n * ```\n *\n * @example\n * ```typescript\n * // Create a hook with custom filters and computed properties\n * interface UseBrandsOptions extends BaseHookOptions {\n * accountId?: string;\n * activeOnly?: boolean;\n * }\n *\n * export const useBrands = createDataHook<Brand, UseBrandsOptions>({\n * model: 'Brand',\n * dataPropertyName: 'brands',\n * buildFilter: (options) => {\n * const filter: any = options.filter || {};\n * if (options.accountId) filter.accountId = { eq: options.accountId };\n * if (options.activeOnly) filter.status = { eq: 'active' };\n * return Object.keys(filter).length > 0 ? filter : undefined;\n * },\n * computedProperties: {\n * activeBrands: (brands) => brands.filter(b => b.status === 'active'),\n * },\n * });\n * ```\n */\nexport function createDataHook<\n\tT,\n\tTOptions extends BaseHookOptions = BaseHookOptions,\n\tTComputed extends Record<string, any> = Record<string, never>,\n>(\n\tconfig: CreateDataHookOptions<T, TOptions> & {\n\t\tcomputedProperties?: { [K in keyof TComputed]: (data: T[]) => TComputed[K] };\n\t},\n) {\n\tconst {\n\t\tmodel,\n\t\tdefaultLimit,\n\t\tselectionSet,\n\t\ttransform,\n\t\tbuildFilter,\n\t\tcomputedProperties,\n\t\tdataPropertyName = \"data\",\n\t} = config;\n\n\treturn function useData(options: TOptions = {} as TOptions): DataHookReturn<T, TComputed> & Record<string, any> {\n\t\tconst { filter: baseFilter, limit = defaultLimit, autoFetch = true } = options;\n\n\t\t// State\n\t\tconst data = ref<T[]>([]) as Ref<T[]>;\n\t\tconst loading = ref(false);\n\t\tconst error = ref<Error | null>(null);\n\n\t\t// Build filter using custom builder or default\n\t\tconst getFilter = () => {\n\t\t\tif (buildFilter) {\n\t\t\t\treturn buildFilter(options);\n\t\t\t}\n\t\t\treturn baseFilter && Object.keys(baseFilter).length > 0 ? baseFilter : undefined;\n\t\t};\n\n\t\t// Fetch function using server proxy\n\t\tasync function fetch() {\n\t\t\tloading.value = true;\n\t\t\terror.value = null;\n\n\t\t\ttry {\n\t\t\t\tconst queryOptions: Record<string, any> = {};\n\n\t\t\t\tconst filter = getFilter();\n\t\t\t\tif (filter) {\n\t\t\t\t\tqueryOptions.filter = filter;\n\t\t\t\t}\n\n\t\t\t\tif (limit) {\n\t\t\t\t\tqueryOptions.limit = limit;\n\t\t\t\t}\n\n\t\t\t\tif (selectionSet) {\n\t\t\t\t\tqueryOptions.selectionSet = selectionSet;\n\t\t\t\t}\n\n\t\t\t\tconst response = await query(model, \"list\", queryOptions);\n\n\t\t\t\tif (hasErrors(response)) {\n\t\t\t\t\tthrow new Error(getErrorMessage(response) || `Failed to fetch ${model}`);\n\t\t\t\t}\n\n\t\t\t\tconst items = response.data || [];\n\t\t\t\tdata.value = transform ? items.map(transform) : items;\n\t\t\t} catch (e) {\n\t\t\t\terror.value = e as Error;\n\t\t\t\tconsole.error(`[use${model}] Error fetching ${model}:`, e);\n\t\t\t} finally {\n\t\t\t\tloading.value = false;\n\t\t\t}\n\t\t}\n\n\t\t// Create computed properties\n\t\tconst computedRefs: Record<string, ComputedRef<any>> = {};\n\t\tif (computedProperties) {\n\t\t\tfor (const [key, fn] of Object.entries(computedProperties)) {\n\t\t\t\tcomputedRefs[key] = computed(() => fn(data.value));\n\t\t\t}\n\t\t}\n\n\t\t// Auto-fetch on mount if enabled\n\t\tif (autoFetch) {\n\t\t\tonMounted(() => {\n\t\t\t\tfetch();\n\t\t\t});\n\t\t}\n\n\t\t// Build return object\n\t\tconst result: DataHookReturn<T, TComputed> & Record<string, any> = {\n\t\t\tdata,\n\t\t\tloading,\n\t\t\terror,\n\t\t\trefetch: fetch,\n\t\t\tcomputed: computedRefs as { [K in keyof TComputed]: ComputedRef<TComputed[K]> },\n\t\t};\n\n\t\t// Add data property with custom name for backwards compatibility\n\t\tif (dataPropertyName !== \"data\") {\n\t\t\tresult[dataPropertyName] = data;\n\t\t}\n\n\t\t// Add computed properties at top level for backwards compatibility\n\t\tfor (const [key, computedRef] of Object.entries(computedRefs)) {\n\t\t\tresult[key] = computedRef;\n\t\t}\n\n\t\treturn result;\n\t};\n}\n\n/**\n * Type helper to extract the return type of a created hook\n */\nexport type InferHookReturn<THook extends (...args: any[]) => any> = ReturnType<THook>;\n","/**\n * useBrands Hook\n *\n * Vue composable for fetching and managing brand data with reactive state.\n * Provides loading states, error handling, and refetch capabilities.\n */\n\nimport type { Ref, ComputedRef } from \"vue\";\nimport type { Brand } from \"@htlkg/core/types\";\nimport { createDataHook, type BaseHookOptions } from \"./createDataHook\";\n\nexport interface UseBrandsOptions extends BaseHookOptions {\n\t/** Filter criteria for brands */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n\t/** Filter by account ID */\n\taccountId?: string;\n\t/** Only active brands */\n\tactiveOnly?: boolean;\n}\n\nexport interface UseBrandsReturn {\n\t/** Reactive array of brands */\n\tbrands: Ref<Brand[]>;\n\t/** Computed array of active brands only */\n\tactiveBrands: ComputedRef<Brand[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch brands */\n\trefetch: () => Promise<void>;\n}\n\n/**\n * Build filter from hook options\n */\nfunction buildFilter(options: UseBrandsOptions): any {\n\tlet filter: any = options.filter || {};\n\n\tif (options.accountId) {\n\t\tfilter = { ...filter, accountId: { eq: options.accountId } };\n\t}\n\n\tif (options.activeOnly) {\n\t\tfilter = { ...filter, status: { eq: \"active\" } };\n\t}\n\n\treturn Object.keys(filter).length > 0 ? filter : undefined;\n}\n\n/**\n * Internal hook created by factory\n */\nconst useBrandsInternal = createDataHook<Brand, UseBrandsOptions, { activeBrands: Brand[] }>({\n\tmodel: \"Brand\",\n\tdataPropertyName: \"brands\",\n\tbuildFilter,\n\tcomputedProperties: {\n\t\tactiveBrands: (brands) => brands.filter((b) => b.status === \"active\"),\n\t},\n});\n\n/**\n * Composable for fetching and managing brands\n *\n * @example\n * ```typescript\n * import { useBrands } from '@htlkg/data/hooks';\n *\n * const { brands, loading, error, refetch } = useBrands();\n * ```\n *\n * @example With filters\n * ```typescript\n * const { brands, loading } = useBrands({\n * accountId: 'account-123',\n * activeOnly: true,\n * limit: 50\n * });\n * ```\n */\nexport function useBrands(options: UseBrandsOptions = {}): UseBrandsReturn {\n\tconst result = useBrandsInternal(options);\n\treturn {\n\t\tbrands: result.brands as Ref<Brand[]>,\n\t\tactiveBrands: result.activeBrands as ComputedRef<Brand[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t};\n}\n","/**\n * useAccounts Hook\n *\n * Vue composable for fetching and managing account data with reactive state.\n * Provides loading states, error handling, and refetch capabilities.\n */\n\nimport type { Ref } from \"vue\";\nimport type { Account } from \"@htlkg/core/types\";\nimport { createDataHook, type BaseHookOptions } from \"./createDataHook\";\n\nexport interface UseAccountsOptions extends BaseHookOptions {\n\t/** Filter criteria for accounts */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n}\n\nexport interface UseAccountsReturn {\n\t/** Reactive array of accounts */\n\taccounts: Ref<Account[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch accounts */\n\trefetch: () => Promise<void>;\n}\n\n/**\n * Internal hook created by factory\n */\nconst useAccountsInternal = createDataHook<Account, UseAccountsOptions>({\n\tmodel: \"Account\",\n\tdataPropertyName: \"accounts\",\n});\n\n/**\n * Composable for fetching and managing accounts\n *\n * @example\n * ```typescript\n * import { useAccounts } from '@htlkg/data/hooks';\n *\n * const { accounts, loading, error, refetch } = useAccounts();\n * ```\n *\n * @example With filters\n * ```typescript\n * const { accounts, loading } = useAccounts({\n * filter: { status: { eq: 'active' } },\n * limit: 50\n * });\n * ```\n */\nexport function useAccounts(options: UseAccountsOptions = {}): UseAccountsReturn {\n\tconst result = useAccountsInternal(options);\n\treturn {\n\t\taccounts: result.accounts as Ref<Account[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t};\n}\n","/**\n * useUsers Hook\n *\n * Vue composable for fetching and managing user data with reactive state.\n * Provides loading states, error handling, and refetch capabilities.\n */\n\nimport type { Ref } from \"vue\";\nimport type { User } from \"@htlkg/core/types\";\nimport { createDataHook, type BaseHookOptions } from \"./createDataHook\";\n\nexport interface UseUsersOptions extends BaseHookOptions {\n\t/** Filter criteria for users */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n\t/** Filter by brand ID */\n\tbrandId?: string;\n\t/** Filter by account ID */\n\taccountId?: string;\n}\n\nexport interface UseUsersReturn {\n\t/** Reactive array of users */\n\tusers: Ref<User[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch users */\n\trefetch: () => Promise<void>;\n}\n\n/**\n * Build filter from hook options\n */\nfunction buildFilter(options: UseUsersOptions): any {\n\tlet filter: any = options.filter || {};\n\n\tif (options.brandId) {\n\t\tfilter = { ...filter, brandIds: { contains: options.brandId } };\n\t}\n\n\tif (options.accountId) {\n\t\tfilter = { ...filter, accountIds: { contains: options.accountId } };\n\t}\n\n\treturn Object.keys(filter).length > 0 ? filter : undefined;\n}\n\n/**\n * Internal hook created by factory\n */\nconst useUsersInternal = createDataHook<User, UseUsersOptions>({\n\tmodel: \"User\",\n\tdataPropertyName: \"users\",\n\tbuildFilter,\n});\n\n/**\n * Composable for fetching and managing users\n *\n * @example\n * ```typescript\n * import { useUsers } from '@htlkg/data/hooks';\n *\n * const { users, loading, error, refetch } = useUsers();\n * ```\n *\n * @example With filters\n * ```typescript\n * const { users, loading } = useUsers({\n * brandId: 'brand-123',\n * accountId: 'account-456',\n * limit: 50\n * });\n * ```\n */\nexport function useUsers(options: UseUsersOptions = {}): UseUsersReturn {\n\tconst result = useUsersInternal(options);\n\treturn {\n\t\tusers: result.users as Ref<User[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t};\n}\n","/**\n * useProducts Hook\n *\n * Vue composable for fetching and managing product data with reactive state.\n * Provides loading states, error handling, and refetch capabilities.\n */\n\nimport type { Ref, ComputedRef } from \"vue\";\nimport type { Product } from \"@htlkg/core/types\";\nimport { createDataHook, type BaseHookOptions } from \"./createDataHook\";\n\nexport interface UseProductsOptions extends BaseHookOptions {\n\t/** Filter criteria for products */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n\t/** Only active products */\n\tactiveOnly?: boolean;\n}\n\nexport interface UseProductsReturn {\n\t/** Reactive array of products */\n\tproducts: Ref<Product[]>;\n\t/** Computed array of active products only */\n\tactiveProducts: ComputedRef<Product[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch products */\n\trefetch: () => Promise<void>;\n}\n\n/**\n * Build filter from hook options\n */\nfunction buildFilter(options: UseProductsOptions): any {\n\tlet filter: any = options.filter || {};\n\n\tif (options.activeOnly) {\n\t\tfilter = { ...filter, isActive: { eq: true } };\n\t}\n\n\treturn Object.keys(filter).length > 0 ? filter : undefined;\n}\n\n/**\n * Internal hook created by factory\n */\nconst useProductsInternal = createDataHook<Product, UseProductsOptions, { activeProducts: Product[] }>({\n\tmodel: \"Product\",\n\tdataPropertyName: \"products\",\n\tbuildFilter,\n\tcomputedProperties: {\n\t\tactiveProducts: (products) => products.filter((p) => p.isActive === true),\n\t},\n});\n\n/**\n * Composable for fetching and managing products\n *\n * @example\n * ```typescript\n * import { useProducts } from '@htlkg/data/hooks';\n *\n * const { products, loading, error, refetch } = useProducts();\n * ```\n *\n * @example With filters\n * ```typescript\n * const { products, loading } = useProducts({\n * activeOnly: true,\n * limit: 50\n * });\n * ```\n */\nexport function useProducts(options: UseProductsOptions = {}): UseProductsReturn {\n\tconst result = useProductsInternal(options);\n\treturn {\n\t\tproducts: result.products as Ref<Product[]>,\n\t\tactiveProducts: result.activeProducts as ComputedRef<Product[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t};\n}\n","/**\n * useProductInstances Hook\n *\n * Vue composable for fetching and managing product instance data with reactive state.\n * Provides loading states, error handling, refetch capabilities, and CRUD operations.\n */\n\nimport type { Ref, ComputedRef } from \"vue\";\nimport type { ProductInstance } from \"@htlkg/core/types\";\nimport { createDataHook, type BaseHookOptions } from \"./createDataHook\";\nimport { getSharedClient } from \"../client\";\nimport {\n\tcreateProductInstance,\n\tupdateProductInstance,\n\tdeleteProductInstance,\n\ttoggleProductInstanceEnabled,\n\ttype CreateProductInstanceInput,\n\ttype UpdateProductInstanceInput,\n} from \"../mutations/productInstances\";\n\nexport interface UseProductInstancesOptions extends BaseHookOptions {\n\t/** Filter criteria for product instances */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n\t/** Filter by brand ID */\n\tbrandId?: string;\n\t/** Filter by account ID */\n\taccountId?: string;\n\t/** Filter by product ID */\n\tproductId?: string;\n\t/** Only enabled instances */\n\tenabledOnly?: boolean;\n}\n\nexport interface UseProductInstancesReturn {\n\t/** Reactive array of product instances */\n\tinstances: Ref<ProductInstance[]>;\n\t/** Computed array of enabled instances only */\n\tenabledInstances: ComputedRef<ProductInstance[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch product instances */\n\trefetch: () => Promise<void>;\n\t/** Create a new product instance */\n\tcreateInstance: (input: CreateProductInstanceInput) => Promise<ProductInstance>;\n\t/** Update an existing product instance */\n\tupdateInstance: (input: UpdateProductInstanceInput) => Promise<ProductInstance>;\n\t/** Delete a product instance */\n\tdeleteInstance: (id: string) => Promise<boolean>;\n\t/** Toggle the enabled status of a product instance */\n\ttoggleEnabled: (id: string, enabled: boolean) => Promise<ProductInstance>;\n}\n\n/**\n * Build filter from hook options\n */\nfunction buildFilter(options: UseProductInstancesOptions): any {\n\tlet filter: any = options.filter || {};\n\n\tif (options.brandId) {\n\t\tfilter = { ...filter, brandId: { eq: options.brandId } };\n\t}\n\n\tif (options.accountId) {\n\t\tfilter = { ...filter, accountId: { eq: options.accountId } };\n\t}\n\n\tif (options.productId) {\n\t\tfilter = { ...filter, productId: { eq: options.productId } };\n\t}\n\n\tif (options.enabledOnly) {\n\t\tfilter = { ...filter, enabled: { eq: true } };\n\t}\n\n\treturn Object.keys(filter).length > 0 ? filter : undefined;\n}\n\n/**\n * Internal hook created by factory\n */\nconst useProductInstancesInternal = createDataHook<\n\tProductInstance,\n\tUseProductInstancesOptions,\n\t{ enabledInstances: ProductInstance[] }\n>({\n\tmodel: \"ProductInstance\",\n\tdataPropertyName: \"instances\",\n\tbuildFilter,\n\tcomputedProperties: {\n\t\tenabledInstances: (instances) => instances.filter((i) => i.enabled),\n\t},\n});\n\n/**\n * Composable for fetching and managing product instances\n *\n * @example\n * ```typescript\n * import { useProductInstances } from '@htlkg/data/hooks';\n *\n * const { instances, loading, error, refetch } = useProductInstances();\n * ```\n *\n * @example With filters\n * ```typescript\n * const { instances, enabledInstances, loading } = useProductInstances({\n * brandId: 'brand-123',\n * enabledOnly: true,\n * limit: 50\n * });\n * ```\n *\n * @example For a specific account\n * ```typescript\n * const { instances, loading } = useProductInstances({\n * accountId: 'account-456',\n * autoFetch: true\n * });\n * ```\n */\nexport function useProductInstances(options: UseProductInstancesOptions = {}): UseProductInstancesReturn {\n\tconst result = useProductInstancesInternal(options);\n\n\t// CRUD methods using mutations from @htlkg/data/mutations\n\tasync function createInstance(input: CreateProductInstanceInput): Promise<ProductInstance> {\n\t\tconst client = getSharedClient();\n\t\tconst instance = await createProductInstance(client, input);\n\t\tif (!instance) {\n\t\t\tthrow new Error(\"Failed to create product instance\");\n\t\t}\n\t\treturn instance;\n\t}\n\n\tasync function updateInstance(input: UpdateProductInstanceInput): Promise<ProductInstance> {\n\t\tconst client = getSharedClient();\n\t\tconst instance = await updateProductInstance(client, input);\n\t\tif (!instance) {\n\t\t\tthrow new Error(\"Failed to update product instance\");\n\t\t}\n\t\treturn instance;\n\t}\n\n\tasync function deleteInstance(id: string): Promise<boolean> {\n\t\tconst client = getSharedClient();\n\t\treturn deleteProductInstance(client, id);\n\t}\n\n\tasync function toggleEnabled(id: string, enabled: boolean): Promise<ProductInstance> {\n\t\tconst client = getSharedClient();\n\t\tconst instance = await toggleProductInstanceEnabled(client, id, enabled);\n\t\tif (!instance) {\n\t\t\tthrow new Error(\"Failed to toggle product instance\");\n\t\t}\n\t\treturn instance;\n\t}\n\n\treturn {\n\t\tinstances: result.instances as Ref<ProductInstance[]>,\n\t\tenabledInstances: result.enabledInstances as ComputedRef<ProductInstance[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t\tcreateInstance,\n\t\tupdateInstance,\n\t\tdeleteInstance,\n\t\ttoggleEnabled,\n\t};\n}\n","/**\n * useReservations Hook\n *\n * Vue composable for fetching and managing reservation data with reactive state.\n * Provides loading states, error handling, pagination, and refetch capabilities.\n */\n\nimport type { Ref, ComputedRef } from \"vue\";\nimport type { Reservation } from \"../queries/reservations\";\nimport { createDataHook, type BaseHookOptions } from \"./createDataHook\";\n\nexport interface UseReservationsOptions extends BaseHookOptions {\n\t/** Filter by brand ID */\n\tbrandId?: string;\n\t/** Filter by start date (check-in date >= startDate) */\n\tstartDate?: string;\n\t/** Filter by end date (check-in date <= endDate) */\n\tendDate?: string;\n\t/** Filter by reservation status */\n\tstatus?: Reservation[\"status\"];\n\t/** Filter by contact/visit ID */\n\tcontactId?: string;\n\t/** Pagination token for fetching next page */\n\tnextToken?: string;\n}\n\nexport interface UseReservationsReturn {\n\t/** Reactive array of reservations */\n\treservations: Ref<Reservation[]>;\n\t/** Computed array of confirmed reservations */\n\tconfirmedReservations: ComputedRef<Reservation[]>;\n\t/** Computed array of active reservations (confirmed or checked_in) */\n\tactiveReservations: ComputedRef<Reservation[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch reservations */\n\trefetch: () => Promise<void>;\n}\n\n/**\n * Build filter from hook options\n */\nfunction buildFilter(options: UseReservationsOptions): any {\n\tconst conditions: any[] = [];\n\n\tif (options.brandId) {\n\t\tconditions.push({ brandId: { eq: options.brandId } });\n\t}\n\n\tif (options.status) {\n\t\tconditions.push({ status: { eq: options.status } });\n\t}\n\n\tif (options.contactId) {\n\t\tconditions.push({ visitId: { eq: options.contactId } });\n\t}\n\n\tif (options.startDate) {\n\t\tconditions.push({ checkIn: { ge: options.startDate } });\n\t}\n\n\tif (options.endDate) {\n\t\tconditions.push({ checkIn: { le: options.endDate } });\n\t}\n\n\tif (options.filter) {\n\t\tconditions.push(options.filter);\n\t}\n\n\tif (conditions.length === 0) {\n\t\treturn undefined;\n\t}\n\n\tif (conditions.length === 1) {\n\t\treturn conditions[0];\n\t}\n\n\treturn { and: conditions };\n}\n\n/**\n * Internal hook created by factory\n */\nconst useReservationsInternal = createDataHook<\n\tReservation,\n\tUseReservationsOptions,\n\t{ confirmedReservations: Reservation[]; activeReservations: Reservation[] }\n>({\n\tmodel: \"Reservation\",\n\tdataPropertyName: \"reservations\",\n\tbuildFilter,\n\tcomputedProperties: {\n\t\tconfirmedReservations: (reservations) =>\n\t\t\treservations.filter((r) => r.status === \"confirmed\"),\n\t\tactiveReservations: (reservations) =>\n\t\t\treservations.filter((r) => r.status === \"confirmed\" || r.status === \"checked_in\"),\n\t},\n});\n\n/**\n * Composable for fetching and managing reservations\n *\n * @example\n * ```typescript\n * import { useReservations } from '@htlkg/data/hooks';\n *\n * const { reservations, loading, error, refetch } = useReservations({\n * brandId: 'brand-123',\n * startDate: '2026-01-01',\n * endDate: '2026-01-31',\n * status: 'confirmed'\n * });\n * ```\n *\n * @example With contact filter\n * ```typescript\n * const { reservations, loading } = useReservations({\n * contactId: 'contact-123',\n * limit: 50\n * });\n * ```\n *\n * @example With computed properties\n * ```typescript\n * const { reservations, activeReservations, confirmedReservations } = useReservations({\n * brandId: 'brand-123'\n * });\n *\n * // activeReservations includes confirmed + checked_in\n * // confirmedReservations includes only confirmed\n * ```\n */\nexport function useReservations(options: UseReservationsOptions = {}): UseReservationsReturn {\n\tconst result = useReservationsInternal(options);\n\treturn {\n\t\treservations: result.reservations as Ref<Reservation[]>,\n\t\tconfirmedReservations: result.confirmedReservations as ComputedRef<Reservation[]>,\n\t\tactiveReservations: result.activeReservations as ComputedRef<Reservation[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t};\n}\n","/**\n * useContacts Hook\n *\n * Vue composable for fetching and managing contact data with reactive state.\n * Provides loading states, error handling, search, pagination, and refetch capabilities.\n */\n\nimport type { Ref, ComputedRef } from \"vue\";\nimport type { Contact } from \"@htlkg/core/types\";\nimport { createDataHook, type BaseHookOptions } from \"./createDataHook\";\n\nexport interface UseContactsOptions extends BaseHookOptions {\n\t/** Filter by brand ID */\n\tbrandId?: string;\n\t/** Search query (searches email, firstName, lastName) */\n\tsearch?: string;\n\t/** Filter by GDPR consent */\n\tgdprConsent?: boolean;\n\t/** Filter by marketing opt-in */\n\tmarketingOptIn?: boolean;\n\t/** Filter by tags (contact must have at least one of these tags) */\n\ttags?: string[];\n\t/** Pagination token for fetching next page */\n\tnextToken?: string;\n}\n\nexport interface UseContactsReturn {\n\t/** Reactive array of contacts */\n\tcontacts: Ref<Contact[]>;\n\t/** Computed array of contacts with GDPR consent */\n\tconsentedContacts: ComputedRef<Contact[]>;\n\t/** Computed array of contacts opted-in for marketing */\n\tmarketingContacts: ComputedRef<Contact[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch contacts */\n\trefetch: () => Promise<void>;\n}\n\n/**\n * Build filter from hook options\n */\nfunction buildFilter(options: UseContactsOptions): any {\n\tconst conditions: any[] = [];\n\n\t// Filter by brand\n\tif (options.brandId) {\n\t\tconditions.push({ brandId: { eq: options.brandId } });\n\t}\n\n\t// Search across email, firstName, lastName\n\tif (options.search) {\n\t\tconditions.push({\n\t\t\tor: [\n\t\t\t\t{ email: { contains: options.search } },\n\t\t\t\t{ firstName: { contains: options.search } },\n\t\t\t\t{ lastName: { contains: options.search } },\n\t\t\t],\n\t\t});\n\t}\n\n\t// Filter by GDPR consent\n\tif (options.gdprConsent !== undefined) {\n\t\tconditions.push({ gdprConsent: { eq: options.gdprConsent } });\n\t}\n\n\t// Filter by marketing opt-in\n\tif (options.marketingOptIn !== undefined) {\n\t\tconditions.push({ marketingOptIn: { eq: options.marketingOptIn } });\n\t}\n\n\t// Filter by tags (contact must have at least one of these tags)\n\tif (options.tags && options.tags.length > 0) {\n\t\tconst tagConditions = options.tags.map((tag) => ({\n\t\t\ttags: { contains: tag },\n\t\t}));\n\t\tconditions.push({ or: tagConditions });\n\t}\n\n\t// Include any additional custom filter\n\tif (options.filter) {\n\t\tconditions.push(options.filter);\n\t}\n\n\tif (conditions.length === 0) {\n\t\treturn undefined;\n\t}\n\n\tif (conditions.length === 1) {\n\t\treturn conditions[0];\n\t}\n\n\treturn { and: conditions };\n}\n\n/**\n * Internal hook created by factory\n */\nconst useContactsInternal = createDataHook<\n\tContact,\n\tUseContactsOptions,\n\t{ consentedContacts: Contact[]; marketingContacts: Contact[] }\n>({\n\tmodel: \"Contact\",\n\tdataPropertyName: \"contacts\",\n\tbuildFilter,\n\tcomputedProperties: {\n\t\tconsentedContacts: (contacts) =>\n\t\t\tcontacts.filter((c) => c.gdprConsent === true),\n\t\tmarketingContacts: (contacts) =>\n\t\t\tcontacts.filter((c) => c.marketingOptIn === true),\n\t},\n});\n\n/**\n * Composable for fetching and managing contacts\n *\n * @example\n * ```typescript\n * import { useContacts } from '@htlkg/data/hooks';\n *\n * const { contacts, loading, error, refetch } = useContacts({\n * brandId: 'brand-123',\n * limit: 25\n * });\n * ```\n *\n * @example With search\n * ```typescript\n * const { contacts, loading } = useContacts({\n * brandId: 'brand-123',\n * search: 'john',\n * limit: 25\n * });\n * ```\n *\n * @example With GDPR and marketing filters\n * ```typescript\n * const { contacts, marketingContacts } = useContacts({\n * brandId: 'brand-123',\n * gdprConsent: true,\n * marketingOptIn: true\n * });\n * ```\n *\n * @example With computed properties\n * ```typescript\n * const { contacts, consentedContacts, marketingContacts } = useContacts({\n * brandId: 'brand-123'\n * });\n *\n * // consentedContacts - contacts with GDPR consent\n * // marketingContacts - contacts opted-in for marketing\n * ```\n *\n * @example With tag filtering\n * ```typescript\n * const { contacts } = useContacts({\n * brandId: 'brand-123',\n * tags: ['vip', 'returning']\n * });\n * ```\n */\nexport function useContacts(options: UseContactsOptions = {}): UseContactsReturn {\n\tconst result = useContactsInternal(options);\n\treturn {\n\t\tcontacts: result.contacts as Ref<Contact[]>,\n\t\tconsentedContacts: result.consentedContacts as ComputedRef<Contact[]>,\n\t\tmarketingContacts: result.marketingContacts as ComputedRef<Contact[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t};\n}\n","import { cleanTasks } from '../task/index.js'\n\nexport let clean = Symbol('clean')\n\nexport let cleanStores = (...stores) => {\n if (process.env.NODE_ENV === 'production') {\n throw new Error(\n 'cleanStores() can be used only during development or tests'\n )\n }\n cleanTasks()\n for (let $store of stores) {\n if ($store) {\n if ($store.mocked) delete $store.mocked\n if ($store[clean]) $store[clean]()\n }\n }\n}\n","import { clean } from '../clean-stores/index.js'\n\nlet listenerQueue = []\nlet lqIndex = 0\nconst QUEUE_ITEMS_PER_LISTENER = 4\nexport let epoch = 0\n\n/* @__NO_SIDE_EFFECTS__ */\nexport const atom = initialValue => {\n let listeners = []\n let $atom = {\n get() {\n if (!$atom.lc) {\n $atom.listen(() => {})()\n }\n return $atom.value\n },\n lc: 0,\n listen(listener) {\n $atom.lc = listeners.push(listener)\n\n return () => {\n for (\n let i = lqIndex + QUEUE_ITEMS_PER_LISTENER;\n i < listenerQueue.length;\n\n ) {\n if (listenerQueue[i] === listener) {\n listenerQueue.splice(i, QUEUE_ITEMS_PER_LISTENER)\n } else {\n i += QUEUE_ITEMS_PER_LISTENER\n }\n }\n\n let index = listeners.indexOf(listener)\n if (~index) {\n listeners.splice(index, 1)\n if (!--$atom.lc) $atom.off()\n }\n }\n },\n notify(oldValue, changedKey) {\n epoch++\n let runListenerQueue = !listenerQueue.length\n for (let listener of listeners) {\n listenerQueue.push(listener, $atom.value, oldValue, changedKey)\n }\n\n if (runListenerQueue) {\n for (\n lqIndex = 0;\n lqIndex < listenerQueue.length;\n lqIndex += QUEUE_ITEMS_PER_LISTENER\n ) {\n listenerQueue[lqIndex](\n listenerQueue[lqIndex + 1],\n listenerQueue[lqIndex + 2],\n listenerQueue[lqIndex + 3]\n )\n }\n listenerQueue.length = 0\n }\n },\n /* It will be called on last listener unsubscribing.\n We will redefine it in onMount and onStop. */\n off() {},\n set(newValue) {\n let oldValue = $atom.value\n if (oldValue !== newValue) {\n $atom.value = newValue\n $atom.notify(oldValue)\n }\n },\n subscribe(listener) {\n let unbind = $atom.listen(listener)\n listener($atom.value)\n return unbind\n },\n value: initialValue\n }\n\n if (process.env.NODE_ENV !== 'production') {\n $atom[clean] = () => {\n listeners = []\n $atom.lc = 0\n $atom.off()\n }\n }\n\n return $atom\n}\n\nexport const readonlyType = store => store\n","/**\n * Store Factory\n *\n * Creates request-scoped nanostores for sharing data across Vue islands\n * without props. Works with @inox-tools/request-nanostores for Astro integration.\n */\n\nimport { atom, type WritableAtom } from \"nanostores\";\n\n/**\n * Type for the shared function from @it-astro:request-nanostores\n */\ntype SharedFn = <T>(key: string, atomFactory: WritableAtom<T>) => WritableAtom<T>;\n\n/**\n * Configuration for a resource store\n */\nexport interface StoreConfig {\n\t/** Resource name (e.g., 'accounts', 'users') */\n\tname: string;\n\t/** Related resources to create stores for (e.g., ['brands', 'products']) */\n\trelations?: string[];\n}\n\n/**\n * Result type for created stores\n */\nexport type ResourceStores<T, TRelations extends string = never> = {\n\t/** Main resource store */\n\t$data: WritableAtom<readonly T[]>;\n} & {\n\t[K in TRelations as `$${K}`]: WritableAtom<readonly any[]>;\n};\n\n/**\n * Capitalize first letter of a string\n */\nfunction capitalize(str: string): string {\n\treturn str.charAt(0).toUpperCase() + str.slice(1);\n}\n\n/**\n * Creates request-scoped stores for a resource and its relations.\n *\n * This factory is designed to work with Astro's request-nanostores integration,\n * providing request-isolated state that syncs from server to client.\n *\n * @param shared - The shared function from @it-astro:request-nanostores\n * @param config - Store configuration\n * @returns Object containing the main store and relation stores\n *\n * @example\n * ```typescript\n * // In your store file (e.g., stores/accounts.ts)\n * import { shared } from '@it-astro:request-nanostores';\n * import { createResourceStores } from '@htlkg/data/stores';\n *\n * export const accountStores = createResourceStores(shared, {\n * name: 'accounts',\n * relations: ['brands'],\n * });\n *\n * // This creates:\n * // - accountStores.$data (WritableAtom<any[]>) - main accounts store\n * // - accountStores.$brands (WritableAtom<any[]>) - related brands store\n *\n * // For cleaner exports:\n * export const $accounts = accountStores.$data;\n * export const $accountsBrands = accountStores.$brands;\n * ```\n *\n * @example\n * ```typescript\n * // With typed stores\n * interface Account { id: number; name: string; }\n * interface Brand { id: number; name: string; }\n *\n * export const { $data: $accounts, $brands } = createResourceStores<Account, 'brands'>(\n * shared,\n * { name: 'accounts', relations: ['brands'] }\n * );\n * ```\n */\nexport function createResourceStores<T = any, TRelations extends string = never>(\n\tshared: SharedFn,\n\tconfig: StoreConfig & { relations?: TRelations[] },\n): ResourceStores<T, TRelations> {\n\tconst { name, relations = [] } = config;\n\n\tconst stores: Record<string, any> = {};\n\n\t// Main resource store\n\tstores.$data = shared(name, atom<T[]>([]));\n\n\t// Relation stores\n\tfor (const relation of relations) {\n\t\tconst storeKey = `$${relation}`;\n\t\tconst sharedKey = `${name}${capitalize(relation)}`;\n\t\tstores[storeKey] = shared(sharedKey, atom<any[]>([]));\n\t}\n\n\treturn stores as ResourceStores<T, TRelations>;\n}\n\n/**\n * Creates a simple single store (non-factory version for simpler use cases)\n *\n * @example\n * ```typescript\n * import { shared } from '@it-astro:request-nanostores';\n * import { createStore } from '@htlkg/data/stores';\n *\n * export const $currentUser = createStore<User>(shared, 'currentUser');\n * ```\n */\nexport function createStore<T>(\n\tshared: SharedFn,\n\tname: string,\n\tdefaultValue: T[] = [],\n): WritableAtom<readonly T[]> {\n\treturn shared(name, atom<T[]>(defaultValue));\n}\n\n/**\n * Creates a single-value store (for non-array values like current user)\n *\n * @example\n * ```typescript\n * import { shared } from '@it-astro:request-nanostores';\n * import { createSingleStore } from '@htlkg/data/stores';\n *\n * export const $currentUser = createSingleStore<User | null>(shared, 'currentUser', null);\n * ```\n */\nexport function createSingleStore<T>(\n\tshared: SharedFn,\n\tname: string,\n\tdefaultValue: T,\n): WritableAtom<T> {\n\treturn shared(name, atom<T>(defaultValue));\n}\n\n/**\n * Helper to create typed store with proper inference\n */\nexport type InferStoreType<TStore extends WritableAtom<any>> = TStore extends WritableAtom<infer T>\n\t? T\n\t: never;\n"],"mappings":";AASA,SAAS,kBAAkB,0BAA0B;AACrD,SAAS,eAAe;;;ACDxB;AAAA,EAIC;AAAA,OACM;AACP,SAAS,+BAA+B;AACxC,SAAS,mCAAmC,oBAAoB;AAEhE,IAAM,MAAM,aAAa,eAAe;;;ACkBxC,IAAM,mBAAmB;AAiCzB,eAAsB,OACrB,OACA,WACA,MACA,SAC8B;AAC9B,SAAO,aAAgB,OAAO,WAAW,MAAM,OAAO;AACvD;AAwBA,eAAsB,MACrB,OACA,WACA,MACA,SAC8B;AAC9B,SAAO,aAAgB,OAAO,WAAW,MAAM,OAAO;AACvD;AAKA,eAAe,aACd,OACA,WACA,MACA,SAC8B;AAC9B,QAAM,WAAW,SAAS,YAAY;AAEtC,MAAI;AACH,UAAM,WAAW,MAAM,MAAM,UAAU;AAAA,MACtC,QAAQ;AAAA,MACR,SAAS;AAAA,QACR,gBAAgB;AAAA,MACjB;AAAA,MACA,aAAa;AAAA;AAAA,MACb,GAAG,SAAS;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M,YAAY,GAAG,IAAI,GAAG,WAAW,QAAQ,CAAC;AAChD,WAAO,QAAQ,IAAI,OAAO,WAAW,KAAY,CAAC,CAAC,CAAC;AAAA,EACrD;AAEA,SAAO;AACR;AAaO,SAAS,YACf,QACA,MACA,eAAoB,CAAC,GACQ;AAC7B,SAAO,OAAO,MAAM,KAAU,YAAY,CAAC;AAC5C;AAaO,SAAS,kBACf,QACA,MACA,cACkB;AAClB,SAAO,OAAO,MAAM,KAAQ,YAAY,CAAC;AAC1C;","names":["getReservation","listReservations","query","createReservation","updateReservation","softDeleteReservation","restoreReservation","deleteReservation","updateReservationStatus","buildFilter","fetch","buildFilter","buildFilter","buildFilter","buildFilter","buildFilter"]}
1
+ {"version":3,"sources":["../src/client/index.ts","../src/client/server.ts","../src/client/proxy.ts","../src/queries/brands/brands.ts","../src/queries/accounts/accounts.ts","../src/queries/users/users.ts","../src/queries/products/products.ts","../src/queries/server-helpers.ts","../src/queries/systemSettings.ts","../src/queries/reservations/reservations.ts","../src/queries/contacts.ts","../src/mutations/brands/brands.ts","../src/mutations/accounts/accounts.ts","../src/mutations/users/users.ts","../src/mutations/productInstances/productInstances.ts","../src/mutations/systemSettings.ts","../src/mutations/reservations/reservations.ts","../src/mutations/contacts.ts","../src/hooks/createDataHook.ts","../src/hooks/createPaginatedDataHook.ts","../src/hooks/brands/useBrands.ts","../src/hooks/brands/usePaginatedBrands.ts","../src/hooks/users/useUsers.ts","../src/hooks/users/usePaginatedUsers.ts","../src/hooks/accounts/useAccounts.ts","../src/hooks/accounts/usePaginatedAccounts.ts","../src/hooks/reservations/useReservations.ts","../src/hooks/reservations/usePaginatedReservations.ts","../src/hooks/products/useProducts.ts","../src/hooks/productInstances/useProductInstances.ts","../src/hooks/useContacts.ts","../../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/clean-stores/index.js","../../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/atom/index.js","../src/stores/createStores.ts"],"sourcesContent":["/**\n * GraphQL Client for @htlkg/data\n *\n * Provides both client-side and server-side GraphQL capabilities using AWS Amplify Data.\n * The server-side functions use the Amplify Astro adapter for proper SSR support.\n *\n * For server-side usage, use `Astro.locals.amplifyClient` (zero-config, injected by middleware).\n */\n\nimport { generateClient as generateDataClient } from \"aws-amplify/data\";\nimport { Amplify } from \"aws-amplify\";\nimport type { ResourcesConfig } from \"aws-amplify\";\nimport { generateServerClientUsingCookies } from \"./server\";\n\n// Re-export server-side client generation (used internally by middleware)\nexport { generateServerClientUsingCookies } from \"./server\";\n\n// Re-export proxy functions for authenticated client-side operations\nexport {\n\tmutate,\n\tquery,\n\thasErrors,\n\tgetErrorMessage,\n\ttype Operation,\n\ttype GraphQLResponse,\n\ttype ProxyOptions,\n} from \"./proxy\";\n\n// Re-export type-safe client-side Reservation operations\nexport {\n\tcreateReservation,\n\tupdateReservation,\n\tsoftDeleteReservation,\n\trestoreReservation,\n\tdeleteReservation,\n\tgetReservation,\n\tlistReservations,\n\tupdateReservationStatus,\n\tbulkSoftDeleteReservations,\n\tbulkRestoreReservations,\n\tbulkDeleteReservations,\n\tbulkUpdateReservationStatus,\n\ttype Reservation,\n\ttype ReservationStatus,\n} from \"./reservations\";\n\n/**\n * Type for the server-side Amplify client (for use in type declarations)\n * This represents the client returned by generateServerClientUsingCookies\n */\nexport type AmplifyServerClient<TSchema extends Record<string, unknown> = Record<string, unknown>> =\n\tReturnType<typeof generateServerClientUsingCookies<TSchema>>;\n\n// Singleton client instance for client-side fetching\nlet sharedClientInstance: any = null;\n\n/**\n * Get or create the shared GraphQL client instance (singleton pattern)\n * Use this for client-side fetching to avoid creating multiple client instances.\n *\n * @example\n * ```typescript\n * const client = getSharedClient<Schema>();\n * const { data } = await client.models.Account.list();\n * ```\n */\nexport function getSharedClient<\n\tTSchema extends Record<string, unknown> = Record<string, unknown>,\n>(): ReturnType<typeof generateDataClient<TSchema>> {\n\tif (!sharedClientInstance) {\n\t\tsharedClientInstance = generateDataClient<TSchema>();\n\t}\n\treturn sharedClientInstance;\n}\n\n/**\n * Reset the shared client instance (useful for testing or auth state changes)\n */\nexport function resetSharedClient(): void {\n\tsharedClientInstance = null;\n}\n\n/**\n * Generate a client-side GraphQL client for use in Vue components and browser contexts\n * This is SSR-safe and should be called within a component's setup function or after hydration\n *\n * @example\n * ```typescript\n * import type { Schema } from '@backend/data/resource';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const { data: brands } = await client.models.Brand.list();\n * ```\n */\nexport function generateClient<\n\tTSchema extends Record<string, unknown> = Record<string, unknown>,\n>(): ReturnType<typeof generateDataClient<TSchema>> {\n\treturn generateDataClient<TSchema>();\n}\n\n/**\n * Configuration for Amplify (matches amplify_outputs.json format)\n */\nexport type AstroAmplifyConfig = ResourcesConfig;\n\n/**\n * Authentication mode for server-side GraphQL client\n */\nexport type ServerAuthMode = 'userPool' | 'apiKey';\n\n/**\n * Options for generating a server-side GraphQL client\n */\nexport interface GenerateServerClientOptions {\n\t/** Authentication mode - 'userPool' (default) uses JWT from cookies, 'apiKey' uses API key */\n\tauthMode?: ServerAuthMode;\n}\n\n/**\n * Generate a server-side GraphQL client for use within runWithAmplifyServerContext\n * \n * This function creates a GraphQL client that can be used for server-side data fetching in Astro.\n * It MUST be called within runWithAmplifyServerContext to access JWT tokens from cookies.\n * \n * The client supports two authentication modes:\n * - 'userPool' (default): Uses JWT tokens from cookies (requires runWithAmplifyServerContext)\n * - 'apiKey': Uses API key for public/unauthenticated requests\n *\n * **Important**: \n * - Amplify.configure() must be called once at app startup (e.g., in amplify-server.ts)\n * - This function must be called INSIDE the operation function of runWithAmplifyServerContext\n * - The context automatically provides the token provider that reads JWT tokens from cookies\n *\n * @example\n * ```typescript\n * // In your Astro page\n * import type { Schema } from '../amplify/data/resource';\n * import { generateServerClient } from '@htlkg/data/client';\n * import { createRunWithAmplifyServerContext } from '@htlkg/core/amplify-astro-adapter';\n * import outputs from '../amplify_outputs.json';\n *\n * const runWithAmplifyServerContext = createRunWithAmplifyServerContext({ config: outputs });\n *\n * // Fetch data with authentication\n * const result = await runWithAmplifyServerContext({\n * astroServerContext: {\n * cookies: Astro.cookies,\n * request: Astro.request\n * },\n * operation: async (contextSpec) => {\n * // Generate client INSIDE the operation\n * const client = generateServerClient<Schema>({ authMode: 'userPool' });\n * return await client.models.User.list();\n * }\n * });\n * \n * const users = result.data || [];\n * ```\n * \n * @example Using API key for public data\n * ```typescript\n * const result = await runWithAmplifyServerContext({\n * astroServerContext: {\n * cookies: Astro.cookies,\n * request: Astro.request\n * },\n * operation: async (contextSpec) => {\n * const client = generateServerClient<Schema>({ authMode: 'apiKey' });\n * return await client.models.Brand.list();\n * }\n * });\n * ```\n */\nexport function generateServerClient<\n\tTSchema extends Record<string, unknown> = Record<string, unknown>,\n>(_options?: GenerateServerClientOptions): ReturnType<typeof generateDataClient<TSchema>> {\n\t// Generate the client without authMode parameter\n\t// When called within runWithAmplifyServerContext, it will automatically use the token provider\n\t// from the context (which reads JWT tokens from cookies)\n\t// The authMode should be specified per-operation, not at client creation\n\tconst client = generateDataClient<TSchema>();\n\n\treturn client;\n}\n\n/**\n * Context required for getting a server client in API routes\n */\nexport interface ServerClientContext {\n\tlocals: { amplifyClient?: any; user?: any };\n\tcookies: any;\n\trequest: Request;\n}\n\n/**\n * Get the server client from Astro context\n *\n * Uses locals.amplifyClient if available (set by middleware),\n * otherwise creates a new client using Amplify's global config.\n * No config parameter needed - uses the config set by the middleware.\n *\n * @example\n * ```typescript\n * import { getServerClient } from '@htlkg/data/client';\n *\n * export const POST: APIRoute = async (context) => {\n * const client = getServerClient(context);\n * if (!client) return new Response('Not authenticated', { status: 401 });\n *\n * const result = await client.models.User.list();\n * };\n * ```\n */\nexport function getServerClient<TSchema extends Record<string, unknown> = Record<string, unknown>>(\n\tcontext: ServerClientContext,\n): ReturnType<typeof generateServerClientUsingCookies<TSchema>> | null {\n\t// Try to use client from middleware first\n\tif (context.locals.amplifyClient) {\n\t\treturn context.locals.amplifyClient as ReturnType<typeof generateServerClientUsingCookies<TSchema>>;\n\t}\n\n\t// If no client from middleware and user is authenticated, create one using global Amplify config\n\tif (context.locals.user) {\n\t\ttry {\n\t\t\t// Get config from Amplify (set by middleware)\n\t\t\tconst amplifyConfig = Amplify.getConfig();\n\t\t\tif (amplifyConfig) {\n\t\t\t\treturn generateServerClientUsingCookies<TSchema>({\n\t\t\t\t\tconfig: amplifyConfig,\n\t\t\t\t\tcookies: context.cookies,\n\t\t\t\t\trequest: context.request,\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tconsole.error('[getServerClient] Failed to get Amplify config:', e);\n\t\t}\n\t}\n\n\t// No authentication available\n\treturn null;\n}\n","/**\n * Server-side data client for Astro\n *\n * Provides a client generator similar to Next.js's generateServerClientUsingCookies\n * using generateClientWithAmplifyInstance for proper server context integration.\n */\n\nimport type { AstroGlobal } from \"astro\";\nimport type { ResourcesConfig } from \"aws-amplify\";\nimport {\n\tCommonPublicClientOptions,\n\tDefaultCommonClientOptions,\n\tV6ClientSSRCookies,\n\tgenerateClientWithAmplifyInstance,\n} from \"aws-amplify/api/internals\";\nimport { getAmplifyServerContext } from \"aws-amplify/adapter-core/internals\";\nimport { createRunWithAmplifyServerContext, createLogger } from \"@htlkg/core/amplify-astro-adapter\";\n\nconst log = createLogger('server-client');\n\ninterface AstroCookiesClientParams {\n\tcookies: AstroGlobal[\"cookies\"];\n\trequest: AstroGlobal[\"request\"];\n\tconfig: ResourcesConfig;\n}\n\n/**\n * Generates a server-side data client for Astro (matches Next.js implementation)\n *\n * This function creates a client that automatically wraps all operations in the Amplify server context,\n * ensuring that authentication tokens from cookies are properly used.\n *\n * @example\n * ```typescript\n * import type { Schema } from '../amplify/data/resource';\n * import { generateServerClientUsingCookies } from '@htlkg/data/client';\n * import { parseAmplifyConfig } from 'aws-amplify/utils';\n * import outputs from '../amplify_outputs.json';\n *\n * const amplifyConfig = parseAmplifyConfig(outputs);\n *\n * const client = generateServerClientUsingCookies<Schema>({\n * config: amplifyConfig,\n * cookies: Astro.cookies,\n * request: Astro.request,\n * });\n *\n * // Use the client directly - operations are automatically wrapped\n * const result = await client.models.User.list({\n * selectionSet: ['id', 'email'],\n * limit: 100,\n * });\n * ```\n */\nexport function generateServerClientUsingCookies<\n\tT extends Record<any, any> = never,\n\tOptions extends CommonPublicClientOptions &\n\t\tAstroCookiesClientParams = DefaultCommonClientOptions &\n\t\tAstroCookiesClientParams,\n>(options: Options): V6ClientSSRCookies<T, Options> {\n\tconst runWithAmplifyServerContext = createRunWithAmplifyServerContext({\n\t\tconfig: options.config,\n\t});\n\n\tconst resourcesConfig = options.config;\n\n\t// This function reference gets passed down to InternalGraphQLAPI.ts.graphql\n\t// where this._graphql is passed in as the `fn` argument\n\t// causing it to always get invoked inside `runWithAmplifyServerContext`\n\tconst getAmplify = (fn: (amplify: any) => Promise<any>) => {\n\t\treturn runWithAmplifyServerContext({\n\t\t\tastroServerContext: {\n\t\t\t\tcookies: options.cookies,\n\t\t\t\trequest: options.request,\n\t\t\t},\n\t\t\toperation: async (contextSpec: any) => {\n\t\t\t\tconst amplifyInstance = getAmplifyServerContext(contextSpec).amplify;\n\t\t\t\t\n\t\t\t\t// Debug logging (only when DEBUG=true)\n\t\t\t\ttry {\n\t\t\t\t\tconst config = amplifyInstance.getConfig();\n\t\t\t\t\tlog.debug('Amplify config from instance:', {\n\t\t\t\t\t\thasAPI: !!config.API,\n\t\t\t\t\t\thasGraphQL: !!config.API?.GraphQL,\n\t\t\t\t\t\tendpoint: config.API?.GraphQL?.endpoint,\n\t\t\t\t\t\tdefaultAuthMode: config.API?.GraphQL?.defaultAuthMode,\n\t\t\t\t\t\tregion: config.API?.GraphQL?.region,\n\t\t\t\t\t});\n\t\t\t\t\t\n\t\t\t\t\tconst session = await amplifyInstance.Auth.fetchAuthSession();\n\t\t\t\t\tlog.debug('Auth session:', {\n\t\t\t\t\t\thasTokens: !!session.tokens,\n\t\t\t\t\t\thasAccessToken: !!session.tokens?.accessToken,\n\t\t\t\t\t\thasIdToken: !!session.tokens?.idToken,\n\t\t\t\t\t\thasCredentials: !!session.credentials,\n\t\t\t\t\t});\n\t\t\t\t} catch (e: any) {\n\t\t\t\t\tlog.debug('Error fetching session:', e.message);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn fn(amplifyInstance);\n\t\t\t},\n\t\t});\n\t};\n\n\tconst {\n\t\tcookies: _cookies,\n\t\trequest: _request,\n\t\tconfig: _config,\n\t\t...params\n\t} = options;\n\n\treturn generateClientWithAmplifyInstance<T, V6ClientSSRCookies<T, Options>>({\n\t\tamplify: getAmplify,\n\t\tconfig: resourcesConfig,\n\t\t...params,\n\t} as any);\n}\n","/**\n * GraphQL Proxy Client\n *\n * Client-side helper for making authenticated GraphQL operations through\n * the server-side proxy. This allows Vue components to perform mutations\n * while keeping auth cookies httpOnly for security.\n *\n * @module @htlkg/data/proxy\n */\n\n/**\n * Valid GraphQL operations\n */\nexport type Operation = \"create\" | \"update\" | \"delete\" | \"get\" | \"list\";\n\n/**\n * Response type from GraphQL operations\n */\nexport interface GraphQLResponse<T = any> {\n\tdata: T | null;\n\terrors?: Array<{ message: string; [key: string]: any }>;\n}\n\n/**\n * Options for proxy requests\n */\nexport interface ProxyOptions {\n\t/** Custom API endpoint (default: /api/graphql) */\n\tendpoint?: string;\n\t/** Additional fetch options */\n\tfetchOptions?: RequestInit;\n}\n\n/**\n * Default proxy endpoint\n */\nconst DEFAULT_ENDPOINT = \"/api/graphql\";\n\n/**\n * Execute a GraphQL mutation through the server proxy\n *\n * @param model - The model name (e.g., 'User', 'Brand', 'Account')\n * @param operation - The operation type ('create', 'update', 'delete')\n * @param data - The operation data/input\n * @param options - Optional configuration\n * @returns Promise with the operation result\n *\n * @example Create\n * ```typescript\n * const result = await mutate('User', 'create', {\n * email: 'user@example.com',\n * accountId: '123',\n * });\n * ```\n *\n * @example Update\n * ```typescript\n * const result = await mutate('User', 'update', {\n * id: 'user-id',\n * status: 'deleted',\n * deletedAt: new Date().toISOString(),\n * });\n * ```\n *\n * @example Delete\n * ```typescript\n * const result = await mutate('User', 'delete', { id: 'user-id' });\n * ```\n */\nexport async function mutate<T = any>(\n\tmodel: string,\n\toperation: \"create\" | \"update\" | \"delete\",\n\tdata: Record<string, any>,\n\toptions?: ProxyOptions,\n): Promise<GraphQLResponse<T>> {\n\treturn proxyRequest<T>(model, operation, data, options);\n}\n\n/**\n * Execute a GraphQL query through the server proxy\n *\n * @param model - The model name (e.g., 'User', 'Brand', 'Account')\n * @param operation - The operation type ('get', 'list')\n * @param data - The query parameters (id for get, filter/limit for list)\n * @param options - Optional configuration\n * @returns Promise with the query result\n *\n * @example Get by ID\n * ```typescript\n * const result = await query('User', 'get', { id: 'user-id' });\n * ```\n *\n * @example List with filter\n * ```typescript\n * const result = await query('User', 'list', {\n * filter: { status: { eq: 'active' } },\n * limit: 100,\n * });\n * ```\n */\nexport async function query<T = any>(\n\tmodel: string,\n\toperation: \"get\" | \"list\",\n\tdata?: Record<string, any>,\n\toptions?: ProxyOptions,\n): Promise<GraphQLResponse<T>> {\n\treturn proxyRequest<T>(model, operation, data, options);\n}\n\n/**\n * Internal function to make proxy requests\n */\nasync function proxyRequest<T>(\n\tmodel: string,\n\toperation: Operation,\n\tdata?: Record<string, any>,\n\toptions?: ProxyOptions,\n): Promise<GraphQLResponse<T>> {\n\tconst endpoint = options?.endpoint ?? DEFAULT_ENDPOINT;\n\n\ttry {\n\t\tconst response = await fetch(endpoint, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t},\n\t\t\tcredentials: \"include\", // Important: include cookies\n\t\t\t...options?.fetchOptions,\n\t\t\tbody: JSON.stringify({ model, operation, data }),\n\t\t});\n\n\t\tconst result: GraphQLResponse<T> = await response.json();\n\n\t\t// Handle auth errors\n\t\tif (response.status === 401) {\n\t\t\tconsole.error(\"[GraphQL Proxy] Unauthorized - session may have expired\");\n\t\t\t// Optionally trigger a redirect to login\n\t\t\t// window.location.href = '/login';\n\t\t}\n\n\t\treturn result;\n\t} catch (error) {\n\t\tconsole.error(\"[GraphQL Proxy] Request failed:\", error);\n\t\treturn {\n\t\t\tdata: null,\n\t\t\terrors: [\n\t\t\t\t{\n\t\t\t\t\tmessage: error instanceof Error ? error.message : \"Network error\",\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}\n}\n\n/**\n * Helper to check if a response has errors\n */\nexport function hasErrors(response: GraphQLResponse): boolean {\n\treturn !!response.errors && response.errors.length > 0;\n}\n\n/**\n * Helper to get the first error message from a response\n */\nexport function getErrorMessage(response: GraphQLResponse): string | null {\n\tif (!response.errors || response.errors.length === 0) {\n\t\treturn null;\n\t}\n\treturn response.errors[0].message;\n}\n","/**\n * Brand Query Functions\n *\n * Provides query functions for fetching brand data from the GraphQL API.\n */\n\nimport type { Brand } from \"@htlkg/core/types\";\n\n/**\n * Get a single brand by ID\n *\n * @example\n * ```typescript\n * import { getBrand } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brand = await getBrand(client, 'brand-123');\n * ```\n */\nexport async function getBrand<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Brand | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Brand.get({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getBrand] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Brand;\n\t} catch (error) {\n\t\tconsole.error(\"[getBrand] Error fetching brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List all brands with optional filtering\n *\n * @example\n * ```typescript\n * import { listBrands } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brands = await listBrands(client, {\n * filter: { status: { eq: 'active' } }\n * });\n * ```\n */\nexport async function listBrands<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Brand[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (client as any).models.Brand.list(\n\t\t\toptions,\n\t\t);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listBrands] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as Brand[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[listBrands] Error fetching brands:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get a brand with its product instances\n *\n * @example\n * ```typescript\n * import { getBrandWithProducts } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brand = await getBrandWithProducts(client, 'brand-123');\n * ```\n */\nexport async function getBrandWithProducts<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Brand | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Brand.get(\n\t\t\t{ id },\n\t\t\t{\n\t\t\t\tselectionSet: [\n\t\t\t\t\t\"id\",\n\t\t\t\t\t\"name\",\n\t\t\t\t\t\"accountId\",\n\t\t\t\t\t\"logo\",\n\t\t\t\t\t\"timezone\",\n\t\t\t\t\t\"status\",\n\t\t\t\t\t\"settings\",\n\t\t\t\t\t\"productInstances.*\",\n\t\t\t\t],\n\t\t\t},\n\t\t);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getBrandWithProducts] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Brand;\n\t} catch (error) {\n\t\tconsole.error(\"[getBrandWithProducts] Error fetching brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List brands by account ID\n *\n * @example\n * ```typescript\n * import { listBrandsByAccount } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brands = await listBrandsByAccount(client, 'account-123');\n * ```\n */\nexport async function listBrandsByAccount<TClient = any>(\n\tclient: TClient,\n\taccountId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Brand[]; nextToken?: string }> {\n\treturn listBrands(client, {\n\t\tfilter: { accountId: { eq: accountId } },\n\t\t...options,\n\t});\n}\n\n/**\n * List active brands\n *\n * @example\n * ```typescript\n * import { listActiveBrands } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brands = await listActiveBrands(client);\n * ```\n */\nexport async function listActiveBrands<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Brand[]; nextToken?: string }> {\n\treturn listBrands(client, {\n\t\tfilter: { status: { eq: \"active\" } },\n\t\t...options,\n\t});\n}\n","/**\n * Account Query Functions\n *\n * Provides query functions for fetching account data from the GraphQL API.\n */\n\nimport type { Account } from \"@htlkg/core/types\";\n\n/**\n * Get a single account by ID\n *\n * @example\n * ```typescript\n * import { getAccount } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const account = await getAccount(client, 'account-123');\n * ```\n */\nexport async function getAccount<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Account | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Account.get({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getAccount] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Account;\n\t} catch (error) {\n\t\tconsole.error(\"[getAccount] Error fetching account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List all accounts with optional filtering\n *\n * @example\n * ```typescript\n * import { listAccounts } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const accounts = await listAccounts(client);\n * ```\n */\nexport async function listAccounts<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Account[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.Account.list(options);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listAccounts] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as Account[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[listAccounts] Error fetching accounts:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get an account with its brands\n *\n * @example\n * ```typescript\n * import { getAccountWithBrands } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const account = await getAccountWithBrands(client, 'account-123');\n * ```\n */\nexport async function getAccountWithBrands<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Account | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Account.get(\n\t\t\t{ id },\n\t\t\t{\n\t\t\t\tselectionSet: [\n\t\t\t\t\t\"id\",\n\t\t\t\t\t\"name\",\n\t\t\t\t\t\"logo\",\n\t\t\t\t\t\"subscription\",\n\t\t\t\t\t\"settings\",\n\t\t\t\t\t\"brands.*\",\n\t\t\t\t],\n\t\t\t},\n\t\t);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getAccountWithBrands] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Account;\n\t} catch (error) {\n\t\tconsole.error(\"[getAccountWithBrands] Error fetching account:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * User Query Functions\n *\n * Provides query functions for fetching user data from the GraphQL API.\n */\n\nimport type { User } from \"@htlkg/core/types\";\n\n/**\n * Get a single user by ID\n *\n * @example\n * ```typescript\n * import { getUser } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await getUser(client, 'user-123');\n * ```\n */\nexport async function getUser<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.get({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getUser] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as User;\n\t} catch (error) {\n\t\tconsole.error(\"[getUser] Error fetching user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get a user by Cognito ID\n *\n * @example\n * ```typescript\n * import { getUserByCognitoId } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await getUserByCognitoId(client, 'cognito-id-123');\n * ```\n */\nexport async function getUserByCognitoId<TClient = any>(\n\tclient: TClient,\n\tcognitoId: string,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.list({\n\t\t\tfilter: { cognitoId: { eq: cognitoId } },\n\t\t\tlimit: 1,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getUserByCognitoId] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data?.[0] as User | null;\n\t} catch (error) {\n\t\tconsole.error(\"[getUserByCognitoId] Error fetching user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get a user by email\n *\n * @example\n * ```typescript\n * import { getUserByEmail } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await getUserByEmail(client, 'user@example.com');\n * ```\n */\nexport async function getUserByEmail<TClient = any>(\n\tclient: TClient,\n\temail: string,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.list({\n\t\t\tfilter: { email: { eq: email } },\n\t\t\tlimit: 1,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getUserByEmail] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data?.[0] as User | null;\n\t} catch (error) {\n\t\tconsole.error(\"[getUserByEmail] Error fetching user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List all users with optional filtering\n *\n * @example\n * ```typescript\n * import { listUsers } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const users = await listUsers(client, {\n * filter: { status: { eq: 'active' } }\n * });\n * ```\n */\nexport async function listUsers<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: User[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (client as any).models.User.list(\n\t\t\toptions,\n\t\t);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listUsers] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as User[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[listUsers] Error fetching users:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List users by account ID\n *\n * @example\n * ```typescript\n * import { listUsersByAccount } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const users = await listUsersByAccount(client, 'account-123');\n * ```\n */\nexport async function listUsersByAccount<TClient = any>(\n\tclient: TClient,\n\taccountId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: User[]; nextToken?: string }> {\n\treturn listUsers(client, {\n\t\tfilter: { accountId: { eq: accountId } },\n\t\t...options,\n\t});\n}\n\n/**\n * List active users\n *\n * @example\n * ```typescript\n * import { listActiveUsers } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const users = await listActiveUsers(client);\n * ```\n */\nexport async function listActiveUsers<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: User[]; nextToken?: string }> {\n\treturn listUsers(client, {\n\t\tfilter: { status: { eq: \"active\" } },\n\t\t...options,\n\t});\n}\n","/**\n * Product Query Functions\n *\n * Provides query functions for fetching product and product instance data from the GraphQL API.\n */\n\nimport type { Product, ProductInstance } from \"@htlkg/core/types\";\n\n/**\n * Get a single product by ID\n *\n * @example\n * ```typescript\n * import { getProduct } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const product = await getProduct(client, 'product-123');\n * ```\n */\nexport async function getProduct<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Product | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Product.get({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getProduct] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Product;\n\t} catch (error) {\n\t\tconsole.error(\"[getProduct] Error fetching product:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List all products with optional filtering\n *\n * @example\n * ```typescript\n * import { listProducts } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const products = await listProducts(client, {\n * filter: { isActive: { eq: true } }\n * });\n * ```\n */\nexport async function listProducts<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Product[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.Product.list(options);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listProducts] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as Product[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[listProducts] Error fetching products:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List active products\n *\n * @example\n * ```typescript\n * import { listActiveProducts } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const products = await listActiveProducts(client);\n * ```\n */\nexport async function listActiveProducts<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Product[]; nextToken?: string }> {\n\treturn listProducts(client, {\n\t\tfilter: { isActive: { eq: true } },\n\t\t...options,\n\t});\n}\n\n/**\n * Get a single product instance by ID\n *\n * @example\n * ```typescript\n * import { getProductInstance } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instance = await getProductInstance(client, 'instance-123');\n * ```\n */\nexport async function getProductInstance<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<ProductInstance | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.ProductInstance.get({\n\t\t\tid,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getProductInstance] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as ProductInstance;\n\t} catch (error) {\n\t\tconsole.error(\"[getProductInstance] Error fetching product instance:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List product instances by brand ID\n *\n * @example\n * ```typescript\n * import { listProductInstancesByBrand } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instances = await listProductInstancesByBrand(client, 'brand-123');\n * ```\n */\nexport async function listProductInstancesByBrand<TClient = any>(\n\tclient: TClient,\n\tbrandId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: ProductInstance[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.ProductInstance.list({\n\t\t\tfilter: { brandId: { eq: brandId } },\n\t\t\t...options,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listProductInstancesByBrand] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as ProductInstance[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t\"[listProductInstancesByBrand] Error fetching product instances:\",\n\t\t\terror,\n\t\t);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List product instances by account ID\n *\n * @example\n * ```typescript\n * import { listProductInstancesByAccount } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instances = await listProductInstancesByAccount(client, 'account-123');\n * ```\n */\nexport async function listProductInstancesByAccount<TClient = any>(\n\tclient: TClient,\n\taccountId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: ProductInstance[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.ProductInstance.list({\n\t\t\tfilter: { accountId: { eq: accountId } },\n\t\t\t...options,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listProductInstancesByAccount] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as ProductInstance[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t\"[listProductInstancesByAccount] Error fetching product instances:\",\n\t\t\terror,\n\t\t);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List enabled product instances by brand ID\n *\n * @example\n * ```typescript\n * import { listEnabledProductInstancesByBrand } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instances = await listEnabledProductInstancesByBrand(client, 'brand-123');\n * ```\n */\nexport async function listEnabledProductInstancesByBrand<TClient = any>(\n\tclient: TClient,\n\tbrandId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: ProductInstance[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.ProductInstance.list({\n\t\t\tfilter: {\n\t\t\t\tbrandId: { eq: brandId },\n\t\t\t\tenabled: { eq: true },\n\t\t\t},\n\t\t\t...options,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\n\t\t\t\t\"[listEnabledProductInstancesByBrand] GraphQL errors:\",\n\t\t\t\terrors,\n\t\t\t);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as ProductInstance[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t\"[listEnabledProductInstancesByBrand] Error fetching product instances:\",\n\t\t\terror,\n\t\t);\n\t\tthrow error;\n\t}\n}\n","/**\n * Server-Side Query Helpers\n *\n * Convenience functions for executing server-side queries in Astro pages.\n * These helpers simplify the common pattern of using runWithAmplifyServerContext.\n */\n\nimport type { AstroGlobal } from \"astro\";\nimport { generateServerClient } from \"../client\";\n\n/**\n * Type for the runWithAmplifyServerContext function\n */\ntype RunWithAmplifyServerContext = (options: {\n\tastroServerContext: {\n\t\tcookies: AstroGlobal[\"cookies\"];\n\t\trequest: AstroGlobal[\"request\"];\n\t};\n\toperation: (contextSpec: unknown) => Promise<unknown>;\n}) => Promise<unknown>;\n\n/**\n * Helper to execute server-side queries in Astro pages\n *\n * This function wraps the common pattern of using runWithAmplifyServerContext\n * with generateServerClient, making it easier to fetch data server-side.\n *\n * **Note**: This requires `createRunWithAmplifyServerContext` from `@htlkg/core/amplify-astro-adapter`.\n * If you need more control, use the full pattern directly.\n *\n * @example\n * ```typescript\n * import type { Schema } from '../amplify/data/resource';\n * import { executeServerQuery } from '@htlkg/data/queries/server-helpers';\n * import { createRunWithAmplifyServerContext } from '@htlkg/core/amplify-astro-adapter';\n * import outputs from '../amplify_outputs.json';\n *\n * const runWithAmplifyServerContext = createRunWithAmplifyServerContext({ config: outputs });\n *\n * const users = await executeServerQuery<Schema>(\n * Astro,\n * runWithAmplifyServerContext,\n * async (client) => {\n * const result = await client.models.User.list();\n * return result.data || [];\n * }\n * );\n * ```\n */\nexport async function executeServerQuery<\n\tTSchema extends Record<string, unknown>,\n\tTResult,\n>(\n\tastro: AstroGlobal,\n\trunWithAmplifyServerContext: RunWithAmplifyServerContext,\n\toperation: (client: ReturnType<typeof generateServerClient<TSchema>>) => Promise<TResult>,\n): Promise<TResult> {\n\tconst result = await runWithAmplifyServerContext({\n\t\tastroServerContext: {\n\t\t\tcookies: astro.cookies,\n\t\t\trequest: astro.request,\n\t\t},\n\t\toperation: async (contextSpec: unknown) => {\n\t\t\tconst client = generateServerClient<TSchema>();\n\t\t\treturn await operation(client);\n\t\t},\n\t});\n\treturn result as TResult;\n}\n\n/**\n * Helper to execute server-side queries with API key authentication (public data)\n *\n * Use this for fetching public data that doesn't require user authentication.\n *\n * @example\n * ```typescript\n * import type { Schema } from '../amplify/data/resource';\n * import { executePublicQuery } from '@htlkg/data/queries/server-helpers';\n * import { createRunWithAmplifyServerContext } from '@htlkg/core/amplify-astro-adapter';\n * import outputs from '../amplify_outputs.json';\n *\n * const runWithAmplifyServerContext = createRunWithAmplifyServerContext({ config: outputs });\n *\n * const brands = await executePublicQuery<Schema>(\n * Astro,\n * runWithAmplifyServerContext,\n * async (client) => {\n * const result = await client.models.Brand.list();\n * return result.data || [];\n * }\n * );\n * ```\n */\nexport async function executePublicQuery<\n\tTSchema extends Record<string, unknown>,\n\tTResult,\n>(\n\tastro: AstroGlobal,\n\trunWithAmplifyServerContext: RunWithAmplifyServerContext,\n\toperation: (client: ReturnType<typeof generateServerClient<TSchema>>) => Promise<TResult>,\n): Promise<TResult> {\n\tconst result = await runWithAmplifyServerContext({\n\t\tastroServerContext: {\n\t\t\tcookies: astro.cookies,\n\t\t\trequest: astro.request,\n\t\t},\n\t\toperation: async (_contextSpec: unknown) => {\n\t\t\tconst client = generateServerClient<TSchema>({ authMode: \"apiKey\" });\n\t\t\treturn await operation(client);\n\t\t},\n\t});\n\treturn result as TResult;\n}\n","/**\n * SystemSettings Query Functions\n *\n * Provides query functions for fetching system settings from the GraphQL API.\n */\n\nimport type { SystemSettings } from \"@htlkg/core/types\";\n\n/** Default retention days if no settings exist */\nexport const DEFAULT_SOFT_DELETE_RETENTION_DAYS = 30;\n\n/** The key used for global system settings */\nexport const SYSTEM_SETTINGS_KEY = \"GLOBAL\";\n\n/**\n * Get system settings\n *\n * @example\n * ```typescript\n * import { getSystemSettings } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const settings = await getSystemSettings(client);\n * ```\n */\nexport async function getSystemSettings<TClient = any>(\n\tclient: TClient,\n): Promise<SystemSettings | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.SystemSettings.get({\n\t\t\tkey: SYSTEM_SETTINGS_KEY,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getSystemSettings] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as SystemSettings;\n\t} catch (error) {\n\t\tconsole.error(\"[getSystemSettings] Error fetching system settings:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get the soft delete retention days from system settings\n * Returns the default (30 days) if settings don't exist\n *\n * @example\n * ```typescript\n * import { getSoftDeleteRetentionDays } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const days = await getSoftDeleteRetentionDays(client);\n * ```\n */\nexport async function getSoftDeleteRetentionDays<TClient = any>(\n\tclient: TClient,\n): Promise<number> {\n\tconst settings = await getSystemSettings(client);\n\treturn settings?.softDeleteRetentionDays ?? DEFAULT_SOFT_DELETE_RETENTION_DAYS;\n}\n\n/**\n * Check if a soft-deleted item can still be restored based on retention period\n *\n * @param deletedAt - The ISO date string when the item was deleted\n * @param retentionDays - Number of days items can be restored\n * @returns Object with canRestore flag and daysRemaining/daysExpired\n */\nexport function checkRestoreEligibility(\n\tdeletedAt: string | undefined | null,\n\tretentionDays: number,\n): {\n\tcanRestore: boolean;\n\tdaysRemaining: number;\n\tdaysExpired: number;\n\texpiresAt: Date | null;\n} {\n\tif (!deletedAt) {\n\t\treturn {\n\t\t\tcanRestore: false,\n\t\t\tdaysRemaining: 0,\n\t\t\tdaysExpired: 0,\n\t\t\texpiresAt: null,\n\t\t};\n\t}\n\n\tconst deletedDate = new Date(deletedAt);\n\tconst expiresAt = new Date(deletedDate);\n\texpiresAt.setDate(expiresAt.getDate() + retentionDays);\n\n\tconst now = new Date();\n\tconst msRemaining = expiresAt.getTime() - now.getTime();\n\tconst daysRemaining = Math.ceil(msRemaining / (1000 * 60 * 60 * 24));\n\n\tif (daysRemaining <= 0) {\n\t\treturn {\n\t\t\tcanRestore: false,\n\t\t\tdaysRemaining: 0,\n\t\t\tdaysExpired: Math.abs(daysRemaining),\n\t\t\texpiresAt,\n\t\t};\n\t}\n\n\treturn {\n\t\tcanRestore: true,\n\t\tdaysRemaining,\n\t\tdaysExpired: 0,\n\t\texpiresAt,\n\t};\n}\n","/**\n * Reservation Query Functions\n *\n * Provides query functions for fetching reservation data from the GraphQL API.\n */\n\n/**\n * Reservation type for query results\n */\nexport interface Reservation {\n\tid: string;\n\tbrandId: string;\n\tvisitId: string;\n\tconfirmationCode: string;\n\tcheckIn: string;\n\tcheckOut: string;\n\tstatus: \"confirmed\" | \"checked_in\" | \"checked_out\" | \"cancelled\" | \"no_show\";\n\tsource?: string;\n\tchannel?: string;\n\troomType?: string;\n\troom?: string;\n\ttotalAmount?: number;\n\tcurrency?: string;\n\tnights?: number;\n\tcreatedAt?: string;\n\tcreatedBy?: string;\n\tupdatedAt?: string;\n\tupdatedBy?: string;\n\tdeletedAt?: string | null;\n\tdeletedBy?: string | null;\n}\n\n/**\n * Get a single reservation by ID\n *\n * @example\n * ```typescript\n * import { getReservation } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const reservation = await getReservation(client, 'reservation-123');\n * ```\n */\nexport async function getReservation<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Reservation | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Reservation.get({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getReservation] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Reservation;\n\t} catch (error) {\n\t\tconsole.error(\"[getReservation] Error fetching reservation:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List all reservations with optional filtering and pagination\n *\n * @example\n * ```typescript\n * import { listReservations } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const reservations = await listReservations(client, {\n * filter: { status: { eq: 'confirmed' } },\n * limit: 50\n * });\n * ```\n */\nexport async function listReservations<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Reservation[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (client as any).models.Reservation.list(\n\t\t\toptions,\n\t\t);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listReservations] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as Reservation[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[listReservations] Error fetching reservations:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List reservations by brand ID\n *\n * @example\n * ```typescript\n * import { listReservationsByBrand } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const reservations = await listReservationsByBrand(client, 'brand-123', {\n * limit: 100\n * });\n * ```\n */\nexport async function listReservationsByBrand<TClient = any>(\n\tclient: TClient,\n\tbrandId: string,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Reservation[]; nextToken?: string }> {\n\tconst filter = options?.filter\n\t\t? { and: [{ brandId: { eq: brandId } }, options.filter] }\n\t\t: { brandId: { eq: brandId } };\n\n\treturn listReservations(client, {\n\t\tfilter,\n\t\tlimit: options?.limit,\n\t\tnextToken: options?.nextToken,\n\t});\n}\n\n/**\n * List reservations by contact/visit ID\n *\n * @example\n * ```typescript\n * import { listReservationsByContact } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const reservations = await listReservationsByContact(client, 'contact-123');\n * ```\n */\nexport async function listReservationsByContact<TClient = any>(\n\tclient: TClient,\n\tcontactId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Reservation[]; nextToken?: string }> {\n\treturn listReservations(client, {\n\t\tfilter: { visitId: { eq: contactId } },\n\t\t...options,\n\t});\n}\n\n/**\n * List reservations by date range for a specific brand\n *\n * Filters reservations where check-in date falls within the specified range.\n *\n * @example\n * ```typescript\n * import { listReservationsByDateRange } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const reservations = await listReservationsByDateRange(\n * client,\n * 'brand-123',\n * '2024-01-01',\n * '2024-01-31'\n * );\n * ```\n */\nexport async function listReservationsByDateRange<TClient = any>(\n\tclient: TClient,\n\tbrandId: string,\n\tstartDate: string,\n\tendDate: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Reservation[]; nextToken?: string }> {\n\treturn listReservations(client, {\n\t\tfilter: {\n\t\t\tand: [\n\t\t\t\t{ brandId: { eq: brandId } },\n\t\t\t\t{ checkIn: { ge: startDate } },\n\t\t\t\t{ checkIn: { le: endDate } },\n\t\t\t],\n\t\t},\n\t\t...options,\n\t});\n}\n\n/**\n * Get a reservation by confirmation code and brand ID\n *\n * Returns the first matching reservation or null if not found.\n *\n * @example\n * ```typescript\n * import { getReservationByConfirmation } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const reservation = await getReservationByConfirmation(\n * client,\n * 'ABC123',\n * 'brand-123'\n * );\n * ```\n */\nexport async function getReservationByConfirmation<TClient = any>(\n\tclient: TClient,\n\tconfirmationCode: string,\n\tbrandId: string,\n): Promise<Reservation | null> {\n\ttry {\n\t\tconst { items } = await listReservations(client, {\n\t\t\tfilter: {\n\t\t\t\tand: [\n\t\t\t\t\t{ confirmationCode: { eq: confirmationCode } },\n\t\t\t\t\t{ brandId: { eq: brandId } },\n\t\t\t\t],\n\t\t\t},\n\t\t\tlimit: 1,\n\t\t});\n\n\t\treturn items.length > 0 ? items[0] : null;\n\t} catch (error) {\n\t\tconsole.error(\"[getReservationByConfirmation] Error fetching reservation:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * Contact Query Functions\n *\n * Provides query functions for fetching contact data from the GraphQL API.\n */\n\nimport type { Contact } from \"@htlkg/core/types\";\n\n/**\n * Get a single contact by ID\n *\n * @example\n * ```typescript\n * import { getContact } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const contact = await getContact(client, 'contact-123');\n * ```\n */\nexport async function getContact<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Contact | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Contact.get({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getContact] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Contact;\n\t} catch (error) {\n\t\tconsole.error(\"[getContact] Error fetching contact:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List all contacts with optional filtering\n *\n * @example\n * ```typescript\n * import { listContacts } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const contacts = await listContacts(client, {\n * filter: { gdprConsent: { eq: true } },\n * limit: 50\n * });\n * ```\n */\nexport async function listContacts<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Contact[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.Contact.list(options);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listContacts] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as Contact[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[listContacts] Error fetching contacts:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List contacts by brand ID\n *\n * @example\n * ```typescript\n * import { listContactsByBrand } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const contacts = await listContactsByBrand(client, 'brand-123');\n * ```\n */\nexport async function listContactsByBrand<TClient = any>(\n\tclient: TClient,\n\tbrandId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Contact[]; nextToken?: string }> {\n\treturn listContacts(client, {\n\t\tfilter: { brandId: { eq: brandId } },\n\t\t...options,\n\t});\n}\n\n/**\n * Get a contact by email within a brand\n *\n * @example\n * ```typescript\n * import { getContactByEmail } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const contact = await getContactByEmail(client, 'guest@example.com', 'brand-123');\n * ```\n */\nexport async function getContactByEmail<TClient = any>(\n\tclient: TClient,\n\temail: string,\n\tbrandId: string,\n): Promise<Contact | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Contact.list({\n\t\t\tfilter: {\n\t\t\t\tand: [{ email: { eq: email } }, { brandId: { eq: brandId } }],\n\t\t\t},\n\t\t\tlimit: 1,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getContactByEmail] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data?.[0] as Contact | null;\n\t} catch (error) {\n\t\tconsole.error(\"[getContactByEmail] Error fetching contact:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get a contact by phone within a brand\n *\n * @example\n * ```typescript\n * import { getContactByPhone } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const contact = await getContactByPhone(client, '+1234567890', 'brand-123');\n * ```\n */\nexport async function getContactByPhone<TClient = any>(\n\tclient: TClient,\n\tphone: string,\n\tbrandId: string,\n): Promise<Contact | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Contact.list({\n\t\t\tfilter: {\n\t\t\t\tand: [{ phone: { eq: phone } }, { brandId: { eq: brandId } }],\n\t\t\t},\n\t\t\tlimit: 1,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getContactByPhone] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data?.[0] as Contact | null;\n\t} catch (error) {\n\t\tconsole.error(\"[getContactByPhone] Error fetching contact:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Search contacts by query string within a brand\n * Searches across email, firstName, and lastName fields\n *\n * @example\n * ```typescript\n * import { searchContacts } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const contacts = await searchContacts(client, 'john', 'brand-123');\n * ```\n */\nexport async function searchContacts<TClient = any>(\n\tclient: TClient,\n\tquery: string,\n\tbrandId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Contact[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.Contact.list({\n\t\t\tfilter: {\n\t\t\t\tand: [\n\t\t\t\t\t{ brandId: { eq: brandId } },\n\t\t\t\t\t{\n\t\t\t\t\t\tor: [\n\t\t\t\t\t\t\t{ email: { contains: query } },\n\t\t\t\t\t\t\t{ firstName: { contains: query } },\n\t\t\t\t\t\t\t{ lastName: { contains: query } },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t...options,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[searchContacts] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as Contact[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[searchContacts] Error searching contacts:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * Brand Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting brands.\n */\n\nimport type { Brand } from \"@htlkg/core/types\";\nimport {\n\tcheckRestoreEligibility,\n\tDEFAULT_SOFT_DELETE_RETENTION_DAYS,\n} from \"../../queries/systemSettings\";\nimport type { CreateAuditFields, UpdateWithSoftDeleteFields } from \"../common\";\n\n/**\n * Input type for creating a brand\n */\nexport interface CreateBrandInput extends CreateAuditFields {\n\taccountId: string;\n\tname: string;\n\tlogo?: string;\n\ttimezone?: string;\n\tstatus?: \"active\" | \"inactive\" | \"maintenance\" | \"suspended\" | \"deleted\";\n\tsettings?: Record<string, any>;\n}\n\n/**\n * Input type for updating a brand\n */\nexport interface UpdateBrandInput extends UpdateWithSoftDeleteFields {\n\tid: string;\n\tname?: string;\n\tlogo?: string;\n\ttimezone?: string;\n\tstatus?: \"active\" | \"inactive\" | \"maintenance\" | \"suspended\" | \"deleted\";\n\tsettings?: Record<string, any>;\n}\n\n/**\n * Create a new brand\n *\n * @example\n * ```typescript\n * import { createBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brand = await createBrand(client, {\n * accountId: 'account-123',\n * name: 'My Brand',\n * timezone: 'America/New_York',\n * status: 'active'\n * });\n * ```\n */\nexport async function createBrand<TClient = any>(\n\tclient: TClient,\n\tinput: CreateBrandInput,\n): Promise<Brand | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Brand.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createBrand] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Brand;\n\t} catch (error) {\n\t\tconsole.error(\"[createBrand] Error creating brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing brand\n *\n * @example\n * ```typescript\n * import { updateBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brand = await updateBrand(client, {\n * id: 'brand-123',\n * name: 'Updated Brand Name',\n * status: 'maintenance'\n * });\n * ```\n */\nexport async function updateBrand<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateBrandInput,\n): Promise<Brand | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Brand.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateBrand] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Brand;\n\t} catch (error) {\n\t\tconsole.error(\"[updateBrand] Error updating brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Soft delete a brand (sets status to \"deleted\" instead of removing)\n *\n * @example\n * ```typescript\n * import { softDeleteBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await softDeleteBrand(client, 'brand-123', 'admin@example.com');\n * ```\n */\nexport async function softDeleteBrand<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tdeletedBy: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Brand.update({\n\t\t\tid,\n\t\t\tstatus: \"deleted\",\n\t\t\tdeletedAt: new Date().toISOString(),\n\t\t\tdeletedBy,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[softDeleteBrand] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[softDeleteBrand] Error soft-deleting brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Restore a soft-deleted brand (sets status back to \"active\")\n * Checks retention period before allowing restoration\n *\n * @example\n * ```typescript\n * import { restoreBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await restoreBrand(client, 'brand-123');\n * // Or with custom retention days:\n * await restoreBrand(client, 'brand-123', 60);\n * ```\n */\nexport async function restoreBrand<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tretentionDays: number = DEFAULT_SOFT_DELETE_RETENTION_DAYS,\n): Promise<{ success: boolean; error?: string }> {\n\ttry {\n\t\t// First, get the brand to check its deletedAt timestamp\n\t\tconst { data: brand, errors: getErrors } = await (\n\t\t\tclient as any\n\t\t).models.Brand.get({ id });\n\n\t\tif (getErrors || !brand) {\n\t\t\tconsole.error(\"[restoreBrand] Error fetching brand:\", getErrors);\n\t\t\treturn { success: false, error: \"Brand not found\" };\n\t\t}\n\n\t\t// Check if restoration is allowed based on retention period\n\t\tconst eligibility = checkRestoreEligibility(brand.deletedAt, retentionDays);\n\n\t\tif (!eligibility.canRestore) {\n\t\t\tconst errorMsg = `Cannot restore brand. Retention period of ${retentionDays} days has expired. Item was deleted ${eligibility.daysExpired} days ago.`;\n\t\t\tconsole.error(\"[restoreBrand]\", errorMsg);\n\t\t\treturn { success: false, error: errorMsg };\n\t\t}\n\n\t\tconst { errors } = await (client as any).models.Brand.update({\n\t\t\tid,\n\t\t\tstatus: \"active\",\n\t\t\tdeletedAt: null,\n\t\t\tdeletedBy: null,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[restoreBrand] GraphQL errors:\", errors);\n\t\t\treturn { success: false, error: \"Failed to restore brand\" };\n\t\t}\n\n\t\treturn { success: true };\n\t} catch (error) {\n\t\tconsole.error(\"[restoreBrand] Error restoring brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Hard delete a brand (permanently removes from database)\n * Use with caution - prefer softDeleteBrand for recoverable deletion\n *\n * @example\n * ```typescript\n * import { deleteBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteBrand(client, 'brand-123');\n * ```\n */\nexport async function deleteBrand<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Brand.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteBrand] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteBrand] Error deleting brand:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * Account Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting accounts.\n */\n\nimport type { Account } from \"@htlkg/core/types\";\nimport {\n\tcheckRestoreEligibility,\n\tDEFAULT_SOFT_DELETE_RETENTION_DAYS,\n} from \"../../queries/systemSettings\";\nimport type { CreateAuditFields, UpdateWithSoftDeleteFields } from \"../common\";\n\n/**\n * Input type for creating an account\n */\nexport interface CreateAccountInput extends CreateAuditFields {\n\tname: string;\n\tlogo?: string;\n\tsubscription?: Record<string, any>;\n\tsettings?: Record<string, any>;\n\tstatus?: \"active\" | \"inactive\" | \"deleted\";\n}\n\n/**\n * Input type for updating an account\n */\nexport interface UpdateAccountInput extends UpdateWithSoftDeleteFields {\n\tid: string;\n\tname?: string;\n\tlogo?: string;\n\tsubscription?: Record<string, any>;\n\tsettings?: Record<string, any>;\n\tstatus?: \"active\" | \"inactive\" | \"deleted\";\n}\n\n/**\n * Create a new account\n *\n * @example\n * ```typescript\n * import { createAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const account = await createAccount(client, {\n * name: 'My Account',\n * subscription: { plan: 'premium' }\n * });\n * ```\n */\nexport async function createAccount<TClient = any>(\n\tclient: TClient,\n\tinput: CreateAccountInput,\n): Promise<Account | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Account.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createAccount] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Account;\n\t} catch (error) {\n\t\tconsole.error(\"[createAccount] Error creating account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing account\n *\n * @example\n * ```typescript\n * import { updateAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const account = await updateAccount(client, {\n * id: 'account-123',\n * name: 'Updated Account Name'\n * });\n * ```\n */\nexport async function updateAccount<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateAccountInput,\n): Promise<Account | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Account.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateAccount] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Account;\n\t} catch (error) {\n\t\tconsole.error(\"[updateAccount] Error updating account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Soft delete an account (sets status to \"deleted\" instead of removing)\n *\n * @example\n * ```typescript\n * import { softDeleteAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await softDeleteAccount(client, 'account-123', 'admin@example.com');\n * ```\n */\nexport async function softDeleteAccount<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tdeletedBy: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Account.update({\n\t\t\tid,\n\t\t\tstatus: \"deleted\",\n\t\t\tdeletedAt: new Date().toISOString(),\n\t\t\tdeletedBy,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[softDeleteAccount] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[softDeleteAccount] Error soft-deleting account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Restore a soft-deleted account (sets status back to \"active\")\n * Checks retention period before allowing restoration\n *\n * @example\n * ```typescript\n * import { restoreAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await restoreAccount(client, 'account-123');\n * // Or with custom retention days:\n * await restoreAccount(client, 'account-123', 60);\n * ```\n */\nexport async function restoreAccount<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tretentionDays: number = DEFAULT_SOFT_DELETE_RETENTION_DAYS,\n): Promise<{ success: boolean; error?: string }> {\n\ttry {\n\t\t// First, get the account to check its deletedAt timestamp\n\t\tconst { data: account, errors: getErrors } = await (\n\t\t\tclient as any\n\t\t).models.Account.get({ id });\n\n\t\tif (getErrors || !account) {\n\t\t\tconsole.error(\"[restoreAccount] Error fetching account:\", getErrors);\n\t\t\treturn { success: false, error: \"Account not found\" };\n\t\t}\n\n\t\t// Check if restoration is allowed based on retention period\n\t\tconst eligibility = checkRestoreEligibility(account.deletedAt, retentionDays);\n\n\t\tif (!eligibility.canRestore) {\n\t\t\tconst errorMsg = `Cannot restore account. Retention period of ${retentionDays} days has expired. Item was deleted ${eligibility.daysExpired} days ago.`;\n\t\t\tconsole.error(\"[restoreAccount]\", errorMsg);\n\t\t\treturn { success: false, error: errorMsg };\n\t\t}\n\n\t\tconst { errors } = await (client as any).models.Account.update({\n\t\t\tid,\n\t\t\tstatus: \"active\",\n\t\t\tdeletedAt: null,\n\t\t\tdeletedBy: null,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[restoreAccount] GraphQL errors:\", errors);\n\t\t\treturn { success: false, error: \"Failed to restore account\" };\n\t\t}\n\n\t\treturn { success: true };\n\t} catch (error) {\n\t\tconsole.error(\"[restoreAccount] Error restoring account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Hard delete an account (permanently removes from database)\n * Use with caution - prefer softDeleteAccount for recoverable deletion\n *\n * @example\n * ```typescript\n * import { deleteAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteAccount(client, 'account-123');\n * ```\n */\nexport async function deleteAccount<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Account.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteAccount] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteAccount] Error deleting account:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * User Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting users.\n */\n\nimport type { User } from \"@htlkg/core/types\";\nimport {\n\tcheckRestoreEligibility,\n\tDEFAULT_SOFT_DELETE_RETENTION_DAYS,\n} from \"../../queries/systemSettings\";\nimport type { CreateAuditFields, UpdateWithSoftDeleteFields } from \"../common\";\n\n/**\n * Input type for creating a user\n */\nexport interface CreateUserInput extends CreateAuditFields {\n\tcognitoId: string;\n\temail: string;\n\taccountId: string;\n\tbrandIds?: string[];\n\troles?: string[];\n\tpermissions?: Record<string, any>;\n\tstatus?: \"active\" | \"inactive\" | \"pending\" | \"suspended\" | \"deleted\";\n}\n\n/**\n * Input type for updating a user\n */\nexport interface UpdateUserInput extends UpdateWithSoftDeleteFields {\n\tid: string;\n\temail?: string;\n\tbrandIds?: string[];\n\troles?: string[];\n\tpermissions?: Record<string, any>;\n\tlastLogin?: string;\n\tstatus?: \"active\" | \"inactive\" | \"pending\" | \"suspended\" | \"deleted\";\n}\n\n/**\n * Create a new user\n *\n * @example\n * ```typescript\n * import { createUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await createUser(client, {\n * cognitoId: 'cognito-123',\n * email: 'user@example.com',\n * accountId: 'account-123',\n * roles: ['BRAND_ADMIN'],\n * status: 'active'\n * });\n * ```\n */\nexport async function createUser<TClient = any>(\n\tclient: TClient,\n\tinput: CreateUserInput,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createUser] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as User;\n\t} catch (error) {\n\t\tconsole.error(\"[createUser] Error creating user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing user\n *\n * @example\n * ```typescript\n * import { updateUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await updateUser(client, {\n * id: 'user-123',\n * roles: ['BRAND_ADMIN', 'ACCOUNT_ADMIN'],\n * status: 'active'\n * });\n * ```\n */\nexport async function updateUser<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateUserInput,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateUser] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as User;\n\t} catch (error) {\n\t\tconsole.error(\"[updateUser] Error updating user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Soft delete a user (sets status to \"deleted\" instead of removing)\n *\n * @example\n * ```typescript\n * import { softDeleteUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await softDeleteUser(client, 'user-123', 'admin@example.com');\n * ```\n */\nexport async function softDeleteUser<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tdeletedBy: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.User.update({\n\t\t\tid,\n\t\t\tstatus: \"deleted\",\n\t\t\tdeletedAt: new Date().toISOString(),\n\t\t\tdeletedBy,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[softDeleteUser] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[softDeleteUser] Error soft-deleting user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Restore a soft-deleted user (sets status back to \"active\")\n * Checks retention period before allowing restoration\n *\n * @example\n * ```typescript\n * import { restoreUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await restoreUser(client, 'user-123');\n * // Or with custom retention days:\n * await restoreUser(client, 'user-123', 60);\n * ```\n */\nexport async function restoreUser<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tretentionDays: number = DEFAULT_SOFT_DELETE_RETENTION_DAYS,\n): Promise<{ success: boolean; error?: string }> {\n\ttry {\n\t\t// First, get the user to check its deletedAt timestamp\n\t\tconst { data: user, errors: getErrors } = await (\n\t\t\tclient as any\n\t\t).models.User.get({ id });\n\n\t\tif (getErrors || !user) {\n\t\t\tconsole.error(\"[restoreUser] Error fetching user:\", getErrors);\n\t\t\treturn { success: false, error: \"User not found\" };\n\t\t}\n\n\t\t// Check if restoration is allowed based on retention period\n\t\tconst eligibility = checkRestoreEligibility(user.deletedAt, retentionDays);\n\n\t\tif (!eligibility.canRestore) {\n\t\t\tconst errorMsg = `Cannot restore user. Retention period of ${retentionDays} days has expired. Item was deleted ${eligibility.daysExpired} days ago.`;\n\t\t\tconsole.error(\"[restoreUser]\", errorMsg);\n\t\t\treturn { success: false, error: errorMsg };\n\t\t}\n\n\t\tconst { errors } = await (client as any).models.User.update({\n\t\t\tid,\n\t\t\tstatus: \"active\",\n\t\t\tdeletedAt: null,\n\t\t\tdeletedBy: null,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[restoreUser] GraphQL errors:\", errors);\n\t\t\treturn { success: false, error: \"Failed to restore user\" };\n\t\t}\n\n\t\treturn { success: true };\n\t} catch (error) {\n\t\tconsole.error(\"[restoreUser] Error restoring user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Hard delete a user (permanently removes from database)\n * Use with caution - prefer softDeleteUser for recoverable deletion\n *\n * @example\n * ```typescript\n * import { deleteUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteUser(client, 'user-123');\n * ```\n */\nexport async function deleteUser<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.User.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteUser] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteUser] Error deleting user:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * ProductInstance Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting product instances.\n * Product instances represent enabled products for a specific brand with their configuration.\n */\n\nimport type { ProductInstance } from \"@htlkg/core/types\";\nimport { getClientUser } from \"@htlkg/core/auth\";\nimport { getCurrentTimestamp } from \"@htlkg/core/utils\";\nimport { AppError } from \"@htlkg/core/errors\";\nimport type { CreateAuditFields, UpdateAuditFields } from \"../common\";\n\n/**\n * Get current user identifier for audit trails\n * Uses getClientUser() and returns email or username, falling back to \"system\"\n */\nasync function getUserIdentifier(fallback = \"system\"): Promise<string> {\n\ttry {\n\t\tconst user = await getClientUser();\n\t\tif (user) {\n\t\t\treturn user.email || user.username || fallback;\n\t\t}\n\t\treturn fallback;\n\t} catch {\n\t\treturn fallback;\n\t}\n}\n\n/**\n * Input type for creating a product instance\n */\nexport interface CreateProductInstanceInput extends CreateAuditFields {\n\tproductId: string;\n\tbrandId: string;\n\taccountId: string;\n\tproductName: string;\n\tenabled: boolean;\n\tconfig?: Record<string, any>;\n\tversion?: string;\n}\n\n/**\n * Input type for updating a product instance\n */\nexport interface UpdateProductInstanceInput extends UpdateAuditFields {\n\tid: string;\n\tenabled?: boolean;\n\tconfig?: Record<string, any>;\n\tversion?: string;\n}\n\n/**\n * Create a new product instance\n *\n * @example\n * ```typescript\n * import { createProductInstance } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instance = await createProductInstance(client, {\n * productId: 'product-123',\n * brandId: 'brand-456',\n * accountId: 'account-789',\n * enabled: true,\n * config: { apiKey: 'xxx', maxRequests: 100 }\n * });\n * ```\n */\nexport async function createProductInstance<TClient = any>(\n\tclient: TClient,\n\tinput: CreateProductInstanceInput,\n): Promise<ProductInstance | null> {\n\ttry {\n\t\t// Get user identifier for audit trail\n\t\tconst userIdentifier = input.createdBy || input.updatedBy || await getUserIdentifier();\n\n\t\t// Build input - manually construct to avoid Vue Proxy issues\n\t\tconst timestamp = input.createdAt || getCurrentTimestamp();\n\t\tconst createInput: any = {\n\t\t\tproductId: input.productId,\n\t\t\tproductName: input.productName,\n\t\t\tbrandId: input.brandId,\n\t\t\taccountId: input.accountId,\n\t\t\tenabled: input.enabled,\n\t\t\tversion: input.version,\n\t\t\tcreatedAt: timestamp,\n\t\t\tcreatedBy: userIdentifier,\n\t\t\tupdatedAt: input.updatedAt || timestamp,\n\t\t\tupdatedBy: userIdentifier,\n\t\t};\n\n\t\t// AWSJSON type requires JSON STRING\n\t\tif (input.config) {\n\t\t\t// Double stringify: first to strip Vue Proxy, second to create JSON string\n\t\t\tcreateInput.config = JSON.stringify(JSON.parse(JSON.stringify(input.config)));\n\t\t}\n\n\t\tconsole.log(\"[createProductInstance] Config as string:\", createInput.config);\n\t\tconsole.log(\"[createProductInstance] Config type:\", typeof createInput.config);\n\n\t\tconst { data, errors } = await (client as any).models.ProductInstance.create(createInput);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createProductInstance] GraphQL errors:\", errors);\n\t\t\tthrow new AppError(\n\t\t\t\t\"Failed to create product instance\",\n\t\t\t\t\"PRODUCT_INSTANCE_CREATE_ERROR\",\n\t\t\t\t500,\n\t\t\t\t{ errors }\n\t\t\t);\n\t\t}\n\n\t\treturn data as ProductInstance;\n\t} catch (error) {\n\t\tconsole.error(\"[createProductInstance] Error creating product instance:\", error);\n\t\tif (error instanceof AppError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new AppError(\n\t\t\t\"Failed to create product instance\",\n\t\t\t\"PRODUCT_INSTANCE_CREATE_ERROR\",\n\t\t\t500,\n\t\t\t{ originalError: error }\n\t\t);\n\t}\n}\n\n/**\n * Update an existing product instance\n *\n * @example\n * ```typescript\n * import { updateProductInstance } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instance = await updateProductInstance(client, {\n * id: 'instance-123',\n * enabled: false,\n * config: { apiKey: 'new-key', maxRequests: 200 }\n * });\n * ```\n */\nexport async function updateProductInstance<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateProductInstanceInput,\n): Promise<ProductInstance | null> {\n\ttry {\n\t\t// Add timestamp and user metadata if not provided\n\t\t// Convert config from Vue Proxy to plain object\n\t\tconst updateInput: any = {\n\t\t\t...input,\n\t\t\tupdatedAt: input.updatedAt || getCurrentTimestamp(),\n\t\t\tupdatedBy: input.updatedBy || await getUserIdentifier(),\n\t\t};\n\n\t\t// AWSJSON type requires JSON STRING\n\t\tif (input.config) {\n\t\t\tupdateInput.config = JSON.stringify(JSON.parse(JSON.stringify(input.config)));\n\t\t}\n\n\t\tconst { data, errors } = await (client as any).models.ProductInstance.update(updateInput);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateProductInstance] GraphQL errors:\", errors);\n\t\t\tthrow new AppError(\n\t\t\t\t\"Failed to update product instance\",\n\t\t\t\t\"PRODUCT_INSTANCE_UPDATE_ERROR\",\n\t\t\t\t500,\n\t\t\t\t{ errors }\n\t\t\t);\n\t\t}\n\n\t\treturn data as ProductInstance;\n\t} catch (error) {\n\t\tconsole.error(\"[updateProductInstance] Error updating product instance:\", error);\n\t\tif (error instanceof AppError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new AppError(\n\t\t\t\"Failed to update product instance\",\n\t\t\t\"PRODUCT_INSTANCE_UPDATE_ERROR\",\n\t\t\t500,\n\t\t\t{ originalError: error }\n\t\t);\n\t}\n}\n\n/**\n * Delete a product instance\n *\n * @example\n * ```typescript\n * import { deleteProductInstance } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteProductInstance(client, 'instance-123');\n * ```\n */\nexport async function deleteProductInstance<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.ProductInstance.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteProductInstance] GraphQL errors:\", errors);\n\t\t\tthrow new AppError(\n\t\t\t\t\"Failed to delete product instance\",\n\t\t\t\t\"PRODUCT_INSTANCE_DELETE_ERROR\",\n\t\t\t\t500,\n\t\t\t\t{ errors }\n\t\t\t);\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteProductInstance] Error deleting product instance:\", error);\n\t\tif (error instanceof AppError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new AppError(\n\t\t\t\"Failed to delete product instance\",\n\t\t\t\"PRODUCT_INSTANCE_DELETE_ERROR\",\n\t\t\t500,\n\t\t\t{ originalError: error }\n\t\t);\n\t}\n}\n\n/**\n * Toggle the enabled status of a product instance\n *\n * @example\n * ```typescript\n * import { toggleProductInstanceEnabled } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instance = await toggleProductInstanceEnabled(client, 'instance-123', true);\n * ```\n */\nexport async function toggleProductInstanceEnabled<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tenabled: boolean,\n): Promise<ProductInstance | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.ProductInstance.update({\n\t\t\tid,\n\t\t\tenabled,\n\t\t\tlastUpdated: getCurrentTimestamp(),\n\t\t\tupdatedBy: await getUserIdentifier(),\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[toggleProductInstanceEnabled] GraphQL errors:\", errors);\n\t\t\tthrow new AppError(\n\t\t\t\t\"Failed to toggle product instance\",\n\t\t\t\t\"PRODUCT_INSTANCE_TOGGLE_ERROR\",\n\t\t\t\t500,\n\t\t\t\t{ errors }\n\t\t\t);\n\t\t}\n\n\t\treturn data as ProductInstance;\n\t} catch (error) {\n\t\tconsole.error(\"[toggleProductInstanceEnabled] Error toggling product instance:\", error);\n\t\tif (error instanceof AppError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new AppError(\n\t\t\t\"Failed to toggle product instance\",\n\t\t\t\"PRODUCT_INSTANCE_TOGGLE_ERROR\",\n\t\t\t500,\n\t\t\t{ originalError: error }\n\t\t);\n\t}\n}\n","/**\n * SystemSettings Mutation Functions\n *\n * Provides mutation functions for managing system settings.\n */\n\nimport type { SystemSettings } from \"@htlkg/core/types\";\nimport {\n\tSYSTEM_SETTINGS_KEY,\n\tDEFAULT_SOFT_DELETE_RETENTION_DAYS,\n} from \"../queries/systemSettings\";\n\n/**\n * Input type for updating system settings\n */\nexport interface UpdateSystemSettingsInput {\n\tsoftDeleteRetentionDays: number;\n\tupdatedBy: string;\n}\n\n/**\n * Update or create system settings\n * Only SUPER_ADMINS can update system settings\n *\n * @example\n * ```typescript\n * import { updateSystemSettings } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const settings = await updateSystemSettings(client, {\n * softDeleteRetentionDays: 60,\n * updatedBy: 'admin@example.com'\n * });\n * ```\n */\nexport async function updateSystemSettings<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateSystemSettingsInput,\n): Promise<SystemSettings | null> {\n\ttry {\n\t\t// Validate retention days (minimum 1 day, maximum 365 days)\n\t\tif (input.softDeleteRetentionDays < 1 || input.softDeleteRetentionDays > 365) {\n\t\t\tconsole.error(\n\t\t\t\t\"[updateSystemSettings] Invalid retention days. Must be between 1 and 365.\",\n\t\t\t);\n\t\t\treturn null;\n\t\t}\n\n\t\t// First, try to get existing settings\n\t\tconst { data: existing } = await (client as any).models.SystemSettings.get({\n\t\t\tkey: SYSTEM_SETTINGS_KEY,\n\t\t});\n\n\t\tconst settingsData = {\n\t\t\tkey: SYSTEM_SETTINGS_KEY,\n\t\t\tsoftDeleteRetentionDays: input.softDeleteRetentionDays,\n\t\t\tupdatedAt: new Date().toISOString(),\n\t\t\tupdatedBy: input.updatedBy,\n\t\t};\n\n\t\tlet result;\n\t\tif (existing) {\n\t\t\t// Update existing settings\n\t\t\tresult = await (client as any).models.SystemSettings.update(settingsData);\n\t\t} else {\n\t\t\t// Create new settings\n\t\t\tresult = await (client as any).models.SystemSettings.create(settingsData);\n\t\t}\n\n\t\tif (result.errors) {\n\t\t\tconsole.error(\"[updateSystemSettings] GraphQL errors:\", result.errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn result.data as SystemSettings;\n\t} catch (error) {\n\t\tconsole.error(\"[updateSystemSettings] Error updating system settings:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Initialize system settings with default values if they don't exist\n *\n * @example\n * ```typescript\n * import { initializeSystemSettings } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const settings = await initializeSystemSettings(client, 'system@hotelinking.com');\n * ```\n */\nexport async function initializeSystemSettings<TClient = any>(\n\tclient: TClient,\n\tinitializedBy: string,\n): Promise<SystemSettings | null> {\n\ttry {\n\t\t// Check if settings already exist\n\t\tconst { data: existing } = await (client as any).models.SystemSettings.get({\n\t\t\tkey: SYSTEM_SETTINGS_KEY,\n\t\t});\n\n\t\tif (existing) {\n\t\t\treturn existing as SystemSettings;\n\t\t}\n\n\t\t// Create default settings\n\t\tconst { data, errors } = await (client as any).models.SystemSettings.create({\n\t\t\tkey: SYSTEM_SETTINGS_KEY,\n\t\t\tsoftDeleteRetentionDays: DEFAULT_SOFT_DELETE_RETENTION_DAYS,\n\t\t\tupdatedAt: new Date().toISOString(),\n\t\t\tupdatedBy: initializedBy,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[initializeSystemSettings] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as SystemSettings;\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t\"[initializeSystemSettings] Error initializing system settings:\",\n\t\t\terror,\n\t\t);\n\t\tthrow error;\n\t}\n}\n","/**\n * Reservation Mutation Functions\n *\n * Provides type-safe mutation functions for creating, updating, and deleting reservations.\n * Includes date validation and status transition rules.\n */\n\nimport {\n\tcheckRestoreEligibility,\n\tDEFAULT_SOFT_DELETE_RETENTION_DAYS,\n} from \"../../queries/systemSettings\";\nimport type { CreateAuditFields, UpdateWithSoftDeleteFields } from \"../common\";\n\n/**\n * Reservation status type\n */\nexport type ReservationStatus = \"confirmed\" | \"checked_in\" | \"checked_out\" | \"cancelled\" | \"no_show\";\n\n/**\n * Valid status transitions for reservations\n * Maps current status -> allowed next statuses\n */\nconst STATUS_TRANSITIONS: Record<ReservationStatus, ReservationStatus[]> = {\n\tconfirmed: [\"checked_in\", \"cancelled\", \"no_show\"],\n\tchecked_in: [\"checked_out\", \"cancelled\"],\n\tchecked_out: [], // Terminal state - no transitions allowed\n\tcancelled: [], // Terminal state - no transitions allowed\n\tno_show: [], // Terminal state - no transitions allowed\n};\n\n/**\n * Validation error class for reservation operations\n */\nexport class ReservationValidationError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"ReservationValidationError\";\n\t}\n}\n\n/**\n * Validate check-in and check-out dates\n * @throws {ReservationValidationError} if dates are invalid\n */\nfunction validateDates(checkIn: string, checkOut: string): void {\n\tconst checkInDate = new Date(checkIn);\n\tconst checkOutDate = new Date(checkOut);\n\n\t// Check if dates are valid\n\tif (isNaN(checkInDate.getTime())) {\n\t\tthrow new ReservationValidationError(\"Invalid check-in date\");\n\t}\n\n\tif (isNaN(checkOutDate.getTime())) {\n\t\tthrow new ReservationValidationError(\"Invalid check-out date\");\n\t}\n\n\t// Check-out must be after check-in\n\tif (checkOutDate <= checkInDate) {\n\t\tthrow new ReservationValidationError(\n\t\t\t\"Check-out date must be after check-in date\"\n\t\t);\n\t}\n\n\t// Calculate minimum stay (at least a few hours)\n\tconst minStayHours = 4;\n\tconst stayDuration = checkOutDate.getTime() - checkInDate.getTime();\n\tconst hoursDiff = stayDuration / (1000 * 60 * 60);\n\n\tif (hoursDiff < minStayHours) {\n\t\tthrow new ReservationValidationError(\n\t\t\t`Minimum stay is ${minStayHours} hours`\n\t\t);\n\t}\n}\n\n/**\n * Validate status transition\n * @throws {ReservationValidationError} if transition is not allowed\n */\nfunction validateStatusTransition(\n\tcurrentStatus: ReservationStatus,\n\tnewStatus: ReservationStatus\n): void {\n\tconst allowedTransitions = STATUS_TRANSITIONS[currentStatus];\n\n\tif (!allowedTransitions.includes(newStatus)) {\n\t\tthrow new ReservationValidationError(\n\t\t\t`Invalid status transition from '${currentStatus}' to '${newStatus}'. ` +\n\t\t\t`Allowed transitions: ${allowedTransitions.length > 0 ? allowedTransitions.join(\", \") : \"none (terminal state)\"}`\n\t\t);\n\t}\n}\n\n/**\n * Input type for creating a reservation\n */\nexport interface CreateReservationInput extends CreateAuditFields {\n\tbrandId: string;\n\tvisitId: string;\n\tconfirmationCode: string;\n\tcheckIn: string;\n\tcheckOut: string;\n\tstatus?: \"confirmed\" | \"checked_in\" | \"checked_out\" | \"cancelled\" | \"no_show\";\n\tsource?: string;\n\tchannel?: string;\n\troomType?: string;\n\troom?: string;\n\ttotalAmount?: number;\n\tcurrency?: string;\n\tnights?: number;\n}\n\n/**\n * Input type for updating a reservation\n */\nexport interface UpdateReservationInput extends UpdateWithSoftDeleteFields {\n\tid: string;\n\tbrandId?: string;\n\tvisitId?: string;\n\tconfirmationCode?: string;\n\tcheckIn?: string;\n\tcheckOut?: string;\n\tstatus?: \"confirmed\" | \"checked_in\" | \"checked_out\" | \"cancelled\" | \"no_show\";\n\tsource?: string;\n\tchannel?: string;\n\troomType?: string;\n\troom?: string;\n\ttotalAmount?: number;\n\tcurrency?: string;\n\tnights?: number;\n}\n\n/**\n * Create a new reservation with date validation\n *\n * @throws {ReservationValidationError} if dates are invalid\n *\n * @example\n * ```typescript\n * import { createReservation } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const reservation = await createReservation(client, {\n * brandId: 'brand-123',\n * visitId: 'visit-456',\n * confirmationCode: 'ABC123',\n * checkIn: '2024-01-01',\n * checkOut: '2024-01-05',\n * status: 'confirmed'\n * });\n * ```\n */\nexport async function createReservation<TClient = any>(\n\tclient: TClient,\n\tinput: CreateReservationInput,\n): Promise<any | null> {\n\ttry {\n\t\t// Validate dates before creating\n\t\tvalidateDates(input.checkIn, input.checkOut);\n\n\t\t// Calculate nights if not provided\n\t\tif (!input.nights) {\n\t\t\tconst checkInDate = new Date(input.checkIn);\n\t\t\tconst checkOutDate = new Date(input.checkOut);\n\t\t\tconst diffTime = checkOutDate.getTime() - checkInDate.getTime();\n\t\t\tconst diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));\n\t\t\tinput.nights = diffDays;\n\t\t}\n\n\t\tconst { data, errors } = await (client as any).models.Reservation.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createReservation] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data;\n\t} catch (error) {\n\t\tif (error instanceof ReservationValidationError) {\n\t\t\tconsole.error(\"[createReservation] Validation error:\", error.message);\n\t\t\tthrow error;\n\t\t}\n\t\tconsole.error(\"[createReservation] Error creating reservation:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing reservation with validation\n *\n * @throws {ReservationValidationError} if dates or status transition is invalid\n *\n * @example\n * ```typescript\n * import { updateReservation } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const reservation = await updateReservation(client, {\n * id: 'reservation-123',\n * status: 'checked_in',\n * room: '201'\n * });\n * ```\n */\nexport async function updateReservation<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateReservationInput,\n): Promise<any | null> {\n\ttry {\n\t\t// If both dates are being updated, validate them\n\t\tif (input.checkIn && input.checkOut) {\n\t\t\tvalidateDates(input.checkIn, input.checkOut);\n\n\t\t\t// Recalculate nights if dates changed\n\t\t\tconst checkInDate = new Date(input.checkIn);\n\t\t\tconst checkOutDate = new Date(input.checkOut);\n\t\t\tconst diffTime = checkOutDate.getTime() - checkInDate.getTime();\n\t\t\tconst diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));\n\t\t\tinput.nights = diffDays;\n\t\t}\n\n\t\t// If status is being updated, validate the transition\n\t\tif (input.status) {\n\t\t\t// Get current reservation to check current status\n\t\t\tconst { data: currentReservation, errors: getErrors } = await (\n\t\t\t\tclient as any\n\t\t\t).models.Reservation.get({ id: input.id });\n\n\t\t\tif (getErrors || !currentReservation) {\n\t\t\t\tconsole.error(\"[updateReservation] Error fetching current reservation:\", getErrors);\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst currentStatus = currentReservation.status as ReservationStatus;\n\t\t\tvalidateStatusTransition(currentStatus, input.status as ReservationStatus);\n\t\t}\n\n\t\tconst { data, errors } = await (client as any).models.Reservation.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateReservation] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data;\n\t} catch (error) {\n\t\tif (error instanceof ReservationValidationError) {\n\t\t\tconsole.error(\"[updateReservation] Validation error:\", error.message);\n\t\t\tthrow error;\n\t\t}\n\t\tconsole.error(\"[updateReservation] Error updating reservation:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Soft delete a reservation (sets deletedAt/deletedBy instead of removing)\n *\n * @example\n * ```typescript\n * import { softDeleteReservation } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await softDeleteReservation(client, 'reservation-123', 'admin@example.com');\n * ```\n */\nexport async function softDeleteReservation<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tdeletedBy: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Reservation.update({\n\t\t\tid,\n\t\t\tdeletedAt: new Date().toISOString(),\n\t\t\tdeletedBy,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[softDeleteReservation] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[softDeleteReservation] Error soft-deleting reservation:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Restore a soft-deleted reservation\n * Checks retention period before allowing restoration\n *\n * @example\n * ```typescript\n * import { restoreReservation } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await restoreReservation(client, 'reservation-123');\n * // Or with custom retention days:\n * await restoreReservation(client, 'reservation-123', 60);\n * ```\n */\nexport async function restoreReservation<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tretentionDays: number = DEFAULT_SOFT_DELETE_RETENTION_DAYS,\n): Promise<{ success: boolean; error?: string }> {\n\ttry {\n\t\t// First, get the reservation to check its deletedAt timestamp\n\t\tconst { data: reservation, errors: getErrors } = await (\n\t\t\tclient as any\n\t\t).models.Reservation.get({ id });\n\n\t\tif (getErrors || !reservation) {\n\t\t\tconsole.error(\"[restoreReservation] Error fetching reservation:\", getErrors);\n\t\t\treturn { success: false, error: \"Reservation not found\" };\n\t\t}\n\n\t\t// Check if restoration is allowed based on retention period\n\t\tconst eligibility = checkRestoreEligibility(reservation.deletedAt, retentionDays);\n\n\t\tif (!eligibility.canRestore) {\n\t\t\tconst errorMsg = `Cannot restore reservation. Retention period of ${retentionDays} days has expired. Item was deleted ${eligibility.daysExpired} days ago.`;\n\t\t\tconsole.error(\"[restoreReservation]\", errorMsg);\n\t\t\treturn { success: false, error: errorMsg };\n\t\t}\n\n\t\tconst { errors } = await (client as any).models.Reservation.update({\n\t\t\tid,\n\t\t\tdeletedAt: null,\n\t\t\tdeletedBy: null,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[restoreReservation] GraphQL errors:\", errors);\n\t\t\treturn { success: false, error: \"Failed to restore reservation\" };\n\t\t}\n\n\t\treturn { success: true };\n\t} catch (error) {\n\t\tconsole.error(\"[restoreReservation] Error restoring reservation:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Hard delete a reservation (permanently removes from database)\n * Use with caution - prefer softDeleteReservation for recoverable deletion\n *\n * @example\n * ```typescript\n * import { deleteReservation } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteReservation(client, 'reservation-123');\n * ```\n */\nexport async function deleteReservation<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Reservation.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteReservation] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteReservation] Error deleting reservation:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update reservation status with validation\n *\n * Validates that the status transition is allowed based on current status.\n * Status transition rules:\n * - confirmed → checked_in, cancelled, no_show\n * - checked_in → checked_out, cancelled\n * - checked_out → (terminal state, no transitions)\n * - cancelled → (terminal state, no transitions)\n * - no_show → (terminal state, no transitions)\n *\n * @throws {ReservationValidationError} if status transition is invalid\n *\n * @example\n * ```typescript\n * import { updateReservationStatus } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const reservation = await updateReservationStatus(\n * client,\n * 'reservation-123',\n * 'checked_in'\n * );\n * ```\n */\nexport async function updateReservationStatus<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tnewStatus: ReservationStatus,\n): Promise<any | null> {\n\ttry {\n\t\t// Get current reservation to check current status\n\t\tconst { data: currentReservation, errors: getErrors } = await (\n\t\t\tclient as any\n\t\t).models.Reservation.get({ id });\n\n\t\tif (getErrors || !currentReservation) {\n\t\t\tconsole.error(\"[updateReservationStatus] Error fetching reservation:\", getErrors);\n\t\t\treturn null;\n\t\t}\n\n\t\tconst currentStatus = currentReservation.status as ReservationStatus;\n\n\t\t// Validate status transition\n\t\tvalidateStatusTransition(currentStatus, newStatus);\n\n\t\t// Perform the update\n\t\tconst { data, errors } = await (client as any).models.Reservation.update({\n\t\t\tid,\n\t\t\tstatus: newStatus,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateReservationStatus] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data;\n\t} catch (error) {\n\t\tif (error instanceof ReservationValidationError) {\n\t\t\tconsole.error(\"[updateReservationStatus] Validation error:\", error.message);\n\t\t\tthrow error;\n\t\t}\n\t\tconsole.error(\"[updateReservationStatus] Error updating status:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * Contact Mutation Functions\n *\n * Provides type-safe mutation functions for creating, updating, and deleting contacts.\n * Includes Zod validation for input data before mutations.\n */\n\nimport { z } from \"zod\";\nimport type { Contact } from \"@htlkg/core/types\";\nimport {\n\tcheckRestoreEligibility,\n\tDEFAULT_SOFT_DELETE_RETENTION_DAYS,\n} from \"../queries/systemSettings\";\nimport { getContact } from \"../queries/contacts\";\nimport type { CreateAuditFields, UpdateWithSoftDeleteFields } from \"./common\";\n\n// ============================================\n// Added Zod Validation Schemas\n// ============================================\n\n/**\n * Zod schema for creating a contact \n */\nexport const createContactSchema = z.object({\n\tbrandId: z.string().min(1, \"Brand ID is required\"),\n\temail: z.string().email(\"Invalid email address\"),\n\tphone: z.string().optional(),\n\tfirstName: z.string().min(1, \"First name is required\"),\n\tlastName: z.string().min(1, \"Last name is required\"),\n\tlocale: z.string().optional(),\n\tgdprConsent: z.boolean(),\n\tgdprConsentDate: z.string().optional(),\n\tmarketingOptIn: z.boolean().optional(),\n\tpreferences: z.record(z.any()).optional(),\n\ttags: z.array(z.string()).optional(),\n\ttotalVisits: z.number().int().min(0).optional(),\n\tlastVisitDate: z.string().optional(),\n\tfirstVisitDate: z.string().optional(),\n\tlegacyId: z.string().optional(),\n\t// Audit fields\n\tcreatedAt: z.string().optional(),\n\tcreatedBy: z.string().optional(),\n\tupdatedAt: z.string().optional(),\n\tupdatedBy: z.string().optional(),\n});\n\n/**\n * Zod schema for updating a contact\n */\nexport const updateContactSchema = z.object({\n\tid: z.string().min(1, \"Contact ID is required\"),\n\tbrandId: z.string().min(1).optional(),\n\temail: z.string().email(\"Invalid email address\").optional(),\n\tphone: z.string().optional(),\n\tfirstName: z.string().min(1).optional(),\n\tlastName: z.string().min(1).optional(),\n\tlocale: z.string().optional(),\n\tgdprConsent: z.boolean().optional(),\n\tgdprConsentDate: z.string().optional(),\n\tmarketingOptIn: z.boolean().optional(),\n\tpreferences: z.record(z.any()).optional(),\n\ttags: z.array(z.string()).optional(),\n\ttotalVisits: z.number().int().min(0).optional(),\n\tlastVisitDate: z.string().optional(),\n\tfirstVisitDate: z.string().optional(),\n\tlegacyId: z.string().optional(),\n\t// Audit fields\n\tupdatedAt: z.string().optional(),\n\tupdatedBy: z.string().optional(),\n\tdeletedAt: z.string().nullable().optional(),\n\tdeletedBy: z.string().nullable().optional(),\n});\n\n/**\n * Zod schema for merging contacts\n */\nexport const mergeContactsSchema = z.object({\n\tprimaryId: z.string().min(1, \"Primary contact ID is required\"),\n\tduplicateIds: z.array(z.string().min(1)).min(1, \"At least one duplicate ID is required\"),\n});\n\n// ============================================\n// Validation Error Class\n// ============================================\n\n/**\n * Validation error class for contact operations\n */\nexport class ContactValidationError extends Error {\n\tpublic readonly issues: z.ZodIssue[];\n\n\tconstructor(message: string, issues: z.ZodIssue[] = []) {\n\t\tsuper(message);\n\t\tthis.name = \"ContactValidationError\";\n\t\tthis.issues = issues;\n\t}\n}\n\n// ============================================\n// Input Types\n// ============================================\n\n/**\n * Input type for creating a contact\n */\nexport interface CreateContactInput extends CreateAuditFields {\n\tbrandId: string;\n\temail: string;\n\tphone?: string;\n\tfirstName: string;\n\tlastName: string;\n\tlocale?: string;\n\tgdprConsent: boolean;\n\tgdprConsentDate?: string;\n\tmarketingOptIn?: boolean;\n\tpreferences?: Record<string, any>;\n\ttags?: string[];\n\ttotalVisits?: number;\n\tlastVisitDate?: string;\n\tfirstVisitDate?: string;\n\tlegacyId?: string;\n}\n\n/**\n * Input type for updating a contact\n */\nexport interface UpdateContactInput extends UpdateWithSoftDeleteFields {\n\tid: string;\n\tbrandId?: string;\n\temail?: string;\n\tphone?: string;\n\tfirstName?: string;\n\tlastName?: string;\n\tlocale?: string;\n\tgdprConsent?: boolean;\n\tgdprConsentDate?: string;\n\tmarketingOptIn?: boolean;\n\tpreferences?: Record<string, any>;\n\ttags?: string[];\n\ttotalVisits?: number;\n\tlastVisitDate?: string;\n\tfirstVisitDate?: string;\n\tlegacyId?: string;\n}\n\n/**\n * Input type for merging contacts\n */\nexport interface MergeContactsInput {\n\tprimaryId: string;\n\tduplicateIds: string[];\n}\n\n/**\n * Result type for merge operation\n */\nexport interface MergeContactsResult {\n\tsuccess: boolean;\n\tmergedContact?: Contact;\n\tdeletedIds?: string[];\n\terror?: string;\n}\n\n// ============================================\n// Mutation Functions\n// ============================================\n\n/**\n * Create a new contact with Zod validation\n *\n * @throws {ContactValidationError} if input validation fails\n *\n * @example\n * ```typescript\n * import { createContact } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const contact = await createContact(client, {\n * brandId: 'brand-123',\n * email: 'guest@example.com',\n * firstName: 'John',\n * lastName: 'Doe',\n * gdprConsent: true,\n * gdprConsentDate: new Date().toISOString()\n * });\n * ```\n */\nexport async function createContact<TClient = any>(\n\tclient: TClient,\n\tinput: CreateContactInput,\n): Promise<Contact | null> {\n\ttry {\n\t\t// Validate input with Zod\n\t\tconst validationResult = createContactSchema.safeParse(input);\n\n\t\tif (!validationResult.success) {\n\t\t\tconst errorMessage = validationResult.error.issues\n\t\t\t\t.map((issue) => `${issue.path.join(\".\")}: ${issue.message}`)\n\t\t\t\t.join(\", \");\n\t\t\tthrow new ContactValidationError(\n\t\t\t\t`Validation failed: ${errorMessage}`,\n\t\t\t\tvalidationResult.error.issues\n\t\t\t);\n\t\t}\n\n\t\tconst { data, errors } = await (client as any).models.Contact.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createContact] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Contact;\n\t} catch (error) {\n\t\tif (error instanceof ContactValidationError) {\n\t\t\tconsole.error(\"[createContact] Validation error:\", error.message);\n\t\t\tthrow error;\n\t\t}\n\t\tconsole.error(\"[createContact] Error creating contact:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing contact with Zod validation\n *\n * @throws {ContactValidationError} if input validation fails\n *\n * @example\n * ```typescript\n * import { updateContact } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const contact = await updateContact(client, {\n * id: 'contact-123',\n * firstName: 'Jane',\n * marketingOptIn: true\n * });\n * ```\n */\nexport async function updateContact<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateContactInput,\n): Promise<Contact | null> {\n\ttry {\n\t\t// Validate input with Zod\n\t\tconst validationResult = updateContactSchema.safeParse(input);\n\n\t\tif (!validationResult.success) {\n\t\t\tconst errorMessage = validationResult.error.issues\n\t\t\t\t.map((issue) => `${issue.path.join(\".\")}: ${issue.message}`)\n\t\t\t\t.join(\", \");\n\t\t\tthrow new ContactValidationError(\n\t\t\t\t`Validation failed: ${errorMessage}`,\n\t\t\t\tvalidationResult.error.issues\n\t\t\t);\n\t\t}\n\n\t\tconst { data, errors } = await (client as any).models.Contact.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateContact] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Contact;\n\t} catch (error) {\n\t\tif (error instanceof ContactValidationError) {\n\t\t\tconsole.error(\"[updateContact] Validation error:\", error.message);\n\t\t\tthrow error;\n\t\t}\n\t\tconsole.error(\"[updateContact] Error updating contact:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Soft delete a contact (sets deletedAt/deletedBy instead of removing)\n *\n * @example\n * ```typescript\n * import { softDeleteContact } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await softDeleteContact(client, 'contact-123', 'admin@example.com');\n * ```\n */\nexport async function softDeleteContact<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tdeletedBy: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Contact.update({\n\t\t\tid,\n\t\t\tdeletedAt: new Date().toISOString(),\n\t\t\tdeletedBy,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[softDeleteContact] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[softDeleteContact] Error soft-deleting contact:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Restore a soft-deleted contact\n * Checks retention period before allowing restoration\n *\n * @example\n * ```typescript\n * import { restoreContact } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await restoreContact(client, 'contact-123');\n * // Or with custom retention days:\n * await restoreContact(client, 'contact-123', 60);\n * ```\n */\nexport async function restoreContact<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tretentionDays: number = DEFAULT_SOFT_DELETE_RETENTION_DAYS,\n): Promise<{ success: boolean; error?: string }> {\n\ttry {\n\t\t// First, get the contact to check its deletedAt timestamp\n\t\tconst contact = await getContact(client, id);\n\n\t\tif (!contact) {\n\t\t\tconsole.error(\"[restoreContact] Contact not found\");\n\t\t\treturn { success: false, error: \"Contact not found\" };\n\t\t}\n\n\t\t// Check if restoration is allowed based on retention period\n\t\tconst eligibility = checkRestoreEligibility(\n\t\t\t(contact as any).deletedAt,\n\t\t\tretentionDays\n\t\t);\n\n\t\tif (!eligibility.canRestore) {\n\t\t\tconst errorMsg = `Cannot restore contact. Retention period of ${retentionDays} days has expired. Item was deleted ${eligibility.daysExpired} days ago.`;\n\t\t\tconsole.error(\"[restoreContact]\", errorMsg);\n\t\t\treturn { success: false, error: errorMsg };\n\t\t}\n\n\t\tconst { errors } = await (client as any).models.Contact.update({\n\t\t\tid,\n\t\t\tdeletedAt: null,\n\t\t\tdeletedBy: null,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[restoreContact] GraphQL errors:\", errors);\n\t\t\treturn { success: false, error: \"Failed to restore contact\" };\n\t\t}\n\n\t\treturn { success: true };\n\t} catch (error) {\n\t\tconsole.error(\"[restoreContact] Error restoring contact:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Hard delete a contact (permanently removes from database)\n * Use with caution - prefer softDeleteContact for recoverable deletion\n *\n * @example\n * ```typescript\n * import { deleteContact } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteContact(client, 'contact-123');\n * ```\n */\nexport async function deleteContact<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Contact.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteContact] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteContact] Error deleting contact:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Merge duplicate contacts into a primary contact\n *\n * This function:\n * 1. Validates all contact IDs exist\n * 2. Aggregates data from duplicates into the primary contact\n * 3. Soft deletes the duplicate contacts\n * 4. Returns the updated primary contact\n *\n * Merge strategy:\n * - totalVisits: Sum of all contacts\n * - firstVisitDate: Earliest date across all contacts\n * - lastVisitDate: Latest date across all contacts\n * - tags: Merged unique tags from all contacts\n * - preferences: Primary contact preferences take precedence\n * - Other fields: Primary contact values are preserved\n *\n * @throws {ContactValidationError} if input validation fails\n *\n * @example\n * ```typescript\n * import { mergeContacts } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const result = await mergeContacts(client, {\n * primaryId: 'contact-primary',\n * duplicateIds: ['contact-dup-1', 'contact-dup-2']\n * }, 'admin@example.com');\n * ```\n */\nexport async function mergeContacts<TClient = any>(\n\tclient: TClient,\n\tinput: MergeContactsInput,\n\tmergedBy: string,\n): Promise<MergeContactsResult> {\n\ttry {\n\t\t// Validate input with Zod\n\t\tconst validationResult = mergeContactsSchema.safeParse(input);\n\n\t\tif (!validationResult.success) {\n\t\t\tconst errorMessage = validationResult.error.issues\n\t\t\t\t.map((issue) => `${issue.path.join(\".\")}: ${issue.message}`)\n\t\t\t\t.join(\", \");\n\t\t\tthrow new ContactValidationError(\n\t\t\t\t`Validation failed: ${errorMessage}`,\n\t\t\t\tvalidationResult.error.issues\n\t\t\t);\n\t\t}\n\n\t\tconst { primaryId, duplicateIds } = input;\n\n\t\t// Fetch primary contact\n\t\tconst primaryContact = await getContact(client, primaryId);\n\t\tif (!primaryContact) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: `Primary contact not found: ${primaryId}`,\n\t\t\t};\n\t\t}\n\n\t\t// Fetch all duplicate contacts\n\t\tconst duplicateContacts: Contact[] = [];\n\t\tfor (const duplicateId of duplicateIds) {\n\t\t\tconst duplicate = await getContact(client, duplicateId);\n\t\t\tif (!duplicate) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: `Duplicate contact not found: ${duplicateId}`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tduplicateContacts.push(duplicate);\n\t\t}\n\n\t\t// Aggregate data from duplicates\n\t\tlet totalVisits = primaryContact.totalVisits || 0;\n\t\tlet firstVisitDate = primaryContact.firstVisitDate;\n\t\tlet lastVisitDate = primaryContact.lastVisitDate;\n\t\tconst allTags = new Set<string>(primaryContact.tags || []);\n\n\t\tfor (const duplicate of duplicateContacts) {\n\t\t\t// Sum total visits\n\t\t\ttotalVisits += duplicate.totalVisits || 0;\n\n\t\t\t// Find earliest first visit date\n\t\t\tif (duplicate.firstVisitDate) {\n\t\t\t\tif (!firstVisitDate || duplicate.firstVisitDate < firstVisitDate) {\n\t\t\t\t\tfirstVisitDate = duplicate.firstVisitDate;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Find latest last visit date\n\t\t\tif (duplicate.lastVisitDate) {\n\t\t\t\tif (!lastVisitDate || duplicate.lastVisitDate > lastVisitDate) {\n\t\t\t\t\tlastVisitDate = duplicate.lastVisitDate;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Merge tags\n\t\t\tif (duplicate.tags) {\n\t\t\t\tduplicate.tags.forEach((tag) => allTags.add(tag));\n\t\t\t}\n\t\t}\n\n\t\t// Update primary contact with aggregated data\n\t\tconst updateInput: UpdateContactInput = {\n\t\t\tid: primaryId,\n\t\t\ttotalVisits,\n\t\t\tfirstVisitDate,\n\t\t\tlastVisitDate,\n\t\t\ttags: Array.from(allTags),\n\t\t\tupdatedAt: new Date().toISOString(),\n\t\t\tupdatedBy: mergedBy,\n\t\t};\n\n\t\tconst updatedPrimary = await updateContact(client, updateInput);\n\n\t\tif (!updatedPrimary) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: \"Failed to update primary contact with merged data\",\n\t\t\t};\n\t\t}\n\n\t\t// Soft delete all duplicate contacts\n\t\tconst deletedIds: string[] = [];\n\t\tfor (const duplicateId of duplicateIds) {\n\t\t\tconst deleted = await softDeleteContact(client, duplicateId, mergedBy);\n\t\t\tif (deleted) {\n\t\t\t\tdeletedIds.push(duplicateId);\n\t\t\t} else {\n\t\t\t\tconsole.error(`[mergeContacts] Failed to soft-delete duplicate: ${duplicateId}`);\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tmergedContact: updatedPrimary,\n\t\t\tdeletedIds,\n\t\t};\n\t} catch (error) {\n\t\tif (error instanceof ContactValidationError) {\n\t\t\tconsole.error(\"[mergeContacts] Validation error:\", error.message);\n\t\t\tthrow error;\n\t\t}\n\t\tconsole.error(\"[mergeContacts] Error merging contacts:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * Data Hook Factory\n *\n * Creates reusable Vue composables for fetching data from GraphQL models.\n * Provides a DRY approach to data fetching with consistent patterns.\n */\n\nimport { ref, computed, onMounted, type Ref, type ComputedRef } from \"vue\";\nimport { query, hasErrors, getErrorMessage } from \"../client/proxy\";\n\n/**\n * Configuration options for creating a data hook\n */\nexport interface CreateDataHookOptions<T, TOptions extends BaseHookOptions = BaseHookOptions> {\n\t/** The GraphQL model name (e.g., 'Account', 'User', 'Brand') */\n\tmodel: string;\n\t/** Default limit for queries */\n\tdefaultLimit?: number;\n\t/** Selection set for the query (fields to fetch) */\n\tselectionSet?: string[];\n\t/** Transform function to apply to fetched data */\n\ttransform?: (item: any) => T;\n\t/** Build filter from hook options */\n\tbuildFilter?: (options: TOptions) => any;\n\t/** Define computed properties based on the data */\n\tcomputedProperties?: Record<string, (data: T[]) => any>;\n\t/** Plural name for the data property (e.g., 'accounts', 'users') */\n\tdataPropertyName?: string;\n}\n\n/**\n * Base options available to all hooks\n */\nexport interface BaseHookOptions {\n\t/** Filter criteria */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n}\n\n/**\n * Return type for data hooks\n */\nexport interface DataHookReturn<T, TComputed extends Record<string, any> = Record<string, never>> {\n\t/** Reactive array of data */\n\tdata: Ref<T[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch data */\n\trefetch: () => Promise<void>;\n\t/** Computed properties */\n\tcomputed: { [K in keyof TComputed]: ComputedRef<TComputed[K]> };\n}\n\n// Reset function for testing convenience (no-op with proxy-based approach)\nexport function resetClientInstance(): void {\n\t// No-op: proxy-based approach doesn't need client reset\n}\n\n/**\n * Creates a reusable data hook for a specific model\n *\n * @example\n * ```typescript\n * // Create a simple hook\n * export const useAccounts = createDataHook<Account>({\n * model: 'Account',\n * dataPropertyName: 'accounts',\n * });\n *\n * // Usage\n * const { data: accounts, loading, error, refetch } = useAccounts();\n * ```\n *\n * @example\n * ```typescript\n * // Create a hook with custom filters and computed properties\n * interface UseBrandsOptions extends BaseHookOptions {\n * accountId?: string;\n * activeOnly?: boolean;\n * }\n *\n * export const useBrands = createDataHook<Brand, UseBrandsOptions>({\n * model: 'Brand',\n * dataPropertyName: 'brands',\n * buildFilter: (options) => {\n * const filter: any = options.filter || {};\n * if (options.accountId) filter.accountId = { eq: options.accountId };\n * if (options.activeOnly) filter.status = { eq: 'active' };\n * return Object.keys(filter).length > 0 ? filter : undefined;\n * },\n * computedProperties: {\n * activeBrands: (brands) => brands.filter(b => b.status === 'active'),\n * },\n * });\n * ```\n */\nexport function createDataHook<\n\tT,\n\tTOptions extends BaseHookOptions = BaseHookOptions,\n\tTComputed extends Record<string, any> = Record<string, never>,\n>(\n\tconfig: CreateDataHookOptions<T, TOptions> & {\n\t\tcomputedProperties?: { [K in keyof TComputed]: (data: T[]) => TComputed[K] };\n\t},\n) {\n\tconst {\n\t\tmodel,\n\t\tdefaultLimit,\n\t\tselectionSet,\n\t\ttransform,\n\t\tbuildFilter,\n\t\tcomputedProperties,\n\t\tdataPropertyName = \"data\",\n\t} = config;\n\n\treturn function useData(options: TOptions = {} as TOptions): DataHookReturn<T, TComputed> & Record<string, any> {\n\t\tconst { filter: baseFilter, limit = defaultLimit, autoFetch = true } = options;\n\n\t\t// State\n\t\tconst data = ref<T[]>([]) as Ref<T[]>;\n\t\tconst loading = ref(false);\n\t\tconst error = ref<Error | null>(null);\n\n\t\t// Build filter using custom builder or default\n\t\tconst getFilter = () => {\n\t\t\tif (buildFilter) {\n\t\t\t\treturn buildFilter(options);\n\t\t\t}\n\t\t\treturn baseFilter && Object.keys(baseFilter).length > 0 ? baseFilter : undefined;\n\t\t};\n\n\t\t// Fetch function using server proxy\n\t\tasync function fetch() {\n\t\t\tloading.value = true;\n\t\t\terror.value = null;\n\n\t\t\ttry {\n\t\t\t\tconst queryOptions: Record<string, any> = {};\n\n\t\t\t\tconst filter = getFilter();\n\t\t\t\tif (filter) {\n\t\t\t\t\tqueryOptions.filter = filter;\n\t\t\t\t}\n\n\t\t\t\tif (limit) {\n\t\t\t\t\tqueryOptions.limit = limit;\n\t\t\t\t}\n\n\t\t\t\tif (selectionSet) {\n\t\t\t\t\tqueryOptions.selectionSet = selectionSet;\n\t\t\t\t}\n\n\t\t\t\tconst response = await query(model, \"list\", queryOptions);\n\n\t\t\t\tif (hasErrors(response)) {\n\t\t\t\t\tthrow new Error(getErrorMessage(response) || `Failed to fetch ${model}`);\n\t\t\t\t}\n\n\t\t\t\tconst items = response.data || [];\n\t\t\t\tdata.value = transform ? items.map(transform) : items;\n\t\t\t} catch (e) {\n\t\t\t\terror.value = e as Error;\n\t\t\t\tconsole.error(`[use${model}] Error fetching ${model}:`, e);\n\t\t\t} finally {\n\t\t\t\tloading.value = false;\n\t\t\t}\n\t\t}\n\n\t\t// Create computed properties\n\t\tconst computedRefs: Record<string, ComputedRef<any>> = {};\n\t\tif (computedProperties) {\n\t\t\tfor (const [key, fn] of Object.entries(computedProperties)) {\n\t\t\t\tcomputedRefs[key] = computed(() => fn(data.value));\n\t\t\t}\n\t\t}\n\n\t\t// Auto-fetch on mount if enabled\n\t\tif (autoFetch) {\n\t\t\tonMounted(() => {\n\t\t\t\tfetch();\n\t\t\t});\n\t\t}\n\n\t\t// Build return object\n\t\tconst result: DataHookReturn<T, TComputed> & Record<string, any> = {\n\t\t\tdata,\n\t\t\tloading,\n\t\t\terror,\n\t\t\trefetch: fetch,\n\t\t\tcomputed: computedRefs as { [K in keyof TComputed]: ComputedRef<TComputed[K]> },\n\t\t};\n\n\t\t// Add data property with custom name for backwards compatibility\n\t\tif (dataPropertyName !== \"data\") {\n\t\t\tresult[dataPropertyName] = data;\n\t\t}\n\n\t\t// Add computed properties at top level for backwards compatibility\n\t\tfor (const [key, computedRef] of Object.entries(computedRefs)) {\n\t\t\tresult[key] = computedRef;\n\t\t}\n\n\t\treturn result;\n\t};\n}\n\n/**\n * Type helper to extract the return type of a created hook\n */\nexport type InferHookReturn<THook extends (...args: any[]) => any> = ReturnType<THook>;\n","/**\n * Paginated Data Hook Factory\n *\n * Creates reusable Vue composables for fetching paginated data from GraphQL models.\n * Supports cursor-based pagination (nextToken) for efficient handling of large datasets.\n *\n * Key features:\n * - Server-side pagination with nextToken\n * - loadMore() for infinite scroll/pagination\n * - hasMore indicator\n * - Independent pagination state per hook instance\n * - Built-in support for active/deleted filtering\n */\n\nimport { ref, computed, onMounted, type Ref, type ComputedRef } from \"vue\";\nimport { query, hasErrors, getErrorMessage } from \"../client/proxy\";\n\n/**\n * Filter for active items (not deleted)\n * Uses OR condition because deletedAt can be:\n * - Missing (attributeExists: false)\n * - Explicitly null (eq: null)\n */\nexport const ACTIVE_FILTER = {\n\tor: [{ deletedAt: { attributeExists: false } }, { deletedAt: { eq: null } }],\n};\n\n/**\n * Filter for deleted items\n * Uses gt: \"\" to match only actual timestamp strings (not null or missing)\n */\nexport const DELETED_FILTER = {\n\tdeletedAt: { gt: \"\" },\n};\n\n/**\n * Configuration options for creating a paginated data hook\n */\nexport interface CreatePaginatedDataHookOptions<T, TOptions extends PaginatedHookOptions = PaginatedHookOptions> {\n\t/** The GraphQL model name (e.g., 'Account', 'User', 'Brand') */\n\tmodel: string;\n\t/** Default page size */\n\tdefaultPageSize?: number;\n\t/** Selection set for the query (fields to fetch) */\n\tselectionSet?: string[];\n\t/** Transform function to apply to fetched data */\n\ttransform?: (item: any) => T;\n\t/** Build filter from hook options */\n\tbuildFilter?: (options: TOptions) => any;\n\t/** Plural name for the data property (e.g., 'accounts', 'users') */\n\tdataPropertyName?: string;\n\t/** Base filter to always apply (e.g., for active/deleted variants) */\n\tbaseFilter?: any;\n}\n\n/**\n * Base options available to paginated hooks\n */\nexport interface PaginatedHookOptions {\n\t/** Additional filter criteria (merged with baseFilter) */\n\tfilter?: any;\n\t/** Page size (default: 25) */\n\tpageSize?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n}\n\n/**\n * Pagination state\n */\nexport interface PaginationState {\n\t/** Current nextToken for fetching next page */\n\tnextToken: string | null;\n\t/** Whether there are more items to load */\n\thasMore: boolean;\n\t/** Total items loaded so far */\n\tloadedCount: number;\n}\n\n/**\n * Return type for paginated data hooks\n */\nexport interface PaginatedDataHookReturn<T> {\n\t/** Reactive array of data (accumulated across pages) */\n\tdata: Ref<T[]>;\n\t/** Loading state (true during any fetch) */\n\tloading: Ref<boolean>;\n\t/** Loading state for initial fetch */\n\tinitialLoading: Ref<boolean>;\n\t/** Loading state for loadMore */\n\tloadingMore: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Pagination state */\n\tpagination: Ref<PaginationState>;\n\t/** Whether there are more items to load */\n\thasMore: ComputedRef<boolean>;\n\t/** Load next page of data */\n\tloadMore: () => Promise<void>;\n\t/** Refetch data (resets to first page) */\n\trefetch: () => Promise<void>;\n\t/** Reset data and pagination state */\n\treset: () => void;\n\t/** Update search filter and refetch from server (searches ALL data) */\n\tsetSearchFilter: (filter: any) => Promise<void>;\n\t/** Current search filter */\n\tsearchFilter: Ref<any>;\n}\n\n/**\n * Creates a reusable paginated data hook for a specific model\n *\n * @example\n * ```typescript\n * // Create a hook for active brands\n * export const useActiveBrands = createPaginatedDataHook<Brand>({\n * model: 'Brand',\n * dataPropertyName: 'brands',\n * baseFilter: ACTIVE_FILTER,\n * selectionSet: ['id', 'name', 'status', 'accountId', 'account.name'],\n * });\n *\n * // Usage in component\n * const { brands, loading, hasMore, loadMore, refetch } = useActiveBrands({\n * pageSize: 25,\n * });\n * ```\n *\n * @example With custom filter builder\n * ```typescript\n * interface UseBrandsOptions extends PaginatedHookOptions {\n * accountId?: string;\n * }\n *\n * export const useActiveBrands = createPaginatedDataHook<Brand, UseBrandsOptions>({\n * model: 'Brand',\n * dataPropertyName: 'brands',\n * baseFilter: ACTIVE_FILTER,\n * buildFilter: (options) => {\n * if (options.accountId) {\n * return { accountId: { eq: options.accountId } };\n * }\n * return undefined;\n * },\n * });\n * ```\n */\nexport function createPaginatedDataHook<T, TOptions extends PaginatedHookOptions = PaginatedHookOptions>(\n\tconfig: CreatePaginatedDataHookOptions<T, TOptions>,\n) {\n\tconst {\n\t\tmodel,\n\t\tdefaultPageSize = 25,\n\t\tselectionSet,\n\t\ttransform,\n\t\tbuildFilter,\n\t\tdataPropertyName = \"data\",\n\t\tbaseFilter,\n\t} = config;\n\n\treturn function usePaginatedData(\n\t\toptions: TOptions = {} as TOptions,\n\t): PaginatedDataHookReturn<T> & Record<string, any> {\n\t\tconst { filter: additionalFilter, pageSize = defaultPageSize, autoFetch = true } = options;\n\n\t\t// State\n\t\tconst data = ref<T[]>([]) as Ref<T[]>;\n\t\tconst loading = ref(false);\n\t\tconst initialLoading = ref(false);\n\t\tconst loadingMore = ref(false);\n\t\tconst error = ref<Error | null>(null);\n\t\tconst pagination = ref<PaginationState>({\n\t\t\tnextToken: null,\n\t\t\thasMore: true,\n\t\t\tloadedCount: 0,\n\t\t});\n\n\t\t// Dynamic search filter (for server-side filtering)\n\t\tconst searchFilter = ref<any>(null);\n\n\t\t// Computed\n\t\tconst hasMore = computed(() => pagination.value.hasMore);\n\n\t\t// Build combined filter\n\t\tconst getFilter = () => {\n\t\t\tconst filters: any[] = [];\n\n\t\t\t// Add base filter (e.g., active/deleted)\n\t\t\tif (baseFilter) {\n\t\t\t\tfilters.push(baseFilter);\n\t\t\t}\n\n\t\t\t// Add custom filter from buildFilter\n\t\t\tif (buildFilter) {\n\t\t\t\tconst customFilter = buildFilter(options);\n\t\t\t\tif (customFilter) {\n\t\t\t\t\tfilters.push(customFilter);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Add additional filter from options\n\t\t\tif (additionalFilter && Object.keys(additionalFilter).length > 0) {\n\t\t\t\tfilters.push(additionalFilter);\n\t\t\t}\n\n\t\t\t// Add dynamic search filter (for server-side search)\n\t\t\tif (searchFilter.value && Object.keys(searchFilter.value).length > 0) {\n\t\t\t\tfilters.push(searchFilter.value);\n\t\t\t}\n\n\t\t\t// Combine filters with AND\n\t\t\tif (filters.length === 0) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (filters.length === 1) {\n\t\t\t\treturn filters[0];\n\t\t\t}\n\t\t\treturn { and: filters };\n\t\t};\n\n\t\t// Fetch function\n\t\tasync function fetchPage(nextToken?: string | null, append: boolean = false) {\n\t\t\tif (!append) {\n\t\t\t\tinitialLoading.value = true;\n\t\t\t} else {\n\t\t\t\tloadingMore.value = true;\n\t\t\t}\n\t\t\tloading.value = true;\n\t\t\terror.value = null;\n\n\t\t\ttry {\n\t\t\t\tconst queryOptions: Record<string, any> = {\n\t\t\t\t\tlimit: pageSize,\n\t\t\t\t};\n\n\t\t\t\tconst filter = getFilter();\n\t\t\t\tif (filter) {\n\t\t\t\t\tqueryOptions.filter = filter;\n\t\t\t\t}\n\n\t\t\t\tif (nextToken) {\n\t\t\t\t\tqueryOptions.nextToken = nextToken;\n\t\t\t\t}\n\n\t\t\t\tif (selectionSet) {\n\t\t\t\t\tqueryOptions.selectionSet = selectionSet;\n\t\t\t\t}\n\n\t\t\t\tconst response = await query(model, \"list\", queryOptions);\n\n\t\t\t\tif (hasErrors(response)) {\n\t\t\t\t\tthrow new Error(getErrorMessage(response) || `Failed to fetch ${model}`);\n\t\t\t\t}\n\n\t\t\t\tconst items = response.data || [];\n\t\t\t\tconst transformedItems = transform ? items.map(transform) : items;\n\n\t\t\t\tif (append) {\n\t\t\t\t\tdata.value = [...data.value, ...transformedItems];\n\t\t\t\t} else {\n\t\t\t\t\tdata.value = transformedItems;\n\t\t\t\t}\n\n\t\t\t\t// Update pagination state\n\t\t\t\t// Note: Amplify returns nextToken in the response\n\t\t\t\tconst responseNextToken = (response as any).nextToken;\n\t\t\t\tpagination.value = {\n\t\t\t\t\tnextToken: responseNextToken || null,\n\t\t\t\t\thasMore: !!responseNextToken,\n\t\t\t\t\tloadedCount: data.value.length,\n\t\t\t\t};\n\t\t\t} catch (e) {\n\t\t\t\terror.value = e as Error;\n\t\t\t\tconsole.error(`[use${model}] Error fetching ${model}:`, e);\n\t\t\t} finally {\n\t\t\t\tloading.value = false;\n\t\t\t\tinitialLoading.value = false;\n\t\t\t\tloadingMore.value = false;\n\t\t\t}\n\t\t}\n\n\t\t// Load more function\n\t\tasync function loadMore() {\n\t\t\tif (loadingMore.value || !pagination.value.hasMore) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait fetchPage(pagination.value.nextToken, true);\n\t\t}\n\n\t\t// Refetch (reset to first page)\n\t\tasync function refetch() {\n\t\t\tpagination.value = {\n\t\t\t\tnextToken: null,\n\t\t\t\thasMore: true,\n\t\t\t\tloadedCount: 0,\n\t\t\t};\n\t\t\tawait fetchPage(null, false);\n\t\t}\n\n\t\t// Reset state\n\t\tfunction reset() {\n\t\t\tdata.value = [];\n\t\t\terror.value = null;\n\t\t\tsearchFilter.value = null;\n\t\t\tpagination.value = {\n\t\t\t\tnextToken: null,\n\t\t\t\thasMore: true,\n\t\t\t\tloadedCount: 0,\n\t\t\t};\n\t\t}\n\n\t\t// Set search filter and refetch from server (searches ALL data)\n\t\tasync function setSearchFilter(filter: any) {\n\t\t\tsearchFilter.value = filter;\n\t\t\t// Reset pagination and fetch with new filter\n\t\t\tpagination.value = {\n\t\t\t\tnextToken: null,\n\t\t\t\thasMore: true,\n\t\t\t\tloadedCount: 0,\n\t\t\t};\n\t\t\tawait fetchPage(null, false);\n\t\t}\n\n\t\t// Auto-fetch on mount if enabled\n\t\tif (autoFetch) {\n\t\t\tonMounted(() => {\n\t\t\t\tfetchPage(null, false);\n\t\t\t});\n\t\t}\n\n\t\t// Build return object\n\t\tconst result: PaginatedDataHookReturn<T> & Record<string, any> = {\n\t\t\tdata,\n\t\t\tloading,\n\t\t\tinitialLoading,\n\t\t\tloadingMore,\n\t\t\terror,\n\t\t\tpagination,\n\t\t\thasMore,\n\t\t\tloadMore,\n\t\t\trefetch,\n\t\t\treset,\n\t\t\tsetSearchFilter,\n\t\t\tsearchFilter,\n\t\t};\n\n\t\t// Add data property with custom name for backwards compatibility\n\t\tif (dataPropertyName !== \"data\") {\n\t\t\tresult[dataPropertyName] = data;\n\t\t}\n\n\t\treturn result;\n\t};\n}\n\n/**\n * Type helper to extract the return type of a created paginated hook\n */\nexport type InferPaginatedHookReturn<THook extends (...args: any[]) => any> = ReturnType<THook>;\n","/**\n * useBrands Hook\n *\n * Vue composable for fetching and managing brand data with reactive state.\n * Provides loading states, error handling, and refetch capabilities.\n */\n\nimport type { Ref, ComputedRef } from \"vue\";\nimport type { Brand } from \"@htlkg/core/types\";\nimport { createDataHook, type BaseHookOptions } from \"../createDataHook\";\n\nexport interface UseBrandsOptions extends BaseHookOptions {\n\t/** Filter criteria for brands */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n\t/** Filter by account ID */\n\taccountId?: string;\n\t/** Only active brands */\n\tactiveOnly?: boolean;\n}\n\nexport interface UseBrandsReturn {\n\t/** Reactive array of brands */\n\tbrands: Ref<Brand[]>;\n\t/** Computed array of active brands only */\n\tactiveBrands: ComputedRef<Brand[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch brands */\n\trefetch: () => Promise<void>;\n}\n\n/**\n * Build filter from hook options\n */\nfunction buildFilter(options: UseBrandsOptions): any {\n\tlet filter: any = options.filter || {};\n\n\tif (options.accountId) {\n\t\tfilter = { ...filter, accountId: { eq: options.accountId } };\n\t}\n\n\tif (options.activeOnly) {\n\t\tfilter = { ...filter, status: { eq: \"active\" } };\n\t}\n\n\treturn Object.keys(filter).length > 0 ? filter : undefined;\n}\n\n/**\n * Internal hook created by factory\n */\nconst useBrandsInternal = createDataHook<Brand, UseBrandsOptions, { activeBrands: Brand[] }>({\n\tmodel: \"Brand\",\n\tdataPropertyName: \"brands\",\n\tbuildFilter,\n\tcomputedProperties: {\n\t\tactiveBrands: (brands) => brands.filter((b) => b.status === \"active\"),\n\t},\n});\n\n/**\n * Composable for fetching and managing brands\n *\n * @example\n * ```typescript\n * import { useBrands } from '@htlkg/data/hooks';\n *\n * const { brands, loading, error, refetch } = useBrands();\n * ```\n *\n * @example With filters\n * ```typescript\n * const { brands, loading } = useBrands({\n * accountId: 'account-123',\n * activeOnly: true,\n * limit: 50\n * });\n * ```\n */\nexport function useBrands(options: UseBrandsOptions = {}): UseBrandsReturn {\n\tconst result = useBrandsInternal(options);\n\treturn {\n\t\tbrands: result.brands as Ref<Brand[]>,\n\t\tactiveBrands: result.activeBrands as ComputedRef<Brand[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t};\n}\n","/**\n * Paginated Brands Hooks\n *\n * Vue composables for fetching brands with server-side pagination.\n * Provides separate hooks for active and deleted brands to enable\n * efficient tab-based filtering in large datasets.\n */\n\nimport type { Ref, ComputedRef } from \"vue\";\nimport type { Brand } from \"@htlkg/core/types\";\nimport {\n\tcreatePaginatedDataHook,\n\tACTIVE_FILTER,\n\tDELETED_FILTER,\n\ttype PaginatedHookOptions,\n\ttype PaginationState,\n} from \"../createPaginatedDataHook\";\n\n/** Extended Brand type with computed fields */\nexport type BrandWithCounts = Brand & {\n\taccountName?: string;\n\tenabledProductCount?: number;\n\ttotalProductCount?: number;\n\tdeletedAt?: string;\n\tdeletedBy?: string;\n};\n\nexport interface UsePaginatedBrandsOptions extends PaginatedHookOptions {\n\t/** Filter by account ID */\n\taccountId?: string;\n}\n\nexport interface UsePaginatedBrandsReturn {\n\t/** Reactive array of brands */\n\tbrands: Ref<BrandWithCounts[]>;\n\t/** Loading state (true during any fetch) */\n\tloading: Ref<boolean>;\n\t/** Loading state for initial fetch */\n\tinitialLoading: Ref<boolean>;\n\t/** Loading state for loadMore */\n\tloadingMore: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Pagination state */\n\tpagination: Ref<PaginationState>;\n\t/** Whether there are more items to load */\n\thasMore: ComputedRef<boolean>;\n\t/** Load next page of data */\n\tloadMore: () => Promise<void>;\n\t/** Refetch data (resets to first page) */\n\trefetch: () => Promise<void>;\n\t/** Reset data and pagination state */\n\treset: () => void;\n\t/** Update search filter and refetch from server (searches ALL data) */\n\tsetSearchFilter: (filter: any) => Promise<void>;\n\t/** Current search filter */\n\tsearchFilter: Ref<any>;\n}\n\n/**\n * Build additional filter from hook options\n */\nfunction buildFilter(options: UsePaginatedBrandsOptions): any {\n\tconst conditions: any[] = [];\n\n\tif (options.accountId) {\n\t\tconditions.push({ accountId: { eq: options.accountId } });\n\t}\n\n\tif (options.filter && Object.keys(options.filter).length > 0) {\n\t\tconditions.push(options.filter);\n\t}\n\n\tif (conditions.length === 0) {\n\t\treturn undefined;\n\t}\n\tif (conditions.length === 1) {\n\t\treturn conditions[0];\n\t}\n\treturn { and: conditions };\n}\n\n/**\n * Transform brand data\n */\nfunction transformBrand(brand: any): BrandWithCounts {\n\treturn {\n\t\t...brand,\n\t\taccountName: brand.account?.name || \"\",\n\t};\n}\n\n/**\n * Selection set for brand queries\n */\nconst BRAND_SELECTION_SET = [\n\t\"id\",\n\t\"name\",\n\t\"accountId\",\n\t\"logo\",\n\t\"timezone\",\n\t\"status\",\n\t\"settings\",\n\t\"deletedAt\",\n\t\"deletedBy\",\n\t\"account.name\",\n];\n\n/**\n * Internal hook for active brands\n */\nconst useActiveBrandsInternal = createPaginatedDataHook<BrandWithCounts, UsePaginatedBrandsOptions>({\n\tmodel: \"Brand\",\n\tdataPropertyName: \"brands\",\n\tdefaultPageSize: 25,\n\tselectionSet: BRAND_SELECTION_SET,\n\ttransform: transformBrand,\n\tbuildFilter,\n\tbaseFilter: ACTIVE_FILTER,\n});\n\n/**\n * Internal hook for deleted brands\n */\nconst useDeletedBrandsInternal = createPaginatedDataHook<BrandWithCounts, UsePaginatedBrandsOptions>({\n\tmodel: \"Brand\",\n\tdataPropertyName: \"brands\",\n\tdefaultPageSize: 25,\n\tselectionSet: BRAND_SELECTION_SET,\n\ttransform: transformBrand,\n\tbuildFilter,\n\tbaseFilter: DELETED_FILTER,\n});\n\n/**\n * Composable for fetching active (non-deleted) brands with pagination\n *\n * @example\n * ```typescript\n * import { useActiveBrands } from '@htlkg/data/hooks';\n *\n * const { brands, loading, hasMore, loadMore, refetch } = useActiveBrands({\n * pageSize: 25,\n * });\n *\n * // Load more when user scrolls or clicks \"Load More\"\n * async function onLoadMore() {\n * await loadMore();\n * }\n * ```\n *\n * @example With account filter\n * ```typescript\n * const { brands, loading } = useActiveBrands({\n * accountId: 'account-123',\n * pageSize: 50\n * });\n * ```\n */\nexport function useActiveBrands(options: UsePaginatedBrandsOptions = {}): UsePaginatedBrandsReturn {\n\tconst result = useActiveBrandsInternal(options);\n\treturn {\n\t\tbrands: result.brands as Ref<BrandWithCounts[]>,\n\t\tloading: result.loading,\n\t\tinitialLoading: result.initialLoading,\n\t\tloadingMore: result.loadingMore,\n\t\terror: result.error,\n\t\tpagination: result.pagination,\n\t\thasMore: result.hasMore,\n\t\tloadMore: result.loadMore,\n\t\trefetch: result.refetch,\n\t\treset: result.reset,\n\t\tsetSearchFilter: result.setSearchFilter,\n\t\tsearchFilter: result.searchFilter,\n\t};\n}\n\n/**\n * Composable for fetching deleted brands with pagination\n *\n * @example\n * ```typescript\n * import { useDeletedBrands } from '@htlkg/data/hooks';\n *\n * const { brands, loading, hasMore, loadMore, refetch } = useDeletedBrands({\n * pageSize: 25,\n * });\n * ```\n */\nexport function useDeletedBrands(options: UsePaginatedBrandsOptions = {}): UsePaginatedBrandsReturn {\n\tconst result = useDeletedBrandsInternal(options);\n\treturn {\n\t\tbrands: result.brands as Ref<BrandWithCounts[]>,\n\t\tloading: result.loading,\n\t\tinitialLoading: result.initialLoading,\n\t\tloadingMore: result.loadingMore,\n\t\terror: result.error,\n\t\tpagination: result.pagination,\n\t\thasMore: result.hasMore,\n\t\tloadMore: result.loadMore,\n\t\trefetch: result.refetch,\n\t\treset: result.reset,\n\t\tsetSearchFilter: result.setSearchFilter,\n\t\tsearchFilter: result.searchFilter,\n\t};\n}\n","/**\n * useUsers Hook\n *\n * Vue composable for fetching and managing user data with reactive state.\n * Provides loading states, error handling, and refetch capabilities.\n */\n\nimport type { Ref } from \"vue\";\nimport type { User } from \"@htlkg/core/types\";\nimport { createDataHook, type BaseHookOptions } from \"../createDataHook\";\n\nexport interface UseUsersOptions extends BaseHookOptions {\n\t/** Filter criteria for users */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n\t/** Filter by brand ID */\n\tbrandId?: string;\n\t/** Filter by account ID */\n\taccountId?: string;\n}\n\nexport interface UseUsersReturn {\n\t/** Reactive array of users */\n\tusers: Ref<User[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch users */\n\trefetch: () => Promise<void>;\n}\n\n/**\n * Build filter from hook options\n */\nfunction buildFilter(options: UseUsersOptions): any {\n\tlet filter: any = options.filter || {};\n\n\tif (options.brandId) {\n\t\tfilter = { ...filter, brandIds: { contains: options.brandId } };\n\t}\n\n\tif (options.accountId) {\n\t\tfilter = { ...filter, accountIds: { contains: options.accountId } };\n\t}\n\n\treturn Object.keys(filter).length > 0 ? filter : undefined;\n}\n\n/**\n * Internal hook created by factory\n */\nconst useUsersInternal = createDataHook<User, UseUsersOptions>({\n\tmodel: \"User\",\n\tdataPropertyName: \"users\",\n\tbuildFilter,\n});\n\n/**\n * Composable for fetching and managing users\n *\n * @example\n * ```typescript\n * import { useUsers } from '@htlkg/data/hooks';\n *\n * const { users, loading, error, refetch } = useUsers();\n * ```\n *\n * @example With filters\n * ```typescript\n * const { users, loading } = useUsers({\n * brandId: 'brand-123',\n * accountId: 'account-456',\n * limit: 50\n * });\n * ```\n */\nexport function useUsers(options: UseUsersOptions = {}): UseUsersReturn {\n\tconst result = useUsersInternal(options);\n\treturn {\n\t\tusers: result.users as Ref<User[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t};\n}\n","/**\n * Paginated Users Hooks\n *\n * Vue composables for fetching users with server-side pagination.\n * Provides separate hooks for active and deleted users to enable\n * efficient tab-based filtering in large datasets.\n */\n\nimport type { Ref, ComputedRef } from \"vue\";\nimport type { User } from \"@htlkg/core/types\";\nimport {\n\tcreatePaginatedDataHook,\n\tACTIVE_FILTER,\n\tDELETED_FILTER,\n\ttype PaginatedHookOptions,\n\ttype PaginationState,\n} from \"../createPaginatedDataHook\";\n\n/** Extended User type with computed fields */\nexport type UserWithRelations = User & {\n\taccountName?: string;\n\tbrandNames?: string[];\n\tdeletedAt?: string;\n\tdeletedBy?: string;\n};\n\nexport interface UsePaginatedUsersOptions extends PaginatedHookOptions {\n\t/** Filter by brand ID */\n\tbrandId?: string;\n\t/** Filter by account ID */\n\taccountId?: string;\n}\n\nexport interface UsePaginatedUsersReturn {\n\t/** Reactive array of users */\n\tusers: Ref<UserWithRelations[]>;\n\t/** Loading state (true during any fetch) */\n\tloading: Ref<boolean>;\n\t/** Loading state for initial fetch */\n\tinitialLoading: Ref<boolean>;\n\t/** Loading state for loadMore */\n\tloadingMore: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Pagination state */\n\tpagination: Ref<PaginationState>;\n\t/** Whether there are more items to load */\n\thasMore: ComputedRef<boolean>;\n\t/** Load next page of data */\n\tloadMore: () => Promise<void>;\n\t/** Refetch data (resets to first page) */\n\trefetch: () => Promise<void>;\n\t/** Reset data and pagination state */\n\treset: () => void;\n\t/** Update search filter and refetch from server (searches ALL data) */\n\tsetSearchFilter: (filter: any) => Promise<void>;\n\t/** Current search filter */\n\tsearchFilter: Ref<any>;\n}\n\n/**\n * Build additional filter from hook options\n */\nfunction buildFilter(options: UsePaginatedUsersOptions): any {\n\tconst conditions: any[] = [];\n\n\tif (options.brandId) {\n\t\tconditions.push({ brandIds: { contains: options.brandId } });\n\t}\n\n\tif (options.accountId) {\n\t\tconditions.push({ accountId: { eq: options.accountId } });\n\t}\n\n\tif (options.filter && Object.keys(options.filter).length > 0) {\n\t\tconditions.push(options.filter);\n\t}\n\n\tif (conditions.length === 0) {\n\t\treturn undefined;\n\t}\n\tif (conditions.length === 1) {\n\t\treturn conditions[0];\n\t}\n\treturn { and: conditions };\n}\n\n/**\n * Transform user data\n */\nfunction transformUser(user: any): UserWithRelations {\n\treturn {\n\t\t...user,\n\t\taccountName: user.account?.name || \"\",\n\t};\n}\n\n/**\n * Selection set for user queries\n */\nconst USER_SELECTION_SET = [\n\t\"id\",\n\t\"email\",\n\t\"accountId\",\n\t\"brandIds\",\n\t\"roles\",\n\t\"status\",\n\t\"lastLogin\",\n\t\"createdAt\",\n\t\"deletedAt\",\n\t\"deletedBy\",\n\t\"account.name\",\n];\n\n/**\n * Internal hook for active users\n */\nconst useActiveUsersInternal = createPaginatedDataHook<UserWithRelations, UsePaginatedUsersOptions>({\n\tmodel: \"User\",\n\tdataPropertyName: \"users\",\n\tdefaultPageSize: 25,\n\tselectionSet: USER_SELECTION_SET,\n\ttransform: transformUser,\n\tbuildFilter,\n\tbaseFilter: ACTIVE_FILTER,\n});\n\n/**\n * Internal hook for deleted users\n */\nconst useDeletedUsersInternal = createPaginatedDataHook<UserWithRelations, UsePaginatedUsersOptions>({\n\tmodel: \"User\",\n\tdataPropertyName: \"users\",\n\tdefaultPageSize: 25,\n\tselectionSet: USER_SELECTION_SET,\n\ttransform: transformUser,\n\tbuildFilter,\n\tbaseFilter: DELETED_FILTER,\n});\n\n/**\n * Composable for fetching active (non-deleted) users with pagination\n *\n * @example\n * ```typescript\n * import { useActiveUsers } from '@htlkg/data/hooks';\n *\n * const { users, loading, hasMore, loadMore, refetch } = useActiveUsers({\n * pageSize: 25,\n * });\n *\n * // Load more when user scrolls or clicks \"Load More\"\n * async function onLoadMore() {\n * await loadMore();\n * }\n * ```\n *\n * @example With filters\n * ```typescript\n * const { users, loading } = useActiveUsers({\n * accountId: 'account-123',\n * brandId: 'brand-456',\n * pageSize: 50\n * });\n * ```\n */\nexport function useActiveUsers(options: UsePaginatedUsersOptions = {}): UsePaginatedUsersReturn {\n\tconst result = useActiveUsersInternal(options);\n\treturn {\n\t\tusers: result.users as Ref<UserWithRelations[]>,\n\t\tloading: result.loading,\n\t\tinitialLoading: result.initialLoading,\n\t\tloadingMore: result.loadingMore,\n\t\terror: result.error,\n\t\tpagination: result.pagination,\n\t\thasMore: result.hasMore,\n\t\tloadMore: result.loadMore,\n\t\trefetch: result.refetch,\n\t\treset: result.reset,\n\t\tsetSearchFilter: result.setSearchFilter,\n\t\tsearchFilter: result.searchFilter,\n\t};\n}\n\n/**\n * Composable for fetching deleted users with pagination\n *\n * @example\n * ```typescript\n * import { useDeletedUsers } from '@htlkg/data/hooks';\n *\n * const { users, loading, hasMore, loadMore, refetch } = useDeletedUsers({\n * pageSize: 25,\n * });\n * ```\n */\nexport function useDeletedUsers(options: UsePaginatedUsersOptions = {}): UsePaginatedUsersReturn {\n\tconst result = useDeletedUsersInternal(options);\n\treturn {\n\t\tusers: result.users as Ref<UserWithRelations[]>,\n\t\tloading: result.loading,\n\t\tinitialLoading: result.initialLoading,\n\t\tloadingMore: result.loadingMore,\n\t\terror: result.error,\n\t\tpagination: result.pagination,\n\t\thasMore: result.hasMore,\n\t\tloadMore: result.loadMore,\n\t\trefetch: result.refetch,\n\t\treset: result.reset,\n\t\tsetSearchFilter: result.setSearchFilter,\n\t\tsearchFilter: result.searchFilter,\n\t};\n}\n","/**\n * useAccounts Hook\n *\n * Vue composable for fetching and managing account data with reactive state.\n * Provides loading states, error handling, and refetch capabilities.\n * Includes brands relationship data for displaying brand info without separate queries.\n */\n\nimport type { Ref } from \"vue\";\nimport type { Account } from \"@htlkg/core/types\";\nimport { createDataHook, type BaseHookOptions } from \"../createDataHook\";\n\nexport interface UseAccountsOptions extends BaseHookOptions {\n\t/** Filter criteria for accounts */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n}\n\n/** Brand info included with account */\nexport interface AccountBrand {\n\tid: string;\n\tname: string;\n\tstatus?: string;\n}\n\n/** Extended account type with brands relationship */\nexport type AccountWithBrands = Account & {\n\tbrands: AccountBrand[];\n\tbrandCount: number;\n\tdeletedAt?: string;\n\tdeletedBy?: string;\n};\n\nexport interface UseAccountsReturn {\n\t/** Reactive array of accounts with brands */\n\taccounts: Ref<AccountWithBrands[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch accounts */\n\trefetch: () => Promise<void>;\n}\n\n/**\n * Transform account data to include brandCount\n */\nfunction transformAccount(account: any): AccountWithBrands {\n\tconst brands = account.brands || [];\n\treturn {\n\t\t...account,\n\t\tbrands,\n\t\tbrandCount: brands.length,\n\t};\n}\n\n/**\n * Internal hook created by factory\n */\nconst useAccountsInternal = createDataHook<AccountWithBrands, UseAccountsOptions>({\n\tmodel: \"Account\",\n\tdataPropertyName: \"accounts\",\n\t// Include brands relationship for brand display\n\tselectionSet: [\n\t\t\"id\",\n\t\t\"name\",\n\t\t\"logo\",\n\t\t\"subscription\",\n\t\t\"settings\",\n\t\t\"status\",\n\t\t\"deletedAt\",\n\t\t\"deletedBy\",\n\t\t\"brands.id\",\n\t\t\"brands.name\",\n\t\t\"brands.status\",\n\t],\n\ttransform: transformAccount,\n});\n\n/**\n * Composable for fetching and managing accounts\n *\n * @example\n * ```typescript\n * import { useAccounts } from '@htlkg/data/hooks';\n *\n * const { accounts, loading, error, refetch } = useAccounts();\n * ```\n *\n * @example With filters\n * ```typescript\n * const { accounts, loading } = useAccounts({\n * filter: { status: { eq: 'active' } },\n * limit: 50\n * });\n * ```\n */\nexport function useAccounts(options: UseAccountsOptions = {}): UseAccountsReturn {\n\tconst result = useAccountsInternal(options);\n\treturn {\n\t\taccounts: result.accounts as Ref<AccountWithBrands[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t};\n}\n","/**\n * Paginated Accounts Hooks\n *\n * Vue composables for fetching accounts with server-side pagination.\n * Provides separate hooks for active and deleted accounts to enable\n * efficient tab-based filtering in large datasets.\n */\n\nimport type { Ref, ComputedRef } from \"vue\";\nimport {\n\tcreatePaginatedDataHook,\n\tACTIVE_FILTER,\n\tDELETED_FILTER,\n\ttype PaginatedHookOptions,\n\ttype PaginationState,\n} from \"../createPaginatedDataHook\";\nimport type { AccountWithBrands } from \"./useAccounts\";\n\nexport interface UsePaginatedAccountsOptions extends PaginatedHookOptions {\n\t// Add any account-specific filters here if needed\n}\n\nexport interface UsePaginatedAccountsReturn {\n\t/** Reactive array of accounts with brands */\n\taccounts: Ref<AccountWithBrands[]>;\n\t/** Loading state (true during any fetch) */\n\tloading: Ref<boolean>;\n\t/** Loading state for initial fetch */\n\tinitialLoading: Ref<boolean>;\n\t/** Loading state for loadMore */\n\tloadingMore: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Pagination state */\n\tpagination: Ref<PaginationState>;\n\t/** Whether there are more items to load */\n\thasMore: ComputedRef<boolean>;\n\t/** Load next page of data */\n\tloadMore: () => Promise<void>;\n\t/** Refetch data (resets to first page) */\n\trefetch: () => Promise<void>;\n\t/** Reset data and pagination state */\n\treset: () => void;\n\t/** Update search filter and refetch from server (searches ALL data) */\n\tsetSearchFilter: (filter: any) => Promise<void>;\n\t/** Current search filter */\n\tsearchFilter: Ref<any>;\n}\n\n/**\n * Transform account data to include brandCount\n */\nfunction transformAccount(account: any): AccountWithBrands {\n\tconst brands = account.brands || [];\n\treturn {\n\t\t...account,\n\t\tbrands,\n\t\tbrandCount: brands.length,\n\t};\n}\n\n/**\n * Selection set for account queries\n */\nconst ACCOUNT_SELECTION_SET = [\n\t\"id\",\n\t\"name\",\n\t\"logo\",\n\t\"subscription\",\n\t\"settings\",\n\t\"status\",\n\t\"deletedAt\",\n\t\"deletedBy\",\n\t\"brands.id\",\n\t\"brands.name\",\n\t\"brands.status\",\n];\n\n/**\n * Internal hook for active accounts\n */\nconst useActiveAccountsInternal = createPaginatedDataHook<AccountWithBrands, UsePaginatedAccountsOptions>({\n\tmodel: \"Account\",\n\tdataPropertyName: \"accounts\",\n\tdefaultPageSize: 25,\n\tselectionSet: ACCOUNT_SELECTION_SET,\n\ttransform: transformAccount,\n\tbaseFilter: ACTIVE_FILTER,\n});\n\n/**\n * Internal hook for deleted accounts\n */\nconst useDeletedAccountsInternal = createPaginatedDataHook<AccountWithBrands, UsePaginatedAccountsOptions>({\n\tmodel: \"Account\",\n\tdataPropertyName: \"accounts\",\n\tdefaultPageSize: 25,\n\tselectionSet: ACCOUNT_SELECTION_SET,\n\ttransform: transformAccount,\n\tbaseFilter: DELETED_FILTER,\n});\n\n/**\n * Composable for fetching active (non-deleted) accounts with pagination\n *\n * @example\n * ```typescript\n * import { useActiveAccounts } from '@htlkg/data/hooks';\n *\n * const { accounts, loading, hasMore, loadMore, refetch } = useActiveAccounts({\n * pageSize: 25,\n * });\n *\n * // Load more when user scrolls or clicks \"Load More\"\n * async function onLoadMore() {\n * await loadMore();\n * }\n * ```\n */\nexport function useActiveAccounts(options: UsePaginatedAccountsOptions = {}): UsePaginatedAccountsReturn {\n\tconst result = useActiveAccountsInternal(options);\n\treturn {\n\t\taccounts: result.accounts as Ref<AccountWithBrands[]>,\n\t\tloading: result.loading,\n\t\tinitialLoading: result.initialLoading,\n\t\tloadingMore: result.loadingMore,\n\t\terror: result.error,\n\t\tpagination: result.pagination,\n\t\thasMore: result.hasMore,\n\t\tloadMore: result.loadMore,\n\t\trefetch: result.refetch,\n\t\treset: result.reset,\n\t\tsetSearchFilter: result.setSearchFilter,\n\t\tsearchFilter: result.searchFilter,\n\t};\n}\n\n/**\n * Composable for fetching deleted accounts with pagination\n *\n * @example\n * ```typescript\n * import { useDeletedAccounts } from '@htlkg/data/hooks';\n *\n * const { accounts, loading, hasMore, loadMore, refetch } = useDeletedAccounts({\n * pageSize: 25,\n * });\n * ```\n */\nexport function useDeletedAccounts(options: UsePaginatedAccountsOptions = {}): UsePaginatedAccountsReturn {\n\tconst result = useDeletedAccountsInternal(options);\n\treturn {\n\t\taccounts: result.accounts as Ref<AccountWithBrands[]>,\n\t\tloading: result.loading,\n\t\tinitialLoading: result.initialLoading,\n\t\tloadingMore: result.loadingMore,\n\t\terror: result.error,\n\t\tpagination: result.pagination,\n\t\thasMore: result.hasMore,\n\t\tloadMore: result.loadMore,\n\t\trefetch: result.refetch,\n\t\treset: result.reset,\n\t\tsetSearchFilter: result.setSearchFilter,\n\t\tsearchFilter: result.searchFilter,\n\t};\n}\n","/**\n * useReservations Hook\n *\n * Vue composable for fetching and managing reservation data with reactive state.\n * Provides loading states, error handling, pagination, and refetch capabilities.\n */\n\nimport type { Ref, ComputedRef } from \"vue\";\nimport type { Reservation } from \"../../queries/reservations\";\nimport { createDataHook, type BaseHookOptions } from \"../createDataHook\";\n\nexport interface UseReservationsOptions extends BaseHookOptions {\n\t/** Filter by brand ID */\n\tbrandId?: string;\n\t/** Filter by start date (check-in date >= startDate) */\n\tstartDate?: string;\n\t/** Filter by end date (check-in date <= endDate) */\n\tendDate?: string;\n\t/** Filter by reservation status */\n\tstatus?: Reservation[\"status\"];\n\t/** Filter by contact/visit ID */\n\tcontactId?: string;\n\t/** Pagination token for fetching next page */\n\tnextToken?: string;\n}\n\n/** Extended reservation type with related data */\nexport type ReservationWithRelations = Reservation & {\n\tbrandName: string;\n\tguestName: string;\n\tguestEmail: string;\n\tguestPhone: string;\n};\n\nexport interface UseReservationsReturn {\n\t/** Reactive array of reservations with brand and guest info */\n\treservations: Ref<ReservationWithRelations[]>;\n\t/** Computed array of confirmed reservations */\n\tconfirmedReservations: ComputedRef<ReservationWithRelations[]>;\n\t/** Computed array of active reservations (confirmed or checked_in) */\n\tactiveReservations: ComputedRef<ReservationWithRelations[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch reservations */\n\trefetch: () => Promise<void>;\n}\n\n/**\n * Build filter from hook options\n */\nfunction buildFilter(options: UseReservationsOptions): any {\n\tconst conditions: any[] = [];\n\n\tif (options.brandId) {\n\t\tconditions.push({ brandId: { eq: options.brandId } });\n\t}\n\n\tif (options.status) {\n\t\tconditions.push({ status: { eq: options.status } });\n\t}\n\n\tif (options.contactId) {\n\t\tconditions.push({ visitId: { eq: options.contactId } });\n\t}\n\n\tif (options.startDate) {\n\t\tconditions.push({ checkIn: { ge: options.startDate } });\n\t}\n\n\tif (options.endDate) {\n\t\tconditions.push({ checkIn: { le: options.endDate } });\n\t}\n\n\tif (options.filter) {\n\t\tconditions.push(options.filter);\n\t}\n\n\tif (conditions.length === 0) {\n\t\treturn undefined;\n\t}\n\n\tif (conditions.length === 1) {\n\t\treturn conditions[0];\n\t}\n\n\treturn { and: conditions };\n}\n\n/**\n * Transform reservation data to include brandName and guest info from visit.snapshot\n */\nfunction transformReservation(r: any): Reservation & { brandName: string; guestName: string; guestEmail: string; guestPhone: string } {\n\t// Parse snapshot if it's a string (handles double-stringification from import)\n\tlet snapshot = r.visit?.snapshot;\n\tif (typeof snapshot === \"string\") {\n\t\ttry {\n\t\t\tsnapshot = JSON.parse(snapshot);\n\t\t} catch {\n\t\t\tsnapshot = null;\n\t\t}\n\t}\n\n\treturn {\n\t\t...r,\n\t\tbrandName: r.brand?.name || \"Unknown Brand\",\n\t\tguestName: snapshot\n\t\t\t? `${snapshot.firstName || \"\"} ${snapshot.lastName || \"\"}`.trim() || \"Unknown Guest\"\n\t\t\t: \"Unknown Guest\",\n\t\tguestEmail: snapshot?.email || \"\",\n\t\tguestPhone: snapshot?.phone || \"\",\n\t};\n}\n\n/**\n * Internal hook created by factory\n */\nconst useReservationsInternal = createDataHook<\n\tReservation & { brandName: string; guestName: string; guestEmail: string; guestPhone: string },\n\tUseReservationsOptions,\n\t{ confirmedReservations: Reservation[]; activeReservations: Reservation[] }\n>({\n\tmodel: \"Reservation\",\n\tdataPropertyName: \"reservations\",\n\tbuildFilter,\n\t// Include related data for brand name and guest info\n\tselectionSet: [\n\t\t\"id\",\n\t\t\"brandId\",\n\t\t\"visitId\",\n\t\t\"checkIn\",\n\t\t\"checkOut\",\n\t\t\"room\",\n\t\t\"roomType\",\n\t\t\"status\",\n\t\t\"source\",\n\t\t\"channel\",\n\t\t\"confirmationCode\",\n\t\t\"totalAmount\",\n\t\t\"currency\",\n\t\t\"nights\",\n\t\t\"deletedAt\",\n\t\t\"deletedBy\",\n\t\t\"brand.name\",\n\t\t\"visit.snapshot\",\n\t],\n\ttransform: transformReservation,\n\tcomputedProperties: {\n\t\tconfirmedReservations: (reservations) =>\n\t\t\treservations.filter((r) => r.status === \"confirmed\"),\n\t\tactiveReservations: (reservations) =>\n\t\t\treservations.filter((r) => r.status === \"confirmed\" || r.status === \"checked_in\"),\n\t},\n});\n\n/**\n * Composable for fetching and managing reservations\n *\n * @example\n * ```typescript\n * import { useReservations } from '@htlkg/data/hooks';\n *\n * const { reservations, loading, error, refetch } = useReservations({\n * brandId: 'brand-123',\n * startDate: '2026-01-01',\n * endDate: '2026-01-31',\n * status: 'confirmed'\n * });\n * ```\n *\n * @example With contact filter\n * ```typescript\n * const { reservations, loading } = useReservations({\n * contactId: 'contact-123',\n * limit: 50\n * });\n * ```\n *\n * @example With computed properties\n * ```typescript\n * const { reservations, activeReservations, confirmedReservations } = useReservations({\n * brandId: 'brand-123'\n * });\n *\n * // activeReservations includes confirmed + checked_in\n * // confirmedReservations includes only confirmed\n * ```\n */\nexport function useReservations(options: UseReservationsOptions = {}): UseReservationsReturn {\n\tconst result = useReservationsInternal(options);\n\treturn {\n\t\treservations: result.reservations as Ref<ReservationWithRelations[]>,\n\t\tconfirmedReservations: result.confirmedReservations as ComputedRef<ReservationWithRelations[]>,\n\t\tactiveReservations: result.activeReservations as ComputedRef<ReservationWithRelations[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t};\n}\n","/**\n * Paginated Reservations Hooks\n *\n * Vue composables for fetching reservations with server-side pagination.\n * Provides separate hooks for active and deleted reservations to enable\n * efficient tab-based filtering in large datasets.\n */\n\nimport type { Ref, ComputedRef } from \"vue\";\nimport type { Reservation } from \"../../queries/reservations\";\nimport {\n\tcreatePaginatedDataHook,\n\tACTIVE_FILTER,\n\tDELETED_FILTER,\n\ttype PaginatedHookOptions,\n\ttype PaginationState,\n} from \"../createPaginatedDataHook\";\nimport type { ReservationWithRelations } from \"./useReservations\";\n\nexport interface UsePaginatedReservationsOptions extends PaginatedHookOptions {\n\t/** Filter by brand ID */\n\tbrandId?: string;\n\t/** Filter by start date (check-in date >= startDate) */\n\tstartDate?: string;\n\t/** Filter by end date (check-in date <= endDate) */\n\tendDate?: string;\n\t/** Filter by reservation status */\n\tstatus?: Reservation[\"status\"];\n\t/** Filter by contact/visit ID */\n\tcontactId?: string;\n}\n\nexport interface UsePaginatedReservationsReturn {\n\t/** Reactive array of reservations with brand and guest info */\n\treservations: Ref<ReservationWithRelations[]>;\n\t/** Loading state (true during any fetch) */\n\tloading: Ref<boolean>;\n\t/** Loading state for initial fetch */\n\tinitialLoading: Ref<boolean>;\n\t/** Loading state for loadMore */\n\tloadingMore: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Pagination state */\n\tpagination: Ref<PaginationState>;\n\t/** Whether there are more items to load */\n\thasMore: ComputedRef<boolean>;\n\t/** Load next page of data */\n\tloadMore: () => Promise<void>;\n\t/** Refetch data (resets to first page) */\n\trefetch: () => Promise<void>;\n\t/** Reset data and pagination state */\n\treset: () => void;\n\t/** Update search filter and refetch from server (searches ALL data) */\n\tsetSearchFilter: (filter: any) => Promise<void>;\n\t/** Current search filter */\n\tsearchFilter: Ref<any>;\n}\n\n/**\n * Build additional filter from hook options\n */\nfunction buildFilter(options: UsePaginatedReservationsOptions): any {\n\tconst conditions: any[] = [];\n\n\tif (options.brandId) {\n\t\tconditions.push({ brandId: { eq: options.brandId } });\n\t}\n\n\tif (options.status) {\n\t\tconditions.push({ status: { eq: options.status } });\n\t}\n\n\tif (options.contactId) {\n\t\tconditions.push({ visitId: { eq: options.contactId } });\n\t}\n\n\tif (options.startDate) {\n\t\tconditions.push({ checkIn: { ge: options.startDate } });\n\t}\n\n\tif (options.endDate) {\n\t\tconditions.push({ checkIn: { le: options.endDate } });\n\t}\n\n\tif (options.filter && Object.keys(options.filter).length > 0) {\n\t\tconditions.push(options.filter);\n\t}\n\n\tif (conditions.length === 0) {\n\t\treturn undefined;\n\t}\n\tif (conditions.length === 1) {\n\t\treturn conditions[0];\n\t}\n\treturn { and: conditions };\n}\n\n/**\n * Transform reservation data to include brandName and guest info from visit.snapshot\n */\nfunction transformReservation(r: any): ReservationWithRelations {\n\t// Parse snapshot if it's a string (handles double-stringification from import)\n\tlet snapshot = r.visit?.snapshot;\n\tif (typeof snapshot === \"string\") {\n\t\ttry {\n\t\t\tsnapshot = JSON.parse(snapshot);\n\t\t} catch {\n\t\t\tsnapshot = null;\n\t\t}\n\t}\n\n\treturn {\n\t\t...r,\n\t\tbrandName: r.brand?.name || \"Unknown Brand\",\n\t\tguestName: snapshot\n\t\t\t? `${snapshot.firstName || \"\"} ${snapshot.lastName || \"\"}`.trim() || \"Unknown Guest\"\n\t\t\t: \"Unknown Guest\",\n\t\tguestEmail: snapshot?.email || \"\",\n\t\tguestPhone: snapshot?.phone || \"\",\n\t};\n}\n\n/**\n * Selection set for reservation queries\n */\nconst RESERVATION_SELECTION_SET = [\n\t\"id\",\n\t\"brandId\",\n\t\"visitId\",\n\t\"checkIn\",\n\t\"checkOut\",\n\t\"room\",\n\t\"roomType\",\n\t\"status\",\n\t\"source\",\n\t\"channel\",\n\t\"confirmationCode\",\n\t\"totalAmount\",\n\t\"currency\",\n\t\"nights\",\n\t\"deletedAt\",\n\t\"deletedBy\",\n\t\"brand.name\",\n\t\"visit.snapshot\",\n];\n\n/**\n * Internal hook for active reservations\n */\nconst useActiveReservationsInternal = createPaginatedDataHook<\n\tReservationWithRelations,\n\tUsePaginatedReservationsOptions\n>({\n\tmodel: \"Reservation\",\n\tdataPropertyName: \"reservations\",\n\tdefaultPageSize: 25,\n\tselectionSet: RESERVATION_SELECTION_SET,\n\ttransform: transformReservation,\n\tbuildFilter,\n\tbaseFilter: ACTIVE_FILTER,\n});\n\n/**\n * Internal hook for deleted reservations\n */\nconst useDeletedReservationsInternal = createPaginatedDataHook<\n\tReservationWithRelations,\n\tUsePaginatedReservationsOptions\n>({\n\tmodel: \"Reservation\",\n\tdataPropertyName: \"reservations\",\n\tdefaultPageSize: 25,\n\tselectionSet: RESERVATION_SELECTION_SET,\n\ttransform: transformReservation,\n\tbuildFilter,\n\tbaseFilter: DELETED_FILTER,\n});\n\n/**\n * Composable for fetching active (non-deleted) reservations with pagination\n *\n * @example\n * ```typescript\n * import { useActiveReservations } from '@htlkg/data/hooks';\n *\n * const { reservations, loading, hasMore, loadMore, refetch } = useActiveReservations({\n * pageSize: 25,\n * brandId: 'brand-123',\n * });\n *\n * // Load more when user scrolls or clicks \"Load More\"\n * async function onLoadMore() {\n * await loadMore();\n * }\n * ```\n *\n * @example With date filters\n * ```typescript\n * const { reservations, loading } = useActiveReservations({\n * brandId: 'brand-123',\n * startDate: '2026-01-01',\n * endDate: '2026-01-31',\n * status: 'confirmed'\n * });\n * ```\n */\nexport function useActiveReservations(\n\toptions: UsePaginatedReservationsOptions = {},\n): UsePaginatedReservationsReturn {\n\tconst result = useActiveReservationsInternal(options);\n\treturn {\n\t\treservations: result.reservations as Ref<ReservationWithRelations[]>,\n\t\tloading: result.loading,\n\t\tinitialLoading: result.initialLoading,\n\t\tloadingMore: result.loadingMore,\n\t\terror: result.error,\n\t\tpagination: result.pagination,\n\t\thasMore: result.hasMore,\n\t\tloadMore: result.loadMore,\n\t\trefetch: result.refetch,\n\t\treset: result.reset,\n\t\tsetSearchFilter: result.setSearchFilter,\n\t\tsearchFilter: result.searchFilter,\n\t};\n}\n\n/**\n * Composable for fetching deleted reservations with pagination\n *\n * @example\n * ```typescript\n * import { useDeletedReservations } from '@htlkg/data/hooks';\n *\n * const { reservations, loading, hasMore, loadMore, refetch } = useDeletedReservations({\n * pageSize: 25,\n * });\n * ```\n */\nexport function useDeletedReservations(\n\toptions: UsePaginatedReservationsOptions = {},\n): UsePaginatedReservationsReturn {\n\tconst result = useDeletedReservationsInternal(options);\n\treturn {\n\t\treservations: result.reservations as Ref<ReservationWithRelations[]>,\n\t\tloading: result.loading,\n\t\tinitialLoading: result.initialLoading,\n\t\tloadingMore: result.loadingMore,\n\t\terror: result.error,\n\t\tpagination: result.pagination,\n\t\thasMore: result.hasMore,\n\t\tloadMore: result.loadMore,\n\t\trefetch: result.refetch,\n\t\treset: result.reset,\n\t\tsetSearchFilter: result.setSearchFilter,\n\t\tsearchFilter: result.searchFilter,\n\t};\n}\n","/**\n * Product Hooks\n *\n * Vue composables for fetching and managing product data with reactive state.\n */\n\nimport type { Ref, ComputedRef } from \"vue\";\nimport type { Product } from \"@htlkg/core/types\";\nimport { createDataHook, type BaseHookOptions } from \"../createDataHook\";\n\nexport interface UseProductsOptions extends BaseHookOptions {\n\t/** Filter criteria for products */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n\t/** Only active products */\n\tactiveOnly?: boolean;\n}\n\nexport interface UseProductsReturn {\n\t/** Reactive array of products */\n\tproducts: Ref<Product[]>;\n\t/** Computed array of active products only */\n\tactiveProducts: ComputedRef<Product[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch products */\n\trefetch: () => Promise<void>;\n}\n\n/**\n * Build filter from hook options\n */\nfunction buildFilter(options: UseProductsOptions): any {\n\tlet filter: any = options.filter || {};\n\n\tif (options.activeOnly) {\n\t\tfilter = { ...filter, isActive: { eq: true } };\n\t}\n\n\treturn Object.keys(filter).length > 0 ? filter : undefined;\n}\n\n/**\n * Internal hook created by factory\n */\nconst useProductsInternal = createDataHook<Product, UseProductsOptions, { activeProducts: Product[] }>({\n\tmodel: \"Product\",\n\tdataPropertyName: \"products\",\n\tbuildFilter,\n\tcomputedProperties: {\n\t\tactiveProducts: (products) => products.filter((p) => p.isActive === true),\n\t},\n});\n\n/**\n * Composable for fetching and managing products\n *\n * @example\n * ```typescript\n * import { useProducts } from '@htlkg/data/hooks/products';\n *\n * const { products, loading, error, refetch } = useProducts();\n * ```\n *\n * @example With filters\n * ```typescript\n * const { products, loading } = useProducts({\n * activeOnly: true,\n * limit: 50\n * });\n * ```\n */\nexport function useProducts(options: UseProductsOptions = {}): UseProductsReturn {\n\tconst result = useProductsInternal(options);\n\treturn {\n\t\tproducts: result.products as Ref<Product[]>,\n\t\tactiveProducts: result.activeProducts as ComputedRef<Product[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t};\n}\n","/**\n * ProductInstance Hooks\n *\n * Vue composables for fetching and managing product instance data with reactive state.\n * Provides loading states, error handling, refetch capabilities, and CRUD operations.\n */\n\nimport type { Ref, ComputedRef } from \"vue\";\nimport type { ProductInstance } from \"@htlkg/core/types\";\nimport { createDataHook, type BaseHookOptions } from \"../createDataHook\";\nimport { getSharedClient } from \"../../client\";\nimport {\n\tcreateProductInstance,\n\tupdateProductInstance,\n\tdeleteProductInstance,\n\ttoggleProductInstanceEnabled,\n\ttype CreateProductInstanceInput,\n\ttype UpdateProductInstanceInput,\n} from \"../../mutations/productInstances\";\n\nexport interface UseProductInstancesOptions extends BaseHookOptions {\n\t/** Filter criteria for product instances */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n\t/** Filter by brand ID */\n\tbrandId?: string;\n\t/** Filter by account ID */\n\taccountId?: string;\n\t/** Filter by product ID */\n\tproductId?: string;\n\t/** Only enabled instances */\n\tenabledOnly?: boolean;\n}\n\nexport interface UseProductInstancesReturn {\n\t/** Reactive array of product instances */\n\tinstances: Ref<ProductInstance[]>;\n\t/** Computed array of enabled instances only */\n\tenabledInstances: ComputedRef<ProductInstance[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch product instances */\n\trefetch: () => Promise<void>;\n\t/** Create a new product instance */\n\tcreateInstance: (input: CreateProductInstanceInput) => Promise<ProductInstance>;\n\t/** Update an existing product instance */\n\tupdateInstance: (input: UpdateProductInstanceInput) => Promise<ProductInstance>;\n\t/** Delete a product instance */\n\tdeleteInstance: (id: string) => Promise<boolean>;\n\t/** Toggle the enabled status of a product instance */\n\ttoggleEnabled: (id: string, enabled: boolean) => Promise<ProductInstance>;\n}\n\n/**\n * Build filter from hook options\n */\nfunction buildFilter(options: UseProductInstancesOptions): any {\n\tlet filter: any = options.filter || {};\n\n\tif (options.brandId) {\n\t\tfilter = { ...filter, brandId: { eq: options.brandId } };\n\t}\n\n\tif (options.accountId) {\n\t\tfilter = { ...filter, accountId: { eq: options.accountId } };\n\t}\n\n\tif (options.productId) {\n\t\tfilter = { ...filter, productId: { eq: options.productId } };\n\t}\n\n\tif (options.enabledOnly) {\n\t\tfilter = { ...filter, enabled: { eq: true } };\n\t}\n\n\treturn Object.keys(filter).length > 0 ? filter : undefined;\n}\n\n/**\n * Internal hook created by factory\n */\nconst useProductInstancesInternal = createDataHook<\n\tProductInstance,\n\tUseProductInstancesOptions,\n\t{ enabledInstances: ProductInstance[] }\n>({\n\tmodel: \"ProductInstance\",\n\tdataPropertyName: \"instances\",\n\tbuildFilter,\n\tcomputedProperties: {\n\t\tenabledInstances: (instances) => instances.filter((i) => i.enabled),\n\t},\n});\n\n/**\n * Composable for fetching and managing product instances\n *\n * @example\n * ```typescript\n * import { useProductInstances } from '@htlkg/data/hooks/productInstances';\n *\n * const { instances, loading, error, refetch } = useProductInstances();\n * ```\n *\n * @example With filters\n * ```typescript\n * const { instances, enabledInstances, loading } = useProductInstances({\n * brandId: 'brand-123',\n * enabledOnly: true,\n * limit: 50\n * });\n * ```\n *\n * @example For a specific account\n * ```typescript\n * const { instances, loading } = useProductInstances({\n * accountId: 'account-456',\n * autoFetch: true\n * });\n * ```\n */\nexport function useProductInstances(options: UseProductInstancesOptions = {}): UseProductInstancesReturn {\n\tconst result = useProductInstancesInternal(options);\n\n\t// CRUD methods using mutations from @htlkg/data/mutations\n\tasync function createInstance(input: CreateProductInstanceInput): Promise<ProductInstance> {\n\t\tconst client = getSharedClient();\n\t\tconst instance = await createProductInstance(client, input);\n\t\tif (!instance) {\n\t\t\tthrow new Error(\"Failed to create product instance\");\n\t\t}\n\t\treturn instance;\n\t}\n\n\tasync function updateInstance(input: UpdateProductInstanceInput): Promise<ProductInstance> {\n\t\tconst client = getSharedClient();\n\t\tconst instance = await updateProductInstance(client, input);\n\t\tif (!instance) {\n\t\t\tthrow new Error(\"Failed to update product instance\");\n\t\t}\n\t\treturn instance;\n\t}\n\n\tasync function deleteInstance(id: string): Promise<boolean> {\n\t\tconst client = getSharedClient();\n\t\treturn deleteProductInstance(client, id);\n\t}\n\n\tasync function toggleEnabled(id: string, enabled: boolean): Promise<ProductInstance> {\n\t\tconst client = getSharedClient();\n\t\tconst instance = await toggleProductInstanceEnabled(client, id, enabled);\n\t\tif (!instance) {\n\t\t\tthrow new Error(\"Failed to toggle product instance\");\n\t\t}\n\t\treturn instance;\n\t}\n\n\treturn {\n\t\tinstances: result.instances as Ref<ProductInstance[]>,\n\t\tenabledInstances: result.enabledInstances as ComputedRef<ProductInstance[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t\tcreateInstance,\n\t\tupdateInstance,\n\t\tdeleteInstance,\n\t\ttoggleEnabled,\n\t};\n}\n\n// Re-export types for convenience\nexport type { CreateProductInstanceInput, UpdateProductInstanceInput };\n","/**\n * useContacts Hook\n *\n * Vue composable for fetching and managing contact data with reactive state.\n * Provides loading states, error handling, search, pagination, and refetch capabilities.\n */\n\nimport type { Ref, ComputedRef } from \"vue\";\nimport type { Contact } from \"@htlkg/core/types\";\nimport { createDataHook, type BaseHookOptions } from \"./createDataHook\";\n\nexport interface UseContactsOptions extends BaseHookOptions {\n\t/** Filter by brand ID */\n\tbrandId?: string;\n\t/** Search query (searches email, firstName, lastName) */\n\tsearch?: string;\n\t/** Filter by GDPR consent */\n\tgdprConsent?: boolean;\n\t/** Filter by marketing opt-in */\n\tmarketingOptIn?: boolean;\n\t/** Filter by tags (contact must have at least one of these tags) */\n\ttags?: string[];\n\t/** Pagination token for fetching next page */\n\tnextToken?: string;\n}\n\nexport interface UseContactsReturn {\n\t/** Reactive array of contacts */\n\tcontacts: Ref<Contact[]>;\n\t/** Computed array of contacts with GDPR consent */\n\tconsentedContacts: ComputedRef<Contact[]>;\n\t/** Computed array of contacts opted-in for marketing */\n\tmarketingContacts: ComputedRef<Contact[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch contacts */\n\trefetch: () => Promise<void>;\n}\n\n/**\n * Build filter from hook options\n */\nfunction buildFilter(options: UseContactsOptions): any {\n\tconst conditions: any[] = [];\n\n\t// Filter by brand\n\tif (options.brandId) {\n\t\tconditions.push({ brandId: { eq: options.brandId } });\n\t}\n\n\t// Search across email, firstName, lastName\n\tif (options.search) {\n\t\tconditions.push({\n\t\t\tor: [\n\t\t\t\t{ email: { contains: options.search } },\n\t\t\t\t{ firstName: { contains: options.search } },\n\t\t\t\t{ lastName: { contains: options.search } },\n\t\t\t],\n\t\t});\n\t}\n\n\t// Filter by GDPR consent\n\tif (options.gdprConsent !== undefined) {\n\t\tconditions.push({ gdprConsent: { eq: options.gdprConsent } });\n\t}\n\n\t// Filter by marketing opt-in\n\tif (options.marketingOptIn !== undefined) {\n\t\tconditions.push({ marketingOptIn: { eq: options.marketingOptIn } });\n\t}\n\n\t// Filter by tags (contact must have at least one of these tags)\n\tif (options.tags && options.tags.length > 0) {\n\t\tconst tagConditions = options.tags.map((tag) => ({\n\t\t\ttags: { contains: tag },\n\t\t}));\n\t\tconditions.push({ or: tagConditions });\n\t}\n\n\t// Include any additional custom filter\n\tif (options.filter) {\n\t\tconditions.push(options.filter);\n\t}\n\n\tif (conditions.length === 0) {\n\t\treturn undefined;\n\t}\n\n\tif (conditions.length === 1) {\n\t\treturn conditions[0];\n\t}\n\n\treturn { and: conditions };\n}\n\n/**\n * Internal hook created by factory\n */\nconst useContactsInternal = createDataHook<\n\tContact,\n\tUseContactsOptions,\n\t{ consentedContacts: Contact[]; marketingContacts: Contact[] }\n>({\n\tmodel: \"Contact\",\n\tdataPropertyName: \"contacts\",\n\tbuildFilter,\n\tcomputedProperties: {\n\t\tconsentedContacts: (contacts) =>\n\t\t\tcontacts.filter((c) => c.gdprConsent === true),\n\t\tmarketingContacts: (contacts) =>\n\t\t\tcontacts.filter((c) => c.marketingOptIn === true),\n\t},\n});\n\n/**\n * Composable for fetching and managing contacts\n *\n * @example\n * ```typescript\n * import { useContacts } from '@htlkg/data/hooks';\n *\n * const { contacts, loading, error, refetch } = useContacts({\n * brandId: 'brand-123',\n * limit: 25\n * });\n * ```\n *\n * @example With search\n * ```typescript\n * const { contacts, loading } = useContacts({\n * brandId: 'brand-123',\n * search: 'john',\n * limit: 25\n * });\n * ```\n *\n * @example With GDPR and marketing filters\n * ```typescript\n * const { contacts, marketingContacts } = useContacts({\n * brandId: 'brand-123',\n * gdprConsent: true,\n * marketingOptIn: true\n * });\n * ```\n *\n * @example With computed properties\n * ```typescript\n * const { contacts, consentedContacts, marketingContacts } = useContacts({\n * brandId: 'brand-123'\n * });\n *\n * // consentedContacts - contacts with GDPR consent\n * // marketingContacts - contacts opted-in for marketing\n * ```\n *\n * @example With tag filtering\n * ```typescript\n * const { contacts } = useContacts({\n * brandId: 'brand-123',\n * tags: ['vip', 'returning']\n * });\n * ```\n */\nexport function useContacts(options: UseContactsOptions = {}): UseContactsReturn {\n\tconst result = useContactsInternal(options);\n\treturn {\n\t\tcontacts: result.contacts as Ref<Contact[]>,\n\t\tconsentedContacts: result.consentedContacts as ComputedRef<Contact[]>,\n\t\tmarketingContacts: result.marketingContacts as ComputedRef<Contact[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t};\n}\n","import { cleanTasks } from '../task/index.js'\n\nexport let clean = Symbol('clean')\n\nexport let cleanStores = (...stores) => {\n if (process.env.NODE_ENV === 'production') {\n throw new Error(\n 'cleanStores() can be used only during development or tests'\n )\n }\n cleanTasks()\n for (let $store of stores) {\n if ($store) {\n if ($store.mocked) delete $store.mocked\n if ($store[clean]) $store[clean]()\n }\n }\n}\n","import { clean } from '../clean-stores/index.js'\n\nlet listenerQueue = []\nlet lqIndex = 0\nconst QUEUE_ITEMS_PER_LISTENER = 4\nexport let epoch = 0\n\n/* @__NO_SIDE_EFFECTS__ */\nexport const atom = initialValue => {\n let listeners = []\n let $atom = {\n get() {\n if (!$atom.lc) {\n $atom.listen(() => {})()\n }\n return $atom.value\n },\n lc: 0,\n listen(listener) {\n $atom.lc = listeners.push(listener)\n\n return () => {\n for (\n let i = lqIndex + QUEUE_ITEMS_PER_LISTENER;\n i < listenerQueue.length;\n\n ) {\n if (listenerQueue[i] === listener) {\n listenerQueue.splice(i, QUEUE_ITEMS_PER_LISTENER)\n } else {\n i += QUEUE_ITEMS_PER_LISTENER\n }\n }\n\n let index = listeners.indexOf(listener)\n if (~index) {\n listeners.splice(index, 1)\n if (!--$atom.lc) $atom.off()\n }\n }\n },\n notify(oldValue, changedKey) {\n epoch++\n let runListenerQueue = !listenerQueue.length\n for (let listener of listeners) {\n listenerQueue.push(listener, $atom.value, oldValue, changedKey)\n }\n\n if (runListenerQueue) {\n for (\n lqIndex = 0;\n lqIndex < listenerQueue.length;\n lqIndex += QUEUE_ITEMS_PER_LISTENER\n ) {\n listenerQueue[lqIndex](\n listenerQueue[lqIndex + 1],\n listenerQueue[lqIndex + 2],\n listenerQueue[lqIndex + 3]\n )\n }\n listenerQueue.length = 0\n }\n },\n /* It will be called on last listener unsubscribing.\n We will redefine it in onMount and onStop. */\n off() {},\n set(newValue) {\n let oldValue = $atom.value\n if (oldValue !== newValue) {\n $atom.value = newValue\n $atom.notify(oldValue)\n }\n },\n subscribe(listener) {\n let unbind = $atom.listen(listener)\n listener($atom.value)\n return unbind\n },\n value: initialValue\n }\n\n if (process.env.NODE_ENV !== 'production') {\n $atom[clean] = () => {\n listeners = []\n $atom.lc = 0\n $atom.off()\n }\n }\n\n return $atom\n}\n\nexport const readonlyType = store => store\n","/**\n * Store Factory\n *\n * Creates request-scoped nanostores for sharing data across Vue islands\n * without props. Works with @inox-tools/request-nanostores for Astro integration.\n */\n\nimport { atom, type WritableAtom } from \"nanostores\";\n\n/**\n * Type for the shared function from @it-astro:request-nanostores\n */\ntype SharedFn = <T>(key: string, atomFactory: WritableAtom<T>) => WritableAtom<T>;\n\n/**\n * Configuration for a resource store\n */\nexport interface StoreConfig {\n\t/** Resource name (e.g., 'accounts', 'users') */\n\tname: string;\n\t/** Related resources to create stores for (e.g., ['brands', 'products']) */\n\trelations?: string[];\n}\n\n/**\n * Result type for created stores\n */\nexport type ResourceStores<T, TRelations extends string = never> = {\n\t/** Main resource store */\n\t$data: WritableAtom<readonly T[]>;\n} & {\n\t[K in TRelations as `$${K}`]: WritableAtom<readonly any[]>;\n};\n\n/**\n * Capitalize first letter of a string\n */\nfunction capitalize(str: string): string {\n\treturn str.charAt(0).toUpperCase() + str.slice(1);\n}\n\n/**\n * Creates request-scoped stores for a resource and its relations.\n *\n * This factory is designed to work with Astro's request-nanostores integration,\n * providing request-isolated state that syncs from server to client.\n *\n * @param shared - The shared function from @it-astro:request-nanostores\n * @param config - Store configuration\n * @returns Object containing the main store and relation stores\n *\n * @example\n * ```typescript\n * // In your store file (e.g., stores/accounts.ts)\n * import { shared } from '@it-astro:request-nanostores';\n * import { createResourceStores } from '@htlkg/data/stores';\n *\n * export const accountStores = createResourceStores(shared, {\n * name: 'accounts',\n * relations: ['brands'],\n * });\n *\n * // This creates:\n * // - accountStores.$data (WritableAtom<any[]>) - main accounts store\n * // - accountStores.$brands (WritableAtom<any[]>) - related brands store\n *\n * // For cleaner exports:\n * export const $accounts = accountStores.$data;\n * export const $accountsBrands = accountStores.$brands;\n * ```\n *\n * @example\n * ```typescript\n * // With typed stores\n * interface Account { id: number; name: string; }\n * interface Brand { id: number; name: string; }\n *\n * export const { $data: $accounts, $brands } = createResourceStores<Account, 'brands'>(\n * shared,\n * { name: 'accounts', relations: ['brands'] }\n * );\n * ```\n */\nexport function createResourceStores<T = any, TRelations extends string = never>(\n\tshared: SharedFn,\n\tconfig: StoreConfig & { relations?: TRelations[] },\n): ResourceStores<T, TRelations> {\n\tconst { name, relations = [] } = config;\n\n\tconst stores: Record<string, any> = {};\n\n\t// Main resource store\n\tstores.$data = shared(name, atom<T[]>([]));\n\n\t// Relation stores\n\tfor (const relation of relations) {\n\t\tconst storeKey = `$${relation}`;\n\t\tconst sharedKey = `${name}${capitalize(relation)}`;\n\t\tstores[storeKey] = shared(sharedKey, atom<any[]>([]));\n\t}\n\n\treturn stores as ResourceStores<T, TRelations>;\n}\n\n/**\n * Creates a simple single store (non-factory version for simpler use cases)\n *\n * @example\n * ```typescript\n * import { shared } from '@it-astro:request-nanostores';\n * import { createStore } from '@htlkg/data/stores';\n *\n * export const $currentUser = createStore<User>(shared, 'currentUser');\n * ```\n */\nexport function createStore<T>(\n\tshared: SharedFn,\n\tname: string,\n\tdefaultValue: T[] = [],\n): WritableAtom<readonly T[]> {\n\treturn shared(name, atom<T[]>(defaultValue));\n}\n\n/**\n * Creates a single-value store (for non-array values like current user)\n *\n * @example\n * ```typescript\n * import { shared } from '@it-astro:request-nanostores';\n * import { createSingleStore } from '@htlkg/data/stores';\n *\n * export const $currentUser = createSingleStore<User | null>(shared, 'currentUser', null);\n * ```\n */\nexport function createSingleStore<T>(\n\tshared: SharedFn,\n\tname: string,\n\tdefaultValue: T,\n): WritableAtom<T> {\n\treturn shared(name, atom<T>(defaultValue));\n}\n\n/**\n * Helper to create typed store with proper inference\n */\nexport type InferStoreType<TStore extends WritableAtom<any>> = TStore extends WritableAtom<infer T>\n\t? T\n\t: never;\n"],"mappings":";AASA,SAAS,kBAAkB,0BAA0B;AACrD,SAAS,eAAe;;;ACDxB;AAAA,EAIC;AAAA,OACM;AACP,SAAS,+BAA+B;AACxC,SAA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;AACzC,UAAM,KAAK,IAAI,MAAM;AACnB,kBAAY,CAAC;AACb,YAAM,KAAK;AACX,YAAM,IAAI;AAAA,IACZ;AAAA,EACF;AAEA,SAAO;AACT;;;ACrDA,SAAS,WAAW,KAAqB;AACxC,SAAO,IAAI,OAAO,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC;AACjD;AA4CO,SAAS,qBACf,QACA,QACgC;AAChC,QAAM,EAAE,MAAM,YAAY,CAAC,EAAE,IAAI;AAEjC,QAAM,SAA8B,CAAC;AAGrC,SAAO,QAAQ,OAAO,MAAM,KAAU,CAAC,CAAC,CAAC;AAGzC,aAAW,YAAY,WAAW;AACjC,UAAM,WAAW,IAAI,QAAQ;AAC7B,UAAM,YAAY,GAAG,IAAI,GAAG,WAAW,QAAQ,CAAC;AAChD,WAAO,QAAQ,IAAI,OAAO,WAAW,KAAY,CAAC,CAAC,CAAC;AAAA,EACrD;AAEA,SAAO;AACR;AAaO,SAAS,YACf,QACA,MACA,eAAoB,CAAC,GACQ;AAC7B,SAAO,OAAO,MAAM,KAAU,YAAY,CAAC;AAC5C;AAaO,SAAS,kBACf,QACA,MACA,cACkB;AAClB,SAAO,OAAO,MAAM,KAAQ,YAAY,CAAC;AAC1C;","names":["getReservation","listReservations","query","createReservation","updateReservation","softDeleteReservation","restoreReservation","deleteReservation","updateReservationStatus","buildFilter","fetch","ref","computed","onMounted","buildFilter","ref","computed","onMounted","buildFilter","buildFilter","buildFilter","transformAccount","buildFilter","buildFilter","transformReservation","buildFilter","buildFilter","buildFilter"]}