@htlkg/data 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.d.ts +102 -31
- package/dist/client/index.js +62 -22
- package/dist/client/index.js.map +1 -1
- package/dist/content-collections/index.js +20 -24
- package/dist/content-collections/index.js.map +1 -1
- package/dist/hooks/index.js +11 -19
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +42 -21
- package/dist/index.js.map +1 -1
- package/dist/queries/index.d.ts +78 -1
- package/dist/queries/index.js +47 -0
- package/dist/queries/index.js.map +1 -1
- package/package.json +37 -37
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/useBrands.ts","../../../../node_modules/.pnpm/aws-amplify@6.15.8/node_modules/aws-amplify/dist/esm/api/index.mjs","../../src/client/index.ts","../../src/hooks/useAccounts.ts","../../src/hooks/useUsers.ts","../../src/hooks/useProducts.ts"],"sourcesContent":["/**\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 { ref, computed, onMounted, type Ref, type ComputedRef } from \"vue\";\nimport { generateClient } from \"../client\";\nimport type { Brand } from \"@htlkg/core/types\";\n\nexport interface UseBrandsOptions {\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 * 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(\n\toptions: UseBrandsOptions = {},\n): UseBrandsReturn {\n\tconst {\n\t\tfilter: baseFilter,\n\t\tlimit,\n\t\tautoFetch = true,\n\t\taccountId,\n\t\tactiveOnly,\n\t} = options;\n\n\t// State\n\tconst brands = ref<Brand[]>([]);\n\tconst loading = ref(false);\n\tconst error = ref<Error | null>(null);\n\n\t// Build filter\n\tlet filter: any = baseFilter || {};\n\n\tif (accountId) {\n\t\tfilter = { ...filter, accountId: { eq: accountId } };\n\t}\n\n\tif (activeOnly) {\n\t\tfilter = { ...filter, status: { eq: \"active\" } };\n\t}\n\n\t// Computed\n\tconst activeBrands = computed(() =>\n\t\tbrands.value.filter((b) => b.status === \"active\"),\n\t);\n\n\t// Fetch function\n\tasync function fetch() {\n\t\tloading.value = true;\n\t\terror.value = null;\n\n\t\ttry {\n\t\t\tconst client = generateClient();\n\t\t\tconst { data, errors } = await (client as any).models.Brand.list({\n\t\t\t\tfilter: Object.keys(filter).length > 0 ? filter : undefined,\n\t\t\t\tlimit,\n\t\t\t});\n\n\t\t\tif (errors) {\n\t\t\t\tthrow new Error(errors[0]?.message || \"Failed to fetch brands\");\n\t\t\t}\n\n\t\t\tbrands.value = (data || []) as Brand[];\n\t\t} catch (e) {\n\t\t\terror.value = e as Error;\n\t\t\tconsole.error(\"[useBrands] Error fetching brands:\", e);\n\t\t} finally {\n\t\t\tloading.value = false;\n\t\t}\n\t}\n\n\t// Auto-fetch on mount if enabled\n\tif (autoFetch) {\n\t\tonMounted(() => {\n\t\t\tfetch();\n\t\t});\n\t}\n\n\treturn {\n\t\tbrands,\n\t\tactiveBrands,\n\t\tloading,\n\t\terror,\n\t\trefetch: fetch,\n\t};\n}\n","export * from '@aws-amplify/api';\n//# sourceMappingURL=index.mjs.map\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\nimport type { AstroCookies } from \"astro\";\nimport { generateClient as generateDataClient } from \"aws-amplify/data\";\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 Astro adapter\n */\nexport interface AstroAmplifyConfig {\n\tAPI?: {\n\t\tGraphQL?: {\n\t\t\tendpoint: string;\n\t\t\tregion: string;\n\t\t\tdefaultAuthMode: string;\n\t\t};\n\t};\n\tAuth?: {\n\t\tCognito?: {\n\t\t\tuserPoolId: string;\n\t\t\tuserPoolClientId: string;\n\t\t\tidentityPoolId?: string;\n\t\t};\n\t};\n}\n\n/**\n * Generate a server-side GraphQL client with cookie-based authentication\n * Use this in Astro pages and API routes for server-side GraphQL operations\n *\n * Note: This is a placeholder that will be properly implemented once the\n * Amplify Astro adapter is migrated to the modular architecture.\n * For now, import generateServerClient from @htlkg/shared/lib/graphql directly.\n *\n * @example\n * ```typescript\n * import type { Schema } from '../amplify/data/resource';\n * import { generateServerClient } from '@htlkg/data/client';\n * import outputs from '../amplify_outputs.json';\n *\n * const client = generateServerClient<Schema>({\n * cookies: Astro.cookies,\n * config: outputs\n * });\n * const { data: brands } = await client.models.Brand.list();\n * ```\n */\nexport function generateServerClient<\n\tTSchema extends Record<string, unknown> = Record<string, unknown>,\n>(options: { cookies: AstroCookies; config: AstroAmplifyConfig }): any {\n\tthrow new Error(\n\t\t\"[generateServerClient] Not yet implemented in modular architecture. \" +\n\t\t\"Please use generateServerClient from @htlkg/shared/lib/graphql for now. \" +\n\t\t\"This will be properly implemented when the Amplify Astro adapter is migrated.\",\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 { ref, onMounted, type Ref } from \"vue\";\nimport { generateClient } from \"../client\";\nimport type { Account } from \"@htlkg/core/types\";\n\nexport interface UseAccountsOptions {\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 * 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(\n\toptions: UseAccountsOptions = {},\n): UseAccountsReturn {\n\tconst { filter, limit, autoFetch = true } = options;\n\n\t// State\n\tconst accounts = ref<Account[]>([]);\n\tconst loading = ref(false);\n\tconst error = ref<Error | null>(null);\n\n\t// Fetch function\n\tasync function fetch() {\n\t\tloading.value = true;\n\t\terror.value = null;\n\n\t\ttry {\n\t\t\tconst client = generateClient();\n\t\t\tconst { data, errors } = await (client as any).models.Account.list({\n\t\t\t\tfilter,\n\t\t\t\tlimit,\n\t\t\t});\n\n\t\t\tif (errors) {\n\t\t\t\tthrow new Error(errors[0]?.message || \"Failed to fetch accounts\");\n\t\t\t}\n\n\t\t\taccounts.value = (data || []) as Account[];\n\t\t} catch (e) {\n\t\t\terror.value = e as Error;\n\t\t\tconsole.error(\"[useAccounts] Error fetching accounts:\", e);\n\t\t} finally {\n\t\t\tloading.value = false;\n\t\t}\n\t}\n\n\t// Auto-fetch on mount if enabled\n\tif (autoFetch) {\n\t\tonMounted(() => {\n\t\t\tfetch();\n\t\t});\n\t}\n\n\treturn {\n\t\taccounts,\n\t\tloading,\n\t\terror,\n\t\trefetch: fetch,\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 { ref, onMounted, type Ref } from \"vue\";\nimport { generateClient } from \"../client\";\nimport type { User } from \"@htlkg/core/types\";\n\nexport interface UseUsersOptions {\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 * 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 { filter: baseFilter, limit, autoFetch = true, brandId, accountId } = options;\n\n\t// State\n\tconst users = ref<User[]>([]);\n\tconst loading = ref(false);\n\tconst error = ref<Error | null>(null);\n\n\t// Build filter\n\tlet filter: any = baseFilter || {};\n\n\tif (brandId) {\n\t\tfilter = { ...filter, brandIds: { contains: brandId } };\n\t}\n\n\tif (accountId) {\n\t\tfilter = { ...filter, accountIds: { contains: accountId } };\n\t}\n\n\t// Fetch function\n\tasync function fetch() {\n\t\tloading.value = true;\n\t\terror.value = null;\n\n\t\ttry {\n\t\t\tconst client = generateClient();\n\t\t\tconst { data, errors } = await (client as any).models.User.list({\n\t\t\t\tfilter: Object.keys(filter).length > 0 ? filter : undefined,\n\t\t\t\tlimit,\n\t\t\t});\n\n\t\t\tif (errors) {\n\t\t\t\tthrow new Error(errors[0]?.message || \"Failed to fetch users\");\n\t\t\t}\n\n\t\t\tusers.value = (data || []) as User[];\n\t\t} catch (e) {\n\t\t\terror.value = e as Error;\n\t\t\tconsole.error(\"[useUsers] Error fetching users:\", e);\n\t\t} finally {\n\t\t\tloading.value = false;\n\t\t}\n\t}\n\n\t// Auto-fetch on mount if enabled\n\tif (autoFetch) {\n\t\tonMounted(() => {\n\t\t\tfetch();\n\t\t});\n\t}\n\n\treturn {\n\t\tusers,\n\t\tloading,\n\t\terror,\n\t\trefetch: fetch,\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 { ref, computed, onMounted, type Ref, type ComputedRef } from \"vue\";\nimport { generateClient } from \"../client\";\nimport type { Product } from \"@htlkg/core/types\";\n\nexport interface UseProductsOptions {\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 * 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(\n\toptions: UseProductsOptions = {},\n): UseProductsReturn {\n\tconst { filter: baseFilter, limit, autoFetch = true, activeOnly } = options;\n\n\t// State\n\tconst products = ref<Product[]>([]);\n\tconst loading = ref(false);\n\tconst error = ref<Error | null>(null);\n\n\t// Build filter\n\tlet filter: any = baseFilter || {};\n\n\tif (activeOnly) {\n\t\tfilter = { ...filter, isActive: { eq: true } };\n\t}\n\n\t// Computed\n\tconst activeProducts = computed(() =>\n\t\tproducts.value.filter((p) => p.isActive === true),\n\t);\n\n\t// Fetch function\n\tasync function fetch() {\n\t\tloading.value = true;\n\t\terror.value = null;\n\n\t\ttry {\n\t\t\tconst client = generateClient();\n\t\t\tconst { data, errors } = await (client as any).models.Product.list({\n\t\t\t\tfilter: Object.keys(filter).length > 0 ? filter : undefined,\n\t\t\t\tlimit,\n\t\t\t});\n\n\t\t\tif (errors) {\n\t\t\t\tthrow new Error(errors[0]?.message || \"Failed to fetch products\");\n\t\t\t}\n\n\t\t\tproducts.value = (data || []) as Product[];\n\t\t} catch (e) {\n\t\t\terror.value = e as Error;\n\t\t\tconsole.error(\"[useProducts] Error fetching products:\", e);\n\t\t} finally {\n\t\t\tloading.value = false;\n\t\t}\n\t}\n\n\t// Auto-fetch on mount if enabled\n\tif (autoFetch) {\n\t\tonMounted(() => {\n\t\t\tfetch();\n\t\t});\n\t}\n\n\treturn {\n\t\tproducts,\n\t\tactiveProducts,\n\t\tloading,\n\t\terror,\n\t\trefetch: fetch,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;AAOA,SAAS,KAAK,UAAU,iBAA6C;;;ACPrE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S,MAC/B,SAAS,MAAM,OAAO,CAAC,MAAM,EAAE,aAAa,IAAI;AAAA,EACjD;AAGA,iBAAe,QAAQ;AACtB,YAAQ,QAAQ;AAChB,UAAM,QAAQ;AAEd,QAAI;AACH,YAAM,SAAS,eAAe;AAC9B,YAAM,EAAE,MAAM,OAAO,IAAI,MAAO,OAAe,OAAO,QAAQ,KAAK;AAAA,QAClE,QAAQ,OAAO,KAAK,MAAM,EAAE,SAAS,IAAI,SAAS;AAAA,QAClD;AAAA,MACD,CAAC;AAED,UAAI,QAAQ;AACX,cAAM,IAAI,MAAM,OAAO,CAAC,GAAG,WAAW,0BAA0B;AAAA,MACjE;AAEA,eAAS,QAAS,QAAQ,CAAC;AAAA,IAC5B,SAAS,GAAG;AACX,YAAM,QAAQ;AACd,cAAQ,MAAM,0CAA0C,CAAC;AAAA,IAC1D,UAAE;AACD,cAAQ,QAAQ;AAAA,IACjB;AAAA,EACD;AAGA,MAAI,WAAW;AACd,IAAAC,WAAU,MAAM;AACf,YAAM;AAAA,IACP,CAAC;AAAA,EACF;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,EACV;AACD;","names":["generateDataClient","ref","onMounted","ref","onMounted","ref","onMounted","ref","onMounted","ref","computed","onMounted","ref","computed","onMounted"]}
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useBrands.ts","../../src/client/index.ts","../../src/client/server.ts","../../src/hooks/useAccounts.ts","../../src/hooks/useUsers.ts","../../src/hooks/useProducts.ts"],"sourcesContent":["/**\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 { ref, computed, onMounted, type Ref, type ComputedRef } from \"vue\";\nimport { generateClient } from \"../client\";\nimport type { Brand } from \"@htlkg/core/types\";\n\nexport interface UseBrandsOptions {\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 * 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(\n\toptions: UseBrandsOptions = {},\n): UseBrandsReturn {\n\tconst {\n\t\tfilter: baseFilter,\n\t\tlimit,\n\t\tautoFetch = true,\n\t\taccountId,\n\t\tactiveOnly,\n\t} = options;\n\n\t// State\n\tconst brands = ref<Brand[]>([]);\n\tconst loading = ref(false);\n\tconst error = ref<Error | null>(null);\n\n\t// Build filter\n\tlet filter: any = baseFilter || {};\n\n\tif (accountId) {\n\t\tfilter = { ...filter, accountId: { eq: accountId } };\n\t}\n\n\tif (activeOnly) {\n\t\tfilter = { ...filter, status: { eq: \"active\" } };\n\t}\n\n\t// Computed\n\tconst activeBrands = computed(() =>\n\t\tbrands.value.filter((b) => b.status === \"active\"),\n\t);\n\n\t// Fetch function\n\tasync function fetch() {\n\t\tloading.value = true;\n\t\terror.value = null;\n\n\t\ttry {\n\t\t\tconst client = generateClient();\n\t\t\tconst { data, errors } = await (client as any).models.Brand.list({\n\t\t\t\tfilter: Object.keys(filter).length > 0 ? filter : undefined,\n\t\t\t\tlimit,\n\t\t\t});\n\n\t\t\tif (errors) {\n\t\t\t\tthrow new Error(errors[0]?.message || \"Failed to fetch brands\");\n\t\t\t}\n\n\t\t\tbrands.value = (data || []) as Brand[];\n\t\t} catch (e) {\n\t\t\terror.value = e as Error;\n\t\t\tconsole.error(\"[useBrands] Error fetching brands:\", e);\n\t\t} finally {\n\t\t\tloading.value = false;\n\t\t}\n\t}\n\n\t// Auto-fetch on mount if enabled\n\tif (autoFetch) {\n\t\tonMounted(() => {\n\t\t\tfetch();\n\t\t});\n\t}\n\n\treturn {\n\t\tbrands,\n\t\tactiveBrands,\n\t\tloading,\n\t\terror,\n\t\trefetch: fetch,\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\nimport { generateClient as generateDataClient } from \"aws-amplify/data\";\nimport type { ResourcesConfig } from \"aws-amplify\";\n\n// Re-export server-side client generation\nexport { generateServerClientUsingCookies } from \"./server\";\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\t\n\treturn client;\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 * 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 { ref, onMounted, type Ref } from \"vue\";\nimport { generateClient } from \"../client\";\nimport type { Account } from \"@htlkg/core/types\";\n\nexport interface UseAccountsOptions {\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 * 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(\n\toptions: UseAccountsOptions = {},\n): UseAccountsReturn {\n\tconst { filter, limit, autoFetch = true } = options;\n\n\t// State\n\tconst accounts = ref<Account[]>([]);\n\tconst loading = ref(false);\n\tconst error = ref<Error | null>(null);\n\n\t// Fetch function\n\tasync function fetch() {\n\t\tloading.value = true;\n\t\terror.value = null;\n\n\t\ttry {\n\t\t\tconst client = generateClient();\n\t\t\tconst { data, errors } = await (client as any).models.Account.list({\n\t\t\t\tfilter,\n\t\t\t\tlimit,\n\t\t\t});\n\n\t\t\tif (errors) {\n\t\t\t\tthrow new Error(errors[0]?.message || \"Failed to fetch accounts\");\n\t\t\t}\n\n\t\t\taccounts.value = (data || []) as Account[];\n\t\t} catch (e) {\n\t\t\terror.value = e as Error;\n\t\t\tconsole.error(\"[useAccounts] Error fetching accounts:\", e);\n\t\t} finally {\n\t\t\tloading.value = false;\n\t\t}\n\t}\n\n\t// Auto-fetch on mount if enabled\n\tif (autoFetch) {\n\t\tonMounted(() => {\n\t\t\tfetch();\n\t\t});\n\t}\n\n\treturn {\n\t\taccounts,\n\t\tloading,\n\t\terror,\n\t\trefetch: fetch,\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 { ref, onMounted, type Ref } from \"vue\";\nimport { generateClient } from \"../client\";\nimport type { User } from \"@htlkg/core/types\";\n\nexport interface UseUsersOptions {\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 * 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 { filter: baseFilter, limit, autoFetch = true, brandId, accountId } = options;\n\n\t// State\n\tconst users = ref<User[]>([]);\n\tconst loading = ref(false);\n\tconst error = ref<Error | null>(null);\n\n\t// Build filter\n\tlet filter: any = baseFilter || {};\n\n\tif (brandId) {\n\t\tfilter = { ...filter, brandIds: { contains: brandId } };\n\t}\n\n\tif (accountId) {\n\t\tfilter = { ...filter, accountIds: { contains: accountId } };\n\t}\n\n\t// Fetch function\n\tasync function fetch() {\n\t\tloading.value = true;\n\t\terror.value = null;\n\n\t\ttry {\n\t\t\tconst client = generateClient();\n\t\t\tconst { data, errors } = await (client as any).models.User.list({\n\t\t\t\tfilter: Object.keys(filter).length > 0 ? filter : undefined,\n\t\t\t\tlimit,\n\t\t\t});\n\n\t\t\tif (errors) {\n\t\t\t\tthrow new Error(errors[0]?.message || \"Failed to fetch users\");\n\t\t\t}\n\n\t\t\tusers.value = (data || []) as User[];\n\t\t} catch (e) {\n\t\t\terror.value = e as Error;\n\t\t\tconsole.error(\"[useUsers] Error fetching users:\", e);\n\t\t} finally {\n\t\t\tloading.value = false;\n\t\t}\n\t}\n\n\t// Auto-fetch on mount if enabled\n\tif (autoFetch) {\n\t\tonMounted(() => {\n\t\t\tfetch();\n\t\t});\n\t}\n\n\treturn {\n\t\tusers,\n\t\tloading,\n\t\terror,\n\t\trefetch: fetch,\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 { ref, computed, onMounted, type Ref, type ComputedRef } from \"vue\";\nimport { generateClient } from \"../client\";\nimport type { Product } from \"@htlkg/core/types\";\n\nexport interface UseProductsOptions {\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 * 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(\n\toptions: UseProductsOptions = {},\n): UseProductsReturn {\n\tconst { filter: baseFilter, limit, autoFetch = true, activeOnly } = options;\n\n\t// State\n\tconst products = ref<Product[]>([]);\n\tconst loading = ref(false);\n\tconst error = ref<Error | null>(null);\n\n\t// Build filter\n\tlet filter: any = baseFilter || {};\n\n\tif (activeOnly) {\n\t\tfilter = { ...filter, isActive: { eq: true } };\n\t}\n\n\t// Computed\n\tconst activeProducts = computed(() =>\n\t\tproducts.value.filter((p) => p.isActive === true),\n\t);\n\n\t// Fetch function\n\tasync function fetch() {\n\t\tloading.value = true;\n\t\terror.value = null;\n\n\t\ttry {\n\t\t\tconst client = generateClient();\n\t\t\tconst { data, errors } = await (client as any).models.Product.list({\n\t\t\t\tfilter: Object.keys(filter).length > 0 ? filter : undefined,\n\t\t\t\tlimit,\n\t\t\t});\n\n\t\t\tif (errors) {\n\t\t\t\tthrow new Error(errors[0]?.message || \"Failed to fetch products\");\n\t\t\t}\n\n\t\t\tproducts.value = (data || []) as Product[];\n\t\t} catch (e) {\n\t\t\terror.value = e as Error;\n\t\t\tconsole.error(\"[useProducts] Error fetching products:\", e);\n\t\t} finally {\n\t\t\tloading.value = false;\n\t\t}\n\t}\n\n\t// Auto-fetch on mount if enabled\n\tif (autoFetch) {\n\t\tonMounted(() => {\n\t\t\tfetch();\n\t\t});\n\t}\n\n\treturn {\n\t\tproducts,\n\t\tactiveProducts,\n\t\tloading,\n\t\terror,\n\t\trefetch: fetch,\n\t};\n}\n"],"mappings":";AAOA,SAAS,KAAK,UAAU,iBAA6C;;;ACArE,SAAS,kBAAkB,0BAA0B;;;ACErD;AAAA,EAIC;AAAA,OACM;AACP,SAAS,+BAA+B;AACxC,SAAS,mCAAmC,oBAAoB;AAEhE,IAAM,MAAM,aAAa,eAAe;;;ADQjC,SAAS,iBAEoC;AACnD,SAAO,mBAA4B;AACpC;;;AD0BO,SAAS,UACf,UAA4B,CAAC,GACX;AAClB,QAAM;AAAA,IACL,QAAQ;AAAA,IACR;AAAA,IACA,YAAY;AAAA,IACZ;AAAA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AAO,IAAI,MAAO,OAAe,OAAO,QAAQ,KAAK;AAAA,QAClE,QAAQ,OAAO,KAAK,MAAM,EAAE,SAAS,IAAI,SAAS;AAAA,QAClD;AAAA,MACD,CAAC;AAED,UAAI,QAAQ;AACX,cAAM,IAAI,MAAM,OAAO,CAAC,GAAG,WAAW,0BAA0B;AAAA,MACjE;AAEA,eAAS,QAAS,QAAQ,CAAC;AAAA,IAC5B,SAAS,GAAG;AACX,YAAM,QAAQ;AACd,cAAQ,MAAM,0CAA0C,CAAC;AAAA,IAC1D,UAAE;AACD,cAAQ,QAAQ;AAAA,IACjB;AAAA,EACD;AAGA,MAAI,WAAW;AACd,IAAAC,WAAU,MAAM;AACf,YAAM;AAAA,IACP,CAAC;AAAA,EACF;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,EACV;AACD;","names":["ref","onMounted","ref","onMounted","ref","onMounted","ref","onMounted","ref","computed","onMounted","ref","computed","onMounted"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export { AstroAmplifyConfig, generateClient, generateServerClient } from './client/index.js';
|
|
2
|
-
export { getAccount, getAccountWithBrands, getBrand, getBrandWithProducts, getProduct, getProductInstance, getUser, getUserByCognitoId, getUserByEmail, listAccounts, listActiveBrands, listActiveProducts, listActiveUsers, listBrands, listBrandsByAccount, listEnabledProductInstancesByBrand, listProductInstancesByAccount, listProductInstancesByBrand, listProducts, listUsers, listUsersByAccount } from './queries/index.js';
|
|
2
|
+
export { executePublicQuery, executeServerQuery, getAccount, getAccountWithBrands, getBrand, getBrandWithProducts, getProduct, getProductInstance, getUser, getUserByCognitoId, getUserByEmail, listAccounts, listActiveBrands, listActiveProducts, listActiveUsers, listBrands, listBrandsByAccount, listEnabledProductInstancesByBrand, listProductInstancesByAccount, listProductInstancesByBrand, listProducts, listUsers, listUsersByAccount } from './queries/index.js';
|
|
3
3
|
export { CreateAccountInput, CreateBrandInput, CreateUserInput, UpdateAccountInput, UpdateBrandInput, UpdateUserInput, createAccount, createBrand, createUser, deleteAccount, deleteBrand, deleteUser, updateAccount, updateBrand, updateUser } from './mutations/index.js';
|
|
4
4
|
export { UseAccountsOptions, UseAccountsReturn, UseBrandsOptions, UseBrandsReturn, UseProductsOptions, UseProductsReturn, UseUsersOptions, UseUsersReturn, useAccounts, useBrands, useProducts, useUsers } from './hooks/index.js';
|
|
5
|
-
import 'astro';
|
|
6
5
|
import 'aws-amplify/data';
|
|
6
|
+
import 'aws-amplify';
|
|
7
|
+
import 'astro';
|
|
8
|
+
import 'aws-amplify/api/internals';
|
|
7
9
|
import '@htlkg/core/types';
|
|
8
10
|
import 'vue';
|
package/dist/index.js
CHANGED
|
@@ -1,30 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
-
}
|
|
11
|
-
return to;
|
|
12
|
-
};
|
|
13
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
1
|
+
// src/client/index.ts
|
|
2
|
+
import { generateClient as generateDataClient } from "aws-amplify/data";
|
|
14
3
|
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
// src/client/server.ts
|
|
5
|
+
import {
|
|
6
|
+
generateClientWithAmplifyInstance
|
|
7
|
+
} from "aws-amplify/api/internals";
|
|
8
|
+
import { getAmplifyServerContext } from "aws-amplify/adapter-core/internals";
|
|
9
|
+
import { createRunWithAmplifyServerContext, createLogger } from "@htlkg/core/amplify-astro-adapter";
|
|
10
|
+
var log = createLogger("server-client");
|
|
19
11
|
|
|
20
12
|
// src/client/index.ts
|
|
21
13
|
function generateClient() {
|
|
22
|
-
return (
|
|
14
|
+
return generateDataClient();
|
|
23
15
|
}
|
|
24
16
|
function generateServerClient(options) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
);
|
|
17
|
+
const client = generateDataClient();
|
|
18
|
+
return client;
|
|
28
19
|
}
|
|
29
20
|
|
|
30
21
|
// src/queries/brands.ts
|
|
@@ -356,6 +347,34 @@ async function listEnabledProductInstancesByBrand(client, brandId, options) {
|
|
|
356
347
|
}
|
|
357
348
|
}
|
|
358
349
|
|
|
350
|
+
// src/queries/server-helpers.ts
|
|
351
|
+
async function executeServerQuery(astro, runWithAmplifyServerContext, operation) {
|
|
352
|
+
const result = await runWithAmplifyServerContext({
|
|
353
|
+
astroServerContext: {
|
|
354
|
+
cookies: astro.cookies,
|
|
355
|
+
request: astro.request
|
|
356
|
+
},
|
|
357
|
+
operation: async (contextSpec) => {
|
|
358
|
+
const client = generateServerClient();
|
|
359
|
+
return await operation(client);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
return result;
|
|
363
|
+
}
|
|
364
|
+
async function executePublicQuery(astro, runWithAmplifyServerContext, operation) {
|
|
365
|
+
const result = await runWithAmplifyServerContext({
|
|
366
|
+
astroServerContext: {
|
|
367
|
+
cookies: astro.cookies,
|
|
368
|
+
request: astro.request
|
|
369
|
+
},
|
|
370
|
+
operation: async (_contextSpec) => {
|
|
371
|
+
const client = generateServerClient({ authMode: "apiKey" });
|
|
372
|
+
return await operation(client);
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
return result;
|
|
376
|
+
}
|
|
377
|
+
|
|
359
378
|
// src/mutations/brands.ts
|
|
360
379
|
async function createBrand(client, input) {
|
|
361
380
|
try {
|
|
@@ -677,6 +696,8 @@ export {
|
|
|
677
696
|
deleteAccount,
|
|
678
697
|
deleteBrand,
|
|
679
698
|
deleteUser,
|
|
699
|
+
executePublicQuery,
|
|
700
|
+
executeServerQuery,
|
|
680
701
|
generateClient,
|
|
681
702
|
generateServerClient,
|
|
682
703
|
getAccount,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../node_modules/.pnpm/aws-amplify@6.15.8/node_modules/aws-amplify/dist/esm/api/index.mjs","../src/client/index.ts","../src/queries/brands.ts","../src/queries/accounts.ts","../src/queries/users.ts","../src/queries/products.ts","../src/mutations/brands.ts","../src/mutations/accounts.ts","../src/mutations/users.ts","../src/hooks/useBrands.ts","../src/hooks/useAccounts.ts","../src/hooks/useUsers.ts","../src/hooks/useProducts.ts"],"sourcesContent":["export * from '@aws-amplify/api';\n//# sourceMappingURL=index.mjs.map\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\nimport type { AstroCookies } from \"astro\";\nimport { generateClient as generateDataClient } from \"aws-amplify/data\";\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 Astro adapter\n */\nexport interface AstroAmplifyConfig {\n\tAPI?: {\n\t\tGraphQL?: {\n\t\t\tendpoint: string;\n\t\t\tregion: string;\n\t\t\tdefaultAuthMode: string;\n\t\t};\n\t};\n\tAuth?: {\n\t\tCognito?: {\n\t\t\tuserPoolId: string;\n\t\t\tuserPoolClientId: string;\n\t\t\tidentityPoolId?: string;\n\t\t};\n\t};\n}\n\n/**\n * Generate a server-side GraphQL client with cookie-based authentication\n * Use this in Astro pages and API routes for server-side GraphQL operations\n *\n * Note: This is a placeholder that will be properly implemented once the\n * Amplify Astro adapter is migrated to the modular architecture.\n * For now, import generateServerClient from @htlkg/shared/lib/graphql directly.\n *\n * @example\n * ```typescript\n * import type { Schema } from '../amplify/data/resource';\n * import { generateServerClient } from '@htlkg/data/client';\n * import outputs from '../amplify_outputs.json';\n *\n * const client = generateServerClient<Schema>({\n * cookies: Astro.cookies,\n * config: outputs\n * });\n * const { data: brands } = await client.models.Brand.list();\n * ```\n */\nexport function generateServerClient<\n\tTSchema extends Record<string, unknown> = Record<string, unknown>,\n>(options: { cookies: AstroCookies; config: AstroAmplifyConfig }): any {\n\tthrow new Error(\n\t\t\"[generateServerClient] Not yet implemented in modular architecture. \" +\n\t\t\"Please use generateServerClient from @htlkg/shared/lib/graphql for now. \" +\n\t\t\"This will be properly implemented when the Amplify Astro adapter is migrated.\",\n\t);\n}\n","/**\n * Brand Query Functions\n *\n * Provides query functions for fetching brand data from the GraphQL API.\n */\n\nimport type { Brand } from \"@htlkg/core/types\";\n\n/**\n * Get a single brand by ID\n *\n * @example\n * ```typescript\n * import { getBrand } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brand = await getBrand(client, 'brand-123');\n * ```\n */\nexport async function getBrand<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Brand | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Brand.get({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getBrand] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Brand;\n\t} catch (error) {\n\t\tconsole.error(\"[getBrand] Error fetching brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List all brands with optional filtering\n *\n * @example\n * ```typescript\n * import { listBrands } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brands = await listBrands(client, {\n * filter: { status: { eq: 'active' } }\n * });\n * ```\n */\nexport async function listBrands<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Brand[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (client as any).models.Brand.list(\n\t\t\toptions,\n\t\t);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listBrands] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as Brand[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[listBrands] Error fetching brands:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get a brand with its product instances\n *\n * @example\n * ```typescript\n * import { getBrandWithProducts } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brand = await getBrandWithProducts(client, 'brand-123');\n * ```\n */\nexport async function getBrandWithProducts<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Brand | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Brand.get(\n\t\t\t{ id },\n\t\t\t{\n\t\t\t\tselectionSet: [\n\t\t\t\t\t\"id\",\n\t\t\t\t\t\"name\",\n\t\t\t\t\t\"accountId\",\n\t\t\t\t\t\"logo\",\n\t\t\t\t\t\"timezone\",\n\t\t\t\t\t\"status\",\n\t\t\t\t\t\"settings\",\n\t\t\t\t\t\"productInstances.*\",\n\t\t\t\t],\n\t\t\t},\n\t\t);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getBrandWithProducts] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Brand;\n\t} catch (error) {\n\t\tconsole.error(\"[getBrandWithProducts] Error fetching brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List brands by account ID\n *\n * @example\n * ```typescript\n * import { listBrandsByAccount } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brands = await listBrandsByAccount(client, 'account-123');\n * ```\n */\nexport async function listBrandsByAccount<TClient = any>(\n\tclient: TClient,\n\taccountId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Brand[]; nextToken?: string }> {\n\treturn listBrands(client, {\n\t\tfilter: { accountId: { eq: accountId } },\n\t\t...options,\n\t});\n}\n\n/**\n * List active brands\n *\n * @example\n * ```typescript\n * import { listActiveBrands } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brands = await listActiveBrands(client);\n * ```\n */\nexport async function listActiveBrands<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Brand[]; nextToken?: string }> {\n\treturn listBrands(client, {\n\t\tfilter: { status: { eq: \"active\" } },\n\t\t...options,\n\t});\n}\n","/**\n * Account Query Functions\n *\n * Provides query functions for fetching account data from the GraphQL API.\n */\n\nimport type { Account } from \"@htlkg/core/types\";\n\n/**\n * Get a single account by ID\n *\n * @example\n * ```typescript\n * import { getAccount } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const account = await getAccount(client, 'account-123');\n * ```\n */\nexport async function getAccount<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Account | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Account.get({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getAccount] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Account;\n\t} catch (error) {\n\t\tconsole.error(\"[getAccount] Error fetching account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List all accounts with optional filtering\n *\n * @example\n * ```typescript\n * import { listAccounts } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const accounts = await listAccounts(client);\n * ```\n */\nexport async function listAccounts<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Account[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.Account.list(options);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listAccounts] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as Account[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[listAccounts] Error fetching accounts:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get an account with its brands\n *\n * @example\n * ```typescript\n * import { getAccountWithBrands } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const account = await getAccountWithBrands(client, 'account-123');\n * ```\n */\nexport async function getAccountWithBrands<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Account | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Account.get(\n\t\t\t{ id },\n\t\t\t{\n\t\t\t\tselectionSet: [\n\t\t\t\t\t\"id\",\n\t\t\t\t\t\"name\",\n\t\t\t\t\t\"logo\",\n\t\t\t\t\t\"subscription\",\n\t\t\t\t\t\"settings\",\n\t\t\t\t\t\"brands.*\",\n\t\t\t\t],\n\t\t\t},\n\t\t);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getAccountWithBrands] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Account;\n\t} catch (error) {\n\t\tconsole.error(\"[getAccountWithBrands] Error fetching account:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * User Query Functions\n *\n * Provides query functions for fetching user data from the GraphQL API.\n */\n\nimport type { User } from \"@htlkg/core/types\";\n\n/**\n * Get a single user by ID\n *\n * @example\n * ```typescript\n * import { getUser } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await getUser(client, 'user-123');\n * ```\n */\nexport async function getUser<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.get({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getUser] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as User;\n\t} catch (error) {\n\t\tconsole.error(\"[getUser] Error fetching user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get a user by Cognito ID\n *\n * @example\n * ```typescript\n * import { getUserByCognitoId } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await getUserByCognitoId(client, 'cognito-id-123');\n * ```\n */\nexport async function getUserByCognitoId<TClient = any>(\n\tclient: TClient,\n\tcognitoId: string,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.list({\n\t\t\tfilter: { cognitoId: { eq: cognitoId } },\n\t\t\tlimit: 1,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getUserByCognitoId] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data?.[0] as User | null;\n\t} catch (error) {\n\t\tconsole.error(\"[getUserByCognitoId] Error fetching user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get a user by email\n *\n * @example\n * ```typescript\n * import { getUserByEmail } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await getUserByEmail(client, 'user@example.com');\n * ```\n */\nexport async function getUserByEmail<TClient = any>(\n\tclient: TClient,\n\temail: string,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.list({\n\t\t\tfilter: { email: { eq: email } },\n\t\t\tlimit: 1,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getUserByEmail] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data?.[0] as User | null;\n\t} catch (error) {\n\t\tconsole.error(\"[getUserByEmail] Error fetching user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List all users with optional filtering\n *\n * @example\n * ```typescript\n * import { listUsers } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const users = await listUsers(client, {\n * filter: { status: { eq: 'active' } }\n * });\n * ```\n */\nexport async function listUsers<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: User[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (client as any).models.User.list(\n\t\t\toptions,\n\t\t);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listUsers] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as User[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[listUsers] Error fetching users:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List users by account ID\n *\n * @example\n * ```typescript\n * import { listUsersByAccount } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const users = await listUsersByAccount(client, 'account-123');\n * ```\n */\nexport async function listUsersByAccount<TClient = any>(\n\tclient: TClient,\n\taccountId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: User[]; nextToken?: string }> {\n\treturn listUsers(client, {\n\t\tfilter: { accountId: { eq: accountId } },\n\t\t...options,\n\t});\n}\n\n/**\n * List active users\n *\n * @example\n * ```typescript\n * import { listActiveUsers } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const users = await listActiveUsers(client);\n * ```\n */\nexport async function listActiveUsers<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: User[]; nextToken?: string }> {\n\treturn listUsers(client, {\n\t\tfilter: { status: { eq: \"active\" } },\n\t\t...options,\n\t});\n}\n","/**\n * Product Query Functions\n *\n * Provides query functions for fetching product and product instance data from the GraphQL API.\n */\n\nimport type { Product, ProductInstance } from \"@htlkg/core/types\";\n\n/**\n * Get a single product by ID\n *\n * @example\n * ```typescript\n * import { getProduct } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const product = await getProduct(client, 'product-123');\n * ```\n */\nexport async function getProduct<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Product | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Product.get({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getProduct] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Product;\n\t} catch (error) {\n\t\tconsole.error(\"[getProduct] Error fetching product:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List all products with optional filtering\n *\n * @example\n * ```typescript\n * import { listProducts } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const products = await listProducts(client, {\n * filter: { isActive: { eq: true } }\n * });\n * ```\n */\nexport async function listProducts<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Product[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.Product.list(options);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listProducts] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as Product[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[listProducts] Error fetching products:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List active products\n *\n * @example\n * ```typescript\n * import { listActiveProducts } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const products = await listActiveProducts(client);\n * ```\n */\nexport async function listActiveProducts<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Product[]; nextToken?: string }> {\n\treturn listProducts(client, {\n\t\tfilter: { isActive: { eq: true } },\n\t\t...options,\n\t});\n}\n\n/**\n * Get a single product instance by ID\n *\n * @example\n * ```typescript\n * import { getProductInstance } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instance = await getProductInstance(client, 'instance-123');\n * ```\n */\nexport async function getProductInstance<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<ProductInstance | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.ProductInstance.get({\n\t\t\tid,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getProductInstance] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as ProductInstance;\n\t} catch (error) {\n\t\tconsole.error(\"[getProductInstance] Error fetching product instance:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List product instances by brand ID\n *\n * @example\n * ```typescript\n * import { listProductInstancesByBrand } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instances = await listProductInstancesByBrand(client, 'brand-123');\n * ```\n */\nexport async function listProductInstancesByBrand<TClient = any>(\n\tclient: TClient,\n\tbrandId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: ProductInstance[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.ProductInstance.list({\n\t\t\tfilter: { brandId: { eq: brandId } },\n\t\t\t...options,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listProductInstancesByBrand] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as ProductInstance[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t\"[listProductInstancesByBrand] Error fetching product instances:\",\n\t\t\terror,\n\t\t);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List product instances by account ID\n *\n * @example\n * ```typescript\n * import { listProductInstancesByAccount } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instances = await listProductInstancesByAccount(client, 'account-123');\n * ```\n */\nexport async function listProductInstancesByAccount<TClient = any>(\n\tclient: TClient,\n\taccountId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: ProductInstance[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.ProductInstance.list({\n\t\t\tfilter: { accountId: { eq: accountId } },\n\t\t\t...options,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listProductInstancesByAccount] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as ProductInstance[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t\"[listProductInstancesByAccount] Error fetching product instances:\",\n\t\t\terror,\n\t\t);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List enabled product instances by brand ID\n *\n * @example\n * ```typescript\n * import { listEnabledProductInstancesByBrand } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instances = await listEnabledProductInstancesByBrand(client, 'brand-123');\n * ```\n */\nexport async function listEnabledProductInstancesByBrand<TClient = any>(\n\tclient: TClient,\n\tbrandId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: ProductInstance[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.ProductInstance.list({\n\t\t\tfilter: {\n\t\t\t\tbrandId: { eq: brandId },\n\t\t\t\tenabled: { eq: true },\n\t\t\t},\n\t\t\t...options,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\n\t\t\t\t\"[listEnabledProductInstancesByBrand] GraphQL errors:\",\n\t\t\t\terrors,\n\t\t\t);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as ProductInstance[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t\"[listEnabledProductInstancesByBrand] Error fetching product instances:\",\n\t\t\terror,\n\t\t);\n\t\tthrow error;\n\t}\n}\n","/**\n * Brand Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting brands.\n */\n\nimport type { Brand } from \"@htlkg/core/types\";\n\n/**\n * Input type for creating a brand\n */\nexport interface CreateBrandInput {\n\taccountId: string;\n\tname: string;\n\tlogo?: string;\n\ttimezone?: string;\n\tstatus?: \"active\" | \"inactive\" | \"maintenance\" | \"suspended\";\n\tsettings?: Record<string, any>;\n}\n\n/**\n * Input type for updating a brand\n */\nexport interface UpdateBrandInput {\n\tid: string;\n\tname?: string;\n\tlogo?: string;\n\ttimezone?: string;\n\tstatus?: \"active\" | \"inactive\" | \"maintenance\" | \"suspended\";\n\tsettings?: Record<string, any>;\n}\n\n/**\n * Create a new brand\n *\n * @example\n * ```typescript\n * import { createBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brand = await createBrand(client, {\n * accountId: 'account-123',\n * name: 'My Brand',\n * timezone: 'America/New_York',\n * status: 'active'\n * });\n * ```\n */\nexport async function createBrand<TClient = any>(\n\tclient: TClient,\n\tinput: CreateBrandInput,\n): Promise<Brand | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Brand.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createBrand] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Brand;\n\t} catch (error) {\n\t\tconsole.error(\"[createBrand] Error creating brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing brand\n *\n * @example\n * ```typescript\n * import { updateBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brand = await updateBrand(client, {\n * id: 'brand-123',\n * name: 'Updated Brand Name',\n * status: 'maintenance'\n * });\n * ```\n */\nexport async function updateBrand<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateBrandInput,\n): Promise<Brand | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Brand.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateBrand] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Brand;\n\t} catch (error) {\n\t\tconsole.error(\"[updateBrand] Error updating brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Delete a brand\n *\n * @example\n * ```typescript\n * import { deleteBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteBrand(client, 'brand-123');\n * ```\n */\nexport async function deleteBrand<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Brand.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteBrand] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteBrand] Error deleting brand:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * Account Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting accounts.\n */\n\nimport type { Account } from \"@htlkg/core/types\";\n\n/**\n * Input type for creating an account\n */\nexport interface CreateAccountInput {\n\tname: string;\n\tlogo?: string;\n\tsubscription?: Record<string, any>;\n\tsettings?: Record<string, any>;\n}\n\n/**\n * Input type for updating an account\n */\nexport interface UpdateAccountInput {\n\tid: string;\n\tname?: string;\n\tlogo?: string;\n\tsubscription?: Record<string, any>;\n\tsettings?: Record<string, any>;\n}\n\n/**\n * Create a new account\n *\n * @example\n * ```typescript\n * import { createAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const account = await createAccount(client, {\n * name: 'My Account',\n * subscription: { plan: 'premium' }\n * });\n * ```\n */\nexport async function createAccount<TClient = any>(\n\tclient: TClient,\n\tinput: CreateAccountInput,\n): Promise<Account | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Account.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createAccount] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Account;\n\t} catch (error) {\n\t\tconsole.error(\"[createAccount] Error creating account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing account\n *\n * @example\n * ```typescript\n * import { updateAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const account = await updateAccount(client, {\n * id: 'account-123',\n * name: 'Updated Account Name'\n * });\n * ```\n */\nexport async function updateAccount<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateAccountInput,\n): Promise<Account | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Account.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateAccount] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Account;\n\t} catch (error) {\n\t\tconsole.error(\"[updateAccount] Error updating account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Delete an account\n *\n * @example\n * ```typescript\n * import { deleteAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteAccount(client, 'account-123');\n * ```\n */\nexport async function deleteAccount<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Account.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteAccount] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteAccount] Error deleting account:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * User Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting users.\n */\n\nimport type { User } from \"@htlkg/core/types\";\n\n/**\n * Input type for creating a user\n */\nexport interface CreateUserInput {\n\tcognitoId: string;\n\temail: string;\n\taccountId: string;\n\tbrandIds?: string[];\n\troles?: string[];\n\tpermissions?: Record<string, any>;\n\tstatus?: \"active\" | \"inactive\" | \"pending\" | \"suspended\";\n}\n\n/**\n * Input type for updating a user\n */\nexport interface UpdateUserInput {\n\tid: string;\n\temail?: string;\n\tbrandIds?: string[];\n\troles?: string[];\n\tpermissions?: Record<string, any>;\n\tlastLogin?: string;\n\tstatus?: \"active\" | \"inactive\" | \"pending\" | \"suspended\";\n}\n\n/**\n * Create a new user\n *\n * @example\n * ```typescript\n * import { createUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await createUser(client, {\n * cognitoId: 'cognito-123',\n * email: 'user@example.com',\n * accountId: 'account-123',\n * roles: ['BRAND_ADMIN'],\n * status: 'active'\n * });\n * ```\n */\nexport async function createUser<TClient = any>(\n\tclient: TClient,\n\tinput: CreateUserInput,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createUser] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as User;\n\t} catch (error) {\n\t\tconsole.error(\"[createUser] Error creating user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing user\n *\n * @example\n * ```typescript\n * import { updateUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await updateUser(client, {\n * id: 'user-123',\n * roles: ['BRAND_ADMIN', 'ACCOUNT_ADMIN'],\n * status: 'active'\n * });\n * ```\n */\nexport async function updateUser<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateUserInput,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateUser] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as User;\n\t} catch (error) {\n\t\tconsole.error(\"[updateUser] Error updating user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Delete a user\n *\n * @example\n * ```typescript\n * import { deleteUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteUser(client, 'user-123');\n * ```\n */\nexport async function deleteUser<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.User.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteUser] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteUser] Error deleting user:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * 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 { ref, computed, onMounted, type Ref, type ComputedRef } from \"vue\";\nimport { generateClient } from \"../client\";\nimport type { Brand } from \"@htlkg/core/types\";\n\nexport interface UseBrandsOptions {\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 * 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(\n\toptions: UseBrandsOptions = {},\n): UseBrandsReturn {\n\tconst {\n\t\tfilter: baseFilter,\n\t\tlimit,\n\t\tautoFetch = true,\n\t\taccountId,\n\t\tactiveOnly,\n\t} = options;\n\n\t// State\n\tconst brands = ref<Brand[]>([]);\n\tconst loading = ref(false);\n\tconst error = ref<Error | null>(null);\n\n\t// Build filter\n\tlet filter: any = baseFilter || {};\n\n\tif (accountId) {\n\t\tfilter = { ...filter, accountId: { eq: accountId } };\n\t}\n\n\tif (activeOnly) {\n\t\tfilter = { ...filter, status: { eq: \"active\" } };\n\t}\n\n\t// Computed\n\tconst activeBrands = computed(() =>\n\t\tbrands.value.filter((b) => b.status === \"active\"),\n\t);\n\n\t// Fetch function\n\tasync function fetch() {\n\t\tloading.value = true;\n\t\terror.value = null;\n\n\t\ttry {\n\t\t\tconst client = generateClient();\n\t\t\tconst { data, errors } = await (client as any).models.Brand.list({\n\t\t\t\tfilter: Object.keys(filter).length > 0 ? filter : undefined,\n\t\t\t\tlimit,\n\t\t\t});\n\n\t\t\tif (errors) {\n\t\t\t\tthrow new Error(errors[0]?.message || \"Failed to fetch brands\");\n\t\t\t}\n\n\t\t\tbrands.value = (data || []) as Brand[];\n\t\t} catch (e) {\n\t\t\terror.value = e as Error;\n\t\t\tconsole.error(\"[useBrands] Error fetching brands:\", e);\n\t\t} finally {\n\t\t\tloading.value = false;\n\t\t}\n\t}\n\n\t// Auto-fetch on mount if enabled\n\tif (autoFetch) {\n\t\tonMounted(() => {\n\t\t\tfetch();\n\t\t});\n\t}\n\n\treturn {\n\t\tbrands,\n\t\tactiveBrands,\n\t\tloading,\n\t\terror,\n\t\trefetch: fetch,\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 { ref, onMounted, type Ref } from \"vue\";\nimport { generateClient } from \"../client\";\nimport type { Account } from \"@htlkg/core/types\";\n\nexport interface UseAccountsOptions {\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 * 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(\n\toptions: UseAccountsOptions = {},\n): UseAccountsReturn {\n\tconst { filter, limit, autoFetch = true } = options;\n\n\t// State\n\tconst accounts = ref<Account[]>([]);\n\tconst loading = ref(false);\n\tconst error = ref<Error | null>(null);\n\n\t// Fetch function\n\tasync function fetch() {\n\t\tloading.value = true;\n\t\terror.value = null;\n\n\t\ttry {\n\t\t\tconst client = generateClient();\n\t\t\tconst { data, errors } = await (client as any).models.Account.list({\n\t\t\t\tfilter,\n\t\t\t\tlimit,\n\t\t\t});\n\n\t\t\tif (errors) {\n\t\t\t\tthrow new Error(errors[0]?.message || \"Failed to fetch accounts\");\n\t\t\t}\n\n\t\t\taccounts.value = (data || []) as Account[];\n\t\t} catch (e) {\n\t\t\terror.value = e as Error;\n\t\t\tconsole.error(\"[useAccounts] Error fetching accounts:\", e);\n\t\t} finally {\n\t\t\tloading.value = false;\n\t\t}\n\t}\n\n\t// Auto-fetch on mount if enabled\n\tif (autoFetch) {\n\t\tonMounted(() => {\n\t\t\tfetch();\n\t\t});\n\t}\n\n\treturn {\n\t\taccounts,\n\t\tloading,\n\t\terror,\n\t\trefetch: fetch,\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 { ref, onMounted, type Ref } from \"vue\";\nimport { generateClient } from \"../client\";\nimport type { User } from \"@htlkg/core/types\";\n\nexport interface UseUsersOptions {\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 * 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 { filter: baseFilter, limit, autoFetch = true, brandId, accountId } = options;\n\n\t// State\n\tconst users = ref<User[]>([]);\n\tconst loading = ref(false);\n\tconst error = ref<Error | null>(null);\n\n\t// Build filter\n\tlet filter: any = baseFilter || {};\n\n\tif (brandId) {\n\t\tfilter = { ...filter, brandIds: { contains: brandId } };\n\t}\n\n\tif (accountId) {\n\t\tfilter = { ...filter, accountIds: { contains: accountId } };\n\t}\n\n\t// Fetch function\n\tasync function fetch() {\n\t\tloading.value = true;\n\t\terror.value = null;\n\n\t\ttry {\n\t\t\tconst client = generateClient();\n\t\t\tconst { data, errors } = await (client as any).models.User.list({\n\t\t\t\tfilter: Object.keys(filter).length > 0 ? filter : undefined,\n\t\t\t\tlimit,\n\t\t\t});\n\n\t\t\tif (errors) {\n\t\t\t\tthrow new Error(errors[0]?.message || \"Failed to fetch users\");\n\t\t\t}\n\n\t\t\tusers.value = (data || []) as User[];\n\t\t} catch (e) {\n\t\t\terror.value = e as Error;\n\t\t\tconsole.error(\"[useUsers] Error fetching users:\", e);\n\t\t} finally {\n\t\t\tloading.value = false;\n\t\t}\n\t}\n\n\t// Auto-fetch on mount if enabled\n\tif (autoFetch) {\n\t\tonMounted(() => {\n\t\t\tfetch();\n\t\t});\n\t}\n\n\treturn {\n\t\tusers,\n\t\tloading,\n\t\terror,\n\t\trefetch: fetch,\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 { ref, computed, onMounted, type Ref, type ComputedRef } from \"vue\";\nimport { generateClient } from \"../client\";\nimport type { Product } from \"@htlkg/core/types\";\n\nexport interface UseProductsOptions {\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 * 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(\n\toptions: UseProductsOptions = {},\n): UseProductsReturn {\n\tconst { filter: baseFilter, limit, autoFetch = true, activeOnly } = options;\n\n\t// State\n\tconst products = ref<Product[]>([]);\n\tconst loading = ref(false);\n\tconst error = ref<Error | null>(null);\n\n\t// Build filter\n\tlet filter: any = baseFilter || {};\n\n\tif (activeOnly) {\n\t\tfilter = { ...filter, isActive: { eq: true } };\n\t}\n\n\t// Computed\n\tconst activeProducts = computed(() =>\n\t\tproducts.value.filter((p) => p.isActive === true),\n\t);\n\n\t// Fetch function\n\tasync function fetch() {\n\t\tloading.value = true;\n\t\terror.value = null;\n\n\t\ttry {\n\t\t\tconst client = generateClient();\n\t\t\tconst { data, errors } = await (client as any).models.Product.list({\n\t\t\t\tfilter: Object.keys(filter).length > 0 ? filter : undefined,\n\t\t\t\tlimit,\n\t\t\t});\n\n\t\t\tif (errors) {\n\t\t\t\tthrow new Error(errors[0]?.message || \"Failed to fetch products\");\n\t\t\t}\n\n\t\t\tproducts.value = (data || []) as Product[];\n\t\t} catch (e) {\n\t\t\terror.value = e as Error;\n\t\t\tconsole.error(\"[useProducts] Error fetching products:\", e);\n\t\t} finally {\n\t\t\tloading.value = false;\n\t\t}\n\t}\n\n\t// Auto-fetch on mount if enabled\n\tif (autoFetch) {\n\t\tonMounted(() => {\n\t\t\tfetch();\n\t\t});\n\t}\n\n\treturn {\n\t\tproducts,\n\t\tactiveProducts,\n\t\tloading,\n\t\terror,\n\t\trefetch: fetch,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc;;;ACuBP,SAAS,iBAEoC;AACnD,aAAO,YAAAA,gBAA4B;AACpC;AA2CO,SAAS,qBAEd,SAAqE;AACtE,QAAM,IAAI;AAAA,IACT;AAAA,EAGD;AACD;;;AC1DA,eAAsB,SACrB,QACA,IACwB;AACxB,MAAI;AACH,UAAM,EAAE,MAAM,OAAO,IAAI,MAAO,OAAe,OAAO,MAAM,IAAI,EAAE,GAAG,CAAC;AAEtE,QAAI,QAAQ;AACX,cAAQ,MAAM,8BAA8B,MAAM;AAClD,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,EACR,SAAS,OAAO;AACf,YAAQ,MAAM,oCAAoC,KAAK;AACvD,UAAM;AAAA,EACP;AACD;AAgBA,eAAsB,WACrB,QACA,SAKkD;AAClD,MAAI;AACH,UAAM,EAAE,MAAM,QAAQ,UAAU,IAAI,MAAO,OAAe,OAAO,MAAM;AAAA,MACtE;AAAA,IACD;AAEA,QAAI,QAAQ;AACX,cAAQ,MAAM,gCAAgC,MAAM;AACpD,aAAO,EAAE,OAAO,CAAC,GAAG,WAA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computed","onMounted","ref","computed","onMounted"]}
|
|
1
|
+
{"version":3,"sources":["../src/client/index.ts","../src/client/server.ts","../src/queries/brands.ts","../src/queries/accounts.ts","../src/queries/users.ts","../src/queries/products.ts","../src/queries/server-helpers.ts","../src/mutations/brands.ts","../src/mutations/accounts.ts","../src/mutations/users.ts","../src/hooks/useBrands.ts","../src/hooks/useAccounts.ts","../src/hooks/useUsers.ts","../src/hooks/useProducts.ts"],"sourcesContent":["/**\n * GraphQL Client for @htlkg/data\n *\n * Provides both client-side and server-side GraphQL capabilities using AWS Amplify Data.\n * The server-side functions use the Amplify Astro adapter for proper SSR support.\n */\n\nimport { generateClient as generateDataClient } from \"aws-amplify/data\";\nimport type { ResourcesConfig } from \"aws-amplify\";\n\n// Re-export server-side client generation\nexport { generateServerClientUsingCookies } from \"./server\";\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\t\n\treturn client;\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 * Brand Query Functions\n *\n * Provides query functions for fetching brand data from the GraphQL API.\n */\n\nimport type { Brand } from \"@htlkg/core/types\";\n\n/**\n * Get a single brand by ID\n *\n * @example\n * ```typescript\n * import { getBrand } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brand = await getBrand(client, 'brand-123');\n * ```\n */\nexport async function getBrand<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Brand | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Brand.get({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getBrand] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Brand;\n\t} catch (error) {\n\t\tconsole.error(\"[getBrand] Error fetching brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List all brands with optional filtering\n *\n * @example\n * ```typescript\n * import { listBrands } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brands = await listBrands(client, {\n * filter: { status: { eq: 'active' } }\n * });\n * ```\n */\nexport async function listBrands<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Brand[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (client as any).models.Brand.list(\n\t\t\toptions,\n\t\t);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listBrands] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as Brand[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[listBrands] Error fetching brands:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get a brand with its product instances\n *\n * @example\n * ```typescript\n * import { getBrandWithProducts } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brand = await getBrandWithProducts(client, 'brand-123');\n * ```\n */\nexport async function getBrandWithProducts<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Brand | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Brand.get(\n\t\t\t{ id },\n\t\t\t{\n\t\t\t\tselectionSet: [\n\t\t\t\t\t\"id\",\n\t\t\t\t\t\"name\",\n\t\t\t\t\t\"accountId\",\n\t\t\t\t\t\"logo\",\n\t\t\t\t\t\"timezone\",\n\t\t\t\t\t\"status\",\n\t\t\t\t\t\"settings\",\n\t\t\t\t\t\"productInstances.*\",\n\t\t\t\t],\n\t\t\t},\n\t\t);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getBrandWithProducts] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Brand;\n\t} catch (error) {\n\t\tconsole.error(\"[getBrandWithProducts] Error fetching brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List brands by account ID\n *\n * @example\n * ```typescript\n * import { listBrandsByAccount } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brands = await listBrandsByAccount(client, 'account-123');\n * ```\n */\nexport async function listBrandsByAccount<TClient = any>(\n\tclient: TClient,\n\taccountId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Brand[]; nextToken?: string }> {\n\treturn listBrands(client, {\n\t\tfilter: { accountId: { eq: accountId } },\n\t\t...options,\n\t});\n}\n\n/**\n * List active brands\n *\n * @example\n * ```typescript\n * import { listActiveBrands } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brands = await listActiveBrands(client);\n * ```\n */\nexport async function listActiveBrands<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Brand[]; nextToken?: string }> {\n\treturn listBrands(client, {\n\t\tfilter: { status: { eq: \"active\" } },\n\t\t...options,\n\t});\n}\n","/**\n * Account Query Functions\n *\n * Provides query functions for fetching account data from the GraphQL API.\n */\n\nimport type { Account } from \"@htlkg/core/types\";\n\n/**\n * Get a single account by ID\n *\n * @example\n * ```typescript\n * import { getAccount } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const account = await getAccount(client, 'account-123');\n * ```\n */\nexport async function getAccount<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Account | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Account.get({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getAccount] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Account;\n\t} catch (error) {\n\t\tconsole.error(\"[getAccount] Error fetching account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List all accounts with optional filtering\n *\n * @example\n * ```typescript\n * import { listAccounts } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const accounts = await listAccounts(client);\n * ```\n */\nexport async function listAccounts<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Account[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.Account.list(options);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listAccounts] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as Account[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[listAccounts] Error fetching accounts:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get an account with its brands\n *\n * @example\n * ```typescript\n * import { getAccountWithBrands } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const account = await getAccountWithBrands(client, 'account-123');\n * ```\n */\nexport async function getAccountWithBrands<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Account | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Account.get(\n\t\t\t{ id },\n\t\t\t{\n\t\t\t\tselectionSet: [\n\t\t\t\t\t\"id\",\n\t\t\t\t\t\"name\",\n\t\t\t\t\t\"logo\",\n\t\t\t\t\t\"subscription\",\n\t\t\t\t\t\"settings\",\n\t\t\t\t\t\"brands.*\",\n\t\t\t\t],\n\t\t\t},\n\t\t);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getAccountWithBrands] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Account;\n\t} catch (error) {\n\t\tconsole.error(\"[getAccountWithBrands] Error fetching account:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * User Query Functions\n *\n * Provides query functions for fetching user data from the GraphQL API.\n */\n\nimport type { User } from \"@htlkg/core/types\";\n\n/**\n * Get a single user by ID\n *\n * @example\n * ```typescript\n * import { getUser } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await getUser(client, 'user-123');\n * ```\n */\nexport async function getUser<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.get({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getUser] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as User;\n\t} catch (error) {\n\t\tconsole.error(\"[getUser] Error fetching user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get a user by Cognito ID\n *\n * @example\n * ```typescript\n * import { getUserByCognitoId } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await getUserByCognitoId(client, 'cognito-id-123');\n * ```\n */\nexport async function getUserByCognitoId<TClient = any>(\n\tclient: TClient,\n\tcognitoId: string,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.list({\n\t\t\tfilter: { cognitoId: { eq: cognitoId } },\n\t\t\tlimit: 1,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getUserByCognitoId] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data?.[0] as User | null;\n\t} catch (error) {\n\t\tconsole.error(\"[getUserByCognitoId] Error fetching user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get a user by email\n *\n * @example\n * ```typescript\n * import { getUserByEmail } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await getUserByEmail(client, 'user@example.com');\n * ```\n */\nexport async function getUserByEmail<TClient = any>(\n\tclient: TClient,\n\temail: string,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.list({\n\t\t\tfilter: { email: { eq: email } },\n\t\t\tlimit: 1,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getUserByEmail] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data?.[0] as User | null;\n\t} catch (error) {\n\t\tconsole.error(\"[getUserByEmail] Error fetching user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List all users with optional filtering\n *\n * @example\n * ```typescript\n * import { listUsers } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const users = await listUsers(client, {\n * filter: { status: { eq: 'active' } }\n * });\n * ```\n */\nexport async function listUsers<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: User[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (client as any).models.User.list(\n\t\t\toptions,\n\t\t);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listUsers] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as User[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[listUsers] Error fetching users:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List users by account ID\n *\n * @example\n * ```typescript\n * import { listUsersByAccount } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const users = await listUsersByAccount(client, 'account-123');\n * ```\n */\nexport async function listUsersByAccount<TClient = any>(\n\tclient: TClient,\n\taccountId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: User[]; nextToken?: string }> {\n\treturn listUsers(client, {\n\t\tfilter: { accountId: { eq: accountId } },\n\t\t...options,\n\t});\n}\n\n/**\n * List active users\n *\n * @example\n * ```typescript\n * import { listActiveUsers } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const users = await listActiveUsers(client);\n * ```\n */\nexport async function listActiveUsers<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: User[]; nextToken?: string }> {\n\treturn listUsers(client, {\n\t\tfilter: { status: { eq: \"active\" } },\n\t\t...options,\n\t});\n}\n","/**\n * Product Query Functions\n *\n * Provides query functions for fetching product and product instance data from the GraphQL API.\n */\n\nimport type { Product, ProductInstance } from \"@htlkg/core/types\";\n\n/**\n * Get a single product by ID\n *\n * @example\n * ```typescript\n * import { getProduct } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const product = await getProduct(client, 'product-123');\n * ```\n */\nexport async function getProduct<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<Product | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Product.get({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getProduct] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Product;\n\t} catch (error) {\n\t\tconsole.error(\"[getProduct] Error fetching product:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List all products with optional filtering\n *\n * @example\n * ```typescript\n * import { listProducts } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const products = await listProducts(client, {\n * filter: { isActive: { eq: true } }\n * });\n * ```\n */\nexport async function listProducts<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tfilter?: any;\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Product[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.Product.list(options);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listProducts] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as Product[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[listProducts] Error fetching products:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List active products\n *\n * @example\n * ```typescript\n * import { listActiveProducts } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const products = await listActiveProducts(client);\n * ```\n */\nexport async function listActiveProducts<TClient = any>(\n\tclient: TClient,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: Product[]; nextToken?: string }> {\n\treturn listProducts(client, {\n\t\tfilter: { isActive: { eq: true } },\n\t\t...options,\n\t});\n}\n\n/**\n * Get a single product instance by ID\n *\n * @example\n * ```typescript\n * import { getProductInstance } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instance = await getProductInstance(client, 'instance-123');\n * ```\n */\nexport async function getProductInstance<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<ProductInstance | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.ProductInstance.get({\n\t\t\tid,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getProductInstance] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as ProductInstance;\n\t} catch (error) {\n\t\tconsole.error(\"[getProductInstance] Error fetching product instance:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List product instances by brand ID\n *\n * @example\n * ```typescript\n * import { listProductInstancesByBrand } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instances = await listProductInstancesByBrand(client, 'brand-123');\n * ```\n */\nexport async function listProductInstancesByBrand<TClient = any>(\n\tclient: TClient,\n\tbrandId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: ProductInstance[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.ProductInstance.list({\n\t\t\tfilter: { brandId: { eq: brandId } },\n\t\t\t...options,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listProductInstancesByBrand] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as ProductInstance[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t\"[listProductInstancesByBrand] Error fetching product instances:\",\n\t\t\terror,\n\t\t);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List product instances by account ID\n *\n * @example\n * ```typescript\n * import { listProductInstancesByAccount } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instances = await listProductInstancesByAccount(client, 'account-123');\n * ```\n */\nexport async function listProductInstancesByAccount<TClient = any>(\n\tclient: TClient,\n\taccountId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: ProductInstance[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.ProductInstance.list({\n\t\t\tfilter: { accountId: { eq: accountId } },\n\t\t\t...options,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[listProductInstancesByAccount] GraphQL errors:\", errors);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as ProductInstance[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t\"[listProductInstancesByAccount] Error fetching product instances:\",\n\t\t\terror,\n\t\t);\n\t\tthrow error;\n\t}\n}\n\n/**\n * List enabled product instances by brand ID\n *\n * @example\n * ```typescript\n * import { listEnabledProductInstancesByBrand } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instances = await listEnabledProductInstancesByBrand(client, 'brand-123');\n * ```\n */\nexport async function listEnabledProductInstancesByBrand<TClient = any>(\n\tclient: TClient,\n\tbrandId: string,\n\toptions?: {\n\t\tlimit?: number;\n\t\tnextToken?: string;\n\t},\n): Promise<{ items: ProductInstance[]; nextToken?: string }> {\n\ttry {\n\t\tconst { data, errors, nextToken } = await (\n\t\t\tclient as any\n\t\t).models.ProductInstance.list({\n\t\t\tfilter: {\n\t\t\t\tbrandId: { eq: brandId },\n\t\t\t\tenabled: { eq: true },\n\t\t\t},\n\t\t\t...options,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\n\t\t\t\t\"[listEnabledProductInstancesByBrand] GraphQL errors:\",\n\t\t\t\terrors,\n\t\t\t);\n\t\t\treturn { items: [], nextToken: undefined };\n\t\t}\n\n\t\treturn {\n\t\t\titems: (data || []) as ProductInstance[],\n\t\t\tnextToken,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t\"[listEnabledProductInstancesByBrand] Error fetching product instances:\",\n\t\t\terror,\n\t\t);\n\t\tthrow error;\n\t}\n}\n","/**\n * Server-Side Query Helpers\n *\n * Convenience functions for executing server-side queries in Astro pages.\n * These helpers simplify the common pattern of using runWithAmplifyServerContext.\n */\n\nimport type { AstroGlobal } from \"astro\";\nimport { generateServerClient } from \"../client\";\n\n/**\n * Type for the runWithAmplifyServerContext function\n */\ntype RunWithAmplifyServerContext = (options: {\n\tastroServerContext: {\n\t\tcookies: AstroGlobal[\"cookies\"];\n\t\trequest: AstroGlobal[\"request\"];\n\t};\n\toperation: (contextSpec: unknown) => Promise<unknown>;\n}) => Promise<unknown>;\n\n/**\n * Helper to execute server-side queries in Astro pages\n *\n * This function wraps the common pattern of using runWithAmplifyServerContext\n * with generateServerClient, making it easier to fetch data server-side.\n *\n * **Note**: This requires `createRunWithAmplifyServerContext` from `@htlkg/core/amplify-astro-adapter`.\n * If you need more control, use the full pattern directly.\n *\n * @example\n * ```typescript\n * import type { Schema } from '../amplify/data/resource';\n * import { executeServerQuery } from '@htlkg/data/queries/server-helpers';\n * import { createRunWithAmplifyServerContext } from '@htlkg/core/amplify-astro-adapter';\n * import outputs from '../amplify_outputs.json';\n *\n * const runWithAmplifyServerContext = createRunWithAmplifyServerContext({ config: outputs });\n *\n * const users = await executeServerQuery<Schema>(\n * Astro,\n * runWithAmplifyServerContext,\n * async (client) => {\n * const result = await client.models.User.list();\n * return result.data || [];\n * }\n * );\n * ```\n */\nexport async function executeServerQuery<\n\tTSchema extends Record<string, unknown>,\n\tTResult,\n>(\n\tastro: AstroGlobal,\n\trunWithAmplifyServerContext: RunWithAmplifyServerContext,\n\toperation: (client: ReturnType<typeof generateServerClient<TSchema>>) => Promise<TResult>,\n): Promise<TResult> {\n\tconst result = await runWithAmplifyServerContext({\n\t\tastroServerContext: {\n\t\t\tcookies: astro.cookies,\n\t\t\trequest: astro.request,\n\t\t},\n\t\toperation: async (contextSpec: unknown) => {\n\t\t\tconst client = generateServerClient<TSchema>();\n\t\t\treturn await operation(client);\n\t\t},\n\t});\n\treturn result as TResult;\n}\n\n/**\n * Helper to execute server-side queries with API key authentication (public data)\n *\n * Use this for fetching public data that doesn't require user authentication.\n *\n * @example\n * ```typescript\n * import type { Schema } from '../amplify/data/resource';\n * import { executePublicQuery } from '@htlkg/data/queries/server-helpers';\n * import { createRunWithAmplifyServerContext } from '@htlkg/core/amplify-astro-adapter';\n * import outputs from '../amplify_outputs.json';\n *\n * const runWithAmplifyServerContext = createRunWithAmplifyServerContext({ config: outputs });\n *\n * const brands = await executePublicQuery<Schema>(\n * Astro,\n * runWithAmplifyServerContext,\n * async (client) => {\n * const result = await client.models.Brand.list();\n * return result.data || [];\n * }\n * );\n * ```\n */\nexport async function executePublicQuery<\n\tTSchema extends Record<string, unknown>,\n\tTResult,\n>(\n\tastro: AstroGlobal,\n\trunWithAmplifyServerContext: RunWithAmplifyServerContext,\n\toperation: (client: ReturnType<typeof generateServerClient<TSchema>>) => Promise<TResult>,\n): Promise<TResult> {\n\tconst result = await runWithAmplifyServerContext({\n\t\tastroServerContext: {\n\t\t\tcookies: astro.cookies,\n\t\t\trequest: astro.request,\n\t\t},\n\t\toperation: async (_contextSpec: unknown) => {\n\t\t\tconst client = generateServerClient<TSchema>({ authMode: \"apiKey\" });\n\t\t\treturn await operation(client);\n\t\t},\n\t});\n\treturn result as TResult;\n}\n","/**\n * Brand Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting brands.\n */\n\nimport type { Brand } from \"@htlkg/core/types\";\n\n/**\n * Input type for creating a brand\n */\nexport interface CreateBrandInput {\n\taccountId: string;\n\tname: string;\n\tlogo?: string;\n\ttimezone?: string;\n\tstatus?: \"active\" | \"inactive\" | \"maintenance\" | \"suspended\";\n\tsettings?: Record<string, any>;\n}\n\n/**\n * Input type for updating a brand\n */\nexport interface UpdateBrandInput {\n\tid: string;\n\tname?: string;\n\tlogo?: string;\n\ttimezone?: string;\n\tstatus?: \"active\" | \"inactive\" | \"maintenance\" | \"suspended\";\n\tsettings?: Record<string, any>;\n}\n\n/**\n * Create a new brand\n *\n * @example\n * ```typescript\n * import { createBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brand = await createBrand(client, {\n * accountId: 'account-123',\n * name: 'My Brand',\n * timezone: 'America/New_York',\n * status: 'active'\n * });\n * ```\n */\nexport async function createBrand<TClient = any>(\n\tclient: TClient,\n\tinput: CreateBrandInput,\n): Promise<Brand | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Brand.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createBrand] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Brand;\n\t} catch (error) {\n\t\tconsole.error(\"[createBrand] Error creating brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing brand\n *\n * @example\n * ```typescript\n * import { updateBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brand = await updateBrand(client, {\n * id: 'brand-123',\n * name: 'Updated Brand Name',\n * status: 'maintenance'\n * });\n * ```\n */\nexport async function updateBrand<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateBrandInput,\n): Promise<Brand | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Brand.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateBrand] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Brand;\n\t} catch (error) {\n\t\tconsole.error(\"[updateBrand] Error updating brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Delete a brand\n *\n * @example\n * ```typescript\n * import { deleteBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteBrand(client, 'brand-123');\n * ```\n */\nexport async function deleteBrand<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Brand.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteBrand] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteBrand] Error deleting brand:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * Account Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting accounts.\n */\n\nimport type { Account } from \"@htlkg/core/types\";\n\n/**\n * Input type for creating an account\n */\nexport interface CreateAccountInput {\n\tname: string;\n\tlogo?: string;\n\tsubscription?: Record<string, any>;\n\tsettings?: Record<string, any>;\n}\n\n/**\n * Input type for updating an account\n */\nexport interface UpdateAccountInput {\n\tid: string;\n\tname?: string;\n\tlogo?: string;\n\tsubscription?: Record<string, any>;\n\tsettings?: Record<string, any>;\n}\n\n/**\n * Create a new account\n *\n * @example\n * ```typescript\n * import { createAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const account = await createAccount(client, {\n * name: 'My Account',\n * subscription: { plan: 'premium' }\n * });\n * ```\n */\nexport async function createAccount<TClient = any>(\n\tclient: TClient,\n\tinput: CreateAccountInput,\n): Promise<Account | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Account.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createAccount] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Account;\n\t} catch (error) {\n\t\tconsole.error(\"[createAccount] Error creating account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing account\n *\n * @example\n * ```typescript\n * import { updateAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const account = await updateAccount(client, {\n * id: 'account-123',\n * name: 'Updated Account Name'\n * });\n * ```\n */\nexport async function updateAccount<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateAccountInput,\n): Promise<Account | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Account.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateAccount] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Account;\n\t} catch (error) {\n\t\tconsole.error(\"[updateAccount] Error updating account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Delete an account\n *\n * @example\n * ```typescript\n * import { deleteAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteAccount(client, 'account-123');\n * ```\n */\nexport async function deleteAccount<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Account.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteAccount] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteAccount] Error deleting account:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * User Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting users.\n */\n\nimport type { User } from \"@htlkg/core/types\";\n\n/**\n * Input type for creating a user\n */\nexport interface CreateUserInput {\n\tcognitoId: string;\n\temail: string;\n\taccountId: string;\n\tbrandIds?: string[];\n\troles?: string[];\n\tpermissions?: Record<string, any>;\n\tstatus?: \"active\" | \"inactive\" | \"pending\" | \"suspended\";\n}\n\n/**\n * Input type for updating a user\n */\nexport interface UpdateUserInput {\n\tid: string;\n\temail?: string;\n\tbrandIds?: string[];\n\troles?: string[];\n\tpermissions?: Record<string, any>;\n\tlastLogin?: string;\n\tstatus?: \"active\" | \"inactive\" | \"pending\" | \"suspended\";\n}\n\n/**\n * Create a new user\n *\n * @example\n * ```typescript\n * import { createUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await createUser(client, {\n * cognitoId: 'cognito-123',\n * email: 'user@example.com',\n * accountId: 'account-123',\n * roles: ['BRAND_ADMIN'],\n * status: 'active'\n * });\n * ```\n */\nexport async function createUser<TClient = any>(\n\tclient: TClient,\n\tinput: CreateUserInput,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createUser] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as User;\n\t} catch (error) {\n\t\tconsole.error(\"[createUser] Error creating user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing user\n *\n * @example\n * ```typescript\n * import { updateUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await updateUser(client, {\n * id: 'user-123',\n * roles: ['BRAND_ADMIN', 'ACCOUNT_ADMIN'],\n * status: 'active'\n * });\n * ```\n */\nexport async function updateUser<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateUserInput,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateUser] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as User;\n\t} catch (error) {\n\t\tconsole.error(\"[updateUser] Error updating user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Delete a user\n *\n * @example\n * ```typescript\n * import { deleteUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteUser(client, 'user-123');\n * ```\n */\nexport async function deleteUser<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.User.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteUser] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteUser] Error deleting user:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * 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 { ref, computed, onMounted, type Ref, type ComputedRef } from \"vue\";\nimport { generateClient } from \"../client\";\nimport type { Brand } from \"@htlkg/core/types\";\n\nexport interface UseBrandsOptions {\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 * 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(\n\toptions: UseBrandsOptions = {},\n): UseBrandsReturn {\n\tconst {\n\t\tfilter: baseFilter,\n\t\tlimit,\n\t\tautoFetch = true,\n\t\taccountId,\n\t\tactiveOnly,\n\t} = options;\n\n\t// State\n\tconst brands = ref<Brand[]>([]);\n\tconst loading = ref(false);\n\tconst error = ref<Error | null>(null);\n\n\t// Build filter\n\tlet filter: any = baseFilter || {};\n\n\tif (accountId) {\n\t\tfilter = { ...filter, accountId: { eq: accountId } };\n\t}\n\n\tif (activeOnly) {\n\t\tfilter = { ...filter, status: { eq: \"active\" } };\n\t}\n\n\t// Computed\n\tconst activeBrands = computed(() =>\n\t\tbrands.value.filter((b) => b.status === \"active\"),\n\t);\n\n\t// Fetch function\n\tasync function fetch() {\n\t\tloading.value = true;\n\t\terror.value = null;\n\n\t\ttry {\n\t\t\tconst client = generateClient();\n\t\t\tconst { data, errors } = await (client as any).models.Brand.list({\n\t\t\t\tfilter: Object.keys(filter).length > 0 ? filter : undefined,\n\t\t\t\tlimit,\n\t\t\t});\n\n\t\t\tif (errors) {\n\t\t\t\tthrow new Error(errors[0]?.message || \"Failed to fetch brands\");\n\t\t\t}\n\n\t\t\tbrands.value = (data || []) as Brand[];\n\t\t} catch (e) {\n\t\t\terror.value = e as Error;\n\t\t\tconsole.error(\"[useBrands] Error fetching brands:\", e);\n\t\t} finally {\n\t\t\tloading.value = false;\n\t\t}\n\t}\n\n\t// Auto-fetch on mount if enabled\n\tif (autoFetch) {\n\t\tonMounted(() => {\n\t\t\tfetch();\n\t\t});\n\t}\n\n\treturn {\n\t\tbrands,\n\t\tactiveBrands,\n\t\tloading,\n\t\terror,\n\t\trefetch: fetch,\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 { ref, onMounted, type Ref } from \"vue\";\nimport { generateClient } from \"../client\";\nimport type { Account } from \"@htlkg/core/types\";\n\nexport interface UseAccountsOptions {\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 * 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(\n\toptions: UseAccountsOptions = {},\n): UseAccountsReturn {\n\tconst { filter, limit, autoFetch = true } = options;\n\n\t// State\n\tconst accounts = ref<Account[]>([]);\n\tconst loading = ref(false);\n\tconst error = ref<Error | null>(null);\n\n\t// Fetch function\n\tasync function fetch() {\n\t\tloading.value = true;\n\t\terror.value = null;\n\n\t\ttry {\n\t\t\tconst client = generateClient();\n\t\t\tconst { data, errors } = await (client as any).models.Account.list({\n\t\t\t\tfilter,\n\t\t\t\tlimit,\n\t\t\t});\n\n\t\t\tif (errors) {\n\t\t\t\tthrow new Error(errors[0]?.message || \"Failed to fetch accounts\");\n\t\t\t}\n\n\t\t\taccounts.value = (data || []) as Account[];\n\t\t} catch (e) {\n\t\t\terror.value = e as Error;\n\t\t\tconsole.error(\"[useAccounts] Error fetching accounts:\", e);\n\t\t} finally {\n\t\t\tloading.value = false;\n\t\t}\n\t}\n\n\t// Auto-fetch on mount if enabled\n\tif (autoFetch) {\n\t\tonMounted(() => {\n\t\t\tfetch();\n\t\t});\n\t}\n\n\treturn {\n\t\taccounts,\n\t\tloading,\n\t\terror,\n\t\trefetch: fetch,\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 { ref, onMounted, type Ref } from \"vue\";\nimport { generateClient } from \"../client\";\nimport type { User } from \"@htlkg/core/types\";\n\nexport interface UseUsersOptions {\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 * 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 { filter: baseFilter, limit, autoFetch = true, brandId, accountId } = options;\n\n\t// State\n\tconst users = ref<User[]>([]);\n\tconst loading = ref(false);\n\tconst error = ref<Error | null>(null);\n\n\t// Build filter\n\tlet filter: any = baseFilter || {};\n\n\tif (brandId) {\n\t\tfilter = { ...filter, brandIds: { contains: brandId } };\n\t}\n\n\tif (accountId) {\n\t\tfilter = { ...filter, accountIds: { contains: accountId } };\n\t}\n\n\t// Fetch function\n\tasync function fetch() {\n\t\tloading.value = true;\n\t\terror.value = null;\n\n\t\ttry {\n\t\t\tconst client = generateClient();\n\t\t\tconst { data, errors } = await (client as any).models.User.list({\n\t\t\t\tfilter: Object.keys(filter).length > 0 ? filter : undefined,\n\t\t\t\tlimit,\n\t\t\t});\n\n\t\t\tif (errors) {\n\t\t\t\tthrow new Error(errors[0]?.message || \"Failed to fetch users\");\n\t\t\t}\n\n\t\t\tusers.value = (data || []) as User[];\n\t\t} catch (e) {\n\t\t\terror.value = e as Error;\n\t\t\tconsole.error(\"[useUsers] Error fetching users:\", e);\n\t\t} finally {\n\t\t\tloading.value = false;\n\t\t}\n\t}\n\n\t// Auto-fetch on mount if enabled\n\tif (autoFetch) {\n\t\tonMounted(() => {\n\t\t\tfetch();\n\t\t});\n\t}\n\n\treturn {\n\t\tusers,\n\t\tloading,\n\t\terror,\n\t\trefetch: fetch,\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 { ref, computed, onMounted, type Ref, type ComputedRef } from \"vue\";\nimport { generateClient } from \"../client\";\nimport type { Product } from \"@htlkg/core/types\";\n\nexport interface UseProductsOptions {\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 * 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(\n\toptions: UseProductsOptions = {},\n): UseProductsReturn {\n\tconst { filter: baseFilter, limit, autoFetch = true, activeOnly } = options;\n\n\t// State\n\tconst products = ref<Product[]>([]);\n\tconst loading = ref(false);\n\tconst error = ref<Error | null>(null);\n\n\t// Build filter\n\tlet filter: any = baseFilter || {};\n\n\tif (activeOnly) {\n\t\tfilter = { ...filter, isActive: { eq: true } };\n\t}\n\n\t// Computed\n\tconst activeProducts = computed(() =>\n\t\tproducts.value.filter((p) => p.isActive === true),\n\t);\n\n\t// Fetch function\n\tasync function fetch() {\n\t\tloading.value = true;\n\t\terror.value = null;\n\n\t\ttry {\n\t\t\tconst client = generateClient();\n\t\t\tconst { data, errors } = await (client as any).models.Product.list({\n\t\t\t\tfilter: Object.keys(filter).length > 0 ? filter : undefined,\n\t\t\t\tlimit,\n\t\t\t});\n\n\t\t\tif (errors) {\n\t\t\t\tthrow new Error(errors[0]?.message || \"Failed to fetch products\");\n\t\t\t}\n\n\t\t\tproducts.value = (data || []) as Product[];\n\t\t} catch (e) {\n\t\t\terror.value = e as Error;\n\t\t\tconsole.error(\"[useProducts] Error fetching products:\", e);\n\t\t} finally {\n\t\t\tloading.value = false;\n\t\t}\n\t}\n\n\t// Auto-fetch on mount if enabled\n\tif (autoFetch) {\n\t\tonMounted(() => {\n\t\t\tfetch();\n\t\t});\n\t}\n\n\treturn {\n\t\tproducts,\n\t\tactiveProducts,\n\t\tloading,\n\t\terror,\n\t\trefetch: fetch,\n\t};\n}\n"],"mappings":";AAOA,SAAS,kBAAkB,0BAA0B;;;ACErD;AAAA,EAIC;AAAA,OACM;AACP,SAAS,+BAA+B;AACxC,SAAS,mCAAmC,oBAAoB;AAEhE,IAAM,MAAM,aAAa,eAAe;;;ADQjC,SAAS,iBAEoC;AACnD,SAAO,mBAA4B;AACpC;AA2EO,SAAS,qBAEd,SAAuF;AAKxF,QAAM,SAAS,mBAA4B;AAE3C,SAAO;AACR;;;AE/FA,eAAsB,SACrB,QACA,IACwB;AACxB,MAAI;AACH,UAAM,EAAE,MAAM,OAAO,IAAI,MAAO,OAAe,OAAO,MAAM,IAAI,EAAE,GAAG,CAAC;AAEtE,QAAI,QAAQ;AACX,cAAQ,MAAM,8BAA8B,MAAM;AAClD,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,EACR,SAAS,OAAO;AACf,YAAQ,MAAM,oCAAoC,KAAK;AACvD,UAAM;AAAA,EACP;AACD;AAgBA,eAAsB,WACrB,QACA,SAKkD;AAClD,MAAI;AACH,UAAM,EAAE,MAAM,QAAQ,UAAU,IAAI,MAAO,OAAe,OAAO,MAAM;AAAA,MACtE;AAAA,IACD;AAEA,QAAI,QAAQ;AACX,cAAQ,MAAM,gC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M,SAAS,eAAe;AAC9B,YAAM,EAAE,MAAM,OAAO,IAAI,MAAO,OAAe,OAAO,QAAQ,KAAK;AAAA,QAClE,QAAQ,OAAO,KAAK,MAAM,EAAE,SAAS,IAAI,SAAS;AAAA,QAClD;AAAA,MACD,CAAC;AAED,UAAI,QAAQ;AACX,cAAM,IAAI,MAAM,OAAO,CAAC,GAAG,WAAW,0BAA0B;AAAA,MACjE;AAEA,eAAS,QAAS,QAAQ,CAAC;AAAA,IAC5B,SAAS,GAAG;AACX,YAAM,QAAQ;AACd,cAAQ,MAAM,0CAA0C,CAAC;AAAA,IAC1D,UAAE;AACD,cAAQ,QAAQ;AAAA,IACjB;AAAA,EACD;AAGA,MAAI,WAAW;AACd,IAAAC,WAAU,MAAM;AACf,YAAM;AAAA,IACP,CAAC;AAAA,EACF;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,EACV;AACD;","names":["ref","onMounted","ref","onMounted","ref","onMounted","ref","onMounted","ref","computed","onMounted","ref","computed","onMounted"]}
|
package/dist/queries/index.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { Brand, Account, User, Product, ProductInstance } from '@htlkg/core/types';
|
|
2
|
+
import { AstroGlobal } from 'astro';
|
|
3
|
+
import { generateServerClient } from '../client/index.js';
|
|
4
|
+
import 'aws-amplify/data';
|
|
5
|
+
import 'aws-amplify';
|
|
6
|
+
import 'aws-amplify/api/internals';
|
|
2
7
|
|
|
3
8
|
/**
|
|
4
9
|
* Brand Query Functions
|
|
@@ -383,4 +388,76 @@ declare function listEnabledProductInstancesByBrand<TClient = any>(client: TClie
|
|
|
383
388
|
nextToken?: string;
|
|
384
389
|
}>;
|
|
385
390
|
|
|
386
|
-
|
|
391
|
+
/**
|
|
392
|
+
* Server-Side Query Helpers
|
|
393
|
+
*
|
|
394
|
+
* Convenience functions for executing server-side queries in Astro pages.
|
|
395
|
+
* These helpers simplify the common pattern of using runWithAmplifyServerContext.
|
|
396
|
+
*/
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Type for the runWithAmplifyServerContext function
|
|
400
|
+
*/
|
|
401
|
+
type RunWithAmplifyServerContext = (options: {
|
|
402
|
+
astroServerContext: {
|
|
403
|
+
cookies: AstroGlobal["cookies"];
|
|
404
|
+
request: AstroGlobal["request"];
|
|
405
|
+
};
|
|
406
|
+
operation: (contextSpec: unknown) => Promise<unknown>;
|
|
407
|
+
}) => Promise<unknown>;
|
|
408
|
+
/**
|
|
409
|
+
* Helper to execute server-side queries in Astro pages
|
|
410
|
+
*
|
|
411
|
+
* This function wraps the common pattern of using runWithAmplifyServerContext
|
|
412
|
+
* with generateServerClient, making it easier to fetch data server-side.
|
|
413
|
+
*
|
|
414
|
+
* **Note**: This requires `createRunWithAmplifyServerContext` from `@htlkg/core/amplify-astro-adapter`.
|
|
415
|
+
* If you need more control, use the full pattern directly.
|
|
416
|
+
*
|
|
417
|
+
* @example
|
|
418
|
+
* ```typescript
|
|
419
|
+
* import type { Schema } from '../amplify/data/resource';
|
|
420
|
+
* import { executeServerQuery } from '@htlkg/data/queries/server-helpers';
|
|
421
|
+
* import { createRunWithAmplifyServerContext } from '@htlkg/core/amplify-astro-adapter';
|
|
422
|
+
* import outputs from '../amplify_outputs.json';
|
|
423
|
+
*
|
|
424
|
+
* const runWithAmplifyServerContext = createRunWithAmplifyServerContext({ config: outputs });
|
|
425
|
+
*
|
|
426
|
+
* const users = await executeServerQuery<Schema>(
|
|
427
|
+
* Astro,
|
|
428
|
+
* runWithAmplifyServerContext,
|
|
429
|
+
* async (client) => {
|
|
430
|
+
* const result = await client.models.User.list();
|
|
431
|
+
* return result.data || [];
|
|
432
|
+
* }
|
|
433
|
+
* );
|
|
434
|
+
* ```
|
|
435
|
+
*/
|
|
436
|
+
declare function executeServerQuery<TSchema extends Record<string, unknown>, TResult>(astro: AstroGlobal, runWithAmplifyServerContext: RunWithAmplifyServerContext, operation: (client: ReturnType<typeof generateServerClient<TSchema>>) => Promise<TResult>): Promise<TResult>;
|
|
437
|
+
/**
|
|
438
|
+
* Helper to execute server-side queries with API key authentication (public data)
|
|
439
|
+
*
|
|
440
|
+
* Use this for fetching public data that doesn't require user authentication.
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* ```typescript
|
|
444
|
+
* import type { Schema } from '../amplify/data/resource';
|
|
445
|
+
* import { executePublicQuery } from '@htlkg/data/queries/server-helpers';
|
|
446
|
+
* import { createRunWithAmplifyServerContext } from '@htlkg/core/amplify-astro-adapter';
|
|
447
|
+
* import outputs from '../amplify_outputs.json';
|
|
448
|
+
*
|
|
449
|
+
* const runWithAmplifyServerContext = createRunWithAmplifyServerContext({ config: outputs });
|
|
450
|
+
*
|
|
451
|
+
* const brands = await executePublicQuery<Schema>(
|
|
452
|
+
* Astro,
|
|
453
|
+
* runWithAmplifyServerContext,
|
|
454
|
+
* async (client) => {
|
|
455
|
+
* const result = await client.models.Brand.list();
|
|
456
|
+
* return result.data || [];
|
|
457
|
+
* }
|
|
458
|
+
* );
|
|
459
|
+
* ```
|
|
460
|
+
*/
|
|
461
|
+
declare function executePublicQuery<TSchema extends Record<string, unknown>, TResult>(astro: AstroGlobal, runWithAmplifyServerContext: RunWithAmplifyServerContext, operation: (client: ReturnType<typeof generateServerClient<TSchema>>) => Promise<TResult>): Promise<TResult>;
|
|
462
|
+
|
|
463
|
+
export { executePublicQuery, executeServerQuery, getAccount, getAccountWithBrands, getBrand, getBrandWithProducts, getProduct, getProductInstance, getUser, getUserByCognitoId, getUserByEmail, listAccounts, listActiveBrands, listActiveProducts, listActiveUsers, listBrands, listBrandsByAccount, listEnabledProductInstancesByBrand, listProductInstancesByAccount, listProductInstancesByBrand, listProducts, listUsers, listUsersByAccount };
|