SingleTableSignUpContract.ts overview

Core sign-up over the single-table IdentifierStore, run on each dialect with an engine: EmailPasswordService signs up and then signs in, with the user writer inserting the row with its address. Everything but the users table is in memory. Never published.


Exports Grouped by Category


utils

SignUpHarness (interface)

The database the sign-up suite runs against.

Signature

export interface SignUpHarness {
  /** Run `build`'s program against the single-table store on the file's database. */
  readonly run: <A, E>(build: () => Effect.Effect<A, E, Auth.Identifier.IdentifierStore>) => Promise<A>
  /** Insert a user row, as the application's own user writer does. */
  readonly insertUser: (row: UserRowInsert) => Promise<void>
  /** The email columns of a user row as stored, or `null` when there is no row. */
  readonly readUserRow: (
    userId: string
  ) => Promise<{ readonly email: string | null; readonly emailVerified: boolean } | null>
  /** How many user rows the table holds. */
  readonly countUserRows: () => Promise<number>
}

Source

UserRowInsert (interface)

A user row’s email columns as the application writes them.

Signature

export interface UserRowInsert {
  readonly id: string
  /** `null` leaves the address out of the insert. */
  readonly email: string | null
  readonly emailVerified: boolean
  readonly createdAt: Date
}

Source

WriterMode (type alias)

Whether the application’s writer puts CreateUserInput.identifier on the row ("writes"), leaves the address for the claim to write ("omits"), or finds or creates on the address ("findsOrCreates"): it puts the address on the row of a new user, and returns the user who already holds it with created: false.

Signature

type WriterMode = "writes" | "omits" | "findsOrCreates"

Source

makeAppWriter

The application’s side of sign-up: an EmailPasswordStore whose createUser inserts the row through insertUser, and a UserStore over the users it created. Password hashes stay in memory.

Signature

declare const makeAppWriter: (
  insertUser: (row: UserRowInsert) => Promise<void>,
  mode: WriterMode
) => {
  createdWith: Array<Auth.UserStore.NewUserIdentifier | undefined>
  createUser: (
    input: Email.CreateUserInput
  ) => Effect.Effect<Auth.UserStore.CreateUserResult, Auth.Errors.AuthError, never>
  withService: <A, E>(
    f: (service: typeof Email.EmailPasswordService.Service) => Effect.Effect<A, E>,
    wrap?: (store: typeof Auth.Identifier.IdentifierStore.Service) => typeof Auth.Identifier.IdentifierStore.Service
  ) => Effect.Effect<A, E, Auth.Identifier.IdentifierStore>
}

Source

signUpContract

The sign-up suite. nullable says which shape the harness’s table has; the suite runs the writer that puts the address on the row against both, and the writer that leaves it out against each with its own expectation.

Signature

declare const signUpContract: (label: string, nullable: boolean, harness: SignUpHarness) => SuiteCollector<object>

Source


This site uses Just the Docs, a documentation theme for Jekyll.