open-index/open-npm huggingface dataset:
npm package: @keystonehq/metamask-airgapped-keyring
Description: airgapped eth keyring for metamask
Author: aaronisme
Latest version: 0.15.2

# `metamask-airgapped-keyring`

## This package is still Working in Progress.

This package is the Keystone implementation of `MetaMaskKeyring` which used in MetaMask Extension.

## Install

```bash
yarn add @keystonehq/metamask-airgapped-keyring
```

```base
npm install --save @keystonehq/metamask-airgapped-keyring
```
npm package: @keystonehq/qr-protocol
Description: QRCode Protocol
Latest version: 0.18.2

# `keystone-qr-protocol`

This package is definition of QR code payload structure used in Keystone App.
Also provides encoding/decoding methods to that.

## Install

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

```base
npm install --save @keystonehq/qr-protocol
```
npm package: @keystonehq/react-native-keystone-wallet-core
Description: React Native wrapper for Keystone Wallet Core Rust library
Author: Your Name
Latest version: 0.1.5

# react-native-pczt

React Native wrapper for PCZT Rust library.

## Installation

```sh
npm install react-native-pczt
```

## Usage

```js
import { createTransparentPczt } from "react-native-pczt";

// ...

const result = await createTransparentPczt(
  [
    {
      txid: "...",
      vout: 0,
      amount: 1000,
      address: "...",
      seedFingerprint: "...",
      derivationPath: [44, 0, 0, 0, 0],
      publicKey: "...",
    },
  ],
  [
    {
      address: "...",
      amount: 900,
    },
  ],
  800000
);
```

## iOS Setup

The package includes a vendored XCFramework. No extra setup should be required other than `pod install`.

## Android Setup

Not yet implemented.
npm package: @keystonejs-contrib-next/fields-bigint
Description: <!--[meta] section: api subSection: field-types title: bigInt [meta]-->
Latest version: 0.1.2

<!--[meta]
section: api
subSection: field-types
title: bigInt
[meta]-->

# BigInt

A bigInt field represents an bigint value, that represented in GraphQL as string.

## Usage

This package isn't included with the keystone fields package and needs to be installed with `yarn add @keystonejs-contrib-next/fields-bigint` or `npm install @keystonejs-contrib-next/fields-bigint`

Then import it, and use it like any other field:

```js
const { bigInt } = require('@keystonejs/fields-bigint');
```
npm package: @keystonejs-contrib-next/fields-file
Description: File field for the new interface KeystoneJs
Author: The KeystoneJS Contrib Development Team
Latest version: 1.0.2

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

# File Field

Support files hosted in a range of different contexts, e.g. in the local filesystem, or on a cloud based file server using s3 adapter.

## Usage

```ts
import { file } from '@keystonejs-contrib-next/fields-file';
import { LocalFileAdapter, S3Adapter } from '@keystone-next/file-adapters-legacy';

const fileAdapter = new LocalFileAdapter({
  /*...config */
});

const s3Options = {
  accessKeyId: process.env.S3_ACCESS_KEY_ID,
  secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
  endpoint: process.env.S3_ENDPOINT,
  region: 'REGION',
};

const s3Adapter = new S3Adapter({
  bucket: process.env.S3_BUCKET,
  folder: process.env.S3_PATH,
  // this for digitalocean - see s3 config for aws and other s3 compatible providers
  publicUrl: ({ id, filename, _meta }) =>
    `${process.env.S3_CDN_URL}/${process.env.S3_PATH}/${filename}`,
  s3Options,
  // based on need to make url public or not
  uploadParams: ({ filename, id, mimetype, encoding }) => ({
    ACL: 'public-read',
    Metadata: {
      keystone_id: `${id}`,
    },
  }),
});

const User = list(
  withAtTracking({
    ui: {
      /*... */
    },
    fields: {
      file: {
        type: File,
        adapter: fileAdapter, // or s3Adapter
        isRequired: true,
      },
    },
    /*... */
  })
);
```

