@startsimpli/integrations 0.2.145 → 0.2.147

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.
Files changed (76) hide show
  1. package/package.json +3 -3
  2. package/src/__tests__/briefing-actions.test.ts +2 -0
  3. package/src/__tests__/briefing-reply.test.ts +334 -0
  4. package/src/__tests__/corpus-tracker.test.tsx +79 -0
  5. package/src/__tests__/extract-classify.test.ts +9 -4
  6. package/src/__tests__/owner-backfill.test.ts +114 -0
  7. package/src/__tests__/owner-link.test.ts +115 -0
  8. package/src/__tests__/owner-picker.test.tsx +70 -0
  9. package/src/__tests__/private-items.test.ts +63 -0
  10. package/src/__tests__/roster.test.ts +27 -0
  11. package/src/__tests__/task-detail-private.test.tsx +44 -0
  12. package/src/__tests__/tracker-sort.test.ts +28 -0
  13. package/src/components/index.ts +1 -0
  14. package/src/components/pages/TaskDetailPage.tsx +51 -2
  15. package/src/components/pages/TrackerPage.tsx +28 -6
  16. package/src/components/pages/task-tracker/OwnerPicker.tsx +82 -0
  17. package/src/components/pages/tracker/TrackerBoard.tsx +45 -0
  18. package/src/components/pages/tracker/TrackerToolbar.tsx +44 -0
  19. package/src/corpus/briefing/actions/execute.ts +5 -4
  20. package/src/corpus/briefing/actions/log.ts +1 -1
  21. package/src/corpus/briefing/actions/types.ts +21 -0
  22. package/src/corpus/briefing/index.ts +1 -0
  23. package/src/corpus/briefing/intent/model.ts +3 -0
  24. package/src/corpus/briefing/intent/resolve.ts +14 -6
  25. package/src/corpus/briefing/intent/types.ts +7 -0
  26. package/src/corpus/briefing/reply/handle.ts +174 -0
  27. package/src/corpus/briefing/reply/index.ts +6 -0
  28. package/src/corpus/briefing/reply/respond.ts +95 -0
  29. package/src/corpus/briefing/reply/types.ts +112 -0
  30. package/src/corpus/briefing/store.ts +14 -0
  31. package/src/corpus/client.ts +24 -18
  32. package/src/corpus/entities.ts +7 -0
  33. package/src/corpus/extract.ts +21 -0
  34. package/src/corpus/index.ts +4 -0
  35. package/src/corpus/owner-backfill.ts +200 -0
  36. package/src/corpus/owner-link.ts +160 -0
  37. package/src/corpus/roster.ts +53 -0
  38. package/src/corpus/tracker-groups.ts +8 -4
  39. package/src/corpus/tracker-sort.ts +51 -0
  40. package/src/corpus/types.ts +24 -1
  41. package/src/native/app/FoundryApp.tsx +25 -7
  42. package/src/native/app/__tests__/briefingLink.test.tsx +57 -0
  43. package/src/native/app/__tests__/briefingServices.test.ts +92 -0
  44. package/src/native/app/__tests__/launch.test.ts +2 -1
  45. package/src/native/app/briefingServices.ts +101 -0
  46. package/src/native/app/config/__tests__/briefingConfig.test.ts +49 -0
  47. package/src/native/app/config/links.ts +4 -1
  48. package/src/native/app/config/types.ts +13 -1
  49. package/src/native/app/config/validate.ts +20 -2
  50. package/src/native/app/data.ts +3 -3
  51. package/src/native/app/device.ts +3 -0
  52. package/src/native/app/launch.ts +4 -0
  53. package/src/native/app/registry.tsx +3 -1
  54. package/src/native/app/screens/RecordScreen.tsx +3 -2
  55. package/src/native/app/services.ts +11 -30
  56. package/src/native/app/strings.ts +28 -0
  57. package/src/native/briefing/BriefingCard.tsx +14 -2
  58. package/src/native/briefing/BriefingReply.tsx +68 -0
  59. package/src/native/briefing/__tests__/BriefingReply.test.tsx +144 -0
  60. package/src/native/briefing/__tests__/fakeReply.test.ts +46 -0
  61. package/src/native/briefing/__tests__/notify.test.ts +42 -1
  62. package/src/native/briefing/__tests__/replyApi.test.ts +43 -0
  63. package/src/native/briefing/__tests__/replyController.test.ts +230 -0
  64. package/src/native/briefing/__tests__/replyPosition.test.ts +116 -0
  65. package/src/native/briefing/audioPlayer.ts +9 -2
  66. package/src/native/briefing/controller.ts +50 -5
  67. package/src/native/briefing/fake.ts +25 -18
  68. package/src/native/briefing/fakeReply.ts +65 -0
  69. package/src/native/briefing/index.ts +8 -3
  70. package/src/native/briefing/notify.ts +42 -0
  71. package/src/native/briefing/reply.ts +261 -0
  72. package/src/native/briefing/replyApi.ts +82 -0
  73. package/src/native/recording/__tests__/deeplink.test.ts +20 -0
  74. package/src/native/recording/deeplink.ts +7 -0
  75. package/src/native/tracker/__tests__/itemsChanged.test.ts +13 -0
  76. package/src/native/tracker/tab.tsx +4 -1
