json icon

Entity Audited

v1.0.0events

A row of an audited table in CNA One was inserted, updated or deleted, with the old and new values, the acting employee and the moment. cna-one publishes it after the commit of each write to a person or a classroom, in production since v0.4.0; nobody consumes it.

1{
2  "$schema": "https://json-schema.org/draft/2020-12/schema",
3  "title": "EntityAudited payload",
4  "type": "object",
5  "additionalProperties": false,
6  "properties": {
7    "entityName": {
8      "type": "string",
9      "description": "Table name of the audited entity (TypeORM tableName, not schema-qualified): persons or classrooms."
10    },
11    "entityId": {
12      "type": "string",
13      "description": "Id of the audited row. Kafka message key."
14    },
15    "operation": {
16      "type": "string",
17      "enum": ["INSERT", "UPDATE", "DELETE"],
18      "description": "Kind of change (cna-one AuditOperation)."
19    },
20    "oldValues": {
21      "type": ["object", "null"],
22      "additionalProperties": true,
23      "description": "Values before the change, keyed by property name. Null on INSERT; only the changed columns on UPDATE. @Auditable drops the fields the entity lists in ignore and replaces those it lists in sensitive by ***; Person and Classroom list none, so their values travel as written."
24    },
25    "newValues": {
26      "type": ["object", "null"],
27      "additionalProperties": true,
28      "description": "Values after the change, keyed by property name. Every column on INSERT, null for a nullable column not given; null on DELETE; only the changed columns on UPDATE. @Auditable drops the fields the entity lists in ignore and replaces those it lists in sensitive by ***; Person and Classroom list none, so their values travel as written."
29    },
30    "userId": {
31      "type": ["string", "null"],
32      "description": "The employee who made the change (franchise.employees id) when it comes from a GraphQL operation behind @requireAuth or @requireMultiAuth, set from the request audit context; null when it comes from a Kafka consumer, a populate script or a job."
33    },
34    "ip": {
35      "type": ["string", "null"],
36      "description": "Client IP (first address of x-forwarded-for, then the other request sources), set from the request audit context in the same GraphQL operations as userId. Null in the other cases."
37    },
38    "timestamp": {
39      "type": "string",
40      "format": "date-time",
41      "description": "When the change was recorded: the moment of the write. A Date in code, serialised as ISO-8601."
42    }
43  },
44  "required": [
45    "entityName",
46    "entityId",
47    "operation",
48    "oldValues",
49    "newValues",
50    "userId",
51    "ip",
52    "timestamp"
53  ]
54}
55

Details

Format
JSON Schema
Resource
events
Filename
schema.json

Versions