@nodii/dsar 0.0.2 → 0.2.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.
Files changed (78) hide show
  1. package/README.md +57 -1
  2. package/dist/audit-actions.d.ts +13 -0
  3. package/dist/audit-actions.d.ts.map +1 -0
  4. package/dist/audit-actions.js +32 -0
  5. package/dist/audit-actions.js.map +1 -0
  6. package/dist/bind-pattern-a.d.ts +27 -0
  7. package/dist/bind-pattern-a.d.ts.map +1 -0
  8. package/dist/bind-pattern-a.js +387 -0
  9. package/dist/bind-pattern-a.js.map +1 -0
  10. package/dist/bind-pattern-b.d.ts +10 -0
  11. package/dist/bind-pattern-b.d.ts.map +1 -0
  12. package/dist/bind-pattern-b.js +89 -0
  13. package/dist/bind-pattern-b.js.map +1 -0
  14. package/dist/bind-pattern-c.d.ts +6 -0
  15. package/dist/bind-pattern-c.d.ts.map +1 -0
  16. package/dist/bind-pattern-c.js +9 -0
  17. package/dist/bind-pattern-c.js.map +1 -0
  18. package/dist/canonical.d.ts +9 -0
  19. package/dist/canonical.d.ts.map +1 -0
  20. package/dist/canonical.js +57 -0
  21. package/dist/canonical.js.map +1 -0
  22. package/dist/grpc/dsar-service.d.ts +37 -0
  23. package/dist/grpc/dsar-service.d.ts.map +1 -0
  24. package/dist/grpc/dsar-service.js +66 -0
  25. package/dist/grpc/dsar-service.js.map +1 -0
  26. package/dist/handlers.d.ts +102 -0
  27. package/dist/handlers.d.ts.map +1 -0
  28. package/dist/handlers.js +268 -0
  29. package/dist/handlers.js.map +1 -0
  30. package/dist/holds.d.ts +48 -0
  31. package/dist/holds.d.ts.map +1 -0
  32. package/dist/holds.js +79 -0
  33. package/dist/holds.js.map +1 -0
  34. package/dist/index.d.ts +33 -1
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +45 -4
  37. package/dist/index.js.map +1 -1
  38. package/dist/init.d.ts +21 -0
  39. package/dist/init.d.ts.map +1 -0
  40. package/dist/init.js +37 -0
  41. package/dist/init.js.map +1 -0
  42. package/dist/migrations/index.d.ts +15 -0
  43. package/dist/migrations/index.d.ts.map +1 -0
  44. package/dist/migrations/index.js +110 -0
  45. package/dist/migrations/index.js.map +1 -0
  46. package/dist/orchestrator.d.ts +41 -0
  47. package/dist/orchestrator.d.ts.map +1 -0
  48. package/dist/orchestrator.js +205 -0
  49. package/dist/orchestrator.js.map +1 -0
  50. package/dist/register.d.ts +36 -0
  51. package/dist/register.d.ts.map +1 -0
  52. package/dist/register.js +97 -0
  53. package/dist/register.js.map +1 -0
  54. package/dist/registry.d.ts +10 -0
  55. package/dist/registry.d.ts.map +1 -0
  56. package/dist/registry.js +57 -0
  57. package/dist/registry.js.map +1 -0
  58. package/dist/retention.d.ts +17 -0
  59. package/dist/retention.d.ts.map +1 -0
  60. package/dist/retention.js +32 -0
  61. package/dist/retention.js.map +1 -0
  62. package/dist/s3-artifact.d.ts +56 -0
  63. package/dist/s3-artifact.d.ts.map +1 -0
  64. package/dist/s3-artifact.js +121 -0
  65. package/dist/s3-artifact.js.map +1 -0
  66. package/dist/state-store/postgres-lifecycle.d.ts +69 -0
  67. package/dist/state-store/postgres-lifecycle.d.ts.map +1 -0
  68. package/dist/state-store/postgres-lifecycle.js +145 -0
  69. package/dist/state-store/postgres-lifecycle.js.map +1 -0
  70. package/dist/store.d.ts +19 -0
  71. package/dist/store.d.ts.map +1 -0
  72. package/dist/store.js +66 -0
  73. package/dist/store.js.map +1 -0
  74. package/dist/types.d.ts +277 -0
  75. package/dist/types.d.ts.map +1 -0
  76. package/dist/types.js +103 -0
  77. package/dist/types.js.map +1 -0
  78. package/package.json +23 -7
