@timardex/cluemart-shared 1.6.112 → 1.6.130

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/dist/affiliate-Bqqlffw8.d.mts +36 -0
  2. package/dist/affiliate-Btlp5XUp.d.ts +36 -0
  3. package/dist/affiliateAdapters-BW3BY7c5.d.mts +118 -0
  4. package/dist/affiliateAdapters-C51ISmuA.d.ts +118 -0
  5. package/dist/apollo/index.d.mts +3 -3
  6. package/dist/apollo/index.d.ts +3 -3
  7. package/dist/auth/index.cjs +2546 -951
  8. package/dist/auth/index.cjs.map +1 -1
  9. package/dist/auth/index.d.mts +28 -30
  10. package/dist/auth/index.d.ts +28 -30
  11. package/dist/auth/index.mjs +24 -25
  12. package/dist/auth/index.mjs.map +1 -1
  13. package/dist/auth-BOmAO53v.d.ts +169 -0
  14. package/dist/auth-CsITA95p.d.mts +169 -0
  15. package/dist/{chunk-VPANTTZI.mjs → chunk-DATBGC2K.mjs} +108 -23
  16. package/dist/chunk-DATBGC2K.mjs.map +1 -0
  17. package/dist/chunk-DDHECBJR.mjs +726 -0
  18. package/dist/chunk-DDHECBJR.mjs.map +1 -0
  19. package/dist/chunk-INQCDU24.mjs +139 -0
  20. package/dist/chunk-INQCDU24.mjs.map +1 -0
  21. package/dist/{chunk-SD42WIMV.mjs → chunk-NWWKI4PJ.mjs} +5 -5
  22. package/dist/chunk-NWWKI4PJ.mjs.map +1 -0
  23. package/dist/{chunk-LBEJECG3.mjs → chunk-OHHJ3KJJ.mjs} +71 -64
  24. package/dist/chunk-OHHJ3KJJ.mjs.map +1 -0
  25. package/dist/chunk-TOEFAEF2.mjs +69 -0
  26. package/dist/chunk-TOEFAEF2.mjs.map +1 -0
  27. package/dist/chunk-UKW7NZEQ.mjs +2813 -0
  28. package/dist/chunk-UKW7NZEQ.mjs.map +1 -0
  29. package/dist/dailyClue-C6WXY73z.d.mts +105 -0
  30. package/dist/dailyClue-C6WXY73z.d.ts +105 -0
  31. package/dist/enums/index.cjs +2 -229
  32. package/dist/enums/index.cjs.map +1 -1
  33. package/dist/enums/index.d.mts +5 -170
  34. package/dist/enums/index.d.ts +5 -170
  35. package/dist/enums/index.mjs +1 -41
  36. package/dist/event-C9K7CSg4.d.ts +53 -0
  37. package/dist/event-W0NhL5Cd.d.mts +53 -0
  38. package/dist/formFields/index.cjs +284 -112
  39. package/dist/formFields/index.cjs.map +1 -1
  40. package/dist/formFields/index.d.mts +4 -2
  41. package/dist/formFields/index.d.ts +4 -2
  42. package/dist/formFields/index.mjs +919 -50
  43. package/dist/formFields/index.mjs.map +1 -1
  44. package/dist/global-BbSFfYdd.d.ts +181 -0
  45. package/dist/global-C6v9tRji.d.mts +181 -0
  46. package/dist/graphql/index.cjs +2860 -2292
  47. package/dist/graphql/index.cjs.map +1 -1
  48. package/dist/graphql/index.d.mts +422 -469
  49. package/dist/graphql/index.d.ts +422 -469
  50. package/dist/graphql/index.mjs +2547 -160
  51. package/dist/graphql/index.mjs.map +1 -1
  52. package/dist/graphql-CDOfA79A.d.ts +1253 -0
  53. package/dist/graphql-CcvzTs9k.d.mts +1253 -0
  54. package/dist/hooks/index.cjs +511 -3846
  55. package/dist/hooks/index.cjs.map +1 -1
  56. package/dist/hooks/index.d.mts +10 -9
  57. package/dist/hooks/index.d.ts +10 -9
  58. package/dist/hooks/index.mjs +54 -72
  59. package/dist/hooks/index.mjs.map +1 -1
  60. package/dist/images/index.mjs +86 -21
  61. package/dist/images/index.mjs.map +1 -1
  62. package/dist/index.cjs +4414 -3168
  63. package/dist/index.cjs.map +1 -1
  64. package/dist/index.d.mts +2439 -1579
  65. package/dist/index.d.ts +2439 -1579
  66. package/dist/index.mjs +4350 -3121
  67. package/dist/index.mjs.map +1 -1
  68. package/dist/map/index.d.mts +3 -2
  69. package/dist/map/index.d.ts +3 -2
  70. package/dist/resourceActivities-CS8YRIIL.d.mts +89 -0
  71. package/dist/resourceActivities-DOdNPkhW.d.ts +89 -0
  72. package/dist/sharing/index.cjs +23 -19
  73. package/dist/sharing/index.cjs.map +1 -1
  74. package/dist/sharing/index.d.mts +16 -3
  75. package/dist/sharing/index.d.ts +16 -3
  76. package/dist/sharing/index.mjs +183 -29
  77. package/dist/sharing/index.mjs.map +1 -1
  78. package/dist/subscription-Cj_qBA7u.d.mts +20 -0
  79. package/dist/subscription-OiJ50uJb.d.ts +20 -0
  80. package/dist/theme/index.mjs +41 -5
  81. package/dist/theme/index.mjs.map +1 -1
  82. package/dist/types/index.cjs +868 -123
  83. package/dist/types/index.cjs.map +1 -1
  84. package/dist/types/index.d.mts +234 -15
  85. package/dist/types/index.d.ts +234 -15
  86. package/dist/types/index.mjs +61 -31
  87. package/dist/utils/index.cjs +292 -117
  88. package/dist/utils/index.cjs.map +1 -1
  89. package/dist/utils/index.d.mts +25 -23
  90. package/dist/utils/index.d.ts +25 -23
  91. package/dist/utils/index.mjs +6 -5
  92. package/dist/vendor-DmMi2qmx.d.mts +73 -0
  93. package/dist/vendor-M9hVZlni.d.ts +73 -0
  94. package/package.json +10 -3
  95. package/dist/ad-BUYzE6zx.d.ts +0 -181
  96. package/dist/ad-BhLoEul3.d.mts +0 -181
  97. package/dist/affiliate-BbtjeUP4.d.mts +0 -73
  98. package/dist/affiliate-C51nzKsw.d.ts +0 -73
  99. package/dist/chunk-32MKHJTX.mjs +0 -1207
  100. package/dist/chunk-32MKHJTX.mjs.map +0 -1
  101. package/dist/chunk-AYO3E4DM.mjs +0 -224
  102. package/dist/chunk-AYO3E4DM.mjs.map +0 -1
  103. package/dist/chunk-BIJ5NDXW.mjs +0 -962
  104. package/dist/chunk-BIJ5NDXW.mjs.map +0 -1
  105. package/dist/chunk-DQ7ZHIXW.mjs +0 -26
  106. package/dist/chunk-DQ7ZHIXW.mjs.map +0 -1
  107. package/dist/chunk-ILILH7E2.mjs +0 -219
  108. package/dist/chunk-ILILH7E2.mjs.map +0 -1
  109. package/dist/chunk-LBEJECG3.mjs.map +0 -1
  110. package/dist/chunk-NPFJ2CN2.mjs +0 -109
  111. package/dist/chunk-NPFJ2CN2.mjs.map +0 -1
  112. package/dist/chunk-R6PCFOYO.mjs +0 -3650
  113. package/dist/chunk-R6PCFOYO.mjs.map +0 -1
  114. package/dist/chunk-SD42WIMV.mjs.map +0 -1
  115. package/dist/chunk-VA5YN2K3.mjs +0 -48
  116. package/dist/chunk-VA5YN2K3.mjs.map +0 -1
  117. package/dist/chunk-VPANTTZI.mjs.map +0 -1
  118. package/dist/chunk-X3OLM35T.mjs +0 -278
  119. package/dist/chunk-X3OLM35T.mjs.map +0 -1
  120. package/dist/contactUs--NoohZBu.d.ts +0 -11
  121. package/dist/contactUs-CBWzefUS.d.mts +0 -11
  122. package/dist/global-CUYYxpy2.d.ts +0 -699
  123. package/dist/global-DePDtOFt.d.mts +0 -699
  124. package/dist/resourceActivities-CMUcn2P7.d.ts +0 -130
  125. package/dist/resourceActivities-CwbJFGIp.d.mts +0 -130
  126. package/dist/subscription-BU8GvH2K.d.ts +0 -12
  127. package/dist/subscription-bmAdrnfi.d.mts +0 -12
  128. package/dist/user-D47MLFyH.d.ts +0 -134
  129. package/dist/user-DE8edl3u.d.mts +0 -134
@@ -1,10 +1,8 @@
1
- import { EnumUserRole, EnumResourceType, EnumUserLicence } from '../enums/index.mjs';
2
- import { P as Permission, S as SafeUserType } from '../user-DE8edl3u.mjs';
3
- export { a as PERMISSIONS, W as WILDCARD_PERMISSION } from '../user-DE8edl3u.mjs';
4
- import { T as Tier } from '../subscription-bmAdrnfi.mjs';
1
+ import { U as UserRoleEnumType, f as ResourceTypeEnum, e as LicencesEnumType, C as UserType } from '../graphql-CcvzTs9k.mjs';
2
+ import { P as Permission, T as Tier } from '../subscription-Cj_qBA7u.mjs';
3
+ export { a as PERMISSIONS, W as WILDCARD_PERMISSION } from '../subscription-Cj_qBA7u.mjs';
5
4
  import React, { ReactNode } from 'react';
6
- import '../global-DePDtOFt.mjs';
7
- import 'react-hook-form';
5
+ import '../images/index.mjs';
8
6
 
