@startsimpli/integrations 0.2.111 → 0.2.113
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/README.md +1 -1
- package/package.json +4 -4
- package/src/__tests__/corpus-planning.test.tsx +2 -11
- package/src/__tests__/focus-standings.test.tsx +8 -9
- package/src/__tests__/project-surfaces.test.tsx +7 -7
- package/src/components/pages/PlanningPage.tsx +7 -24
- package/src/corpus/client.ts +2 -31
- package/src/corpus/standings.ts +1 -1
- package/src/corpus/types.ts +1 -4
- package/src/native/app/__tests__/FoundryApp.test.tsx +36 -0
package/README.md
CHANGED
|
@@ -220,7 +220,7 @@ Rules every list tab follows: one server request per page (never load a list and
|
|
|
220
220
|
|
|
221
221
|
**Planning, Connections, Connect Claude** (`src/native/screens/`, bd startsim-23np6.1.6). Each is a tab factory: `createPlanningTab({ api: createNativeCorpusApi(...), documentTab? })`, `createConnectionsTab({ api: createConnectionsMeApi({ baseUrl, fetch }) })`, `createConnectClaudeTab({ api: createMcpTokensApi({ baseUrl, fetch }), share? })`. `baseUrl` is the API root (`https://<tenant>/api/v1`) and `fetch` is the app's `authorizedFetch`; the tenant proxies `/api/v1/auth/*` (the MCP token mint) to central. Fakes for the simulator: `createFakePlanningApi()`, `createFakeConnectionsApi()`, `createFakeMcpTokensApi()`.
|
|
222
222
|
|
|
223
|
-
- Planning: projects worst-off first (server `orderBy=progress`, 25 a page), each
|
|
223
|
+
- Planning: projects worst-off first (server `orderBy=progress`, 25 a page), each page's done/overdue counts from `api.standings` (two grouped `entities/counts` reads for the whole page); a project opens onto its open or closed items (`in_focus` edge walk) and its notes (`about_focus`), each a server page.
|
|
224
224
|
- Connections: my connected accounts and their status, Test now, Disconnect (confirmed). Connecting a new account stays on the web.
|
|
225
225
|
- Connect Claude: mints only from the Create button, shows the token once, hands it to the system share sheet (Copy is on it), and forgets it on Done. The server has no list of issued tokens and no revoke (bd startsim-ja8mt), so the screen says so instead of offering either.
|
|
226
226
|
- `createMcpTokensApi` / `createConnectionsMeApi` take `{ baseUrl, fetch }` and never touch the web's module-global base, token provider or cookies; `mcpTokens` / `connectionsMe` are the same clients built over those globals.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startsimpli/integrations",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.113",
|
|
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",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"react-native": ">=0.74.0",
|
|
51
51
|
"@startsimpli/ui-native": ">=0.1.12",
|
|
52
52
|
"react-native-safe-area-context": ">=4.0.0",
|
|
53
|
-
"@startsimpli/ui": "^0.4.170",
|
|
54
53
|
"@startsimpli/auth": "^0.4.49",
|
|
55
|
-
"@startsimpli/utils": "^0.4.17"
|
|
54
|
+
"@startsimpli/utils": "^0.4.17",
|
|
55
|
+
"@startsimpli/ui": "^0.4.170"
|
|
56
56
|
},
|
|
57
57
|
"peerDependenciesMeta": {
|
|
58
58
|
"react": {
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"react-native-safe-area-context": "~5.7.0",
|
|
101
101
|
"@startsimpli/llm": "0.4.28",
|
|
102
102
|
"@startsimpli/ui": "0.4.170",
|
|
103
|
-
"@startsimpli/ui-native": "0.1.
|
|
103
|
+
"@startsimpli/ui-native": "0.1.14",
|
|
104
104
|
"@startsimpli/auth": "0.4.49",
|
|
105
105
|
"@startsimpli/utils": "0.4.17"
|
|
106
106
|
},
|
|
@@ -374,15 +374,6 @@ describe('filing is an edge, and the client has to say so', () => {
|
|
|
374
374
|
expect(calls.at(-1)!.params['attr._origin']).toBe('human');
|
|
375
375
|
});
|
|
376
376
|
|
|
377
|
-
it('counts a focus standing without pulling a single row body', async () => {
|
|
378
|
-
const { calls, http } = httpSpy();
|
|
379
|
-
const api = createPlanningApi({ http: http as never, scope: SCOPE });
|
|
380
|
-
await api.focusStanding!('focus-uuid', NOW);
|
|
381
|
-
const counting = calls.slice(-3);
|
|
382
|
-
expect(counting).toHaveLength(3);
|
|
383
|
-
for (const call of counting) expect(call.params.page_size).toBe(1);
|
|
384
|
-
});
|
|
385
|
-
|
|
386
377
|
it('sends a snake_cased key when its camelCase draft field was patched', async () => {
|
|
387
378
|
// The map exists because the two names DIFFER. A guard that compared the
|
|
388
379
|
// wrong side would pass on `ownerName` — where both spellings coincide —
|
|
@@ -458,8 +449,8 @@ function fakeApi(options: {
|
|
|
458
449
|
return page(options.items ?? [], options.applied ?? ['status']);
|
|
459
450
|
},
|
|
460
451
|
listFocuses: async () => page(options.focuses ?? []),
|
|
461
|
-
|
|
462
|
-
options.standings?.[focusId] ?? { focusId, total: 0, done: 0, overdue: 0 },
|
|
452
|
+
focusStandings: async (focusIds) => Object.fromEntries(focusIds.map((focusId) =>
|
|
453
|
+
[focusId, options.standings?.[focusId] ?? { focusId, total: 0, done: 0, overdue: 0 }])),
|
|
463
454
|
};
|
|
464
455
|
}
|
|
465
456
|
|
|
@@ -100,20 +100,19 @@ function planning(extra: Partial<PlanningApi>): PlanningApi {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
describe('PlanningPage standings', () => {
|
|
103
|
-
it('uses ONE batched read for every card
|
|
104
|
-
const focusStanding = vi.fn();
|
|
103
|
+
it('uses ONE batched read for every card', async () => {
|
|
105
104
|
const focusStandings = vi.fn(async (): Promise<Record<string, FocusStanding>> => ({ f1: { focusId: 'f1', total: 40, done: 12, overdue: 3 } }));
|
|
106
|
-
render(<PlanningPage api={planning({
|
|
105
|
+
render(<PlanningPage api={planning({ focusStandings })} scope={SCOPE} now={NOW} />);
|
|
107
106
|
await waitFor(() => expect(screen.getByText(/12 of 40 done/)).toBeInTheDocument());
|
|
108
107
|
expect(focusStandings).toHaveBeenCalledTimes(1);
|
|
109
|
-
expect(focusStanding).not.toHaveBeenCalled();
|
|
110
108
|
});
|
|
111
109
|
|
|
112
|
-
it('
|
|
110
|
+
it('a refused batched read leaves the cards without counts: no per-card reads, no error screen', async () => {
|
|
113
111
|
const focusStandings = vi.fn(async () => { throw new Error('400'); });
|
|
114
|
-
const focusStanding = vi.fn(
|
|
115
|
-
render(<PlanningPage api={planning({
|
|
116
|
-
await waitFor(() => expect(
|
|
117
|
-
expect(
|
|
112
|
+
const focusStanding = vi.fn();
|
|
113
|
+
render(<PlanningPage api={planning({ focusStandings, ...({ focusStanding } as object) })} scope={SCOPE} now={NOW} />);
|
|
114
|
+
await waitFor(() => expect(focusStandings).toHaveBeenCalledTimes(1));
|
|
115
|
+
expect(screen.getByText('Crochets')).toBeInTheDocument();
|
|
116
|
+
expect(focusStanding).not.toHaveBeenCalled();
|
|
118
117
|
});
|
|
119
118
|
});
|
|
@@ -229,17 +229,17 @@ describe('about_focus never changes a focus’s standing', () => {
|
|
|
229
229
|
it('counts only commitments over in_focus, before and after a document is filed', async () => {
|
|
230
230
|
const { edges, gets, http } = fakeTenant();
|
|
231
231
|
const api = createPlanningApi({ http: http as never, scope: SCOPE });
|
|
232
|
-
await api.
|
|
232
|
+
await api.focusStandings!(['f1'], Date.parse('2026-11-02T00:00:00Z'));
|
|
233
233
|
await api.fileDocument!('d1', 'f1');
|
|
234
234
|
await api.listDocuments!({ focus: 'f1', page: 1, pageSize: 10 });
|
|
235
|
-
await api.
|
|
235
|
+
await api.focusStandings!(['f1'], Date.parse('2026-11-02T00:00:00Z'));
|
|
236
236
|
|
|
237
237
|
expect(edgesOf(edges, 'd1')).toHaveLength(1);
|
|
238
|
-
const counts = gets.filter((g) => g.
|
|
239
|
-
expect(counts.length).toBe(
|
|
238
|
+
const counts = gets.filter((g) => g.path.endsWith('counts'));
|
|
239
|
+
expect(counts.length).toBe(4); // 2 grouped reads x 2 passes
|
|
240
240
|
for (const call of counts) {
|
|
241
241
|
expect(call.params.type).toBe('commitment');
|
|
242
|
-
expect(call.params.
|
|
242
|
+
expect(String(call.params.group_by)).toContain('edge:in_focus');
|
|
243
243
|
}
|
|
244
244
|
});
|
|
245
245
|
|
|
@@ -277,8 +277,8 @@ function planningWithDocs(options: {
|
|
|
277
277
|
return {
|
|
278
278
|
listCommitments: async () => page([]),
|
|
279
279
|
listFocuses: async () => page([FOCUS_A, FOCUS_B]),
|
|
280
|
-
|
|
281
|
-
options.standings?.[focusId] ?? { focusId, total: 0, done: 0, overdue: 0 },
|
|
280
|
+
focusStandings: async (focusIds) => Object.fromEntries(focusIds.map((focusId) =>
|
|
281
|
+
[focusId, options.standings?.[focusId] ?? { focusId, total: 0, done: 0, overdue: 0 }])),
|
|
282
282
|
listDocuments: async (query: DocumentQuery) => {
|
|
283
283
|
options.onDocuments?.(query);
|
|
284
284
|
// The server pages: a second page returns the second slice.
|
|
@@ -99,7 +99,6 @@ const PRIORITY_OPTIONS = [
|
|
|
99
99
|
* unbounded for the same reason the corpus graph read is: the tenant data API
|
|
100
100
|
* pays for every one of them.
|
|
101
101
|
*/
|
|
102
|
-
const STANDING_CONCURRENCY = 4;
|
|
103
102
|
|
|
104
103
|
export interface PlanningPageProps {
|
|
105
104
|
api: PlanningApi;
|
|
@@ -175,30 +174,14 @@ export function PlanningPage({
|
|
|
175
174
|
const api = apiRef.current;
|
|
176
175
|
// The clock is passed IN so "overdue" is computed against the frozen mount
|
|
177
176
|
// time rather than a fresh Date.now() per call.
|
|
178
|
-
if (api.focusStandings)
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
if (!live) return;
|
|
184
|
-
setStandings((prev) => ({ ...prev, ...found }));
|
|
185
|
-
return;
|
|
186
|
-
} catch { /* fall through to one standing per card */ }
|
|
187
|
-
}
|
|
188
|
-
if (!api.focusStanding) return;
|
|
189
|
-
const standing = api.focusStanding.bind(api);
|
|
190
|
-
for (let i = 0; i < loaded.length && live; i += STANDING_CONCURRENCY) {
|
|
191
|
-
const slice = loaded.slice(i, i + STANDING_CONCURRENCY);
|
|
192
|
-
const results = await Promise.all(
|
|
193
|
-
slice.map((focus) => standing(focus.id, clock).catch(() => null)),
|
|
194
|
-
);
|
|
177
|
+
if (!api.focusStandings) return;
|
|
178
|
+
// The whole page in two grouped reads. A refusal leaves the cards without
|
|
179
|
+
// counts; the list itself still renders.
|
|
180
|
+
try {
|
|
181
|
+
const found = await api.focusStandings(loaded.map((f) => f.id), clock);
|
|
195
182
|
if (!live) return;
|
|
196
|
-
setStandings((prev) => {
|
|
197
|
-
|
|
198
|
-
for (const result of results) if (result) next[result.focusId] = result;
|
|
199
|
-
return next;
|
|
200
|
-
});
|
|
201
|
-
}
|
|
183
|
+
setStandings((prev) => ({ ...prev, ...found }));
|
|
184
|
+
} catch { /* cards show no counts */ }
|
|
202
185
|
})();
|
|
203
186
|
return () => { live = false; };
|
|
204
187
|
// `scope.orgId` and not `scope`: an app that rebuilds the scope object every
|
package/src/corpus/client.ts
CHANGED
|
@@ -1181,10 +1181,8 @@ const FOCUS_PATCH_KEYS: Record<string, keyof FocusDraft> = {
|
|
|
1181
1181
|
* the SAME rows, and a full-object PUT from an edit dialog would silently drop
|
|
1182
1182
|
* whatever the last extraction pass had just added.
|
|
1183
1183
|
*
|
|
1184
|
-
*
|
|
1185
|
-
*
|
|
1186
|
-
* paginator's own `count`, so a focus card costs three empty pages rather than
|
|
1187
|
-
* three pages of bodies.
|
|
1184
|
+
* Counts come from the tenant's grouped `entities/counts` read
|
|
1185
|
+
* (`focusStandings`), two requests for a whole page of focus cards.
|
|
1188
1186
|
*/
|
|
1189
1187
|
export function createPlanningApi(options: CreateCorpusApiOptions): PlanningApi {
|
|
1190
1188
|
const base = createCorpusApi(options);
|
|
@@ -1241,14 +1239,6 @@ export function createPlanningApi(options: CreateCorpusApiOptions): PlanningApi
|
|
|
1241
1239
|
};
|
|
1242
1240
|
}
|
|
1243
1241
|
|
|
1244
|
-
/** A count with no rows: ask for one, read `count`, throw the row away. */
|
|
1245
|
-
async function countOnly(params: Record<string, unknown>): Promise<number> {
|
|
1246
|
-
const response = await http.get<DrfPage<TenantEntity>>(entities, {
|
|
1247
|
-
params: { ...params, page_size: 1 },
|
|
1248
|
-
});
|
|
1249
|
-
return response.count ?? response.results?.length ?? 0;
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
1242
|
/** The `in_focus` scope for one focus, as query params. */
|
|
1253
1243
|
function inFocus(focusId: string): Record<string, unknown> {
|
|
1254
1244
|
return {
|
|
@@ -1431,25 +1421,6 @@ export function createPlanningApi(options: CreateCorpusApiOptions): PlanningApi
|
|
|
1431
1421
|
await setCommitmentFocus(http, item.id, focusId, { relationships });
|
|
1432
1422
|
},
|
|
1433
1423
|
|
|
1434
|
-
/**
|
|
1435
|
-
* "12 of 40 done, 3 overdue" for one focus — three counts, no row bodies.
|
|
1436
|
-
*
|
|
1437
|
-
* `now` is a PARAMETER and not a `Date.now()` read inside, for the reason
|
|
1438
|
-
* `TrackerPageProps.now` records: a clock read on the way past is a new
|
|
1439
|
-
* value every call, which makes it a new memo dependency, which is how a
|
|
1440
|
-
* screen ends up issuing 917 requests in ten minutes on a live tenant.
|
|
1441
|
-
*/
|
|
1442
|
-
async focusStanding(focusId: string, now?: number): Promise<FocusStanding> {
|
|
1443
|
-
const scopeParams = inFocus(focusId);
|
|
1444
|
-
const asOf = new Date(now ?? Date.now()).toISOString();
|
|
1445
|
-
const [total, done, overdue] = await Promise.all([
|
|
1446
|
-
countOnly(scopeParams),
|
|
1447
|
-
countOnly({ ...scopeParams, 'attr.status': 'done' }),
|
|
1448
|
-
countOnly({ ...scopeParams, 'attr.status': 'open', 'attr.due_at__lte': asOf }),
|
|
1449
|
-
]);
|
|
1450
|
-
return { focusId, total, done, overdue };
|
|
1451
|
-
},
|
|
1452
|
-
|
|
1453
1424
|
focusStandings: (focusIds, now) => readStandings(http, focusIds, now ?? Date.now(), {
|
|
1454
1425
|
commitmentType: types.commitment, entitiesPath: entities,
|
|
1455
1426
|
}),
|
package/src/corpus/standings.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* "12 of 40 done, 3 overdue" for a PAGE of projects, from two grouped reads of
|
|
3
3
|
* `GET api/v1/entities/counts/` (bd startsim-09zue) - however many projects the
|
|
4
|
-
* page holds. It replaces
|
|
4
|
+
* page holds. It replaces three count-only reads PER project
|
|
5
5
|
* (a 100-project web page was 300 requests). The web and native Planning screens
|
|
6
6
|
* share this one reader.
|
|
7
7
|
*
|
package/src/corpus/types.ts
CHANGED
|
@@ -1371,12 +1371,9 @@ export interface PlanningApi extends CommitmentApi {
|
|
|
1371
1371
|
/** Children of a focus, one level. The tree is walked a level at a time
|
|
1372
1372
|
* because the query layer caps a traversal at `related_depth=2`. */
|
|
1373
1373
|
listChildFocuses?(focusId: string): Promise<CorpusPage<Focus>>;
|
|
1374
|
-
/** Counts for one focus, from `count` alone — no row bodies cross the wire. */
|
|
1375
|
-
focusStanding?(focusId: string, now?: number): Promise<FocusStanding>;
|
|
1376
1374
|
/**
|
|
1377
1375
|
* Counts for a whole PAGE of projects in two grouped reads (`entities/counts`),
|
|
1378
|
-
* keyed by focus id.
|
|
1379
|
-
* that predates the endpoint rejects it and the caller falls back.
|
|
1376
|
+
* keyed by focus id. Every live tenant serves the endpoint.
|
|
1380
1377
|
*/
|
|
1381
1378
|
focusStandings?(focusIds: string[], now?: number): Promise<Record<string, FocusStanding>>;
|
|
1382
1379
|
/** The tenant's real members, for the owner picker. Absent when the fork is
|
|
@@ -12,6 +12,7 @@ vi.mock('react-native', async () => {
|
|
|
12
12
|
};
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
+
import { __setColorScheme } from '../../../../../ui-native/test/rn-stub';
|
|
15
16
|
import { act, allText, hostById, maybeById, press, render } from '../../../../../ui-native/test/render';
|
|
16
17
|
import { FoundryApp } from '../FoundryApp';
|
|
17
18
|
import type { FoundryDevice } from '../device';
|
|
@@ -58,4 +59,39 @@ describe('FoundryApp over fakes (no sign-in, no network)', () => {
|
|
|
58
59
|
delete launchArgs.tgFakeTabs;
|
|
59
60
|
expect(() => render(<FoundryApp config={{ ...config, features: { recording: true }, tabs: undefined }} device={device()} />)).toThrow(/recording/);
|
|
60
61
|
});
|
|
62
|
+
|
|
63
|
+
describe('theme.mode', () => {
|
|
64
|
+
const bar = (r: ReturnType<typeof render>) => r.root.findAllByType('StatusBar' as never)[0].props.barStyle;
|
|
65
|
+
const themed = (mode?: string) => {
|
|
66
|
+
launchArgs.tgFakeTabs = '1';
|
|
67
|
+
const r = render(<FoundryApp config={{ ...config, ...(mode ? { theme: { mode } } : {}) }} device={device()} />);
|
|
68
|
+
return r;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
it('defaults to dark whatever the system says', async () => {
|
|
72
|
+
__setColorScheme('light');
|
|
73
|
+
const r = themed();
|
|
74
|
+
await tick();
|
|
75
|
+
expect(bar(r)).toBe('light-content');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('light stays light under a dark system', async () => {
|
|
79
|
+
__setColorScheme('dark');
|
|
80
|
+
const r = themed('light');
|
|
81
|
+
await tick();
|
|
82
|
+
expect(bar(r)).toBe('dark-content');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('system follows the system appearance', async () => {
|
|
86
|
+
__setColorScheme('light');
|
|
87
|
+
const light = themed('system');
|
|
88
|
+
await tick();
|
|
89
|
+
expect(bar(light)).toBe('dark-content');
|
|
90
|
+
__setColorScheme('dark');
|
|
91
|
+
const dark = themed('system');
|
|
92
|
+
await tick();
|
|
93
|
+
expect(bar(dark)).toBe('light-content');
|
|
94
|
+
__setColorScheme('light');
|
|
95
|
+
});
|
|
96
|
+
});
|
|
61
97
|
});
|