IdentifierStoreContract.ts overview
The IdentifierStore contract suites, run against every drizzle store that claims it: the shared contract (email identifiers only), the single-table store’s own rules, a NOT NULL email column and a mapped emailVerifiedAt. A harness supplies the database and the user rows. Never published.
Exports Grouped by Category
utils
NotNullHarness (interface)
The NOT NULL email suite: the store’s behaviour when the column cannot hold NULL. The harness seeds USER’s ada and grace with addresses, since a NOT NULL row always holds one.
Signature
export interface NotNullHarness extends SingleTableHarness {
/** Delete the user row itself, as account deletion does after the identifier store. */
readonly deleteUserRow: (userId: string) => Promise<void>
}
SingleTableHarness (interface)
The single-table suite also looks at the user row itself.
Signature
export interface SingleTableHarness extends StoreHarness {
/**
* The email columns of a user row as they are stored, or `null` when the row
* is gone. Read straight from the table, not through the store.
*/
readonly readUserRow: (
userId: string
) => Promise<{ readonly email: string | null; readonly emailVerified: boolean } | null>
}
StoreHarness (interface)
The database a suite runs against.
Signature
export interface StoreHarness {
/** Run `build`'s program against the store under test on the file's database. */
readonly run: <A, E>(build: () => Effect.Effect<A, E, Auth.Identifier.IdentifierStore>) => Promise<A>
/**
* Insert {@link USER}'s `ada` and `grace` rows, as the application's own user
* writer would, with no login handle. A store that keeps identifiers in its
* own table has nothing to seed.
*/
readonly seedUsers: () => Promise<void>
}
USER
Three user ids in the shape the applications use: uuid keys. The multi-identifier store keys on text, so the same ids serve both.
Signature
declare const USER: {
readonly ada: "5e1f0c3a-7b1d-4a53-9c0e-00000000000a"
readonly grace: "5e1f0c3a-7b1d-4a53-9c0e-00000000000b"
readonly ghost: "5e1f0c3a-7b1d-4a53-9c0e-0000000000ff"
}
USER_CREATED_AT
The created_at every seeded user row carries.
Signature
declare const USER_CREATED_AT: Date
VerifiedAtHarness (interface)
The mapped emailVerifiedAt suite’s harness: the single-table one plus a read of the column.
Signature
export interface VerifiedAtHarness extends SingleTableHarness {
/** The raw `email_verified_at` column of a user row, or `null`. */
readonly readVerifiedAt: (userId: string) => Promise<Date | null>
}
identifierStoreContract
The semantics every IdentifierStore states, over email identifiers.
Signature
declare const identifierStoreContract: (label: string, harness: StoreHarness) => SuiteCollector<object>
notNullContract
The NOT NULL suite; see NotNullHarness.
Signature
declare const notNullContract: (label: string, harness: NotNullHarness) => SuiteCollector<object>
singleTableContract
What only the single-table store does, over the same database harness.
Signature
declare const singleTableContract: (label: string, harness: SingleTableHarness) => SuiteCollector<object>
verifiedAtContract
The suite for a store that maps emailVerifiedAt: the timestamp is stored and reported. The unmapped case is singleTableContract’s “never reports a verifiedAt”.
Signature
declare const verifiedAtContract: (label: string, harness: VerifiedAtHarness) => SuiteCollector<object>