Skip to content

Documentation

TypeScript export transformations

Open an export, choose code processing and select TypeScript. Transformations work with CSV, JSON, file exports and Webhooks according to export delivery settings. They process saved records and do not start a new website collection.

In Records mode, preserve the input count and order. Emit once per input item.

async function run(ctx: Akmelo.Context): Promise<void> {
  for (const item of ctx.param<Akmelo.Row[]>('items', [])) {
    const price = ctx.text().money(item.price_rub);
    ctx.emit({ ...item, price_with_vat: price === null ? null : Math.round(price * 1.2 * 100) / 100 });
  }
}

In Dataset mode you may filter, sort, group and aggregate. File and Webhook delivery processes the selection; an endpoint processes its current page; preview processes the first five records.

async function run(ctx: Akmelo.Context): Promise<void> {
  const rows = ctx.param<Akmelo.Row[]>('items', []);
  const priced = rows.map(row => ({ ...row, price: ctx.text().money(row.price_rub) }))
    .filter(row => row.price !== null && row.price > 0)
    .sort((left, right) => (left.price ?? 0) - (right.price ?? 0));
  for (const row of priced) ctx.emit(row);
}

Dataset input is limited to 10,000 records and 16 MB; each call has a 30-second deadline. Exceeding a limit fails rather than silently truncating data. Network, documents, email, credentials and storage access are unavailable in a transformation. Use collected data; type checking does not override runtime restrictions.

Save, then choose “Test on data”. An invalid revision never replaces a working version. Changing language creates a separate transformation script and preserves earlier versions with their original language. Optimistic version checks prevent an outdated editor overwriting another revision.

Runtime · Context