@startsimpli/integrations 0.2.88 → 0.2.90

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.88",
3
+ "version": "0.2.90",
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",
@@ -98,10 +98,10 @@
98
98
  "vitest": "^3.0.0",
99
99
  "react-native": "0.85.3",
100
100
  "react-native-safe-area-context": "~5.7.0",
101
- "@startsimpli/ui": "0.4.167",
102
101
  "@startsimpli/llm": "0.4.28",
103
- "@startsimpli/ui-native": "0.1.3",
104
102
  "@startsimpli/auth": "0.4.47",
103
+ "@startsimpli/ui-native": "0.1.4",
104
+ "@startsimpli/ui": "0.4.167",
105
105
  "@startsimpli/utils": "0.4.15"
106
106
  },
107
107
  "scripts": {
@@ -0,0 +1,38 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { createFakeNativeCorpusApi } from '../fake';
3
+ import { createFakeVoiceApi } from '../../voice/fake';
4
+ import { readFakeScenario, withScenario } from '../fake-scenarios';
5
+
6
+ describe('fake scenarios', () => {
7
+ it('reads -tgFakeState; anything unknown is the normal data', () => {
8
+ expect(readFakeScenario((k) => (k === 'tgFakeState' ? 'empty' : undefined))).toBe('empty');
9
+ expect(readFakeScenario(() => 'bogus')).toBe('normal');
10
+ expect(readFakeScenario(() => undefined)).toBe('normal');
11
+ });
12
+
13
+ it('empty: no notes, no documents', async () => {
14
+ expect(await createFakeVoiceApi({ scenario: 'empty' }).list()).toEqual([]);
15
+ const api = createFakeNativeCorpusApi({ scenario: 'empty' });
16
+ expect((await api.entities.list({ type: 'source_document' })).items).toHaveLength(0);
17
+ });
18
+
19
+ it('error: every call rejects with a network failure', async () => {
20
+ const voice = createFakeVoiceApi({ scenario: 'error' });
21
+ await expect(voice.list()).rejects.toThrow('Network request failed');
22
+ const api = createFakeNativeCorpusApi({ scenario: 'error' });
23
+ await expect(api.entities.list({ type: 'source_document' })).rejects.toThrow('Network request failed');
24
+ });
25
+
26
+ it('loading: calls never settle', async () => {
27
+ const wrapped = withScenario({ read: async () => 1 }, 'loading');
28
+ const settled = await Promise.race([wrapped.read().then(() => 'settled'), new Promise((r) => setTimeout(() => r('pending'), 30))]);
29
+ expect(settled).toBe('pending');
30
+ });
31
+
32
+ it('long: titles and summaries are long enough to wrap and truncate', async () => {
33
+ const notes = await createFakeVoiceApi({ scenario: 'long' }).list();
34
+ expect(notes.every((n) => n.title.length > 80)).toBe(true);
35
+ const docs = (await createFakeNativeCorpusApi({ scenario: 'long' }).entities.list({ type: 'source_document' })).items;
36
+ expect(docs.every((d) => d.name.length > 80)).toBe(true);
37
+ });
38
+ });
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Fake-data scenarios for simulator checks and tests: the same in-memory fakes, but empty, failing, never
3
+ * answering, or full of long text, so the empty / error / loading / long-text states of every screen can be
4
+ * looked at and tested. Chosen with `-tgFakeState empty|error|loading|long`; anything else is the normal data.
5
+ */
6
+ export type FakeScenario = 'normal' | 'empty' | 'error' | 'loading' | 'long';
7
+
8
+ const SCENARIOS: FakeScenario[] = ['empty', 'error', 'loading', 'long'];
9
+
10
+ export function readFakeScenario(get: (key: string) => unknown): FakeScenario {
11
+ const v = String(get('tgFakeState') ?? '');
12
+ return (SCENARIOS as string[]).includes(v) ? (v as FakeScenario) : 'normal';
13
+ }
14
+
15
+ const LONG_TAIL = ' - and then a much longer description that keeps going so the row has to wrap or truncate instead of fitting on one line';
16
+
17
+ /** `error` rejects and `loading` never settles every function on the api; other scenarios pass it through. */
18
+ export function withScenario<T extends object>(api: T, scenario: FakeScenario | undefined): T {
19
+ if (scenario !== 'error' && scenario !== 'loading') return api;
20
+ return new Proxy(api, {
21
+ get(target, prop, receiver) {
22
+ const v = Reflect.get(target, prop, receiver);
23
+ if (typeof v !== 'function') return v;
24
+ return () => (scenario === 'loading'
25
+ ? new Promise(() => {})
26
+ : Promise.reject(Object.assign(new Error('Network request failed'), { status: 0 })));
27
+ },
28
+ }) as T;
29
+ }
30
+
31
+ /** Make a string long enough to wrap, once. */
32
+ export const longText = (s: string): string => (s && s.length < 80 ? s + LONG_TAIL : s);
@@ -5,22 +5,31 @@
5
5
  * against the tenant - minus the network and any prod data. Ask answers from the
6
6
  * fake corpus with the provider-free fixture model (`live: false`).
7
7
  */
8
+ import type { TenantEntity } from '../../corpus/entities';
8
9
  import { askCorpus } from '../../corpus/ask';
9
10
  import { createFixtureLlm } from '../../corpus/fixtures';
10
11
  import type { AskRequest, AskResult, CorpusAskApi, CorpusApi } from '../../corpus/types';
11
12
  import { createNativeCorpusApi, type NativeCorpusApi } from './api';
12
13
  import { sampleTenantEntities, sampleTenantRelationships } from './fake-data';
13
14
  import { createFakeTenantHttp, type FakeTenant, type FakeTenantOptions } from './fake-tenant';
15
+ import { longText, withScenario, type FakeScenario } from './fake-scenarios';
14
16
 
15
17
  export type FakeNativeCorpusApi = NativeCorpusApi & { tenant: FakeTenant };
16
18
 
17
- export function createFakeNativeCorpusApi(options: FakeTenantOptions = {}): FakeNativeCorpusApi {
19
+ const lengthen = (e: TenantEntity): TenantEntity => ({
20
+ ...e,
21
+ name: longText(e.name),
22
+ data: Object.fromEntries(Object.entries(e.data ?? {}).map(([k, v]) => [k, (k === 'title' || k === 'summary') && typeof v === 'string' ? longText(v) : v])),
23
+ });
24
+
25
+ export function createFakeNativeCorpusApi(options: FakeTenantOptions & { scenario?: FakeScenario } = {}): FakeNativeCorpusApi {
26
+ const { scenario, ...tenantOptions } = options;
18
27
  const tenant = createFakeTenantHttp({
19
- entities: sampleTenantEntities(),
20
- relationships: sampleTenantRelationships(),
21
- ...options,
28
+ entities: scenario === 'empty' ? [] : scenario === 'long' ? sampleTenantEntities().map(lengthen) : sampleTenantEntities(),
29
+ relationships: scenario === 'empty' ? [] : sampleTenantRelationships(),
30
+ ...tenantOptions,
22
31
  });
23
- const base = createNativeCorpusApi({ http: tenant.http, scope: { orgId: 'tandem' } });
32
+ const base = createNativeCorpusApi({ http: withScenario(tenant.http, scenario), scope: { orgId: 'tandem' } });
24
33
  const llm = createFixtureLlm();
25
34
  const ask: CorpusAskApi = {
26
35
  ask: (request: AskRequest): Promise<AskResult> =>
@@ -21,6 +21,7 @@ export * from './corpus/api';
21
21
  export * from './corpus/ask';
22
22
  export * from './corpus/paged';
23
23
  export * from './corpus/fake';
24
+ export * from './corpus/fake-scenarios';
24
25
  export * from './corpus/fake-tenant';
25
26
  export * from './corpus/fake-data';
26
27
  export * from '../corpus/entity-query';
@@ -78,7 +78,7 @@ export function ConnectClaudeScreen({ controller }: { controller: ConnectClaudeC
78
78
  />
79
79
  <Text variant="muted">Up to {s.maxTtl} days. Shorter is safer.</Text>
80
80
  </View>
81
- <Alert variant="destructive" title="Before you create this">
81
+ <Alert variant="notice" title="Before you create this">
82
82
  It reads this workspace as you: whatever you can see, it can see. It is shown once and cannot be retrieved again, and it cannot be cancelled before it expires. Turning off your access to the workspace stops new ones being made; it does not switch this one off.
83
83
  </Alert>
84
84
  {s.error ? <Alert variant="destructive">{s.error}</Alert> : null}
@@ -1,8 +1,9 @@
1
1
  import { useMemo, useState } from 'react';
2
2
  import { ScrollView, View } from 'react-native';
3
3
  import { Alert, Button, DataList, Header, Sheet, StatusChip, Text, useTheme } from '@startsimpli/ui-native';
4
- import { connectionStatusLabel, connectionStatusLine } from '../../../components/pages/connection-format';
4
+ import { connectionStatusLabel } from '../../../components/pages/connection-format';
5
5
  import type { Connection, ConnectionStatus, MemberConnectionsApi } from '../../../components/pages/types';
6
+ import { connectionHealthLine } from './format';
6
7
  import { PressableCard } from '../shared/PressableCard';
7
8
  import { useControllerState } from '../../components/useControllerState';
8
9
  import { createConnectionsController, type ConnectionsController } from './controller';
@@ -46,7 +47,7 @@ export function ConnectionsListScreen({ controller, onOpen }: ConnectionsListScr
46
47
  <StatusChip status={chipStatus(item.status)} label={connectionStatusLabel(item.status)} />
47
48
  </View>
48
49
  {subtitle(item) ? <Text variant="caption">{subtitle(item)}</Text> : null}
49
- <Text variant="muted">{connectionStatusLine(item)}</Text>
50
+ <Text variant="muted">{connectionHealthLine(item)}</Text>
50
51
  </PressableCard>
51
52
  )}
52
53
  />
@@ -76,7 +77,7 @@ export function ConnectionDetailScreen({ controller, id, onBack }: { controller:
76
77
  <ScrollView contentContainerStyle={{ padding: theme.spacing.lg, gap: theme.spacing.md }}>
77
78
  <View style={{ flexDirection: 'row', alignItems: 'center', gap: theme.spacing.sm }}>
78
79
  <StatusChip status={chipStatus(row.status)} label={connectionStatusLabel(row.status)} />
79
- <Text variant="muted" style={{ flex: 1 }}>{connectionStatusLine(row)}</Text>
80
+ <Text variant="muted" style={{ flex: 1 }}>{connectionHealthLine(row)}</Text>
80
81
  </View>
81
82
  {row.check_error ? <Alert variant="destructive">{row.check_error}</Alert> : null}
82
83
  {row.status === 'needs_reauth' ? <Text variant="muted">The vendor stopped accepting this grant. Reconnect it on the web.</Text> : null}
@@ -0,0 +1,20 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { connectionHealthLine } from '../format';
3
+
4
+ const NOW = Date.parse('2026-11-03T12:00:00Z');
5
+
6
+ describe('connectionHealthLine', () => {
7
+ it('drops the raw status word (the chip already says it) and words the health plainly', () => {
8
+ expect(connectionHealthLine({ status: 'needs_reauth', health: 'token expired', last_checked_at: '2026-11-02T10:00:00Z' }, NOW))
9
+ .toBe('Token expired · checked 1d ago');
10
+ });
11
+ it('shows a relative time instead of a locale timestamp', () => {
12
+ expect(connectionHealthLine({ status: 'connected', health: 'ok', last_checked_at: '2026-11-03T10:00:00Z' }, NOW)).toBe('Working · checked 2h ago');
13
+ });
14
+ it('says never checked', () => {
15
+ expect(connectionHealthLine({ status: 'connected', health: '', last_checked_at: null }, NOW)).toBe('Never checked');
16
+ });
17
+ it('turns snake_case health codes into words', () => {
18
+ expect(connectionHealthLine({ status: 'error', health: 'rate_limited', last_checked_at: null }, NOW)).toBe('Rate limited · Never checked');
19
+ });
20
+ });
@@ -0,0 +1,20 @@
1
+ import { timeAgo } from '../../home/controller';
2
+ import type { ConnectionStatus } from '../../../components/pages/types';
3
+
4
+ const HEALTH_WORDS: Record<string, string> = { ok: 'Working' };
5
+
6
+ const sentence = (raw: string) => {
7
+ const words = HEALTH_WORDS[raw] ?? raw.replace(/_/g, ' ').trim();
8
+ return words ? words.charAt(0).toUpperCase() + words.slice(1) : '';
9
+ };
10
+
11
+ /** "Token expired · checked 1d ago" for a connection row. The status word is left to the chip; times are relative. Native only: the web roster keeps `connectionStatusLine`. */
12
+ export function connectionHealthLine(
13
+ row: { status: ConnectionStatus; health?: string; last_checked_at?: string | null },
14
+ now: number = Date.now(),
15
+ ): string {
16
+ const health = sentence(row.health ?? '');
17
+ const when = row.last_checked_at ? timeAgo(row.last_checked_at, now) : '';
18
+ const checked = when ? `checked ${when}` : 'Never checked';
19
+ return health ? `${health} · ${checked}` : checked;
20
+ }
@@ -3,6 +3,7 @@
3
3
  * network or a tenant. Notes include every state (processing, ready, failed)
4
4
  * and both shapes (with sections, without).
5
5
  */
6
+ import { longText, withScenario, type FakeScenario } from '../corpus/fake-scenarios';
6
7
  import type { VoiceFocus, VoiceNote, VoiceNotesApi } from '../../corpus/voice';
7
8
 
8
9
  export function sampleVoiceNotes(now = new Date('2026-11-03T15:00:00Z')): VoiceNote[] {
@@ -37,6 +38,8 @@ export interface FakeVoiceApiOptions {
37
38
  pageSize?: number;
38
39
  /** Query parts to behave like an older server: not applied, and reported ignored. */
39
40
  unsupported?: Array<'search' | 'order' | 'related_to'>;
41
+ /** empty / error / loading / long text instead of the sample data. */
42
+ scenario?: FakeScenario;
40
43
  }
41
44
 
42
45
  const hay = (n: VoiceNote) => `${n.title} ${n.summary} ${n.transcript}`.toLowerCase();
@@ -44,7 +47,14 @@ const filedUnder = (n: VoiceNote, focusId: string) =>
44
47
  n.focusId === focusId || (n.focusIds ?? []).includes(focusId) || (n.sections ?? []).some((s) => s.focusId === focusId);
45
48
 
46
49
  export function createFakeVoiceApi(options: FakeVoiceApiOptions = {}): VoiceNotesApi {
47
- let notes = options.notes ?? sampleVoiceNotes();
50
+ return withScenario(createInMemoryVoiceApi(options), options.scenario);
51
+ }
52
+
53
+ function createInMemoryVoiceApi(options: FakeVoiceApiOptions): VoiceNotesApi {
54
+ const sample = options.scenario === 'empty' ? [] : options.scenario === 'long'
55
+ ? sampleVoiceNotes().map((n) => ({ ...n, title: longText(n.title), summary: longText(n.summary) }))
56
+ : sampleVoiceNotes();
57
+ let notes = options.notes ?? sample;
48
58
  const focuses = options.focuses ?? sampleVoiceFocuses();
49
59
  const polls = options.processingPolls ?? 2;
50
60
  const pageSize = options.pageSize ?? 25;