@procflow/sdk-nestjs
v0.1.5
Published
NestJS adapter for Process Inspector SDK — YAML/JSON specs + binding decorators
Maintainers
Readme
@procflow/sdk-nestjs
NestJS adapter for @procflow/sdk-js.
- Process graph comes from YAML or JSON (
spec) @Process/@Step/@ProcessEntryonly bind methods to document ids and enable runtime wrapping- Events are reported to the Process Inspector hub (
hubUrlrequired)
Install
npm install @procflow/sdk-js @procflow/sdk-nestjsSetup
import { join } from 'node:path';
import { NestFactory } from '@nestjs/core';
import { ProcessInspectorModule } from '@procflow/sdk-nestjs';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
ProcessInspectorModule.setup(app, {
// YAML or JSON path (same schema)
spec: join(__dirname, 'processes.yaml'),
// spec: join(__dirname, 'processes.json'),
ingestToken: process.env.PROCESS_INSPECTOR_INGEST_TOKEN!,
hubUrl: process.env.PROCESS_INSPECTOR_HUB_URL ?? 'http://127.0.0.1:3100',
redact: ['password'],
});
await app.listen(3000);
}
bootstrap();When enabled (enabled: true, default), spec, hubUrl, and an ingest/shared token are required. See docs/security.md and docs/hub.md.
By default Nest also:
- reads continue headers on inbound HTTP (
continueFromHeaders) - writes continue headers on outbound
HttpService/axioscalls while a run is active (propagateContinue)
Disable with propagateContinue: false if needed.
Decorators
import { Injectable } from '@nestjs/common';
import { Process, Step } from '@procflow/sdk-nestjs';
@Injectable()
@Process({ id: 'createOrder' })
export class OrdersService {
@Step({ id: 'validate' })
async validate(dto: CreateOrderDto) {
return dto;
}
@Step({ id: 'persistOrder' })
async persistOrder(dto: CreateOrderDto) {
return { orderId: `ord_${Date.now()}` };
}
@Process({ id: 'createOrder' })
async create(dto: CreateOrderDto) {
await this.validate(dto);
return this.persistOrder(dto);
}
}| Decorator | Purpose |
| --- | --- |
| @Process({ id }) | Bind class/method to a process id from the document |
| @Step({ id }) | Bind method to a step id from the document |
| @ProcessEntry() | Mark HTTP/service entrypoint |
| @ProcessIgnore() | Skip instrumentation |
Full guide: docs/decorators.md.
