Paul Frazee fd08591933
API package ()
* WIP API branch squash

 * Cleanup

 * Add missing pieces of API package's api

 * Add locale support to schemas package

 * Add test for view schemas

 * Add validation to the view api

 * Add createViewValidator() to schemas

 * Add client-side schema validation to record CRUD ops

 * Add writes to API client

 * WIP make progress on the PDS API (server and client)

 * Add .collection and .recordKey to AdxUri

 * Move name-resolution code to common

 * Remove leftover imports

 * WIP progress on API client code-structure

 * More progress on API module

 * WIP: Refactor server routes

 * Update schemas to use the canonical name & id for keying

 * Fix a bug in the schemas readme

 * Schemas readme improvements

 * Add @adxp/schemas

 * Fix typo in AdxUri regex that allowed invalid characters in names

 * Remove accidental commit

 * WIP: Add @adxp/api package

 * WIP: add .mkuser to dev-env repl

 * Allow colons in the adx uri name section

 * Update did:web devenv server to allow overwriting dids

 * Add AdxUri utility class

* Move api and schemas packages to the packages folder

* Update schemas package to use new repo structure

* Update API package to use new build system

* Fix some merge conflicts that werent caught earlier

* Switch from .incompatible to .compatible

* Dont send authStore over the wire

* Quick patch - refactor followup ()

* patching ws-relay build

* added @babel/core

* fixed package exports ()

* Quick auth lobby fix ()

* readme update

* fixed up api build

* cleaned up uri tests

* api types

* fix old esm imports & temporarily remove server tests

Co-authored-by: Daniel Holmgren <dtholmgren@gmail.com>
2022-07-14 18:36:23 -05:00
..
2022-07-14 18:36:23 -05:00
2022-07-14 18:36:23 -05:00
2022-07-14 18:36:23 -05:00
2022-07-14 18:36:23 -05:00
2022-07-14 18:36:23 -05:00
2022-07-14 18:36:23 -05:00

ADX API

Usage

import { adx } from '@adxp/api'

// configure the API
adx.configure({
  schemas: [ublogSchema, likeSchema, pollSchema, followSchema, feedViewSchema]
})

const alice = adx.user('alice.com')
await alice.collections() // list all of alice's collections
const feed = alice.collection('blueskyweb.xyz:Feed')

await feed.list('*') // fetch all (apply no validation)
await feed.list('Ublog') // fetch only ublogs
await feed.list(['Ublog', 'Like']) // fetch ublogs and likes
await feed.list(['Ublog', 'Like', '*']) // fetch all, but apply validation on ublogs and likes
await feed.list({type: 'Ublog', ext: 'Poll'}) // fetch only ublogs and support poll extensions

await feed.get('Ublog', key) // fetch the record and validate as a ublog
await feed.get('*', key) // fetch the record and don't validate

await feed.create('Ublog', record) // create a record after validating as a ublog
await feed.create({type: 'Ublog', ext: 'Poll'}, record) // create a record after validating as a ublog with the poll extension
await feed.create('*', record) // create a record with no validation

await feed.put('Ublog', record) // write a record after validating as a ublog
await feed.put({type: 'Ublog', ext: 'Poll'}, record) // write a record after validating as a ublog with the poll extension
await feed.put('*', record) // write a record after no validation

await feed.del(record) // delete a record

await alice.view('FeedView') // fetch the feed view from alice's PDS

const ublogSchema = adx.schema({type: 'Ublog', ext: 'Poll'}) // create a validator for ublog posts
for (const post in (await alice.view('FeedView')).posts) {
  if (ublogSchema.isValid(post)) {
    // good to go
  }
}