Reference · SDK

Per-type helpers

Next release: this page describes techne-sdk/types, which is not in techne-sdk 0.3.4 yet. With techne-sdk 0.3 today shows the released API.

generatedtechne-sdk/typestechne-sdk/types/Place

Every lexicon generates one object with the same set of helpers. The set is its TypeScript type, a typed query, the lexicon check, and a few small tools. Place is the example here.

The set is the same for every record type. What changes is the roles a type's query takes and the sidecars it has. Each type's own list is in the "In the SDK" section of its page on techne.pub.

The set

HelperWhat it does
Place.query(roles?, options?)A query for places, narrowed by the roles the place lexicon declares (location, text) and its category. Pass it to techne.query or useRecordQuery.
Place.validate(x)The lexicon check. It answers { valid: true, record } or { valid: false, problems } and never throws. The same check techne.computer runs, compiled to WebAssembly.
Place.parse(x)The record, or throws RecordProblems with the same problems.
Place.create(fields)A record with $type set, and createdAt set to now unless you give one.
Place.sample()A valid place, the same one every call, for tests and docs.
Place.uri(s)Types a string as an AT-URI of a place. Nothing is checked.
Place.provenance(uri) …One query per sidecar, on the sidecar's subject. A place has eight. They are provenance, source, receipt, assessment, verdict, geo, description, containedIn.

Also Place.nsid ('pub.techne.draft.place') and Place.roles.

Read, check, write
Live. This page runs the real check.

Each type's own helpers are on its page on techne.pub, under "In the SDK". A place's are on place.draft.techne.pub.