open-index/open-npm huggingface dataset:
npm package: @keystone-next/app-graphql-legacy
Description: KeystoneJS GraphQL App.
Author: The KeystoneJS Development Team
Latest version: 7.0.0

<!--[meta]
section: api
subSection: apps
title: GraphQL app
[meta]-->

# GraphQL app

[![View changelog](https://img.shields.io/badge/changelogs.xyz-Explore%20Changelog-brightgreen)](https://changelogs.xyz/@keystonejs/app-graphql)

A KeystoneJS app that creates a GraphQL API and [GraphiQL](https://github.com/graphql/graphiql/blob/master/packages/graphiql/README.md) playground.

> **Note:** The GraphiQL playground is disabled in production mode.

For information about writing queries and mutations for KeystoneJS see the [Introduction to KeystoneJS' GraphQL API](https://keystonejs.com/guides/intro-to-graphql).

## Usage

```javascript
const { Keystone } = require('@keystone-next/keystone-legacy');
const { GraphQLApp } = require('@keystone-next/app-graphql-legacy');
const { AdminUIApp } = require('@keystone-next/app-admin-ui-legacy');

module.exports = {
  keystone: new Keystone(),
  apps: [
    new GraphQLApp({
      // All config keys are optional. Default values are shown here for completeness.
      apiPath: '/admin/api',
      schemaName: 'admin',
      apollo: {},
    }),
    new AdminUIApp(),
  ],
};
```

## Config

| Option         | Type     | Default           | Description                                      |
| -------------- | -------- | ----------------- | ------------------------------------------------ |
| `apiPath`      | `String` | `/admin/api`      | Change the API path                              |
| `schemaName`   | `String` | `admin`           | Change the graphQL schema name (not recommended) |
| `apollo`       | `Object` | `{}`              | Options passed directly to Apollo Server         |

## Setting a custom schemaName

To use a custom `schemaName`, please ensure it is also passed in to the [keystone constructor](https://www.keystonejs.com/keystonejs/keystone/#schemanames) at initialization.
npm package: @keystone-next/app-graphql-playground-legacy
Description: KeystoneJS GraphQL Playground App.
Author: The KeystoneJS Development Team
Latest version: 5.1.10

<!--[meta]
section: api
subSection: apps
title: GraphQL Playground App
draft: true
[meta]-->

# GraphQL Playground App

[![View changelog](https://img.shields.io/badge/changelogs.xyz-Explore%20Changelog-brightgreen)](https://changelogs.xyz/@keystonejs/app-graphql-playground)

A KeystoneJS App that creates an Apollo GraphQL playground.

## Usage

```javascript
const { Keystone } = require('@keystone-next/keystone-legacy');
const { GraphQLApp } = require('@keystone-next/app-graphql-legacy');
const { GraphQLPlaygroundApp } = require('@keystone-next/app-graphql-playground-legacy');
const { AdminUIApp } = require('@keystone-next/app-admin-ui-legacy');

// Ensure that the GraphQLApp and GraphQLAppPlayground are referring to the same endpoint
const apiPath = '/admin/api';

module.exports = {
  keystone: new Keystone(),
  apps: [
    // This should come before the GraphQLApp, as it sets up the dev query middleware
    new GraphQLPlaygroundApp({ apiPath })
    // Disable the default playground on this app
    new GraphQLApp({ apiPath, graphiqlPath: undefined }),
    new AdminUIApp()
  ],
};
```

## Config

| Option         | Type     | Default           | Description                               |
| -------------- | -------- | ----------------- | ----------------------------------------- |
| `apiPath`      | `String` | `/admin/api`      | Change the API path                       |
| `graphiqlPath` | `String` | `/admin/graphiql` | Change the Apollo GraphQL playground path |
npm package: @keystone-next/app-next-legacy
Description: KeystoneJS Next.js App.
Author: The KeystoneJS Development Team
Latest version: 6.0.1

<!--[meta]
section: api
subSection: apps
title: Next.js app
[meta]-->

# Next.js app

[![View changelog](https://img.shields.io/badge/changelogs.xyz-Explore%20Changelog-brightgreen)](https://changelogs.xyz/@keystonejs/app-next)

A KeystoneJS app for serving a [Next.js](https://nextjs.org/) application.

## Usage

```javascript
const { NextApp } = require('@keystone-next/app-next-legacy');

module.exports = {
  keystone,
  apps: [
    new GraphQLApp(),
    new AdminUIApp({ enableDefaultRoute: false }),
    new NextApp({ dir: 'app' }),
  ],
  distDir,
};
```

### Config

| Option | Type     | Default | Required | Description                       |
| ------ | -------- | ------- | -------- | --------------------------------- |
| `dir`  | `String` | `null`  | `true`   | The directory of the Next.js app. |
npm package: @keystone-next/app-nuxt-legacy
Description: KeystoneJS Nuxt.js App.
Author: The KeystoneJS Development Team
Latest version: 5.1.7

<!--[meta]
section: api
subSection: apps
title: Nuxt.js app
[meta]-->

# Nuxt.js app

[![View changelog](https://img.shields.io/badge/changelogs.xyz-Explore%20Changelog-brightgreen)](https://changelogs.xyz/@keystonejs/app-nuxt)

## Usage

```javascript
const { NuxtApp } = require('@keystone-next/app-nuxt-legacy');

const config = {
  srcDir: 'src',
  buildDir: 'dist',
};

module.exports = {
  keystone,
  apps: [new GraphQLApp(), new AdminUIApp(), new NuxtApp(config)],
};
```

### Config

A config object can be passed to the `NuxtApp` instance. Documentation for the `nuxtConfig` options is available on the [NuxtJS documentation website](https://nuxtjs.org/guide/configuration).
npm package: @keystone-next/app-schema-router-legacy
Description: KeystoneJS GraphQL App.
Author: The KeystoneJS Development Team
Latest version: 5.1.2

<!--[meta]
section: api
subSection: apps
title: GraphQL Schema Router
[meta]-->

# GraphQL Schema Router

[![View changelog](https://img.shields.io/badge/changelogs.xyz-Explore%20Changelog-brightgreen)](https://changelogs.xyz/@keystonejs/app-schema-router)

A KeystoneJS App that route requests to different GraphQL schemas.

The `SchemaRouterApp` allows you to define a `routerFn` which takes `(req, res)` and returns
a `routerId`, which is used to pick between different GraphQL schemas which exist at the same
`apiPath`.

## Usage

```javascript
const { Keystone } = require('@keystone-next/keystone-legacy');
const { GraphQLAppPlayground } = require('@keystone-next/app-graphql-playground-legacy');
const { SchemaRouterApp } = require('@keystone-next/app-schema-router-legacy');
const { GraphQLApp } = require('@keystone-next/app-graphql-legacy');
const { AdminUIApp } = require('@keystone-next/app-admin-ui-legacy');

module.exports = {
  keystone: new Keystone(),
  apps: [
    new GraphQLAppPlayground({ apiPath })
    new SchemaRouterApp({
      apiPath,
      routerFn: (req) => req.session.keystoneItemId ? 'private' : 'public',
      apps: {
        public: new GraphQLApp({ apiPath, schemaName: 'public', graphiqlPath: undefined }),
        private: new GraphQLApp({ apiPath, schemaName: 'private', graphiqlPath: undefined }),
      },
    }),
    new AdminUIApp()
  ],
};
```

## Config

| Option     | Type       | Default      | Description                                                    |
| ---------- | ---------- | ------------ | -------------------------------------------------------------- |
| `apiPath`  | `String`   | `/admin/api` | The GraphQL API path                                           |
| `routerFn` | `Function` | `() => {}`   | A function which takes `(req, res)` and returns a `routerId`   |
| `apps`     | `Object`   | `{}`         | An object with `routerId`s as keys and `GraphQLApp`s as values |
npm package: @keystone-next/app-static-legacy
Description: KeystoneJS Static File App.
Author: The KeystoneJS Development Team
Latest version: 5.1.5

<!--[meta]
section: api
subSection: apps
title: Static file app
[meta]-->

# Static file app

[![View changelog](https://img.shields.io/badge/changelogs.xyz-Explore%20Changelog-brightgreen)](https://changelogs.xyz/@keystonejs/app-static)

A KeystoneJS app to serve static files such as images, CSS and JavaScript with support for client side routing.

## Usage

```js title=index.js
const { Keystone } = require('@keystone-next/keystone-legacy');
const { GraphQLApp } = require('@keystone-next/app-graphql-legacy');
const { AdminUIApp } = require('@keystone-next/app-admin-ui-legacy');
const { StaticApp } = require('@keystone-next/app-static-legacy');

module.exports = {
  keystone: new Keystone(),
  apps: [
    new GraphQLApp(),
    new AdminUIApp(),
    new StaticApp({
      path: '/',
      src: 'public',
      fallback: 'index.html',
    }),
  ],
};
```

## Config

| Option     | Type     | Required | Description                                                                                       |
| ---------- | -------- | -------- | ------------------------------------------------------------------------------------------------- |
| `path`     | `string` | `true`   | The path to serve files from.                                                                     |
| `src`      | `string` | `true`   | The path to the folder containing static files.                                                   |
| `fallback` | `string` | `false`  | The path to the file to serve if none is found. This path is resolved relative to the `src` path. |
npm package: @keystone-next/app-version-legacy
Description: KeystoneJS App Version Plugin
Author: The KeystoneJS Development Team
Latest version: 2.0.1
Deprecated: Keystone Next has graduated to the @keystone-6 namespace; for more information see https://keystonejs.com/updates/general-availability

<!--[meta]
section: api
subSection: utilities
title: App version plugin
[meta]-->

# App version plugin

[![View changelog](https://img.shields.io/badge/changelogs.xyz-Explore%20Changelog-brightgreen)](https://changelogs.xyz/@keystonejs/app-version)

This package provides support for including a version string both as an HTTP response header and as a graphQL query.

The function `appVersionMiddleware(version)` will return a piece of middleware which will set the `X-Keystone-App-Version` response header to `version` on all HTTP requests.

The graphQL provider `AppVersionProvider` will add an `{ appVersion }` query to your graphQL API which returns `version` as a string.

## Usage

### Indirectly

This package is designed to be used indirectly via the conveniance API on the `Keystone` class:

```javascript
const keystone = new Keystone({
  appVersion: {
    version: '1.0.0',
    addVersionToHttpHeaders: true,
    access: true,
  },
});
```

### Directly

It can also be used directly if you would like to manually manage your middleware stack of graphQL providers.

```javascript
const { AppVersionProvider, appVersionMiddleware } = require('@keystone-next/app-version-legacy');

const version = '1.0.0';

app.use(appVersionMiddleware(version));

keystone._providers.push(
  new AppVersionProvider({
    version,
    access: true,
    schemaNames: ['public'],
  })
);
```
npm package: @keystone-next/auth
Description: Keystone-next is a preview release of the next version of Keystone. Please visit <https://keystonejs.com/> for full details.
Latest version: 37.0.0
Deprecated: Keystone Next has graduated to the @keystone-6 namespace; for more information see https://keystonejs.com/updates/general-availability

# @keystone-next/auth

Keystone-next is a preview release of the next version of Keystone. Please visit <https://keystonejs.com/> for full details.

For updates, [follow @keystonejs on Twitter](https://twitter.com/keystonejs) and [join us in Slack](https://community.keystonejs.com/).
npm package: @keystone-next/field-views-loader-legacy
Description: A webpack loader used to load all the field views used in an app
Author: The Keystone Development Team
Latest version: 6.0.3
Deprecated: Keystone Next has graduated to the @keystone-6 namespace; for more information see https://keystonejs.com/updates/general-availability

<!--[meta]
title: Field Views Loader
[meta]-->

# Field Views Loader

This packages contains a [webpack loader](https://webpack.js.org/api/loaders) which makes the field type UI components available to the Admin UI.

This package is an internal helper package used by Keystone. It contains a [webpack loader](https://webpack.js.org/api/loaders) which makes the field type UI components available to the Admin UI.

You should probably not use this directly in your Keystone projects.
npm package: @keystone-next/fields
Description: The exports of this package have been moved to `@keystone-next/keystone/fields`.
Latest version: 15.0.0
Deprecated: Keystone Next has graduated to the @keystone-6 namespace; for more information see https://keystonejs.com/updates/general-availability

# @keystone-next/fields

The exports of this package have been moved to `@keystone-next/keystone/fields`.

Keystone-next is a preview release of the next version of Keystone. Please visit <https://keystonejs.com/> for full details.

For updates, [follow @keystonejs on Twitter](https://twitter.com/keystonejs) and [join us in Slack](https://community.keystonejs.com/).
npm package: @keystone-next/fields-authed-relationship-legacy
Description: KeystoneJS AuthedRelationship Field Type
Author: The KeystoneJS Development Team
Latest version: 1.0.19

<!--[meta]
section: api
subSection: field-types
title: AuthedRelationship
[meta]-->

# AuthedRelationship

An extension on the `Relationship` field which is automatically set to the
currently authenticated item during a create mutation.

Great for setting fields like `Post.author` or `Product.owner`, etc.

## Usage

### Basic

```js
const { AuthedRelationship } = require('@keystone-next/fields-authed-relationship-legacy');
const { Text } = require('@keystone-next/fields-legacy');

keystone.createList('User', {
  fields: {
    name: { type: Text },
  },
});

keystone.createList('Post', {
  fields: {
    // Automatically set to the currently logged in user on create
    author: {
      type: AuthedRelationship,
      ref: 'User',
    },
  },
});
```

### Complete example

This example allows "admins" to overwrite the value

```js
const { AuthedRelationship } = require('@keystone-next/fields-authed-relationship-legacy');
const { Checkbox, Text } = require('@keystone-next/fields-legacy');

keystone.createList('User', {
  fields: {
    name: { type: Text },
    isAdmin: { type: Checkbox, default: false },
  },
});

const isAdmin = ({ authentication: { item } }) => !!item && item.isAdmin;

keystone.createList('Post', {
  fields: {
    author: {
      type: AuthedRelationship,
      ref: 'User',
      access: {
        create: isAdmin,
        update: isAdmin,
      },
    },
  },
});
```

### Config

| Option       | Type      | Default | Description                      |
| ------------ | --------- | ------- | -------------------------------- |
| `isRequired` | `Boolean` | `false` | Does this field require a value? |

## Differences from `Relationship`

- No `many: true`. This field is purely for a to-single relationship and cannot
  be used to refer to more than one item.
- Cannot specify a `defaultValue`. The entire purpose of this field is to
  provide that method for you.
- When setting `isRequired`, it will be checked during the "default value" phase
  of the mutation lifecycle. This means it may throw an error earlier than other
  fields
- Default access control set to `{ create: false, read: true, update: false }`
- Access control _does not_ respect any Keystone-level `defaultAccess`
npm package: @keystone-next/fields-cloudinary-image-legacy
Description: KeystoneJS Cloudinary Image Field Type
Author: The KeystoneJS Development Team
Latest version: 5.0.0
Deprecated: Keystone Next has graduated to the @keystone-6 namespace; for more information see https://keystonejs.com/updates/general-availability

<!--[meta]
section: api
subSection: field-types
title: CloudinaryImage
[meta]-->

# CloudinaryImage

The `CloudinaryImage` field extends the [`File`](/packages/fields/src/types/File/README.md) field and allows uploading images to Cloudinary. It also exposes additional GraphQL functionality for querying your uploaded images.

## Usage

This field must be used with the [`CoundinaryAdapter`](/packages/file-adapters/README.md#cloudinaryfileadapter) file adapter:

```js title=index.js
const { Keystone } = require('@keystone-next/keystone-legacy');
const { CloudinaryAdapter } = require('@keystone-next/file-adapters-legacy');
const { CloudinaryImage } = require('@keystone-next/fields-cloudinary-image-legacy');

const keystone = new Keystone({...});

const fileAdapter = new CloudinaryAdapter({
  cloudName: process.env.CLOUDINARY_CLOUD_NAME,
  apiKey: process.env.CLOUDINARY_KEY,
  apiSecret: process.env.CLOUDINARY_SECRET,
  folder: 'my-keystone-app',
});

keystone.createList('Image', {
  fields: {
    image: { type: CloudinaryImage, adapter: fileAdapter },
  },
});
```

## Config

Since this field extends the `File` field, it accepts all the same config options.

## GraphQL

Will add the following to the GraphQL schema:

```graphql
"""
Mirrors the formatting options [Cloudinary provides](https://cloudinary.com/documentation/image_transformation_reference).
All options are strings as they ultimately end up in a URL.
"""
input CloudinaryImageFormat {
  """
  Rewrites the filename to be this pretty string. Do not include \`/\` or \`.\`
  """
  prettyName: String
  width: String
  height: String
  crop: String
  aspect_ratio: String
  gravity: String
  zoom: String
  x: String
  y: String
  format: String
  fetch_format: String
  quality: String
  radius: String
  angle: String
  effect: String
  opacity: String
  border: String
  background: String
  overlay: String
  underlay: String
  default_image: String
  delay: String
  color: String
  color_space: String
  dpr: String
  page: String
  density: String
  flags: String
  transformation: String
}

type CloudinaryImage_File {
  id: ID
  path: String
  filename: String
  originalFilename: String
  mimetype: String
  encoding: String
  publicUrl: String
  publicUrlTransformed(transformation: CloudinaryImageFormat): String
}
```

`CloudinaryImage` fields will have type `CloudinaryImage_File` in the schema. For example, to query an entry in our `Image` list, one could do:

```graphql
query getFirstCloudinaryImage {
  allImages(first: 1) {
    image {
      filename
      publicUrlTransformed(transformation: { width: "120", crop: "limit" })
    }
  }
}
```
npm package: @keystone-next/fields-color-legacy
Description: KeystoneJS Color Field Type
Author: The KeystoneJS Development Team
Latest version: 1.1.0

<!--[meta]
section: api
subSection: field-types
title: Color
[meta]-->

# Color

Stores hexidecimal RGBA (Red, Green, Blue, Alpha) color values.
Presents in the Admin UI as an interactive color picker.

## Usage

```js
const { Color } = require('@keystone-next/fields-color-legacy');

keystone.createList('Product', {
  fields: {
    heroColor: { type: Color },
  },
});
```

## Config

| Option       | Type      | Default | Description                                                     |
| ------------ | --------- | ------- | --------------------------------------------------------------- |
| `isRequired` | `Boolean` | `false` | Does this field require a value?                                |
| `isUnique`   | `Boolean` | `false` | Adds a unique index that allows only unique values to be stored |
npm package: @keystone-next/fields-location-google-legacy
Description: KeystoneJS LocationGoogle field type.
Author: The KeystoneJS Development Team
Latest version: 3.3.4

<!--[meta]
section: api
subSection: field-types
title: LocationGoogle
[meta]-->

# LocationGoogle

The LocationGoogle Field Type enables storing data from the Google Maps API.

## Usage

```javascript
const { LocationGoogle } = require('@keystone-next/fields-location-google-legacy');
const { Keystone } = require('@keystone-next/keystone-legacy');

const keystone = new Keystone({...});

keystone.createList('Event', {
  fields: {
    venue: {
      type: LocationGoogle,
      googleMapsKey: 'GOOGLE_MAPS_KEY',
    },
  },
});
```

## GraphQL

```graphql
query {
  allEvents {
    venue {
      id
      googlePlaceID
      formattedAddress
      lat
      lng
    }
  }
}
```

Will yield:

```javascript
{
  "data": {
    "allEvents": [
      {
        "venue": {
          "id": "1",
          "googlePlaceID": "ChIJOza7MD-uEmsRrf4t12uji6Y",
          "formattedAddress": "10/191 Clarence St, Sydney NSW 2000, Australia",
          "lat": -33.869374,
          "lng": 151.205097
        }
      }
    ]
  }
}
```

### Mutations

To create a `Location`, pass the Google `place_id` for the desired field path.

```graphql
mutation {
  createEvent(data: { venue: "ChIJOza7MD-uEmsRrf4t12uji6Y" }) {
    venue {
      id
      googlePlaceID
      formattedAddress
      lat
      lng
    }
  }
}
```

Results in:

```javascript
{
  "createEvent": {
    "venue": {
      "id": "1",
      "googlePlaceID": "ChIJOza7MD-uEmsRrf4t12uji6Y",
      "formattedAddress": "10/191 Clarence St, Sydney NSW 2000, Australia",
      "lat": -33.869374,
      "lng": 151.205097
    }
  }
}
```
npm package: @keystone-next/fields-markdown-legacy
Description: KeystoneJS Markdown Field Type
Author: The KeystoneJS Development Team
Latest version: 5.3.0

<!--[meta]
section: api
subSection: field-types
title: Markdown
[meta]-->

# Markdown

This field inserts a string path into your schema based on the `Text` field type implementation, and renders a Markdown editor using [CodeMirror](https://codemirror.net/).

## Usage

This package isn't included with the keystone fields package and needs to be installed:

```shell allowCopy=false showLanguage=false
yarn add @keystone-next/fields-markdown-legacy
# or
npm install @keystone-next/fields-markdown-legacy
```

Then import it, and use it like any other field:

```js
const { Markdown } = require('@keystone-next/fields-markdown-legacy');

keystone.createList('Post', {
  fields: {
    content: {
      type: Markdown,
    },
  },
});
```

## Credit

The `Editor` implementation is based on [SquidDev/MirrorMark](https://github.com/SquidDev/MirrorMark).
npm package: @keystone-next/fields-wysiwyg-tinymce-legacy
Description: KeystoneJS WYSIWYG HTML Field Type, powered by TinyMCE
Author: The KeystoneJS Development Team
Latest version: 5.4.0

<!--[meta]
section: api
subSection: field-types
title: Wysiwyg
[meta]-->

# Wysiwyg

This field inserts a string path into your schema based on the `Text` field type implementation, and renders a WYSIWYG editor in the Admin UI using [TinyMCE](https://www.tiny.cloud/)

## Usage

This package isn't included with the keystone fields package and needs to be installed with `yarn add @keystone-next/fields-wysiwyg-tinymce-legacy` or `npm install @keystone-next/fields-wysiwyg-tinymce-legacy`

Then import it, and use it like any other field:

```js
const { Wysiwyg } = require('@keystone-next/fields-wysiwyg-tinymce-legacy');
```

## Config

### `editorConfig`

**Default:** `{}`

Accepts any [TinyMCE config options](https://www.tiny.cloud/docs/configure/). These will be passed to `tinymce.init` and can be used to override Keystone.js' default editor appearance and functionality.
npm package: @keystone-next/keystone
Description: Keystone-next is a preview release of the next version of Keystone. Please visit <https://keystonejs.com/> for full details.
Latest version: 29.0.0
Deprecated: Keystone Next has graduated to the @keystone-6 namespace; for more information see https://keystonejs.com/updates/general-availability

# @keystone-next/keystone

Keystone-next is a preview release of the next version of Keystone. Please visit <https://keystonejs.com/> for full details.

For updates, [follow @keystonejs on Twitter](https://twitter.com/keystonejs) and [join us in Slack](https://community.keystonejs.com/).
npm package: @keystone-next/session-store-redis
Description: Keystone-next is a preview release of the next version of Keystone. Please visit <https://keystonejs.com/> for full details.
Latest version: 9.0.0
Deprecated: Keystone Next has graduated to the @keystone-6 namespace; for more information see https://keystonejs.com/updates/general-availability

# @keystone-next/session-store-redis

Keystone-next is a preview release of the next version of Keystone. Please visit <https://keystonejs.com/> for full details.

For updates, [follow @keystonejs on Twitter](https://twitter.com/keystonejs) and [join us in Slack](https://community.keystonejs.com/).
npm package: @keystone-next/test-utils-legacy
Description: Common utilities used while testing @keystonejs/* packages.
Author: The KeystoneJS Development Team
Latest version: 21.0.0

<!--[meta]
section: api
subSection: utilities
title: Test utils
[meta]-->

# Test utils

This package is an internal KeystoneJS package which contains utility functions to assist in running tests against the GraphQL API.

## Installation

```shell
yarn add @keystone-next/test-utils-legacy
```

<!--- TODO: The contents of this file should be generated by JSDoc --->
npm package: @keystone-next/testing
Description: Tools to assist with testing Keystone projects
Author: The KeystoneJS Development Team
Latest version: 2.0.0
Deprecated: Keystone Next has graduated to the @keystone-6 namespace; for more information see https://keystonejs.com/updates/general-availability

# Testing

This exports of this package have been moved to `@keystone-next/keystone`
npm package: @keystone-next/types
Description: The exports of this package have been moved to `@keystone-next/keystone/types`.
Latest version: 25.0.0
Deprecated: Keystone Next has graduated to the @keystone-6 namespace; for more information see https://keystonejs.com/updates/general-availability

# @keystone-next/types

The exports of this package have been moved to `@keystone-next/keystone/types`.

Keystone-next is a preview release of the next version of Keystone. Please visit <https://keystonejs.com/> for full details.

For updates, [follow @keystonejs on Twitter](https://twitter.com/keystonejs) and [join us in Slack](https://community.keystonejs.com/).
npm package: @keystone-next/utils
Description: Common utility functions used throughout @keystone-next packages.
Author: The KeystoneJS Development Team
Latest version: 2.0.0
Deprecated: Keystone Next has graduated to the @keystone-6 namespace; for more information see https://keystonejs.com/updates/general-availability

<!--[meta]
title: Utilities
[meta]-->

# Utilities

This package is an internal Keystone package which contains various helper functions which are used throughout the monorepo.

You should probably not use this directly in your Keystone projects.
npm package: @keystone-next/utils-legacy
Description: Common utility functions used throughout @keystonejs packages.
Author: The KeystoneJS Development Team
Latest version: 12.0.0
Deprecated: Keystone Next has graduated to the @keystone-6 namespace; for more information see https://keystonejs.com/updates/general-availability

<!--[meta]
title: Utilities
[meta]-->

# Utilities

This package is an internal Keystone package which contains various helper functions which are used throughout the monorepo.

You should probably not use this directly in your Keystone projects.
npm package: @keystone-os/sdk
Description: SDK for Keystone Mini-Apps — 21 hooks including useVault, usePortfolio, useJupiterSwap, useTheme, useNotification, useStorage
Latest version: 0.3.0

# @keystone-os/sdk

**Sovereign OS 2026** — Policy-as-Code and Agentic Interoperability SDK for Keystone Studio Mini-Apps.

## Install

```bash
npm install @keystone-os/sdk react
```

## Usage

```tsx
import { useVault, useFetch, useSIWS, useImpactReport } from '@keystone-os/sdk';

export default function App() {
  const { tokens } = useVault();
  const { signIn, session } = useSIWS();
  const { simulate } = useImpactReport();

  return (
    <div>
      {tokens.map((t) => (
        <div key={t.symbol}>{t.symbol}: {t.balance}</div>
      ))}
    </div>
  );
}
```

## Core API

- **useVault()** — Vault state (balances, tokens)
- **useTurnkey()** — `getPublicKey()`, `signTransaction()` (routes through host)
- **useFetch(url, options?)** — Proxy-gated fetch; optional `observability: { provider: 'langfuse' }`
- **AppEventBus.emit(type, payload?)** — Emit events to host

## Sovereign OS 2026 Hooks

| Category | Hook | Description |
|----------|------|-------------|
| **Identity** | `useSIWS()` | Sign-In With Solana, session persistence |
| **Finance** | `useJupiterSwap()` | Jupiter routing, quotes |
| **Compliance** | `useACEReport()` | ACE regulatory reporting |
| **Reporting** | `useTaxForensics()` | Tax basis, gain/loss |
| **Simulation** | `useImpactReport()` | Before/After treasury snapshots |
| **Security** | `useEncryptedSecret()` | Lit Protocol wallet-based secrets |
| **Agentic** | `useAgentHandoff()`, `useMCPClient()`, `useMCPServer()` | Federated handoff, MCP |
| **DX** | `useYieldOptimizer()`, `useGaslessTx()` | Earn stack, gasless hub |
| **Utils** | `toBlink()`, `verifyZKSP()` | Blinks export, ZK simulation proofs |

## Bridge

Mini-Apps run in a sandboxed iframe. The host injects `keystoneBridge` before your code runs. For local testing, use `setBridge(mockBridge)`.

## Glass Safety Standard

- No blind signing — `signTransaction` routes through host Simulation Firewall
- No direct `fetch` — use `useFetch` (Proxy Gate)
- No `localStorage` / `eval` — sandbox blocks these
npm package: @keystonehq/alias-sampling
Description: A Node.js module for efficient sampling from a discrete probability distribution using the alias method.
Latest version: 0.1.2

# Alias Method for Sampling

A JavaScript library for efficient sampling of random values from a discrete probability distribution using the Walker-Vose alias method, provided by KeystoneHQ.

## Installation

Install the library using yarn:

```shell
yarn add @keystonehq/alias-sampling
```

Or npm:

```shell
npm install @keystonehq/alias-sampling
```

## Usage

To use the library, first import the `sample` function and then create a sampler with a given probability distribution and optionally an array of outcomes. You can then generate random samples using the `.next()` method.

### Basic Usage

```javascript
import sample from '@keystonehq/alias-sampling';

// Create a sampler with specified probabilities and outcomes
var s = sample([0.5, 0.25, 0.25], ['A', 'B', 'C']);

// Generate a single random outcome
console.log(s.next()); // => 'A', 'B', or 'C' according to specified probabilities
```

### Generating Multiple Samples

```javascript
import sample from '@keystonehq/alias-sampling';

// Create a sampler with specified probabilities
var s = sample([0.5, 0.25, 0.25], [10, 20, 30]);

// Generate multiple random samples
console.log(s.next(1000)); // => an array of 1000 random samples
```

### Sampling Indices

```javascript
import sample from '@keystonehq/alias-sampling';

// Create a sampler without specifying outcomes (defaults to indices)
var s = sample([0.5, 0.25, 0.25]);

// Generate a single random index
console.log(s.next()); // => 0, 1, or 2 with the specified probabilities
```

### Using a Custom Random Generator

```javascript
import sample from '@keystonehq/alias-sampling';

// Custom random generator function
var rand = Math.random;

// Create a sampler with specified probabilities and custom random generator
var s = sample([0.5, 0.25, 0.25], null, rand);

// Generate a random index using the custom random generator
console.log(s.next()); // => 0, 1, or 2 with the specified probabilities
```
npm package: @keystonehq/animated-qr
Description: animated qr code and scanner
Author: LiYanLance
Latest version: 0.10.0

# `animated-qr`

This package is the keystone implementation of AnimatedQRCode and AnimatedQRScanner 

## Install

```bash
yarn add @keystonehq/animated-qr
```

```bash
npm install --save @keystonehq/animated-qr
```


## Usage

### QR Code

#### Component

```jsx
import { AnimatedQRCode } from '@keystonehq/animated-qr';

const ContainerView = () => {
  return (
    <AnimatedQRCode cbor="01234567" type="bytes" />
  )
}
```

#### Hook

```jsx
import { useAnimatedQRCode } from '@keystonehq/animated-qr';

const ContainerView = () => {
  const currentQRCode = useAnimatedQRCode({ cbor, type })
  return (
    <MyOwnQRCode data="currentQRCode" />
  )
}
```


### QR Scanner

#### Important

Please check camera permission before rendering this Component.

#### Component

```jsx
import { AnimatedQRScanner, Purpose } from '@keystonehq/animated-qr';

const ContainerView = () => {
  const handleScan= useCallback(({type: string, cbor: string}) => {
    console.log("onScanSuccess", cbor)
  }, [])

  const handleError= useCallback((error: string) => {
    console.log("onScanError", error)
  }, [])


  return (
    <AnimatedQRScanner
      purpose={Purpose.SYNC}
      handleScan={handleScan}
      handleError={handleError} 
      options={{
        width: 300
      }}
    />
  )
}
```

#### Hook

```jsx
import { useAnimatedQRScanner, Purpose } from '@keystonehq/animated-qr';

const ContainerView = () => {
  const handleScan= useCallback(({type: string, cbor: string}) => {
    console.log("onScanSuccess", ur)
  }, [])

  const handleError= useCallback((error: string) => {
    console.log("onScanError", error)
  }, [])
  
  const { AnimatedQRScanner } = useAnimatedQRScanner({
    Scanner: MyOwnQRScanner, // Optional, using Keystone BaseQRScanner by default,
    scannerProps: { myOwnQRScannerPropsKey: "value" } // Optional
  })

  return (
    <AnimatedQRScanner
      purpose={Purpose.SYNC}
      handleScan={handleScan}
      handleError={handleError} 
    />
  )
}
```


Error List
- QR Code
  - UNEXPECTED_QRCODE
  - INVALID_QR_CODE
npm package: @keystonehq/base-eth-keyring
Description: base eth keyring
Author: aaronisme
Latest version: 0.15.1

# `base-eth-keyring`

This package is the base module of Keystone implementations of `MetaMaskKeyring`, you can import this module and extend your own Keystone compatible keyring.

This package uses [bc-ur-registry-eth](https://github.com/KeystoneHQ/keystone-airgaped-base/tree/master/packages/ur-registry-eth) to struct QR code payload. 

Please check out [eth-keyring](https://github.com/KeystoneHQ/keystone-airgaped-base/tree/master/packages/eth-keyring) and [metamask-airgapped-keyring](https://github.com/KeystoneHQ/keystone-airgaped-base/tree/master/packages/metamask-airgapped-keyring) if you wanna an example.

## Install

```bash
yarn add @keystonehq/base-eth-keyring
```

```bash
npm install --save @keystonehq/base-eth-keyring
```


## Usage

```
import { BaseKeyring } from '@keystonehq/base-eth-keyring';

export class YouOwnKeyring extends BaseKeyring {}
```