@htlkg/data 0.0.24 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/hooks/index.d.ts +22 -2
- package/dist/hooks/index.js +52 -8
- 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 -53
- 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/index.ts +9 -0
- package/src/index.ts +3 -0
- package/src/mutations/contacts.ts +12 -75
- package/src/mutations/index.ts +1 -0
- package/src/queries/activityLogs.ts +87 -0
- package/src/queries/index.ts +8 -0
- package/src/validation/contact.schemas.test.ts +975 -0
- package/src/validation/contact.schemas.ts +611 -0
- package/src/validation/index.ts +54 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { AstroAmplifyConfig, GraphQLResponse, Operation, ProxyOptions, generateClient, generateServerClient, getErrorMessage, getSharedClient, hasErrors, mutate, query, resetSharedClient } from './client/index.js';
|
|
2
|
-
export { DEFAULT_SOFT_DELETE_RETENTION_DAYS, SYSTEM_SETTINGS_KEY, checkRestoreEligibility, executePublicQuery, executeServerQuery, getAccount, getAccountWithBrands, getBrand, getBrandWithProducts, getContact, getContactByEmail, getContactByPhone, getProduct, getProductInstance, getSoftDeleteRetentionDays, getSystemSettings, getUser, getUserByCognitoId, getUserByEmail, listAccounts, listActiveBrands, listActiveProducts, listActiveUsers, listBrands, listBrandsByAccount, listContacts, listContactsByBrand, listEnabledProductInstancesByBrand, listProductInstancesByAccount, listProductInstancesByBrand, listProducts, listUsers, listUsersByAccount, searchContacts } from './queries/index.js';
|
|
2
|
+
export { DEFAULT_SOFT_DELETE_RETENTION_DAYS, SYSTEM_SETTINGS_KEY, checkRestoreEligibility, executePublicQuery, executeServerQuery, getAccount, getAccountWithBrands, getBrand, getBrandWithProducts, getContact, getContactByEmail, getContactByPhone, getProduct, getProductInstance, getSoftDeleteRetentionDays, getSystemSettings, getUser, getUserByCognitoId, getUserByEmail, listAccounts, listActiveBrands, listActiveProducts, listActiveUsers, listActivityLogs, listActivityLogsByAccount, listActivityLogsByBrand, listBrands, listBrandsByAccount, listContacts, listContactsByBrand, listEnabledProductInstancesByBrand, listProductInstancesByAccount, listProductInstancesByBrand, listProducts, listRecentActivityLogs, listUsers, listUsersByAccount, searchContacts } from './queries/index.js';
|
|
3
3
|
export { R as Reservation, g as getReservation, d as getReservationByConfirmation, l as listReservations, a as listReservationsByBrand, b as listReservationsByContact, c as listReservationsByDateRange } from './reservations-C0FNm__0.js';
|
|
4
4
|
export { C as CreateAuditFields, S as SoftDeleteFields, U as UpdateAuditFields, a as UpdateWithSoftDeleteFields } from './common-DSxswsZ3.js';
|
|
5
|
-
export { ContactValidationError, CreateAccountInput, CreateBrandInput, CreateContactInput, CreateUserInput, MergeContactsInput, MergeContactsResult, UpdateAccountInput, UpdateBrandInput, UpdateContactInput, UpdateSystemSettingsInput, UpdateUserInput, 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 } from './
|
|
5
|
+
export { ai as BulkImportContactInput, al as CommunicationPreferences, aj as ContactPreferences, D as ContactValidationError, h as CreateAccountInput, C as CreateBrandInput, H as CreateContactInput, o as CreateUserInput, ag as CustomFieldDefinition, a0 as CustomFieldType, af as CustomFieldTypeValue, M as MergeContactsInput, J as MergeContactsResult, ak as NotificationPreferences, ah as SearchContactInput, i as UpdateAccountInput, U as UpdateBrandInput, I as UpdateContactInput, v as UpdateSystemSettingsInput, p as UpdateUserInput, Z as brandIdSchema, a7 as bulkImportContactSchema, a5 as communicationPreferencesSchema, a3 as contactPreferencesSchema, a as createAccount, c as createBrand, w as createContact, E as createContactSchema, a2 as createCustomFieldValueSchema, j as createUser, a1 as customFieldDefinitionSchema, e as deleteAccount, d as deleteBrand, y as deleteContact, l as deleteUser, K as emailSchema, P as firstNameSchema, ad as formatValidationErrors, ae as getValidationErrorDetails, t as initializeSystemSettings, W as isoDateStringSchema, Q as lastNameSchema, T as localeSchema, B as mergeContacts, G as mergeContactsSchema, a4 as notificationPreferencesSchema, L as optionalEmailSchema, R as optionalFirstNameSchema, X as optionalIsoDateStringSchema, S as optionalLastNameSchema, V as optionalLocaleSchema, O as optionalPhoneSchema, N as phoneSchema, g as restoreAccount, r as restoreBrand, A as restoreContact, n as restoreUser, a6 as searchContactSchema, f as softDeleteAccount, s as softDeleteBrand, z as softDeleteContact, m as softDeleteUser, _ as tagSchema, $ as tagsArraySchema, b as updateAccount, u as updateBrand, x as updateContact, F as updateContactSchema, q as updateSystemSettings, k as updateUser, Y as uuidSchema, aa as validateContactName, ab as validateCreateContact, a8 as validateEmail, a9 as validatePhone, ac as validateUpdateContact } from './index-ZmmFz38a.js';
|
|
6
6
|
export { C as CreateProductInstanceInput, U as UpdateProductInstanceInput, c as createProductInstance, d as deleteProductInstance, t as toggleProductInstanceEnabled, u as updateProductInstance } from './productInstances-BpQv1oLS.js';
|
|
7
7
|
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';
|
|
8
|
-
export { ACTIVE_FILTER, AccountWithBrands, BaseHookOptions, BrandWithCounts, ContactWithRelations, CreateDataHookOptions, CreatePaginatedDataHookOptions, DELETED_FILTER, DataHookReturn, InferHookReturn, InferPaginatedHookReturn, AccountWithBrands as PaginatedAccountWithBrands, PaginatedDataHookReturn, PaginatedHookOptions, PaginationState, ReservationWithRelations, UseAccountsOptions, UseAccountsReturn, UseBrandsOptions, UseBrandsReturn, UseContactsOptions, UseContactsReturn, UsePaginatedAccountsOptions, UsePaginatedAccountsReturn, UsePaginatedBrandsOptions, UsePaginatedBrandsReturn, UsePaginatedContactsOptions, UsePaginatedContactsReturn, UsePaginatedReservationsOptions, UsePaginatedReservationsReturn, UsePaginatedUsersOptions, UsePaginatedUsersReturn, UseProductInstancesOptions, UseProductInstancesReturn, UseProductsOptions, UseProductsReturn, UseReservationsOptions, UseReservationsReturn, UseUsersOptions, UseUsersReturn, UserWithRelations, createDataHook, createPaginatedDataHook, resetClientInstance, useAccounts, useActiveAccounts, useActiveBrands, useActiveContacts, useActiveReservations, useActiveUsers, useBrands, useContacts, useDeletedAccounts, useDeletedBrands, useDeletedContacts, useDeletedReservations, useDeletedUsers, useProductInstances, useProducts, useReservations, useUsers } from './hooks/index.js';
|
|
8
|
+
export { ACTIVE_FILTER, AccountWithBrands, BaseHookOptions, BrandWithCounts, ContactWithRelations, CreateDataHookOptions, CreatePaginatedDataHookOptions, DELETED_FILTER, DataHookReturn, InferHookReturn, InferPaginatedHookReturn, AccountWithBrands as PaginatedAccountWithBrands, PaginatedDataHookReturn, PaginatedHookOptions, PaginationState, ReservationWithRelations, UseAccountsOptions, UseAccountsReturn, UseActivityLogsOptions, UseActivityLogsReturn, UseBrandsOptions, UseBrandsReturn, UseContactsOptions, UseContactsReturn, UsePaginatedAccountsOptions, UsePaginatedAccountsReturn, UsePaginatedBrandsOptions, UsePaginatedBrandsReturn, UsePaginatedContactsOptions, UsePaginatedContactsReturn, UsePaginatedReservationsOptions, UsePaginatedReservationsReturn, UsePaginatedUsersOptions, UsePaginatedUsersReturn, UseProductInstancesOptions, UseProductInstancesReturn, UseProductsOptions, UseProductsReturn, UseReservationsOptions, UseReservationsReturn, UseUsersOptions, UseUsersReturn, UserWithRelations, createDataHook, createPaginatedDataHook, resetClientInstance, useAccounts, useActiveAccounts, useActiveBrands, useActiveContacts, useActiveReservations, useActiveUsers, useActivityLogs, useBrands, useContacts, useDeletedAccounts, useDeletedBrands, useDeletedContacts, useDeletedReservations, useDeletedUsers, useProductInstances, useProducts, useReservations, useUsers } from './hooks/index.js';
|
|
9
9
|
export { InferStoreType, ResourceStores, StoreConfig, createResourceStores, createSingleStore, createStore } from './stores/index.js';
|
|
10
10
|
import 'aws-amplify/data';
|
|
11
11
|
import 'aws-amplify';
|
package/dist/index.js
CHANGED
|
@@ -666,6 +666,45 @@ async function searchContacts(client, query2, brandId, options) {
|
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
668
|
|
|
669
|
+
// src/queries/activityLogs.ts
|
|
670
|
+
async function listActivityLogs(client, options) {
|
|
671
|
+
try {
|
|
672
|
+
const { data, errors, nextToken } = await client.models.ActivityLog.list(options);
|
|
673
|
+
if (errors) {
|
|
674
|
+
console.error("[listActivityLogs] GraphQL errors:", errors);
|
|
675
|
+
return { items: [], nextToken: void 0 };
|
|
676
|
+
}
|
|
677
|
+
return {
|
|
678
|
+
items: data || [],
|
|
679
|
+
nextToken
|
|
680
|
+
};
|
|
681
|
+
} catch (error) {
|
|
682
|
+
console.error("[listActivityLogs] Error:", error);
|
|
683
|
+
throw error;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
async function listActivityLogsByAccount(client, accountId, options) {
|
|
687
|
+
return listActivityLogs(client, {
|
|
688
|
+
filter: { accountId: { eq: accountId } },
|
|
689
|
+
...options
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
async function listActivityLogsByBrand(client, brandId, options) {
|
|
693
|
+
return listActivityLogs(client, {
|
|
694
|
+
filter: { brandId: { eq: brandId } },
|
|
695
|
+
...options
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
async function listRecentActivityLogs(client, options) {
|
|
699
|
+
const { items } = await listActivityLogs(client, {
|
|
700
|
+
filter: options?.filter,
|
|
701
|
+
limit: options?.limit || 20
|
|
702
|
+
});
|
|
703
|
+
return items.sort(
|
|
704
|
+
(a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
|
|
705
|
+
);
|
|
706
|
+
}
|
|
707
|
+
|
|
669
708
|
// src/mutations/brands/brands.ts
|
|
670
709
|
async function createBrand(client, input) {
|
|
671
710
|
try {
|
|
@@ -1337,57 +1376,261 @@ async function updateReservationStatus2(client, id, newStatus) {
|
|
|
1337
1376
|
}
|
|
1338
1377
|
}
|
|
1339
1378
|
|
|
1340
|
-
// src/
|
|
1379
|
+
// src/validation/contact.schemas.ts
|
|
1341
1380
|
import { z } from "zod";
|
|
1342
|
-
var
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1381
|
+
var emailSchema = z.string().trim().toLowerCase().email("Invalid email address").max(254, "Email must not exceed 254 characters");
|
|
1382
|
+
var optionalEmailSchema = z.string().trim().toLowerCase().email("Invalid email address").max(254, "Email must not exceed 254 characters").optional();
|
|
1383
|
+
var PHONE_REGEX = /^[\+]?[(]?[0-9]{1,4}[)]?[-\s\.]?[(]?[0-9]{1,3}[)]?[-\s\.]?[0-9]{1,4}[-\s\.]?[0-9]{1,4}[-\s\.]?[0-9]{0,9}$/;
|
|
1384
|
+
var phoneSchema = z.string().trim().min(7, "Phone number must be at least 7 characters").max(20, "Phone number must not exceed 20 characters").regex(PHONE_REGEX, "Invalid phone number format");
|
|
1385
|
+
var optionalPhoneSchema = z.string().trim().optional().refine(
|
|
1386
|
+
(val) => {
|
|
1387
|
+
if (!val || val === "") return true;
|
|
1388
|
+
return PHONE_REGEX.test(val) && val.length >= 7 && val.length <= 20;
|
|
1389
|
+
},
|
|
1390
|
+
{ message: "Invalid phone number format" }
|
|
1391
|
+
);
|
|
1392
|
+
var NAME_REGEX = /^[\p{L}\s\-'\.]+$/u;
|
|
1393
|
+
var firstNameSchema = z.string().trim().min(1, "First name is required").max(100, "First name must not exceed 100 characters").regex(NAME_REGEX, "First name contains invalid characters");
|
|
1394
|
+
var lastNameSchema = z.string().trim().min(1, "Last name is required").max(100, "Last name must not exceed 100 characters").regex(NAME_REGEX, "Last name contains invalid characters");
|
|
1395
|
+
var optionalFirstNameSchema = z.string().trim().min(1, "First name cannot be empty if provided").max(100, "First name must not exceed 100 characters").regex(NAME_REGEX, "First name contains invalid characters").optional();
|
|
1396
|
+
var optionalLastNameSchema = z.string().trim().min(1, "Last name cannot be empty if provided").max(100, "Last name must not exceed 100 characters").regex(NAME_REGEX, "Last name contains invalid characters").optional();
|
|
1397
|
+
var LOCALE_REGEX = /^[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$/;
|
|
1398
|
+
var localeSchema = z.string().regex(LOCALE_REGEX, "Invalid locale format. Use BCP 47 format (e.g., 'en', 'en-US', 'pt-BR')");
|
|
1399
|
+
var optionalLocaleSchema = z.string().regex(LOCALE_REGEX, "Invalid locale format. Use BCP 47 format (e.g., 'en', 'en-US', 'pt-BR')").optional();
|
|
1400
|
+
var ISO_DATE_REGEX = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{1,3})?(Z|[+-]\d{2}:\d{2})?)?$/;
|
|
1401
|
+
var isoDateStringSchema = z.string().refine(
|
|
1402
|
+
(val) => {
|
|
1403
|
+
if (!ISO_DATE_REGEX.test(val)) return false;
|
|
1404
|
+
const date = new Date(val);
|
|
1405
|
+
return !isNaN(date.getTime());
|
|
1406
|
+
},
|
|
1407
|
+
{ message: "Invalid date format. Use ISO 8601 format (e.g., '2024-01-15T10:30:00Z')" }
|
|
1408
|
+
);
|
|
1409
|
+
var optionalIsoDateStringSchema = z.string().refine(
|
|
1410
|
+
(val) => {
|
|
1411
|
+
if (!ISO_DATE_REGEX.test(val)) return false;
|
|
1412
|
+
const date = new Date(val);
|
|
1413
|
+
return !isNaN(date.getTime());
|
|
1414
|
+
},
|
|
1415
|
+
{ message: "Invalid date format. Use ISO 8601 format (e.g., '2024-01-15T10:30:00Z')" }
|
|
1416
|
+
).optional();
|
|
1417
|
+
var uuidSchema = z.string().uuid("Invalid UUID format").or(z.string().min(1, "ID is required"));
|
|
1418
|
+
var brandIdSchema = z.string().min(1, "Brand ID is required");
|
|
1419
|
+
var tagSchema = z.string().trim().toLowerCase().min(1, "Tag cannot be empty").max(50, "Tag must not exceed 50 characters");
|
|
1420
|
+
var tagsArraySchema = z.array(tagSchema).max(100, "Cannot have more than 100 tags").optional();
|
|
1421
|
+
var CustomFieldType = {
|
|
1422
|
+
STRING: "string",
|
|
1423
|
+
NUMBER: "number",
|
|
1424
|
+
BOOLEAN: "boolean",
|
|
1425
|
+
DATE: "date",
|
|
1426
|
+
ARRAY: "array",
|
|
1427
|
+
OBJECT: "object"
|
|
1428
|
+
};
|
|
1429
|
+
var customFieldDefinitionSchema = z.object({
|
|
1430
|
+
type: z.enum(["string", "number", "boolean", "date", "array", "object"]),
|
|
1431
|
+
required: z.boolean().optional().default(false),
|
|
1432
|
+
maxLength: z.number().positive().optional(),
|
|
1433
|
+
minLength: z.number().nonnegative().optional(),
|
|
1434
|
+
min: z.number().optional(),
|
|
1435
|
+
max: z.number().optional(),
|
|
1436
|
+
pattern: z.string().optional(),
|
|
1437
|
+
enum: z.array(z.union([z.string(), z.number()])).optional()
|
|
1438
|
+
});
|
|
1439
|
+
function createCustomFieldValueSchema(definition) {
|
|
1440
|
+
let schema;
|
|
1441
|
+
switch (definition.type) {
|
|
1442
|
+
case "string":
|
|
1443
|
+
schema = z.string();
|
|
1444
|
+
if (definition.maxLength) {
|
|
1445
|
+
schema = schema.max(definition.maxLength);
|
|
1446
|
+
}
|
|
1447
|
+
if (definition.minLength) {
|
|
1448
|
+
schema = schema.min(definition.minLength);
|
|
1449
|
+
}
|
|
1450
|
+
if (definition.pattern) {
|
|
1451
|
+
schema = schema.regex(new RegExp(definition.pattern));
|
|
1452
|
+
}
|
|
1453
|
+
if (definition.enum) {
|
|
1454
|
+
schema = z.enum(definition.enum);
|
|
1455
|
+
}
|
|
1456
|
+
break;
|
|
1457
|
+
case "number":
|
|
1458
|
+
schema = z.number();
|
|
1459
|
+
if (definition.min !== void 0) {
|
|
1460
|
+
schema = schema.min(definition.min);
|
|
1461
|
+
}
|
|
1462
|
+
if (definition.max !== void 0) {
|
|
1463
|
+
schema = schema.max(definition.max);
|
|
1464
|
+
}
|
|
1465
|
+
break;
|
|
1466
|
+
case "boolean":
|
|
1467
|
+
schema = z.boolean();
|
|
1468
|
+
break;
|
|
1469
|
+
case "date":
|
|
1470
|
+
schema = isoDateStringSchema;
|
|
1471
|
+
break;
|
|
1472
|
+
case "array":
|
|
1473
|
+
schema = z.array(z.any());
|
|
1474
|
+
break;
|
|
1475
|
+
case "object":
|
|
1476
|
+
schema = z.record(z.any());
|
|
1477
|
+
break;
|
|
1478
|
+
default:
|
|
1479
|
+
schema = z.any();
|
|
1480
|
+
}
|
|
1481
|
+
if (!definition.required) {
|
|
1482
|
+
schema = schema.optional();
|
|
1483
|
+
}
|
|
1484
|
+
return schema;
|
|
1485
|
+
}
|
|
1486
|
+
var contactPreferencesSchema = z.record(
|
|
1487
|
+
z.string(),
|
|
1488
|
+
z.union([
|
|
1489
|
+
z.string(),
|
|
1490
|
+
z.number(),
|
|
1491
|
+
z.boolean(),
|
|
1492
|
+
z.array(z.any()),
|
|
1493
|
+
z.record(z.any()),
|
|
1494
|
+
z.null()
|
|
1495
|
+
])
|
|
1496
|
+
).optional().refine(
|
|
1497
|
+
(preferences) => {
|
|
1498
|
+
if (!preferences) return true;
|
|
1499
|
+
if (preferences.theme && !["light", "dark", "system"].includes(preferences.theme)) {
|
|
1500
|
+
return false;
|
|
1501
|
+
}
|
|
1502
|
+
if (preferences.language && typeof preferences.language === "string") {
|
|
1503
|
+
const localeResult = localeSchema.safeParse(preferences.language);
|
|
1504
|
+
if (!localeResult.success) return false;
|
|
1505
|
+
}
|
|
1506
|
+
return true;
|
|
1507
|
+
},
|
|
1508
|
+
{
|
|
1509
|
+
message: "Invalid preferences structure. Check theme (light/dark/system) and language (BCP 47) values."
|
|
1510
|
+
}
|
|
1511
|
+
);
|
|
1512
|
+
var notificationPreferencesSchema = z.object({
|
|
1513
|
+
email: z.boolean().optional().default(true),
|
|
1514
|
+
sms: z.boolean().optional().default(false),
|
|
1515
|
+
push: z.boolean().optional().default(false)
|
|
1516
|
+
});
|
|
1517
|
+
var communicationPreferencesSchema = z.object({
|
|
1518
|
+
preferredChannel: z.enum(["email", "phone", "sms"]).optional().default("email")
|
|
1519
|
+
});
|
|
1520
|
+
var baseContactFieldsSchema = {
|
|
1521
|
+
brandId: brandIdSchema,
|
|
1522
|
+
email: emailSchema,
|
|
1523
|
+
phone: optionalPhoneSchema,
|
|
1524
|
+
firstName: firstNameSchema,
|
|
1525
|
+
lastName: lastNameSchema,
|
|
1526
|
+
locale: optionalLocaleSchema,
|
|
1527
|
+
gdprConsent: z.boolean({
|
|
1528
|
+
required_error: "GDPR consent is required",
|
|
1529
|
+
invalid_type_error: "GDPR consent must be a boolean"
|
|
1530
|
+
}),
|
|
1531
|
+
gdprConsentDate: optionalIsoDateStringSchema,
|
|
1351
1532
|
marketingOptIn: z.boolean().optional(),
|
|
1352
|
-
preferences:
|
|
1353
|
-
tags:
|
|
1354
|
-
totalVisits: z.number().int().min(0).optional(),
|
|
1355
|
-
lastVisitDate:
|
|
1356
|
-
firstVisitDate:
|
|
1357
|
-
legacyId: z.string().optional()
|
|
1358
|
-
|
|
1359
|
-
|
|
1533
|
+
preferences: contactPreferencesSchema,
|
|
1534
|
+
tags: tagsArraySchema,
|
|
1535
|
+
totalVisits: z.number().int().min(0, "Total visits cannot be negative").optional(),
|
|
1536
|
+
lastVisitDate: optionalIsoDateStringSchema,
|
|
1537
|
+
firstVisitDate: optionalIsoDateStringSchema,
|
|
1538
|
+
legacyId: z.string().max(255, "Legacy ID must not exceed 255 characters").optional()
|
|
1539
|
+
};
|
|
1540
|
+
var createAuditFieldsSchema = {
|
|
1541
|
+
createdAt: optionalIsoDateStringSchema,
|
|
1360
1542
|
createdBy: z.string().optional(),
|
|
1361
|
-
updatedAt:
|
|
1543
|
+
updatedAt: optionalIsoDateStringSchema,
|
|
1362
1544
|
updatedBy: z.string().optional()
|
|
1545
|
+
};
|
|
1546
|
+
var updateAuditFieldsSchema = {
|
|
1547
|
+
updatedAt: optionalIsoDateStringSchema,
|
|
1548
|
+
updatedBy: z.string().optional(),
|
|
1549
|
+
deletedAt: z.string().nullable().optional(),
|
|
1550
|
+
deletedBy: z.string().nullable().optional()
|
|
1551
|
+
};
|
|
1552
|
+
var createContactSchema = z.object({
|
|
1553
|
+
...baseContactFieldsSchema,
|
|
1554
|
+
...createAuditFieldsSchema
|
|
1363
1555
|
});
|
|
1364
1556
|
var updateContactSchema = z.object({
|
|
1365
1557
|
id: z.string().min(1, "Contact ID is required"),
|
|
1366
|
-
brandId:
|
|
1367
|
-
email:
|
|
1368
|
-
phone:
|
|
1369
|
-
firstName:
|
|
1370
|
-
lastName:
|
|
1371
|
-
locale:
|
|
1558
|
+
brandId: brandIdSchema.optional(),
|
|
1559
|
+
email: optionalEmailSchema,
|
|
1560
|
+
phone: optionalPhoneSchema,
|
|
1561
|
+
firstName: optionalFirstNameSchema,
|
|
1562
|
+
lastName: optionalLastNameSchema,
|
|
1563
|
+
locale: optionalLocaleSchema,
|
|
1372
1564
|
gdprConsent: z.boolean().optional(),
|
|
1373
|
-
gdprConsentDate:
|
|
1565
|
+
gdprConsentDate: optionalIsoDateStringSchema,
|
|
1374
1566
|
marketingOptIn: z.boolean().optional(),
|
|
1375
|
-
preferences:
|
|
1376
|
-
tags:
|
|
1377
|
-
totalVisits: z.number().int().min(0).optional(),
|
|
1378
|
-
lastVisitDate:
|
|
1379
|
-
firstVisitDate:
|
|
1380
|
-
legacyId: z.string().optional(),
|
|
1381
|
-
|
|
1382
|
-
updatedAt: z.string().optional(),
|
|
1383
|
-
updatedBy: z.string().optional(),
|
|
1384
|
-
deletedAt: z.string().nullable().optional(),
|
|
1385
|
-
deletedBy: z.string().nullable().optional()
|
|
1567
|
+
preferences: contactPreferencesSchema,
|
|
1568
|
+
tags: tagsArraySchema,
|
|
1569
|
+
totalVisits: z.number().int().min(0, "Total visits cannot be negative").optional(),
|
|
1570
|
+
lastVisitDate: optionalIsoDateStringSchema,
|
|
1571
|
+
firstVisitDate: optionalIsoDateStringSchema,
|
|
1572
|
+
legacyId: z.string().max(255, "Legacy ID must not exceed 255 characters").optional(),
|
|
1573
|
+
...updateAuditFieldsSchema
|
|
1386
1574
|
});
|
|
1387
1575
|
var mergeContactsSchema = z.object({
|
|
1388
1576
|
primaryId: z.string().min(1, "Primary contact ID is required"),
|
|
1389
|
-
duplicateIds: z.array(z.string().min(1)).min(1, "At least one duplicate ID is required")
|
|
1577
|
+
duplicateIds: z.array(z.string().min(1, "Duplicate ID cannot be empty")).min(1, "At least one duplicate ID is required").max(50, "Cannot merge more than 50 contacts at once")
|
|
1578
|
+
});
|
|
1579
|
+
var searchContactSchema = z.object({
|
|
1580
|
+
brandId: brandIdSchema.optional(),
|
|
1581
|
+
email: z.string().optional(),
|
|
1582
|
+
phone: z.string().optional(),
|
|
1583
|
+
firstName: z.string().optional(),
|
|
1584
|
+
lastName: z.string().optional(),
|
|
1585
|
+
search: z.string().max(255, "Search query must not exceed 255 characters").optional(),
|
|
1586
|
+
tags: z.array(z.string()).optional(),
|
|
1587
|
+
gdprConsent: z.boolean().optional(),
|
|
1588
|
+
marketingOptIn: z.boolean().optional(),
|
|
1589
|
+
includeDeleted: z.boolean().optional().default(false),
|
|
1590
|
+
limit: z.number().int().min(1).max(250).optional().default(25),
|
|
1591
|
+
nextToken: z.string().optional()
|
|
1592
|
+
});
|
|
1593
|
+
var bulkImportContactSchema = z.object({
|
|
1594
|
+
contacts: z.array(createContactSchema.omit({ createdAt: true, createdBy: true, updatedAt: true, updatedBy: true })).min(1, "At least one contact is required").max(1e3, "Cannot import more than 1000 contacts at once"),
|
|
1595
|
+
skipDuplicates: z.boolean().optional().default(true),
|
|
1596
|
+
updateExisting: z.boolean().optional().default(false)
|
|
1390
1597
|
});
|
|
1598
|
+
function validateEmail(email) {
|
|
1599
|
+
return emailSchema.safeParse(email);
|
|
1600
|
+
}
|
|
1601
|
+
function validatePhone(phone) {
|
|
1602
|
+
return phoneSchema.safeParse(phone);
|
|
1603
|
+
}
|
|
1604
|
+
function validateContactName(firstName, lastName) {
|
|
1605
|
+
const firstNameResult = firstNameSchema.safeParse(firstName);
|
|
1606
|
+
const lastNameResult = lastNameSchema.safeParse(lastName);
|
|
1607
|
+
return {
|
|
1608
|
+
firstName: firstNameResult,
|
|
1609
|
+
lastName: lastNameResult,
|
|
1610
|
+
isValid: firstNameResult.success && lastNameResult.success
|
|
1611
|
+
};
|
|
1612
|
+
}
|
|
1613
|
+
function validateCreateContact(input) {
|
|
1614
|
+
return createContactSchema.safeParse(input);
|
|
1615
|
+
}
|
|
1616
|
+
function validateUpdateContact(input) {
|
|
1617
|
+
return updateContactSchema.safeParse(input);
|
|
1618
|
+
}
|
|
1619
|
+
function formatValidationErrors(error) {
|
|
1620
|
+
return error.issues.map((issue) => {
|
|
1621
|
+
const path = issue.path.join(".");
|
|
1622
|
+
return path ? `${path}: ${issue.message}` : issue.message;
|
|
1623
|
+
}).join("; ");
|
|
1624
|
+
}
|
|
1625
|
+
function getValidationErrorDetails(error) {
|
|
1626
|
+
return error.issues.map((issue) => ({
|
|
1627
|
+
path: issue.path.join("."),
|
|
1628
|
+
message: issue.message,
|
|
1629
|
+
code: issue.code
|
|
1630
|
+
}));
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
// src/mutations/contacts.ts
|
|
1391
1634
|
var ContactValidationError = class extends Error {
|
|
1392
1635
|
issues;
|
|
1393
1636
|
constructor(message, issues = []) {
|
|
@@ -1400,9 +1643,8 @@ async function createContact(client, input) {
|
|
|
1400
1643
|
try {
|
|
1401
1644
|
const validationResult = createContactSchema.safeParse(input);
|
|
1402
1645
|
if (!validationResult.success) {
|
|
1403
|
-
const errorMessage = validationResult.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join(", ");
|
|
1404
1646
|
throw new ContactValidationError(
|
|
1405
|
-
`Validation failed: ${
|
|
1647
|
+
`Validation failed: ${formatValidationErrors(validationResult.error)}`,
|
|
1406
1648
|
validationResult.error.issues
|
|
1407
1649
|
);
|
|
1408
1650
|
}
|
|
@@ -1425,9 +1667,8 @@ async function updateContact(client, input) {
|
|
|
1425
1667
|
try {
|
|
1426
1668
|
const validationResult = updateContactSchema.safeParse(input);
|
|
1427
1669
|
if (!validationResult.success) {
|
|
1428
|
-
const errorMessage = validationResult.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join(", ");
|
|
1429
1670
|
throw new ContactValidationError(
|
|
1430
|
-
`Validation failed: ${
|
|
1671
|
+
`Validation failed: ${formatValidationErrors(validationResult.error)}`,
|
|
1431
1672
|
validationResult.error.issues
|
|
1432
1673
|
);
|
|
1433
1674
|
}
|
|
@@ -1511,9 +1752,8 @@ async function mergeContacts(client, input, mergedBy) {
|
|
|
1511
1752
|
try {
|
|
1512
1753
|
const validationResult = mergeContactsSchema.safeParse(input);
|
|
1513
1754
|
if (!validationResult.success) {
|
|
1514
|
-
const errorMessage = validationResult.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join(", ");
|
|
1515
1755
|
throw new ContactValidationError(
|
|
1516
|
-
`Validation failed: ${
|
|
1756
|
+
`Validation failed: ${formatValidationErrors(validationResult.error)}`,
|
|
1517
1757
|
validationResult.error.issues
|
|
1518
1758
|
);
|
|
1519
1759
|
}
|
|
@@ -1606,7 +1846,7 @@ function createDataHook(config) {
|
|
|
1606
1846
|
defaultLimit,
|
|
1607
1847
|
selectionSet,
|
|
1608
1848
|
transform,
|
|
1609
|
-
buildFilter:
|
|
1849
|
+
buildFilter: buildFilter12,
|
|
1610
1850
|
computedProperties,
|
|
1611
1851
|
dataPropertyName = "data"
|
|
1612
1852
|
} = config;
|
|
@@ -1616,8 +1856,8 @@ function createDataHook(config) {
|
|
|
1616
1856
|
const loading = ref(false);
|
|
1617
1857
|
const error = ref(null);
|
|
1618
1858
|
const getFilter = () => {
|
|
1619
|
-
if (
|
|
1620
|
-
return
|
|
1859
|
+
if (buildFilter12) {
|
|
1860
|
+
return buildFilter12(options);
|
|
1621
1861
|
}
|
|
1622
1862
|
return baseFilter && Object.keys(baseFilter).length > 0 ? baseFilter : void 0;
|
|
1623
1863
|
};
|
|
@@ -1691,7 +1931,7 @@ function createPaginatedDataHook(config) {
|
|
|
1691
1931
|
defaultPageSize = 25,
|
|
1692
1932
|
selectionSet,
|
|
1693
1933
|
transform,
|
|
1694
|
-
buildFilter:
|
|
1934
|
+
buildFilter: buildFilter12,
|
|
1695
1935
|
dataPropertyName = "data",
|
|
1696
1936
|
baseFilter
|
|
1697
1937
|
} = config;
|
|
@@ -1714,8 +1954,8 @@ function createPaginatedDataHook(config) {
|
|
|
1714
1954
|
if (baseFilter) {
|
|
1715
1955
|
filters.push(baseFilter);
|
|
1716
1956
|
}
|
|
1717
|
-
if (
|
|
1718
|
-
const customFilter =
|
|
1957
|
+
if (buildFilter12) {
|
|
1958
|
+
const customFilter = buildFilter12(options);
|
|
1719
1959
|
if (customFilter) {
|
|
1720
1960
|
filters.push(customFilter);
|
|
1721
1961
|
}
|
|
@@ -1889,9 +2129,14 @@ function buildFilter2(options) {
|
|
|
1889
2129
|
return { and: conditions };
|
|
1890
2130
|
}
|
|
1891
2131
|
function transformBrand(brand) {
|
|
2132
|
+
const productInstances = brand.productInstances?.items || [];
|
|
2133
|
+
const enabledProductCount = productInstances.filter((p) => p.enabled).length;
|
|
2134
|
+
const totalProductCount = productInstances.length;
|
|
1892
2135
|
return {
|
|
1893
2136
|
...brand,
|
|
1894
|
-
accountName: brand.account?.name || ""
|
|
2137
|
+
accountName: brand.account?.name || "",
|
|
2138
|
+
enabledProductCount,
|
|
2139
|
+
totalProductCount
|
|
1895
2140
|
};
|
|
1896
2141
|
}
|
|
1897
2142
|
var BRAND_SELECTION_SET = [
|
|
@@ -1904,7 +2149,8 @@ var BRAND_SELECTION_SET = [
|
|
|
1904
2149
|
"settings",
|
|
1905
2150
|
"deletedAt",
|
|
1906
2151
|
"deletedBy",
|
|
1907
|
-
"account.name"
|
|
2152
|
+
"account.name",
|
|
2153
|
+
"productInstances.*"
|
|
1908
2154
|
];
|
|
1909
2155
|
var useActiveBrandsInternal = createPaginatedDataHook({
|
|
1910
2156
|
model: "Brand",
|
|
@@ -2672,6 +2918,43 @@ function useDeletedContacts(options = {}) {
|
|
|
2672
2918
|
};
|
|
2673
2919
|
}
|
|
2674
2920
|
|
|
2921
|
+
// src/hooks/activityLogs/useActivityLogs.ts
|
|
2922
|
+
function buildFilter11(options) {
|
|
2923
|
+
const conditions = [];
|
|
2924
|
+
if (options.accountId) {
|
|
2925
|
+
conditions.push({ accountId: { eq: options.accountId } });
|
|
2926
|
+
}
|
|
2927
|
+
if (options.brandId) {
|
|
2928
|
+
conditions.push({ brandId: { eq: options.brandId } });
|
|
2929
|
+
}
|
|
2930
|
+
if (options.resourceType) {
|
|
2931
|
+
conditions.push({ resourceType: { eq: options.resourceType } });
|
|
2932
|
+
}
|
|
2933
|
+
if (options.action) {
|
|
2934
|
+
conditions.push({ action: { eq: options.action } });
|
|
2935
|
+
}
|
|
2936
|
+
if (options.filter) {
|
|
2937
|
+
conditions.push(options.filter);
|
|
2938
|
+
}
|
|
2939
|
+
if (conditions.length === 0) return void 0;
|
|
2940
|
+
if (conditions.length === 1) return conditions[0];
|
|
2941
|
+
return { and: conditions };
|
|
2942
|
+
}
|
|
2943
|
+
var useActivityLogsInternal = createDataHook({
|
|
2944
|
+
model: "ActivityLog",
|
|
2945
|
+
dataPropertyName: "activityLogs",
|
|
2946
|
+
buildFilter: buildFilter11
|
|
2947
|
+
});
|
|
2948
|
+
function useActivityLogs(options = {}) {
|
|
2949
|
+
const result = useActivityLogsInternal(options);
|
|
2950
|
+
return {
|
|
2951
|
+
activityLogs: result.activityLogs,
|
|
2952
|
+
loading: result.loading,
|
|
2953
|
+
error: result.error,
|
|
2954
|
+
refetch: result.refetch
|
|
2955
|
+
};
|
|
2956
|
+
}
|
|
2957
|
+
|
|
2675
2958
|
// ../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/clean-stores/index.js
|
|
2676
2959
|
var clean = /* @__PURE__ */ Symbol("clean");
|
|
2677
2960
|
|
|
@@ -2777,15 +3060,21 @@ function createSingleStore(shared, name, defaultValue) {
|
|
|
2777
3060
|
export {
|
|
2778
3061
|
ACTIVE_FILTER,
|
|
2779
3062
|
ContactValidationError,
|
|
3063
|
+
CustomFieldType,
|
|
2780
3064
|
DEFAULT_SOFT_DELETE_RETENTION_DAYS,
|
|
2781
3065
|
DELETED_FILTER,
|
|
2782
3066
|
ReservationValidationError,
|
|
2783
3067
|
SYSTEM_SETTINGS_KEY,
|
|
3068
|
+
brandIdSchema,
|
|
3069
|
+
bulkImportContactSchema,
|
|
2784
3070
|
checkRestoreEligibility,
|
|
3071
|
+
communicationPreferencesSchema,
|
|
3072
|
+
contactPreferencesSchema,
|
|
2785
3073
|
createAccount,
|
|
2786
3074
|
createBrand,
|
|
2787
3075
|
createContact,
|
|
2788
3076
|
createContactSchema,
|
|
3077
|
+
createCustomFieldValueSchema,
|
|
2789
3078
|
createDataHook,
|
|
2790
3079
|
createPaginatedDataHook,
|
|
2791
3080
|
createProductInstance,
|
|
@@ -2794,14 +3083,18 @@ export {
|
|
|
2794
3083
|
createSingleStore,
|
|
2795
3084
|
createStore,
|
|
2796
3085
|
createUser,
|
|
3086
|
+
customFieldDefinitionSchema,
|
|
2797
3087
|
deleteAccount,
|
|
2798
3088
|
deleteBrand,
|
|
2799
3089
|
deleteContact,
|
|
2800
3090
|
deleteProductInstance,
|
|
2801
3091
|
deleteReservation2 as deleteReservation,
|
|
2802
3092
|
deleteUser,
|
|
3093
|
+
emailSchema,
|
|
2803
3094
|
executePublicQuery,
|
|
2804
3095
|
executeServerQuery,
|
|
3096
|
+
firstNameSchema,
|
|
3097
|
+
formatValidationErrors,
|
|
2805
3098
|
generateClient,
|
|
2806
3099
|
generateServerClient,
|
|
2807
3100
|
getAccount,
|
|
@@ -2822,12 +3115,18 @@ export {
|
|
|
2822
3115
|
getUser,
|
|
2823
3116
|
getUserByCognitoId,
|
|
2824
3117
|
getUserByEmail,
|
|
3118
|
+
getValidationErrorDetails,
|
|
2825
3119
|
hasErrors,
|
|
2826
3120
|
initializeSystemSettings,
|
|
3121
|
+
isoDateStringSchema,
|
|
3122
|
+
lastNameSchema,
|
|
2827
3123
|
listAccounts,
|
|
2828
3124
|
listActiveBrands,
|
|
2829
3125
|
listActiveProducts,
|
|
2830
3126
|
listActiveUsers,
|
|
3127
|
+
listActivityLogs,
|
|
3128
|
+
listActivityLogsByAccount,
|
|
3129
|
+
listActivityLogsByBrand,
|
|
2831
3130
|
listBrands,
|
|
2832
3131
|
listBrandsByAccount,
|
|
2833
3132
|
listContacts,
|
|
@@ -2836,15 +3135,25 @@ export {
|
|
|
2836
3135
|
listProductInstancesByAccount,
|
|
2837
3136
|
listProductInstancesByBrand,
|
|
2838
3137
|
listProducts,
|
|
3138
|
+
listRecentActivityLogs,
|
|
2839
3139
|
listReservations2 as listReservations,
|
|
2840
3140
|
listReservationsByBrand,
|
|
2841
3141
|
listReservationsByContact,
|
|
2842
3142
|
listReservationsByDateRange,
|
|
2843
3143
|
listUsers,
|
|
2844
3144
|
listUsersByAccount,
|
|
3145
|
+
localeSchema,
|
|
2845
3146
|
mergeContacts,
|
|
2846
3147
|
mergeContactsSchema,
|
|
2847
3148
|
mutate,
|
|
3149
|
+
notificationPreferencesSchema,
|
|
3150
|
+
optionalEmailSchema,
|
|
3151
|
+
optionalFirstNameSchema,
|
|
3152
|
+
optionalIsoDateStringSchema,
|
|
3153
|
+
optionalLastNameSchema,
|
|
3154
|
+
optionalLocaleSchema,
|
|
3155
|
+
optionalPhoneSchema,
|
|
3156
|
+
phoneSchema,
|
|
2848
3157
|
query,
|
|
2849
3158
|
resetClientInstance,
|
|
2850
3159
|
resetSharedClient,
|
|
@@ -2853,12 +3162,15 @@ export {
|
|
|
2853
3162
|
restoreContact,
|
|
2854
3163
|
restoreReservation2 as restoreReservation,
|
|
2855
3164
|
restoreUser,
|
|
3165
|
+
searchContactSchema,
|
|
2856
3166
|
searchContacts,
|
|
2857
3167
|
softDeleteAccount,
|
|
2858
3168
|
softDeleteBrand,
|
|
2859
3169
|
softDeleteContact,
|
|
2860
3170
|
softDeleteReservation2 as softDeleteReservation,
|
|
2861
3171
|
softDeleteUser,
|
|
3172
|
+
tagSchema,
|
|
3173
|
+
tagsArraySchema,
|
|
2862
3174
|
toggleProductInstanceEnabled,
|
|
2863
3175
|
updateAccount,
|
|
2864
3176
|
updateBrand,
|
|
@@ -2875,6 +3187,7 @@ export {
|
|
|
2875
3187
|
useActiveContacts,
|
|
2876
3188
|
useActiveReservations,
|
|
2877
3189
|
useActiveUsers,
|
|
3190
|
+
useActivityLogs,
|
|
2878
3191
|
useBrands,
|
|
2879
3192
|
useContacts,
|
|
2880
3193
|
useDeletedAccounts,
|
|
@@ -2885,6 +3198,12 @@ export {
|
|
|
2885
3198
|
useProductInstances,
|
|
2886
3199
|
useProducts,
|
|
2887
3200
|
useReservations,
|
|
2888
|
-
useUsers
|
|
3201
|
+
useUsers,
|
|
3202
|
+
uuidSchema,
|
|
3203
|
+
validateContactName,
|
|
3204
|
+
validateCreateContact,
|
|
3205
|
+
validateEmail,
|
|
3206
|
+
validatePhone,
|
|
3207
|
+
validateUpdateContact
|
|
2889
3208
|
};
|
|
2890
3209
|
//# sourceMappingURL=index.js.map
|