@startsimpli/integrations 0.2.133 → 0.2.135
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 +1 -1
- package/src/__tests__/corpus-planning.test.tsx +13 -3
- package/src/__tests__/corpus-tracker.test.tsx +53 -69
- package/src/__tests__/focus-standings.test.tsx +3 -1
- package/src/__tests__/home-brief.test.tsx +84 -0
- package/src/__tests__/project-surfaces.test.tsx +1 -1
- package/src/__tests__/work-groups.test.ts +181 -0
- package/src/components/index.ts +1 -0
- package/src/components/pages/ConnectionsPage.tsx +7 -1402
- package/src/components/pages/PlanningPage.tsx +129 -67
- package/src/components/pages/TrackerPage.tsx +174 -149
- package/src/components/pages/connections/CapabilityPicker.tsx +75 -0
- package/src/components/pages/connections/CatalogCard.tsx +300 -0
- package/src/components/pages/connections/ConnectionCard.tsx +489 -0
- package/src/components/pages/connections/ConnectionForms.tsx +215 -0
- package/src/components/pages/connections/MemberPolicyToggle.tsx +106 -0
- package/src/components/pages/connections/bound-api.ts +175 -0
- package/src/components/pages/connections/copy.ts +74 -0
- package/src/components/pages/home/BriefCard.tsx +84 -0
- package/src/components/pages/home/CompactItemRow.tsx +61 -0
- package/src/components/pages/home/DueAcrossProjects.tsx +74 -0
- package/src/components/pages/home/HomeBriefPage.tsx +112 -0
- package/src/components/pages/home/RecentNotes.tsx +69 -0
- package/src/components/pages/home/index.ts +10 -0
- package/src/components/pages/home/useProjectNames.ts +23 -0
- package/src/components/pages/work-items.tsx +15 -9
- package/src/corpus/due-groups.ts +81 -0
- package/src/corpus/focus-overview.ts +54 -0
- package/src/corpus/index.ts +10 -0
- package/src/corpus/note-actions.ts +44 -0
- package/src/corpus/tracker-groups.ts +84 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replace-the-key and settings forms for a connection that exists. Split out of ConnectionsPage (bd startsim-ovq7f) with no behaviour change.
|
|
3
|
+
*/
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
import { CredentialSchemaForm, isSecret, missingRequired, patternWarnings, schemaFields } from '../../CredentialSchemaForm';
|
|
7
|
+
import type { Connection, ConnectorCatalogEntry, ConnectorFieldSpec } from '../types';
|
|
8
|
+
import type { BoundApi } from './bound-api';
|
|
9
|
+
import { DEFAULTS } from './copy';
|
|
10
|
+
|
|
11
|
+
// --------------------------------------------------------------------------
|
|
12
|
+
// replacing the key on a connection that already exists
|
|
13
|
+
// --------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* ROTATION, rendered from the same schema as the connect form.
|
|
17
|
+
*
|
|
18
|
+
* Two things make this safe to put in front of a non-engineer, and both are
|
|
19
|
+
* properties of the endpoint rather than of this component:
|
|
20
|
+
*
|
|
21
|
+
* * the pasted credential is run through `check()` against the vendor BEFORE
|
|
22
|
+
* anything is written, so a wrong key changes nothing and the working
|
|
23
|
+
* connection stays up. That is said in the copy, because someone about to
|
|
24
|
+
* paste a production key is entitled to know it;
|
|
25
|
+
* * a PARTIAL map is legal. A connector with a url + a key + a select takes
|
|
26
|
+
* just the key here, and the stored values fill in the rest — so replacing
|
|
27
|
+
* a secret never means re-typing the settings around it.
|
|
28
|
+
*
|
|
29
|
+
* Only the CREDENTIAL fields render. `config` is not a credential and is edited
|
|
30
|
+
* through `ConnectionSettingsForm` below; mixing them here would make a
|
|
31
|
+
* rotation quietly a config change.
|
|
32
|
+
*/
|
|
33
|
+
export function ReplaceKeyForm({
|
|
34
|
+
api, connection, entry, classNames: cn, onDone,
|
|
35
|
+
}: {
|
|
36
|
+
api: BoundApi;
|
|
37
|
+
connection: Connection;
|
|
38
|
+
entry?: ConnectorCatalogEntry;
|
|
39
|
+
classNames: typeof DEFAULTS;
|
|
40
|
+
onDone: () => void;
|
|
41
|
+
}) {
|
|
42
|
+
const [values, setValues] = React.useState<Record<string, unknown>>({});
|
|
43
|
+
const [busy, setBusy] = React.useState(false);
|
|
44
|
+
const [error, setError] = React.useState('');
|
|
45
|
+
|
|
46
|
+
const fields = schemaFields(entry?.credential_schema);
|
|
47
|
+
const warnings = patternWarnings(fields, values);
|
|
48
|
+
// NOT `missingRequired`. A rotation is partial by design — the whole point is
|
|
49
|
+
// to replace one secret without re-typing the fields around it — so the gate
|
|
50
|
+
// is "something was actually typed", and the server decides the rest.
|
|
51
|
+
const submitted = React.useMemo(() => {
|
|
52
|
+
const out: Record<string, unknown> = {};
|
|
53
|
+
for (const spec of fields) {
|
|
54
|
+
const value = values[isSecret(spec) ? `${spec.key}__draft` : spec.key];
|
|
55
|
+
if (value) out[spec.key] = value;
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}, [fields, values]);
|
|
59
|
+
const empty = Object.keys(submitted).length === 0;
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<div className="mt-3 space-y-3 border-t pt-3" data-replace-key={connection.id}>
|
|
63
|
+
<p className={cn.muted}>
|
|
64
|
+
The new key is tested against the vendor before it replaces the current
|
|
65
|
+
one. If it is rejected, nothing changes and this connection keeps
|
|
66
|
+
working on the key it has.
|
|
67
|
+
</p>
|
|
68
|
+
{fields.length === 0 ? (
|
|
69
|
+
<p className={cn.muted}>
|
|
70
|
+
This connector holds no credential of ours, so there is nothing to
|
|
71
|
+
replace.
|
|
72
|
+
</p>
|
|
73
|
+
) : (
|
|
74
|
+
<CredentialSchemaForm
|
|
75
|
+
fields={fields}
|
|
76
|
+
values={values}
|
|
77
|
+
warnings={warnings}
|
|
78
|
+
idPrefix={`replace-${connection.id}`}
|
|
79
|
+
onChange={(key, value) => {
|
|
80
|
+
const spec = fields.find((f) => f.key === key);
|
|
81
|
+
setValues((prev) => ({
|
|
82
|
+
...prev, [spec && isSecret(spec) ? `${key}__draft` : key]: value,
|
|
83
|
+
}));
|
|
84
|
+
}}
|
|
85
|
+
/>
|
|
86
|
+
)}
|
|
87
|
+
{error ? <p className={cn.error} role="alert">{error}</p> : null}
|
|
88
|
+
<button
|
|
89
|
+
type="button"
|
|
90
|
+
className={cn.button}
|
|
91
|
+
disabled={busy || empty}
|
|
92
|
+
onClick={() => {
|
|
93
|
+
setBusy(true);
|
|
94
|
+
setError('');
|
|
95
|
+
api.rotateCredential(connection.id, submitted)
|
|
96
|
+
.then(() => { setValues({}); onDone(); })
|
|
97
|
+
// The server's typed answer, verbatim: it already scrubbed itself of
|
|
98
|
+
// the values just submitted, and "the vendor rejected this key" is
|
|
99
|
+
// not something the browser could work out on its own.
|
|
100
|
+
.catch((err: unknown) => setError(
|
|
101
|
+
(err as { message?: string })?.message || 'Could not replace the key.'))
|
|
102
|
+
.finally(() => setBusy(false));
|
|
103
|
+
}}
|
|
104
|
+
>
|
|
105
|
+
{busy ? 'Testing…' : 'Test and replace'}
|
|
106
|
+
</button>
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// --------------------------------------------------------------------------
|
|
112
|
+
// a connected account: discover -> wire -> confirm -> fire
|
|
113
|
+
// --------------------------------------------------------------------------
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The connection's own settings — its connector's `config_schema`, for an
|
|
117
|
+
* account that already exists.
|
|
118
|
+
*
|
|
119
|
+
* WHY IT IS A SEPARATE FORM FROM THE CONNECT CARD. Connecting is "here are my
|
|
120
|
+
* credentials, does this work"; this is "change how it behaves". Rotating a key
|
|
121
|
+
* must not quietly change a setting, and changing a setting must not ask for a
|
|
122
|
+
* key. `ReplaceKeyForm` has said as much in its own docstring since it shipped,
|
|
123
|
+
* pointing at a surface that did not exist.
|
|
124
|
+
*
|
|
125
|
+
* IT SENDS ONLY WHAT CHANGED, and the API merges. Two reasons, and the second is
|
|
126
|
+
* the one that bites: resending untouched fields turns "I ticked one box" into
|
|
127
|
+
* "I reassert every setting", which silently overwrites an edit made in another
|
|
128
|
+
* tab — and it is exactly how the retention bound gets reset to whatever this
|
|
129
|
+
* form happened to be showing.
|
|
130
|
+
*
|
|
131
|
+
* A FALSE IS SENT, not omitted. The connect card drops falsy values, which for a
|
|
132
|
+
* checkbox makes "off" indistinguishable from "untouched" — and against a
|
|
133
|
+
* merging API that would make the off position literally unreachable. For
|
|
134
|
+
* `ingest_transcripts` the off position is the whole privacy posture.
|
|
135
|
+
*/
|
|
136
|
+
export function ConnectionSettingsForm({
|
|
137
|
+
api, connection, fields, classNames: cn, onDone,
|
|
138
|
+
}: {
|
|
139
|
+
api: BoundApi;
|
|
140
|
+
connection: Connection;
|
|
141
|
+
fields: ConnectorFieldSpec[];
|
|
142
|
+
classNames: typeof DEFAULTS;
|
|
143
|
+
/** Handed whatever the SERVER said about the change, so the card can say it. */
|
|
144
|
+
onDone: (notices: string[]) => void;
|
|
145
|
+
}) {
|
|
146
|
+
const stored = React.useMemo(
|
|
147
|
+
() => (connection.config ?? {}) as Record<string, unknown>,
|
|
148
|
+
[connection.config],
|
|
149
|
+
);
|
|
150
|
+
const [edits, setEdits] = React.useState<Record<string, string | boolean>>({});
|
|
151
|
+
const [busy, setBusy] = React.useState(false);
|
|
152
|
+
const [error, setError] = React.useState('');
|
|
153
|
+
|
|
154
|
+
const values = React.useMemo(() => ({ ...stored, ...edits }), [stored, edits]);
|
|
155
|
+
const warnings = patternWarnings(fields, values);
|
|
156
|
+
const changed = Object.keys(edits);
|
|
157
|
+
|
|
158
|
+
async function save() {
|
|
159
|
+
setBusy(true);
|
|
160
|
+
setError('');
|
|
161
|
+
try {
|
|
162
|
+
// Numbers go back as numbers. A `number` input hands back a string, and a
|
|
163
|
+
// retention bound stored as "0" rather than 0 is a comparison that quietly
|
|
164
|
+
// stops being true.
|
|
165
|
+
const config: Record<string, unknown> = {};
|
|
166
|
+
for (const key of changed) {
|
|
167
|
+
const spec = fields.find((field) => field.key === key);
|
|
168
|
+
const value = edits[key];
|
|
169
|
+
config[key] =
|
|
170
|
+
spec?.type === 'number' && typeof value === 'string' && value.trim() !== ''
|
|
171
|
+
? Number(value)
|
|
172
|
+
: value;
|
|
173
|
+
}
|
|
174
|
+
const saved = await api.updateConnectionConfig!(connection.id, config);
|
|
175
|
+
// WHAT THE SERVER WANTS THEM TO KNOW, handed up rather than rendered here.
|
|
176
|
+
// The live case is a scope change restarting the walk, and this file
|
|
177
|
+
// cannot work that out: it names no vendor and therefore cannot know which
|
|
178
|
+
// fields bear the scope. A heuristic on field names would be both a vendor
|
|
179
|
+
// branch and untestable at the level that matters. Handed to the CARD
|
|
180
|
+
// because saving closes this panel, and a sentence that unmounts with the
|
|
181
|
+
// form is one nobody reads.
|
|
182
|
+
onDone(saved?.notices ?? []);
|
|
183
|
+
} catch (err) {
|
|
184
|
+
setError((err as { message?: string })?.message || 'Those settings were not saved.');
|
|
185
|
+
} finally {
|
|
186
|
+
setBusy(false);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return (
|
|
191
|
+
<div className="mt-3 space-y-3 border-t pt-3" role="group" aria-label="Connection settings">
|
|
192
|
+
<CredentialSchemaForm
|
|
193
|
+
fields={fields}
|
|
194
|
+
values={values}
|
|
195
|
+
onChange={(key, value) => setEdits((current) => ({ ...current, [key]: value }))}
|
|
196
|
+
warnings={warnings}
|
|
197
|
+
idPrefix={`settings-${connection.id}`}
|
|
198
|
+
/>
|
|
199
|
+
{error ? <p className={cn.error} role="alert">{error}</p> : null}
|
|
200
|
+
<div className="flex items-center gap-2">
|
|
201
|
+
<button
|
|
202
|
+
type="button"
|
|
203
|
+
className={cn.button}
|
|
204
|
+
disabled={busy || changed.length === 0}
|
|
205
|
+
onClick={() => void save()}
|
|
206
|
+
>
|
|
207
|
+
{busy ? 'Saving…' : 'Save settings'}
|
|
208
|
+
</button>
|
|
209
|
+
{changed.length === 0 ? (
|
|
210
|
+
<span className={cn.muted}>Nothing changed yet.</span>
|
|
211
|
+
) : null}
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-connector governance: may members connect their own account? Split out of ConnectionsPage (bd startsim-ovq7f) with no behaviour change.
|
|
3
|
+
*/
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
import type { ConnectorCatalogEntry } from '../types';
|
|
7
|
+
import { DEFAULTS } from './copy';
|
|
8
|
+
|
|
9
|
+
// --------------------------------------------------------------------------
|
|
10
|
+
// who may connect their OWN account (bd startsim-768w.22.25.8)
|
|
11
|
+
// --------------------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* ONE CONNECTOR, ONE DECISION: may this foundry's members connect their own
|
|
15
|
+
* account on it?
|
|
16
|
+
*
|
|
17
|
+
* DEFAULT-DENY, and the copy has to carry that, because the switch is not a
|
|
18
|
+
* display preference. Turning it on means members send THEIR vendor data into
|
|
19
|
+
* this foundry, under their own credentials, for this foundry to store and
|
|
20
|
+
* process — an admin is agreeing to receive that, and is entitled to read it in
|
|
21
|
+
* those words before flipping anything.
|
|
22
|
+
*
|
|
23
|
+
* TURNING IT OFF IS NOT A KILL SWITCH, and saying so in the confirmation rather
|
|
24
|
+
* than in a docs page is the point. Off stops NEW personal connections
|
|
25
|
+
* immediately; every connection that already exists keeps running, with its
|
|
26
|
+
* credential and its scheduled fetches. Ending those is one explicit disconnect
|
|
27
|
+
* per person from the roster below — destructive, irreversible, and never a side
|
|
28
|
+
* effect of tightening a default. The wording here is the server's own, lifted
|
|
29
|
+
* from `apps/connectors/services/policy.py` so the two cannot drift apart.
|
|
30
|
+
*
|
|
31
|
+
* A connector that CANNOT be opened yet renders disabled WITH the server's
|
|
32
|
+
* reason instead of vanishing: an admin who cannot find Dropbox in this list
|
|
33
|
+
* would reasonably conclude the catalog is broken, when the real answer is that
|
|
34
|
+
* the member surface has no OAuth path yet.
|
|
35
|
+
*
|
|
36
|
+
* THE THIRD STATE IS THE ONE THAT MATTERS: already allowed, and no longer
|
|
37
|
+
* openable — a connector opened while it was an API key that has since moved to
|
|
38
|
+
* OAuth, or whose class stopped importing. The server answers `settable: true`
|
|
39
|
+
* with a `reason`, because the only move an ON switch offers is OFF and the
|
|
40
|
+
* write always accepts that. Disabling it on `reason` alone would draw a switch
|
|
41
|
+
* an admin cannot turn off, which is the exact opposite of what a governance
|
|
42
|
+
* control is for. It renders live, with the reason as a one-way warning.
|
|
43
|
+
*/
|
|
44
|
+
export function MemberPolicyToggle({
|
|
45
|
+
connectorKey, policy, canManage, write, classNames: cn, onChanged,
|
|
46
|
+
}: {
|
|
47
|
+
connectorKey: string;
|
|
48
|
+
policy: NonNullable<ConnectorCatalogEntry['member_policy']>;
|
|
49
|
+
canManage: boolean;
|
|
50
|
+
write: (connectorKey: string, allowed: boolean) => Promise<unknown>;
|
|
51
|
+
classNames: typeof DEFAULTS;
|
|
52
|
+
onChanged?: () => void;
|
|
53
|
+
}) {
|
|
54
|
+
const [busy, setBusy] = React.useState(false);
|
|
55
|
+
const [error, setError] = React.useState('');
|
|
56
|
+
const id = `member-policy-${connectorKey}`;
|
|
57
|
+
|
|
58
|
+
async function set(allowed: boolean) {
|
|
59
|
+
setBusy(true);
|
|
60
|
+
setError('');
|
|
61
|
+
try {
|
|
62
|
+
await write(connectorKey, allowed);
|
|
63
|
+
onChanged?.();
|
|
64
|
+
} catch (err) {
|
|
65
|
+
setError((err as { message?: string })?.message || 'Could not save that.');
|
|
66
|
+
} finally {
|
|
67
|
+
setBusy(false);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<div className="mt-3 border-t border-gray-100 pt-3" data-member-policy={connectorKey}>
|
|
73
|
+
<label htmlFor={id} className="flex items-start gap-2 text-sm">
|
|
74
|
+
<input
|
|
75
|
+
id={id}
|
|
76
|
+
type="checkbox"
|
|
77
|
+
className="mt-0.5"
|
|
78
|
+
checked={policy.allowed}
|
|
79
|
+
disabled={busy || !canManage || !policy.settable}
|
|
80
|
+
onChange={(event) => void set(event.target.checked)}
|
|
81
|
+
/>
|
|
82
|
+
<span>
|
|
83
|
+
<span className="text-gray-900">Members may connect their own account</span>
|
|
84
|
+
<span className={`block ${cn.muted}`}>
|
|
85
|
+
{policy.settable
|
|
86
|
+
? 'Each member signs in with their own key, and sees only their own'
|
|
87
|
+
+ ' data. Allowing this means their vendor data flows into this'
|
|
88
|
+
+ ' foundry. Turning it off later stops new connections — the ones'
|
|
89
|
+
+ ' already connected keep running until you disconnect them below.'
|
|
90
|
+
: policy.reason}
|
|
91
|
+
</span>
|
|
92
|
+
{/* Settable AND blocked: open today, unopenable tomorrow. Said next to
|
|
93
|
+
the switch rather than after the click, because the click is the
|
|
94
|
+
irreversible half. */}
|
|
95
|
+
{policy.settable && policy.reason ? (
|
|
96
|
+
<span className={`block ${cn.error}`} data-member-policy-oneway={connectorKey}>
|
|
97
|
+
This is on, but can no longer be turned back on once off:{' '}
|
|
98
|
+
{policy.reason}
|
|
99
|
+
</span>
|
|
100
|
+
) : null}
|
|
101
|
+
</span>
|
|
102
|
+
</label>
|
|
103
|
+
{error ? <p className={cn.error} role="alert">{error}</p> : null}
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The injected api as the connection components use it (slugless), and the page props. Split out of ConnectionsPage (bd startsim-ovq7f) with no behaviour change.
|
|
3
|
+
*/
|
|
4
|
+
import type { Connection, ConnectionChoicePage, ConnectionInvokeResult, ConnectionPermissions, ConnectionRun, ConnectionTarget, ConnectionsApi, ConnectorAction, ConnectorCatalogEntry, MemberConnectionRow, MemberConnectionsApi } from '../types';
|
|
5
|
+
|
|
6
|
+
export type ClassNames = Partial<Record<
|
|
7
|
+
'root' | 'section' | 'heading' | 'card' | 'button' | 'muted' | 'error', string
|
|
8
|
+
>>;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* TWO SURFACES, ONE COMPOSER (bd startsim-768w.22.25.6).
|
|
12
|
+
*
|
|
13
|
+
* A discriminated union rather than an optional slug, because the two modes do
|
|
14
|
+
* not merely differ in their arguments — `personal` has no slug ANYWHERE, which
|
|
15
|
+
* is the member surface's whole security property (see `MemberConnectionsApi`).
|
|
16
|
+
* Making `foundrySlug` optional would let a personal mount pass one and read as
|
|
17
|
+
* though it meant something.
|
|
18
|
+
*/
|
|
19
|
+
export type ConnectionsPageProps =
|
|
20
|
+
| {
|
|
21
|
+
mode?: 'foundry';
|
|
22
|
+
api: ConnectionsApi;
|
|
23
|
+
foundrySlug: string;
|
|
24
|
+
classNames?: ClassNames;
|
|
25
|
+
}
|
|
26
|
+
| {
|
|
27
|
+
mode: 'personal';
|
|
28
|
+
api: MemberConnectionsApi;
|
|
29
|
+
/** There is no slug on this surface. The token's audience names the foundry. */
|
|
30
|
+
foundrySlug?: never;
|
|
31
|
+
classNames?: ClassNames;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The api as the components below use it: SLUGLESS, because the slug is a
|
|
36
|
+
* property of the mount and not of any control on the page.
|
|
37
|
+
*
|
|
38
|
+
* The foundry-level verbs are optional, and that is what gates the UI. A control
|
|
39
|
+
* renders when the verb behind it exists, so personal mode cannot render a
|
|
40
|
+
* button whose handler would be `undefined` — the type checker, not a
|
|
41
|
+
* `mode === 'personal'` sprinkled through nine call sites, is what keeps the
|
|
42
|
+
* two surfaces honest.
|
|
43
|
+
*/
|
|
44
|
+
export interface BoundApi {
|
|
45
|
+
connectorCatalog(): Promise<{ results: ConnectorCatalogEntry[] }>;
|
|
46
|
+
connections(): Promise<{ results: Connection[]; permissions: ConnectionPermissions }>;
|
|
47
|
+
connect(input: {
|
|
48
|
+
connector_key: string;
|
|
49
|
+
name?: string;
|
|
50
|
+
credentials?: Record<string, unknown>;
|
|
51
|
+
config?: Record<string, unknown>;
|
|
52
|
+
capabilities_enabled?: string[];
|
|
53
|
+
}): Promise<Connection>;
|
|
54
|
+
checkConnection(id: string): Promise<{ ok: boolean; account_label: string; detail: string }>;
|
|
55
|
+
rotateCredential(id: string, credentials: Record<string, unknown>): Promise<Connection>;
|
|
56
|
+
disconnect(id: string): Promise<void>;
|
|
57
|
+
updateConnection?(id: string, input: {
|
|
58
|
+
name?: string; capabilities_enabled?: string[]; config?: Record<string, unknown>;
|
|
59
|
+
}): Promise<Connection>;
|
|
60
|
+
/**
|
|
61
|
+
* SETTINGS ALONE, and separate from `updateConnection` on purpose
|
|
62
|
+
* (bd startsim-sfms2).
|
|
63
|
+
*
|
|
64
|
+
* Both surfaces have it; only the control plane has `updateConnection`. A
|
|
65
|
+
* personal connection's config is the MEMBER's privacy boundary — which of
|
|
66
|
+
* their own files this platform reads — while its name and what it may DO are
|
|
67
|
+
* the foundry's. One verb carrying all three would have made the Settings
|
|
68
|
+
* control and the capability Save appear together, so opening the first would
|
|
69
|
+
* have opened the second by accident.
|
|
70
|
+
*/
|
|
71
|
+
updateConnectionConfig?(
|
|
72
|
+
id: string, config: Record<string, unknown>,
|
|
73
|
+
): Promise<Connection>;
|
|
74
|
+
connectionChoices?(id: string, params?: { kind?: string; cursor?: string }):
|
|
75
|
+
Promise<ConnectionChoicePage>;
|
|
76
|
+
/** Task-tracker connections: sync now (bd startsim-el0zf). */
|
|
77
|
+
syncConnectionNow?(id: string): Promise<{ queued: boolean }>;
|
|
78
|
+
wireTarget?(id: string, input: {
|
|
79
|
+
choice_id: string; name?: string; options?: Record<string, unknown>;
|
|
80
|
+
}): Promise<ConnectionTarget>;
|
|
81
|
+
confirmTarget?(id: string, destinationId: string): Promise<ConnectionTarget>;
|
|
82
|
+
connectionActions?(id: string): Promise<{ results: ConnectorAction[] }>;
|
|
83
|
+
invokeConnectionAction?(id: string, action: string, input: {
|
|
84
|
+
destination_id: string; record_type?: string; records?: unknown[];
|
|
85
|
+
}): Promise<ConnectionInvokeResult>;
|
|
86
|
+
/**
|
|
87
|
+
* RECENT ACTIVITY on both legs (bd startsim-ei8gm.2). Required on both
|
|
88
|
+
* injected interfaces and, until this bead, called by nothing — so the reason
|
|
89
|
+
* a run failed reached the payload and never a pixel.
|
|
90
|
+
*
|
|
91
|
+
* Optional HERE for the reason every other verb on this type is: an app
|
|
92
|
+
* pinned to an older `@startsimpli/api` keeps type-checking, and the card
|
|
93
|
+
* renders no control rather than a button whose handler is `undefined`.
|
|
94
|
+
*/
|
|
95
|
+
connectionRuns?(id: string): Promise<{ results: ConnectionRun[] }>;
|
|
96
|
+
/** Per-member governance (bd startsim-768w.22.25.8). Foundry mode only, and
|
|
97
|
+
absent on an api that predates the endpoints — see `ConnectionsApi`. */
|
|
98
|
+
/** The OAuth hand-off (bd startsim-768w.22.25.14/.23). Optional: an app on an
|
|
99
|
+
older client keeps type-checking, and the card renders the connector as
|
|
100
|
+
not-connectable-here rather than offering a button that cannot fire. */
|
|
101
|
+
startOAuth?(input: {
|
|
102
|
+
connector_key: string;
|
|
103
|
+
name?: string;
|
|
104
|
+
config?: Record<string, unknown>;
|
|
105
|
+
capabilities_enabled?: string[];
|
|
106
|
+
return_to?: string;
|
|
107
|
+
}): Promise<{ authorization_url: string; state: string; redirect_uri: string }>;
|
|
108
|
+
setMemberConnectorPolicy?(connectorKey: string, allowed: boolean): Promise<unknown>;
|
|
109
|
+
memberConnections?(): Promise<{
|
|
110
|
+
results: MemberConnectionRow[]; permissions: ConnectionPermissions;
|
|
111
|
+
}>;
|
|
112
|
+
disconnectMemberConnection?(id: string): Promise<void>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function bindApi(props: ConnectionsPageProps): BoundApi {
|
|
116
|
+
if (props.mode === 'personal') {
|
|
117
|
+
// Already slugless. Passed through rather than wrapped, so nothing here can
|
|
118
|
+
// grow a slug argument by accident.
|
|
119
|
+
return props.api;
|
|
120
|
+
}
|
|
121
|
+
const { api, foundrySlug: slug } = props;
|
|
122
|
+
// Bound only when the injected client HAS them, so `verb in api` stays the
|
|
123
|
+
// test the components run — a wrapper that always exists and throws inside
|
|
124
|
+
// would render the control and fail on click.
|
|
125
|
+
const memberPolicy = api.setMemberConnectorPolicy
|
|
126
|
+
? { setMemberConnectorPolicy: (key: string, allowed: boolean) =>
|
|
127
|
+
api.setMemberConnectorPolicy!(slug, key, allowed) }
|
|
128
|
+
: {};
|
|
129
|
+
const oauth = api.startOAuth
|
|
130
|
+
? { startOAuth: (input: Parameters<NonNullable<BoundApi['startOAuth']>>[0]) =>
|
|
131
|
+
api.startOAuth!(slug, input) }
|
|
132
|
+
: {};
|
|
133
|
+
const roster = api.memberConnections
|
|
134
|
+
? { memberConnections: () => api.memberConnections!(slug) }
|
|
135
|
+
: {};
|
|
136
|
+
const cutMember = api.disconnectMemberConnection
|
|
137
|
+
? { disconnectMemberConnection: (id: string) =>
|
|
138
|
+
api.disconnectMemberConnection!(slug, id) }
|
|
139
|
+
: {};
|
|
140
|
+
// Bound only when the injected client HAS it, even though `ConnectionsApi`
|
|
141
|
+
// declares it required: apps consume `@startsimpli/*` as PUBLISHED packages,
|
|
142
|
+
// so a runtime object that predates the verb is a real state the TYPE cannot
|
|
143
|
+
// see (bd startsim-ei8gm.2). Same rule as the four above — a wrapper that
|
|
144
|
+
// always exists and throws inside would render the control and fail on click.
|
|
145
|
+
const runs = api.connectionRuns
|
|
146
|
+
? { connectionRuns: (id: string) => api.connectionRuns(slug, id) }
|
|
147
|
+
: {};
|
|
148
|
+
return {
|
|
149
|
+
...runs,
|
|
150
|
+
...memberPolicy,
|
|
151
|
+
...oauth,
|
|
152
|
+
...roster,
|
|
153
|
+
...cutMember,
|
|
154
|
+
connectorCatalog: () => api.connectorCatalog(slug),
|
|
155
|
+
connections: () => api.connections(slug),
|
|
156
|
+
connect: (input) => api.connect(slug, input),
|
|
157
|
+
checkConnection: (id) => api.checkConnection(slug, id),
|
|
158
|
+
rotateCredential: (id, credentials) => api.rotateCredential(slug, id, credentials),
|
|
159
|
+
disconnect: (id) => api.disconnect(slug, id),
|
|
160
|
+
updateConnection: (id, input) => api.updateConnection(slug, id, input),
|
|
161
|
+
// The control plane reaches settings through the same PATCH it reaches
|
|
162
|
+
// everything else with; the narrow verb is a property of the MEMBER router,
|
|
163
|
+
// not of the form. Both modes therefore satisfy the same bound signature and
|
|
164
|
+
// the settings form never learns which surface it is on.
|
|
165
|
+
updateConnectionConfig: (id, config) =>
|
|
166
|
+
api.updateConnection(slug, id, { config }),
|
|
167
|
+
connectionChoices: (id, params) => api.connectionChoices(slug, id, params),
|
|
168
|
+
wireTarget: (id, input) => api.wireTarget(slug, id, input),
|
|
169
|
+
confirmTarget: (id, destinationId) => api.confirmTarget(slug, id, destinationId),
|
|
170
|
+
connectionActions: (id) => api.connectionActions(slug, id),
|
|
171
|
+
invokeConnectionAction: (id, action, input) =>
|
|
172
|
+
api.invokeConnectionAction(slug, id, action, input),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared class defaults and copy for the connections surface. Split out of ConnectionsPage (bd startsim-ovq7f) with no behaviour change.
|
|
3
|
+
*/
|
|
4
|
+
import { CatalogCard } from './CatalogCard';
|
|
5
|
+
|
|
6
|
+
export const DEFAULTS = {
|
|
7
|
+
root: 'space-y-8',
|
|
8
|
+
section: 'space-y-3',
|
|
9
|
+
heading: 'text-lg font-semibold text-gray-900',
|
|
10
|
+
card: 'rounded-lg border border-gray-200 p-4',
|
|
11
|
+
button: 'rounded-md bg-gray-900 px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50',
|
|
12
|
+
muted: 'text-sm text-gray-500',
|
|
13
|
+
error: 'text-sm text-red-600',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* WHICH LEG A RUN BELONGS TO, in a reader's words (bd startsim-ei8gm.2).
|
|
18
|
+
*
|
|
19
|
+
* The card merges three tables — `SourceRun`, `DestinationRun` and
|
|
20
|
+
* `DestinationWebhookEvent` — into one list, and "failed" means a different
|
|
21
|
+
* thing and needs a different action on each. Data with a fall-through to the
|
|
22
|
+
* raw key, the same rule `CAPABILITY_COPY` below states: a `kind` this bundle
|
|
23
|
+
* has never heard of renders as itself rather than vanishing from the list.
|
|
24
|
+
*/
|
|
25
|
+
export const RUN_KIND_COPY: Record<string, string> = {
|
|
26
|
+
source_run: 'Fetched in',
|
|
27
|
+
destination_run: 'Sent out',
|
|
28
|
+
webhook_event: 'Received',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* WHAT AN ADMIN IS AGREEING TO, in their words rather than the wire's.
|
|
33
|
+
*
|
|
34
|
+
* Data, not a branch: an unknown key falls through to the key itself, because
|
|
35
|
+
* the capability vocabulary lives in the connector package and will outrun this
|
|
36
|
+
* bundle exactly the way the credential schema does. A capability this build has
|
|
37
|
+
* never heard of must render as a choice, not vanish from the list.
|
|
38
|
+
*/
|
|
39
|
+
export const CAPABILITY_COPY: Record<string, string> = {
|
|
40
|
+
poll: 'Fetch new records on a schedule',
|
|
41
|
+
webhook_in: 'Receive events pushed to us',
|
|
42
|
+
action: 'Let us run actions in this account',
|
|
43
|
+
writeback_credential: 'Issue a token this vendor uses to call us',
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A refusal must read as a refusal, not as an empty page — and it must name the
|
|
48
|
+
* refusal that actually happened. This runs in ONE place: the catch around the
|
|
49
|
+
* two GETs `reload` makes. So trace which 403 can reach here on each surface.
|
|
50
|
+
*
|
|
51
|
+
* Control plane: the caller lacks the connections permission on this foundry.
|
|
52
|
+
*
|
|
53
|
+
* Member surface: `IsSeatedMember` denied — no ACTIVE `CompanyMembership` and
|
|
54
|
+
* not the org's `owner`. That is the ONLY 403 either GET produces;
|
|
55
|
+
* `MyConnectorCatalogView` answers a foundry that has allowed nothing with
|
|
56
|
+
* `{results: []}` and a 200, and `MyConnectionsView.get` runs no per-connector
|
|
57
|
+
* policy at all. The allowlist refusal (`_NOT_ALLOWED`) is raised by the POST,
|
|
58
|
+
* lands in `CatalogCard`'s own catch, and renders the server's wording verbatim.
|
|
59
|
+
* Blaming the allowlist here would send someone whose SEAT is gone to ask an
|
|
60
|
+
* admin to allow a connector — the admin could allow every one of them and this
|
|
61
|
+
* page would still refuse.
|
|
62
|
+
*/
|
|
63
|
+
export function readFailureMessage(err: unknown, personal: boolean): string {
|
|
64
|
+
const status = (err as { status?: number })?.status;
|
|
65
|
+
if (status === 403) {
|
|
66
|
+
return personal
|
|
67
|
+
? 'You are not a member of this foundry, or your access to it has ended. Ask an admin to add you.'
|
|
68
|
+
: 'You do not have access to this foundry’s connections. Ask an admin for the connections permission.';
|
|
69
|
+
}
|
|
70
|
+
if (status === 401) return 'Your session has expired. Sign in again.';
|
|
71
|
+
const message = (err as { message?: string })?.message;
|
|
72
|
+
return message || 'Could not load connections.';
|
|
73
|
+
}
|
|
74
|
+
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE BRIEF — the text the app speaks, shown (bd startsim-cpzoz).
|
|
3
|
+
*
|
|
4
|
+
* It renders `BriefingResult.text` UNCHANGED. That text is the stored row the
|
|
5
|
+
* voice route synthesises its audio from (`generateBriefing`: one row per person
|
|
6
|
+
* per day, same hash for text and audio), so what is read here is, word for word,
|
|
7
|
+
* what Play says. The card never composes or rewrites anything and never sends
|
|
8
|
+
* `force`: a forced call pays for the language model and the voice again.
|
|
9
|
+
*/
|
|
10
|
+
import * as React from 'react';
|
|
11
|
+
|
|
12
|
+
import type { BriefingResult } from '../../../corpus/briefing';
|
|
13
|
+
|
|
14
|
+
export interface BriefCardApi {
|
|
15
|
+
/** POST /corpus/briefing: cached per person per day on the server. */
|
|
16
|
+
fetch(): Promise<BriefingResult>;
|
|
17
|
+
/** An object URL (or any playable URL) for the briefing's audio, fetched with the caller's credentials. */
|
|
18
|
+
loadAudio?(result: BriefingResult): Promise<string | null>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type State = { phase: 'loading' } | { phase: 'error'; message: string } | { phase: 'ready'; result: BriefingResult };
|
|
22
|
+
|
|
23
|
+
export function BriefCard({ api, onAsk }: { api: BriefCardApi; onAsk?: () => void }) {
|
|
24
|
+
const apiRef = React.useRef(api);
|
|
25
|
+
apiRef.current = api;
|
|
26
|
+
const [state, setState] = React.useState<State>({ phase: 'loading' });
|
|
27
|
+
const [playing, setPlaying] = React.useState(false);
|
|
28
|
+
const [audioError, setAudioError] = React.useState('');
|
|
29
|
+
const audio = React.useRef<HTMLAudioElement | null>(null);
|
|
30
|
+
|
|
31
|
+
const load = React.useCallback(async () => {
|
|
32
|
+
setState({ phase: 'loading' });
|
|
33
|
+
try { setState({ phase: 'ready', result: await apiRef.current.fetch() }); }
|
|
34
|
+
catch (err) { setState({ phase: 'error', message: (err as Error)?.message || 'The brief could not be loaded.' }); }
|
|
35
|
+
}, []);
|
|
36
|
+
React.useEffect(() => { void load(); }, [load]);
|
|
37
|
+
React.useEffect(() => () => { audio.current?.pause(); }, []);
|
|
38
|
+
|
|
39
|
+
const play = async (result: BriefingResult) => {
|
|
40
|
+
setAudioError('');
|
|
41
|
+
if (playing) { audio.current?.pause(); setPlaying(false); return; }
|
|
42
|
+
try {
|
|
43
|
+
if (!audio.current) {
|
|
44
|
+
const url = await apiRef.current.loadAudio?.(result);
|
|
45
|
+
if (!url) { setAudioError(result.audioReason || 'There is no audio for today’s brief.'); return; }
|
|
46
|
+
const el = new Audio(url);
|
|
47
|
+
el.onended = () => setPlaying(false);
|
|
48
|
+
el.onpause = () => setPlaying(false);
|
|
49
|
+
audio.current = el;
|
|
50
|
+
}
|
|
51
|
+
await audio.current.play();
|
|
52
|
+
setPlaying(true);
|
|
53
|
+
} catch { setAudioError('The audio could not be played.'); }
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<section aria-label="Today’s brief" className="rounded-lg border border-gray-200 bg-white p-4 shadow-sm" data-testid="brief-card">
|
|
58
|
+
<div className="flex items-center gap-2">
|
|
59
|
+
<h2 className="text-sm font-semibold uppercase tracking-wide text-gray-500">Today’s brief</h2>
|
|
60
|
+
<div className="ml-auto flex items-center gap-2">
|
|
61
|
+
{state.phase === 'ready' && apiRef.current.loadAudio ? (
|
|
62
|
+
<button type="button" className="rounded-md bg-gray-900 px-3 py-1.5 text-sm font-medium text-white" onClick={() => void play(state.result)}>
|
|
63
|
+
{playing ? 'Pause' : 'Play'}
|
|
64
|
+
</button>
|
|
65
|
+
) : null}
|
|
66
|
+
{onAsk ? <button type="button" className="rounded-md border border-gray-300 px-3 py-1.5 text-sm font-medium text-gray-800" onClick={onAsk}>Ask</button> : null}
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
{state.phase === 'loading' ? <p className="mt-3 text-sm text-gray-500">Putting your brief together…</p> : null}
|
|
70
|
+
{state.phase === 'error' ? (
|
|
71
|
+
<p className="mt-3 text-sm text-red-600" role="alert">
|
|
72
|
+
{state.message} <button type="button" className="underline" onClick={() => void load()}>Try again</button>
|
|
73
|
+
</p>
|
|
74
|
+
) : null}
|
|
75
|
+
{state.phase === 'ready' ? (
|
|
76
|
+
<>
|
|
77
|
+
<p className="mt-3 whitespace-pre-line text-base leading-relaxed text-gray-900" data-testid="brief-text">{state.result.text}</p>
|
|
78
|
+
{state.result.remaining > 0 ? <p className="mt-2 text-xs text-gray-500">{state.result.remaining} more not read out.</p> : null}
|
|
79
|
+
</>
|
|
80
|
+
) : null}
|
|
81
|
+
{audioError ? <p className="mt-2 text-xs text-amber-800" role="status">{audioError}</p> : null}
|
|
82
|
+
</section>
|
|
83
|
+
);
|
|
84
|
+
}
|