@htlkg/data 0.0.20 → 0.0.22

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.
Files changed (69) hide show
  1. package/dist/hooks/index.d.ts +659 -66
  2. package/dist/hooks/index.js +711 -42
  3. package/dist/hooks/index.js.map +1 -1
  4. package/dist/index.d.ts +4 -3
  5. package/dist/index.js +1098 -51
  6. package/dist/index.js.map +1 -1
  7. package/dist/mutations/index.d.ts +338 -2
  8. package/dist/mutations/index.js +290 -4
  9. package/dist/mutations/index.js.map +1 -1
  10. package/dist/queries/index.d.ts +110 -2
  11. package/dist/queries/index.js +115 -6
  12. package/dist/queries/index.js.map +1 -1
  13. package/package.json +2 -2
  14. package/src/hooks/accounts/index.ts +2 -0
  15. package/src/hooks/{useAccounts.ts → accounts/useAccounts.ts} +48 -5
  16. package/src/hooks/accounts/usePaginatedAccounts.ts +166 -0
  17. package/src/hooks/brands/index.ts +2 -0
  18. package/src/hooks/{useBrands.ts → brands/useBrands.ts} +1 -1
  19. package/src/hooks/brands/usePaginatedBrands.ts +206 -0
  20. package/src/hooks/createPaginatedDataHook.ts +359 -0
  21. package/src/hooks/data-hook-errors.property.test.ts +4 -4
  22. package/src/hooks/data-hook-filters.property.test.ts +4 -4
  23. package/src/hooks/data-hooks.property.test.ts +4 -4
  24. package/src/hooks/index.ts +96 -7
  25. package/src/hooks/productInstances/index.ts +1 -0
  26. package/src/hooks/{useProductInstances.ts → productInstances/useProductInstances.ts} +9 -6
  27. package/src/hooks/products/index.ts +1 -0
  28. package/src/hooks/{useProducts.ts → products/useProducts.ts} +4 -5
  29. package/src/hooks/reservations/index.ts +2 -0
  30. package/src/hooks/reservations/usePaginatedReservations.ts +258 -0
  31. package/src/hooks/{useReservations.ts → reservations/useReservations.ts} +65 -10
  32. package/src/hooks/useContacts.test.ts +159 -0
  33. package/src/hooks/useContacts.ts +176 -0
  34. package/src/hooks/users/index.ts +2 -0
  35. package/src/hooks/users/usePaginatedUsers.ts +213 -0
  36. package/src/hooks/{useUsers.ts → users/useUsers.ts} +1 -1
  37. package/src/mutations/accounts/accounts.test.ts +287 -0
  38. package/src/mutations/{accounts.ts → accounts/accounts.ts} +2 -2
  39. package/src/mutations/accounts/index.ts +1 -0
  40. package/src/mutations/brands/brands.test.ts +292 -0
  41. package/src/mutations/{brands.ts → brands/brands.ts} +2 -2
  42. package/src/mutations/brands/index.ts +1 -0
  43. package/src/mutations/contacts.test.ts +604 -0
  44. package/src/mutations/contacts.ts +554 -0
  45. package/src/mutations/index.ts +18 -0
  46. package/src/mutations/reservations/index.ts +1 -0
  47. package/src/mutations/{reservations.test.ts → reservations/reservations.test.ts} +1 -1
  48. package/src/mutations/{reservations.ts → reservations/reservations.ts} +2 -2
  49. package/src/mutations/users/index.ts +1 -0
  50. package/src/mutations/users/users.test.ts +289 -0
  51. package/src/mutations/{users.ts → users/users.ts} +2 -2
  52. package/src/queries/accounts/accounts.test.ts +228 -0
  53. package/src/queries/accounts/index.ts +1 -0
  54. package/src/queries/brands/brands.test.ts +288 -0
  55. package/src/queries/brands/index.ts +1 -0
  56. package/src/queries/contacts.test.ts +505 -0
  57. package/src/queries/contacts.ts +237 -0
  58. package/src/queries/index.ts +10 -0
  59. package/src/queries/products/index.ts +1 -0
  60. package/src/queries/products/products.test.ts +347 -0
  61. package/src/queries/reservations/index.ts +1 -0
  62. package/src/queries/users/index.ts +1 -0
  63. package/src/queries/users/users.test.ts +301 -0
  64. /package/src/queries/{accounts.ts → accounts/accounts.ts} +0 -0
  65. /package/src/queries/{brands.ts → brands/brands.ts} +0 -0
  66. /package/src/queries/{products.ts → products/products.ts} +0 -0
  67. /package/src/queries/{reservations.test.ts → reservations/reservations.test.ts} +0 -0
  68. /package/src/queries/{reservations.ts → reservations/reservations.ts} +0 -0
  69. /package/src/queries/{users.ts → users/users.ts} +0 -0
@@ -1,7 +1,7 @@
1
1
  import { Ref, ComputedRef } from 'vue';