@@ -0,0 +1,82 @@
1
+ import type { ReplyResult } from '../../corpus/briefing';
2
+ import type { PlaybackSource } from './audioPlayer';
3
+ import type { BriefingPosition } from './controller';
4
+
5
+ type AuthorizedFetch = (url: string, init?: RequestInit) => Promise<Response>;
6
+
7
+ /** One press of the reply button, as the tenant's reply route takes it. */
8
+ export interface ReplySend {
9
+ briefingId: string;
10
+ /** Fresh per press; the same id again is a replay (a retry after a lost answer). */
11
+ clientActionId: string;
12
+ /** The recording to understand. Omit for `apply` and `undo`. */
13
+ recording?: { uri: string; durationMs: number };
14
+ /** Where the briefing was at the press ("this one"). */
15
+ position?: BriefingPosition | null;
16
+ /** `auto` applies a sure reply at once; `preview` only says what was understood. */
17
+ mode?: 'auto' | 'preview';
18
+ apply?: boolean;
19
+ undo?: boolean;
20
+ /** The id of the press whose question this one answers. */
21
+ inReplyTo?: string;
22
+ }
23
+
24
+ export interface BriefingReplyApi {
25
+ send(request: ReplySend): Promise<ReplyResult>;
26
+ /** The spoken confirmation, owner-checked (needs the bearer), or null when there is only text. */
27
+ confirmationSource(result: ReplyResult): Promise<PlaybackSource | null>;
28
+ }
29
+
30
+ /**
31
+ * POST /corpus/briefing/reply. Audio goes up as multipart (the same `filePart` the recorder's uploads use); apply and undo
32
+ * are small JSON. A refusal throws with the route's `status` and `code` (`transcription_failed` is the one worth a retry).
33
+ */
34
+ export function createBriefingReplyApi(deps: {
35
+ tandemUrl: string;
36
+ authorizedFetch: AuthorizedFetch;
37
+ bearer: () => Promise<string | null>;
38
+ filePart?: (uri: string) => Blob;
39
+ createForm?: () => FormData;
40
+ timeZone?: string;
41
+ }): BriefingReplyApi {
42
+ const base = deps.tandemUrl.replace(/\/+$/, '');
43
+ const timeZone = deps.timeZone ?? (() => { try { return Intl.DateTimeFormat().resolvedOptions().timeZone; } catch { return undefined; } })();
44
+ return {
45
+ async send(request) {
46
+ const fields: Record<string, string> = {
47
+ briefingId: request.briefingId,
48
+ clientActionId: request.clientActionId,
49
+ ...(timeZone ? { timeZone } : {}),
50
+ ...(request.mode ? { mode: request.mode } : {}),
51
+ ...(request.apply ? { apply: 'true' } : {}),
52
+ ...(request.undo ? { undo: 'true' } : {}),
53
+ ...(request.inReplyTo ? { inReplyTo: request.inReplyTo } : {}),
54
+ ...(request.position ? { position: JSON.stringify({ seconds: request.position.seconds, durationSeconds: request.position.durationSeconds }) } : {}),
55
+ };
56
+ let init: RequestInit;
57
+ if (request.recording) {
58
+ const body = (deps.createForm ?? (() => new FormData()))();
59
+ if (deps.filePart) body.append('audio', deps.filePart(request.recording.uri), 'reply.m4a');
60
+ else body.append('audio', { uri: request.recording.uri, name: 'reply.m4a', type: 'audio/mp4' } as unknown as Blob);
61
+ for (const [k, v] of Object.entries(fields)) body.append(k, v);
62
+ init = { method: 'POST', body };
63
+ } else {
64
+ const json: Record<string, unknown> = { ...fields };
65
+ if (request.position) json.position = { seconds: request.position.seconds, durationSeconds: request.position.durationSeconds };
66
+ init = { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(json) };
67
+ }
68
+ const res = await deps.authorizedFetch(`${base}/corpus/briefing/reply`, init);
69
+ if (!res.ok) {
70
+ const detail = await res.json().catch(() => ({})) as { detail?: string; code?: string };
71
+ throw Object.assign(new Error(detail.detail || `POST /corpus/briefing/reply failed (${res.status})`), { status: res.status, ...(detail.code ? { code: detail.code } : {}) });
72
+ }
73
+ return (await res.json()) as ReplyResult;
74
+ },
75
+ async confirmationSource(result) {
76
+ const url = result.confirmation?.audioUrl;
77
+ if (!url) return null;
78
+ const token = await deps.bearer();
79
+ return { uri: new URL(url, `${base}/`).toString(), ...(token ? { headers: { authorization: `Bearer ${token}` } } : {}) };
80
+ },
81
+ };
82
+ }
@@ -105,3 +105,23 @@ describe('deep link autostop test hook', () => {
105
105
  expect(log).toHaveBeenCalledWith('deeplink', expect.objectContaining({ url: 'tandemgo://record', action: 'ignored-recording' }));
106
106
  });