@@ -0,0 +1,48 @@
1
+ import type { HoldConsultResult } from "./types";
2
+ type SqlClient = {
3
+ unsafe: (sql: string, args?: unknown[]) => Promise<any>;
4
+ };
5
+ export interface IsHeldOpts {
6
+ sql: SqlClient;
7
+ tenantId: string;
8
+ subjectId?: string;
9
+ holdKind: "erase" | "restrict";
10
+ /** Defaults to `data_residency_holds`. */
11
+ tableName?: string;
12
+ }
13
+ /**
14
+ * Check whether `(tenantId, subjectId?, holdKind)` matches an active hold.
15
+ *
16
+ * A subject-level hold matches when subjectId is supplied AND a row exists
17
+ * with that exact subjectId. A tenant-level hold (subject_id IS NULL in the
18
+ * row) ALWAYS matches — tenant holds override subject lookups.
19
+ */
20
+ export declare function isHeld(opts: IsHeldOpts): Promise<HoldConsultResult>;
21
+ /**
22
+ * Place a retention hold.
23
+ */
24
+ export declare function placeHold(opts: {
25
+ sql: SqlClient;
26
+ tenantId: string;
27
+ subjectId: string | null;
28
+ holdKind: "erase" | "restrict";
29
+ statuteCitation: string;
30
+ expiresAt?: string;
31
+ placedBy: string;
32
+ tableName?: string;
33
+ }): Promise<{
34
+ id: string;
35
+ }>;
36
+ /** Lift any matching active hold. */
37
+ export declare function liftHold(opts: {
38
+ sql: SqlClient;
39
+ tenantId: string;
40
+ subjectId: string | null;
41
+ holdKind: "erase" | "restrict";
42
+ liftedBy: string;
43
+ tableName?: string;
44
+ }): Promise<{
45
+ count: number;
46
+ }>;
47
+ export {};
48
+ //# sourceMappingURL=holds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"holds.d.ts","sourceRoot":"","sources":["../src/holds.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,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,UAAU;IACzB,GAAG,EAAE,SAAS,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,GAAG,UAAU,CAAC;IAC/B,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAsB,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA2BzE;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,GAAG,EAAE,SAAS,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,OAAO,GAAG,UAAU,CAAC;IAC/B,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAiB1B;AAED,qCAAqC;AACrC,wBAAsB,QAAQ,CAAC,IAAI,EAAE;IACnC,GAAG,EAAE,SAAS,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,OAAO,GAAG,UAAU,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAc7B"}
package/dist/holds.js ADDED
@@ -0,0 +1,79 @@
1
+ // data_residency_holds integration per spec § 5.8.
2
+ //
3
+ // Pattern A handlers consult `isHeld` before any erase/restrict path. If
4
+ // held, the consumer handler doesn't run; we return `HELD` with the citation
5
+ // instead.
6
+ /**
7
+ * Check whether `(tenantId, subjectId?, holdKind)` matches an active hold.
8
+ *
9
+ * A subject-level hold matches when subjectId is supplied AND a row exists
10
+ * with that exact subjectId. A tenant-level hold (subject_id IS NULL in the
11
+ * row) ALWAYS matches — tenant holds override subject lookups.
12
+ */
13
+ export async function isHeld(opts) {
14
+ const table = opts.tableName ?? "data_residency_holds";
15
+ // tenant-level holds first (subject_id IS NULL), then subject-specific.
16
+ const stmt = `SELECT statute_citation,
17
+ to_char(expires_at, 'YYYY-MM-DD"T"HH24:MI:SS.US"Z"') AS expires_at
18
+ FROM ${table}
19
+ WHERE tenant_id = $1 AND hold_kind = $2
20
+ AND lifted_at IS NULL
21
+ AND (subject_id IS NULL OR subject_id = $3)
22
+ AND (expires_at IS NULL OR expires_at > now())
23
+ ORDER BY (subject_id IS NULL) DESC, placed_at DESC
24
+ LIMIT 1`;
25
+ const rows = (await opts.sql.unsafe(stmt, [
26
+ opts.tenantId,
27
+ opts.holdKind,
28
+ opts.subjectId ?? null,
29
+ ]));
30
+ if (rows.length === 0) {
31
+ return { held: false };
32
+ }
33
+ const r = rows[0];
34
+ if (!r)
35
+ return { held: false };
36
+ return {
37
+ held: true,
38
+ statute_citation: r.statute_citation,
39
+ expires_at: r.expires_at ?? undefined,
40
+ };
41
+ }
42
+ /**
43
+ * Place a retention hold.
44
+ */
45
+ export async function placeHold(opts) {
46
+ const table = opts.tableName ?? "data_residency_holds";
47
+ const { randomUUID } = await import("node:crypto");
48
+ const id = randomUUID();
49
+ const stmt = `INSERT INTO ${table}
50
+ (id, tenant_id, subject_id, hold_kind, statute_citation, expires_at, placed_by)
51
+ VALUES ($1, $2, $3, $4, $5, $6::timestamptz, $7)`;
52
+ await opts.sql.unsafe(stmt, [
53
+ id,
54
+ opts.tenantId,
55
+ opts.subjectId,
56
+ opts.holdKind,
57
+ opts.statuteCitation,
58
+ opts.expiresAt ?? null,
59
+ opts.placedBy,
60
+ ]);
61
+ return { id };
62
+ }
63
+ /** Lift any matching active hold. */
64
+ export async function liftHold(opts) {
65
+ const table = opts.tableName ?? "data_residency_holds";
66
+ const stmt = `UPDATE ${table}
67
+ SET lifted_at = now(), lifted_by = $4
68
+ WHERE tenant_id = $1 AND hold_kind = $2 AND lifted_at IS NULL
69
+ AND ($3::text IS NULL OR subject_id = $3 OR subject_id IS NULL)`;
70
+ const result = (await opts.sql.unsafe(stmt, [
71
+ opts.tenantId,
72
+ opts.holdKind,
73
+ opts.subjectId,
74
+ opts.liftedBy,
75
+ ]));
76
+ // porsager/postgres returns an array-like with .count = affected rows.
77
+ return { count: result.count ?? 0 };
78
+ }
79
+ //# sourceMappingURL=holds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"holds.js","sourceRoot":"","sources":["../src/holds.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,WAAW;AAkBX;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAgB;IAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,IAAI,sBAAsB,CAAC;IACvD,wEAAwE;IACxE,MAAM,IAAI,GAAG;;WAEJ,KAAK;;;;;;YAMJ,CAAC;IACX,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE;QACxC,IAAI,CAAC,QAAQ;QACb,IAAI,CAAC,QAAQ;QACb,IAAI,CAAC,SAAS,IAAI,IAAI;KACvB,CAAC,CAA8D,CAAC;IACjE,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACzB,CAAC;IACD,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,IAAI,CAAC,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IAC/B,OAAO;QACL,IAAI,EAAE,IAAI;QACV,gBAAgB,EAAE,CAAC,CAAC,gBAAgB;QACpC,UAAU,EAAE,CAAC,CAAC,UAAU,IAAI,SAAS;KACtC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,IAS/B;IACC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,IAAI,sBAAsB,CAAC;IACvD,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;IACnD,MAAM,EAAE,GAAG,UAAU,EAAE,CAAC;IACxB,MAAM,IAAI,GAAG,eAAe,KAAK;;qDAEkB,CAAC;IACpD,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE;QAC1B,EAAE;QACF,IAAI,CAAC,QAAQ;QACb,IAAI,CAAC,SAAS;QACd,IAAI,CAAC,QAAQ;QACb,IAAI,CAAC,eAAe;QACpB,IAAI,CAAC,SAAS,IAAI,IAAI;QACtB,IAAI,CAAC,QAAQ;KACd,CAAC,CAAC;IACH,OAAO,EAAE,EAAE,EAAE,CAAC;AAChB,CAAC;AAED,qCAAqC;AACrC,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAO9B;IACC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,IAAI,sBAAsB,CAAC;IACvD,MAAM,IAAI,GAAG,UAAU,KAAK;;;sEAGwC,CAAC;IACrE,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE;QAC1C,IAAI,CAAC,QAAQ;QACb,IAAI,CAAC,QAAQ;QACb,IAAI,CAAC,SAAS;QACd,IAAI,CAAC,QAAQ;KACd,CAAC,CAAmC,CAAC;IACtC,uEAAuE;IACvE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC;AACtC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,35 @@
1
1
  export declare const LIB_NAME = "dsar";
