---
title: "nuxt-backend/functions"
description: "Every export of nuxt-backend/functions, with its signature and where it is defined."
canonical_url: "https://nuxt-backend.dev/docs/reference/api/functions"
---
# nuxt-backend/functions

Version: nuxt-backend 0.6.x · Tab: Reference · Kind: reference · Status: stable

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

## Interfaces

### CallerRule

Defined in: [src/convex/integrations/access.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/access.ts)

How a session was opened, for the functions that refuse some kinds. An
impersonated session may read but not spend or change billing.

#### Extended by

- [`BillingAccessRule`](https://nuxt-backend.dev/docs/reference/api/billing#billingaccessrule)

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="impersonation">
        
      </a>
      
       <code>
        impersonation?
      </code>
    </td>
    
    <td>
      <code>
        "refused"
      </code>
      
       | <code>
        "allowed"
      </code>
    </td>
    
    <td>
      A session an administrator opened by impersonating the caller: <code>
        'allowed'
      </code>
      
       unless refused.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/access.ts" rel="nofollow">
        src/convex/integrations/access.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="recentsignin">
        
      </a>
      
       <code>
        recentSignIn?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      How recent a sign-in it takes, in seconds since the person signed in to the session (<code>
        RECENT_SIGN_IN_SECONDS
      </code>
      
      , the package's ten minutes, for its own). An older one is refused as <code>
        reauthentication_required
      </code>
      
      , and so is a token that names no session or carries no <code>
        authTime
      </code>
      
      ; an administrator's visit is refused as <code>
        forbidden
      </code>
      
       (reason <code>
        impersonating
      </code>
      
      ): no sign-in of the person's own stands behind it. A mutation's or an action's rule only: a query is not rerun as time passes.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/access.ts" rel="nofollow">
        src/convex/integrations/access.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### FunctionUser

Defined in: [src/convex/integrations/authorization.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts)

The signed-in user, as read from identity claims.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="id">
        
      </a>
      
       <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Better Auth user id (the component's <code>
        user
      </code>
      
       document id).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="email">
        
      </a>
      
       <code>
        email
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="name">
        
      </a>
      
       <code>
        name
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="role">
        
      </a>
      
       <code>
        role
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      App-wide role from the admin plugin; <code>
        'user'
      </code>
      
       when unset.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="banned">
        
      </a>
      
       <code>
        banned
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="activeworkspaceid">
        
      </a>
      
       <code>
        activeWorkspaceId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
       | <code>
        null
      </code>
    </td>
    
    <td>
      The session's active workspace, or <code>
        null
      </code>
      
       when none.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="impersonatedby">
        
      </a>
      
       <code>
        impersonatedBy
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
       | <code>
        null
      </code>
    </td>
    
    <td>
      The admin impersonating this user, or <code>
        null
      </code>
      
       for the user's own session. Refuse what an impersonating admin must not do: <code>
        if (user.impersonatedBy) throw …
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="authtime">
        
      </a>
      
       <code>
        authTime
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
      
       | <code>
        null
      </code>
    </td>
    
    <td>
      When the person signed in to the session the token belongs to, as epoch milliseconds (the <code>
        authTime
      </code>
      
       claim), or <code>
        null
      </code>
      
       for a token minted before the claim existed.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="signinmethod">
        
      </a>
      
       <code>
        signInMethod
      </code>
    </td>
    
    <td>
      <code>
        "passkey"
      </code>
      
       | <code>
        "email-otp"
      </code>
      
       | <code>
        null
      </code>
    </td>
    
    <td>
      How the person signed in to this session: <code>
        'passkey'
      </code>
      
       or <code>
        'email-otp'
      </code>
      
       (the <code>
        signInMethod
      </code>
      
       claim, the session's own, never the account's last sign-in elsewhere); <code>
        null
      </code>
      
       for an administrator's visit and a token minted before the claim existed. Hold a passkey-only step to it: <code>
        if (ctx.user.signInMethod !== 'passkey') throw …
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="claims">
        
      </a>
      
       <code>
        claims
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        unknown
      </code>
      
      >
    </td>
    
    <td>
      All identity claims, for anything not surfaced above.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### AuthorizationWorkspace

Defined in: [src/convex/integrations/authorization.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts)

A workspace the caller belongs to, as the `workspace` tier injects it as `ctx.workspace`.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="id-1">
        
      </a>
      
       <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="slug">
        
      </a>
      
       <code>
        slug
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="name-1">
        
      </a>
      
       <code>
        name
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="role-1">
        
      </a>
      
       <code>
        role
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The caller's role <em>
        within the workspace
      </em>
      
       (owner/admin/member or custom).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### AuthorizationCtx

Defined in: [src/convex/integrations/authorization.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts)

Any Convex ctx that can read identity and run component queries.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="auth">
        
      </a>
      
       <code>
        auth
      </code>
    </td>
    
    <td>
      <code>
        Auth
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="runquery">
        
      </a>
      
       <code>
        runQuery
      </code>
    </td>
    
    <td>
      <<code>
        Query
      </code>
      
      >(<code>
        query
      </code>
      
      , ...<code>
        args
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        FunctionReturnType
      </code>
      
      <<code>
        Query
      </code>
      
      >>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### AuthorizationComponents

Defined in: [src/convex/integrations/authorization.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts)

The component handle `createFunctions` reads from your generated
`components` object: the package's all-in-one `backend` component, whose
auth adapter functions it queries through. Pass the whole `components`
object — the key is picked structurally.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="backend">
        
      </a>
      
       <code>
        backend
      </code>
    </td>
    
    <td>
      { <code>
        adapter
      </code>
      
      : { <code>
        findOne
      </code>
      
      : <code>
        unknown
      </code>
      
      ; <code>
        updateOne
      </code>
      
      : <code>
        unknown
      </code>
      
      ; }; <code>
        audit?
      </code>
      
      : { <code>
        record
      </code>
      
      : <code>
        unknown
      </code>
      
      ; }; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.adapter
      </code>
    </td>
    
    <td>
      { <code>
        findOne
      </code>
      
      : <code>
        unknown
      </code>
      
      ; <code>
        updateOne
      </code>
      
      : <code>
        unknown
      </code>
      
      ; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.adapter.findOne
      </code>
    </td>
    
    <td>
      <code>
        unknown
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.adapter.updateOne
      </code>
    </td>
    
    <td>
      <code>
        unknown
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.audit?
      </code>
    </td>
    
    <td>
      { <code>
        record
      </code>
      
      : <code>
        unknown
      </code>
      
      ; }
    </td>
    
    <td>
      The activity trail <code>
        setUserRole
      </code>
      
       records a role change on; absent from a component built before it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.audit.record
      </code>
    </td>
    
    <td>
      <code>
        unknown
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### FunctionWorkspace

Defined in: [src/convex/integrations/functions.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts)

The workspace context the `workspace` tier injects as `ctx.workspace`.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="id-2">
        
      </a>
      
       <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="slug-1">
        
      </a>
      
       <code>
        slug
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="name-2">
        
      </a>
      
       <code>
        name
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="role-2">
        
      </a>
      
       <code>
        role
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The caller's role within the workspace: <code>
        owner
      </code>
      
      , <code>
        admin
      </code>
      
       or <code>
        member
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### FunctionDeclaration

Defined in: [src/convex/integrations/functions.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts)

What a tier's function may declare beside `args` and `handler`: how
recent a sign-in it takes, and whether an administrator's visit to the
account may call it.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="recentsignin-1">
        
      </a>
      
       <code>
        recentSignIn?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
      
       | <code>
        boolean
      </code>
    </td>
    
    <td>
      A sensitive action: <code>
        true
      </code>
      
       takes a sign-in from the last ten minutes (<code>
        RECENT_SIGN_IN_SECONDS
      </code>
      
      ), a number from the last that many seconds. An older one is refused as <code>
        reauthentication_required
      </code>
      
      , which <code>
        useReauthentication
      </code>
      
       answers by asking the person to sign in again; an administrator's visit never passes. The <code>
        admin
      </code>
      
       tier's mutations and actions take a recent sign-in unless they say <code>
        false
      </code>
      
      . A query cannot take one: it is not rerun as time passes, so its window would not hold, and defining one that says so throws.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="impersonation-1">
        
      </a>
      
       <code>
        impersonation?
      </code>
    </td>
    
    <td>
      <code>
        "refused"
      </code>
      
       | <code>
        "allowed"
      </code>
    </td>
    
    <td>
      <code>
        'refused'
      </code>
      
       refuses a session an administrator opened by impersonating the account (<code>
        forbidden
      </code>
      
      , reason <code>
        impersonating
      </code>
      
      ): for a function where a person's money or access is at stake. <code>
        'allowed'
      </code>
      
      , the default, lets the visit in. The <code>
        admin
      </code>
      
       tier's mutations and actions refuse it always.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### FunctionsRateLimiter

Defined in: [src/convex/integrations/functions.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts)

A rate limiter compatible with `setupRateLimiter(...)` from `nuxt-backend/rate-limit`.

#### Methods

##### limit()

```ts
limit(
   ctx, 
   name, 
   options?
): Promise<unknown>;
```

Defined in: [src/convex/integrations/functions.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts)

###### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        ctx
      </code>
    </td>
    
    <td>
      <code>
        never
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        name
      </code>
    </td>
    
    <td>
      <code>
        never
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options?
      </code>
    </td>
    
    <td>
      <code>
        undefined
      </code>
    </td>
  </tr>
</tbody>
</table>

###### Returns

`Promise`<`unknown`>

---

### FunctionsBilling

Defined in: [src/convex/integrations/functions.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts)

What the `withFeature` tier needs of the app's billing: `setupBilling`'s
return satisfies it.

#### Methods

##### requireFeature()

```ts
requireFeature(ctx, feature): Promise<void>;
```

Defined in: [src/convex/integrations/functions.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts)

###### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        ctx
      </code>
    </td>
    
    <td>
      <a href="#authorizationctx">
        <code>
          AuthorizationCtx
        </code>
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        feature
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
  </tr>
</tbody>
</table>

###### Returns

`Promise`<`void`>

---

### CreateFunctionsOptions

Defined in: [src/convex/integrations/functions.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts)

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="components">
        
      </a>
      
       <code>
        components
      </code>
    </td>
    
    <td>
      <a href="#authorizationcomponents">
        <code>
          AuthorizationComponents
        </code>
      </a>
    </td>
    
    <td>
      Your generated <code>
        components
      </code>
      
       (<code>
        ./_generated/api
      </code>
      
      ): the tiers read the <code>
        backend
      </code>
      
       component's tables.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="billing">
        
      </a>
      
       <code>
        billing?
      </code>
    </td>
    
    <td>
      <a href="#functionsbilling">
        <code>
          FunctionsBilling
        </code>
      </a>
    </td>
    
    <td>
      Your <code>
        setupBilling
      </code>
      
       instance (<code>
        ./billing
      </code>
      
      ). It enables <code>
        withFeature
      </code>
      
      , which checks a plan's features against it. <code>
        billing.ts
      </code>
      
       imports nothing from <code>
        functions.ts
      </code>
      
      , so the two files never import each other.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="ratelimiter">
        
      </a>
      
       <code>
        rateLimiter?
      </code>
    </td>
    
    <td>
      <a href="#functionsratelimiter">
        <code>
          FunctionsRateLimiter
        </code>
      </a>
    </td>
    
    <td>
      Your <code>
        setupRateLimiter
      </code>
      
       instance, to guard the tiers' writes with <code>
        limits
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="limits">
        
      </a>
      
       <code>
        limits?
      </code>
    </td>
    
    <td>
      <code>
        Partial
      </code>
      
      <<code>
        Record
      </code>
      
      <<code>
        "admin"
      </code>
      
       | <code>
        "workspace"
      </code>
      
       | <code>
        "authed"
      </code>
      
      , <code>
        string
      </code>
      
      >>
    </td>
    
    <td>
      A named rate limit per tier, spent on its <strong>
        mutations and actions
      </strong>
      
       (keyed by user id; queries are reads and spend none). <code>
        { authed: 'write' }
      </code>
      
       with a matching limit in <code>
        setupRateLimiter
      </code>
      
      . <code>
        withRole
      </code>
      
       spends <code>
        authed
      </code>
      
      's, and <code>
        withFeature
      </code>
      
       <code>
        workspace
      </code>
      
      's.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="adminroles">
        
      </a>
      
       <code>
        adminRoles?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      App-wide roles that pass the <code>
        admin
      </code>
      
       tier. Default <code>
        ['admin']
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### RetentionResult

Defined in: [src/convex/integrations/retention.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/retention.ts)

What a pass reports: the rows it deleted, and whether rows past the age are left for the next batch.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="deleted">
        
      </a>
      
       <code>
        deleted
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      The rows this batch deleted.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/retention.ts" rel="nofollow">
        src/convex/integrations/retention.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="more">
        
      </a>
      
       <code>
        more
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      Whether the batch left rows past the age: the pass has scheduled its next batch.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/retention.ts" rel="nofollow">
        src/convex/integrations/retention.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### RetentionOptions

Defined in: [src/convex/integrations/retention.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/retention.ts)

The options of [defineRetention](#defineretention).

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-dm-1">
        
      </a>
      
       <code>
        DM
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        GenericDataModel
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="type-parameter-t">
        
      </a>
      
       <code>
        T
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        TableNamesInDataModel
      </code>
      
      <<code>
        DM
      </code>
      
      >
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="type-parameter-i">
        
      </a>
      
       <code>
        I
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        IndexNames
      </code>
      
      <<code>
        NamedTableInfo
      </code>
      
      <<code>
        DM
      </code>
      
      , <code>
        T
      </code>
      
      >>
    </td>
  </tr>
</tbody>
</table>

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="fn">
        
      </a>
      
       <code>
        fn
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The rule's own function path, as <code>
        npx convex run
      </code>
      
       takes it, such as <code>
        'retention:pruneDrafts'
      </code>
      
      . A batch that leaves rows behind schedules it again.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/retention.ts" rel="nofollow">
        src/convex/integrations/retention.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="table">
        
      </a>
      
       <code>
        table
      </code>
    </td>
    
    <td>
      <code>
        T
      </code>
    </td>
    
    <td>
      The table to prune. Its rows are typed from your schema.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/retention.ts" rel="nofollow">
        src/convex/integrations/retention.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="index">
        
      </a>
      
       <code>
        index
      </code>
    </td>
    
    <td>
      <code>
        I
      </code>
    </td>
    
    <td>
      The index to read through, named by its fields as Convex's guidelines ask (<code>
        by_status_and_updatedAt
      </code>
      
      ): the rule reads the fields from the name. The field after any <code>
        match
      </code>
      
       fields holds the time; <code>
        by_creation_time
      </code>
      
       uses <code>
        _creationTime
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/retention.ts" rel="nofollow">
        src/convex/integrations/retention.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="match">
        
      </a>
      
       <code>
        match?
      </code>
    </td>
    
    <td>
      <code>
        { [F in string]?: FieldTypeFromFieldPath<DocumentByName<DM, T>, F> }
      </code>
    </td>
    
    <td>
      Equal values for the index's leading fields, in the index's order.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/retention.ts" rel="nofollow">
        src/convex/integrations/retention.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="ttl">
        
      </a>
      
       <code>
        ttl
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      How old a row may get, in milliseconds, on the index's time field. <code>
        0
      </code>
      
       deletes a row once that time has passed, for an <code>
        expiresAt
      </code>
      
       field.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/retention.ts" rel="nofollow">
        src/convex/integrations/retention.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="batch">
        
      </a>
      
       <code>
        batch?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      Rows per transaction. Lower it for large rows or a heavy <code>
        onDelete
      </code>
      
      . Defaults to 100.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/retention.ts" rel="nofollow">
        src/convex/integrations/retention.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="ondelete">
        
      </a>
      
       <code>
        onDelete?
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        row
      </code>
      
      ) => <code>
        void
      </code>
      
       | <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Runs before each row is deleted, in the same transaction.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/retention.ts" rel="nofollow">
        src/convex/integrations/retention.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="schedule">
        
      </a>
      
       <code>
        schedule?
      </code>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/monitoring#backendcronschedule">
        <code>
          BackendCronSchedule
        </code>
      </a>
    </td>
    
    <td>
      When the rule runs: <code>
        every
      </code>
      
       an interval, or on a <code>
        cron
      </code>
      
       expression (five fields, UTC). <code>
        scheduleRetention(crons, rules)
      </code>
      
       in <code>
        backend/crons.ts
      </code>
      
       starts every rule that has one. Without it, start the rule from a cron of your own.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/retention.ts" rel="nofollow">
        src/convex/integrations/retention.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### SensitiveLimit

Defined in: [src/convex/sensitive-actions.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/sensitive-actions.ts)

Where a limit's bucket is keyed, one per kind of key.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="caller">
        
      </a>
      
       <code>
        caller?
      </code>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/auth#authratelimitname">
        <code>
          AuthRateLimitName
        </code>
      </a>
    </td>
    
    <td>
      Per signed-in caller, by user id: opening more sessions does not multiply it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/sensitive-actions.ts" rel="nofollow">
        src/convex/sensitive-actions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="address">
        
      </a>
      
       <code>
        address?
      </code>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/auth#authratelimitname">
        <code>
          AuthRateLimitName
        </code>
      </a>
    </td>
    
    <td>
      Per address the request names, by a digest of it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/sensitive-actions.ts" rel="nofollow">
        src/convex/sensitive-actions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="client">
        
      </a>
      
       <code>
        client?
      </code>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/auth#authratelimitname">
        <code>
          AuthRateLimitName
        </code>
      </a>
    </td>
    
    <td>
      Per client network address, by an HMAC of it under the auth secret.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/sensitive-actions.ts" rel="nofollow">
        src/convex/sensitive-actions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="entity">
        
      </a>
      
       <code>
        entity?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Per billing entity (the workspace, or the account with <code>
        billTo: 'user'
      </code>
      
      ).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/sensitive-actions.ts" rel="nofollow">
        src/convex/sensitive-actions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="global">
        
      </a>
      
       <code>
        global?
      </code>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/auth#authratelimitname">
        <code>
          AuthRateLimitName
        </code>
      </a>
    </td>
    
    <td>
      One ceiling for the whole deployment, spent after every keyed bucket allowed the request.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/sensitive-actions.ts" rel="nofollow">
        src/convex/sensitive-actions.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### SensitiveAction

Defined in: [src/convex/sensitive-actions.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/sensitive-actions.ts)

One row: what a write takes.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="recentsignin-2">
        
      </a>
      
       <code>
        recentSignIn
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
      
       | <code>
        null
      </code>
    </td>
    
    <td>
      How recent a sign-in it takes, in seconds since the person signed in to the session (<code>
        RECENT_SIGN_IN_SECONDS
      </code>
      
      , ten minutes, on every row of the package's); <code>
        null
      </code>
      
       for none. An older sign-in is refused as <code>
        reauthentication_required
      </code>
      
      . An impersonated session never passes, since no sign-in of the person's own stands behind it: <code>
        forbidden
      </code>
      
      , reason <code>
        impersonating
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/sensitive-actions.ts" rel="nofollow">
        src/convex/sensitive-actions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="impersonation-2">
        
      </a>
      
       <code>
        impersonation
      </code>
    </td>
    
    <td>
      <code>
        "refused"
      </code>
      
       | <code>
        "allowed"
      </code>
    </td>
    
    <td>
      A session an administrator opened by impersonating the account: <code>
        'refused'
      </code>
      
       as <code>
        forbidden
      </code>
      
      , reason <code>
        impersonating
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/sensitive-actions.ts" rel="nofollow">
        src/convex/sensitive-actions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="limit-1">
        
      </a>
      
       <code>
        limit
      </code>
    </td>
    
    <td>
      <a href="#sensitivelimit">
        <code>
          SensitiveLimit
        </code>
      </a>
      
       | <code>
        null
      </code>
    </td>
    
    <td>
      The limits it spends, each keyed as its field says; <code>
        null
      </code>
      
       for none.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/sensitive-actions.ts" rel="nofollow">
        src/convex/sensitive-actions.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

## Type Aliases

### BackendErrorCode

```ts
type BackendErrorCode = keyof typeof BACKEND_ERRORS;
```

Defined in: [src/convex/errors.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts)

One of the catalog's codes.

---

### BackendErrorData

```ts
type BackendErrorData<C> = Infer<typeof BACKEND_ERRORS[C]["data"]>;
```

Defined in: [src/convex/errors.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts)

The fields a code carries beside it.

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
    
    <th>
      Default type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-c">
        
      </a>
      
       <code>
        C
      </code>
      
       <em>
        extends
      </em>
      
       <a href="#backenderrorcode">
        <code>
          BackendErrorCode
        </code>
      </a>
    </td>
    
    <td>
      <a href="#backenderrorcode">
        <code>
          BackendErrorCode
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### BackendError

```ts
type BackendError = { [C in BackendErrorCode]: { code: C; data: Partial<BackendErrorData<C>>; message: string } }[BackendErrorCode];
```

Defined in: [src/convex/errors.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts)

A refusal read back by [getBackendError](#getbackenderror): its code, its fields, and a
sentence to show — `data.message` when the throw site wrote one for the
person, else the code's English label. Every field is optional here, the
required ones too: the reader keeps only the fields that fit the catalog,
and an auth route or an older deployment may send fewer.

---

### BackendErrorPayload

```ts
type BackendErrorPayload<C> = {
  code: C;
} & BackendErrorData<C> & {
[key: string]: Value | undefined;
};
```

Defined in: [src/convex/errors.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts)

What a `backendError()` carries to the client: the code and its fields, flat.

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
    
    <th>
      Default type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-c-1">
        
      </a>
      
       <code>
        C
      </code>
      
       <em>
        extends
      </em>
      
       <a href="#backenderrorcode">
        <code>
          BackendErrorCode
        </code>
      </a>
    </td>
    
    <td>
      <a href="#backenderrorcode">
        <code>
          BackendErrorCode
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

#### Type Declaration

<table>
<thead>
  <tr>
    <th>
      Name
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        code
      </code>
    </td>
    
    <td>
      <code>
        C
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### BackendErrorArgs

```ts
type BackendErrorArgs<C> = Record<string, never> extends BackendErrorData<C> ? [data?: BackendErrorData<C>, detail?: string] : [data: BackendErrorData<C>, detail?: string];
```

Defined in: [src/convex/errors.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts)

What `backendError` takes after the code: the code's data, optional for a
code whose fields are all optional, then the English detail for the log.

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-c-2">
        
      </a>
      
       <code>
        C
      </code>
      
       <em>
        extends
      </em>
      
       <a href="#backenderrorcode">
        <code>
          BackendErrorCode
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### FunctionsComponents

```ts
type FunctionsComponents = AuthorizationComponents;
```

Defined in: [src/convex/integrations/functions.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts)

The generated `components` the tiers read the `backend` component's tables through.

---

### RetentionSchedule

```ts
type RetentionSchedule = BackendCronSchedule;
```

Defined in: [src/convex/integrations/retention.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/retention.ts)

When a rule runs, for [scheduleRetention](#scheduleretention): `every` an interval (`{ hours: 24 }`), or on a `cron` expression (five fields, UTC).

---

### RetentionArgs

```ts
type RetentionArgs = {
  now?: number;
};
```

Defined in: [src/convex/integrations/retention.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/retention.ts)

What a rule's internal mutation takes.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="now">
        
      </a>
      
       <code>
        now?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      The pass's clock, in epoch milliseconds: the current time by default. A test passes it to move time without fake timers.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/retention.ts" rel="nofollow">
        src/convex/integrations/retention.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

## Variables

### RECENT_SIGN_IN_SECONDS

```ts
const RECENT_SIGN_IN_SECONDS: 600 = 600;
```

Defined in: [src/convex/constants.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/constants.ts)

How recent a sign-in a sensitive action takes, in seconds: ten minutes.
One constant for the whole package: Better Auth's `session.freshAge` (the
passkey routes' own check), every row of the sensitive-action table that
asks for a recent sign-in, and `requireRecentSignIn`'s default `within`.

---

### BACKEND_ERRORS

```ts
const BACKEND_ERRORS: {
  unauthenticated: {
     status: 401;
     data: VObject<{
        message?: string;
      }, {
        message: VString<string | undefined, "optional">;
     }, "required", "message">;
  };
  forbidden: {
     status: 403;
     data: VObject<{
        message?: string;
        phase?: string;
        invite?: string;
        kind?: string;
        until?: number;
        waitlist?: {
           position?: number;
           total?: number;
           token: string;
        };
        reason: string;
      }, {
        reason: VString<string, "required">;
        message: VString<string | undefined, "optional">;
        phase: VString<string | undefined, "optional">;
        invite: VString<string | undefined, "optional">;
        kind: VString<string | undefined, "optional">;
        until: VFloat64<number | undefined, "optional">;
        waitlist: VObject<
           | {
           position?: number;
           total?: number;
           token: string;
         }
           | undefined, {
           position: VFloat64<number | undefined, "optional">;
           total: VFloat64<number | undefined, "optional">;
           token: VString<string, "required">;
        }, "optional", "position" | "total" | "token">;
      }, "required", 
        | "message"
        | "reason"
        | "phase"
        | "invite"
        | "kind"
        | "until"
        | "waitlist"
        | "waitlist.position"
        | "waitlist.total"
       | "waitlist.token">;
  };
  reauthentication_required: {
     status: 403;
     data: VObject<{
        message?: string;
      }, {
        message: VString<string | undefined, "optional">;
     }, "required", "message">;
  };
  no_workspace: {
     status: 409;
     data: VObject<{
        message?: string;
      }, {
        message: VString<string | undefined, "optional">;
     }, "required", "message">;
  };
  rate_limited: {
     status: 429;
     data: VObject<{
        message?: string;
        retryAfter?: number;
        limit?: string;
        plans?: string[];
      }, {
        retryAfter: VFloat64<number | undefined, "optional">;
        limit: VString<string | undefined, "optional">;
        plans: VArray<string[] | undefined, VString<string, "required">, "optional">;
        message: VString<string | undefined, "optional">;
     }, "required", "message" | "retryAfter" | "limit" | "plans">;
  };
  insufficient_credits: {
     status: 402;
     data: VObject<{
        message?: string;
        meter?: string;
        balance: number;
        need: number;
      }, {
        meter: VString<string | undefined, "optional">;
        balance: VFloat64<number, "required">;
        need: VFloat64<number, "required">;
        message: VString<string | undefined, "optional">;
     }, "required", "message" | "meter" | "balance" | "need">;
  };
  feature_required: {
     status: 402;
     data: VObject<{
        message?: string;
        feature: string;
        plans: string[];
      }, {
        feature: VString<string, "required">;
        plans: VArray<string[], VString<string, "required">, "required">;
        message: VString<string | undefined, "optional">;
     }, "required", "feature" | "message" | "plans">;
  };
  quota_exceeded: {
     status: 402;
     data: VObject<{
        message?: string;
        limit: number;
        plans: string[];
        quota: string;
        used: number;
        amount: number;
      }, {
        quota: VString<string, "required">;
        limit: VFloat64<number, "required">;
        used: VFloat64<number, "required">;
        amount: VFloat64<number, "required">;
        plans: VArray<string[], VString<string, "required">, "required">;
        message: VString<string | undefined, "optional">;
     }, "required", "message" | "limit" | "plans" | "quota" | "used" | "amount">;
  };
  invalid_input: {
     status: 400;
     data: VObject<{
        message?: string;
        reason?: string;
        need?: number;
        units?: number;
        field: string;
      }, {
        field: VString<string, "required">;
        reason: VString<string | undefined, "optional">;
        need: VFloat64<number | undefined, "optional">;
        units: VFloat64<number | undefined, "optional">;
        message: VString<string | undefined, "optional">;
     }, "required", "message" | "reason" | "need" | "field" | "units">;
  };
  not_ready: {
     status: 409;
     data: VObject<{
        message?: string;
        reason: string;
      }, {
        reason: VString<string, "required">;
        message: VString<string | undefined, "optional">;
     }, "required", "message" | "reason">;
  };
  unavailable: {
     status: 503;
     data: VObject<{
        message?: string;
        reason: string;
        service: string;
      }, {
        service: VString<string, "required">;
        reason: VString<string, "required">;
        message: VString<string | undefined, "optional">;
     }, "required", "message" | "reason" | "service">;
  };
};
```

Defined in: [src/convex/errors.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts)

Every code the package throws, with the HTTP status an auth route answers
it with and the validator its data is checked against where it is thrown.
Codes and their fields are stable (STABILITY.md); a feature adds a code, it
never renames one.

- `unauthenticated` — nobody is signed in, or the session is gone.
- `forbidden` — signed in, but not allowed; `reason` says why (`banned`,
`role`, `permission`, `not_member`, `workspace_role`, `admin_only`,
`not_owner`, `impersonating`, `admin_target`,
`sign_in_refused`, `customer_taken`, `already_subscribed`,
`not_billing_manager`, `provider_owner_only`, `gift_refused`,
`gift_refunded`, `not_recipient`, `no_email`, `bot_check`,
`other_account`, `flag_off`, `sole_owner`, `paid_subscription`, `ticket_required`, `invitation_refused`,
`consent_required`, `age_required`, `under_age`, `passkey_only_admin`). A `banned` refusal of a
sign-in also carries `until`, when the ban ends (epoch ms), for a ban that ends. A `consent_required` refusal
also carries `kind`, the required consent not yet accepted at its latest version. A
`ticket_required` refusal also carries `phase`, the launch phase that
asks for a ticket, and `invite`, how the invite code given checked
(`expired`, `used-up`, `revoked`, `unknown`), when one was.
- `reauthentication_required` — the call is a sensitive action, and the
session's sign-in is older than it takes: sign in again
(`useReauthentication`), then retry. Better Auth's own refusals of a
session too old for its route read as this code too.
- `no_workspace` — the call needs an active workspace and there is none.
- `rate_limited` — a named limit is spent; `retryAfter` is in milliseconds.
The job queue's budget (`limit: 'jobBudget'`) also names the `plans`
on sale whose tier would fit the job now, in pricing order.
- `insufficient_credits` — the balance can't cover the spend.
- `feature_required` — the billing entity's plan does not include the
feature the call needs; `plans` names the catalog plans on sale that
do, in pricing order (none when no plan on sale includes it).
- `quota_exceeded` — the billing entity's plan allows `limit` of the
`quota`, `used` are held, and `amount` more do not fit; `plans` names
the catalog plans on sale that allow enough, in pricing order.
- `invalid_input` — an argument the call refuses; `field` names it, and
`reason` says why when the field alone does not (`otp_expired`,
`passkey_cancelled`, `no_password`, `retired`, `has_account`). A job
bigger than any budget of the queue is `over_budget` on `cost`, with
its `need` and the owner's `units`; a step's model refusing the
content is `content_blocked` on `prompt`.
- `not_ready` — there is nothing to act on yet, and retrying will not
change that: `reason` says what has to happen first (`no_customer`,
`not_synced`, `no_catalog`, `not_paid`, and `no_budget`: AI on a
sandbox deployment whose `setupAi` sets no `spendLimit`).
- `unavailable` — a service can't serve the call; `service` and
`reason` say which and why. Only `provider_refused` may pass on a retry;
the others need the deployment fixed, but a kill switch's
(`signups_paused`, `checkout_paused`, `ai_paused`, service `signups`,
`checkout` or `ai`), which an administrator turns off, billing's
`not_launched` (a production deployment with no provider token or
production catalog yet), which launching it ends, and its
`refund_refused` (the provider declined this refund request, which
refunded nothing more: a balance short of it, which passes once it is
topped up, or a payment refunded already, still being refunded, past
its window, disputed, or one whose refund failed before (Stripe takes
no other); the server error names which, by the provider's code, and
what to settle there: a gift refund that failed at once has no code,
and its error points to the refund on the payment in the provider's
dashboard). Nothing throws service `backend`
with reason `unexpected`: it is how a composable's `error` reads a
failure without a code (a crash, an app's own error), and says nothing
about whether a service is down.

#### Type Declaration

<table>
<thead>
  <tr>
    <th>
      Name
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Default value
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="property-unauthenticated">
        
      </a>
      
       <code>
        unauthenticated
      </code>
    </td>
    
    <td>
      { <code>
        status
      </code>
      
      : <code>
        401
      </code>
      
      ; <code>
        data
      </code>
      
      : <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, { <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , <code>
        "message"
      </code>
      
      >; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        unauthenticated.status
      </code>
    </td>
    
    <td>
      <code>
        401
      </code>
    </td>
    
    <td>
      <code>
        401
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        unauthenticated.data
      </code>
    </td>
    
    <td>
      <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, { <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , <code>
        "message"
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-forbidden">
        
      </a>
      
       <code>
        forbidden
      </code>
    </td>
    
    <td>
      { <code>
        status
      </code>
      
      : <code>
        403
      </code>
      
      ; <code>
        data
      </code>
      
      : <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        phase?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        invite?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        kind?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        until?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        waitlist?
      </code>
      
      : { <code>
        position?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        total?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        token
      </code>
      
      : <code>
        string
      </code>
      
      ; }; <code>
        reason
      </code>
      
      : <code>
        string
      </code>
      
      ; }, { <code>
        reason
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        phase
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        invite
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        kind
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        until
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        waitlist
      </code>
      
      : <code>
        VObject
      </code>
      
      < | { <code>
        position?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        total?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        token
      </code>
      
      : <code>
        string
      </code>
      
      ; } | <code>
        undefined
      </code>
      
      , { <code>
        position
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        total
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        token
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >; }, <code>
        "optional"
      </code>
      
      , <code>
        "position"
      </code>
      
       | <code>
        "total"
      </code>
      
       | <code>
        "token"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , | <code>
        "message"
      </code>
      
       | <code>
        "reason"
      </code>
      
       | <code>
        "phase"
      </code>
      
       | <code>
        "invite"
      </code>
      
       | <code>
        "kind"
      </code>
      
       | <code>
        "until"
      </code>
      
       | <code>
        "waitlist"
      </code>
      
       | <code>
        "waitlist.position"
      </code>
      
       | <code>
        "waitlist.total"
      </code>
      
       | <code>
        "waitlist.token"
      </code>
      
      >; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        forbidden.status
      </code>
    </td>
    
    <td>
      <code>
        403
      </code>
    </td>
    
    <td>
      <code>
        403
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        forbidden.data
      </code>
    </td>
    
    <td>
      <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        phase?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        invite?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        kind?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        until?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        waitlist?
      </code>
      
      : { <code>
        position?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        total?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        token
      </code>
      
      : <code>
        string
      </code>
      
      ; }; <code>
        reason
      </code>
      
      : <code>
        string
      </code>
      
      ; }, { <code>
        reason
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        phase
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        invite
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        kind
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        until
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        waitlist
      </code>
      
      : <code>
        VObject
      </code>
      
      < | { <code>
        position?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        total?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        token
      </code>
      
      : <code>
        string
      </code>
      
      ; } | <code>
        undefined
      </code>
      
      , { <code>
        position
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        total
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        token
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >; }, <code>
        "optional"
      </code>
      
      , <code>
        "position"
      </code>
      
       | <code>
        "total"
      </code>
      
       | <code>
        "token"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , | <code>
        "message"
      </code>
      
       | <code>
        "reason"
      </code>
      
       | <code>
        "phase"
      </code>
      
       | <code>
        "invite"
      </code>
      
       | <code>
        "kind"
      </code>
      
       | <code>
        "until"
      </code>
      
       | <code>
        "waitlist"
      </code>
      
       | <code>
        "waitlist.position"
      </code>
      
       | <code>
        "waitlist.total"
      </code>
      
       | <code>
        "waitlist.token"
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-reauthentication_required">
        
      </a>
      
       <code>
        reauthentication_required
      </code>
    </td>
    
    <td>
      { <code>
        status
      </code>
      
      : <code>
        403
      </code>
      
      ; <code>
        data
      </code>
      
      : <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, { <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , <code>
        "message"
      </code>
      
      >; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        reauthentication_required.status
      </code>
    </td>
    
    <td>
      <code>
        403
      </code>
    </td>
    
    <td>
      <code>
        403
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        reauthentication_required.data
      </code>
    </td>
    
    <td>
      <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, { <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , <code>
        "message"
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-no_workspace">
        
      </a>
      
       <code>
        no_workspace
      </code>
    </td>
    
    <td>
      { <code>
        status
      </code>
      
      : <code>
        409
      </code>
      
      ; <code>
        data
      </code>
      
      : <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, { <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , <code>
        "message"
      </code>
      
      >; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        no_workspace.status
      </code>
    </td>
    
    <td>
      <code>
        409
      </code>
    </td>
    
    <td>
      <code>
        409
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        no_workspace.data
      </code>
    </td>
    
    <td>
      <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, { <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , <code>
        "message"
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-rate_limited">
        
      </a>
      
       <code>
        rate_limited
      </code>
    </td>
    
    <td>
      { <code>
        status
      </code>
      
      : <code>
        429
      </code>
      
      ; <code>
        data
      </code>
      
      : <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        retryAfter?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        limit?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        plans?
      </code>
      
      : <code>
        string
      </code>
      
      <span>
        
      </span>
      
      ; }, { <code>
        retryAfter
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        limit
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        plans
      </code>
      
      : <code>
        VArray
      </code>
      
      <<code>
        string
      </code>
      
      <span>
        
      </span>
      
       | <code>
        undefined
      </code>
      
      , <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >, <code>
        "optional"
      </code>
      
      >; <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , <code>
        "message"
      </code>
      
       | <code>
        "retryAfter"
      </code>
      
       | <code>
        "limit"
      </code>
      
       | <code>
        "plans"
      </code>
      
      >; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        rate_limited.status
      </code>
    </td>
    
    <td>
      <code>
        429
      </code>
    </td>
    
    <td>
      <code>
        429
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        rate_limited.data
      </code>
    </td>
    
    <td>
      <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        retryAfter?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        limit?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        plans?
      </code>
      
      : <code>
        string
      </code>
      
      <span>
        
      </span>
      
      ; }, { <code>
        retryAfter
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        limit
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        plans
      </code>
      
      : <code>
        VArray
      </code>
      
      <<code>
        string
      </code>
      
      <span>
        
      </span>
      
       | <code>
        undefined
      </code>
      
      , <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >, <code>
        "optional"
      </code>
      
      >; <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , <code>
        "message"
      </code>
      
       | <code>
        "retryAfter"
      </code>
      
       | <code>
        "limit"
      </code>
      
       | <code>
        "plans"
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-insufficient_credits">
        
      </a>
      
       <code>
        insufficient_credits
      </code>
    </td>
    
    <td>
      { <code>
        status
      </code>
      
      : <code>
        402
      </code>
      
      ; <code>
        data
      </code>
      
      : <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        meter?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        balance
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        need
      </code>
      
      : <code>
        number
      </code>
      
      ; }, { <code>
        meter
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        balance
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        need
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , <code>
        "message"
      </code>
      
       | <code>
        "meter"
      </code>
      
       | <code>
        "balance"
      </code>
      
       | <code>
        "need"
      </code>
      
      >; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        insufficient_credits.status
      </code>
    </td>
    
    <td>
      <code>
        402
      </code>
    </td>
    
    <td>
      <code>
        402
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        insufficient_credits.data
      </code>
    </td>
    
    <td>
      <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        meter?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        balance
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        need
      </code>
      
      : <code>
        number
      </code>
      
      ; }, { <code>
        meter
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        balance
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        need
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , <code>
        "message"
      </code>
      
       | <code>
        "meter"
      </code>
      
       | <code>
        "balance"
      </code>
      
       | <code>
        "need"
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-feature_required">
        
      </a>
      
       <code>
        feature_required
      </code>
    </td>
    
    <td>
      { <code>
        status
      </code>
      
      : <code>
        402
      </code>
      
      ; <code>
        data
      </code>
      
      : <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        feature
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        plans
      </code>
      
      : <code>
        string
      </code>
      
      <span>
        
      </span>
      
      ; }, { <code>
        feature
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        plans
      </code>
      
      : <code>
        VArray
      </code>
      
      <<code>
        string
      </code>
      
      <span>
        
      </span>
      
      , <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >, <code>
        "required"
      </code>
      
      >; <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , <code>
        "feature"
      </code>
      
       | <code>
        "message"
      </code>
      
       | <code>
        "plans"
      </code>
      
      >; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        feature_required.status
      </code>
    </td>
    
    <td>
      <code>
        402
      </code>
    </td>
    
    <td>
      <code>
        402
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        feature_required.data
      </code>
    </td>
    
    <td>
      <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        feature
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        plans
      </code>
      
      : <code>
        string
      </code>
      
      <span>
        
      </span>
      
      ; }, { <code>
        feature
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        plans
      </code>
      
      : <code>
        VArray
      </code>
      
      <<code>
        string
      </code>
      
      <span>
        
      </span>
      
      , <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >, <code>
        "required"
      </code>
      
      >; <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , <code>
        "feature"
      </code>
      
       | <code>
        "message"
      </code>
      
       | <code>
        "plans"
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-quota_exceeded">
        
      </a>
      
       <code>
        quota_exceeded
      </code>
    </td>
    
    <td>
      { <code>
        status
      </code>
      
      : <code>
        402
      </code>
      
      ; <code>
        data
      </code>
      
      : <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        limit
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        plans
      </code>
      
      : <code>
        string
      </code>
      
      <span>
        
      </span>
      
      ; <code>
        quota
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        used
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        amount
      </code>
      
      : <code>
        number
      </code>
      
      ; }, { <code>
        quota
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        limit
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        used
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        amount
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        plans
      </code>
      
      : <code>
        VArray
      </code>
      
      <<code>
        string
      </code>
      
      <span>
        
      </span>
      
      , <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >, <code>
        "required"
      </code>
      
      >; <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , <code>
        "message"
      </code>
      
       | <code>
        "limit"
      </code>
      
       | <code>
        "plans"
      </code>
      
       | <code>
        "quota"
      </code>
      
       | <code>
        "used"
      </code>
      
       | <code>
        "amount"
      </code>
      
      >; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        quota_exceeded.status
      </code>
    </td>
    
    <td>
      <code>
        402
      </code>
    </td>
    
    <td>
      <code>
        402
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        quota_exceeded.data
      </code>
    </td>
    
    <td>
      <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        limit
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        plans
      </code>
      
      : <code>
        string
      </code>
      
      <span>
        
      </span>
      
      ; <code>
        quota
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        used
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        amount
      </code>
      
      : <code>
        number
      </code>
      
      ; }, { <code>
        quota
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        limit
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        used
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        amount
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        plans
      </code>
      
      : <code>
        VArray
      </code>
      
      <<code>
        string
      </code>
      
      <span>
        
      </span>
      
      , <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >, <code>
        "required"
      </code>
      
      >; <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , <code>
        "message"
      </code>
      
       | <code>
        "limit"
      </code>
      
       | <code>
        "plans"
      </code>
      
       | <code>
        "quota"
      </code>
      
       | <code>
        "used"
      </code>
      
       | <code>
        "amount"
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-invalid_input">
        
      </a>
      
       <code>
        invalid_input
      </code>
    </td>
    
    <td>
      { <code>
        status
      </code>
      
      : <code>
        400
      </code>
      
      ; <code>
        data
      </code>
      
      : <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        reason?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        need?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        units?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        field
      </code>
      
      : <code>
        string
      </code>
      
      ; }, { <code>
        field
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        reason
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        need
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        units
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , <code>
        "message"
      </code>
      
       | <code>
        "reason"
      </code>
      
       | <code>
        "need"
      </code>
      
       | <code>
        "field"
      </code>
      
       | <code>
        "units"
      </code>
      
      >; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        invalid_input.status
      </code>
    </td>
    
    <td>
      <code>
        400
      </code>
    </td>
    
    <td>
      <code>
        400
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        invalid_input.data
      </code>
    </td>
    
    <td>
      <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        reason?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        need?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        units?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        field
      </code>
      
      : <code>
        string
      </code>
      
      ; }, { <code>
        field
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        reason
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        need
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        units
      </code>
      
      : <code>
        VFloat64
      </code>
      
      <<code>
        number
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , <code>
        "message"
      </code>
      
       | <code>
        "reason"
      </code>
      
       | <code>
        "need"
      </code>
      
       | <code>
        "field"
      </code>
      
       | <code>
        "units"
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-not_ready">
        
      </a>
      
       <code>
        not_ready
      </code>
    </td>
    
    <td>
      { <code>
        status
      </code>
      
      : <code>
        409
      </code>
      
      ; <code>
        data
      </code>
      
      : <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        reason
      </code>
      
      : <code>
        string
      </code>
      
      ; }, { <code>
        reason
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , <code>
        "message"
      </code>
      
       | <code>
        "reason"
      </code>
      
      >; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        not_ready.status
      </code>
    </td>
    
    <td>
      <code>
        409
      </code>
    </td>
    
    <td>
      <code>
        409
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        not_ready.data
      </code>
    </td>
    
    <td>
      <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        reason
      </code>
      
      : <code>
        string
      </code>
      
      ; }, { <code>
        reason
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , <code>
        "message"
      </code>
      
       | <code>
        "reason"
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-unavailable">
        
      </a>
      
       <code>
        unavailable
      </code>
    </td>
    
    <td>
      { <code>
        status
      </code>
      
      : <code>
        503
      </code>
      
      ; <code>
        data
      </code>
      
      : <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        reason
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        service
      </code>
      
      : <code>
        string
      </code>
      
      ; }, { <code>
        service
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        reason
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , <code>
        "message"
      </code>
      
       | <code>
        "reason"
      </code>
      
       | <code>
        "service"
      </code>
      
      >; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        unavailable.status
      </code>
    </td>
    
    <td>
      <code>
        503
      </code>
    </td>
    
    <td>
      <code>
        503
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        unavailable.data
      </code>
    </td>
    
    <td>
      <code>
        VObject
      </code>
      
      <{ <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        reason
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        service
      </code>
      
      : <code>
        string
      </code>
      
      ; }, { <code>
        service
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        reason
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        "required"
      </code>
      
      >; <code>
        message
      </code>
      
      : <code>
        VString
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      , <code>
        "optional"
      </code>
      
      >; }, <code>
        "required"
      </code>
      
      , <code>
        "message"
      </code>
      
       | <code>
        "reason"
      </code>
      
       | <code>
        "service"
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts" rel="nofollow">
        src/convex/errors.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### SENSITIVE_ACTIONS

```ts
const SENSITIVE_ACTIONS: Readonly<Record<string, SensitiveAction>> = ROWS;
```

Defined in: [src/convex/sensitive-actions.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/sensitive-actions.ts)

The table, by Better Auth route (its path under the auth base path) or by
scaffold function (`module:export`, as the client calls it). Reads appear
where their impersonation rule or limit says something: an impersonated
session may use only the routes whose row allows it.

## Functions

### backendError()

```ts
function backendError<C>(code, ...args): ConvexError<BackendErrorPayload<C>>;
```

Defined in: [src/convex/errors.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts)

Build the error for a refusal: `throw backendError('forbidden', { reason: 'role' })`. The data is checked against the code's validator, so a throw
site cannot send a field the catalog does not list. `detail` is the
English sentence the deployment log shows as the error's message; it never
reaches the person in production.

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-c-3">
        
      </a>
      
       <code>
        C
      </code>
      
       <em>
        extends
      </em>
      
       | <code>
        "unauthenticated"
      </code>
      
       | <code>
        "forbidden"
      </code>
      
       | <code>
        "reauthentication_required"
      </code>
      
       | <code>
        "no_workspace"
      </code>
      
       | <code>
        "rate_limited"
      </code>
      
       | <code>
        "insufficient_credits"
      </code>
      
       | <code>
        "feature_required"
      </code>
      
       | <code>
        "quota_exceeded"
      </code>
      
       | <code>
        "invalid_input"
      </code>
      
       | <code>
        "not_ready"
      </code>
      
       | <code>
        "unavailable"
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        code
      </code>
    </td>
    
    <td>
      <code>
        C
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      ...<code>
        args
      </code>
    </td>
    
    <td>
      <a href="#backenderrorargs">
        <code>
          BackendErrorArgs
        </code>
      </a>
      
      <<code>
        C
      </code>
      
      >
    </td>
  </tr>
</tbody>
</table>

#### Returns

`ConvexError`<[`BackendErrorPayload`](#backenderrorpayload)<`C`>>

#### Example

```ts
import { backendError } from 'nuxt-backend/functions'

if (project.ownerId !== ctx.user.id) throw backendError('forbidden', { reason: 'not_owner' })
if (!name.trim()) throw backendError('invalid_input', { field: 'name' }, 'A project needs a name.')
```

---

### getBackendError()

```ts
function getBackendError(error): BackendError | null;
```

Defined in: [src/convex/errors.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/errors.ts)

Read a refusal out of anything a call threw or resolved with: a
`backendError()` from a Convex function, the rate limiter's own
`RateLimited` error, an auth client's `{ data, error }` result or its
`error`, a Better Auth `APIError`, and any of these as an `Error`'s
`cause`. `null` for anything else — a crash, an app's own error — so the
caller keeps its own fallback.

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        error
      </code>
    </td>
    
    <td>
      <code>
        unknown
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Returns

[`BackendError`](#backenderror) | `null`

#### Example

```ts
try {
  await transform({ text })
}
catch (error) {
  const refusal = getBackendError(error)
  // Every field may be absent on the read side: check the one you use.
  if (refusal?.code === 'insufficient_credits' && refusal.data.need !== undefined) offerTopUp(refusal.data.need)
  else message.value = refusal?.message ?? 'Something went wrong.'
}
```

---

### createFunctions()

```ts
function createFunctions<DM>(builders, options): {
  authed: {
     query: CustomBuilder<"query", Record<string, never>, {
        user: FunctionUser;
     }, Record<string, never>, GenericQueryCtx<DM>, "public", FunctionDeclaration>;
     mutation: CustomBuilder<"mutation", Record<string, never>, {
        user: FunctionUser;
     }, Record<string, never>, GenericMutationCtx<DM>, "public", FunctionDeclaration>;
     action: CustomBuilder<"action", Record<string, never>, {
        user: FunctionUser;
     }, Record<string, never>, GenericActionCtx<DM>, "public", FunctionDeclaration>;
  };
  workspace: {
     query: CustomBuilder<"query", Record<string, never>, {
        user: FunctionUser;
        workspace: AuthorizationWorkspace;
     }, Record<string, never>, GenericQueryCtx<DM>, "public", FunctionDeclaration>;
     mutation: CustomBuilder<"mutation", Record<string, never>, {
        user: FunctionUser;
        workspace: AuthorizationWorkspace;
     }, Record<string, never>, GenericMutationCtx<DM>, "public", FunctionDeclaration>;
     action: CustomBuilder<"action", Record<string, never>, {
        user: FunctionUser;
        workspace: AuthorizationWorkspace;
     }, Record<string, never>, GenericActionCtx<DM>, "public", FunctionDeclaration>;
  };
  admin: {
     query: CustomBuilder<"query", Record<string, never>, {
        user: FunctionUser;
     }, Record<string, never>, GenericQueryCtx<DM>, "public", FunctionDeclaration>;
     mutation: CustomBuilder<"mutation", Record<string, never>, {
        user: FunctionUser;
     }, Record<string, never>, GenericMutationCtx<DM>, "public", FunctionDeclaration>;
     action: CustomBuilder<"action", Record<string, never>, {
        user: FunctionUser;
     }, Record<string, never>, GenericActionCtx<DM>, "public", FunctionDeclaration>;
  };
  withRole: (role) => {
     query: CustomBuilder<"query", Record<string, never>, {
        user: FunctionUser;
     }, Record<string, never>, GenericQueryCtx<DM>, "public", FunctionDeclaration>;
     mutation: CustomBuilder<"mutation", Record<string, never>, {
        user: FunctionUser;
     }, Record<string, never>, GenericMutationCtx<DM>, "public", FunctionDeclaration>;
     action: CustomBuilder<"action", Record<string, never>, {
        user: FunctionUser;
     }, Record<string, never>, GenericActionCtx<DM>, "public", FunctionDeclaration>;
  };
  withFeature: (feature) => {
     query: CustomBuilder<"query", Record<string, never>, {
        user: FunctionUser;
        workspace: AuthorizationWorkspace;
     }, Record<string, never>, GenericQueryCtx<DM>, "public", FunctionDeclaration>;
     mutation: CustomBuilder<"mutation", Record<string, never>, {
        user: FunctionUser;
        workspace: AuthorizationWorkspace;
     }, Record<string, never>, GenericMutationCtx<DM>, "public", FunctionDeclaration>;
     action: CustomBuilder<"action", Record<string, never>, {
        user: FunctionUser;
        workspace: AuthorizationWorkspace;
     }, Record<string, never>, GenericActionCtx<DM>, "public", FunctionDeclaration>;
  };
  setUserRole: RegisteredMutation<"internal", {
     email: string;
     role: string;
  }, Promise<null>>;
};
```

Defined in: [src/convex/integrations/functions.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts)

Every access tier of your backend, from one call in `backend/functions.ts`:
each a drop-in `{ query, mutation, action }` that checks the caller before
the handler runs.

```ts
// backend/functions.ts
import { createFunctions } from 'nuxt-backend/functions'
import { billing } from './billing'
import { rateLimiter } from './rateLimiter'
import { components } from './_generated/api'
import { action, mutation, query } from './_generated/server'

export const { authed, workspace, admin, withRole, withFeature, setUserRole } = createFunctions(
  { query, mutation, action },
  { components, billing, rateLimiter, limits: { authed: 'write', workspace: 'write' } },
)

// backend/strips.ts
export const create = workspace.mutation({ // ctx.user + ctx.workspace (fresh membership)
  args: { title: v.string() },
  handler: async (ctx, { title }) =>
    ctx.db.insert('strips', { title, workspaceId: ctx.workspace.id }),
})
```

The `workspace` tier verifies membership with a fresh member-table read on every
call (a removed member is locked out immediately, not at token expiry). The
`admin` tier reads the role fresh too, so a demoted admin is refused on
their next call, and its mutations and actions refuse a session an
administrator opened by impersonating someone (`forbidden`, reason
`impersonating`): an admin write is a person's own act. The mutations
and actions of every tier read the account fresh, so a ban, a deletion
or (for `withRole`) a role change lands on the next write; `authed` and
`withRole` queries read the token's claims, which can lag by up to its
15-minute lifetime.

Every tier's action reports a crash of its handler, or an `unavailable`
refusal, to the monitoring service `MONITORING_DSN` names
(`nuxt-backend/monitoring`), then rethrows it. Pass your
trigger-wrapped `mutation` to keep aggregate triggers composing.

A function declares `recentSignIn` beside `args` for a sign-in from the
last ten minutes (`true`) or a number of seconds, and
`impersonation: 'refused'` to refuse an administrator's visit. The
`admin` tier's mutations and actions take a recent sign-in by default.

`setUserRole` is the internal mutation that sets an app-wide role by
email: `npx nuxt-backend doctor --fix` runs it to make your first
administrator.

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-dm">
        
      </a>
      
       <code>
        DM
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        GenericDataModel
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        builders
      </code>
    </td>
    
    <td>
      <code>
        Builders
      </code>
      
      <<code>
        DM
      </code>
      
      >
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options
      </code>
    </td>
    
    <td>
      <a href="#createfunctionsoptions">
        <code>
          CreateFunctionsOptions
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

#### Returns

<table>
<thead>
  <tr>
    <th>
      Name
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        authed
      </code>
    </td>
    
    <td>
      { <code>
        query
      </code>
      
      : <code>
        CustomBuilder
      </code>
      
      <<code>
        "query"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericQueryCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >; <code>
        mutation
      </code>
      
      : <code>
        CustomBuilder
      </code>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericMutationCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >; <code>
        action
      </code>
      
      : <code>
        CustomBuilder
      </code>
      
      <<code>
        "action"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericActionCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >; }
    </td>
    
    <td>
      Signed-in (and not banned): injects <code>
        ctx.user
      </code>
      
      . Its mutations and actions read the account fresh, so a ban lands at once; its queries read the token's claims.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        authed.query
      </code>
    </td>
    
    <td>
      <code>
        CustomBuilder
      </code>
      
      <<code>
        "query"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericQueryCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        authed.mutation
      </code>
    </td>
    
    <td>
      <code>
        CustomBuilder
      </code>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericMutationCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        authed.action
      </code>
    </td>
    
    <td>
      <code>
        CustomBuilder
      </code>
      
      <<code>
        "action"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericActionCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        workspace
      </code>
    </td>
    
    <td>
      { <code>
        query
      </code>
      
      : <code>
        CustomBuilder
      </code>
      
      <<code>
        "query"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; <code>
        workspace
      </code>
      
      : <a href="#authorizationworkspace">
        <code>
          AuthorizationWorkspace
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericQueryCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >; <code>
        mutation
      </code>
      
      : <code>
        CustomBuilder
      </code>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; <code>
        workspace
      </code>
      
      : <a href="#authorizationworkspace">
        <code>
          AuthorizationWorkspace
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericMutationCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >; <code>
        action
      </code>
      
      : <code>
        CustomBuilder
      </code>
      
      <<code>
        "action"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; <code>
        workspace
      </code>
      
      : <a href="#authorizationworkspace">
        <code>
          AuthorizationWorkspace
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericActionCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >; }
    </td>
    
    <td>
      Workspace member (fresh check): injects <code>
        ctx.user
      </code>
      
       + <code>
        ctx.workspace
      </code>
      
       (<code>
        { id, slug, name, role }
      </code>
      
      ). Its writes read the account fresh too.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        workspace.query
      </code>
    </td>
    
    <td>
      <code>
        CustomBuilder
      </code>
      
      <<code>
        "query"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; <code>
        workspace
      </code>
      
      : <a href="#authorizationworkspace">
        <code>
          AuthorizationWorkspace
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericQueryCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        workspace.mutation
      </code>
    </td>
    
    <td>
      <code>
        CustomBuilder
      </code>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; <code>
        workspace
      </code>
      
      : <a href="#authorizationworkspace">
        <code>
          AuthorizationWorkspace
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericMutationCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        workspace.action
      </code>
    </td>
    
    <td>
      <code>
        CustomBuilder
      </code>
      
      <<code>
        "action"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; <code>
        workspace
      </code>
      
      : <a href="#authorizationworkspace">
        <code>
          AuthorizationWorkspace
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericActionCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        admin
      </code>
    </td>
    
    <td>
      { <code>
        query
      </code>
      
      : <code>
        CustomBuilder
      </code>
      
      <<code>
        "query"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericQueryCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >; <code>
        mutation
      </code>
      
      : <code>
        CustomBuilder
      </code>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericMutationCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >; <code>
        action
      </code>
      
      : <code>
        CustomBuilder
      </code>
      
      <<code>
        "action"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericActionCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >; }
    </td>
    
    <td>
      App-wide admin (<code>
        adminRoles
      </code>
      
      , read fresh): injects <code>
        ctx.user
      </code>
      
      . Its mutations and actions refuse impersonated sessions, and take a sign-in from the last ten minutes unless the function says <code>
        recentSignIn: false
      </code>
      
       (<code>
        reauthentication_required
      </code>
      
      ). On a <code>
        sandbox
      </code>
      
       deployment it refuses an administrator whose account is not passkey-only (<code>
        forbidden
      </code>
      
      , reason <code>
        passkey_only_admin
      </code>
      
      ).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        admin.query
      </code>
    </td>
    
    <td>
      <code>
        CustomBuilder
      </code>
      
      <<code>
        "query"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericQueryCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        admin.mutation
      </code>
    </td>
    
    <td>
      <code>
        CustomBuilder
      </code>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericMutationCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        admin.action
      </code>
    </td>
    
    <td>
      <code>
        CustomBuilder
      </code>
      
      <<code>
        "action"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericActionCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        withRole()
      </code>
    </td>
    
    <td>
      (<code>
        role
      </code>
      
      ) => { <code>
        query
      </code>
      
      : <code>
        CustomBuilder
      </code>
      
      <<code>
        "query"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericQueryCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >; <code>
        mutation
      </code>
      
      : <code>
        CustomBuilder
      </code>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericMutationCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >; <code>
        action
      </code>
      
      : <code>
        CustomBuilder
      </code>
      
      <<code>
        "action"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericActionCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >; }
    </td>
    
    <td>
      Custom app-wide role tier: <code>
        withRole('editor').query(...)
      </code>
      
      . Its writes read the role and the ban fresh.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        withFeature()
      </code>
    </td>
    
    <td>
      (<code>
        feature
      </code>
      
      ) => { <code>
        query
      </code>
      
      : <code>
        CustomBuilder
      </code>
      
      <<code>
        "query"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; <code>
        workspace
      </code>
      
      : <a href="#authorizationworkspace">
        <code>
          AuthorizationWorkspace
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericQueryCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >; <code>
        mutation
      </code>
      
      : <code>
        CustomBuilder
      </code>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; <code>
        workspace
      </code>
      
      : <a href="#authorizationworkspace">
        <code>
          AuthorizationWorkspace
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericMutationCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >; <code>
        action
      </code>
      
      : <code>
        CustomBuilder
      </code>
      
      <<code>
        "action"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, { <code>
        user
      </code>
      
      : <a href="#functionuser">
        <code>
          FunctionUser
        </code>
      </a>
      
      ; <code>
        workspace
      </code>
      
      : <a href="#authorizationworkspace">
        <code>
          AuthorizationWorkspace
        </code>
      </a>
      
      ; }, <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <code>
        GenericActionCtx
      </code>
      
      <<code>
        DM
      </code>
      
      >, <code>
        "public"
      </code>
      
      , <a href="#functiondeclaration">
        <code>
          FunctionDeclaration
        </code>
      </a>
      
      >; }
    </td>
    
    <td>
      The <code>
        workspace
      </code>
      
       tier for a plan's feature: <code>
        withFeature('reports').query(...)
      </code>
      
      . A workspace member (read fresh) whose billing entity's plan grants the feature, as <code>
        billing.requireFeature
      </code>
      
       checks it: from the entitlement cache, matched by its catalog key. Anyone else is refused <code>
        feature_required
      </code>
      
      , its <code>
        plans
      </code>
      
       the plans on sale that include it. Injects <code>
        ctx.user
      </code>
      
       and <code>
        ctx.workspace
      </code>
      
      ; its <code>
        recentSignIn
      </code>
      
       is asked last, of a caller the feature already lets in. Its writes spend <code>
        limits.workspace
      </code>
      
      . Needs <code>
        billing
      </code>
      
       in <code>
        createFunctions
      </code>
      
      ' options: without it, defining a function throws. The plan checked is the billing entity's, as billing resolves it: the active workspace, <code>
        ctx.workspace
      </code>
      
      , by default; the one your <code>
        setupBilling({ resolveEntity })
      </code>
      
       names when you have one. With <code>
        billTo: 'user'
      </code>
      
       it is the caller's own plan, and the tier still asks for a workspace member: gate a function on a user's plan, or behind another tier, with <code>
        billing.requireFeature(ctx, key)
      </code>
      
       in its handler. <strong>
        Guarantee
      </strong>
      
       Refuses a caller who may not act at all (signed out, no member) as the <code>
        workspace
      </code>
      
       tier does, before the feature is read.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        setUserRole
      </code>
    </td>
    
    <td>
      <code>
        RegisteredMutation
      </code>
      
      <<code>
        "internal"
      </code>
      
      , { <code>
        email
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        role
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <<code>
        null
      </code>
      
      >>
    </td>
    
    <td>
      The internal mutation that sets an app-wide role by email, never callable from a browser: <code>
        npx nuxt-backend doctor --fix
      </code>
      
       runs it to make your first administrator. A role it changes is recorded on the activity trail as <code>
        admin.role_changed
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts" rel="nofollow">
        src/convex/integrations/functions.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### verifyHuman()

```ts
function verifyHuman(
   ctx, 
   token, 
   __namedParameters
): Promise<void>;
```

Defined in: [src/convex/integrations/functions.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts)

Check that a call comes from a person, in a function of your own: a
waitlist join, a contact form, a referral claim, any call that reaches the
deployment over the live connection and never through the app's server.
The client gets the token from `useHumanCheck().token(action, subject)`
and passes it along with the call.

It accepts either:

- a proof the app's server signed for this `action` (and `subject`, when
one is named) and this deployment after its own bot check passed (on
Vercel, BotID), under `PROTECTION_PROOF_SECRET`, at most a minute old;
- a challenge answer, given for this `action` and verified with the
provider under `PROTECTION_CHALLENGE_SECRET_KEY`. That takes a `fetch`,
which Convex runs in actions only, and off Vercel no proof is signed:
check in an action, as below, which works on every host.

A proof for a call that names no subject is bound to the browser that
asked for it, by the visitor cookie the proof route sets: `jobs.enqueue`
in the same function puts a signed-out caller's guest job under that
visitor (`defineJobQueue({ guest })`).

With neither secret set, the deployment checks nobody and every call
passes: bot protection is missing (`nuxt-backend doctor --prod` says so).
Anything else is refused as `forbidden` with reason `bot_check`; a
provider that cannot be reached as `unavailable` (`provider_refused`).

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        ctx
      </code>
    </td>
    
    <td>
      <code>
        object
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        token
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
       | <code>
        undefined
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        __namedParameters
      </code>
    </td>
    
    <td>
      { <code>
        action
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        subject?
      </code>
      
      : <code>
        string
      </code>
      
      ; }
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        __namedParameters.action
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        __namedParameters.subject?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Returns

`Promise`<`void`>

#### Guarantee

A token passes for the one action (and subject) it was given for, and a proof for a minute on its own deployment.

#### Guarantee

Without a secret on the deployment, no token is ever required.

#### Example

```ts
import { verifyHuman } from 'nuxt-backend/functions'

export const joinWaitlist = action({
  args: { email: v.string(), human: v.optional(v.union(v.string(), v.null())) },
  handler: async (ctx, { email, human }) => {
    await verifyHuman(ctx, human, { action: 'waitlist', subject: email })
    await ctx.runMutation(internal.waitlist.insert, { email })
  },
})
```

---

### defineRetention()

```ts
function defineRetention<DM, T, I>(internalMutation, options): RegisteredMutation<"internal", RetentionArgs, Promise<RetentionResult>>;
```

Defined in: [src/convex/integrations/retention.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/retention.ts)

Delete a table's rows once they pass an age, a batch per transaction,
until none is left. Returns the rule's internal mutation: export it from
a file in `backend/`, and give it a `schedule` that
[scheduleRetention](#scheduleretention) starts from `backend/crons.ts` (or start it
from a cron of your own: `crons.cron(..., internal.retention.pruneDrafts, {})`).

A pass fixes its cutoff when it starts (the current time minus `ttl`), so
it always ends: each batch reads up to `batch` rows older than the cutoff
through `index`, runs `onDelete` for each and deletes it, all in one
transaction, and a batch that leaves rows behind schedules the next one
through the rule's own `fn`, carrying the same clock. A batch that throws
rolls back, ends the pass and logs `retention.batch_failed` with the table
and the row; the next pass retries from the same oldest rows.

Pass the builder your other writes use: when an aggregate counts the table,
that is the trigger-wrapped `internalMutation`, so a pruned row leaves the
count too.

The mutation takes an optional `{ now }` (epoch milliseconds) and returns
`{ deleted, more }`.

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-dm-2">
        
      </a>
      
       <code>
        DM
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        GenericDataModel
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="type-parameter-t-1">
        
      </a>
      
       <code>
        T
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        string
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="type-parameter-i-1">
        
      </a>
      
       <code>
        I
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        string
      </code>
      
       | <code>
        number
      </code>
      
       | <code>
        symbol
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        internalMutation
      </code>
    </td>
    
    <td>
      <code>
        MutationBuilder
      </code>
      
      <<code>
        DM
      </code>
      
      , <code>
        "internal"
      </code>
      
      >
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options
      </code>
    </td>
    
    <td>
      <a href="#retentionoptions">
        <code>
          RetentionOptions
        </code>
      </a>
      
      <<code>
        DM
      </code>
      
      , <code>
        T
      </code>
      
      , <code>
        I
      </code>
      
      >
    </td>
  </tr>
</tbody>
</table>

#### Returns

`RegisteredMutation`<`"internal"`, [`RetentionArgs`](#retentionargs), `Promise`<[`RetentionResult`](#retentionresult)>>

#### Guarantee

A pass ends: its cutoff is fixed when it starts.

#### Guarantee

`onDelete` and the delete of its row are one transaction: both happen or neither does.

#### Guarantee

Rows are read through an index, never scanned, so a batch reads at most `batch + 1` rows.

#### Guarantee

A row whose time field is missing sorts first and is deleted on the first pass.

#### Throws

TypeError when `fn`, `ttl`, `batch`, `index` or `schedule` is malformed, as the module loads.

#### Example

```ts
// backend/retention.ts
import { defineRetention } from 'nuxt-backend/functions'
import { DAY } from 'nuxt-backend/rate-limit'
import { internalMutation } from './_generated/server'

export const pruneDrafts = defineRetention(internalMutation, {
  fn: 'retention:pruneDrafts',
  table: 'strips',
  index: 'by_status_and_updatedAt',
  match: { status: 'draft' },
  ttl: 30 * DAY,
  schedule: { cron: '20 3 * * *' },
})
```

---

### scheduleRetention()

```ts
function scheduleRetention(crons, rules): string[];
```

Defined in: [src/convex/integrations/retention.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/retention.ts)

Start every retention rule that has a `schedule` from your
`backend/crons.ts`: one cron each, named after the rule's `fn`. Pass the
rules' module (`import * as retention from './retention'`) or an object
of rules; anything else in it, and a rule with no `schedule`, is left out.
A rule it schedules needs no cron of yours: one under another name is a
second cron, and the rule runs twice.

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        crons
      </code>
    </td>
    
    <td>
      <code>
        Crons
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        rules
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        unknown
      </code>
      
      >
    </td>
  </tr>
</tbody>
</table>

#### Returns

`string`<span>



</span>



The `fn` of each rule it scheduled.

#### Guarantee

Each rule runs on its own `schedule`, under its `fn` as the cron's name: renaming a rule renames its cron.

#### Example

```ts
// backend/crons.ts
import { cronJobs } from 'convex/server'
import { scheduleRetention } from 'nuxt-backend/functions'
import * as retention from './retention'

const crons = cronJobs()
scheduleRetention(crons, retention)

export default crons
```

---

### randomToken()

```ts
function randomToken(bytes?): string;
```

Defined in: [src/convex/tokens.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/tokens.ts)

A random token from the platform's secure random source: 32 bytes by
default, written as 43 URL-safe characters (`A-Z a-z 0-9 - _`), so it
goes into a path or a query as it is. Hand it out once and keep only
`sha256Hex(token)`.

`bytes` is the entropy, from 16 to 1024. The token's length is longer:
22 characters for 16 bytes.

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Default value
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        bytes?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        32
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Returns

`string`

#### Throws

TypeError when `bytes` is no whole number from 16 to 1024.

#### Example

```ts
import { randomToken, sha256Hex } from 'nuxt-backend/functions'

const token = randomToken()
const tokenHash = await sha256Hex(token) // store this
return token // shown once
```

---

### sha256Hex()

```ts
function sha256Hex(text): Promise<string>;
```

Defined in: [src/convex/tokens.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/tokens.ts)

The text's SHA-256 as 64 lower-case hex characters, from its UTF-8
bytes. The hash to store for a token, and to look it up by: hash what
arrives and compare hashes.

It suits tokens that are random and long. A password or any guessable
secret needs a slow, salted hash instead (the package never stores
passwords).

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        text
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Returns

`Promise`<`string`>

#### Example

```ts
import { sha256Hex } from 'nuxt-backend/functions'

await sha256Hex('abc') // 'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad'
```

---

### normalizeEmail()

```ts
function normalizeEmail(address): string;
```

Defined in: [src/convex/tokens.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/tokens.ts)

The address trimmed and lower-cased: the form to store and compare it in,
so `Ana@Example.com ` and `ana@example.com` are one person. Only
surrounding whitespace and case change, and the domain is not rewritten
(no punycode, no plus-tag or dot rules, which differ by provider).

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        address
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Returns

`string`

#### Example

```ts
import { normalizeEmail } from 'nuxt-backend/functions'

normalizeEmail('  Ana@Example.com ') // 'ana@example.com'
```


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
