tool.contractspec-drizzle-gen
Generator that compiles ContractSpec defineDatabaseTable specs into Drizzle pgTable definitions, relations, and an RLS adapter manifest.
@lssm-tech/tool.contractspec-drizzle-genbun add @lssm-tech/tool.contractspec-drizzle-genManifest declarations describe the current workspace; they do not verify registry publication or runtime execution.
Package guide
Deterministically compile ContractSpec physical-table declarations into typed Drizzle pgTable definitions and an optional tenant-RLS evidence manifest.
Usage
import {
defineDatabaseTable,
defineUnscopedDatabaseTable,
} from "@lssm-tech/lib.contracts-spec/database";
import { generateContractSpecDrizzle } from "@lssm-tech/tool.contractspec-drizzle-gen";
const claims = defineDatabaseTable({
name: "grace_claims",
columns: [
{ name: "id", type: "uuid", nullable: false },
{ name: "tenant_id", type: "uuid", nullable: false },
{
name: "status",
type: "text",
nullable: false,
enumValues: ["draft", "submitted"],
},
],
primaryKey: ["id"],
foreignKeys: [],
tenantColumn: "tenant_id",
});
const principals = defineUnscopedDatabaseTable({
name: "grace_business_principals",
columns: [
{ name: "id", type: "uuid", nullable: false },
{ name: "email", type: "text", nullable: false },
],
primaryKey: ["id"],
foreignKeys: [],
});
const artifacts = generateContractSpecDrizzle({}, [claims, principals]);schemaSource contains the generated Drizzle module. The RLS manifest contains only tables declared through defineDatabaseTable; unscoped tables never gain invented tenant authority. Commit generated schema source and compare a fresh in-memory generation byte-for-byte in CI.
This tool does not replace a migration authority. Consumers may retain dbmate, Drizzle Kit, or another reviewed migration workflow while using generated Drizzle models for typed queries.
Relationships
Arrows point from a package to its direct dependency. Counts are derived from captured workspace manifests.
2 declarations
@lssm-tech/lib.contracts-integrationsworkspace:^
Read the package manual ↗@lssm-tech/lib.contracts-spec-coreworkspace:^
Read the package manual ↗
Declared capabilities
This manifest does not declare a capability catalogue. Use the guide, import map and source to assess the package.
Scripts
buildcontractspec-bun-build buildbuild:bundlecontractspec-bun-build transpilebuild:typescontractspec-bun-build typesprebuildcontractspec-bun-build prebuilddevcontractspec-bun-build devcleanrimraf dist .turbotypechecktsgo --noEmittestbun testlint:checknode ../../../scripts/biome.cjs check .lintbun run lint:fixlint:fixnode ../../../scripts/biome.cjs check --write .