@startsimpli/integrations 0.2.96 → 0.2.97
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.
|
|
3
|
+
"version": "0.2.97",
|
|
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",
|
|
@@ -100,9 +100,9 @@
|
|
|
100
100
|
"react-native-safe-area-context": "~5.7.0",
|
|
101
101
|
"@startsimpli/llm": "0.4.28",
|
|
102
102
|
"@startsimpli/ui": "0.4.167",
|
|
103
|
+
"@startsimpli/ui-native": "0.1.9",
|
|
103
104
|
"@startsimpli/auth": "0.4.47",
|
|
104
|
-
"@startsimpli/utils": "0.4.15"
|
|
105
|
-
"@startsimpli/ui-native": "0.1.9"
|
|
105
|
+
"@startsimpli/utils": "0.4.15"
|
|
106
106
|
},
|
|
107
107
|
"scripts": {
|
|
108
108
|
"type-check": "tsc --noEmit && tsc --noEmit -p tsconfig.native.json",
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Planning list must say which focus each item is filed under.
|
|
3
|
+
*
|
|
4
|
+
* Filing is an `in_focus` edge, not an attribute, so an item row read from the
|
|
5
|
+
* entities endpoint carries no focus of its own. Before this, every row came
|
|
6
|
+
* back with `focusId` unset and the per-row project control read "Unfiled" for
|
|
7
|
+
* items that had their edge, under "across every focus".
|
|
8
|
+
*/
|
|
9
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
10
|
+
import { createPlanningApi } from '../corpus/client';
|
|
11
|
+
|
|
12
|
+
const SCOPE = { orgId: 'o' } as never;
|
|
13
|
+
|
|
14
|
+
function item(id: string) {
|
|
15
|
+
return { id, entity_type: 'commitment', external_id: `commit:${id}`, name: id, data: { title: id, status: 'open', subtype: 'action' } };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function tenant(edges: Array<{ rel_type: string; source: string; target: string }>) {
|
|
19
|
+
const gets: Array<{ path: string; params: Record<string, unknown> }> = [];
|
|
20
|
+
const http = {
|
|
21
|
+
get: vi.fn(async (path: string, options?: { params?: Record<string, unknown> }) => {
|
|
22
|
+
const params = options?.params ?? {};
|
|
23
|
+
gets.push({ path, params });
|
|
24
|
+
if (path.includes('relationships')) {
|
|
25
|
+
const ids = String(params.entity__in ?? '').split(',');
|
|
26
|
+
const types = String(params.rel_type ?? '').split(',');
|
|
27
|
+
return {
|
|
28
|
+
count: 0, next: null, previous: null, applied_filters: ['entity__in', 'rel_type'],
|
|
29
|
+
results: edges.filter((e) => types.includes(e.rel_type) && (ids.includes(e.source) || ids.includes(e.target))),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return { count: 3, next: null, previous: null, results: [item('i1'), item('i2'), item('i3')] };
|
|
33
|
+
}),
|
|
34
|
+
};
|
|
35
|
+
return { gets, api: createPlanningApi({ http: http as never, scope: SCOPE }) };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
describe('planning listCommitments carries each item’s focus', () => {
|
|
39
|
+
it('sets focusId from the in_focus edge, and leaves a truly unfiled item unset', async () => {
|
|
40
|
+
const { api } = tenant([
|
|
41
|
+
{ rel_type: 'in_focus', source: 'i1', target: 'f1' },
|
|
42
|
+
{ rel_type: 'in_focus', source: 'i2', target: 'f2' },
|
|
43
|
+
{ rel_type: 'about_focus', source: 'i3', target: 'f1' },
|
|
44
|
+
]);
|
|
45
|
+
const page = await api.listCommitments({ withFocus: true });
|
|
46
|
+
expect(page.results.map((r) => r.focusId)).toEqual(['f1', 'f2', undefined]);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('reads the edges of the page in one request, narrowed to in_focus', async () => {
|
|
50
|
+
const { api, gets } = tenant([{ rel_type: 'in_focus', source: 'i1', target: 'f1' }]);
|
|
51
|
+
await api.listCommitments({ withFocus: true });
|
|
52
|
+
const edgeReads = gets.filter((g) => g.path.includes('relationships'));
|
|
53
|
+
expect(edgeReads).toHaveLength(1);
|
|
54
|
+
expect(edgeReads[0].params.rel_type).toBe('in_focus');
|
|
55
|
+
expect(edgeReads[0].params.entity__in).toBe('i1,i2,i3');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('a focus-scoped read needs no edge read: every row is in that focus', async () => {
|
|
59
|
+
const { api, gets } = tenant([]);
|
|
60
|
+
const page = await api.listCommitments({ focus: 'f9', withFocus: true });
|
|
61
|
+
expect(page.results.map((r) => r.focusId)).toEqual(['f9', 'f9', 'f9']);
|
|
62
|
+
expect(gets.filter((g) => g.path.includes('relationships'))).toHaveLength(0);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('does not read edges unless asked, so other screens pay nothing', async () => {
|
|
66
|
+
const { api, gets } = tenant([{ rel_type: 'in_focus', source: 'i1', target: 'f1' }]);
|
|
67
|
+
await api.listCommitments({});
|
|
68
|
+
expect(gets.filter((g) => g.path.includes('relationships'))).toHaveLength(0);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('still lists items when the edge read fails', async () => {
|
|
72
|
+
const http = {
|
|
73
|
+
get: vi.fn(async (path: string) => {
|
|
74
|
+
if (path.includes('relationships')) throw new Error('boom');
|
|
75
|
+
return { count: 1, next: null, previous: null, results: [item('i1')] };
|
|
76
|
+
}),
|
|
77
|
+
};
|
|
78
|
+
const page = await createPlanningApi({ http: http as never, scope: SCOPE }).listCommitments({ withFocus: true });
|
|
79
|
+
expect(page.results).toHaveLength(1);
|
|
80
|
+
expect(page.results[0].focusId).toBeUndefined();
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -199,6 +199,8 @@ export function PlanningPage({
|
|
|
199
199
|
status: showDone ? 'done' : (['open', 'blocked'] as CommitmentStatus[]),
|
|
200
200
|
...(owner.trim() ? { owner: owner.trim() } : {}),
|
|
201
201
|
...(selected ? { focus: selected } : {}),
|
|
202
|
+
// Each row names its project, and filing is an edge the entity row lacks.
|
|
203
|
+
withFocus: true,
|
|
202
204
|
pageSize: 200,
|
|
203
205
|
}), [showDone, owner, selected]);
|
|
204
206
|
|
package/src/corpus/client.ts
CHANGED
|
@@ -1264,6 +1264,58 @@ export function createPlanningApi(options: CreateCorpusApiOptions): PlanningApi
|
|
|
1264
1264
|
return {
|
|
1265
1265
|
...base,
|
|
1266
1266
|
|
|
1267
|
+
/**
|
|
1268
|
+
* The base read, plus each item's focus when `withFocus` is asked for.
|
|
1269
|
+
*
|
|
1270
|
+
* Filing is an `in_focus` EDGE and the entity row carries no trace of it, so
|
|
1271
|
+
* the base read leaves `focusId` unset on every item and the per-row project
|
|
1272
|
+
* control reads "Unfiled" for items that are filed. A focus-scoped read
|
|
1273
|
+
* already knows the answer (every row came back through that edge); an
|
|
1274
|
+
* unscoped one asks for the edges of this page, narrowed to `in_focus`.
|
|
1275
|
+
* If that read fails or the server does not honour the narrowing, the rows
|
|
1276
|
+
* come back as they were: an unknown focus is left unset, never guessed.
|
|
1277
|
+
*/
|
|
1278
|
+
async listCommitments(query: CommitmentQuery = {}): Promise<CorpusPage<Commitment>> {
|
|
1279
|
+
const page = await base.listCommitments!(query);
|
|
1280
|
+
if (!query.withFocus) return page;
|
|
1281
|
+
if (query.focus) {
|
|
1282
|
+
return { ...page, results: page.results.map((item) => ({ ...item, focusId: query.focus })) };
|
|
1283
|
+
}
|
|
1284
|
+
const ids = page.results.map((item) => String(item.id));
|
|
1285
|
+
if (ids.length === 0) return page;
|
|
1286
|
+
try {
|
|
1287
|
+
const filed = new Map<string, string>();
|
|
1288
|
+
for (let start = 0; start < ids.length; start += MAX_ID_LIST) {
|
|
1289
|
+
const response = await http.get<DrfPage<TenantRelationship> & ServerFilterReport>(
|
|
1290
|
+
relationships,
|
|
1291
|
+
{
|
|
1292
|
+
params: {
|
|
1293
|
+
entity__in: ids.slice(start, start + MAX_ID_LIST).join(','),
|
|
1294
|
+
rel_type: IN_FOCUS,
|
|
1295
|
+
page_size: MAX_ID_LIST,
|
|
1296
|
+
},
|
|
1297
|
+
},
|
|
1298
|
+
);
|
|
1299
|
+
const applied = response.applied_filters ?? response.appliedFilters;
|
|
1300
|
+
if (!applied?.includes('entity__in')) return page;
|
|
1301
|
+
for (const edge of response.results ?? []) {
|
|
1302
|
+
if (String(edge.rel_type ?? edge.relType) !== IN_FOCUS) continue;
|
|
1303
|
+
const source = String(edge.source);
|
|
1304
|
+
if (!filed.has(source)) filed.set(source, String(edge.target));
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
return {
|
|
1308
|
+
...page,
|
|
1309
|
+
results: page.results.map((item) => {
|
|
1310
|
+
const focusId = filed.get(String(item.id));
|
|
1311
|
+
return focusId ? { ...item, focusId } : item;
|
|
1312
|
+
}),
|
|
1313
|
+
};
|
|
1314
|
+
} catch {
|
|
1315
|
+
return page;
|
|
1316
|
+
}
|
|
1317
|
+
},
|
|
1318
|
+
|
|
1267
1319
|
listFocuses: (query: FocusQuery = {}) => focusPage(focusParams(query)),
|
|
1268
1320
|
|
|
1269
1321
|
/**
|
package/src/corpus/types.ts
CHANGED
|
@@ -821,6 +821,12 @@ export interface CommitmentQuery {
|
|
|
821
821
|
* `unrelated_via=in_focus`. Ignored when `focus` is set.
|
|
822
822
|
*/
|
|
823
823
|
unfiled?: boolean;
|
|
824
|
+
/**
|
|
825
|
+
* Fill `focusId` on every returned item. Not a filter, and not sent to the
|
|
826
|
+
* server: filing is an edge, so naming each row's project costs one extra
|
|
827
|
+
* edge read per page, which only a screen that shows the project should pay.
|
|
828
|
+
*/
|
|
829
|
+
withFocus?: boolean;
|
|
824
830
|
/** `tenant-extraction` | `human` | ... — filters on the `_origin` attribute. */
|
|
825
831
|
origin?: string;
|
|
826
832
|
search?: string;
|