@mostajs/rbac 2.3.0 → 2.3.1

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.
@@ -3,14 +3,14 @@
3
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  import { useState } from 'react';
5
5
  import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
6
- import { Button } from './ui/button';
7
- import { Input } from './ui/input';
8
- import { Label } from './ui/label';
9
- import { Badge } from './ui/badge';
10
- import { Card, CardContent } from './ui/card';
11
- import { Dialog, DialogContent, DialogHeader, DialogTitle, } from './ui/dialog';
12
- import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from './ui/alert-dialog';
13
- import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from './ui/table';
6
+ import { Button } from './ui/button.js';
7
+ import { Input } from './ui/input.js';
8
+ import { Label } from './ui/label.js';
9
+ import { Badge } from './ui/badge.js';
10
+ import { Card, CardContent } from './ui/card.js';
11
+ import { Dialog, DialogContent, DialogHeader, DialogTitle, } from './ui/dialog.js';
12
+ import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from './ui/alert-dialog.js';
13
+ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from './ui/table.js';
14
14
  import { Plus, Pencil, Trash2, Loader2 } from 'lucide-react';
15
15
  import { toast } from 'sonner';
16
16
  import { createCategoriesApi, createPermissionsApi } from '../lib/rbac-api';
@@ -3,11 +3,11 @@
3
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  import { useState, useCallback, Fragment } from 'react';
5
5
  import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
6
- import { Button } from './ui/button';
7
- import { Badge } from './ui/badge';
8
- import { Card, CardContent } from './ui/card';
9
- import { Checkbox } from './ui/checkbox';
10
- import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from './ui/table';
6
+ import { Button } from './ui/button.js';
7
+ import { Badge } from './ui/badge.js';
8
+ import { Card, CardContent } from './ui/card.js';
9
+ import { Checkbox } from './ui/checkbox.js';
10
+ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from './ui/table.js';
11
11
  import { Loader2, Save, Database } from 'lucide-react';
12
12
  import { toast } from 'sonner';
13
13
  import { createMatrixApi } from '../lib/rbac-api';
@@ -3,15 +3,15 @@
3
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  import { useState } from 'react';
5
5
  import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
6
- import { Button } from './ui/button';
7
- import { Input } from './ui/input';
8
- import { Label } from './ui/label';
9
- import { Badge } from './ui/badge';
10
- import { Card, CardContent } from './ui/card';
11
- import { Dialog, DialogContent, DialogHeader, DialogTitle, } from './ui/dialog';
12
- import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from './ui/alert-dialog';
13
- import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from './ui/table';
14
- import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from './ui/select';
6
+ import { Button } from './ui/button.js';
7
+ import { Input } from './ui/input.js';
8
+ import { Label } from './ui/label.js';
9
+ import { Badge } from './ui/badge.js';
10
+ import { Card, CardContent } from './ui/card.js';
11
+ import { Dialog, DialogContent, DialogHeader, DialogTitle, } from './ui/dialog.js';
12
+ import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from './ui/alert-dialog.js';
13
+ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from './ui/table.js';
14
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from './ui/select.js';
15
15
  import { Plus, Pencil, Trash2, Loader2 } from 'lucide-react';
16
16
  import { toast } from 'sonner';
17
17
  import { createPermissionsApi, createCategoriesApi } from '../lib/rbac-api';
@@ -2,12 +2,12 @@
2
2
  'use client';
3
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  import { useState } from 'react';
5
- import { Tabs, TabsContent, TabsList, TabsTrigger } from './ui/tabs';
5
+ import { Tabs, TabsContent, TabsList, TabsTrigger } from './ui/tabs.js';
6
6
  import { Shield } from 'lucide-react';
