integrationPackage manifestv2.0.5

integration.provider-database

Database provider implementations for ContractSpec.

@lssm-tech/integration.provider-database
Source, release and verification context

Source snapshot bcc79fcc · Declared package version 2.0.5. This page combines the checked-in package guide and manifest; commands and runtime behavior were not executed in this review.

Package source ↗ Manifest ↗
servernode
EXPLORE THE PACKAGE

See where this package fits.

Follow a declared connection, inspect an import, then open the source guide when you need the detail.

THIS PACKAGEintegration.provider-databaseintegrations

Arrows point from a package to its direct dependency. Each count is derived from the captured manifests.

5 déclarationsSELECT TO INSPECT

@lssm-tech/integration.provider-database

Website: https://contractspec.io

Database provider implementations for ContractSpec.

Usage

Import the root entrypoint for the domain surface, or import a concrete implementation from the ./impls/* subpaths. Use ./governed-read when a contracts-spec DataViewQueryGenerator emits a database.query.readonly descriptor and you need to execute that governed read through a DatabaseProvider. The helper builds parameterized SQL from field mappings and keeps SQL construction inside this adapter package. Governed reads support offset descriptors and cursor descriptors from DataViewDatabaseBinding.pagination. Cursor descriptors add a parameterized cursorField > cursor predicate only when the cursor field is present in the contract-owned select mapping; unknown cursor fields fail before provider execution, and maxPageSize is enforced before the query reaches the provider. executeQuery exposes the governed read as a Transport-shaped resolver for the data-fetching engine: it executes a canonical QueryEnvelope and returns a ContractResult<QueryResultEnvelope> carrying a real versionToken (read from the entity's version column with versionTokenFromColumn()) for the engine's etag / optimistic-concurrency path.

Utiliser ./governed-mutation for first-class database writes after the owning domain command has planned a portable database.mutation.execute@2.0.0 envelope. The helper validates actor, tenant, domain-command authority, policy decision, idempotency key, transaction boundary, expected write set, audit refs, replay ref, and correlation ref before running the provider transaction. Drizzle/PostgreSQL rendering remains in this integration package, not in contracts-spec core.

Version-governed entities

Declare the entities whose writes need optimistic concurrency once, at the composition root, and pass the registry to every governed mutation:

ts
const versioning = createGovernedVersionRegistry([
	{ entity: 'workspace', table: 'workspaces' }, // schema public, column version
]);
await applyVersionColumnMigration(provider, buildVersionColumnMigration(versioning));

await executeGovernedMutation({
	descriptor: { ...renameDescriptor, expectedVersionToken: ctx.queryEnvelope?.versionToken },
	provider,
	versioning,
});
  • buildVersionColumnMigration(registry) returns idempotent up statements and down statements. up adds a missing column as bigint NOT NULL DEFAULT 1 (existing rows start at 1) and marks it with a column comment, or normalizes an existing smallint/integer/bigint column (NULLs backfilled to 1, NOT NULL DEFAULT 1; any other type fails the migration). It then installs a BEFORE UPDATE trigger that sets NEW.<column> = OLD.<column> + 1, so writers that bypass the store still advance the version. down removes the triggers and functions and drops only the columns up added. Building the migration fails when two entities of one schema would share a trigger function name.
  • A descriptor without a schema matches the one registered schema that governs its table and fails when several do; the governed SQL always names the registered schema, so it never depends on the connection's search_path.
  • On a governed table, insert returns the new versionToken; update and delete must carry expectedVersionToken, check it in the same statement (AND <column> = $n::bigint ... RETURNING <column>) and return the new token (update) or none (delete). Their where must name one row by its key: the store refuses a write that returns more than one row, but it does not see rows the version filter excluded.
  • A missing, stale or non-integer token (BIGINT range only), or a row that no longer matches, throws ContractSpecError with the typed Core version conflict (CONFLICT 409, metadata.versionConflict.reason = missing, stale or gone, and the stored version in versionToken when the row exists). The transaction rolls back and the idempotency key is not stored. The data engine resolves it with the mutation's conflict policy; under client-wins a gone row fails the mutation and rolls the optimistic write back.
  • A write that returns more than one row, a value for the version column itself, or an expectedVersionToken on a table that is not in the registry fails with an error.
  • Clients send the expected token as MutationRequest.versionToken; the engine forwards it as QueryEnvelope.versionToken and REST carries it as $versionToken, so handlers read ctx.queryEnvelope?.versionToken.

Managed and BYOK Postgres/Supabase deployments are the production posture. Local/PgLite remains a provider-binding compatibility mode for deterministic tests and demos, not a separate ownership mode.

Postgres statement parameters preserve the shared DatabaseProvider contract: Date values are serialized as ISO-8601 timestamps before reaching postgres.js, while bigint, byte, JSON-object, and array parameters retain their existing normalized representations.

Public subpaths

  • . re-exports the provider surface plus governed read/mutation helpers.
  • ./database re-exports the shared DatabaseProvider contracts.
  • ./governed-read executes portable DataView read descriptors through a provider.
  • ./governed-mutation executes governed mutation descriptors with transaction, idempotency, audit hooks and, for version-governed tables, the version precondition.
  • ./governed-versioning declares version-governed entities (createGovernedVersionRegistry).
  • ./version-column-migration builds and applies the per-entity version-column rollout (buildVersionColumnMigration, applyVersionColumnMigration, VERSION_COLUMN_ROLLOUT_MARKER).
  • ./version-token-source maps a stored version column to a VersionToken (versionTokenFromColumn, versionTokenFromValue) and a token back to its BIGINT bind value (parseVersionCounter).
  • ./impls and ./impls/supabase-psql expose concrete PostgreSQL/Supabase implementations.
  • ./postgres-json-semantics exports withPgJsonSemantics(client), which makes a raw postgres.js client pass JSON text through to json/jsonb parameters instead of double-encoding it (pg/PGlite semantics). It has no imports, so any runtime that builds its own postgres.js client can use it.

Compatibility

This package owns the database implementation slice split out of @lssm-tech/integration.providers-impls. The legacy package continues to re-export these subpaths for existing consumers.

Declared capabilities.

Integration Provider Database

Database provider implementations for ContractSpec.

Use it to

  • Adopt database provider implementations for contractspec

Requires

  • TypeScript

Choose another boundary when

  • The @lssm-tech/integration.provider-database package constraints do not match the target runtime or platform.

@lssm-tech/integration.provider-database

@lssm-tech/integration.provider-database/auth-seam

@lssm-tech/integration.provider-database/database

@lssm-tech/integration.provider-database/generated/contractspec-schema.generated

@lssm-tech/integration.provider-database/generated/contractspec-schema.manifest.generated

@lssm-tech/integration.provider-database/governed-execute-query

@lssm-tech/integration.provider-database/governed-mutation

@lssm-tech/integration.provider-database/governed-read

@lssm-tech/integration.provider-database/governed-relational-read

@lssm-tech/integration.provider-database/governed-sql-guards

@lssm-tech/integration.provider-database/impls

@lssm-tech/integration.provider-database/impls/drizzle-contractspec

Imports and export paths.

20 entries

These are package-manifest entry points. Named symbols listed above come from the capability catalogue; this is not an exhaustive TypeScript symbol reference.

20 imports

Dependencies and related packages.

Runtime dependencies 5
drizzle-orm
catalog:data
Development dependencies 7
@types/bun
catalog:types
postgres
^3.4.9
typescript
catalog:

Package scripts.

Commands declared by this package. Review its setup requirements before running them; no command here was executed by this review.

buildcontractspec-bun-build build
build:bundlecontractspec-bun-build transpile
build:typescontractspec-bun-build types
devcontractspec-bun-build dev
cleanrimraf dist .turbo
lint:checknode ../../../scripts/biome.cjs check .
lint:fixnode ../../../scripts/biome.cjs check --write --unsafe --only=nursery/useSortedClasses . && node ../../../scripts/biome.cjs check --write .
testbun test
prebuildcontractspec-bun-build prebuild
typechecktsgo --noEmit
Votre vue

Make room for your context.

Shape the presentation around this moment. You can change it whenever you need.

Votre contexte

The different parts of you

Choose a starting point

Un mélange utile de contexte, de visuels et de guidage discret.

Tune each dimension
Each dimension can change independently. Product permissions and available actions stay unchanged.

Support the way you begin and return

Tune your support

Confort de lecture

Choisir votre langue

La langue de l’interface change uniquement le texte. Les marchés, les prix et les parcours conservent leurs propres paramètres.

Couverture des traductions

Une partie du contenu est affichée en anglais.

Navigation151
Graphe616
Catégories378
Portfolio833
Exemples2 035
Aperçu de la source1 542

D’autres traductions seront ajoutées à mesure que le contenu sera relu.

Cette préférence est enregistrée dans ce navigateur.

Rechercher sur le site

Des points de départ utiles

Aucun résultat. Essayez une expression plus courte, un nom d’opération ou un autre périmètre de recherche.

UN PEU DE PLACE POUR EXPLORER

Trouvez quelque chose à explorer.

Ouvrez un aperçu détaillé sur cette page, essayez une autre perspective ou suivez le détail vers sa propre page.

Fonctionnement des aperçus et des commandes
01

Regarder avant de partir

Survolez un lien ou sélectionnez-le avec Tab pour voir un aperçu. Cliquer sur le lien d’origine ou appuyer sur Entrée ouvre toujours sa destination.

02

Rester dans le contexte

Entrez dans l’aperçu pour explorer ses sections. Depuis un lien sélectionné, utilisez Alt + ↓ pour y entrer au clavier. Échap le ferme.

03

Ouvrir les possibilités

Les lignes dépliables, les choix de perspective et les commandes mises en évidence révèlent davantage. Votre vue adapte le confort de lecture et le contexte exploré.

Un bouton séparé pour voir de plus près

Affichez de petits boutons d’aperçu à côté des liens quand l’espace le permet. Touchez l’œil pour examiner ou le lien pour y aller directement. Ce choix reste dans cet onglet.

Aucun historique de navigation n’est collecté. La réduction des animations suit votre appareil et Votre vue.