@htlkg/data 0.0.23 → 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 +7 -0
- package/dist/hooks/index.d.ts +22 -4
- package/dist/hooks/index.js +52 -12
- package/dist/hooks/index.js.map +1 -1
- package/dist/index-ZmmFz38a.d.ts +1089 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +372 -57
- package/dist/index.js.map +1 -1
- package/dist/mutations/index.d.ts +4 -714
- package/dist/mutations/index.js +163 -47
- package/dist/mutations/index.js.map +1 -1
- package/dist/queries/index.d.ts +48 -2
- package/dist/queries/index.js +43 -0
- package/dist/queries/index.js.map +1 -1
- package/package.json +3 -3
- package/src/hooks/activityLogs/index.ts +5 -0
- package/src/hooks/activityLogs/useActivityLogs.ts +63 -0
- package/src/hooks/brands/usePaginatedBrands.ts +9 -1
- package/src/hooks/contacts/usePaginatedContacts.ts +0 -7
- package/src/hooks/index.ts +9 -0
- package/src/index.ts +3 -0
- package/src/mutations/contacts.ts +12 -75
- package/src/mutations/index.ts +1 -0
- package/src/queries/activityLogs.ts +87 -0
- package/src/queries/index.ts +8 -0
- package/src/validation/contact.schemas.test.ts +975 -0
- package/src/validation/contact.schemas.ts +611 -0
- package/src/validation/index.ts +54 -0
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
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -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';
|
|
@@ -1056,8 +1056,6 @@ type ContactWithRelations = Contact & {
|
|
|
1056
1056
|
interface UsePaginatedContactsOptions extends PaginatedHookOptions {
|
|
1057
1057
|
/** Filter by brand ID */
|
|
1058
1058
|
brandId?: string;
|
|
1059
|
-
/** Filter by account ID */
|
|
1060
|
-
accountId?: string;
|
|
1061
1059
|
/** Search query (searches email, firstName, lastName) */
|
|
1062
1060
|
search?: string;
|
|
1063
1061
|
/** Filter by GDPR consent */
|
|
@@ -1139,4 +1137,24 @@ declare function useActiveContacts(options?: UsePaginatedContactsOptions): UsePa
|
|
|
1139
1137
|
*/
|
|
1140
1138
|
declare function useDeletedContacts(options?: UsePaginatedContactsOptions): UsePaginatedContactsReturn;
|
|
1141
1139
|
|
|
1142
|
-
|
|
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 };
|
package/dist/hooks/index.js
CHANGED
|
@@ -55,7 +55,7 @@ function createDataHook(config) {
|
|
|
55
55
|
defaultLimit,
|
|
56
56
|
selectionSet,
|
|
57
57
|
transform,
|
|
58
|
-
buildFilter:
|
|
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 (
|
|
69
|
-
return
|
|
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:
|
|
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 (
|
|
167
|
-
const customFilter =
|
|
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",
|
|
@@ -1178,9 +1184,6 @@ function buildFilter10(options) {
|
|
|
1178
1184
|
if (options.brandId) {
|
|
1179
1185
|
conditions.push({ brandId: { eq: options.brandId } });
|
|
1180
1186
|
}
|
|
1181
|
-
if (options.accountId) {
|
|
1182
|
-
conditions.push({ accountId: { eq: options.accountId } });
|
|
1183
|
-
}
|
|
1184
1187
|
if (options.search) {
|
|
1185
1188
|
conditions.push({
|
|
1186
1189
|
or: [
|
|
@@ -1228,7 +1231,6 @@ var CONTACT_SELECTION_SET = [
|
|
|
1228
1231
|
"lastName",
|
|
1229
1232
|
"locale",
|
|
1230
1233
|
"brandId",
|
|
1231
|
-
"accountId",
|
|
1232
1234
|
"gdprConsent",
|
|
1233
1235
|
"gdprConsentDate",
|
|
1234
1236
|
"marketingOptIn",
|
|
@@ -1297,6 +1299,43 @@ function useDeletedContacts(options = {}) {
|
|
|
1297
1299
|
searchFilter: result.searchFilter
|
|
1298
1300
|
};
|
|
1299
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
|
+
}
|
|
1300
1339
|
export {
|
|
1301
1340
|
ACTIVE_FILTER,
|
|
1302
1341
|
DELETED_FILTER,
|
|
@@ -1309,6 +1348,7 @@ export {
|
|
|
1309
1348
|
useActiveContacts,
|
|
1310
1349
|
useActiveReservations,
|
|
1311
1350
|
useActiveUsers,
|
|
1351
|
+
useActivityLogs,
|
|
1312
1352
|
useBrands,
|
|
1313
1353
|
useContacts,
|
|
1314
1354
|
useDeletedAccounts,
|