2
- import { Brand, Account, User, Product, ProductInstance } from '@htlkg/core/types';
3
- import { C as CreateProductInstanceInput, U as UpdateProductInstanceInput } from '../productInstances-BpQv1oLS.js';
2
+ import { Brand, User, Account, Product, ProductInstance, Contact } from '@htlkg/core/types';
4
3
  import { R as Reservation } from '../reservations-C0FNm__0.js';
4
+ import { C as CreateProductInstanceInput, U as UpdateProductInstanceInput } from '../productInstances-BpQv1oLS.js';
5
5
  import '../common-DSxswsZ3.js';
6
6
 
7
7
  /**
@@ -107,6 +107,162 @@ declare function createDataHook<T, TOptions extends BaseHookOptions = BaseHookOp
107
107
  */
108
108
  type InferHookReturn<THook extends (...args: any[]) => any> = ReturnType<THook>;
109
109
 
110
+ /**
111
+ * Paginated Data Hook Factory
112
+ *
113
+ * Creates reusable Vue composables for fetching paginated data from GraphQL models.
114
+ * Supports cursor-based pagination (nextToken) for efficient handling of large datasets.
115
+ *
116
+ * Key features:
117
+ * - Server-side pagination with nextToken
118
+ * - loadMore() for infinite scroll/pagination
119
+ * - hasMore indicator
120
+ * - Independent pagination state per hook instance
121
+ * - Built-in support for active/deleted filtering
122
+ */
123
+
124
+ /**
125
+ * Filter for active items (not deleted)
126
+ * Uses OR condition because deletedAt can be:
127
+ * - Missing (attributeExists: false)
128
+ * - Explicitly null (eq: null)
129
+ */
130
+ declare const ACTIVE_FILTER: {
131
+ or: ({
132
+ deletedAt: {
133
+ attributeExists: boolean;
134
+ eq?: undefined;
135
+ };
136
+ } | {
137
+ deletedAt: {
138
+ eq: null;
139
+ attributeExists?: undefined;
140
+ };
141
+ })[];
142
+ };
143
+ /**
144
+ * Filter for deleted items
145
+ * Uses gt: "" to match only actual timestamp strings (not null or missing)
146
+ */
147
+ declare const DELETED_FILTER: {
148
+ deletedAt: {
149
+ gt: string;
150
+ };
151
+ };
152
+ /**
153
+ * Configuration options for creating a paginated data hook
154
+ */
155
+ interface CreatePaginatedDataHookOptions<T, TOptions extends PaginatedHookOptions = PaginatedHookOptions> {
156
+ /** The GraphQL model name (e.g., 'Account', 'User', 'Brand') */
157
+ model: string;
158
+ /** Default page size */
159
+ defaultPageSize?: number;
160
+ /** Selection set for the query (fields to fetch) */
161
+ selectionSet?: string[];
162
+ /** Transform function to apply to fetched data */
163
+ transform?: (item: any) => T;
164
+ /** Build filter from hook options */
165
+ buildFilter?: (options: TOptions) => any;
166
+ /** Plural name for the data property (e.g., 'accounts', 'users') */
167
+ dataPropertyName?: string;
168
+ /** Base filter to always apply (e.g., for active/deleted variants) */
169
+ baseFilter?: any;
170
+ }
171
+ /**
172
+ * Base options available to paginated hooks
173
+ */
174
+ interface PaginatedHookOptions {
175
+ /** Additional filter criteria (merged with baseFilter) */
176
+ filter?: any;
177
+ /** Page size (default: 25) */
178
+ pageSize?: number;
179
+ /** Auto-fetch on mount (default: true) */
180
+ autoFetch?: boolean;
181
+ }
182
+ /**
183
+ * Pagination state
184
+ */
185
+ interface PaginationState {
186
+ /** Current nextToken for fetching next page */
187
+ nextToken: string | null;
188
+ /** Whether there are more items to load */
189
+ hasMore: boolean;
190
+ /** Total items loaded so far */
191
+ loadedCount: number;
192
+ }
193
+ /**
194
+ * Return type for paginated data hooks
195
+ */
196
+ interface PaginatedDataHookReturn<T> {
197
+ /** Reactive array of data (accumulated across pages) */
198
+ data: Ref<T[]>;
199
+ /** Loading state (true during any fetch) */
200
+ loading: Ref<boolean>;
201
+ /** Loading state for initial fetch */
202
+ initialLoading: Ref<boolean>;
203
+ /** Loading state for loadMore */
204
+ loadingMore: Ref<boolean>;
205
+ /** Error state */
206
+ error: Ref<Error | null>;
207
+ /** Pagination state */
208
+ pagination: Ref<PaginationState>;
209
+ /** Whether there are more items to load */
210
+ hasMore: ComputedRef<boolean>;
211
+ /** Load next page of data */
212
+ loadMore: () => Promise<void>;
213
+ /** Refetch data (resets to first page) */
214
+ refetch: () => Promise<void>;
215
+ /** Reset data and pagination state */
216
+ reset: () => void;
217
+ /** Update search filter and refetch from server (searches ALL data) */
218
+ setSearchFilter: (filter: any) => Promise<void>;
219
+ /** Current search filter */
220
+ searchFilter: Ref<any>;
221
+ }
222
+ /**
223
+ * Creates a reusable paginated data hook for a specific model
224
+ *
225
+ * @example
226
+ * ```typescript
227
+ * // Create a hook for active brands
228
+ * export const useActiveBrands = createPaginatedDataHook<Brand>({
229
+ * model: 'Brand',
230
+ * dataPropertyName: 'brands',
231
+ * baseFilter: ACTIVE_FILTER,
232
+ * selectionSet: ['id', 'name', 'status', 'accountId', 'account.name'],
233
+ * });
234
+ *
235
+ * // Usage in component
236
+ * const { brands, loading, hasMore, loadMore, refetch } = useActiveBrands({
237
+ * pageSize: 25,
238
+ * });
239
+ * ```
240
+ *
241
+ * @example With custom filter builder
242
+ * ```typescript
243
+ * interface UseBrandsOptions extends PaginatedHookOptions {
244
+ * accountId?: string;
245
+ * }
246
+ *
247
+ * export const useActiveBrands = createPaginatedDataHook<Brand, UseBrandsOptions>({
248
+ * model: 'Brand',
249
+ * dataPropertyName: 'brands',
250
+ * baseFilter: ACTIVE_FILTER,
251
+ * buildFilter: (options) => {
252
+ * if (options.accountId) {
253
+ * return { accountId: { eq: options.accountId } };
254
+ * }
255
+ * return undefined;
256
+ * },
257
+ * });
258
+ * ```
259
+ */
260
+ declare function createPaginatedDataHook<T, TOptions extends PaginatedHookOptions = PaginatedHookOptions>(config: CreatePaginatedDataHookOptions<T, TOptions>): (options?: TOptions) => PaginatedDataHookReturn<T> & Record<string, any>;
261
+ /**
262
+ * Type helper to extract the return type of a created paginated hook
263
+ */
264
+ type InferPaginatedHookReturn<THook extends (...args: any[]) => any> = ReturnType<THook>;
265
+
110
266
  /**
111
267
  * useBrands Hook
112
268
  *
@@ -160,49 +316,90 @@ interface UseBrandsReturn {
160
316
  declare function useBrands(options?: UseBrandsOptions): UseBrandsReturn;
161
317
 
162
318
  /**
163
- * useAccounts Hook
319
+ * Paginated Brands Hooks
164
320
  *
165
- * Vue composable for fetching and managing account data with reactive state.
166
- * Provides loading states, error handling, and refetch capabilities.
321
+ * Vue composables for fetching brands with server-side pagination.
322
+ * Provides separate hooks for active and deleted brands to enable
323
+ * efficient tab-based filtering in large datasets.
167
324
  */
