@startsimpli/integrations 0.2.90 → 0.2.92
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__/entity-query.test.ts +13 -0
- package/src/__tests__/voice-manage.test.ts +8 -0
- package/src/__tests__/voice-notes-page-query.test.tsx +14 -1
- package/src/__tests__/voice-notes-page.test.tsx +32 -2
- package/src/__tests__/voice-notes-query.test.ts +16 -0
- package/src/components/pages/VoiceNotesPage.tsx +11 -4
- package/src/corpus/client.ts +6 -0
- package/src/corpus/entity-query.ts +12 -0
- package/src/corpus/filing.ts +9 -0
- package/src/corpus/types.ts +5 -0
- package/src/corpus/voice-query.ts +5 -2
- package/src/native/components/NoteDetailScreen.tsx +2 -2
- package/src/native/components/NotesListScreen.tsx +4 -3
- package/src/native/components/__tests__/notes-screens.test.tsx +25 -0
- package/src/native/corpus/__tests__/api.test.ts +22 -0
- package/src/native/corpus/fake-tenant.ts +12 -0
- package/src/native/tracker/TrackerListScreen.tsx +2 -1
- package/src/native/tracker/__tests__/controller.test.ts +18 -0
- package/src/native/tracker/__tests__/format.test.ts +4 -0
- package/src/native/tracker/format.ts +3 -2
- package/src/native/voice/__tests__/controller-query.test.ts +12 -0
- package/src/native/voice/__tests__/format.test.ts +8 -1
- package/src/native/voice/controller.ts +7 -2
- package/src/native/voice/fake.ts +5 -1
- package/src/native/voice/format.ts +15 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startsimpli/integrations",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.92",
|
|
4
4
|
"description": "Provider-agnostic types, API clients, hooks, and UI primitives for email + calendar integrations across StartSimpli apps, plus foundry customer email (subpath ./comms).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://startsimpli.com",
|
|
@@ -99,9 +99,9 @@
|
|
|
99
99
|
"react-native": "0.85.3",
|
|
100
100
|
"react-native-safe-area-context": "~5.7.0",
|
|
101
101
|
"@startsimpli/llm": "0.4.28",
|
|
102
|
-
"@startsimpli/auth": "0.4.47",
|
|
103
|
-
"@startsimpli/ui-native": "0.1.4",
|
|
104
102
|
"@startsimpli/ui": "0.4.167",
|
|
103
|
+
"@startsimpli/ui-native": "0.1.6",
|
|
104
|
+
"@startsimpli/auth": "0.4.47",
|
|
105
105
|
"@startsimpli/utils": "0.4.15"
|
|
106
106
|
},
|
|
107
107
|
"scripts": {
|
|
@@ -54,6 +54,19 @@ describe('entityParams serialization', () => {
|
|
|
54
54
|
expect(orphan.related_direction).toBeUndefined();
|
|
55
55
|
expect(orphan.related_via).toBeUndefined();
|
|
56
56
|
});
|
|
57
|
+
it('serializes unrelated_via (rows with NO such edge), and drops the direction when there is no unrelatedVia', () => {
|
|
58
|
+
expect(entityParams({ type: 't', filters: { unrelatedVia: 'about_focus' } })).toMatchObject({ unrelated_via: 'about_focus' });
|
|
59
|
+
expect(entityParams({ type: 't', filters: { unrelatedVia: ['in_focus', 'about_focus'], unrelatedDirection: 'out' } }))
|
|
60
|
+
.toMatchObject({ unrelated_via: 'in_focus,about_focus', unrelated_direction: 'out' });
|
|
61
|
+
const orphan = entityParams({ type: 't', filters: { unrelatedDirection: 'out' } });
|
|
62
|
+
expect(orphan.unrelated_direction).toBeUndefined();
|
|
63
|
+
expect(orphan.unrelated_via).toBeUndefined();
|
|
64
|
+
});
|
|
65
|
+
it('confirms unrelated_via only when the server names it in applied_filters', () => {
|
|
66
|
+
const params = entityParams({ type: 't', filters: { unrelatedVia: 'about_focus' } });
|
|
67
|
+
expect(reconcileFilters(params, { applied_filters: ['type', 'unrelated_via'] }).ignored).toEqual([]);
|
|
68
|
+
expect(reconcileFilters(params, { applied_filters: ['type'] }).ignored).toEqual(['unrelated_via']);
|
|
69
|
+
});
|
|
57
70
|
it('serializes attribute filters with operators and comma-joined __in lists', () => {
|
|
58
71
|
expect(entityParams({
|
|
59
72
|
type: 't',
|
|
@@ -117,6 +117,14 @@ describe('retry re-runs the pipeline from the STORED audio', () => {
|
|
|
117
117
|
});
|
|
118
118
|
|
|
119
119
|
describe('delete removes the edge, the row, then the object last', () => {
|
|
120
|
+
|
|
121
|
+
it('leaves the to-dos taken from the note alone: no commitment read, no in_focus edge touched (bd startsim-ij1lw.2)', async () => {
|
|
122
|
+
const w = world();
|
|
123
|
+
await deleteVoiceNote('n1', { http: w.http as never, store: w.store });
|
|
124
|
+
const reads = w.http.get.mock.calls.map((c) => [c[0], JSON.stringify((c as unknown[])[1] ?? {})].join(' '));
|
|
125
|
+
expect(reads.some((r) => r.includes('commitment') || r.includes('in_focus'))).toBe(false);
|
|
126
|
+
expect(w.http.delete.mock.calls.map((c) => c[0])).toEqual(['api/v1/relationships/e1', 'api/v1/entities/n1']);
|
|
127
|
+
});
|
|
120
128
|
it('orders the three deletes', async () => {
|
|
121
129
|
const w = world({ entity: row({ voice_status: 'failed' }) });
|
|
122
130
|
await deleteVoiceNote('n1', { http: w.http as never, store: w.store });
|
|
@@ -53,7 +53,7 @@ describe('VoiceNotesPage on the shared controller', () => {
|
|
|
53
53
|
it('the project filter and the sort are server parameters', async () => {
|
|
54
54
|
const { spy } = mount();
|
|
55
55
|
await screen.findByText('Snake plant watering');
|
|
56
|
-
await waitFor(() => expect((screen.getByLabelText('Filter by project') as HTMLSelectElement).options.length).toBe(
|
|
56
|
+
await waitFor(() => expect((screen.getByLabelText('Filter by project') as HTMLSelectElement).options.length).toBe(5));
|
|
57
57
|
fireEvent.change(screen.getByLabelText('Filter by project'), { target: { value: 'fma' } });
|
|
58
58
|
await waitFor(() => expect(titles().sort()).toEqual(['Hearing prep and a dentist reminder', 'Snake plant watering']));
|
|
59
59
|
expect(spy).toHaveBeenCalledWith(expect.objectContaining({ focusId: 'fma' }), 1);
|
|
@@ -61,6 +61,19 @@ describe('VoiceNotesPage on the shared controller', () => {
|
|
|
61
61
|
await waitFor(() => expect(titles()[0]).toBe('Snake plant watering'));
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
+
it('the project filter has an Unfiled option, answered by the server (no project edge)', async () => {
|
|
65
|
+
const { spy } = mount();
|
|
66
|
+
await screen.findByText('Snake plant watering');
|
|
67
|
+
const select = screen.getByLabelText('Filter by project') as HTMLSelectElement;
|
|
68
|
+
await waitFor(() => expect(select.options.length).toBe(5));
|
|
69
|
+
expect([...select.options].map((o) => o.textContent)).toEqual(['All projects', 'Unfiled', '287A', 'Marketing agents', 'Debug']);
|
|
70
|
+
fireEvent.change(select, { target: { value: 'unfiled' } });
|
|
71
|
+
await waitFor(() => expect(titles().sort()).toEqual(['Voice note — Nov 2, 9:12 AM', 'Voice note — Nov 3, 2:58 PM']));
|
|
72
|
+
expect(spy).toHaveBeenCalledWith(expect.objectContaining({ unfiled: true }), 1);
|
|
73
|
+
expect(spy).not.toHaveBeenCalledWith(expect.objectContaining({ focusId: 'unfiled' }), 1);
|
|
74
|
+
expect(screen.getByText('2 notes')).toBeTruthy();
|
|
75
|
+
});
|
|
76
|
+
|
|
64
77
|
it('Load more appends the next page and goes away on the last one', async () => {
|
|
65
78
|
mount({ pageSize: 3 });
|
|
66
79
|
await screen.findByText('Snake plant watering');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @vitest-environment jsdom
|
|
2
2
|
import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
5
|
|
|
6
6
|
import { VoiceNotesPage, formatDuration, pickMimeType } from '../components/pages/VoiceNotesPage';
|
|
7
7
|
import type { VoiceNote, VoiceNotesApi } from '../corpus/voice';
|
|
@@ -139,6 +139,9 @@ describe('VoiceNotesPage', () => {
|
|
|
139
139
|
});
|
|
140
140
|
|
|
141
141
|
describe('VoiceNotesPage: playback, retry and delete (bd startsim-lkvwd)', () => {
|
|
142
|
+
beforeEach(() => { vi.spyOn(window, 'confirm').mockReturnValue(true); });
|
|
143
|
+
afterEach(() => { vi.restoreAllMocks(); });
|
|
144
|
+
|
|
142
145
|
it('offers an <audio> player for a ready note that has a recording, loaded on demand', async () => {
|
|
143
146
|
const audioUrl = vi.fn(async () => 'blob:n1');
|
|
144
147
|
const { container } = render(<VoiceNotesPage api={api({ list: vi.fn(async () => [note({ audioRef: 's3://b/k.webm' })]), audioUrl })} />);
|
|
@@ -183,10 +186,37 @@ describe('VoiceNotesPage: playback, retry and delete (bd startsim-lkvwd)', () =>
|
|
|
183
186
|
expect(screen.getByText('Checkout bug')).toBeTruthy();
|
|
184
187
|
});
|
|
185
188
|
|
|
186
|
-
it('does not offer Retry
|
|
189
|
+
it('does not offer Retry on a ready note', async () => {
|
|
187
190
|
render(<VoiceNotesPage api={api({ retry: vi.fn(), remove: vi.fn() })} />);
|
|
188
191
|
await screen.findByText('Checkout bug');
|
|
189
192
|
expect(screen.queryByText('Retry')).toBeNull();
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('offers Delete on a ready note, confirms with what stays, then removes it (bd startsim-ij1lw.2)', async () => {
|
|
196
|
+
const confirm = vi.spyOn(window, 'confirm').mockReturnValue(true);
|
|
197
|
+
const remove = vi.fn(async () => undefined);
|
|
198
|
+
render(<VoiceNotesPage api={api({ remove })} />);
|
|
199
|
+
fireEvent.click(await screen.findByText('Delete'));
|
|
200
|
+
expect(confirm).toHaveBeenCalledTimes(1);
|
|
201
|
+
expect(String(confirm.mock.calls[0][0])).toMatch(/to-dos .* stay/i);
|
|
202
|
+
await waitFor(() => expect(remove).toHaveBeenCalledWith('n1'));
|
|
203
|
+
await waitFor(() => expect(screen.queryByText('Checkout bug')).toBeNull());
|
|
204
|
+
confirm.mockRestore();
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('does nothing when the confirm is cancelled', async () => {
|
|
208
|
+
const confirm = vi.spyOn(window, 'confirm').mockReturnValue(false);
|
|
209
|
+
const remove = vi.fn(async () => undefined);
|
|
210
|
+
render(<VoiceNotesPage api={api({ remove })} />);
|
|
211
|
+
fireEvent.click(await screen.findByText('Delete'));
|
|
212
|
+
expect(remove).not.toHaveBeenCalled();
|
|
213
|
+
expect(screen.getByText('Checkout bug')).toBeTruthy();
|
|
214
|
+
confirm.mockRestore();
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('has no Delete when the api cannot remove', async () => {
|
|
218
|
+
render(<VoiceNotesPage api={api()} />);
|
|
219
|
+
await screen.findByText('Checkout bug');
|
|
190
220
|
expect(screen.queryByText('Delete')).toBeNull();
|
|
191
221
|
});
|
|
192
222
|
});
|
|
@@ -35,11 +35,27 @@ describe('voiceNotesParams', () => {
|
|
|
35
35
|
expect(p).not.toHaveProperty('search');
|
|
36
36
|
expect(p).not.toHaveProperty('order');
|
|
37
37
|
});
|
|
38
|
+
it('asks for notes with no project as unrelated_via=about_focus, never as a related_to', () => {
|
|
39
|
+
const p = voiceNotesParams({ unfiled: true, order: 'recent' }, 1, 25);
|
|
40
|
+
expect(p).toMatchObject({ source: 'voice', unrelated_via: 'about_focus', unrelated_direction: 'out' });
|
|
41
|
+
expect(p).not.toHaveProperty('related_to');
|
|
42
|
+
});
|
|
38
43
|
it('re-reads exact ids with id__in', () => {
|
|
39
44
|
expect(voiceNotesParams({ ids: ['a', 'b'] }, 1, 25)).toMatchObject({ id__in: 'a,b' });
|
|
40
45
|
});
|
|
41
46
|
});
|
|
42
47
|
|
|
48
|
+
describe('createVoiceApi.listPage unfiled', () => {
|
|
49
|
+
it('sends the Unfiled filter to the server and reports it ignored when the server did not apply it', async () => {
|
|
50
|
+
const applied = world({ applied_filters: ['type', 'source', 'order', 'unrelated_via', 'unrelated_direction'] });
|
|
51
|
+
const ok = await applied.api.listPage!({ unfiled: true }, 1);
|
|
52
|
+
expect(applied.gets[0].params).toMatchObject({ unrelated_via: 'about_focus' });
|
|
53
|
+
expect(ok.ignoredFilters).toEqual([]);
|
|
54
|
+
const old = world({ applied_filters: ['type', 'source', 'order'] });
|
|
55
|
+
expect((await old.api.listPage!({ unfiled: true }, 1)).ignoredFilters).toContain('unrelated_via');
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
43
59
|
describe('createVoiceApi.listPage', () => {
|
|
44
60
|
it('asks the server for the page and reads count + nextPage + the project edges of that page only', async () => {
|
|
45
61
|
const { api, gets } = world();
|
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
import * as React from 'react';
|
|
24
24
|
|
|
25
25
|
import type { VoiceNote, VoiceNoteOrder, VoiceNotesApi } from '../../corpus/voice';
|
|
26
|
+
import { UNFILED_PROJECT } from '../../corpus/filing';
|
|
27
|
+
import { deleteNoteMessage } from '../../native/voice/format';
|
|
26
28
|
import { createVoiceNotesController, type VoiceNotesController } from '../../native/voice/controller';
|
|
27
29
|
import { noteLead, noteSections } from '../../native/voice/sections';
|
|
28
30
|
import { VoiceRecordButton, formatDuration } from './VoiceRecordButton';
|
|
@@ -56,7 +58,7 @@ export interface VoiceNotesPageProps {
|
|
|
56
58
|
recorderFactory?: (stream: MediaStream, mimeType: string) => MediaRecorder;
|
|
57
59
|
}
|
|
58
60
|
|
|
59
|
-
const IGNORED_NAMES: Record<string, string> = { search: 'search notes', related_to: 'filter by project', order: 'sort notes' };
|
|
61
|
+
const IGNORED_NAMES: Record<string, string> = { search: 'search notes', related_to: 'filter by project', unrelated_via: 'filter by unfiled', order: 'sort notes' };
|
|
60
62
|
|
|
61
63
|
/** The controller is made once; this lets it keep calling whatever `api` the parent passes now. */
|
|
62
64
|
function liveApi(ref: React.MutableRefObject<VoiceNotesApi>): VoiceNotesApi {
|
|
@@ -118,7 +120,11 @@ export function VoiceNotesPage({
|
|
|
118
120
|
}
|
|
119
121
|
|
|
120
122
|
const retry = (note: VoiceNote) => act(note, () => controller.retry(note.id), 'Could not retry that note.');
|
|
121
|
-
const remove = (note: VoiceNote) =>
|
|
123
|
+
const remove = (note: VoiceNote) => {
|
|
124
|
+
// Deleting is for good: say what goes and what stays before doing it.
|
|
125
|
+
if (!window.confirm(`Delete "${note.title}"?\n\n${deleteNoteMessage(note.status)}`)) return Promise.resolve();
|
|
126
|
+
return act(note, () => controller.remove(note.id), 'Could not delete that note.');
|
|
127
|
+
};
|
|
122
128
|
const play = (note: VoiceNote) => act(note, async () => {
|
|
123
129
|
const url = await apiRef.current.audioUrl?.(note.id);
|
|
124
130
|
if (url) setAudio((current) => ({ ...current, [note.id]: url }));
|
|
@@ -185,6 +191,7 @@ export function VoiceNotesPage({
|
|
|
185
191
|
onChange={(event) => void controller.setFocusFilter(event.target.value || null)}
|
|
186
192
|
>
|
|
187
193
|
<option value="">All projects</option>
|
|
194
|
+
<option value={UNFILED_PROJECT}>Unfiled</option>
|
|
188
195
|
{focuses.map((focus) => (
|
|
189
196
|
<option key={focus.id} value={focus.id}>{focus.title}</option>
|
|
190
197
|
))}
|
|
@@ -229,9 +236,9 @@ export function VoiceNotesPage({
|
|
|
229
236
|
{note.status === 'failed' ? (
|
|
230
237
|
<p role="alert" className={cx('error')}>Could not process this note{note.error ? `: ${note.error}` : '.'}</p>
|
|
231
238
|
) : null}
|
|
232
|
-
{note.status === 'failed' &&
|
|
239
|
+
{(note.status === 'failed' && controller.canRetry) || (note.status !== 'processing' && controller.canRemove) ? (
|
|
233
240
|
<p>
|
|
234
|
-
{controller.canRetry ? (
|
|
241
|
+
{note.status === 'failed' && controller.canRetry ? (
|
|
235
242
|
<button type="button" className={cx('button')} disabled={busy.has(note.id)} onClick={() => void retry(note)}>Retry</button>
|
|
236
243
|
) : null}{' '}
|
|
237
244
|
{controller.canRemove ? (
|
package/src/corpus/client.ts
CHANGED
|
@@ -261,6 +261,11 @@ function commitmentParams(query: CommitmentQuery, type: string): Record<string,
|
|
|
261
261
|
out.related_to = query.focus;
|
|
262
262
|
out.related_via = IN_FOCUS;
|
|
263
263
|
out.related_direction = 'out';
|
|
264
|
+
} else if (query.unfiled) {
|
|
265
|
+
// The converse walk: an item is the SOURCE of its own `in_focus` edge, so
|
|
266
|
+
// "filed nowhere" is `unrelated_via=in_focus` from the item's (`out`) end.
|
|
267
|
+
out.unrelated_via = IN_FOCUS;
|
|
268
|
+
out.unrelated_direction = 'out';
|
|
264
269
|
}
|
|
265
270
|
return out;
|
|
266
271
|
}
|
|
@@ -280,6 +285,7 @@ const FILTER_PARAMS: Array<[keyof CommitmentQuery, string[]]> = [
|
|
|
280
285
|
// spelling of `applied_filters`. `partyId -> related_to` on the document side
|
|
281
286
|
// is the same shape, and the precedent for it.
|
|
282
287
|
['focus', ['related_to']],
|
|
288
|
+
['unfiled', ['unrelated_via']],
|
|
283
289
|
['search', ['search']],
|
|
284
290
|
];
|
|
285
291
|
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* type, id, id__in (comma list), external_id, external_id__in (REPEATED param),
|
|
13
13
|
* source, party, scope, occurred_after/before, created_after/before,
|
|
14
14
|
* related_to + related_via/related_direction/related_depth,
|
|
15
|
+
* unrelated_via + unrelated_direction (rows with NO such edge),
|
|
15
16
|
* attr.<name>[__op] (op: in gt gte lt lte icontains isnull isblank startswith
|
|
16
17
|
* istartswith under).
|
|
17
18
|
* Every parameter is either applied (named in `applied_filters`) or reported in
|
|
@@ -46,6 +47,13 @@ export interface EntityFilters {
|
|
|
46
47
|
relatedVia?: string | string[];
|
|
47
48
|
relatedDirection?: 'out' | 'in' | 'any';
|
|
48
49
|
relatedDepth?: 1 | 2;
|
|
50
|
+
/**
|
|
51
|
+
* Rows with NO edge of these types (`unrelated_via`), e.g. a note with no
|
|
52
|
+
* `about_focus` edge: the "Unfiled" bucket. `unrelatedDirection` names which end
|
|
53
|
+
* of the edge the ROW is on, as `relatedDirection` does. No `relatedTo` needed.
|
|
54
|
+
*/
|
|
55
|
+
unrelatedVia?: string | string[];
|
|
56
|
+
unrelatedDirection?: 'out' | 'in' | 'any';
|
|
49
57
|
}
|
|
50
58
|
|
|
51
59
|
export interface EntityQuery {
|
|
@@ -106,6 +114,10 @@ export function entityFilterParams(filters: EntityFilters = {}): Record<string,
|
|
|
106
114
|
put(out, 'related_direction', filters.relatedDirection);
|
|
107
115
|
put(out, 'related_depth', filters.relatedDepth);
|
|
108
116
|
}
|
|
117
|
+
if (filters.unrelatedVia?.length) {
|
|
118
|
+
out.unrelated_via = Array.isArray(filters.unrelatedVia) ? filters.unrelatedVia.join(',') : filters.unrelatedVia;
|
|
119
|
+
put(out, 'unrelated_direction', filters.unrelatedDirection);
|
|
120
|
+
}
|
|
109
121
|
return out;
|
|
110
122
|
}
|
|
111
123
|
|
package/src/corpus/filing.ts
CHANGED
|
@@ -18,6 +18,15 @@ import { FOCUS_TYPE, IN_FOCUS } from './planning';
|
|
|
18
18
|
/** A document is ABOUT a focus — its own edge, never `in_focus`. */
|
|
19
19
|
export const ABOUT_FOCUS = 'about_focus';
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* The project-filter choice "Unfiled" (bd startsim-23np6.4). It rides in the same
|
|
23
|
+
* slot as a project id (`focusId`) so a screen has one select; it is never sent
|
|
24
|
+
* to the server as an id: the query maps it to `unrelated_via=<edge key>`, which
|
|
25
|
+
* the server answers as "rows with NO such edge". A real id is a UUID, so it can
|
|
26
|
+
* never collide.
|
|
27
|
+
*/
|
|
28
|
+
export const UNFILED_PROJECT = 'unfiled';
|
|
29
|
+
|
|
21
30
|
export interface FocusChoice {
|
|
22
31
|
id: string;
|
|
23
32
|
title: string;
|
package/src/corpus/types.ts
CHANGED
|
@@ -816,6 +816,11 @@ export interface CommitmentQuery {
|
|
|
816
816
|
* same class of bug as reading only one spelling of `applied_filters`.
|
|
817
817
|
*/
|
|
818
818
|
focus?: string;
|
|
819
|
+
/**
|
|
820
|
+
* Only the items filed under NO focus (no `in_focus` edge): the server's
|
|
821
|
+
* `unrelated_via=in_focus`. Ignored when `focus` is set.
|
|
822
|
+
*/
|
|
823
|
+
unfiled?: boolean;
|
|
819
824
|
/** `tenant-extraction` | `human` | ... — filters on the `_origin` attribute. */
|
|
820
825
|
origin?: string;
|
|
821
826
|
search?: string;
|
|
@@ -15,6 +15,8 @@ export interface VoiceNotesQuery {
|
|
|
15
15
|
search?: string;
|
|
16
16
|
/** Only notes filed under this project (an `about_focus` edge to it). */
|
|
17
17
|
focusId?: string | null;
|
|
18
|
+
/** Only notes filed under NO project (no `about_focus` edge at all). Wins over `focusId`. */
|
|
19
|
+
unfiled?: boolean;
|
|
18
20
|
order?: VoiceNoteOrder;
|
|
19
21
|
/** Re-read exactly these notes (the poll while they transcribe). */
|
|
20
22
|
ids?: string[];
|
|
@@ -31,7 +33,7 @@ export interface VoiceNotesPage {
|
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
/** The parts of a query a screen can say "not applied" about. */
|
|
34
|
-
export const QUERY_FILTER_KEYS = ['search', 'order', 'related_to', 'related_via', 'related_direction'];
|
|
36
|
+
export const QUERY_FILTER_KEYS = ['search', 'order', 'related_to', 'related_via', 'related_direction', 'unrelated_via', 'unrelated_direction'];
|
|
35
37
|
|
|
36
38
|
export function voiceNotesParams(query: VoiceNotesQuery, page: number, pageSize: number): Record<string, unknown> {
|
|
37
39
|
return entityParams({
|
|
@@ -43,7 +45,8 @@ export function voiceNotesParams(query: VoiceNotesQuery, page: number, pageSize:
|
|
|
43
45
|
filters: {
|
|
44
46
|
source: 'voice',
|
|
45
47
|
...(query.ids?.length ? { idIn: query.ids } : {}),
|
|
46
|
-
...(query.
|
|
48
|
+
...(query.unfiled ? { unrelatedVia: ABOUT_FOCUS, unrelatedDirection: 'out' as const } : {}),
|
|
49
|
+
...(query.focusId && !query.unfiled ? { relatedTo: query.focusId, relatedVia: ABOUT_FOCUS, relatedDirection: 'out' as const } : {}),
|
|
47
50
|
},
|
|
48
51
|
});
|
|
49
52
|
}
|
|
@@ -3,7 +3,7 @@ import { Alert as RNAlert, ScrollView, View } from 'react-native';
|
|
|
3
3
|
import { Alert, Badge, Button, Chip, Separator, Spinner, Text, useTheme } from '@startsimpli/ui-native';
|
|
4
4
|
import type { VoiceFocus, VoiceNote } from '../../corpus/voice';
|
|
5
5
|
import type { VoiceNotesController } from '../voice/controller';
|
|
6
|
-
import { formatDuration, formatNoteDate, statusLabel, statusVariant } from '../voice/format';
|
|
6
|
+
import { DELETE_NOTE_TITLE, deleteNoteMessage, formatDuration, formatNoteDate, statusLabel, statusVariant } from '../voice/format';
|
|
7
7
|
import { noteSections, noteLead } from '../voice/sections';
|
|
8
8
|
import { useVoiceNotes } from './useVoiceNotes';
|
|
9
9
|
|
|
@@ -46,7 +46,7 @@ export function NoteDetailScreen({ controller, noteId, onBack }: NoteDetailScree
|
|
|
46
46
|
const sections = noteSections(note);
|
|
47
47
|
const focusTitle = (id: string | null) => (id ? state.focuses.find((f) => f.id === id)?.title ?? 'Project' : 'Unfiled');
|
|
48
48
|
const confirmDelete = () =>
|
|
49
|
-
RNAlert.alert(
|
|
49
|
+
RNAlert.alert(DELETE_NOTE_TITLE, deleteNoteMessage(note.status), [
|
|
50
50
|
{ text: 'Cancel', style: 'cancel' },
|
|
51
51
|
{ text: 'Delete', style: 'destructive', onPress: () => { void controller.remove(note.id).then(onBack); } },
|
|
52
52
|
]);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { Pressable, View } from 'react-native';
|
|
3
3
|
import { Alert, Badge, DataList, Text, useTheme, type FilterGroup } from '@startsimpli/ui-native';
|
|
4
|
+
import { UNFILED_PROJECT } from '../../corpus/filing';
|
|
4
5
|
import type { VoiceNote, VoiceNoteOrder } from '../../corpus/voice';
|
|
5
6
|
import type { VoiceNotesController } from '../voice/controller';
|
|
6
7
|
import { formatDuration, formatNoteDate, statusLabel, statusVariant } from '../voice/format';
|
|
@@ -15,7 +16,7 @@ export interface NotesListScreenProps {
|
|
|
15
16
|
const subtitle = (n: VoiceNote) =>
|
|
16
17
|
[formatNoteDate(n.occurredAt), formatDuration(n.durationMs)].filter(Boolean).join(' · ');
|
|
17
18
|
|
|
18
|
-
const IGNORED_NAMES: Record<string, string> = { search: 'search notes', related_to: 'filter by project', order: 'sort' };
|
|
19
|
+
const IGNORED_NAMES: Record<string, string> = { search: 'search notes', related_to: 'filter by project', unrelated_via: 'filter by unfiled', order: 'sort' };
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Notes, newest first: server-side search, project filter, sort and paging (the
|
|
@@ -31,7 +32,7 @@ export function NotesListScreen({ controller, onOpen }: NotesListScreenProps) {
|
|
|
31
32
|
|
|
32
33
|
const projects: FilterGroup = {
|
|
33
34
|
key: 'project', label: 'Project', display: 'select', value: query.focusId,
|
|
34
|
-
options: state.focuses.map((f) => ({ value: f.id, label: f.title })),
|
|
35
|
+
options: [{ value: UNFILED_PROJECT, label: 'Unfiled' }, ...state.focuses.map((f) => ({ value: f.id, label: f.title }))],
|
|
35
36
|
};
|
|
36
37
|
const ignored = state.ignoredFilters.map((k) => IGNORED_NAMES[k] ?? k);
|
|
37
38
|
const count = state.count;
|
|
@@ -54,7 +55,7 @@ export function NotesListScreen({ controller, onOpen }: NotesListScreenProps) {
|
|
|
54
55
|
value: draft, onChange: setDraft, placeholder: 'Search your notes',
|
|
55
56
|
onSearch: (text) => { void controller.setSearch(text); },
|
|
56
57
|
} : undefined}
|
|
57
|
-
filters={canQuery
|
|
58
|
+
filters={canQuery ? [projects] : []}
|
|
58
59
|
onFilterChange={(_key, value) => { void controller.setFocusFilter(value); }}
|
|
59
60
|
onClearFilters={() => { setDraft(''); void controller.clearFilters(); }}
|
|
60
61
|
sort={canQuery ? {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* bd startsim-23np6.3 (search / project filter / sort / paging on the Notes tab)
|
|
3
3
|
* and startsim-ij1lw.13 (a note's to-dos come from its section items, nothing else).
|
|
4
4
|
*/
|
|
5
|
+
import { Alert as RNAlert } from 'react-native';
|
|
5
6
|
import { describe, expect, it, vi } from 'vitest';
|
|
6
7
|
import { act, allText, hostById, maybeById, press, render } from '../../../../../ui-native/test/render';
|
|
7
8
|
import { createVoiceNotesController } from '../../voice/controller';
|
|
@@ -61,6 +62,15 @@ describe('NotesListScreen', () => {
|
|
|
61
62
|
expect(controller.getState().notes?.map((n) => n.id).sort()).toEqual(['n1', 'n2']);
|
|
62
63
|
});
|
|
63
64
|
|
|
65
|
+
it('the project filter offers Unfiled, which is a server query for notes with no project', async () => {
|
|
66
|
+
const { r, controller } = await mountList();
|
|
67
|
+
press(hostById(r, 'notes-list-filter-project'));
|
|
68
|
+
press(hostById(r, 'notes-list-filter-project-option-unfiled'));
|
|
69
|
+
await settle();
|
|
70
|
+
expect(controller.getState().notes?.map((n) => n.id).sort()).toEqual(['n0', 'n3']);
|
|
71
|
+
expect(allText(r)).toContain('2 notes');
|
|
72
|
+
});
|
|
73
|
+
|
|
64
74
|
it('newest / oldest changes the server order, and best match appears only with a search', async () => {
|
|
65
75
|
const { r, controller } = await mountList();
|
|
66
76
|
expect(maybeById(r, 'notes-list-sort-relevance').length).toBe(0);
|
|
@@ -109,6 +119,21 @@ async function mountDetail(id: string, options: FakeVoiceApiOptions = {}) {
|
|
|
109
119
|
return { r, controller, onBack };
|
|
110
120
|
}
|
|
111
121
|
|
|
122
|
+
describe('NoteDetailScreen delete (bd startsim-ij1lw.2)', () => {
|
|
123
|
+
it('a ready note can be deleted; the confirm says its filed to-dos stay', async () => {
|
|
124
|
+
const alert = vi.spyOn(RNAlert, 'alert').mockImplementation(() => undefined);
|
|
125
|
+
const { r, controller, onBack } = await mountDetail('n2');
|
|
126
|
+
press(hostById(r, 'note-delete'));
|
|
127
|
+
expect(alert).toHaveBeenCalledTimes(1);
|
|
128
|
+
const [, message, buttons] = alert.mock.calls[0] as [string, string, Array<{ text: string; onPress?: () => void }>];
|
|
129
|
+
expect(message).toMatch(/to-dos .* stay/i);
|
|
130
|
+
await act(async () => { buttons.find((b) => b.text === 'Delete')!.onPress!(); await new Promise((res) => setTimeout(res, 0)); });
|
|
131
|
+
expect(controller.getState().notes?.some((n) => n.id === 'n2')).toBe(false);
|
|
132
|
+
expect(onBack).toHaveBeenCalled();
|
|
133
|
+
alert.mockRestore();
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
112
137
|
describe('NoteDetailScreen', () => {
|
|
113
138
|
it('to-dos come from the section items, one list per section', async () => {
|
|
114
139
|
const { r } = await mountDetail('n1');
|
|
@@ -18,6 +18,28 @@ describe('authorized http transport', () => {
|
|
|
18
18
|
});
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
+
describe('entities.list unrelatedVia', () => {
|
|
22
|
+
it('sends unrelated_via and gets only rows with no such edge, reported as applied', async () => {
|
|
23
|
+
const { tenant, api } = fake();
|
|
24
|
+
const page = await api.entities.list({ type: 'commitment', filters: { unrelatedVia: 'in_focus', unrelatedDirection: 'out' } });
|
|
25
|
+
expect(tenant.requests.at(-1)?.params).toMatchObject({ unrelated_via: 'in_focus', unrelated_direction: 'out' });
|
|
26
|
+
expect(page.items.map((e) => e.id)).toEqual(['c4', 'c5']);
|
|
27
|
+
for (const filed of ['c1', 'c2', 'c3']) expect(page.items.map((e) => e.id)).not.toContain(filed);
|
|
28
|
+
expect(page.appliedFilters).toEqual(expect.arrayContaining(['unrelated_via', 'unrelated_direction']));
|
|
29
|
+
});
|
|
30
|
+
it('flags it when an older server ignores it', async () => {
|
|
31
|
+
const { api } = fake({ unsupported: ['unrelated_via'] });
|
|
32
|
+
const page = await api.entities.list({ type: 'commitment', filters: { unrelatedVia: 'in_focus' } });
|
|
33
|
+
expect(page.ignoredFilters).toEqual(['unrelated_via']);
|
|
34
|
+
});
|
|
35
|
+
it('corpus.listCommitments({ unfiled }) goes out as the same server filter', async () => {
|
|
36
|
+
const { tenant, api } = fake();
|
|
37
|
+
const res = await api.corpus.listCommitments({ unfiled: true });
|
|
38
|
+
expect(tenant.requests.filter((r) => r.params?.type === 'commitment').at(-1)?.params).toMatchObject({ unrelated_via: 'in_focus', unrelated_direction: 'out' });
|
|
39
|
+
expect(res.appliedFilters).toContain('unfiled');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
21
43
|
describe('entities.list: generic, server-side', () => {
|
|
22
44
|
it('returns {items,next,appliedFilters} for a typed query and sends every parameter to the server', async () => {
|
|
23
45
|
const { tenant, api } = fake();
|
|
@@ -134,6 +134,18 @@ export function createFakeTenantHttp(options: FakeTenantOptions = {}): FakeTenan
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
+
if (ok('unrelated_via')) {
|
|
138
|
+
const via = asList(params.unrelated_via);
|
|
139
|
+
const direction = String(params.unrelated_direction ?? 'any');
|
|
140
|
+
const filed = new Set<string>();
|
|
141
|
+
for (const edge of relationships) {
|
|
142
|
+
if (!via.includes(String(edge.rel_type ?? edge.relType))) continue;
|
|
143
|
+
if (direction !== 'in') filed.add(String(edge.source));
|
|
144
|
+
if (direction !== 'out') filed.add(String(edge.target));
|
|
145
|
+
}
|
|
146
|
+
narrow('unrelated_via', (e) => !filed.has(String(e.id)));
|
|
147
|
+
if ('unrelated_direction' in params && !unsupported.has('unrelated_direction')) applied.push('unrelated_direction');
|
|
148
|
+
}
|
|
137
149
|
for (const [key, value] of Object.entries(params)) {
|
|
138
150
|
if (key.startsWith('attr.') && !unsupported.has(key)) narrow(key, (e) => attrMatches(e, key, value));
|
|
139
151
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import { DataList, ListRow, StatusChip, SwipeRow, Text, useTheme, type FilterGroup } from '@startsimpli/ui-native';
|
|
4
|
+
import { UNFILED_PROJECT } from '../../corpus/filing';
|
|
4
5
|
import type { Commitment } from '../../corpus/types';
|
|
5
6
|
import { useControllerState } from '../components/useControllerState';
|
|
6
7
|
import type { TrackerController, TrackerRow } from './controller';
|
|
@@ -28,7 +29,7 @@ export function TrackerListScreen({ controller, onOpen, now = Date.now }: Tracke
|
|
|
28
29
|
const closed = state.filters.view === 'closed';
|
|
29
30
|
const filters: FilterGroup[] = [
|
|
30
31
|
{ key: 'view', label: 'Show', options: TRACKER_VIEWS, value: state.filters.view },
|
|
31
|
-
{ key: 'project', label: 'Project', display: 'select', options: state.projects.map((p) => ({ value: p.id, label: p.title })), value: state.filters.focusId },
|
|
32
|
+
{ key: 'project', label: 'Project', display: 'select', options: [{ value: UNFILED_PROJECT, label: 'Unfiled' }, ...state.projects.map((p) => ({ value: p.id, label: p.title }))], value: state.filters.focusId },
|
|
32
33
|
];
|
|
33
34
|
const isFiltered = state.filters.focusId !== null || state.filters.search.trim() !== '';
|
|
34
35
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { UNFILED_PROJECT } from '../../../corpus/filing';
|
|
2
3
|
import { createFakeNativeCorpusApi } from '../../corpus/fake';
|
|
3
4
|
import { createTrackerController } from '../controller';
|
|
4
5
|
|
|
@@ -45,6 +46,23 @@ describe('tracker controller: every list change is a server request', () => {
|
|
|
45
46
|
expect(titles(c).length).toBe(5);
|
|
46
47
|
});
|
|
47
48
|
|
|
49
|
+
it('Unfiled asks the server for to-dos with no in_focus edge, and shows only those', async () => {
|
|
50
|
+
const { c, api } = await setup();
|
|
51
|
+
await c.setFocus(UNFILED_PROJECT);
|
|
52
|
+
const sent = api.tenant.requests.filter((r) => r.params?.type === 'commitment').at(-1)!.params;
|
|
53
|
+
expect(sent).toMatchObject({ unrelated_via: 'in_focus', unrelated_direction: 'out' });
|
|
54
|
+
expect(sent).not.toHaveProperty('related_to');
|
|
55
|
+
expect(titles(c)).toEqual(['Book the dentist']);
|
|
56
|
+
expect(c.getState().ignoredFilters).toEqual([]);
|
|
57
|
+
expect(c.getState().rows.every((r) => r.focusId === null)).toBe(true);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('says so when the server did not apply Unfiled', async () => {
|
|
61
|
+
const { c } = await setup({ unsupported: ['unrelated_via'] });
|
|
62
|
+
await c.setFocus(UNFILED_PROJECT);
|
|
63
|
+
expect(c.getState().ignoredFilters).toContain('unfiled');
|
|
64
|
+
});
|
|
65
|
+
|
|
48
66
|
it('search goes to the server', async () => {
|
|
49
67
|
const { c, api } = await setup();
|
|
50
68
|
await c.setSearch('dentist');
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { UNFILED_PROJECT } from '../../../corpus/filing';
|
|
2
3
|
import { DEFAULT_TRACKER_FILTERS, formatDue, isOverdueAt, leavesView, rowSubtitle, trackerQuery } from '../format';
|
|
3
4
|
|
|
4
5
|
const NOW = Date.parse('2026-11-05T00:00:00Z');
|
|
5
6
|
|
|
6
7
|
describe('trackerQuery', () => {
|
|
8
|
+
it('the Unfiled project choice is a server filter, not a project id', () => {
|
|
9
|
+
expect(trackerQuery({ ...DEFAULT_TRACKER_FILTERS, focusId: UNFILED_PROJECT }, NOW)).toEqual({ status: ['open', 'blocked'], unfiled: true });
|
|
10
|
+
});
|
|
7
11
|
it('maps each view to server filters', () => {
|
|
8
12
|
expect(trackerQuery(DEFAULT_TRACKER_FILTERS, NOW)).toEqual({ status: ['open', 'blocked'] });
|
|
9
13
|
expect(trackerQuery({ ...DEFAULT_TRACKER_FILTERS, view: 'overdue' }, NOW)).toEqual({ status: ['open', 'blocked'], dueBefore: '2026-11-05T00:00:00.000Z' });
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UNFILED_PROJECT } from '../../corpus/filing';
|
|
1
2
|
import type { Commitment, CommitmentQuery, CommitmentStatus } from '../../corpus/types';
|
|
2
3
|
|
|
3
4
|
/** The four views the web Tracker has: Outstanding, Overdue, Changed this week, Closed. */
|
|
@@ -12,7 +13,7 @@ export const TRACKER_VIEWS: Array<{ value: TrackerView; label: string }> = [
|
|
|
12
13
|
|
|
13
14
|
export interface TrackerFilters {
|
|
14
15
|
view: TrackerView;
|
|
15
|
-
/** A focus (project) id, or null for all projects. */
|
|
16
|
+
/** A focus (project) id, `UNFILED_PROJECT` for to-dos filed nowhere, or null for all projects. */
|
|
16
17
|
focusId: string | null;
|
|
17
18
|
search: string;
|
|
18
19
|
}
|
|
@@ -35,7 +36,7 @@ export function trackerQuery(filters: TrackerFilters, now: number): Omit<Commitm
|
|
|
35
36
|
status: filters.view === 'closed' ? CLOSED : OPEN,
|
|
36
37
|
...(filters.view === 'overdue' ? { dueBefore: new Date(now).toISOString() } : {}),
|
|
37
38
|
...(filters.view === 'recent' ? { changedAfter: new Date(now - WEEK_MS).toISOString() } : {}),
|
|
38
|
-
...(filters.focusId ? { focus: filters.focusId } : {}),
|
|
39
|
+
...(filters.focusId === UNFILED_PROJECT ? { unfiled: true } : filters.focusId ? { focus: filters.focusId } : {}),
|
|
39
40
|
...(search ? { search } : {}),
|
|
40
41
|
};
|
|
41
42
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
6
6
|
import type { VoiceNote, VoiceNotesApi, VoiceNotesPage, VoiceNotesQuery } from '../../../corpus/voice';
|
|
7
|
+
import { UNFILED_PROJECT } from '../../../corpus/filing';
|
|
7
8
|
import { createVoiceNotesController } from '../controller';
|
|
8
9
|
|
|
9
10
|
const note = (id: string, status: VoiceNote['status'] = 'ready', over: Partial<VoiceNote> = {}): VoiceNote => ({
|
|
@@ -66,6 +67,17 @@ describe('query', () => {
|
|
|
66
67
|
expect(c.getState().query).toEqual({ search: '', focusId: null, order: 'recent' });
|
|
67
68
|
});
|
|
68
69
|
|
|
70
|
+
it('Unfiled is a server filter (no project edge), and moving a note into a project drops it from that view', async () => {
|
|
71
|
+
const listPage = vi.fn<NonNullable<VoiceNotesApi['listPage']>>().mockResolvedValue(page([note('1')]));
|
|
72
|
+
const c = createVoiceNotesController({ api: fakeApi(listPage) });
|
|
73
|
+
await c.setFocusFilter(UNFILED_PROJECT);
|
|
74
|
+
expect(listPage).toHaveBeenLastCalledWith({ unfiled: true, order: 'recent' }, 1);
|
|
75
|
+
expect(c.getState().query.focusId).toBe(UNFILED_PROJECT);
|
|
76
|
+
listPage.mockClear();
|
|
77
|
+
await c.file('1', 'f1');
|
|
78
|
+
expect(listPage).toHaveBeenCalledTimes(1);
|
|
79
|
+
});
|
|
80
|
+
|
|
69
81
|
it('clearing the search leaves "best match" order, which needs a term', async () => {
|
|
70
82
|
const listPage = vi.fn<NonNullable<VoiceNotesApi['listPage']>>().mockResolvedValue(page([]));
|
|
71
83
|
const c = createVoiceNotesController({ api: fakeApi(listPage) });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { formatDuration, formatNoteDate, statusLabel } from '../format';
|
|
2
|
+
import { deleteNoteMessage, formatDuration, formatNoteDate, statusLabel } from '../format';
|
|
3
3
|
|
|
4
4
|
describe('format', () => {
|
|
5
5
|
it('formats a duration as m:ss, hiding a missing one', () => {
|
|
@@ -15,6 +15,13 @@ describe('format', () => {
|
|
|
15
15
|
expect(formatNoteDate('nope')).toBe('');
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
+
it('the delete confirm says what goes and that filed to-dos stay', () => {
|
|
19
|
+
const ready = deleteNoteMessage('ready');
|
|
20
|
+
expect(ready).toMatch(/recording, transcript and summary are removed/i);
|
|
21
|
+
expect(ready).toMatch(/to-dos .* stay/i);
|
|
22
|
+
expect(deleteNoteMessage('failed')).not.toMatch(/to-dos/i);
|
|
23
|
+
});
|
|
24
|
+
|
|
18
25
|
it('labels the three statuses', () => {
|
|
19
26
|
expect(statusLabel('processing')).toBe('Transcribing...');
|
|
20
27
|
expect(statusLabel('ready')).toBe('Ready');
|
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
* (`api.listPage` absent) still works as a plain `list()`, with `canQuery` false
|
|
10
10
|
* so a screen hides the search / filter / order controls instead of faking them.
|
|
11
11
|
*/
|
|
12
|
+
import { UNFILED_PROJECT } from '../../corpus/filing';
|
|
12
13
|
import type { VoiceFocus, VoiceNote, VoiceNoteOrder, VoiceNotesApi, VoiceNotesQuery } from '../../corpus/voice';
|
|
13
14
|
|
|
14
15
|
export interface VoiceNotesFilters {
|
|
15
16
|
search: string;
|
|
16
|
-
/** Only notes filed under this project; null = all. */
|
|
17
|
+
/** Only notes filed under this project; `UNFILED_PROJECT` = notes filed nowhere; null = all. */
|
|
17
18
|
focusId: string | null;
|
|
18
19
|
order: VoiceNoteOrder;
|
|
19
20
|
}
|
|
@@ -76,7 +77,11 @@ const message = (e: unknown) => (e instanceof Error && e.message ? e.message : '
|
|
|
76
77
|
|
|
77
78
|
export function toApiQuery(f: VoiceNotesFilters): VoiceNotesQuery {
|
|
78
79
|
const search = f.search.trim();
|
|
79
|
-
return {
|
|
80
|
+
return {
|
|
81
|
+
...(search ? { search } : {}),
|
|
82
|
+
...(f.focusId === UNFILED_PROJECT ? { unfiled: true } : f.focusId ? { focusId: f.focusId } : {}),
|
|
83
|
+
order: f.order,
|
|
84
|
+
};
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
export function createVoiceNotesController(options: VoiceNotesControllerOptions): VoiceNotesController {
|
package/src/native/voice/fake.ts
CHANGED
|
@@ -37,12 +37,14 @@ export interface FakeVoiceApiOptions {
|
|
|
37
37
|
/** Notes per page for `listPage`. Default 25. */
|
|
38
38
|
pageSize?: number;
|
|
39
39
|
/** Query parts to behave like an older server: not applied, and reported ignored. */
|
|
40
|
-
unsupported?: Array<'search' | 'order' | 'related_to'>;
|
|
40
|
+
unsupported?: Array<'search' | 'order' | 'related_to' | 'unrelated_via'>;
|
|
41
41
|
/** empty / error / loading / long text instead of the sample data. */
|
|
42
42
|
scenario?: FakeScenario;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
const hay = (n: VoiceNote) => `${n.title} ${n.summary} ${n.transcript}`.toLowerCase();
|
|
46
|
+
const filedNowhere = (n: VoiceNote) =>
|
|
47
|
+
!n.focusId && !(n.focusIds ?? []).length && !(n.sections ?? []).some((s) => s.focusId);
|
|
46
48
|
const filedUnder = (n: VoiceNote, focusId: string) =>
|
|
47
49
|
n.focusId === focusId || (n.focusIds ?? []).includes(focusId) || (n.sections ?? []).some((s) => s.focusId === focusId);
|
|
48
50
|
|
|
@@ -84,6 +86,7 @@ function createInMemoryVoiceApi(options: FakeVoiceApiOptions): VoiceNotesApi {
|
|
|
84
86
|
const term = unsupported.has('search') ? '' : (query.search ?? '').trim().toLowerCase();
|
|
85
87
|
let rows = notes.filter((n) => !query.ids?.length || query.ids.includes(n.id));
|
|
86
88
|
if (query.focusId && !unsupported.has('related_to')) rows = rows.filter((n) => filedUnder(n, query.focusId!));
|
|
89
|
+
if (query.unfiled && !unsupported.has('unrelated_via')) rows = rows.filter(filedNowhere);
|
|
87
90
|
if (term) rows = rows.filter((n) => hay(n).includes(term));
|
|
88
91
|
const order = unsupported.has('order') ? 'recent' : query.order ?? 'recent';
|
|
89
92
|
const hits = (n: VoiceNote) => hay(n).split(term).length - 1;
|
|
@@ -96,6 +99,7 @@ function createInMemoryVoiceApi(options: FakeVoiceApiOptions): VoiceNotesApi {
|
|
|
96
99
|
ignoredFilters: [
|
|
97
100
|
...(query.search?.trim() && unsupported.has('search') ? ['search'] : []),
|
|
98
101
|
...(query.focusId && unsupported.has('related_to') ? ['related_to'] : []),
|
|
102
|
+
...(query.unfiled && unsupported.has('unrelated_via') ? ['unrelated_via'] : []),
|
|
99
103
|
...(query.order && query.order !== 'recent' && unsupported.has('order') ? ['order'] : []),
|
|
100
104
|
],
|
|
101
105
|
};
|
|
@@ -17,5 +17,20 @@ export function statusLabel(status: VoiceStatus): string {
|
|
|
17
17
|
return status === 'ready' ? 'Ready' : status === 'failed' ? 'Failed' : 'Transcribing...';
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
export const DELETE_NOTE_TITLE = 'Delete this note?';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* What the confirm to delete a note says. The ONE wording, used by the web page and
|
|
24
|
+
* the iOS Notes tab (bd startsim-ij1lw.2). DELETING A NOTE IS DELETING THE NOTE:
|
|
25
|
+
* its recording, transcript, summary and project link go. The to-dos taken from it
|
|
26
|
+
* are the person's own list (they may be done, edited or reassigned), so they stay,
|
|
27
|
+
* filed where they are. A failed note never produced any.
|
|
28
|
+
*/
|
|
29
|
+
export function deleteNoteMessage(status: VoiceStatus): string {
|
|
30
|
+
return status === 'ready'
|
|
31
|
+
? 'The recording, transcript and summary are removed for good. To-dos taken from this note stay in your to-do list, under their projects.'
|
|
32
|
+
: 'The recording and this failed attempt are removed for good.';
|
|
33
|
+
}
|
|
34
|
+
|
|
20
35
|
export const statusVariant = (status: VoiceStatus) =>
|
|
21
36
|
status === 'ready' ? 'success' : status === 'failed' ? 'destructive' : 'secondary';
|