@timardex/cluemart-shared 1.5.828 → 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 +109 -13
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.mts +24 -4
- package/dist/auth/index.d.ts +24 -4
- package/dist/auth/index.mjs +18 -8
- package/dist/auth/index.mjs.map +1 -1
- package/dist/{chunk-GHW3ZGBY.mjs → chunk-VPANTTZI.mjs} +102 -8
- package/dist/chunk-VPANTTZI.mjs.map +1 -0
- package/dist/hooks/index.cjs +56 -6
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.mjs +1 -1
- package/dist/index.cjs +107 -6
- 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 +100 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-GHW3ZGBY.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,
|
|
@@ -8505,9 +8512,6 @@ var WILDCARD_PERMISSION = "*";
|
|
|
8505
8512
|
// src/auth/permissions/rolePermissions.ts
|
|
8506
8513
|
var ADMIN_PERMISSIONS = [
|
|
8507
8514
|
"dashboard.admin",
|
|
8508
|
-
"users.read",
|
|
8509
|
-
"users.update",
|
|
8510
|
-
"users.delete",
|
|
8511
8515
|
"events.read",
|
|
8512
8516
|
"events.create",
|
|
8513
8517
|
"events.update",
|
|
@@ -8535,9 +8539,7 @@ var ADMIN_PERMISSIONS = [
|
|
|
8535
8539
|
"posts.read",
|
|
8536
8540
|
"posts.create",
|
|
8537
8541
|
"posts.update",
|
|
8538
|
-
"posts.delete"
|
|
8539
|
-
"settings.read",
|
|
8540
|
-
"settings.update"
|
|
8542
|
+
"posts.delete"
|
|
8541
8543
|
];
|
|
8542
8544
|
var ROLE_PERMISSIONS = {
|
|
8543
8545
|
["super_admin" /* SUPER_ADMIN */]: ["*"],
|
|
@@ -8596,8 +8598,102 @@ function hasAnyRole(roles, checkRoles) {
|
|
|
8596
8598
|
const set = new Set(normalizeRoles(roles));
|
|
8597
8599
|
return checkRoles.some((r) => set.has(r));
|
|
8598
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
|
+
}
|
|
8599
8693
|
// Annotate the CommonJS export names for ESM import in node:
|
|
8600
8694
|
0 && (module.exports = {
|
|
8695
|
+
ADMIN_APP_ROLES,
|
|
8696
|
+
ADMIN_DASHBOARD_CONTEXTS,
|
|
8601
8697
|
AFFILIATE_PARTICIPANT_TYPE_LABELS,
|
|
8602
8698
|
ANDROID_URL,
|
|
8603
8699
|
CLUEMART_MAIN_DOMAIN_URL,
|
|
@@ -8725,6 +8821,8 @@ function hasAnyRole(roles, checkRoles) {
|
|
|
8725
8821
|
buildShareOgDescriptionFromSections,
|
|
8726
8822
|
buildSharePagePath,
|
|
8727
8823
|
buildShareUrl,
|
|
8824
|
+
canAccessAdminApp,
|
|
8825
|
+
canAccessAdminPath,
|
|
8728
8826
|
capitalizeFirstLetter,
|
|
8729
8827
|
categoryColors,
|
|
8730
8828
|
cluemartSocialMedia,
|
|
@@ -8780,6 +8878,7 @@ function hasAnyRole(roles, checkRoles) {
|
|
|
8780
8878
|
gameTypeToDisplayName,
|
|
8781
8879
|
getAllowedEventDateStatuses,
|
|
8782
8880
|
getCurrentAndFutureDates,
|
|
8881
|
+
getDefaultAdminHome,
|
|
8783
8882
|
getErrorMessage,
|
|
8784
8883
|
getEventCalendarIsoDates,
|
|
8785
8884
|
getEventDatesWithStallholders,
|
|
@@ -8794,6 +8893,7 @@ function hasAnyRole(roles, checkRoles) {
|
|
|
8794
8893
|
getStallholderCategoryOptions,
|
|
8795
8894
|
getUnregisteredVendorCategoryNames,
|
|
8796
8895
|
getUnregisteredVendorStartDates,
|
|
8896
|
+
getUsableAdminContexts,
|
|
8797
8897
|
getVendorEventRelationDateOptions,
|
|
8798
8898
|
getVendorEventRelationStartDates,
|
|
8799
8899
|
getVendorEventsEmptyMessage,
|
|
@@ -8853,6 +8953,7 @@ function hasAnyRole(roles, checkRoles) {
|
|
|
8853
8953
|
requestPasswordResetFields,
|
|
8854
8954
|
requirementsOptions,
|
|
8855
8955
|
resetPasswordFields,
|
|
8956
|
+
resolveAdminContextFromPath,
|
|
8856
8957
|
resolveResourceImageActive,
|
|
8857
8958
|
rewardNiceNames,
|
|
8858
8959
|
seededShuffle,
|