@fonderie/audit 1.0.0 → 2.0.0

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,14 @@
1
+ <!-- GENERATED — do not edit. Regenerate with: npm run docs:signatures -->
2
+
3
+ # @fonderie/audit — outcomes
4
+
5
+ What this package does to a running app: tables its migrations create,
6
+ rows it seeds, routes it registers. Generated from the migration SQL and
7
+ route tables in source — trust this file instead of reading `dist/` or
8
+ downloading tarballs.
9
+
10
+ ## HTTP routes registered
11
+
12
+ | Method | Path | Middleware chain (auth / validation / handler) |
13
+ |---|---|---|
14
+ | GET | `/audit` | `requireAuth → async (ctx) => { if (!ctx.workspace) return setApiResponse( HTTP.UNPROCESSABLE, 'MISSING_WORKSPACE', 'Workspace context required', ); const url = new URL(ctx.request.url); const params = url.searchParams; const limit = Math.min(Number(params.get('limit') ?? 50), 200); const type = params.get('type') ?? undefined; const actor = params.get('actorId') ?? undefined; const from = params.get('from') ? new Date(params.get('from')!) : undefined; const to = params.get('to') ? new Date(params.get('to')!) : undefined; const cursor = params.get('cursor') ?? undefined; const query: Parameters<AuditEventModel['list']>[0] = { workspaceId: ctx.workspace.id, limit: limit + 1, }; if (type) query.type = type; if (actor) query.actorId = actor; if (from) query.from = from; if (to) query.to = to; if (cursor) query.cursor = cursor; const events = await new AuditEventModel(store).list(query); // fetch one extra to determine if there's a next page const hasMore = events.length > limit; const page = hasMore ? events.slice(0, limit) : events; const lastEvent = page[page.length - 1]; const nextCursor = hasMore && lastEvent ? encodeCursor(lastEvent.createdAt, lastEvent.id) : null; return setApiResponse(HTTP.OK, 'AUDIT_FETCHED', 'Audit events retrieved.', { events: page.map(toAuditEventDTO), nextCursor, }); }` |
@@ -0,0 +1,44 @@
1
+ <!-- GENERATED — do not edit. Regenerate with: npm run docs:signatures -->
2
+
3
+ # @fonderie/audit — signatures
4
+
5
+ ## @fonderie/audit
6
+
7
+ ```ts
8
+ new AuditModule(store: IStoreAdapter): AuditModule
9
+ .name: "@fonderie/audit"
10
+ .deps: string[]
11
+ .install(app: IFonderieApp): void
12
+
13
+ interface IAuditEvent {
14
+ id: string;
15
+ type: string;
16
+ payload: Record<string, unknown>;
17
+ meta: Record<string, unknown>;
18
+ createdAt: Date;
19
+ }
20
+
21
+ interface IAuditQuery {
22
+ workspaceId: string;
23
+ type?: string;
24
+ actorId?: string;
25
+ from?: Date;
26
+ to?: Date;
27
+ limit?: number;
28
+ cursor?: string;
29
+ }
30
+
31
+ interface IAuditEventDTO {
32
+ id: string;
33
+ type: string;
34
+ actorId: string | null;
35
+ requestId: string | null;
36
+ payload: Record<string, unknown>;
37
+ createdAt: string;
38
+ }
39
+
40
+ interface IAuditPageDTO {
41
+ events: IAuditEventDTO[];
42
+ nextCursor: string | null;
43
+ }
44
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonderie/audit",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "Workspace-scoped audit log — query fonderie_events for a human-readable activity trail.",
5
5
  "keywords": [
6
6
  "fonderie-js",
@@ -34,8 +34,8 @@
34
34
  "check": "biome check --write src"
35
35
  },
36
36
  "peerDependencies": {
37
- "@fonderie/core": "^0.1.0",
38
- "@fonderie/store": "^0.1.0"
37
+ "@fonderie/core": "^0.2.0",
38
+ "@fonderie/store": "^0.1.1"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@fonderie/core": "../core",
@@ -50,16 +50,17 @@
50
50
  },
51
51
  "files": [
52
52
  "dist",
53
+ "brain",
53
54
  "LICENSE",
54
55
  "README.md"
55
56
  ],
56
57
  "repository": {
57
58
  "type": "git",
58
- "url": "git+https://github.com/fonderie-js/sdk.git",
59
+ "url": "git+https://github.com/fonderiejs/sdk.git",
59
60
  "directory": "packages/audit"
60
61
  },
61
- "homepage": "https://github.com/fonderie-js/sdk/tree/main/packages/audit#readme",
62
+ "homepage": "https://github.com/fonderiejs/sdk/tree/main/packages/audit#readme",
62
63
  "bugs": {
63
- "url": "https://github.com/fonderie-js/sdk/issues"
64
+ "url": "https://github.com/fonderiejs/sdk/issues"
64
65
  }
65
66
  }