* 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 (#153)
* patching ws-relay build
* added @babel/core
* fixed package exports (#154)
* Quick auth lobby fix (#155)
* 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>
import{adx}from'@adxp/api'// configure the API
adx.configure({schemas:[ublogSchema,likeSchema,pollSchema,followSchema,feedViewSchema]})constalice=adx.user('alice.com')awaitalice.collections()// list all of alice's collections
constfeed=alice.collection('blueskyweb.xyz:Feed')awaitfeed.list('*')// fetch all (apply no validation)
awaitfeed.list('Ublog')// fetch only ublogs
awaitfeed.list(['Ublog','Like'])// fetch ublogs and likes
awaitfeed.list(['Ublog','Like','*'])// fetch all, but apply validation on ublogs and likes
awaitfeed.list({type:'Ublog',ext:'Poll'})// fetch only ublogs and support poll extensions
awaitfeed.get('Ublog',key)// fetch the record and validate as a ublog
awaitfeed.get('*',key)// fetch the record and don't validate
awaitfeed.create('Ublog',record)// create a record after validating as a ublog
awaitfeed.create({type:'Ublog',ext:'Poll'},record)// create a record after validating as a ublog with the poll extension
awaitfeed.create('*',record)// create a record with no validation
awaitfeed.put('Ublog',record)// write a record after validating as a ublog
awaitfeed.put({type:'Ublog',ext:'Poll'},record)// write a record after validating as a ublog with the poll extension
awaitfeed.put('*',record)// write a record after no validation
awaitfeed.del(record)// delete a record
awaitalice.view('FeedView')// fetch the feed view from alice's PDS
constublogSchema=adx.schema({type:'Ublog',ext:'Poll'})// create a validator for ublog posts
for(constpostin(awaitalice.view('FeedView')).posts){if(ublogSchema.isValid(post)){// good to go
}}