26 lines
851 B
TypeScript
26 lines
851 B
TypeScript
import type { IProcessingRestriction } from "./processing-restriction.interface";
|
|
|
|
/**
|
|
* Volatile in-memory IProcessingRestriction. Tracks restriction state in
|
|
* memory; state is lost on process restart.
|
|
*
|
|
* Used in dev-seed and storybook contexts where Payload is unavailable.
|
|
* Not a recording double — use RecordingProcessingRestriction from
|
|
* @repo/core-testing for call-assertion in unit tests.
|
|
*/
|
|
export class InMemoryProcessingRestriction implements IProcessingRestriction {
|
|
private readonly restricted = new Set<string>();
|
|
|
|
async setRestriction(subjectId: string, granted: boolean): Promise<void> {
|
|
if (granted) {
|
|
this.restricted.add(subjectId);
|
|
} else {
|
|
this.restricted.delete(subjectId);
|
|
}
|
|
}
|
|
|
|
async isRestricted(subjectId: string): Promise<boolean> {
|
|
return this.restricted.has(subjectId);
|
|
}
|
|
}
|