@htlkg/data 0.0.19 → 0.0.20

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,6 +1,8 @@
1
- import { C as CreateAuditFields, a as UpdateWithSoftDeleteFields } from '../productInstances-BA3cNsYc.js';
2
- export { b as CreateProductInstanceInput, S as SoftDeleteFields, U as UpdateAuditFields, e as UpdateProductInstanceInput, c as createProductInstance, d as deleteProductInstance, t as toggleProductInstanceEnabled, u as updateProductInstance } from '../productInstances-BA3cNsYc.js';
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
3
  import { Brand, Account, User, SystemSettings } from '@htlkg/core/types';
4
+ export { C as CreateProductInstanceInput, U as UpdateProductInstanceInput, c as createProductInstance, d as deleteProductInstance, t as toggleProductInstanceEnabled, u as updateProductInstance } from '../productInstances-BpQv1oLS.js';
5
+ 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';
4
6
 
5
7
  /**
6
8
  * Brand Mutation Functions
@@ -509,26 +509,226 @@ async function initializeSystemSettings(client, initializedBy) {
509
509
  throw error;
510
510
  }
511
511
  }
512
+
513
+ // src/mutations/reservations.ts
514
+ var STATUS_TRANSITIONS = {
515
+ confirmed: ["checked_in", "cancelled", "no_show"],
516
+ checked_in: ["checked_out", "cancelled"],
517
+ checked_out: [],
518
+ // Terminal state - no transitions allowed
519
+ cancelled: [],
520
+ // Terminal state - no transitions allowed
521
+ no_show: []
522
+ // Terminal state - no transitions allowed
523
+ };
524
+ var ReservationValidationError = class extends Error {
525
+ constructor(message) {
526
+ super(message);
527
+ this.name = "ReservationValidationError";
528
+ }
529
+ };
530
+ function validateDates(checkIn, checkOut) {
531
+ const checkInDate = new Date(checkIn);
532
+ const checkOutDate = new Date(checkOut);
533
+ if (isNaN(checkInDate.getTime())) {
534
+ throw new ReservationValidationError("Invalid check-in date");
535
+ }
536
+ if (isNaN(checkOutDate.getTime())) {
537
+ throw new ReservationValidationError("Invalid check-out date");
538
+ }
539
+ if (checkOutDate <= checkInDate) {
540
+ throw new ReservationValidationError(
541
+ "Check-out date must be after check-in date"
542
+ );
543
+ }
544
+ const minStayHours = 4;
545
+ const stayDuration = checkOutDate.getTime() - checkInDate.getTime();
546
+ const hoursDiff = stayDuration / (1e3 * 60 * 60);
547
+ if (hoursDiff < minStayHours) {
548
+ throw new ReservationValidationError(
549
+ `Minimum stay is ${minStayHours} hours`
550
+ );
551
+ }
552
+ }
553
+ function validateStatusTransition(currentStatus, newStatus) {
554
+ const allowedTransitions = STATUS_TRANSITIONS[currentStatus];
555
+ if (!allowedTransitions.includes(newStatus)) {
556
+ throw new ReservationValidationError(
557
+ `Invalid status transition from '${currentStatus}' to '${newStatus}'. Allowed transitions: ${allowedTransitions.length > 0 ? allowedTransitions.join(", ") : "none (terminal state)"}`
558
+ );
559
+ }
560
+ }
561
+ async function createReservation(client, input) {
562
+ try {
563
+ validateDates(input.checkIn, input.checkOut);
564
+ if (!input.nights) {
565
+ const checkInDate = new Date(input.checkIn);
566
+ const checkOutDate = new Date(input.checkOut);
567
+ const diffTime = checkOutDate.getTime() - checkInDate.getTime();
568
+ const diffDays = Math.ceil(diffTime / (1e3 * 60 * 60 * 24));
569
+ input.nights = diffDays;
570
+ }
571
+ const { data, errors } = await client.models.Reservation.create(input);
572
+ if (errors) {
573
+ console.error("[createReservation] GraphQL errors:", errors);
574
+ return null;
575
+ }
576
+ return data;
577
+ } catch (error) {
578
+ if (error instanceof ReservationValidationError) {
579
+ console.error("[createReservation] Validation error:", error.message);
580
+ throw error;
581
+ }
582
+ console.error("[createReservation] Error creating reservation:", error);
583
+ throw error;
584
+ }
585
+ }
586
+ async function updateReservation(client, input) {
587
+ try {
588
+ if (input.checkIn && input.checkOut) {
589
+ validateDates(input.checkIn, input.checkOut);
590
+ const checkInDate = new Date(input.checkIn);
591
+ const checkOutDate = new Date(input.checkOut);
592
+ const diffTime = checkOutDate.getTime() - checkInDate.getTime();
593
+ const diffDays = Math.ceil(diffTime / (1e3 * 60 * 60 * 24));
594
+ input.nights = diffDays;
595
+ }
596
+ if (input.status) {
597
+ const { data: currentReservation, errors: getErrors } = await client.models.Reservation.get({ id: input.id });
598
+ if (getErrors || !currentReservation) {
599
+ console.error("[updateReservation] Error fetching current reservation:", getErrors);
600
+ return null;
601
+ }
602
+ const currentStatus = currentReservation.status;
603
+ validateStatusTransition(currentStatus, input.status);
604
+ }
605
+ const { data, errors } = await client.models.Reservation.update(input);
606
+ if (errors) {
607
+ console.error("[updateReservation] GraphQL errors:", errors);
608
+ return null;
609
+ }
610
+ return data;
611
+ } catch (error) {
612
+ if (error instanceof ReservationValidationError) {
613
+ console.error("[updateReservation] Validation error:", error.message);
614
+ throw error;
615
+ }
616
+ console.error("[updateReservation] Error updating reservation:", error);
617
+ throw error;
618
+ }
619
+ }
620
+ async function softDeleteReservation(client, id, deletedBy) {
621
+ try {
622
+ const { errors } = await client.models.Reservation.update({
623
+ id,
624
+ deletedAt: (/* @__PURE__ */ new Date()).toISOString(),
625
+ deletedBy
626
+ });
627
+ if (errors) {
628
+ console.error("[softDeleteReservation] GraphQL errors:", errors);
629
+ return false;
630
+ }
631
+ return true;
632
+ } catch (error) {
633
+ console.error("[softDeleteReservation] Error soft-deleting reservation:", error);
634
+ throw error;
635
+ }
636
+ }
637
+ async function restoreReservation(client, id, retentionDays = DEFAULT_SOFT_DELETE_RETENTION_DAYS) {
638
+ try {
639
+ const { data: reservation, errors: getErrors } = await client.models.Reservation.get({ id });
640
+ if (getErrors || !reservation) {
641
+ console.error("[restoreReservation] Error fetching reservation:", getErrors);
642
+ return { success: false, error: "Reservation not found" };
643
+ }
644
+ const eligibility = checkRestoreEligibility(reservation.deletedAt, retentionDays);
645
+ if (!eligibility.canRestore) {
646
+ const errorMsg = `Cannot restore reservation. Retention period of ${retentionDays} days has expired. Item was deleted ${eligibility.daysExpired} days ago.`;
647
+ console.error("[restoreReservation]", errorMsg);
648
+ return { success: false, error: errorMsg };
649
+ }
650
+ const { errors } = await client.models.Reservation.update({
651
+ id,
652
+ deletedAt: null,
653
+ deletedBy: null
654
+ });
655
+ if (errors) {
656
+ console.error("[restoreReservation] GraphQL errors:", errors);
657
+ return { success: false, error: "Failed to restore reservation" };
658
+ }
659
+ return { success: true };
660
+ } catch (error) {
661
+ console.error("[restoreReservation] Error restoring reservation:", error);
662
+ throw error;
663
+ }
664
+ }
665
+ async function deleteReservation(client, id) {
666
+ try {
667
+ const { errors } = await client.models.Reservation.delete({ id });
668
+ if (errors) {
669
+ console.error("[deleteReservation] GraphQL errors:", errors);
670
+ return false;
671
+ }
672
+ return true;
673
+ } catch (error) {
674
+ console.error("[deleteReservation] Error deleting reservation:", error);
675
+ throw error;
676
+ }
677
+ }
678
+ async function updateReservationStatus(client, id, newStatus) {
679
+ try {
680
+ const { data: currentReservation, errors: getErrors } = await client.models.Reservation.get({ id });
681
+ if (getErrors || !currentReservation) {
682
+ console.error("[updateReservationStatus] Error fetching reservation:", getErrors);
683
+ return null;
684
+ }
685
+ const currentStatus = currentReservation.status;
686
+ validateStatusTransition(currentStatus, newStatus);
687
+ const { data, errors } = await client.models.Reservation.update({
688
+ id,
689
+ status: newStatus
690
+ });
691
+ if (errors) {
692
+ console.error("[updateReservationStatus] GraphQL errors:", errors);
693
+ return null;
694
+ }
695
+ return data;
696
+ } catch (error) {
697
+ if (error instanceof ReservationValidationError) {
698
+ console.error("[updateReservationStatus] Validation error:", error.message);
699
+ throw error;
700
+ }
701
+ console.error("[updateReservationStatus] Error updating status:", error);
702
+ throw error;
703
+ }
704
+ }
512
705
  export {
706
+ ReservationValidationError,
513
707
  createAccount,
514
708
  createBrand,
515
709
  createProductInstance,
710
+ createReservation,
516
711
  createUser,
517
712
  deleteAccount,
518
713
  deleteBrand,
519
714
  deleteProductInstance,
715
+ deleteReservation,
520
716
  deleteUser,
521
717
  initializeSystemSettings,
522
718
  restoreAccount,
523
719
  restoreBrand,
720
+ restoreReservation,
524
721
  restoreUser,
525
722
  softDeleteAccount,
526
723
  softDeleteBrand,
724
+ softDeleteReservation,
527
725
  softDeleteUser,
528
726
  toggleProductInstanceEnabled,
529
727
  updateAccount,
530
728
  updateBrand,
531
729
  updateProductInstance,
730
+ updateReservation,
731
+ updateReservationStatus,
532
732
  updateSystemSettings,
533
733
  updateUser
534
734
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/queries/systemSettings.ts","../../src/mutations/brands.ts","../../src/mutations/accounts.ts","../../src/mutations/users.ts","../../src/mutations/productInstances/productInstances.ts","../../src/mutations/systemSettings.ts"],"sourcesContent":["/**\n * SystemSettings Query Functions\n *\n * Provides query functions for fetching system settings from the GraphQL API.\n */\n\nimport type { SystemSettings } from \"@htlkg/core/types\";\n\n/** Default retention days if no settings exist */\nexport const DEFAULT_SOFT_DELETE_RETENTION_DAYS = 30;\n\n/** The key used for global system settings */\nexport const SYSTEM_SETTINGS_KEY = \"GLOBAL\";\n\n/**\n * Get system settings\n *\n * @example\n * ```typescript\n * import { getSystemSettings } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const settings = await getSystemSettings(client);\n * ```\n */\nexport async function getSystemSettings<TClient = any>(\n\tclient: TClient,\n): Promise<SystemSettings | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.SystemSettings.get({\n\t\t\tkey: SYSTEM_SETTINGS_KEY,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getSystemSettings] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as SystemSettings;\n\t} catch (error) {\n\t\tconsole.error(\"[getSystemSettings] Error fetching system settings:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get the soft delete retention days from system settings\n * Returns the default (30 days) if settings don't exist\n *\n * @example\n * ```typescript\n * import { getSoftDeleteRetentionDays } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const days = await getSoftDeleteRetentionDays(client);\n * ```\n */\nexport async function getSoftDeleteRetentionDays<TClient = any>(\n\tclient: TClient,\n): Promise<number> {\n\tconst settings = await getSystemSettings(client);\n\treturn settings?.softDeleteRetentionDays ?? DEFAULT_SOFT_DELETE_RETENTION_DAYS;\n}\n\n/**\n * Check if a soft-deleted item can still be restored based on retention period\n *\n * @param deletedAt - The ISO date string when the item was deleted\n * @param retentionDays - Number of days items can be restored\n * @returns Object with canRestore flag and daysRemaining/daysExpired\n */\nexport function checkRestoreEligibility(\n\tdeletedAt: string | undefined | null,\n\tretentionDays: number,\n): {\n\tcanRestore: boolean;\n\tdaysRemaining: number;\n\tdaysExpired: number;\n\texpiresAt: Date | null;\n} {\n\tif (!deletedAt) {\n\t\treturn {\n\t\t\tcanRestore: false,\n\t\t\tdaysRemaining: 0,\n\t\t\tdaysExpired: 0,\n\t\t\texpiresAt: null,\n\t\t};\n\t}\n\n\tconst deletedDate = new Date(deletedAt);\n\tconst expiresAt = new Date(deletedDate);\n\texpiresAt.setDate(expiresAt.getDate() + retentionDays);\n\n\tconst now = new Date();\n\tconst msRemaining = expiresAt.getTime() - now.getTime();\n\tconst daysRemaining = Math.ceil(msRemaining / (1000 * 60 * 60 * 24));\n\n\tif (daysRemaining <= 0) {\n\t\treturn {\n\t\t\tcanRestore: false,\n\t\t\tdaysRemaining: 0,\n\t\t\tdaysExpired: Math.abs(daysRemaining),\n\t\t\texpiresAt,\n\t\t};\n\t}\n\n\treturn {\n\t\tcanRestore: true,\n\t\tdaysRemaining,\n\t\tdaysExpired: 0,\n\t\texpiresAt,\n\t};\n}\n","/**\n * Brand Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting brands.\n */\n\nimport type { Brand } from \"@htlkg/core/types\";\nimport {\n\tcheckRestoreEligibility,\n\tDEFAULT_SOFT_DELETE_RETENTION_DAYS,\n} from \"../queries/systemSettings\";\nimport type { CreateAuditFields, UpdateWithSoftDeleteFields } from \"./common\";\n\n/**\n * Input type for creating a brand\n */\nexport interface CreateBrandInput extends CreateAuditFields {\n\taccountId: string;\n\tname: string;\n\tlogo?: string;\n\ttimezone?: string;\n\tstatus?: \"active\" | \"inactive\" | \"maintenance\" | \"suspended\" | \"deleted\";\n\tsettings?: Record<string, any>;\n}\n\n/**\n * Input type for updating a brand\n */\nexport interface UpdateBrandInput extends UpdateWithSoftDeleteFields {\n\tid: string;\n\tname?: string;\n\tlogo?: string;\n\ttimezone?: string;\n\tstatus?: \"active\" | \"inactive\" | \"maintenance\" | \"suspended\" | \"deleted\";\n\tsettings?: Record<string, any>;\n}\n\n/**\n * Create a new brand\n *\n * @example\n * ```typescript\n * import { createBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brand = await createBrand(client, {\n * accountId: 'account-123',\n * name: 'My Brand',\n * timezone: 'America/New_York',\n * status: 'active'\n * });\n * ```\n */\nexport async function createBrand<TClient = any>(\n\tclient: TClient,\n\tinput: CreateBrandInput,\n): Promise<Brand | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Brand.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createBrand] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Brand;\n\t} catch (error) {\n\t\tconsole.error(\"[createBrand] Error creating brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing brand\n *\n * @example\n * ```typescript\n * import { updateBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brand = await updateBrand(client, {\n * id: 'brand-123',\n * name: 'Updated Brand Name',\n * status: 'maintenance'\n * });\n * ```\n */\nexport async function updateBrand<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateBrandInput,\n): Promise<Brand | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Brand.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateBrand] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Brand;\n\t} catch (error) {\n\t\tconsole.error(\"[updateBrand] Error updating brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Soft delete a brand (sets status to \"deleted\" instead of removing)\n *\n * @example\n * ```typescript\n * import { softDeleteBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await softDeleteBrand(client, 'brand-123', 'admin@example.com');\n * ```\n */\nexport async function softDeleteBrand<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tdeletedBy: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Brand.update({\n\t\t\tid,\n\t\t\tstatus: \"deleted\",\n\t\t\tdeletedAt: new Date().toISOString(),\n\t\t\tdeletedBy,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[softDeleteBrand] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[softDeleteBrand] Error soft-deleting brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Restore a soft-deleted brand (sets status back to \"active\")\n * Checks retention period before allowing restoration\n *\n * @example\n * ```typescript\n * import { restoreBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await restoreBrand(client, 'brand-123');\n * // Or with custom retention days:\n * await restoreBrand(client, 'brand-123', 60);\n * ```\n */\nexport async function restoreBrand<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tretentionDays: number = DEFAULT_SOFT_DELETE_RETENTION_DAYS,\n): Promise<{ success: boolean; error?: string }> {\n\ttry {\n\t\t// First, get the brand to check its deletedAt timestamp\n\t\tconst { data: brand, errors: getErrors } = await (\n\t\t\tclient as any\n\t\t).models.Brand.get({ id });\n\n\t\tif (getErrors || !brand) {\n\t\t\tconsole.error(\"[restoreBrand] Error fetching brand:\", getErrors);\n\t\t\treturn { success: false, error: \"Brand not found\" };\n\t\t}\n\n\t\t// Check if restoration is allowed based on retention period\n\t\tconst eligibility = checkRestoreEligibility(brand.deletedAt, retentionDays);\n\n\t\tif (!eligibility.canRestore) {\n\t\t\tconst errorMsg = `Cannot restore brand. Retention period of ${retentionDays} days has expired. Item was deleted ${eligibility.daysExpired} days ago.`;\n\t\t\tconsole.error(\"[restoreBrand]\", errorMsg);\n\t\t\treturn { success: false, error: errorMsg };\n\t\t}\n\n\t\tconst { errors } = await (client as any).models.Brand.update({\n\t\t\tid,\n\t\t\tstatus: \"active\",\n\t\t\tdeletedAt: null,\n\t\t\tdeletedBy: null,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[restoreBrand] GraphQL errors:\", errors);\n\t\t\treturn { success: false, error: \"Failed to restore brand\" };\n\t\t}\n\n\t\treturn { success: true };\n\t} catch (error) {\n\t\tconsole.error(\"[restoreBrand] Error restoring brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Hard delete a brand (permanently removes from database)\n * Use with caution - prefer softDeleteBrand for recoverable deletion\n *\n * @example\n * ```typescript\n * import { deleteBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteBrand(client, 'brand-123');\n * ```\n */\nexport async function deleteBrand<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Brand.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteBrand] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteBrand] Error deleting brand:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * Account Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting accounts.\n */\n\nimport type { Account } from \"@htlkg/core/types\";\nimport {\n\tcheckRestoreEligibility,\n\tDEFAULT_SOFT_DELETE_RETENTION_DAYS,\n} from \"../queries/systemSettings\";\nimport type { CreateAuditFields, UpdateWithSoftDeleteFields } from \"./common\";\n\n/**\n * Input type for creating an account\n */\nexport interface CreateAccountInput extends CreateAuditFields {\n\tname: string;\n\tlogo?: string;\n\tsubscription?: Record<string, any>;\n\tsettings?: Record<string, any>;\n\tstatus?: \"active\" | \"inactive\" | \"deleted\";\n}\n\n/**\n * Input type for updating an account\n */\nexport interface UpdateAccountInput extends UpdateWithSoftDeleteFields {\n\tid: string;\n\tname?: string;\n\tlogo?: string;\n\tsubscription?: Record<string, any>;\n\tsettings?: Record<string, any>;\n\tstatus?: \"active\" | \"inactive\" | \"deleted\";\n}\n\n/**\n * Create a new account\n *\n * @example\n * ```typescript\n * import { createAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const account = await createAccount(client, {\n * name: 'My Account',\n * subscription: { plan: 'premium' }\n * });\n * ```\n */\nexport async function createAccount<TClient = any>(\n\tclient: TClient,\n\tinput: CreateAccountInput,\n): Promise<Account | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Account.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createAccount] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Account;\n\t} catch (error) {\n\t\tconsole.error(\"[createAccount] Error creating account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing account\n *\n * @example\n * ```typescript\n * import { updateAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const account = await updateAccount(client, {\n * id: 'account-123',\n * name: 'Updated Account Name'\n * });\n * ```\n */\nexport async function updateAccount<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateAccountInput,\n): Promise<Account | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Account.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateAccount] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Account;\n\t} catch (error) {\n\t\tconsole.error(\"[updateAccount] Error updating account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Soft delete an account (sets status to \"deleted\" instead of removing)\n *\n * @example\n * ```typescript\n * import { softDeleteAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await softDeleteAccount(client, 'account-123', 'admin@example.com');\n * ```\n */\nexport async function softDeleteAccount<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tdeletedBy: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Account.update({\n\t\t\tid,\n\t\t\tstatus: \"deleted\",\n\t\t\tdeletedAt: new Date().toISOString(),\n\t\t\tdeletedBy,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[softDeleteAccount] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[softDeleteAccount] Error soft-deleting account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Restore a soft-deleted account (sets status back to \"active\")\n * Checks retention period before allowing restoration\n *\n * @example\n * ```typescript\n * import { restoreAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await restoreAccount(client, 'account-123');\n * // Or with custom retention days:\n * await restoreAccount(client, 'account-123', 60);\n * ```\n */\nexport async function restoreAccount<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tretentionDays: number = DEFAULT_SOFT_DELETE_RETENTION_DAYS,\n): Promise<{ success: boolean; error?: string }> {\n\ttry {\n\t\t// First, get the account to check its deletedAt timestamp\n\t\tconst { data: account, errors: getErrors } = await (\n\t\t\tclient as any\n\t\t).models.Account.get({ id });\n\n\t\tif (getErrors || !account) {\n\t\t\tconsole.error(\"[restoreAccount] Error fetching account:\", getErrors);\n\t\t\treturn { success: false, error: \"Account not found\" };\n\t\t}\n\n\t\t// Check if restoration is allowed based on retention period\n\t\tconst eligibility = checkRestoreEligibility(account.deletedAt, retentionDays);\n\n\t\tif (!eligibility.canRestore) {\n\t\t\tconst errorMsg = `Cannot restore account. Retention period of ${retentionDays} days has expired. Item was deleted ${eligibility.daysExpired} days ago.`;\n\t\t\tconsole.error(\"[restoreAccount]\", errorMsg);\n\t\t\treturn { success: false, error: errorMsg };\n\t\t}\n\n\t\tconst { errors } = await (client as any).models.Account.update({\n\t\t\tid,\n\t\t\tstatus: \"active\",\n\t\t\tdeletedAt: null,\n\t\t\tdeletedBy: null,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[restoreAccount] GraphQL errors:\", errors);\n\t\t\treturn { success: false, error: \"Failed to restore account\" };\n\t\t}\n\n\t\treturn { success: true };\n\t} catch (error) {\n\t\tconsole.error(\"[restoreAccount] Error restoring account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Hard delete an account (permanently removes from database)\n * Use with caution - prefer softDeleteAccount for recoverable deletion\n *\n * @example\n * ```typescript\n * import { deleteAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteAccount(client, 'account-123');\n * ```\n */\nexport async function deleteAccount<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Account.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteAccount] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteAccount] Error deleting account:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * User Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting users.\n */\n\nimport type { User } from \"@htlkg/core/types\";\nimport {\n\tcheckRestoreEligibility,\n\tDEFAULT_SOFT_DELETE_RETENTION_DAYS,\n} from \"../queries/systemSettings\";\nimport type { CreateAuditFields, UpdateWithSoftDeleteFields } from \"./common\";\n\n/**\n * Input type for creating a user\n */\nexport interface CreateUserInput extends CreateAuditFields {\n\tcognitoId: string;\n\temail: string;\n\taccountId: string;\n\tbrandIds?: string[];\n\troles?: string[];\n\tpermissions?: Record<string, any>;\n\tstatus?: \"active\" | \"inactive\" | \"pending\" | \"suspended\" | \"deleted\";\n}\n\n/**\n * Input type for updating a user\n */\nexport interface UpdateUserInput extends UpdateWithSoftDeleteFields {\n\tid: string;\n\temail?: string;\n\tbrandIds?: string[];\n\troles?: string[];\n\tpermissions?: Record<string, any>;\n\tlastLogin?: string;\n\tstatus?: \"active\" | \"inactive\" | \"pending\" | \"suspended\" | \"deleted\";\n}\n\n/**\n * Create a new user\n *\n * @example\n * ```typescript\n * import { createUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await createUser(client, {\n * cognitoId: 'cognito-123',\n * email: 'user@example.com',\n * accountId: 'account-123',\n * roles: ['BRAND_ADMIN'],\n * status: 'active'\n * });\n * ```\n */\nexport async function createUser<TClient = any>(\n\tclient: TClient,\n\tinput: CreateUserInput,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createUser] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as User;\n\t} catch (error) {\n\t\tconsole.error(\"[createUser] Error creating user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing user\n *\n * @example\n * ```typescript\n * import { updateUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await updateUser(client, {\n * id: 'user-123',\n * roles: ['BRAND_ADMIN', 'ACCOUNT_ADMIN'],\n * status: 'active'\n * });\n * ```\n */\nexport async function updateUser<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateUserInput,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateUser] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as User;\n\t} catch (error) {\n\t\tconsole.error(\"[updateUser] Error updating user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Soft delete a user (sets status to \"deleted\" instead of removing)\n *\n * @example\n * ```typescript\n * import { softDeleteUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await softDeleteUser(client, 'user-123', 'admin@example.com');\n * ```\n */\nexport async function softDeleteUser<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tdeletedBy: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.User.update({\n\t\t\tid,\n\t\t\tstatus: \"deleted\",\n\t\t\tdeletedAt: new Date().toISOString(),\n\t\t\tdeletedBy,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[softDeleteUser] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[softDeleteUser] Error soft-deleting user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Restore a soft-deleted user (sets status back to \"active\")\n * Checks retention period before allowing restoration\n *\n * @example\n * ```typescript\n * import { restoreUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await restoreUser(client, 'user-123');\n * // Or with custom retention days:\n * await restoreUser(client, 'user-123', 60);\n * ```\n */\nexport async function restoreUser<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tretentionDays: number = DEFAULT_SOFT_DELETE_RETENTION_DAYS,\n): Promise<{ success: boolean; error?: string }> {\n\ttry {\n\t\t// First, get the user to check its deletedAt timestamp\n\t\tconst { data: user, errors: getErrors } = await (\n\t\t\tclient as any\n\t\t).models.User.get({ id });\n\n\t\tif (getErrors || !user) {\n\t\t\tconsole.error(\"[restoreUser] Error fetching user:\", getErrors);\n\t\t\treturn { success: false, error: \"User not found\" };\n\t\t}\n\n\t\t// Check if restoration is allowed based on retention period\n\t\tconst eligibility = checkRestoreEligibility(user.deletedAt, retentionDays);\n\n\t\tif (!eligibility.canRestore) {\n\t\t\tconst errorMsg = `Cannot restore user. Retention period of ${retentionDays} days has expired. Item was deleted ${eligibility.daysExpired} days ago.`;\n\t\t\tconsole.error(\"[restoreUser]\", errorMsg);\n\t\t\treturn { success: false, error: errorMsg };\n\t\t}\n\n\t\tconst { errors } = await (client as any).models.User.update({\n\t\t\tid,\n\t\t\tstatus: \"active\",\n\t\t\tdeletedAt: null,\n\t\t\tdeletedBy: null,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[restoreUser] GraphQL errors:\", errors);\n\t\t\treturn { success: false, error: \"Failed to restore user\" };\n\t\t}\n\n\t\treturn { success: true };\n\t} catch (error) {\n\t\tconsole.error(\"[restoreUser] Error restoring user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Hard delete a user (permanently removes from database)\n * Use with caution - prefer softDeleteUser for recoverable deletion\n *\n * @example\n * ```typescript\n * import { deleteUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteUser(client, 'user-123');\n * ```\n */\nexport async function deleteUser<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.User.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteUser] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteUser] Error deleting user:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * ProductInstance Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting product instances.\n * Product instances represent enabled products for a specific brand with their configuration.\n */\n\nimport type { ProductInstance } from \"@htlkg/core/types\";\nimport { getClientUser } from \"@htlkg/core/auth\";\nimport { getCurrentTimestamp } from \"@htlkg/core/utils\";\nimport { AppError } from \"@htlkg/core/errors\";\nimport type { CreateAuditFields, UpdateAuditFields } from \"../common\";\n\n/**\n * Get current user identifier for audit trails\n * Uses getClientUser() and returns email or username, falling back to \"system\"\n */\nasync function getUserIdentifier(fallback = \"system\"): Promise<string> {\n\ttry {\n\t\tconst user = await getClientUser();\n\t\tif (user) {\n\t\t\treturn user.email || user.username || fallback;\n\t\t}\n\t\treturn fallback;\n\t} catch {\n\t\treturn fallback;\n\t}\n}\n\n/**\n * Input type for creating a product instance\n */\nexport interface CreateProductInstanceInput extends CreateAuditFields {\n\tproductId: string;\n\tbrandId: string;\n\taccountId: string;\n\tproductName: string;\n\tenabled: boolean;\n\tconfig?: Record<string, any>;\n\tversion?: string;\n}\n\n/**\n * Input type for updating a product instance\n */\nexport interface UpdateProductInstanceInput extends UpdateAuditFields {\n\tid: string;\n\tenabled?: boolean;\n\tconfig?: Record<string, any>;\n\tversion?: string;\n}\n\n/**\n * Create a new product instance\n *\n * @example\n * ```typescript\n * import { createProductInstance } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instance = await createProductInstance(client, {\n * productId: 'product-123',\n * brandId: 'brand-456',\n * accountId: 'account-789',\n * enabled: true,\n * config: { apiKey: 'xxx', maxRequests: 100 }\n * });\n * ```\n */\nexport async function createProductInstance<TClient = any>(\n\tclient: TClient,\n\tinput: CreateProductInstanceInput,\n): Promise<ProductInstance | null> {\n\ttry {\n\t\t// Get user identifier for audit trail\n\t\tconst userIdentifier = input.createdBy || input.updatedBy || await getUserIdentifier();\n\n\t\t// Build input - manually construct to avoid Vue Proxy issues\n\t\tconst timestamp = input.createdAt || getCurrentTimestamp();\n\t\tconst createInput: any = {\n\t\t\tproductId: input.productId,\n\t\t\tproductName: input.productName,\n\t\t\tbrandId: input.brandId,\n\t\t\taccountId: input.accountId,\n\t\t\tenabled: input.enabled,\n\t\t\tversion: input.version,\n\t\t\tcreatedAt: timestamp,\n\t\t\tcreatedBy: userIdentifier,\n\t\t\tupdatedAt: input.updatedAt || timestamp,\n\t\t\tupdatedBy: userIdentifier,\n\t\t};\n\n\t\t// AWSJSON type requires JSON STRING\n\t\tif (input.config) {\n\t\t\t// Double stringify: first to strip Vue Proxy, second to create JSON string\n\t\t\tcreateInput.config = JSON.stringify(JSON.parse(JSON.stringify(input.config)));\n\t\t}\n\n\t\tconsole.log(\"[createProductInstance] Config as string:\", createInput.config);\n\t\tconsole.log(\"[createProductInstance] Config type:\", typeof createInput.config);\n\n\t\tconst { data, errors } = await (client as any).models.ProductInstance.create(createInput);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createProductInstance] GraphQL errors:\", errors);\n\t\t\tthrow new AppError(\n\t\t\t\t\"Failed to create product instance\",\n\t\t\t\t\"PRODUCT_INSTANCE_CREATE_ERROR\",\n\t\t\t\t500,\n\t\t\t\t{ errors }\n\t\t\t);\n\t\t}\n\n\t\treturn data as ProductInstance;\n\t} catch (error) {\n\t\tconsole.error(\"[createProductInstance] Error creating product instance:\", error);\n\t\tif (error instanceof AppError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new AppError(\n\t\t\t\"Failed to create product instance\",\n\t\t\t\"PRODUCT_INSTANCE_CREATE_ERROR\",\n\t\t\t500,\n\t\t\t{ originalError: error }\n\t\t);\n\t}\n}\n\n/**\n * Update an existing product instance\n *\n * @example\n * ```typescript\n * import { updateProductInstance } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instance = await updateProductInstance(client, {\n * id: 'instance-123',\n * enabled: false,\n * config: { apiKey: 'new-key', maxRequests: 200 }\n * });\n * ```\n */\nexport async function updateProductInstance<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateProductInstanceInput,\n): Promise<ProductInstance | null> {\n\ttry {\n\t\t// Add timestamp and user metadata if not provided\n\t\t// Convert config from Vue Proxy to plain object\n\t\tconst updateInput: any = {\n\t\t\t...input,\n\t\t\tupdatedAt: input.updatedAt || getCurrentTimestamp(),\n\t\t\tupdatedBy: input.updatedBy || await getUserIdentifier(),\n\t\t};\n\n\t\t// AWSJSON type requires JSON STRING\n\t\tif (input.config) {\n\t\t\tupdateInput.config = JSON.stringify(JSON.parse(JSON.stringify(input.config)));\n\t\t}\n\n\t\tconst { data, errors } = await (client as any).models.ProductInstance.update(updateInput);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateProductInstance] GraphQL errors:\", errors);\n\t\t\tthrow new AppError(\n\t\t\t\t\"Failed to update product instance\",\n\t\t\t\t\"PRODUCT_INSTANCE_UPDATE_ERROR\",\n\t\t\t\t500,\n\t\t\t\t{ errors }\n\t\t\t);\n\t\t}\n\n\t\treturn data as ProductInstance;\n\t} catch (error) {\n\t\tconsole.error(\"[updateProductInstance] Error updating product instance:\", error);\n\t\tif (error instanceof AppError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new AppError(\n\t\t\t\"Failed to update product instance\",\n\t\t\t\"PRODUCT_INSTANCE_UPDATE_ERROR\",\n\t\t\t500,\n\t\t\t{ originalError: error }\n\t\t);\n\t}\n}\n\n/**\n * Delete a product instance\n *\n * @example\n * ```typescript\n * import { deleteProductInstance } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteProductInstance(client, 'instance-123');\n * ```\n */\nexport async function deleteProductInstance<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.ProductInstance.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteProductInstance] GraphQL errors:\", errors);\n\t\t\tthrow new AppError(\n\t\t\t\t\"Failed to delete product instance\",\n\t\t\t\t\"PRODUCT_INSTANCE_DELETE_ERROR\",\n\t\t\t\t500,\n\t\t\t\t{ errors }\n\t\t\t);\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteProductInstance] Error deleting product instance:\", error);\n\t\tif (error instanceof AppError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new AppError(\n\t\t\t\"Failed to delete product instance\",\n\t\t\t\"PRODUCT_INSTANCE_DELETE_ERROR\",\n\t\t\t500,\n\t\t\t{ originalError: error }\n\t\t);\n\t}\n}\n\n/**\n * Toggle the enabled status of a product instance\n *\n * @example\n * ```typescript\n * import { toggleProductInstanceEnabled } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instance = await toggleProductInstanceEnabled(client, 'instance-123', true);\n * ```\n */\nexport async function toggleProductInstanceEnabled<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tenabled: boolean,\n): Promise<ProductInstance | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.ProductInstance.update({\n\t\t\tid,\n\t\t\tenabled,\n\t\t\tlastUpdated: getCurrentTimestamp(),\n\t\t\tupdatedBy: await getUserIdentifier(),\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[toggleProductInstanceEnabled] GraphQL errors:\", errors);\n\t\t\tthrow new AppError(\n\t\t\t\t\"Failed to toggle product instance\",\n\t\t\t\t\"PRODUCT_INSTANCE_TOGGLE_ERROR\",\n\t\t\t\t500,\n\t\t\t\t{ errors }\n\t\t\t);\n\t\t}\n\n\t\treturn data as ProductInstance;\n\t} catch (error) {\n\t\tconsole.error(\"[toggleProductInstanceEnabled] Error toggling product instance:\", error);\n\t\tif (error instanceof AppError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new AppError(\n\t\t\t\"Failed to toggle product instance\",\n\t\t\t\"PRODUCT_INSTANCE_TOGGLE_ERROR\",\n\t\t\t500,\n\t\t\t{ originalError: error }\n\t\t);\n\t}\n}\n","/**\n * SystemSettings Mutation Functions\n *\n * Provides mutation functions for managing system settings.\n */\n\nimport type { SystemSettings } from \"@htlkg/core/types\";\nimport {\n\tSYSTEM_SETTINGS_KEY,\n\tDEFAULT_SOFT_DELETE_RETENTION_DAYS,\n} from \"../queries/systemSettings\";\n\n/**\n * Input type for updating system settings\n */\nexport interface UpdateSystemSettingsInput {\n\tsoftDeleteRetentionDays: number;\n\tupdatedBy: string;\n}\n\n/**\n * Update or create system settings\n * Only SUPER_ADMINS can update system settings\n *\n * @example\n * ```typescript\n * import { updateSystemSettings } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const settings = await updateSystemSettings(client, {\n * softDeleteRetentionDays: 60,\n * updatedBy: 'admin@example.com'\n * });\n * ```\n */\nexport async function updateSystemSettings<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateSystemSettingsInput,\n): Promise<SystemSettings | null> {\n\ttry {\n\t\t// Validate retention days (minimum 1 day, maximum 365 days)\n\t\tif (input.softDeleteRetentionDays < 1 || input.softDeleteRetentionDays > 365) {\n\t\t\tconsole.error(\n\t\t\t\t\"[updateSystemSettings] Invalid retention days. Must be between 1 and 365.\",\n\t\t\t);\n\t\t\treturn null;\n\t\t}\n\n\t\t// First, try to get existing settings\n\t\tconst { data: existing } = await (client as any).models.SystemSettings.get({\n\t\t\tkey: SYSTEM_SETTINGS_KEY,\n\t\t});\n\n\t\tconst settingsData = {\n\t\t\tkey: SYSTEM_SETTINGS_KEY,\n\t\t\tsoftDeleteRetentionDays: input.softDeleteRetentionDays,\n\t\t\tupdatedAt: new Date().toISOString(),\n\t\t\tupdatedBy: input.updatedBy,\n\t\t};\n\n\t\tlet result;\n\t\tif (existing) {\n\t\t\t// Update existing settings\n\t\t\tresult = await (client as any).models.SystemSettings.update(settingsData);\n\t\t} else {\n\t\t\t// Create new settings\n\t\t\tresult = await (client as any).models.SystemSettings.create(settingsData);\n\t\t}\n\n\t\tif (result.errors) {\n\t\t\tconsole.error(\"[updateSystemSettings] GraphQL errors:\", result.errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn result.data as SystemSettings;\n\t} catch (error) {\n\t\tconsole.error(\"[updateSystemSettings] Error updating system settings:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Initialize system settings with default values if they don't exist\n *\n * @example\n * ```typescript\n * import { initializeSystemSettings } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const settings = await initializeSystemSettings(client, 'system@hotelinking.com');\n * ```\n */\nexport async function initializeSystemSettings<TClient = any>(\n\tclient: TClient,\n\tinitializedBy: string,\n): Promise<SystemSettings | null> {\n\ttry {\n\t\t// Check if settings already exist\n\t\tconst { data: existing } = await (client as any).models.SystemSettings.get({\n\t\t\tkey: SYSTEM_SETTINGS_KEY,\n\t\t});\n\n\t\tif (existing) {\n\t\t\treturn existing as SystemSettings;\n\t\t}\n\n\t\t// Create default settings\n\t\tconst { data, errors } = await (client as any).models.SystemSettings.create({\n\t\t\tkey: SYSTEM_SETTINGS_KEY,\n\t\t\tsoftDeleteRetentionDays: DEFAULT_SOFT_DELETE_RETENTION_DAYS,\n\t\t\tupdatedAt: new Date().toISOString(),\n\t\t\tupdatedBy: initializedBy,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[initializeSystemSettings] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as SystemSettings;\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t\"[initializeSystemSettings] Error initializing system settings:\",\n\t\t\terror,\n\t\t);\n\t\tthrow error;\n\t}\n}\n"],"mappings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AAGA,UAAM,EAAE,MAAM,OAAO,IAAI,MAAO,OAAe,OAAO,eAAe,OAAO;AAAA,MAC3E,KAAK;AAAA,MACL,yBAAyB;AAAA,MACzB,YAAW,oBAAI,KAAK,GAAE,YAAY;AAAA,MAClC,WAAW;AAAA,IACZ,CAAC;AAED,QAAI,QAAQ;AACX,cAAQ,MAAM,8CAA8C,MAAM;AAClE,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,EACR,SAAS,OAAO;AACf,YAAQ;AAAA,MACP;AAAA,MACA;AAAA,IACD;AACA,UAAM;AAAA,EACP;AACD;","names":[]}
1
+ {"version":3,"sources":["../../src/queries/systemSettings.ts","../../src/mutations/brands.ts","../../src/mutations/accounts.ts","../../src/mutations/users.ts","../../src/mutations/productInstances/productInstances.ts","../../src/mutations/systemSettings.ts","../../src/mutations/reservations.ts"],"sourcesContent":["/**\n * SystemSettings Query Functions\n *\n * Provides query functions for fetching system settings from the GraphQL API.\n */\n\nimport type { SystemSettings } from \"@htlkg/core/types\";\n\n/** Default retention days if no settings exist */\nexport const DEFAULT_SOFT_DELETE_RETENTION_DAYS = 30;\n\n/** The key used for global system settings */\nexport const SYSTEM_SETTINGS_KEY = \"GLOBAL\";\n\n/**\n * Get system settings\n *\n * @example\n * ```typescript\n * import { getSystemSettings } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const settings = await getSystemSettings(client);\n * ```\n */\nexport async function getSystemSettings<TClient = any>(\n\tclient: TClient,\n): Promise<SystemSettings | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.SystemSettings.get({\n\t\t\tkey: SYSTEM_SETTINGS_KEY,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[getSystemSettings] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as SystemSettings;\n\t} catch (error) {\n\t\tconsole.error(\"[getSystemSettings] Error fetching system settings:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get the soft delete retention days from system settings\n * Returns the default (30 days) if settings don't exist\n *\n * @example\n * ```typescript\n * import { getSoftDeleteRetentionDays } from '@htlkg/data/queries';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const days = await getSoftDeleteRetentionDays(client);\n * ```\n */\nexport async function getSoftDeleteRetentionDays<TClient = any>(\n\tclient: TClient,\n): Promise<number> {\n\tconst settings = await getSystemSettings(client);\n\treturn settings?.softDeleteRetentionDays ?? DEFAULT_SOFT_DELETE_RETENTION_DAYS;\n}\n\n/**\n * Check if a soft-deleted item can still be restored based on retention period\n *\n * @param deletedAt - The ISO date string when the item was deleted\n * @param retentionDays - Number of days items can be restored\n * @returns Object with canRestore flag and daysRemaining/daysExpired\n */\nexport function checkRestoreEligibility(\n\tdeletedAt: string | undefined | null,\n\tretentionDays: number,\n): {\n\tcanRestore: boolean;\n\tdaysRemaining: number;\n\tdaysExpired: number;\n\texpiresAt: Date | null;\n} {\n\tif (!deletedAt) {\n\t\treturn {\n\t\t\tcanRestore: false,\n\t\t\tdaysRemaining: 0,\n\t\t\tdaysExpired: 0,\n\t\t\texpiresAt: null,\n\t\t};\n\t}\n\n\tconst deletedDate = new Date(deletedAt);\n\tconst expiresAt = new Date(deletedDate);\n\texpiresAt.setDate(expiresAt.getDate() + retentionDays);\n\n\tconst now = new Date();\n\tconst msRemaining = expiresAt.getTime() - now.getTime();\n\tconst daysRemaining = Math.ceil(msRemaining / (1000 * 60 * 60 * 24));\n\n\tif (daysRemaining <= 0) {\n\t\treturn {\n\t\t\tcanRestore: false,\n\t\t\tdaysRemaining: 0,\n\t\t\tdaysExpired: Math.abs(daysRemaining),\n\t\t\texpiresAt,\n\t\t};\n\t}\n\n\treturn {\n\t\tcanRestore: true,\n\t\tdaysRemaining,\n\t\tdaysExpired: 0,\n\t\texpiresAt,\n\t};\n}\n","/**\n * Brand Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting brands.\n */\n\nimport type { Brand } from \"@htlkg/core/types\";\nimport {\n\tcheckRestoreEligibility,\n\tDEFAULT_SOFT_DELETE_RETENTION_DAYS,\n} from \"../queries/systemSettings\";\nimport type { CreateAuditFields, UpdateWithSoftDeleteFields } from \"./common\";\n\n/**\n * Input type for creating a brand\n */\nexport interface CreateBrandInput extends CreateAuditFields {\n\taccountId: string;\n\tname: string;\n\tlogo?: string;\n\ttimezone?: string;\n\tstatus?: \"active\" | \"inactive\" | \"maintenance\" | \"suspended\" | \"deleted\";\n\tsettings?: Record<string, any>;\n}\n\n/**\n * Input type for updating a brand\n */\nexport interface UpdateBrandInput extends UpdateWithSoftDeleteFields {\n\tid: string;\n\tname?: string;\n\tlogo?: string;\n\ttimezone?: string;\n\tstatus?: \"active\" | \"inactive\" | \"maintenance\" | \"suspended\" | \"deleted\";\n\tsettings?: Record<string, any>;\n}\n\n/**\n * Create a new brand\n *\n * @example\n * ```typescript\n * import { createBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brand = await createBrand(client, {\n * accountId: 'account-123',\n * name: 'My Brand',\n * timezone: 'America/New_York',\n * status: 'active'\n * });\n * ```\n */\nexport async function createBrand<TClient = any>(\n\tclient: TClient,\n\tinput: CreateBrandInput,\n): Promise<Brand | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Brand.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createBrand] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Brand;\n\t} catch (error) {\n\t\tconsole.error(\"[createBrand] Error creating brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing brand\n *\n * @example\n * ```typescript\n * import { updateBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const brand = await updateBrand(client, {\n * id: 'brand-123',\n * name: 'Updated Brand Name',\n * status: 'maintenance'\n * });\n * ```\n */\nexport async function updateBrand<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateBrandInput,\n): Promise<Brand | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Brand.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateBrand] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Brand;\n\t} catch (error) {\n\t\tconsole.error(\"[updateBrand] Error updating brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Soft delete a brand (sets status to \"deleted\" instead of removing)\n *\n * @example\n * ```typescript\n * import { softDeleteBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await softDeleteBrand(client, 'brand-123', 'admin@example.com');\n * ```\n */\nexport async function softDeleteBrand<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tdeletedBy: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Brand.update({\n\t\t\tid,\n\t\t\tstatus: \"deleted\",\n\t\t\tdeletedAt: new Date().toISOString(),\n\t\t\tdeletedBy,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[softDeleteBrand] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[softDeleteBrand] Error soft-deleting brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Restore a soft-deleted brand (sets status back to \"active\")\n * Checks retention period before allowing restoration\n *\n * @example\n * ```typescript\n * import { restoreBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await restoreBrand(client, 'brand-123');\n * // Or with custom retention days:\n * await restoreBrand(client, 'brand-123', 60);\n * ```\n */\nexport async function restoreBrand<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tretentionDays: number = DEFAULT_SOFT_DELETE_RETENTION_DAYS,\n): Promise<{ success: boolean; error?: string }> {\n\ttry {\n\t\t// First, get the brand to check its deletedAt timestamp\n\t\tconst { data: brand, errors: getErrors } = await (\n\t\t\tclient as any\n\t\t).models.Brand.get({ id });\n\n\t\tif (getErrors || !brand) {\n\t\t\tconsole.error(\"[restoreBrand] Error fetching brand:\", getErrors);\n\t\t\treturn { success: false, error: \"Brand not found\" };\n\t\t}\n\n\t\t// Check if restoration is allowed based on retention period\n\t\tconst eligibility = checkRestoreEligibility(brand.deletedAt, retentionDays);\n\n\t\tif (!eligibility.canRestore) {\n\t\t\tconst errorMsg = `Cannot restore brand. Retention period of ${retentionDays} days has expired. Item was deleted ${eligibility.daysExpired} days ago.`;\n\t\t\tconsole.error(\"[restoreBrand]\", errorMsg);\n\t\t\treturn { success: false, error: errorMsg };\n\t\t}\n\n\t\tconst { errors } = await (client as any).models.Brand.update({\n\t\t\tid,\n\t\t\tstatus: \"active\",\n\t\t\tdeletedAt: null,\n\t\t\tdeletedBy: null,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[restoreBrand] GraphQL errors:\", errors);\n\t\t\treturn { success: false, error: \"Failed to restore brand\" };\n\t\t}\n\n\t\treturn { success: true };\n\t} catch (error) {\n\t\tconsole.error(\"[restoreBrand] Error restoring brand:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Hard delete a brand (permanently removes from database)\n * Use with caution - prefer softDeleteBrand for recoverable deletion\n *\n * @example\n * ```typescript\n * import { deleteBrand } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteBrand(client, 'brand-123');\n * ```\n */\nexport async function deleteBrand<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Brand.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteBrand] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteBrand] Error deleting brand:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * Account Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting accounts.\n */\n\nimport type { Account } from \"@htlkg/core/types\";\nimport {\n\tcheckRestoreEligibility,\n\tDEFAULT_SOFT_DELETE_RETENTION_DAYS,\n} from \"../queries/systemSettings\";\nimport type { CreateAuditFields, UpdateWithSoftDeleteFields } from \"./common\";\n\n/**\n * Input type for creating an account\n */\nexport interface CreateAccountInput extends CreateAuditFields {\n\tname: string;\n\tlogo?: string;\n\tsubscription?: Record<string, any>;\n\tsettings?: Record<string, any>;\n\tstatus?: \"active\" | \"inactive\" | \"deleted\";\n}\n\n/**\n * Input type for updating an account\n */\nexport interface UpdateAccountInput extends UpdateWithSoftDeleteFields {\n\tid: string;\n\tname?: string;\n\tlogo?: string;\n\tsubscription?: Record<string, any>;\n\tsettings?: Record<string, any>;\n\tstatus?: \"active\" | \"inactive\" | \"deleted\";\n}\n\n/**\n * Create a new account\n *\n * @example\n * ```typescript\n * import { createAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const account = await createAccount(client, {\n * name: 'My Account',\n * subscription: { plan: 'premium' }\n * });\n * ```\n */\nexport async function createAccount<TClient = any>(\n\tclient: TClient,\n\tinput: CreateAccountInput,\n): Promise<Account | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Account.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createAccount] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Account;\n\t} catch (error) {\n\t\tconsole.error(\"[createAccount] Error creating account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing account\n *\n * @example\n * ```typescript\n * import { updateAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const account = await updateAccount(client, {\n * id: 'account-123',\n * name: 'Updated Account Name'\n * });\n * ```\n */\nexport async function updateAccount<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateAccountInput,\n): Promise<Account | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.Account.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateAccount] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as Account;\n\t} catch (error) {\n\t\tconsole.error(\"[updateAccount] Error updating account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Soft delete an account (sets status to \"deleted\" instead of removing)\n *\n * @example\n * ```typescript\n * import { softDeleteAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await softDeleteAccount(client, 'account-123', 'admin@example.com');\n * ```\n */\nexport async function softDeleteAccount<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tdeletedBy: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Account.update({\n\t\t\tid,\n\t\t\tstatus: \"deleted\",\n\t\t\tdeletedAt: new Date().toISOString(),\n\t\t\tdeletedBy,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[softDeleteAccount] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[softDeleteAccount] Error soft-deleting account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Restore a soft-deleted account (sets status back to \"active\")\n * Checks retention period before allowing restoration\n *\n * @example\n * ```typescript\n * import { restoreAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await restoreAccount(client, 'account-123');\n * // Or with custom retention days:\n * await restoreAccount(client, 'account-123', 60);\n * ```\n */\nexport async function restoreAccount<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tretentionDays: number = DEFAULT_SOFT_DELETE_RETENTION_DAYS,\n): Promise<{ success: boolean; error?: string }> {\n\ttry {\n\t\t// First, get the account to check its deletedAt timestamp\n\t\tconst { data: account, errors: getErrors } = await (\n\t\t\tclient as any\n\t\t).models.Account.get({ id });\n\n\t\tif (getErrors || !account) {\n\t\t\tconsole.error(\"[restoreAccount] Error fetching account:\", getErrors);\n\t\t\treturn { success: false, error: \"Account not found\" };\n\t\t}\n\n\t\t// Check if restoration is allowed based on retention period\n\t\tconst eligibility = checkRestoreEligibility(account.deletedAt, retentionDays);\n\n\t\tif (!eligibility.canRestore) {\n\t\t\tconst errorMsg = `Cannot restore account. Retention period of ${retentionDays} days has expired. Item was deleted ${eligibility.daysExpired} days ago.`;\n\t\t\tconsole.error(\"[restoreAccount]\", errorMsg);\n\t\t\treturn { success: false, error: errorMsg };\n\t\t}\n\n\t\tconst { errors } = await (client as any).models.Account.update({\n\t\t\tid,\n\t\t\tstatus: \"active\",\n\t\t\tdeletedAt: null,\n\t\t\tdeletedBy: null,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[restoreAccount] GraphQL errors:\", errors);\n\t\t\treturn { success: false, error: \"Failed to restore account\" };\n\t\t}\n\n\t\treturn { success: true };\n\t} catch (error) {\n\t\tconsole.error(\"[restoreAccount] Error restoring account:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Hard delete an account (permanently removes from database)\n * Use with caution - prefer softDeleteAccount for recoverable deletion\n *\n * @example\n * ```typescript\n * import { deleteAccount } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteAccount(client, 'account-123');\n * ```\n */\nexport async function deleteAccount<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Account.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteAccount] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteAccount] Error deleting account:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * User Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting users.\n */\n\nimport type { User } from \"@htlkg/core/types\";\nimport {\n\tcheckRestoreEligibility,\n\tDEFAULT_SOFT_DELETE_RETENTION_DAYS,\n} from \"../queries/systemSettings\";\nimport type { CreateAuditFields, UpdateWithSoftDeleteFields } from \"./common\";\n\n/**\n * Input type for creating a user\n */\nexport interface CreateUserInput extends CreateAuditFields {\n\tcognitoId: string;\n\temail: string;\n\taccountId: string;\n\tbrandIds?: string[];\n\troles?: string[];\n\tpermissions?: Record<string, any>;\n\tstatus?: \"active\" | \"inactive\" | \"pending\" | \"suspended\" | \"deleted\";\n}\n\n/**\n * Input type for updating a user\n */\nexport interface UpdateUserInput extends UpdateWithSoftDeleteFields {\n\tid: string;\n\temail?: string;\n\tbrandIds?: string[];\n\troles?: string[];\n\tpermissions?: Record<string, any>;\n\tlastLogin?: string;\n\tstatus?: \"active\" | \"inactive\" | \"pending\" | \"suspended\" | \"deleted\";\n}\n\n/**\n * Create a new user\n *\n * @example\n * ```typescript\n * import { createUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await createUser(client, {\n * cognitoId: 'cognito-123',\n * email: 'user@example.com',\n * accountId: 'account-123',\n * roles: ['BRAND_ADMIN'],\n * status: 'active'\n * });\n * ```\n */\nexport async function createUser<TClient = any>(\n\tclient: TClient,\n\tinput: CreateUserInput,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createUser] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as User;\n\t} catch (error) {\n\t\tconsole.error(\"[createUser] Error creating user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing user\n *\n * @example\n * ```typescript\n * import { updateUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const user = await updateUser(client, {\n * id: 'user-123',\n * roles: ['BRAND_ADMIN', 'ACCOUNT_ADMIN'],\n * status: 'active'\n * });\n * ```\n */\nexport async function updateUser<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateUserInput,\n): Promise<User | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.User.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateUser] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as User;\n\t} catch (error) {\n\t\tconsole.error(\"[updateUser] Error updating user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Soft delete a user (sets status to \"deleted\" instead of removing)\n *\n * @example\n * ```typescript\n * import { softDeleteUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await softDeleteUser(client, 'user-123', 'admin@example.com');\n * ```\n */\nexport async function softDeleteUser<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tdeletedBy: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.User.update({\n\t\t\tid,\n\t\t\tstatus: \"deleted\",\n\t\t\tdeletedAt: new Date().toISOString(),\n\t\t\tdeletedBy,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[softDeleteUser] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[softDeleteUser] Error soft-deleting user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Restore a soft-deleted user (sets status back to \"active\")\n * Checks retention period before allowing restoration\n *\n * @example\n * ```typescript\n * import { restoreUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await restoreUser(client, 'user-123');\n * // Or with custom retention days:\n * await restoreUser(client, 'user-123', 60);\n * ```\n */\nexport async function restoreUser<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tretentionDays: number = DEFAULT_SOFT_DELETE_RETENTION_DAYS,\n): Promise<{ success: boolean; error?: string }> {\n\ttry {\n\t\t// First, get the user to check its deletedAt timestamp\n\t\tconst { data: user, errors: getErrors } = await (\n\t\t\tclient as any\n\t\t).models.User.get({ id });\n\n\t\tif (getErrors || !user) {\n\t\t\tconsole.error(\"[restoreUser] Error fetching user:\", getErrors);\n\t\t\treturn { success: false, error: \"User not found\" };\n\t\t}\n\n\t\t// Check if restoration is allowed based on retention period\n\t\tconst eligibility = checkRestoreEligibility(user.deletedAt, retentionDays);\n\n\t\tif (!eligibility.canRestore) {\n\t\t\tconst errorMsg = `Cannot restore user. Retention period of ${retentionDays} days has expired. Item was deleted ${eligibility.daysExpired} days ago.`;\n\t\t\tconsole.error(\"[restoreUser]\", errorMsg);\n\t\t\treturn { success: false, error: errorMsg };\n\t\t}\n\n\t\tconst { errors } = await (client as any).models.User.update({\n\t\t\tid,\n\t\t\tstatus: \"active\",\n\t\t\tdeletedAt: null,\n\t\t\tdeletedBy: null,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[restoreUser] GraphQL errors:\", errors);\n\t\t\treturn { success: false, error: \"Failed to restore user\" };\n\t\t}\n\n\t\treturn { success: true };\n\t} catch (error) {\n\t\tconsole.error(\"[restoreUser] Error restoring user:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Hard delete a user (permanently removes from database)\n * Use with caution - prefer softDeleteUser for recoverable deletion\n *\n * @example\n * ```typescript\n * import { deleteUser } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteUser(client, 'user-123');\n * ```\n */\nexport async function deleteUser<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.User.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteUser] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteUser] Error deleting user:\", error);\n\t\tthrow error;\n\t}\n}\n","/**\n * ProductInstance Mutation Functions\n *\n * Provides mutation functions for creating, updating, and deleting product instances.\n * Product instances represent enabled products for a specific brand with their configuration.\n */\n\nimport type { ProductInstance } from \"@htlkg/core/types\";\nimport { getClientUser } from \"@htlkg/core/auth\";\nimport { getCurrentTimestamp } from \"@htlkg/core/utils\";\nimport { AppError } from \"@htlkg/core/errors\";\nimport type { CreateAuditFields, UpdateAuditFields } from \"../common\";\n\n/**\n * Get current user identifier for audit trails\n * Uses getClientUser() and returns email or username, falling back to \"system\"\n */\nasync function getUserIdentifier(fallback = \"system\"): Promise<string> {\n\ttry {\n\t\tconst user = await getClientUser();\n\t\tif (user) {\n\t\t\treturn user.email || user.username || fallback;\n\t\t}\n\t\treturn fallback;\n\t} catch {\n\t\treturn fallback;\n\t}\n}\n\n/**\n * Input type for creating a product instance\n */\nexport interface CreateProductInstanceInput extends CreateAuditFields {\n\tproductId: string;\n\tbrandId: string;\n\taccountId: string;\n\tproductName: string;\n\tenabled: boolean;\n\tconfig?: Record<string, any>;\n\tversion?: string;\n}\n\n/**\n * Input type for updating a product instance\n */\nexport interface UpdateProductInstanceInput extends UpdateAuditFields {\n\tid: string;\n\tenabled?: boolean;\n\tconfig?: Record<string, any>;\n\tversion?: string;\n}\n\n/**\n * Create a new product instance\n *\n * @example\n * ```typescript\n * import { createProductInstance } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instance = await createProductInstance(client, {\n * productId: 'product-123',\n * brandId: 'brand-456',\n * accountId: 'account-789',\n * enabled: true,\n * config: { apiKey: 'xxx', maxRequests: 100 }\n * });\n * ```\n */\nexport async function createProductInstance<TClient = any>(\n\tclient: TClient,\n\tinput: CreateProductInstanceInput,\n): Promise<ProductInstance | null> {\n\ttry {\n\t\t// Get user identifier for audit trail\n\t\tconst userIdentifier = input.createdBy || input.updatedBy || await getUserIdentifier();\n\n\t\t// Build input - manually construct to avoid Vue Proxy issues\n\t\tconst timestamp = input.createdAt || getCurrentTimestamp();\n\t\tconst createInput: any = {\n\t\t\tproductId: input.productId,\n\t\t\tproductName: input.productName,\n\t\t\tbrandId: input.brandId,\n\t\t\taccountId: input.accountId,\n\t\t\tenabled: input.enabled,\n\t\t\tversion: input.version,\n\t\t\tcreatedAt: timestamp,\n\t\t\tcreatedBy: userIdentifier,\n\t\t\tupdatedAt: input.updatedAt || timestamp,\n\t\t\tupdatedBy: userIdentifier,\n\t\t};\n\n\t\t// AWSJSON type requires JSON STRING\n\t\tif (input.config) {\n\t\t\t// Double stringify: first to strip Vue Proxy, second to create JSON string\n\t\t\tcreateInput.config = JSON.stringify(JSON.parse(JSON.stringify(input.config)));\n\t\t}\n\n\t\tconsole.log(\"[createProductInstance] Config as string:\", createInput.config);\n\t\tconsole.log(\"[createProductInstance] Config type:\", typeof createInput.config);\n\n\t\tconst { data, errors } = await (client as any).models.ProductInstance.create(createInput);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createProductInstance] GraphQL errors:\", errors);\n\t\t\tthrow new AppError(\n\t\t\t\t\"Failed to create product instance\",\n\t\t\t\t\"PRODUCT_INSTANCE_CREATE_ERROR\",\n\t\t\t\t500,\n\t\t\t\t{ errors }\n\t\t\t);\n\t\t}\n\n\t\treturn data as ProductInstance;\n\t} catch (error) {\n\t\tconsole.error(\"[createProductInstance] Error creating product instance:\", error);\n\t\tif (error instanceof AppError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new AppError(\n\t\t\t\"Failed to create product instance\",\n\t\t\t\"PRODUCT_INSTANCE_CREATE_ERROR\",\n\t\t\t500,\n\t\t\t{ originalError: error }\n\t\t);\n\t}\n}\n\n/**\n * Update an existing product instance\n *\n * @example\n * ```typescript\n * import { updateProductInstance } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instance = await updateProductInstance(client, {\n * id: 'instance-123',\n * enabled: false,\n * config: { apiKey: 'new-key', maxRequests: 200 }\n * });\n * ```\n */\nexport async function updateProductInstance<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateProductInstanceInput,\n): Promise<ProductInstance | null> {\n\ttry {\n\t\t// Add timestamp and user metadata if not provided\n\t\t// Convert config from Vue Proxy to plain object\n\t\tconst updateInput: any = {\n\t\t\t...input,\n\t\t\tupdatedAt: input.updatedAt || getCurrentTimestamp(),\n\t\t\tupdatedBy: input.updatedBy || await getUserIdentifier(),\n\t\t};\n\n\t\t// AWSJSON type requires JSON STRING\n\t\tif (input.config) {\n\t\t\tupdateInput.config = JSON.stringify(JSON.parse(JSON.stringify(input.config)));\n\t\t}\n\n\t\tconst { data, errors } = await (client as any).models.ProductInstance.update(updateInput);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateProductInstance] GraphQL errors:\", errors);\n\t\t\tthrow new AppError(\n\t\t\t\t\"Failed to update product instance\",\n\t\t\t\t\"PRODUCT_INSTANCE_UPDATE_ERROR\",\n\t\t\t\t500,\n\t\t\t\t{ errors }\n\t\t\t);\n\t\t}\n\n\t\treturn data as ProductInstance;\n\t} catch (error) {\n\t\tconsole.error(\"[updateProductInstance] Error updating product instance:\", error);\n\t\tif (error instanceof AppError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new AppError(\n\t\t\t\"Failed to update product instance\",\n\t\t\t\"PRODUCT_INSTANCE_UPDATE_ERROR\",\n\t\t\t500,\n\t\t\t{ originalError: error }\n\t\t);\n\t}\n}\n\n/**\n * Delete a product instance\n *\n * @example\n * ```typescript\n * import { deleteProductInstance } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteProductInstance(client, 'instance-123');\n * ```\n */\nexport async function deleteProductInstance<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.ProductInstance.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteProductInstance] GraphQL errors:\", errors);\n\t\t\tthrow new AppError(\n\t\t\t\t\"Failed to delete product instance\",\n\t\t\t\t\"PRODUCT_INSTANCE_DELETE_ERROR\",\n\t\t\t\t500,\n\t\t\t\t{ errors }\n\t\t\t);\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteProductInstance] Error deleting product instance:\", error);\n\t\tif (error instanceof AppError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new AppError(\n\t\t\t\"Failed to delete product instance\",\n\t\t\t\"PRODUCT_INSTANCE_DELETE_ERROR\",\n\t\t\t500,\n\t\t\t{ originalError: error }\n\t\t);\n\t}\n}\n\n/**\n * Toggle the enabled status of a product instance\n *\n * @example\n * ```typescript\n * import { toggleProductInstanceEnabled } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const instance = await toggleProductInstanceEnabled(client, 'instance-123', true);\n * ```\n */\nexport async function toggleProductInstanceEnabled<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tenabled: boolean,\n): Promise<ProductInstance | null> {\n\ttry {\n\t\tconst { data, errors } = await (client as any).models.ProductInstance.update({\n\t\t\tid,\n\t\t\tenabled,\n\t\t\tlastUpdated: getCurrentTimestamp(),\n\t\t\tupdatedBy: await getUserIdentifier(),\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[toggleProductInstanceEnabled] GraphQL errors:\", errors);\n\t\t\tthrow new AppError(\n\t\t\t\t\"Failed to toggle product instance\",\n\t\t\t\t\"PRODUCT_INSTANCE_TOGGLE_ERROR\",\n\t\t\t\t500,\n\t\t\t\t{ errors }\n\t\t\t);\n\t\t}\n\n\t\treturn data as ProductInstance;\n\t} catch (error) {\n\t\tconsole.error(\"[toggleProductInstanceEnabled] Error toggling product instance:\", error);\n\t\tif (error instanceof AppError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new AppError(\n\t\t\t\"Failed to toggle product instance\",\n\t\t\t\"PRODUCT_INSTANCE_TOGGLE_ERROR\",\n\t\t\t500,\n\t\t\t{ originalError: error }\n\t\t);\n\t}\n}\n","/**\n * SystemSettings Mutation Functions\n *\n * Provides mutation functions for managing system settings.\n */\n\nimport type { SystemSettings } from \"@htlkg/core/types\";\nimport {\n\tSYSTEM_SETTINGS_KEY,\n\tDEFAULT_SOFT_DELETE_RETENTION_DAYS,\n} from \"../queries/systemSettings\";\n\n/**\n * Input type for updating system settings\n */\nexport interface UpdateSystemSettingsInput {\n\tsoftDeleteRetentionDays: number;\n\tupdatedBy: string;\n}\n\n/**\n * Update or create system settings\n * Only SUPER_ADMINS can update system settings\n *\n * @example\n * ```typescript\n * import { updateSystemSettings } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const settings = await updateSystemSettings(client, {\n * softDeleteRetentionDays: 60,\n * updatedBy: 'admin@example.com'\n * });\n * ```\n */\nexport async function updateSystemSettings<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateSystemSettingsInput,\n): Promise<SystemSettings | null> {\n\ttry {\n\t\t// Validate retention days (minimum 1 day, maximum 365 days)\n\t\tif (input.softDeleteRetentionDays < 1 || input.softDeleteRetentionDays > 365) {\n\t\t\tconsole.error(\n\t\t\t\t\"[updateSystemSettings] Invalid retention days. Must be between 1 and 365.\",\n\t\t\t);\n\t\t\treturn null;\n\t\t}\n\n\t\t// First, try to get existing settings\n\t\tconst { data: existing } = await (client as any).models.SystemSettings.get({\n\t\t\tkey: SYSTEM_SETTINGS_KEY,\n\t\t});\n\n\t\tconst settingsData = {\n\t\t\tkey: SYSTEM_SETTINGS_KEY,\n\t\t\tsoftDeleteRetentionDays: input.softDeleteRetentionDays,\n\t\t\tupdatedAt: new Date().toISOString(),\n\t\t\tupdatedBy: input.updatedBy,\n\t\t};\n\n\t\tlet result;\n\t\tif (existing) {\n\t\t\t// Update existing settings\n\t\t\tresult = await (client as any).models.SystemSettings.update(settingsData);\n\t\t} else {\n\t\t\t// Create new settings\n\t\t\tresult = await (client as any).models.SystemSettings.create(settingsData);\n\t\t}\n\n\t\tif (result.errors) {\n\t\t\tconsole.error(\"[updateSystemSettings] GraphQL errors:\", result.errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn result.data as SystemSettings;\n\t} catch (error) {\n\t\tconsole.error(\"[updateSystemSettings] Error updating system settings:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Initialize system settings with default values if they don't exist\n *\n * @example\n * ```typescript\n * import { initializeSystemSettings } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const settings = await initializeSystemSettings(client, 'system@hotelinking.com');\n * ```\n */\nexport async function initializeSystemSettings<TClient = any>(\n\tclient: TClient,\n\tinitializedBy: string,\n): Promise<SystemSettings | null> {\n\ttry {\n\t\t// Check if settings already exist\n\t\tconst { data: existing } = await (client as any).models.SystemSettings.get({\n\t\t\tkey: SYSTEM_SETTINGS_KEY,\n\t\t});\n\n\t\tif (existing) {\n\t\t\treturn existing as SystemSettings;\n\t\t}\n\n\t\t// Create default settings\n\t\tconst { data, errors } = await (client as any).models.SystemSettings.create({\n\t\t\tkey: SYSTEM_SETTINGS_KEY,\n\t\t\tsoftDeleteRetentionDays: DEFAULT_SOFT_DELETE_RETENTION_DAYS,\n\t\t\tupdatedAt: new Date().toISOString(),\n\t\t\tupdatedBy: initializedBy,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[initializeSystemSettings] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data as SystemSettings;\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t\"[initializeSystemSettings] Error initializing system settings:\",\n\t\t\terror,\n\t\t);\n\t\tthrow error;\n\t}\n}\n","/**\n * Reservation Mutation Functions\n *\n * Provides type-safe mutation functions for creating, updating, and deleting reservations.\n * Includes date validation and status transition rules.\n */\n\nimport {\n\tcheckRestoreEligibility,\n\tDEFAULT_SOFT_DELETE_RETENTION_DAYS,\n} from \"../queries/systemSettings\";\nimport type { CreateAuditFields, UpdateWithSoftDeleteFields } from \"./common\";\n\n/**\n * Reservation status type\n */\nexport type ReservationStatus = \"confirmed\" | \"checked_in\" | \"checked_out\" | \"cancelled\" | \"no_show\";\n\n/**\n * Valid status transitions for reservations\n * Maps current status -> allowed next statuses\n */\nconst STATUS_TRANSITIONS: Record<ReservationStatus, ReservationStatus[]> = {\n\tconfirmed: [\"checked_in\", \"cancelled\", \"no_show\"],\n\tchecked_in: [\"checked_out\", \"cancelled\"],\n\tchecked_out: [], // Terminal state - no transitions allowed\n\tcancelled: [], // Terminal state - no transitions allowed\n\tno_show: [], // Terminal state - no transitions allowed\n};\n\n/**\n * Validation error class for reservation operations\n */\nexport class ReservationValidationError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"ReservationValidationError\";\n\t}\n}\n\n/**\n * Validate check-in and check-out dates\n * @throws {ReservationValidationError} if dates are invalid\n */\nfunction validateDates(checkIn: string, checkOut: string): void {\n\tconst checkInDate = new Date(checkIn);\n\tconst checkOutDate = new Date(checkOut);\n\n\t// Check if dates are valid\n\tif (isNaN(checkInDate.getTime())) {\n\t\tthrow new ReservationValidationError(\"Invalid check-in date\");\n\t}\n\n\tif (isNaN(checkOutDate.getTime())) {\n\t\tthrow new ReservationValidationError(\"Invalid check-out date\");\n\t}\n\n\t// Check-out must be after check-in\n\tif (checkOutDate <= checkInDate) {\n\t\tthrow new ReservationValidationError(\n\t\t\t\"Check-out date must be after check-in date\"\n\t\t);\n\t}\n\n\t// Calculate minimum stay (at least a few hours)\n\tconst minStayHours = 4;\n\tconst stayDuration = checkOutDate.getTime() - checkInDate.getTime();\n\tconst hoursDiff = stayDuration / (1000 * 60 * 60);\n\n\tif (hoursDiff < minStayHours) {\n\t\tthrow new ReservationValidationError(\n\t\t\t`Minimum stay is ${minStayHours} hours`\n\t\t);\n\t}\n}\n\n/**\n * Validate status transition\n * @throws {ReservationValidationError} if transition is not allowed\n */\nfunction validateStatusTransition(\n\tcurrentStatus: ReservationStatus,\n\tnewStatus: ReservationStatus\n): void {\n\tconst allowedTransitions = STATUS_TRANSITIONS[currentStatus];\n\n\tif (!allowedTransitions.includes(newStatus)) {\n\t\tthrow new ReservationValidationError(\n\t\t\t`Invalid status transition from '${currentStatus}' to '${newStatus}'. ` +\n\t\t\t`Allowed transitions: ${allowedTransitions.length > 0 ? allowedTransitions.join(\", \") : \"none (terminal state)\"}`\n\t\t);\n\t}\n}\n\n/**\n * Input type for creating a reservation\n */\nexport interface CreateReservationInput extends CreateAuditFields {\n\tbrandId: string;\n\tvisitId: string;\n\tconfirmationCode: string;\n\tcheckIn: string;\n\tcheckOut: string;\n\tstatus?: \"confirmed\" | \"checked_in\" | \"checked_out\" | \"cancelled\" | \"no_show\";\n\tsource?: string;\n\tchannel?: string;\n\troomType?: string;\n\troom?: string;\n\ttotalAmount?: number;\n\tcurrency?: string;\n\tnights?: number;\n}\n\n/**\n * Input type for updating a reservation\n */\nexport interface UpdateReservationInput extends UpdateWithSoftDeleteFields {\n\tid: string;\n\tbrandId?: string;\n\tvisitId?: string;\n\tconfirmationCode?: string;\n\tcheckIn?: string;\n\tcheckOut?: string;\n\tstatus?: \"confirmed\" | \"checked_in\" | \"checked_out\" | \"cancelled\" | \"no_show\";\n\tsource?: string;\n\tchannel?: string;\n\troomType?: string;\n\troom?: string;\n\ttotalAmount?: number;\n\tcurrency?: string;\n\tnights?: number;\n}\n\n/**\n * Create a new reservation with date validation\n *\n * @throws {ReservationValidationError} if dates are invalid\n *\n * @example\n * ```typescript\n * import { createReservation } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const reservation = await createReservation(client, {\n * brandId: 'brand-123',\n * visitId: 'visit-456',\n * confirmationCode: 'ABC123',\n * checkIn: '2024-01-01',\n * checkOut: '2024-01-05',\n * status: 'confirmed'\n * });\n * ```\n */\nexport async function createReservation<TClient = any>(\n\tclient: TClient,\n\tinput: CreateReservationInput,\n): Promise<any | null> {\n\ttry {\n\t\t// Validate dates before creating\n\t\tvalidateDates(input.checkIn, input.checkOut);\n\n\t\t// Calculate nights if not provided\n\t\tif (!input.nights) {\n\t\t\tconst checkInDate = new Date(input.checkIn);\n\t\t\tconst checkOutDate = new Date(input.checkOut);\n\t\t\tconst diffTime = checkOutDate.getTime() - checkInDate.getTime();\n\t\t\tconst diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));\n\t\t\tinput.nights = diffDays;\n\t\t}\n\n\t\tconst { data, errors } = await (client as any).models.Reservation.create(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[createReservation] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data;\n\t} catch (error) {\n\t\tif (error instanceof ReservationValidationError) {\n\t\t\tconsole.error(\"[createReservation] Validation error:\", error.message);\n\t\t\tthrow error;\n\t\t}\n\t\tconsole.error(\"[createReservation] Error creating reservation:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update an existing reservation with validation\n *\n * @throws {ReservationValidationError} if dates or status transition is invalid\n *\n * @example\n * ```typescript\n * import { updateReservation } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const reservation = await updateReservation(client, {\n * id: 'reservation-123',\n * status: 'checked_in',\n * room: '201'\n * });\n * ```\n */\nexport async function updateReservation<TClient = any>(\n\tclient: TClient,\n\tinput: UpdateReservationInput,\n): Promise<any | null> {\n\ttry {\n\t\t// If both dates are being updated, validate them\n\t\tif (input.checkIn && input.checkOut) {\n\t\t\tvalidateDates(input.checkIn, input.checkOut);\n\n\t\t\t// Recalculate nights if dates changed\n\t\t\tconst checkInDate = new Date(input.checkIn);\n\t\t\tconst checkOutDate = new Date(input.checkOut);\n\t\t\tconst diffTime = checkOutDate.getTime() - checkInDate.getTime();\n\t\t\tconst diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));\n\t\t\tinput.nights = diffDays;\n\t\t}\n\n\t\t// If status is being updated, validate the transition\n\t\tif (input.status) {\n\t\t\t// Get current reservation to check current status\n\t\t\tconst { data: currentReservation, errors: getErrors } = await (\n\t\t\t\tclient as any\n\t\t\t).models.Reservation.get({ id: input.id });\n\n\t\t\tif (getErrors || !currentReservation) {\n\t\t\t\tconsole.error(\"[updateReservation] Error fetching current reservation:\", getErrors);\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst currentStatus = currentReservation.status as ReservationStatus;\n\t\t\tvalidateStatusTransition(currentStatus, input.status as ReservationStatus);\n\t\t}\n\n\t\tconst { data, errors } = await (client as any).models.Reservation.update(input);\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateReservation] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data;\n\t} catch (error) {\n\t\tif (error instanceof ReservationValidationError) {\n\t\t\tconsole.error(\"[updateReservation] Validation error:\", error.message);\n\t\t\tthrow error;\n\t\t}\n\t\tconsole.error(\"[updateReservation] Error updating reservation:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Soft delete a reservation (sets deletedAt/deletedBy instead of removing)\n *\n * @example\n * ```typescript\n * import { softDeleteReservation } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await softDeleteReservation(client, 'reservation-123', 'admin@example.com');\n * ```\n */\nexport async function softDeleteReservation<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tdeletedBy: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Reservation.update({\n\t\t\tid,\n\t\t\tdeletedAt: new Date().toISOString(),\n\t\t\tdeletedBy,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[softDeleteReservation] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[softDeleteReservation] Error soft-deleting reservation:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Restore a soft-deleted reservation\n * Checks retention period before allowing restoration\n *\n * @example\n * ```typescript\n * import { restoreReservation } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await restoreReservation(client, 'reservation-123');\n * // Or with custom retention days:\n * await restoreReservation(client, 'reservation-123', 60);\n * ```\n */\nexport async function restoreReservation<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tretentionDays: number = DEFAULT_SOFT_DELETE_RETENTION_DAYS,\n): Promise<{ success: boolean; error?: string }> {\n\ttry {\n\t\t// First, get the reservation to check its deletedAt timestamp\n\t\tconst { data: reservation, errors: getErrors } = await (\n\t\t\tclient as any\n\t\t).models.Reservation.get({ id });\n\n\t\tif (getErrors || !reservation) {\n\t\t\tconsole.error(\"[restoreReservation] Error fetching reservation:\", getErrors);\n\t\t\treturn { success: false, error: \"Reservation not found\" };\n\t\t}\n\n\t\t// Check if restoration is allowed based on retention period\n\t\tconst eligibility = checkRestoreEligibility(reservation.deletedAt, retentionDays);\n\n\t\tif (!eligibility.canRestore) {\n\t\t\tconst errorMsg = `Cannot restore reservation. Retention period of ${retentionDays} days has expired. Item was deleted ${eligibility.daysExpired} days ago.`;\n\t\t\tconsole.error(\"[restoreReservation]\", errorMsg);\n\t\t\treturn { success: false, error: errorMsg };\n\t\t}\n\n\t\tconst { errors } = await (client as any).models.Reservation.update({\n\t\t\tid,\n\t\t\tdeletedAt: null,\n\t\t\tdeletedBy: null,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[restoreReservation] GraphQL errors:\", errors);\n\t\t\treturn { success: false, error: \"Failed to restore reservation\" };\n\t\t}\n\n\t\treturn { success: true };\n\t} catch (error) {\n\t\tconsole.error(\"[restoreReservation] Error restoring reservation:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Hard delete a reservation (permanently removes from database)\n * Use with caution - prefer softDeleteReservation for recoverable deletion\n *\n * @example\n * ```typescript\n * import { deleteReservation } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * await deleteReservation(client, 'reservation-123');\n * ```\n */\nexport async function deleteReservation<TClient = any>(\n\tclient: TClient,\n\tid: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst { errors } = await (client as any).models.Reservation.delete({ id });\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[deleteReservation] GraphQL errors:\", errors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(\"[deleteReservation] Error deleting reservation:\", error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Update reservation status with validation\n *\n * Validates that the status transition is allowed based on current status.\n * Status transition rules:\n * - confirmed → checked_in, cancelled, no_show\n * - checked_in → checked_out, cancelled\n * - checked_out → (terminal state, no transitions)\n * - cancelled → (terminal state, no transitions)\n * - no_show → (terminal state, no transitions)\n *\n * @throws {ReservationValidationError} if status transition is invalid\n *\n * @example\n * ```typescript\n * import { updateReservationStatus } from '@htlkg/data/mutations';\n * import { generateClient } from '@htlkg/data/client';\n *\n * const client = generateClient<Schema>();\n * const reservation = await updateReservationStatus(\n * client,\n * 'reservation-123',\n * 'checked_in'\n * );\n * ```\n */\nexport async function updateReservationStatus<TClient = any>(\n\tclient: TClient,\n\tid: string,\n\tnewStatus: ReservationStatus,\n): Promise<any | null> {\n\ttry {\n\t\t// Get current reservation to check current status\n\t\tconst { data: currentReservation, errors: getErrors } = await (\n\t\t\tclient as any\n\t\t).models.Reservation.get({ id });\n\n\t\tif (getErrors || !currentReservation) {\n\t\t\tconsole.error(\"[updateReservationStatus] Error fetching reservation:\", getErrors);\n\t\t\treturn null;\n\t\t}\n\n\t\tconst currentStatus = currentReservation.status as ReservationStatus;\n\n\t\t// Validate status transition\n\t\tvalidateStatusTransition(currentStatus, newStatus);\n\n\t\t// Perform the update\n\t\tconst { data, errors } = await (client as any).models.Reservation.update({\n\t\t\tid,\n\t\t\tstatus: newStatus,\n\t\t});\n\n\t\tif (errors) {\n\t\t\tconsole.error(\"[updateReservationStatus] GraphQL errors:\", errors);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn data;\n\t} catch (error) {\n\t\tif (error instanceof ReservationValidationError) {\n\t\t\tconsole.error(\"[updateReservationStatus] Validation error:\", error.message);\n\t\t\tthrow error;\n\t\t}\n\t\tconsole.error(\"[updateReservationStatus] Error updating status:\", error);\n\t\tthrow error;\n\t}\n}\n"],"mappings":";AASO,IAAM,qCAAqC;AAG3C,IAAM,sBAAsB;AA6D5B,SAAS,wBACf,WACA,eAMC;AACD,MAAI,CAAC,WAAW;AACf,WAAO;AAAA,MACN,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,aAAa;AAAA,MACb,WAAW;AAAA,IACZ;AAAA,EACD;AAEA,QAAM,cAAc,IAAI,KAAK,SAAS;AACtC,QAAM,YAAY,IAAI,KAAK,WAAW;AACtC,YAAU,QAAQ,UAAU,QAAQ,IAAI,aAAa;AAErD,QAAM,MAAM,oBAAI,KAAK;AACrB,QAAM,cAAc,UAAU,QAAQ,IAAI,IAAI,QAAQ;AACtD,QAAM,gBAAgB,KAAK,KAAK,eAAe,MAAO,KAAK,KAAK,GAAG;AAEnE,MAAI,iBAAiB,GAAG;AACvB,WAAO;AAAA,MACN,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,aAAa,KAAK,IAAI,aAAa;AAAA,MACnC;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AAAA,IACN,YAAY;AAAA,IACZ;AAAA,IACA,aAAa;AAAA,IACb;AAAA,EACD;AACD;;;AC5DA,eAAsB,YACrB,QACA,OACwB;AACxB,MAAI;AACH,UAAM,EAAE,MAAM,OAAO,IAAI,MAAO,OAAe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AAO,EAAE,GAAG,CAAC;AAEzE,QAAI,QAAQ;AACX,cAAQ,MAAM,uCAAuC,MAAM;AAC3D,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,EACR,SAAS,OAAO;AACf,YAAQ,MAAM,mDAAmD,KAAK;AACtE,UAAM;AAAA,EACP;AACD;AA4BA,eAAsB,wBACrB,QACA,IACA,WACsB;AACtB,MAAI;AAEH,UAAM,EAAE,MAAM,oBAAoB,QAAQ,UAAU,IAAI,MACvD,OACC,OAAO,YAAY,IAAI,EAAE,GAAG,CAAC;AAE/B,QAAI,aAAa,CAAC,oBAAoB;AACrC,cAAQ,MAAM,yDAAyD,SAAS;AAChF,aAAO;AAAA,IACR;AAEA,UAAM,gBAAgB,mBAAmB;AAGzC,6BAAyB,eAAe,SAAS;AAGjD,UAAM,EAAE,MAAM,OAAO,IAAI,MAAO,OAAe,OAAO,YAAY,OAAO;AAAA,MACxE;AAAA,MACA,QAAQ;AAAA,IACT,CAAC;AAED,QAAI,QAAQ;AACX,cAAQ,MAAM,6CAA6C,MAAM;AACjE,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,EACR,SAAS,OAAO;AACf,QAAI,iBAAiB,4BAA4B;AAChD,cAAQ,MAAM,+CAA+C,MAAM,OAAO;AAC1E,YAAM;AAAA,IACP;AACA,YAAQ,MAAM,oDAAoD,KAAK;AACvE,UAAM;AAAA,EACP;AACD;","names":[]}
@@ -1,43 +1,5 @@
1
1
  import { ProductInstance } from '@htlkg/core/types';
