Skip to content

hailer.insight ​

Read insights (reports) and their data.

MethodHost opReturns
list()insight.listPromise<InsightDoc[]>
data(insightId, options)insight.dataPromise<InsightData>
update(insightId, update)insight.updatePromise<InsightDoc[]>
query(workspaceId, sources, query)insight.queryPromise<InsightQueryResult>

list() ​

Insights the app can see, projected to { _id, name, publicKey, presets }.

ts
const insights = await hailer.insight.list();
  • Workspace app — insights in the app's workspace.
  • Private app — insights in the user's current workspace.

data(insightId, options) ​

Run an insight and read its result.

ts
const data = await hailer.insight.data(insightId, {});
const fresh = await hailer.insight.data(insightId, { update: true });

The options argument is required. Pass { update: true } to force a recompute. Returns { headers, rows, time } — see InsightData.

update(insightId, update) ​

ts
const insights = await hailer.insight.update(insightId, { name: 'Renamed' });

Takes a partial InsightDoc and returns the updated list.

query(workspaceId, sources, query) ​

Run an ad-hoc SQL query against Insight sources without saving an insight.

ts
const result = await hailer.insight.query(workspaceId, [
    {
        name: 'orders',
        workflowId,
        fields: [{ name: 'status', fieldId }],
    },
], 'SELECT status, COUNT(*) AS count FROM orders GROUP BY status');

Each source is an InsightSource describing a workflow and the fields to expose as columns of a temporary table named after source.name. The query is a read-only SQLite statement over those tables. Returns InsightQueryResult - { headers, rows, details }, where details maps each table name to its headers and row count. Unlike data(), results are computed on demand, are not cached, and have no row-count cap.

The calling user must be an admin of the workspace.

Insight editor dialogs (create/edit/delete/permission) are opened through hailer.ui.insight. Public (logged-out) insight reads are in hailer.public.insight.

Hailer Developer Documentation · v1.8.0