flowmyna
v0.1.2
Published
Official Node.js SDK for FlowMyna - Process Mining Event Tracking
Maintainers
Readme
flowmyna
Official Node.js SDK for FlowMyna - Process Mining Event Tracking.
Installation
npm install flowmyna
# or
yarn add flowmyna
# or
pnpm add flowmynaQuick Start
import { FlowMyna } from 'flowmyna';
const client = new FlowMyna({
apiKey: process.env.FLOWMYNA_API_KEY!
});
// Record an event
await client.recordEvent({
event: 'Order Placed',
objects: [
{ type: 'Order', id: 'ORD-123' },
{ type: 'Customer', id: 'CUST-456' }
],
properties: { total: 149.99 }
});
// Upsert an object
await client.upsertObject({
type: 'Customer',
id: 'CUST-456',
properties: {
name: 'Jane Doe',
email: '[email protected]'
}
});Features
- TypeScript-first - Full type definitions included
- Automatic retries - Exponential backoff for transient failures
- Rate limit handling - Respects Retry-After headers
- ESM and CommonJS - Works with both module systems
- Node.js 18+ - Uses native fetch API
Configuration
const client = new FlowMyna({
apiKey: 'fm_live_xxx', // Required
baseUrl: 'https://...', // Optional, defaults to production
timeout: 30000, // Optional, request timeout in ms
maxRetries: 3, // Optional, max retry attempts
});API Reference
recordEvent(request)
Record a single process event.
const result = await client.recordEvent({
event: 'Order Shipped',
objects: [
{ type: 'Order', id: 'ORD-123' },
{ type: 'Shipment', id: 'SHIP-456' }
],
timestamp: new Date(),
properties: { carrier: 'FedEx' }
});recordEventBatch(events)
Record multiple events in a single request (max 100).
const result = await client.recordEventBatch([
{ event: 'Order Created', objects: [{ type: 'Order', id: 'ORD-1' }] },
{ event: 'Order Shipped', objects: [{ type: 'Order', id: 'ORD-1' }] },
]);
console.log(`Processed: ${result.processed}`);upsertObject(request)
Create or update an object with properties.
const result = await client.upsertObject({
type: 'Customer',
id: 'CUST-456',
properties: { name: 'Jane Doe', tier: 'gold' }
});
console.log(`Object ${result.created ? 'created' : 'updated'}`);upsertObjectBatch(objects)
Create or update multiple objects (max 100).
const result = await client.upsertObjectBatch([
{ type: 'Customer', id: 'CUST-1', properties: { tier: 'gold' } },
{ type: 'Customer', id: 'CUST-2', properties: { tier: 'silver' } },
]);health()
Verify API key and get workspace info.
const health = await client.health();
console.log(`Connected to ${health.workspaceName}`);Error Handling
import { FlowMyna } from 'flowmyna';
import {
AuthenticationError,
ValidationError,
RateLimitError,
ServerError,
FlowMynaError
} from 'flowmyna/errors';
try {
await client.recordEvent({ ... });
} catch (error) {
if (error instanceof AuthenticationError) {
console.error('Invalid API key');
} else if (error instanceof ValidationError) {
console.error('Invalid request:', error.message);
} else if (error instanceof RateLimitError) {
console.error(`Rate limited. Retry after ${error.retryAfter}s`);
} else if (error instanceof ServerError) {
console.error('Server error:', error.message);
} else if (error instanceof FlowMynaError) {
console.error('FlowMyna error:', error.message);
}
}Documentation
Full documentation available at flowmyna.com/api/sdks/nodejs
License
MIT
