Skip to content

TypeScript SDK

@flowcatalyst/sdk is the TypeScript and JavaScript SDK for the platform. It is for Node.js services (and any server-side JavaScript runtime that supports node:crypto) that produce events, receive deliveries, declare their definitions in code and call the platform API. It is written in TypeScript, ships its own types, and is ESM only ("type": "module").

Current version: v0.29.0.

Capability Where it lives Page
Typed API client with token handling, retries and neverthrow results FlowCatalystClient and its resource accessors Client
Transactional outbox writer: events, dispatch jobs, audit logs and pushes OutboxManager, PgOutboxDriver, CreateEventDto and friends Client
Use-case envelope (operation, plan, unit of work) usecase namespace Client and Effect
Declare roles, event types, subscriptions and more in code sync namespace, client.definitions() Sync
Push to clients: topic rules, ticket minting CreatePushDto, TicketMinter Sync and Client
Scheduled-job runner, lock providers, delivery-signature verification, cache ScheduledJobRunner, PgLockProvider, verifyDeliverySignature, PgCacheStore Client
Sign-in for web apps and Bearer validation for APIs @flowcatalyst/sdk/fastify Fastify
Compile-time guarantees on the write path @flowcatalyst/sdk/effect/usecase Effect
Customer-portal sign-in and portal-user administration portal: true, ensurePortalUser Portal
Field-worker token verification and field admin API FieldTokenVerifier, fieldAuth, fieldWorkers() Field
Error values SdkError and friends Errors
Agent access to platform metadata not part of the SDK MCP

The SDK is released from a split repository, flowcatalyst/typescript-sdk. Each release tags the split repository vX.Y.Z and the committed tree includes the built dist/, so a git dependency works without a build step. The package is not published to npm.

Terminal window
npm install github:flowcatalyst/typescript-sdk#v0.29.0
# or
pnpm add github:flowcatalyst/typescript-sdk#v0.29.0

Pin the tag. Moving to a newer release is a change of tag in package.json.

package.json defines exactly these entry points:

Import Contents
@flowcatalyst/sdk Client, outbox, sync, usecase, push, runner, cache, field verifier, webhook verification, generated wire types, the api namespace
@flowcatalyst/sdk/fastify flowcatalystAuth, fieldAuth, defineRbac, session stores
@flowcatalyst/sdk/effect The Effect flavour (re-exports usecase)
@flowcatalyst/sdk/effect/usecase UnitOfWork, ExecutionContext, tagged errors, OutboxUnitOfWork, TestUnitOfWork
@flowcatalyst/sdk/usecase The neverthrow use-case envelope as a subpath

There is no @flowcatalyst/sdk/sync entry point: import sync from the package root.

The only runtime dependencies are neverthrow and fastify-plugin. The rest are optional peer dependencies, installed only if you use the matching feature:

Peer Needed for
fastify (^5) @flowcatalyst/sdk/fastify
@fastify/cookie (^11) flowcatalystAuth (registered for you if your app has not already)
jose (^5 or ^6) Bearer verification, the OIDC flow, and FieldTokenVerifier
effect (^4.0.0-beta.70) @flowcatalyst/sdk/effect*

Effect 4 is still in beta, so the peer range is a beta range.

import { FlowCatalystClient } from '@flowcatalyst/sdk';
const client = new FlowCatalystClient({
baseUrl: 'http://localhost:8080',
clientId: process.env.FLOWCATALYST_CLIENT_ID!,
clientSecret: process.env.FLOWCATALYST_CLIENT_SECRET!,
});
const result = await client.eventTypes().list();
result.match(
(page) => console.log(page),
(error) => console.error(error.type, error.message),
);

Every call returns a ResultAsync: errors are values, not exceptions. See Errors.

To get a platform to talk to locally, install fcdev (Install fcdev). If you publish events through the outbox, the relay that forwards them is the platform’s outbox processor, which fcdev outbox runs next to your application database. See The transactional outbox.

  • Qualified codes. Event types and dispatch-job codes written to the outbox must be application:subdomain:aggregate:action with four non-empty segments. The SDK throws if they are not (assertQualifiedCode, src/outbox/qualified-code.ts). See Events.
  • Dedup ids. An event written without a deduplicationId is given the outbox row’s id as one, so a batch the relay sends again does not create a second event.
  • Ids are TSIDs. generateTsid() and isValidTsid() are exported. See Identifiers.
  • The code is the wire authority. Wire types are generated from the platform’s OpenAPI document and re-exported from the package root, for example EventTypeResponse.

Each page ends with a Testing section. The SDK’s own tests use Node’s built-in runner (node --import tsx --test); none of them need a running platform. The patterns they use are described where they apply: an in-memory OutboxDriver for the use-case envelope, a mock OIDC issuer for the Fastify plugin, a local JWKS for field tokens.