@kindgi/audit-events 0.1.4-rc.0 → 0.1.4-rc.2

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 CHANGED
@@ -16,10 +16,10 @@ Give the whole system one audit substrate: one record shape, one write surface,
16
16
  - `payload` — versioned envelope `{ v: 1, doc: … }`; the `doc` shape depends on `kind`.
17
17
  - **`AuditEventBinding`** — the adapter interface:
18
18
  - `append(events)` — batched write. Duplicate `(tenantId, id)` pairs are ignored, so retries are safe. Fails with `PersistenceError` or `AuditEventValidationError`.
19
- - `query(input)` — cursor-paginated read ordered by `(timestamp, id)`; the cursor is opaque. Fails with `PersistenceError` or `InvalidCursorError`.
19
+ - `query(input)` — cursor-paginated read ordered by `(timestamp, id)`, oldest first, or newest first with `order: 'desc'`; the cursor is opaque and continues in the same order. Fails with `PersistenceError` or `InvalidCursorError`.
20
20
  - `purge(input)` — delete one kind's events older than a cutoff; returns the deleted count.
21
21
  - `describe()` — `{ name, version }`.
22
- - **`AuditEventQueryInput`** — `tenantId`, `filter?`, `cursor?`, `limit?`.
22
+ - **`AuditEventQueryInput`** — `tenantId`, `filter?`, `cursor?`, `limit?`, `order?` (**`AuditEventOrder`**: `'asc'`, the default, or `'desc'`). A binding that predates `order` pages oldest first.
23
23
  - **`AuditEventFilter`** — AND-combined; absent fields match anything. Fields: `id`, `kind`, `kinds` (an empty array matches nothing), `actor`, `onBehalfOf`, `runId`, `agentId`, `flowId`, `correlationId`, `outcome`, `payloadDoc` (every entry must equal the same field of `payload.doc`), and inclusive ISO `from` / `to` bounds.
24
24
  - **`AuditEventPage`** — `data` plus `nextCursor` (absent on the last page).
25
25
  - **`AuditEventPurgeInput`** (`tenantId`, `kind`, `olderThan`) and **`AuditEventPurgeResult`** (`deleted`).
package/dist/binding.d.ts CHANGED
@@ -11,7 +11,8 @@ import type { AuditEvent, AuditEventFilter, AuditEventPage } from './types.js';
11
11
  * (idempotent — safer than throwing when the caller re-fires
12
12
  * from a retry loop).
13
13
  * - `query` — cursor-paginated read; opaque cursor tokens encode
14
- * `(timestamp, id)` for keyset pagination.
14
+ * `(timestamp, id)` for keyset pagination, oldest first or, with
15
+ * `order: 'desc'`, newest first.
15
16
  * - `purge` — delete rows matching `(tenantId, kind, olderThan)`;
16
17
  * retention cleanup calls this per kind. Legal-hold kinds are
17
18
  * excluded by the caller (the compliance classifier decides).
@@ -34,7 +35,15 @@ export interface AuditEventQueryInput {
34
35
  readonly filter?: AuditEventFilter;
35
36
  readonly cursor?: string;
36
37
  readonly limit?: number;
38
+ /**
39
+ * `asc` (absent): oldest first. `desc`: newest first. `nextCursor`
40
+ * continues in the same order. A binding that predates `order` pages
41
+ * oldest first.
42
+ */
43
+ readonly order?: AuditEventOrder;
37
44
  }
45
+ /** The order `query` pages in, by `(timestamp, id)`. */
46
+ export type AuditEventOrder = 'asc' | 'desc';
38
47
  export interface AuditEventPurgeInput {
39
48
  readonly tenantId: TenantId;
40
49
  /**
@@ -45,6 +54,13 @@ export interface AuditEventPurgeInput {
45
54
  readonly kind: string;
46
55
  /** ISO timestamp cutoff. Rows with `timestamp < olderThan` are deleted. */
47
56
  readonly olderThan: string;
57
+ /**
58
+ * Only rows with this outcome, e.g. a kind's denials kept longer than the
59
+ * rest (a classifier's `onDenyDays`). Absent: any outcome.
60
+ */
61
+ readonly outcome?: string;
62
+ /** Only rows whose outcome isn't this one (rows with no outcome included). */
63
+ readonly exceptOutcome?: string;
48
64
  }