168
325
 
169
- interface UseAccountsOptions extends BaseHookOptions {
170
- /** Filter criteria for accounts */
171
- filter?: any;
172
- /** Limit number of results */
173
- limit?: number;
174
- /** Auto-fetch on mount (default: true) */
175
- autoFetch?: boolean;
326
+ /** Extended Brand type with computed fields */
327
+ type BrandWithCounts = Brand & {
328
+ accountName?: string;
329
+ enabledProductCount?: number;
330
+ totalProductCount?: number;
331
+ deletedAt?: string;
332
+ deletedBy?: string;
333
+ };
334
+ interface UsePaginatedBrandsOptions extends PaginatedHookOptions {
335
+ /** Filter by account ID */
336
+ accountId?: string;
176
337
  }
177
- interface UseAccountsReturn {
178
- /** Reactive array of accounts */
179
- accounts: Ref<Account[]>;
180
- /** Loading state */
338
+ interface UsePaginatedBrandsReturn {
339
+ /** Reactive array of brands */
340
+ brands: Ref<BrandWithCounts[]>;
341
+ /** Loading state (true during any fetch) */
181
342
  loading: Ref<boolean>;
343
+ /** Loading state for initial fetch */
344
+ initialLoading: Ref<boolean>;
345
+ /** Loading state for loadMore */
346
+ loadingMore: Ref<boolean>;
182
347
  /** Error state */
183
348
  error: Ref<Error | null>;
184
- /** Refetch accounts */
349
+ /** Pagination state */
350
+ pagination: Ref<PaginationState>;
351
+ /** Whether there are more items to load */
352
+ hasMore: ComputedRef<boolean>;
353
+ /** Load next page of data */
354
+ loadMore: () => Promise<void>;
355
+ /** Refetch data (resets to first page) */
185
356
  refetch: () => Promise<void>;
357
+ /** Reset data and pagination state */
358
+ reset: () => void;
359
+ /** Update search filter and refetch from server (searches ALL data) */
360
+ setSearchFilter: (filter: any) => Promise<void>;
361
+ /** Current search filter */
362
+ searchFilter: Ref<any>;
186
363
  }
187
364
  /**
188
- * Composable for fetching and managing accounts
365
+ * Composable for fetching active (non-deleted) brands with pagination
189
366
  *
190
367
  * @example
191
368
  * ```typescript
192
- * import { useAccounts } from '@htlkg/data/hooks';
369
+ * import { useActiveBrands } from '@htlkg/data/hooks';
193
370
  *
194
- * const { accounts, loading, error, refetch } = useAccounts();
371
+ * const { brands, loading, hasMore, loadMore, refetch } = useActiveBrands({
372
+ * pageSize: 25,
373
+ * });
374
+ *
375
+ * // Load more when user scrolls or clicks "Load More"
376
+ * async function onLoadMore() {
377
+ * await loadMore();
378
+ * }
195
379
  * ```
196
380
  *
197
- * @example With filters
381
+ * @example With account filter
198
382
  * ```typescript
199
- * const { accounts, loading } = useAccounts({
200
- * filter: { status: { eq: 'active' } },
201
- * limit: 50
383
+ * const { brands, loading } = useActiveBrands({
384
+ * accountId: 'account-123',
385
+ * pageSize: 50
202
386
  * });
203
387
  * ```
204
388
  */
205
- declare function useAccounts(options?: UseAccountsOptions): UseAccountsReturn;
389
+ declare function useActiveBrands(options?: UsePaginatedBrandsOptions): UsePaginatedBrandsReturn;
390
+ /**
391
+ * Composable for fetching deleted brands with pagination
392
+ *
393
+ * @example
394
+ * ```typescript
395
+ * import { useDeletedBrands } from '@htlkg/data/hooks';
396
+ *
397
+ * const { brands, loading, hasMore, loadMore, refetch } = useDeletedBrands({
398
+ * pageSize: 25,
399
+ * });
400
+ * ```
401
+ */
402
+ declare function useDeletedBrands(options?: UsePaginatedBrandsOptions): UsePaginatedBrandsReturn;
206
403
 
207
404
  /**
208
405
  * useUsers Hook
@@ -255,10 +452,390 @@ interface UseUsersReturn {
255
452
  declare function useUsers(options?: UseUsersOptions): UseUsersReturn;
256
453
 
257
454
  /**
258
- * useProducts Hook
455
+ * Paginated Users Hooks
456
+ *
457
+ * Vue composables for fetching users with server-side pagination.
458
+ * Provides separate hooks for active and deleted users to enable
459
+ * efficient tab-based filtering in large datasets.
460
+ */
461
+
462
+ /** Extended User type with computed fields */
463
+ type UserWithRelations = User & {
464
+ accountName?: string;
465
+ brandNames?: string[];
466
+ deletedAt?: string;
467
+ deletedBy?: string;
468
+ };
469
+ interface UsePaginatedUsersOptions extends PaginatedHookOptions {
470
+ /** Filter by brand ID */
471
+ brandId?: string;
472
+ /** Filter by account ID */
473
+ accountId?: string;
474
+ }
475
+ interface UsePaginatedUsersReturn {
476
+ /** Reactive array of users */
477
+ users: Ref<UserWithRelations[]>;
478
+ /** Loading state (true during any fetch) */
479
+ loading: Ref<boolean>;
480
+ /** Loading state for initial fetch */
481
+ initialLoading: Ref<boolean>;
482
+ /** Loading state for loadMore */
483
+ loadingMore: Ref<boolean>;
484
+ /** Error state */
485
+ error: Ref<Error | null>;
486
+ /** Pagination state */
487
+ pagination: Ref<PaginationState>;
488
+ /** Whether there are more items to load */
489
+ hasMore: ComputedRef<boolean>;
490
+ /** Load next page of data */
491
+ loadMore: () => Promise<void>;
492
+ /** Refetch data (resets to first page) */
493
+ refetch: () => Promise<void>;
494
+ /** Reset data and pagination state */
495
+ reset: () => void;
496
+ /** Update search filter and refetch from server (searches ALL data) */
497
+ setSearchFilter: (filter: any) => Promise<void>;
498
+ /** Current search filter */
499
+ searchFilter: Ref<any>;
500
+ }
501
+ /**
502
+ * Composable for fetching active (non-deleted) users with pagination
503
+ *
504
+ * @example
505
+ * ```typescript
506
+ * import { useActiveUsers } from '@htlkg/data/hooks';
507
+ *
508
+ * const { users, loading, hasMore, loadMore, refetch } = useActiveUsers({
509
+ * pageSize: 25,
510
+ * });
511
+ *
512
+ * // Load more when user scrolls or clicks "Load More"
513
+ * async function onLoadMore() {
514
+ * await loadMore();
515
+ * }
516
+ * ```
517
+ *
518
+ * @example With filters
519
+ * ```typescript
520
+ * const { users, loading } = useActiveUsers({
521
+ * accountId: 'account-123',
522
+ * brandId: 'brand-456',
523
+ * pageSize: 50
524
+ * });
525
+ * ```
526
+ */
527
+ declare function useActiveUsers(options?: UsePaginatedUsersOptions): UsePaginatedUsersReturn;
528
+ /**
529
+ * Composable for fetching deleted users with pagination
530
+ *
531
+ * @example
532
+ * ```typescript
533
+ * import { useDeletedUsers } from '@htlkg/data/hooks';
534
+ *
535
+ * const { users, loading, hasMore, loadMore, refetch } = useDeletedUsers({
536
+ * pageSize: 25,
537
+ * });
538
+ * ```
539
+ */
540
+ declare function useDeletedUsers(options?: UsePaginatedUsersOptions): UsePaginatedUsersReturn;
541
+
542
+ /**
543
+ * useAccounts Hook
259
544
  *
260
- * Vue composable for fetching and managing product data with reactive state.
545
+ * Vue composable for fetching and managing account data with reactive state.
261
546
  * Provides loading states, error handling, and refetch capabilities.
547
+ * Includes brands relationship data for displaying brand info without separate queries.
548
+ */
549
+
550
+ interface UseAccountsOptions extends BaseHookOptions {
551
+ /** Filter criteria for accounts */
552
+ filter?: any;
553
+ /** Limit number of results */
554
+ limit?: number;
555
+ /** Auto-fetch on mount (default: true) */
556
+ autoFetch?: boolean;
557
+ }
558
+ /** Brand info included with account */
559
+ interface AccountBrand {
560
+ id: string;
561
+ name: string;
562
+ status?: string;
563
+ }
564
+ /** Extended account type with brands relationship */
565
+ type AccountWithBrands = Account & {
566
+ brands: AccountBrand[];
567
+ brandCount: number;
568
+ deletedAt?: string;
569
+ deletedBy?: string;
570
+ };
571
+ interface UseAccountsReturn {
572
+ /** Reactive array of accounts with brands */
573
+ accounts: Ref<AccountWithBrands[]>;
574
+ /** Loading state */
575
+ loading: Ref<boolean>;
576
+ /** Error state */
577
+ error: Ref<Error | null>;
578
+ /** Refetch accounts */
579
+ refetch: () => Promise<void>;
580
+ }
581
+ /**
582
+ * Composable for fetching and managing accounts
583
+ *
584
+ * @example
585
+ * ```typescript
586
+ * import { useAccounts } from '@htlkg/data/hooks';
587
+ *
588
+ * const { accounts, loading, error, refetch } = useAccounts();
589
+ * ```
590
+ *
591
+ * @example With filters
592
+ * ```typescript
593
+ * const { accounts, loading } = useAccounts({
594
+ * filter: { status: { eq: 'active' } },
595
+ * limit: 50
596
+ * });
597
+ * ```
598
+ */
599
+ declare function useAccounts(options?: UseAccountsOptions): UseAccountsReturn;
600
+
601
+ /**
602
+ * Paginated Accounts Hooks
603
+ *
604
+ * Vue composables for fetching accounts with server-side pagination.
605
+ * Provides separate hooks for active and deleted accounts to enable
606
+ * efficient tab-based filtering in large datasets.
607
+ */
608
+
609
+ interface UsePaginatedAccountsOptions extends PaginatedHookOptions {
610
+ }
611
+ interface UsePaginatedAccountsReturn {
612
+ /** Reactive array of accounts with brands */
613
+ accounts: Ref<AccountWithBrands[]>;
614
+ /** Loading state (true during any fetch) */
615
+ loading: Ref<boolean>;
616
+ /** Loading state for initial fetch */
617
+ initialLoading: Ref<boolean>;
618
+ /** Loading state for loadMore */
619
+ loadingMore: Ref<boolean>;
620
+ /** Error state */
621
+ error: Ref<Error | null>;
622
+ /** Pagination state */
623
+ pagination: Ref<PaginationState>;
624
+ /** Whether there are more items to load */
625
+ hasMore: ComputedRef<boolean>;
626
+ /** Load next page of data */
627
+ loadMore: () => Promise<void>;
628
+ /** Refetch data (resets to first page) */
629
+ refetch: () => Promise<void>;
630
+ /** Reset data and pagination state */
631
+ reset: () => void;
632
+ /** Update search filter and refetch from server (searches ALL data) */
633
+ setSearchFilter: (filter: any) => Promise<void>;
634
+ /** Current search filter */
635
+ searchFilter: Ref<any>;
636
+ }
637
+ /**
638
+ * Composable for fetching active (non-deleted) accounts with pagination
639
+ *
640
+ * @example
641
+ * ```typescript
642
+ * import { useActiveAccounts } from '@htlkg/data/hooks';
643
+ *
644
+ * const { accounts, loading, hasMore, loadMore, refetch } = useActiveAccounts({
645
+ * pageSize: 25,
646
+ * });
647
+ *
648
+ * // Load more when user scrolls or clicks "Load More"
649
+ * async function onLoadMore() {
650
+ * await loadMore();
651
+ * }
652
+ * ```
653
+ */
654
+ declare function useActiveAccounts(options?: UsePaginatedAccountsOptions): UsePaginatedAccountsReturn;
655
+ /**
656
+ * Composable for fetching deleted accounts with pagination
657
+ *
658
+ * @example
659
+ * ```typescript
660
+ * import { useDeletedAccounts } from '@htlkg/data/hooks';
661
+ *
662
+ * const { accounts, loading, hasMore, loadMore, refetch } = useDeletedAccounts({
663
+ * pageSize: 25,
664
+ * });
665
+ * ```
666
+ */
667
+ declare function useDeletedAccounts(options?: UsePaginatedAccountsOptions): UsePaginatedAccountsReturn;
668
+
669
+ /**
670
+ * useReservations Hook
671
+ *
672
+ * Vue composable for fetching and managing reservation data with reactive state.
673
+ * Provides loading states, error handling, pagination, and refetch capabilities.
674
+ */
675
+
676
+ interface UseReservationsOptions extends BaseHookOptions {
677
+ /** Filter by brand ID */
678
+ brandId?: string;
679
+ /** Filter by start date (check-in date >= startDate) */
680
+ startDate?: string;
681
+ /** Filter by end date (check-in date <= endDate) */
682
+ endDate?: string;
683
+ /** Filter by reservation status */
684
+ status?: Reservation["status"];
685
+ /** Filter by contact/visit ID */
686
+ contactId?: string;
687
+ /** Pagination token for fetching next page */
688
+ nextToken?: string;
689
+ }
690
+ /** Extended reservation type with related data */
691
+ type ReservationWithRelations = Reservation & {
692
+ brandName: string;
693
+ guestName: string;
694
+ guestEmail: string;
695
+ guestPhone: string;
696
+ };
697
+ interface UseReservationsReturn {
698
+ /** Reactive array of reservations with brand and guest info */
699
+ reservations: Ref<ReservationWithRelations[]>;
700
+ /** Computed array of confirmed reservations */
701
+ confirmedReservations: ComputedRef<ReservationWithRelations[]>;
702
+ /** Computed array of active reservations (confirmed or checked_in) */
703
+ activeReservations: ComputedRef<ReservationWithRelations[]>;
704
+ /** Loading state */
705
+ loading: Ref<boolean>;
706
+ /** Error state */
707
+ error: Ref<Error | null>;
708
+ /** Refetch reservations */
709
+ refetch: () => Promise<void>;
710
+ }
711
+ /**
712
+ * Composable for fetching and managing reservations
713
+ *
714
+ * @example
715
+ * ```typescript
716
+ * import { useReservations } from '@htlkg/data/hooks';
717
+ *
718
+ * const { reservations, loading, error, refetch } = useReservations({
719
+ * brandId: 'brand-123',
720
+ * startDate: '2026-01-01',
721
+ * endDate: '2026-01-31',
722
+ * status: 'confirmed'
723
+ * });
724
+ * ```
725
+ *
726
+ * @example With contact filter
727
+ * ```typescript
728
+ * const { reservations, loading } = useReservations({
729
+ * contactId: 'contact-123',
730
+ * limit: 50
731
+ * });
732
+ * ```
733
+ *
734
+ * @example With computed properties
735
+ * ```typescript
736
+ * const { reservations, activeReservations, confirmedReservations } = useReservations({
737
+ * brandId: 'brand-123'
738
+ * });
739
+ *
740
+ * // activeReservations includes confirmed + checked_in
741
+ * // confirmedReservations includes only confirmed
742
+ * ```
743
+ */
744
+ declare function useReservations(options?: UseReservationsOptions): UseReservationsReturn;
745
+
746
+ /**
747
+ * Paginated Reservations Hooks
748
+ *
749
+ * Vue composables for fetching reservations with server-side pagination.
750
+ * Provides separate hooks for active and deleted reservations to enable
751
+ * efficient tab-based filtering in large datasets.
752
+ */
753
+
754
+ interface UsePaginatedReservationsOptions extends PaginatedHookOptions {
755
+ /** Filter by brand ID */
756
+ brandId?: string;
757
+ /** Filter by start date (check-in date >= startDate) */
758
+ startDate?: string;
759
+ /** Filter by end date (check-in date <= endDate) */
760
+ endDate?: string;
761
+ /** Filter by reservation status */
762
+ status?: Reservation["status"];
763
+ /** Filter by contact/visit ID */
764
+ contactId?: string;
765
+ }
766
+ interface UsePaginatedReservationsReturn {
767
+ /** Reactive array of reservations with brand and guest info */
768
+ reservations: Ref<ReservationWithRelations[]>;
769
+ /** Loading state (true during any fetch) */
770
+ loading: Ref<boolean>;
771
+ /** Loading state for initial fetch */
772
+ initialLoading: Ref<boolean>;
773
+ /** Loading state for loadMore */
774
+ loadingMore: Ref<boolean>;
775
+ /** Error state */
776
+ error: Ref<Error | null>;
777
+ /** Pagination state */
778
+ pagination: Ref<PaginationState>;
779
+ /** Whether there are more items to load */
780
+ hasMore: ComputedRef<boolean>;
781
+ /** Load next page of data */
782
+ loadMore: () => Promise<void>;
783
+ /** Refetch data (resets to first page) */
784
+ refetch: () => Promise<void>;
785
+ /** Reset data and pagination state */
786
+ reset: () => void;
787
+ /** Update search filter and refetch from server (searches ALL data) */
788
+ setSearchFilter: (filter: any) => Promise<void>;
789
+ /** Current search filter */
790
+ searchFilter: Ref<any>;
791
+ }
792
+ /**
793
+ * Composable for fetching active (non-deleted) reservations with pagination
794
+ *
795
+ * @example
796
+ * ```typescript
797
+ * import { useActiveReservations } from '@htlkg/data/hooks';
798
+ *
799
+ * const { reservations, loading, hasMore, loadMore, refetch } = useActiveReservations({
800
+ * pageSize: 25,
801
+ * brandId: 'brand-123',
802
+ * });
803
+ *
804
+ * // Load more when user scrolls or clicks "Load More"
805
+ * async function onLoadMore() {
806
+ * await loadMore();
807
+ * }
808
+ * ```
809
+ *
810
+ * @example With date filters
811
+ * ```typescript
812
+ * const { reservations, loading } = useActiveReservations({
813
+ * brandId: 'brand-123',
814
+ * startDate: '2026-01-01',
815
+ * endDate: '2026-01-31',
816
+ * status: 'confirmed'
817
+ * });
818
+ * ```
819
+ */
820
+ declare function useActiveReservations(options?: UsePaginatedReservationsOptions): UsePaginatedReservationsReturn;
821
+ /**
822
+ * Composable for fetching deleted reservations with pagination
823
+ *
824
+ * @example
825
+ * ```typescript
826
+ * import { useDeletedReservations } from '@htlkg/data/hooks';
827
+ *
828
+ * const { reservations, loading, hasMore, loadMore, refetch } = useDeletedReservations({
829
+ * pageSize: 25,
830
+ * });
831
+ * ```
832
+ */
833
+ declare function useDeletedReservations(options?: UsePaginatedReservationsOptions): UsePaginatedReservationsReturn;
834
+
835
+ /**
836
+ * Product Hooks
837
+ *
838
+ * Vue composables for fetching and managing product data with reactive state.
262
839
  */
263
840
 
264
841
  interface UseProductsOptions extends BaseHookOptions {
@@ -288,7 +865,7 @@ interface UseProductsReturn {
288
865
  *
289
866
  * @example
290
867
  * ```typescript
291
- * import { useProducts } from '@htlkg/data/hooks';
868
+ * import { useProducts } from '@htlkg/data/hooks/products';
292
869
  *
293
870
  * const { products, loading, error, refetch } = useProducts();
294
871
  * ```
@@ -304,9 +881,9 @@ interface UseProductsReturn {
304
881
  declare function useProducts(options?: UseProductsOptions): UseProductsReturn;
305
882
 
306
883
  /**
307
- * useProductInstances Hook
884
+ * ProductInstance Hooks
308
885
  *
309
- * Vue composable for fetching and managing product instance data with reactive state.
886
+ * Vue composables for fetching and managing product instance data with reactive state.
310
887
  * Provides loading states, error handling, refetch capabilities, and CRUD operations.
311
888
  */
312
889
 
@@ -351,7 +928,7 @@ interface UseProductInstancesReturn {
351
928
  *
352
929
  * @example
353
930
  * ```typescript
354
- * import { useProductInstances } from '@htlkg/data/hooks';
931
+ * import { useProductInstances } from '@htlkg/data/hooks/productInstances';
355
932
  *
356
933
  * const { instances, loading, error, refetch } = useProductInstances();
357
934
  * ```
@@ -376,73 +953,89 @@ interface UseProductInstancesReturn {
376
953
  declare function useProductInstances(options?: UseProductInstancesOptions): UseProductInstancesReturn;
377
954
 
378
955
  /**
379
- * useReservations Hook
956
+ * useContacts Hook
380
957
  *
381
- * Vue composable for fetching and managing reservation data with reactive state.
382
- * Provides loading states, error handling, pagination, and refetch capabilities.
958
+ * Vue composable for fetching and managing contact data with reactive state.
959
+ * Provides loading states, error handling, search, pagination, and refetch capabilities.
383
960
  */
384
961
 
385
- interface UseReservationsOptions extends BaseHookOptions {
962
+ interface UseContactsOptions extends BaseHookOptions {
386
963
  /** Filter by brand ID */
387
964
  brandId?: string;
388
- /** Filter by start date (check-in date >= startDate) */
389
- startDate?: string;
390
- /** Filter by end date (check-in date <= endDate) */
391
- endDate?: string;
392
- /** Filter by reservation status */
393
- status?: Reservation["status"];
394
- /** Filter by contact/visit ID */
395
- contactId?: string;
965
+ /** Search query (searches email, firstName, lastName) */
966
+ search?: string;
967
+ /** Filter by GDPR consent */
968
+ gdprConsent?: boolean;
969
+ /** Filter by marketing opt-in */
970
+ marketingOptIn?: boolean;
971
+ /** Filter by tags (contact must have at least one of these tags) */
972
+ tags?: string[];
396
973
  /** Pagination token for fetching next page */
397
974
  nextToken?: string;
398
975
  }
399
- interface UseReservationsReturn {
400
- /** Reactive array of reservations */
401
- reservations: Ref<Reservation[]>;
402
- /** Computed array of confirmed reservations */
403
- confirmedReservations: ComputedRef<Reservation[]>;
404
- /** Computed array of active reservations (confirmed or checked_in) */
405
- activeReservations: ComputedRef<Reservation[]>;
976
+ interface UseContactsReturn {
977
+ /** Reactive array of contacts */
978
+ contacts: Ref<Contact[]>;
979
+ /** Computed array of contacts with GDPR consent */
980
+ consentedContacts: ComputedRef<Contact[]>;
981
+ /** Computed array of contacts opted-in for marketing */
982
+ marketingContacts: ComputedRef<Contact[]>;
406
983
  /** Loading state */
407
984
  loading: Ref<boolean>;
408
985
  /** Error state */
409
986
  error: Ref<Error | null>;
410
- /** Refetch reservations */
987
+ /** Refetch contacts */
411
988
  refetch: () => Promise<void>;
412
989
  }
413
990
  /**
414
- * Composable for fetching and managing reservations
991
+ * Composable for fetching and managing contacts
415
992
  *
416
993
  * @example
417
994
  * ```typescript
418
- * import { useReservations } from '@htlkg/data/hooks';
995
+ * import { useContacts } from '@htlkg/data/hooks';
419
996
  *
420
- * const { reservations, loading, error, refetch } = useReservations({
997
+ * const { contacts, loading, error, refetch } = useContacts({
421
998
  * brandId: 'brand-123',
422
- * startDate: '2026-01-01',
423
- * endDate: '2026-01-31',
424
- * status: 'confirmed'
999
+ * limit: 25
425
1000
  * });
426
1001
  * ```
427
1002
  *
428
- * @example With contact filter
1003
+ * @example With search
429
1004
  * ```typescript
430
- * const { reservations, loading } = useReservations({
431
- * contactId: 'contact-123',
432
- * limit: 50
1005
+ * const { contacts, loading } = useContacts({
1006
+ * brandId: 'brand-123',
1007
+ * search: 'john',
1008
+ * limit: 25
1009
+ * });
1010
+ * ```
1011
+ *
1012
+ * @example With GDPR and marketing filters
1013
+ * ```typescript
1014
+ * const { contacts, marketingContacts } = useContacts({
1015
+ * brandId: 'brand-123',
1016
+ * gdprConsent: true,
1017
+ * marketingOptIn: true
433
1018
  * });
434
1019
  * ```
435
1020
  *
436
1021
  * @example With computed properties
437
1022
  * ```typescript
438
- * const { reservations, activeReservations, confirmedReservations } = useReservations({
1023
+ * const { contacts, consentedContacts, marketingContacts } = useContacts({
439
1024
  * brandId: 'brand-123'
440
1025
  * });
441
1026
  *
442
- * // activeReservations includes confirmed + checked_in
443
- * // confirmedReservations includes only confirmed
1027
+ * // consentedContacts - contacts with GDPR consent
1028
+ * // marketingContacts - contacts opted-in for marketing
1029
+ * ```
1030
+ *
1031
+ * @example With tag filtering
1032
+ * ```typescript
1033
+ * const { contacts } = useContacts({
1034
+ * brandId: 'brand-123',
1035
+ * tags: ['vip', 'returning']
1036
+ * });
444
1037
  * ```
445
1038
  */
446
- declare function useReservations(options?: UseReservationsOptions): UseReservationsReturn;
1039
+ declare function useContacts(options?: UseContactsOptions): UseContactsReturn;
447
1040
 
448
- export { type BaseHookOptions, type CreateDataHookOptions, type DataHookReturn, type InferHookReturn, type UseAccountsOptions, type UseAccountsReturn, type UseBrandsOptions, type UseBrandsReturn, type UseProductInstancesOptions, type UseProductInstancesReturn, type UseProductsOptions, type UseProductsReturn, type UseReservationsOptions, type UseReservationsReturn, type UseUsersOptions, type UseUsersReturn, createDataHook, resetClientInstance, useAccounts, useBrands, useProductInstances, useProducts, useReservations, useUsers };
1041
+ export { ACTIVE_FILTER, type AccountWithBrands, type BaseHookOptions, type BrandWithCounts, 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 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, useActiveReservations, useActiveUsers, useBrands, useContacts, useDeletedAccounts, useDeletedBrands, useDeletedReservations, useDeletedUsers, useProductInstances, useProducts, useReservations, useUsers };