@ekanos/harness 0.25.0 → 0.26.0
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 +3 -4
- package/dist/api-types.d.ts +98 -0
- package/dist/internal/components/approvals-tray.js +1 -1
- package/dist/internal/components/ask-assistant-bridge.js +2 -8
- package/dist/internal/components/connect-panel.js +414 -20
- package/dist/internal/components/dev-toolbar.js +3 -3
- package/dist/internal/components/docs-link.js +1 -1
- package/dist/internal/components/integration-badge.js +2 -2
- package/dist/internal/components/local-oauth-panel.js +28 -2
- package/dist/internal/components/provenance-banner.js +2 -2
- package/dist/internal/components/surface-nav.js +16 -16
- package/dist/internal/components/widget-boundary.js +1 -7
- package/dist/internal/lib/console-client.d.ts +22 -5
- package/dist/internal/lib/console-client.js +32 -6
- package/dist/internal/lib/console-context.js +14 -2
- package/dist/internal/lib/console-types.d.ts +11 -1
- package/dist/internal/lib/experience-runtime.d.ts +20 -0
- package/dist/internal/lib/experience-runtime.js +16 -1
- package/dist/internal/lib/oauth-connect-href.d.ts +9 -0
- package/dist/internal/lib/oauth-connect-href.js +14 -0
- package/dist/internal/lib/run-log-view.js +1 -0
- package/dist/internal/lib/trigger-contract.d.ts +19 -0
- package/dist/internal/lib/trigger-runner.js +4 -1
- package/dist/internal/routes/experience-page-host.d.ts +5 -1
- package/dist/internal/routes/experience-page-host.js +8 -7
- package/dist/internal/routes/repo-home-page.js +1 -1
- package/dist/internal/routes/repo-layout.js +2 -4
- package/dist/internal/routes/root-layout.d.ts +0 -1
- package/dist/internal/routes/root-layout.js +2 -4
- package/dist/internal/routes/tile-page.js +1 -1
- package/dist/internal/routes/triggers-page.js +30 -2
- package/dist/internal/server/activation-credentials.d.ts +26 -0
- package/dist/internal/server/activation-credentials.js +56 -0
- package/dist/internal/server/api-router.js +63 -5
- package/dist/internal/server/console-state.d.ts +25 -0
- package/dist/internal/server/console-state.js +44 -0
- package/dist/internal/server/ekanos-api-router.js +168 -4
- package/dist/internal/server/live-context.js +2 -1
- package/dist/internal/server/live-invoker.js +10 -2
- package/dist/internal/server/local-secrets.d.ts +47 -0
- package/dist/internal/server/local-secrets.js +111 -2
- package/dist/internal/server/local-state.d.ts +8 -2
- package/dist/internal/server/local-state.js +26 -9
- package/dist/internal/server/nonce-store.d.ts +2 -0
- package/dist/internal/server/oauth-connections.d.ts +45 -0
- package/dist/internal/server/oauth-connections.js +69 -0
- package/dist/internal/server/oauth-loop.d.ts +1 -1
- package/dist/internal/server/oauth-loop.js +4 -1
- package/dist/internal/server/oauth-persistence.d.ts +13 -0
- package/dist/internal/server/oauth-persistence.js +28 -0
- package/dist/internal/server/operation-runner.js +21 -1
- package/dist/internal/server/person-context.d.ts +35 -0
- package/dist/internal/server/person-context.js +115 -0
- package/dist/internal/server/semantics.d.ts +1 -1
- package/dist/internal/surfaces.d.ts +1 -1
- package/dist/internal/surfaces.js +4 -4
- package/dist/registry.d.ts +7 -0
- package/dist/registry.js +4 -0
- package/dist/styles.css +3 -8
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -1108,7 +1108,7 @@ API token predictably appears on screen.
|
|
|
1108
1108
|
| `@ekanos/harness/routes` | `IntegrationLayout`, `WidgetsPage`, `SingleWidgetPage`, `TilePage`, `ActivationPage`, `TriggersPage`. |
|
|
1109
1109
|
| `@ekanos/harness/hooks` | `useHarnessDataMode()`, `useLiveActivationData()` — see "Knowing the mode, and the activation-data channel" above. Prefer `FetchProvider`'s own `mode`/`activationData` props where you can; reach for these only from code that runs nowhere but inside the dev harness. |
|
|
1110
1110
|
| `@ekanos/harness/api` | `createHarnessApiHandlers(registry)` — the SERVER entry the shell's one API route injects your registry into. Serves `oauth/{connect,callback,status}`, `storage`, `trigger` and `local-setup` per integration in live mode. Never import it from a `'use client'` module. |
|
|
1111
|
-
| `@ekanos/harness/styles.css` | The harness's Tailwind layer: the Tailwind entry, the `@ekanos/ui` token preset
|
|
1111
|
+
| `@ekanos/harness/styles.css` | The harness's Tailwind layer: the Tailwind entry, the `@ekanos/ui` token preset (with the Phosphor icon fonts), and the `@source` globs covering everything the chrome renders. |
|
|
1112
1112
|
| `@ekanos/harness/mocks/team-account-workspace` | The stand-in for the host's `useTeamAccountWorkspace()`. The generated `next.config.mjs` aliases `@kit/team-accounts/hooks/use-team-account-workspace` onto it, so unmodified widget source runs unchanged. |
|
|
1113
1113
|
|
|
1114
1114
|
## The shell contract
|
|
@@ -1163,6 +1163,5 @@ published tarball, in a clean room outside the workspace.
|
|
|
1163
1163
|
|
|
1164
1164
|
## Licence
|
|
1165
1165
|
|
|
1166
|
-
MIT.
|
|
1167
|
-
|
|
1168
|
-
Ekanos's own Pro webfonts are commercially licensed and cannot be redistributed.
|
|
1166
|
+
MIT. Icons are [Phosphor](https://phosphoricons.com) (MIT), whose fonts ship
|
|
1167
|
+
inside `@ekanos/ui`; this package ships no font data of its own.
|
package/dist/api-types.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ import type { Contract, ExecutionChannel, OperationRefusalReason } from '@ekanos
|
|
|
26
26
|
* PUT /__ekanos/api/integrations/:integration/mode -> IntegrationRuntime (body: SetRuntimeModeRequest)
|
|
27
27
|
* PUT /__ekanos/api/credentials/:integration/activation -> CredentialsResponse (body: SaveActivationRequest)
|
|
28
28
|
* POST /__ekanos/api/credentials/:integration/disconnect -> CredentialsResponse (body: DisconnectCredentialsRequest)
|
|
29
|
+
* PUT /__ekanos/api/credentials/:integration/switches -> CredentialsResponse (body: SetSwitchesRequest)
|
|
29
30
|
*/
|
|
30
31
|
export declare const HARNESS_API_PREFIX = "/__ekanos/api";
|
|
31
32
|
/** Next treats a leading `_` folder as private; the shell mounts the route under this encoded segment. */
|
|
@@ -374,15 +375,84 @@ export interface CredentialsResponse {
|
|
|
374
375
|
displayRoot?: string;
|
|
375
376
|
/** The integration's code connects through an OAuth loop. */
|
|
376
377
|
oauth?: boolean;
|
|
378
|
+
/**
|
|
379
|
+
* Every OAuth connection the definition declares — the main `oauth`
|
|
380
|
+
* (`default`) first, then each `oauthConnections` entry — with its own
|
|
381
|
+
* keys and status, so each gets its own Connect and Disconnect.
|
|
382
|
+
*/
|
|
383
|
+
oauthConnections?: OAuthConnectionStatus[];
|
|
384
|
+
/**
|
|
385
|
+
* The secret `activation.fields`, grouped by the credential each belongs
|
|
386
|
+
* to (`activation.credentials`; the ungrouped secrets are one team
|
|
387
|
+
* credential). Absent when the definition declares no secret field.
|
|
388
|
+
*/
|
|
389
|
+
activationCredentials?: ActivationCredentialStatus[];
|
|
390
|
+
/** Who calls the harness runs act as; `me` unless the switch says otherwise. */
|
|
391
|
+
runAs?: HarnessRunAs;
|
|
377
392
|
/** Connection status and live/fixtures answer, from the one function. */
|
|
378
393
|
facts: IntegrationConnectionFacts;
|
|
379
394
|
}
|
|
395
|
+
/** One declared activation credential and its fields. Never a value. */
|
|
396
|
+
export interface ActivationCredentialStatus {
|
|
397
|
+
/** The `activation.credentials` id; `activation` for the ungrouped secret fields. */
|
|
398
|
+
id: string;
|
|
399
|
+
label: string;
|
|
400
|
+
level: RepoConnectLevel;
|
|
401
|
+
/** Which tier Save writes to: the declared level unless the switch says otherwise. */
|
|
402
|
+
connectAs?: HarnessConnectAs;
|
|
403
|
+
/** Each field's `set` describes the tier `connectAs` names. */
|
|
404
|
+
fields: Array<{
|
|
405
|
+
name: string;
|
|
406
|
+
label: string;
|
|
407
|
+
required: boolean;
|
|
408
|
+
set: boolean;
|
|
409
|
+
}>;
|
|
410
|
+
}
|
|
411
|
+
/** One declared OAuth connection, as the Connect surfaces show it. Never a value. */
|
|
412
|
+
export interface OAuthConnectionStatus {
|
|
413
|
+
/** `default` for the main `oauth`, otherwise its `oauthConnections` key. */
|
|
414
|
+
id: string;
|
|
415
|
+
/** `Main connection`, or the connection's declared `label`. */
|
|
416
|
+
label: string;
|
|
417
|
+
description?: string;
|
|
418
|
+
/** The team brings its own app for this connection (`teamApp`). */
|
|
419
|
+
teamApp: boolean;
|
|
420
|
+
/** The secret names this connection needs; `label` is the teamApp field's. */
|
|
421
|
+
keys: Array<{
|
|
422
|
+
name: string;
|
|
423
|
+
label: string;
|
|
424
|
+
secret: boolean;
|
|
425
|
+
set: boolean;
|
|
426
|
+
}>;
|
|
427
|
+
/** Declared extra authorize parameters (Linear's `actor=app`). */
|
|
428
|
+
authorizationParams?: Record<string, string>;
|
|
429
|
+
/** The connection's declared level (`oauth.level`); `team` when unstated. */
|
|
430
|
+
level?: RepoConnectLevel;
|
|
431
|
+
/** Which tier Connect writes to: the declared level unless the switch says otherwise. */
|
|
432
|
+
connectAs?: HarnessConnectAs;
|
|
433
|
+
/** `connected` and `obtainedAt` describe the tier `connectAs` names. */
|
|
434
|
+
connected: boolean;
|
|
435
|
+
obtainedAt: string | null;
|
|
436
|
+
}
|
|
380
437
|
/** One non-sensitive field of the local credentials, shown beside "Connected". */
|
|
381
438
|
export interface ConnectionTargetField {
|
|
382
439
|
key: string;
|
|
383
440
|
label: string;
|
|
384
441
|
value: string;
|
|
385
442
|
}
|
|
443
|
+
/** The two Connect/Run switches (plan 261 R6); each part is optional. */
|
|
444
|
+
export interface SetSwitchesRequest {
|
|
445
|
+
/** Who calls the harness runs act as. */
|
|
446
|
+
runAs?: HarnessRunAs;
|
|
447
|
+
/**
|
|
448
|
+
* Override which tier one credential connects into: `credential` is
|
|
449
|
+
* `oauth:<connection id>` or `activation:<credential id>`.
|
|
450
|
+
*/
|
|
451
|
+
connectAs?: {
|
|
452
|
+
credential: string;
|
|
453
|
+
as: HarnessConnectAs;
|
|
454
|
+
};
|
|
455
|
+
}
|
|
386
456
|
export interface DisconnectCredentialsRequest {
|
|
387
457
|
/**
|
|
388
458
|
* Also blank the declared secret names. An API-key integration's keys ARE
|
|
@@ -390,6 +460,14 @@ export interface DisconnectCredentialsRequest {
|
|
|
390
460
|
* credentials, which a disconnect keeps.
|
|
391
461
|
*/
|
|
392
462
|
clearKeys?: boolean;
|
|
463
|
+
/**
|
|
464
|
+
* Forget only this OAuth connection's tokens (`default`, or an
|
|
465
|
+
* `oauthConnections` id): its app keys, the other connections and the
|
|
466
|
+
* activation fields stay. Ignores `clearKeys`.
|
|
467
|
+
*/
|
|
468
|
+
connection?: string;
|
|
469
|
+
/** Forget the person's own tokens for `connection` instead of the team's. */
|
|
470
|
+
as?: HarnessConnectAs;
|
|
393
471
|
}
|
|
394
472
|
export interface SaveCredentialsRequest {
|
|
395
473
|
/** Declared secret name -> value. Empty string clears. Only declared names are accepted. */
|
|
@@ -402,6 +480,14 @@ export interface SaveActivationRequest {
|
|
|
402
480
|
* replace whatever was stored before.
|
|
403
481
|
*/
|
|
404
482
|
activationData: Record<string, unknown>;
|
|
483
|
+
/**
|
|
484
|
+
* Keep the stored fields and set only the non-empty ones given, which must
|
|
485
|
+
* be declared `activation.fields`: one credential saved from the Connect
|
|
486
|
+
* tab. Without it the given fields replace the stored ones.
|
|
487
|
+
*/
|
|
488
|
+
merge?: boolean;
|
|
489
|
+
/** Whose tier the fields are stored in. Defaults to the team's. */
|
|
490
|
+
as?: HarnessConnectAs;
|
|
405
491
|
}
|
|
406
492
|
export type ApiErrorBody = {
|
|
407
493
|
error: {
|
|
@@ -419,6 +505,18 @@ export type RepoConnectionType = 'keys' | 'oauth' | 'shipped';
|
|
|
419
505
|
export type RepoConnectionStatus = 'connected' | 'not_connected' | 'not_needed' | 'managed';
|
|
420
506
|
/** Who connects once published: the Source, a team, or each person. */
|
|
421
507
|
export type RepoConnectLevel = 'source' | 'team' | 'user';
|
|
508
|
+
/**
|
|
509
|
+
* Whose tier a credential is connected into: `me` is the local person's own
|
|
510
|
+
* tier, `team` the team's (the existing local account tier). Defaults to the
|
|
511
|
+
* credential's declared level: `user` is `me`, anything else `team`.
|
|
512
|
+
*/
|
|
513
|
+
export type HarnessConnectAs = 'me' | 'team';
|
|
514
|
+
/**
|
|
515
|
+
* Who a call the harness runs acts as: `me` is the local person (a user
|
|
516
|
+
* principal, with `ctx.identity` once they have connected a personal
|
|
517
|
+
* credential), `machine` a call nobody is behind (never any `ctx.identity`).
|
|
518
|
+
*/
|
|
519
|
+
export type HarnessRunAs = 'me' | 'machine';
|
|
422
520
|
export interface RepoConnection {
|
|
423
521
|
type: RepoConnectionType;
|
|
424
522
|
status: RepoConnectionStatus;
|
|
@@ -95,7 +95,7 @@ function ApprovalsTray() {
|
|
|
95
95
|
const list = approvals.data ?? [];
|
|
96
96
|
if (list.length === 0) return null;
|
|
97
97
|
return /* @__PURE__ */ jsxs(Alert, { variant: "warning", className: "*:min-w-0", "data-test": "approvals-tray", children: [
|
|
98
|
-
/* @__PURE__ */ jsx(Icon, { name: "
|
|
98
|
+
/* @__PURE__ */ jsx(Icon, { name: "hand", className: "h-4 w-4" }),
|
|
99
99
|
/* @__PURE__ */ jsx(AlertTitle, { "data-test": "approvals-summary", children: approvalsSummary(list) }),
|
|
100
100
|
/* @__PURE__ */ jsx(AlertDescription, { children: /* @__PURE__ */ jsx("div", { className: "mt-2 flex min-w-0 flex-col gap-3", children: list.map((approval) => /* @__PURE__ */ jsx(
|
|
101
101
|
ApprovalCard,
|
|
@@ -13,13 +13,7 @@ function AskAssistantBridge() {
|
|
|
13
13
|
if (!asked) return null;
|
|
14
14
|
return /* @__PURE__ */ jsxs("div", { className: "fixed right-6 bottom-24 z-50 flex max-h-[60vh] w-[min(28rem,calc(100vw-3rem))] flex-col overflow-hidden rounded-lg border", children: [
|
|
15
15
|
/* @__PURE__ */ jsxs("div", { className: "bg-card flex items-center gap-3 border-b px-5 py-3", children: [
|
|
16
|
-
/* @__PURE__ */ jsx(
|
|
17
|
-
Icon,
|
|
18
|
-
{
|
|
19
|
-
name: "fa-wand-magic-sparkles",
|
|
20
|
-
className: "text-muted-foreground h-5 w-5"
|
|
21
|
-
}
|
|
22
|
-
),
|
|
16
|
+
/* @__PURE__ */ jsx(Icon, { name: "magic-wand", className: "text-muted-foreground h-5 w-5" }),
|
|
23
17
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
24
18
|
/* @__PURE__ */ jsx("p", { className: "truncate text-sm font-medium", children: "Ask payload" }),
|
|
25
19
|
/* @__PURE__ */ jsxs("p", { className: "text-muted-foreground truncate text-xs", children: [
|
|
@@ -35,7 +29,7 @@ function AskAssistantBridge() {
|
|
|
35
29
|
size: "icon",
|
|
36
30
|
onClick: () => setAsked(null),
|
|
37
31
|
"aria-label": "Close ask payload",
|
|
38
|
-
children: /* @__PURE__ */ jsx(Icon, { name: "
|
|
32
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "x", className: "h-4 w-4" })
|
|
39
33
|
}
|
|
40
34
|
)
|
|
41
35
|
] }),
|
|
@@ -20,7 +20,121 @@ import {
|
|
|
20
20
|
useConnection,
|
|
21
21
|
useConsoleMutation
|
|
22
22
|
} from "../lib/console-hooks.js";
|
|
23
|
+
import { oauthConnectHref } from "../lib/oauth-connect-href.js";
|
|
23
24
|
import { ConnectionChip } from "./connection-chip.js";
|
|
25
|
+
const LEVEL_LABEL = {
|
|
26
|
+
source: "For the Source",
|
|
27
|
+
team: "For the team",
|
|
28
|
+
user: "For you"
|
|
29
|
+
};
|
|
30
|
+
function LevelBadge({
|
|
31
|
+
level,
|
|
32
|
+
testId
|
|
33
|
+
}) {
|
|
34
|
+
return /* @__PURE__ */ jsx(StatusBadge, { tone: "neutral", "data-test": testId, children: LEVEL_LABEL[level] });
|
|
35
|
+
}
|
|
36
|
+
function TierSwitch({
|
|
37
|
+
label,
|
|
38
|
+
value,
|
|
39
|
+
options,
|
|
40
|
+
testId,
|
|
41
|
+
disabled,
|
|
42
|
+
onChange
|
|
43
|
+
}) {
|
|
44
|
+
return /* @__PURE__ */ jsxs(
|
|
45
|
+
"div",
|
|
46
|
+
{
|
|
47
|
+
className: "flex flex-wrap items-center gap-2",
|
|
48
|
+
role: "group",
|
|
49
|
+
"aria-label": label,
|
|
50
|
+
"data-test": testId,
|
|
51
|
+
children: [
|
|
52
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-xs", children: label }),
|
|
53
|
+
options.map((option) => /* @__PURE__ */ jsx(
|
|
54
|
+
Button,
|
|
55
|
+
{
|
|
56
|
+
type: "button",
|
|
57
|
+
size: "sm",
|
|
58
|
+
variant: option.value === value ? "secondary" : "ghost",
|
|
59
|
+
"aria-pressed": option.value === value,
|
|
60
|
+
disabled,
|
|
61
|
+
"data-test": `${testId}-${option.value}`,
|
|
62
|
+
onClick: () => {
|
|
63
|
+
if (option.value !== value) onChange(option.value);
|
|
64
|
+
},
|
|
65
|
+
children: option.label
|
|
66
|
+
},
|
|
67
|
+
option.value
|
|
68
|
+
))
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
const CONNECT_AS_OPTIONS = [
|
|
74
|
+
{ value: "me", label: "Me" },
|
|
75
|
+
{ value: "team", label: "The team" }
|
|
76
|
+
];
|
|
77
|
+
const RUN_AS_OPTIONS = [
|
|
78
|
+
{ value: "me", label: "Me" },
|
|
79
|
+
{ value: "machine", label: "Machine" }
|
|
80
|
+
];
|
|
81
|
+
function ConnectAsSwitch({
|
|
82
|
+
integration,
|
|
83
|
+
credential,
|
|
84
|
+
value,
|
|
85
|
+
testId
|
|
86
|
+
}) {
|
|
87
|
+
const queryClient = useQueryClient();
|
|
88
|
+
const change = useConsoleMutation(
|
|
89
|
+
(c, as) => c.setSwitches(integration, { connectAs: { credential, as } })
|
|
90
|
+
);
|
|
91
|
+
return /* @__PURE__ */ jsx(
|
|
92
|
+
TierSwitch,
|
|
93
|
+
{
|
|
94
|
+
label: "Connect as",
|
|
95
|
+
value,
|
|
96
|
+
options: CONNECT_AS_OPTIONS,
|
|
97
|
+
testId,
|
|
98
|
+
disabled: change.isPending,
|
|
99
|
+
onChange: (as) => change.mutate(as, {
|
|
100
|
+
onSuccess: () => queryClient.invalidateQueries({
|
|
101
|
+
queryKey: consoleKeys.connection(integration)
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
function RunAsSwitch({
|
|
108
|
+
integration,
|
|
109
|
+
value
|
|
110
|
+
}) {
|
|
111
|
+
const queryClient = useQueryClient();
|
|
112
|
+
const change = useConsoleMutation(
|
|
113
|
+
(c, runAs) => c.setSwitches(integration, { runAs })
|
|
114
|
+
);
|
|
115
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex max-w-xl flex-col gap-1", "data-test": "run-as", children: [
|
|
116
|
+
/* @__PURE__ */ jsx(
|
|
117
|
+
TierSwitch,
|
|
118
|
+
{
|
|
119
|
+
label: "Run as",
|
|
120
|
+
value,
|
|
121
|
+
options: RUN_AS_OPTIONS,
|
|
122
|
+
testId: "run-as-switch",
|
|
123
|
+
disabled: change.isPending,
|
|
124
|
+
onChange: (runAs) => change.mutate(runAs, {
|
|
125
|
+
onSuccess: () => queryClient.invalidateQueries({
|
|
126
|
+
queryKey: consoleKeys.connection(integration)
|
|
127
|
+
})
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
/* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-xs", children: [
|
|
132
|
+
value === "me" ? "Calls act as you, with ctx.identity holding only what you connected as yourself." : "Calls act as a machine: no person, and never a ctx.identity.",
|
|
133
|
+
" ",
|
|
134
|
+
"ctx.secrets stays the team's either way."
|
|
135
|
+
] })
|
|
136
|
+
] });
|
|
137
|
+
}
|
|
24
138
|
function ConnectPanel({
|
|
25
139
|
integration,
|
|
26
140
|
oauth = false,
|
|
@@ -57,6 +171,7 @@ function ConnectPanel({
|
|
|
57
171
|
const noConnectionNeeded = state.facts.state === "no_connection_needed";
|
|
58
172
|
const inDialog = surface === "dialog";
|
|
59
173
|
const dirty = Object.values(drafts).some((value) => value !== "");
|
|
174
|
+
const showActivationForm = state.fields.length === 0 && activationForm;
|
|
60
175
|
return /* @__PURE__ */ jsxs(
|
|
61
176
|
"div",
|
|
62
177
|
{
|
|
@@ -115,6 +230,13 @@ function ConnectPanel({
|
|
|
115
230
|
}
|
|
116
231
|
),
|
|
117
232
|
disconnect.isError ? /* @__PURE__ */ jsx(Alert, { variant: "destructive", children: /* @__PURE__ */ jsx(AlertDescription, { children: disconnect.error.message }) }) : null,
|
|
233
|
+
state.runAs ? /* @__PURE__ */ jsx(
|
|
234
|
+
RunAsSwitch,
|
|
235
|
+
{
|
|
236
|
+
integration: integration.integration,
|
|
237
|
+
value: state.runAs
|
|
238
|
+
}
|
|
239
|
+
) : null,
|
|
118
240
|
/* @__PURE__ */ jsxs(
|
|
119
241
|
"form",
|
|
120
242
|
{
|
|
@@ -140,7 +262,7 @@ function ConnectPanel({
|
|
|
140
262
|
" ",
|
|
141
263
|
/* @__PURE__ */ jsx("code", { title: state.root, children: state.displayRoot ?? state.root })
|
|
142
264
|
] }) : null,
|
|
143
|
-
state.fields.length === 0 && !activationForm ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm", children: "This integration declares no keys." }) : null,
|
|
265
|
+
state.fields.length === 0 && !activationForm && (state.activationCredentials ?? []).length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm", children: "This integration declares no keys." }) : null,
|
|
144
266
|
state.fields.map((field) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
145
267
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
146
268
|
/* @__PURE__ */ jsx(
|
|
@@ -179,35 +301,307 @@ function ConnectPanel({
|
|
|
179
301
|
]
|
|
180
302
|
}
|
|
181
303
|
),
|
|
182
|
-
|
|
304
|
+
showActivationForm ? /* @__PURE__ */ jsx(
|
|
183
305
|
ActivationConnect,
|
|
184
306
|
{
|
|
185
307
|
integration: integration.integration,
|
|
186
|
-
Form:
|
|
308
|
+
Form: showActivationForm,
|
|
187
309
|
saveLabel: noConnectionNeeded,
|
|
188
310
|
...onChanged ? { onChanged } : {}
|
|
189
311
|
}
|
|
190
312
|
) : null,
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
{
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
313
|
+
!showActivationForm && (state.activationCredentials ?? []).length > 0 ? /* @__PURE__ */ jsx(
|
|
314
|
+
ActivationCredentials,
|
|
315
|
+
{
|
|
316
|
+
integration: integration.integration,
|
|
317
|
+
credentials: state.activationCredentials ?? [],
|
|
318
|
+
...onChanged ? { onChanged } : {}
|
|
319
|
+
}
|
|
320
|
+
) : null,
|
|
321
|
+
oauth ? /* @__PURE__ */ jsx(
|
|
322
|
+
OAuthConnections,
|
|
323
|
+
{
|
|
324
|
+
integration: integration.integration,
|
|
325
|
+
connections: state.oauthConnections ?? [],
|
|
326
|
+
disconnectable: !inDialog,
|
|
327
|
+
...returnPath ? { returnPath } : {},
|
|
328
|
+
...onChanged ? { onChanged } : {}
|
|
329
|
+
}
|
|
330
|
+
) : null
|
|
331
|
+
]
|
|
332
|
+
}
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
function OAuthConnections({
|
|
336
|
+
integration,
|
|
337
|
+
connections,
|
|
338
|
+
disconnectable,
|
|
339
|
+
returnPath,
|
|
340
|
+
onChanged
|
|
341
|
+
}) {
|
|
342
|
+
const queryClient = useQueryClient();
|
|
343
|
+
const disconnect = useConsoleMutation(
|
|
344
|
+
(c, target) => c.disconnect(integration, false, target.connection, target.as)
|
|
345
|
+
);
|
|
346
|
+
const rows = connections.length > 0 ? connections : [
|
|
347
|
+
{
|
|
348
|
+
id: "default",
|
|
349
|
+
label: "Main connection",
|
|
350
|
+
teamApp: false,
|
|
351
|
+
keys: [],
|
|
352
|
+
connected: false,
|
|
353
|
+
obtainedAt: null
|
|
354
|
+
}
|
|
355
|
+
];
|
|
356
|
+
const single = connections.length === 0;
|
|
357
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", "data-test": "oauth-block", children: [
|
|
358
|
+
/* @__PURE__ */ jsx("h3", { className: "text-sm font-medium", children: "OAuth" }),
|
|
359
|
+
/* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-xs", children: [
|
|
360
|
+
"Runs the real authorize and callback loop on localhost, with your own provider app credentials (save them above first).",
|
|
361
|
+
rows.length > 1 ? " Each connection has its own app, consent and tokens." : ""
|
|
362
|
+
] }),
|
|
363
|
+
disconnect.isError ? /* @__PURE__ */ jsx(Alert, { variant: "destructive", children: /* @__PURE__ */ jsx(AlertDescription, { children: disconnect.error.message }) }) : null,
|
|
364
|
+
rows.map((connection) => {
|
|
365
|
+
const missing = connection.keys.filter((key) => !key.set);
|
|
366
|
+
const params = Object.entries(connection.authorizationParams ?? {});
|
|
367
|
+
return /* @__PURE__ */ jsxs(
|
|
368
|
+
"div",
|
|
369
|
+
{
|
|
370
|
+
className: "flex max-w-xl flex-col gap-2 rounded-md border p-3",
|
|
371
|
+
"data-test": `oauth-connection-${connection.id}`,
|
|
372
|
+
children: [
|
|
373
|
+
single ? null : /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
374
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: connection.label }),
|
|
375
|
+
/* @__PURE__ */ jsx("code", { className: "text-muted-foreground text-xs", children: connection.id }),
|
|
376
|
+
/* @__PURE__ */ jsx(
|
|
377
|
+
StatusBadge,
|
|
378
|
+
{
|
|
379
|
+
tone: connection.connected ? "success" : "neutral",
|
|
380
|
+
children: connection.connected ? "connected" : "not connected"
|
|
381
|
+
}
|
|
382
|
+
),
|
|
383
|
+
/* @__PURE__ */ jsx(
|
|
384
|
+
LevelBadge,
|
|
385
|
+
{
|
|
386
|
+
level: connection.level ?? "team",
|
|
387
|
+
testId: `oauth-connection-level-${connection.id}`
|
|
388
|
+
}
|
|
389
|
+
)
|
|
390
|
+
] }),
|
|
391
|
+
connection.description ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: connection.description }) : null,
|
|
392
|
+
connection.teamApp ? /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-xs", children: [
|
|
393
|
+
"The team brings its own app for this connection. Here, its fields are the keys above:",
|
|
394
|
+
" ",
|
|
395
|
+
connection.keys.map((key) => key.label).join(", "),
|
|
396
|
+
"."
|
|
397
|
+
] }) : null,
|
|
398
|
+
params.length > 0 ? /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-xs", children: [
|
|
399
|
+
"Sends",
|
|
400
|
+
" ",
|
|
401
|
+
params.map(([key, value]) => /* @__PURE__ */ jsxs("code", { className: "mr-1", children: [
|
|
402
|
+
key,
|
|
403
|
+
"=",
|
|
404
|
+
value
|
|
405
|
+
] }, key)),
|
|
406
|
+
"to the provider."
|
|
407
|
+
] }) : null,
|
|
408
|
+
connection.connectAs ? /* @__PURE__ */ jsx(
|
|
409
|
+
ConnectAsSwitch,
|
|
410
|
+
{
|
|
411
|
+
integration,
|
|
412
|
+
credential: `oauth:${connection.id}`,
|
|
413
|
+
value: connection.connectAs,
|
|
414
|
+
testId: `oauth-connect-as-${connection.id}`
|
|
415
|
+
}
|
|
416
|
+
) : null,
|
|
417
|
+
missing.length > 0 ? /* @__PURE__ */ jsxs(
|
|
418
|
+
"p",
|
|
419
|
+
{
|
|
420
|
+
className: "text-muted-foreground text-xs",
|
|
421
|
+
"data-test": `oauth-connection-missing-${connection.id}`,
|
|
422
|
+
children: [
|
|
423
|
+
"Save ",
|
|
424
|
+
missing.map((key) => key.label).join(", "),
|
|
425
|
+
" first."
|
|
426
|
+
]
|
|
427
|
+
}
|
|
428
|
+
) : null,
|
|
429
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
430
|
+
/* @__PURE__ */ jsx(
|
|
431
|
+
Button,
|
|
203
432
|
{
|
|
204
|
-
|
|
433
|
+
variant: "outline",
|
|
434
|
+
className: "self-start",
|
|
435
|
+
"data-test": connection.id === "default" ? "start-oauth" : `start-oauth-${connection.id}`,
|
|
436
|
+
nativeButton: false,
|
|
437
|
+
render: /* @__PURE__ */ jsx(
|
|
438
|
+
"a",
|
|
439
|
+
{
|
|
440
|
+
href: oauthConnectHref(
|
|
441
|
+
integration,
|
|
442
|
+
connection.id,
|
|
443
|
+
returnPath,
|
|
444
|
+
connection.connectAs
|
|
445
|
+
)
|
|
446
|
+
}
|
|
447
|
+
),
|
|
448
|
+
children: single ? "Connect with OAuth" : connection.connected ? `Reconnect ${connection.label}` : `Connect ${connection.label}`
|
|
205
449
|
}
|
|
206
450
|
),
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
451
|
+
disconnectable && connection.connected ? /* @__PURE__ */ jsx(
|
|
452
|
+
Button,
|
|
453
|
+
{
|
|
454
|
+
variant: "ghost",
|
|
455
|
+
size: "sm",
|
|
456
|
+
disabled: disconnect.isPending,
|
|
457
|
+
"data-test": `disconnect-oauth-${connection.id}`,
|
|
458
|
+
onClick: () => disconnect.mutate(
|
|
459
|
+
{ connection: connection.id, as: connection.connectAs },
|
|
460
|
+
{
|
|
461
|
+
onSuccess: async () => {
|
|
462
|
+
await queryClient.invalidateQueries({
|
|
463
|
+
queryKey: consoleKeys.connection(integration)
|
|
464
|
+
});
|
|
465
|
+
onChanged?.();
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
),
|
|
469
|
+
children: "Disconnect"
|
|
470
|
+
}
|
|
471
|
+
) : null
|
|
472
|
+
] })
|
|
473
|
+
]
|
|
474
|
+
},
|
|
475
|
+
connection.id
|
|
476
|
+
);
|
|
477
|
+
})
|
|
478
|
+
] });
|
|
479
|
+
}
|
|
480
|
+
function ActivationCredentials({
|
|
481
|
+
integration,
|
|
482
|
+
credentials,
|
|
483
|
+
onChanged
|
|
484
|
+
}) {
|
|
485
|
+
const queryClient = useQueryClient();
|
|
486
|
+
const [drafts, setDrafts] = useState({});
|
|
487
|
+
const save = useConsoleMutation(
|
|
488
|
+
async (c, groups) => {
|
|
489
|
+
for (const [as, values] of groups) {
|
|
490
|
+
await c.saveActivation(integration, values, {
|
|
491
|
+
merge: true,
|
|
492
|
+
...as ? { as } : {}
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
);
|
|
497
|
+
const dirty = Object.values(drafts).some((value) => value !== "");
|
|
498
|
+
const perPerson = credentials.some(
|
|
499
|
+
(credential) => credential.level === "user" && !credential.connectAs
|
|
500
|
+
);
|
|
501
|
+
return /* @__PURE__ */ jsxs(
|
|
502
|
+
"form",
|
|
503
|
+
{
|
|
504
|
+
className: "flex w-full max-w-xl min-w-0 flex-col gap-3",
|
|
505
|
+
"data-test": "activation-credentials",
|
|
506
|
+
onSubmit: (event) => {
|
|
507
|
+
event.preventDefault();
|
|
508
|
+
const typed = Object.fromEntries(
|
|
509
|
+
Object.entries(drafts).filter(([, value]) => value !== "")
|
|
510
|
+
);
|
|
511
|
+
const groups = /* @__PURE__ */ new Map();
|
|
512
|
+
for (const credential of credentials) {
|
|
513
|
+
for (const field of credential.fields) {
|
|
514
|
+
const value = typed[field.name];
|
|
515
|
+
if (value === void 0) continue;
|
|
516
|
+
groups.set(credential.connectAs, {
|
|
517
|
+
...groups.get(credential.connectAs),
|
|
518
|
+
[field.name]: value
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
save.mutate([...groups], {
|
|
523
|
+
onSuccess: () => {
|
|
524
|
+
setDrafts({});
|
|
525
|
+
onChanged?.();
|
|
526
|
+
return queryClient.invalidateQueries({
|
|
527
|
+
queryKey: consoleKeys.connection(integration)
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
},
|
|
532
|
+
children: [
|
|
533
|
+
/* @__PURE__ */ jsx("h3", { className: "text-sm font-medium", children: "Activation credentials" }),
|
|
534
|
+
perPerson ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: "The harness keeps one local store, so a credential for you is stored beside the team's and every call can read it." }) : null,
|
|
535
|
+
credentials.map((credential) => /* @__PURE__ */ jsxs(
|
|
536
|
+
"div",
|
|
537
|
+
{
|
|
538
|
+
className: "flex flex-col gap-2 rounded-md border p-3",
|
|
539
|
+
"data-test": `activation-credential-${credential.id}`,
|
|
540
|
+
children: [
|
|
541
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
542
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: credential.label }),
|
|
543
|
+
/* @__PURE__ */ jsx(
|
|
544
|
+
LevelBadge,
|
|
545
|
+
{
|
|
546
|
+
level: credential.level,
|
|
547
|
+
testId: `activation-credential-level-${credential.id}`
|
|
548
|
+
}
|
|
549
|
+
)
|
|
550
|
+
] }),
|
|
551
|
+
credential.connectAs ? /* @__PURE__ */ jsx(
|
|
552
|
+
ConnectAsSwitch,
|
|
553
|
+
{
|
|
554
|
+
integration,
|
|
555
|
+
credential: `activation:${credential.id}`,
|
|
556
|
+
value: credential.connectAs,
|
|
557
|
+
testId: `activation-connect-as-${credential.id}`
|
|
558
|
+
}
|
|
559
|
+
) : null,
|
|
560
|
+
credential.fields.map((field) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
561
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
562
|
+
/* @__PURE__ */ jsxs(
|
|
563
|
+
Label,
|
|
564
|
+
{
|
|
565
|
+
htmlFor: `activation-${field.name}`,
|
|
566
|
+
className: "text-sm font-medium",
|
|
567
|
+
children: [
|
|
568
|
+
field.label,
|
|
569
|
+
field.required ? null : /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground font-normal", children: [
|
|
570
|
+
" ",
|
|
571
|
+
"(optional)"
|
|
572
|
+
] })
|
|
573
|
+
]
|
|
574
|
+
}
|
|
575
|
+
),
|
|
576
|
+
/* @__PURE__ */ jsx(StatusBadge, { tone: field.set ? "success" : "neutral", children: field.set ? "set" : "not set" })
|
|
577
|
+
] }),
|
|
578
|
+
/* @__PURE__ */ jsx(
|
|
579
|
+
Input,
|
|
580
|
+
{
|
|
581
|
+
id: `activation-${field.name}`,
|
|
582
|
+
type: "password",
|
|
583
|
+
autoComplete: "off",
|
|
584
|
+
placeholder: field.set ? "Set" : "",
|
|
585
|
+
value: drafts[field.name] ?? "",
|
|
586
|
+
onChange: (event) => setDrafts({ ...drafts, [field.name]: event.target.value })
|
|
587
|
+
}
|
|
588
|
+
)
|
|
589
|
+
] }, field.name))
|
|
590
|
+
]
|
|
591
|
+
},
|
|
592
|
+
credential.id
|
|
593
|
+
)),
|
|
594
|
+
save.isError ? /* @__PURE__ */ jsx(Alert, { variant: "destructive", children: /* @__PURE__ */ jsx(AlertDescription, { children: save.error.message }) }) : null,
|
|
595
|
+
/* @__PURE__ */ jsx(
|
|
596
|
+
Button,
|
|
597
|
+
{
|
|
598
|
+
type: "submit",
|
|
599
|
+
className: "self-start",
|
|
600
|
+
disabled: !dirty || save.isPending,
|
|
601
|
+
"data-test": "save-activation-credentials",
|
|
602
|
+
children: save.isPending ? "Saving\u2026" : "Save credentials"
|
|
603
|
+
}
|
|
604
|
+
)
|
|
211
605
|
]
|
|
212
606
|
}
|
|
213
607
|
);
|