@timardex/cluemart-shared 1.6.130 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ad-CVkVX_z5.d.ts +296 -0
- package/dist/ad-DA9ECAhK.d.mts +296 -0
- package/dist/affiliate-1RtkLnLP.d.ts +35 -0
- package/dist/affiliate-Cos2Syz5.d.mts +35 -0
- package/dist/chunk-HZMP7GXC.mjs +5330 -0
- package/dist/chunk-HZMP7GXC.mjs.map +1 -0
- package/dist/chunk-KZTOISPA.mjs +272 -0
- package/dist/chunk-KZTOISPA.mjs.map +1 -0
- package/dist/chunk-MVQ3CFQR.mjs +230 -0
- package/dist/chunk-MVQ3CFQR.mjs.map +1 -0
- package/dist/chunk-NPFJ2CN2.mjs +109 -0
- package/dist/chunk-NPFJ2CN2.mjs.map +1 -0
- package/dist/chunk-RKIRWZCH.mjs +368 -0
- package/dist/chunk-RKIRWZCH.mjs.map +1 -0
- package/dist/{chunk-OHHJ3KJJ.mjs → chunk-TAECMXM4.mjs} +267 -304
- package/dist/chunk-TAECMXM4.mjs.map +1 -0
- package/dist/chunk-VA5YN2K3.mjs +48 -0
- package/dist/chunk-VA5YN2K3.mjs.map +1 -0
- package/dist/chunk-ZZJSCYJK.mjs +958 -0
- package/dist/chunk-ZZJSCYJK.mjs.map +1 -0
- package/dist/contactUs-DGrDzJaM.d.mts +11 -0
- package/dist/contactUs-H7799pWe.d.ts +11 -0
- package/dist/enums/index.cjs +223 -2
- package/dist/enums/index.cjs.map +1 -1
- package/dist/enums/index.d.mts +164 -5
- package/dist/enums/index.d.ts +164 -5
- package/dist/enums/index.mjs +41 -1
- package/dist/formFields/index.cjs +168 -403
- package/dist/formFields/index.cjs.map +1 -1
- package/dist/formFields/index.d.mts +3 -6
- package/dist/formFields/index.d.ts +3 -6
- package/dist/formFields/index.mjs +47 -921
- package/dist/formFields/index.mjs.map +1 -1
- package/dist/global-BUUfmCo7.d.mts +698 -0
- package/dist/global-fKbMmluy.d.ts +698 -0
- package/dist/graphql/index.cjs +3329 -3340
- package/dist/graphql/index.cjs.map +1 -1
- package/dist/graphql/index.d.mts +487 -690
- package/dist/graphql/index.d.ts +487 -690
- package/dist/graphql/index.mjs +153 -2552
- package/dist/graphql/index.mjs.map +1 -1
- package/dist/hooks/index.cjs +3478 -773
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.mts +6 -13
- package/dist/hooks/index.d.ts +6 -13
- package/dist/hooks/index.mjs +99 -193
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/images/apple-maps-icon.webp.d.ts +1 -8
- package/dist/images/banner-horizontal.webp.d.ts +1 -8
- package/dist/images/banner-vertical.webp.d.ts +1 -8
- package/dist/images/cluiTui.webp.d.ts +1 -8
- package/dist/images/corporate.webp.d.ts +1 -8
- package/dist/images/facebook.webp.d.ts +1 -8
- package/dist/images/gazebo-top.webp.d.ts +1 -8
- package/dist/images/google-maps-icon.webp.d.ts +1 -8
- package/dist/images/googleMaps-logo-dark.webp.d.ts +1 -8
- package/dist/images/googleMaps-logo-light.webp.d.ts +1 -8
- package/dist/images/index.mjs +21 -86
- package/dist/images/index.mjs.map +1 -1
- package/dist/images/instagram.webp.d.ts +1 -8
- package/dist/images/logo-atr.webp.d.ts +1 -8
- package/dist/images/logo-dark.webp.d.ts +1 -8
- package/dist/images/logo.webp.d.ts +1 -8
- package/dist/images/meet.webp.d.ts +1 -8
- package/dist/images/mini-market1.webp.d.ts +1 -8
- package/dist/images/mini-market2.webp.d.ts +1 -8
- package/dist/images/mini-market3.webp.d.ts +1 -8
- package/dist/images/mini-market4.webp.d.ts +1 -8
- package/dist/images/mini-market5.webp.d.ts +1 -8
- package/dist/images/poll.webp.d.ts +1 -8
- package/dist/images/poster1.webp.d.ts +1 -8
- package/dist/images/poster2.webp.d.ts +1 -8
- package/dist/images/poster3.webp.d.ts +1 -8
- package/dist/images/poster4.webp.d.ts +1 -8
- package/dist/images/private.webp.d.ts +1 -8
- package/dist/images/qr-code.webp.d.ts +1 -8
- package/dist/images/school.webp.d.ts +1 -8
- package/dist/images/sima.webp.d.ts +1 -8
- package/dist/images/store-android.webp.d.ts +1 -8
- package/dist/images/store-ios.webp.d.ts +1 -8
- package/dist/images/tablas.webp.d.ts +1 -8
- package/dist/images/telefonos.webp.d.ts +1 -8
- package/dist/images/tiktok.webp.d.ts +1 -8
- package/dist/images/tip.webp.d.ts +1 -8
- package/dist/images/ugralos.webp.d.ts +1 -8
- package/dist/images/waze-maps-icon.webp.d.ts +1 -8
- package/dist/images/website.webp.d.ts +1 -8
- package/dist/images/youtube.webp.d.ts +1 -8
- package/dist/index.cjs +5883 -7079
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1692 -2966
- package/dist/index.d.ts +1692 -2966
- package/dist/index.mjs +5020 -6162
- package/dist/index.mjs.map +1 -1
- package/dist/map/index.cjs +9 -14
- package/dist/map/index.cjs.map +1 -1
- package/dist/map/index.d.mts +14 -18
- package/dist/map/index.d.ts +14 -18
- package/dist/map/index.mjs +9 -14
- package/dist/map/index.mjs.map +1 -1
- package/dist/resourceActivities-BL_12IAo.d.ts +125 -0
- package/dist/resourceActivities-zczOntNk.d.mts +125 -0
- package/dist/sharing/index.cjs +1272 -63
- package/dist/sharing/index.cjs.map +1 -1
- package/dist/sharing/index.d.mts +7 -32
- package/dist/sharing/index.d.ts +7 -32
- package/dist/sharing/index.mjs +30 -188
- package/dist/sharing/index.mjs.map +1 -1
- package/dist/theme/index.mjs +5 -41
- package/dist/theme/index.mjs.map +1 -1
- package/dist/types/index.cjs +110 -868
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.mts +24 -230
- package/dist/types/index.d.ts +24 -230
- package/dist/types/index.mjs +27 -61
- package/dist/utils/index.cjs +214 -608
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.mts +53 -107
- package/dist/utils/index.d.ts +53 -107
- package/dist/utils/index.mjs +15 -43
- package/package.json +12 -40
- package/dist/affiliate-Bqqlffw8.d.mts +0 -36
- package/dist/affiliate-Btlp5XUp.d.ts +0 -36
- package/dist/affiliateAdapters-BW3BY7c5.d.mts +0 -118
- package/dist/affiliateAdapters-C51ISmuA.d.ts +0 -118
- package/dist/apollo/index.cjs +0 -1383
- package/dist/apollo/index.cjs.map +0 -1
- package/dist/apollo/index.d.mts +0 -323
- package/dist/apollo/index.d.ts +0 -323
- package/dist/apollo/index.mjs +0 -1295
- package/dist/apollo/index.mjs.map +0 -1
- package/dist/auth/index.cjs +0 -3322
- package/dist/auth/index.cjs.map +0 -1
- package/dist/auth/index.d.mts +0 -164
- package/dist/auth/index.d.ts +0 -164
- package/dist/auth/index.mjs +0 -379
- package/dist/auth/index.mjs.map +0 -1
- package/dist/auth-BOmAO53v.d.ts +0 -169
- package/dist/auth-CsITA95p.d.mts +0 -169
- package/dist/chunk-DATBGC2K.mjs +0 -347
- package/dist/chunk-DATBGC2K.mjs.map +0 -1
- package/dist/chunk-DDHECBJR.mjs +0 -726
- package/dist/chunk-DDHECBJR.mjs.map +0 -1
- package/dist/chunk-INQCDU24.mjs +0 -139
- package/dist/chunk-INQCDU24.mjs.map +0 -1
- package/dist/chunk-NWWKI4PJ.mjs +0 -297
- package/dist/chunk-NWWKI4PJ.mjs.map +0 -1
- package/dist/chunk-OHHJ3KJJ.mjs.map +0 -1
- package/dist/chunk-RAYUJODN.mjs +0 -45
- package/dist/chunk-RAYUJODN.mjs.map +0 -1
- package/dist/chunk-TOEFAEF2.mjs +0 -69
- package/dist/chunk-TOEFAEF2.mjs.map +0 -1
- package/dist/chunk-UKW7NZEQ.mjs +0 -2813
- package/dist/chunk-UKW7NZEQ.mjs.map +0 -1
- package/dist/dailyClue-C6WXY73z.d.mts +0 -105
- package/dist/dailyClue-C6WXY73z.d.ts +0 -105
- package/dist/event-C9K7CSg4.d.ts +0 -53
- package/dist/event-W0NhL5Cd.d.mts +0 -53
- package/dist/global-BbSFfYdd.d.ts +0 -181
- package/dist/global-C6v9tRji.d.mts +0 -181
- package/dist/graphql-CDOfA79A.d.ts +0 -1253
- package/dist/graphql-CcvzTs9k.d.mts +0 -1253
- package/dist/resourceActivities-CS8YRIIL.d.mts +0 -89
- package/dist/resourceActivities-DOdNPkhW.d.ts +0 -89
- package/dist/subscription-Cj_qBA7u.d.mts +0 -20
- package/dist/subscription-OiJ50uJb.d.ts +0 -20
- package/dist/vendor-DmMi2qmx.d.mts +0 -73
- package/dist/vendor-M9hVZlni.d.ts +0 -73
package/dist/auth/index.mjs
DELETED
|
@@ -1,379 +0,0 @@
|
|
|
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";
|
|
9
|
-
import {
|
|
10
|
-
ADMIN_APP_ROLES,
|
|
11
|
-
ADMIN_DASHBOARD_CONTEXTS,
|
|
12
|
-
PERMISSIONS,
|
|
13
|
-
ROLE_PERMISSIONS,
|
|
14
|
-
TIERS_BY_PRIORITY,
|
|
15
|
-
WILDCARD_PERMISSION,
|
|
16
|
-
canAccessAdminApp,
|
|
17
|
-
canAccessAdminPath,
|
|
18
|
-
getDefaultAdminHome,
|
|
19
|
-
getPermissionsForRoles,
|
|
20
|
-
getUsableAdminContexts,
|
|
21
|
-
hasAllPermissions,
|
|
22
|
-
hasAnyPermission,
|
|
23
|
-
hasAnyRole,
|
|
24
|
-
hasPermission,
|
|
25
|
-
hasRole,
|
|
26
|
-
permissionListIncludes,
|
|
27
|
-
resolveAdminContextFromPath,
|
|
28
|
-
toUserPermissions
|
|
29
|
-
} from "../chunk-DATBGC2K.mjs";
|
|
30
|
-
import "../chunk-INQCDU24.mjs";
|
|
31
|
-
|
|
32
|
-
// src/auth/createAuthManager.ts
|
|
33
|
-
function createAuthManager() {
|
|
34
|
-
let logoutFn = null;
|
|
35
|
-
let userRefetchFn = null;
|
|
36
|
-
let logoutPromise = null;
|
|
37
|
-
return {
|
|
38
|
-
handleRefetchUser: async () => {
|
|
39
|
-
if (userRefetchFn) {
|
|
40
|
-
await userRefetchFn();
|
|
41
|
-
} else {
|
|
42
|
-
console.warn("\u274C User refetch function not set!");
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
logout() {
|
|
46
|
-
if (logoutPromise !== null) return logoutPromise;
|
|
47
|
-
if (logoutFn === null) {
|
|
48
|
-
console.warn("\u274C Logout function not set!");
|
|
49
|
-
return Promise.resolve();
|
|
50
|
-
}
|
|
51
|
-
logoutPromise = logoutFn().finally(() => {
|
|
52
|
-
logoutPromise = null;
|
|
53
|
-
});
|
|
54
|
-
return logoutPromise;
|
|
55
|
-
},
|
|
56
|
-
setLogout(fn) {
|
|
57
|
-
logoutFn = fn;
|
|
58
|
-
},
|
|
59
|
-
setUserRefetch(fn) {
|
|
60
|
-
userRefetchFn = fn;
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// src/auth/licenceUtils.ts
|
|
66
|
-
function isLicencedResourceType(resourceType) {
|
|
67
|
-
return resourceType !== "affiliate" /* Affiliate */ && resourceType !== "school" /* School */;
|
|
68
|
-
}
|
|
69
|
-
function isProfileBadgeLicence(licenceType) {
|
|
70
|
-
return licenceType !== "standard_affiliate" /* StandardAffiliate */ && licenceType !== "standard_school" /* StandardSchool */;
|
|
71
|
-
}
|
|
72
|
-
var hasUserLicenceType = (authUser, licenceType) => authUser?.licences?.some((licence) => licence.licenceType === licenceType) ?? false;
|
|
73
|
-
var hasLicence = (authUser, licenceType) => {
|
|
74
|
-
const directLicence = authUser?.licences?.some(
|
|
75
|
-
(licence) => licence.licenceType?.includes(licenceType)
|
|
76
|
-
) ?? false;
|
|
77
|
-
return {
|
|
78
|
-
directLicence
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
var DEFAULT_LIMITS = {
|
|
82
|
-
// 1 means calendar/productMenu is enabled, 0 means disabled
|
|
83
|
-
availability: { pro: 1, pro_plus: 1, standard: 0 },
|
|
84
|
-
calendar: { pro: 1, pro_plus: 1, standard: 0 },
|
|
85
|
-
images: { pro: 12, pro_plus: 12, standard: 6 },
|
|
86
|
-
posters: { pro: 5, pro_plus: 5, standard: 5 },
|
|
87
|
-
productsList: { pro: 1, pro_plus: 1, standard: 0 },
|
|
88
|
-
relationShare: { pro: 1, pro_plus: 1, standard: 0 },
|
|
89
|
-
statistics: { pro: 1, pro_plus: 1, standard: 0 }
|
|
90
|
-
};
|
|
91
|
-
var NO_LICENCE_FLAGS = {
|
|
92
|
-
event: {
|
|
93
|
-
pro_plus: false,
|
|
94
|
-
// eslint-disable-next-line sort-keys
|
|
95
|
-
pro: false,
|
|
96
|
-
standard: false
|
|
97
|
-
},
|
|
98
|
-
partner: {
|
|
99
|
-
pro_plus: false,
|
|
100
|
-
// eslint-disable-next-line sort-keys
|
|
101
|
-
pro: false,
|
|
102
|
-
standard: false
|
|
103
|
-
},
|
|
104
|
-
vendor: {
|
|
105
|
-
pro_plus: false,
|
|
106
|
-
// eslint-disable-next-line sort-keys
|
|
107
|
-
pro: false,
|
|
108
|
-
standard: false
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
function getLicenceFlagsByRole(licences) {
|
|
112
|
-
const normalized = licences?.map((l) => l.toLowerCase()) ?? [];
|
|
113
|
-
const hasAnyLicence = normalized.length > 0;
|
|
114
|
-
function resolve(role) {
|
|
115
|
-
const result = {
|
|
116
|
-
pro_plus: false,
|
|
117
|
-
// eslint-disable-next-line sort-keys
|
|
118
|
-
pro: false,
|
|
119
|
-
standard: false
|
|
120
|
-
};
|
|
121
|
-
for (const tier of TIERS_BY_PRIORITY) {
|
|
122
|
-
if (normalized.some((l) => l.startsWith(`${tier}_${role}`))) {
|
|
123
|
-
result[tier] = true;
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
if (!hasAnyLicence) {
|
|
128
|
-
result.pro = true;
|
|
129
|
-
}
|
|
130
|
-
return result;
|
|
131
|
-
}
|
|
132
|
-
return {
|
|
133
|
-
event: resolve("event" /* Event */),
|
|
134
|
-
partner: resolve("partner" /* Partner */),
|
|
135
|
-
vendor: resolve("vendor" /* Vendor */)
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// src/auth/useAuthCore.ts
|
|
140
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
141
|
-
function useAuthCore(adapters) {
|
|
142
|
-
const {
|
|
143
|
-
storage,
|
|
144
|
-
authManager,
|
|
145
|
-
afterLogout,
|
|
146
|
-
shouldCallLogoutMutation = () => true,
|
|
147
|
-
notifyLogoutSuccess,
|
|
148
|
-
notifySessionExpired,
|
|
149
|
-
onError
|
|
150
|
-
} = adapters;
|
|
151
|
-
const [authUser, setAuthUser] = useState(null);
|
|
152
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
153
|
-
const userId = useMemo(() => authUser?._id ?? "", [authUser?._id]);
|
|
154
|
-
const { refetch } = useGetUser(userId);
|
|
155
|
-
const { logout, loading } = useLogout();
|
|
156
|
-
const handleSetAuthUser = useCallback(
|
|
157
|
-
async (user) => {
|
|
158
|
-
setAuthUser(user);
|
|
159
|
-
if (user) {
|
|
160
|
-
await storage.setItem(USER_STORAGE_KEY, JSON.stringify(user));
|
|
161
|
-
} else {
|
|
162
|
-
await storage.removeItem(USER_STORAGE_KEY);
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
[storage]
|
|
166
|
-
);
|
|
167
|
-
const handleRefetchUser = useCallback(async () => {
|
|
168
|
-
if (!authUser) return;
|
|
169
|
-
try {
|
|
170
|
-
const result = await refetch();
|
|
171
|
-
if (!result) return;
|
|
172
|
-
const { data } = result;
|
|
173
|
-
if (data?.user) await handleSetAuthUser(data.user);
|
|
174
|
-
} catch (error) {
|
|
175
|
-
onError?.(error, { action: "refetchUser" });
|
|
176
|
-
console.warn(
|
|
177
|
-
"Failed to refetch user:",
|
|
178
|
-
error instanceof Error ? error.message : error
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
}, [authUser, handleSetAuthUser, onError, refetch]);
|
|
182
|
-
const licences = useCallback(
|
|
183
|
-
(resourceId) => {
|
|
184
|
-
const myLicences = authUser?.licences?.map((licence) => licence.licenceType).filter((type) => type != null) ?? [];
|
|
185
|
-
const myResourceIds = [
|
|
186
|
-
authUser?.vendor ?? null,
|
|
187
|
-
authUser?.partner ?? null,
|
|
188
|
-
...authUser?.events ?? []
|
|
189
|
-
].filter((id) => id != null);
|
|
190
|
-
return myResourceIds.includes(resourceId) ? getLicenceFlagsByRole(myLicences) : NO_LICENCE_FLAGS;
|
|
191
|
-
},
|
|
192
|
-
[authUser]
|
|
193
|
-
);
|
|
194
|
-
const getLicenseAccessLevel = useCallback(
|
|
195
|
-
(limitType, resourceId, resourceType) => {
|
|
196
|
-
if (!isLicencedResourceType(resourceType)) {
|
|
197
|
-
return 0;
|
|
198
|
-
}
|
|
199
|
-
if (resourceId === "") {
|
|
200
|
-
return DEFAULT_LIMITS[limitType].pro;
|
|
201
|
-
}
|
|
202
|
-
const roleLicences = licences(resourceId)[resourceType];
|
|
203
|
-
if (roleLicences.pro_plus) return DEFAULT_LIMITS[limitType].pro_plus;
|
|
204
|
-
if (roleLicences.pro) return DEFAULT_LIMITS[limitType].pro;
|
|
205
|
-
if (roleLicences.standard) return DEFAULT_LIMITS[limitType].standard;
|
|
206
|
-
return 0;
|
|
207
|
-
},
|
|
208
|
-
[licences]
|
|
209
|
-
);
|
|
210
|
-
const hasVendorLicence = useMemo(
|
|
211
|
-
() => hasLicence(authUser, "vendor"),
|
|
212
|
-
[authUser]
|
|
213
|
-
);
|
|
214
|
-
const hasPartnerLicence = useMemo(
|
|
215
|
-
() => hasLicence(authUser, "partner"),
|
|
216
|
-
[authUser]
|
|
217
|
-
);
|
|
218
|
-
const hasEventLicence = useMemo(
|
|
219
|
-
() => hasLicence(authUser, "event"),
|
|
220
|
-
[authUser]
|
|
221
|
-
);
|
|
222
|
-
const hasUserLicence = useCallback(
|
|
223
|
-
(licenceType) => hasUserLicenceType(authUser, licenceType),
|
|
224
|
-
[authUser]
|
|
225
|
-
);
|
|
226
|
-
const permissions = useMemo(() => {
|
|
227
|
-
if (authUser?.permissions != null) {
|
|
228
|
-
return toUserPermissions(authUser.permissions);
|
|
229
|
-
}
|
|
230
|
-
return getPermissionsForRoles(authUser?.roles);
|
|
231
|
-
}, [authUser?.permissions, authUser?.roles]);
|
|
232
|
-
const hasPermissionFn = useCallback(
|
|
233
|
-
(permission) => permissionListIncludes(permissions, permission),
|
|
234
|
-
[permissions]
|
|
235
|
-
);
|
|
236
|
-
const hasRoleFn = useCallback(
|
|
237
|
-
(role) => hasRole(authUser?.roles, role),
|
|
238
|
-
[authUser?.roles]
|
|
239
|
-
);
|
|
240
|
-
const isAdmin = useMemo(
|
|
241
|
-
() => hasRole(authUser?.roles, "admin" /* Admin */) || permissionListIncludes(permissions, "dashboard.admin") || permissionListIncludes(permissions, "*"),
|
|
242
|
-
[authUser?.roles, permissions]
|
|
243
|
-
);
|
|
244
|
-
const isSuperAdmin = useMemo(
|
|
245
|
-
() => hasRole(authUser?.roles, "super_admin" /* SuperAdmin */),
|
|
246
|
-
[authUser?.roles]
|
|
247
|
-
);
|
|
248
|
-
const isAffiliate = useMemo(
|
|
249
|
-
() => hasRole(authUser?.roles, "affiliate" /* Affiliate */) && authUser?.affiliate !== null && authUser?.affiliate !== void 0,
|
|
250
|
-
[authUser?.roles, authUser?.affiliate]
|
|
251
|
-
);
|
|
252
|
-
const isSchool = useMemo(
|
|
253
|
-
() => hasRole(authUser?.roles, "school" /* School */) && authUser?.school !== null && authUser?.school !== void 0,
|
|
254
|
-
[authUser?.roles, authUser?.school]
|
|
255
|
-
);
|
|
256
|
-
useEffect(() => {
|
|
257
|
-
const loadUser = async () => {
|
|
258
|
-
try {
|
|
259
|
-
const userJson = await storage.getItem(USER_STORAGE_KEY);
|
|
260
|
-
await handleSetAuthUser(userJson ? JSON.parse(userJson) : null);
|
|
261
|
-
} catch (error) {
|
|
262
|
-
onError?.(error, { action: "loadUserFromStorage" });
|
|
263
|
-
console.error("Failed to load user from storage:", error);
|
|
264
|
-
} finally {
|
|
265
|
-
setIsLoading(false);
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
void loadUser();
|
|
269
|
-
}, []);
|
|
270
|
-
const logoutWithReason = useCallback(
|
|
271
|
-
async (reason) => {
|
|
272
|
-
try {
|
|
273
|
-
if (shouldCallLogoutMutation(reason)) {
|
|
274
|
-
try {
|
|
275
|
-
const result = await logout();
|
|
276
|
-
const message = result?.data?.logout?.message;
|
|
277
|
-
if (message) {
|
|
278
|
-
notifyLogoutSuccess?.(message);
|
|
279
|
-
}
|
|
280
|
-
} catch (err) {
|
|
281
|
-
onError?.(err, { action: "logout" });
|
|
282
|
-
console.warn("Logout request failed (ignored):", err);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
} finally {
|
|
286
|
-
await afterLogout(reason);
|
|
287
|
-
setAuthUser(null);
|
|
288
|
-
await storage.removeItem(USER_STORAGE_KEY);
|
|
289
|
-
}
|
|
290
|
-
},
|
|
291
|
-
[
|
|
292
|
-
afterLogout,
|
|
293
|
-
logout,
|
|
294
|
-
notifyLogoutSuccess,
|
|
295
|
-
onError,
|
|
296
|
-
shouldCallLogoutMutation,
|
|
297
|
-
storage
|
|
298
|
-
]
|
|
299
|
-
);
|
|
300
|
-
const handleLogoutExplicit = useCallback(
|
|
301
|
-
() => logoutWithReason("manual"),
|
|
302
|
-
[logoutWithReason]
|
|
303
|
-
);
|
|
304
|
-
const handleLogoutExpired = useCallback(async () => {
|
|
305
|
-
const hadSession = authUser != null;
|
|
306
|
-
if (!hadSession) return;
|
|
307
|
-
await logoutWithReason("expired");
|
|
308
|
-
notifySessionExpired?.();
|
|
309
|
-
}, [authUser, logoutWithReason, notifySessionExpired]);
|
|
310
|
-
useEffect(() => {
|
|
311
|
-
authManager.setLogout(() => handleLogoutExpired());
|
|
312
|
-
authManager.setUserRefetch(() => handleRefetchUser());
|
|
313
|
-
}, [authManager, handleLogoutExpired, handleRefetchUser]);
|
|
314
|
-
return {
|
|
315
|
-
authUser,
|
|
316
|
-
getLicenseAccessLevel,
|
|
317
|
-
handleLogoutExplicit,
|
|
318
|
-
hasEventLicence,
|
|
319
|
-
hasPartnerLicence,
|
|
320
|
-
hasPermission: hasPermissionFn,
|
|
321
|
-
hasRole: hasRoleFn,
|
|
322
|
-
hasUserLicence,
|
|
323
|
-
hasVendorLicence,
|
|
324
|
-
isAdmin,
|
|
325
|
-
isAffiliate,
|
|
326
|
-
isLoading: loading || isLoading,
|
|
327
|
-
isSchool,
|
|
328
|
-
isSuperAdmin,
|
|
329
|
-
permissions,
|
|
330
|
-
refetchUser: handleRefetchUser,
|
|
331
|
-
setUser: handleSetAuthUser
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
// src/auth/UserProvider.tsx
|
|
336
|
-
import { createContext, useContext } from "react";
|
|
337
|
-
import { jsx } from "react/jsx-runtime";
|
|
338
|
-
var UserContext = createContext(void 0);
|
|
339
|
-
var UserProvider = ({ children, value }) => {
|
|
340
|
-
return /* @__PURE__ */ jsx(UserContext.Provider, { value, children });
|
|
341
|
-
};
|
|
342
|
-
var useAuthUser = () => {
|
|
343
|
-
const context = useContext(UserContext);
|
|
344
|
-
if (!context) {
|
|
345
|
-
throw new Error("useAuthUser must be used within a UserProvider");
|
|
346
|
-
}
|
|
347
|
-
return context;
|
|
348
|
-
};
|
|
349
|
-
export {
|
|
350
|
-
ADMIN_APP_ROLES,
|
|
351
|
-
ADMIN_DASHBOARD_CONTEXTS,
|
|
352
|
-
DEFAULT_LIMITS,
|
|
353
|
-
NO_LICENCE_FLAGS,
|
|
354
|
-
PERMISSIONS,
|
|
355
|
-
ROLE_PERMISSIONS,
|
|
356
|
-
UserProvider,
|
|
357
|
-
WILDCARD_PERMISSION,
|
|
358
|
-
canAccessAdminApp,
|
|
359
|
-
canAccessAdminPath,
|
|
360
|
-
createAuthManager,
|
|
361
|
-
getDefaultAdminHome,
|
|
362
|
-
getLicenceFlagsByRole,
|
|
363
|
-
getPermissionsForRoles,
|
|
364
|
-
getUsableAdminContexts,
|
|
365
|
-
hasAllPermissions,
|
|
366
|
-
hasAnyPermission,
|
|
367
|
-
hasAnyRole,
|
|
368
|
-
hasLicence,
|
|
369
|
-
hasPermission,
|
|
370
|
-
hasRole,
|
|
371
|
-
hasUserLicenceType,
|
|
372
|
-
isLicencedResourceType,
|
|
373
|
-
isProfileBadgeLicence,
|
|
374
|
-
permissionListIncludes,
|
|
375
|
-
resolveAdminContextFromPath,
|
|
376
|
-
useAuthCore,
|
|
377
|
-
useAuthUser
|
|
378
|
-
};
|
|
379
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/auth/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;AAA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,IACF;AAAA,EACF;AAEA,QAAM,uBAAuB;AAAA,IAC3B,MAAM,iBAAiB,QAAQ;AAAA,IAC/B,CAAC,gBAAgB;AAAA,EACnB;AAEA,QAAM,sBAAsB,YAAY,YAAY;AAClD,UAAM,aAAa,YAAY;AAC/B,QAAI,CAAC,WAAY;AACjB,UAAM,iBAAiB,SAAS;AAChC,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":[]}
|
package/dist/auth-BOmAO53v.d.ts
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
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 };
|