feat(core-dsr): Payload impls, recording doubles, DI binders, contract tests
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
21
packages/core-dsr/src/di/bind-dev-seed.ts
Normal file
21
packages/core-dsr/src/di/bind-dev-seed.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { InMemoryDataExport } from "../in-memory-data-export";
|
||||
import { InMemoryDataDelete } from "../in-memory-data-delete";
|
||||
import { InMemoryDataRectify } from "../in-memory-data-rectify";
|
||||
import { InMemoryProcessingRestriction } from "../in-memory-processing-restriction";
|
||||
import type { DsrBinding } from "./bind-production";
|
||||
|
||||
/**
|
||||
* Returns in-memory DSR implementations for dev-seed and storybook contexts
|
||||
* where Payload is unavailable.
|
||||
*
|
||||
* No config or auditLog needed: all operations are no-ops that return
|
||||
* well-shaped responses.
|
||||
*/
|
||||
export function bindDevSeedDsr(): DsrBinding {
|
||||
return {
|
||||
dataExport: new InMemoryDataExport(),
|
||||
dataDelete: new InMemoryDataDelete(),
|
||||
dataRectify: new InMemoryDataRectify(),
|
||||
processingRestriction: new InMemoryProcessingRestriction(),
|
||||
};
|
||||
}
|
||||
44
packages/core-dsr/src/di/bind-production.ts
Normal file
44
packages/core-dsr/src/di/bind-production.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import type { SanitizedConfig } from "payload";
|
||||
import type { AuditLogProtocol } from "@repo/core-shared/di";
|
||||
import type { IDataExport } from "../data-export.interface";
|
||||
import type { IDataDelete } from "../data-delete.interface";
|
||||
import type { IDataRectify } from "../data-rectify.interface";
|
||||
import type { IProcessingRestriction } from "../processing-restriction.interface";
|
||||
import { PayloadDataExport } from "../payload-data-export";
|
||||
import { PayloadDataDelete } from "../payload-data-delete";
|
||||
import { PayloadDataRectify } from "../payload-data-rectify";
|
||||
import { PayloadProcessingRestriction } from "../payload-processing-restriction";
|
||||
|
||||
export type DsrBinding = {
|
||||
dataExport: IDataExport;
|
||||
dataDelete: IDataDelete;
|
||||
dataRectify: IDataRectify;
|
||||
processingRestriction: IProcessingRestriction;
|
||||
};
|
||||
|
||||
export type BindProductionDsrOpts = {
|
||||
config: SanitizedConfig;
|
||||
auditLog?: AuditLogProtocol;
|
||||
};
|
||||
|
||||
const noopAuditLog: AuditLogProtocol = { record: async () => {} };
|
||||
|
||||
/**
|
||||
* Returns Payload-backed DSR implementations pre-wired with config + auditLog.
|
||||
*
|
||||
* Wired by the app aggregator alongside feature binders. The returned binding
|
||||
* is passed as a dependency to dsrRouter and any feature that needs DSR
|
||||
* operations.
|
||||
*/
|
||||
export function bindProductionDsr(opts: BindProductionDsrOpts): DsrBinding {
|
||||
const auditLog = opts.auditLog ?? noopAuditLog;
|
||||
return {
|
||||
dataExport: new PayloadDataExport(opts.config, auditLog),
|
||||
dataDelete: new PayloadDataDelete(opts.config, auditLog),
|
||||
dataRectify: new PayloadDataRectify(opts.config, auditLog),
|
||||
processingRestriction: new PayloadProcessingRestriction(
|
||||
opts.config,
|
||||
auditLog,
|
||||
),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user