@tallpond/schema
v0.0.3
Published
Schema DSL for tallpond — define tables, resources, and access rules in a .tallpond.schema.ts, deployed via the tallpond CLI.
Downloads
265
Readme
@tallpond/schema
Schema DSL for tallpond. You describe an app's tables,
shareable resources, and access rules in an .tallpond.schema.ts; the tallpond
CLI deploys it, and the gateway then runs scoped, metered CRUD against it.
npm install @tallpond/schemaUsage
import { defineSchema } from '@tallpond/schema'
export default defineSchema({
tables: {
messages: (table) => {
table.text('body').notNull()
table.text('kind').notNull()
table.timestamps()
table.index(['createdAt'])
},
},
resources: {
// A discoverable room anyone can browse and self-join.
room: (room) => {
room.visibility('discoverable')
room.defaultRole('writer')
room.grant({ owner: 'admin', admin: 'writer', writer: null, reader: null })
room.shares('messages', (m) => {
m.access({ read: 'reader', create: 'writer', update: 'creator', delete: 'creator', unlink: 'admin' })
})
},
},
})Row types can be inferred from the schema with InferRow / InferSchema, and
the tallpond CLI's typegen uses this to type the SDK against your tables.
License
MIT