### Config

| Option       | Type      | Default  | Description                                                                             |
| ------------ | --------- | -------- | --------------------------------------------------------------------------------------- |
| `adapter`    | `Object`  | Required | See the [File Adapters](/packages/file-adapters/README.md) page for available adapters. |
| `isRequired` | `Boolean` | `false`  | Does this field require a value?                                                        |
npm package: @keystonejs-contrib/app-express
Description: Provides functionality similar to Keystone 4 views.
Author: The KeystoneJS-Contrib Community Development Team
Latest version: 0.2.1

---
section: packages
title: Express App
---

# Express App

This package helps create custom middleware using express config

## initialize

#### Constructor
```js
new ExpressApp({
  app = express(),
  ...expressOptions
}, configureExpress = app => {})
```

**Paremeters**
* `app`: used for providing custom express instance.  
* `expressOptions`: all those things can be set using `app.set(key, value)`  
* `configureExpress`: function argument which will be called similar to `configureExpress` method.
>`expressOptions` can be skipped altogether and only `configureExpress` may be used

##### example:

```js
const customApp = new ExpressApp({
    views: './templates',
    'view engine': 'pug',
  },
  app => {
    app.use(bodyParser.urlencoded({ extended: true }));
    someOtherMethod(keystone, app);
  }
);

// OR when skipping expressOptions

new ExpressApp(app => {
  app.set(...);
  app.use(...);
  app.get(...);
  app.post(...);
})
```


#### Methods

##### configureExpress(fn)

useful for configuring the express instance for more settings.

```js
const customApp = new ExpressApp({....config});
customApp.configureExpress(app => {
  app.use(....);
  someOthermethod(app);
})
```


##### use(middleware)

proxy for `app.use` method for express instance wrapped inside

```js
const customApp = new ExpressApp({....config});
customApp.use(bodyParser());
```

##### set(key, value)

proxy for `app.set` method for express instance wrapped inside

```js
const customApp = new ExpressApp({....config});
customApp.set('my option', 'my value');
```
npm package: @keystonejs-contrib/fields-ckeditor
Description: KeystoneJS CKEditor field type
Latest version: 1.0.1

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

# KeystoneJS CKEditor field

