dpdp-kit 0.1.1 → 0.2.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/README.md +138 -11
- package/dist/audit.d.ts +2 -2
- package/dist/chunk-KVTUMHXO.js +491 -0
- package/dist/cli.js +61 -9
- package/dist/config.d.ts +15 -0
- package/dist/data-access.d.ts +19 -0
- package/dist/dpdp.d.ts +60 -3
- package/dist/drizzle.d.ts +505 -4
- package/dist/drizzle.js +268 -3
- package/dist/erasure.d.ts +2 -1
- package/dist/errors.d.ts +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.js +375 -24
- package/dist/personal.d.ts +17 -0
- package/dist/records.d.ts +124 -0
- package/dist/retention.d.ts +47 -0
- package/dist/rights.d.ts +49 -0
- package/dist/run-audit.d.ts +12 -0
- package/dist/schema-check.d.ts +22 -0
- package/dist/store.d.ts +9 -2
- package/package.json +1 -1
- package/dist/chunk-HRKHRKV4.js +0 -185
package/dist/dpdp.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { DpdpConfig } from "./config.js";
|
|
2
|
+
import type { DataAccess } from "./data-access.js";
|
|
2
3
|
import { type ErasurePlan } from "./erasure.js";
|
|
3
4
|
import { type NoticeLanguage } from "./languages.js";
|
|
4
|
-
import type
|
|
5
|
+
import { type ErasureTask, type RequestFilter, type RequestType, type RightsRequest, type TaskFilter } from "./records.js";
|
|
6
|
+
import { type ProcessorHooks, type RunReport } from "./retention.js";
|
|
7
|
+
import { type AccessSummary } from "./rights.js";
|
|
8
|
+
import { type ConsentEvent, type ConsentStore } from "./store.js";
|
|
5
9
|
export interface ConsentMeta {
|
|
6
10
|
noticeVersion?: string;
|
|
7
11
|
language?: NoticeLanguage;
|
|
@@ -19,7 +23,15 @@ export type VerifyResult = {
|
|
|
19
23
|
};
|
|
20
24
|
export interface DpdpOptions<P extends string> {
|
|
21
25
|
config: DpdpConfig<P>;
|
|
26
|
+
/** `memoryStore()`, `drizzleStore(db)`, or your own. Rights and retention need a full `DpdpStore`. */
|
|
22
27
|
store: ConsentStore;
|
|
28
|
+
/**
|
|
29
|
+
* How to reach the personal data in your tables, for access summaries and erasure:
|
|
30
|
+
* `drizzleData(db)` from `dpdp-kit/drizzle`, or your own `DataAccess`.
|
|
31
|
+
*/
|
|
32
|
+
data?: DataAccess;
|
|
33
|
+
/** Hooks for each processor in `config.processors`, to stop or erase on their side. */
|
|
34
|
+
processors?: Partial<Record<string, ProcessorHooks>>;
|
|
23
35
|
/** Clock, for tests. */
|
|
24
36
|
now?: () => Date;
|
|
25
37
|
/** Attempts when two writes for the same person race. Default 5. */
|
|
@@ -31,12 +43,13 @@ export interface Dpdp<P extends string> {
|
|
|
31
43
|
/** Record that the person agreed to these consent purposes. */
|
|
32
44
|
grant(subjectId: string, purposes: readonly P[], meta?: ConsentMeta): Promise<ConsentEvent>;
|
|
33
45
|
/**
|
|
34
|
-
* Record that the person withdrew consent. Returns
|
|
35
|
-
*
|
|
46
|
+
* Record that the person withdrew consent. Returns the erasure plan and, when the store keeps
|
|
47
|
+
* tasks, schedules it: `retention.run()` carries the tasks out when they're due.
|
|
36
48
|
*/
|
|
37
49
|
withdraw(subjectId: string, purposes: readonly P[], meta?: ConsentMeta): Promise<{
|
|
38
50
|
event: ConsentEvent;
|
|
39
51
|
erasure: ErasurePlan;
|
|
52
|
+
tasks: ErasureTask[];
|
|
40
53
|
}>;
|
|
41
54
|
/**
|
|
42
55
|
* Whether you hold consent, or don't need it, for this purpose. For consent purposes: true when
|
|
@@ -56,6 +69,50 @@ export interface Dpdp<P extends string> {
|
|
|
56
69
|
plan(subjectId: string, input: {
|
|
57
70
|
reason: "account-deletion";
|
|
58
71
|
}): Promise<ErasurePlan>;
|
|
72
|
+
/** Turn a plan into dated tasks for `retention.run()`. */
|
|
73
|
+
schedule(plan: ErasurePlan): Promise<ErasureTask[]>;
|
|
74
|
+
/** Plan and schedule erasure for a deleted account. */
|
|
75
|
+
deleteAccount(subjectId: string): Promise<{
|
|
76
|
+
plan: ErasurePlan;
|
|
77
|
+
tasks: ErasureTask[];
|
|
78
|
+
}>;
|
|
79
|
+
};
|
|
80
|
+
readonly retention: {
|
|
81
|
+
/**
|
|
82
|
+
* Carry out every due erasure task: null out or delete rows through `data`, and call processor
|
|
83
|
+
* hooks. Run it on a schedule (a daily cron is plenty). Safe to run from several processes.
|
|
84
|
+
*/
|
|
85
|
+
run(input?: {
|
|
86
|
+
limit?: number;
|
|
87
|
+
}): Promise<RunReport>;
|
|
88
|
+
tasks(filter?: TaskFilter): Promise<ErasureTask[]>;
|
|
89
|
+
/** Mark a `manual` or `failed` task as handled by a person. */
|
|
90
|
+
markDone(taskId: string, note: string): Promise<ErasureTask>;
|
|
91
|
+
};
|
|
92
|
+
readonly rights: {
|
|
93
|
+
/** Record a request (Sections 11–14). It's due after `config.rights.responseWithin` (default 90 days). */
|
|
94
|
+
open(subjectId: string, type: RequestType, details?: Record<string, unknown>): Promise<RightsRequest>;
|
|
95
|
+
get(id: string): Promise<RightsRequest | undefined>;
|
|
96
|
+
/** Requests, oldest first. `overdue: true` gives open requests past their due date. */
|
|
97
|
+
list(filter?: RequestFilter & {
|
|
98
|
+
overdue?: boolean;
|
|
99
|
+
}): Promise<RightsRequest[]>;
|
|
100
|
+
resolve(id: string, note?: string): Promise<RightsRequest>;
|
|
101
|
+
reject(id: string, reason: string): Promise<RightsRequest>;
|
|
102
|
+
/** What you hold about the person and who you shared it with (Section 11(1)). Needs `data`. */
|
|
103
|
+
summary(subjectId: string): Promise<AccessSummary>;
|
|
104
|
+
/**
|
|
105
|
+
* Erase on request (Section 12(3)): every purpose ends except those in `keepFor`, which you still
|
|
106
|
+
* need for the specified purpose. Legal holds and `minimumRetention` still apply. Pass the
|
|
107
|
+
* request id to resolve it.
|
|
108
|
+
*/
|
|
109
|
+
erase(subjectId: string, input?: {
|
|
110
|
+
keepFor?: readonly P[];
|
|
111
|
+
requestId?: string;
|
|
112
|
+
}): Promise<{
|
|
113
|
+
plan: ErasurePlan;
|
|
114
|
+
tasks: ErasureTask[];
|
|
115
|
+
}>;
|
|
59
116
|
};
|
|
60
117
|
}
|
|
61
118
|
type HashedFields = Omit<ConsentEvent, "hash">;
|
package/dist/drizzle.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { type PgDatabase } from "drizzle-orm/pg-core";
|
|
2
|
-
import type {
|
|
2
|
+
import type { DataAccess } from "./data-access.js";
|
|
3
|
+
import type { RequestStatus, RequestType, TaskKind, TaskStatus } from "./records.js";
|
|
4
|
+
import type { Schema } from "./schema-check.js";
|
|
5
|
+
import type { DpdpStore } from "./store.js";
|
|
3
6
|
/**
|
|
4
7
|
* The consent events table. Export it from your Drizzle schema so drizzle-kit creates it:
|
|
5
8
|
*
|
|
@@ -207,10 +210,508 @@ export declare const consentEvents: import("drizzle-orm/pg-core").PgTableWithCol
|
|
|
207
210
|
}>;
|
|
208
211
|
/** The same table as plain SQL, if you don't use drizzle-kit for migrations. */
|
|
209
212
|
export declare const CONSENT_EVENTS_DDL = "CREATE TABLE IF NOT EXISTS dpdp_consent_events (\n subject_id text NOT NULL,\n seq integer NOT NULL,\n action text NOT NULL CHECK (action IN ('grant', 'withdraw')),\n purposes jsonb NOT NULL,\n notice_version text,\n language text,\n channel text,\n evidence jsonb,\n at timestamptz NOT NULL,\n prev_hash text,\n hash text NOT NULL,\n PRIMARY KEY (subject_id, seq)\n);";
|
|
213
|
+
/** Rights requests (Sections 11–14). Export it from your Drizzle schema with `consentEvents`. */
|
|
214
|
+
export declare const rightsRequests: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
215
|
+
name: "dpdp_requests";
|
|
216
|
+
schema: undefined;
|
|
217
|
+
columns: {
|
|
218
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
219
|
+
name: "id";
|
|
220
|
+
tableName: "dpdp_requests";
|
|
221
|
+
dataType: "string";
|
|
222
|
+
columnType: "PgText";
|
|
223
|
+
data: string;
|
|
224
|
+
driverParam: string;
|
|
225
|
+
notNull: true;
|
|
226
|
+
hasDefault: false;
|
|
227
|
+
isPrimaryKey: true;
|
|
228
|
+
isAutoincrement: false;
|
|
229
|
+
hasRuntimeDefault: false;
|
|
230
|
+
enumValues: [string, ...string[]];
|
|
231
|
+
baseColumn: never;
|
|
232
|
+
identity: undefined;
|
|
233
|
+
generated: undefined;
|
|
234
|
+
}, {}, {}>;
|
|
235
|
+
subjectId: import("drizzle-orm/pg-core").PgColumn<{
|
|
236
|
+
name: "subject_id";
|
|
237
|
+
tableName: "dpdp_requests";
|
|
238
|
+
dataType: "string";
|
|
239
|
+
columnType: "PgText";
|
|
240
|
+
data: string;
|
|
241
|
+
driverParam: string;
|
|
242
|
+
notNull: true;
|
|
243
|
+
hasDefault: false;
|
|
244
|
+
isPrimaryKey: false;
|
|
245
|
+
isAutoincrement: false;
|
|
246
|
+
hasRuntimeDefault: false;
|
|
247
|
+
enumValues: [string, ...string[]];
|
|
248
|
+
baseColumn: never;
|
|
249
|
+
identity: undefined;
|
|
250
|
+
generated: undefined;
|
|
251
|
+
}, {}, {}>;
|
|
252
|
+
type: import("drizzle-orm/pg-core").PgColumn<{
|
|
253
|
+
name: "type";
|
|
254
|
+
tableName: "dpdp_requests";
|
|
255
|
+
dataType: "string";
|
|
256
|
+
columnType: "PgText";
|
|
257
|
+
data: RequestType;
|
|
258
|
+
driverParam: string;
|
|
259
|
+
notNull: true;
|
|
260
|
+
hasDefault: false;
|
|
261
|
+
isPrimaryKey: false;
|
|
262
|
+
isAutoincrement: false;
|
|
263
|
+
hasRuntimeDefault: false;
|
|
264
|
+
enumValues: [string, ...string[]];
|
|
265
|
+
baseColumn: never;
|
|
266
|
+
identity: undefined;
|
|
267
|
+
generated: undefined;
|
|
268
|
+
}, {}, {
|
|
269
|
+
$type: RequestType;
|
|
270
|
+
}>;
|
|
271
|
+
status: import("drizzle-orm/pg-core").PgColumn<{
|
|
272
|
+
name: "status";
|
|
273
|
+
tableName: "dpdp_requests";
|
|
274
|
+
dataType: "string";
|
|
275
|
+
columnType: "PgText";
|
|
276
|
+
data: RequestStatus;
|
|
277
|
+
driverParam: string;
|
|
278
|
+
notNull: true;
|
|
279
|
+
hasDefault: false;
|
|
280
|
+
isPrimaryKey: false;
|
|
281
|
+
isAutoincrement: false;
|
|
282
|
+
hasRuntimeDefault: false;
|
|
283
|
+
enumValues: [string, ...string[]];
|
|
284
|
+
baseColumn: never;
|
|
285
|
+
identity: undefined;
|
|
286
|
+
generated: undefined;
|
|
287
|
+
}, {}, {
|
|
288
|
+
$type: RequestStatus;
|
|
289
|
+
}>;
|
|
290
|
+
openedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
291
|
+
name: string;
|
|
292
|
+
tableName: "dpdp_requests";
|
|
293
|
+
dataType: "date";
|
|
294
|
+
columnType: "PgTimestamp";
|
|
295
|
+
data: Date;
|
|
296
|
+
driverParam: string;
|
|
297
|
+
notNull: true;
|
|
298
|
+
hasDefault: false;
|
|
299
|
+
isPrimaryKey: false;
|
|
300
|
+
isAutoincrement: false;
|
|
301
|
+
hasRuntimeDefault: false;
|
|
302
|
+
enumValues: undefined;
|
|
303
|
+
baseColumn: never;
|
|
304
|
+
identity: undefined;
|
|
305
|
+
generated: undefined;
|
|
306
|
+
}, {}, {}>;
|
|
307
|
+
dueAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
308
|
+
name: string;
|
|
309
|
+
tableName: "dpdp_requests";
|
|
310
|
+
dataType: "date";
|
|
311
|
+
columnType: "PgTimestamp";
|
|
312
|
+
data: Date;
|
|
313
|
+
driverParam: string;
|
|
314
|
+
notNull: true;
|
|
315
|
+
hasDefault: false;
|
|
316
|
+
isPrimaryKey: false;
|
|
317
|
+
isAutoincrement: false;
|
|
318
|
+
hasRuntimeDefault: false;
|
|
319
|
+
enumValues: undefined;
|
|
320
|
+
baseColumn: never;
|
|
321
|
+
identity: undefined;
|
|
322
|
+
generated: undefined;
|
|
323
|
+
}, {}, {}>;
|
|
324
|
+
closedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
325
|
+
name: string;
|
|
326
|
+
tableName: "dpdp_requests";
|
|
327
|
+
dataType: "date";
|
|
328
|
+
columnType: "PgTimestamp";
|
|
329
|
+
data: Date;
|
|
330
|
+
driverParam: string;
|
|
331
|
+
notNull: false;
|
|
332
|
+
hasDefault: false;
|
|
333
|
+
isPrimaryKey: false;
|
|
334
|
+
isAutoincrement: false;
|
|
335
|
+
hasRuntimeDefault: false;
|
|
336
|
+
enumValues: undefined;
|
|
337
|
+
baseColumn: never;
|
|
338
|
+
identity: undefined;
|
|
339
|
+
generated: undefined;
|
|
340
|
+
}, {}, {}>;
|
|
341
|
+
details: import("drizzle-orm/pg-core").PgColumn<{
|
|
342
|
+
name: "details";
|
|
343
|
+
tableName: "dpdp_requests";
|
|
344
|
+
dataType: "json";
|
|
345
|
+
columnType: "PgJsonb";
|
|
346
|
+
data: Record<string, unknown>;
|
|
347
|
+
driverParam: unknown;
|
|
348
|
+
notNull: false;
|
|
349
|
+
hasDefault: false;
|
|
350
|
+
isPrimaryKey: false;
|
|
351
|
+
isAutoincrement: false;
|
|
352
|
+
hasRuntimeDefault: false;
|
|
353
|
+
enumValues: undefined;
|
|
354
|
+
baseColumn: never;
|
|
355
|
+
identity: undefined;
|
|
356
|
+
generated: undefined;
|
|
357
|
+
}, {}, {
|
|
358
|
+
$type: Record<string, unknown>;
|
|
359
|
+
}>;
|
|
360
|
+
history: import("drizzle-orm/pg-core").PgColumn<{
|
|
361
|
+
name: "history";
|
|
362
|
+
tableName: "dpdp_requests";
|
|
363
|
+
dataType: "json";
|
|
364
|
+
columnType: "PgJsonb";
|
|
365
|
+
data: import("./records.js").RequestHistoryEntry[];
|
|
366
|
+
driverParam: unknown;
|
|
367
|
+
notNull: true;
|
|
368
|
+
hasDefault: false;
|
|
369
|
+
isPrimaryKey: false;
|
|
370
|
+
isAutoincrement: false;
|
|
371
|
+
hasRuntimeDefault: false;
|
|
372
|
+
enumValues: undefined;
|
|
373
|
+
baseColumn: never;
|
|
374
|
+
identity: undefined;
|
|
375
|
+
generated: undefined;
|
|
376
|
+
}, {}, {
|
|
377
|
+
$type: import("./records.js").RequestHistoryEntry[];
|
|
378
|
+
}>;
|
|
379
|
+
};
|
|
380
|
+
dialect: 'pg';
|
|
381
|
+
}>;
|
|
382
|
+
/** Erasure tasks for the retention runner. Export it from your Drizzle schema with `consentEvents`. */
|
|
383
|
+
export declare const erasureTasks: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
384
|
+
name: "dpdp_erasure_tasks";
|
|
385
|
+
schema: undefined;
|
|
386
|
+
columns: {
|
|
387
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
388
|
+
name: "id";
|
|
389
|
+
tableName: "dpdp_erasure_tasks";
|
|
390
|
+
dataType: "string";
|
|
391
|
+
columnType: "PgText";
|
|
392
|
+
data: string;
|
|
393
|
+
driverParam: string;
|
|
394
|
+
notNull: true;
|
|
395
|
+
hasDefault: false;
|
|
396
|
+
isPrimaryKey: true;
|
|
397
|
+
isAutoincrement: false;
|
|
398
|
+
hasRuntimeDefault: false;
|
|
399
|
+
enumValues: [string, ...string[]];
|
|
400
|
+
baseColumn: never;
|
|
401
|
+
identity: undefined;
|
|
402
|
+
generated: undefined;
|
|
403
|
+
}, {}, {}>;
|
|
404
|
+
subjectId: import("drizzle-orm/pg-core").PgColumn<{
|
|
405
|
+
name: "subject_id";
|
|
406
|
+
tableName: "dpdp_erasure_tasks";
|
|
407
|
+
dataType: "string";
|
|
408
|
+
columnType: "PgText";
|
|
409
|
+
data: string;
|
|
410
|
+
driverParam: string;
|
|
411
|
+
notNull: true;
|
|
412
|
+
hasDefault: false;
|
|
413
|
+
isPrimaryKey: false;
|
|
414
|
+
isAutoincrement: false;
|
|
415
|
+
hasRuntimeDefault: false;
|
|
416
|
+
enumValues: [string, ...string[]];
|
|
417
|
+
baseColumn: never;
|
|
418
|
+
identity: undefined;
|
|
419
|
+
generated: undefined;
|
|
420
|
+
}, {}, {}>;
|
|
421
|
+
reason: import("drizzle-orm/pg-core").PgColumn<{
|
|
422
|
+
name: "reason";
|
|
423
|
+
tableName: "dpdp_erasure_tasks";
|
|
424
|
+
dataType: "string";
|
|
425
|
+
columnType: "PgText";
|
|
426
|
+
data: string;
|
|
427
|
+
driverParam: string;
|
|
428
|
+
notNull: true;
|
|
429
|
+
hasDefault: false;
|
|
430
|
+
isPrimaryKey: false;
|
|
431
|
+
isAutoincrement: false;
|
|
432
|
+
hasRuntimeDefault: false;
|
|
433
|
+
enumValues: [string, ...string[]];
|
|
434
|
+
baseColumn: never;
|
|
435
|
+
identity: undefined;
|
|
436
|
+
generated: undefined;
|
|
437
|
+
}, {}, {}>;
|
|
438
|
+
kind: import("drizzle-orm/pg-core").PgColumn<{
|
|
439
|
+
name: "kind";
|
|
440
|
+
tableName: "dpdp_erasure_tasks";
|
|
441
|
+
dataType: "string";
|
|
442
|
+
columnType: "PgText";
|
|
443
|
+
data: TaskKind;
|
|
444
|
+
driverParam: string;
|
|
445
|
+
notNull: true;
|
|
446
|
+
hasDefault: false;
|
|
447
|
+
isPrimaryKey: false;
|
|
448
|
+
isAutoincrement: false;
|
|
449
|
+
hasRuntimeDefault: false;
|
|
450
|
+
enumValues: [string, ...string[]];
|
|
451
|
+
baseColumn: never;
|
|
452
|
+
identity: undefined;
|
|
453
|
+
generated: undefined;
|
|
454
|
+
}, {}, {
|
|
455
|
+
$type: TaskKind;
|
|
456
|
+
}>;
|
|
457
|
+
tableKey: import("drizzle-orm/pg-core").PgColumn<{
|
|
458
|
+
name: "table_key";
|
|
459
|
+
tableName: "dpdp_erasure_tasks";
|
|
460
|
+
dataType: "string";
|
|
461
|
+
columnType: "PgText";
|
|
462
|
+
data: string;
|
|
463
|
+
driverParam: string;
|
|
464
|
+
notNull: false;
|
|
465
|
+
hasDefault: false;
|
|
466
|
+
isPrimaryKey: false;
|
|
467
|
+
isAutoincrement: false;
|
|
468
|
+
hasRuntimeDefault: false;
|
|
469
|
+
enumValues: [string, ...string[]];
|
|
470
|
+
baseColumn: never;
|
|
471
|
+
identity: undefined;
|
|
472
|
+
generated: undefined;
|
|
473
|
+
}, {}, {}>;
|
|
474
|
+
fields: import("drizzle-orm/pg-core").PgColumn<{
|
|
475
|
+
name: "fields";
|
|
476
|
+
tableName: "dpdp_erasure_tasks";
|
|
477
|
+
dataType: "json";
|
|
478
|
+
columnType: "PgJsonb";
|
|
479
|
+
data: string[];
|
|
480
|
+
driverParam: unknown;
|
|
481
|
+
notNull: false;
|
|
482
|
+
hasDefault: false;
|
|
483
|
+
isPrimaryKey: false;
|
|
484
|
+
isAutoincrement: false;
|
|
485
|
+
hasRuntimeDefault: false;
|
|
486
|
+
enumValues: undefined;
|
|
487
|
+
baseColumn: never;
|
|
488
|
+
identity: undefined;
|
|
489
|
+
generated: undefined;
|
|
490
|
+
}, {}, {
|
|
491
|
+
$type: string[];
|
|
492
|
+
}>;
|
|
493
|
+
processor: import("drizzle-orm/pg-core").PgColumn<{
|
|
494
|
+
name: "processor";
|
|
495
|
+
tableName: "dpdp_erasure_tasks";
|
|
496
|
+
dataType: "string";
|
|
497
|
+
columnType: "PgText";
|
|
498
|
+
data: string;
|
|
499
|
+
driverParam: string;
|
|
500
|
+
notNull: false;
|
|
501
|
+
hasDefault: false;
|
|
502
|
+
isPrimaryKey: false;
|
|
503
|
+
isAutoincrement: false;
|
|
504
|
+
hasRuntimeDefault: false;
|
|
505
|
+
enumValues: [string, ...string[]];
|
|
506
|
+
baseColumn: never;
|
|
507
|
+
identity: undefined;
|
|
508
|
+
generated: undefined;
|
|
509
|
+
}, {}, {}>;
|
|
510
|
+
purposes: import("drizzle-orm/pg-core").PgColumn<{
|
|
511
|
+
name: "purposes";
|
|
512
|
+
tableName: "dpdp_erasure_tasks";
|
|
513
|
+
dataType: "json";
|
|
514
|
+
columnType: "PgJsonb";
|
|
515
|
+
data: string[];
|
|
516
|
+
driverParam: unknown;
|
|
517
|
+
notNull: false;
|
|
518
|
+
hasDefault: false;
|
|
519
|
+
isPrimaryKey: false;
|
|
520
|
+
isAutoincrement: false;
|
|
521
|
+
hasRuntimeDefault: false;
|
|
522
|
+
enumValues: undefined;
|
|
523
|
+
baseColumn: never;
|
|
524
|
+
identity: undefined;
|
|
525
|
+
generated: undefined;
|
|
526
|
+
}, {}, {
|
|
527
|
+
$type: string[];
|
|
528
|
+
}>;
|
|
529
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
530
|
+
name: string;
|
|
531
|
+
tableName: "dpdp_erasure_tasks";
|
|
532
|
+
dataType: "date";
|
|
533
|
+
columnType: "PgTimestamp";
|
|
534
|
+
data: Date;
|
|
535
|
+
driverParam: string;
|
|
536
|
+
notNull: true;
|
|
537
|
+
hasDefault: false;
|
|
538
|
+
isPrimaryKey: false;
|
|
539
|
+
isAutoincrement: false;
|
|
540
|
+
hasRuntimeDefault: false;
|
|
541
|
+
enumValues: undefined;
|
|
542
|
+
baseColumn: never;
|
|
543
|
+
identity: undefined;
|
|
544
|
+
generated: undefined;
|
|
545
|
+
}, {}, {}>;
|
|
546
|
+
dueAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
547
|
+
name: string;
|
|
548
|
+
tableName: "dpdp_erasure_tasks";
|
|
549
|
+
dataType: "date";
|
|
550
|
+
columnType: "PgTimestamp";
|
|
551
|
+
data: Date;
|
|
552
|
+
driverParam: string;
|
|
553
|
+
notNull: true;
|
|
554
|
+
hasDefault: false;
|
|
555
|
+
isPrimaryKey: false;
|
|
556
|
+
isAutoincrement: false;
|
|
557
|
+
hasRuntimeDefault: false;
|
|
558
|
+
enumValues: undefined;
|
|
559
|
+
baseColumn: never;
|
|
560
|
+
identity: undefined;
|
|
561
|
+
generated: undefined;
|
|
562
|
+
}, {}, {}>;
|
|
563
|
+
status: import("drizzle-orm/pg-core").PgColumn<{
|
|
564
|
+
name: "status";
|
|
565
|
+
tableName: "dpdp_erasure_tasks";
|
|
566
|
+
dataType: "string";
|
|
567
|
+
columnType: "PgText";
|
|
568
|
+
data: TaskStatus;
|
|
569
|
+
driverParam: string;
|
|
570
|
+
notNull: true;
|
|
571
|
+
hasDefault: false;
|
|
572
|
+
isPrimaryKey: false;
|
|
573
|
+
isAutoincrement: false;
|
|
574
|
+
hasRuntimeDefault: false;
|
|
575
|
+
enumValues: [string, ...string[]];
|
|
576
|
+
baseColumn: never;
|
|
577
|
+
identity: undefined;
|
|
578
|
+
generated: undefined;
|
|
579
|
+
}, {}, {
|
|
580
|
+
$type: TaskStatus;
|
|
581
|
+
}>;
|
|
582
|
+
attempts: import("drizzle-orm/pg-core").PgColumn<{
|
|
583
|
+
name: "attempts";
|
|
584
|
+
tableName: "dpdp_erasure_tasks";
|
|
585
|
+
dataType: "number";
|
|
586
|
+
columnType: "PgInteger";
|
|
587
|
+
data: number;
|
|
588
|
+
driverParam: string | number;
|
|
589
|
+
notNull: true;
|
|
590
|
+
hasDefault: false;
|
|
591
|
+
isPrimaryKey: false;
|
|
592
|
+
isAutoincrement: false;
|
|
593
|
+
hasRuntimeDefault: false;
|
|
594
|
+
enumValues: undefined;
|
|
595
|
+
baseColumn: never;
|
|
596
|
+
identity: undefined;
|
|
597
|
+
generated: undefined;
|
|
598
|
+
}, {}, {}>;
|
|
599
|
+
claimedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
600
|
+
name: string;
|
|
601
|
+
tableName: "dpdp_erasure_tasks";
|
|
602
|
+
dataType: "date";
|
|
603
|
+
columnType: "PgTimestamp";
|
|
604
|
+
data: Date;
|
|
605
|
+
driverParam: string;
|
|
606
|
+
notNull: false;
|
|
607
|
+
hasDefault: false;
|
|
608
|
+
isPrimaryKey: false;
|
|
609
|
+
isAutoincrement: false;
|
|
610
|
+
hasRuntimeDefault: false;
|
|
611
|
+
enumValues: undefined;
|
|
612
|
+
baseColumn: never;
|
|
613
|
+
identity: undefined;
|
|
614
|
+
generated: undefined;
|
|
615
|
+
}, {}, {}>;
|
|
616
|
+
doneAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
617
|
+
name: string;
|
|
618
|
+
tableName: "dpdp_erasure_tasks";
|
|
619
|
+
dataType: "date";
|
|
620
|
+
columnType: "PgTimestamp";
|
|
621
|
+
data: Date;
|
|
622
|
+
driverParam: string;
|
|
623
|
+
notNull: false;
|
|
624
|
+
hasDefault: false;
|
|
625
|
+
isPrimaryKey: false;
|
|
626
|
+
isAutoincrement: false;
|
|
627
|
+
hasRuntimeDefault: false;
|
|
628
|
+
enumValues: undefined;
|
|
629
|
+
baseColumn: never;
|
|
630
|
+
identity: undefined;
|
|
631
|
+
generated: undefined;
|
|
632
|
+
}, {}, {}>;
|
|
633
|
+
affected: import("drizzle-orm/pg-core").PgColumn<{
|
|
634
|
+
name: "affected";
|
|
635
|
+
tableName: "dpdp_erasure_tasks";
|
|
636
|
+
dataType: "number";
|
|
637
|
+
columnType: "PgInteger";
|
|
638
|
+
data: number;
|
|
639
|
+
driverParam: string | number;
|
|
640
|
+
notNull: false;
|
|
641
|
+
hasDefault: false;
|
|
642
|
+
isPrimaryKey: false;
|
|
643
|
+
isAutoincrement: false;
|
|
644
|
+
hasRuntimeDefault: false;
|
|
645
|
+
enumValues: undefined;
|
|
646
|
+
baseColumn: never;
|
|
647
|
+
identity: undefined;
|
|
648
|
+
generated: undefined;
|
|
649
|
+
}, {}, {}>;
|
|
650
|
+
lastError: import("drizzle-orm/pg-core").PgColumn<{
|
|
651
|
+
name: "last_error";
|
|
652
|
+
tableName: "dpdp_erasure_tasks";
|
|
653
|
+
dataType: "string";
|
|
654
|
+
columnType: "PgText";
|
|
655
|
+
data: string;
|
|
656
|
+
driverParam: string;
|
|
657
|
+
notNull: false;
|
|
658
|
+
hasDefault: false;
|
|
659
|
+
isPrimaryKey: false;
|
|
660
|
+
isAutoincrement: false;
|
|
661
|
+
hasRuntimeDefault: false;
|
|
662
|
+
enumValues: [string, ...string[]];
|
|
663
|
+
baseColumn: never;
|
|
664
|
+
identity: undefined;
|
|
665
|
+
generated: undefined;
|
|
666
|
+
}, {}, {}>;
|
|
667
|
+
note: import("drizzle-orm/pg-core").PgColumn<{
|
|
668
|
+
name: "note";
|
|
669
|
+
tableName: "dpdp_erasure_tasks";
|
|
670
|
+
dataType: "string";
|
|
671
|
+
columnType: "PgText";
|
|
672
|
+
data: string;
|
|
673
|
+
driverParam: string;
|
|
674
|
+
notNull: false;
|
|
675
|
+
hasDefault: false;
|
|
676
|
+
isPrimaryKey: false;
|
|
677
|
+
isAutoincrement: false;
|
|
678
|
+
hasRuntimeDefault: false;
|
|
679
|
+
enumValues: [string, ...string[]];
|
|
680
|
+
baseColumn: never;
|
|
681
|
+
identity: undefined;
|
|
682
|
+
generated: undefined;
|
|
683
|
+
}, {}, {}>;
|
|
684
|
+
};
|
|
685
|
+
dialect: 'pg';
|
|
686
|
+
}>;
|
|
687
|
+
/** Rights requests and erasure tasks as plain SQL, if you don't use drizzle-kit for migrations. */
|
|
688
|
+
export declare const RECORDS_DDL = "CREATE TABLE IF NOT EXISTS dpdp_requests (\n id text PRIMARY KEY,\n subject_id text NOT NULL,\n type text NOT NULL,\n status text NOT NULL,\n opened_at timestamptz NOT NULL,\n due_at timestamptz NOT NULL,\n closed_at timestamptz,\n details jsonb,\n history jsonb NOT NULL\n);\nCREATE INDEX IF NOT EXISTS dpdp_requests_subject_idx ON dpdp_requests (subject_id);\nCREATE INDEX IF NOT EXISTS dpdp_requests_status_due_idx ON dpdp_requests (status, due_at);\nCREATE TABLE IF NOT EXISTS dpdp_erasure_tasks (\n id text PRIMARY KEY,\n subject_id text NOT NULL,\n reason text NOT NULL,\n kind text NOT NULL,\n table_key text,\n fields jsonb,\n processor text,\n purposes jsonb,\n created_at timestamptz NOT NULL,\n due_at timestamptz NOT NULL,\n status text NOT NULL,\n attempts integer NOT NULL,\n claimed_at timestamptz,\n done_at timestamptz,\n affected integer,\n last_error text,\n note text\n);\nCREATE INDEX IF NOT EXISTS dpdp_erasure_tasks_subject_idx ON dpdp_erasure_tasks (subject_id);\nCREATE INDEX IF NOT EXISTS dpdp_erasure_tasks_status_due_idx ON dpdp_erasure_tasks (status, due_at);";
|
|
689
|
+
/** Every dpdp-kit table as plain SQL. */
|
|
690
|
+
export declare const DPDP_DDL = "CREATE TABLE IF NOT EXISTS dpdp_consent_events (\n subject_id text NOT NULL,\n seq integer NOT NULL,\n action text NOT NULL CHECK (action IN ('grant', 'withdraw')),\n purposes jsonb NOT NULL,\n notice_version text,\n language text,\n channel text,\n evidence jsonb,\n at timestamptz NOT NULL,\n prev_hash text,\n hash text NOT NULL,\n PRIMARY KEY (subject_id, seq)\n);\nCREATE TABLE IF NOT EXISTS dpdp_requests (\n id text PRIMARY KEY,\n subject_id text NOT NULL,\n type text NOT NULL,\n status text NOT NULL,\n opened_at timestamptz NOT NULL,\n due_at timestamptz NOT NULL,\n closed_at timestamptz,\n details jsonb,\n history jsonb NOT NULL\n);\nCREATE INDEX IF NOT EXISTS dpdp_requests_subject_idx ON dpdp_requests (subject_id);\nCREATE INDEX IF NOT EXISTS dpdp_requests_status_due_idx ON dpdp_requests (status, due_at);\nCREATE TABLE IF NOT EXISTS dpdp_erasure_tasks (\n id text PRIMARY KEY,\n subject_id text NOT NULL,\n reason text NOT NULL,\n kind text NOT NULL,\n table_key text,\n fields jsonb,\n processor text,\n purposes jsonb,\n created_at timestamptz NOT NULL,\n due_at timestamptz NOT NULL,\n status text NOT NULL,\n attempts integer NOT NULL,\n claimed_at timestamptz,\n done_at timestamptz,\n affected integer,\n last_error text,\n note text\n);\nCREATE INDEX IF NOT EXISTS dpdp_erasure_tasks_subject_idx ON dpdp_erasure_tasks (subject_id);\nCREATE INDEX IF NOT EXISTS dpdp_erasure_tasks_status_due_idx ON dpdp_erasure_tasks (status, due_at);";
|
|
210
691
|
type AnyPgDatabase = PgDatabase<any, any, any>;
|
|
211
692
|
/**
|
|
212
|
-
*
|
|
213
|
-
* PGlite and other Drizzle Postgres drivers.
|
|
693
|
+
* Store on Postgres through Drizzle: consent events, rights requests and erasure tasks. Works with
|
|
694
|
+
* node-postgres, postgres.js, Neon, PGlite and other Drizzle Postgres drivers. Needs the tables
|
|
695
|
+
* `consentEvents`, `rightsRequests` and `erasureTasks` (or `DPDP_DDL`).
|
|
696
|
+
*/
|
|
697
|
+
export declare function drizzleStore(db: AnyPgDatabase): DpdpStore;
|
|
698
|
+
/**
|
|
699
|
+
* Read a Drizzle schema module (Postgres, MySQL or SQLite) for `checkSchema()`. Pass the module
|
|
700
|
+
* itself, so every exported table is found:
|
|
701
|
+
*
|
|
702
|
+
* ```ts
|
|
703
|
+
* import * as schema from "./db/schema";
|
|
704
|
+
* checkSchema(config, drizzleSchema(schema));
|
|
705
|
+
* ```
|
|
706
|
+
*/
|
|
707
|
+
export declare function drizzleSchema(module: Record<string, unknown>): Schema;
|
|
708
|
+
/**
|
|
709
|
+
* Data access for your own Postgres tables through Drizzle, for access summaries and erasure.
|
|
710
|
+
* Pass your schema module if data map names are Drizzle property names (`userId`) rather than
|
|
711
|
+
* database column names (`user_id`). Erasure sets fields to NULL, so erasable columns must be
|
|
712
|
+
* nullable; a NOT NULL column makes the task fail with the database's message.
|
|
214
713
|
*/
|
|
215
|
-
export declare function
|
|
714
|
+
export declare function drizzleData(db: AnyPgDatabase, options?: {
|
|
715
|
+
schema?: Record<string, unknown>;
|
|
716
|
+
}): DataAccess;
|
|
216
717
|
export {};
|