Tide · API

createTide

createTide builds a Tide from options the host supplies: a store for its rows, a transform that evaluates templates, a select that executes a reflex’s query, and effects, the effect handlers by name. Tide calls these and nothing else. In the example, select and the effect handler record the input each receives.

Call
const tide = createTide({
  store: createMemoryStore(),
  transform: evaluate, // Prism
  select: (query) => passes.filter((pass) => pass.amount_cents > query.over),
  effects: { 'payments.charge': { run: (input) => gateway.charge(input) } },
});
Reflex
{
  id: 'billing.charge',
  intent: 'On the first of the month, charge every season pass above a hundred euros.',
  on: {
    clock: {
      every: 'month',
      on: 1,
      at: '03:00',
      tz: 'Europe/Vienna',
    },
  },
  params: { over: 10000 },
  select: {
    query: { table: 'passes', over: { $ref: '$.params.over' } },
    mode: 'each',
    unitKey: 'member',
  },
  effect: {
    name: 'payments.charge',
    input: {
      member: { $ref: '$.row.member' },
      amount: { $ref: '$.row.amount_cents' },
    },
  },
}
select and effect inputs
{
  select: [{ table: 'passes', over: 10000 }],
  effect: [{ member: 'grace', amount: 12000 }],
}
Output matches the expected value

Runs in this page on the installed package. The input and the expected output are defined by the example.