@htlkg/data 0.0.20 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { Ref, ComputedRef } from 'vue';
2
- import { Brand, Account, User, Product, ProductInstance } from '@htlkg/core/types';
2
+ import { Brand, Account, User, Product, ProductInstance, Contact } from '@htlkg/core/types';
3
3
  import { C as CreateProductInstanceInput, U as UpdateProductInstanceInput } from '../productInstances-BpQv1oLS.js';
4
4
  import { R as Reservation } from '../reservations-C0FNm__0.js';
5
5
  import '../common-DSxswsZ3.js';
@@ -445,4 +445,90 @@ interface UseReservationsReturn {
445
445
  */
446
446
  declare function useReservations(options?: UseReservationsOptions): UseReservationsReturn;
447
447
 
448
- export { type BaseHookOptions, type CreateDataHookOptions, type DataHookReturn, type InferHookReturn, type UseAccountsOptions, type UseAccountsReturn, type UseBrandsOptions, type UseBrandsReturn, type UseProductInstancesOptions, type UseProductInstancesReturn, type UseProductsOptions, type UseProductsReturn, type UseReservationsOptions, type UseReservationsReturn, type UseUsersOptions, type UseUsersReturn, createDataHook, resetClientInstance, useAccounts, useBrands, useProductInstances, useProducts, useReservations, useUsers };
448
+ /**
449
+ * useContacts Hook
450
+ *
451
+ * Vue composable for fetching and managing contact data with reactive state.
452
+ * Provides loading states, error handling, search, pagination, and refetch capabilities.
453
+ */
454
+
455
+ interface UseContactsOptions extends BaseHookOptions {
456
+ /** Filter by brand ID */
457
+ brandId?: string;
458
+ /** Search query (searches email, firstName, lastName) */
459
+ search?: string;
460
+ /** Filter by GDPR consent */
461
+ gdprConsent?: boolean;
462
+ /** Filter by marketing opt-in */
463
+ marketingOptIn?: boolean;
464
+ /** Filter by tags (contact must have at least one of these tags) */
465
+ tags?: string[];
466
+ /** Pagination token for fetching next page */
467
+ nextToken?: string;
468
+ }
469
+ interface UseContactsReturn {
470
+ /** Reactive array of contacts */
471
+ contacts: Ref<Contact[]>;
472
+ /** Computed array of contacts with GDPR consent */
473
+ consentedContacts: ComputedRef<Contact[]>;
474
+ /** Computed array of contacts opted-in for marketing */
475
+ marketingContacts: ComputedRef<Contact[]>;
476
+ /** Loading state */
477
+ loading: Ref<boolean>;
478
+ /** Error state */
479
+ error: Ref<Error | null>;
480
+ /** Refetch contacts */
481
+ refetch: () => Promise<void>;
482
+ }
483
+ /**
484
+ * Composable for fetching and managing contacts
485
+ *
486
+ * @example
487
+ * ```typescript
488
+ * import { useContacts } from '@htlkg/data/hooks';
489
+ *
490
+ * const { contacts, loading, error, refetch } = useContacts({
491
+ * brandId: 'brand-123',
492
+ * limit: 25
493
+ * });
494
+ * ```
495
+ *
496
+ * @example With search
497
+ * ```typescript
498
+ * const { contacts, loading } = useContacts({
499
+ * brandId: 'brand-123',
500
+ * search: 'john',
501
+ * limit: 25
502
+ * });
503
+ * ```
504
+ *
505
+ * @example With GDPR and marketing filters
506
+ * ```typescript
507
+ * const { contacts, marketingContacts } = useContacts({
508
+ * brandId: 'brand-123',
509
+ * gdprConsent: true,
510
+ * marketingOptIn: true
511
+ * });
512
+ * ```
513
+ *
514
+ * @example With computed properties
515
+ * ```typescript
516
+ * const { contacts, consentedContacts, marketingContacts } = useContacts({
517
+ * brandId: 'brand-123'
518
+ * });
519
+ *
520
+ * // consentedContacts - contacts with GDPR consent
521
+ * // marketingContacts - contacts opted-in for marketing
522
+ * ```
523
+ *
524
+ * @example With tag filtering
525
+ * ```typescript
526
+ * const { contacts } = useContacts({
527
+ * brandId: 'brand-123',
528
+ * tags: ['vip', 'returning']
529
+ * });
530
+ * ```
531
+ */
532
+ declare function useContacts(options?: UseContactsOptions): UseContactsReturn;
533
+
534
+ export { type BaseHookOptions, type CreateDataHookOptions, type DataHookReturn, type InferHookReturn, type UseAccountsOptions, type UseAccountsReturn, type UseBrandsOptions, type UseBrandsReturn, type UseContactsOptions, type UseContactsReturn, type UseProductInstancesOptions, type UseProductInstancesReturn, type UseProductsOptions, type UseProductsReturn, type UseReservationsOptions, type UseReservationsReturn, type UseUsersOptions, type UseUsersReturn, createDataHook, resetClientInstance, useAccounts, useBrands, useContacts, useProductInstances, useProducts, useReservations, useUsers };
@@ -55,7 +55,7 @@ function createDataHook(config) {
55
55
  defaultLimit,
56
56
  selectionSet,
57
57
  transform,
58
- buildFilter: buildFilter6,
58
+ buildFilter: buildFilter7,
59
59
  computedProperties,
60
60
  dataPropertyName = "data"
61
61
  } = config;
@@ -65,8 +65,8 @@ function createDataHook(config) {
65
65
  const loading = ref(false);
66
66
  const error = ref(null);
67
67
  const getFilter = () => {
68
- if (buildFilter6) {
69
- return buildFilter6(options);
68
+ if (buildFilter7) {
69
+ return buildFilter7(options);
70
70
  }
71
71
  return baseFilter && Object.keys(baseFilter).length > 0 ? baseFilter : void 0;
72
72
  };
@@ -514,11 +514,71 @@ function useReservations(options = {}) {
514
514
  refetch: result.refetch
515
515
  };
516
516
  }
517
+
518
+ // src/hooks/useContacts.ts
519
+ function buildFilter6(options) {
520
+ const conditions = [];
521
+ if (options.brandId) {
522
+ conditions.push({ brandId: { eq: options.brandId } });
523
+ }
524
+ if (options.search) {
525
+ conditions.push({
526
+ or: [
527
+ { email: { contains: options.search } },
528
+ { firstName: { contains: options.search } },
529
+ { lastName: { contains: options.search } }
530
+ ]
531
+ });
532
+ }
533
+ if (options.gdprConsent !== void 0) {
534
+ conditions.push({ gdprConsent: { eq: options.gdprConsent } });
535
+ }
536
+ if (options.marketingOptIn !== void 0) {
537
+ conditions.push({ marketingOptIn: { eq: options.marketingOptIn } });
538
+ }
539
+ if (options.tags && options.tags.length > 0) {
540
+ const tagConditions = options.tags.map((tag) => ({
541
+ tags: { contains: tag }
542
+ }));
543
+ conditions.push({ or: tagConditions });
544
+ }
545
+ if (options.filter) {
546
+ conditions.push(options.filter);
547
+ }
548
+ if (conditions.length === 0) {
549
+ return void 0;
550
+ }
551
+ if (conditions.length === 1) {
552
+ return conditions[0];
553
+ }
554
+ return { and: conditions };
555
+ }
556
+ var useContactsInternal = createDataHook({
557
+ model: "Contact",
558
+ dataPropertyName: "contacts",
559
+ buildFilter: buildFilter6,
560
+ computedProperties: {
561
+ consentedContacts: (contacts) => contacts.filter((c) => c.gdprConsent === true),
562
+ marketingContacts: (contacts) => contacts.filter((c) => c.marketingOptIn === true)
563
+ }
564
+ });
565
+ function useContacts(options = {}) {
566
+ const result = useContactsInternal(options);
567
+ return {
568
+ contacts: result.contacts,
569
+ consentedContacts: result.consentedContacts,
570
+ marketingContacts: result.marketingContacts,
571
+ loading: result.loading,
572
+ error: result.error,
573
+ refetch: result.refetch
574
+ };
575
+ }
517
576
  export {
518
577
  createDataHook,
519
578
  resetClientInstance,
520
579
  useAccounts,
521
580
  useBrands,
581
+ useContacts,
522
582
  useProductInstances,
523
583
  useProducts,
524
584
  useReservations,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/createDataHook.ts","../../src/client/proxy.ts","../../src/hooks/useBrands.ts","../../src/hooks/useAccounts.ts","../../src/hooks/useUsers.ts","../../src/hooks/useProducts.ts","../../src/client/index.ts","../../src/client/server.ts","../../src/mutations/productInstances/productInstances.ts","../../src/hooks/useProductInstances.ts","../../src/hooks/useReservations.ts"],"sourcesContent":["/**\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 * 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 * 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 * 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 * 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 * 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"],"mappings":";AAOA,SAAS,KAAK,UAAU,iBAA6C;;;AC6BrE,IAAM,mBAAmB;AAgEzB,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;AAAA,MACZ,MAAM,KAAK,UAAU,EAAE,OAAO,WAAW,KAAK,CAAC;AAAA,IAChD,CAAC;AAED,UAAM,SAA6B,MAAM,SAAS,KAAK;AAGvD,QAAI,SAAS,WAAW,KAAK;AAC5B,cAAQ,MAAM,yDAAyD;AAAA,IAGxE;AAEA,WAAO;AAAA,EACR,SAAS,OAAO;AACf,YAAQ,MAAM,mCAAmC,KAAK;AACtD,WAAO;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,QACP;AAAA,UACC,SAAS,iBAAiB,QAAQ,MAAM,U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E,CAAC;AAAA,EACvD;AAEA,MAAI,QAAQ,WAAW;AACtB,eAAW,KAAK,EAAE,SAAS,EAAE,IAAI,QAAQ,UAAU,EAAE,CAAC;AAAA,EACvD;AAEA,MAAI,QAAQ,SAAS;AACpB,eAAW,KAAK,EAAE,SAAS,EAAE,IAAI,QAAQ,QAAQ,EAAE,CAAC;AAAA,EACrD;AAEA,MAAI,QAAQ,QAAQ;AACnB,eAAW,KAAK,QAAQ,MAAM;AAAA,EAC/B;AAEA,MAAI,WAAW,WAAW,GAAG;AAC5B,WAAO;AAAA,EACR;AAEA,MAAI,WAAW,WAAW,GAAG;AAC5B,WAAO,WAAW,CAAC;AAAA,EACpB;AAEA,SAAO,EAAE,KAAK,WAAW;AAC1B;AAKA,IAAM,0BAA0B,eAI9B;AAAA,EACD,OAAO;AAAA,EACP,kBAAkB;AAAA,EAClB,aAAAA;AAAA,EACA,oBAAoB;AAAA,IACnB,uBAAuB,CAAC,iBACvB,aAAa,OAAO,CAAC,MAAM,EAAE,WAAW,WAAW;AAAA,IACpD,oBAAoB,CAAC,iBACpB,aAAa,OAAO,CAAC,MAAM,EAAE,WAAW,eAAe,EAAE,WAAW,YAAY;AAAA,EAClF;AACD,CAAC;AAmCM,SAAS,gBAAgB,UAAkC,CAAC,GAA0B;AAC5F,QAAM,SAAS,wBAAwB,OAAO;AAC9C,SAAO;AAAA,IACN,cAAc,OAAO;AAAA,IACrB,uBAAuB,OAAO;AAAA,IAC9B,oBAAoB,OAAO;AAAA,IAC3B,SAAS,OAAO;AAAA,IAChB,OAAO,OAAO;AAAA,IACd,SAAS,OAAO;AAAA,EACjB;AACD;","names":["buildFilter","fetch","buildFilter","buildFilter","buildFilter","buildFilter"]}
1
+ {"version":3,"sources":["../../src/hooks/createDataHook.ts","../../src/client/proxy.ts","../../src/hooks/useBrands.ts","../../src/hooks/useAccounts.ts","../../src/hooks/useUsers.ts","../../src/hooks/useProducts.ts","../../src/client/index.ts","../../src/client/server.ts","../../src/mutations/productInstances/productInstances.ts","../../src/hooks/useProductInstances.ts","../../src/hooks/useReservations.ts","../../src/hooks/useContacts.ts"],"sourcesContent":["/**\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 * 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 * 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 * 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 * 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 * 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"],"mappings":";AAOA,SAAS,KAAK,UAAU,iBAA6C;;;AC6BrE,IAAM,mBAAmB;AAgEzB,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;AAAA,MACZ,MAAM,KAAK,UAAU,EAAE,OAAO,WAAW,KAAK,CAAC;AAAA,IAChD,CAAC;AAED,UAAM,SAA6B,MAAM,SAAS,KAAK;AAGvD,QAAI,SAAS,WAAW,KAAK;AAC5B,cAAQ,MAAM,yDAAyD;AAAA,IAGxE;AAEA,WAAO;AAAA,EACR,SAAS,OAAO;AACf,YAAQ,MAAM,mCAAmC,KAAK;AACtD,WAAO;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,QACP;AAAA,UACC,SAAS,iBAAiB,QAAQ,MAAM,UAAU;AAAA,QACnD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;AAKO,SAAS,UAAU,UAAoC;AAC7D,SAAO,CAAC,CAAC,SAAS,UAAU,SAAS,OAAO,SAAS;AACtD;AAKO,SAAS,gBAAgB,UAA0C;AACzE,MAAI,CAAC,SAAS,UAAU,SAAS,OAAO,WAAW,GAAG;AACrD,WAAO;AAAA,EACR;AACA,SAAO,SAAS,OAAO,CAAC,EAAE;AAC3B;;;AD9GO,SAAS,sBAA4B;AAE5C;AAwCO,SAAS,eAKf,QAGC;AACD,QAAM;AAAA,IACL;AAAA,IACA;A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E,gBAAgB,EAAE,IAAI,QAAQ,eAAe,EAAE,CAAC;AAAA,EACnE;AAGA,MAAI,QAAQ,QAAQ,QAAQ,KAAK,SAAS,GAAG;AAC5C,UAAM,gBAAgB,QAAQ,KAAK,IAAI,CAAC,SAAS;AAAA,MAChD,MAAM,EAAE,UAAU,IAAI;AAAA,IACvB,EAAE;AACF,eAAW,KAAK,EAAE,IAAI,cAAc,CAAC;AAAA,EACtC;AAGA,MAAI,QAAQ,QAAQ;AACnB,eAAW,KAAK,QAAQ,MAAM;AAAA,EAC/B;AAEA,MAAI,WAAW,WAAW,GAAG;AAC5B,WAAO;AAAA,EACR;AAEA,MAAI,WAAW,WAAW,GAAG;AAC5B,WAAO,WAAW,CAAC;AAAA,EACpB;AAEA,SAAO,EAAE,KAAK,WAAW;AAC1B;AAKA,IAAM,sBAAsB,eAI1B;AAAA,EACD,OAAO;AAAA,EACP,kBAAkB;AAAA,EAClB,aAAAA;AAAA,EACA,oBAAoB;AAAA,IACnB,mBAAmB,CAAC,aACnB,SAAS,OAAO,CAAC,MAAM,EAAE,gBAAgB,IAAI;AAAA,IAC9C,mBAAmB,CAAC,aACnB,SAAS,OAAO,CAAC,MAAM,EAAE,mBAAmB,IAAI;AAAA,EAClD;AACD,CAAC;AAmDM,SAAS,YAAY,UAA8B,CAAC,GAAsB;AAChF,QAAM,SAAS,oBAAoB,OAAO;AAC1C,SAAO;AAAA,IACN,UAAU,OAAO;AAAA,IACjB,mBAAmB,OAAO;AAAA,IAC1B,mBAAmB,OAAO;AAAA,IAC1B,SAAS,OAAO;AAAA,IAChB,OAAO,OAAO;AAAA,IACd,SAAS,OAAO;AAAA,EACjB;AACD;","names":["buildFilter","fetch","buildFilter","buildFilter","buildFilter","buildFilter","buildFilter"]}
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  export { AstroAmplifyConfig, GraphQLResponse, Operation, ProxyOptions, generateClient, generateServerClient, getErrorMessage, getSharedClient, hasErrors, mutate, query, resetSharedClient } from './client/index.js';
2
- export { DEFAULT_SOFT_DELETE_RETENTION_DAYS, SYSTEM_SETTINGS_KEY, checkRestoreEligibility, executePublicQuery, executeServerQuery, getAccount, getAccountWithBrands, getBrand, getBrandWithProducts, getProduct, getProductInstance, getSoftDeleteRetentionDays, getSystemSettings, getUser, getUserByCognitoId, getUserByEmail, listAccounts, listActiveBrands, listActiveProducts, listActiveUsers, listBrands, listBrandsByAccount, listEnabledProductInstancesByBrand, listProductInstancesByAccount, listProductInstancesByBrand, listProducts, listUsers, listUsersByAccount } from './queries/index.js';
2
+ export { DEFAULT_SOFT_DELETE_RETENTION_DAYS, SYSTEM_SETTINGS_KEY, checkRestoreEligibility, executePublicQuery, executeServerQuery, getAccount, getAccountWithBrands, getBrand, getBrandWithProducts, getContact, getContactByEmail, getContactByPhone, getProduct, getProductInstance, getSoftDeleteRetentionDays, getSystemSettings, getUser, getUserByCognitoId, getUserByEmail, listAccounts, listActiveBrands, listActiveProducts, listActiveUsers, listBrands, listBrandsByAccount, listContacts, listContactsByBrand, listEnabledProductInstancesByBrand, listProductInstancesByAccount, listProductInstancesByBrand, listProducts, listUsers, listUsersByAccount, searchContacts } from './queries/index.js';
3
3
  export { R as Reservation, g as getReservation, d as getReservationByConfirmation, l as listReservations, a as listReservationsByBrand, b as listReservationsByContact, c as listReservationsByDateRange } from './reservations-C0FNm__0.js';
4
4
  export { C as CreateAuditFields, S as SoftDeleteFields, U as UpdateAuditFields, a as UpdateWithSoftDeleteFields } from './common-DSxswsZ3.js';
5
- export { CreateAccountInput, CreateBrandInput, CreateUserInput, UpdateAccountInput, UpdateBrandInput, UpdateSystemSettingsInput, UpdateUserInput, createAccount, createBrand, createUser, deleteAccount, deleteBrand, deleteUser, initializeSystemSettings, restoreAccount, restoreBrand, restoreUser, softDeleteAccount, softDeleteBrand, softDeleteUser, updateAccount, updateBrand, updateSystemSettings, updateUser } from './mutations/index.js';
5
+ export { ContactValidationError, CreateAccountInput, CreateBrandInput, CreateContactInput, CreateUserInput, MergeContactsInput, MergeContactsResult, UpdateAccountInput, UpdateBrandInput, UpdateContactInput, UpdateSystemSettingsInput, UpdateUserInput, createAccount, createBrand, createContact, createContactSchema, createUser, deleteAccount, deleteBrand, deleteContact, deleteUser, initializeSystemSettings, mergeContacts, mergeContactsSchema, restoreAccount, restoreBrand, restoreContact, restoreUser, softDeleteAccount, softDeleteBrand, softDeleteContact, softDeleteUser, updateAccount, updateBrand, updateContact, updateContactSchema, updateSystemSettings, updateUser } from './mutations/index.js';
6
6
  export { C as CreateProductInstanceInput, U as UpdateProductInstanceInput, c as createProductInstance, d as deleteProductInstance, t as toggleProductInstanceEnabled, u as updateProductInstance } from './productInstances-BpQv1oLS.js';
7
7
  export { C as CreateReservationInput, b as ReservationStatus, R as ReservationValidationError, U as UpdateReservationInput, c as createReservation, d as deleteReservation, r as restoreReservation, s as softDeleteReservation, u as updateReservation, a as updateReservationStatus } from './reservations-CdDfkcZ_.js';
8
- export { BaseHookOptions, CreateDataHookOptions, DataHookReturn, InferHookReturn, UseAccountsOptions, UseAccountsReturn, UseBrandsOptions, UseBrandsReturn, UseProductInstancesOptions, UseProductInstancesReturn, UseProductsOptions, UseProductsReturn, UseReservationsOptions, UseReservationsReturn, UseUsersOptions, UseUsersReturn, createDataHook, resetClientInstance, useAccounts, useBrands, useProductInstances, useProducts, useReservations, useUsers } from './hooks/index.js';
8
+ export { BaseHookOptions, CreateDataHookOptions, DataHookReturn, InferHookReturn, UseAccountsOptions, UseAccountsReturn, UseBrandsOptions, UseBrandsReturn, UseContactsOptions, UseContactsReturn, UseProductInstancesOptions, UseProductInstancesReturn, UseProductsOptions, UseProductsReturn, UseReservationsOptions, UseReservationsReturn, UseUsersOptions, UseUsersReturn, createDataHook, resetClientInstance, useAccounts, useBrands, useContacts, useProductInstances, useProducts, useReservations, useUsers } from './hooks/index.js';
9
9
  export { InferStoreType, ResourceStores, StoreConfig, createResourceStores, createSingleStore, createStore } from './stores/index.js';
10
10
  import 'aws-amplify/data';
11
11
  import 'aws-amplify';
@@ -13,5 +13,6 @@ import './server/index.js';
13
13
  import 'astro';
14
14
  import 'aws-amplify/api/internals';
15
15
  import '@htlkg/core/types';
16
+ import 'zod';
16
17
  import 'vue';
17
18
  import 'nanostores';