@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.
@@ -1,716 +1,6 @@
1
- import { C as CreateAuditFields, a as UpdateWithSoftDeleteFields } from '../common-DSxswsZ3.js';
2
- export { S as SoftDeleteFields, U as UpdateAuditFields } from '../common-DSxswsZ3.js';
3
- import { Brand, Account, User, SystemSettings, Contact } from '@htlkg/core/types';
1
+ export { C as CreateAuditFields, S as SoftDeleteFields, U as UpdateAuditFields, a as UpdateWithSoftDeleteFields } from '../common-DSxswsZ3.js';
2
+ export { D as ContactValidationError, h as CreateAccountInput, C as CreateBrandInput, H as CreateContactInput, o as CreateUserInput, M as MergeContactsInput, J as MergeContactsResult, i as UpdateAccountInput, U as UpdateBrandInput, I as UpdateContactInput, v as UpdateSystemSettingsInput, p as UpdateUserInput, a as createAccount, c as createBrand, w as createContact, E as createContactSchema, j as createUser, e as deleteAccount, d as deleteBrand, y as deleteContact, l as deleteUser, t as initializeSystemSettings, B as mergeContacts, G as mergeContactsSchema, g as restoreAccount, r as restoreBrand, A as restoreContact, n as restoreUser, f as softDeleteAccount, s as softDeleteBrand, z as softDeleteContact, m as softDeleteUser, b as updateAccount, u as updateBrand, x as updateContact, F as updateContactSchema, q as updateSystemSettings, k as updateUser } from '../index-ZmmFz38a.js';
4
3
  export { C as CreateProductInstanceInput, U as UpdateProductInstanceInput, c as createProductInstance, d as deleteProductInstance, t as toggleProductInstanceEnabled, u as updateProductInstance } from '../productInstances-BpQv1oLS.js';
5
4
  export { C as CreateReservationInput, b as ReservationStatus, R as ReservationValidationError, U as UpdateReservationInput, c as createReservation, d as deleteReservation, r as restoreReservation, s as softDeleteReservation, u as updateReservation, a as updateReservationStatus } from '../reservations-CdDfkcZ_.js';