2
-
3
- /**
4
- * Common Mutation Input Base Types
5
- *
6
- * Provides reusable base interfaces for audit fields to avoid duplication
7
- * across all mutation input types.
8
- */
9
- /**
10
- * Audit fields for creation operations
11
- * Includes timestamps and user tracking
12
- */
13
- interface CreateAuditFields {
14
- createdAt?: string;
15
- createdBy?: string;
16
- updatedAt?: string;
17
- updatedBy?: string;
18
- }
19
- /**
20
- * Audit fields for update operations
21
- * Includes timestamps and user tracking
22
- */
23
- interface UpdateAuditFields {
24
- updatedAt?: string;
25
- updatedBy?: string;
26
- }
27
- /**
28
- * Soft delete fields for entities that support soft deletion
29
- * Tracks when and by whom an entity was deleted
30
- */
31
- interface SoftDeleteFields {
32
- deletedAt?: string | null;
33
- deletedBy?: string | null;
34
- }
35
- /**
36
- * Complete audit trail for entities with soft delete support
37
- * Combines update and soft delete fields
38
- */
39
- interface UpdateWithSoftDeleteFields extends UpdateAuditFields, SoftDeleteFields {
40
- }
2
+ import { C as CreateAuditFields, U as UpdateAuditFields } from './common-DSxswsZ3.js';
41
3
 
