@contractspec/module.audit-trail 3.7.6 → 3.7.10
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/README.md +55 -100
- package/dist/browser/contracts/index.js +2 -2
- package/dist/browser/index.js +2 -2
- package/dist/contracts/index.js +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/node/contracts/index.js +2 -2
- package/dist/node/index.js +2 -2
- package/dist/storage/index.d.ts +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -1,113 +1,68 @@
|
|
|
1
1
|
# @contractspec/module.audit-trail
|
|
2
2
|
|
|
3
|
-
Website: https://contractspec.io
|
|
3
|
+
Website: https://contractspec.io
|
|
4
4
|
|
|
5
|
+
**Audit trail module for tracking and querying system events.**
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
## What It Provides
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
- **Layer**: module.
|
|
10
|
+
- **Consumers**: bundles (library, contractspec-studio), apps (web-landing).
|
|
11
|
+
- `src/contracts/` contains contract specs, operations, entities, and registry exports.
|
|
12
|
+
- Related ContractSpec packages include `@contractspec/lib.bus`, `@contractspec/lib.contracts-spec`, `@contractspec/lib.schema`, `@contractspec/tool.bun`, `@contractspec/tool.typescript`.
|
|
13
|
+
- `src/contracts/` contains contract specs, operations, entities, and registry exports.
|
|
9
14
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
## Features
|
|
15
|
+
## Installation
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
- **Persistent Storage**: Multiple storage adapters (Prisma, append-only log)
|
|
16
|
-
- **Rich Querying**: Filter by actor, target, organization, time range
|
|
17
|
-
- **Retention Policies**: Configurable retention and archival
|
|
18
|
-
- **Export**: Export audit logs for compliance reporting
|
|
17
|
+
`npm install @contractspec/module.audit-trail`
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
or
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
bun add @contractspec/module.audit-trail
|
|
24
|
-
```
|
|
21
|
+
`bun add @contractspec/module.audit-trail`
|
|
25
22
|
|
|
26
23
|
## Usage
|
|
27
24
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// Query by actor
|
|
70
|
-
const userActions = await service.query({
|
|
71
|
-
actorId: 'user-123',
|
|
72
|
-
from: new Date('2024-01-01'),
|
|
73
|
-
to: new Date(),
|
|
74
|
-
limit: 100,
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
// Query by target
|
|
78
|
-
const resourceChanges = await service.query({
|
|
79
|
-
targetId: 'project-456',
|
|
80
|
-
eventName: 'project.*',
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// Export for compliance
|
|
84
|
-
const report = await service.export({
|
|
85
|
-
orgId: 'org-789',
|
|
86
|
-
from: new Date('2024-01-01'),
|
|
87
|
-
to: new Date('2024-12-31'),
|
|
88
|
-
format: 'csv',
|
|
89
|
-
});
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
## Entity Overview
|
|
93
|
-
|
|
94
|
-
| Entity | Description |
|
|
95
|
-
|--------|-------------|
|
|
96
|
-
| AuditLog | Main audit log entry |
|
|
97
|
-
| AuditLogArchive | Archived logs for retention |
|
|
98
|
-
|
|
99
|
-
## Retention
|
|
100
|
-
|
|
101
|
-
Configure retention policies:
|
|
102
|
-
|
|
103
|
-
```typescript
|
|
104
|
-
const retention = new RetentionPolicy({
|
|
105
|
-
// Keep detailed logs for 90 days
|
|
106
|
-
hotRetentionDays: 90,
|
|
107
|
-
// Archive for 7 years (compliance)
|
|
108
|
-
archiveRetentionDays: 2555,
|
|
109
|
-
// Run cleanup daily at 3 AM
|
|
110
|
-
cleanupSchedule: '0 3 * * *',
|
|
111
|
-
});
|
|
112
|
-
```
|
|
25
|
+
Import the root entrypoint from `@contractspec/module.audit-trail`, or choose a documented subpath when you only need one part of the package surface.
|
|
26
|
+
|
|
27
|
+
## Architecture
|
|
28
|
+
|
|
29
|
+
- `src/audit-trail.capability.ts` defines a capability surface.
|
|
30
|
+
- `src/audit-trail.feature.ts` defines a feature entrypoint.
|
|
31
|
+
- `src/contracts/` contains contract specs, operations, entities, and registry exports.
|
|
32
|
+
- `src/entities/` contains domain entities and value objects.
|
|
33
|
+
- `src/index.ts` is the root public barrel and package entrypoint.
|
|
34
|
+
- `src/storage/` contains persistence adapters and storage implementations.
|
|
35
|
+
|
|
36
|
+
## Public Entry Points
|
|
37
|
+
|
|
38
|
+
- Export `.` resolves through `./src/index.ts`.
|
|
39
|
+
- Export `./audit-trail.capability` resolves through `./src/audit-trail.capability.ts`.
|
|
40
|
+
- Export `./audit-trail.feature` resolves through `./src/audit-trail.feature.ts`.
|
|
41
|
+
- Export `./contracts` resolves through `./src/contracts/index.ts`.
|
|
42
|
+
- Export `./entities` resolves through `./src/entities/index.ts`.
|
|
43
|
+
- Export `./storage` resolves through `./src/storage/index.ts`.
|
|
44
|
+
|
|
45
|
+
## Local Commands
|
|
46
|
+
|
|
47
|
+
- `bun run dev` — contractspec-bun-build dev
|
|
48
|
+
- `bun run build` — bun run prebuild && bun run build:bundle && bun run build:types
|
|
49
|
+
- `bun run lint` — bun lint:fix
|
|
50
|
+
- `bun run lint:check` — biome check .
|
|
51
|
+
- `bun run lint:fix` — biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .
|
|
52
|
+
- `bun run typecheck` — tsc --noEmit
|
|
53
|
+
- `bun run publish:pkg` — bun publish --tolerate-republish --ignore-scripts --verbose
|
|
54
|
+
- `bun run publish:pkg:canary` — bun publish:pkg --tag canary
|
|
55
|
+
- `bun run clean` — rimraf dist .turbo
|
|
56
|
+
- `bun run build:bundle` — contractspec-bun-build transpile
|
|
57
|
+
- `bun run build:types` — contractspec-bun-build types
|
|
58
|
+
- `bun run prebuild` — contractspec-bun-build prebuild
|
|
59
|
+
|
|
60
|
+
## Recent Updates
|
|
61
|
+
|
|
62
|
+
- Replace eslint+prettier by biomejs to optimize speed.
|
|
63
|
+
|
|
64
|
+
## Notes
|
|
113
65
|
|
|
66
|
+
- Depends on `lib.bus` for event dispatch -- never emit events outside the bus.
|
|
67
|
+
- Audit records are append-only; mutations or deletions break compliance invariants.
|
|
68
|
+
- Storage adapters must implement the store interface; do not bypass it.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// src/contracts/index.ts
|
|
2
2
|
import { defineCommand, defineQuery } from "@contractspec/lib.contracts-spec";
|
|
3
3
|
import {
|
|
4
|
-
ScalarTypeEnum,
|
|
5
4
|
defineEnum,
|
|
6
|
-
defineSchemaModel
|
|
5
|
+
defineSchemaModel,
|
|
6
|
+
ScalarTypeEnum
|
|
7
7
|
} from "@contractspec/lib.schema";
|
|
8
8
|
var OWNERS = ["platform.audit-trail"];
|
|
9
9
|
var AuditLogModel = defineSchemaModel({
|
package/dist/browser/index.js
CHANGED
|
@@ -31,9 +31,9 @@ var AuditTrailFeature = defineFeature({
|
|
|
31
31
|
// src/contracts/index.ts
|
|
32
32
|
import { defineCommand, defineQuery } from "@contractspec/lib.contracts-spec";
|
|
33
33
|
import {
|
|
34
|
-
ScalarTypeEnum,
|
|
35
34
|
defineEnum,
|
|
36
|
-
defineSchemaModel
|
|
35
|
+
defineSchemaModel,
|
|
36
|
+
ScalarTypeEnum
|
|
37
37
|
} from "@contractspec/lib.schema";
|
|
38
38
|
var OWNERS = ["platform.audit-trail"];
|
|
39
39
|
var AuditLogModel = defineSchemaModel({
|
package/dist/contracts/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// src/contracts/index.ts
|
|
3
3
|
import { defineCommand, defineQuery } from "@contractspec/lib.contracts-spec";
|
|
4
4
|
import {
|
|
5
|
-
ScalarTypeEnum,
|
|
6
5
|
defineEnum,
|
|
7
|
-
defineSchemaModel
|
|
6
|
+
defineSchemaModel,
|
|
7
|
+
ScalarTypeEnum
|
|
8
8
|
} from "@contractspec/lib.schema";
|
|
9
9
|
var OWNERS = ["platform.audit-trail"];
|
|
10
10
|
var AuditLogModel = defineSchemaModel({
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type { AuditQueryOptions, AuditRecord, AuditStorage, } from '@contractspec/lib.bus';
|
|
2
|
+
export * from './audit-trail.feature';
|
|
2
3
|
export * from './contracts';
|
|
4
|
+
export * from './entities';
|
|
3
5
|
export * from './storage';
|
|
4
|
-
export * from './audit-trail.feature';
|
|
5
|
-
export type { AuditRecord, AuditStorage, AuditQueryOptions, } from '@contractspec/lib.bus';
|
package/dist/index.js
CHANGED
|
@@ -32,9 +32,9 @@ var AuditTrailFeature = defineFeature({
|
|
|
32
32
|
// src/contracts/index.ts
|
|
33
33
|
import { defineCommand, defineQuery } from "@contractspec/lib.contracts-spec";
|
|
34
34
|
import {
|
|
35
|
-
ScalarTypeEnum,
|
|
36
35
|
defineEnum,
|
|
37
|
-
defineSchemaModel
|
|
36
|
+
defineSchemaModel,
|
|
37
|
+
ScalarTypeEnum
|
|
38
38
|
} from "@contractspec/lib.schema";
|
|
39
39
|
var OWNERS = ["platform.audit-trail"];
|
|
40
40
|
var AuditLogModel = defineSchemaModel({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// src/contracts/index.ts
|
|
2
2
|
import { defineCommand, defineQuery } from "@contractspec/lib.contracts-spec";
|
|
3
3
|
import {
|
|
4
|
-
ScalarTypeEnum,
|
|
5
4
|
defineEnum,
|
|
6
|
-
defineSchemaModel
|
|
5
|
+
defineSchemaModel,
|
|
6
|
+
ScalarTypeEnum
|
|
7
7
|
} from "@contractspec/lib.schema";
|
|
8
8
|
var OWNERS = ["platform.audit-trail"];
|
|
9
9
|
var AuditLogModel = defineSchemaModel({
|
package/dist/node/index.js
CHANGED
|
@@ -31,9 +31,9 @@ var AuditTrailFeature = defineFeature({
|
|
|
31
31
|
// src/contracts/index.ts
|
|
32
32
|
import { defineCommand, defineQuery } from "@contractspec/lib.contracts-spec";
|
|
33
33
|
import {
|
|
34
|
-
ScalarTypeEnum,
|
|
35
34
|
defineEnum,
|
|
36
|
-
defineSchemaModel
|
|
35
|
+
defineSchemaModel,
|
|
36
|
+
ScalarTypeEnum
|
|
37
37
|
} from "@contractspec/lib.schema";
|
|
38
38
|
var OWNERS = ["platform.audit-trail"];
|
|
39
39
|
var AuditLogModel = defineSchemaModel({
|
package/dist/storage/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractspec/module.audit-trail",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.10",
|
|
4
4
|
"description": "Audit trail module for tracking and querying system events",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contractspec",
|
|
@@ -21,21 +21,21 @@
|
|
|
21
21
|
"dev": "contractspec-bun-build dev",
|
|
22
22
|
"clean": "rimraf dist .turbo",
|
|
23
23
|
"lint": "bun lint:fix",
|
|
24
|
-
"lint:fix": "
|
|
25
|
-
"lint:check": "
|
|
24
|
+
"lint:fix": "biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .",
|
|
25
|
+
"lint:check": "biome check .",
|
|
26
26
|
"prebuild": "contractspec-bun-build prebuild",
|
|
27
27
|
"typecheck": "tsc --noEmit"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@contractspec/lib.schema": "3.7.
|
|
31
|
-
"@contractspec/lib.contracts-spec": "
|
|
32
|
-
"@contractspec/lib.bus": "3.7.
|
|
30
|
+
"@contractspec/lib.schema": "3.7.8",
|
|
31
|
+
"@contractspec/lib.contracts-spec": "4.1.2",
|
|
32
|
+
"@contractspec/lib.bus": "3.7.10",
|
|
33
33
|
"zod": "^4.3.5"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@contractspec/tool.typescript": "3.7.
|
|
36
|
+
"@contractspec/tool.typescript": "3.7.8",
|
|
37
37
|
"typescript": "^5.9.3",
|
|
38
|
-
"@contractspec/tool.bun": "3.7.
|
|
38
|
+
"@contractspec/tool.bun": "3.7.8"
|
|
39
39
|
},
|
|
40
40
|
"exports": {
|
|
41
41
|
".": {
|