close

@atproto/lexicon

atproto Lexicon schema language library

  • Types
  • ESM
License
MIT
Install Size
989.2 kB(6.1 MB)
Vulns
0
Published

Get started

$npm install @atproto/lexicon
$pnpm add @atproto/lexicon
$yarn add @atproto/lexicon
$bun add @atproto/lexicon
$deno add npm:@atproto/lexicon
$vlt install @atproto/lexicon
$vp add @atproto/lexicon

Readme

@atproto/lexicon: schema validation library

TypeScript implementation of the Lexicon data and API schema description language, which is part of atproto.

NPM Github CI Status

Usage

import { Lexicons } from '@atproto/lexicon'

// create your lexicons collection
const lex = new Lexicons()

// add lexicon documents
lex.add({
  lex: 1,
  id: 'com.example.post',
  defs: {
    // ...
  }
})

// validate
lex.assertValidRecord('com.example.record', {$type: 'com.example.record', ...})
lex.assertValidXrpcParams('com.example.query', {...})
lex.assertValidXrpcInput('com.example.procedure', {...})
lex.assertValidXrpcOutput('com.example.query', {...})

License

This project is dual-licensed under MIT and Apache 2.0 terms:

Downstream projects and end users may chose either license individually, or both together, at their discretion. The motivation for this dual-licensing is the additional software patent assurance provided by Apache 2.0.