@startsimpli/integrations 0.2.72 → 0.2.74
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 +2 -0
- package/package.json +3 -3
- package/src/__tests__/view-text.test.ts +31 -0
- package/src/components/Markdown.tsx +1 -15
- package/src/components/pages/AskPage.tsx +12 -59
- package/src/components/pages/LibraryPage.tsx +1 -45
- package/src/corpus/client.ts +8 -4
- package/src/corpus/entities.ts +1 -0
- package/src/corpus/types.ts +4 -0
- package/src/corpus/view-text.ts +113 -0
- package/src/native/components/NotesShell.tsx +9 -4
- package/src/native/corpus/fake-tenant.ts +6 -0
- package/src/native/home/HomeScreen.tsx +2 -2
- package/src/native/index.ts +9 -0
- package/src/native/screens/__tests__/ask-controller.test.ts +135 -0
- package/src/native/screens/__tests__/ask-screen.test.tsx +96 -0
- package/src/native/screens/__tests__/library-controller.test.ts +185 -0
- package/src/native/screens/__tests__/library-screens.test.tsx +134 -0
- package/src/native/screens/__tests__/tabs.test.tsx +46 -0
- package/src/native/screens/ask/AskScreen.tsx +118 -0
- package/src/native/screens/ask/answer-view.ts +53 -0
- package/src/native/screens/ask/controller.ts +100 -0
- package/src/native/screens/library/LibraryDetailScreen.tsx +93 -0
- package/src/native/screens/library/LibraryListScreen.tsx +99 -0
- package/src/native/screens/library/controller.ts +196 -0
- package/src/native/screens/library/fake-library.ts +38 -0
- package/src/native/screens/store.ts +19 -0
- package/src/native/screens/tabs.tsx +41 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared tenant fake plus the extra documents the Library and Ask screens
|
|
3
|
+
* need to look like a real corpus: a Markdown summary, an unfiled document and a
|
|
4
|
+
* second page worth of rows. The base rows (`sampleTenantEntities`) stay as the
|
|
5
|
+
* other tabs expect them; these are added on top, for this tab's simulator proof
|
|
6
|
+
* and tests only.
|
|
7
|
+
*/
|
|
8
|
+
import type { TenantEntity, TenantRelationship } from '../../../corpus/entities';
|
|
9
|
+
import { createFakeNativeCorpusApi, type FakeNativeCorpusApi } from '../../corpus/fake';
|
|
10
|
+
import { sampleTenantEntities, sampleTenantRelationships } from '../../corpus/fake-data';
|
|
11
|
+
import type { FakeTenantOptions } from '../../corpus/fake-tenant';
|
|
12
|
+
|
|
13
|
+
const doc = (id: string, source: string, subtype: string, title: string, createdAt: string, summary: string, extra: Record<string, unknown> = {}): TenantEntity => ({
|
|
14
|
+
id, entity_type: 'source_document', external_id: `${source}:${id}`, name: title, created_at: createdAt, org_id: 'tandem',
|
|
15
|
+
data: { title, source, subtype, occurred_at: createdAt, summary, ...extra },
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export function libraryExtraEntities(): TenantEntity[] {
|
|
19
|
+
return [
|
|
20
|
+
doc('d4', 'granola', 'meeting', 'Pricing call with Acme', '2026-10-20T13:00:00Z',
|
|
21
|
+
'## Decisions\n\nAcme renews at **$4,800 per month** for 12 months.\n\n## Next steps\n\n- Send the order form\n- Confirm the start date'),
|
|
22
|
+
doc('d5', 'drive', 'document', 'Office move notes', '2026-10-12T09:30:00Z',
|
|
23
|
+
'Movers booked for the 14th. Keys go back to the landlord on the 15th.', { path: '/Admin' }),
|
|
24
|
+
];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function libraryExtraRelationships(): TenantRelationship[] {
|
|
28
|
+
return [{ id: 'e8', rel_type: 'about_focus', source: 'd4', target: 'fma' }];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** `createFakeNativeCorpusApi` over the base corpus plus the Library extras. */
|
|
32
|
+
export function createFakeLibraryApi(options: FakeTenantOptions = {}): FakeNativeCorpusApi {
|
|
33
|
+
return createFakeNativeCorpusApi({
|
|
34
|
+
entities: [...sampleTenantEntities(), ...libraryExtraEntities()],
|
|
35
|
+
relationships: [...sampleTenantRelationships(), ...libraryExtraRelationships()],
|
|
36
|
+
...options,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tiny store both tab controllers are built on: an immutable state value, a
|
|
3
|
+
* subscribe, and `set(patch)`. Screens read it with `useControllerState`.
|
|
4
|
+
*/
|
|
5
|
+
import type { Store } from '../components/useControllerState';
|
|
6
|
+
|
|
7
|
+
export function createStore<S extends object>(initial: S) {
|
|
8
|
+
let state = initial;
|
|
9
|
+
const listeners = new Set<() => void>();
|
|
10
|
+
return {
|
|
11
|
+
getState: () => state,
|
|
12
|
+
subscribe(listener: () => void) { listeners.add(listener); return () => { listeners.delete(listener); }; },
|
|
13
|
+
set(patch: Partial<S>) { state = { ...state, ...patch }; listeners.forEach((l) => l()); },
|
|
14
|
+
update(fn: (s: S) => Partial<S>) { state = { ...state, ...fn(state) }; listeners.forEach((l) => l()); },
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const errorMessage = (e: unknown, fallback = 'That did not work.'): string =>
|
|
19
|
+
e instanceof Error && e.message ? e.message : fallback;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import type { FoundryTab, TabContext } from '../components/FoundryTabsShell';
|
|
3
|
+
import type { NativeCorpusApi } from '../corpus/api';
|
|
4
|
+
import { AskScreen } from './ask/AskScreen';
|
|
5
|
+
import { createAskController } from './ask/controller';
|
|
6
|
+
import { LibraryDetailScreen } from './library/LibraryDetailScreen';
|
|
7
|
+
import { LibraryListScreen } from './library/LibraryListScreen';
|
|
8
|
+
import { createLibraryController } from './library/controller';
|
|
9
|
+
|
|
10
|
+
export const LIBRARY_TAB = 'library';
|
|
11
|
+
export const ASK_TAB = 'ask';
|
|
12
|
+
|
|
13
|
+
function LibraryTabBody({ api, ctx }: { api: NativeCorpusApi; ctx: TabContext }) {
|
|
14
|
+
const controller = useMemo(() => createLibraryController(api), [api]);
|
|
15
|
+
return ctx.route
|
|
16
|
+
? <LibraryDetailScreen controller={controller} documentId={ctx.route.id} onBack={ctx.back} />
|
|
17
|
+
: <LibraryListScreen controller={controller} onOpen={(id) => ctx.push(id)} />;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function AskTabBody({ api, ctx }: { api: NativeCorpusApi; ctx: TabContext }) {
|
|
21
|
+
const controller = useMemo(() => createAskController({
|
|
22
|
+
api: api.ask,
|
|
23
|
+
scope: api.scope,
|
|
24
|
+
listProjects: async () => (await api.corpus.listFocusChoices?.()) ?? [],
|
|
25
|
+
}), [api]);
|
|
26
|
+
// A citation opens the cited record in the Library tab; Back there returns to its list.
|
|
27
|
+
return <AskScreen controller={controller} onOpenDocument={(id) => ctx.openTab(LIBRARY_TAB, id)} />;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The Library tab: documents list -> one document. */
|
|
31
|
+
export function libraryTab(api: NativeCorpusApi, over: Partial<Pick<FoundryTab, 'key' | 'label'>> = {}): FoundryTab {
|
|
32
|
+
return { key: LIBRARY_TAB, label: 'Library', ...over, render: (ctx) => <LibraryTabBody api={api} ctx={ctx} /> };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The Ask tab: project-scoped questions over the documents. Citations jump to the Library tab. */
|
|
36
|
+
export function askTab(api: NativeCorpusApi, over: Partial<Pick<FoundryTab, 'key' | 'label'>> = {}): FoundryTab {
|
|
37
|
+
return { key: ASK_TAB, label: 'Ask', ...over, render: (ctx) => <AskTabBody api={api} ctx={ctx} /> };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Both tabs, for an app that wants Library and Ask in one go. */
|
|
41
|
+
export const libraryAskTabs = (api: NativeCorpusApi): FoundryTab[] => [libraryTab(api), askTab(api)];
|