@htlkg/data 0.0.13 → 0.0.15
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/hooks/index.d.ts +75 -2
- package/dist/hooks/index.js +220 -3
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +224 -3
- package/dist/index.js.map +1 -1
- package/dist/mutations/index.d.ts +1 -0
- package/dist/mutations/index.js +152 -0
- package/dist/mutations/index.js.map +1 -1
- package/dist/productInstances-CzT3NZKU.d.ts +98 -0
- package/package.json +2 -2
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useProductInstances.ts +174 -0
- package/src/mutations/index.ts +10 -0
- package/src/mutations/productInstances/index.ts +14 -0
- package/src/mutations/productInstances/productInstances.integration.test.ts +621 -0
- package/src/mutations/productInstances/productInstances.test.ts +680 -0
- package/src/mutations/productInstances/productInstances.ts +280 -0
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Ref, ComputedRef } from 'vue';
|
|
2
|
-
import { Brand, Account, User, Product } from '@htlkg/core/types';
|
|
2
|
+
import { Brand, Account, User, Product, ProductInstance } from '@htlkg/core/types';
|
|
3
|
+
import { C as CreateProductInstanceInput, U as UpdateProductInstanceInput } from '../productInstances-CzT3NZKU.js';
|
|
3
4
|
export { resetSharedClient as resetClientInstance } from '../client/index.js';
|
|
4
5
|
import 'aws-amplify/data';
|
|
5
6
|
import 'aws-amplify';
|
|
@@ -305,4 +306,76 @@ interface UseProductsReturn {
|
|
|
305
306
|
*/
|
|
306
307
|
declare function useProducts(options?: UseProductsOptions): UseProductsReturn;
|
|
307
308
|
|
|
308
|
-
|
|
309
|
+
/**
|
|
310
|
+
* useProductInstances Hook
|
|
311
|
+
*
|
|
312
|
+
* Vue composable for fetching and managing product instance data with reactive state.
|
|
313
|
+
* Provides loading states, error handling, refetch capabilities, and CRUD operations.
|
|
314
|
+
*/
|
|
315
|
+
|
|
316
|
+
interface UseProductInstancesOptions extends BaseHookOptions {
|
|
317
|
+
/** Filter criteria for product instances */
|
|
318
|
+
filter?: any;
|
|
319
|
+
/** Limit number of results */
|
|
320
|
+
limit?: number;
|
|
321
|
+
/** Auto-fetch on mount (default: true) */
|
|
322
|
+
autoFetch?: boolean;
|
|
323
|
+
/** Filter by brand ID */
|
|
324
|
+
brandId?: string;
|
|
325
|
+
/** Filter by account ID */
|
|
326
|
+
accountId?: string;
|
|
327
|
+
/** Filter by product ID */
|
|
328
|
+
productId?: string;
|
|
329
|
+
/** Only enabled instances */
|
|
330
|
+
enabledOnly?: boolean;
|
|
331
|
+
}
|
|
332
|
+
interface UseProductInstancesReturn {
|
|
333
|
+
/** Reactive array of product instances */
|
|
334
|
+
instances: Ref<ProductInstance[]>;
|
|
335
|
+
/** Computed array of enabled instances only */
|
|
336
|
+
enabledInstances: ComputedRef<ProductInstance[]>;
|
|
337
|
+
/** Loading state */
|
|
338
|
+
loading: Ref<boolean>;
|
|
339
|
+
/** Error state */
|
|
340
|
+
error: Ref<Error | null>;
|
|
341
|
+
/** Refetch product instances */
|
|
342
|
+
refetch: () => Promise<void>;
|
|
343
|
+
/** Create a new product instance */
|
|
344
|
+
createInstance: (input: CreateProductInstanceInput) => Promise<ProductInstance>;
|
|
345
|
+
/** Update an existing product instance */
|
|
346
|
+
updateInstance: (input: UpdateProductInstanceInput) => Promise<ProductInstance>;
|
|
347
|
+
/** Delete a product instance */
|
|
348
|
+
deleteInstance: (id: string) => Promise<boolean>;
|
|
349
|
+
/** Toggle the enabled status of a product instance */
|
|
350
|
+
toggleEnabled: (id: string, enabled: boolean) => Promise<ProductInstance>;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Composable for fetching and managing product instances
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* ```typescript
|
|
357
|
+
* import { useProductInstances } from '@htlkg/data/hooks';
|
|
358
|
+
*
|
|
359
|
+
* const { instances, loading, error, refetch } = useProductInstances();
|
|
360
|
+
* ```
|
|
361
|
+
*
|
|
362
|
+
* @example With filters
|
|
363
|
+
* ```typescript
|
|
364
|
+
* const { instances, enabledInstances, loading } = useProductInstances({
|
|
365
|
+
* brandId: 'brand-123',
|
|
366
|
+
* enabledOnly: true,
|
|
367
|
+
* limit: 50
|
|
368
|
+
* });
|
|
369
|
+
* ```
|
|
370
|
+
*
|
|
371
|
+
* @example For a specific account
|
|
372
|
+
* ```typescript
|
|
373
|
+
* const { instances, loading } = useProductInstances({
|
|
374
|
+
* accountId: 'account-456',
|
|
375
|
+
* autoFetch: true
|
|
376
|
+
* });
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
379
|
+
declare function useProductInstances(options?: UseProductInstancesOptions): UseProductInstancesReturn;
|
|
380
|
+
|
|
381
|
+
export { type BaseHookOptions, type CreateDataHookOptions, type DataHookReturn, type InferHookReturn, type UseAccountsOptions, type UseAccountsReturn, type UseBrandsOptions, type UseBrandsReturn, type UseProductInstancesOptions, type UseProductInstancesReturn, type UseProductsOptions, type UseProductsReturn, type UseUsersOptions, type UseUsersReturn, createDataHook, useAccounts, useBrands, useProductInstances, useProducts, useUsers };
|
package/dist/hooks/index.js
CHANGED
|
@@ -31,7 +31,7 @@ function createDataHook(config) {
|
|
|
31
31
|
defaultLimit,
|
|
32
32
|
selectionSet,
|
|
33
33
|
transform,
|
|
34
|
-
buildFilter:
|
|
34
|
+
buildFilter: buildFilter5,
|
|
35
35
|
computedProperties,
|
|
36
36
|
dataPropertyName = "data"
|
|
37
37
|
} = config;
|
|
@@ -41,8 +41,8 @@ function createDataHook(config) {
|
|
|
41
41
|
const loading = ref(false);
|
|
42
42
|
const error = ref(null);
|
|
43
43
|
const getFilter = () => {
|
|
44
|
-
if (
|
|
45
|
-
return
|
|
44
|
+
if (buildFilter5) {
|
|
45
|
+
return buildFilter5(options);
|
|
46
46
|
}
|
|
47
47
|
return baseFilter && Object.keys(baseFilter).length > 0 ? baseFilter : void 0;
|
|
48
48
|
};
|
|
@@ -196,11 +196,228 @@ function useProducts(options = {}) {
|
|
|
196
196
|
refetch: result.refetch
|
|
197
197
|
};
|
|
198
198
|
}
|
|
199
|
+
|
|
200
|
+
// src/mutations/productInstances/productInstances.ts
|
|
201
|
+
import { getClientUser } from "@htlkg/core/auth";
|
|
202
|
+
import { getCurrentTimestamp } from "@htlkg/core/utils";
|
|
203
|
+
import { AppError } from "@htlkg/core/errors";
|
|
204
|
+
async function getUserIdentifier(fallback = "system") {
|
|
205
|
+
try {
|
|
206
|
+
const user = await getClientUser();
|
|
207
|
+
if (user) {
|
|
208
|
+
return user.email || user.username || fallback;
|
|
209
|
+
}
|
|
210
|
+
return fallback;
|
|
211
|
+
} catch {
|
|
212
|
+
return fallback;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
async function createProductInstance(client, input) {
|
|
216
|
+
try {
|
|
217
|
+
const createInput = {
|
|
218
|
+
productId: input.productId,
|
|
219
|
+
productName: input.productName,
|
|
220
|
+
brandId: input.brandId,
|
|
221
|
+
accountId: input.accountId,
|
|
222
|
+
enabled: input.enabled,
|
|
223
|
+
version: input.version,
|
|
224
|
+
lastUpdated: input.lastUpdated || getCurrentTimestamp(),
|
|
225
|
+
updatedBy: input.updatedBy || await getUserIdentifier()
|
|
226
|
+
};
|
|
227
|
+
if (input.config) {
|
|
228
|
+
createInput.config = JSON.stringify(JSON.parse(JSON.stringify(input.config)));
|
|
229
|
+
}
|
|
230
|
+
console.log("[createProductInstance] Config as string:", createInput.config);
|
|
231
|
+
console.log("[createProductInstance] Config type:", typeof createInput.config);
|
|
232
|
+
const { data, errors } = await client.models.ProductInstance.create(createInput);
|
|
233
|
+
if (errors) {
|
|
234
|
+
console.error("[createProductInstance] GraphQL errors:", errors);
|
|
235
|
+
throw new AppError(
|
|
236
|
+
"Failed to create product instance",
|
|
237
|
+
"PRODUCT_INSTANCE_CREATE_ERROR",
|
|
238
|
+
500,
|
|
239
|
+
{ errors }
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
return data;
|
|
243
|
+
} catch (error) {
|
|
244
|
+
console.error("[createProductInstance] Error creating product instance:", error);
|
|
245
|
+
if (error instanceof AppError) {
|
|
246
|
+
throw error;
|
|
247
|
+
}
|
|
248
|
+
throw new AppError(
|
|
249
|
+
"Failed to create product instance",
|
|
250
|
+
"PRODUCT_INSTANCE_CREATE_ERROR",
|
|
251
|
+
500,
|
|
252
|
+
{ originalError: error }
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
async function updateProductInstance(client, input) {
|
|
257
|
+
try {
|
|
258
|
+
const updateInput = {
|
|
259
|
+
...input,
|
|
260
|
+
lastUpdated: input.lastUpdated || getCurrentTimestamp(),
|
|
261
|
+
updatedBy: input.updatedBy || await getUserIdentifier()
|
|
262
|
+
};
|
|
263
|
+
if (input.config) {
|
|
264
|
+
updateInput.config = JSON.stringify(JSON.parse(JSON.stringify(input.config)));
|
|
265
|
+
}
|
|
266
|
+
const { data, errors } = await client.models.ProductInstance.update(updateInput);
|
|
267
|
+
if (errors) {
|
|
268
|
+
console.error("[updateProductInstance] GraphQL errors:", errors);
|
|
269
|
+
throw new AppError(
|
|
270
|
+
"Failed to update product instance",
|
|
271
|
+
"PRODUCT_INSTANCE_UPDATE_ERROR",
|
|
272
|
+
500,
|
|
273
|
+
{ errors }
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
return data;
|
|
277
|
+
} catch (error) {
|
|
278
|
+
console.error("[updateProductInstance] Error updating product instance:", error);
|
|
279
|
+
if (error instanceof AppError) {
|
|
280
|
+
throw error;
|
|
281
|
+
}
|
|
282
|
+
throw new AppError(
|
|
283
|
+
"Failed to update product instance",
|
|
284
|
+
"PRODUCT_INSTANCE_UPDATE_ERROR",
|
|
285
|
+
500,
|
|
286
|
+
{ originalError: error }
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
async function deleteProductInstance(client, id) {
|
|
291
|
+
try {
|
|
292
|
+
const { errors } = await client.models.ProductInstance.delete({ id });
|
|
293
|
+
if (errors) {
|
|
294
|
+
console.error("[deleteProductInstance] GraphQL errors:", errors);
|
|
295
|
+
throw new AppError(
|
|
296
|
+
"Failed to delete product instance",
|
|
297
|
+
"PRODUCT_INSTANCE_DELETE_ERROR",
|
|
298
|
+
500,
|
|
299
|
+
{ errors }
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
return true;
|
|
303
|
+
} catch (error) {
|
|
304
|
+
console.error("[deleteProductInstance] Error deleting product instance:", error);
|
|
305
|
+
if (error instanceof AppError) {
|
|
306
|
+
throw error;
|
|
307
|
+
}
|
|
308
|
+
throw new AppError(
|
|
309
|
+
"Failed to delete product instance",
|
|
310
|
+
"PRODUCT_INSTANCE_DELETE_ERROR",
|
|
311
|
+
500,
|
|
312
|
+
{ originalError: error }
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
async function toggleProductInstanceEnabled(client, id, enabled) {
|
|
317
|
+
try {
|
|
318
|
+
const { data, errors } = await client.models.ProductInstance.update({
|
|
319
|
+
id,
|
|
320
|
+
enabled,
|
|
321
|
+
lastUpdated: getCurrentTimestamp(),
|
|
322
|
+
updatedBy: await getUserIdentifier()
|
|
323
|
+
});
|
|
324
|
+
if (errors) {
|
|
325
|
+
console.error("[toggleProductInstanceEnabled] GraphQL errors:", errors);
|
|
326
|
+
throw new AppError(
|
|
327
|
+
"Failed to toggle product instance",
|
|
328
|
+
"PRODUCT_INSTANCE_TOGGLE_ERROR",
|
|
329
|
+
500,
|
|
330
|
+
{ errors }
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
return data;
|
|
334
|
+
} catch (error) {
|
|
335
|
+
console.error("[toggleProductInstanceEnabled] Error toggling product instance:", error);
|
|
336
|
+
if (error instanceof AppError) {
|
|
337
|
+
throw error;
|
|
338
|
+
}
|
|
339
|
+
throw new AppError(
|
|
340
|
+
"Failed to toggle product instance",
|
|
341
|
+
"PRODUCT_INSTANCE_TOGGLE_ERROR",
|
|
342
|
+
500,
|
|
343
|
+
{ originalError: error }
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// src/hooks/useProductInstances.ts
|
|
349
|
+
function buildFilter4(options) {
|
|
350
|
+
let filter = options.filter || {};
|
|
351
|
+
if (options.brandId) {
|
|
352
|
+
filter = { ...filter, brandId: { eq: options.brandId } };
|
|
353
|
+
}
|
|
354
|
+
if (options.accountId) {
|
|
355
|
+
filter = { ...filter, accountId: { eq: options.accountId } };
|
|
356
|
+
}
|
|
357
|
+
if (options.productId) {
|
|
358
|
+
filter = { ...filter, productId: { eq: options.productId } };
|
|
359
|
+
}
|
|
360
|
+
if (options.enabledOnly) {
|
|
361
|
+
filter = { ...filter, enabled: { eq: true } };
|
|
362
|
+
}
|
|
363
|
+
return Object.keys(filter).length > 0 ? filter : void 0;
|
|
364
|
+
}
|
|
365
|
+
var useProductInstancesInternal = createDataHook({
|
|
366
|
+
model: "ProductInstance",
|
|
367
|
+
dataPropertyName: "instances",
|
|
368
|
+
buildFilter: buildFilter4,
|
|
369
|
+
computedProperties: {
|
|
370
|
+
enabledInstances: (instances) => instances.filter((i) => i.enabled)
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
function useProductInstances(options = {}) {
|
|
374
|
+
const result = useProductInstancesInternal(options);
|
|
375
|
+
async function createInstance(input) {
|
|
376
|
+
const client = getSharedClient();
|
|
377
|
+
const instance = await createProductInstance(client, input);
|
|
378
|
+
if (!instance) {
|
|
379
|
+
throw new Error("Failed to create product instance");
|
|
380
|
+
}
|
|
381
|
+
return instance;
|
|
382
|
+
}
|
|
383
|
+
async function updateInstance(input) {
|
|
384
|
+
const client = getSharedClient();
|
|
385
|
+
const instance = await updateProductInstance(client, input);
|
|
386
|
+
if (!instance) {
|
|
387
|
+
throw new Error("Failed to update product instance");
|
|
388
|
+
}
|
|
389
|
+
return instance;
|
|
390
|
+
}
|
|
391
|
+
async function deleteInstance(id) {
|
|
392
|
+
const client = getSharedClient();
|
|
393
|
+
return deleteProductInstance(client, id);
|
|
394
|
+
}
|
|
395
|
+
async function toggleEnabled(id, enabled) {
|
|
396
|
+
const client = getSharedClient();
|
|
397
|
+
const instance = await toggleProductInstanceEnabled(client, id, enabled);
|
|
398
|
+
if (!instance) {
|
|
399
|
+
throw new Error("Failed to toggle product instance");
|
|
400
|
+
}
|
|
401
|
+
return instance;
|
|
402
|
+
}
|
|
403
|
+
return {
|
|
404
|
+
instances: result.instances,
|
|
405
|
+
enabledInstances: result.enabledInstances,
|
|
406
|
+
loading: result.loading,
|
|
407
|
+
error: result.error,
|
|
408
|
+
refetch: result.refetch,
|
|
409
|
+
createInstance,
|
|
410
|
+
updateInstance,
|
|
411
|
+
deleteInstance,
|
|
412
|
+
toggleEnabled
|
|
413
|
+
};
|
|
414
|
+
}
|
|
199
415
|
export {
|
|
200
416
|
createDataHook,
|
|
201
417
|
resetSharedClient as resetClientInstance,
|
|
202
418
|
useAccounts,
|
|
203
419
|
useBrands,
|
|
420
|
+
useProductInstances,
|
|
204
421
|
useProducts,
|
|
205
422
|
useUsers
|
|
206
423
|
};
|
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/createDataHook.ts","../../src/client/index.ts","../../src/client/server.ts","../../src/hooks/useBrands.ts","../../src/hooks/useAccounts.ts","../../src/hooks/useUsers.ts","../../src/hooks/useProducts.ts"],"sourcesContent":["/**\n * Data Hook Factory\n *\n * Creates reusable Vue composables for fetching data from GraphQL models.\n * Provides a DRY approach to data fetching with consistent patterns.\n */\n\nimport { ref, computed, onMounted, type Ref, type ComputedRef } from \"vue\";\nimport { getSharedClient, resetSharedClient } from \"../client\";\n\n/**\n * Configuration options for creating a data hook\n */\nexport interface CreateDataHookOptions<T, TOptions extends BaseHookOptions = BaseHookOptions> {\n\t/** The GraphQL model name (e.g., 'Account', 'User', 'Brand') */\n\tmodel: string;\n\t/** Default limit for queries */\n\tdefaultLimit?: number;\n\t/** Selection set for the query (fields to fetch) */\n\tselectionSet?: string[];\n\t/** Transform function to apply to fetched data */\n\ttransform?: (item: any) => T;\n\t/** Build filter from hook options */\n\tbuildFilter?: (options: TOptions) => any;\n\t/** Define computed properties based on the data */\n\tcomputedProperties?: Record<string, (data: T[]) => any>;\n\t/** Plural name for the data property (e.g., 'accounts', 'users') */\n\tdataPropertyName?: string;\n}\n\n/**\n * Base options available to all hooks\n */\nexport interface BaseHookOptions {\n\t/** Filter criteria */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n}\n\n/**\n * Return type for data hooks\n */\nexport interface DataHookReturn<T, TComputed extends Record<string, any> = Record<string, never>> {\n\t/** Reactive array of data */\n\tdata: Ref<T[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch data */\n\trefetch: () => Promise<void>;\n\t/** Computed properties */\n\tcomputed: { [K in keyof TComputed]: ComputedRef<TComputed[K]> };\n}\n\n// Re-export resetSharedClient for testing convenience\nexport { resetSharedClient as resetClientInstance };\n\n/**\n * Creates a reusable data hook for a specific model\n *\n * @example\n * ```typescript\n * // Create a simple hook\n * export const useAccounts = createDataHook<Account>({\n * model: 'Account',\n * dataPropertyName: 'accounts',\n * });\n *\n * // Usage\n * const { data: accounts, loading, error, refetch } = useAccounts();\n * ```\n *\n * @example\n * ```typescript\n * // Create a hook with custom filters and computed properties\n * interface UseBrandsOptions extends BaseHookOptions {\n * accountId?: string;\n * activeOnly?: boolean;\n * }\n *\n * export const useBrands = createDataHook<Brand, UseBrandsOptions>({\n * model: 'Brand',\n * dataPropertyName: 'brands',\n * buildFilter: (options) => {\n * const filter: any = options.filter || {};\n * if (options.accountId) filter.accountId = { eq: options.accountId };\n * if (options.activeOnly) filter.status = { eq: 'active' };\n * return Object.keys(filter).length > 0 ? filter : undefined;\n * },\n * computedProperties: {\n * activeBrands: (brands) => brands.filter(b => b.status === 'active'),\n * },\n * });\n * ```\n */\nexport function createDataHook<\n\tT,\n\tTOptions extends BaseHookOptions = BaseHookOptions,\n\tTComputed extends Record<string, any> = Record<string, never>,\n>(\n\tconfig: CreateDataHookOptions<T, TOptions> & {\n\t\tcomputedProperties?: { [K in keyof TComputed]: (data: T[]) => TComputed[K] };\n\t},\n) {\n\tconst {\n\t\tmodel,\n\t\tdefaultLimit,\n\t\tselectionSet,\n\t\ttransform,\n\t\tbuildFilter,\n\t\tcomputedProperties,\n\t\tdataPropertyName = \"data\",\n\t} = config;\n\n\treturn function useData(options: TOptions = {} as TOptions): DataHookReturn<T, TComputed> & Record<string, any> {\n\t\tconst { filter: baseFilter, limit = defaultLimit, autoFetch = true } = options;\n\n\t\t// State\n\t\tconst data = ref<T[]>([]) as Ref<T[]>;\n\t\tconst loading = ref(false);\n\t\tconst error = ref<Error | null>(null);\n\n\t\t// Build filter using custom builder or default\n\t\tconst getFilter = () => {\n\t\t\tif (buildFilter) {\n\t\t\t\treturn buildFilter(options);\n\t\t\t}\n\t\t\treturn baseFilter && Object.keys(baseFilter).length > 0 ? baseFilter : undefined;\n\t\t};\n\n\t\t// Fetch function\n\t\tasync function fetch() {\n\t\t\tloading.value = true;\n\t\t\terror.value = null;\n\n\t\t\ttry {\n\t\t\t\tconst client = getSharedClient();\n\t\t\t\tconst queryOptions: any = {\n\t\t\t\t\tfilter: getFilter(),\n\t\t\t\t\tlimit,\n\t\t\t\t};\n\n\t\t\t\tif (selectionSet) {\n\t\t\t\t\tqueryOptions.selectionSet = selectionSet;\n\t\t\t\t}\n\n\t\t\t\tconst { data: responseData, errors } = await (client as any).models[model].list(queryOptions);\n\n\t\t\t\tif (errors) {\n\t\t\t\t\tthrow new Error(errors[0]?.message || `Failed to fetch ${model}`);\n\t\t\t\t}\n\n\t\t\t\tconst items = responseData || [];\n\t\t\t\tdata.value = transform ? items.map(transform) : items;\n\t\t\t} catch (e) {\n\t\t\t\terror.value = e as Error;\n\t\t\t\tconsole.error(`[use${model}] Error fetching ${model}:`, e);\n\t\t\t} finally {\n\t\t\t\tloading.value = false;\n\t\t\t}\n\t\t}\n\n\t\t// Create computed properties\n\t\tconst computedRefs: Record<string, ComputedRef<any>> = {};\n\t\tif (computedProperties) {\n\t\t\tfor (const [key, fn] of Object.entries(computedProperties)) {\n\t\t\t\tcomputedRefs[key] = computed(() => fn(data.value));\n\t\t\t}\n\t\t}\n\n\t\t// Auto-fetch on mount if enabled\n\t\tif (autoFetch) {\n\t\t\tonMounted(() => {\n\t\t\t\tfetch();\n\t\t\t});\n\t\t}\n\n\t\t// Build return object\n\t\tconst result: DataHookReturn<T, TComputed> & Record<string, any> = {\n\t\t\tdata,\n\t\t\tloading,\n\t\t\terror,\n\t\t\trefetch: fetch,\n\t\t\tcomputed: computedRefs as { [K in keyof TComputed]: ComputedRef<TComputed[K]> },\n\t\t};\n\n\t\t// Add data property with custom name for backwards compatibility\n\t\tif (dataPropertyName !== \"data\") {\n\t\t\tresult[dataPropertyName] = data;\n\t\t}\n\n\t\t// Add computed properties at top level for backwards compatibility\n\t\tfor (const [key, computedRef] of Object.entries(computedRefs)) {\n\t\t\tresult[key] = computedRef;\n\t\t}\n\n\t\treturn result;\n\t};\n}\n\n/**\n * Type helper to extract the return type of a created hook\n */\nexport type InferHookReturn<THook extends (...args: any[]) => any> = ReturnType<THook>;\n","/**\n * GraphQL 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// Singleton client instance for client-side fetching\nlet sharedClientInstance: any = null;\n\n/**\n * Get or create the shared GraphQL client instance (singleton pattern)\n * Use this for client-side fetching to avoid creating multiple client instances.\n *\n * @example\n * ```typescript\n * const client = getSharedClient<Schema>();\n * const { data } = await client.models.Account.list();\n * ```\n */\nexport function getSharedClient<\n\tTSchema extends Record<string, unknown> = Record<string, unknown>,\n>(): ReturnType<typeof generateDataClient<TSchema>> {\n\tif (!sharedClientInstance) {\n\t\tsharedClientInstance = generateDataClient<TSchema>();\n\t}\n\treturn sharedClientInstance;\n}\n\n/**\n * Reset the shared client instance (useful for testing or auth state changes)\n */\nexport function resetSharedClient(): void {\n\tsharedClientInstance = null;\n}\n\n/**\n * Generate a client-side GraphQL client for use in Vue components and browser contexts\n * This is SSR-safe and should be called within a component's setup function or after hydration\n *\n * @example\n * ```typescript\n * import type { Schema } from '@backend/data/resource';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const { data: brands } = await client.models.Brand.list();\n * ```\n */\nexport function generateClient<\n\tTSchema extends Record<string, unknown> = Record<string, unknown>,\n>(): ReturnType<typeof generateDataClient<TSchema>> {\n\treturn generateDataClient<TSchema>();\n}\n\n/**\n * Configuration for Amplify (matches amplify_outputs.json format)\n */\nexport type AstroAmplifyConfig = ResourcesConfig;\n\n/**\n * Authentication mode for server-side GraphQL client\n */\nexport type ServerAuthMode = 'userPool' | 'apiKey';\n\n/**\n * Options for generating a server-side GraphQL client\n */\nexport interface GenerateServerClientOptions {\n\t/** Authentication mode - 'userPool' (default) uses JWT from cookies, 'apiKey' uses API key */\n\tauthMode?: ServerAuthMode;\n}\n\n/**\n * Generate a server-side GraphQL client for use within runWithAmplifyServerContext\n * \n * This function creates a GraphQL client that can be used for server-side data fetching in Astro.\n * It MUST be called within runWithAmplifyServerContext to access JWT tokens from cookies.\n * \n * The client supports two authentication modes:\n * - 'userPool' (default): Uses JWT tokens from cookies (requires runWithAmplifyServerContext)\n * - 'apiKey': Uses API key for public/unauthenticated requests\n *\n * **Important**: \n * - Amplify.configure() must be called once at app startup (e.g., in amplify-server.ts)\n * - This function must be called INSIDE the operation function of runWithAmplifyServerContext\n * - The context automatically provides the token provider that reads JWT tokens from cookies\n *\n * @example\n * ```typescript\n * // In your Astro page\n * import type { Schema } from '../amplify/data/resource';\n * import { generateServerClient } from '@htlkg/data/client';\n * import { createRunWithAmplifyServerContext } from '@htlkg/core/amplify-astro-adapter';\n * import outputs from '../amplify_outputs.json';\n *\n * const runWithAmplifyServerContext = createRunWithAmplifyServerContext({ config: outputs });\n *\n * // Fetch data with authentication\n * const result = await runWithAmplifyServerContext({\n * astroServerContext: {\n * cookies: Astro.cookies,\n * request: Astro.request\n * },\n * operation: async (contextSpec) => {\n * // Generate client INSIDE the operation\n * const client = generateServerClient<Schema>({ authMode: 'userPool' });\n * return await client.models.User.list();\n * }\n * });\n * \n * const users = result.data || [];\n * ```\n * \n * @example Using API key for public data\n * ```typescript\n * const result = await runWithAmplifyServerContext({\n * astroServerContext: {\n * cookies: Astro.cookies,\n * request: Astro.request\n * },\n * operation: async (contextSpec) => {\n * const client = generateServerClient<Schema>({ authMode: 'apiKey' });\n * return await client.models.Brand.list();\n * }\n * });\n * ```\n */\nexport function generateServerClient<\n\tTSchema extends Record<string, unknown> = Record<string, unknown>,\n>(options?: GenerateServerClientOptions): ReturnType<typeof generateDataClient<TSchema>> {\n\t// Generate the client without authMode parameter\n\t// When called within runWithAmplifyServerContext, it will automatically use the token provider\n\t// from the context (which reads JWT tokens from cookies)\n\t// The authMode should be specified per-operation, not at client creation\n\tconst client = generateDataClient<TSchema>();\n\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 * useBrands Hook\n *\n * Vue composable for fetching and managing brand data with reactive state.\n * Provides loading states, error handling, and refetch capabilities.\n */\n\nimport type { Ref, ComputedRef } from \"vue\";\nimport type { Brand } from \"@htlkg/core/types\";\nimport { createDataHook, type BaseHookOptions } from \"./createDataHook\";\n\nexport interface UseBrandsOptions extends BaseHookOptions {\n\t/** Filter criteria for brands */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n\t/** Filter by account ID */\n\taccountId?: string;\n\t/** Only active brands */\n\tactiveOnly?: boolean;\n}\n\nexport interface UseBrandsReturn {\n\t/** Reactive array of brands */\n\tbrands: Ref<Brand[]>;\n\t/** Computed array of active brands only */\n\tactiveBrands: ComputedRef<Brand[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch brands */\n\trefetch: () => Promise<void>;\n}\n\n/**\n * Build filter from hook options\n */\nfunction buildFilter(options: UseBrandsOptions): any {\n\tlet filter: any = options.filter || {};\n\n\tif (options.accountId) {\n\t\tfilter = { ...filter, accountId: { eq: options.accountId } };\n\t}\n\n\tif (options.activeOnly) {\n\t\tfilter = { ...filter, status: { eq: \"active\" } };\n\t}\n\n\treturn Object.keys(filter).length > 0 ? filter : undefined;\n}\n\n/**\n * Internal hook created by factory\n */\nconst useBrandsInternal = createDataHook<Brand, UseBrandsOptions, { activeBrands: Brand[] }>({\n\tmodel: \"Brand\",\n\tdataPropertyName: \"brands\",\n\tbuildFilter,\n\tcomputedProperties: {\n\t\tactiveBrands: (brands) => brands.filter((b) => b.status === \"active\"),\n\t},\n});\n\n/**\n * Composable for fetching and managing brands\n *\n * @example\n * ```typescript\n * import { useBrands } from '@htlkg/data/hooks';\n *\n * const { brands, loading, error, refetch } = useBrands();\n * ```\n *\n * @example With filters\n * ```typescript\n * const { brands, loading } = useBrands({\n * accountId: 'account-123',\n * activeOnly: true,\n * limit: 50\n * });\n * ```\n */\nexport function useBrands(options: UseBrandsOptions = {}): UseBrandsReturn {\n\tconst result = useBrandsInternal(options);\n\treturn {\n\t\tbrands: result.brands as Ref<Brand[]>,\n\t\tactiveBrands: result.activeBrands as ComputedRef<Brand[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t};\n}\n","/**\n * useAccounts Hook\n *\n * Vue composable for fetching and managing account data with reactive state.\n * Provides loading states, error handling, and refetch capabilities.\n */\n\nimport type { Ref } from \"vue\";\nimport type { Account } from \"@htlkg/core/types\";\nimport { createDataHook, type BaseHookOptions } from \"./createDataHook\";\n\nexport interface UseAccountsOptions extends BaseHookOptions {\n\t/** Filter criteria for accounts */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n}\n\nexport interface UseAccountsReturn {\n\t/** Reactive array of accounts */\n\taccounts: Ref<Account[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch accounts */\n\trefetch: () => Promise<void>;\n}\n\n/**\n * Internal hook created by factory\n */\nconst useAccountsInternal = createDataHook<Account, UseAccountsOptions>({\n\tmodel: \"Account\",\n\tdataPropertyName: \"accounts\",\n});\n\n/**\n * Composable for fetching and managing accounts\n *\n * @example\n * ```typescript\n * import { useAccounts } from '@htlkg/data/hooks';\n *\n * const { accounts, loading, error, refetch } = useAccounts();\n * ```\n *\n * @example With filters\n * ```typescript\n * const { accounts, loading } = useAccounts({\n * filter: { status: { eq: 'active' } },\n * limit: 50\n * });\n * ```\n */\nexport function useAccounts(options: UseAccountsOptions = {}): UseAccountsReturn {\n\tconst result = useAccountsInternal(options);\n\treturn {\n\t\taccounts: result.accounts as Ref<Account[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t};\n}\n","/**\n * useUsers Hook\n *\n * Vue composable for fetching and managing user data with reactive state.\n * Provides loading states, error handling, and refetch capabilities.\n */\n\nimport type { Ref } from \"vue\";\nimport type { User } from \"@htlkg/core/types\";\nimport { createDataHook, type BaseHookOptions } from \"./createDataHook\";\n\nexport interface UseUsersOptions extends BaseHookOptions {\n\t/** Filter criteria for users */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n\t/** Filter by brand ID */\n\tbrandId?: string;\n\t/** Filter by account ID */\n\taccountId?: string;\n}\n\nexport interface UseUsersReturn {\n\t/** Reactive array of users */\n\tusers: Ref<User[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch users */\n\trefetch: () => Promise<void>;\n}\n\n/**\n * Build filter from hook options\n */\nfunction buildFilter(options: UseUsersOptions): any {\n\tlet filter: any = options.filter || {};\n\n\tif (options.brandId) {\n\t\tfilter = { ...filter, brandIds: { contains: options.brandId } };\n\t}\n\n\tif (options.accountId) {\n\t\tfilter = { ...filter, accountIds: { contains: options.accountId } };\n\t}\n\n\treturn Object.keys(filter).length > 0 ? filter : undefined;\n}\n\n/**\n * Internal hook created by factory\n */\nconst useUsersInternal = createDataHook<User, UseUsersOptions>({\n\tmodel: \"User\",\n\tdataPropertyName: \"users\",\n\tbuildFilter,\n});\n\n/**\n * Composable for fetching and managing users\n *\n * @example\n * ```typescript\n * import { useUsers } from '@htlkg/data/hooks';\n *\n * const { users, loading, error, refetch } = useUsers();\n * ```\n *\n * @example With filters\n * ```typescript\n * const { users, loading } = useUsers({\n * brandId: 'brand-123',\n * accountId: 'account-456',\n * limit: 50\n * });\n * ```\n */\nexport function useUsers(options: UseUsersOptions = {}): UseUsersReturn {\n\tconst result = useUsersInternal(options);\n\treturn {\n\t\tusers: result.users as Ref<User[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t};\n}\n","/**\n * useProducts Hook\n *\n * Vue composable for fetching and managing product data with reactive state.\n * Provides loading states, error handling, and refetch capabilities.\n */\n\nimport type { Ref, ComputedRef } from \"vue\";\nimport type { Product } from \"@htlkg/core/types\";\nimport { createDataHook, type BaseHookOptions } from \"./createDataHook\";\n\nexport interface UseProductsOptions extends BaseHookOptions {\n\t/** Filter criteria for products */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n\t/** Only active products */\n\tactiveOnly?: boolean;\n}\n\nexport interface UseProductsReturn {\n\t/** Reactive array of products */\n\tproducts: Ref<Product[]>;\n\t/** Computed array of active products only */\n\tactiveProducts: ComputedRef<Product[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch products */\n\trefetch: () => Promise<void>;\n}\n\n/**\n * Build filter from hook options\n */\nfunction buildFilter(options: UseProductsOptions): any {\n\tlet filter: any = options.filter || {};\n\n\tif (options.activeOnly) {\n\t\tfilter = { ...filter, isActive: { eq: true } };\n\t}\n\n\treturn Object.keys(filter).length > 0 ? filter : undefined;\n}\n\n/**\n * Internal hook created by factory\n */\nconst useProductsInternal = createDataHook<Product, UseProductsOptions, { activeProducts: Product[] }>({\n\tmodel: \"Product\",\n\tdataPropertyName: \"products\",\n\tbuildFilter,\n\tcomputedProperties: {\n\t\tactiveProducts: (products) => products.filter((p) => p.isActive === true),\n\t},\n});\n\n/**\n * Composable for fetching and managing products\n *\n * @example\n * ```typescript\n * import { useProducts } from '@htlkg/data/hooks';\n *\n * const { products, loading, error, refetch } = useProducts();\n * ```\n *\n * @example With filters\n * ```typescript\n * const { products, loading } = useProducts({\n * activeOnly: true,\n * limit: 50\n * });\n * ```\n */\nexport function useProducts(options: UseProductsOptions = {}): UseProductsReturn {\n\tconst result = useProductsInternal(options);\n\treturn {\n\t\tproducts: result.products as Ref<Product[]>,\n\t\tactiveProducts: result.activeProducts as ComputedRef<Product[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t};\n}\n"],"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;;;ADJxC,IAAI,uBAA4B;AAYzB,SAAS,kBAEoC;AACnD,MAAI,CAAC,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AAClD;AAKA,IAAM,sBAAsB,eAA2E;AAAA,EACtG,OAAO;AAAA,EACP,kBAAkB;AAAA,EAClB,aAAAA;AAAA,EACA,oBAAoB;AAAA,IACnB,gBAAgB,CAAC,aAAa,SAAS,OAAO,CAAC,MAAM,EAAE,aAAa,IAAI;AAAA,EACzE;AACD,CAAC;AAoBM,SAAS,YAAY,UAA8B,CAAC,GAAsB;AAChF,QAAM,SAAS,oBAAoB,OAAO;AAC1C,SAAO;AAAA,IACN,UAAU,OAAO;AAAA,IACjB,gBAAgB,OAAO;AAAA,IACvB,SAAS,OAAO;AAAA,IAChB,OAAO,OAAO;AAAA,IACd,SAAS,OAAO;AAAA,EACjB;AACD;","names":["buildFilter","buildFilter","buildFilter"]}
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/createDataHook.ts","../../src/client/index.ts","../../src/client/server.ts","../../src/hooks/useBrands.ts","../../src/hooks/useAccounts.ts","../../src/hooks/useUsers.ts","../../src/hooks/useProducts.ts","../../src/mutations/productInstances/productInstances.ts","../../src/hooks/useProductInstances.ts"],"sourcesContent":["/**\n * Data Hook Factory\n *\n * Creates reusable Vue composables for fetching data from GraphQL models.\n * Provides a DRY approach to data fetching with consistent patterns.\n */\n\nimport { ref, computed, onMounted, type Ref, type ComputedRef } from \"vue\";\nimport { getSharedClient, resetSharedClient } from \"../client\";\n\n/**\n * Configuration options for creating a data hook\n */\nexport interface CreateDataHookOptions<T, TOptions extends BaseHookOptions = BaseHookOptions> {\n\t/** The GraphQL model name (e.g., 'Account', 'User', 'Brand') */\n\tmodel: string;\n\t/** Default limit for queries */\n\tdefaultLimit?: number;\n\t/** Selection set for the query (fields to fetch) */\n\tselectionSet?: string[];\n\t/** Transform function to apply to fetched data */\n\ttransform?: (item: any) => T;\n\t/** Build filter from hook options */\n\tbuildFilter?: (options: TOptions) => any;\n\t/** Define computed properties based on the data */\n\tcomputedProperties?: Record<string, (data: T[]) => any>;\n\t/** Plural name for the data property (e.g., 'accounts', 'users') */\n\tdataPropertyName?: string;\n}\n\n/**\n * Base options available to all hooks\n */\nexport interface BaseHookOptions {\n\t/** Filter criteria */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n}\n\n/**\n * Return type for data hooks\n */\nexport interface DataHookReturn<T, TComputed extends Record<string, any> = Record<string, never>> {\n\t/** Reactive array of data */\n\tdata: Ref<T[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch data */\n\trefetch: () => Promise<void>;\n\t/** Computed properties */\n\tcomputed: { [K in keyof TComputed]: ComputedRef<TComputed[K]> };\n}\n\n// Re-export resetSharedClient for testing convenience\nexport { resetSharedClient as resetClientInstance };\n\n/**\n * Creates a reusable data hook for a specific model\n *\n * @example\n * ```typescript\n * // Create a simple hook\n * export const useAccounts = createDataHook<Account>({\n * model: 'Account',\n * dataPropertyName: 'accounts',\n * });\n *\n * // Usage\n * const { data: accounts, loading, error, refetch } = useAccounts();\n * ```\n *\n * @example\n * ```typescript\n * // Create a hook with custom filters and computed properties\n * interface UseBrandsOptions extends BaseHookOptions {\n * accountId?: string;\n * activeOnly?: boolean;\n * }\n *\n * export const useBrands = createDataHook<Brand, UseBrandsOptions>({\n * model: 'Brand',\n * dataPropertyName: 'brands',\n * buildFilter: (options) => {\n * const filter: any = options.filter || {};\n * if (options.accountId) filter.accountId = { eq: options.accountId };\n * if (options.activeOnly) filter.status = { eq: 'active' };\n * return Object.keys(filter).length > 0 ? filter : undefined;\n * },\n * computedProperties: {\n * activeBrands: (brands) => brands.filter(b => b.status === 'active'),\n * },\n * });\n * ```\n */\nexport function createDataHook<\n\tT,\n\tTOptions extends BaseHookOptions = BaseHookOptions,\n\tTComputed extends Record<string, any> = Record<string, never>,\n>(\n\tconfig: CreateDataHookOptions<T, TOptions> & {\n\t\tcomputedProperties?: { [K in keyof TComputed]: (data: T[]) => TComputed[K] };\n\t},\n) {\n\tconst {\n\t\tmodel,\n\t\tdefaultLimit,\n\t\tselectionSet,\n\t\ttransform,\n\t\tbuildFilter,\n\t\tcomputedProperties,\n\t\tdataPropertyName = \"data\",\n\t} = config;\n\n\treturn function useData(options: TOptions = {} as TOptions): DataHookReturn<T, TComputed> & Record<string, any> {\n\t\tconst { filter: baseFilter, limit = defaultLimit, autoFetch = true } = options;\n\n\t\t// State\n\t\tconst data = ref<T[]>([]) as Ref<T[]>;\n\t\tconst loading = ref(false);\n\t\tconst error = ref<Error | null>(null);\n\n\t\t// Build filter using custom builder or default\n\t\tconst getFilter = () => {\n\t\t\tif (buildFilter) {\n\t\t\t\treturn buildFilter(options);\n\t\t\t}\n\t\t\treturn baseFilter && Object.keys(baseFilter).length > 0 ? baseFilter : undefined;\n\t\t};\n\n\t\t// Fetch function\n\t\tasync function fetch() {\n\t\t\tloading.value = true;\n\t\t\terror.value = null;\n\n\t\t\ttry {\n\t\t\t\tconst client = getSharedClient();\n\t\t\t\tconst queryOptions: any = {\n\t\t\t\t\tfilter: getFilter(),\n\t\t\t\t\tlimit,\n\t\t\t\t};\n\n\t\t\t\tif (selectionSet) {\n\t\t\t\t\tqueryOptions.selectionSet = selectionSet;\n\t\t\t\t}\n\n\t\t\t\tconst { data: responseData, errors } = await (client as any).models[model].list(queryOptions);\n\n\t\t\t\tif (errors) {\n\t\t\t\t\tthrow new Error(errors[0]?.message || `Failed to fetch ${model}`);\n\t\t\t\t}\n\n\t\t\t\tconst items = responseData || [];\n\t\t\t\tdata.value = transform ? items.map(transform) : items;\n\t\t\t} catch (e) {\n\t\t\t\terror.value = e as Error;\n\t\t\t\tconsole.error(`[use${model}] Error fetching ${model}:`, e);\n\t\t\t} finally {\n\t\t\t\tloading.value = false;\n\t\t\t}\n\t\t}\n\n\t\t// Create computed properties\n\t\tconst computedRefs: Record<string, ComputedRef<any>> = {};\n\t\tif (computedProperties) {\n\t\t\tfor (const [key, fn] of Object.entries(computedProperties)) {\n\t\t\t\tcomputedRefs[key] = computed(() => fn(data.value));\n\t\t\t}\n\t\t}\n\n\t\t// Auto-fetch on mount if enabled\n\t\tif (autoFetch) {\n\t\t\tonMounted(() => {\n\t\t\t\tfetch();\n\t\t\t});\n\t\t}\n\n\t\t// Build return object\n\t\tconst result: DataHookReturn<T, TComputed> & Record<string, any> = {\n\t\t\tdata,\n\t\t\tloading,\n\t\t\terror,\n\t\t\trefetch: fetch,\n\t\t\tcomputed: computedRefs as { [K in keyof TComputed]: ComputedRef<TComputed[K]> },\n\t\t};\n\n\t\t// Add data property with custom name for backwards compatibility\n\t\tif (dataPropertyName !== \"data\") {\n\t\t\tresult[dataPropertyName] = data;\n\t\t}\n\n\t\t// Add computed properties at top level for backwards compatibility\n\t\tfor (const [key, computedRef] of Object.entries(computedRefs)) {\n\t\t\tresult[key] = computedRef;\n\t\t}\n\n\t\treturn result;\n\t};\n}\n\n/**\n * Type helper to extract the return type of a created hook\n */\nexport type InferHookReturn<THook extends (...args: any[]) => any> = ReturnType<THook>;\n","/**\n * GraphQL 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// Singleton client instance for client-side fetching\nlet sharedClientInstance: any = null;\n\n/**\n * Get or create the shared GraphQL client instance (singleton pattern)\n * Use this for client-side fetching to avoid creating multiple client instances.\n *\n * @example\n * ```typescript\n * const client = getSharedClient<Schema>();\n * const { data } = await client.models.Account.list();\n * ```\n */\nexport function getSharedClient<\n\tTSchema extends Record<string, unknown> = Record<string, unknown>,\n>(): ReturnType<typeof generateDataClient<TSchema>> {\n\tif (!sharedClientInstance) {\n\t\tsharedClientInstance = generateDataClient<TSchema>();\n\t}\n\treturn sharedClientInstance;\n}\n\n/**\n * Reset the shared client instance (useful for testing or auth state changes)\n */\nexport function resetSharedClient(): void {\n\tsharedClientInstance = null;\n}\n\n/**\n * Generate a client-side GraphQL client for use in Vue components and browser contexts\n * This is SSR-safe and should be called within a component's setup function or after hydration\n *\n * @example\n * ```typescript\n * import type { Schema } from '@backend/data/resource';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const { data: brands } = await client.models.Brand.list();\n * ```\n */\nexport function generateClient<\n\tTSchema extends Record<string, unknown> = Record<string, unknown>,\n>(): ReturnType<typeof generateDataClient<TSchema>> {\n\treturn generateDataClient<TSchema>();\n}\n\n/**\n * Configuration for Amplify (matches amplify_outputs.json format)\n */\nexport type AstroAmplifyConfig = ResourcesConfig;\n\n/**\n * Authentication mode for server-side GraphQL client\n */\nexport type ServerAuthMode = 'userPool' | 'apiKey';\n\n/**\n * Options for generating a server-side GraphQL client\n */\nexport interface GenerateServerClientOptions {\n\t/** Authentication mode - 'userPool' (default) uses JWT from cookies, 'apiKey' uses API key */\n\tauthMode?: ServerAuthMode;\n}\n\n/**\n * Generate a server-side GraphQL client for use within runWithAmplifyServerContext\n * \n * This function creates a GraphQL client that can be used for server-side data fetching in Astro.\n * It MUST be called within runWithAmplifyServerContext to access JWT tokens from cookies.\n * \n * The client supports two authentication modes:\n * - 'userPool' (default): Uses JWT tokens from cookies (requires runWithAmplifyServerContext)\n * - 'apiKey': Uses API key for public/unauthenticated requests\n *\n * **Important**: \n * - Amplify.configure() must be called once at app startup (e.g., in amplify-server.ts)\n * - This function must be called INSIDE the operation function of runWithAmplifyServerContext\n * - The context automatically provides the token provider that reads JWT tokens from cookies\n *\n * @example\n * ```typescript\n * // In your Astro page\n * import type { Schema } from '../amplify/data/resource';\n * import { generateServerClient } from '@htlkg/data/client';\n * import { createRunWithAmplifyServerContext } from '@htlkg/core/amplify-astro-adapter';\n * import outputs from '../amplify_outputs.json';\n *\n * const runWithAmplifyServerContext = createRunWithAmplifyServerContext({ config: outputs });\n *\n * // Fetch data with authentication\n * const result = await runWithAmplifyServerContext({\n * astroServerContext: {\n * cookies: Astro.cookies,\n * request: Astro.request\n * },\n * operation: async (contextSpec) => {\n * // Generate client INSIDE the operation\n * const client = generateServerClient<Schema>({ authMode: 'userPool' });\n * return await client.models.User.list();\n * }\n * });\n * \n * const users = result.data || [];\n * ```\n * \n * @example Using API key for public data\n * ```typescript\n * const result = await runWithAmplifyServerContext({\n * astroServerContext: {\n * cookies: Astro.cookies,\n * request: Astro.request\n * },\n * operation: async (contextSpec) => {\n * const client = generateServerClient<Schema>({ authMode: 'apiKey' });\n * return await client.models.Brand.list();\n * }\n * });\n * ```\n */\nexport function generateServerClient<\n\tTSchema extends Record<string, unknown> = Record<string, unknown>,\n>(options?: GenerateServerClientOptions): ReturnType<typeof generateDataClient<TSchema>> {\n\t// Generate the client without authMode parameter\n\t// When called within runWithAmplifyServerContext, it will automatically use the token provider\n\t// from the context (which reads JWT tokens from cookies)\n\t// The authMode should be specified per-operation, not at client creation\n\tconst client = generateDataClient<TSchema>();\n\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 * useBrands Hook\n *\n * Vue composable for fetching and managing brand data with reactive state.\n * Provides loading states, error handling, and refetch capabilities.\n */\n\nimport type { Ref, ComputedRef } from \"vue\";\nimport type { Brand } from \"@htlkg/core/types\";\nimport { createDataHook, type BaseHookOptions } from \"./createDataHook\";\n\nexport interface UseBrandsOptions extends BaseHookOptions {\n\t/** Filter criteria for brands */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n\t/** Filter by account ID */\n\taccountId?: string;\n\t/** Only active brands */\n\tactiveOnly?: boolean;\n}\n\nexport interface UseBrandsReturn {\n\t/** Reactive array of brands */\n\tbrands: Ref<Brand[]>;\n\t/** Computed array of active brands only */\n\tactiveBrands: ComputedRef<Brand[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch brands */\n\trefetch: () => Promise<void>;\n}\n\n/**\n * Build filter from hook options\n */\nfunction buildFilter(options: UseBrandsOptions): any {\n\tlet filter: any = options.filter || {};\n\n\tif (options.accountId) {\n\t\tfilter = { ...filter, accountId: { eq: options.accountId } };\n\t}\n\n\tif (options.activeOnly) {\n\t\tfilter = { ...filter, status: { eq: \"active\" } };\n\t}\n\n\treturn Object.keys(filter).length > 0 ? filter : undefined;\n}\n\n/**\n * Internal hook created by factory\n */\nconst useBrandsInternal = createDataHook<Brand, UseBrandsOptions, { activeBrands: Brand[] }>({\n\tmodel: \"Brand\",\n\tdataPropertyName: \"brands\",\n\tbuildFilter,\n\tcomputedProperties: {\n\t\tactiveBrands: (brands) => brands.filter((b) => b.status === \"active\"),\n\t},\n});\n\n/**\n * Composable for fetching and managing brands\n *\n * @example\n * ```typescript\n * import { useBrands } from '@htlkg/data/hooks';\n *\n * const { brands, loading, error, refetch } = useBrands();\n * ```\n *\n * @example With filters\n * ```typescript\n * const { brands, loading } = useBrands({\n * accountId: 'account-123',\n * activeOnly: true,\n * limit: 50\n * });\n * ```\n */\nexport function useBrands(options: UseBrandsOptions = {}): UseBrandsReturn {\n\tconst result = useBrandsInternal(options);\n\treturn {\n\t\tbrands: result.brands as Ref<Brand[]>,\n\t\tactiveBrands: result.activeBrands as ComputedRef<Brand[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t};\n}\n","/**\n * useAccounts Hook\n *\n * Vue composable for fetching and managing account data with reactive state.\n * Provides loading states, error handling, and refetch capabilities.\n */\n\nimport type { Ref } from \"vue\";\nimport type { Account } from \"@htlkg/core/types\";\nimport { createDataHook, type BaseHookOptions } from \"./createDataHook\";\n\nexport interface UseAccountsOptions extends BaseHookOptions {\n\t/** Filter criteria for accounts */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n}\n\nexport interface UseAccountsReturn {\n\t/** Reactive array of accounts */\n\taccounts: Ref<Account[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch accounts */\n\trefetch: () => Promise<void>;\n}\n\n/**\n * Internal hook created by factory\n */\nconst useAccountsInternal = createDataHook<Account, UseAccountsOptions>({\n\tmodel: \"Account\",\n\tdataPropertyName: \"accounts\",\n});\n\n/**\n * Composable for fetching and managing accounts\n *\n * @example\n * ```typescript\n * import { useAccounts } from '@htlkg/data/hooks';\n *\n * const { accounts, loading, error, refetch } = useAccounts();\n * ```\n *\n * @example With filters\n * ```typescript\n * const { accounts, loading } = useAccounts({\n * filter: { status: { eq: 'active' } },\n * limit: 50\n * });\n * ```\n */\nexport function useAccounts(options: UseAccountsOptions = {}): UseAccountsReturn {\n\tconst result = useAccountsInternal(options);\n\treturn {\n\t\taccounts: result.accounts as Ref<Account[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t};\n}\n","/**\n * useUsers Hook\n *\n * Vue composable for fetching and managing user data with reactive state.\n * Provides loading states, error handling, and refetch capabilities.\n */\n\nimport type { Ref } from \"vue\";\nimport type { User } from \"@htlkg/core/types\";\nimport { createDataHook, type BaseHookOptions } from \"./createDataHook\";\n\nexport interface UseUsersOptions extends BaseHookOptions {\n\t/** Filter criteria for users */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n\t/** Filter by brand ID */\n\tbrandId?: string;\n\t/** Filter by account ID */\n\taccountId?: string;\n}\n\nexport interface UseUsersReturn {\n\t/** Reactive array of users */\n\tusers: Ref<User[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch users */\n\trefetch: () => Promise<void>;\n}\n\n/**\n * Build filter from hook options\n */\nfunction buildFilter(options: UseUsersOptions): any {\n\tlet filter: any = options.filter || {};\n\n\tif (options.brandId) {\n\t\tfilter = { ...filter, brandIds: { contains: options.brandId } };\n\t}\n\n\tif (options.accountId) {\n\t\tfilter = { ...filter, accountIds: { contains: options.accountId } };\n\t}\n\n\treturn Object.keys(filter).length > 0 ? filter : undefined;\n}\n\n/**\n * Internal hook created by factory\n */\nconst useUsersInternal = createDataHook<User, UseUsersOptions>({\n\tmodel: \"User\",\n\tdataPropertyName: \"users\",\n\tbuildFilter,\n});\n\n/**\n * Composable for fetching and managing users\n *\n * @example\n * ```typescript\n * import { useUsers } from '@htlkg/data/hooks';\n *\n * const { users, loading, error, refetch } = useUsers();\n * ```\n *\n * @example With filters\n * ```typescript\n * const { users, loading } = useUsers({\n * brandId: 'brand-123',\n * accountId: 'account-456',\n * limit: 50\n * });\n * ```\n */\nexport function useUsers(options: UseUsersOptions = {}): UseUsersReturn {\n\tconst result = useUsersInternal(options);\n\treturn {\n\t\tusers: result.users as Ref<User[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t};\n}\n","/**\n * useProducts Hook\n *\n * Vue composable for fetching and managing product data with reactive state.\n * Provides loading states, error handling, and refetch capabilities.\n */\n\nimport type { Ref, ComputedRef } from \"vue\";\nimport type { Product } from \"@htlkg/core/types\";\nimport { createDataHook, type BaseHookOptions } from \"./createDataHook\";\n\nexport interface UseProductsOptions extends BaseHookOptions {\n\t/** Filter criteria for products */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n\t/** Only active products */\n\tactiveOnly?: boolean;\n}\n\nexport interface UseProductsReturn {\n\t/** Reactive array of products */\n\tproducts: Ref<Product[]>;\n\t/** Computed array of active products only */\n\tactiveProducts: ComputedRef<Product[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch products */\n\trefetch: () => Promise<void>;\n}\n\n/**\n * Build filter from hook options\n */\nfunction buildFilter(options: UseProductsOptions): any {\n\tlet filter: any = options.filter || {};\n\n\tif (options.activeOnly) {\n\t\tfilter = { ...filter, isActive: { eq: true } };\n\t}\n\n\treturn Object.keys(filter).length > 0 ? filter : undefined;\n}\n\n/**\n * Internal hook created by factory\n */\nconst useProductsInternal = createDataHook<Product, UseProductsOptions, { activeProducts: Product[] }>({\n\tmodel: \"Product\",\n\tdataPropertyName: \"products\",\n\tbuildFilter,\n\tcomputedProperties: {\n\t\tactiveProducts: (products) => products.filter((p) => p.isActive === true),\n\t},\n});\n\n/**\n * Composable for fetching and managing products\n *\n * @example\n * ```typescript\n * import { useProducts } from '@htlkg/data/hooks';\n *\n * const { products, loading, error, refetch } = useProducts();\n * ```\n *\n * @example With filters\n * ```typescript\n * const { products, loading } = useProducts({\n * activeOnly: true,\n * limit: 50\n * });\n * ```\n */\nexport function useProducts(options: UseProductsOptions = {}): UseProductsReturn {\n\tconst result = useProductsInternal(options);\n\treturn {\n\t\tproducts: result.products as Ref<Product[]>,\n\t\tactiveProducts: result.activeProducts as ComputedRef<Product[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t};\n}\n","/**\n * ProductInstance Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting product instances.\n * Product instances represent enabled products for a specific brand with their configuration.\n */\n\nimport type { ProductInstance } from \"@htlkg/core/types\";\nimport { getClientUser } from \"@htlkg/core/auth\";\nimport { getCurrentTimestamp } from \"@htlkg/core/utils\";\nimport { AppError } from \"@htlkg/core/errors\";\n\n/**\n * Get current user identifier for audit trails\n * Uses getClientUser() and returns email or username, falling back to \"system\"\n */\nasync function getUserIdentifier(fallback = \"system\"): Promise<string> {\n\ttry {\n\t\tconst user = await getClientUser();\n\t\tif (user) {\n\t\t\treturn user.email || user.username || fallback;\n\t\t}\n\t\treturn fallback;\n\t} catch {\n\t\treturn fallback;\n\t}\n}\n\n/**\n * Input type for creating a product instance\n */\nexport interface CreateProductInstanceInput {\n\tproductId: string;\n\tbrandId: string;\n\taccountId: string;\n\tproductName: string;\n\tenabled: boolean;\n\tconfig?: Record<string, any>;\n\tversion?: string;\n\tlastUpdated?: string;\n\tupdatedBy?: string;\n}\n\n/**\n * Input type for updating a product instance\n */\nexport interface UpdateProductInstanceInput {\n\tid: string;\n\tenabled?: boolean;\n\tconfig?: Record<string, any>;\n\tversion?: string;\n\tlastUpdated?: string;\n\tupdatedBy?: string;\n}\n\n/**\n * Create a new product instance\n *\n * @example\n * ```typescript\n * import { createProductInstance } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instance = await createProductInstance(client, {\n * productId: 'product-123',\n * brandId: 'brand-456',\n * accountId: 'account-789',\n * enabled: true,\n * config: { apiKey: 'xxx', maxRequests: 100 }\n * });\n * ```\n */\nexport async function createProductInstance<TClient = any>(\n\tclient: TClient,\n\tinput: CreateProductInstanceInput,\n): Promise<ProductInstance | null> {\n\ttry {\n\t\t// Build input - manually construct to avoid Vue Proxy issues\n\t\tconst createInput: any = {\n\t\t\tproductId: input.productId,\n\t\t\tproductName: input.productName,\n\t\t\tbrandId: input.brandId,\n\t\t\taccountId: input.accountId,\n\t\t\tenabled: input.enabled,\n\t\t\tversion: input.version,\n\t\t\tlastUpdated: input.lastUpdated || getCurrentTimestamp(),\n\t\t\tupdatedBy: input.updatedBy || await getUserIdentifier(),\n\t\t};\n\n\t\t// AWSJSON type requires JSON STRING\n\t\tif (input.config) {\n\t\t\t// Double stringify: first to strip Vue Proxy, second to create JSON string\n\t\t\tcreateInput.config = JSON.stringify(JSON.parse(JSON.stringify(input.config)));\n\t\t}\n\n\t\tconsole.log(\"[createProductInstance] Config as string:\", createInput.config);\n\t\tconsole.log(\"[createProductInstance] Config type:\", typeof createInput.config);\n\n\t\tconst { data, errors } = await (client as any).models.ProductInstance.create(createInput);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createProductInstance] GraphQL errors:\", errors);\n\t\t\tthrow new AppError(\n\t\t\t\t\"Failed to create product instance\",\n\t\t\t\t\"PRODUCT_INSTANCE_CREATE_ERROR\",\n\t\t\t\t500,\n\t\t\t\t{ errors }\n\t\t\t);\n\t\t}\n\n\t\treturn data as ProductInstance;\n\t} catch (error) {\n\t\tconsole.error(\"[createProductInstance] Error creating product instance:\", error);\n\t\tif (error instanceof AppError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new AppError(\n\t\t\t\"Failed to create product instance\",\n\t\t\t\"PRODUCT_INSTANCE_CREATE_ERROR\",\n\t\t\t500,\n\t\t\t{ originalError: error }\n\t\t);\n\t}\n}\n\n/**\n * Update an existing product instance\n *\n * @example\n * ```typescript\n * import { updateProductInstance } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instance = await updateProductInstance(client, {\n * id: 'instance-123',\n * enabled: false,\n * config: { apiKey: 'new-key', maxRequests: 200 }\n * });\n * ```\n */\nexport async function updateProductInstance<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateProductInstanceInput,\n): Promise<ProductInstance | null> {\n\ttry {\n\t\t// Add timestamp and user metadata if not provided\n\t\t// Convert config from Vue Proxy to plain object\n\t\tconst updateInput: any = {\n\t\t\t...input,\n\t\t\tlastUpdated: input.lastUpdated || getCurrentTimestamp(),\n\t\t\tupdatedBy: input.updatedBy || await getUserIdentifier(),\n\t\t};\n\n\t\t// AWSJSON type requires JSON STRING\n\t\tif (input.config) {\n\t\t\tupdateInput.config = JSON.stringify(JSON.parse(JSON.stringify(input.config)));\n\t\t}\n\n\t\tconst { data, errors } = await (client as any).models.ProductInstance.update(updateInput);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateProductInstance] GraphQL errors:\", errors);\n\t\t\tthrow new AppError(\n\t\t\t\t\"Failed to update product instance\",\n\t\t\t\t\"PRODUCT_INSTANCE_UPDATE_ERROR\",\n\t\t\t\t500,\n\t\t\t\t{ errors }\n\t\t\t);\n\t\t}\n\n\t\treturn data as ProductInstance;\n\t} catch (error) {\n\t\tconsole.error(\"[updateProductInstance] Error updating product instance:\", error);\n\t\tif (error instanceof AppError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new AppError(\n\t\t\t\"Failed to update product instance\",\n\t\t\t\"PRODUCT_INSTANCE_UPDATE_ERROR\",\n\t\t\t500,\n\t\t\t{ originalError: error }\n\t\t);\n\t}\n}\n\n/**\n * Delete a product instance\n *\n * @example\n * ```typescript\n * import { deleteProductInstance } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteProductInstance(client, 'instance-123');\n * ```\n */\nexport async function deleteProductInstance<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.ProductInstance.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteProductInstance] GraphQL errors:\", errors);\n\t\t\tthrow new AppError(\n\t\t\t\t\"Failed to delete product instance\",\n\t\t\t\t\"PRODUCT_INSTANCE_DELETE_ERROR\",\n\t\t\t\t500,\n\t\t\t\t{ errors }\n\t\t\t);\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteProductInstance] Error deleting product instance:\", error);\n\t\tif (error instanceof AppError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new AppError(\n\t\t\t\"Failed to delete product instance\",\n\t\t\t\"PRODUCT_INSTANCE_DELETE_ERROR\",\n\t\t\t500,\n\t\t\t{ originalError: error }\n\t\t);\n\t}\n}\n\n/**\n * Toggle the enabled status of a product instance\n *\n * @example\n * ```typescript\n * import { toggleProductInstanceEnabled } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instance = await toggleProductInstanceEnabled(client, 'instance-123', true);\n * ```\n */\nexport async function toggleProductInstanceEnabled<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tenabled: boolean,\n): Promise<ProductInstance | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.ProductInstance.update({\n\t\t\tid,\n\t\t\tenabled,\n\t\t\tlastUpdated: getCurrentTimestamp(),\n\t\t\tupdatedBy: await getUserIdentifier(),\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[toggleProductInstanceEnabled] GraphQL errors:\", errors);\n\t\t\tthrow new AppError(\n\t\t\t\t\"Failed to toggle product instance\",\n\t\t\t\t\"PRODUCT_INSTANCE_TOGGLE_ERROR\",\n\t\t\t\t500,\n\t\t\t\t{ errors }\n\t\t\t);\n\t\t}\n\n\t\treturn data as ProductInstance;\n\t} catch (error) {\n\t\tconsole.error(\"[toggleProductInstanceEnabled] Error toggling product instance:\", error);\n\t\tif (error instanceof AppError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new AppError(\n\t\t\t\"Failed to toggle product instance\",\n\t\t\t\"PRODUCT_INSTANCE_TOGGLE_ERROR\",\n\t\t\t500,\n\t\t\t{ originalError: error }\n\t\t);\n\t}\n}\n","/**\n * useProductInstances Hook\n *\n * Vue composable for fetching and managing product instance data with reactive state.\n * Provides loading states, error handling, refetch capabilities, and CRUD operations.\n */\n\nimport type { Ref, ComputedRef } from \"vue\";\nimport type { ProductInstance } from \"@htlkg/core/types\";\nimport { createDataHook, type BaseHookOptions } from \"./createDataHook\";\nimport { getSharedClient } from \"../client\";\nimport {\n\tcreateProductInstance,\n\tupdateProductInstance,\n\tdeleteProductInstance,\n\ttoggleProductInstanceEnabled,\n\ttype CreateProductInstanceInput,\n\ttype UpdateProductInstanceInput,\n} from \"../mutations/productInstances\";\n\nexport interface UseProductInstancesOptions extends BaseHookOptions {\n\t/** Filter criteria for product instances */\n\tfilter?: any;\n\t/** Limit number of results */\n\tlimit?: number;\n\t/** Auto-fetch on mount (default: true) */\n\tautoFetch?: boolean;\n\t/** Filter by brand ID */\n\tbrandId?: string;\n\t/** Filter by account ID */\n\taccountId?: string;\n\t/** Filter by product ID */\n\tproductId?: string;\n\t/** Only enabled instances */\n\tenabledOnly?: boolean;\n}\n\nexport interface UseProductInstancesReturn {\n\t/** Reactive array of product instances */\n\tinstances: Ref<ProductInstance[]>;\n\t/** Computed array of enabled instances only */\n\tenabledInstances: ComputedRef<ProductInstance[]>;\n\t/** Loading state */\n\tloading: Ref<boolean>;\n\t/** Error state */\n\terror: Ref<Error | null>;\n\t/** Refetch product instances */\n\trefetch: () => Promise<void>;\n\t/** Create a new product instance */\n\tcreateInstance: (input: CreateProductInstanceInput) => Promise<ProductInstance>;\n\t/** Update an existing product instance */\n\tupdateInstance: (input: UpdateProductInstanceInput) => Promise<ProductInstance>;\n\t/** Delete a product instance */\n\tdeleteInstance: (id: string) => Promise<boolean>;\n\t/** Toggle the enabled status of a product instance */\n\ttoggleEnabled: (id: string, enabled: boolean) => Promise<ProductInstance>;\n}\n\n/**\n * Build filter from hook options\n */\nfunction buildFilter(options: UseProductInstancesOptions): any {\n\tlet filter: any = options.filter || {};\n\n\tif (options.brandId) {\n\t\tfilter = { ...filter, brandId: { eq: options.brandId } };\n\t}\n\n\tif (options.accountId) {\n\t\tfilter = { ...filter, accountId: { eq: options.accountId } };\n\t}\n\n\tif (options.productId) {\n\t\tfilter = { ...filter, productId: { eq: options.productId } };\n\t}\n\n\tif (options.enabledOnly) {\n\t\tfilter = { ...filter, enabled: { eq: true } };\n\t}\n\n\treturn Object.keys(filter).length > 0 ? filter : undefined;\n}\n\n/**\n * Internal hook created by factory\n */\nconst useProductInstancesInternal = createDataHook<\n\tProductInstance,\n\tUseProductInstancesOptions,\n\t{ enabledInstances: ProductInstance[] }\n>({\n\tmodel: \"ProductInstance\",\n\tdataPropertyName: \"instances\",\n\tbuildFilter,\n\tcomputedProperties: {\n\t\tenabledInstances: (instances) => instances.filter((i) => i.enabled),\n\t},\n});\n\n/**\n * Composable for fetching and managing product instances\n *\n * @example\n * ```typescript\n * import { useProductInstances } from '@htlkg/data/hooks';\n *\n * const { instances, loading, error, refetch } = useProductInstances();\n * ```\n *\n * @example With filters\n * ```typescript\n * const { instances, enabledInstances, loading } = useProductInstances({\n * brandId: 'brand-123',\n * enabledOnly: true,\n * limit: 50\n * });\n * ```\n *\n * @example For a specific account\n * ```typescript\n * const { instances, loading } = useProductInstances({\n * accountId: 'account-456',\n * autoFetch: true\n * });\n * ```\n */\nexport function useProductInstances(options: UseProductInstancesOptions = {}): UseProductInstancesReturn {\n\tconst result = useProductInstancesInternal(options);\n\n\t// CRUD methods using mutations from @htlkg/data/mutations\n\tasync function createInstance(input: CreateProductInstanceInput): Promise<ProductInstance> {\n\t\tconst client = getSharedClient();\n\t\tconst instance = await createProductInstance(client, input);\n\t\tif (!instance) {\n\t\t\tthrow new Error(\"Failed to create product instance\");\n\t\t}\n\t\treturn instance;\n\t}\n\n\tasync function updateInstance(input: UpdateProductInstanceInput): Promise<ProductInstance> {\n\t\tconst client = getSharedClient();\n\t\tconst instance = await updateProductInstance(client, input);\n\t\tif (!instance) {\n\t\t\tthrow new Error(\"Failed to update product instance\");\n\t\t}\n\t\treturn instance;\n\t}\n\n\tasync function deleteInstance(id: string): Promise<boolean> {\n\t\tconst client = getSharedClient();\n\t\treturn deleteProductInstance(client, id);\n\t}\n\n\tasync function toggleEnabled(id: string, enabled: boolean): Promise<ProductInstance> {\n\t\tconst client = getSharedClient();\n\t\tconst instance = await toggleProductInstanceEnabled(client, id, enabled);\n\t\tif (!instance) {\n\t\t\tthrow new Error(\"Failed to toggle product instance\");\n\t\t}\n\t\treturn instance;\n\t}\n\n\treturn {\n\t\tinstances: result.instances as Ref<ProductInstance[]>,\n\t\tenabledInstances: result.enabledInstances as ComputedRef<ProductInstance[]>,\n\t\tloading: result.loading,\n\t\terror: result.error,\n\t\trefetch: result.refetch,\n\t\tcreateInstance,\n\t\tupdateInstance,\n\t\tdeleteInstance,\n\t\ttoggleEnabled,\n\t};\n}\n"],"mappings":";AAOA,SAAS,KAAK,UAAU,iBAA6C;;;ACArE,SAAS,kBAAkB,0BAA0B;;;ACErD;AAA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ACxC;AAEA,iBAAe,cAAc,IAAY,SAA4C;AACpF,UAAM,SAAS,gBAAgB;AAC/B,UAAM,WAAW,MAAM,6BAA6B,QAAQ,IAAI,OAAO;AACvE,QAAI,CAAC,UAAU;AACd,YAAM,IAAI,MAAM,mCAAmC;AAAA,IACpD;AACA,WAAO;AAAA,EACR;AAEA,SAAO;AAAA,IACN,WAAW,OAAO;AAAA,IAClB,kBAAkB,OAAO;AAAA,IACzB,SAAS,OAAO;AAAA,IAChB,OAAO,OAAO;AAAA,IACd,SAAS,OAAO;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;","names":["buildFilter","buildFilter","buildFilter","buildFilter"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { AstroAmplifyConfig, generateClient, generateServerClient, getSharedClient, resetSharedClient as resetClientInstance, resetSharedClient } from './client/index.js';
|
|
2
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
|
-
export {
|
|
4
|
+
export { C as CreateProductInstanceInput, U as UpdateProductInstanceInput, c as createProductInstance, d as deleteProductInstance, t as toggleProductInstanceEnabled, u as updateProductInstance } from './productInstances-CzT3NZKU.js';
|
|
5
|
+
export { BaseHookOptions, CreateDataHookOptions, DataHookReturn, InferHookReturn, UseAccountsOptions, UseAccountsReturn, UseBrandsOptions, UseBrandsReturn, UseProductInstancesOptions, UseProductInstancesReturn, UseProductsOptions, UseProductsReturn, UseUsersOptions, UseUsersReturn, createDataHook, useAccounts, useBrands, useProductInstances, useProducts, useUsers } from './hooks/index.js';
|
|
5
6
|
export { InferStoreType, ResourceStores, StoreConfig, createResourceStores, createSingleStore, createStore } from './stores/index.js';
|
|
6
7
|
import 'aws-amplify/data';
|
|
7
8
|
import 'aws-amplify';
|