107
107
  });
108
+
109
+ describe('deep link tandemgo://briefing', () => {
110
+ const withBriefing = createLinkResolver(resolveFoundryApp({ app: { name: 'Tandem Go', scheme: 'tandemgo' }, tenant: { url: 'https://t.example.com' }, features: { briefing: true } }));
111
+ it('waits for the session, then opens the briefing once', async () => {
112
+ const openBriefing = vi.fn();
113
+ const link = createDeepLink({ resolver: withBriefing, openBriefing, log: vi.fn() });
114
+ link.handle('tandemgo://briefing');
115
+ expect(openBriefing).not.toHaveBeenCalled();
116
+ await link.sessionReady();
117
+ await link.sessionReady();
118
+ expect(openBriefing).toHaveBeenCalledTimes(1);
119
+ });
120
+ it('opens at once when the session is already ready', async () => {
121
+ const openBriefing = vi.fn();
122
+ const link = createDeepLink({ resolver: withBriefing, openBriefing, log: vi.fn() });
123
+ await link.sessionReady();
124
+ link.handle('tandemgo://briefing');
125
+ expect(openBriefing).toHaveBeenCalledTimes(1);
126
+ });
127
+ });
@@ -12,6 +12,8 @@ export function createDeepLink(deps: {
12
12
  go?: (options: GoOptions) => Promise<void> | void;
13
13
  /** Open a tab (optionally on one record): the shell navigator. */
14
14
  open?: (tab: string, id?: string) => void;
15
+ /** Open the GO screen and play today's briefing (the morning notification's link). */
16
+ openBriefing?: () => void;
15
17
  log?: (event: string, fields?: Record<string, unknown>) => void;
16
18
  }) {
17
19
  const log = deps.log ?? (() => undefined);
@@ -19,6 +21,11 @@ export function createDeepLink(deps: {
19
21
  let pending: { action: LinkAction; url: string } | null = null;
20
22
 
21
23
  const run = (action: LinkAction, url: string) => {
24
+ if (action.kind === 'briefing') {
25
+ log('deeplink', { url, action: 'briefing' });
26
+ deps.openBriefing?.();
27
+ return;
28
+ }
22
29
  if (action.kind === 'open') {
23
30
  log('deeplink', { url, action: 'open', tab: action.tab, id: action.id });
24
31
  deps.open?.(action.tab, action.id);
@@ -0,0 +1,13 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import { trackerTab } from '../tab';
3
+
4
+ describe('the to-do list re-reads when a reply edited items', () => {
5
+ it('test_items_changed_refreshes_the_list_controller', () => {
6
+ const listeners = new Set<() => void>();
7
+ const controller = { refresh: vi.fn(async () => undefined) };
8
+ trackerTab({ api: {} as never, controller: controller as never, itemsChanged: { subscribe: (l) => { listeners.add(l); return () => listeners.delete(l); } } });
9
+ expect(controller.refresh).not.toHaveBeenCalled();
10
+ listeners.forEach((l) => l());
11
+ expect(controller.refresh).toHaveBeenCalledTimes(1);
12
+ });
13
+ });
@@ -18,10 +18,13 @@ export interface TrackerTabOptions {
18
18
  memberConnections?: Pick<MemberConnectionsApi, 'connections' | 'connectorCatalog'>;
19
19
  /** Opens a URL outside the app (`Linking.openURL`). A tracker link tries the tracker's app, then https. */
20
20
  openUrl?: (url: string) => Promise<unknown>;
21
+ /** Something else edited items (a spoken reply): the list re-reads. */
22
+ itemsChanged?: { subscribe(listener: () => void): () => void };
21
23
  }
22
24
 
23
25
  /** The to-do tab as one `FoundryTabsShell` entry: list -> detail (with the source note link). */
24
- export function trackerTab({ api, key = 'tracker', label = 'To-dos', notesKey = 'notes', controller = createTrackerController({ api }), memberConnections, openUrl }: TrackerTabOptions): FoundryTab {
26
+ export function trackerTab({ api, key = 'tracker', label = 'To-dos', notesKey = 'notes', controller = createTrackerController({ api }), memberConnections, openUrl, itemsChanged }: TrackerTabOptions): FoundryTab {
27
+ itemsChanged?.subscribe(() => { void controller.refresh(); });
25
28
  const onOpenLink = openUrl ? (url: string) => { void openTrackerLink(url, openUrl).catch(() => undefined); } : undefined;
26
29
  function Screen({ route, push, back, openTab }: { route: { id: string } | null; push: (id: string) => void; back: () => void; openTab: (tab: string, id?: string) => void }) {
27
30
  const trackerName = useTrackerName(memberConnections);