pipework 0.128.0 → 0.129.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.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.129.0
|
|
4
|
+
|
|
5
|
+
- **Fixed: a failed infra audit write was logged and swallowed, so its credits ledger or access-link row committed unaudited** (#629). `writeInfraAudit` ran the `audit_record` insert in a savepoint and logged any error (a deadlock, a lost connection, a constraint), and the operation carried on. A failed audit insert now fails the operation it audits: it throws `Failed to write the <entity> <verb> audit record`, the caller's transaction rolls back, and the ledger row goes with it. The driver's error is on `cause`, and the Postgres error (with its `code`, e.g. `40P01` for a deadlock) on `cause.cause`. Upgrading: a credits `reserve`/`release`/`settle` or an access-link write that used to succeed with a missing audit record now rejects.
|
|
6
|
+
|
|
3
7
|
## 0.128.0
|
|
4
8
|
|
|
5
9
|
- **Fixed: `pipe.insert(T).values()` and `pipe.upsert(T).values()` weren't typed against the table** (#626). On a `pipe.define` table they took `Record<string, any>`, so a renamed or misspelled column, or a value of the wrong type, compiled and was dropped or failed only at run time. `values()` now takes the table's insert shape: a NOT NULL column without a default is required, a nullable or defaulted one optional, and any other key is a compile error, in a single row or an array. Columns pipework normally fills (traits' `effectiveFrom`, `createdAt`, …) can still be given. The tenant column is optional, because a write in a tenant context fills it from the flow. Upgrading may turn wrong inserts that used to compile into type errors. Drizzle's `$inferInsert` on a defined table now gives the same shape.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infra-audit.d.ts","sourceRoot":"","sources":["../../../../src/data/write/audit/infra-audit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"infra-audit.d.ts","sourceRoot":"","sources":["../../../../src/data/write/audit/infra-audit.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mCAAmC,CAAA;AAG7D,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACxC;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAc3F"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Writes one audit_record for an infrastructure operation (access links,
|
|
2
2
|
// credits) into the open trace step, in the operation's own transaction.
|
|
3
|
-
// No trace or no open step: nothing is written. A failed write
|
|
4
|
-
//
|
|
3
|
+
// No trace or no open step: nothing is written. A failed write fails the
|
|
4
|
+
// operation: the error reaches the caller and its transaction rolls back, so
|
|
5
|
+
// no row commits without its audit record. The database error stays on `cause`.
|
|
5
6
|
import { sql } from '../../db/sql.js';
|
|
6
|
-
import { getBaseLogger } from '../../../core/logging/index.js';
|
|
7
7
|
import { resolveActorId } from './actor.js';
|
|
8
8
|
export async function writeInfraAudit(flow, tx, record) {
|
|
9
9
|
const trace = flow.trace;
|
|
@@ -11,17 +11,15 @@ export async function writeInfraAudit(flow, tx, record) {
|
|
|
11
11
|
if (trace === null || stepId === null)
|
|
12
12
|
return;
|
|
13
13
|
try {
|
|
14
|
-
await tx.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
`);
|
|
21
|
-
});
|
|
14
|
+
await tx.execute(sql `
|
|
15
|
+
INSERT INTO audit_record
|
|
16
|
+
(trace_day, trace_id, trace_step_id, tenant_id, actor_id, entity, verb, entity_id, after, occurred_at)
|
|
17
|
+
VALUES (${trace.openedDay}, ${trace.id}, ${stepId}, ${record.tenantId}, ${resolveActorId(flow)},
|
|
18
|
+
${record.entity}, ${record.verb}, ${record.entityId}, ${JSON.stringify(record.after)}::jsonb, now())
|
|
19
|
+
`);
|
|
22
20
|
}
|
|
23
21
|
catch (err) {
|
|
24
|
-
|
|
22
|
+
throw new Error(`Failed to write the ${record.entity} ${record.verb} audit record`, { cause: err });
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
25
|
//# sourceMappingURL=infra-audit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infra-audit.js","sourceRoot":"","sources":["../../../../src/data/write/audit/infra-audit.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,yEAAyE;AACzE,6EAA6E;AAC7E,
|
|
1
|
+
{"version":3,"file":"infra-audit.js","sourceRoot":"","sources":["../../../../src/data/write/audit/infra-audit.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,yEAAyE;AACzE,yEAAyE;AACzE,6EAA6E;AAC7E,gFAAgF;AAEhF,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAGrC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAU3C,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAU,EAAE,EAAM,EAAE,MAAkB;IAC1E,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;IACxB,MAAM,MAAM,GAAG,KAAK,EAAE,MAAM,CAAC,UAAU,IAAI,IAAI,CAAA;IAC/C,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,KAAK,IAAI;QAAE,OAAM;IAC7C,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAA;;;gBAGR,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,EAAE,KAAK,MAAM,KAAK,MAAM,CAAC,QAAQ,KAAK,cAAc,CAAC,IAAI,CAAC;UAC1F,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC;KACvF,CAAC,CAAA;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,uBAAuB,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,eAAe,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IACrG,CAAC;AACH,CAAC"}
|