@echelon-framework/transport-mock
v0.7.1
Published
Mock TransportAdapter dla dev i testów — fixture-based responses i streams.
Downloads
6,461
Maintainers
Readme
@echelon-framework/transport-mock
Mock TransportAdapter for Echelon framework — declarative simulators for development and testing.
Part of the Echelon Framework — Angular-based, config-driven dashboard & low-code platform.
Installation
npm install @echelon-framework/transport-mockStream Simulators
FX Random Walk (GBM-like)
{ simulate: {
kind: 'fx-random-walk',
mid: 4.05, // starting mid price
vol: 0.0003, // volatility
bounds: [3.9, 4.2], // mean reversion bounds
precision: 5, // decimal places
intervalMs: 600, // tick every 600ms
shape: 'bid-ask', // emits { bid, ask, mid, at }
jumpProbability: 0.01, // 1% chance of price jump
}}Sine Wave
{ simulate: {
kind: 'sine',
amplitude: 10,
periodMs: 30000, // 30 second period
offset: 100, // center value
intervalMs: 500,
}}Random Integer
{ simulate: {
kind: 'random-int',
min: 1,
max: 100,
intervalMs: 1000,
}}HTTP Mock Responses
provideEchelon({
responses: {
'api/clients': [
{ code: 'CLI-001', name: 'Acme Corp' },
{ code: 'CLI-002', name: 'Wayne Enterprises' },
],
},
streams: {
'rates.usdpln': { simulate: { kind: 'fx-random-walk', mid: 4.05 } },
},
});Endpoint Handlers (dynamic responses)
import type { EndpointHandler, EndpointContext } from '@echelon-framework/transport-mock';
const createOrder: EndpointHandler = (params, ctx) => {
const orderId = `ORD-${Date.now()}`;
// Push confirmation to stream after 2s delay
ctx.scheduleAfter(2000, () => {
ctx.pushTo('orders.status', { orderId, status: 'filled' });
});
return { orderId, status: 'pending' };
};License
BUSL-1.1
