@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
|
@@ -0,0 +1,1089 @@
|
|
|
1
|
+
import { C as CreateAuditFields, a as UpdateWithSoftDeleteFields } from './common-DSxswsZ3.js';
|
|
2
|
+
import { Brand, Account, User, SystemSettings, Contact } from '@htlkg/core/types';
|
|
3
|
+
import './productInstances-BpQv1oLS.js';
|
|
4
|
+
import './reservations-CdDfkcZ_.js';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Brand Mutation Functions
|
|
9
|
+
*
|
|
10
|
+
* Provides mutation functions for creating, updating, and deleting brands.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Input type for creating a brand
|
|
15
|
+
*/
|
|
16
|
+
interface CreateBrandInput extends CreateAuditFields {
|
|
17
|
+
accountId: string;
|
|
18
|
+
name: string;
|
|
19
|
+
logo?: string;
|
|
20
|
+
timezone?: string;
|
|
21
|
+
status?: "active" | "inactive" | "maintenance" | "suspended" | "deleted";
|
|
22
|
+
settings?: Record<string, any>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Input type for updating a brand
|
|
26
|
+
*/
|
|
27
|
+
interface UpdateBrandInput extends UpdateWithSoftDeleteFields {
|
|
28
|
+
id: string;
|
|
29
|
+
name?: string;
|
|
30
|
+
logo?: string;
|
|
31
|
+
timezone?: string;
|
|
32
|
+
status?: "active" | "inactive" | "maintenance" | "suspended" | "deleted";
|
|
33
|
+
settings?: Record<string, any>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Create a new brand
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* import { createBrand } from '@htlkg/data/mutations';
|
|
41
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
42
|
+
*
|
|
43
|
+
* const client = generateClient<Schema>();
|
|
44
|
+
* const brand = await createBrand(client, {
|
|
45
|
+
* accountId: 'account-123',
|
|
46
|
+
* name: 'My Brand',
|
|
47
|
+
* timezone: 'America/New_York',
|
|
48
|
+
* status: 'active'
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare function createBrand<TClient = any>(client: TClient, input: CreateBrandInput): Promise<Brand | null>;
|
|
53
|
+
/**
|
|
54
|
+
* Update an existing brand
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* import { updateBrand } from '@htlkg/data/mutations';
|
|
59
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
60
|
+
*
|
|
61
|
+
* const client = generateClient<Schema>();
|
|
62
|
+
* const brand = await updateBrand(client, {
|
|
63
|
+
* id: 'brand-123',
|
|
64
|
+
* name: 'Updated Brand Name',
|
|
65
|
+
* status: 'maintenance'
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
declare function updateBrand<TClient = any>(client: TClient, input: UpdateBrandInput): Promise<Brand | null>;
|
|
70
|
+
/**
|
|
71
|
+
* Soft delete a brand (sets status to "deleted" instead of removing)
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* import { softDeleteBrand } from '@htlkg/data/mutations';
|
|
76
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
77
|
+
*
|
|
78
|
+
* const client = generateClient<Schema>();
|
|
79
|
+
* await softDeleteBrand(client, 'brand-123', 'admin@example.com');
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
declare function softDeleteBrand<TClient = any>(client: TClient, id: string, deletedBy: string): Promise<boolean>;
|
|
83
|
+
/**
|
|
84
|
+
* Restore a soft-deleted brand (sets status back to "active")
|
|
85
|
+
* Checks retention period before allowing restoration
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* import { restoreBrand } from '@htlkg/data/mutations';
|
|
90
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
91
|
+
*
|
|
92
|
+
* const client = generateClient<Schema>();
|
|
93
|
+
* await restoreBrand(client, 'brand-123');
|
|
94
|
+
* // Or with custom retention days:
|
|
95
|
+
* await restoreBrand(client, 'brand-123', 60);
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
declare function restoreBrand<TClient = any>(client: TClient, id: string, retentionDays?: number): Promise<{
|
|
99
|
+
success: boolean;
|
|
100
|
+
error?: string;
|
|
101
|
+
}>;
|
|
102
|
+
/**
|
|
103
|
+
* Hard delete a brand (permanently removes from database)
|
|
104
|
+
* Use with caution - prefer softDeleteBrand for recoverable deletion
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* import { deleteBrand } from '@htlkg/data/mutations';
|
|
109
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
110
|
+
*
|
|
111
|
+
* const client = generateClient<Schema>();
|
|
112
|
+
* await deleteBrand(client, 'brand-123');
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
declare function deleteBrand<TClient = any>(client: TClient, id: string): Promise<boolean>;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Account Mutation Functions
|
|
119
|
+
*
|
|
120
|
+
* Provides mutation functions for creating, updating, and deleting accounts.
|
|
121
|
+
*/
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Input type for creating an account
|
|
125
|
+
*/
|
|
126
|
+
interface CreateAccountInput extends CreateAuditFields {
|
|
127
|
+
name: string;
|
|
128
|
+
logo?: string;
|
|
129
|
+
subscription?: Record<string, any>;
|
|
130
|
+
settings?: Record<string, any>;
|
|
131
|
+
status?: "active" | "inactive" | "deleted";
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Input type for updating an account
|
|
135
|
+
*/
|
|
136
|
+
interface UpdateAccountInput extends UpdateWithSoftDeleteFields {
|
|
137
|
+
id: string;
|
|
138
|
+
name?: string;
|
|
139
|
+
logo?: string;
|
|
140
|
+
subscription?: Record<string, any>;
|
|
141
|
+
settings?: Record<string, any>;
|
|
142
|
+
status?: "active" | "inactive" | "deleted";
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Create a new account
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* import { createAccount } from '@htlkg/data/mutations';
|
|
150
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
151
|
+
*
|
|
152
|
+
* const client = generateClient<Schema>();
|
|
153
|
+
* const account = await createAccount(client, {
|
|
154
|
+
* name: 'My Account',
|
|
155
|
+
* subscription: { plan: 'premium' }
|
|
156
|
+
* });
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
declare function createAccount<TClient = any>(client: TClient, input: CreateAccountInput): Promise<Account | null>;
|
|
160
|
+
/**
|
|
161
|
+
* Update an existing account
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* import { updateAccount } from '@htlkg/data/mutations';
|
|
166
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
167
|
+
*
|
|
168
|
+
* const client = generateClient<Schema>();
|
|
169
|
+
* const account = await updateAccount(client, {
|
|
170
|
+
* id: 'account-123',
|
|
171
|
+
* name: 'Updated Account Name'
|
|
172
|
+
* });
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
declare function updateAccount<TClient = any>(client: TClient, input: UpdateAccountInput): Promise<Account | null>;
|
|
176
|
+
/**
|
|
177
|
+
* Soft delete an account (sets status to "deleted" instead of removing)
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* import { softDeleteAccount } from '@htlkg/data/mutations';
|
|
182
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
183
|
+
*
|
|
184
|
+
* const client = generateClient<Schema>();
|
|
185
|
+
* await softDeleteAccount(client, 'account-123', 'admin@example.com');
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
declare function softDeleteAccount<TClient = any>(client: TClient, id: string, deletedBy: string): Promise<boolean>;
|
|
189
|
+
/**
|
|
190
|
+
* Restore a soft-deleted account (sets status back to "active")
|
|
191
|
+
* Checks retention period before allowing restoration
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```typescript
|
|
195
|
+
* import { restoreAccount } from '@htlkg/data/mutations';
|
|
196
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
197
|
+
*
|
|
198
|
+
* const client = generateClient<Schema>();
|
|
199
|
+
* await restoreAccount(client, 'account-123');
|
|
200
|
+
* // Or with custom retention days:
|
|
201
|
+
* await restoreAccount(client, 'account-123', 60);
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
declare function restoreAccount<TClient = any>(client: TClient, id: string, retentionDays?: number): Promise<{
|
|
205
|
+
success: boolean;
|
|
206
|
+
error?: string;
|
|
207
|
+
}>;
|
|
208
|
+
/**
|
|
209
|
+
* Hard delete an account (permanently removes from database)
|
|
210
|
+
* Use with caution - prefer softDeleteAccount for recoverable deletion
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript
|
|
214
|
+
* import { deleteAccount } from '@htlkg/data/mutations';
|
|
215
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
216
|
+
*
|
|
217
|
+
* const client = generateClient<Schema>();
|
|
218
|
+
* await deleteAccount(client, 'account-123');
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
declare function deleteAccount<TClient = any>(client: TClient, id: string): Promise<boolean>;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* User Mutation Functions
|
|
225
|
+
*
|
|
226
|
+
* Provides mutation functions for creating, updating, and deleting users.
|
|
227
|
+
*/
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Input type for creating a user
|
|
231
|
+
*/
|
|
232
|
+
interface CreateUserInput extends CreateAuditFields {
|
|
233
|
+
cognitoId: string;
|
|
234
|
+
email: string;
|
|
235
|
+
accountId: string;
|
|
236
|
+
brandIds?: string[];
|
|
237
|
+
roles?: string[];
|
|
238
|
+
permissions?: Record<string, any>;
|
|
239
|
+
status?: "active" | "inactive" | "pending" | "suspended" | "deleted";
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Input type for updating a user
|
|
243
|
+
*/
|
|
244
|
+
interface UpdateUserInput extends UpdateWithSoftDeleteFields {
|
|
245
|
+
id: string;
|
|
246
|
+
email?: string;
|
|
247
|
+
brandIds?: string[];
|
|
248
|
+
roles?: string[];
|
|
249
|
+
permissions?: Record<string, any>;
|
|
250
|
+
lastLogin?: string;
|
|
251
|
+
status?: "active" | "inactive" | "pending" | "suspended" | "deleted";
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Create a new user
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```typescript
|
|
258
|
+
* import { createUser } from '@htlkg/data/mutations';
|
|
259
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
260
|
+
*
|
|
261
|
+
* const client = generateClient<Schema>();
|
|
262
|
+
* const user = await createUser(client, {
|
|
263
|
+
* cognitoId: 'cognito-123',
|
|
264
|
+
* email: 'user@example.com',
|
|
265
|
+
* accountId: 'account-123',
|
|
266
|
+
* roles: ['BRAND_ADMIN'],
|
|
267
|
+
* status: 'active'
|
|
268
|
+
* });
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
declare function createUser<TClient = any>(client: TClient, input: CreateUserInput): Promise<User | null>;
|
|
272
|
+
/**
|
|
273
|
+
* Update an existing user
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```typescript
|
|
277
|
+
* import { updateUser } from '@htlkg/data/mutations';
|
|
278
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
279
|
+
*
|
|
280
|
+
* const client = generateClient<Schema>();
|
|
281
|
+
* const user = await updateUser(client, {
|
|
282
|
+
* id: 'user-123',
|
|
283
|
+
* roles: ['BRAND_ADMIN', 'ACCOUNT_ADMIN'],
|
|
284
|
+
* status: 'active'
|
|
285
|
+
* });
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
declare function updateUser<TClient = any>(client: TClient, input: UpdateUserInput): Promise<User | null>;
|
|
289
|
+
/**
|
|
290
|
+
* Soft delete a user (sets status to "deleted" instead of removing)
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```typescript
|
|
294
|
+
* import { softDeleteUser } from '@htlkg/data/mutations';
|
|
295
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
296
|
+
*
|
|
297
|
+
* const client = generateClient<Schema>();
|
|
298
|
+
* await softDeleteUser(client, 'user-123', 'admin@example.com');
|
|
299
|
+
* ```
|
|
300
|
+
*/
|
|
301
|
+
declare function softDeleteUser<TClient = any>(client: TClient, id: string, deletedBy: string): Promise<boolean>;
|
|
302
|
+
/**
|
|
303
|
+
* Restore a soft-deleted user (sets status back to "active")
|
|
304
|
+
* Checks retention period before allowing restoration
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* ```typescript
|
|
308
|
+
* import { restoreUser } from '@htlkg/data/mutations';
|
|
309
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
310
|
+
*
|
|
311
|
+
* const client = generateClient<Schema>();
|
|
312
|
+
* await restoreUser(client, 'user-123');
|
|
313
|
+
* // Or with custom retention days:
|
|
314
|
+
* await restoreUser(client, 'user-123', 60);
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
declare function restoreUser<TClient = any>(client: TClient, id: string, retentionDays?: number): Promise<{
|
|
318
|
+
success: boolean;
|
|
319
|
+
error?: string;
|
|
320
|
+
}>;
|
|
321
|
+
/**
|
|
322
|
+
* Hard delete a user (permanently removes from database)
|
|
323
|
+
* Use with caution - prefer softDeleteUser for recoverable deletion
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ```typescript
|
|
327
|
+
* import { deleteUser } from '@htlkg/data/mutations';
|
|
328
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
329
|
+
*
|
|
330
|
+
* const client = generateClient<Schema>();
|
|
331
|
+
* await deleteUser(client, 'user-123');
|
|
332
|
+
* ```
|
|
333
|
+
*/
|
|
334
|
+
declare function deleteUser<TClient = any>(client: TClient, id: string): Promise<boolean>;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* SystemSettings Mutation Functions
|
|
338
|
+
*
|
|
339
|
+
* Provides mutation functions for managing system settings.
|
|
340
|
+
*/
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Input type for updating system settings
|
|
344
|
+
*/
|
|
345
|
+
interface UpdateSystemSettingsInput {
|
|
346
|
+
softDeleteRetentionDays: number;
|
|
347
|
+
updatedBy: string;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Update or create system settings
|
|
351
|
+
* Only SUPER_ADMINS can update system settings
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* ```typescript
|
|
355
|
+
* import { updateSystemSettings } from '@htlkg/data/mutations';
|
|
356
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
357
|
+
*
|
|
358
|
+
* const client = generateClient<Schema>();
|
|
359
|
+
* const settings = await updateSystemSettings(client, {
|
|
360
|
+
* softDeleteRetentionDays: 60,
|
|
361
|
+
* updatedBy: 'admin@example.com'
|
|
362
|
+
* });
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
365
|
+
declare function updateSystemSettings<TClient = any>(client: TClient, input: UpdateSystemSettingsInput): Promise<SystemSettings | null>;
|
|
366
|
+
/**
|
|
367
|
+
* Initialize system settings with default values if they don't exist
|
|
368
|
+
*
|
|
369
|
+
* @example
|
|
370
|
+
* ```typescript
|
|
371
|
+
* import { initializeSystemSettings } from '@htlkg/data/mutations';
|
|
372
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
373
|
+
*
|
|
374
|
+
* const client = generateClient<Schema>();
|
|
375
|
+
* const settings = await initializeSystemSettings(client, 'system@hotelinking.com');
|
|
376
|
+
* ```
|
|
377
|
+
*/
|
|
378
|
+
declare function initializeSystemSettings<TClient = any>(client: TClient, initializedBy: string): Promise<SystemSettings | null>;
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Contact Validation Schemas
|
|
382
|
+
*
|
|
383
|
+
* Comprehensive Zod validation schemas for Contact entities.
|
|
384
|
+
* Includes field-level validators, custom field schemas, and complete entity schemas.
|
|
385
|
+
*
|
|
386
|
+
* @module @htlkg/data/validation/contact.schemas
|
|
387
|
+
*/
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Email validation schema
|
|
391
|
+
* - Must be valid email format
|
|
392
|
+
* - Transforms to lowercase for consistency
|
|
393
|
+
* - Max 254 characters (RFC 5321)
|
|
394
|
+
*/
|
|
395
|
+
declare const emailSchema: z.ZodString;
|
|
396
|
+
/**
|
|
397
|
+
* Optional email validation schema
|
|
398
|
+
* Same rules as emailSchema but allows undefined
|
|
399
|
+
*/
|
|
400
|
+
declare const optionalEmailSchema: z.ZodOptional<z.ZodString>;
|
|
401
|
+
declare const phoneSchema: z.ZodString;
|
|
402
|
+
/**
|
|
403
|
+
* Optional phone validation schema
|
|
404
|
+
* Validates format only if value is provided and non-empty
|
|
405
|
+
*/
|
|
406
|
+
declare const optionalPhoneSchema: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
|
|
407
|
+
declare const firstNameSchema: z.ZodString;
|
|
408
|
+
/**
|
|
409
|
+
* Last name validation schema
|
|
410
|
+
* - Required, 1-100 characters
|
|
411
|
+
* - Trims whitespace
|
|
412
|
+
* - Allows Unicode letters, spaces, hyphens, apostrophes
|
|
413
|
+
*/
|
|
414
|
+
declare const lastNameSchema: z.ZodString;
|
|
415
|
+
/**
|
|
416
|
+
* Optional first name validation schema
|
|
417
|
+
*/
|
|
418
|
+
declare const optionalFirstNameSchema: z.ZodOptional<z.ZodString>;
|
|
419
|
+
/**
|
|
420
|
+
* Optional last name validation schema
|
|
421
|
+
*/
|
|
422
|
+
declare const optionalLastNameSchema: z.ZodOptional<z.ZodString>;
|
|
423
|
+
declare const localeSchema: z.ZodString;
|
|
424
|
+
/**
|
|
425
|
+
* Optional locale validation schema
|
|
426
|
+
*/
|
|
427
|
+
declare const optionalLocaleSchema: z.ZodOptional<z.ZodString>;
|
|
428
|
+
/**
|
|
429
|
+
* ISO 8601 date string validation schema
|
|
430
|
+
* Validates date strings in ISO 8601 format
|
|
431
|
+
*/
|
|
432
|
+
declare const isoDateStringSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
433
|
+
/**
|
|
434
|
+
* Optional ISO 8601 date string validation schema
|
|
435
|
+
*/
|
|
436
|
+
declare const optionalIsoDateStringSchema: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
437
|
+
/**
|
|
438
|
+
* UUID validation schema
|
|
439
|
+
*/
|
|
440
|
+
declare const uuidSchema: z.ZodUnion<[z.ZodString, z.ZodString]>;
|
|
441
|
+
/**
|
|
442
|
+
* Brand ID validation schema
|
|
443
|
+
*/
|
|
444
|
+
declare const brandIdSchema: z.ZodString;
|
|
445
|
+
/**
|
|
446
|
+
* Tag validation schema
|
|
447
|
+
* - Non-empty string
|
|
448
|
+
* - Max 50 characters per tag
|
|
449
|
+
* - Trimmed and lowercased for consistency
|
|
450
|
+
*/
|
|
451
|
+
declare const tagSchema: z.ZodString;
|
|
452
|
+
/**
|
|
453
|
+
* Tags array validation schema
|
|
454
|
+
* - Array of valid tags
|
|
455
|
+
* - Max 100 tags per contact
|
|
456
|
+
*/
|
|
457
|
+
declare const tagsArraySchema: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
458
|
+
/**
|
|
459
|
+
* Supported custom field types
|
|
460
|
+
*/
|
|
461
|
+
declare const CustomFieldType: {
|
|
462
|
+
readonly STRING: "string";
|
|
463
|
+
readonly NUMBER: "number";
|
|
464
|
+
readonly BOOLEAN: "boolean";
|
|
465
|
+
readonly DATE: "date";
|
|
466
|
+
readonly ARRAY: "array";
|
|
467
|
+
readonly OBJECT: "object";
|
|
468
|
+
};
|
|
469
|
+
type CustomFieldTypeValue = (typeof CustomFieldType)[keyof typeof CustomFieldType];
|
|
470
|
+
/**
|
|
471
|
+
* Custom field definition schema
|
|
472
|
+
* Defines the structure for a single custom field
|
|
473
|
+
*/
|
|
474
|
+
declare const customFieldDefinitionSchema: z.ZodObject<{
|
|
475
|
+
type: z.ZodEnum<["string", "number", "boolean", "date", "array", "object"]>;
|
|
476
|
+
required: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
477
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
478
|
+
minLength: z.ZodOptional<z.ZodNumber>;
|
|
479
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
480
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
481
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
482
|
+
enum: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">>;
|
|
483
|
+
}, "strip", z.ZodTypeAny, {
|
|
484
|
+
type: "string" | "number" | "boolean" | "object" | "date" | "array";
|
|
485
|
+
required: boolean;
|
|
486
|
+
maxLength?: number | undefined;
|
|
487
|
+
minLength?: number | undefined;
|
|
488
|
+
min?: number | undefined;
|
|
489
|
+
max?: number | undefined;
|
|
490
|
+
pattern?: string | undefined;
|
|
491
|
+
enum?: (string | number)[] | undefined;
|
|
492
|
+
}, {
|
|
493
|
+
type: "string" | "number" | "boolean" | "object" | "date" | "array";
|
|
494
|
+
required?: boolean | undefined;
|
|
495
|
+
maxLength?: number | undefined;
|
|
496
|
+
minLength?: number | undefined;
|
|
497
|
+
min?: number | undefined;
|
|
498
|
+
max?: number | undefined;
|
|
499
|
+
pattern?: string | undefined;
|
|
500
|
+
enum?: (string | number)[] | undefined;
|
|
501
|
+
}>;
|
|
502
|
+
type CustomFieldDefinition = z.infer<typeof customFieldDefinitionSchema>;
|
|
503
|
+
/**
|
|
504
|
+
* Custom field value schema
|
|
505
|
+
* Validates a value based on its field definition
|
|
506
|
+
*/
|
|
507
|
+
declare function createCustomFieldValueSchema(definition: CustomFieldDefinition): z.ZodTypeAny;
|
|
508
|
+
/**
|
|
509
|
+
* Contact preferences schema
|
|
510
|
+
* Validates the preferences Record with type-safe structure
|
|
511
|
+
*
|
|
512
|
+
* Known preference fields with validation:
|
|
513
|
+
* - theme: "light" | "dark" | "system"
|
|
514
|
+
* - language: BCP 47 locale
|
|
515
|
+
* - notifications: { email: boolean, sms: boolean, push: boolean }
|
|
516
|
+
* - communication: { preferredChannel: "email" | "phone" | "sms" }
|
|
517
|
+
* - Other fields: any valid JSON value
|
|
518
|
+
*/
|
|
519
|
+
declare const contactPreferencesSchema: z.ZodEffects<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodAny, "many">, z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodNull]>>>, Record<string, string | number | boolean | any[] | Record<string, any> | null> | undefined, Record<string, string | number | boolean | any[] | Record<string, any> | null> | undefined>;
|
|
520
|
+
/**
|
|
521
|
+
* Notification preferences sub-schema
|
|
522
|
+
*/
|
|
523
|
+
declare const notificationPreferencesSchema: z.ZodObject<{
|
|
524
|
+
email: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
525
|
+
sms: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
526
|
+
push: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
527
|
+
}, "strip", z.ZodTypeAny, {
|
|
528
|
+
push: boolean;
|
|
529
|
+
email: boolean;
|
|
530
|
+
sms: boolean;
|
|
531
|
+
}, {
|
|
532
|
+
push?: boolean | undefined;
|
|
533
|
+
email?: boolean | undefined;
|
|
534
|
+
sms?: boolean | undefined;
|
|
535
|
+
}>;
|
|
536
|
+
/**
|
|
537
|
+
* Communication preferences sub-schema
|
|
538
|
+
*/
|
|
539
|
+
declare const communicationPreferencesSchema: z.ZodObject<{
|
|
540
|
+
preferredChannel: z.ZodDefault<z.ZodOptional<z.ZodEnum<["email", "phone", "sms"]>>>;
|
|
541
|
+
}, "strip", z.ZodTypeAny, {
|
|
542
|
+
preferredChannel: "email" | "phone" | "sms";
|
|
543
|
+
}, {
|
|
544
|
+
preferredChannel?: "email" | "phone" | "sms" | undefined;
|
|
545
|
+
}>;
|
|
546
|
+
/**
|
|
547
|
+
* Create Contact Schema
|
|
548
|
+
* Full validation for creating a new contact
|
|
549
|
+
*/
|
|
550
|
+
declare const createContactSchema: z.ZodObject<{
|
|
551
|
+
createdAt: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
552
|
+
createdBy: z.ZodOptional<z.ZodString>;
|
|
553
|
+
updatedAt: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
554
|
+
updatedBy: z.ZodOptional<z.ZodString>;
|
|
555
|
+
brandId: z.ZodString;
|
|
556
|
+
email: z.ZodString;
|
|
557
|
+
phone: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
|
|
558
|
+
firstName: z.ZodString;
|
|
559
|
+
lastName: z.ZodString;
|
|
560
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
561
|
+
gdprConsent: z.ZodBoolean;
|
|
562
|
+
gdprConsentDate: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
563
|
+
marketingOptIn: z.ZodOptional<z.ZodBoolean>;
|
|
564
|
+
preferences: z.ZodEffects<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodAny, "many">, z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodNull]>>>, Record<string, string | number | boolean | any[] | Record<string, any> | null> | undefined, Record<string, string | number | boolean | any[] | Record<string, any> | null> | undefined>;
|
|
565
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
566
|
+
totalVisits: z.ZodOptional<z.ZodNumber>;
|
|
567
|
+
lastVisitDate: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
568
|
+
firstVisitDate: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
569
|
+
legacyId: z.ZodOptional<z.ZodString>;
|
|
570
|
+
}, "strip", z.ZodTypeAny, {
|
|
571
|
+
brandId: string;
|
|
572
|
+
email: string;
|
|
573
|
+
lastName: string;
|
|
574
|
+
firstName: string;
|
|
575
|
+
gdprConsent: boolean;
|
|
576
|
+
updatedAt?: string | undefined;
|
|
577
|
+
updatedBy?: string | undefined;
|
|
578
|
+
phone?: string | undefined;
|
|
579
|
+
createdAt?: string | undefined;
|
|
580
|
+
createdBy?: string | undefined;
|
|
581
|
+
locale?: string | undefined;
|
|
582
|
+
gdprConsentDate?: string | undefined;
|
|
583
|
+
marketingOptIn?: boolean | undefined;
|
|
584
|
+
preferences?: Record<string, string | number | boolean | any[] | Record<string, any> | null> | undefined;
|
|
585
|
+
tags?: string[] | undefined;
|
|
586
|
+
totalVisits?: number | undefined;
|
|
587
|
+
lastVisitDate?: string | undefined;
|
|
588
|
+
firstVisitDate?: string | undefined;
|
|
589
|
+
legacyId?: string | undefined;
|
|
590
|
+
}, {
|
|
591
|
+
brandId: string;
|
|
592
|
+
email: string;
|
|
593
|
+
lastName: string;
|
|
594
|
+
firstName: string;
|
|
595
|
+
gdprConsent: boolean;
|
|
596
|
+
updatedAt?: string | undefined;
|
|
597
|
+
updatedBy?: string | undefined;
|
|
598
|
+
phone?: string | undefined;
|
|
599
|
+
createdAt?: string | undefined;
|
|
600
|
+
createdBy?: string | undefined;
|
|
601
|
+
locale?: string | undefined;
|
|
602
|
+
gdprConsentDate?: string | undefined;
|
|
603
|
+
marketingOptIn?: boolean | undefined;
|
|
604
|
+
preferences?: Record<string, string | number | boolean | any[] | Record<string, any> | null> | undefined;
|
|
605
|
+
tags?: string[] | undefined;
|
|
606
|
+
totalVisits?: number | undefined;
|
|
607
|
+
lastVisitDate?: string | undefined;
|
|
608
|
+
firstVisitDate?: string | undefined;
|
|
609
|
+
legacyId?: string | undefined;
|
|
610
|
+
}>;
|
|
611
|
+
/**
|
|
612
|
+
* Update Contact Schema
|
|
613
|
+
* Partial validation for updating an existing contact
|
|
614
|
+
* All fields except 'id' are optional
|
|
615
|
+
*/
|
|
616
|
+
declare const updateContactSchema: z.ZodObject<{
|
|
617
|
+
updatedAt: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
618
|
+
updatedBy: z.ZodOptional<z.ZodString>;
|
|
619
|
+
deletedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
620
|
+
deletedBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
621
|
+
id: z.ZodString;
|
|
622
|
+
brandId: z.ZodOptional<z.ZodString>;
|
|
623
|
+
email: z.ZodOptional<z.ZodString>;
|
|
624
|
+
phone: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
|
|
625
|
+
firstName: z.ZodOptional<z.ZodString>;
|
|
626
|
+
lastName: z.ZodOptional<z.ZodString>;
|
|
627
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
628
|
+
gdprConsent: z.ZodOptional<z.ZodBoolean>;
|
|
629
|
+
gdprConsentDate: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
630
|
+
marketingOptIn: z.ZodOptional<z.ZodBoolean>;
|
|
631
|
+
preferences: z.ZodEffects<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodAny, "many">, z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodNull]>>>, Record<string, string | number | boolean | any[] | Record<string, any> | null> | undefined, Record<string, string | number | boolean | any[] | Record<string, any> | null> | undefined>;
|
|
632
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
633
|
+
totalVisits: z.ZodOptional<z.ZodNumber>;
|
|
634
|
+
lastVisitDate: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
635
|
+
firstVisitDate: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
636
|
+
legacyId: z.ZodOptional<z.ZodString>;
|
|
637
|
+
}, "strip", z.ZodTypeAny, {
|
|
638
|
+
id: string;
|
|
639
|
+
updatedAt?: string | undefined;
|
|
640
|
+
updatedBy?: string | undefined;
|
|
641
|
+
brandId?: string | undefined;
|
|
642
|
+
deletedAt?: string | null | undefined;
|
|
643
|
+
deletedBy?: string | null | undefined;
|
|
644
|
+
email?: string | undefined;
|
|
645
|
+
phone?: string | undefined;
|
|
646
|
+
lastName?: string | undefined;
|
|
647
|
+
firstName?: string | undefined;
|
|
648
|
+
locale?: string | undefined;
|
|
649
|
+
gdprConsent?: boolean | undefined;
|
|
650
|
+
gdprConsentDate?: string | undefined;
|
|
651
|
+
marketingOptIn?: boolean | undefined;
|
|
652
|
+
preferences?: Record<string, string | number | boolean | any[] | Record<string, any> | null> | undefined;
|
|
653
|
+
tags?: string[] | undefined;
|
|
654
|
+
totalVisits?: number | undefined;
|
|
655
|
+
lastVisitDate?: string | undefined;
|
|
656
|
+
firstVisitDate?: string | undefined;
|
|
657
|
+
legacyId?: string | undefined;
|
|
658
|
+
}, {
|
|
659
|
+
id: string;
|
|
660
|
+
updatedAt?: string | undefined;
|
|
661
|
+
updatedBy?: string | undefined;
|
|
662
|
+
brandId?: string | undefined;
|
|
663
|
+
deletedAt?: string | null | undefined;
|
|
664
|
+
deletedBy?: string | null | undefined;
|
|
665
|
+
email?: string | undefined;
|
|
666
|
+
phone?: string | undefined;
|
|
667
|
+
lastName?: string | undefined;
|
|
668
|
+
firstName?: string | undefined;
|
|
669
|
+
locale?: string | undefined;
|
|
670
|
+
gdprConsent?: boolean | undefined;
|
|
671
|
+
gdprConsentDate?: string | undefined;
|
|
672
|
+
marketingOptIn?: boolean | undefined;
|
|
673
|
+
preferences?: Record<string, string | number | boolean | any[] | Record<string, any> | null> | undefined;
|
|
674
|
+
tags?: string[] | undefined;
|
|
675
|
+
totalVisits?: number | undefined;
|
|
676
|
+
lastVisitDate?: string | undefined;
|
|
677
|
+
firstVisitDate?: string | undefined;
|
|
678
|
+
legacyId?: string | undefined;
|
|
679
|
+
}>;
|
|
680
|
+
/**
|
|
681
|
+
* Merge Contacts Schema
|
|
682
|
+
* Validation for merging duplicate contacts
|
|
683
|
+
*/
|
|
684
|
+
declare const mergeContactsSchema: z.ZodObject<{
|
|
685
|
+
primaryId: z.ZodString;
|
|
686
|
+
duplicateIds: z.ZodArray<z.ZodString, "many">;
|
|
687
|
+
}, "strip", z.ZodTypeAny, {
|
|
688
|
+
primaryId: string;
|
|
689
|
+
duplicateIds: string[];
|
|
690
|
+
}, {
|
|
691
|
+
primaryId: string;
|
|
692
|
+
duplicateIds: string[];
|
|
693
|
+
}>;
|
|
694
|
+
/**
|
|
695
|
+
* Search/Filter Contact Schema
|
|
696
|
+
* Validation for contact search and filter operations
|
|
697
|
+
*/
|
|
698
|
+
declare const searchContactSchema: z.ZodObject<{
|
|
699
|
+
brandId: z.ZodOptional<z.ZodString>;
|
|
700
|
+
email: z.ZodOptional<z.ZodString>;
|
|
701
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
702
|
+
firstName: z.ZodOptional<z.ZodString>;
|
|
703
|
+
lastName: z.ZodOptional<z.ZodString>;
|
|
704
|
+
search: z.ZodOptional<z.ZodString>;
|
|
705
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
706
|
+
gdprConsent: z.ZodOptional<z.ZodBoolean>;
|
|
707
|
+
marketingOptIn: z.ZodOptional<z.ZodBoolean>;
|
|
708
|
+
includeDeleted: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
709
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
710
|
+
nextToken: z.ZodOptional<z.ZodString>;
|
|
711
|
+
}, "strip", z.ZodTypeAny, {
|
|
712
|
+
limit: number;
|
|
713
|
+
includeDeleted: boolean;
|
|
714
|
+
brandId?: string | undefined;
|
|
715
|
+
nextToken?: string | undefined;
|
|
716
|
+
email?: string | undefined;
|
|
717
|
+
phone?: string | undefined;
|
|
718
|
+
lastName?: string | undefined;
|
|
719
|
+
firstName?: string | undefined;
|
|
720
|
+
gdprConsent?: boolean | undefined;
|
|
721
|
+
marketingOptIn?: boolean | undefined;
|
|
722
|
+
tags?: string[] | undefined;
|
|
723
|
+
search?: string | undefined;
|
|
724
|
+
}, {
|
|
725
|
+
brandId?: string | undefined;
|
|
726
|
+
nextToken?: string | undefined;
|
|
727
|
+
limit?: number | undefined;
|
|
728
|
+
email?: string | undefined;
|
|
729
|
+
phone?: string | undefined;
|
|
730
|
+
lastName?: string | undefined;
|
|
731
|
+
firstName?: string | undefined;
|
|
732
|
+
gdprConsent?: boolean | undefined;
|
|
733
|
+
marketingOptIn?: boolean | undefined;
|
|
734
|
+
tags?: string[] | undefined;
|
|
735
|
+
search?: string | undefined;
|
|
736
|
+
includeDeleted?: boolean | undefined;
|
|
737
|
+
}>;
|
|
738
|
+
/**
|
|
739
|
+
* Bulk Import Contact Schema
|
|
740
|
+
* Validation for importing contacts in bulk
|
|
741
|
+
*/
|
|
742
|
+
declare const bulkImportContactSchema: z.ZodObject<{
|
|
743
|
+
contacts: z.ZodArray<z.ZodObject<Omit<{
|
|
744
|
+
createdAt: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
745
|
+
createdBy: z.ZodOptional<z.ZodString>;
|
|
746
|
+
updatedAt: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
747
|
+
updatedBy: z.ZodOptional<z.ZodString>;
|
|
748
|
+
brandId: z.ZodString;
|
|
749
|
+
email: z.ZodString;
|
|
750
|
+
phone: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
|
|
751
|
+
firstName: z.ZodString;
|
|
752
|
+
lastName: z.ZodString;
|
|
753
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
754
|
+
gdprConsent: z.ZodBoolean;
|
|
755
|
+
gdprConsentDate: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
756
|
+
marketingOptIn: z.ZodOptional<z.ZodBoolean>;
|
|
757
|
+
preferences: z.ZodEffects<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodAny, "many">, z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodNull]>>>, Record<string, string | number | boolean | any[] | Record<string, any> | null> | undefined, Record<string, string | number | boolean | any[] | Record<string, any> | null> | undefined>;
|
|
758
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
759
|
+
totalVisits: z.ZodOptional<z.ZodNumber>;
|
|
760
|
+
lastVisitDate: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
761
|
+
firstVisitDate: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
762
|
+
legacyId: z.ZodOptional<z.ZodString>;
|
|
763
|
+
}, "updatedAt" | "updatedBy" | "createdAt" | "createdBy">, "strip", z.ZodTypeAny, {
|
|
764
|
+
brandId: string;
|
|
765
|
+
email: string;
|
|
766
|
+
lastName: string;
|
|
767
|
+
firstName: string;
|
|
768
|
+
gdprConsent: boolean;
|
|
769
|
+
phone?: string | undefined;
|
|
770
|
+
locale?: string | undefined;
|
|
771
|
+
gdprConsentDate?: string | undefined;
|
|
772
|
+
marketingOptIn?: boolean | undefined;
|
|
773
|
+
preferences?: Record<string, string | number | boolean | any[] | Record<string, any> | null> | undefined;
|
|
774
|
+
tags?: string[] | undefined;
|
|
775
|
+
totalVisits?: number | undefined;
|
|
776
|
+
lastVisitDate?: string | undefined;
|
|
777
|
+
firstVisitDate?: string | undefined;
|
|
778
|
+
legacyId?: string | undefined;
|
|
779
|
+
}, {
|
|
780
|
+
brandId: string;
|
|
781
|
+
email: string;
|
|
782
|
+
lastName: string;
|
|
783
|
+
firstName: string;
|
|
784
|
+
gdprConsent: boolean;
|
|
785
|
+
phone?: string | undefined;
|
|
786
|
+
locale?: string | undefined;
|
|
787
|
+
gdprConsentDate?: string | undefined;
|
|
788
|
+
marketingOptIn?: boolean | undefined;
|
|
789
|
+
preferences?: Record<string, string | number | boolean | any[] | Record<string, any> | null> | undefined;
|
|
790
|
+
tags?: string[] | undefined;
|
|
791
|
+
totalVisits?: number | undefined;
|
|
792
|
+
lastVisitDate?: string | undefined;
|
|
793
|
+
firstVisitDate?: string | undefined;
|
|
794
|
+
legacyId?: string | undefined;
|
|
795
|
+
}>, "many">;
|
|
796
|
+
skipDuplicates: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
797
|
+
updateExisting: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
798
|
+
}, "strip", z.ZodTypeAny, {
|
|
799
|
+
contacts: {
|
|
800
|
+
brandId: string;
|
|
801
|
+
email: string;
|
|
802
|
+
lastName: string;
|
|
803
|
+
firstName: string;
|
|
804
|
+
gdprConsent: boolean;
|
|
805
|
+
phone?: string | undefined;
|
|
806
|
+
locale?: string | undefined;
|
|
807
|
+
gdprConsentDate?: string | undefined;
|
|
808
|
+
marketingOptIn?: boolean | undefined;
|
|
809
|
+
preferences?: Record<string, string | number | boolean | any[] | Record<string, any> | null> | undefined;
|
|
810
|
+
tags?: string[] | undefined;
|
|
811
|
+
totalVisits?: number | undefined;
|
|
812
|
+
lastVisitDate?: string | undefined;
|
|
813
|
+
firstVisitDate?: string | undefined;
|
|
814
|
+
legacyId?: string | undefined;
|
|
815
|
+
}[];
|
|
816
|
+
skipDuplicates: boolean;
|
|
817
|
+
updateExisting: boolean;
|
|
818
|
+
}, {
|
|
819
|
+
contacts: {
|
|
820
|
+
brandId: string;
|
|
821
|
+
email: string;
|
|
822
|
+
lastName: string;
|
|
823
|
+
firstName: string;
|
|
824
|
+
gdprConsent: boolean;
|
|
825
|
+
phone?: string | undefined;
|
|
826
|
+
locale?: string | undefined;
|
|
827
|
+
gdprConsentDate?: string | undefined;
|
|
828
|
+
marketingOptIn?: boolean | undefined;
|
|
829
|
+
preferences?: Record<string, string | number | boolean | any[] | Record<string, any> | null> | undefined;
|
|
830
|
+
tags?: string[] | undefined;
|
|
831
|
+
totalVisits?: number | undefined;
|
|
832
|
+
lastVisitDate?: string | undefined;
|
|
833
|
+
firstVisitDate?: string | undefined;
|
|
834
|
+
legacyId?: string | undefined;
|
|
835
|
+
}[];
|
|
836
|
+
skipDuplicates?: boolean | undefined;
|
|
837
|
+
updateExisting?: boolean | undefined;
|
|
838
|
+
}>;
|
|
839
|
+
type CreateContactInput$1 = z.infer<typeof createContactSchema>;
|
|
840
|
+
type UpdateContactInput$1 = z.infer<typeof updateContactSchema>;
|
|
841
|
+
type SearchContactInput = z.infer<typeof searchContactSchema>;
|
|
842
|
+
type BulkImportContactInput = z.infer<typeof bulkImportContactSchema>;
|
|
843
|
+
type ContactPreferences = z.infer<typeof contactPreferencesSchema>;
|
|
844
|
+
type NotificationPreferences = z.infer<typeof notificationPreferencesSchema>;
|
|
845
|
+
type CommunicationPreferences = z.infer<typeof communicationPreferencesSchema>;
|
|
846
|
+
/**
|
|
847
|
+
* Validate email address
|
|
848
|
+
* @param email - Email string to validate
|
|
849
|
+
* @returns Validation result with success status and normalized email or error
|
|
850
|
+
*/
|
|
851
|
+
declare function validateEmail(email: string): z.SafeParseReturnType<string, string>;
|
|
852
|
+
/**
|
|
853
|
+
* Validate phone number
|
|
854
|
+
* @param phone - Phone string to validate
|
|
855
|
+
* @returns Validation result with success status and normalized phone or error
|
|
856
|
+
*/
|
|
857
|
+
declare function validatePhone(phone: string): z.SafeParseReturnType<string, string>;
|
|
858
|
+
/**
|
|
859
|
+
* Validate contact name
|
|
860
|
+
* @param firstName - First name to validate
|
|
861
|
+
* @param lastName - Last name to validate
|
|
862
|
+
* @returns Object with validation results for both names
|
|
863
|
+
*/
|
|
864
|
+
declare function validateContactName(firstName: string, lastName: string): {
|
|
865
|
+
firstName: z.SafeParseReturnType<string, string>;
|
|
866
|
+
lastName: z.SafeParseReturnType<string, string>;
|
|
867
|
+
isValid: boolean;
|
|
868
|
+
};
|
|
869
|
+
/**
|
|
870
|
+
* Validate create contact input
|
|
871
|
+
* @param input - Contact input to validate
|
|
872
|
+
* @returns Validation result with success status and validated data or error
|
|
873
|
+
*/
|
|
874
|
+
declare function validateCreateContact(input: unknown): z.SafeParseReturnType<unknown, CreateContactInput$1>;
|
|
875
|
+
/**
|
|
876
|
+
* Validate update contact input
|
|
877
|
+
* @param input - Contact update input to validate
|
|
878
|
+
* @returns Validation result with success status and validated data or error
|
|
879
|
+
*/
|
|
880
|
+
declare function validateUpdateContact(input: unknown): z.SafeParseReturnType<unknown, UpdateContactInput$1>;
|
|
881
|
+
/**
|
|
882
|
+
* Format Zod errors into user-friendly message
|
|
883
|
+
* @param error - Zod error object
|
|
884
|
+
* @returns Formatted error message string
|
|
885
|
+
*/
|
|
886
|
+
declare function formatValidationErrors(error: z.ZodError): string;
|
|
887
|
+
/**
|
|
888
|
+
* Get validation error details as array
|
|
889
|
+
* @param error - Zod error object
|
|
890
|
+
* @returns Array of error details with path and message
|
|
891
|
+
*/
|
|
892
|
+
declare function getValidationErrorDetails(error: z.ZodError): Array<{
|
|
893
|
+
path: string;
|
|
894
|
+
message: string;
|
|
895
|
+
code: string;
|
|
896
|
+
}>;
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* Contact Mutation Functions
|
|
900
|
+
*
|
|
901
|
+
* Provides type-safe mutation functions for creating, updating, and deleting contacts.
|
|
902
|
+
* Includes Zod validation for input data before mutations.
|
|
903
|
+
*/
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Validation error class for contact operations
|
|
907
|
+
*/
|
|
908
|
+
declare class ContactValidationError extends Error {
|
|
909
|
+
readonly issues: z.ZodIssue[];
|
|
910
|
+
constructor(message: string, issues?: z.ZodIssue[]);
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* Input type for creating a contact
|
|
914
|
+
*/
|
|
915
|
+
interface CreateContactInput extends CreateAuditFields {
|
|
916
|
+
brandId: string;
|
|
917
|
+
email: string;
|
|
918
|
+
phone?: string;
|
|
919
|
+
firstName: string;
|
|
920
|
+
lastName: string;
|
|
921
|
+
locale?: string;
|
|
922
|
+
gdprConsent: boolean;
|
|
923
|
+
gdprConsentDate?: string;
|
|
924
|
+
marketingOptIn?: boolean;
|
|
925
|
+
preferences?: Record<string, any>;
|
|
926
|
+
tags?: string[];
|
|
927
|
+
totalVisits?: number;
|
|
928
|
+
lastVisitDate?: string;
|
|
929
|
+
firstVisitDate?: string;
|
|
930
|
+
legacyId?: string;
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* Input type for updating a contact
|
|
934
|
+
*/
|
|
935
|
+
interface UpdateContactInput extends UpdateWithSoftDeleteFields {
|
|
936
|
+
id: string;
|
|
937
|
+
brandId?: string;
|
|
938
|
+
email?: string;
|
|
939
|
+
phone?: string;
|
|
940
|
+
firstName?: string;
|
|
941
|
+
lastName?: string;
|
|
942
|
+
locale?: string;
|
|
943
|
+
gdprConsent?: boolean;
|
|
944
|
+
gdprConsentDate?: string;
|
|
945
|
+
marketingOptIn?: boolean;
|
|
946
|
+
preferences?: Record<string, any>;
|
|
947
|
+
tags?: string[];
|
|
948
|
+
totalVisits?: number;
|
|
949
|
+
lastVisitDate?: string;
|
|
950
|
+
firstVisitDate?: string;
|
|
951
|
+
legacyId?: string;
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Input type for merging contacts
|
|
955
|
+
*/
|
|
956
|
+
interface MergeContactsInput {
|
|
957
|
+
primaryId: string;
|
|
958
|
+
duplicateIds: string[];
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Result type for merge operation
|
|
962
|
+
*/
|
|
963
|
+
interface MergeContactsResult {
|
|
964
|
+
success: boolean;
|
|
965
|
+
mergedContact?: Contact;
|
|
966
|
+
deletedIds?: string[];
|
|
967
|
+
error?: string;
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Create a new contact with Zod validation
|
|
971
|
+
*
|
|
972
|
+
* @throws {ContactValidationError} if input validation fails
|
|
973
|
+
*
|
|
974
|
+
* @example
|
|
975
|
+
* ```typescript
|
|
976
|
+
* import { createContact } from '@htlkg/data/mutations';
|
|
977
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
978
|
+
*
|
|
979
|
+
* const client = generateClient<Schema>();
|
|
980
|
+
* const contact = await createContact(client, {
|
|
981
|
+
* brandId: 'brand-123',
|
|
982
|
+
* email: 'guest@example.com',
|
|
983
|
+
* firstName: 'John',
|
|
984
|
+
* lastName: 'Doe',
|
|
985
|
+
* gdprConsent: true,
|
|
986
|
+
* gdprConsentDate: new Date().toISOString()
|
|
987
|
+
* });
|
|
988
|
+
* ```
|
|
989
|
+
*/
|
|
990
|
+
declare function createContact<TClient = any>(client: TClient, input: CreateContactInput): Promise<Contact | null>;
|
|
991
|
+
/**
|
|
992
|
+
* Update an existing contact with Zod validation
|
|
993
|
+
*
|
|
994
|
+
* @throws {ContactValidationError} if input validation fails
|
|
995
|
+
*
|
|
996
|
+
* @example
|
|
997
|
+
* ```typescript
|
|
998
|
+
* import { updateContact } from '@htlkg/data/mutations';
|
|
999
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
1000
|
+
*
|
|
1001
|
+
* const client = generateClient<Schema>();
|
|
1002
|
+
* const contact = await updateContact(client, {
|
|
1003
|
+
* id: 'contact-123',
|
|
1004
|
+
* firstName: 'Jane',
|
|
1005
|
+
* marketingOptIn: true
|
|
1006
|
+
* });
|
|
1007
|
+
* ```
|
|
1008
|
+
*/
|
|
1009
|
+
declare function updateContact<TClient = any>(client: TClient, input: UpdateContactInput): Promise<Contact | null>;
|
|
1010
|
+
/**
|
|
1011
|
+
* Soft delete a contact (sets deletedAt/deletedBy instead of removing)
|
|
1012
|
+
*
|
|
1013
|
+
* @example
|
|
1014
|
+
* ```typescript
|
|
1015
|
+
* import { softDeleteContact } from '@htlkg/data/mutations';
|
|
1016
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
1017
|
+
*
|
|
1018
|
+
* const client = generateClient<Schema>();
|
|
1019
|
+
* await softDeleteContact(client, 'contact-123', 'admin@example.com');
|
|
1020
|
+
* ```
|
|
1021
|
+
*/
|
|
1022
|
+
declare function softDeleteContact<TClient = any>(client: TClient, id: string, deletedBy: string): Promise<boolean>;
|
|
1023
|
+
/**
|
|
1024
|
+
* Restore a soft-deleted contact
|
|
1025
|
+
* Checks retention period before allowing restoration
|
|
1026
|
+
*
|
|
1027
|
+
* @example
|
|
1028
|
+
* ```typescript
|
|
1029
|
+
* import { restoreContact } from '@htlkg/data/mutations';
|
|
1030
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
1031
|
+
*
|
|
1032
|
+
* const client = generateClient<Schema>();
|
|
1033
|
+
* await restoreContact(client, 'contact-123');
|
|
1034
|
+
* // Or with custom retention days:
|
|
1035
|
+
* await restoreContact(client, 'contact-123', 60);
|
|
1036
|
+
* ```
|
|
1037
|
+
*/
|
|
1038
|
+
declare function restoreContact<TClient = any>(client: TClient, id: string, retentionDays?: number): Promise<{
|
|
1039
|
+
success: boolean;
|
|
1040
|
+
error?: string;
|
|
1041
|
+
}>;
|
|
1042
|
+
/**
|
|
1043
|
+
* Hard delete a contact (permanently removes from database)
|
|
1044
|
+
* Use with caution - prefer softDeleteContact for recoverable deletion
|
|
1045
|
+
*
|
|
1046
|
+
* @example
|
|
1047
|
+
* ```typescript
|
|
1048
|
+
* import { deleteContact } from '@htlkg/data/mutations';
|
|
1049
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
1050
|
+
*
|
|
1051
|
+
* const client = generateClient<Schema>();
|
|
1052
|
+
* await deleteContact(client, 'contact-123');
|
|
1053
|
+
* ```
|
|
1054
|
+
*/
|
|
1055
|
+
declare function deleteContact<TClient = any>(client: TClient, id: string): Promise<boolean>;
|
|
1056
|
+
/**
|
|
1057
|
+
* Merge duplicate contacts into a primary contact
|
|
1058
|
+
*
|
|
1059
|
+
* This function:
|
|
1060
|
+
* 1. Validates all contact IDs exist
|
|
1061
|
+
* 2. Aggregates data from duplicates into the primary contact
|
|
1062
|
+
* 3. Soft deletes the duplicate contacts
|
|
1063
|
+
* 4. Returns the updated primary contact
|
|
1064
|
+
*
|
|
1065
|
+
* Merge strategy:
|
|
1066
|
+
* - totalVisits: Sum of all contacts
|
|
1067
|
+
* - firstVisitDate: Earliest date across all contacts
|
|
1068
|
+
* - lastVisitDate: Latest date across all contacts
|
|
1069
|
+
* - tags: Merged unique tags from all contacts
|
|
1070
|
+
* - preferences: Primary contact preferences take precedence
|
|
1071
|
+
* - Other fields: Primary contact values are preserved
|
|
1072
|
+
*
|
|
1073
|
+
* @throws {ContactValidationError} if input validation fails
|
|
1074
|
+
*
|
|
1075
|
+
* @example
|
|
1076
|
+
* ```typescript
|
|
1077
|
+
* import { mergeContacts } from '@htlkg/data/mutations';
|
|
1078
|
+
* import { generateClient } from '@htlkg/data/client';
|
|
1079
|
+
*
|
|
1080
|
+
* const client = generateClient<Schema>();
|
|
1081
|
+
* const result = await mergeContacts(client, {
|
|
1082
|
+
* primaryId: 'contact-primary',
|
|
1083
|
+
* duplicateIds: ['contact-dup-1', 'contact-dup-2']
|
|
1084
|
+
* }, 'admin@example.com');
|
|
1085
|
+
* ```
|
|
1086
|
+
*/
|
|
1087
|
+
declare function mergeContacts<TClient = any>(client: TClient, input: MergeContactsInput, mergedBy: string): Promise<MergeContactsResult>;
|
|
1088
|
+
|
|
1089
|
+
export { tagsArraySchema as $, restoreContact as A, mergeContacts as B, type CreateBrandInput as C, ContactValidationError as D, createContactSchema as E, updateContactSchema as F, mergeContactsSchema as G, type CreateContactInput as H, type UpdateContactInput as I, type MergeContactsResult as J, emailSchema as K, optionalEmailSchema as L, type MergeContactsInput as M, phoneSchema as N, optionalPhoneSchema as O, firstNameSchema as P, lastNameSchema as Q, optionalFirstNameSchema as R, optionalLastNameSchema as S, localeSchema as T, type UpdateBrandInput as U, optionalLocaleSchema as V, isoDateStringSchema as W, optionalIsoDateStringSchema as X, uuidSchema as Y, brandIdSchema as Z, tagSchema as _, createAccount as a, CustomFieldType as a0, customFieldDefinitionSchema as a1, createCustomFieldValueSchema as a2, contactPreferencesSchema as a3, notificationPreferencesSchema as a4, communicationPreferencesSchema as a5, searchContactSchema as a6, bulkImportContactSchema as a7, validateEmail as a8, validatePhone as a9, validateContactName as aa, validateCreateContact as ab, validateUpdateContact as ac, formatValidationErrors as ad, getValidationErrorDetails as ae, type CustomFieldTypeValue as af, type CustomFieldDefinition as ag, type SearchContactInput as ah, type BulkImportContactInput as ai, type ContactPreferences as aj, type NotificationPreferences as ak, type CommunicationPreferences as al, updateAccount as b, createBrand as c, deleteBrand as d, deleteAccount as e, softDeleteAccount as f, restoreAccount as g, type CreateAccountInput as h, type UpdateAccountInput as i, createUser as j, updateUser as k, deleteUser as l, softDeleteUser as m, restoreUser as n, type CreateUserInput as o, type UpdateUserInput as p, updateSystemSettings as q, restoreBrand as r, softDeleteBrand as s, initializeSystemSettings as t, updateBrand as u, type UpdateSystemSettingsInput as v, createContact as w, updateContact as x, deleteContact as y, softDeleteContact as z };
|