2
- export declare const VERSION = "0.0.1";
2
+ export declare const VERSION = "0.1.1";
3
+ export { initDsar, getDsarOrNull, requireDsar, _resetForTests, } from "./init";
4
+ export type { InitDsarConfig, ResolvedDsarConfig } from "./init";
5
+ export { InMemoryDsarStore } from "./store";
6
+ export { registerExportGather, registerEraseExecutor, registerRectifyHandler, lookupExportGather, lookupEraseExecutor, lookupRectifyHandler, _resetRegistryForTests, } from "./registry";
7
+ export { beginDsar, getDsar, listDsars, accessData, eraseData, portabilityExport, rectify, markComplete, appealRejection, dsar, JUSTIFICATION_MIN_LEN, _resetBeginLocksForTests, } from "./handlers";
8
+ export type { BeginDsarArgs, BeginDsarResult, GetDsarArgs, ListDsarsArgs, AccessDataArgs, AccessDataResult, EraseDataArgs, EraseDataResult, PortabilityExportArgs, PortabilityExportResult, RectifyArgs, RectifyResult, MarkCompleteArgs, MarkCompleteResult, AppealRejectionArgs, AppealRejectionResult, } from "./handlers";
9
+ export { canonicalJson, CanonicalSerializationError } from "./canonical";
10
+ export type { CanonicalValue } from "./canonical";
11
+ export { applyRetention } from "./retention";
12
+ export type { RetentionMatch } from "./retention";
13
+ export { DsarError, DsarNotInitialized, DsarNotFound, JustificationRequired, SubjectKindNotRegistered, DsarTerminalStateViolation, ExportGatherFailed, EraseExecutionFailed, HandlerAlreadyRegistered, } from "./types";
14
+ export type { CompensationLogEntry, DsarRequestType, DsarRow, DsarStatus, DsarStore, DsarSubjectKind, EraseExecutorFn, ExportGatherFn, PortabilityFormat, RectifyHandlerFn, RetentionPolicy, LifecycleResponse, SubjectKindStr, PatternAEnvelope, PatternAHandlers, RetentionHoldHandlers, HoldConsultResult, AuditEmitter, PiiAdapter, } from "./types";
15
+ export { type DsarServiceImpl, type DsarMethodHandler, noDataServiceImpl, subjectKindFromProto, } from "./grpc/dsar-service";
16
+ export { bindPatternA } from "./bind-pattern-a";
17
+ export type { BindPatternAOpts } from "./bind-pattern-a";
18
+ export { bindPatternB } from "./bind-pattern-b";
19
+ export type { BindPatternBOpts } from "./bind-pattern-b";
20
+ export { bindPatternC } from "./bind-pattern-c";
21
+ export type { BindPatternCOpts } from "./bind-pattern-c";
22
+ export { bindOrchestrator, dispatchModeFor, SYNC_RPCS, ASYNC_RPCS, } from "./orchestrator";
23
+ export type { BindOrchestratorOpts, SiblingClient, } from "./orchestrator";
24
+ export { registerWithOrchestrator } from "./register";
25
+ export type { RegisterWithOrchestratorOpts, RegisterWithOrchestratorResult, DataClassRegistration, } from "./register";
26
+ export { PostgresLifecycleRequestsStore, withLifecycleIdempotency, } from "./state-store/postgres-lifecycle";
27
+ export type { LifecycleRequestRow, PostgresLifecycleRequestsStoreOpts, } from "./state-store/postgres-lifecycle";
28
+ export { applyDsarMigrations, getDsarMigrationSQL, splitStatements, } from "./migrations";
29
+ export { isHeld, placeHold, liftHold } from "./holds";
30
+ export type { IsHeldOpts } from "./holds";
31
+ export { createArtifact, bucketNameForRegion, ensureBucket, makeS3Client, } from "./s3-artifact";
32
+ export type { CreateArtifactOpts, CreateArtifactResult, } from "./s3-artifact";
33
+ export { actionName, RPC_TO_VERB } from "./audit-actions";
34
+ export type { DsarPhase } from "./audit-actions";
3
35
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,QAAQ,SAAS,CAAC;AAC/B,eAAO,MAAM,OAAO,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,QAAQ,SAAS,CAAC;AAC/B,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,OAAO,EACL,QAAQ,EACR,aAAa,EACb,WAAW,EACX,cAAc,GACf,MAAM,QAAQ,CAAC;AAChB,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAEjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,SAAS,EACT,OAAO,EACP,SAAS,EACT,UAAU,EACV,SAAS,EACT,iBAAiB,EACj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AAChD,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGzD,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,SAAS,EACT,UAAU,GACX,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,oBAAoB,EACpB,aAAa,GACd,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACtD,YAAY,EACV,4BAA4B,EAC5B,8BAA8B,EAC9B,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,8BAA8B,EAC9B,wBAAwB,GACzB,MAAM,kCAAkC,CAAC;AAC1C,YAAY,EACV,mBAAmB,EACnB,kCAAkC,GACnC,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,GAChB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG1C,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC1D,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,48 @@
1
- // @nodii/dsar — placeholder at v0.0.1.
2
- // Implementation lands at v0.1.0 per the locked feature_doc.
1
+ // @nodii/dsar — v0.1.1 public barrel.
3
2
  //
