@mostajs/audit 1.0.4 → 1.0.6

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.
@@ -0,0 +1 @@
1
+ export declare function GET(req: Request): Promise<Response>;
@@ -0,0 +1,28 @@
1
+ // @mostajs/audit — Route handler for audit-log
2
+ // Author: Dr Hamid MADANI drmdh@msn.com
3
+ // Bare handler — NO auth. The socle catch-all does it via permission.
4
+ import { AuditLogRepository } from '../../repositories/audit-log.repository.js';
5
+ export async function GET(req) {
6
+ const url = new URL(req.url);
7
+ const page = parseInt(url.searchParams.get('page') || '1', 10);
8
+ const limit = parseInt(url.searchParams.get('limit') || '50', 10);
9
+ const module = url.searchParams.get('module') || undefined;
10
+ const action = url.searchParams.get('action') || undefined;
11
+ const userId = url.searchParams.get('userId') || undefined;
12
+ const status = url.searchParams.get('status') || undefined;
13
+ const dateFrom = url.searchParams.get('dateFrom') || url.searchParams.get('from') || null;
14
+ const dateTo = url.searchParams.get('dateTo') || url.searchParams.get('to') || null;
15
+ const { getDialect } = await import('@mostajs/orm');
16
+ const dialect = await getDialect();
17
+ const repo = new AuditLogRepository(dialect);
18
+ const { data: logs, total } = await repo.findPaginated({
19
+ module, action, userId, status,
20
+ from: dateFrom ? new Date(dateFrom) : undefined,
21
+ to: dateTo ? new Date(dateTo + 'T23:59:59.999Z') : undefined,
22
+ page, limit,
23
+ });
24
+ return Response.json({
25
+ data: logs,
26
+ pagination: { page, limit, total, totalPages: Math.ceil(total / limit) },
27
+ });
28
+ }
@@ -0,0 +1,4 @@
1
+ import type { ModuleRegistration } from '@mostajs/socle';
2
+ export declare function register(registry: {
3
+ register(r: ModuleRegistration): void;
4
+ }): void;
@@ -0,0 +1,41 @@
1
+ // @mostajs/audit — Runtime module registration
2
+ // Author: Dr Hamid MADANI drmdh@msn.com
3
+ import { AuditLogSchema } from './schemas/audit-log.schema.js';
4
+ import { AuditLogRepository } from './repositories/audit-log.repository.js';
5
+ import { auditMenuContribution } from './lib/menu.js';
6
+ import { GET as auditLogGET } from './lib/handlers/audit-log.js';
7
+ export function register(registry) {
8
+ registry.register({
9
+ manifest: {
10
+ name: 'audit',
11
+ package: '@mostajs/audit',
12
+ version: '2.0.0',
13
+ type: 'core',
14
+ priority: 5,
15
+ dependencies: ['auth'],
16
+ displayName: 'Audit',
17
+ description: 'Audit logging — activity journal with filtering and pagination',
18
+ icon: 'FileText',
19
+ register: './dist/register.js',
20
+ },
21
+ schemas: [
22
+ { name: 'AuditLog', schema: AuditLogSchema },
23
+ ],
24
+ repositories: {
25
+ auditLogRepo: (dialect) => new AuditLogRepository(dialect),
26
+ },
27
+ permissions: {
28
+ permissions: { AUDIT_VIEW: 'audit:view' },
29
+ definitions: [
30
+ { code: 'audit:view', name: 'audit:view', description: 'Consulter les journaux d\'audit', category: 'audit' },
31
+ ],
32
+ categories: [
33
+ { name: 'audit', label: 'Audit', description: 'Consultation des journaux d\'audit', icon: 'FileText', order: 20, system: true },
34
+ ],
35
+ },
36
+ routes: [
37
+ { path: 'audit-log', handlers: { GET: auditLogGET }, permission: 'audit:view' },
38
+ ],
39
+ menu: auditMenuContribution,
40
+ });
41
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mostajs/audit",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Reusable audit logging module — fire-and-forget logAudit() with paginated consultation",
5
5
  "author": "Dr Hamid MADANI <drmdh@msn.com>",
6
6
  "license": "MIT",
@@ -32,10 +32,16 @@
32
32
  "types": "./dist/lib/menu.d.ts",
33
33
  "import": "./dist/lib/menu.js",
34
34
  "default": "./dist/lib/menu.js"
35
+ },
36
+ "./register": {
37
+ "types": "./dist/register.d.ts",
38
+ "import": "./dist/register.js",
39
+ "default": "./dist/register.js"
35
40
  }
36
41
  },
37
42
  "files": [
38
43
  "dist",
44
+ "wire.json",
39
45
  "audit.wire.json",
40
46
  "LICENSE",
41
47
  "README.md"
@@ -64,6 +70,7 @@
64
70
  },
65
71
  "peerDependencies": {
66
72
  "@mostajs/menu": ">=1.0.2",
73
+ "@mostajs/socle": ">=2.0.0",
67
74
  "next": ">=14",
68
75
  "react": ">=18"
69
76
  },
@@ -80,6 +87,7 @@
80
87
  },
81
88
  "devDependencies": {
82
89
  "@mostajs/menu": "^1.0.2",
90
+ "@mostajs/socle": "^2.0.0",
83
91
  "@types/react": "^19.0.0",
84
92
  "next": "^16.1.6",
85
93
  "react": "^19.0.0",
package/wire.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "audit",
3
+ "package": "@mostajs/audit",
4
+ "version": "2.0.0",
5
+ "type": "core",
6
+ "priority": 5,
7
+ "dependencies": ["auth"],
8
+ "displayName": "Audit",
9
+ "description": "Audit logging — activity journal with filtering and pagination",
10
+ "icon": "FileText",
11
+ "register": "./dist/register.js"
12
+ }