@startsimpli/integrations 0.2.101 → 0.2.103
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/package.json +3 -3
- package/src/__tests__/focus-standings.test.tsx +119 -0
- package/src/components/pages/PlanningPage.tsx +16 -4
- package/src/corpus/client.ts +5 -0
- package/src/corpus/entity-query.ts +67 -4
- package/src/corpus/index.ts +4 -2
- package/src/corpus/standings.ts +75 -0
- package/src/corpus/types.ts +6 -0
- package/src/native/app/config/__tests__/validate.test.ts +9 -1
- package/src/native/app/config/types.ts +3 -1
- package/src/native/app/config/validate.ts +7 -3
- package/src/native/corpus/__tests__/counts.test.ts +82 -0
- package/src/native/corpus/__tests__/display.test.ts +37 -0
- package/src/native/corpus/api.ts +35 -2
- package/src/native/corpus/counts.ts +16 -0
- package/src/native/corpus/display.ts +62 -0
- package/src/native/corpus/fake-counts.ts +59 -0
- package/src/native/corpus/fake-tenant.ts +31 -3
- package/src/native/home/__tests__/controller.test.ts +24 -11
- package/src/native/home/controller.ts +23 -17
- package/src/native/index.ts +3 -1
- package/src/native/screens/planning/__tests__/controller.test.ts +17 -23
- package/src/native/screens/planning/controller.ts +18 -26
- package/src/native/tracker/__tests__/detail.test.ts +17 -0
- package/src/native/tracker/detail.ts +32 -19
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* One to-do, read directly (
|
|
3
|
-
*
|
|
2
|
+
* One to-do, read directly (the entity and its project edge together, then the
|
|
3
|
+
* project and ALL source documents together) - never by scanning the list and
|
|
4
|
+
* never one read per mention. Mark done /
|
|
4
5
|
* reopen is optimistic and rolls back with the server's reason.
|
|
5
6
|
*/
|
|
6
|
-
import type { Commitment, CommitmentStatus } from '../../corpus/types';
|
|
7
|
-
import { toCommitment } from '../../corpus/entities';
|
|
7
|
+
import type { Commitment, CommitmentStatus, SourceDocument } from '../../corpus/types';
|
|
8
|
+
import { DEFAULT_TYPE_KEYS, toCommitment, toSourceDocument } from '../../corpus/entities';
|
|
8
9
|
import type { NativeCorpusApi } from '../corpus/api';
|
|
9
10
|
import { statusText } from './format';
|
|
10
11
|
|
|
@@ -37,7 +38,7 @@ export interface TrackerDetailController {
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
export interface TrackerDetailOptions {
|
|
40
|
-
api: Pick<NativeCorpusApi, 'entities' | '
|
|
41
|
+
api: Pick<NativeCorpusApi, 'entities' | 'relationships' | 'commitments' | 'scope'>;
|
|
41
42
|
id: string;
|
|
42
43
|
/** Called after a status write succeeds, so the list can refresh. */
|
|
43
44
|
onChanged?: () => void;
|
|
@@ -56,23 +57,35 @@ export function createTrackerDetailController({ api, id, onChanged }: TrackerDet
|
|
|
56
57
|
async load() {
|
|
57
58
|
set({ loading: true, error: null });
|
|
58
59
|
try {
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
// Round 1: the to-do and its project edge are independent. Round 2: the
|
|
61
|
+
// project's name and ALL source documents (one `id__in` read, not one
|
|
62
|
+
// read per mention).
|
|
63
|
+
const [entity, edge] = await Promise.all([
|
|
64
|
+
api.entities.get(id),
|
|
65
|
+
api.relationships.list({ relType: 'in_focus', source: id, pageSize: 1 }).catch(() => null),
|
|
66
|
+
]);
|
|
67
|
+
const item = toCommitment(entity, api.scope);
|
|
61
68
|
const focusId = edge?.items[0]?.target;
|
|
62
|
-
const
|
|
69
|
+
const documentIds = [...new Set(item.mentions.map((m) => m.documentId))];
|
|
70
|
+
const [project, documents] = await Promise.all([
|
|
63
71
|
focusId ? api.entities.get(String(focusId)).then((f) => f.name || null).catch(() => null) : Promise.resolve(null),
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
quote: m.quote,
|
|
70
|
-
occurredAt: m.occurredAt ?? doc?.occurredAt ?? null,
|
|
71
|
-
...(m.section ? { section: m.section } : {}),
|
|
72
|
-
isVoiceNote: (doc?.source ?? item.source) === 'voice',
|
|
73
|
-
};
|
|
74
|
-
})),
|
|
72
|
+
documentIds.length
|
|
73
|
+
? api.entities.list({ type: DEFAULT_TYPE_KEYS.document, filters: { idIn: documentIds }, pageSize: documentIds.length })
|
|
74
|
+
.then((page) => new Map(page.items.map((e) => [String(e.id), toSourceDocument(e, api.scope)])))
|
|
75
|
+
.catch(() => new Map<string, SourceDocument>())
|
|
76
|
+
: Promise.resolve(new Map<string, SourceDocument>()),
|
|
75
77
|
]);
|
|
78
|
+
const sources = item.mentions.map((m): TrackerSource => {
|
|
79
|
+
const doc = documents.get(m.documentId);
|
|
80
|
+
return {
|
|
81
|
+
documentId: m.documentId,
|
|
82
|
+
title: doc?.title || item.sourceLabel || 'Source',
|
|
83
|
+
quote: m.quote,
|
|
84
|
+
occurredAt: m.occurredAt ?? doc?.occurredAt ?? null,
|
|
85
|
+
...(m.section ? { section: m.section } : {}),
|
|
86
|
+
isVoiceNote: (doc?.source ?? item.source) === 'voice',
|
|
87
|
+
};
|
|
88
|
+
});
|
|
76
89
|
set({ loading: false, item, projectTitle: project, sources });
|
|
77
90
|
} catch (e) {
|
|
78
91
|
set({ loading: false, item: null, error: (e as { status?: number })?.status === 404 ? 'This to-do is no longer available.' : msg(e) });
|