@nodii/dsar 0.25.0 → 0.26.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/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +11 -0
- package/dist/migrations/index.js.map +1 -1
- package/dist/register.d.ts +26 -0
- package/dist/register.d.ts.map +1 -1
- package/dist/register.js +56 -5
- package/dist/register.js.map +1 -1
- package/package.json +2 -2
- package/src/migrations/001-lifecycle-requests.sql +11 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAUA,KAAK,SAAS,GAAG;IAEf,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACzD,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAUA,KAAK,SAAS,GAAG;IAEf,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACzD,CAAC;AA4NF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAsC9C;AAaD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAoCzD;AAmDD,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,2BAA2B,kzaAkQvC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,iCAAiC,4hBAQ9B,CAAC;AAEjB;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CA4BrD"}
|
package/dist/migrations/index.js
CHANGED
|
@@ -145,10 +145,21 @@ CREATE TABLE IF NOT EXISTS retention_policies (
|
|
|
145
145
|
data_class TEXT NOT NULL,
|
|
146
146
|
subject_kind TEXT NOT NULL,
|
|
147
147
|
rpc_addr TEXT NOT NULL,
|
|
148
|
+
retention_days INT,
|
|
148
149
|
registered_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
149
150
|
soft_deleted_at TIMESTAMPTZ,
|
|
150
151
|
PRIMARY KEY (service_id, data_class, subject_kind)
|
|
151
152
|
);
|
|
153
|
+
-- Upgrade-safety (LIB-API-GAP 3a534bb8 precedent; LIB-10), the same shape as the
|
|
154
|
+
-- ADD COLUMN IF NOT EXISTS backfills this migration already carries for every
|
|
155
|
+
-- other additively-added column: CREATE TABLE IF NOT EXISTS is a NO-OP on a DB whose
|
|
156
|
+
-- retention_policies predates retention_days, and registerWithOrchestrator now
|
|
157
|
+
-- binds that column on the direct-SQL leg — so without this ALTER the first
|
|
158
|
+
-- boot after the upgrade fails on an UPSERT naming a column that is not there.
|
|
159
|
+
-- Nullable: 11-dsar §6.3 declares it "nullable; service override per data
|
|
160
|
+
-- class", and omitted means NULL. Matches tenant's registry
|
|
161
|
+
-- (0081_retention_policies_registry.sql: "retention_days" integer).
|
|
162
|
+
ALTER TABLE retention_policies ADD COLUMN IF NOT EXISTS retention_days INT;
|
|
152
163
|
CREATE INDEX IF NOT EXISTS idx_retention_policies_active
|
|
153
164
|
ON retention_policies (data_class, subject_kind)
|
|
154
165
|
WHERE soft_deleted_at IS NULL;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../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AC;YAChB,CAAC;iBAAM,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;gBAC3B,SAAS,GAAG,IAAI,CAAC;YACnB,CAAC;QACH,CAAC;QAED,IAAI,SAAS,KAAK,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7C,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;YAC3B,IAAI,OAAO;gBAAE,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC/B,GAAG,GAAG,EAAE,CAAC;QACX,CAAC;IACH,CAAC;IACD,IAAI,GAAG,CAAC,IAAI,EAAE;QAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IACrC,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/register.d.ts
CHANGED
|
@@ -25,6 +25,32 @@ export interface DataClassRegistration {
|
|
|
25
25
|
* ticket id or an explanation.
|
|
26
26
|
*/
|
|
27
27
|
statuteCitation?: string;
|
|
28
|
+
/**
|
|
29
|
+
* 11-dsar §6.3 — the per-class retention WINDOW, in days, written to the
|
|
30
|
+
* registry's nullable `retention_days` column ("service override per data
|
|
31
|
+
* class"). §6.3 names `data_class` as "the key for per-class `retention_days`
|
|
32
|
+
* overrides"; this is the value that key is for.
|
|
33
|
+
*
|
|
34
|
+
* It is the service's honest statement of how long it actually keeps the
|
|
35
|
+
* class, so the registry — which doubles as the platform's
|
|
36
|
+
* records-of-processing inventory — reports a window that someone is really
|
|
37
|
+
* running. nodii-task-tracking's `project_resources` is the first consumer
|
|
38
|
+
* (request f720c6a6): soft-deleted project files hard-delete after
|
|
39
|
+
* `PROJECT_RESOURCE_RETENTION_DAYS` (default 30), and without this field the
|
|
40
|
+
* registry read NULL for a class that is in fact purged at 30 days.
|
|
41
|
+
*
|
|
42
|
+
* OMITTED MEANS NULL — "this service declares no window for this class" —
|
|
43
|
+
* and that is the pre-field behaviour for every existing registration. An
|
|
44
|
+
* explicit `null` counts as omitted too, so a config loader that yields
|
|
45
|
+
* `null` for an unset value (`JSON.parse`, an optional env read) declares no
|
|
46
|
+
* window rather than failing the boot — which is also what the Python port's
|
|
47
|
+
* `None` does, so the two cannot disagree on the same config.
|
|
48
|
+
* A declared value must be an integer in [1, 2147483647] (the column is
|
|
49
|
+
* Postgres `INT`); anything else is refused at register time, i.e. at boot.
|
|
50
|
+
* ADVISORY INVENTORY ONLY: nothing in the orchestrator purges on this value,
|
|
51
|
+
* and routing stays subject_kind-only (D486).
|
|
52
|
+
*/
|
|
53
|
+
retentionDays?: number;
|
|
28
54
|
}
|
|
29
55
|
export interface RegisterWithOrchestratorOpts {
|
|
30
56
|
serviceName: string;
|
package/dist/register.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAaA,OAAO,EAAe,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAE9E,KAAK,SAAS,GAAG;IAEf,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACzD,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,cAAc,CAAC;IAC5B;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAaA,OAAO,EAAe,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAE9E,KAAK,SAAS,GAAG;IAEf,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACzD,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,cAAc,CAAC;IAC5B;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,4BAA4B;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,qBAAqB,EAAE,CAAC;IACrC,iDAAiD;IACjD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gEAAgE;IAChE,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAED,MAAM,WAAW,8BAA8B;IAC7C,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAgCD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,4BAA4B,GACjC,OAAO,CAAC,8BAA8B,CAAC,CA2CzC"}
|
package/dist/register.js
CHANGED
|
@@ -11,6 +11,22 @@
|
|
|
11
11
|
// internal mode; used by nodii-tenant-service itself).
|
|
12
12
|
import { assertSubjectKind } from "./subject-kinds.js";
|
|
13
13
|
import { isPiiBucket } from "./types.js";
|
|
14
|
+
/**
|
|
15
|
+
* The ceiling of a Postgres `INT` (int4), which is what 11-dsar §6.3 declares
|
|
16
|
+
* `retention_policies.retention_days` as. A larger window is refused HERE, with
|
|
17
|
+
* the column named, rather than reaching the database and coming back as
|
|
18
|
+
* `integer out of range` from a boot-time UPSERT — or, on the HTTP leg, being
|
|
19
|
+
* accepted by the orchestrator and failing inside ITS write.
|
|
20
|
+
*/
|
|
21
|
+
const RETENTION_DAYS_MAX = 2147483647;
|
|
22
|
+
function assertRetentionDays(value, serviceName, dataClass) {
|
|
23
|
+
if (typeof value !== "number" ||
|
|
24
|
+
!Number.isInteger(value) ||
|
|
25
|
+
value < 1 ||
|
|
26
|
+
value > RETENTION_DAYS_MAX) {
|
|
27
|
+
throw new Error(`registerWithOrchestrator(serviceName=${JSON.stringify(serviceName)}, dataClass=${JSON.stringify(dataClass)}): invalid retentionDays ${JSON.stringify(value)} — expected an integer between 1 and ${RETENTION_DAYS_MAX} (11-dsar §6.3 \`retention_policies.retention_days INT\`), or omit the field to declare no window (NULL). A retention window is published as this service's records-of-processing inventory, so it is never coerced or defaulted.`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
14
30
|
/**
|
|
15
31
|
* Register this service's data-class set with the orchestrator. Spec § 5.11.5.
|
|
16
32
|
*
|
|
@@ -42,6 +58,18 @@ export async function registerWithOrchestrator(opts) {
|
|
|
42
58
|
if (dc.bucket !== undefined && !isPiiBucket(dc.bucket)) {
|
|
43
59
|
throw new Error(`registerWithOrchestrator(serviceName=${JSON.stringify(opts.serviceName)}, dataClass=${JSON.stringify(dc.dataClass)}): unknown retention bucket ${JSON.stringify(dc.bucket)} — expected one of statutory | operational | free_text (D720). The bucket decides whether a DSAR erase destroys this class or retains it under statute; an unrecognised value cannot be defaulted.`);
|
|
44
60
|
}
|
|
61
|
+
// 11-dsar §6.3 — boot-loud on a nonsense retention window, for the same
|
|
62
|
+
// reason as the two checks above. This value lands in the registry that
|
|
63
|
+
// doubles as the platform's records-of-processing inventory, so a coerced
|
|
64
|
+
// one (0.5 → 0, "30" → NaN) would publish a window nobody runs as though a
|
|
65
|
+
// service had declared it. `undefined` is the omitted-default (NULL) and is
|
|
66
|
+
// accepted; a declared value must survive the `INT` column intact.
|
|
67
|
+
// `!= null` (not `!== undefined`): null and undefined are BOTH absent, for
|
|
68
|
+
// parity with Python's `is not None`. A value that is present but unusable
|
|
69
|
+
// is still refused.
|
|
70
|
+
if (dc.retentionDays != null) {
|
|
71
|
+
assertRetentionDays(dc.retentionDays, opts.serviceName, dc.dataClass);
|
|
72
|
+
}
|
|
45
73
|
}
|
|
46
74
|
if (opts.sqlClient) {
|
|
47
75
|
return registerViaSql(opts);
|
|
@@ -60,11 +88,17 @@ async function registerViaSql(opts) {
|
|
|
60
88
|
let rowsInserted = 0;
|
|
61
89
|
let rowsUpdated = 0;
|
|
62
90
|
for (const dc of dataClassSet) {
|
|
91
|
+
// `retention_days = EXCLUDED.retention_days` on conflict: a registration is
|
|
92
|
+
// the service's CURRENT declaration, the same way `rpc_addr` is, so dropping
|
|
93
|
+
// the field between boots clears the window rather than leaving a stale one
|
|
94
|
+
// behind. Omitted binds SQL NULL, never 0 — 0 is not a window, and the
|
|
95
|
+
// column is nullable precisely so "no declared window" has a value.
|
|
63
96
|
const stmt = `INSERT INTO ${table}
|
|
64
|
-
(service_id, data_class, subject_kind, rpc_addr, registered_at, soft_deleted_at)
|
|
65
|
-
VALUES ($1, $2, $3, $4, now(), NULL)
|
|
97
|
+
(service_id, data_class, subject_kind, rpc_addr, retention_days, registered_at, soft_deleted_at)
|
|
98
|
+
VALUES ($1, $2, $3, $4, $5, now(), NULL)
|
|
66
99
|
ON CONFLICT (service_id, data_class, subject_kind) DO UPDATE
|
|
67
100
|
SET rpc_addr = EXCLUDED.rpc_addr,
|
|
101
|
+
retention_days = EXCLUDED.retention_days,
|
|
68
102
|
registered_at = now(),
|
|
69
103
|
soft_deleted_at = NULL
|
|
70
104
|
RETURNING xmax::text::bigint AS xmax`;
|
|
@@ -73,15 +107,24 @@ async function registerViaSql(opts) {
|
|
|
73
107
|
dc.dataClass,
|
|
74
108
|
dc.subjectKind,
|
|
75
109
|
opts.rpcAddr,
|
|
110
|
+
dc.retentionDays ?? null,
|
|
76
111
|
]));
|
|
77
112
|
if (rows[0]?.xmax === "0")
|
|
78
113
|
rowsInserted++;
|
|
79
114
|
else
|
|
80
115
|
rowsUpdated++;
|
|
81
116
|
}
|
|
82
|
-
// Soft-delete any rows for this service not in the set.
|
|
117
|
+
// Soft-delete any rows for this service not in the set. Every label is a
|
|
118
|
+
// BOUND parameter: this runs on the orchestrator's BYPASSRLS owner client,
|
|
119
|
+
// and `data_class` reaches here from an S2S door that only checks it is
|
|
120
|
+
// non-empty, so interpolating it was an injection vector (drift, DSAR-RET).
|
|
121
|
+
const tupleArgs = [];
|
|
83
122
|
const tuples = dataClassSet
|
|
84
|
-
.map((dc) =>
|
|
123
|
+
.map((dc) => {
|
|
124
|
+
tupleArgs.push(dc.dataClass, dc.subjectKind);
|
|
125
|
+
const n = tupleArgs.length;
|
|
126
|
+
return `($${n}, $${n + 1})`;
|
|
127
|
+
})
|
|
85
128
|
.join(",");
|
|
86
129
|
let rowsSoftDeleted = 0;
|
|
87
130
|
if (tuples.length > 0) {
|
|
@@ -90,7 +133,10 @@ async function registerViaSql(opts) {
|
|
|
90
133
|
WHERE service_id = $1
|
|
91
134
|
AND soft_deleted_at IS NULL
|
|
92
135
|
AND (data_class, subject_kind) NOT IN (${tuples})`;
|
|
93
|
-
const result = (await opts.sqlClient.unsafe(stmt, [
|
|
136
|
+
const result = (await opts.sqlClient.unsafe(stmt, [
|
|
137
|
+
opts.serviceName,
|
|
138
|
+
...tupleArgs,
|
|
139
|
+
]));
|
|
94
140
|
rowsSoftDeleted = result?.count ?? 0;
|
|
95
141
|
}
|
|
96
142
|
return {
|
|
@@ -108,6 +154,11 @@ async function registerViaHttp(opts) {
|
|
|
108
154
|
data_classes: opts.dataClasses.map((dc) => ({
|
|
109
155
|
data_class: dc.dataClass,
|
|
110
156
|
subject_kind: dc.subjectKind,
|
|
157
|
+
// Spread, not `retention_days: dc.retentionDays ?? null`: an absent window
|
|
158
|
+
// leaves the KEY out, so the posted body is byte-identical to the one this
|
|
159
|
+
// lib sent before the field existed and an orchestrator that does not know
|
|
160
|
+
// the field sees no change at all.
|
|
161
|
+
...(dc.retentionDays == null ? {} : { retention_days: dc.retentionDays }),
|
|
111
162
|
})),
|
|
112
163
|
};
|
|
113
164
|
const resp = await f(url, {
|
package/dist/register.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,EAAE;AACF,6EAA6E;AAC7E,qEAAqE;AACrE,wDAAwD;AACxD,EAAE;AACF,0BAA0B;AAC1B,uEAAuE;AACvE,0EAA0E;AAC1E,+EAA+E;AAC/E,2DAA2D;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAuC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,EAAE;AACF,6EAA6E;AAC7E,qEAAqE;AACrE,wDAAwD;AACxD,EAAE;AACF,0BAA0B;AAC1B,uEAAuE;AACvE,0EAA0E;AAC1E,+EAA+E;AAC/E,2DAA2D;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAuC,MAAM,YAAY,CAAC;AA8E9E;;;;;;GAMG;AACH,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAEtC,SAAS,mBAAmB,CAC1B,KAAa,EACb,WAAmB,EACnB,SAAiB;IAEjB,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC;QACxB,KAAK,GAAG,CAAC;QACT,KAAK,GAAG,kBAAkB,EAC1B,CAAC;QACD,MAAM,IAAI,KAAK,CACb,wCAAwC,IAAI,CAAC,SAAS,CACpD,WAAW,CACZ,eAAe,IAAI,CAAC,S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AAG,CAAC,EAAE,CAAC,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,EAAE,CAAC,aAAa,EAAE,CAAC;SAC1E,CAAC,CAAC;KACJ,CAAC;IACF,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,GAAG,EAAE;QACxB,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,CAAC,CAAC;IACH,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,kCAAkC,IAAI,CAAC,MAAM,SAAS,GAAG,EAAE,CAC5D,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAmC,CAAC;AAC/D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nodii/dsar",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "GDPR Data Subject Access Request (DSAR) library for the Nodii microservice stack — 9-RPC DataLifecycleService surface with typed handler registry + DsarStore + retention policy helpers. Polyglot ship: TS + Python + Go in parity. Spec: planning hub docKey=dsar.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@grpc/proto-loader": "^0.7.13",
|
|
36
36
|
"@nodii/audit-chain": "0.14.0",
|
|
37
37
|
"@nodii/pii": "0.21.0",
|
|
38
|
-
"@nodii/telemetry": "0.
|
|
38
|
+
"@nodii/telemetry": "0.33.0",
|
|
39
39
|
"@types/bun": "^1.3.13",
|
|
40
40
|
"typescript": "^5.9.3"
|
|
41
41
|
},
|
|
@@ -157,11 +157,22 @@ CREATE TABLE IF NOT EXISTS retention_policies (
|
|
|
157
157
|
data_class TEXT NOT NULL,
|
|
158
158
|
subject_kind TEXT NOT NULL,
|
|
159
159
|
rpc_addr TEXT NOT NULL,
|
|
160
|
+
retention_days INT,
|
|
160
161
|
registered_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
161
162
|
soft_deleted_at TIMESTAMPTZ,
|
|
162
163
|
PRIMARY KEY (service_id, data_class, subject_kind)
|
|
163
164
|
);
|
|
164
165
|
|
|
166
|
+
-- Upgrade-safety (LIB-API-GAP 3a534bb8 precedent; LIB-10), the same shape as the
|
|
167
|
+
-- ADD COLUMN IF NOT EXISTS backfills this migration already carries for every
|
|
168
|
+
-- other additively-added column: CREATE TABLE IF NOT EXISTS is a NO-OP on a DB whose
|
|
169
|
+
-- retention_policies predates retention_days, and registerWithOrchestrator now
|
|
170
|
+
-- binds that column on the direct-SQL leg — so without this ALTER the first
|
|
171
|
+
-- boot after the upgrade fails on an UPSERT naming a column that is not there.
|
|
172
|
+
-- Nullable: 11-dsar §6.3 declares it "nullable; service override per data
|
|
173
|
+
-- class", and omitted means NULL. Matches tenant's registry
|
|
174
|
+
-- (0081_retention_policies_registry.sql: "retention_days" integer).
|
|
175
|
+
ALTER TABLE retention_policies ADD COLUMN IF NOT EXISTS retention_days INT;
|
|
165
176
|
CREATE INDEX IF NOT EXISTS idx_retention_policies_active
|
|
166
177
|
ON retention_policies (data_class, subject_kind)
|
|
167
178
|
WHERE soft_deleted_at IS NULL;
|