@arbidocs/react 0.5.157 → 0.5.159
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/calls/livekit/index.cjs +50 -50
- package/dist/{chunk-IX4HOS5Z.cjs → chunk-5ECKSF6H.cjs} +13 -4
- package/dist/chunk-5ECKSF6H.cjs.map +1 -0
- package/dist/{chunk-6RRKO4ZK.cjs → chunk-6HJZCIND.cjs} +10 -10
- package/dist/{chunk-6RRKO4ZK.cjs.map → chunk-6HJZCIND.cjs.map} +1 -1
- package/dist/{chunk-QWKTQYGM.cjs → chunk-V7GGKT6W.cjs} +13 -10
- package/dist/chunk-V7GGKT6W.cjs.map +1 -0
- package/dist/conversation-list.js +4 -1
- package/dist/conversation-list.js.map +2 -2
- package/dist/datasets/panel.js +1 -1
- package/dist/datasets/panel.js.map +2 -2
- package/dist/datasets/types.js.map +1 -1
- package/dist/index.cjs +527 -520
- package/dist/index.cjs.map +1 -1
- package/dist/{index.d-KbsNPTEN.d.ts → index.d-COC3NkxH.d.ts} +6 -0
- package/dist/index.d.ts +30 -8
- package/dist/notifications/notify-store.js +11 -2
- package/dist/notifications/notify-store.js.map +2 -2
- package/dist/shell/index.cjs +50 -50
- package/dist/shell/index.d.ts +1 -1
- package/dist/workspaces/switch.js +41 -34
- package/dist/workspaces/switch.js.map +2 -2
- package/package.json +3 -3
- package/dist/chunk-IX4HOS5Z.cjs.map +0 -1
- package/dist/chunk-QWKTQYGM.cjs.map +0 -1
|
@@ -10,7 +10,10 @@ function patchConversationList(queryClient, workspaceId, reducer) {
|
|
|
10
10
|
const key = arbiQueryKeys.conversations(workspaceId);
|
|
11
11
|
const current = queryClient.getQueryData(key) ?? [];
|
|
12
12
|
const next = reducer(current);
|
|
13
|
-
if (next
|
|
13
|
+
if (next === current) return;
|
|
14
|
+
const staleRead = queryClient.getQueryState(key)?.fetchStatus === "fetching";
|
|
15
|
+
queryClient.setQueryData(key, next);
|
|
16
|
+
if (staleRead) void queryClient.refetchQueries({ queryKey: key, exact: true });
|
|
14
17
|
}
|
|
15
18
|
function addConversationToList(queryClient, workspaceId, conversation) {
|
|
16
19
|
patchConversationList(queryClient, workspaceId, (old) => [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/conversation-list.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The workspace's conversation list in the query cache (`arbiQueryKeys.conversations(ws)`).\n *\n * The list is kept current by its writers, not by re-reading it: the workspace open seeds it, every\n * write patches the rows it changed (with the server's version when the server returns one), and\n * the workspace's events invalidate it. These are the writers, for every host and kit, so that one\n * list serves the whole app.\n *\n * Conversation ids are unique across workspaces, so a row is patched (or looked up) by its id in\n * every cached list; only adding a row needs to name its workspace.\n */\n\nimport type { QueryClient, QueryKey } from '@tanstack/react-query'\nimport type { ConversationResponse } from '@arbidocs/sdk/browser'\nimport { arbiQueryKeys } from './hooks'\n\n/** Whether a query key is a workspace's conversation list (not its threads, activity or usage). */\nexport function isConversationListKey(queryKey: QueryKey): boolean {\n return queryKey.length === 3 && queryKey[0] === 'arbi' && queryKey[1] === 'conversations'\n}\n\nconst LISTS = {\n predicate: (query: { queryKey: QueryKey }) => isConversationListKey(query.queryKey),\n}\n\n/** Apply `reducer` to a workspace's cached list (an absent list counts as empty). */\nexport function patchConversationList(\n queryClient: QueryClient,\n workspaceId: string | null | undefined,\n reducer: (old: ConversationResponse[]) => ConversationResponse[]\n): void {\n if (!workspaceId) return\n const key = arbiQueryKeys.conversations(workspaceId)\n const current = queryClient.getQueryData<ConversationResponse[]>(key) ?? []\n const next = reducer(current)\n if (next
|
|
5
|
-
"mappings": "AAcA,SAAS,qBAAqB;AAGvB,SAAS,sBAAsB,UAA6B;AACjE,SAAO,SAAS,WAAW,KAAK,SAAS,CAAC,MAAM,UAAU,SAAS,CAAC,MAAM;AAC5E;AAEA,MAAM,QAAQ;AAAA,EACZ,WAAW,CAAC,UAAkC,sBAAsB,MAAM,QAAQ;AACpF;AAGO,SAAS,sBACd,aACA,aACA,SACM;AACN,MAAI,CAAC,YAAa;AAClB,QAAM,MAAM,cAAc,cAAc,WAAW;AACnD,QAAM,UAAU,YAAY,aAAqC,GAAG,KAAK,CAAC;AAC1E,QAAM,OAAO,QAAQ,OAAO;AAC5B,MAAI,SAAS,QAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * The workspace's conversation list in the query cache (`arbiQueryKeys.conversations(ws)`).\n *\n * The list is kept current by its writers, not by re-reading it: the workspace open seeds it, every\n * write patches the rows it changed (with the server's version when the server returns one), and\n * the workspace's events invalidate it. These are the writers, for every host and kit, so that one\n * list serves the whole app.\n *\n * Conversation ids are unique across workspaces, so a row is patched (or looked up) by its id in\n * every cached list; only adding a row needs to name its workspace.\n */\n\nimport type { QueryClient, QueryKey } from '@tanstack/react-query'\nimport type { ConversationResponse } from '@arbidocs/sdk/browser'\nimport { arbiQueryKeys } from './hooks'\n\n/** Whether a query key is a workspace's conversation list (not its threads, activity or usage). */\nexport function isConversationListKey(queryKey: QueryKey): boolean {\n return queryKey.length === 3 && queryKey[0] === 'arbi' && queryKey[1] === 'conversations'\n}\n\nconst LISTS = {\n predicate: (query: { queryKey: QueryKey }) => isConversationListKey(query.queryKey),\n}\n\n/** Apply `reducer` to a workspace's cached list (an absent list counts as empty). */\nexport function patchConversationList(\n queryClient: QueryClient,\n workspaceId: string | null | undefined,\n reducer: (old: ConversationResponse[]) => ConversationResponse[]\n): void {\n if (!workspaceId) return\n const key = arbiQueryKeys.conversations(workspaceId)\n const current = queryClient.getQueryData<ConversationResponse[]>(key) ?? []\n const next = reducer(current)\n if (next === current) return\n // A read of the list already on its way left before this write: its answer would undo it (a new\n // task gone from the list it was just added to). It is cancelled and the list read again, now\n // that the server has the write.\n const staleRead = queryClient.getQueryState(key)?.fetchStatus === 'fetching'\n queryClient.setQueryData(key, next)\n if (staleRead) void queryClient.refetchQueries({ queryKey: key, exact: true })\n}\n\n/** Put a new conversation at the top of its workspace's list (replacing an earlier copy). */\nexport function addConversationToList(\n queryClient: QueryClient,\n workspaceId: string | null | undefined,\n conversation: ConversationResponse\n): void {\n patchConversationList(queryClient, workspaceId, (old) => [\n conversation,\n ...old.filter((c) => c.external_id !== conversation.external_id),\n ])\n}\n\n/** Change one conversation's row, wherever it is listed. */\nexport function patchConversation(\n queryClient: QueryClient,\n conversationId: string,\n update: Partial<ConversationResponse> | ((row: ConversationResponse) => ConversationResponse)\n): void {\n queryClient.setQueriesData<ConversationResponse[]>(LISTS, (old) => {\n if (!old?.some((c) => c.external_id === conversationId)) return old\n return old.map((c) =>\n c.external_id === conversationId\n ? typeof update === 'function'\n ? update(c)\n : { ...c, ...update }\n : c\n )\n })\n}\n\n/** Take a conversation out of every list. */\nexport function removeConversationFromLists(\n queryClient: QueryClient,\n conversationId: string\n): void {\n queryClient.setQueriesData<ConversationResponse[]>(LISTS, (old) =>\n old?.some((c) => c.external_id === conversationId)\n ? old.filter((c) => c.external_id !== conversationId)\n : old\n )\n}\n\n/** Read the lists again: a change the cache cannot know (the server shared a thread, a run ended). */\nexport function invalidateConversationLists(queryClient: QueryClient): Promise<void> {\n return queryClient.invalidateQueries(LISTS)\n}\n\n/** A conversation's row, from whichever cached list holds it. */\nexport function findConversation(\n queryClient: QueryClient,\n conversationId: string | null | undefined\n): ConversationResponse | undefined {\n if (!conversationId) return undefined\n for (const [, list] of queryClient.getQueriesData<ConversationResponse[]>(LISTS)) {\n const row = list?.find((c) => c.external_id === conversationId)\n if (row) return row\n }\n return undefined\n}\n\n/** Whether the conversation is shared with the workspace, from the cached lists (false when unknown). */\nexport function isConversationShared(\n queryClient: QueryClient,\n conversationId: string | null | undefined\n): boolean {\n return findConversation(queryClient, conversationId)?.is_shared ?? false\n}\n\n/**\n * Refresh what hangs off one conversation (its activity, usage, pending access): not the lists, and\n * not its threads, which the chat engine and the conversation's events keep current.\n */\nexport function invalidateConversationDetails(\n queryClient: QueryClient,\n conversationId: string\n): Promise<void> {\n return queryClient.invalidateQueries({\n predicate: ({ queryKey }) =>\n queryKey[0] === 'arbi' &&\n queryKey[1] === 'conversations' &&\n queryKey[2] === conversationId &&\n queryKey[3] !== 'threads',\n })\n}\n"],
|
|
5
|
+
"mappings": "AAcA,SAAS,qBAAqB;AAGvB,SAAS,sBAAsB,UAA6B;AACjE,SAAO,SAAS,WAAW,KAAK,SAAS,CAAC,MAAM,UAAU,SAAS,CAAC,MAAM;AAC5E;AAEA,MAAM,QAAQ;AAAA,EACZ,WAAW,CAAC,UAAkC,sBAAsB,MAAM,QAAQ;AACpF;AAGO,SAAS,sBACd,aACA,aACA,SACM;AACN,MAAI,CAAC,YAAa;AAClB,QAAM,MAAM,cAAc,cAAc,WAAW;AACnD,QAAM,UAAU,YAAY,aAAqC,GAAG,KAAK,CAAC;AAC1E,QAAM,OAAO,QAAQ,OAAO;AAC5B,MAAI,SAAS,QAAS;AAItB,QAAM,YAAY,YAAY,cAAc,GAAG,GAAG,gBAAgB;AAClE,cAAY,aAAa,KAAK,IAAI;AAClC,MAAI,UAAW,MAAK,YAAY,eAAe,EAAE,UAAU,KAAK,OAAO,KAAK,CAAC;AAC/E;AAGO,SAAS,sBACd,aACA,aACA,cACM;AACN,wBAAsB,aAAa,aAAa,CAAC,QAAQ;AAAA,IACvD;AAAA,IACA,GAAG,IAAI,OAAO,CAAC,MAAM,EAAE,gBAAgB,aAAa,WAAW;AAAA,EACjE,CAAC;AACH;AAGO,SAAS,kBACd,aACA,gBACA,QACM;AACN,cAAY,eAAuC,OAAO,CAAC,QAAQ;AACjE,QAAI,CAAC,KAAK,KAAK,CAAC,MAAM,EAAE,gBAAgB,cAAc,EAAG,QAAO;AAChE,WAAO,IAAI;AAAA,MAAI,CAAC,MACd,EAAE,gBAAgB,iBACd,OAAO,WAAW,aAChB,OAAO,CAAC,IACR,EAAE,GAAG,GAAG,GAAG,OAAO,IACpB;AAAA,IACN;AAAA,EACF,CAAC;AACH;AAGO,SAAS,4BACd,aACA,gBACM;AACN,cAAY;AAAA,IAAuC;AAAA,IAAO,CAAC,QACzD,KAAK,KAAK,CAAC,MAAM,EAAE,gBAAgB,cAAc,IAC7C,IAAI,OAAO,CAAC,MAAM,EAAE,gBAAgB,cAAc,IAClD;AAAA,EACN;AACF;AAGO,SAAS,4BAA4B,aAAyC;AACnF,SAAO,YAAY,kBAAkB,KAAK;AAC5C;AAGO,SAAS,iBACd,aACA,gBACkC;AAClC,MAAI,CAAC,eAAgB,QAAO;AAC5B,aAAW,CAAC,EAAE,IAAI,KAAK,YAAY,eAAuC,KAAK,GAAG;AAChF,UAAM,MAAM,MAAM,KAAK,CAAC,MAAM,EAAE,gBAAgB,cAAc;AAC9D,QAAI,IAAK,QAAO;AAAA,EAClB;AACA,SAAO;AACT;AAGO,SAAS,qBACd,aACA,gBACS;AACT,SAAO,iBAAiB,aAAa,cAAc,GAAG,aAAa;AACrE;AAMO,SAAS,8BACd,aACA,gBACe;AACf,SAAO,YAAY,kBAAkB;AAAA,IACnC,WAAW,CAAC,EAAE,SAAS,MACrB,SAAS,CAAC,MAAM,UAChB,SAAS,CAAC,MAAM,mBAChB,SAAS,CAAC,MAAM,kBAChB,SAAS,CAAC,MAAM;AAAA,EACpB,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/datasets/panel.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
2
|
import { fillTimeGaps } from "./aggregate.js";
|
|
3
3
|
function queryOfChart(chart) {
|
|
4
|
-
if (chart.type === "table" && !chart.x) {
|
|
4
|
+
if (chart.type === "table" && !chart.x || chart.type === "scatter") {
|
|
5
5
|
return {
|
|
6
6
|
records: true,
|
|
7
7
|
...chart.filters?.length ? { filters: chart.filters } : {},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/datasets/panel.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * From a panel's spec to its dataset: the query a `ChartSpec` asks of its source, and the hook a\n * panel reads (grouped and measured by the source, date gaps filled for a trend).\n */\nimport { useMemo } from 'react'\nimport { fillTimeGaps } from './aggregate'\nimport type {\n ChartSpec,\n DataSource,\n DataSourceParams,\n DatasetField,\n DatasetQuery,\n DatasetState,\n} from './types'\n\n/**\n * The query a chart asks: its x field grouped (a metric: one group), its series split, its y\n * measured by the aggregate; a table without `x
|
|
5
|
-
"mappings": "AAIA,SAAS,eAAe;AACxB,SAAS,oBAAoB;
|
|
4
|
+
"sourcesContent": ["/**\n * From a panel's spec to its dataset: the query a `ChartSpec` asks of its source, and the hook a\n * panel reads (grouped and measured by the source, date gaps filled for a trend).\n */\nimport { useMemo } from 'react'\nimport { fillTimeGaps } from './aggregate'\nimport type {\n ChartSpec,\n DataSource,\n DataSourceParams,\n DatasetField,\n DatasetQuery,\n DatasetState,\n} from './types'\n\n/**\n * The query a chart asks: its x field grouped (a metric: one group), its series split, its y\n * measured by the aggregate; a table without `x`, and a scatter (a point per record), list the\n * records (filtered, ordered, limited).\n */\nexport function queryOfChart(chart: ChartSpec): DatasetQuery {\n if ((chart.type === 'table' && !chart.x) || chart.type === 'scatter') {\n return {\n records: true,\n ...(chart.filters?.length ? { filters: chart.filters } : {}),\n ...(chart.orderBy ? { orderBy: chart.orderBy } : {}),\n ...(chart.limit ? { limit: chart.limit } : {}),\n }\n }\n const grouped = chart.type !== 'metric'\n const split = grouped && chart.type !== 'pie' && chart.type !== 'donut' && chart.series\n const op = chart.aggregate ?? 'count'\n return {\n ...(chart.filters?.length ? { filters: chart.filters } : {}),\n ...(grouped && chart.x ? { groupBy: chart.x, bucket: chart.bucket ?? 'month' } : {}),\n ...(split ? { splitBy: chart.series } : {}),\n measure: { op, ...(chart.y ? { field: chart.y } : {}) },\n ...(chart.sort ? { sort: chart.sort } : {}),\n ...(chart.limit ? { limit: chart.limit } : {}),\n }\n}\n\n/** Charts drawn along time, whose missing buckets read as gaps. */\nconst TRENDS = new Set<ChartSpec['type']>(['bar', 'line', 'area'])\n\nexport interface PanelDatasetState extends DatasetState {\n /** The source's fields (for labels and units). */\n fields: readonly DatasetField[]\n}\n\n/**\n * The dataset a panel shows. Render it from a component keyed by `source.id`: the source's hooks\n * run here, and differ from one source to another.\n */\nexport function usePanelDataset(\n source: DataSource,\n params: DataSourceParams | undefined,\n chart: ChartSpec,\n options?: { enabled?: boolean }\n): PanelDatasetState {\n // Specs arrive as fresh objects (edited, parsed); key the memo on their content.\n const paramsKey = JSON.stringify(params ?? {})\n const chartKey = JSON.stringify(chart)\n const stableParams = useMemo(() => JSON.parse(paramsKey) as DataSourceParams, [paramsKey])\n const query = useMemo(() => queryOfChart(JSON.parse(chartKey) as ChartSpec), [chartKey])\n const fields = source.useFields(stableParams)\n const state = source.useDataset(stableParams, query, options)\n const xField = fields.fields.find((f) => f.id === chart.x)\n const fillGaps =\n !!state.dataset &&\n xField?.type === 'date' &&\n TRENDS.has(chart.type) &&\n (chart.sort ?? 'label') === 'label'\n const dataset = useMemo(\n () =>\n state.dataset && fillGaps\n ? fillTimeGaps(state.dataset, chart.bucket ?? 'month')\n : state.dataset,\n [state.dataset, fillGaps, chart.bucket]\n )\n return { ...state, dataset, fields: fields.fields }\n}\n"],
|
|
5
|
+
"mappings": "AAIA,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAetB,SAAS,aAAa,OAAgC;AAC3D,MAAK,MAAM,SAAS,WAAW,CAAC,MAAM,KAAM,MAAM,SAAS,WAAW;AACpE,WAAO;AAAA,MACL,SAAS;AAAA,MACT,GAAI,MAAM,SAAS,SAAS,EAAE,SAAS,MAAM,QAAQ,IAAI,CAAC;AAAA,MAC1D,GAAI,MAAM,UAAU,EAAE,SAAS,MAAM,QAAQ,IAAI,CAAC;AAAA,MAClD,GAAI,MAAM,QAAQ,EAAE,OAAO,MAAM,MAAM,IAAI,CAAC;AAAA,IAC9C;AAAA,EACF;AACA,QAAM,UAAU,MAAM,SAAS;AAC/B,QAAM,QAAQ,WAAW,MAAM,SAAS,SAAS,MAAM,SAAS,WAAW,MAAM;AACjF,QAAM,KAAK,MAAM,aAAa;AAC9B,SAAO;AAAA,IACL,GAAI,MAAM,SAAS,SAAS,EAAE,SAAS,MAAM,QAAQ,IAAI,CAAC;AAAA,IAC1D,GAAI,WAAW,MAAM,IAAI,EAAE,SAAS,MAAM,GAAG,QAAQ,MAAM,UAAU,QAAQ,IAAI,CAAC;AAAA,IAClF,GAAI,QAAQ,EAAE,SAAS,MAAM,OAAO,IAAI,CAAC;AAAA,IACzC,SAAS,EAAE,IAAI,GAAI,MAAM,IAAI,EAAE,OAAO,MAAM,EAAE,IAAI,CAAC,EAAG;AAAA,IACtD,GAAI,MAAM,OAAO,EAAE,MAAM,MAAM,KAAK,IAAI,CAAC;AAAA,IACzC,GAAI,MAAM,QAAQ,EAAE,OAAO,MAAM,MAAM,IAAI,CAAC;AAAA,EAC9C;AACF;AAGA,MAAM,SAAS,oBAAI,IAAuB,CAAC,OAAO,QAAQ,MAAM,CAAC;AAW1D,SAAS,gBACd,QACA,QACA,OACA,SACmB;AAEnB,QAAM,YAAY,KAAK,UAAU,UAAU,CAAC,CAAC;AAC7C,QAAM,WAAW,KAAK,UAAU,KAAK;AACrC,QAAM,eAAe,QAAQ,MAAM,KAAK,MAAM,SAAS,GAAuB,CAAC,SAAS,CAAC;AACzF,QAAM,QAAQ,QAAQ,MAAM,aAAa,KAAK,MAAM,QAAQ,CAAc,GAAG,CAAC,QAAQ,CAAC;AACvF,QAAM,SAAS,OAAO,UAAU,YAAY;AAC5C,QAAM,QAAQ,OAAO,WAAW,cAAc,OAAO,OAAO;AAC5D,QAAM,SAAS,OAAO,OAAO,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,CAAC;AACzD,QAAM,WACJ,CAAC,CAAC,MAAM,WACR,QAAQ,SAAS,UACjB,OAAO,IAAI,MAAM,IAAI,MACpB,MAAM,QAAQ,aAAa;AAC9B,QAAM,UAAU;AAAA,IACd,MACE,MAAM,WAAW,WACb,aAAa,MAAM,SAAS,MAAM,UAAU,OAAO,IACnD,MAAM;AAAA,IACZ,CAAC,MAAM,SAAS,UAAU,MAAM,MAAM;AAAA,EACxC;AACA,SAAO,EAAE,GAAG,OAAO,SAAS,QAAQ,OAAO,OAAO;AACpD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/datasets/types.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Datasets: the one shape every chart and dashboard reads, whatever the data comes from.\n *\n * Three layers, each knowing only the one below it:\n * 1. A `DataSource` adapter (AI usage, documents, threads, projects, a database, later an external\n * feed) exposes its data as a normalized `Dataset`: typed fields and plain rows. Filtering,\n * grouping and aggregation happen here (`aggregateDataset`, or on the server where the backend\n * can, as a database does), never in a chart.\n * 2. A `ChartSpec` (inside a `PanelSpec`, inside a `DashboardSpec`) says what to show in terms of\n * field ids only: the chart type, x / series / y fields, the aggregate, sort and limit. It is\n * plain JSON, saved in dashboards and studio pages.\n * 3. A renderer (`@arbidocs/blocks/dashboards`) maps a spec plus the aggregated dataset onto the\n * drawing component. No renderer type appears here, so the renderer stays swappable.\n */\n\n/** A field's value type. Dates are ISO strings (`2026-06-12` or a full timestamp). */\nexport type DatasetFieldType = 'string' | 'number' | 'date' | 'boolean'\n\n/** One column of a dataset. */\nexport interface DatasetField {\n /** Stable id: what specs and rows use. */\n id: string\n /** What people read (a column name, \"Status\"). */\n label: string\n type: DatasetFieldType\n /**\n * The unit of a number field, which picks its formatting: `gbp` (\u00A3), `bytes`, `tokens`, or any\n * suffix (`\"MB\"`, `\"%\"`).\n */\n unit?: string\n /** The values a string field takes, when known (a select column's options), for a filter picker. */\n options?: readonly string[]\n /** A string field whose cell holds several values (tags, linked rows): a row counts in each. */\n multiple?: boolean\n}\n\n/** A cell: a scalar, `null` when empty, or a list for a `multiple` field. */\nexport type DatasetValue = string | number | boolean | null | readonly string[]\n\n/** One row, keyed by field id. */\nexport type DatasetRow = Readonly<Record<string, DatasetValue | undefined>>\n\n/** A normalized dataset: typed fields and the rows. */\nexport interface Dataset {\n fields: readonly DatasetField[]\n rows: readonly DatasetRow[]\n /** Rows matched before grouping (after filters). */\n totalRows?: number\n /** More groups existed than the query's `limit`. */\n truncated?: boolean\n}\n\n/** How a date field is grouped. Keys: `2026-06-12`, `2026-W24`, `2026-06`, `2026-Q2`, `2026`. */\nexport type TimeBucket = 'day' | 'week' | 'month' | 'quarter' | 'year'\n\nexport type AggregateOp = 'count' | 'sum' | 'avg' | 'min' | 'max'\n\nexport type FilterOp =\n 'eq' | 'neq' | 'contains' | 'gt' | 'gte' | 'lt' | 'lte' | 'empty' | 'not_empty'\n\n/** Keep rows whose `field` satisfies `op value` (compared in the field's type). */\nexport interface DatasetFilter {\n field: string\n op: FilterOp\n value?: string | number | boolean | null\n}\n\n/** How the groups are ordered: by label (dates: chronological), or by value. */\nexport type DatasetSort = 'label' | 'value-desc' | 'value-asc'\n\n/** How records are ordered: by a field (empty cells last). */\nexport interface DatasetOrder {\n field: string\n /** Default `asc`. */\n direction?: 'asc' | 'desc'\n}\n\n/**\n * What to read of a source. Grouped (the default): the (filtered) rows grouped and each group\n * measured, a dataset in long form with the fields {@link AGGREGATE_FIELDS}, one row per group (and\n * series). With `records`: the matching rows themselves, ordered by `orderBy` and cut at `limit`.\n */\nexport interface DatasetQuery {\n /** List the matching records instead of grouping them (`groupBy`, `splitBy`, `measure` unused). */\n records?: boolean\n /** The order of the records. */\n orderBy?: DatasetOrder\n filters?: readonly DatasetFilter[]\n /** The field whose values (or date buckets) are the groups. Absent: one group, \"All\". */\n groupBy?: string\n /** The bucket of a date `groupBy` / `splitBy`. Default `month`. */\n bucket?: TimeBucket\n /** A second field: one series per value (a stacked or multi-line chart). */\n splitBy?: string\n /** Default: count rows. `count` with a `field` counts the rows where it is not empty. */\n measure?: { op: AggregateOp; field?: string }\n /** Default: dates chronological, others by value, largest first. */\n sort?: DatasetSort\n /** Most groups kept (by value), or records listed. Default 50 groups; every record. */\n limit?: number\n}\n\n/** The field ids of an aggregated dataset. */\nexport const AGGREGATE_FIELDS = {\n /** The group's label (\"Open\", \"2026-06\"). */\n group: 'group',\n /** The group's key as grouped (a date bucket, an id), for ordering and links. */\n key: 'key',\n /** The series' label (only with `splitBy`). */\n series: 'series',\n /** The measured value; `null` when the group has no value to measure. */\n value: 'value',\n} as const\n\n/** A dataset (or a source's fields) as a hook reads it. */\nexport interface DatasetState {\n dataset: Dataset | undefined\n /**\n * No dataset yet, and one is coming: a read in flight or still waiting to start (the workspace\n * opening, a saved view being read first). A panel says \"Loading\u2026\" then, never \"nothing to show\".\n */\n isLoading: boolean\n error: unknown\n}\n\nexport interface DataSourceFieldsState {\n fields: readonly DatasetField[]\n isLoading: boolean\n error: unknown\n}\n\n/** A source's parameters as saved in a panel (a database id, a period). */\nexport type DataSourceParams = Readonly<\n Record<string, string | number | boolean | null | undefined>\n>\n\n/** A choice for a parameter (an option of a select). */\nexport interface DataSourceOption {\n value: string\n label: string\n /** Other parameters set with this choice (a database's workspace, so a panel reads it anywhere). */\n params?: DataSourceParams\n}\n\n/** A parameter the panel editor asks for, before the source's fields are known. */\nexport interface DataSourceParam {\n id: string\n label: string\n /** Absent: the parameter may be left empty. */\n required?: boolean\n /** Shown when nothing is chosen (\"All columns\"). */\n placeholder?: string\n /** The choices, read live (databases of the open workspace; a database's saved views). */\n useOptions: (params: DataSourceParams) => {\n options: readonly DataSourceOption[]\n isLoading: boolean\n }\n}\n\n/**\n * A data source adapter: where a dataset comes from.\n *\n * `useFields` and `useDataset` are hooks. A caller renders them from a component keyed by the\n * source id, so switching source mounts afresh (the hooks differ between sources).\n *\n * Extension point: an external source (an HTTP/JSON API, a CSV feed, a warehouse) is one more\n * adapter. It reads its rows however it likes (its own `useQuery`) and returns them as a `Dataset`;\n * `defineRowsSource` aggregates them for it. A host lists it in `<ArbiHost config={{ dashboards:\n * { sources } }}>` and every editor, panel and studio block offers it. Fetching third-party URLs\n * from the browser is the host's decision (CORS, credentials, what a shared dashboard may reach),\n * so none is built in; data to chart today is imported into a database (CSV / spreadsheet import).\n */\nexport interface DataSource {\n id: string\n label: string\n description?: string\n /** `workspace`: it reads the open workspace's data (documents, threads\u2026), so it shows nothing until\n * one is open; a function decides from the panel's parameters (a database panel that does not name\n * its workspace). Absent: it is the person's own or names what it reads (AI usage). */\n scope?: 'workspace' | ((params: DataSourceParams) => 'workspace' | undefined)\n params?: readonly DataSourceParam[]\n /** The fields a panel can use, given the parameters. */\n useFields: (params: DataSourceParams) => DataSourceFieldsState\n /**\n * The dataset: grouped and measured (long form with {@link AGGREGATE_FIELDS}), or the records\n * (`query.records`), filtered either way.\n */\n useDataset: (\n params: DataSourceParams,\n query: DatasetQuery,\n options?: { enabled?: boolean }\n ) => DatasetState\n}\n\n// \u2500\u2500 Specs: what a panel shows (plain JSON) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** How a panel draws its data. `metric` is one number; `table` a table of rows or groups. */\nexport type ChartType = 'metric' | 'bar' | 'line' | 'area' | 'pie' | 'donut' | 'table'\n\n/** What to show, in terms of the dataset's field ids. Serialisable. */\nexport interface ChartSpec {\n type: ChartType\n /** The category or date field along the x axis (pie slices; table groups). */\n x?: string\n /** The bucket of a date `x`. Default `month`. */\n bucket?: TimeBucket\n /** A field whose values become the series (stacked bars or areas, several lines). */\n series?: string\n /** The number field the aggregate reads (absent: rows are counted). */\n y?: string\n /** Default `count`. */\n aggregate?: AggregateOp\n sort?: DatasetSort\n limit?: number\n /** Stack the series (bar, area). */\n stacked?: boolean\n filters?: readonly DatasetFilter[]\n /** A table of records (no aggregate): the fields shown, in order. Absent: every field. */\n columns?: readonly string[]\n /** A table of records: their order. */\n orderBy?: DatasetOrder\n}\n\n/** The source a panel reads, by registry id, with its parameters. */\nexport interface DataSourceRef {\n id: string\n params?: DataSourceParams\n}\n\n/** One panel of a dashboard. */\nexport interface PanelSpec {\n id: string\n title: string\n description?: string\n source: DataSourceRef\n chart: ChartSpec\n /** Columns of the 12-column grid it spans on a wide screen (it is full width on a phone). */\n width?: number\n}\n\n/** A dashboard: a titled grid of panels. Plain JSON (`version` for later migrations). */\nexport interface DashboardSpec {\n version: 1\n title: string\n description?: string\n panels: readonly PanelSpec[]\n}\n"],
|
|
4
|
+
"sourcesContent": ["/**\n * Datasets: the one shape every chart and dashboard reads, whatever the data comes from.\n *\n * Three layers, each knowing only the one below it:\n * 1. A `DataSource` adapter (AI usage, documents, threads, projects, a database, later an external\n * feed) exposes its data as a normalized `Dataset`: typed fields and plain rows. Filtering,\n * grouping and aggregation happen here (`aggregateDataset`, or on the server where the backend\n * can, as a database does), never in a chart.\n * 2. A `ChartSpec` (inside a `PanelSpec`, inside a `DashboardSpec`) says what to show in terms of\n * field ids only: the chart type, x / series / y fields, the aggregate, sort and limit. It is\n * plain JSON, saved in dashboards and studio pages.\n * 3. A renderer (`@arbidocs/blocks/dashboards`) maps a spec plus the aggregated dataset onto the\n * drawing component. No renderer type appears here, so the renderer stays swappable.\n */\n\n/** A field's value type. Dates are ISO strings (`2026-06-12` or a full timestamp). */\nexport type DatasetFieldType = 'string' | 'number' | 'date' | 'boolean'\n\n/** One column of a dataset. */\nexport interface DatasetField {\n /** Stable id: what specs and rows use. */\n id: string\n /** What people read (a column name, \"Status\"). */\n label: string\n type: DatasetFieldType\n /**\n * The unit of a number field, which picks its formatting: `gbp` (\u00A3), `bytes`, `tokens`, or any\n * suffix (`\"MB\"`, `\"%\"`).\n */\n unit?: string\n /** The values a string field takes, when known (a select column's options), for a filter picker. */\n options?: readonly string[]\n /** A string field whose cell holds several values (tags, linked rows): a row counts in each. */\n multiple?: boolean\n}\n\n/** A cell: a scalar, `null` when empty, or a list for a `multiple` field. */\nexport type DatasetValue = string | number | boolean | null | readonly string[]\n\n/** One row, keyed by field id. */\nexport type DatasetRow = Readonly<Record<string, DatasetValue | undefined>>\n\n/** A normalized dataset: typed fields and the rows. */\nexport interface Dataset {\n fields: readonly DatasetField[]\n rows: readonly DatasetRow[]\n /** Rows matched before grouping (after filters). */\n totalRows?: number\n /** More groups existed than the query's `limit`. */\n truncated?: boolean\n}\n\n/** How a date field is grouped. Keys: `2026-06-12`, `2026-W24`, `2026-06`, `2026-Q2`, `2026`. */\nexport type TimeBucket = 'day' | 'week' | 'month' | 'quarter' | 'year'\n\nexport type AggregateOp = 'count' | 'sum' | 'avg' | 'min' | 'max'\n\nexport type FilterOp =\n 'eq' | 'neq' | 'contains' | 'gt' | 'gte' | 'lt' | 'lte' | 'empty' | 'not_empty'\n\n/** Keep rows whose `field` satisfies `op value` (compared in the field's type). */\nexport interface DatasetFilter {\n field: string\n op: FilterOp\n value?: string | number | boolean | null\n}\n\n/** How the groups are ordered: by label (dates: chronological), or by value. */\nexport type DatasetSort = 'label' | 'value-desc' | 'value-asc'\n\n/** How records are ordered: by a field (empty cells last). */\nexport interface DatasetOrder {\n field: string\n /** Default `asc`. */\n direction?: 'asc' | 'desc'\n}\n\n/**\n * What to read of a source. Grouped (the default): the (filtered) rows grouped and each group\n * measured, a dataset in long form with the fields {@link AGGREGATE_FIELDS}, one row per group (and\n * series). With `records`: the matching rows themselves, ordered by `orderBy` and cut at `limit`.\n */\nexport interface DatasetQuery {\n /** List the matching records instead of grouping them (`groupBy`, `splitBy`, `measure` unused). */\n records?: boolean\n /** The order of the records. */\n orderBy?: DatasetOrder\n filters?: readonly DatasetFilter[]\n /** The field whose values (or date buckets) are the groups. Absent: one group, \"All\". */\n groupBy?: string\n /** The bucket of a date `groupBy` / `splitBy`. Default `month`. */\n bucket?: TimeBucket\n /** A second field: one series per value (a stacked or multi-line chart). */\n splitBy?: string\n /** Default: count rows. `count` with a `field` counts the rows where it is not empty. */\n measure?: { op: AggregateOp; field?: string }\n /** Default: dates chronological, others by value, largest first. */\n sort?: DatasetSort\n /** Most groups kept (by value), or records listed. Default 50 groups; every record. */\n limit?: number\n}\n\n/** The field ids of an aggregated dataset. */\nexport const AGGREGATE_FIELDS = {\n /** The group's label (\"Open\", \"2026-06\"). */\n group: 'group',\n /** The group's key as grouped (a date bucket, an id), for ordering and links. */\n key: 'key',\n /** The series' label (only with `splitBy`). */\n series: 'series',\n /** The measured value; `null` when the group has no value to measure. */\n value: 'value',\n} as const\n\n/** A dataset (or a source's fields) as a hook reads it. */\nexport interface DatasetState {\n dataset: Dataset | undefined\n /**\n * No dataset yet, and one is coming: a read in flight or still waiting to start (the workspace\n * opening, a saved view being read first). A panel says \"Loading\u2026\" then, never \"nothing to show\".\n */\n isLoading: boolean\n error: unknown\n}\n\nexport interface DataSourceFieldsState {\n fields: readonly DatasetField[]\n isLoading: boolean\n error: unknown\n}\n\n/** A source's parameters as saved in a panel (a database id, a period). */\nexport type DataSourceParams = Readonly<\n Record<string, string | number | boolean | null | undefined>\n>\n\n/** A choice for a parameter (an option of a select). */\nexport interface DataSourceOption {\n value: string\n label: string\n /** Other parameters set with this choice (a database's workspace, so a panel reads it anywhere). */\n params?: DataSourceParams\n}\n\n/** A parameter the panel editor asks for, before the source's fields are known. */\nexport interface DataSourceParam {\n id: string\n label: string\n /** Absent: the parameter may be left empty. */\n required?: boolean\n /** Shown when nothing is chosen (\"All columns\"). */\n placeholder?: string\n /** The choices, read live (databases of the open workspace; a database's saved views). */\n useOptions: (params: DataSourceParams) => {\n options: readonly DataSourceOption[]\n isLoading: boolean\n }\n}\n\n/**\n * A data source adapter: where a dataset comes from.\n *\n * `useFields` and `useDataset` are hooks. A caller renders them from a component keyed by the\n * source id, so switching source mounts afresh (the hooks differ between sources).\n *\n * Extension point: an external source (an HTTP/JSON API, a CSV feed, a warehouse) is one more\n * adapter. It reads its rows however it likes (its own `useQuery`) and returns them as a `Dataset`;\n * `defineRowsSource` aggregates them for it. A host lists it in `<ArbiHost config={{ dashboards:\n * { sources } }}>` and every editor, panel and studio block offers it. Fetching third-party URLs\n * from the browser is the host's decision (CORS, credentials, what a shared dashboard may reach),\n * so none is built in; data to chart today is imported into a database (CSV / spreadsheet import).\n */\nexport interface DataSource {\n id: string\n label: string\n description?: string\n /** `workspace`: it reads the open workspace's data (documents, threads\u2026), so it shows nothing until\n * one is open; a function decides from the panel's parameters (a database panel that does not name\n * its workspace). Absent: it is the person's own or names what it reads (AI usage). */\n scope?: 'workspace' | ((params: DataSourceParams) => 'workspace' | undefined)\n params?: readonly DataSourceParam[]\n /** The fields a panel can use, given the parameters. */\n useFields: (params: DataSourceParams) => DataSourceFieldsState\n /**\n * The dataset: grouped and measured (long form with {@link AGGREGATE_FIELDS}), or the records\n * (`query.records`), filtered either way.\n */\n useDataset: (\n params: DataSourceParams,\n query: DatasetQuery,\n options?: { enabled?: boolean }\n ) => DatasetState\n}\n\n// \u2500\u2500 Specs: what a panel shows (plain JSON) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * How a panel draws its data. `metric` is one number; `table` a table of rows or groups; `scatter`\n * one point per record (x and y both numbers).\n */\nexport type ChartType = 'metric' | 'bar' | 'line' | 'area' | 'pie' | 'donut' | 'scatter' | 'table'\n\n/** Which way is better on a scatter axis, for its Pareto frontier. */\nexport type FrontierGoal = 'min' | 'max'\n\n/** What to show, in terms of the dataset's field ids. Serialisable. */\nexport interface ChartSpec {\n type: ChartType\n /** The category or date field along the x axis (pie slices; table groups); a scatter's number field. */\n x?: string\n /** The bucket of a date `x`. Default `month`. */\n bucket?: TimeBucket\n /** A field whose values become the series (stacked bars or areas, several lines). */\n series?: string\n /** The number field the aggregate reads (absent: rows are counted); a scatter's vertical number. */\n y?: string\n /** Default `count`. */\n aggregate?: AggregateOp\n sort?: DatasetSort\n limit?: number\n /** Stack the series (bar, area). */\n stacked?: boolean\n filters?: readonly DatasetFilter[]\n /** A table of records (no aggregate): the fields shown, in order. Absent: every field. */\n columns?: readonly string[]\n /** A table of records: their order. */\n orderBy?: DatasetOrder\n /** A scatter: the field that names each point. */\n label?: string\n /** Categories (bar, line, area) or point labels (scatter) drawn in the accent colour. */\n highlight?: readonly string[]\n /**\n * A scatter: draw its Pareto frontier, the points no other point beats on both axes. `x` / `y`\n * say which way is better (price: `min`, score: `max`).\n */\n frontier?: { x: FrontierGoal; y: FrontierGoal }\n /** A scatter: dashed guides at the median x and median y, splitting it into quadrants. */\n quadrants?: boolean\n /** A scatter: the x axis's scale (`log` for values across orders of magnitude). Default `linear`. */\n xScale?: 'linear' | 'log'\n}\n\n/** The source a panel reads, by registry id, with its parameters. */\nexport interface DataSourceRef {\n id: string\n params?: DataSourceParams\n}\n\n/** One panel of a dashboard. */\nexport interface PanelSpec {\n id: string\n title: string\n description?: string\n source: DataSourceRef\n chart: ChartSpec\n /** Columns of the 12-column grid it spans on a wide screen (it is full width on a phone). */\n width?: number\n}\n\n/** A dashboard: a titled grid of panels. Plain JSON (`version` for later migrations). */\nexport interface DashboardSpec {\n version: 1\n title: string\n description?: string\n panels: readonly PanelSpec[]\n}\n"],
|
|
5
5
|
"mappings": "AAuGO,MAAM,mBAAmB;AAAA;AAAA,EAE9B,OAAO;AAAA;AAAA,EAEP,KAAK;AAAA;AAAA,EAEL,QAAQ;AAAA;AAAA,EAER,OAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|