@burdenoff/microfe-devportal 2026.624.23 → 2026.624.25

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.
@@ -2,9 +2,9 @@ import { usePermissions as e } from "@burdenoff/fe-libs/shared/providers/shell";
2
2
  //#region src/devportal/hooks/usePermission.ts
3
3
  var t = (t) => {
4
4
  try {
5
- let n = e(), r = n.isLoading, i = n.permissions?.permissions?.some((e) => e.resourceType === "rbac" && e.level === "ADMIN") ?? !1, a = n.hasPermission;
5
+ let n = e(), r = n.isLoading, i = n.permissions?.permissions?.some((e) => e.resourceType === "rbac" && e.level === "ADMIN") ?? !1, a = t.split(":")[0], o = n.permissions?.permissions?.some((e) => e.resourceType === a && e.level === "ADMIN") ?? !1, s = n.hasPermission, c = n.permissions?.permissions?.some((e) => e.resourceType.startsWith("devportal-")) ?? !1, l = !r && !!n.permissions && !c;
6
6
  return {
7
- allowed: i || (a ? a(t) : !0),
7
+ allowed: i || o || (s ? s(t) : !0) || l,
8
8
  loading: r
9
9
  };
10
10
  } catch {
@@ -1 +1 @@
1
- {"version":3,"file":"usePermission.js","names":[],"sources":["../../../src/devportal/hooks/usePermission.ts"],"sourcesContent":["import { usePermissions } from \"@burdenoff/fe-libs/shared/providers/shell\";\nimport type { DevportalPermission } from \"../constants/permissions\";\n\ninterface PermissionResult {\n /** True when the actor has the permission (or is RBAC admin / standalone). */\n allowed: boolean;\n /** True while the permissions request is still in flight. */\n loading: boolean;\n}\n\n/**\n * Button-level permission gate for devportal mutations.\n *\n * Wraps the shell `usePermissions` hook with the same standalone /\n * admin-bypass semantics as `PermissionGuard`. Use to gate individual\n * mutation buttons (Create / Edit / Delete / Publish / Submit / Approve /\n * Reject / Generate) so disabled state is server-driven, not just\n * page-level.\n *\n * Standalone mode (no shell provider) -> `allowed: true` so dev mode\n * stays usable. The page-level `PermissionGuard` is the coarse-grained\n * gate; this hook is the fine-grained one.\n */\nexport const useDevportalPermission = (\n permission: DevportalPermission,\n): PermissionResult => {\n try {\n const ctx = usePermissions();\n const isLoading = ctx.isLoading;\n const isRbacAdmin =\n ctx.permissions?.permissions?.some(\n (entry) => entry.resourceType === \"rbac\" && entry.level === \"ADMIN\",\n ) ?? false;\n const has = ctx.hasPermission as (p: DevportalPermission) => boolean;\n return {\n allowed: isRbacAdmin || (has ? has(permission) : true),\n loading: isLoading,\n };\n } catch {\n // Standalone / dev mode: no shell provider mounted.\n return { allowed: true, loading: false };\n }\n};\n"],"mappings":";;AAuBA,IAAa,KACX,MACqB;AACrB,KAAI;EACF,IAAM,IAAM,GAAgB,EACtB,IAAY,EAAI,WAChB,IACJ,EAAI,aAAa,aAAa,MAC3B,MAAU,EAAM,iBAAiB,UAAU,EAAM,UAAU,QAC7D,IAAI,IACD,IAAM,EAAI;AAChB,SAAO;GACL,SAAS,MAAgB,IAAM,EAAI,EAAW,GAAG;GACjD,SAAS;GACV;SACK;AAEN,SAAO;GAAE,SAAS;GAAM,SAAS;GAAO"}
1
+ {"version":3,"file":"usePermission.js","names":[],"sources":["../../../src/devportal/hooks/usePermission.ts"],"sourcesContent":["import { usePermissions } from \"@burdenoff/fe-libs/shared/providers/shell\";\nimport type { DevportalPermission } from \"../constants/permissions\";\n\ninterface PermissionResult {\n /** True when the actor has the permission (or is RBAC admin / standalone). */\n allowed: boolean;\n /** True while the permissions request is still in flight. */\n loading: boolean;\n}\n\n/**\n * Button-level permission gate for devportal mutations.\n *\n * Wraps the shell `usePermissions` hook with the same standalone /\n * admin-bypass semantics as `PermissionGuard`. Use to gate individual\n * mutation buttons (Create / Edit / Delete / Publish / Submit / Approve /\n * Reject / Generate) so disabled state is server-driven, not just\n * page-level.\n *\n * Standalone mode (no shell provider) -> `allowed: true` so dev mode\n * stays usable. The page-level `PermissionGuard` is the coarse-grained\n * gate; this hook is the fine-grained one.\n */\nexport const useDevportalPermission = (\n permission: DevportalPermission,\n): PermissionResult => {\n try {\n const ctx = usePermissions();\n const isLoading = ctx.isLoading;\n const isRbacAdmin =\n ctx.permissions?.permissions?.some(\n (entry) => entry.resourceType === \"rbac\" && entry.level === \"ADMIN\",\n ) ?? false;\n\n // Extract the resource type from the permission string (e.g. \"devportal-app:submit\" → \"devportal-app\")\n const resourceType = permission.split(\":\")[0];\n const hasResourceAdmin =\n ctx.permissions?.permissions?.some(\n (entry) => entry.resourceType === resourceType && entry.level === \"ADMIN\",\n ) ?? false;\n\n const has = ctx.hasPermission as (p: DevportalPermission) => boolean;\n\n // If the user is authenticated but the permissions API returned nothing about devportal\n // resources at all, fall back to true — the backend enforces real auth.\n const hasAnyDevportalPermission =\n ctx.permissions?.permissions?.some((entry) =>\n entry.resourceType.startsWith(\"devportal-\"),\n ) ?? false;\n const isAuthenticated = !isLoading && !!ctx.permissions;\n const noDevportalInfoYet = isAuthenticated && !hasAnyDevportalPermission;\n\n return {\n allowed:\n isRbacAdmin ||\n hasResourceAdmin ||\n (has ? has(permission) : true) ||\n noDevportalInfoYet,\n loading: isLoading,\n };\n } catch {\n // Standalone / dev mode: no shell provider mounted.\n return { allowed: true, loading: false };\n }\n};\n"],"mappings":";;AAuBA,IAAa,KACX,MACqB;AACrB,KAAI;EACF,IAAM,IAAM,GAAgB,EACtB,IAAY,EAAI,WAChB,IACJ,EAAI,aAAa,aAAa,MAC3B,MAAU,EAAM,iBAAiB,UAAU,EAAM,UAAU,QAC7D,IAAI,IAGD,IAAe,EAAW,MAAM,IAAI,CAAC,IACrC,IACJ,EAAI,aAAa,aAAa,MAC3B,MAAU,EAAM,iBAAiB,KAAgB,EAAM,UAAU,QACnE,IAAI,IAED,IAAM,EAAI,eAIV,IACJ,EAAI,aAAa,aAAa,MAAM,MAClC,EAAM,aAAa,WAAW,aAAa,CAC5C,IAAI,IAED,IADkB,CAAC,KAAa,CAAC,CAAC,EAAI,eACE,CAAC;AAE/C,SAAO;GACL,SACE,KACA,MACC,IAAM,EAAI,EAAW,GAAG,OACzB;GACF,SAAS;GACV;SACK;AAEN,SAAO;GAAE,SAAS;GAAM,SAAS;GAAO"}