# ssb-schema-definitions

> standardised schema definitions for JSON validation of ssb references

Latest version **3.2.1** (published 2020-07-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install ssb-schema-definitions
pnpm add ssb-schema-definitions
yarn add ssb-schema-definitions
bun add ssb-schema-definitions
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.2.1 |
| Published | 2020-07-03 |
| First published | 2018-07-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 23.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | kyphae |
| Maintainers | ahdinosaur, aljoscha-meyer, andregarzia, arj03, cel, chereseeriepa, christianbundy, cryp7ix, dominictarr, happy0, kyphae, luandro, mixmix, mmckegg, noffle, pfrazee, pietgeursen, regular, staltz, vtduncan |
| Keywords | schema, definitions, ssb, json, validation |

## Links

- npm: https://www.npmjs.com/package/ssb-schema-definitions
- Repository: https://github.com/ssbc/ssb-schema-definitions
- Homepage: https://github.com/ssbc/ssb-schema-definitions#readme
- Issues: https://github.com/ssbc/ssb-schema-definitions/issues
- npm.io page: https://npm.io/package/ssb-schema-definitions

## Dependencies (2)

- [ssb-ref](https://npm.io/package/ssb-ref.md) ^2.14.0
- [lodash.clone](https://npm.io/package/lodash.clone.md) ^4.5.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 3.2.1 (latest) — 2020-07-03
- 3.2.0 — 2020-07-02
- 3.1.0 — 2020-06-14
- 3.0.1 — 2020-06-14
- 3.0.0 — 2020-05-24
- 2.1.0 — 2020-03-08
- 2.0.2 — 2019-10-20
- 2.0.1 — 2019-10-20
- 2.0.0 — 2019-10-20
- 1.3.0 — 2019-10-19
- 1.2.0 — 2019-08-29
- 1.1.6 — 2019-08-19
- 1.1.5 — 2018-11-04
- 1.1.3 — 2018-11-01
- 1.1.2 — 2018-11-01
- … 11 more at https://npm.io/package/ssb-schema-definitions/versions

## README

# SSB Schema Definitions

Standardised schema definitions for SSB messages when using [is-my-json-valid](https://github.com/mafintosh/is-my-json-valid).

## Example Usage

```js
const Definitions = require('ssb-schema-definitions')
const Validator = require('is-my-json-valid')

const schema = {
  $schema: 'http://json-schema.org/schema#',
  type: 'object',
  required: ['type', 'tangles'],
  properties: {
    type: {
      type: 'string',
      pattern: '^profile/.*$'
    },
    preferredName: { type: 'string' },
    avatarImage: { $ref: '#/definitions/image' }, // << reference a definition
    tangles: {
      group: { $ref: '#/definitions/tangle/any' },
      profile: { $ref: '#/definitions/tangle/root' }
    },
    recps: { $ref: '#/definitions/recipients/box2' }
  },
  additionalProperties: false,
  definitions: Definitions() // attach the definitions
}

const isValid = Validator(schema)

// isValid(msgContent) => Boolean
// isValid.errors => null | [Errors]
```

## API

### `Definitions() => Object`

The definitions is a getter (function) so that you can pull it and mutate it awithout getting into trouble.

To see what definitions are available check out `index.js`.

You can also see examples of how to use most of the definitions in the `tests/` folder.
At time of writing there's good test coverage here for fields:
- `contentWarning`
- `image`
- `mentions`
- `tangle`
- `tombstone`
- `recps` (box1, box2/ envelope)

---
_Source: https://npm.io/package/ssb-schema-definitions · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