7
- import { PermissionMatrix } from './PermissionMatrix';
8
- import { RolesManager } from './RolesManager';
9
- import { PermissionsManager } from './PermissionsManager';
10
- import { CategoriesManager } from './CategoriesManager';
7
+ import { PermissionMatrix } from './PermissionMatrix.js';
8
+ import { RolesManager } from './RolesManager.js';
9
+ import { PermissionsManager } from './PermissionsManager.js';
10
+ import { CategoriesManager } from './CategoriesManager.js';
11
11
  const defaultT = (key) => key;
12
12
  export function RBACManager({ apiBasePath = '/api', t = defaultT, systemRoles = [], roleColors, statusColors, }) {
13
13
  const [tab, setTab] = useState('matrix');
@@ -3,14 +3,14 @@
3
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  import { useState } from 'react';
5
5
  import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
6
- import { Button } from './ui/button';
7
- import { Input } from './ui/input';
8
- import { Label } from './ui/label';
9
- import { Badge } from './ui/badge';
10
- import { Card, CardContent } from './ui/card';
11
- import { Dialog, DialogContent, DialogHeader, DialogTitle, } from './ui/dialog';
12
- import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from './ui/alert-dialog';
13
- import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from './ui/table';
6
+ import { Button } from './ui/button.js';
7
+ import { Input } from './ui/input.js';
8
+ import { Label } from './ui/label.js';
9
+ import { Badge } from './ui/badge.js';
10
+ import { Card, CardContent } from './ui/card.js';
11
+ import { Dialog, DialogContent, DialogHeader, DialogTitle, } from './ui/dialog.js';
12
+ import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from './ui/alert-dialog.js';
13
+ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from './ui/table.js';
14
14
  import { Plus, Pencil, Trash2, Loader2 } from 'lucide-react';
15
15
  import { toast } from 'sonner';
16
16
  import { createRolesApi } from '../lib/rbac-api';
@@ -3,16 +3,16 @@
3
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  import { useState } from 'react';
5
5
  import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
6
- import { Button } from './ui/button';
7
- import { Input } from './ui/input';
8
- import { Label } from './ui/label';
9
- import { Badge } from './ui/badge';
10
- import { Card, CardContent } from './ui/card';
11
- import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger, } from './ui/dialog';
12
- import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from './ui/select';
13
- import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from './ui/table';
6
+ import { Button } from './ui/button.js';
7
+ import { Input } from './ui/input.js';
8
+ import { Label } from './ui/label.js';
9
+ import { Badge } from './ui/badge.js';
10
+ import { Card, CardContent } from './ui/card.js';
11
+ import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger, } from './ui/dialog.js';
12
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from './ui/select.js';
13
+ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from './ui/table.js';
14
14
  import { Plus, Pencil, Trash2, Loader2 } from 'lucide-react';
15
- import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from './ui/alert-dialog';
15
+ import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from './ui/alert-dialog.js';
16
16
  import { toast } from 'sonner';
17
17
  import { createUsersApi } from '../lib/rbac-api';
18
18
  const defaultT = (key) => key;