This field inserts a string path into your schema based on the `Text` field type implementation, and renders a [CKEditor5](https://ckeditor.com/ckeditor-5/) editor in the Admin UI.

## Usage

This package isn't included with the keystone fields package and needs to be installed with `yarn add @keystonejs-contrib/fields-ckeditor` or `npm install @keystonejs-contrib/fields-ckeditor`

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

```js
const { CKEditor } = require('@keystonejs/fields-ckeditor');
```
npm package: @keystonejs-contrib/fields-editorjs
Description: KeystoneJS EditorJS Block Editor Field Type, powered by EditorJs
Author: The KeystoneJS-Contrib Development Team
Latest version: 0.1.1

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

# EditorJS

This field inserts a string path into your schema based on the `Text` field type implementation, and renders a Block based editor in the Admin UI powered by [EditorJS](https://editorjs.io/)

## Usage

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

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

```js
const { EditorJs } = require('@keystonejs/fields-editorjs');
```

## Config

### `editorConfig`

**Default:** `{}`

**TODO**
- [ ] tools configuration needs to be passed on to editorjs instance.
- [ ] image upload backend and adapter
npm package: @keystonejs-contrib/list-plugins
Description: List level plugins which can update list config during list initialization including adding additional fields
Author: KeystoneJS-Contrib Community Development Team
Latest version: 1.0.0

# Contrib List Plugins

# simpleListConfig

helps make list config cleaner compared to default KeystoneJs way.

## Usage

```js
const {
  simpleListConfig,
  required,
  unique,
  indexed,
  readonly,
  multiline,
} = require('@keystonejs-contrib/list-plugins');
// values for required, unique, indexed, readonly, multiline all are true
keystone.createList('ListWithPlugin', {
  fields: {
    type: FieldType,
    required, // isRequired
    unique, // isUnique
    indexed, // isIndexed
    readonly, // adminConfig: { isReadOnly }
    multiline, // isMultiline
    default: 'text\nvalue', // defaultValue
  },
  plugins: [
    simpleListConfig(), // function to make it easier to add plugin config later
  ],
});
```
npm package: @keystonejs-contrib/view
Description: Provides functionality similar to Keystone 4 views.
Author: The KeystoneJS-Contrib Community Development Team
Latest version: 2.0.0

---
section: packages
title: View
---

# View

This package contains functions to assist with view management in your Keystone system. This feature is ported from Keystone v4

## Initialize

Initialize View support by setting ExpressJs view engine options, you have to add respective view engine package in packages.json. You must use [Custom Server](https://v5.keystonejs.com/discussions/custom-server) config.

```js
//... keystone.prepare(....).then( ({middlewares}) => {
  const app = express();
  app.use(middlewares);
  app.use(bodyParser.urlencoded({ extended: true }));
  app.set('views', './templates');
  app.set('view engine', 'pug');
//})
```

you need to create `templates` folder in root of the project where you keep all the view templates

## Query

Create Routes to use `View`, `View` constructor needs instance of `Keystone` and `express app`.
For details check out the `demo-projects/blog-view` project.

```js
module.exports = (keystone, app) => {
  app.use('/', async (req, res) => {
    const locals = res.locals || {};
    const view = new View(keystone, req, res);
    view.query(
      'posts',
      `{ 
          allPosts {
            title
            id
            body
            posted
            image {
              publicUrl
              filename
            }
            author {
              name
            }
          }
      }`
    );

    view.render('views/home', locals);
  });
};
```

Initialize this route after `keystone.prepare`

```js
const homeRoute = require('../routes/view/home');
homeRoute(keystone, app);
```

> if there are multiple objects returned in GraphQl queries then both of them are attached to the `path` parameter in `view.query`

## Mutation

you can run mutation queries with `view.query`

## HTTP methods support in View

Similar to v4, View support `view.on` conditionals based on HTTP methods, for example you can process for post when specific field is having specific value, usually the case when you have multiple forms on page and yo want to handle them selectively.

> Improved in v5, any query you add inside `view.on` will get executed before any other queries, giving you single page refresh to accomplish result refresh after form post.

```js
view.on('post', { action: 'new-post' }, async () => {
  // in the form you have to have a hidden field like this :
  // input(type='hidden', name='action', value='new-post')
  const { title, body, admin } = req.body;
  const input = { title, body, author: { connect: { id: admin } } };
  view
    .query(
      'created',
      `mutation createPost($input: PostCreateInput){
        createPost(data: $input) {id}
      }`,
      { variables: { input } }
    )
    .err(err => {
      console.log(err);
      locals.err = err;
    });
});
```
npm package: @keystonejs/access-control
Description: KeystoneJS Access Control parsing and validating utilities.
Author: The KeystoneJS Development Team
Latest version: 7.1.2

<!--[meta]
title: Access Control
[meta]-->

# Access Control

> This is the last active development release of this package as **Keystone 5** is now in a 6 to 12 month active maintenance phase. For more information please read our [Keystone 5 and beyond](https://github.com/keystonejs/keystone-5/issues/21) post.

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

This package is an internal helper package used by Keystone to parse and validate access control expressions.

You should probably not use this directly in your Keystone projects.

For more information on how to configure access control for you Keystone application, please consult the [Access Control Guide](/docs/guides/access-control.md).
npm package: @keystonejs/adapter-knex
Description: KeystoneJS Knex Database Adapter
Author: The KeystoneJS Development Team
Latest version: 13.3.2

<!--[meta]
section: api
subSection: database-adapters
title: Knex adapter
[meta]-->

# Knex database adapter

> This is the last active development release of this package as **Keystone 5** is now in a 6 to 12 month active maintenance phase. For more information please read our [Keystone 5 and beyond](https://github.com/keystonejs/keystone-5/issues/21) post.

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

The [Knex](https://knexjs.org/#changelog) adapter is a general purpose adapter which can be used to connect to a range of different database backends.
At present, the only fully tested backend is `Postgres`, however Knex gives the potential for `MSSQL`, `MySQL`, `MariaDB`, `SQLite3`, `Oracle`, and `Amazon Redshift` to be supported.

## Usage

```javascript
const { KnexAdapter } = require('@keystonejs/adapter-knex');

const keystone = new Keystone({
  adapter: new KnexAdapter({...}),
});
```

## Config

### `schemaName`

_**Default:**_ `'public'`

All postgres tables are grouped within a schema and `public` is the default schema.

### `dropDatabase`

_**Default:**_ `false`

Allow the adapter to drop the entire database and recreate the tables / foreign keys based on the list schema in your application. This option is ignored in production, i.e. when the environment variable NODE_ENV === 'production'.

### `knexOptions`

These options are passed directly through to Knex.

See the [knex docs](https://knexjs.org/#Installation-client) for more details.

_**Default:**_

```javascript
{
  client: 'postgres',
  connection: process.env.CONNECT_TO || process.env.DATABASE_URL || process.env.KNEX_URI
}
```

## Debugging

To log all Knex queries, run the server with the environment variable `DEBUG=knex:query`.

## Setup

Before running Keystone with the Knex adapter you should configure a database. By default Knex will look for a Postgres database on the default port, matching the project name, as the current user.

In most cases this database will not exist and you will want to configure a user and database for your application.

Assuming you're on MacOS and have Postgres installed the `build-test-db.sh` does this for you:

```shell
./build-test-db.sh
```

Otherwise, you can run these steps manually:

```shell allowCopy=false showLanguage=false
createdb -U postgres keystone
psql keystone -U postgres -c "CREATE USER keystone5 PASSWORD 'change_me_plz'"
psql keystone -U postgres -c "GRANT ALL ON DATABASE keystone TO keystone5;"
```

If using the above, you will want to set a connection string of: `postgres://keystone5:change_me_plz@localhost:5432/keystone`
npm package: @keystonejs/adapter-mongoose
Description: KeystoneJS Mongoose Database adapter.
Author: The KeystoneJS Development Team
Latest version: 11.2.2

<!--[meta]
section: api
subSection: database-adapters
title: Mongoose adapter
[meta]-->

# Mongoose database adapter

> This is the last active development release of this package as **Keystone 5** is now in a 6 to 12 month active maintenance phase. For more information please read our [Keystone 5 and beyond](https://github.com/keystonejs/keystone-5/issues/21) post.

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

## Usage

```javascript
const { MongooseAdapter } = require('@keystonejs/adapter-mongoose');

const keystone = new Keystone({
  adapter: new MongooseAdapter({...}),
});
```

## Config

### `mongoUri` (required)

This is used as the `uri` parameter for `mongoose.connect()`.

_**Default:**_ Environment variable (see below) or `'mongodb://localhost/<DATABASE_NAME>'`

If not specified, KeystoneJS will look for one of the following environment variables:

- `CONNECT_TO`
- `DATABASE_URL`
- `MONGO_URI`
- `MONGODB_URI`
- `MONGO_URL`
- `MONGODB_URL`
- `MONGOLAB_URI`
- `MONGOLAB_URL`

### Mongoose options (optional)

Additional Mongoose config options are passed directly through to `mongoose.connect()`.

_**Default:**_

```javascript
{
  useNewUrlParser: true,
  useFindAndModify: false,
  useUnifiedTopology: true,
}
```

See the [Mongoose docs](https://mongoosejs.com/docs/api.html#mongoose_Mongoose-connect) for a detailed list of options.
npm package: @keystonejs/app-graphql
Description: KeystoneJS GraphQL App.
Author: The KeystoneJS Development Team
Latest version: 6.3.3

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

# GraphQL app

> This is the last active development release of this package as **Keystone 5** is now in a 6 to 12 month active maintenance phase. For more information please read our [Keystone 5 and beyond](https://github.com/keystonejs/keystone-5/issues/21) post.

[![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('@keystonejs/keystone');
const { GraphQLApp } = require('@keystonejs/app-graphql');
const { AdminUIApp } = require('@keystonejs/app-admin-ui');

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

## Config

| Option         | Type     | Default           | Description                                      |
| -------------- | -------- | ----------------- | ------------------------------------------------ |
| `apiPath`      | `String` | `/admin/api`      | Change the API path                              |
| `graphiqlPath` | `String` | `/admin/graphiql` | Change the GraphiQL playground 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: @keystonejs/app-graphql-playground
Description: KeystoneJS GraphQL Playground App.
Author: The KeystoneJS Development Team
Latest version: 5.2.3

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

# GraphQL Playground App

> This is the last active development release of this package as **Keystone 5** is now in a 6 to 12 month active maintenance phase. For more information please read our [Keystone 5 and beyond](https://github.com/keystonejs/keystone-5/issues/21) post.

[![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('@keystonejs/keystone');
const { GraphQLApp } = require('@keystonejs/app-graphql');
const { GraphQLPlaygroundApp } = require('@keystonejs/app-graphql-playground');
const { AdminUIApp } = require('@keystonejs/app-admin-ui');

// 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: @keystonejs/app-next
Description: KeystoneJS Next.js App.
Author: The KeystoneJS Development Team
Latest version: 6.1.2

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

# Next.js app

> This is the last active development release of this package as **Keystone 5** is now in a 6 to 12 month active maintenance phase. For more information please read our [Keystone 5 and beyond](https://github.com/keystonejs/keystone-5/issues/21) post.

[![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('@keystonejs/app-next');

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: @keystonejs/app-nuxt
Description: KeystoneJS Nuxt.js App.
Author: The KeystoneJS Development Team
Latest version: 5.2.3

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

# Nuxt.js app

> This is the last active development release of this package as **Keystone 5** is now in a 6 to 12 month active maintenance phase. For more information please read our [Keystone 5 and beyond](https://github.com/keystonejs/keystone-5/issues/21) post.

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

## Usage

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

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: @keystonejs/app-schema-router
Description: KeystoneJS GraphQL App.
Author: The KeystoneJS Development Team
Latest version: 5.2.3

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

# GraphQL Schema Router

> This is the last active development release of this package as **Keystone 5** is now in a 6 to 12 month active maintenance phase. For more information please read our [Keystone 5 and beyond](https://github.com/keystonejs/keystone-5/issues/21) post.

[![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('@keystonejs/keystone');
const { GraphQLAppPlayground } = require('@keystonejs/app-graphql-playground');
const { SchemaRouterApp } = require('@keystonejs/app-schema-router');
const { GraphQLApp } = require('@keystonejs/app-graphql');
const { AdminUIApp } = require('@keystonejs/app-admin-ui');

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: @keystonejs/app-static
Description: KeystoneJS Static File App.
Author: The KeystoneJS Development Team
Latest version: 5.2.3

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

# Static file app

> This is the last active development release of this package as **Keystone 5** is now in a 6 to 12 month active maintenance phase. For more information please read our [Keystone 5 and beyond](https://github.com/keystonejs/keystone-5/issues/21) post.

[![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('@keystonejs/keystone');
const { GraphQLApp } = require('@keystonejs/app-graphql');
const { AdminUIApp } = require('@keystonejs/app-admin-ui');
const { StaticApp } = require('@keystonejs/app-static');

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: @keystonejs/app-version
Description: KeystoneJS App Version Plugin
Author: The KeystoneJS Development Team
Latest version: 2.1.2

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

# App version plugin

> This is the last active development release of this package as **Keystone 5** is now in a 6 to 12 month active maintenance phase. For more information please read our [Keystone 5 and beyond](https://github.com/keystonejs/keystone-5/issues/21) post.

[![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('@keystonejs/app-version');

const version = '1.0.0';

app.use(appVersionMiddleware(version));

keystone._providers.push(
  new AppVersionProvider({
    version,
    access: true,
    schemaNames: ['public'],
  })
);
```
npm package: @keystonejs/field-views-loader
Description: A webpack loader used to load all the field views used in an app
Author: The Keystone Development Team
Latest version: 6.1.2

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

# Field Views Loader

> This is the last active development release of this package as **Keystone 5** is now in a 6 to 12 month active maintenance phase. For more information please read our [Keystone 5 and beyond](https://github.com/keystonejs/keystone-5/issues/21) post.

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: @keystonejs/fields-authed-relationship
Description: KeystoneJS AuthedRelationship Field Type
Author: The KeystoneJS Development Team
Latest version: 1.1.2

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

# AuthedRelationship

> This is the last active development release of this package as **Keystone 5** is now in a 6 to 12 month active maintenance phase. For more information please read our [Keystone 5 and beyond](https://github.com/keystonejs/keystone-5/issues/21) post.

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('@keystonejs/fields-authed-relationship');
const { Text } = require('@keystonejs/fields');

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('@keystonejs/fields-authed-relationship');
const { Checkbox, Text } = require('@keystonejs/fields');

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: @keystonejs/fields-color
Description: KeystoneJS Color Field Type
Author: The KeystoneJS Development Team
Latest version: 1.1.2

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

# Color

> This is the last active development release of this package as **Keystone 5** is now in a 6 to 12 month active maintenance phase. For more information please read our [Keystone 5 and beyond](https://github.com/keystonejs/keystone-5/issues/21) post.

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

## Usage

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

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: @keystonejs/fields-location-google
Description: KeystoneJS LocationGoogle field type.
Author: The KeystoneJS Development Team
Latest version: 3.4.2

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

# LocationGoogle

> This is the last active development release of this package as **Keystone 5** is now in a 6 to 12 month active maintenance phase. For more information please read our [Keystone 5 and beyond](https://github.com/keystonejs/keystone-5/issues/21) post.

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

## Usage

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

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: @keystonejs/fields-markdown
Description: KeystoneJS Markdown Field Type
Author: The KeystoneJS Development Team
Latest version: 5.3.2

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

# Markdown

> This is the last active development release of this package as **Keystone 5** is now in a 6 to 12 month active maintenance phase. For more information please read our [Keystone 5 and beyond](https://github.com/keystonejs/keystone-5/issues/21) post.

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 @keystonejs/fields-markdown
# or
npm install @keystonejs/fields-markdown
```

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

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

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

## Credit

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

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

# Wysiwyg

> This is the last active development release of this package as **Keystone 5** is now in a 6 to 12 month active maintenance phase. For more information please read our [Keystone 5 and beyond](https://github.com/keystonejs/keystone-5/issues/21) post.

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 @keystonejs/fields-wysiwyg-tinymce` or `npm install @keystonejs/fields-wysiwyg-tinymce`

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

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

## 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: @keystonejs/logger
Description: Common logging functionality used within @keystonejs/* packages.
Author: The KeystoneJS Development Team
Latest version: 6.0.0

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

# Logger

**Deprecation notice** This module is no longer maintained. Please directly use `pino` or the logging library of your choice.

## API

### `require('@keystonejs/logger').logger(name)`

Provides an instance of [`pino`](https://github.com/pinojs/pino) based on the given `name`.

Instances are cached and re-used, making it safe to request the same named instance across multiple files.

### `process.env.DISABLE_LOGGING`

When set to any "truthy" value, will prevent any log output from occurring (particularly useful during test runs).
npm package: @keystonejs/session
Description: Tools to assist with setting up session management in your Keystone system.
Author: The KeystoneJS Development Team
Latest version: 8.3.2

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

# Session

> This is the last active development release of this package as **Keystone 5** is now in a 6 to 12 month active maintenance phase. For more information please read our [Keystone 5 and beyond](https://github.com/keystonejs/keystone-5/issues/21) post.

<!-- TODO -->

This package contains functions to assist with setting up session management in your KeystoneJS system.
npm package: @keystonejs/test-utils
Description: Common utilities used while testing @keystonejs/* packages.
Author: The KeystoneJS Development Team
Latest version: 13.1.2

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

# Test utils

> This is the last active development release of this package as **Keystone 5** is now in a 6 to 12 month active maintenance phase. For more information please read our [Keystone 5 and beyond](https://github.com/keystonejs/keystone-5/issues/21) post.

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

## Installation

```shell
yarn add @keystonejs/test-utils
```

<!--- TODO: The contents of this file should be generated by JSDoc --->
npm package: @keystonejs/utils
Description: Common utility functions used throughout @keystonejs packages.
Author: The KeystoneJS Development Team
Latest version: 6.1.2

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

# Utilities

> This is the last active development release of this package as **Keystone 5** is now in a 6 to 12 month active maintenance phase. For more information please read our [Keystone 5 and beyond](https://github.com/keystonejs/keystone-5/issues/21) post.

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: @keystore/lib
Description: keystore lib
Author: fay
Latest version: 0.0.1-alpha.28

# keystore lib
#### 工具库

# Usage
`npm i @keystore/lib`

### 生成npm可引用文件

`npm run pub:export`

# fetch
```javascript
import {get, put, post, remove, getJson, putJson, postJson, removeJson} from '@keystore/lib/fetch';
get({path, data});
put({path, data, contentType, defaultQuery});
post({path, data, contentType});
remove({path, data, contentType});
```
* getJson, putJson, postJson, removeJson对应get,put,post,remove的返回值转成JSON对象

# 按需加载(code splitting)

```javascript
import Loadable  from '@keystore/lib/loadable';

export default (props) => Loadable({
    view: () => import(/* webpackChunkName: "test" */'./views'),
    reducer: () => import(/* webpackChunkName: "testReducer" */'./reducer'),
    sagas: () => import(/* webpackChunkName: "testSagas" */'./sagas')
},props)
```

* reducer和sagas为可选项，非必传

```javascript
//reducer.js
import * as types from './actionType';
import reducerName from './reducerName'

const initState = {};

const reducer = (state = initState,action) => {
    const {type} = action;
    switch (type) {
        case types.INIT: {
            return {type}
        }
        default: {
            return state;
        }
    }
};

export default {
    [reducerName]: reducer
}
```

# Provider
```javascript
import React from 'react';
import {render} from 'dom';
import Root from './root';
import Provider from '@keystore/lib/provider';

render(<Provider root={Root}/>, document.getElementById('app'));
```
npm package: @keystore/react-lib
Description: keystore react lib
Author: fay
Latest version: 0.0.1-alpha.4

# keystore react lib
#### 工具库

# Usage
`npm i @keystore/react-lib`

# fetch
```javascript
import {get, put, post, remove, getJson, putJson, postJson, removeJson} from '@keystore/react-lib/fetch';
get({path, data});
put({path, data, contentType, defaultQuery});
post({path, data, contentType});
remove({path, data, contentType});
```
* getJson, putJson, postJson, removeJson对应get,put,post,remove的返回值转成JSON对象

# 按需加载(code splitting)

```javascript
import Loadable  from '@keystore/react-lib/loadable';

export default (props) => Loadable({
    view: () => import(/* webpackChunkName: "test" */'./views'),
    reducer: () => import(/* webpackChunkName: "testReducer" */'./reducer'),
    sagas: () => import(/* webpackChunkName: "testSagas" */'./sagas')
},props)
```

* reducer和sagas为可选项，非必传

```javascript
//reducer.js
import * as types from './actionType';
import reducerName from './reducerName'

const initState = {};

const reducer = (state = initState,action) => {
    const {type} = action;
    switch (type) {
        case types.INIT: {
            return {type}
        }
        default: {
            return state;
        }
    }
};

export default {
    [reducerName]: reducer
}
```

# Provider
```javascript
import React from 'react';
import {render} from 'react-dom';
import Root from './root';
import Provider from '@keystore/react-lib/provider';

render(<Provider root={Root}/>, document.getElementById('app'));
```
npm package: @keystore/react-tool
Description: neltharion react tool
Author: fay
Latest version: 0.0.1-alpha.6

# keystore react tool
#### react app build tool

Let's focus attention in our applications.

***

#### config
* [babel](https://github.com/love-fay/neltharion-reborn/tree/master/packages/keystore-react-tool/config/babel)
* [nginx](https://github.com/love-fay/neltharion-reborn/tree/master/packages/keystore-react-tool/config/nginx)
* [typescript](https://github.com/love-fay/neltharion-reborn/tree/master/packages/keystore-react-tool/config/typescript)
* [webpack](https://github.com/love-fay/neltharion-reborn/tree/master/packages/keystore-react-tool/config/webpack)

# Usage

app root directory structure:
* src
* assets

start
* node_modules/.bin/webpack-cli serve --config node_modules/@keystore/react-tool/config/webpack/default/webpack.config.js --color --progress

build
* node_modules/.bin/webpack-cli --config node_modules/@keystore/react-tool/config/webpack/default/webpack.pro.config.js --color --progress
npm package: @keystore/tool
Description: keystore tool
Author: fay
Latest version: 0.0.1-alpha.43

# keystore tool
#### app build tool

Let's focus attention in our applications.

***

#### config
* [babel](https://bitbucket.bitrost.tech/projects/NEL2/repos/keystore-tool/browse/config/babel)
* [nginx](https://bitbucket.bitrost.tech/projects/NEL2/repos/keystore-tool/browse/config/nginx)
* [typescript](https://bitbucket.bitrost.tech/projects/NEL2/repos/keystore-tool/browse/config/typescript)
* [webpack](https://bitbucket.bitrost.tech/projects/NEL2/repos/keystore-tool/browse/config/webpack)

# Usage

app root directory structure:
* src
* assets

start
* node_modules/.bin/webpack-cli serve --config node_modules/@keystore/tool/config/webpack/default/webpack.config.js --color --progress

build
* node_modules/.bin/webpack-cli --config node_modules/@keystore/tool/config/webpack/default/webpack.pro.config.js --color --progress
npm package: @keyto/basex
Description: 编码转换工具
Author: Keyto
Latest version: 1.1.1-0

# baseX

编码转换工具

```js
// base58: 去除易混淆的 `0、I、O、l`，比特币所用编码
BASE58_CODE_STRING = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
// base60: 去除易混淆的 `O、l`
BASE60_CODE_STRING = "0123456789ABCDEFGHIJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
```

## 安装

```bash
$ npm i @keyto/basex
```

## 使用

Base60：

```js
import { BaseX, BASE60_CODE_STRING } from "@keyto/basex";
const base60 = new BaseX(BASE60_CODE_STRING);
const a = base60.toBase("74623");
console.log(a); // "Kii"
```

Base58：

```js
import { BaseX, BASE58_CODE_STRING } from "@keyto/basex";
const base58 = new BaseX(BASE58_CODE_STRING);
const a = base58.toBase("74623");
console.log(a); // "PBc"
```