9
7
  type AuthManager = {
10
8
  logout: () => Promise<void>;
@@ -22,7 +20,7 @@ type AuthManager = {
22
20
  declare function createAuthManager(): AuthManager;
23
21
 
24
22
  /** Roles allowed to sign into the admin web app (CUSTOMER-only is denied). */
25
- declare const ADMIN_APP_ROLES: readonly [EnumUserRole.SUPER_ADMIN, EnumUserRole.ADMIN, EnumUserRole.EVENT, EnumUserRole.VENDOR, EnumUserRole.PARTNER, EnumUserRole.SCHOOL, EnumUserRole.AFFILIATE];
23
+ declare const ADMIN_APP_ROLES: readonly [UserRoleEnumType.SuperAdmin, UserRoleEnumType.Admin, UserRoleEnumType.Event, UserRoleEnumType.Vendor, UserRoleEnumType.Partner, UserRoleEnumType.School, UserRoleEnumType.Affiliate];
26
24
  type AdminAppRole = (typeof ADMIN_APP_ROLES)[number];
27
25
  type AdminDashboardContext = "staff" | "event" | "vendor" | "partner" | "school" | "affiliate";
28
26
  type AdminDashboardContextInfo = {
@@ -31,39 +29,39 @@ type AdminDashboardContextInfo = {
31
29
  label: string;
32
30
  /** Path prefixes that belong to this context (including home). */
33
31
  pathPrefixes: readonly string[];
34
- roles: readonly EnumUserRole[];
32
+ roles: readonly UserRoleEnumType[];
35
33
  };
36
34
  /**
37
35
  * Priority order for default home + role switcher.
38
36
  * Staff first, then product roles.
39
37
  */
40
38
  declare const ADMIN_DASHBOARD_CONTEXTS: readonly AdminDashboardContextInfo[];
41
- declare function canAccessAdminApp(roles: EnumUserRole[] | null | undefined): boolean;
42
- declare function getUsableAdminContexts(roles: EnumUserRole[] | null | undefined): AdminDashboardContextInfo[];
43
- declare function getDefaultAdminHome(roles: EnumUserRole[] | null | undefined, preferredContext?: AdminDashboardContext | null): string;
39
+ declare function canAccessAdminApp(roles: UserRoleEnumType[] | null | undefined): boolean;
40
+ declare function getUsableAdminContexts(roles: UserRoleEnumType[] | null | undefined): AdminDashboardContextInfo[];
41
+ declare function getDefaultAdminHome(roles: UserRoleEnumType[] | null | undefined, preferredContext?: AdminDashboardContext | null): string;
44
42
  declare function resolveAdminContextFromPath(pathname: string): AdminDashboardContext | null;
45
- declare function canAccessAdminPath(roles: EnumUserRole[] | null | undefined, pathname: string): boolean;
43
+ declare function canAccessAdminPath(roles: UserRoleEnumType[] | null | undefined, pathname: string): boolean;
46
44
 
47
45
  /**
48
46
  * Union of permissions for the given roles (deduped, stable order).
49
47
  */
50
- declare function getPermissionsForRoles(roles: EnumUserRole[] | null | undefined): Permission[];
48
+ declare function getPermissionsForRoles(roles: UserRoleEnumType[] | null | undefined): Permission[];
51
49
  /**
52
50
  * Check a concrete permission list (e.g. authUser.permissions) for a grant.
53
51
  * Honours the "*" wildcard.
54
52
  */
55
53
  declare function permissionListIncludes(permissions: readonly Permission[] | null | undefined, permission: Permission): boolean;
56
- declare function hasPermission(roles: EnumUserRole[] | null | undefined, permission: Permission): boolean;
57
- declare function hasAnyPermission(roles: EnumUserRole[] | null | undefined, permissions: readonly Permission[]): boolean;
58
- declare function hasAllPermissions(roles: EnumUserRole[] | null | undefined, permissions: readonly Permission[]): boolean;
59
- declare function hasRole(roles: EnumUserRole[] | null | undefined, role: EnumUserRole): boolean;
60
- declare function hasAnyRole(roles: EnumUserRole[] | null | undefined, checkRoles: readonly EnumUserRole[]): boolean;
54
+ declare function hasPermission(roles: UserRoleEnumType[] | null | undefined, permission: Permission): boolean;
55
+ declare function hasAnyPermission(roles: UserRoleEnumType[] | null | undefined, permissions: readonly Permission[]): boolean;
56
+ declare function hasAllPermissions(roles: UserRoleEnumType[] | null | undefined, permissions: readonly Permission[]): boolean;
57
+ declare function hasRole(roles: UserRoleEnumType[] | null | undefined, role: UserRoleEnumType): boolean;
58
+ declare function hasAnyRole(roles: UserRoleEnumType[] | null | undefined, checkRoles: readonly UserRoleEnumType[]): boolean;
61
59
 
62
60
  /**
63
61
  * Static role → permissions map. Source of truth for access.
64
62
  * Permissions for a user = union of all their roles' lists.
65
63
  */
66
- declare const ROLE_PERMISSIONS: Record<EnumUserRole, readonly Permission[]>;
64
+ declare const ROLE_PERMISSIONS: Record<UserRoleEnumType, readonly Permission[]>;
67
65
 
68
66
  type LimitType = "availability" | "images" | "calendar" | "posters" | "productsList" | "statistics" | "relationShare";
69
67
  interface RoleLicences {
@@ -77,9 +75,9 @@ interface LicencesByRole {
77
75
  partner: RoleLicences;
78
76
  }
79
77
  /** Resource types with subscription/licence limits (excludes affiliate & school). */
80
- type LicencedResourceType = Exclude<EnumResourceType, EnumResourceType.AFFILIATE | EnumResourceType.SCHOOL>;
78
+ type LicencedResourceType = Exclude<ResourceTypeEnum, ResourceTypeEnum.Affiliate | ResourceTypeEnum.School>;
81
79
  /** Licence badges shown on the profile screen (excludes affiliate & school). */
82
- type ProfileBadgeLicence = Exclude<EnumUserLicence, EnumUserLicence.STANDARD_AFFILIATE | EnumUserLicence.STANDARD_SCHOOL>;
80
+ type ProfileBadgeLicence = Exclude<LicencesEnumType, LicencesEnumType.StandardAffiliate | LicencesEnumType.StandardSchool>;
83
81
  type HasLicenceResult = {
84
82
  directLicence: boolean;
85
83
  };
@@ -112,29 +110,29 @@ type UseAuthCoreAdapters = {
112
110
  }) => void;
113
111
  };
114
112
  interface UseAuthReturnType {
115
- authUser: SafeUserType | null;
113
+ authUser: UserType | null;
116
114
  isAffiliate: boolean;
117
115
  isSchool: boolean;
118
116
  handleLogoutExplicit: () => Promise<void>;
119
117
  hasEventLicence: HasLicenceResult;
120
118
  hasPartnerLicence: HasLicenceResult;
121
119
  hasPermission: (permission: Permission) => boolean;
122
- hasRole: (role: EnumUserRole) => boolean;
123
- hasUserLicence: (licenceType: EnumUserLicence) => boolean;
120
+ hasRole: (role: UserRoleEnumType) => boolean;
121
+ hasUserLicence: (licenceType: LicencesEnumType) => boolean;
124
122
  hasVendorLicence: HasLicenceResult;
125
123
  isAdmin: boolean;
126
124
  isSuperAdmin: boolean;
127
125
  isLoading: boolean;
128
126
  permissions: Permission[];
129
- getLicenseAccessLevel: (limitType: LimitType, resourceId: string, resourceType: EnumResourceType) => number;
127
+ getLicenseAccessLevel: (limitType: LimitType, resourceId: string, resourceType: ResourceTypeEnum) => number;
130
128
  refetchUser: () => Promise<void>;
131
- setUser: (user: SafeUserType | null) => Promise<void>;
129
+ setUser: (user: UserType | null) => Promise<void>;
132
130
  }
133
131
 
134
- declare function isLicencedResourceType(resourceType: EnumResourceType): resourceType is LicencedResourceType;
135
- declare function isProfileBadgeLicence(licenceType: EnumUserLicence): licenceType is ProfileBadgeLicence;
136
- declare const hasUserLicenceType: (authUser: SafeUserType | null, licenceType: EnumUserLicence) => boolean;
137
- declare const hasLicence: (authUser: SafeUserType | null, licenceType: "vendor" | "partner" | "event") => HasLicenceResult;
132
+ declare function isLicencedResourceType(resourceType: ResourceTypeEnum): resourceType is LicencedResourceType;
133
+ declare function isProfileBadgeLicence(licenceType: LicencesEnumType): licenceType is ProfileBadgeLicence;
134
+ declare const hasUserLicenceType: (authUser: UserType | null, licenceType: LicencesEnumType) => boolean;
135
+ declare const hasLicence: (authUser: UserType | null, licenceType: "vendor" | "partner" | "event") => HasLicenceResult;
138
136
  /** Default limits per subscription tier. */
139
137
  declare const DEFAULT_LIMITS: Record<LimitType, Record<Tier, number>>;
140
138
  /** All tiers off — used when the viewer does not own the resource. */
@@ -1,10 +1,8 @@
1
- import { EnumUserRole, EnumResourceType, EnumUserLicence } from '../enums/index.js';
2
- import { P as Permission, S as SafeUserType } from '../user-D47MLFyH.js';
3
- export { a as PERMISSIONS, W as WILDCARD_PERMISSION } from '../user-D47MLFyH.js';
4
- import { T as Tier } from '../subscription-BU8GvH2K.js';
1
+ import { U as UserRoleEnumType, f as ResourceTypeEnum, e as LicencesEnumType, C as UserType } from '../graphql-CDOfA79A.js';
2
+ import { P as Permission, T as Tier } from '../subscription-OiJ50uJb.js';
3
+ export { a as PERMISSIONS, W as WILDCARD_PERMISSION } from '../subscription-OiJ50uJb.js';
5
4
  import React, { ReactNode } from 'react';
6
- import '../global-CUYYxpy2.js';
7
- import 'react-hook-form';
5
+ import '../images/index.js';
8
6
 
9
7
  type AuthManager = {
10
8
  logout: () => Promise<void>;
@@ -22,7 +20,7 @@ type AuthManager = {
22
20
  declare function createAuthManager(): AuthManager;
23
21
 
24
22
  /** Roles allowed to sign into the admin web app (CUSTOMER-only is denied). */
25
- declare const ADMIN_APP_ROLES: readonly [EnumUserRole.SUPER_ADMIN, EnumUserRole.ADMIN, EnumUserRole.EVENT, EnumUserRole.VENDOR, EnumUserRole.PARTNER, EnumUserRole.SCHOOL, EnumUserRole.AFFILIATE];
23
+ declare const ADMIN_APP_ROLES: readonly [UserRoleEnumType.SuperAdmin, UserRoleEnumType.Admin, UserRoleEnumType.Event, UserRoleEnumType.Vendor, UserRoleEnumType.Partner, UserRoleEnumType.School, UserRoleEnumType.Affiliate];
26
24
  type AdminAppRole = (typeof ADMIN_APP_ROLES)[number];
27
25
  type AdminDashboardContext = "staff" | "event" | "vendor" | "partner" | "school" | "affiliate";
28
26
  type AdminDashboardContextInfo = {
@@ -31,39 +29,39 @@ type AdminDashboardContextInfo = {
31
29
  label: string;
32
30
  /** Path prefixes that belong to this context (including home). */
33
31
  pathPrefixes: readonly string[];
34
- roles: readonly EnumUserRole[];
32
+ roles: readonly UserRoleEnumType[];
35
33
  };
36
34
  /**
37
35
  * Priority order for default home + role switcher.
38
36
  * Staff first, then product roles.
39
37
  */
40
38
  declare const ADMIN_DASHBOARD_CONTEXTS: readonly AdminDashboardContextInfo[];
41
- declare function canAccessAdminApp(roles: EnumUserRole[] | null | undefined): boolean;
42
- declare function getUsableAdminContexts(roles: EnumUserRole[] | null | undefined): AdminDashboardContextInfo[];
43
- declare function getDefaultAdminHome(roles: EnumUserRole[] | null | undefined, preferredContext?: AdminDashboardContext | null): string;
39
+ declare function canAccessAdminApp(roles: UserRoleEnumType[] | null | undefined): boolean;
40
+ declare function getUsableAdminContexts(roles: UserRoleEnumType[] | null | undefined): AdminDashboardContextInfo[];
41
+ declare function getDefaultAdminHome(roles: UserRoleEnumType[] | null | undefined, preferredContext?: AdminDashboardContext | null): string;
44
42
  declare function resolveAdminContextFromPath(pathname: string): AdminDashboardContext | null;
45
- declare function canAccessAdminPath(roles: EnumUserRole[] | null | undefined, pathname: string): boolean;
43
+ declare function canAccessAdminPath(roles: UserRoleEnumType[] | null | undefined, pathname: string): boolean;
46
44
 
47
45
  /**
48
46
  * Union of permissions for the given roles (deduped, stable order).
49
47
  */
50
- declare function getPermissionsForRoles(roles: EnumUserRole[] | null | undefined): Permission[];
48
+ declare function getPermissionsForRoles(roles: UserRoleEnumType[] | null | undefined): Permission[];
51
49
  /**
52
50
  * Check a concrete permission list (e.g. authUser.permissions) for a grant.
53
51
  * Honours the "*" wildcard.
54
52
  */
55
53
  declare function permissionListIncludes(permissions: readonly Permission[] | null | undefined, permission: Permission): boolean;
56
- declare function hasPermission(roles: EnumUserRole[] | null | undefined, permission: Permission): boolean;
57
- declare function hasAnyPermission(roles: EnumUserRole[] | null | undefined, permissions: readonly Permission[]): boolean;
58
- declare function hasAllPermissions(roles: EnumUserRole[] | null | undefined, permissions: readonly Permission[]): boolean;
59
- declare function hasRole(roles: EnumUserRole[] | null | undefined, role: EnumUserRole): boolean;
60
- declare function hasAnyRole(roles: EnumUserRole[] | null | undefined, checkRoles: readonly EnumUserRole[]): boolean;
54
+ declare function hasPermission(roles: UserRoleEnumType[] | null | undefined, permission: Permission): boolean;
55
+ declare function hasAnyPermission(roles: UserRoleEnumType[] | null | undefined, permissions: readonly Permission[]): boolean;
56
+ declare function hasAllPermissions(roles: UserRoleEnumType[] | null | undefined, permissions: readonly Permission[]): boolean;
57
+ declare function hasRole(roles: UserRoleEnumType[] | null | undefined, role: UserRoleEnumType): boolean;
58
+ declare function hasAnyRole(roles: UserRoleEnumType[] | null | undefined, checkRoles: readonly UserRoleEnumType[]): boolean;
61
59
 
62
60
  /**
63
61
  * Static role → permissions map. Source of truth for access.
64
62
  * Permissions for a user = union of all their roles' lists.
65
63
  */
66
- declare const ROLE_PERMISSIONS: Record<EnumUserRole, readonly Permission[]>;
64
+ declare const ROLE_PERMISSIONS: Record<UserRoleEnumType, readonly Permission[]>;
67
65
 
68
66
  type LimitType = "availability" | "images" | "calendar" | "posters" | "productsList" | "statistics" | "relationShare";
69
67
  interface RoleLicences {
@@ -77,9 +75,9 @@ interface LicencesByRole {
77
75
  partner: RoleLicences;
78
76
  }
79
77
  /** Resource types with subscription/licence limits (excludes affiliate & school). */
80
- type LicencedResourceType = Exclude<EnumResourceType, EnumResourceType.AFFILIATE | EnumResourceType.SCHOOL>;
78
+ type LicencedResourceType = Exclude<ResourceTypeEnum, ResourceTypeEnum.Affiliate | ResourceTypeEnum.School>;
81
79
  /** Licence badges shown on the profile screen (excludes affiliate & school). */
82
- type ProfileBadgeLicence = Exclude<EnumUserLicence, EnumUserLicence.STANDARD_AFFILIATE | EnumUserLicence.STANDARD_SCHOOL>;
80
+ type ProfileBadgeLicence = Exclude<LicencesEnumType, LicencesEnumType.StandardAffiliate | LicencesEnumType.StandardSchool>;
83
81
  type HasLicenceResult = {
84
82
  directLicence: boolean;
85
83
  };
@@ -112,29 +110,29 @@ type UseAuthCoreAdapters = {
112
110
  }) => void;
113
111
  };
114
112
  interface UseAuthReturnType {
115
- authUser: SafeUserType | null;
113
+ authUser: UserType | null;
116
114
  isAffiliate: boolean;
117
115
  isSchool: boolean;
118
116
  handleLogoutExplicit: () => Promise<void>;
119
117
  hasEventLicence: HasLicenceResult;
120
118
  hasPartnerLicence: HasLicenceResult;
121
119
  hasPermission: (permission: Permission) => boolean;
122
- hasRole: (role: EnumUserRole) => boolean;
123
- hasUserLicence: (licenceType: EnumUserLicence) => boolean;
120
+ hasRole: (role: UserRoleEnumType) => boolean;
121
+ hasUserLicence: (licenceType: LicencesEnumType) => boolean;
124
122
  hasVendorLicence: HasLicenceResult;
125
123
  isAdmin: boolean;
126
124
  isSuperAdmin: boolean;
127
125
  isLoading: boolean;
128
126
  permissions: Permission[];
129
- getLicenseAccessLevel: (limitType: LimitType, resourceId: string, resourceType: EnumResourceType) => number;
127
+ getLicenseAccessLevel: (limitType: LimitType, resourceId: string, resourceType: ResourceTypeEnum) => number;
130
128
  refetchUser: () => Promise<void>;
131
- setUser: (user: SafeUserType | null) => Promise<void>;
129
+ setUser: (user: UserType | null) => Promise<void>;
132
130
  }
133
131
 
134
- declare function isLicencedResourceType(resourceType: EnumResourceType): resourceType is LicencedResourceType;
135
- declare function isProfileBadgeLicence(licenceType: EnumUserLicence): licenceType is ProfileBadgeLicence;
136
- declare const hasUserLicenceType: (authUser: SafeUserType | null, licenceType: EnumUserLicence) => boolean;
137
- declare const hasLicence: (authUser: SafeUserType | null, licenceType: "vendor" | "partner" | "event") => HasLicenceResult;
132
+ declare function isLicencedResourceType(resourceType: ResourceTypeEnum): resourceType is LicencedResourceType;
133
+ declare function isProfileBadgeLicence(licenceType: LicencesEnumType): licenceType is ProfileBadgeLicence;
134
+ declare const hasUserLicenceType: (authUser: UserType | null, licenceType: LicencesEnumType) => boolean;
135
+ declare const hasLicence: (authUser: UserType | null, licenceType: "vendor" | "partner" | "event") => HasLicenceResult;
138
136
  /** Default limits per subscription tier. */
139
137
  declare const DEFAULT_LIMITS: Record<LimitType, Record<Tier, number>>;
140
138
  /** All tiers off — used when the viewer does not own the resource. */
@@ -1,9 +1,17 @@
1
1
  "use client";
2
+ import {
3
+ USER_STORAGE_KEY
4
+ } from "../chunk-DWO35OY4.mjs";
5
+ import {
6
+ useGetUser,
7
+ useLogout
8
+ } from "../chunk-UKW7NZEQ.mjs";
2
9
  import {
3
10
  ADMIN_APP_ROLES,
4
11
  ADMIN_DASHBOARD_CONTEXTS,
5
12
  PERMISSIONS,
6
13
  ROLE_PERMISSIONS,
14
+ TIERS_BY_PRIORITY,
7
15
  WILDCARD_PERMISSION,
8
16
  canAccessAdminApp,
9
17
  canAccessAdminPath,
@@ -16,19 +24,10 @@ import {
16
24
  hasPermission,
17
25
  hasRole,
18
26
  permissionListIncludes,
19
- resolveAdminContextFromPath
20
- } from "../chunk-VPANTTZI.mjs";
21
- import {
22
- USER_STORAGE_KEY
23
- } from "../chunk-DWO35OY4.mjs";
24
- import {
25
- TIERS_BY_PRIORITY
26
- } from "../chunk-DQ7ZHIXW.mjs";
27
- import {
28
- useGetUser,
29
- useLogout
30
- } from "../chunk-32MKHJTX.mjs";
31
- import "../chunk-X3OLM35T.mjs";
27
+ resolveAdminContextFromPath,
28
+ toUserPermissions
29
+ } from "../chunk-DATBGC2K.mjs";
30
+ import "../chunk-INQCDU24.mjs";
32
31
 
33
32
  // src/auth/createAuthManager.ts
34
33
  function createAuthManager() {
@@ -65,10 +64,10 @@ function createAuthManager() {
65
64
 
66
65
  // src/auth/licenceUtils.ts
67
66
  function isLicencedResourceType(resourceType) {
68
- return resourceType !== "affiliate" /* AFFILIATE */ && resourceType !== "school" /* SCHOOL */;
67
+ return resourceType !== "affiliate" /* Affiliate */ && resourceType !== "school" /* School */;
69
68
  }
70
69
  function isProfileBadgeLicence(licenceType) {
71
- return licenceType !== "standard_affiliate" /* STANDARD_AFFILIATE */ && licenceType !== "standard_school" /* STANDARD_SCHOOL */;
70
+ return licenceType !== "standard_affiliate" /* StandardAffiliate */ && licenceType !== "standard_school" /* StandardSchool */;
72
71
  }
73
72
  var hasUserLicenceType = (authUser, licenceType) => authUser?.licences?.some((licence) => licence.licenceType === licenceType) ?? false;
74
73
  var hasLicence = (authUser, licenceType) => {
@@ -131,9 +130,9 @@ function getLicenceFlagsByRole(licences) {
131
130
  return result;
132
131
  }
133
132
  return {
134
- event: resolve("event" /* EVENT */),
135
- partner: resolve("partner" /* PARTNER */),
136
- vendor: resolve("vendor" /* VENDOR */)
133
+ event: resolve("event" /* Event */),
134
+ partner: resolve("partner" /* Partner */),
135
+ vendor: resolve("vendor" /* Vendor */)
137
136
  };
138
137
  }
139
138
 
@@ -182,12 +181,12 @@ function useAuthCore(adapters) {
182
181
  }, [authUser, handleSetAuthUser, onError, refetch]);
183
182
  const licences = useCallback(
184
183
  (resourceId) => {
185
- const myLicences = authUser?.licences?.map((licence) => licence.licenceType) ?? [];
184
+ const myLicences = authUser?.licences?.map((licence) => licence.licenceType).filter((type) => type != null) ?? [];
186
185
  const myResourceIds = [
187
186
  authUser?.vendor ?? null,
188
187
  authUser?.partner ?? null,
189
188
  ...authUser?.events ?? []
190
- ].filter((id) => id !== null);
189
+ ].filter((id) => id != null);
191
190
  return myResourceIds.includes(resourceId) ? getLicenceFlagsByRole(myLicences) : NO_LICENCE_FLAGS;
192
191
  },
193
192
  [authUser]
@@ -226,7 +225,7 @@ function useAuthCore(adapters) {
226
225
  );
227
226
  const permissions = useMemo(() => {
228
227
  if (authUser?.permissions != null) {
229
- return authUser.permissions;
228
+ return toUserPermissions(authUser.permissions);
230
229
  }
231
230
  return getPermissionsForRoles(authUser?.roles);
232
231
  }, [authUser?.permissions, authUser?.roles]);
@@ -239,19 +238,19 @@ function useAuthCore(adapters) {
239
238
  [authUser?.roles]
240
239
  );
241
240
  const isAdmin = useMemo(
242
- () => hasRole(authUser?.roles, "admin" /* ADMIN */) || permissionListIncludes(permissions, "dashboard.admin") || permissionListIncludes(permissions, "*"),
241
+ () => hasRole(authUser?.roles, "admin" /* Admin */) || permissionListIncludes(permissions, "dashboard.admin") || permissionListIncludes(permissions, "*"),
243
242
  [authUser?.roles, permissions]
244
243
  );
245
244
  const isSuperAdmin = useMemo(
246
- () => hasRole(authUser?.roles, "super_admin" /* SUPER_ADMIN */),
245
+ () => hasRole(authUser?.roles, "super_admin" /* SuperAdmin */),
247
246
  [authUser?.roles]
248
247
  );
249
248
  const isAffiliate = useMemo(
250
- () => hasRole(authUser?.roles, "affiliate" /* AFFILIATE */) && authUser?.affiliate !== null && authUser?.affiliate !== void 0,
249
+ () => hasRole(authUser?.roles, "affiliate" /* Affiliate */) && authUser?.affiliate !== null && authUser?.affiliate !== void 0,
251
250
  [authUser?.roles, authUser?.affiliate]
252
251
  );
253
252
  const isSchool = useMemo(
254
- () => hasRole(authUser?.roles, "school" /* SCHOOL */) && authUser?.school !== null && authUser?.school !== void 0,
253
+ () => hasRole(authUser?.roles, "school" /* School */) && authUser?.school !== null && authUser?.school !== void 0,
255
254
  [authUser?.roles, authUser?.school]
256
255
  );
257
256
  useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/auth/createAuthManager.ts","../../src/auth/licenceUtils.ts","../../src/auth/useAuthCore.ts","../../src/auth/UserProvider.tsx"],"sourcesContent":["export type AuthManager = {\n logout: () => Promise<void>;\n setLogout: (fn: () => Promise<void>) => void;\n handleRefetchUser: () => Promise<void>;\n setUserRefetch: (fn: () => Promise<void>) => void;\n};\n\n/**\n * Creates an auth manager used by Apollo error links to trigger logout/refetch\n * without importing React. Matches the former mobile authManager shape.\n *\n * `logout()` dedupes concurrent calls via an in-flight promise so token-refresh\n * failures do not kick off multiple logout sequences.\n */\nexport function createAuthManager(): AuthManager {\n let logoutFn: (() => Promise<void>) | null = null;\n let userRefetchFn: (() => Promise<void>) | null = null;\n let logoutPromise: Promise<void> | null = null;\n\n return {\n handleRefetchUser: async () => {\n if (userRefetchFn) {\n await userRefetchFn();\n } else {\n console.warn(\"❌ User refetch function not set!\");\n }\n },\n logout(): Promise<void> {\n if (logoutPromise !== null) return logoutPromise;\n if (logoutFn === null) {\n console.warn(\"❌ Logout function not set!\");\n return Promise.resolve();\n }\n logoutPromise = logoutFn().finally(() => {\n logoutPromise = null;\n });\n return logoutPromise;\n },\n setLogout(fn: () => Promise<void>) {\n logoutFn = fn;\n },\n setUserRefetch(fn: () => Promise<void>) {\n userRefetchFn = fn;\n },\n };\n}\n","/* eslint-disable camelcase */\nimport { EnumResourceType, EnumUserLicence } from \"../enums\";\nimport type { SafeUserType } from \"../types\";\nimport { TIERS_BY_PRIORITY, type Tier } from \"../types/subscription\";\n\nimport type {\n HasLicenceResult,\n LicencedResourceType,\n LicencesByRole,\n LimitType,\n ProfileBadgeLicence,\n RoleLicences,\n} from \"./types\";\n\nexport function isLicencedResourceType(\n resourceType: EnumResourceType,\n): resourceType is LicencedResourceType {\n return (\n resourceType !== EnumResourceType.AFFILIATE &&\n resourceType !== EnumResourceType.SCHOOL\n );\n}\n\nexport function isProfileBadgeLicence(\n licenceType: EnumUserLicence,\n): licenceType is ProfileBadgeLicence {\n return (\n licenceType !== EnumUserLicence.STANDARD_AFFILIATE &&\n licenceType !== EnumUserLicence.STANDARD_SCHOOL\n );\n}\n\nexport const hasUserLicenceType = (\n authUser: SafeUserType | null,\n licenceType: EnumUserLicence,\n): boolean =>\n authUser?.licences?.some((licence) => licence.licenceType === licenceType) ??\n false;\n\nexport const hasLicence = (\n authUser: SafeUserType | null,\n licenceType: \"vendor\" | \"partner\" | \"event\",\n): HasLicenceResult => {\n const directLicence =\n authUser?.licences?.some((licence) =>\n licence.licenceType?.includes(licenceType),\n ) ?? false;\n\n return {\n directLicence,\n };\n};\n\n/** Default limits per subscription tier. */\nexport const DEFAULT_LIMITS: Record<LimitType, Record<Tier, number>> = {\n // 1 means calendar/productMenu is enabled, 0 means disabled\n availability: { pro: 1, pro_plus: 1, standard: 0 },\n calendar: { pro: 1, pro_plus: 1, standard: 0 },\n images: { pro: 12, pro_plus: 12, standard: 6 },\n posters: { pro: 5, pro_plus: 5, standard: 5 },\n productsList: { pro: 1, pro_plus: 1, standard: 0 },\n relationShare: { pro: 1, pro_plus: 1, standard: 0 },\n statistics: { pro: 1, pro_plus: 1, standard: 0 },\n};\n\n/** All tiers off — used when the viewer does not own the resource. */\nexport const NO_LICENCE_FLAGS: LicencesByRole = {\n event: {\n pro_plus: false,\n // eslint-disable-next-line sort-keys\n pro: false,\n standard: false,\n },\n partner: {\n pro_plus: false,\n // eslint-disable-next-line sort-keys\n pro: false,\n standard: false,\n },\n vendor: {\n pro_plus: false,\n // eslint-disable-next-line sort-keys\n pro: false,\n standard: false,\n },\n};\n\n/**\n * Parses an array of licence strings into structured, role-based licences.\n * Users with no licences yet default to pro (create / trial access).\n */\nexport function getLicenceFlagsByRole(licences?: string[]): LicencesByRole {\n const normalized = licences?.map((l) => l.toLowerCase()) ?? [];\n const hasAnyLicence = normalized.length > 0;\n\n function resolve(role: EnumResourceType): RoleLicences {\n const result: RoleLicences = {\n pro_plus: false,\n // eslint-disable-next-line sort-keys\n pro: false,\n standard: false,\n };\n\n for (const tier of TIERS_BY_PRIORITY) {\n if (normalized.some((l) => l.startsWith(`${tier}_${role}`))) {\n result[tier] = true;\n break; // stop at first match → ensures mutual exclusivity\n }\n }\n\n // No licences at all → grant pro so new users can use pro features\n if (!hasAnyLicence) {\n result.pro = true;\n }\n\n return result;\n }\n\n return {\n event: resolve(EnumResourceType.EVENT),\n partner: resolve(EnumResourceType.PARTNER),\n vendor: resolve(EnumResourceType.VENDOR),\n };\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\n\nimport { EnumResourceType, EnumUserLicence, EnumUserRole } from \"../enums\";\nimport { useLogout } from \"../graphql/hooks/auth\";\nimport { useGetUser } from \"../graphql/hooks/user/hooksQuery\";\nimport { USER_STORAGE_KEY } from \"../storage\";\nimport type { SafeUserType } from \"../types\";\n\nimport {\n DEFAULT_LIMITS,\n getLicenceFlagsByRole,\n hasLicence,\n hasUserLicenceType,\n isLicencedResourceType,\n NO_LICENCE_FLAGS,\n} from \"./licenceUtils\";\nimport {\n getPermissionsForRoles,\n hasRole as roleHasRole,\n permissionListIncludes,\n} from \"./permissions\";\nimport type { Permission } from \"./permissions\";\nimport type {\n LimitType,\n LogoutReason,\n UseAuthCoreAdapters,\n UseAuthReturnType,\n} from \"./types\";\n\n/**\n * Platform-agnostic auth session core (source of truth for shared useAuth).\n *\n * Owns: persisted user load/set, refetch, role/licence flags, logout orchestration.\n * Does not own: AsyncStorage vs localStorage, Expo/Next navigation, toasts,\n * Apollo/WS reset, Firebase — those stay in each app's adapter wrapper.\n */\nexport function useAuthCore(adapters: UseAuthCoreAdapters): UseAuthReturnType {\n const {\n storage,\n authManager,\n afterLogout,\n shouldCallLogoutMutation = () => true,\n notifyLogoutSuccess,\n notifySessionExpired,\n onError,\n } = adapters;\n\n const [authUser, setAuthUser] = useState<SafeUserType | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n\n const userId = useMemo(() => authUser?._id ?? \"\", [authUser?._id]);\n const { refetch } = useGetUser(userId);\n const { logout, loading } = useLogout();\n\n const handleSetAuthUser = useCallback(\n async (user: SafeUserType | null) => {\n setAuthUser(user);\n if (user) {\n await storage.setItem(USER_STORAGE_KEY, JSON.stringify(user));\n } else {\n await storage.removeItem(USER_STORAGE_KEY);\n }\n },\n [storage],\n );\n\n const handleRefetchUser = useCallback(async () => {\n if (!authUser) return;\n try {\n const result = await refetch();\n if (!result) return;\n const { data } = result;\n if (data?.user) await handleSetAuthUser(data.user);\n } catch (error: unknown) {\n onError?.(error, { action: \"refetchUser\" });\n console.warn(\n \"Failed to refetch user:\",\n error instanceof Error ? error.message : error,\n );\n }\n }, [authUser, handleSetAuthUser, onError, refetch]);\n\n const licences = useCallback(\n (resourceId: string) => {\n const myLicences =\n authUser?.licences?.map((licence) => licence.licenceType) ?? [];\n\n const myResourceIds = [\n authUser?.vendor ?? null,\n authUser?.partner ?? null,\n ...(authUser?.events ?? []),\n ].filter((id): id is string => id !== null);\n\n return myResourceIds.includes(resourceId)\n ? getLicenceFlagsByRole(myLicences)\n : NO_LICENCE_FLAGS;\n },\n [authUser],\n );\n\n const getLicenseAccessLevel = useCallback(\n (\n limitType: LimitType,\n resourceId: string,\n resourceType: EnumResourceType,\n ): number => {\n if (!isLicencedResourceType(resourceType)) {\n return 0;\n }\n\n // No resource yet (e.g. create flow): grant pro limits.\n if (resourceId === \"\") {\n return DEFAULT_LIMITS[limitType].pro;\n }\n\n const roleLicences = licences(resourceId)[resourceType];\n\n if (roleLicences.pro_plus) return DEFAULT_LIMITS[limitType].pro_plus;\n if (roleLicences.pro) return DEFAULT_LIMITS[limitType].pro;\n if (roleLicences.standard) return DEFAULT_LIMITS[limitType].standard;\n\n return 0;\n },\n [licences],\n );\n\n const hasVendorLicence = useMemo(\n () => hasLicence(authUser, \"vendor\"),\n [authUser],\n );\n\n const hasPartnerLicence = useMemo(\n () => hasLicence(authUser, \"partner\"),\n [authUser],\n );\n\n const hasEventLicence = useMemo(\n () => hasLicence(authUser, \"event\"),\n [authUser],\n );\n\n const hasUserLicence = useCallback(\n (licenceType: EnumUserLicence) => hasUserLicenceType(authUser, licenceType),\n [authUser],\n );\n\n const permissions = useMemo(() => {\n if (authUser?.permissions != null) {\n return authUser.permissions;\n }\n return getPermissionsForRoles(authUser?.roles);\n }, [authUser?.permissions, authUser?.roles]);\n\n const hasPermissionFn = useCallback(\n (permission: Permission) => permissionListIncludes(permissions, permission),\n [permissions],\n );\n\n const hasRoleFn = useCallback(\n (role: EnumUserRole) => roleHasRole(authUser?.roles, role),\n [authUser?.roles],\n );\n\n const isAdmin = useMemo(\n () =>\n roleHasRole(authUser?.roles, EnumUserRole.ADMIN) ||\n permissionListIncludes(permissions, \"dashboard.admin\") ||\n permissionListIncludes(permissions, \"*\"),\n [authUser?.roles, permissions],\n );\n\n const isSuperAdmin = useMemo(\n () => roleHasRole(authUser?.roles, EnumUserRole.SUPER_ADMIN),\n [authUser?.roles],\n );\n\n const isAffiliate = useMemo(\n () =>\n roleHasRole(authUser?.roles, EnumUserRole.AFFILIATE) &&\n authUser?.affiliate !== null &&\n authUser?.affiliate !== undefined,\n [authUser?.roles, authUser?.affiliate],\n );\n\n const isSchool = useMemo(\n () =>\n roleHasRole(authUser?.roles, EnumUserRole.SCHOOL) &&\n authUser?.school !== null &&\n authUser?.school !== undefined,\n [authUser?.roles, authUser?.school],\n );\n\n // Mount-only hydrate from storage. Do not re-run when adapter identities\n // change — that can overwrite a newer in-memory user (e.g. post-login setUser).\n useEffect(() => {\n const loadUser = async () => {\n try {\n const userJson = await storage.getItem(USER_STORAGE_KEY);\n await handleSetAuthUser(userJson ? JSON.parse(userJson) : null);\n } catch (error: unknown) {\n onError?.(error, { action: \"loadUserFromStorage\" });\n console.error(\"Failed to load user from storage:\", error);\n } finally {\n setIsLoading(false);\n }\n };\n\n void loadUser();\n }, []);\n\n const logoutWithReason = useCallback(\n async (reason: LogoutReason) => {\n try {\n if (shouldCallLogoutMutation(reason)) {\n try {\n const result = await logout();\n const message = result?.data?.logout?.message as string | undefined;\n if (message) {\n notifyLogoutSuccess?.(message);\n }\n } catch (err: unknown) {\n onError?.(err, { action: \"logout\" });\n console.warn(\"Logout request failed (ignored):\", err);\n }\n }\n } finally {\n await afterLogout(reason);\n setAuthUser(null);\n await storage.removeItem(USER_STORAGE_KEY);\n }\n },\n [\n afterLogout,\n logout,\n notifyLogoutSuccess,\n onError,\n shouldCallLogoutMutation,\n storage,\n ],\n );\n\n const handleLogoutExplicit = useCallback(\n () => logoutWithReason(\"manual\"),\n [logoutWithReason],\n );\n\n const handleLogoutExpired = useCallback(async () => {\n const hadSession = authUser != null;\n if (!hadSession) return;\n await logoutWithReason(\"expired\");\n notifySessionExpired?.();\n }, [authUser, logoutWithReason, notifySessionExpired]);\n\n useEffect(() => {\n authManager.setLogout(() => handleLogoutExpired());\n authManager.setUserRefetch(() => handleRefetchUser());\n }, [authManager, handleLogoutExpired, handleRefetchUser]);\n\n return {\n authUser,\n getLicenseAccessLevel,\n handleLogoutExplicit,\n hasEventLicence,\n hasPartnerLicence,\n hasPermission: hasPermissionFn,\n hasRole: hasRoleFn,\n hasUserLicence,\n hasVendorLicence,\n isAdmin,\n isAffiliate,\n isLoading: loading || isLoading,\n isSchool,\n isSuperAdmin,\n permissions,\n refetchUser: handleRefetchUser,\n setUser: handleSetAuthUser,\n };\n}\n","/**\n * Shared React context for auth session state.\n *\n * Apps keep a thin local UserProvider that calls their platform `useAuth`\n * (adapters) and pass the result here as `value`. Import `useAuthUser` from\n * this module (or re-export it) so consumers share one context instance.\n *\n * `\"use client\"`: required for Next.js; ignored by React Native.\n */\n\"use client\";\n\nimport React, { createContext, useContext, type ReactNode } from \"react\";\n\nimport type { UseAuthReturnType } from \"./types\";\n\nconst UserContext = createContext<UseAuthReturnType | undefined>(undefined);\n\n/**\n * Provides auth session value from the app's thin useAuth wrapper.\n */\nexport const UserProvider: React.FC<{\n children: ReactNode;\n value: UseAuthReturnType;\n}> = ({ children, value }) => {\n return <UserContext.Provider value={value}>{children}</UserContext.Provider>;\n};\n\nexport const useAuthUser = (): UseAuthReturnType => {\n const context = useContext(UserContext);\n if (!context) {\n throw new Error(\"useAuthUser must be used within a UserProvider\");\n }\n return context;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcO,SAAS,oBAAiC;AAC/C,MAAI,WAAyC;AAC7C,MAAI,gBAA8C;AAClD,MAAI,gBAAsC;AAE1C,SAAO;AAAA,IACL,mBAAmB,YAAY;AAC7B,UAAI,eAAe;AACjB,cAAM,cAAc;AAAA,MACtB,OAAO;AACL,gBAAQ,KAAK,uCAAkC;AAAA,MACjD;AAAA,IACF;AAAA,IACA,SAAwB;AACtB,UAAI,kBAAkB,KAAM,QAAO;AACnC,UAAI,aAAa,MAAM;AACrB,gBAAQ,KAAK,iCAA4B;AACzC,eAAO,QAAQ,QAAQ;AAAA,MACzB;AACA,sBAAgB,SAAS,EAAE,QAAQ,MAAM;AACvC,wBAAgB;AAAA,MAClB,CAAC;AACD,aAAO;AAAA,IACT;AAAA,IACA,UAAU,IAAyB;AACjC,iBAAW;AAAA,IACb;AAAA,IACA,eAAe,IAAyB;AACtC,sBAAgB;AAAA,IAClB;AAAA,EACF;AACF;;;AC/BO,SAAS,uBACd,cACsC;AACtC,SACE,gDACA;AAEJ;AAEO,SAAS,sBACd,aACoC;AACpC,SACE,iEACA;AAEJ;AAEO,IAAM,qBAAqB,CAChC,UACA,gBAEA,UAAU,UAAU,KAAK,CAAC,YAAY,QAAQ,gBAAgB,WAAW,KACzE;AAEK,IAAM,aAAa,CACxB,UACA,gBACqB;AACrB,QAAM,gBACJ,UAAU,UAAU;AAAA,IAAK,CAAC,YACxB,QAAQ,aAAa,SAAS,WAAW;AAAA,EAC3C,KAAK;AAEP,SAAO;AAAA,IACL;AAAA,E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AAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,SAAS;AAAA,EACX;AACF;;;AC1QA,SAAgB,eAAe,kBAAkC;AAaxD;AATT,IAAM,cAAc,cAA6C,MAAS;AAKnE,IAAM,eAGR,CAAC,EAAE,UAAU,MAAM,MAAM;AAC5B,SAAO,oBAAC,YAAY,UAAZ,EAAqB,OAAe,UAAS;AACvD;AAEO,IAAM,cAAc,MAAyB;AAClD,QAAM,UAAU,WAAW,WAAW;AACtC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,gDAAgD;AAAA,EAClE;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/auth/createAuthManager.ts","../../src/auth/licenceUtils.ts","../../src/auth/useAuthCore.ts","../../src/auth/UserProvider.tsx"],"sourcesContent":["export type AuthManager = {\n logout: () => Promise<void>;\n setLogout: (fn: () => Promise<void>) => void;\n handleRefetchUser: () => Promise<void>;\n setUserRefetch: (fn: () => Promise<void>) => void;\n};\n\n/**\n * Creates an auth manager used by Apollo error links to trigger logout/refetch\n * without importing React. Matches the former mobile authManager shape.\n *\n * `logout()` dedupes concurrent calls via an in-flight promise so token-refresh\n * failures do not kick off multiple logout sequences.\n */\nexport function createAuthManager(): AuthManager {\n let logoutFn: (() => Promise<void>) | null = null;\n let userRefetchFn: (() => Promise<void>) | null = null;\n let logoutPromise: Promise<void> | null = null;\n\n return {\n handleRefetchUser: async () => {\n if (userRefetchFn) {\n await userRefetchFn();\n } else {\n console.warn(\"❌ User refetch function not set!\");\n }\n },\n logout(): Promise<void> {\n if (logoutPromise !== null) return logoutPromise;\n if (logoutFn === null) {\n console.warn(\"❌ Logout function not set!\");\n return Promise.resolve();\n }\n logoutPromise = logoutFn().finally(() => {\n logoutPromise = null;\n });\n return logoutPromise;\n },\n setLogout(fn: () => Promise<void>) {\n logoutFn = fn;\n },\n setUserRefetch(fn: () => Promise<void>) {\n userRefetchFn = fn;\n },\n };\n}\n","/* eslint-disable camelcase */\nimport { ResourceTypeEnum, LicencesEnumType } from \"../generated/graphql\";\nimport type { SafeUserType } from \"../types\";\nimport { TIERS_BY_PRIORITY, type Tier } from \"../types/subscription\";\n\nimport type {\n HasLicenceResult,\n LicencedResourceType,\n LicencesByRole,\n LimitType,\n ProfileBadgeLicence,\n RoleLicences,\n} from \"./types\";\n\nexport function isLicencedResourceType(\n resourceType: ResourceTypeEnum,\n): resourceType is LicencedResourceType {\n return (\n resourceType !== ResourceTypeEnum.Affiliate &&\n resourceType !== ResourceTypeEnum.School\n );\n}\n\nexport function isProfileBadgeLicence(\n licenceType: LicencesEnumType,\n): licenceType is ProfileBadgeLicence {\n return (\n licenceType !== LicencesEnumType.StandardAffiliate &&\n licenceType !== LicencesEnumType.StandardSchool\n );\n}\n\nexport const hasUserLicenceType = (\n authUser: SafeUserType | null,\n licenceType: LicencesEnumType,\n): boolean =>\n authUser?.licences?.some((licence) => licence.licenceType === licenceType) ??\n false;\n\nexport const hasLicence = (\n authUser: SafeUserType | null,\n licenceType: \"vendor\" | \"partner\" | \"event\",\n): HasLicenceResult => {\n const directLicence =\n authUser?.licences?.some((licence) =>\n licence.licenceType?.includes(licenceType),\n ) ?? false;\n\n return {\n directLicence,\n };\n};\n\n/** Default limits per subscription tier. */\nexport const DEFAULT_LIMITS: Record<LimitType, Record<Tier, number>> = {\n // 1 means calendar/productMenu is enabled, 0 means disabled\n availability: { pro: 1, pro_plus: 1, standard: 0 },\n calendar: { pro: 1, pro_plus: 1, standard: 0 },\n images: { pro: 12, pro_plus: 12, standard: 6 },\n posters: { pro: 5, pro_plus: 5, standard: 5 },\n productsList: { pro: 1, pro_plus: 1, standard: 0 },\n relationShare: { pro: 1, pro_plus: 1, standard: 0 },\n statistics: { pro: 1, pro_plus: 1, standard: 0 },\n};\n\n/** All tiers off — used when the viewer does not own the resource. */\nexport const NO_LICENCE_FLAGS: LicencesByRole = {\n event: {\n pro_plus: false,\n // eslint-disable-next-line sort-keys\n pro: false,\n standard: false,\n },\n partner: {\n pro_plus: false,\n // eslint-disable-next-line sort-keys\n pro: false,\n standard: false,\n },\n vendor: {\n pro_plus: false,\n // eslint-disable-next-line sort-keys\n pro: false,\n standard: false,\n },\n};\n\n/**\n * Parses an array of licence strings into structured, role-based licences.\n * Users with no licences yet default to pro (create / trial access).\n */\nexport function getLicenceFlagsByRole(licences?: string[]): LicencesByRole {\n const normalized = licences?.map((l) => l.toLowerCase()) ?? [];\n const hasAnyLicence = normalized.length > 0;\n\n function resolve(role: ResourceTypeEnum): RoleLicences {\n const result: RoleLicences = {\n pro_plus: false,\n // eslint-disable-next-line sort-keys\n pro: false,\n standard: false,\n };\n\n for (const tier of TIERS_BY_PRIORITY) {\n if (normalized.some((l) => l.startsWith(`${tier}_${role}`))) {\n result[tier] = true;\n break; // stop at first match → ensures mutual exclusivity\n }\n }\n\n // No licences at all → grant pro so new users can use pro features\n if (!hasAnyLicence) {\n result.pro = true;\n }\n\n return result;\n }\n\n return {\n event: resolve(ResourceTypeEnum.Event),\n partner: resolve(ResourceTypeEnum.Partner),\n vendor: resolve(ResourceTypeEnum.Vendor),\n };\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\n\nimport {\n ResourceTypeEnum,\n LicencesEnumType,\n UserRoleEnumType,\n} from \"../generated/graphql\";\nimport { useLogout } from \"../graphql/hooks/auth\";\nimport { useGetUser } from \"../graphql/hooks/user/hooksQuery\";\nimport { USER_STORAGE_KEY } from \"../storage\";\nimport type { SafeUserType } from \"../types\";\nimport { toUserPermissions } from \"../types/userAdapters\";\n\nimport {\n DEFAULT_LIMITS,\n getLicenceFlagsByRole,\n hasLicence,\n hasUserLicenceType,\n isLicencedResourceType,\n NO_LICENCE_FLAGS,\n} from \"./licenceUtils\";\nimport {\n getPermissionsForRoles,\n hasRole as roleHasRole,\n permissionListIncludes,\n} from \"./permissions\";\nimport type { Permission } from \"./permissions\";\nimport type {\n LimitType,\n LogoutReason,\n UseAuthCoreAdapters,\n UseAuthReturnType,\n} from \"./types\";\n\n/**\n * Platform-agnostic auth session core (source of truth for shared useAuth).\n *\n * Owns: persisted user load/set, refetch, role/licence flags, logout orchestration.\n * Does not own: AsyncStorage vs localStorage, Expo/Next navigation, toasts,\n * Apollo/WS reset, Firebase — those stay in each app's adapter wrapper.\n */\nexport function useAuthCore(adapters: UseAuthCoreAdapters): UseAuthReturnType {\n const {\n storage,\n authManager,\n afterLogout,\n shouldCallLogoutMutation = () => true,\n notifyLogoutSuccess,\n notifySessionExpired,\n onError,\n } = adapters;\n\n const [authUser, setAuthUser] = useState<SafeUserType | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n\n const userId = useMemo(() => authUser?._id ?? \"\", [authUser?._id]);\n const { refetch } = useGetUser(userId);\n const { logout, loading } = useLogout();\n\n const handleSetAuthUser = useCallback(\n async (user: SafeUserType | null) => {\n setAuthUser(user);\n if (user) {\n await storage.setItem(USER_STORAGE_KEY, JSON.stringify(user));\n } else {\n await storage.removeItem(USER_STORAGE_KEY);\n }\n },\n [storage],\n );\n\n const handleRefetchUser = useCallback(async () => {\n if (!authUser) return;\n try {\n const result = await refetch();\n if (!result) return;\n const { data } = result;\n if (data?.user) await handleSetAuthUser(data.user);\n } catch (error: unknown) {\n onError?.(error, { action: \"refetchUser\" });\n console.warn(\n \"Failed to refetch user:\",\n error instanceof Error ? error.message : error,\n );\n }\n }, [authUser, handleSetAuthUser, onError, refetch]);\n\n const licences = useCallback(\n (resourceId: string) => {\n const myLicences =\n authUser?.licences\n ?.map((licence) => licence.licenceType)\n .filter((type): type is LicencesEnumType => type != null) ?? [];\n\n const myResourceIds = [\n authUser?.vendor ?? null,\n authUser?.partner ?? null,\n ...(authUser?.events ?? []),\n ].filter((id): id is string => id != null);\n\n return myResourceIds.includes(resourceId)\n ? getLicenceFlagsByRole(myLicences)\n : NO_LICENCE_FLAGS;\n },\n [authUser],\n );\n\n const getLicenseAccessLevel = useCallback(\n (\n limitType: LimitType,\n resourceId: string,\n resourceType: ResourceTypeEnum,\n ): number => {\n if (!isLicencedResourceType(resourceType)) {\n return 0;\n }\n\n // No resource yet (e.g. create flow): grant pro limits.\n if (resourceId === \"\") {\n return DEFAULT_LIMITS[limitType].pro;\n }\n\n const roleLicences = licences(resourceId)[resourceType];\n\n if (roleLicences.pro_plus) return DEFAULT_LIMITS[limitType].pro_plus;\n if (roleLicences.pro) return DEFAULT_LIMITS[limitType].pro;\n if (roleLicences.standard) return DEFAULT_LIMITS[limitType].standard;\n\n return 0;\n },\n [licences],\n );\n\n const hasVendorLicence = useMemo(\n () => hasLicence(authUser, \"vendor\"),\n [authUser],\n );\n\n const hasPartnerLicence = useMemo(\n () => hasLicence(authUser, \"partner\"),\n [authUser],\n );\n\n const hasEventLicence = useMemo(\n () => hasLicence(authUser, \"event\"),\n [authUser],\n );\n\n const hasUserLicence = useCallback(\n (licenceType: LicencesEnumType) =>\n hasUserLicenceType(authUser, licenceType),\n [authUser],\n );\n\n const permissions = useMemo(() => {\n if (authUser?.permissions != null) {\n return toUserPermissions(authUser.permissions);\n }\n return getPermissionsForRoles(authUser?.roles);\n }, [authUser?.permissions, authUser?.roles]);\n\n const hasPermissionFn = useCallback(\n (permission: Permission) => permissionListIncludes(permissions, permission),\n [permissions],\n );\n\n const hasRoleFn = useCallback(\n (role: UserRoleEnumType) => roleHasRole(authUser?.roles, role),\n [authUser?.roles],\n );\n\n const isAdmin = useMemo(\n () =>\n roleHasRole(authUser?.roles, UserRoleEnumType.Admin) ||\n permissionListIncludes(permissions, \"dashboard.admin\") ||\n permissionListIncludes(permissions, \"*\"),\n [authUser?.roles, permissions],\n );\n\n const isSuperAdmin = useMemo(\n () => roleHasRole(authUser?.roles, UserRoleEnumType.SuperAdmin),\n [authUser?.roles],\n );\n\n const isAffiliate = useMemo(\n () =>\n roleHasRole(authUser?.roles, UserRoleEnumType.Affiliate) &&\n authUser?.affiliate !== null &&\n authUser?.affiliate !== undefined,\n [authUser?.roles, authUser?.affiliate],\n );\n\n const isSchool = useMemo(\n () =>\n roleHasRole(authUser?.roles, UserRoleEnumType.School) &&\n authUser?.school !== null &&\n authUser?.school !== undefined,\n [authUser?.roles, authUser?.school],\n );\n\n // Mount-only hydrate from storage. Do not re-run when adapter identities\n // change — that can overwrite a newer in-memory user (e.g. post-login setUser).\n useEffect(() => {\n const loadUser = async () => {\n try {\n const userJson = await storage.getItem(USER_STORAGE_KEY);\n await handleSetAuthUser(userJson ? JSON.parse(userJson) : null);\n } catch (error: unknown) {\n onError?.(error, { action: \"loadUserFromStorage\" });\n console.error(\"Failed to load user from storage:\", error);\n } finally {\n setIsLoading(false);\n }\n };\n\n void loadUser();\n }, []);\n\n const logoutWithReason = useCallback(\n async (reason: LogoutReason) => {\n try {\n if (shouldCallLogoutMutation(reason)) {\n try {\n const result = await logout();\n const message = result?.data?.logout?.message as string | undefined;\n if (message) {\n notifyLogoutSuccess?.(message);\n }\n } catch (err: unknown) {\n onError?.(err, { action: \"logout\" });\n console.warn(\"Logout request failed (ignored):\", err);\n }\n }\n } finally {\n await afterLogout(reason);\n setAuthUser(null);\n await storage.removeItem(USER_STORAGE_KEY);\n }\n },\n [\n afterLogout,\n logout,\n notifyLogoutSuccess,\n onError,\n shouldCallLogoutMutation,\n storage,\n ],\n );\n\n const handleLogoutExplicit = useCallback(\n () => logoutWithReason(\"manual\"),\n [logoutWithReason],\n );\n\n const handleLogoutExpired = useCallback(async () => {\n const hadSession = authUser != null;\n if (!hadSession) return;\n await logoutWithReason(\"expired\");\n notifySessionExpired?.();\n }, [authUser, logoutWithReason, notifySessionExpired]);\n\n useEffect(() => {\n authManager.setLogout(() => handleLogoutExpired());\n authManager.setUserRefetch(() => handleRefetchUser());\n }, [authManager, handleLogoutExpired, handleRefetchUser]);\n\n return {\n authUser,\n getLicenseAccessLevel,\n handleLogoutExplicit,\n hasEventLicence,\n hasPartnerLicence,\n hasPermission: hasPermissionFn,\n hasRole: hasRoleFn,\n hasUserLicence,\n hasVendorLicence,\n isAdmin,\n isAffiliate,\n isLoading: loading || isLoading,\n isSchool,\n isSuperAdmin,\n permissions,\n refetchUser: handleRefetchUser,\n setUser: handleSetAuthUser,\n };\n}\n","/**\n * Shared React context for auth session state.\n *\n * Apps keep a thin local UserProvider that calls their platform `useAuth`\n * (adapters) and pass the result here as `value`. Import `useAuthUser` from\n * this module (or re-export it) so consumers share one context instance.\n *\n * `\"use client\"`: required for Next.js; ignored by React Native.\n */\n\"use client\";\n\nimport React, { createContext, useContext, type ReactNode } from \"react\";\n\nimport type { UseAuthReturnType } from \"./types\";\n\nconst UserContext = createContext<UseAuthReturnType | undefined>(undefined);\n\n/**\n * Provides auth session value from the app's thin useAuth wrapper.\n */\nexport const UserProvider: React.FC<{\n children: ReactNode;\n value: UseAuthReturnType;\n}> = ({ children, value }) => {\n return <UserContext.Provider value={value}>{children}</UserContext.Provider>;\n};\n\nexport const useAuthUser = (): UseAuthReturnType => {\n const context = useContext(UserContext);\n if (!context) {\n throw new Error(\"useAuthUser must be used within a UserProvider\");\n }\n return context;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcO,SAAS,oBAAiC;AAC/C,MAAI,WAAyC;AAC7C,MAAI,gBAA8C;AAClD,MAAI,gBAAsC;AAE1C,SAAO;AAAA,IACL,mBAAmB,YAAY;AAC7B,UAAI,eAAe;AACjB,cAAM,cAAc;AAAA,MACtB,OAAO;AACL,gBAAQ,KAAK,uCAAkC;AAAA,MACjD;AAAA,IACF;AAAA,IACA,SAAwB;AACtB,UAAI,kBAAkB,KAAM,QAAO;AACnC,UAAI,aAAa,MAAM;AACrB,gBAAQ,KAAK,iCAA4B;AACzC,eAAO,QAAQ,QAAQ;AAAA,MACzB;AACA,sBAAgB,SAAS,EAAE,QAAQ,MAAM;AACvC,wBAAgB;AAAA,MAClB,CAAC;AACD,aAAO;AAAA,IACT;AAAA,IACA,UAAU,IAAyB;AACjC,iBAAW;AAAA,IACb;AAAA,IACA,eAAe,IAAyB;AACtC,sBAAgB;AAAA,IAClB;AAAA,EACF;AACF;;;AC/BO,S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2BAAuB;AAAA,EACzB,GAAG,CAAC,UAAU,kBAAkB,oBAAoB,CAAC;AAErD,YAAU,MAAM;AACd,gBAAY,UAAU,MAAM,oBAAoB,CAAC;AACjD,gBAAY,eAAe,MAAM,kBAAkB,CAAC;AAAA,EACtD,GAAG,CAAC,aAAa,qBAAqB,iBAAiB,CAAC;AAExD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW,WAAW;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,SAAS;AAAA,EACX;AACF;;;AClRA,SAAgB,eAAe,kBAAkC;AAaxD;AATT,IAAM,cAAc,cAA6C,MAAS;AAKnE,IAAM,eAGR,CAAC,EAAE,UAAU,MAAM,MAAM;AAC5B,SAAO,oBAAC,YAAY,UAAZ,EAAqB,OAAe,UAAS;AACvD;AAEO,IAAM,cAAc,MAAyB;AAClD,QAAM,UAAU,WAAW,WAAW;AACtC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,gDAAgD;AAAA,EAClE;AACA,SAAO;AACT;","names":[]}
@@ -0,0 +1,169 @@
1
+ import { h as SubscriptionStatusEnumType, e as LicencesEnumType, i as RedeemRewardResponseType, R as ResourceImageType, L as LocationType, O as OsPlatformEnumType, j as RewardEnumType, D as DateTimeType, N as NotificationResourceEnumType, U as UserRoleEnumType, k as AuthPayloadType, l as RefreshTokenPayloadType, m as VerificationEnumType } from './graphql-CDOfA79A.js';
2
+ import { M as MutationResponse, T as TermsAgreement, a as CreateFormData, U as UserLicenceType, P as PromoCodeType } from './global-BbSFfYdd.js';
3
+
4
+ type UserFormData = {
5
+ _id?: string;
6
+ active: boolean;
7
+ avatar?: ResourceImageType | null;
8
+ avatarUpload?: ResourceImageType | null;
9
+ confirmPassword?: string | null;
10
+ email: string;
11
+ firstName: string;
12
+ isTester: boolean;
13
+ lastName: string;
14
+ location?: LocationType | null;
15
+ password?: string | null;
16
+ platform?: OsPlatformEnumType;
17
+ preferredRegion: string;
18
+ termsAgreement?: TermsAgreement | null;
19
+ };
20
+ type CreateUserFormData = CreateFormData<UserFormData>;
21
+ /**
22
+ * Write-side / mongoose activity event. GraphQL EventReferenceType uses the
23
+ * same fields; DateTimeType is already the generated ISO-string shape.
24
+ */
25
+ type UserActivityEvent = {
26
+ resourceId: string;
27
+ dateTime: DateTimeType;
28
+ };
29
+ /**
30
+ * Write-side Stripe subscription document (mongoose Dates).
31
+ * GraphQL StripeSubscriptionType serializes dates as ISO strings — dual-shape.
32
+ */
33
+ type StripeSubscription = {
34
+ currentPlan?: LicencesEnumType;
35
+ customerId?: string;
36
+ endDate?: Date;
37
+ startDate?: Date;
38
+ status?: SubscriptionStatusEnumType;
39
+ subscriptionId?: string;
40
+ };
41
+ type SubscriptionStatusData = {
42
+ subscriptionId: string | null;
43
+ status: SubscriptionStatusEnumType;
44
+ priceId: string | null;
45
+ currentPlan: LicencesEnumType | null;
46
+ };
47
+ /**
48
+ * Write-side embedded userActivity (mongoose). GraphQL UserActivityType uses
49
+ * Maybe lists / EventReferenceType — dual-shape, do not collapse.
50
+ */
51
+ type UserActivity = {
52
+ favourites: {
53
+ events: string[];
54
+ vendors: string[];
55
+ partners: string[];
56
+ };
57
+ going: {
58
+ events: UserActivityEvent[];
59
+ };
60
+ interested: {
61
+ events: UserActivityEvent[];
62
+ };
63
+ present: {
64
+ events: UserActivityEvent[];
65
+ };
66
+ };
67
+ /** GraphQL envelope for `redeemReward`. */
68
+ type RedeemRewardMutationResponse = MutationResponse<RedeemRewardResponseType>;
69
+ /**
70
+ * Write-side redeemed reward (mongoose Date). GraphQL RedeemedRewardType
71
+ * serializes redeemedAt as an ISO string — dual-shape.
72
+ */
73
+ type RedeemedReward = {
74
+ name: RewardEnumType;
75
+ pointsUsed: number;
76
+ redeemedAt: Date;
77
+ };
78
+ /**
79
+ * Persistence / mongoose user document. Includes secrets (password hash,
80
+ * refreshToken) and internal emailSentFor that GraphQL UserType never exposes.
81
+ * Dates stay as JS Date for mongoose. Dual-shape vs generated UserType —
82
+ * do not collapse.
83
+ *
84
+ * Client-facing GraphQL UserType / SafeUserType are generated — see
85
+ * src/generated/graphql.ts, re-exported from types/index.ts. SafeUserType is
86
+ * an alias of that generated UserType (schema UserType already omits
87
+ * password/refreshToken).
88
+ */
89
+ type UserWriteType = Omit<UserFormData, "confirmPassword" | "avatarUpload" | "_id"> & {
90
+ _id: string;
91
+ affiliate?: string | null;
92
+ createdAt: Date;
93
+ deletedAt: Date | null;
94
+ emailSentFor?: NotificationResourceEnumType[] | null;
95
+ events: string[] | null;
96
+ game: string | null;
97
+ licences: UserLicenceType[] | null;
98
+ overallPoints: number | null;
99
+ partner: string | null;
100
+ password: string;
101
+ promoCodes?: PromoCodeType[] | null;
102
+ redeemedRewards?: RedeemedReward[] | null;
103
+ refreshToken: string | null;
104
+ roles: UserRoleEnumType[];
105
+ school: string | null;
106
+ stripe?: StripeSubscription;
107
+ updatedAt: Date | null;
108
+ userActivity: UserActivity | null;
109
+ vendor: string | null;
110
+ };
111
+
112
+ interface AppSettingsFormData {
113
+ appVersion: string;
114
+ isOfflineMode: boolean;
115
+ minimumRedeemableAffiliatePoints: number;
116
+ }
117
+ type CreateAppSettingsFormData = CreateFormData<AppSettingsFormData>;
118
+ type AppSettingsType = AppSettingsFormData & {
119
+ _id: string;
120
+ activeSchoolsStudentCountTotal: number;
121
+ activeSchoolsStudentCountUpdatedAt: Date;
122
+ createdAt: Date;
123
+ key: string;
124
+ updatedAt: Date | null;
125
+ };
126
+
127
+ type LoginFormData = {
128
+ email: string;
129
+ isAdminPage?: boolean;
130
+ password: string;
131
+ platform?: OsPlatformEnumType;
132
+ };
133
+ type CreateLoginFormData = CreateFormData<LoginFormData>;
134
+ type RegisterFormData = {
135
+ email: string;
136
+ firstName: string;
137
+ lastName: string;
138
+ password: string;
139
+ platform?: OsPlatformEnumType;
140
+ preferredRegion: string;
141
+ promoCode?: PromoCodeType | null;
142
+ termsAgreement?: TermsAgreement | null;
143
+ };
144
+ type CreateRegisterFormData = CreateFormData<RegisterFormData>;
145
+ type RequestPasswordResetFormData = {
146
+ email: string;
147
+ };
148
+ type CreateRequestPasswordResetFormData = CreateFormData<RequestPasswordResetFormData>;
149
+ type ResetPasswordFormData = {
150
+ confirmPassword: string;
151
+ email: string;
152
+ password: string;
153
+ };
154
+ type CreateResetPasswordFormData = CreateFormData<ResetPasswordFormData>;
155
+ type ValidateVerificationTokenFormData = {
156
+ email: string;
157
+ verificationToken: string;
158
+ verificationType?: VerificationEnumType;
159
+ };
160
+ type CreateValidateVerificationTokenFormData = CreateFormData<ValidateVerificationTokenFormData>;
161
+ /**
162
+ * GraphQL AuthPayloadType / RefreshTokenPayloadType are generated —
163
+ * re-exported from types/index.ts. AuthPayloadType.user is schema UserType,
164
+ * which is already the redacted client shape (no password / refreshToken).
165
+ */
166
+ type AuthMutationResponse = MutationResponse<AuthPayloadType>;
167
+ type RefreshTokenMutationResponse = MutationResponse<RefreshTokenPayloadType>;
168
+
169
+ export type { AppSettingsFormData as A, CreateAppSettingsFormData as C, LoginFormData as L, RedeemRewardMutationResponse as R, StripeSubscription as S, UserFormData as U, ValidateVerificationTokenFormData as V, AppSettingsType as a, AuthMutationResponse as b, CreateLoginFormData as c, CreateRegisterFormData as d, CreateRequestPasswordResetFormData as e, CreateResetPasswordFormData as f, CreateUserFormData as g, CreateValidateVerificationTokenFormData as h, RedeemedReward as i, RefreshTokenMutationResponse as j, RegisterFormData as k, RequestPasswordResetFormData as l, ResetPasswordFormData as m, SubscriptionStatusData as n, UserActivity as o, UserActivityEvent as p, UserWriteType as q };