@htlkg/data 0.0.24 → 0.0.25

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/README.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  GraphQL client, queries, mutations, hooks, and stores for Hotelinking applications.
4
4
 
5
+ ## Changelog
6
+
7
+ ### 0.0.25
8
+ - Added `useActivityLogs` hook for reactive activity log fetching
9
+ - Added `fetchActivityLogs` and `fetchRecentActivity` query functions
10
+ - Removed `createActivityLog` mutation (activity logging is now handled by DynamoDB Streams Lambdas, not the GraphQL proxy)
11
+
5
12
  ## Installation
6
13
 
7
14
  ```bash
@@ -1,5 +1,5 @@
1
1
  import { Ref, ComputedRef } from 'vue';
2
- import { Brand, User, Account, Product, ProductInstance, Contact } from '@htlkg/core/types';
2
+ import { Brand, User, Account, Product, ProductInstance, Contact, ActivityLog } from '@htlkg/core/types';
3
3
  import { R as Reservation } from '../reservations-C0FNm__0.js';
4
4
  import { C as CreateProductInstanceInput, U as UpdateProductInstanceInput } from '../productInstances-BpQv1oLS.js';
5
5
  import '../common-DSxswsZ3.js';
@@ -1137,4 +1137,24 @@ declare function useActiveContacts(options?: UsePaginatedContactsOptions): UsePa
1137
1137
  */
1138
1138
  declare function useDeletedContacts(options?: UsePaginatedContactsOptions): UsePaginatedContactsReturn;
1139
1139
 
1140
- export { ACTIVE_FILTER, type AccountWithBrands, type BaseHookOptions, type BrandWithCounts, type ContactWithRelations, type CreateDataHookOptions, type CreatePaginatedDataHookOptions, DELETED_FILTER, type DataHookReturn, type InferHookReturn, type InferPaginatedHookReturn, type AccountWithBrands as PaginatedAccountWithBrands, type PaginatedDataHookReturn, type PaginatedHookOptions, type PaginationState, type ReservationWithRelations, type UseAccountsOptions, type UseAccountsReturn, type UseBrandsOptions, type UseBrandsReturn, type UseContactsOptions, type UseContactsReturn, type UsePaginatedAccountsOptions, type UsePaginatedAccountsReturn, type UsePaginatedBrandsOptions, type UsePaginatedBrandsReturn, type UsePaginatedContactsOptions, type UsePaginatedContactsReturn, type UsePaginatedReservationsOptions, type UsePaginatedReservationsReturn, type UsePaginatedUsersOptions, type UsePaginatedUsersReturn, type UseProductInstancesOptions, type UseProductInstancesReturn, type UseProductsOptions, type UseProductsReturn, type UseReservationsOptions, type UseReservationsReturn, type UseUsersOptions, type UseUsersReturn, type UserWithRelations, createDataHook, createPaginatedDataHook, resetClientInstance, useAccounts, useActiveAccounts, useActiveBrands, useActiveContacts, useActiveReservations, useActiveUsers, useBrands, useContacts, useDeletedAccounts, useDeletedBrands, useDeletedContacts, useDeletedReservations, useDeletedUsers, useProductInstances, useProducts, useReservations, useUsers };
1140
+ /**
1141
+ * useActivityLogs Hook
1142
+ *
1143
+ * Vue composable for fetching activity log data with reactive state.
1144
+ */
1145
+
1146
+ interface UseActivityLogsOptions extends BaseHookOptions {
1147
+ accountId?: string;
1148
+ brandId?: string;
1149
+ resourceType?: string;
1150
+ action?: "create" | "update" | "delete";
1151
+ }
1152
+ interface UseActivityLogsReturn {
1153
+ activityLogs: Ref<ActivityLog[]>;
1154
+ loading: Ref<boolean>;
1155
+ error: Ref<Error | null>;
1156
+ refetch: () => Promise<void>;
1157
+ }
1158
+ declare function useActivityLogs(options?: UseActivityLogsOptions): UseActivityLogsReturn;
1159
+
1160
+ export { ACTIVE_FILTER, type AccountWithBrands, type BaseHookOptions, type BrandWithCounts, type ContactWithRelations, type CreateDataHookOptions, type CreatePaginatedDataHookOptions, DELETED_FILTER, type DataHookReturn, type InferHookReturn, type InferPaginatedHookReturn, type AccountWithBrands as PaginatedAccountWithBrands, type PaginatedDataHookReturn, type PaginatedHookOptions, type PaginationState, type ReservationWithRelations, type UseAccountsOptions, type UseAccountsReturn, type UseActivityLogsOptions, type UseActivityLogsReturn, type UseBrandsOptions, type UseBrandsReturn, type UseContactsOptions, type UseContactsReturn, type UsePaginatedAccountsOptions, type UsePaginatedAccountsReturn, type UsePaginatedBrandsOptions, type UsePaginatedBrandsReturn, type UsePaginatedContactsOptions, type UsePaginatedContactsReturn, type UsePaginatedReservationsOptions, type UsePaginatedReservationsReturn, type UsePaginatedUsersOptions, type UsePaginatedUsersReturn, type UseProductInstancesOptions, type UseProductInstancesReturn, type UseProductsOptions, type UseProductsReturn, type UseReservationsOptions, type UseReservationsReturn, type UseUsersOptions, type UseUsersReturn, type UserWithRelations, createDataHook, createPaginatedDataHook, resetClientInstance, useAccounts, useActiveAccounts, useActiveBrands, useActiveContacts, useActiveReservations, useActiveUsers, useActivityLogs, useBrands, useContacts, useDeletedAccounts, useDeletedBrands, useDeletedContacts, useDeletedReservations, useDeletedUsers, useProductInstances, useProducts, useReservations, useUsers };
@@ -55,7 +55,7 @@ function createDataHook(config) {
55
55
  defaultLimit,
56
56
  selectionSet,
57
57
  transform,
58
- buildFilter: buildFilter11,
58
+ buildFilter: buildFilter12,
59
59
  computedProperties,
60
60
  dataPropertyName = "data"
61
61
  } = config;
@@ -65,8 +65,8 @@ function createDataHook(config) {
65
65
  const loading = ref(false);
66
66
  const error = ref(null);
67
67
  const getFilter = () => {
68
- if (buildFilter11) {
69
- return buildFilter11(options);
68
+ if (buildFilter12) {
69
+ return buildFilter12(options);
70
70
  }
71
71
  return baseFilter && Object.keys(baseFilter).length > 0 ? baseFilter : void 0;
72
72
  };
@@ -140,7 +140,7 @@ function createPaginatedDataHook(config) {
140
140
  defaultPageSize = 25,
141
141
  selectionSet,
142
142
  transform,
143
- buildFilter: buildFilter11,
143
+ buildFilter: buildFilter12,
144
144
  dataPropertyName = "data",
145
145
  baseFilter
146
146
  } = config;
@@ -163,8 +163,8 @@ function createPaginatedDataHook(config) {
163
163
  if (baseFilter) {
164
164
  filters.push(baseFilter);
165
165
  }
166
- if (buildFilter11) {
167
- const customFilter = buildFilter11(options);
166
+ if (buildFilter12) {
167
+ const customFilter = buildFilter12(options);
168
168
  if (customFilter) {
169
169
  filters.push(customFilter);
170
170
  }
@@ -338,9 +338,14 @@ function buildFilter2(options) {
338
338
  return { and: conditions };
339
339
  }
340
340
  function transformBrand(brand) {
341
+ const productInstances = brand.productInstances?.items || [];
342
+ const enabledProductCount = productInstances.filter((p) => p.enabled).length;
343
+ const totalProductCount = productInstances.length;
341
344
  return {
342
345
  ...brand,
343
- accountName: brand.account?.name || ""
346
+ accountName: brand.account?.name || "",
347
+ enabledProductCount,
348
+ totalProductCount
344
349
  };
345
350
  }
346
351
  var BRAND_SELECTION_SET = [
@@ -353,7 +358,8 @@ var BRAND_SELECTION_SET = [
353
358
  "settings",
354
359
  "deletedAt",
355
360
  "deletedBy",
356
- "account.name"
361
+ "account.name",
362
+ "productInstances.*"
357
363
  ];
358
364
  var useActiveBrandsInternal = createPaginatedDataHook({
359
365
  model: "Brand",
@@ -1293,6 +1299,43 @@ function useDeletedContacts(options = {}) {
1293
1299
  searchFilter: result.searchFilter
1294
1300
  };
1295
1301
  }
1302
+
1303
+ // src/hooks/activityLogs/useActivityLogs.ts
1304
+ function buildFilter11(options) {
1305
+ const conditions = [];
1306
+ if (options.accountId) {
1307
+ conditions.push({ accountId: { eq: options.accountId } });
1308
+ }
1309
+ if (options.brandId) {
1310
+ conditions.push({ brandId: { eq: options.brandId } });
1311
+ }
1312
+ if (options.resourceType) {
1313
+ conditions.push({ resourceType: { eq: options.resourceType } });
1314
+ }
1315
+ if (options.action) {
1316
+ conditions.push({ action: { eq: options.action } });
1317
+ }
1318
+ if (options.filter) {
1319
+ conditions.push(options.filter);
1320
+ }
1321
+ if (conditions.length === 0) return void 0;
1322
+ if (conditions.length === 1) return conditions[0];
1323
+ return { and: conditions };
1324
+ }
1325
+ var useActivityLogsInternal = createDataHook({
1326
+ model: "ActivityLog",
1327
+ dataPropertyName: "activityLogs",
1328
+ buildFilter: buildFilter11
1329
+ });
1330
+ function useActivityLogs(options = {}) {
1331
+ const result = useActivityLogsInternal(options);
1332
+ return {
1333
+ activityLogs: result.activityLogs,
1334
+ loading: result.loading,
1335
+ error: result.error,
1336
+ refetch: result.refetch
1337
+ };
1338
+ }
1296
1339
  export {
1297
1340
  ACTIVE_FILTER,
1298
1341
  DELETED_FILTER,
@@ -1305,6 +1348,7 @@ export {
1305
1348
  useActiveContacts,
1306
1349
  useActiveReservations,
1307
1350
  useActiveUsers,
1351
+ useActivityLogs,
1308
1352
  useBrands,
1309
1353
  useContacts,
1310
1354
  useDeletedAccounts,