4
- // Spec: https://planning.dev.nucleus-cloud.in/api/v1/feature-docs?serviceId=nodii-libs&docKey=dsar
3
+ // Spec: planning hub feature_doc serviceId=nodii-libs docKey=dsar.
4
+ // Polyglot ship: TS + Python + Go in parity.
5
+ //
6
+ // v0.1.1 surface:
7
+ // - Bootstrap: initDsar / getDsarOrNull / _resetForTests.
8
+ // - 9-RPC DataLifecycleService surface as typed handler functions (legacy
9
+ // pre-bind* shape; kept for backwards compat) + the proto-aligned
10
+ // LifecycleResponse-returning gRPC service descriptor shape (new).
11
+ // - Pattern A/B/C bindings: bindPatternA / bindPatternB / bindPatternC.
12
+ // - Orchestrator-side bindOrchestrator.
13
+ // - Service self-registry registerWithOrchestrator.
14
+ // - PostgresLifecycleRequestsStore + withLifecycleIdempotency wrap.
15
+ // - createArtifact() for S3 artifact lifecycle (against AWS or minio).
16
+ // - applyDsarMigrations() for lifecycle_requests + platform_lifecycle_requests
17
+ // + retention_policies + data_residency_holds.
18
+ // - isHeld() / placeHold() / liftHold() for data_residency_holds.
19
+ // - Audit-action auto-naming via actionName() per 28-action family.
5
20
  export const LIB_NAME = "dsar";
