@timardex/cluemart-shared 1.5.829 → 1.5.830
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/auth/index.cjs +106 -0
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.mts +24 -1
- package/dist/auth/index.d.ts +24 -1
- package/dist/auth/index.mjs +16 -2
- package/dist/auth/index.mjs.map +1 -1
- package/dist/{chunk-JL4MCXKK.mjs → chunk-VPANTTZI.mjs} +101 -2
- package/dist/chunk-VPANTTZI.mjs.map +1 -0
- package/dist/hooks/index.cjs +55 -0
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.mjs +1 -1
- package/dist/index.cjs +106 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.mjs +99 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-JL4MCXKK.mjs.map +0 -1
package/dist/hooks/index.mjs
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
ADMIN_APP_ROLES: () => ADMIN_APP_ROLES,
|
|
34
|
+
ADMIN_DASHBOARD_CONTEXTS: () => ADMIN_DASHBOARD_CONTEXTS,
|
|
33
35
|
AFFILIATE_PARTICIPANT_TYPE_LABELS: () => AFFILIATE_PARTICIPANT_TYPE_LABELS,
|
|
34
36
|
ANDROID_URL: () => ANDROID_URL,
|
|
35
37
|
CLUEMART_MAIN_DOMAIN_URL: () => CLUEMART_MAIN_DOMAIN_URL,
|
|
@@ -157,6 +159,8 @@ __export(index_exports, {
|
|
|
157
159
|
buildShareOgDescriptionFromSections: () => buildShareOgDescriptionFromSections,
|
|
158
160
|
buildSharePagePath: () => buildSharePagePath,
|
|
159
161
|
buildShareUrl: () => buildShareUrl,
|
|
162
|
+
canAccessAdminApp: () => canAccessAdminApp,
|
|
163
|
+
canAccessAdminPath: () => canAccessAdminPath,
|
|
160
164
|
capitalizeFirstLetter: () => capitalizeFirstLetter,
|
|
161
165
|
categoryColors: () => categoryColors,
|
|
162
166
|
cluemartSocialMedia: () => cluemartSocialMedia,
|
|
@@ -212,6 +216,7 @@ __export(index_exports, {
|
|
|
212
216
|
gameTypeToDisplayName: () => gameTypeToDisplayName,
|
|
213
217
|
getAllowedEventDateStatuses: () => getAllowedEventDateStatuses,
|
|
214
218
|
getCurrentAndFutureDates: () => getCurrentAndFutureDates,
|
|
219
|
+
getDefaultAdminHome: () => getDefaultAdminHome,
|
|
215
220
|
getErrorMessage: () => getErrorMessage,
|
|
216
221
|
getEventCalendarIsoDates: () => getEventCalendarIsoDates,
|
|
217
222
|
getEventDatesWithStallholders: () => getEventDatesWithStallholders,
|
|
@@ -226,6 +231,7 @@ __export(index_exports, {
|
|
|
226
231
|
getStallholderCategoryOptions: () => getStallholderCategoryOptions,
|
|
227
232
|
getUnregisteredVendorCategoryNames: () => getUnregisteredVendorCategoryNames,
|
|
228
233
|
getUnregisteredVendorStartDates: () => getUnregisteredVendorStartDates,
|
|
234
|
+
getUsableAdminContexts: () => getUsableAdminContexts,
|
|
229
235
|
getVendorEventRelationDateOptions: () => getVendorEventRelationDateOptions,
|
|
230
236
|
getVendorEventRelationStartDates: () => getVendorEventRelationStartDates,
|
|
231
237
|
getVendorEventsEmptyMessage: () => getVendorEventsEmptyMessage,
|
|
@@ -285,6 +291,7 @@ __export(index_exports, {
|
|
|
285
291
|
requestPasswordResetFields: () => requestPasswordResetFields,
|
|
286
292
|
requirementsOptions: () => requirementsOptions,
|
|
287
293
|
resetPasswordFields: () => resetPasswordFields,
|
|
294
|
+
resolveAdminContextFromPath: () => resolveAdminContextFromPath,
|
|
288
295
|
resolveResourceImageActive: () => resolveResourceImageActive,
|
|
289
296
|
rewardNiceNames: () => rewardNiceNames,
|
|
290
297
|
seededShuffle: () => seededShuffle,
|
|
@@ -8591,8 +8598,102 @@ function hasAnyRole(roles, checkRoles) {
|
|
|
8591
8598
|
const set = new Set(normalizeRoles(roles));
|
|
8592
8599
|
return checkRoles.some((r) => set.has(r));
|
|
8593
8600
|
}
|
|
8601
|
+
|
|
8602
|
+
// src/auth/permissions/adminAppAccess.ts
|
|
8603
|
+
var ADMIN_APP_ROLES = [
|
|
8604
|
+
"super_admin" /* SUPER_ADMIN */,
|
|
8605
|
+
"admin" /* ADMIN */,
|
|
8606
|
+
"event" /* EVENT */,
|
|
8607
|
+
"vendor" /* VENDOR */,
|
|
8608
|
+
"partner" /* PARTNER */,
|
|
8609
|
+
"school" /* SCHOOL */,
|
|
8610
|
+
"affiliate" /* AFFILIATE */
|
|
8611
|
+
];
|
|
8612
|
+
var ADMIN_DASHBOARD_CONTEXTS = [
|
|
8613
|
+
{
|
|
8614
|
+
context: "staff",
|
|
8615
|
+
home: "/dashboard",
|
|
8616
|
+
label: "Staff",
|
|
8617
|
+
pathPrefixes: ["/dashboard"],
|
|
8618
|
+
roles: ["super_admin" /* SUPER_ADMIN */, "admin" /* ADMIN */]
|
|
8619
|
+
},
|
|
8620
|
+
{
|
|
8621
|
+
context: "event",
|
|
8622
|
+
home: "/event/dashboard",
|
|
8623
|
+
label: "Events",
|
|
8624
|
+
pathPrefixes: ["/event"],
|
|
8625
|
+
roles: ["event" /* EVENT */]
|
|
8626
|
+
},
|
|
8627
|
+
{
|
|
8628
|
+
context: "vendor",
|
|
8629
|
+
home: "/vendor/dashboard",
|
|
8630
|
+
label: "Stallholders",
|
|
8631
|
+
pathPrefixes: ["/vendor"],
|
|
8632
|
+
roles: ["vendor" /* VENDOR */]
|
|
8633
|
+
},
|
|
8634
|
+
{
|
|
8635
|
+
context: "partner",
|
|
8636
|
+
home: "/partner/dashboard",
|
|
8637
|
+
label: "Partners",
|
|
8638
|
+
pathPrefixes: ["/partner"],
|
|
8639
|
+
roles: ["partner" /* PARTNER */]
|
|
8640
|
+
},
|
|
8641
|
+
{
|
|
8642
|
+
context: "school",
|
|
8643
|
+
home: "/school/dashboard",
|
|
8644
|
+
label: "Schools",
|
|
8645
|
+
pathPrefixes: ["/school"],
|
|
8646
|
+
roles: ["school" /* SCHOOL */]
|
|
8647
|
+
},
|
|
8648
|
+
{
|
|
8649
|
+
context: "affiliate",
|
|
8650
|
+
home: "/affiliate/dashboard",
|
|
8651
|
+
label: "Affiliate",
|
|
8652
|
+
pathPrefixes: ["/affiliate"],
|
|
8653
|
+
roles: ["affiliate" /* AFFILIATE */]
|
|
8654
|
+
}
|
|
8655
|
+
];
|
|
8656
|
+
function canAccessAdminApp(roles) {
|
|
8657
|
+
return hasAnyRole(roles, ADMIN_APP_ROLES);
|
|
8658
|
+
}
|
|
8659
|
+
function getUsableAdminContexts(roles) {
|
|
8660
|
+
return ADMIN_DASHBOARD_CONTEXTS.filter((ctx) => hasAnyRole(roles, ctx.roles));
|
|
8661
|
+
}
|
|
8662
|
+
function getDefaultAdminHome(roles, preferredContext) {
|
|
8663
|
+
const usable = getUsableAdminContexts(roles);
|
|
8664
|
+
if (usable.length === 0) {
|
|
8665
|
+
return "/login";
|
|
8666
|
+
}
|
|
8667
|
+
if (preferredContext) {
|
|
8668
|
+
const preferred = usable.find((ctx) => ctx.context === preferredContext);
|
|
8669
|
+
if (preferred) return preferred.home;
|
|
8670
|
+
}
|
|
8671
|
+
return usable[0].home;
|
|
8672
|
+
}
|
|
8673
|
+
function resolveAdminContextFromPath(pathname) {
|
|
8674
|
+
for (const ctx of ADMIN_DASHBOARD_CONTEXTS) {
|
|
8675
|
+
if (ctx.pathPrefixes.some(
|
|
8676
|
+
(prefix) => pathname === prefix || pathname.startsWith(`${prefix}/`)
|
|
8677
|
+
)) {
|
|
8678
|
+
return ctx.context;
|
|
8679
|
+
}
|
|
8680
|
+
}
|
|
8681
|
+
return null;
|
|
8682
|
+
}
|
|
8683
|
+
function canAccessAdminPath(roles, pathname) {
|
|
8684
|
+
if (!canAccessAdminApp(roles)) return false;
|
|
8685
|
+
const context = resolveAdminContextFromPath(pathname);
|
|
8686
|
+
if (!context) {
|
|
8687
|
+
return true;
|
|
8688
|
+
}
|
|
8689
|
+
const info = ADMIN_DASHBOARD_CONTEXTS.find((ctx) => ctx.context === context);
|
|
8690
|
+
if (!info) return false;
|
|
8691
|
+
return hasAnyRole(roles, info.roles);
|
|
8692
|
+
}
|
|
8594
8693
|
// Annotate the CommonJS export names for ESM import in node:
|
|
8595
8694
|
0 && (module.exports = {
|
|
8695
|
+
ADMIN_APP_ROLES,
|
|
8696
|
+
ADMIN_DASHBOARD_CONTEXTS,
|
|
8596
8697
|
AFFILIATE_PARTICIPANT_TYPE_LABELS,
|
|
8597
8698
|
ANDROID_URL,
|
|
8598
8699
|
CLUEMART_MAIN_DOMAIN_URL,
|
|
@@ -8720,6 +8821,8 @@ function hasAnyRole(roles, checkRoles) {
|
|
|
8720
8821
|
buildShareOgDescriptionFromSections,
|
|
8721
8822
|
buildSharePagePath,
|
|
8722
8823
|
buildShareUrl,
|
|
8824
|
+
canAccessAdminApp,
|
|
8825
|
+
canAccessAdminPath,
|
|
8723
8826
|
capitalizeFirstLetter,
|
|
8724
8827
|
categoryColors,
|
|
8725
8828
|
cluemartSocialMedia,
|
|
@@ -8775,6 +8878,7 @@ function hasAnyRole(roles, checkRoles) {
|
|
|
8775
8878
|
gameTypeToDisplayName,
|
|
8776
8879
|
getAllowedEventDateStatuses,
|
|
8777
8880
|
getCurrentAndFutureDates,
|
|
8881
|
+
getDefaultAdminHome,
|
|
8778
8882
|
getErrorMessage,
|
|
8779
8883
|
getEventCalendarIsoDates,
|
|
8780
8884
|
getEventDatesWithStallholders,
|
|
@@ -8789,6 +8893,7 @@ function hasAnyRole(roles, checkRoles) {
|
|
|
8789
8893
|
getStallholderCategoryOptions,
|
|
8790
8894
|
getUnregisteredVendorCategoryNames,
|
|
8791
8895
|
getUnregisteredVendorStartDates,
|
|
8896
|
+
getUsableAdminContexts,
|
|
8792
8897
|
getVendorEventRelationDateOptions,
|
|
8793
8898
|
getVendorEventRelationStartDates,
|
|
8794
8899
|
getVendorEventsEmptyMessage,
|
|
@@ -8848,6 +8953,7 @@ function hasAnyRole(roles, checkRoles) {
|
|
|
8848
8953
|
requestPasswordResetFields,
|
|
8849
8954
|
requirementsOptions,
|
|
8850
8955
|
resetPasswordFields,
|
|
8956
|
+
resolveAdminContextFromPath,
|
|
8851
8957
|
resolveResourceImageActive,
|
|
8852
8958
|
rewardNiceNames,
|
|
8853
8959
|
seededShuffle,
|