@@ -14,7 +14,7 @@ var __rest = (this && this.__rest) || function (s, e) {
14
14
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
15
  import { AlertDialog as AlertDialogPrimitive } from "radix-ui";
16
16
  import { cn } from "../../lib/utils";
17
- import { Button } from "./button";
17
+ import { Button } from "./button.js";
18
18
  function AlertDialog(_a) {
19
19
  var props = __rest(_a, []);
20
20
  return _jsx(AlertDialogPrimitive.Root, Object.assign({ "data-slot": "alert-dialog" }, props));
@@ -15,7 +15,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
15
  import { XIcon } from "lucide-react";
16
16
  import { Dialog as DialogPrimitive } from "radix-ui";
17
17
  import { cn } from "../../lib/utils";
18
- import { Button } from "./button";
18
+ import { Button } from "./button.js";
19
19
  function Dialog(_a) {
20
20
  var props = __rest(_a, []);
21
21
  return _jsx(DialogPrimitive.Root, Object.assign({ "data-slot": "dialog" }, props));
package/dist/index.js CHANGED
@@ -2,27 +2,27 @@
2
2
  // @mostajs/rbac — Client-safe barrel (NO ORM imports)
3
3
  // For server-side code (repos, seed, permissions-server), use '@mostajs/rbac/server'
4
4
  // Schemas (pure data definitions — no ORM dependency)
5
- export { UserSchema } from './schemas/user.schema';
6
- export { RoleSchema } from './schemas/role.schema';
7
- export { PermissionSchema } from './schemas/permission.schema';
8
- export { PermissionCategorySchema } from './schemas/permission-category.schema';
9
- export { AccountSchema } from './schemas/account.schema';
5
+ export { UserSchema } from './schemas/user.schema.js';
6
+ export { RoleSchema } from './schemas/role.schema.js';
7
+ export { PermissionSchema } from './schemas/permission.schema.js';
8
+ export { PermissionCategorySchema } from './schemas/permission-category.schema.js';
9
+ export { AccountSchema } from './schemas/account.schema.js';
10
10
  // Menu contribution
11
- export { rbacMenuContribution } from './lib/menu';
11
+ export { rbacMenuContribution } from './lib/menu.js';
12
12
  // Pages (client-side, registered via PageRegistration)
13
- export { default as UsersPage } from './pages/UsersPage';
14
- export { default as RolesPage } from './pages/RolesPage';
13
+ export { default as UsersPage } from './pages/UsersPage.js';
14
+ export { default as RolesPage } from './pages/RolesPage.js';
15
15
  // i18n
16
- export { t as rbacT } from './lib/i18n';
16
+ export { t as rbacT } from './lib/i18n.js';
17
17
  // Components (client-side)
18
- export { UsersManager } from './components/UsersManager';
19
- export { RBACManager } from './components/RBACManager';
20
- export { RolesManager } from './components/RolesManager';
21
- export { PermissionsManager } from './components/PermissionsManager';
22
- export { CategoriesManager } from './components/CategoriesManager';
23
- export { PermissionMatrix } from './components/PermissionMatrix';
18
+ export { UsersManager } from './components/UsersManager.js';
19
+ export { RBACManager } from './components/RBACManager.js';
20
+ export { RolesManager } from './components/RolesManager.js';
21
+ export { PermissionsManager } from './components/PermissionsManager.js';
22
+ export { CategoriesManager } from './components/CategoriesManager.js';
23
+ export { PermissionMatrix } from './components/PermissionMatrix.js';
24
24
  // Permission matching helpers
25
- export { hasPermission, matchesPermission } from './helpers/permissions';
25
+ export { hasPermission, matchesPermission } from './helpers/permissions.js';
26
26
  // API helpers (client-side fetch wrappers — no server deps)
27
- export { createUsersApi, createRolesApi, createPermissionsApi, createMatrixApi, createCategoriesApi, } from './lib/rbac-api';
27
+ export { createUsersApi, createRolesApi, createPermissionsApi, createMatrixApi, createCategoriesApi, } from './lib/rbac-api.js';
28
28
  //# sourceMappingURL=index.js.map
package/dist/server.js CHANGED
@@ -2,32 +2,32 @@
2
2
  // @mostajs/rbac/server — Server-side exports (ORM-dependent)
3
3
  // Import from '@mostajs/rbac/server' in API routes and server code
4
4
  // Repositories (depend on @mostajs/orm)
5
- export { UserRepository } from './repositories/user.repository';
6
- export { RoleRepository } from './repositories/role.repository';
7
- export { PermissionRepository } from './repositories/permission.repository';
8
- export { PermissionCategoryRepository } from './repositories/permission-category.repository';
9
- export { AccountRepository } from './repositories/account.repository';
5
+ export { UserRepository } from './repositories/user.repository.js';
6
+ export { RoleRepository } from './repositories/role.repository.js';
7
+ export { PermissionRepository } from './repositories/permission.repository.js';
8
+ export { PermissionCategoryRepository } from './repositories/permission-category.repository.js';
9
+ export { AccountRepository } from './repositories/account.repository.js';
10
10
  // RBAC seed (depends on repos → ORM)
11
- export { seedRBAC } from './lib/rbac-seed';
11
+ export { seedRBAC } from './lib/rbac-seed.js';
12
12
  // Pre-built RBAC seeds (categories + permissions + roles ready to apply)
13
- export { OCTONET_RBAC_SEED, OCTONET_PERMS } from './seeds/octonet';
13
+ export { OCTONET_RBAC_SEED, OCTONET_PERMS } from './seeds/octonet.js';
14
14
  // Permission matching helpers
15
- export { hasPermission, matchesPermission } from './helpers/permissions';
15
+ export { hasPermission, matchesPermission } from './helpers/permissions.js';
16
16
  // Create admin (depends on repos → ORM + bcrypt)
17
- export { createAdmin } from './lib/create-admin';
17
+ export { createAdmin } from './lib/create-admin.js';
18
18
  // Module info (schemas, seeds, metadata — for setup discovery)
19
- export { getSchemas, moduleInfo } from './lib/module-info';
19
+ export { getSchemas, moduleInfo } from './lib/module-info.js';
20
20
  // Server-side permission DB lookup (depends on repos → ORM)
21
- export { getPermissionsForRoleFromDB } from './lib/permissions-server';
21
+ export { getPermissionsForRoleFromDB } from './lib/permissions-server.js';
22
22
  // API handler factories
23
- export { createUsersHandler } from './api/users';
24
- export { createUsersIdHandler } from './api/users-id';
25
- export { createRolesHandler } from './api/roles';
26
- export { createRolesIdHandler } from './api/roles-id';
27
- export { createPermissionsHandler } from './api/permissions';
28
- export { createPermissionsIdHandler } from './api/permissions-id';
29
- export { createMatrixHandler } from './api/matrix';
30
- export { createCategoriesHandler } from './api/categories';
31
- export { createCategoriesIdHandler } from './api/categories-id';
32
- export { createSeedHandler } from './api/seed';
23
+ export { createUsersHandler } from './api/users.js';
24
+ export { createUsersIdHandler } from './api/users-id.js';
25
+ export { createRolesHandler } from './api/roles.js';
26
+ export { createRolesIdHandler } from './api/roles-id.js';
27
+ export { createPermissionsHandler } from './api/permissions.js';
28
+ export { createPermissionsIdHandler } from './api/permissions-id.js';
29
+ export { createMatrixHandler } from './api/matrix.js';
30
+ export { createCategoriesHandler } from './api/categories.js';
31
+ export { createCategoriesIdHandler } from './api/categories-id.js';
32
+ export { createSeedHandler } from './api/seed.js';
33
33
  //# sourceMappingURL=server.js.map
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@mostajs/rbac",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "RBAC — User/Role/Permission schemas, repos, management UI, API handlers",
5
5
  "author": "Dr Hamid MADANI <drmdh@msn.com>",
6
6
  "license": "AGPL-3.0-or-later",
7
+ "type": "module",
7
8
  "main": "dist/index.js",
8
9
  "types": "dist/index.d.ts",
9
10
  "exports": {
@@ -187,7 +188,8 @@
187
188
  "node": ">=18.0.0"
188
189
  },
189
190
  "scripts": {
190
- "build": "tsc",
191
+ "build": "tsc && npm run fix-esm",
192
+ "fix-esm": "find dist -name '*.js' -exec sed -i -E \"s|from '(\\\\./[^']+)'(;?)|from '\\\\1.js'\\\\2|g; s|from \\\"(\\\\./[^\\\"]+)\\\"(;?)|from \\\"\\\\1.js\\\"\\\\2|g\" {} \\; && find dist -name '*.js' -exec sed -i -E \"s|\\\\.js\\\\.js|.js|g\" {} \\;",
191
193
  "prepublishOnly": "npm run build"
192
194
  },
193
195
  "dependencies": {