On this page
DocumentationGuides

Show calculator help to users

Use this guide when your UI needs labels, required facts or validation help for the selected calculator.

Before you start

  • Choose a calculator ID such as au.pay.take-home.
  • Use HTTP for browser clients that cannot import rule packages.
  • Keep the generated OpenAPI reference as the endpoint field source.

Steps

  1. Fetch calculator schema metadata.
  2. Render fact titles and question metadata.
  3. Display safe issue paths alongside the schema endpoint’s field guidance.
  4. Show returned issue paths beside your fields.

Example

TypeScript
import { Function as EffectFunction, Array, Effect, Option } from "effect";
import { HttpApiClient } from "effect/http-api";
import * as FetchHttpClient from "effect/http/FetchHttpClient";
import { AuPayTakeHomeCalculation } from "taxkit/au/effect";
import { TaxKitApi } from "taxkit/http";
import { HelpQuery } from "taxkit/schemas";

export const loadCalculatorHelp = Effect.fnUntraced(function* (baseUrl: URL) {
  const client = yield* HttpApiClient.make(TaxKitApi, { baseUrl });
  const query = yield* HelpQuery.makeEffect({
    help: Option.some("schema"),
  });
  const schema = yield* client.calculatorApi.getCalculatorSchema({
    params: { calculatorId: AuPayTakeHomeCalculation.calculatorId },
    query,
  });
  return EffectFunction.pipe(
    schema.inputFacts,
    Array.map((fact) => `${fact.id}: ${fact.title}`)
  );
});
// Your application supplies the public API origin and owns Effect execution.
export const program = loadCalculatorHelp(
  new URL("http://127.0.0.1:4000")
).pipe(Effect.provide(FetchHttpClient.layer));

Verify the result

Expected output includes fact descriptors for gross pay and the tax-free threshold claim used by the take-home pay calculator.

Handle errors

Let the typed client's expected error channel reach your application error handler. Display the checked issue paths or descriptor help from an input decode failure; API errors explains the envelope and other server failures. The schema endpoint supplies field guidance when its checked request facts do not match the selected calculator.