Users.ts overview

Users and their one email identifier, read from WorkOS: the core’s UserStore and IdentifierStore over /user_management/users. WorkOS holds one email per user and no identifier objects, so an identifier’s id is derived from the user’s, and a second email, a username or a phone number is refused.

Since v0.1.0


Exports Grouped by Category


constants

UserAttribute

The attribute keys this package writes on a User, under workos..

Signature

declare const UserAttribute: {
  readonly email: "workos.email"
  readonly emailVerified: "workos.emailVerified"
  readonly externalId: "workos.externalId"
  readonly metadata: "workos.metadata"
  readonly lastSignInAt: "workos.lastSignInAt"
}

Source

Since v0.1.0

constructors

makeUsers

Reads and writes of WorkOS users.

Signature

declare const makeUsers: () => Effect.Effect<
  {
    getWire: (
      userId: string
    ) => Effect.Effect<
      | Option.Option<{
          readonly id: string
          readonly created_at: string
          readonly email: string
          readonly email_verified: boolean
          readonly updated_at: string
          readonly first_name?: string | null | undefined
          readonly last_name?: string | null | undefined
          readonly name?: string | null | undefined
          readonly profile_picture_url?: string | null | undefined
          readonly last_sign_in_at?: string | null | undefined
          readonly external_id?: string | null | undefined
          readonly metadata?: { readonly [x: string]: string } | null | undefined
        }>
      | Option.Option<never>,
      Auth.Errors.AuthError,
      never
    >
    byEmail: (
      email: string
    ) => Effect.Effect<
      Option.Option<{
        readonly id: string
        readonly created_at: string
        readonly email: string
        readonly email_verified: boolean
        readonly updated_at: string
        readonly first_name?: string | null | undefined
        readonly last_name?: string | null | undefined
        readonly name?: string | null | undefined
        readonly profile_picture_url?: string | null | undefined
        readonly last_sign_in_at?: string | null | undefined
        readonly external_id?: string | null | undefined
        readonly metadata?: { readonly [x: string]: string } | null | undefined
      }>,
      Auth.Errors.AuthError,
      never
    >
    update: (
      userId: string,
      body: Schema.JsonObject
    ) => Effect.Effect<
      | Option.Option<{
          readonly id: string
          readonly created_at: string
          readonly email: string
          readonly email_verified: boolean
          readonly updated_at: string
          readonly first_name?: string | null | undefined
          readonly last_name?: string | null | undefined
          readonly name?: string | null | undefined
          readonly profile_picture_url?: string | null | undefined
          readonly last_sign_in_at?: string | null | undefined
          readonly external_id?: string | null | undefined
          readonly metadata?: { readonly [x: string]: string } | null | undefined
        }>
      | Option.Option<never>,
      Auth.Errors.AuthError,
      never
    >
  },
  never,
  WorkOSClient
>

Source

Since v0.1.0

layers

identifierStoreLayer

The core IdentifierStore over WorkOS: each user’s one email. Changing the address (replace) and its verified flag (setVerified) write the user; adding or removing an identifier is refused.

Signature

declare const identifierStoreLayer: Layer.Layer<Auth.Identifier.IdentifierStore, never, WorkOSClient>

Source

Since v0.1.0

userServiceLayer

The core UserService over WorkOS: name and image map to WorkOS’s first_name / last_name and are written there; WorkOS has no free-form attribute bag, so updateUserAttributes writes string values to metadata and refuses any other value. deleteUser deletes the WorkOS user, which ends its sessions; core stores keyed by the user id (API keys and the like) are the app’s to clear, from the user.deleted event.

Signature

declare const userServiceLayer: Layer.Layer<Auth.User.UserService, never, WorkOSClient>

Source

Since v0.1.0

userStoreLayer

The core UserStore over WorkOS.

Signature

declare const userStoreLayer: Layer.Layer<Auth.UserStore.UserStore, never, WorkOSClient>

Source

Since v0.1.0

mapping

toIdentifier

A WorkOS user’s email as a core Identifier.

Signature

declare const toIdentifier: (user: WireUser) => Auth.Identifier.Identifier

Source

Since v0.1.0

toUser

A WorkOS user as a core User.

Signature

declare const toUser: (user: WireUser) => Auth.Types.User

Source

Since v0.1.0


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