6
- import { z } from 'zod';
7
-
8
- /**
9
- * Brand Mutation Functions
10
- *
11
- * Provides mutation functions for creating, updating, and deleting brands.
12
- */
13
-
14
- /**
15
- * Input type for creating a brand
16
- */
17
- interface CreateBrandInput extends CreateAuditFields {
18
- accountId: string;
19
- name: string;
20
- logo?: string;
21
- timezone?: string;
22
- status?: "active" | "inactive" | "maintenance" | "suspended" | "deleted";
23
- settings?: Record<string, any>;
24
- }
25
- /**
26
- * Input type for updating a brand
27
- */
28
- interface UpdateBrandInput extends UpdateWithSoftDeleteFields {
29
- id: string;
30
- name?: string;
31
- logo?: string;
32
- timezone?: string;
33
- status?: "active" | "inactive" | "maintenance" | "suspended" | "deleted";
34
- settings?: Record<string, any>;
35
- }
36
- /**
37
- * Create a new brand
38
- *
39
- * @example
40
- * ```typescript
41
- * import { createBrand } from '@htlkg/data/mutations';
42
- * import { generateClient } from '@htlkg/data/client';
43
- *
44
- * const client = generateClient<Schema>();
45
- * const brand = await createBrand(client, {
46
- * accountId: 'account-123',
47
- * name: 'My Brand',
48
- * timezone: 'America/New_York',
49
- * status: 'active'
50
- * });
51
- * ```
52
- */
53
- declare function createBrand<TClient = any>(client: TClient, input: CreateBrandInput): Promise<Brand | null>;
54
- /**
55
- * Update an existing brand
56
- *
57
- * @example
58
- * ```typescript
59
- * import { updateBrand } from '@htlkg/data/mutations';
60
- * import { generateClient } from '@htlkg/data/client';
61
- *
62
- * const client = generateClient<Schema>();
63
- * const brand = await updateBrand(client, {
64
- * id: 'brand-123',
65
- * name: 'Updated Brand Name',
66
- * status: 'maintenance'
67
- * });
68
- * ```
69
- */
70
- declare function updateBrand<TClient = any>(client: TClient, input: UpdateBrandInput): Promise<Brand | null>;
71
- /**
72
- * Soft delete a brand (sets status to "deleted" instead of removing)
73
- *
74
- * @example
75
- * ```typescript
76
- * import { softDeleteBrand } from '@htlkg/data/mutations';
77
- * import { generateClient } from '@htlkg/data/client';
78
- *
79
- * const client = generateClient<Schema>();
80
- * await softDeleteBrand(client, 'brand-123', 'admin@example.com');
81
- * ```
82
- */
83
- declare function softDeleteBrand<TClient = any>(client: TClient, id: string, deletedBy: string): Promise<boolean>;
84
- /**
85
- * Restore a soft-deleted brand (sets status back to "active")
86
- * Checks retention period before allowing restoration
87
- *
88
- * @example
89
- * ```typescript
90
- * import { restoreBrand } from '@htlkg/data/mutations';
91
- * import { generateClient } from '@htlkg/data/client';
92
- *
93
- * const client = generateClient<Schema>();
94
- * await restoreBrand(client, 'brand-123');
95
- * // Or with custom retention days:
96
- * await restoreBrand(client, 'brand-123', 60);
97
- * ```
98
- */
99
- declare function restoreBrand<TClient = any>(client: TClient, id: string, retentionDays?: number): Promise<{
100
- success: boolean;
101
- error?: string;
102
- }>;
103
- /**
104
- * Hard delete a brand (permanently removes from database)
105
- * Use with caution - prefer softDeleteBrand for recoverable deletion
106
- *
107
- * @example
108
- * ```typescript
109
- * import { deleteBrand } from '@htlkg/data/mutations';
110
- * import { generateClient } from '@htlkg/data/client';
111
- *
112
- * const client = generateClient<Schema>();
113
- * await deleteBrand(client, 'brand-123');
114
- * ```
115
- */
116
- declare function deleteBrand<TClient = any>(client: TClient, id: string): Promise<boolean>;
117
-
118
- /**
119
- * Account Mutation Functions
120
- *
121
- * Provides mutation functions for creating, updating, and deleting accounts.
122
- */
123
-
124
- /**
125
- * Input type for creating an account
126
- */
127
- interface CreateAccountInput extends CreateAuditFields {
128
- name: string;
129
- logo?: string;
130
- subscription?: Record<string, any>;
131
- settings?: Record<string, any>;
132
- status?: "active" | "inactive" | "deleted";
133
- }
134
- /**
135
- * Input type for updating an account
136
- */
137
- interface UpdateAccountInput extends UpdateWithSoftDeleteFields {
138
- id: string;
139
- name?: string;
140
- logo?: string;
141
- subscription?: Record<string, any>;
142
- settings?: Record<string, any>;
143
- status?: "active" | "inactive" | "deleted";
144
- }
145
- /**
146
- * Create a new account
147
- *
148
- * @example
149
- * ```typescript
150
- * import { createAccount } from '@htlkg/data/mutations';
151
- * import { generateClient } from '@htlkg/data/client';
152
- *
153
- * const client = generateClient<Schema>();
154
- * const account = await createAccount(client, {
155
- * name: 'My Account',
156
- * subscription: { plan: 'premium' }
157
- * });
158
- * ```
159
- */
160
- declare function createAccount<TClient = any>(client: TClient, input: CreateAccountInput): Promise<Account | null>;
161
- /**
162
- * Update an existing account
163
- *
164
- * @example
165
- * ```typescript
166
- * import { updateAccount } from '@htlkg/data/mutations';
167
- * import { generateClient } from '@htlkg/data/client';
168
- *
169
- * const client = generateClient<Schema>();
170
- * const account = await updateAccount(client, {
171
- * id: 'account-123',
172
- * name: 'Updated Account Name'
173
- * });
174
- * ```
175
- */
176
- declare function updateAccount<TClient = any>(client: TClient, input: UpdateAccountInput): Promise<Account | null>;
177
- /**
178
- * Soft delete an account (sets status to "deleted" instead of removing)
179
- *
180
- * @example
181
- * ```typescript
182
- * import { softDeleteAccount } from '@htlkg/data/mutations';
183
- * import { generateClient } from '@htlkg/data/client';
184
- *
185
- * const client = generateClient<Schema>();
186
- * await softDeleteAccount(client, 'account-123', 'admin@example.com');
187
- * ```
188
- */
189
- declare function softDeleteAccount<TClient = any>(client: TClient, id: string, deletedBy: string): Promise<boolean>;
190
- /**
191
- * Restore a soft-deleted account (sets status back to "active")
192
- * Checks retention period before allowing restoration
193
- *
194
- * @example
195
- * ```typescript
196
- * import { restoreAccount } from '@htlkg/data/mutations';
197
- * import { generateClient } from '@htlkg/data/client';
198
- *
199
- * const client = generateClient<Schema>();
200
- * await restoreAccount(client, 'account-123');
201
- * // Or with custom retention days:
202
- * await restoreAccount(client, 'account-123', 60);
203
- * ```
204
- */
205
- declare function restoreAccount<TClient = any>(client: TClient, id: string, retentionDays?: number): Promise<{
206
- success: boolean;
207
- error?: string;
208
- }>;
209
- /**
210
- * Hard delete an account (permanently removes from database)
211
- * Use with caution - prefer softDeleteAccount for recoverable deletion
212
- *
213
- * @example
214
- * ```typescript
215
- * import { deleteAccount } from '@htlkg/data/mutations';
216
- * import { generateClient } from '@htlkg/data/client';
217
- *
218
- * const client = generateClient<Schema>();
219
- * await deleteAccount(client, 'account-123');
220
- * ```
221
- */
222
- declare function deleteAccount<TClient = any>(client: TClient, id: string): Promise<boolean>;
223
-
224
- /**
225
- * User Mutation Functions
226
- *
227
- * Provides mutation functions for creating, updating, and deleting users.
228
- */
229
-
230
- /**
231
- * Input type for creating a user
232
- */
233
- interface CreateUserInput extends CreateAuditFields {
234
- cognitoId: string;
235
- email: string;
236
- accountId: string;
237
- brandIds?: string[];
238
- roles?: string[];
239
- permissions?: Record<string, any>;
240
- status?: "active" | "inactive" | "pending" | "suspended" | "deleted";
241
- }
242
- /**
243
- * Input type for updating a user
244
- */
245
- interface UpdateUserInput extends UpdateWithSoftDeleteFields {
246
- id: string;
247
- email?: string;
248
- brandIds?: string[];
249
- roles?: string[];
250
- permissions?: Record<string, any>;
251
- lastLogin?: string;
252
- status?: "active" | "inactive" | "pending" | "suspended" | "deleted";
253
- }
254
- /**
255
- * Create a new user
256
- *
257
- * @example
258
- * ```typescript
259
- * import { createUser } from '@htlkg/data/mutations';
260
- * import { generateClient } from '@htlkg/data/client';
261
- *
262
- * const client = generateClient<Schema>();
263
- * const user = await createUser(client, {
264
- * cognitoId: 'cognito-123',
265
- * email: 'user@example.com',
266
- * accountId: 'account-123',
267
- * roles: ['BRAND_ADMIN'],
268
- * status: 'active'
269
- * });
270
- * ```
271
- */
272
- declare function createUser<TClient = any>(client: TClient, input: CreateUserInput): Promise<User | null>;
273
- /**
274
- * Update an existing user
275
- *
276
- * @example
277
- * ```typescript
278
- * import { updateUser } from '@htlkg/data/mutations';
279
- * import { generateClient } from '@htlkg/data/client';
280
- *
281
- * const client = generateClient<Schema>();
282
- * const user = await updateUser(client, {
283
- * id: 'user-123',
284
- * roles: ['BRAND_ADMIN', 'ACCOUNT_ADMIN'],
285
- * status: 'active'
286
- * });
287
- * ```
288
- */
289
- declare function updateUser<TClient = any>(client: TClient, input: UpdateUserInput): Promise<User | null>;
290
- /**
291
- * Soft delete a user (sets status to "deleted" instead of removing)
292
- *
293
- * @example
294
- * ```typescript
295
- * import { softDeleteUser } from '@htlkg/data/mutations';
296
- * import { generateClient } from '@htlkg/data/client';
297
- *
298
- * const client = generateClient<Schema>();
299
- * await softDeleteUser(client, 'user-123', 'admin@example.com');
300
- * ```
301
- */
302
- declare function softDeleteUser<TClient = any>(client: TClient, id: string, deletedBy: string): Promise<boolean>;
303
- /**
304
- * Restore a soft-deleted user (sets status back to "active")
305
- * Checks retention period before allowing restoration
306
- *
307
- * @example
308
- * ```typescript
309
- * import { restoreUser } from '@htlkg/data/mutations';
310
- * import { generateClient } from '@htlkg/data/client';
311
- *
312
- * const client = generateClient<Schema>();
313
- * await restoreUser(client, 'user-123');
314
- * // Or with custom retention days:
315
- * await restoreUser(client, 'user-123', 60);
316
- * ```
317
- */
318
- declare function restoreUser<TClient = any>(client: TClient, id: string, retentionDays?: number): Promise<{
319
- success: boolean;
320
- error?: string;
321
- }>;
322
- /**
323
- * Hard delete a user (permanently removes from database)
324
- * Use with caution - prefer softDeleteUser for recoverable deletion
325
- *
326
- * @example
327
- * ```typescript
328
- * import { deleteUser } from '@htlkg/data/mutations';
329
- * import { generateClient } from '@htlkg/data/client';
330
- *
331
- * const client = generateClient<Schema>();
332
- * await deleteUser(client, 'user-123');
333
- * ```
334
- */
335
- declare function deleteUser<TClient = any>(client: TClient, id: string): Promise<boolean>;
336
-
337
- /**
338
- * SystemSettings Mutation Functions
339
- *
340
- * Provides mutation functions for managing system settings.
341
- */
342
-
343
- /**
344
- * Input type for updating system settings
345
- */
346
- interface UpdateSystemSettingsInput {
347
- softDeleteRetentionDays: number;
348
- updatedBy: string;
349
- }
350
- /**
351
- * Update or create system settings
352
- * Only SUPER_ADMINS can update system settings
353
- *
354
- * @example
355
- * ```typescript
356
- * import { updateSystemSettings } from '@htlkg/data/mutations';
357
- * import { generateClient } from '@htlkg/data/client';
358
- *
359
- * const client = generateClient<Schema>();
360
- * const settings = await updateSystemSettings(client, {
361
- * softDeleteRetentionDays: 60,
362
- * updatedBy: 'admin@example.com'
363
- * });
364
- * ```
365
- */
366
- declare function updateSystemSettings<TClient = any>(client: TClient, input: UpdateSystemSettingsInput): Promise<SystemSettings | null>;
367
- /**
368
- * Initialize system settings with default values if they don't exist
369
- *
370
- * @example
371
- * ```typescript
372
- * import { initializeSystemSettings } from '@htlkg/data/mutations';
373
- * import { generateClient } from '@htlkg/data/client';
374
- *
375
- * const client = generateClient<Schema>();
376
- * const settings = await initializeSystemSettings(client, 'system@hotelinking.com');
377
- * ```
378
- */
379
- declare function initializeSystemSettings<TClient = any>(client: TClient, initializedBy: string): Promise<SystemSettings | null>;
380
-
381
- /**
382
- * Contact Mutation Functions
383
- *
384
- * Provides type-safe mutation functions for creating, updating, and deleting contacts.
385
- * Includes Zod validation for input data before mutations.
386
- */
387
-
388
- /**
389
- * Zod schema for creating a contact
390
- */
391
- declare const createContactSchema: z.ZodObject<{
392
- brandId: z.ZodString;
393
- email: z.ZodString;
394
- phone: z.ZodOptional<z.ZodString>;
395
- firstName: z.ZodString;
396
- lastName: z.ZodString;
397
- locale: z.ZodOptional<z.ZodString>;
398
- gdprConsent: z.ZodBoolean;
399
- gdprConsentDate: z.ZodOptional<z.ZodString>;
400
- marketingOptIn: z.ZodOptional<z.ZodBoolean>;
401
- preferences: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
402
- tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
403
- totalVisits: z.ZodOptional<z.ZodNumber>;
404
- lastVisitDate: z.ZodOptional<z.ZodString>;
405
- firstVisitDate: z.ZodOptional<z.ZodString>;
406
- legacyId: z.ZodOptional<z.ZodString>;
407
- createdAt: z.ZodOptional<z.ZodString>;
408
- createdBy: z.ZodOptional<z.ZodString>;
409
- updatedAt: z.ZodOptional<z.ZodString>;
410
- updatedBy: z.ZodOptional<z.ZodString>;
411
- }, "strip", z.ZodTypeAny, {
412
- brandId: string;
413
- email: string;
414
- lastName: string;
415
- firstName: string;
416
- gdprConsent: boolean;
417
- updatedAt?: string | undefined;
418
- updatedBy?: string | undefined;
419
- phone?: string | undefined;
420
- locale?: string | undefined;
421
- gdprConsentDate?: string | undefined;
422
- marketingOptIn?: boolean | undefined;
423
- preferences?: Record<string, any> | undefined;
424
- tags?: string[] | undefined;
425
- totalVisits?: number | undefined;
426
- lastVisitDate?: string | undefined;
427
- firstVisitDate?: string | undefined;
428
- legacyId?: string | undefined;
429
- createdAt?: string | undefined;
430
- createdBy?: string | undefined;
431
- }, {
432
- brandId: string;
433
- email: string;
434
- lastName: string;
435
- firstName: string;
436
- gdprConsent: boolean;
437
- updatedAt?: string | undefined;
438
- updatedBy?: string | undefined;
439
- phone?: string | undefined;
440
- locale?: string | undefined;
441
- gdprConsentDate?: string | undefined;
442
- marketingOptIn?: boolean | undefined;
443
- preferences?: Record<string, any> | undefined;
444
- tags?: string[] | undefined;
445
- totalVisits?: number | undefined;
446
- lastVisitDate?: string | undefined;
447
- firstVisitDate?: string | undefined;
448
- legacyId?: string | undefined;
449
- createdAt?: string | undefined;
450
- createdBy?: string | undefined;
451
- }>;
452
- /**
453
- * Zod schema for updating a contact
454
- */
455
- declare const updateContactSchema: z.ZodObject<{
456
- id: z.ZodString;
457
- brandId: z.ZodOptional<z.ZodString>;
458
- email: z.ZodOptional<z.ZodString>;
459
- phone: z.ZodOptional<z.ZodString>;
460
- firstName: z.ZodOptional<z.ZodString>;
461
- lastName: z.ZodOptional<z.ZodString>;
462
- locale: z.ZodOptional<z.ZodString>;
463
- gdprConsent: z.ZodOptional<z.ZodBoolean>;
464
- gdprConsentDate: z.ZodOptional<z.ZodString>;
465
- marketingOptIn: z.ZodOptional<z.ZodBoolean>;
466
- preferences: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
467
- tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
468
- totalVisits: z.ZodOptional<z.ZodNumber>;
469
- lastVisitDate: z.ZodOptional<z.ZodString>;
470
- firstVisitDate: z.ZodOptional<z.ZodString>;
471
- legacyId: z.ZodOptional<z.ZodString>;
472
- updatedAt: z.ZodOptional<z.ZodString>;
473
- updatedBy: z.ZodOptional<z.ZodString>;
474
- deletedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
475
- deletedBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
476
- }, "strip", z.ZodTypeAny, {
477
- id: string;
478
- updatedAt?: string | undefined;
479
- updatedBy?: string | undefined;
480
- brandId?: string | undefined;
481
- deletedAt?: string | null | undefined;
482
- deletedBy?: string | null | undefined;
483
- email?: string | undefined;
484
- phone?: string | undefined;
485
- lastName?: string | undefined;
486
- firstName?: string | undefined;
487
- locale?: string | undefined;
488
- gdprConsent?: boolean | undefined;
489
- gdprConsentDate?: string | undefined;
490
- marketingOptIn?: boolean | undefined;
491
- preferences?: Record<string, any> | undefined;
492
- tags?: string[] | undefined;
493
- totalVisits?: number | undefined;
494
- lastVisitDate?: string | undefined;
495
- firstVisitDate?: string | undefined;
496
- legacyId?: string | undefined;
497
- }, {
498
- id: string;
499
- updatedAt?: string | undefined;
500
- updatedBy?: string | undefined;
501
- brandId?: string | undefined;
502
- deletedAt?: string | null | undefined;
503
- deletedBy?: string | null | undefined;
504
- email?: string | undefined;
505
- phone?: string | undefined;
506
- lastName?: string | undefined;
507
- firstName?: string | undefined;
508
- locale?: string | undefined;
509
- gdprConsent?: boolean | undefined;
510
- gdprConsentDate?: string | undefined;
511
- marketingOptIn?: boolean | undefined;
512
- preferences?: Record<string, any> | undefined;
513
- tags?: string[] | undefined;
514
- totalVisits?: number | undefined;
515
- lastVisitDate?: string | undefined;
516
- firstVisitDate?: string | undefined;
517
- legacyId?: string | undefined;
518
- }>;
519
- /**
520
- * Zod schema for merging contacts
521
- */
522
- declare const mergeContactsSchema: z.ZodObject<{
523
- primaryId: z.ZodString;
524
- duplicateIds: z.ZodArray<z.ZodString, "many">;
525
- }, "strip", z.ZodTypeAny, {
526
- primaryId: string;
527
- duplicateIds: string[];
528
- }, {
529
- primaryId: string;
530
- duplicateIds: string[];
531
- }>;
532
- /**
533
- * Validation error class for contact operations
534
- */
535
- declare class ContactValidationError extends Error {
536
- readonly issues: z.ZodIssue[];
537
- constructor(message: string, issues?: z.ZodIssue[]);
538
- }
539
- /**
540
- * Input type for creating a contact
541
- */
542
- interface CreateContactInput extends CreateAuditFields {
543
- brandId: string;
544
- email: string;
545
- phone?: string;
546
- firstName: string;
547
- lastName: string;
548
- locale?: string;
549
- gdprConsent: boolean;
550
- gdprConsentDate?: string;
551
- marketingOptIn?: boolean;
552
- preferences?: Record<string, any>;
553
- tags?: string[];
554
- totalVisits?: number;
555
- lastVisitDate?: string;
556
- firstVisitDate?: string;
557
- legacyId?: string;
558
- }
559
- /**
560
- * Input type for updating a contact
561
- */
562
- interface UpdateContactInput extends UpdateWithSoftDeleteFields {
563
- id: string;
564
- brandId?: string;
565
- email?: string;
566
- phone?: string;
567
- firstName?: string;
568
- lastName?: string;
569
- locale?: string;
570
- gdprConsent?: boolean;
571
- gdprConsentDate?: string;
572
- marketingOptIn?: boolean;
573
- preferences?: Record<string, any>;
574
- tags?: string[];
575
- totalVisits?: number;
576
- lastVisitDate?: string;
577
- firstVisitDate?: string;
578
- legacyId?: string;
579
- }
580
- /**
581
- * Input type for merging contacts
582
- */
583
- interface MergeContactsInput {
584
- primaryId: string;
585
- duplicateIds: string[];
586
- }
587
- /**
588
- * Result type for merge operation
589
- */
590
- interface MergeContactsResult {
591
- success: boolean;
592
- mergedContact?: Contact;
593
- deletedIds?: string[];
594
- error?: string;
595
- }
596
- /**
597
- * Create a new contact with Zod validation
598
- *
599
- * @throws {ContactValidationError} if input validation fails
600
- *
601
- * @example
602
- * ```typescript
603
- * import { createContact } from '@htlkg/data/mutations';
604
- * import { generateClient } from '@htlkg/data/client';
605
- *
606
- * const client = generateClient<Schema>();
607
- * const contact = await createContact(client, {
608
- * brandId: 'brand-123',
609
- * email: 'guest@example.com',
610
- * firstName: 'John',
611
- * lastName: 'Doe',
612
- * gdprConsent: true,
613
- * gdprConsentDate: new Date().toISOString()
614
- * });
615
- * ```
616
- */
617
- declare function createContact<TClient = any>(client: TClient, input: CreateContactInput): Promise<Contact | null>;
618
- /**
619
- * Update an existing contact with Zod validation
620
- *
621
- * @throws {ContactValidationError} if input validation fails
622
- *
623
- * @example
624
- * ```typescript
625
- * import { updateContact } from '@htlkg/data/mutations';
626
- * import { generateClient } from '@htlkg/data/client';
627
- *
628
- * const client = generateClient<Schema>();
629
- * const contact = await updateContact(client, {
630
- * id: 'contact-123',
631
- * firstName: 'Jane',
632
- * marketingOptIn: true
633
- * });
634
- * ```
635
- */
636
- declare function updateContact<TClient = any>(client: TClient, input: UpdateContactInput): Promise<Contact | null>;
637
- /**
638
- * Soft delete a contact (sets deletedAt/deletedBy instead of removing)
639
- *
640
- * @example
641
- * ```typescript
642
- * import { softDeleteContact } from '@htlkg/data/mutations';
643
- * import { generateClient } from '@htlkg/data/client';
644
- *
645
- * const client = generateClient<Schema>();
646
- * await softDeleteContact(client, 'contact-123', 'admin@example.com');
647
- * ```
648
- */
649
- declare function softDeleteContact<TClient = any>(client: TClient, id: string, deletedBy: string): Promise<boolean>;
650
- /**
651
- * Restore a soft-deleted contact
652
- * Checks retention period before allowing restoration
653
- *
654
- * @example
655
- * ```typescript
656
- * import { restoreContact } from '@htlkg/data/mutations';
657
- * import { generateClient } from '@htlkg/data/client';
658
- *
659
- * const client = generateClient<Schema>();
660
- * await restoreContact(client, 'contact-123');
661
- * // Or with custom retention days:
662
- * await restoreContact(client, 'contact-123', 60);
663
- * ```
664
- */
665
- declare function restoreContact<TClient = any>(client: TClient, id: string, retentionDays?: number): Promise<{
666
- success: boolean;
667
- error?: string;
668
- }>;
669
- /**
670
- * Hard delete a contact (permanently removes from database)
671
- * Use with caution - prefer softDeleteContact for recoverable deletion
672
- *
673
- * @example
674
- * ```typescript
675
- * import { deleteContact } from '@htlkg/data/mutations';
676
- * import { generateClient } from '@htlkg/data/client';
677
- *
678
- * const client = generateClient<Schema>();
679
- * await deleteContact(client, 'contact-123');
680
- * ```
681
- */
682
- declare function deleteContact<TClient = any>(client: TClient, id: string): Promise<boolean>;
683
- /**
684
- * Merge duplicate contacts into a primary contact
685
- *
686
- * This function:
687
- * 1. Validates all contact IDs exist
688
- * 2. Aggregates data from duplicates into the primary contact
689
- * 3. Soft deletes the duplicate contacts
690
- * 4. Returns the updated primary contact
691
- *
692
- * Merge strategy:
693
- * - totalVisits: Sum of all contacts
694
- * - firstVisitDate: Earliest date across all contacts
695
- * - lastVisitDate: Latest date across all contacts
696
- * - tags: Merged unique tags from all contacts
697
- * - preferences: Primary contact preferences take precedence
698
- * - Other fields: Primary contact values are preserved
699
- *
700
- * @throws {ContactValidationError} if input validation fails
701
- *
702
- * @example
703
- * ```typescript
704
- * import { mergeContacts } from '@htlkg/data/mutations';
705
- * import { generateClient } from '@htlkg/data/client';
706
- *
707
- * const client = generateClient<Schema>();
708
- * const result = await mergeContacts(client, {
709
- * primaryId: 'contact-primary',
710
- * duplicateIds: ['contact-dup-1', 'contact-dup-2']
711
- * }, 'admin@example.com');
712
- * ```
713
- */
714
- declare function mergeContacts<TClient = any>(client: TClient, input: MergeContactsInput, mergedBy: string): Promise<MergeContactsResult>;
715
-
716
- export { ContactValidationError, type CreateAccountInput, CreateAuditFields, type CreateBrandInput, type CreateContactInput, type CreateUserInput, type MergeContactsInput, type MergeContactsResult, type UpdateAccountInput, type UpdateBrandInput, type UpdateContactInput, type UpdateSystemSettingsInput, type UpdateUserInput, UpdateWithSoftDeleteFields, createAccount, createBrand, createContact, createContactSchema, createUser, deleteAccount, deleteBrand, deleteContact, deleteUser, initializeSystemSettings, mergeContacts, mergeContactsSchema, restoreAccount, restoreBrand, restoreContact, restoreUser, softDeleteAccount, softDeleteBrand, softDeleteContact, softDeleteUser, updateAccount, updateBrand, updateContact, updateContactSchema, updateSystemSettings, updateUser };
5
+ import '@htlkg/core/types';
6
+ import 'zod';