42
4
  /**
43
5
  * ProductInstance Mutation Functions
@@ -130,4 +92,4 @@ declare function deleteProductInstance<TClient = any>(client: TClient, id: strin
130
92
  */
131
93
  declare function toggleProductInstanceEnabled<TClient = any>(client: TClient, id: string, enabled: boolean): Promise<ProductInstance | null>;
132
94
 
133
- export { type CreateAuditFields as C, type SoftDeleteFields as S, type UpdateAuditFields as U, type UpdateWithSoftDeleteFields as a, type CreateProductInstanceInput as b, createProductInstance as c, deleteProductInstance as d, type UpdateProductInstanceInput as e, toggleProductInstanceEnabled as t, updateProductInstance as u };
95
+ export { type CreateProductInstanceInput as C, type UpdateProductInstanceInput as U, createProductInstance as c, deleteProductInstance as d, toggleProductInstanceEnabled as t, updateProductInstance as u };
@@ -1,10 +1,13 @@
1
1
  import { Brand, Account, User, Product, ProductInstance, SystemSettings } from '@htlkg/core/types';
2
2
  import { AstroGlobal } from 'astro';
3
3
  import { generateServerClient } from '../client/index.js';
4
+ 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
5
  import 'aws-amplify/data';
5
6
  import 'aws-amplify';
6
7
  import '../server/index.js';
7
8
  import 'aws-amplify/api/internals';
9
+ import '../reservations-CdDfkcZ_.js';
10
+ import '../common-DSxswsZ3.js';
8
11
 
9
12
  /**
10
13
  * Brand Query Functions