@karpo.dev/schema
v0.4.0
Published
The Karpo schema DSL — containers, tables, roles, permissions, seed helpers.
Readme
@karpo.dev/schema
The Karpo schema DSL and its compiler. You describe containers, tables, columns and roles in TypeScript; the compiler turns that description into the manifest artifact the platform publishes and into the typed client the app imports.
npm install @karpo.dev/schemaDefining a schema
import { column, container, defineSchema, table } from "@karpo.dev/schema";
export const workspaces = container({
description: "A workspace holding one team's todos; shared independently",
columns: {
name: column.text({ default: "Untitled workspace" }),
},
tables: {
todos: table({
columns: {
title: column.text({ default: "" }),
done: column.boolean({ default: false }),
},
indexes: [["done"]],
}),
},
roles: {
owner: { "*": "full", manages: "all" },
member: { self: "read", todos: "write" },
},
creatorRole: "owner",
});
export const schema = defineSchema({ containers: { workspaces } });A container is the unit of sharing: each one is granted independently, and a user only syncs the containers they hold a role on. Roles are declared beside the data they govern, so permissions travel with the schema.
You rarely call the rest directly — karpo push and karpo generate do:
compile(...)— schema definitions to a manifest artifact, with a change summary against the previous version.generate(...)— the codegen behindkarpo generate:types.ts,db.ts,schema.json.validateSchemaDef(...)— the DSL-level checks, returning structured issues.defineAuth(...)— the auth section: methods, claims, external issuers.seedState(...)/roster(...)— the fixtureskarpo seedapplies.
Documentation
- Schema reference: https://karpo.dev/schema
- Permissions: https://karpo.dev/permissions
- Generated code: https://karpo.dev/generated-code
- Source: https://github.com/Chirich-GmbH/karpo-core (
packages/schema)
