Skip to content

Sypnorm

The use-case ORM that comes with Cases. Your code is a set of use cases, and the map comes from it.

Applies to EngineCloud
View as Markdown
On this page
  1. One package
  2. Where it runs
  3. Why use cases

Most ORMs organize code around tables. Sypnorm organizes it around what people do: use cases. «A customer orders today’s bread» is one use case: it says who does it, what it receives, which tables it reads and writes, and every way it can fail. Your app is the set of its use cases, and Sypnorm derives that set as the code side of your map.

That is why Sypnorm belongs to Cases. A Cases map written by people says what the app must do; Sypnorm says, from the code itself, what the app does. The check compares the two.

  • Use cases

    How to write a use case with Sypnorm, what each part means, and how failures work.

  • Tables, queries and types

    Generate typed tables from your database, and read and write with Sypnorm's query builder.

  • Runners and transactions

    Run use cases on Sypnia Data through its API, or on any Postgres with a direct connection, all or nothing.

  • The map from your code

    Derive the map from your use cases, upload it to your Cases project, and keep code and map in agreement.

One package

Terminal
npm install @sypnia/cases
ImportFor
@sypnia/cases/sypnormthe ORM: useCase, ctx.db, ctx.outcome, typed tables, runners and transactions
@sypnia/cases/mapderive the map from your code and upload it, from your own scripts
@sypnia/cases/specthe format: types, JSON Schemas, parser and validator (The SDK)
@sypnia/cases/clientthe Cases API (The SDK)

The command comes with it: npx @sypnia/cases generate, tables, map, link, check and the rest of the CLI.

Where it runs

DatabaseRunnerTransactions
Sypnia Datathrough the Data API, with the person’s token, under row-level security, for cases nobody listens to; a case some case listens to runs in its area’s serviceatomic over HTTP, one request per use case (Runners)
Any Postgres 14+a direct connection from your serverreal Postgres transactions, with row locks

Sypnorm does not need Sypnia Data, and Sypnia Data does not need Sypnorm: Data works with plain SQL, Prisma, Drizzle or any other tool.

Why use cases

  • Anyone can read the app. A use case reads like the sentence a client would say.
  • Scope is visible. The map lists everything the app does; a flow that is not on it is a scope error.
  • Every ending is part of the design. Outcomes and failures are named and typed in the case file, and ctx.outcome accepts nothing else, so nothing is found by surprise in production.
  • Production by use case. With Sypnia Telemetry, each run is a span named after its use case, with its outcome; when another case listens, the area’s service saves the outcome in the outbox in the same transaction (Running cases).
  1. One package
  2. Where it runs
  3. Why use cases

    Search pages, sections and terms