Skip to content

Domain.Vault reference

Source: packages/domain/src/Vault.ts

A field whose value is encrypted under a key kept per subject. Deleting the subject’s key makes every copy unreadable, wherever it was stored.

import * as Domain from "@alchemy.run/domain";
import * as Schema from "effect/Schema";
import { VaultError } from "./VaultError.ts";
export { VaultError } from "./VaultError.ts";
export const Name = Domain.Sealed(Schema.String);
export class CustomerRegistered extends Domain.Event("CustomerRegistered", { name: Name }) {}

A client sends the value with the subject it belongs to. The model seals it when the command arrives, before anything is stored.

yield* bank.RegisterCustomer({ customerId, name: Name.plain(customerId, "Sam") });