Typed Effect client for the Wolters Kluwer Flowin e-invoicing API.
The SDK is generated from the published Flowin OpenAPI document, then wrapped in a hand-written runtime for OAuth2 client credentials and the mutual-TLS transport the gateway requires. It is a library with no I/O beyond the calls you make: every operation returns an Effect.
- 34 typed operations covering suppliers, Peppol inbound and outbound documents, Zoomit documents, and B2B/B2C payments and transactions
- Typed request and response models generated from the OpenAPI schemas, including the JSON:API resource shapes
- OAuth2 client-credentials token cache, refreshed shortly before expiry and shared by concurrent calls
- A dedicated mutual-TLS
HttpClient, so an ambient client is never used for Flowin calls - Typed errors per HTTP status, plus
UnknownFlowinErrorandFlowinParseErrorfor anything unmodelled - Optional blanket retry policies (
Retry.transient,Retry.throttling, or your own) - OpenTelemetry span metadata stamped into the generated model, with
flowin-apias the system andFlowin.*span names
pnpm add @endevops/effect-flowin effecteffect ~4.1.7 is a peer dependency. Node.js 26 or newer is required.
The environment layer reads the client id, secret, and PEM client certificate:
| Variable | Required | Description |
|---|---|---|
FLOWIN_CLIENT_ID |
yes | OAuth2 client id |
FLOWIN_CLIENT_SECRET |
yes | OAuth2 client secret |
FLOWIN_CERT |
yes | Client certificate, PEM encoded |
FLOWIN_CERT_KEY |
yes | Private key for the client certificate, PEM encoded |
FLOWIN_CERT_CA |
yes | Certificate authority, PEM encoded |
FLOWIN_CERT_PASSPHRASE |
no | Passphrase of an encrypted private key |
FLOWIN_BASE_URL |
no | API root; defaults to the documented integration host |
FLOWIN_TOKEN_URL |
no | Token endpoint; defaults to <base>/oauth2/token |
import * as Flowin from '@endevops/effect-flowin';
import { Effect } from 'effect';
const program = Effect.gen(function* () {
const suppliers = yield* Flowin.listSuppliers({});
return suppliers.data;
});
program.pipe(Effect.provide(Flowin.CredentialsFromEnv), Effect.runPromise);Build the layer yourself when the values come from somewhere other than the environment:
import * as Flowin from '@endevops/effect-flowin';
import { Redacted } from 'effect';
const FlowinLive = Flowin.credentials({
clientId: 'client-id',
clientSecret: Redacted.make('client-secret'),
apiBaseUrl: 'https://flowin-einvoicing-int.api.wolterskluwer.cloud/einvoicing',
ca: Redacted.make(caPem),
cert: Redacted.make(certPem),
key: Redacted.make(keyPem),
});credentials mints and caches the token per layer value, so provide the same layer to every call to reuse it.
Operations are exported from the package root. Request and response types are exported alongside them.
import * as Flowin from '@endevops/effect-flowin';
import { Effect } from 'effect';
const invoice = Effect.gen(function* () {
const result = yield* Flowin.createPeppolOutboundInvoice({
supplierId: 'supplier-1',
body: peppolXml,
integratorDocumentReference: 'invoice-2026-001',
});
return result.data;
});Outbound invoice, credit-note, and Zoomit invoice bodies are raw Peppol XML strings. They are sent verbatim as application/xml; every other bodied request uses application/vnd.api+json.
Typed status errors share their _tag with the core HTTP classes, so either import works with Effect.catchTag:
myCall.pipe(Effect.catchTag('NotFound', () => Effect.succeed(undefined)));import * as Flowin from '@endevops/effect-flowin';
myCall.pipe(Flowin.Retry.transient); // retry transient failures indefinitely
myCall.pipe(Flowin.Retry.throttling); // retry throttling responses indefinitely
myCall.pipe(Flowin.Retry.none); // disable automatic retriessrc/services/ is generated and must not be hand-edited. The pipeline is:
spec/openapi.jsonis the upstream Flowin OpenAPI document.scripts/convert.tsconverts it to a Smithy model in.generated-specs/(gitignored) and appliespatches/*.patch.json.scripts/generate.tscompiles that model intosrc/services/.
git submodule update --init # fetch vendor/distilled, the shared codegen
pnpm install
pnpm generate # convert + generate
pnpm convert # convert only
mise run spec:refresh # download the latest spec and regenerateThe converter and compiler are the shared distilled codegen, vendored as the vendor/distilled git submodule. Patches correct what the converter cannot express: raw XML bodies, raw document responses, and the optional Flowin-Integrator-Document-Reference header. Change the model with a patch, not by editing the generated TypeScript.
The generation scripts set telemetry explicitly (flowin-api, Flowin.*, flowin.* labels) because the converter's defaults derive span names from the npm package name.
pnpm check # format + lint
pnpm typecheck
pnpm test
pnpm build
pnpm fallow # dead code, duplication, complexity, dependenciesTests are colocated as src/*.spec.ts. See AGENTS.md for contributor notes.
MIT © Endevops