Skip to content

Documentation

TypeScript SDK: Sources: workflow inputs and prices

ctx.sources() reads inputs pinned to a workflow and compares prices locally. Arbitrary mail or another run is not accessible.

Each example is a separate fragment inside async function run(ctx: Akmelo.Context): Promise<void>. Use await only for methods whose signature returns a Promise.

Methods

input

ctx.sources().input(key) → Promise<object>

A records input returns records, run_id, collected_at. A mail input returns the checked message, body and attachment metadata. New mail does not replace the pinned message. A newer crawl invalidates the pinned records instead of mixing runs. Deleted or expired mail cannot be read even after the workflow has been queued.

const result = await ctx.sources().input('catalog');

document

ctx.sources().document(key, id) → Promise<Document>

Read a safe attachment belonging to the pinned mail input. Parsing runs inside the system. File contents are not sent to an external model. The shared limit is eight document reads per run.

const result = await ctx.sources().document('supplier', 'attachment-id');

comparePrices

ctx.sources().comparePrices(offers) → Array<object>

Compare two to ten named sources, each with up to 5000 records containing string sku, numeric price with at most two fractional digits and explicit currency, such as RUB. SKU matching is exact. Negative or invalid prices, repeated SKUs within a source and mixed currencies are rejected.

const result = ctx.sources().comparePrices({ catalog: [{ sku: 'A-1', price: 1250, currency: 'RUB' }], supplier: [{ sku: 'A-1', price: 1200, currency: 'RUB' }] });