49
65
  export interface AuditEventPurgeResult {
50
66
  readonly deleted: number;
@@ -1 +1 @@
1
- {"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../src/binding.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,KAAK,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,KAAK,EAAE,UAAU,EAAE,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E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,8EAA8E;IAC9E,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type { AuditEventBinding, AuditEventPurgeInput, AuditEventPurgeResult, AuditEventQueryInput, } from './binding.js';
1
+ export type { AuditEventBinding, AuditEventOrder, AuditEventPurgeInput, AuditEventPurgeResult, AuditEventQueryInput, } from './binding.js';
2
2
  export type { AuditEventError, AuditEventValidationError, InvalidCursorError, PersistenceError, } from './errors.js';
3
3
  export type { AuditEvent, AuditEventFilter, AuditEventPage } from './types.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EACV,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,eAAe,EACf,yBAAyB,EACzB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,eAAe,EACf,yBAAyB,EACzB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kindgi/audit-events",
3
- "version": "0.1.4-rc.0",
3
+ "version": "0.1.4-rc.2",
4
4
  "description": "Kindgi™ audit events contract. Types only: AuditEvent (the audit record — id, tenantId, projectId, kind, timestamp, actor, outcome, run / agent / flow / correlation ids, versioned payload), AuditEventFilter and AuditEventPage, AuditEventBinding (the caller-plugged append / query / purge interface) with its input and result shapes, and the AuditEventError union. No runtime code. A reference in-memory binding is @kindgi/audit-events-inmemory; durable bindings are provided by the Kindgi runtime.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  "README.md"
29
29
  ],
30
30
  "dependencies": {
31
- "@kindgi/types": "0.1.4-rc.0"
31
+ "@kindgi/types": "0.1.4-rc.2"
32
32
  },
33
33
  "engines": {
34
34
  "node": ">=22.12.0"
package/src/binding.ts CHANGED
@@ -16,7 +16,8 @@ import type { AuditEvent, AuditEventFilter, AuditEventPage } from './types.js';
16
16
  * (idempotent — safer than throwing when the caller re-fires
17
17
  * from a retry loop).
18
18
  * - `query` — cursor-paginated read; opaque cursor tokens encode
19
- * `(timestamp, id)` for keyset pagination.
19
+ * `(timestamp, id)` for keyset pagination, oldest first or, with
20
+ * `order: 'desc'`, newest first.
20
21
  * - `purge` — delete rows matching `(tenantId, kind, olderThan)`;
21
22
  * retention cleanup calls this per kind. Legal-hold kinds are
22
23
  * excluded by the caller (the compliance classifier decides).
@@ -44,8 +45,17 @@ export interface AuditEventQueryInput {
44
45
  readonly filter?: AuditEventFilter;
45
46
  readonly cursor?: string;
46
47
  readonly limit?: number;
48
+ /**
49
+ * `asc` (absent): oldest first. `desc`: newest first. `nextCursor`
50
+ * continues in the same order. A binding that predates `order` pages
51
+ * oldest first.
52
+ */
53
+ readonly order?: AuditEventOrder;
47
54
  }
48
55
 
56
+ /** The order `query` pages in, by `(timestamp, id)`. */
57
+ export type AuditEventOrder = 'asc' | 'desc';
58
+
49
59
  export interface AuditEventPurgeInput {
50
60
  readonly tenantId: TenantId;
51
61
  /**
@@ -56,6 +66,13 @@ export interface AuditEventPurgeInput {
56
66
  readonly kind: string;
57
67
  /** ISO timestamp cutoff. Rows with `timestamp < olderThan` are deleted. */
58
68
  readonly olderThan: string;
69
+ /**
70
+ * Only rows with this outcome, e.g. a kind's denials kept longer than the
71
+ * rest (a classifier's `onDenyDays`). Absent: any outcome.
72
+ */
73
+ readonly outcome?: string;
74
+ /** Only rows whose outcome isn't this one (rows with no outcome included). */
75
+ readonly exceptOutcome?: string;
59
76
  }
60
77
 
61
78
  export interface AuditEventPurgeResult {
package/src/index.ts CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  export type {
5
5
  AuditEventBinding,
6
+ AuditEventOrder,
6
7
  AuditEventPurgeInput,
7
8
  AuditEventPurgeResult,
8
9
  AuditEventQueryInput,