@startsimpli/integrations 0.2.146 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startsimpli/integrations",
3
- "version": "0.2.146",
3
+ "version": "0.2.147",
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",
@@ -51,8 +51,8 @@
51
51
  "@startsimpli/ui-native": ">=0.1.12",
52
52
  "react-native-safe-area-context": ">=4.0.0",
53
53
  "@startsimpli/utils": "^0.4.17",
54
- "@startsimpli/auth": "^0.4.50",
55
- "@startsimpli/ui": "^0.4.171"
54
+ "@startsimpli/ui": "^0.4.171",
55
+ "@startsimpli/auth": "^0.4.50"
56
56
  },
57
57
  "peerDependenciesMeta": {
58
58
  "react": {
@@ -99,10 +99,10 @@
99
99
  "react-native": "0.85.3",
100
100
  "react-native-safe-area-context": "~5.7.0",
101
101
  "@startsimpli/llm": "0.4.31",
102
+ "@startsimpli/ui": "0.4.171",
102
103
  "@startsimpli/ui-native": "0.1.14",
103
104
  "@startsimpli/auth": "0.4.50",
104
- "@startsimpli/utils": "0.4.17",
105
- "@startsimpli/ui": "0.4.171"
105
+ "@startsimpli/utils": "0.4.17"
106
106
  },
107
107
  "scripts": {
108
108
  "type-check": "tsc --noEmit && tsc --noEmit -p tsconfig.native.json",
@@ -78,11 +78,13 @@ describe('the Nov 5 replay (startsim-8dttf)', () => {
78
78
  expect(filed[byTitle(items, 'tunnel timeout').externalId]).toBe('f-dbg');
79
79
  });
80
80
 
81
- it("dad's bench present links to Prezzies, or to the personal destination", async () => {
81
+ it("dad's bench present is under the note's Personal heading: private and personal, even when the model would file it under Prezzies (bd startsim-768w.38.48)", async () => {
82
82
  const { corpus, saves } = world();
83
83
  await extractCommitments({ scope: SCOPE }, { corpus, extractor: extractor(reader()) });
84
84
  const bench = byTitle(saves[0].items, 'bench');
85
- expect(saves[0].options!.fileUnder![bench.externalId]).toBe('f-prez');
85
+ expect(saves[0].options?.fileUnder?.[bench.externalId]).toBeUndefined();
86
+ expect(bench.visibility).toBe('private');
87
+ expect(bench.destination).toBe('personal');
86
88
  const second = world();
87
89
  await extractCommitments({ scope: SCOPE }, { corpus: second.corpus, extractor: extractor(reader({ 'Order the bench as a present for dad': PERSONAL })) });
88
90
  const personal = byTitle(second.saves[0].items, 'bench');
@@ -118,7 +120,9 @@ describe('one destination per item', () => {
118
120
  await extractCommitments({ scope: SCOPE }, { corpus, extractor: extractor(reader({ 'Book the dentist for next week': 'f-invented' })) });
119
121
  const dentist = byTitle(saves[0].items, 'dentist');
120
122
  expect(dentist.focusId).toBeUndefined();
121
- expect(dentist.destination).toBeUndefined();
123
+ // Under the Personal heading, so private + personal whatever the model said.
124
+ expect(dentist.destination).toBe('personal');
125
+ expect(dentist.visibility).toBe('private');
122
126
  expect(saves[0].options!.fileUnder![dentist.externalId]).toBeUndefined();
123
127
  });
124
128
 
@@ -161,7 +165,8 @@ describe('no loss', () => {
161
165
  const result = await extractCommitments({ scope: SCOPE }, { corpus, extractor: extractor(async () => { throw new Error('model down'); }) });
162
166
  expect(saves[0].items).toHaveLength(5);
163
167
  expect(saves[0].options?.fileUnder).toBeUndefined();
164
- expect(saves[0].items.every((i) => !i.focusId && !i.destination)).toBe(true);
168
+ // The Personal-heading items are private without the model; nothing is FILED.
169
+ expect(saves[0].items.every((i) => !i.focusId && (!i.destination || i.visibility === 'private'))).toBe(true);
165
170
  expect(result.classifyFailure?.message).toContain('model down');
166
171
  });
167
172
 
@@ -0,0 +1,63 @@
1
+ /**
2
+ * PERSONAL SECTIONS BECOME PRIVATE ITEMS (bd startsim-768w.38.48).
3
+ *
4
+ * A voice note's Personal section must never reach teammates. The tenant enforces
5
+ * it (row scope `visibility`); this is the writer's half: the item is written with
6
+ * `visibility: private`, whether or not the classifier called it personal, and a
7
+ * project item is never marked.
8
+ */
9
+ import { describe, expect, it } from 'vitest';
10
+
11
+ import { commitmentToEntity } from '../corpus/entities';
12
+ import { extractCommitments } from '../corpus/extract';
13
+ import { toSourceDocument } from '../corpus/entities';
14
+ import { NOV5_SUMMARY } from './fixtures/nov5-note';
15
+ import type { Commitment, CorpusExtractorLlm } from '../corpus/types';
16
+ import { isPersonalItem } from '../corpus/extract';
17
+
18
+ const SCOPE = { orgId: 'o' } as never;
19
+ const note = () =>
20
+ toSourceDocument(
21
+ { id: 'e527a7f5', name: 'Nov 5', data: { source: 'voice', title: 'Nov 5 note', summary: NOV5_SUMMARY, body: '' } } as never,
22
+ SCOPE,
23
+ );
24
+
25
+ describe('private items from a voice note', () => {
26
+ it('marks every item under a Personal heading private, even with NO classifier', async () => {
27
+ const saved: Commitment[] = [];
28
+ const document = note();
29
+ const corpus = {
30
+ listDocuments: async () => ({ count: 1, next: null, previous: null, results: [document] }),
31
+ getDocument: async () => document,
32
+ listParties: async () => ({ count: 0, next: null, previous: null, results: [] }),
33
+ listSources: async () => [],
34
+ listCommitments: async () => ({ count: 0, next: null, previous: null, results: [] }),
35
+ saveCommitments: async (items: Commitment[]) => { saved.push(...items); },
36
+ } as never;
37
+ const extractor: CorpusExtractorLlm = {
38
+ describe: () => ({ provider: 'fixture', model: 'fixture', live: false }),
39
+ extract: async () => ({ items: [], resolutions: [] }),
40
+ };
41
+ await extractCommitments({ scope: SCOPE }, { corpus, extractor });
42
+ const personal = saved.filter((i) => i.mentions.some((m) => /^personal/i.test(m.section ?? '')));
43
+ const shared = saved.filter((i) => !personal.includes(i));
44
+ expect(personal.length).toBeGreaterThan(0);
45
+ expect(shared.length).toBeGreaterThan(0);
46
+ expect(personal.every((i) => i.visibility === 'private' && i.destination === 'personal' && !i.focusId)).toBe(true);
47
+ expect(shared.every((i) => i.visibility === undefined)).toBe(true);
48
+ });
49
+
50
+ it('the classifier calling an item personal is enough, whatever the heading', () => {
51
+ expect(isPersonalItem({ destination: 'personal', mentions: [] })).toBe(true);
52
+ expect(isPersonalItem({ mentions: [{ section: 'Crochets' }] as never })).toBe(false);
53
+ expect(isPersonalItem({ mentions: [{ section: ' personal ' }] as never })).toBe(true);
54
+ expect(isPersonalItem({ mentions: [{ section: 'Personal projects' }] as never })).toBe(true);
55
+ expect(isPersonalItem({ mentions: [{ section: 'Impersonal' }] as never })).toBe(false);
56
+ });
57
+
58
+ it('is written to the row, and only when private', () => {
59
+ const base = { externalId: 'x', title: 't', status: 'open', mentions: [], subjectKey: '', actionKey: '', dedupeKey: 'd', firstSeenAt: '', lastSeenAt: '', extractorVersion: 'v', source: 'voice' } as unknown as Commitment;
60
+ expect(commitmentToEntity({ ...base, visibility: 'private' }).data.visibility).toBe('private');
61
+ expect('visibility' in commitmentToEntity(base).data).toBe(false);
62
+ });
63
+ });
@@ -0,0 +1,44 @@
1
+ /**
2
+ * An item's owner can make it private (readable by them alone) and shared again
3
+ * from its detail page (bd startsim-768w.38.48). The tenant enforces it; this is
4
+ * the control and the badge.
5
+ */
6
+ import { describe, expect, it, vi } from 'vitest';
7
+ import { render, screen, waitFor, fireEvent } from '@testing-library/react';
8
+
9
+ import { TaskDetailPage } from '../components/pages/TaskDetailPage';
10
+ import { toCommitment, type TenantEntity } from '../corpus/entities';
11
+ import type { Commitment, CommitmentApi } from '../corpus/types';
12
+
13
+ const make = (data: Record<string, unknown> = {}): Commitment =>
14
+ toCommitment({
15
+ id: 'a', external_id: 'commit:a', name: 'a', entity_type: 'commitment', version: 1,
16
+ data: { title: 'Task a', status: 'open', subtype: 'action', mentions: [], ...data },
17
+ } as unknown as TenantEntity, { orgId: 'o' });
18
+
19
+ function apiWith(item: Commitment): CommitmentApi & { updateCommitment: ReturnType<typeof vi.fn> } {
20
+ return {
21
+ listCommitments: vi.fn(async (q: { page?: number } = {}) => ({ results: (q.page ?? 1) === 1 ? [item] : [], count: 1 })) as never,
22
+ updateCommitment: vi.fn(async (it: Commitment, patch: object) => ({ ...it, ...patch })) as never,
23
+ };
24
+ }
25
+
26
+ describe('private items', () => {
27
+ it('a shared item offers "Make private" and sends visibility: private', async () => {
28
+ const api = apiWith(make());
29
+ render(<TaskDetailPage api={api} scope={{ orgId: 'o' } as never} itemId="commit:a" />);
30
+ fireEvent.click(await screen.findByRole('button', { name: /make private/i }));
31
+ await waitFor(() => expect(api.updateCommitment).toHaveBeenCalledWith(expect.anything(), { visibility: 'private' }));
32
+ expect(await screen.findByText(/only you can see this/i)).toBeInTheDocument();
33
+ expect(screen.getByRole('button', { name: /share with the team/i })).toBeInTheDocument();
34
+ });
35
+
36
+ it('a private item is badged and can be shared again (visibility: null)', async () => {
37
+ const api = apiWith(make({ visibility: 'private' }));
38
+ render(<TaskDetailPage api={api} scope={{ orgId: 'o' } as never} itemId="commit:a" />);
39
+ expect(await screen.findByText(/only you can see this/i)).toBeInTheDocument();
40
+ fireEvent.click(screen.getByRole('button', { name: /share with the team/i }));
41
+ await waitFor(() => expect(api.updateCommitment).toHaveBeenCalledWith(expect.anything(), { visibility: null }));
42
+ expect(await screen.findByRole('button', { name: /make private/i })).toBeInTheDocument();
43
+ });
44
+ });
@@ -104,6 +104,20 @@ export function TaskDetailPage({
104
104
  setBusy(false);
105
105
  }
106
106
  };
107
+ const setPrivate = async (makePrivate: boolean) => {
108
+ if (!item || !apiRef.current.updateCommitment) return;
109
+ setBusy(true);
110
+ setError('');
111
+ try {
112
+ const updated = await apiRef.current.updateCommitment(item, { visibility: makePrivate ? 'private' : null });
113
+ const { visibility: _was, ...rest } = { ...item, ...updated };
114
+ setItem(makePrivate ? { ...rest, visibility: 'private' } : rest);
115
+ } catch (err) {
116
+ setError(failureMessage(err));
117
+ } finally {
118
+ setBusy(false);
119
+ }
120
+ };
107
121
  const [form, setForm] = React.useState({ title: '', detail: '', owner: '', due: '' });
108
122
 
109
123
  React.useEffect(() => {
@@ -194,6 +208,7 @@ export function TaskDetailPage({
194
208
  <div className="flex flex-wrap items-center gap-2">
195
209
  <span className={cn.badge}>{item.status.replace('_', ' ')}</span>
196
210
  {priority ? <span className={cn.badge}>{priority}</span> : null}
211
+ {item.visibility === 'private' ? <span className={cn.badge} title="Hidden from everyone else in the workspace">Private: only you can see this</span> : null}
197
212
  {project ? <span className={cn.badge}>{project}</span> : null}
198
213
  {item.sync ? <ExternalLinkChip sync={item.sync} trackerName={trackerName} className={cn.badge} /> : null}
199
214
  </div>
@@ -249,6 +264,9 @@ export function TaskDetailPage({
249
264
  {canWrite && !editing ? (
250
265
  <div className="mt-4 flex flex-wrap gap-2">
251
266
  <button type="button" className={cn.secondaryButton} disabled={busy} onClick={startEdit}>Edit</button>
267
+ <button type="button" className={cn.secondaryButton} disabled={busy} onClick={() => void setPrivate(item.visibility !== 'private')}>
268
+ {item.visibility === 'private' ? 'Share with the team' : 'Make private'}
269
+ </button>
252
270
  {closed ? (
253
271
  <button type="button" className={cn.secondaryButton} disabled={busy} onClick={() => void setStatus('open')}>Reopen</button>
254
272
  ) : (
@@ -1422,6 +1422,14 @@ export function createPlanningApi(options: CreateCorpusApiOptions): PlanningApi
1422
1422
  if (patch.subtype !== undefined) wire.subtype = patch.subtype;
1423
1423
  if (patch.priority !== undefined) wire.priority = patch.priority;
1424
1424
  if (patch.resolvedAt !== undefined) wire.resolved_at = patch.resolvedAt;
1425
+ // `null` clears the mark: the tenant reads anything but 'private' as shared.
1426
+ if (patch.visibility !== undefined) {
1427
+ wire.visibility = patch.visibility ?? '';
1428
+ // Private items also route as personal so the tracker push never sends
1429
+ // them to a shared team; an already-linked issue is left as it is.
1430
+ if (patch.visibility === 'private' && !item.sync) wire.destination = 'personal';
1431
+ if (patch.visibility === null && item.visibility === 'private' && item.destination === 'personal') wire.destination = '';
1432
+ }
1425
1433
  const name = patch.title !== undefined ? patch.title.slice(0, 200) : undefined;
1426
1434
  if (http.patch && item.id) {
1427
1435
  const claimed = await patchEditedItem(
@@ -737,6 +737,8 @@ export function toCommitment(
737
737
  ? { dueConfidence: asNumber(pick(data, 'due_confidence', 'dueConfidence')) } : {}),
738
738
  ...(pick(data, 'owner_sub', 'ownerSub')
739
739
  ? { ownerSub: asText(pick(data, 'owner_sub', 'ownerSub')) } : {}),
740
+ ...(pick(data, 'visibility') === 'private' ? { visibility: 'private' as const } : {}),
741
+ ...(pick(data, 'destination') === 'personal' ? { destination: 'personal' as const } : {}),
740
742
  ...(decodeOwnerSubs(pick(data, 'owner_subs', 'ownerSubs')).length
741
743
  ? { ownerSubs: decodeOwnerSubs(pick(data, 'owner_subs', 'ownerSubs')) } : {}),
742
744
  // Both spellings, for the reason spelled out on ORIGIN_KEY above: the
@@ -817,6 +819,7 @@ export function commitmentToEntity(commitment: Commitment): {
817
819
  ...(commitment.ownerSub ? { owner_sub: commitment.ownerSub } : {}),
818
820
  ...(commitment.ownerSubs?.length ? { owner_subs: encodeOwnerSubs(commitment.ownerSubs) } : {}),
819
821
  ...(commitment.destination ? { destination: commitment.destination } : {}),
822
+ ...(commitment.visibility === 'private' ? { visibility: 'private' } : {}),
820
823
  ...(commitment.externalFocusId ? { external_focus_id: commitment.externalFocusId } : {}),
821
824
  ...(commitment.externalContainerId ? { external_container_id: commitment.externalContainerId } : {}),
822
825
  first_seen_at: commitment.firstSeenAt,
@@ -562,6 +562,15 @@ export async function extractCommitments(
562
562
  } else if (placed?.destination) {
563
563
  item.destination = placed.destination;
564
564
  }
565
+ if (isPersonalItem(item)) {
566
+ // Private also means "never leaves Tandem for a shared tracker": the push
567
+ // engine routes `destination: personal` to the member's private space, or
568
+ // holds it. A project filing would send it to a team's Linear project.
569
+ item.visibility = 'private';
570
+ item.destination = 'personal';
571
+ delete item.focusId;
572
+ delete item.externalFocusId;
573
+ }
565
574
  }
566
575
  const teams = await classifyTeams(fresh, { corpus, extractor, documents, promptText });
567
576
  for (const item of fresh) {
@@ -672,6 +681,18 @@ async function classifyTeams(
672
681
  }
673
682
  }
674
683
 
684
+ /**
685
+ * An item that came from the speaker's own Personal section, or that the
686
+ * classifier called a personal errand. Both are private to the owner (bd
687
+ * startsim-768w.38.48). The heading rule is deterministic on purpose: the
688
+ * classifier is a model and did not mark a single Personal-section item on the
689
+ * live tenant, so privacy cannot depend on it.
690
+ */
691
+ export function isPersonalItem(item: Pick<Commitment, 'destination' | 'mentions'>): boolean {
692
+ if (item.destination === 'personal') return true;
693
+ return item.mentions.some((mention) => /^\s*personal\b/i.test(mention.section ?? ''));
694
+ }
695
+
675
696
  async function readAllFocuses(list: NonNullable<PlanningApi['listFocuses']>) {
676
697
  const out = [];
677
698
  for (let page = 1; page <= 10; page++) {
@@ -715,6 +715,15 @@ export interface Commitment {
715
715
  * Mutually exclusive with `focusId`.
716
716
  */
717
717
  destination?: 'personal';
718
+ /**
719
+ * `private` makes the item readable by its owner ALONE, enforced by the tenant
720
+ * on every read path (bd startsim-768w.38.48): the tenant's `visibility` row
721
+ * scope reads `data.visibility`. Absent means shared with the workspace.
722
+ * Set on extraction for a voice note's Personal section and by the owner's
723
+ * manual mark; never inferred client-side, because hiding in the UI is not
724
+ * privacy.
725
+ */
726
+ visibility?: 'private';
718
727
  /**
719
728
  * The focus the push should file the tracker issue under (a copy of `focusId`
720
729
  * at classification time, written to the row so the central push can read it).
@@ -906,6 +915,8 @@ export interface CommitmentApi {
906
915
  updateCommitment?(item: Commitment, patch: Partial<Pick<Commitment,
907
916
  'status' | 'statusReason' | 'ownerName' | 'ownerSub' | 'ownerSubs' | 'dueAt' | 'subtype'
908
917
  | 'title' | 'detail' | 'resolvedAt'>> & {
918
+ /** `private` hides the item from everyone but its owner; `null` makes it shared again. */
919
+ visibility?: 'private' | null;
909
920
  /** `null` clears it (undoing a voice-set priority). */
910
921
  priority?: number | null;
911
922
  }): Promise<Commitment>;