6
- export const VERSION = "0.0.1";
21
+ export const VERSION = "0.1.1";
22
+ // ---- Bootstrap ----
23
+ export { initDsar, getDsarOrNull, requireDsar, _resetForTests, } from "./init";
24
+ export { InMemoryDsarStore } from "./store";
25
+ // ---- Legacy 9-RPC handler-function surface (kept for backwards compat) ----
26
+ export { registerExportGather, registerEraseExecutor, registerRectifyHandler, lookupExportGather, lookupEraseExecutor, lookupRectifyHandler, _resetRegistryForTests, } from "./registry";
27
+ export { beginDsar, getDsar, listDsars, accessData, eraseData, portabilityExport, rectify, markComplete, appealRejection, dsar, JUSTIFICATION_MIN_LEN, _resetBeginLocksForTests, } from "./handlers";
28
+ export { canonicalJson, CanonicalSerializationError } from "./canonical";
29
+ export { applyRetention } from "./retention";
30
+ export { DsarError, DsarNotInitialized, DsarNotFound, JustificationRequired, SubjectKindNotRegistered, DsarTerminalStateViolation, ExportGatherFailed, EraseExecutionFailed, HandlerAlreadyRegistered, } from "./types";
31
+ // ---- v0.1.1: gRPC service descriptor + Pattern A/B/C bindings ----
32
+ export { noDataServiceImpl, subjectKindFromProto, } from "./grpc/dsar-service";
33
+ export { bindPatternA } from "./bind-pattern-a";
34
+ export { bindPatternB } from "./bind-pattern-b";
35
+ export { bindPatternC } from "./bind-pattern-c";
36
+ // ---- v0.1.1: orchestrator + register ----
37
+ export { bindOrchestrator, dispatchModeFor, SYNC_RPCS, ASYNC_RPCS, } from "./orchestrator";
38
+ export { registerWithOrchestrator } from "./register";
39
+ // ---- v0.1.1: lifecycle store + migrations ----
40
+ export { PostgresLifecycleRequestsStore, withLifecycleIdempotency, } from "./state-store/postgres-lifecycle";
41
+ export { applyDsarMigrations, getDsarMigrationSQL, splitStatements, } from "./migrations";
42
+ // ---- v0.1.1: holds ----
43
+ export { isHeld, placeHold, liftHold } from "./holds";
44
+ // ---- v0.1.1: S3 artifact ----
45
+ export { createArtifact, bucketNameForRegion, ensureBucket, makeS3Client, } from "./s3-artifact";
46
+ // ---- v0.1.1: audit-action helper ----
47
+ export { actionName, RPC_TO_VERB } from "./audit-actions";
7
48
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,6DAA6D;AAC7D,EAAE;AACF,mGAAmG;AAEnG,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC;AAC/B,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,mEAAmE;AACnE,6CAA6C;AAC7C,EAAE;AACF,kBAAkB;AAClB,4DAA4D;AAC5D,4EAA4E;AAC5E,sEAAsE;AACtE,uEAAuE;AACvE,0EAA0E;AAC1E,0CAA0C;AAC1C,sDAAsD;AACtD,sEAAsE;AACtE,yEAAyE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X,MAAM,gBAAgB,CAAC;AAMxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAOtD,iDAAiD;AACjD,OAAO,EACL,8BAA8B,EAC9B,wBAAwB,GACzB,MAAM,kCAAkC,CAAC;AAM1C,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,GAChB,MAAM,cAAc,CAAC;AAEtB,0BAA0B;AAC1B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGtD,gCAAgC;AAChC,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,YAAY,GACb,MAAM,eAAe,CAAC;AAMvB,wCAAwC;AACxC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/init.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import { type DsarStore } from "./types";
2
+ export interface InitDsarConfig {
3
+ /** Pluggable typed DsarStore. Defaults to InMemoryDsarStore. */
4
+ store?: DsarStore;
5
+ /** Custom warn logger (defaults to console.warn). */
6
+ logger?: {
7
+ warn(msg: string, fields?: Record<string, unknown>): void;
8
+ };
9
+ }
10
+ export interface ResolvedDsarConfig {
11
+ store: DsarStore;
12
+ logger: {
13
+ warn(msg: string, fields?: Record<string, unknown>): void;
14
+ };
15
+ }
16
+ export declare function initDsar(config?: InitDsarConfig): void;
17
+ export declare function requireDsar(): ResolvedDsarConfig;
18
+ export declare function getDsarOrNull(): ResolvedDsarConfig | null;
19
+ /** Test-only reset. Exposed through the public barrel for synthetic consumers. */
20
+ export declare function _resetForTests(): void;
21
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,SAAS,EAAsB,MAAM,SAAS,CAAC;AAE7D,MAAM,WAAW,cAAc;IAC7B,gEAAgE;IAChE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,qDAAqD;IACrD,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;KAAE,CAAC;CACxE;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE;QAAE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;KAAE,CAAC;CACvE;AAID,wBAAgB,QAAQ,CAAC,MAAM,GAAE,cAAmB,GAAG,IAAI,CAiB1D;AAED,wBAAgB,WAAW,IAAI,kBAAkB,CAKhD;AAED,wBAAgB,aAAa,IAAI,kBAAkB,GAAG,IAAI,CAEzD;AAED,kFAAkF;AAClF,wBAAgB,cAAc,IAAI,IAAI,CAErC"}
package/dist/init.js ADDED
@@ -0,0 +1,37 @@
1
+ // initDsar — process-local bootstrap; mirrors initSaga / initAuditChain.
2
+ //
3
+ // Subsequent calls warn + no-op (first-init wins). Public APIs throw
4
+ // `DsarNotInitialized` before init.
5
+ import { InMemoryDsarStore } from "./store";
6
+ import { DsarNotInitialized } from "./types";
7
+ let resolved = null;
8
+ export function initDsar(config = {}) {
9
+ if (resolved) {
10
+ // eslint-disable-next-line no-console
11
+ console.warn("[@nodii/dsar] initDsar() called more than once; ignoring subsequent call.");
12
+ return;
13
+ }
14
+ resolved = {
15
+ store: config.store ?? new InMemoryDsarStore(),
16
+ logger: config.logger ?? {
17
+ warn(msg, fields) {
18
+ // eslint-disable-next-line no-console
19
+ console.warn(`[@nodii/dsar] ${msg}`, fields ?? {});
20
+ },
21
+ },
22
+ };
23
+ }
24
+ export function requireDsar() {
25
+ if (!resolved) {
26
+ throw new DsarNotInitialized();
27
+ }
28
+ return resolved;
29
+ }
30
+ export function getDsarOrNull() {
31
+ return resolved;
32
+ }
33
+ /** Test-only reset. Exposed through the public barrel for synthetic consumers. */
34
+ export function _resetForTests() {
35
+ resolved = null;
36
+ }
37
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,EAAE;AACF,qEAAqE;AACrE,oCAAoC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAkB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAc7D,IAAI,QAAQ,GAA8B,IAAI,CAAC;AAE/C,MAAM,UAAU,QAAQ,CAAC,SAAyB,EAAE;IAClD,IAAI,QAAQ,EAAE,CAAC;QACb,sCAAsC;QACtC,OAAO,CAAC,IAAI,CACV,2EAA2E,CAC5E,CAAC;QACF,OAAO;IACT,CAAC;IACD,QAAQ,GAAG;QACT,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,IAAI,iBAAiB,EAAE;QAC9C,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI;YACvB,IAAI,CAAC,GAAG,EAAE,MAAM;gBACd,sCAAsC;gBACtC,OAAO,CAAC,IAAI,CAAC,iBAAiB,GAAG,EAAE,EAAE,MAAM,IAAI,EAAE,CAAC,CAAC;YACrD,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,kBAAkB,EAAE,CAAC;IACjC,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,cAAc;IAC5B,QAAQ,GAAG,IAAI,CAAC;AAClB,CAAC"}
@@ -0,0 +1,15 @@
1
+ type SqlClient = {
2
+ unsafe: (sql: string, args?: unknown[]) => Promise<any>;
3
+ };
4
+ export declare function getDsarMigrationSQL(): string;
5
+ /**
6
+ * Apply the DSAR migrations idempotently. Safe to call at every service boot.
7
+ *
8
+ * porsager/postgres refuses multi-statement queries via the extended-query
9
+ * protocol; we split on `;` boundaries we control.
10
+ */
11
+ export declare function applyDsarMigrations(sql: SqlClient): Promise<void>;
12
+ /** Internal — exported only for unit coverage. */
13
+ export declare function splitStatements(ddl: string): string[];
14
+ export {};
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAQA,KAAK,SAAS,GAAG;IAEf,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACzD,CAAC;AAqEF,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAMvE;AAED,kDAAkD;AAClD,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAerD"}
@@ -0,0 +1,110 @@
1
+ // Migration helper — applies the lifecycle_requests + platform_lifecycle_requests
2
+ // + retention_policies + data_residency_holds DDL idempotently.
3
+ //
4
+ // Services consume this via `applyDsarMigrations(sql)` at boot. Mirrors
5
+ // `applySagaMigrations` in shape. The SQL source-of-truth lives at
6
+ // `src/migrations/001-lifecycle-requests.sql` for downstream services that
7
+ // prefer a different migration runner (Flyway, golang-migrate, alembic).
8
+ const DSAR_MIGRATION_SQL = `
9
+ CREATE TABLE IF NOT EXISTS lifecycle_requests (
10
+ id UUID PRIMARY KEY,
11
+ request_id TEXT NOT NULL,
12
+ rpc_method TEXT NOT NULL,
13
+ tenant_id TEXT NOT NULL,
14
+ subject_kind TEXT NOT NULL,
15
+ subject_id TEXT NOT NULL,
16
+ status TEXT NOT NULL,
17
+ request_payload JSONB NOT NULL,
18
+ response_cached JSONB,
19
+ error_detail TEXT,
20
+ created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
21
+ completed_at TIMESTAMPTZ,
22
+ cleanup_after TIMESTAMPTZ NOT NULL DEFAULT (now() + interval '7 days'),
23
+ CONSTRAINT lifecycle_requests_request_id_rpc_uniq UNIQUE (request_id, rpc_method)
24
+ );
25
+ CREATE INDEX IF NOT EXISTS idx_lifecycle_requests_tenant_at
26
+ ON lifecycle_requests (tenant_id, created_at);
27
+ CREATE INDEX IF NOT EXISTS idx_lifecycle_requests_cleanup
28
+ ON lifecycle_requests (cleanup_after);
29
+ CREATE TABLE IF NOT EXISTS platform_lifecycle_requests (
30
+ id UUID PRIMARY KEY,
31
+ request_id TEXT NOT NULL,
32
+ rpc_method TEXT NOT NULL,
33
+ tenant_id TEXT NOT NULL,
34
+ subject_kind TEXT NOT NULL,
35
+ subject_id TEXT NOT NULL,
36
+ status TEXT NOT NULL,
37
+ sibling_results JSONB NOT NULL DEFAULT '{}'::jsonb,
38
+ requested_by TEXT NOT NULL,
39
+ result_artifact_uri TEXT,
40
+ created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
41
+ completed_at TIMESTAMPTZ,
42
+ CONSTRAINT platform_lifecycle_requests_uniq UNIQUE (request_id, rpc_method)
43
+ );
44
+ CREATE INDEX IF NOT EXISTS idx_platform_lifecycle_requests_tenant_at
45
+ ON platform_lifecycle_requests (tenant_id, created_at);
46
+ CREATE TABLE IF NOT EXISTS retention_policies (
47
+ service_id TEXT NOT NULL,
48
+ data_class TEXT NOT NULL,
49
+ subject_kind TEXT NOT NULL,
50
+ rpc_addr TEXT NOT NULL,
51
+ registered_at TIMESTAMPTZ NOT NULL DEFAULT now(),
52
+ soft_deleted_at TIMESTAMPTZ,
53
+ PRIMARY KEY (service_id, data_class, subject_kind)
54
+ );
55
+ CREATE INDEX IF NOT EXISTS idx_retention_policies_active
56
+ ON retention_policies (data_class, subject_kind)
57
+ WHERE soft_deleted_at IS NULL;
58
+ CREATE TABLE IF NOT EXISTS data_residency_holds (
59
+ id UUID PRIMARY KEY,
60
+ tenant_id TEXT NOT NULL,
61
+ subject_id TEXT,
62
+ hold_kind TEXT NOT NULL,
63
+ statute_citation TEXT NOT NULL,
64
+ expires_at TIMESTAMPTZ,
65
+ placed_by TEXT NOT NULL,
66
+ placed_at TIMESTAMPTZ NOT NULL DEFAULT now(),
67
+ lifted_at TIMESTAMPTZ,
68
+ lifted_by TEXT
69
+ );
70
+ CREATE INDEX IF NOT EXISTS idx_data_residency_holds_lookup
71
+ ON data_residency_holds (tenant_id, subject_id, hold_kind)
72
+ WHERE lifted_at IS NULL;
73
+ `.trim();
74
+ export function getDsarMigrationSQL() {
75
+ return DSAR_MIGRATION_SQL;
76
+ }
77
+ /**
78
+ * Apply the DSAR migrations idempotently. Safe to call at every service boot.
79
+ *
80
+ * porsager/postgres refuses multi-statement queries via the extended-query
81
+ * protocol; we split on `;` boundaries we control.
82
+ */
83
+ export async function applyDsarMigrations(sql) {
84
+ const ddl = getDsarMigrationSQL();
85
+ const statements = splitStatements(ddl);
86
+ for (const stmt of statements) {
87
+ await sql.unsafe(stmt);
88
+ }
89
+ }
90
+ /** Internal — exported only for unit coverage. */
91
+ export function splitStatements(ddl) {
92
+ const out = [];
93
+ let buf = "";
94
+ for (const rawLine of ddl.split("\n")) {
95
+ const line = rawLine.trim();
96
+ if (!line || line.startsWith("--"))
97
+ continue;
98
+ buf = buf ? `${buf}\n${rawLine}` : rawLine;
99
+ if (line.endsWith(";")) {
100
+ const cleaned = buf.trim();
101
+ if (cleaned)
102
+ out.push(cleaned);
103
+ buf = "";
104
+ }
105
+ }
106
+ if (buf.trim())
107
+ out.push(buf.trim());
108
+ return out;
109
+ }
110
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,kFA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;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"}
@@ -0,0 +1,41 @@
1
+ import type { DsarServiceImpl } from "./grpc/dsar-service";
2
+ import type { AuditEmitter } from "./types";
3
+ type SqlClient = {
4
+ unsafe: (sql: string, args?: unknown[]) => Promise<any>;
5
+ };
6
+ /** Per-sibling client — a thin proxy over the sibling's DsarServiceImpl. */
7
+ export interface SiblingClient {
8
+ serviceName: string;
9
+ rpcAddr: string;
10
+ service: DsarServiceImpl;
11
+ }
12
+ export interface BindOrchestratorOpts {
13
+ /** Postgres SQL client for retention_policies + platform_lifecycle_requests. */
14
+ sqlClient?: SqlClient;
15
+ /** Static sibling client registry (overrides DB lookup when supplied). */
16
+ siblingClients?: Record<string, SiblingClient>;
17
+ /** Audit emitter for tenant-side dispatch + aggregator events. */
18
+ auditEmitter?: AuditEmitter;
19
+ /** Defaults to `platform_lifecycle_requests`. */
20
+ aggregatorTableName?: string;
21
+ /** Defaults to `retention_policies`. */
22
+ retentionTableName?: string;
23
+ /** Defaults to `data_residency_holds`. */
24
+ holdsTableName?: string;
25
+ /**
26
+ * Per-(data_class, subject_kind) → siblings static map. Used when a
27
+ * sqlClient isn't supplied (unit tests / dev). Sibling names must
28
+ * match `siblingClients` keys.
29
+ */
30
+ retentionPolicies?: Record<string, string[]>;
31
+ }
32
+ declare const SYNC_RPCS: Set<string>;
33
+ declare const ASYNC_RPCS: Set<string>;
34
+ export declare function dispatchModeFor(rpcMethod: string): "sync" | "async";
35
+ /**
36
+ * bindOrchestrator returns a DsarServiceImpl that aggregates across all
37
+ * registered siblings. Spec § 5.5 + § 5.9.
38
+ */
39
+ export declare function bindOrchestrator(opts: BindOrchestratorOpts): DsarServiceImpl;
40
+ export { SYNC_RPCS, ASYNC_RPCS };
41
+ //# sourceMappingURL=orchest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