@arbidocs/react 0.5.152 → 0.5.153
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/artifacts/index.cjs +46 -46
- package/dist/calls/livekit/index.cjs +51 -51
- package/dist/{chunk-VXFTVWEI.cjs → chunk-4VHECR5O.cjs} +44 -44
- package/dist/{chunk-VXFTVWEI.cjs.map → chunk-4VHECR5O.cjs.map} +1 -1
- package/dist/{chunk-P2DPOZBS.cjs → chunk-5ZNO77YB.cjs} +11 -2
- package/dist/chunk-5ZNO77YB.cjs.map +1 -0
- package/dist/{chunk-MK5L56Z3.cjs → chunk-BUMLF3MS.cjs} +60 -60
- package/dist/{chunk-MK5L56Z3.cjs.map → chunk-BUMLF3MS.cjs.map} +1 -1
- package/dist/{chunk-6RRKO4ZK.cjs → chunk-DBWW6DXJ.cjs} +5 -5
- package/dist/{chunk-6RRKO4ZK.cjs.map → chunk-DBWW6DXJ.cjs.map} +1 -1
- package/dist/{chunk-KULS4YWP.cjs → chunk-DQODLWFX.cjs} +3 -3
- package/dist/{chunk-KULS4YWP.cjs.map → chunk-DQODLWFX.cjs.map} +1 -1
- package/dist/{chunk-GFX7LQGR.cjs → chunk-HISGJISX.cjs} +67 -67
- package/dist/{chunk-GFX7LQGR.cjs.map → chunk-HISGJISX.cjs.map} +1 -1
- package/dist/{chunk-BI7HFGXF.cjs → chunk-NJWQPNGD.cjs} +14 -14
- package/dist/{chunk-BI7HFGXF.cjs.map → chunk-NJWQPNGD.cjs.map} +1 -1
- package/dist/{chunk-SKJWJ3OY.cjs → chunk-WWGUGZZN.cjs} +39 -39
- package/dist/{chunk-SKJWJ3OY.cjs.map → chunk-WWGUGZZN.cjs.map} +1 -1
- package/dist/{chunk-WJIRX5MS.cjs → chunk-XQLJSNAL.cjs} +3 -3
- package/dist/{chunk-WJIRX5MS.cjs.map → chunk-XQLJSNAL.cjs.map} +1 -1
- package/dist/datasets/aggregate-source.js +133 -0
- package/dist/datasets/aggregate-source.js.map +7 -0
- package/dist/datasets/aggregate.js +72 -22
- package/dist/datasets/aggregate.js.map +2 -2
- package/dist/datasets/index.js +27 -1
- package/dist/datasets/index.js.map +2 -2
- package/dist/datasets/sources/activity.js +44 -9
- package/dist/datasets/sources/activity.js.map +2 -2
- package/dist/datasets/sources/conversations.js +37 -7
- package/dist/datasets/sources/conversations.js.map +2 -2
- package/dist/datasets/sources/documents.js +44 -6
- package/dist/datasets/sources/documents.js.map +2 -2
- package/dist/datasets/sources/facts.js +31 -5
- package/dist/datasets/sources/facts.js.map +3 -3
- package/dist/datasets/sources/tags.js +37 -5
- package/dist/datasets/sources/tags.js.map +3 -3
- package/dist/datasets/sources/usage.js +29 -32
- package/dist/datasets/sources/usage.js.map +2 -2
- package/dist/datasets/sources/workflows.js +56 -22
- package/dist/datasets/sources/workflows.js.map +2 -2
- package/dist/datasets/workspace-aggregate.js +64 -0
- package/dist/datasets/workspace-aggregate.js.map +7 -0
- package/dist/document-tools/core.cjs +102 -102
- package/dist/document-tools/core.d.ts +2 -2
- package/dist/document-tools/index.cjs +104 -104
- package/dist/document-tools/index.d.ts +2 -2
- package/dist/{file-shares.d-CamKxNLC.d.ts → file-shares.d-CyTnJ2Re.d.ts} +11 -0
- package/dist/index.cjs +2935 -2476
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +138 -5
- package/dist/index.js +11 -2
- package/dist/index.js.map +2 -2
- package/dist/projects.js +9 -0
- package/dist/projects.js.map +2 -2
- package/dist/query-keys.js +9 -0
- package/dist/query-keys.js.map +2 -2
- package/dist/shell/index.cjs +40 -40
- package/dist/storage.js +24 -1
- package/dist/storage.js.map +2 -2
- package/dist/table-views.js +19 -1
- package/dist/table-views.js.map +2 -2
- package/dist/ui/index.cjs +181 -181
- package/dist/viewers/index.cjs +9 -9
- package/package.json +3 -3
- package/dist/chunk-P2DPOZBS.cjs.map +0 -1
|
@@ -3,8 +3,12 @@ import { useArbi } from "../../useArbi.js";
|
|
|
3
3
|
import { useWorkspaceActivity } from "../../hooks.js";
|
|
4
4
|
import { useArbiSessionState } from "../../session/index.js";
|
|
5
5
|
import { useSwitchWorkspace } from "../../workspaces/switch.js";
|
|
6
|
+
import {
|
|
7
|
+
cellText,
|
|
8
|
+
defineAggregateSource,
|
|
9
|
+
useOpenWorkspace
|
|
10
|
+
} from "../aggregate-source.js";
|
|
6
11
|
import { useNames } from "../members.js";
|
|
7
|
-
import { defineRowsSource, staticFields } from "../rows-source.js";
|
|
8
12
|
import { DEFAULT_WORKFLOWS_SOURCE_LABELS } from "./workflows.js";
|
|
9
13
|
const ENTRIES = 100;
|
|
10
14
|
const DEFAULT_ACTIVITY_SOURCE_LABELS = {
|
|
@@ -40,13 +44,40 @@ function createActivitySource(labels) {
|
|
|
40
44
|
{ id: "item", label: l.item, type: "string" },
|
|
41
45
|
{ id: "status", label: l.status, type: "string" }
|
|
42
46
|
];
|
|
43
|
-
|
|
47
|
+
const byId = new Map(fields.map((f) => [f.id, f]));
|
|
48
|
+
const field = (id) => byId.get(id) ?? { id, label: id, type: "string" };
|
|
49
|
+
const areas = new Map(Object.entries(l.areas));
|
|
50
|
+
const kindOf = (kind) => kind ? l.kinds[kind] ?? inWords(kind) : null;
|
|
51
|
+
const statusOf = (status) => status ? l.statuses[status] ?? inWords(status) : null;
|
|
52
|
+
return defineAggregateSource({
|
|
44
53
|
id: "activity",
|
|
45
|
-
|
|
54
|
+
source: "activity",
|
|
46
55
|
label: l.source,
|
|
47
56
|
description: l.description,
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
fields,
|
|
58
|
+
useAggregateFields(enabled) {
|
|
59
|
+
const nameOf = useNames(enabled);
|
|
60
|
+
return useMemo(
|
|
61
|
+
() => [
|
|
62
|
+
{ field: field("when"), from: ["when"] },
|
|
63
|
+
{
|
|
64
|
+
field: field("area"),
|
|
65
|
+
from: ["area"],
|
|
66
|
+
value: ([a]) => {
|
|
67
|
+
const area = cellText(a);
|
|
68
|
+
return area ? areas.get(area) ?? area : null;
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{ field: field("kind"), from: ["kind"], value: ([k]) => kindOf(cellText(k)) },
|
|
72
|
+
{ field: field("person"), from: ["person"], value: ([u]) => nameOf(cellText(u)) },
|
|
73
|
+
{ field: field("item"), from: ["item"] },
|
|
74
|
+
{ field: field("status"), from: ["status"], value: ([st]) => statusOf(cellText(st)) }
|
|
75
|
+
],
|
|
76
|
+
[nameOf]
|
|
77
|
+
);
|
|
78
|
+
},
|
|
79
|
+
useWorkspace: useOpenWorkspace,
|
|
80
|
+
useRecords(_params, enabled) {
|
|
50
81
|
const arbi = useArbi();
|
|
51
82
|
const workspaceId = useArbiSessionState((s) => s.workspaceId) ?? void 0;
|
|
52
83
|
const { settled, openSelectedWorkspace } = useSwitchWorkspace();
|
|
@@ -63,16 +94,20 @@ function createActivitySource(labels) {
|
|
|
63
94
|
() => feed.data?.pages.flatMap(
|
|
64
95
|
(page) => page.items.map((e) => ({
|
|
65
96
|
when: e.created_at,
|
|
66
|
-
area:
|
|
67
|
-
kind:
|
|
97
|
+
area: areas.get(e.source) ?? e.source,
|
|
98
|
+
kind: kindOf(e.kind),
|
|
68
99
|
person: nameOf(e.actor_ext_id),
|
|
69
100
|
item: e.conversation_title || e.document_name || e.workflow_name || null,
|
|
70
|
-
status: e.status
|
|
101
|
+
status: statusOf(e.status ?? null)
|
|
71
102
|
}))
|
|
72
103
|
),
|
|
73
104
|
[feed.data, nameOf]
|
|
74
105
|
);
|
|
75
|
-
return {
|
|
106
|
+
return {
|
|
107
|
+
rows,
|
|
108
|
+
isLoading: enabled && feed.isPending && !!workspaceId,
|
|
109
|
+
error: feed.error
|
|
110
|
+
};
|
|
76
111
|
}
|
|
77
112
|
});
|
|
78
113
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/datasets/sources/activity.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The open workspace's recent activity as a dataset: a row per entry of its activity feed (thread\n * history, people posting, uploads, new versions and signatures, workflow runs), newest first, as\n * far as the feed's first page reaches (up to 100 entries, cached apart from the feed's own pages).\n * Titles and names decrypt only while the session has the workspace open, so it is re-opened\n * before the read, as the activity feed does. Activity by day, by person, or the\n * workflow runs and how they ended, are a group-by away. Reads the shared feed\n * (`useWorkspaceActivity`), so only what the user can see is counted.\n */\nimport { useMemo } from 'react'\nimport type { components } from '@arbidocs/client'\nimport { useArbi } from '../../useArbi'\nimport { useWorkspaceActivity } from '../../hooks'\nimport { useArbiSessionState } from '../../session'\nimport { useSwitchWorkspace } from '../../workspaces/switch'\nimport {
|
|
5
|
-
"mappings": "AASA,SAAS,eAAe;AAExB,SAAS,eAAe;AACxB,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,
|
|
4
|
+
"sourcesContent": ["/**\n * The open workspace's recent activity as a dataset: a row per entry of its activity feed (thread\n * history, people posting, uploads, new versions and signatures, workflow runs), newest first, as\n * far as the feed's first page reaches (up to 100 entries, cached apart from the feed's own pages).\n * Titles and names decrypt only while the session has the workspace open, so it is re-opened\n * before the read, as the activity feed does. Activity by day, by person, or the\n * workflow runs and how they ended, are a group-by away. Reads the shared feed\n * (`useWorkspaceActivity`), so only what the user can see is counted.\n */\nimport { useMemo } from 'react'\nimport type { components } from '@arbidocs/client'\nimport { useArbi } from '../../useArbi'\nimport { useWorkspaceActivity } from '../../hooks'\nimport { useArbiSessionState } from '../../session'\nimport { useSwitchWorkspace } from '../../workspaces/switch'\nimport {\n cellText,\n defineAggregateSource,\n useOpenWorkspace,\n type AggregateField,\n} from '../aggregate-source'\nimport { useNames } from '../members'\nimport type { DataSource, DatasetField, DatasetRow } from '../types'\nimport { DEFAULT_WORKFLOWS_SOURCE_LABELS } from './workflows'\n\ntype ActivityEntry = components['schemas']['WorkspaceActivityEntry']\ntype ActivityArea = components['schemas']['WorkspaceActivitySource']\n\n/** Entries read: the most the feed gives in one page. */\nconst ENTRIES = 100\n\nexport interface ActivitySourceLabels {\n source: string\n description: string\n when: string\n area: string\n areas: Record<ActivityArea, string>\n kind: string\n /** An entry's kind by the server's name; one not listed is shown in words (`task_done`: \"Task done\"). */\n kinds: Readonly<Record<string, string>>\n person: string\n item: string\n status: string\n /** A workflow run's status by the server's name; one not listed is shown as it comes. */\n statuses: Readonly<Record<string, string>>\n}\n\nexport const DEFAULT_ACTIVITY_SOURCE_LABELS: ActivitySourceLabels = {\n source: 'Recent activity',\n description:\n 'The latest activity of the open workspace: threads, messages, documents and workflow runs.',\n when: 'When',\n area: 'Area',\n areas: { thread: 'Threads', message: 'Messages', document: 'Documents', workflow: 'Workflows' },\n kind: 'What happened',\n kinds: {\n message_posted: 'Message posted',\n document_uploaded: 'Document uploaded',\n document_version: 'New version',\n document_signed: 'Document signed',\n workflow_run: 'Workflow run',\n },\n person: 'Person',\n item: 'Item',\n status: 'Status',\n statuses: DEFAULT_WORKFLOWS_SOURCE_LABELS.results,\n}\n\nconst inWords = (name: string) => {\n const words = name.replaceAll('_', ' ')\n return words.charAt(0).toUpperCase() + words.slice(1)\n}\n\nexport function createActivitySource(labels?: Partial<ActivitySourceLabels>): DataSource {\n const l = { ...DEFAULT_ACTIVITY_SOURCE_LABELS, ...labels }\n const fields: DatasetField[] = [\n { id: 'when', label: l.when, type: 'date' },\n { id: 'area', label: l.area, type: 'string', options: Object.values(l.areas) },\n { id: 'kind', label: l.kind, type: 'string' },\n { id: 'person', label: l.person, type: 'string' },\n { id: 'item', label: l.item, type: 'string' },\n { id: 'status', label: l.status, type: 'string' },\n ]\n const byId = new Map(fields.map((f) => [f.id, f]))\n const field = (id: string): DatasetField => byId.get(id) ?? { id, label: id, type: 'string' }\n const areas = new Map<string, string>(Object.entries(l.areas))\n const kindOf = (kind: string | null) => (kind ? (l.kinds[kind] ?? inWords(kind)) : null)\n const statusOf = (status: string | null) =>\n status ? (l.statuses[status] ?? inWords(status)) : null\n return defineAggregateSource({\n id: 'activity',\n source: 'activity',\n label: l.source,\n description: l.description,\n fields,\n useAggregateFields(enabled) {\n const nameOf = useNames(enabled)\n return useMemo(\n (): AggregateField[] => [\n { field: field('when'), from: ['when'] },\n {\n field: field('area'),\n from: ['area'],\n value: ([a]) => {\n const area = cellText(a)\n return area ? (areas.get(area) ?? area) : null\n },\n },\n { field: field('kind'), from: ['kind'], value: ([k]) => kindOf(cellText(k)) },\n { field: field('person'), from: ['person'], value: ([u]) => nameOf(cellText(u)) },\n { field: field('item'), from: ['item'] },\n { field: field('status'), from: ['status'], value: ([st]) => statusOf(cellText(st)) },\n ],\n [nameOf]\n )\n },\n useWorkspace: useOpenWorkspace,\n useRecords(_params, enabled) {\n const arbi = useArbi()\n const workspaceId = useArbiSessionState((s) => s.workspaceId) ?? undefined\n const { settled, openSelectedWorkspace } = useSwitchWorkspace()\n const feed = useWorkspaceActivity(workspaceId, {\n enabled: enabled && arbi.isLoggedIn,\n limit: ENTRIES,\n beforeFetch: async () => {\n await settled()\n await openSelectedWorkspace()\n },\n })\n const nameOf = useNames(enabled)\n const rows = useMemo(\n () =>\n feed.data?.pages.flatMap((page) =>\n (page.items as ActivityEntry[]).map((e): DatasetRow => ({\n when: e.created_at,\n area: areas.get(e.source) ?? e.source,\n kind: kindOf(e.kind),\n person: nameOf(e.actor_ext_id),\n item: e.conversation_title || e.document_name || e.workflow_name || null,\n status: statusOf(e.status ?? null),\n }))\n ),\n [feed.data, nameOf]\n )\n return {\n rows,\n isLoading: enabled && feed.isPending && !!workspaceId,\n error: feed.error,\n }\n },\n })\n}\n"],
|
|
5
|
+
"mappings": "AASA,SAAS,eAAe;AAExB,SAAS,eAAe;AACxB,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,gBAAgB;AAEzB,SAAS,uCAAuC;AAMhD,MAAM,UAAU;AAkBT,MAAM,iCAAuD;AAA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d,WAAW,SAAS,SAAS;AAC3B,YAAM,OAAO,QAAQ;AACrB,YAAM,cAAc,oBAAoB,CAAC,MAAM,EAAE,WAAW,KAAK;AACjE,YAAM,EAAE,SAAS,sBAAsB,IAAI,mBAAmB;AAC9D,YAAM,OAAO,qBAAqB,aAAa;AAAA,QAC7C,SAAS,WAAW,KAAK;AAAA,QACzB,OAAO;AAAA,QACP,aAAa,YAAY;AACvB,gBAAM,QAAQ;AACd,gBAAM,sBAAsB;AAAA,QAC9B;AAAA,MACF,CAAC;AACD,YAAM,SAAS,SAAS,OAAO;AAC/B,YAAM,OAAO;AAAA,QACX,MACE,KAAK,MAAM,MAAM;AAAA,UAAQ,CAAC,SACvB,KAAK,MAA0B,IAAI,CAAC,OAAmB;AAAA,YACtD,MAAM,EAAE;AAAA,YACR,MAAM,MAAM,IAAI,EAAE,MAAM,KAAK,EAAE;AAAA,YAC/B,MAAM,OAAO,EAAE,IAAI;AAAA,YACnB,QAAQ,OAAO,EAAE,YAAY;AAAA,YAC7B,MAAM,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,iBAAiB;AAAA,YACpE,QAAQ,SAAS,EAAE,UAAU,IAAI;AAAA,UACnC,EAAE;AAAA,QACJ;AAAA,QACF,CAAC,KAAK,MAAM,MAAM;AAAA,MACpB;AACA,aAAO;AAAA,QACL;AAAA,QACA,WAAW,WAAW,KAAK,aAAa,CAAC,CAAC;AAAA,QAC1C,OAAO,KAAK;AAAA,MACd;AAAA,IACF;AAAA,EACF,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
2
|
import { useArbi } from "../../useArbi.js";
|
|
3
3
|
import { useConversations } from "../../hooks.js";
|
|
4
|
+
import { cellText, defineAggregateSource } from "../aggregate-source.js";
|
|
4
5
|
import { useNames } from "../members.js";
|
|
5
|
-
import { defineRowsSource, staticFields } from "../rows-source.js";
|
|
6
6
|
const DEFAULT_CONVERSATIONS_SOURCE_LABELS = {
|
|
7
7
|
source: "Threads",
|
|
8
8
|
description: "The threads and tasks of the open workspace: activity, status, owners, due dates.",
|
|
@@ -36,15 +36,45 @@ function createConversationsSource(labels) {
|
|
|
36
36
|
{ id: "messages", label: l.messages, type: "number" },
|
|
37
37
|
{ id: "shared", label: l.shared, type: "boolean" }
|
|
38
38
|
];
|
|
39
|
-
|
|
39
|
+
const byId = new Map(fields.map((f) => [f.id, f]));
|
|
40
|
+
const field = (id) => byId.get(id) ?? { id, label: id, type: "string" };
|
|
41
|
+
const statusOf = (status) => status === "todo" || status === "generating" || status === "done" ? l.statuses[status] : status;
|
|
42
|
+
function useWorkspaceOf(params) {
|
|
43
|
+
const arbi = useArbi();
|
|
44
|
+
return typeof params.workspaceId === "string" && params.workspaceId ? params.workspaceId : arbi.hasWorkspace ? arbi.getWorkspaceId() : void 0;
|
|
45
|
+
}
|
|
46
|
+
return defineAggregateSource({
|
|
40
47
|
id: "conversations",
|
|
41
|
-
|
|
48
|
+
source: "conversations",
|
|
42
49
|
label: l.source,
|
|
43
50
|
description: l.description,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
51
|
+
fields,
|
|
52
|
+
useAggregateFields(enabled) {
|
|
53
|
+
const nameOf = useNames(enabled);
|
|
54
|
+
return useMemo(
|
|
55
|
+
() => [
|
|
56
|
+
{ field: field("title"), from: ["title"] },
|
|
57
|
+
{ field: field("created"), from: ["created"] },
|
|
58
|
+
{ field: field("lastActivity"), from: ["last_activity"] },
|
|
59
|
+
{ field: field("due"), from: ["due"] },
|
|
60
|
+
{ field: field("completed"), from: ["completed"] },
|
|
61
|
+
{
|
|
62
|
+
field: field("kind"),
|
|
63
|
+
from: ["status"],
|
|
64
|
+
value: ([s]) => cellText(s) ? l.task : l.thread
|
|
65
|
+
},
|
|
66
|
+
{ field: field("status"), from: ["status"], value: ([s]) => statusOf(cellText(s)) },
|
|
67
|
+
{ field: field("overdue"), from: ["overdue"] },
|
|
68
|
+
{ field: field("owner"), from: ["owner"], value: ([u]) => nameOf(cellText(u)) },
|
|
69
|
+
{ field: field("messages"), from: ["messages"] },
|
|
70
|
+
{ field: field("shared"), from: ["shared"] }
|
|
71
|
+
],
|
|
72
|
+
[nameOf]
|
|
73
|
+
);
|
|
74
|
+
},
|
|
75
|
+
useWorkspace: useWorkspaceOf,
|
|
76
|
+
useRecords(params, enabled) {
|
|
77
|
+
const workspaceId = useWorkspaceOf(params);
|
|
48
78
|
const query = useConversations(workspaceId, { enabled });
|
|
49
79
|
const nameOf = useNames(enabled);
|
|
50
80
|
const rows = useMemo(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/datasets/sources/conversations.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The conversations of a workspace (threads and tasks) as a dataset (default: the open one;\n * `params.workspaceId` names another): activity over time, work by status, owner and due date.\n *
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * The conversations of a workspace (threads and tasks) as a dataset (default: the open one;\n * `params.workspaceId` names another): activity over time, work by status, owner and due date.\n * Counted on the server (`defineAggregateSource`); a table of threads (due dates) reads the shared\n * conversation list (`useConversations`).\n */\nimport { useMemo } from 'react'\nimport { useArbi } from '../../useArbi'\nimport { useConversations } from '../../hooks'\nimport { cellText, defineAggregateSource, type AggregateField } from '../aggregate-source'\nimport { useNames } from '../members'\nimport type { DataSource, DataSourceParams, DatasetField, DatasetRow } from '../types'\n\nexport interface ConversationsSourceLabels {\n source: string\n description: string\n title: string\n created: string\n lastActivity: string\n due: string\n completed: string\n kind: string\n /** The `kind` of a conversation without a work status. */\n thread: string\n /** The `kind` of a conversation with a work status. */\n task: string\n status: string\n statuses: { todo: string; generating: string; done: string }\n overdue: string\n owner: string\n messages: string\n shared: string\n}\n\nexport const DEFAULT_CONVERSATIONS_SOURCE_LABELS: ConversationsSourceLabels = {\n source: 'Threads',\n description: 'The threads and tasks of the open workspace: activity, status, owners, due dates.',\n title: 'Title',\n created: 'Started',\n lastActivity: 'Last activity',\n due: 'Due',\n completed: 'Completed',\n kind: 'Kind',\n thread: 'Thread',\n task: 'Task',\n status: 'Status',\n statuses: { todo: 'To do', generating: 'Running', done: 'Done' },\n overdue: 'Overdue',\n owner: 'Owner',\n messages: 'Messages',\n shared: 'Shared',\n}\n\ninterface ConversationLike {\n external_id: string\n title?: string | null\n created_at?: string | null\n updated_at?: string | null\n last_message_updated_at?: string | null\n due_at?: string | null\n completed_at?: string | null\n status?: 'todo' | 'generating' | 'done' | null\n is_shared?: boolean | null\n message_count?: number | null\n owner_ext_id?: string | null\n created_by_ext_id?: string | null\n}\n\nexport function createConversationsSource(labels?: Partial<ConversationsSourceLabels>): DataSource {\n const l = { ...DEFAULT_CONVERSATIONS_SOURCE_LABELS, ...labels }\n const fields: DatasetField[] = [\n { id: 'title', label: l.title, type: 'string' },\n { id: 'created', label: l.created, type: 'date' },\n { id: 'lastActivity', label: l.lastActivity, type: 'date' },\n { id: 'due', label: l.due, type: 'date' },\n { id: 'completed', label: l.completed, type: 'date' },\n { id: 'kind', label: l.kind, type: 'string', options: [l.thread, l.task] },\n { id: 'status', label: l.status, type: 'string', options: Object.values(l.statuses) },\n { id: 'overdue', label: l.overdue, type: 'boolean' },\n { id: 'owner', label: l.owner, type: 'string' },\n { id: 'messages', label: l.messages, type: 'number' },\n { id: 'shared', label: l.shared, type: 'boolean' },\n ]\n const byId = new Map(fields.map((f) => [f.id, f]))\n const field = (id: string): DatasetField => byId.get(id) ?? { id, label: id, type: 'string' }\n const statusOf = (status: string | null): string | null =>\n status === 'todo' || status === 'generating' || status === 'done' ? l.statuses[status] : status\n function useWorkspaceOf(params: DataSourceParams): string | undefined {\n const arbi = useArbi()\n return typeof params.workspaceId === 'string' && params.workspaceId\n ? params.workspaceId\n : arbi.hasWorkspace\n ? arbi.getWorkspaceId()\n : undefined\n }\n return defineAggregateSource({\n id: 'conversations',\n source: 'conversations',\n label: l.source,\n description: l.description,\n fields,\n useAggregateFields(enabled) {\n const nameOf = useNames(enabled)\n return useMemo(\n (): AggregateField[] => [\n { field: field('title'), from: ['title'] },\n { field: field('created'), from: ['created'] },\n { field: field('lastActivity'), from: ['last_activity'] },\n { field: field('due'), from: ['due'] },\n { field: field('completed'), from: ['completed'] },\n {\n field: field('kind'),\n from: ['status'],\n value: ([s]) => (cellText(s) ? l.task : l.thread),\n },\n { field: field('status'), from: ['status'], value: ([s]) => statusOf(cellText(s)) },\n { field: field('overdue'), from: ['overdue'] },\n { field: field('owner'), from: ['owner'], value: ([u]) => nameOf(cellText(u)) },\n { field: field('messages'), from: ['messages'] },\n { field: field('shared'), from: ['shared'] },\n ],\n [nameOf]\n )\n },\n useWorkspace: useWorkspaceOf,\n useRecords(params: DataSourceParams, enabled) {\n const workspaceId = useWorkspaceOf(params)\n const query = useConversations(workspaceId, { enabled })\n const nameOf = useNames(enabled)\n const rows = useMemo(() => {\n const now = new Date().toISOString()\n return (query.data as ConversationLike[] | undefined)?.map((c): DatasetRow => ({\n title: c.title || null,\n created: c.created_at ?? null,\n lastActivity: c.last_message_updated_at ?? c.updated_at ?? null,\n due: c.due_at ?? null,\n completed: c.completed_at ?? null,\n kind: c.status ? l.task : l.thread,\n status: c.status ? l.statuses[c.status] : null,\n overdue: Boolean(c.due_at && c.status !== 'done' && c.due_at < now),\n owner: nameOf(c.owner_ext_id ?? c.created_by_ext_id),\n messages: c.message_count ?? null,\n shared: c.is_shared ?? null,\n }))\n }, [query.data, nameOf])\n return { rows, isLoading: enabled && query.isPending, error: query.error }\n },\n })\n}\n"],
|
|
5
|
+
"mappings": "AAMA,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,wBAAwB;AACjC,SAAS,UAAU,6BAAkD;AACrE,SAAS,gBAAgB;AAwBlB,MAAM,sCAAiE;AAAA,EAC5E,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,OAAO;AAAA,EACP,S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
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
+
import { useArbi } from "../../useArbi.js";
|
|
2
3
|
import { useDocuments } from "../../documents/documents-data.js";
|
|
3
4
|
import { friendlyFileType } from "../../entities/file-type.js";
|
|
5
|
+
import { cellText, defineAggregateSource } from "../aggregate-source.js";
|
|
4
6
|
import { useNames } from "../members.js";
|
|
5
|
-
import { defineRowsSource, staticFields } from "../rows-source.js";
|
|
6
7
|
const DEFAULT_DOCUMENTS_SOURCE_LABELS = {
|
|
7
8
|
source: "Documents",
|
|
8
9
|
description: "The documents of the open workspace: type, folder, status, dates.",
|
|
@@ -55,13 +56,50 @@ function createDocumentsSource(labels) {
|
|
|
55
56
|
{ id: "size", label: l.size, type: "number", unit: "bytes" },
|
|
56
57
|
{ id: "shared", label: l.shared, type: "boolean" }
|
|
57
58
|
];
|
|
58
|
-
|
|
59
|
+
const byId = new Map(fields.map((f) => [f.id, f]));
|
|
60
|
+
const field = (id) => byId.get(id) ?? { id, label: id, type: "string" };
|
|
61
|
+
const statusOf = (status) => status ? l.statuses[status] ?? status : null;
|
|
62
|
+
return defineAggregateSource({
|
|
59
63
|
id: "documents",
|
|
60
|
-
|
|
64
|
+
source: "documents",
|
|
61
65
|
label: l.source,
|
|
62
66
|
description: l.description,
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
fields,
|
|
68
|
+
useAggregateFields(enabled) {
|
|
69
|
+
const nameOf = useNames(enabled);
|
|
70
|
+
return useMemo(
|
|
71
|
+
() => [
|
|
72
|
+
{ field: field("name"), from: ["name"] },
|
|
73
|
+
{ field: field("created"), from: ["created"] },
|
|
74
|
+
{ field: field("updated"), from: ["updated"] },
|
|
75
|
+
// Encrypted: the server buckets it, but cannot compare it.
|
|
76
|
+
{ field: field("documentDate"), from: ["document_date"], server: false },
|
|
77
|
+
{ field: field("status"), from: ["status"], value: ([s]) => statusOf(cellText(s)) },
|
|
78
|
+
{
|
|
79
|
+
field: field("type"),
|
|
80
|
+
// The name's extension, not the name: what a file type is read from.
|
|
81
|
+
from: ["file_type", "extension", "folder"],
|
|
82
|
+
value: ([type, extension, folder]) => {
|
|
83
|
+
const ext = cellText(extension);
|
|
84
|
+
return friendlyFileType(cellText(type), ext ? `file.${ext}` : null, cellText(folder)) || null;
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
{ field: field("folder"), from: ["folder"], value: ([f]) => cellText(f) },
|
|
88
|
+
{ field: field("nature"), from: ["nature"] },
|
|
89
|
+
{ field: field("author"), from: ["author"] },
|
|
90
|
+
{ field: field("createdBy"), from: ["created_by"], value: ([u]) => nameOf(cellText(u)) },
|
|
91
|
+
{ field: field("pages"), from: ["pages"] },
|
|
92
|
+
{ field: field("size"), from: ["size"] },
|
|
93
|
+
{ field: field("shared"), from: ["shared"] }
|
|
94
|
+
],
|
|
95
|
+
[nameOf]
|
|
96
|
+
);
|
|
97
|
+
},
|
|
98
|
+
useWorkspace(params) {
|
|
99
|
+
const arbi = useArbi();
|
|
100
|
+
return workspaceOf(params) ?? (arbi.hasWorkspace ? arbi.getWorkspaceId() : void 0);
|
|
101
|
+
},
|
|
102
|
+
useRecords(params, enabled) {
|
|
65
103
|
const query = useDocuments(workspaceOf(params), { enabled });
|
|
66
104
|
const nameOf = useNames(enabled);
|
|
67
105
|
const rows = useMemo(
|
|
@@ -70,7 +108,7 @@ function createDocumentsSource(labels) {
|
|
|
70
108
|
created: d.created_at ?? null,
|
|
71
109
|
updated: d.updated_at ?? null,
|
|
72
110
|
documentDate: d.doc_metadata?.doc_date ?? null,
|
|
73
|
-
status: d.status
|
|
111
|
+
status: statusOf(d.status ?? null),
|
|
74
112
|
type: friendlyFileType(d.file_type, d.file_name, d.folder) || null,
|
|
75
113
|
folder: d.folder || null,
|
|
76
114
|
nature: d.doc_metadata?.doc_nature ?? null,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/datasets/sources/documents.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The documents of a workspace as a dataset (default: the open one; `params.workspaceId` names\n * another): counts and status by type, folder, author or time.
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * The documents of a workspace as a dataset (default: the open one; `params.workspaceId` names\n * another): counts and status by type, folder, author or time. Counted on the server\n * (`defineAggregateSource`), over every document at once; a table of the latest documents reads\n * the shared documents list (`useDocuments`).\n */\nimport { useMemo } from 'react'\nimport { useArbi } from '../../useArbi'\nimport { useDocuments } from '../../documents/documents-data'\nimport { friendlyFileType } from '../../entities/file-type'\nimport { cellText, defineAggregateSource, type AggregateField } from '../aggregate-source'\nimport { useNames } from '../members'\nimport type { DataSource, DataSourceParams, DatasetField, DatasetRow } from '../types'\n\n/** The field labels (a site's words). */\nexport interface DocumentsSourceLabels {\n source: string\n description: string\n created: string\n updated: string\n documentDate: string\n status: string\n /** A processing status by the server's name; one not listed is shown as it comes. */\n statuses: Readonly<Record<string, string>>\n type: string\n folder: string\n nature: string\n author: string\n createdBy: string\n pages: string\n size: string\n shared: string\n}\n\nexport const DEFAULT_DOCUMENTS_SOURCE_LABELS: DocumentsSourceLabels = {\n source: 'Documents',\n description: 'The documents of the open workspace: type, folder, status, dates.',\n created: 'Added',\n updated: 'Updated',\n documentDate: 'Document date',\n status: 'Status',\n statuses: {\n completed: 'Ready',\n 'low-content': 'Little text',\n failed: 'Failed',\n skipped: 'Skipped',\n empty: 'Empty',\n queued: 'Queued',\n uploading: 'Uploading',\n parsing: 'Processing',\n encrypting: 'Processing',\n indexing: 'Processing',\n analysing: 'Processing',\n },\n type: 'Type',\n folder: 'Folder',\n nature: 'Kind of document',\n author: 'Author',\n createdBy: 'Added by',\n pages: 'Pages',\n size: 'Size',\n shared: 'Shared',\n}\n\ninterface DocumentLike {\n external_id: string\n file_name?: string | null\n file_type?: string | null\n file_size?: number | null\n status?: string | null\n folder?: string | null\n n_pages?: number | null\n shared?: boolean | null\n created_by_ext_id?: string | null\n created_at?: string | null\n updated_at?: string | null\n doc_metadata?: {\n doc_nature?: string | null\n doc_author?: string | null\n doc_date?: string | null\n title?: string | null\n } | null\n}\n\nconst workspaceOf = (params: DataSourceParams) =>\n typeof params.workspaceId === 'string' && params.workspaceId ? params.workspaceId : undefined\n\nexport function createDocumentsSource(labels?: Partial<DocumentsSourceLabels>): DataSource {\n const l = { ...DEFAULT_DOCUMENTS_SOURCE_LABELS, ...labels }\n const fields: DatasetField[] = [\n { id: 'name', label: l.source, type: 'string' },\n { id: 'created', label: l.created, type: 'date' },\n { id: 'updated', label: l.updated, type: 'date' },\n { id: 'documentDate', label: l.documentDate, type: 'date' },\n {\n id: 'status',\n label: l.status,\n type: 'string',\n options: [...new Set(Object.values(l.statuses))],\n },\n { id: 'type', label: l.type, type: 'string' },\n { id: 'folder', label: l.folder, type: 'string' },\n { id: 'nature', label: l.nature, type: 'string' },\n { id: 'author', label: l.author, type: 'string' },\n { id: 'createdBy', label: l.createdBy, type: 'string' },\n { id: 'pages', label: l.pages, type: 'number' },\n { id: 'size', label: l.size, type: 'number', unit: 'bytes' },\n { id: 'shared', label: l.shared, type: 'boolean' },\n ]\n const byId = new Map(fields.map((f) => [f.id, f]))\n const field = (id: string): DatasetField => byId.get(id) ?? { id, label: id, type: 'string' }\n const statusOf = (status: string | null) => (status ? (l.statuses[status] ?? status) : null)\n return defineAggregateSource({\n id: 'documents',\n source: 'documents',\n label: l.source,\n description: l.description,\n fields,\n useAggregateFields(enabled) {\n const nameOf = useNames(enabled)\n return useMemo(\n (): AggregateField[] => [\n { field: field('name'), from: ['name'] },\n { field: field('created'), from: ['created'] },\n { field: field('updated'), from: ['updated'] },\n // Encrypted: the server buckets it, but cannot compare it.\n { field: field('documentDate'), from: ['document_date'], server: false },\n { field: field('status'), from: ['status'], value: ([s]) => statusOf(cellText(s)) },\n {\n field: field('type'),\n // The name's extension, not the name: what a file type is read from.\n from: ['file_type', 'extension', 'folder'],\n value: ([type, extension, folder]) => {\n const ext = cellText(extension)\n return (\n friendlyFileType(cellText(type), ext ? `file.${ext}` : null, cellText(folder)) ||\n null\n )\n },\n },\n { field: field('folder'), from: ['folder'], value: ([f]) => cellText(f) },\n { field: field('nature'), from: ['nature'] },\n { field: field('author'), from: ['author'] },\n { field: field('createdBy'), from: ['created_by'], value: ([u]) => nameOf(cellText(u)) },\n { field: field('pages'), from: ['pages'] },\n { field: field('size'), from: ['size'] },\n { field: field('shared'), from: ['shared'] },\n ],\n [nameOf]\n )\n },\n useWorkspace(params) {\n const arbi = useArbi()\n return workspaceOf(params) ?? (arbi.hasWorkspace ? arbi.getWorkspaceId() : undefined)\n },\n useRecords(params, enabled) {\n const query = useDocuments(workspaceOf(params), { enabled })\n const nameOf = useNames(enabled)\n const rows = useMemo(\n () =>\n (query.data as DocumentLike[] | undefined)?.map((d): DatasetRow => ({\n name: d.doc_metadata?.title || d.file_name || d.external_id,\n created: d.created_at ?? null,\n updated: d.updated_at ?? null,\n documentDate: d.doc_metadata?.doc_date ?? null,\n status: statusOf(d.status ?? null),\n type: friendlyFileType(d.file_type, d.file_name, d.folder) || null,\n folder: d.folder || null,\n nature: d.doc_metadata?.doc_nature ?? null,\n author: d.doc_metadata?.doc_author ?? null,\n createdBy: nameOf(d.created_by_ext_id),\n pages: d.n_pages ?? null,\n size: d.file_size ?? null,\n shared: d.shared ?? null,\n })),\n [query.data, nameOf]\n )\n return { rows, isLoading: enabled && query.isPending, error: query.error }\n },\n })\n}\n"],
|
|
5
|
+
"mappings": "AAMA,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,SAAS,UAAU,6BAAkD;AACrE,SAAS,gBAAgB;AAuBlB,MAAM,kCAAyD;AAAA,EACpE,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,SAAS;AAAA,EACT,SAAS;AAAA,EACT,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,UAAU;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B,cAAc,EAAE,cAAc,YAAY;AAAA,UAC1C,QAAQ,SAAS,EAAE,UAAU,IAAI;AAAA,UACjC,MAAM,iBAAiB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,KAAK;AAAA,UAC9D,QAAQ,EAAE,UAAU;AAAA,UACpB,QAAQ,EAAE,cAAc,cAAc;AAAA,UACtC,QAAQ,EAAE,cAAc,cAAc;AAAA,UACtC,WAAW,OAAO,EAAE,iBAAiB;AAAA,UACrC,OAAO,EAAE,WAAW;AAAA,UACpB,MAAM,EAAE,aAAa;AAAA,UACrB,QAAQ,EAAE,UAAU;AAAA,QACtB,EAAE;AAAA,QACJ,CAAC,MAAM,MAAM,MAAM;AAAA,MACrB;AACA,aAAO,EAAE,MAAM,WAAW,WAAW,MAAM,WAAW,OAAO,MAAM,MAAM;AAAA,IAC3E;AAAA,EACF,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
2
|
import { useFacts } from "../../facts.js";
|
|
3
|
+
import {
|
|
4
|
+
cellText,
|
|
5
|
+
defineAggregateSource,
|
|
6
|
+
useOpenWorkspace
|
|
7
|
+
} from "../aggregate-source.js";
|
|
3
8
|
import { useNames } from "../members.js";
|
|
4
|
-
import { defineRowsSource, staticFields } from "../rows-source.js";
|
|
5
9
|
const DEFAULT_FACTS_SOURCE_LABELS = {
|
|
6
10
|
source: "Facts",
|
|
7
11
|
description: "The facts of the open workspace: their tags, dates, and whether they are confirmed.",
|
|
@@ -24,13 +28,35 @@ function createFactsSource(labels) {
|
|
|
24
28
|
{ id: "created", label: l.created, type: "date" },
|
|
25
29
|
{ id: "createdBy", label: l.createdBy, type: "string" }
|
|
26
30
|
];
|
|
27
|
-
|
|
31
|
+
const byId = new Map(fields.map((f) => [f.id, f]));
|
|
32
|
+
const field = (id) => byId.get(id) ?? { id, label: id, type: "string" };
|
|
33
|
+
return defineAggregateSource({
|
|
28
34
|
id: "facts",
|
|
29
|
-
|
|
35
|
+
source: "facts",
|
|
30
36
|
label: l.source,
|
|
31
37
|
description: l.description,
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
fields,
|
|
39
|
+
useAggregateFields(enabled) {
|
|
40
|
+
const nameOf = useNames(enabled);
|
|
41
|
+
return useMemo(
|
|
42
|
+
() => [
|
|
43
|
+
{ field: field("text"), from: ["text"] },
|
|
44
|
+
{
|
|
45
|
+
field: field("tags"),
|
|
46
|
+
from: ["tags"],
|
|
47
|
+
value: ([ids], labels2) => Array.isArray(ids) ? ids.map((id) => labels2[id] ?? id) : []
|
|
48
|
+
},
|
|
49
|
+
{ field: field("confirmed"), from: ["confirmed"] },
|
|
50
|
+
{ field: field("shared"), from: ["shared"] },
|
|
51
|
+
{ field: field("date"), from: ["date"] },
|
|
52
|
+
{ field: field("created"), from: ["created"] },
|
|
53
|
+
{ field: field("createdBy"), from: ["created_by"], value: ([u]) => nameOf(cellText(u)) }
|
|
54
|
+
],
|
|
55
|
+
[nameOf]
|
|
56
|
+
);
|
|
57
|
+
},
|
|
58
|
+
useWorkspace: useOpenWorkspace,
|
|
59
|
+
useRecords(_params, enabled) {
|
|
34
60
|
const query = useFacts(void 0, { enabled });
|
|
35
61
|
const nameOf = useNames(enabled);
|
|
36
62
|
const rows = useMemo(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/datasets/sources/facts.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The facts (notes) of the open workspace as a dataset: a row per fact with its tags (a fact counts\n * under each), whether it is confirmed, its date and who added it.
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["/**\n * The facts (notes) of the open workspace as a dataset: a row per fact with its tags (a fact counts\n * under each), whether it is confirmed, its date and who added it. Counted on the server\n * (`defineAggregateSource`: a fact's tags come as ids, with their names); a table of the latest\n * facts reads the shared fact list (`useFacts`).\n */\nimport { useMemo } from 'react'\nimport type { FactResponse } from '@arbidocs/sdk/browser'\nimport { useFacts } from '../../facts'\nimport {\n cellText,\n defineAggregateSource,\n useOpenWorkspace,\n type AggregateField,\n} from '../aggregate-source'\nimport { useNames } from '../members'\nimport type { DataSource, DatasetField, DatasetRow } from '../types'\n\nexport interface FactsSourceLabels {\n source: string\n description: string\n text: string\n tags: string\n confirmed: string\n shared: string\n date: string\n created: string\n createdBy: string\n}\n\nexport const DEFAULT_FACTS_SOURCE_LABELS: FactsSourceLabels = {\n source: 'Facts',\n description:\n 'The facts of the open workspace: their tags, dates, and whether they are confirmed.',\n text: 'Fact',\n tags: 'Tags',\n confirmed: 'Confirmed',\n shared: 'Shared',\n date: 'Date',\n created: 'Added',\n createdBy: 'Added by',\n}\n\nexport function createFactsSource(labels?: Partial<FactsSourceLabels>): DataSource {\n const l = { ...DEFAULT_FACTS_SOURCE_LABELS, ...labels }\n const fields: DatasetField[] = [\n { id: 'text', label: l.text, type: 'string' },\n { id: 'tags', label: l.tags, type: 'string', multiple: true },\n { id: 'confirmed', label: l.confirmed, type: 'boolean' },\n { id: 'shared', label: l.shared, type: 'boolean' },\n { id: 'date', label: l.date, type: 'date' },\n { id: 'created', label: l.created, type: 'date' },\n { id: 'createdBy', label: l.createdBy, type: 'string' },\n ]\n const byId = new Map(fields.map((f) => [f.id, f]))\n const field = (id: string): DatasetField => byId.get(id) ?? { id, label: id, type: 'string' }\n return defineAggregateSource({\n id: 'facts',\n source: 'facts',\n label: l.source,\n description: l.description,\n fields,\n useAggregateFields(enabled) {\n const nameOf = useNames(enabled)\n return useMemo(\n (): AggregateField[] => [\n { field: field('text'), from: ['text'] },\n {\n field: field('tags'),\n from: ['tags'],\n value: ([ids], labels) => (Array.isArray(ids) ? ids.map((id) => labels[id] ?? id) : []),\n },\n { field: field('confirmed'), from: ['confirmed'] },\n { field: field('shared'), from: ['shared'] },\n { field: field('date'), from: ['date'] },\n { field: field('created'), from: ['created'] },\n { field: field('createdBy'), from: ['created_by'], value: ([u]) => nameOf(cellText(u)) },\n ],\n [nameOf]\n )\n },\n useWorkspace: useOpenWorkspace,\n useRecords(_params, enabled) {\n const query = useFacts(undefined, { enabled })\n const nameOf = useNames(enabled)\n const rows = useMemo(\n () =>\n (query.data as FactResponse[] | undefined)?.map((f): DatasetRow => ({\n text: f.text,\n tags: f.tags.map((t) => t.name),\n confirmed: f.confirmed,\n shared: f.shared,\n date: f.date_start ?? null,\n created: f.created_at,\n createdBy: nameOf(f.created_by_ext_id),\n })),\n [query.data, nameOf]\n )\n return { rows, isLoading: enabled && query.isPending, error: query.error }\n },\n })\n}\n"],
|
|
5
|
+
"mappings": "AAMA,SAAS,eAAe;AAExB,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,gBAAgB;AAelB,MAAM,8BAAiD;AAAA,EAC5D,QAAQ;AAAA,EACR,aACE;AAAA,EACF,MAAM;AAAA,EACN,MAAM;AAAA,EACN,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,SAAS;AAAA,EACT,WAAW;AACb;AAEO,SAAS,kBAAkB,QAAiD;AACjF,QAAM,IAAI,EAAE,GAAG,6BAA6B,GAAG,OAAO;AACtD,QAAM,SAAyB;AAAA,IAC7B,EAAE,IAAI,QAAQ,OAAO,EAAE,MAAM,MAAM,SAAS;AAAA,IAC5C,EAAE,IAAI,QAAQ,OAAO,EAAE,MAAM,MAAM,UAAU,UAAU,KAAK;AAAA,IAC5D,EAAE,IAAI,aAAa,OAAO,EAAE,WAAW,MAAM,UAAU;AAAA,IACvD,EAAE,IAAI,UAAU,OAAO,EAAE,QAAQ,MAAM,UAAU;AAAA,IACjD,EAAE,IAAI,QAAQ,OAAO,EAAE,MAAM,MAAM,OAAO;AAAA,IAC1C,EAAE,IAAI,WAAW,OAAO,EAAE,SAAS,MAAM,OAAO;AAAA,IAChD,EAAE,IAAI,aAAa,OAAO,EAA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EAAE,QAAQ,CAAC;AAC7C,YAAM,SAAS,SAAS,OAAO;AAC/B,YAAM,OAAO;AAAA,QACX,MACG,MAAM,MAAqC,IAAI,CAAC,OAAmB;AAAA,UAClE,MAAM,EAAE;AAAA,UACR,MAAM,EAAE,KAAK,IAAI,CAAC,MAAM,EAAE,IAAI;AAAA,UAC9B,WAAW,EAAE;AAAA,UACb,QAAQ,EAAE;AAAA,UACV,MAAM,EAAE,cAAc;AAAA,UACtB,SAAS,EAAE;AAAA,UACX,WAAW,OAAO,EAAE,iBAAiB;AAAA,QACvC,EAAE;AAAA,QACJ,CAAC,MAAM,MAAM,MAAM;AAAA,MACrB;AACA,aAAO,EAAE,MAAM,WAAW,WAAW,MAAM,WAAW,OAAO,MAAM,MAAM;AAAA,IAC3E;AAAA,EACF,CAAC;AACH;",
|
|
6
|
+
"names": ["labels"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
2
|
import { useTags } from "../../hooks.js";
|
|
3
|
+
import {
|
|
4
|
+
cellText,
|
|
5
|
+
defineAggregateSource,
|
|
6
|
+
useOpenWorkspace
|
|
7
|
+
} from "../aggregate-source.js";
|
|
3
8
|
import { useNames } from "../members.js";
|
|
4
|
-
import { defineRowsSource, staticFields } from "../rows-source.js";
|
|
5
9
|
const DEFAULT_TAGS_SOURCE_LABELS = {
|
|
6
10
|
source: "Tags",
|
|
7
11
|
description: "The tags of the open workspace: their kind, and the documents, facts and threads carrying them.",
|
|
@@ -34,13 +38,41 @@ function createTagsSource(labels) {
|
|
|
34
38
|
{ id: "created", label: l.created, type: "date" },
|
|
35
39
|
{ id: "createdBy", label: l.createdBy, type: "string" }
|
|
36
40
|
];
|
|
37
|
-
|
|
41
|
+
const byId = new Map(fields.map((f) => [f.id, f]));
|
|
42
|
+
const field = (id) => byId.get(id) ?? { id, label: id, type: "string" };
|
|
43
|
+
const kinds = new Map(Object.entries(l.kinds));
|
|
44
|
+
const kindOf = (kind) => kind ? kinds.get(kind) ?? kind : null;
|
|
45
|
+
return defineAggregateSource({
|
|
38
46
|
id: "tags",
|
|
39
|
-
|
|
47
|
+
source: "tags",
|
|
40
48
|
label: l.source,
|
|
41
49
|
description: l.description,
|
|
42
|
-
|
|
43
|
-
|
|
50
|
+
fields,
|
|
51
|
+
useAggregateFields(enabled) {
|
|
52
|
+
const nameOf = useNames(enabled);
|
|
53
|
+
return useMemo(
|
|
54
|
+
() => [
|
|
55
|
+
{
|
|
56
|
+
field: field("name"),
|
|
57
|
+
from: ["name"],
|
|
58
|
+
value: ([id], labels2) => {
|
|
59
|
+
const tag = cellText(id);
|
|
60
|
+
return tag ? labels2[tag] ?? tag : null;
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{ field: field("kind"), from: ["kind"], value: ([k]) => kindOf(cellText(k)) },
|
|
64
|
+
{ field: field("documents"), from: ["documents"] },
|
|
65
|
+
{ field: field("facts"), from: ["facts"] },
|
|
66
|
+
{ field: field("threads"), from: ["threads"] },
|
|
67
|
+
{ field: field("shared"), from: ["shared"] },
|
|
68
|
+
{ field: field("created"), from: ["created"] },
|
|
69
|
+
{ field: field("createdBy"), from: ["created_by"], value: ([u]) => nameOf(cellText(u)) }
|
|
70
|
+
],
|
|
71
|
+
[nameOf]
|
|
72
|
+
);
|
|
73
|
+
},
|
|
74
|
+
useWorkspace: useOpenWorkspace,
|
|
75
|
+
useRecords(_params, enabled) {
|
|
44
76
|
const query = useTags(void 0, { enabled });
|
|
45
77
|
const nameOf = useNames(enabled);
|
|
46
78
|
const rows = useMemo(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/datasets/sources/tags.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The tags of the open workspace as a dataset: a row per tag with its kind, and how many\n * documents, facts and threads carry it. The most used tags, or tags by kind, are a group-by and a\n * sum away.
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["/**\n * The tags of the open workspace as a dataset: a row per tag with its kind, and how many\n * documents, facts and threads carry it. The most used tags, or tags by kind, are a group-by and a\n * sum away. Counted on the server (`defineAggregateSource`: a tag's name comes with its id); a\n * table of tags reads the shared tag list (`useTags`).\n */\nimport { useMemo } from 'react'\nimport type { TagResponse } from '@arbidocs/sdk/browser'\nimport { useTags } from '../../hooks'\nimport {\n cellText,\n defineAggregateSource,\n useOpenWorkspace,\n type AggregateField,\n} from '../aggregate-source'\nimport { useNames } from '../members'\nimport type { DataSource, DatasetField, DatasetRow } from '../types'\n\nexport interface TagsSourceLabels {\n source: string\n description: string\n name: string\n kind: string\n kinds: Record<TagResponse['kind'], string>\n documents: string\n facts: string\n threads: string\n shared: string\n created: string\n createdBy: string\n}\n\nexport const DEFAULT_TAGS_SOURCE_LABELS: TagsSourceLabels = {\n source: 'Tags',\n description:\n 'The tags of the open workspace: their kind, and the documents, facts and threads carrying them.',\n name: 'Tag',\n kind: 'Kind',\n kinds: {\n label: 'Label',\n annotation: 'Annotation',\n search: 'Search',\n issue: 'Issue',\n person: 'Person',\n organisation: 'Organisation',\n },\n documents: 'Documents',\n facts: 'Facts',\n threads: 'Threads',\n shared: 'Shared',\n created: 'Created',\n createdBy: 'Created by',\n}\n\nexport function createTagsSource(labels?: Partial<TagsSourceLabels>): DataSource {\n const l = { ...DEFAULT_TAGS_SOURCE_LABELS, ...labels }\n const fields: DatasetField[] = [\n { id: 'name', label: l.name, type: 'string' },\n { id: 'kind', label: l.kind, type: 'string', options: Object.values(l.kinds) },\n { id: 'documents', label: l.documents, type: 'number' },\n { id: 'facts', label: l.facts, type: 'number' },\n { id: 'threads', label: l.threads, type: 'number' },\n { id: 'shared', label: l.shared, type: 'boolean' },\n { id: 'created', label: l.created, type: 'date' },\n { id: 'createdBy', label: l.createdBy, type: 'string' },\n ]\n const byId = new Map(fields.map((f) => [f.id, f]))\n const field = (id: string): DatasetField => byId.get(id) ?? { id, label: id, type: 'string' }\n const kinds = new Map<string, string>(Object.entries(l.kinds))\n const kindOf = (kind: string | null): string | null => (kind ? (kinds.get(kind) ?? kind) : null)\n return defineAggregateSource({\n id: 'tags',\n source: 'tags',\n label: l.source,\n description: l.description,\n fields,\n useAggregateFields(enabled) {\n const nameOf = useNames(enabled)\n return useMemo(\n (): AggregateField[] => [\n {\n field: field('name'),\n from: ['name'],\n value: ([id], labels) => {\n const tag = cellText(id)\n return tag ? (labels[tag] ?? tag) : null\n },\n },\n { field: field('kind'), from: ['kind'], value: ([k]) => kindOf(cellText(k)) },\n { field: field('documents'), from: ['documents'] },\n { field: field('facts'), from: ['facts'] },\n { field: field('threads'), from: ['threads'] },\n { field: field('shared'), from: ['shared'] },\n { field: field('created'), from: ['created'] },\n { field: field('createdBy'), from: ['created_by'], value: ([u]) => nameOf(cellText(u)) },\n ],\n [nameOf]\n )\n },\n useWorkspace: useOpenWorkspace,\n useRecords(_params, enabled) {\n const query = useTags(undefined, { enabled })\n const nameOf = useNames(enabled)\n const rows = useMemo(\n () =>\n (query.data as TagResponse[] | undefined)?.map((t): DatasetRow => ({\n name: t.name,\n kind: l.kinds[t.kind] ?? t.kind,\n documents: t.doctag_count,\n facts: t.facttag_count,\n threads: t.convotag_count,\n shared: t.shared,\n created: t.created_at,\n createdBy: nameOf(t.created_by_ext_id),\n })),\n [query.data, nameOf]\n )\n return { rows, isLoading: enabled && query.isPending, error: query.error }\n },\n })\n}\n"],
|
|
5
|
+
"mappings": "AAMA,SAAS,eAAe;AAExB,SAAS,eAAe;AACxB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,gBAAgB;AAiBlB,MAAM,6BAA+C;AAAA,EAC1D,QAAQ;AAAA,EACR,aACE;AAAA,EACF,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,IACL,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,QAAQ;AAAA,I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