@ekanos/harness 0.30.0 → 0.32.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/dist/api-types.d.ts +21 -0
- package/dist/internal/components/publish-status.d.ts +13 -1
- package/dist/internal/components/publish-status.js +39 -2
- package/dist/internal/components/source-switcher.d.ts +10 -0
- package/dist/internal/components/source-switcher.js +82 -0
- package/dist/internal/lib/console-client.js +2 -1
- package/dist/internal/lib/console-types.d.ts +4 -2
- package/dist/internal/lib/host-data.d.ts +5 -0
- package/dist/internal/lib/host-data.js +25 -1
- package/dist/internal/lib/name-scope.d.ts +28 -0
- package/dist/internal/lib/name-scope.js +54 -0
- package/dist/internal/routes/catalog-pages.js +4 -2
- package/dist/internal/routes/experience-summary-page.js +2 -1
- package/dist/internal/routes/integrations-overview-page.js +10 -2
- package/dist/internal/routes/repo-home-page.js +4 -2
- package/dist/internal/server/ekanos-api-router.js +4 -1
- package/dist/internal/server/host-snapshots.d.ts +15 -4
- package/dist/internal/server/host-snapshots.js +36 -3
- package/dist/internal/server/package-naming.d.ts +14 -0
- package/dist/internal/server/package-naming.js +43 -0
- package/dist/internal/server/repo-api-router.js +11 -5
- package/package.json +6 -6
package/dist/api-types.d.ts
CHANGED
|
@@ -172,8 +172,27 @@ export interface ActiveOverride {
|
|
|
172
172
|
via: 'file' | 'env';
|
|
173
173
|
mode: RunMode;
|
|
174
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* How a local package is named when it publishes, as its files declare it:
|
|
177
|
+
* `global`, a bare name (`availability.mode: "global"` in its `ekanos.json`,
|
|
178
|
+
* which needs an approved global name), or `restricted`, the default, named
|
|
179
|
+
* under the publishing Source's namespace (`acme/google-drive`). The host's
|
|
180
|
+
* answer once it is published (`PublishedPackage.namespace`) is authoritative.
|
|
181
|
+
* Naming only: who may see a package is set separately.
|
|
182
|
+
*/
|
|
183
|
+
export interface PackageNaming {
|
|
184
|
+
availability: 'global' | 'restricted';
|
|
185
|
+
/**
|
|
186
|
+
* The namespace it publishes under, as far as the files say: the repo's
|
|
187
|
+
* root `ekanos.json` `namespace`, else the Source every integration names.
|
|
188
|
+
* Null when nothing says.
|
|
189
|
+
*/
|
|
190
|
+
namespace: string | null;
|
|
191
|
+
}
|
|
175
192
|
export interface IntegrationsResponse {
|
|
176
193
|
kind: HarnessKind;
|
|
194
|
+
/** How the project's own package is named when it publishes. */
|
|
195
|
+
naming?: PackageNaming;
|
|
177
196
|
integrations: IntegrationView[];
|
|
178
197
|
overrides: ActiveOverride[];
|
|
179
198
|
/** True while any override is active: `ekanos publish` refuses. */
|
|
@@ -543,6 +562,7 @@ export interface RepoIntegrationRow {
|
|
|
543
562
|
consoleHref: string;
|
|
544
563
|
/** Experience packages of this repo that use it. */
|
|
545
564
|
usedBy: string[];
|
|
565
|
+
naming: PackageNaming;
|
|
546
566
|
}
|
|
547
567
|
export interface RepoExperienceIntegration {
|
|
548
568
|
name: string;
|
|
@@ -568,6 +588,7 @@ export interface RepoExperienceRow {
|
|
|
568
588
|
connectHref: string;
|
|
569
589
|
integrations: RepoExperienceIntegration[];
|
|
570
590
|
error?: string;
|
|
591
|
+
naming: PackageNaming;
|
|
571
592
|
}
|
|
572
593
|
export interface RepoResponse {
|
|
573
594
|
root: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PublishFinding } from '@ekanos/integration-schema';
|
|
2
|
+
import type { PackageNaming } from '../lib/console-types.js';
|
|
2
3
|
/**
|
|
3
4
|
* The latest published version of a local package, as a chip: "Live on dev ·
|
|
4
5
|
* 0.3.1". Nothing at all when the host could not be read, so a missing login
|
|
@@ -7,10 +8,21 @@ import type { PublishFinding } from '@ekanos/integration-schema';
|
|
|
7
8
|
export declare function PublishChip({ name }: {
|
|
8
9
|
name: string;
|
|
9
10
|
}): import("react").JSX.Element | null;
|
|
11
|
+
/**
|
|
12
|
+
* Whether a local package is global or named under a namespace: the host's
|
|
13
|
+
* answer once it is published, else what its `ekanos.json` declares. Nothing
|
|
14
|
+
* when neither says.
|
|
15
|
+
*/
|
|
16
|
+
export declare function NameScopeBadge({ name, naming, }: {
|
|
17
|
+
name: string;
|
|
18
|
+
naming?: PackageNaming | null | undefined;
|
|
19
|
+
}): import("react").JSX.Element | null;
|
|
10
20
|
/** One line on the latest publish, for an Overview, linking to its Publishes tab. */
|
|
11
|
-
export declare function LatestPublishLine({ name, href, }: {
|
|
21
|
+
export declare function LatestPublishLine({ name, href, naming, }: {
|
|
12
22
|
name: string;
|
|
13
23
|
href: string;
|
|
24
|
+
/** The package's declared naming, shown as a global/namespaced badge. */
|
|
25
|
+
naming?: PackageNaming | null | undefined;
|
|
14
26
|
}): import("react").JSX.Element | null;
|
|
15
27
|
/**
|
|
16
28
|
* The checks can report the same finding more than once (one per stage that
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
sortVersions,
|
|
14
14
|
usePublishSnapshot
|
|
15
15
|
} from "../lib/host-data.js";
|
|
16
|
+
import { describeNameScope } from "../lib/name-scope.js";
|
|
16
17
|
import { HostFreshness, fullTime, timeAgo } from "./host-freshness.js";
|
|
17
18
|
import { PageSkeleton } from "./page-skeletons.js";
|
|
18
19
|
import { FOCUS_RING } from "./scrollable-nav.js";
|
|
@@ -53,13 +54,47 @@ function PublishChip({ name }) {
|
|
|
53
54
|
}
|
|
54
55
|
);
|
|
55
56
|
}
|
|
57
|
+
function NameScopeBadge({
|
|
58
|
+
name,
|
|
59
|
+
naming
|
|
60
|
+
}) {
|
|
61
|
+
const publish = usePublishSnapshot();
|
|
62
|
+
const snapshot = publish.data?.snapshot;
|
|
63
|
+
const published = snapshot && !snapshot.unavailable ? findPublishedPackage(snapshot, name) : null;
|
|
64
|
+
const scope = describeNameScope({ name, published, declared: naming });
|
|
65
|
+
if (!scope) return null;
|
|
66
|
+
return /* @__PURE__ */ jsxs(
|
|
67
|
+
"span",
|
|
68
|
+
{
|
|
69
|
+
"data-test": "name-scope",
|
|
70
|
+
"data-scope": scope.scope,
|
|
71
|
+
"data-confirmed": scope.confirmed,
|
|
72
|
+
title: scope.detail,
|
|
73
|
+
className: "text-foreground inline-flex h-6 w-fit shrink-0 items-center gap-1 rounded-full border px-2 text-xs font-semibold tracking-wide whitespace-nowrap",
|
|
74
|
+
children: [
|
|
75
|
+
/* @__PURE__ */ jsx(
|
|
76
|
+
Icon,
|
|
77
|
+
{
|
|
78
|
+
name: scope.scope === "global" ? "globe" : "folder-simple",
|
|
79
|
+
className: "size-3",
|
|
80
|
+
"aria-hidden": true
|
|
81
|
+
}
|
|
82
|
+
),
|
|
83
|
+
scope.label
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
}
|
|
56
88
|
function LatestPublishLine({
|
|
57
89
|
name,
|
|
58
|
-
href
|
|
90
|
+
href,
|
|
91
|
+
naming
|
|
59
92
|
}) {
|
|
60
93
|
const publish = usePublishSnapshot();
|
|
61
94
|
const snapshot = publish.data?.snapshot;
|
|
62
|
-
if (!snapshot || snapshot.unavailable)
|
|
95
|
+
if (!snapshot || snapshot.unavailable) {
|
|
96
|
+
return naming ? /* @__PURE__ */ jsx("p", { className: "flex flex-wrap items-center gap-2", "data-test": "naming-line", children: /* @__PURE__ */ jsx(NameScopeBadge, { name, naming }) }) : null;
|
|
97
|
+
}
|
|
63
98
|
const pkg = findPublishedPackage(snapshot, name);
|
|
64
99
|
const latest = pkg ? sortVersions(pkg.versions)[0] : void 0;
|
|
65
100
|
return /* @__PURE__ */ jsxs(
|
|
@@ -77,6 +112,7 @@ function LatestPublishLine({
|
|
|
77
112
|
/* @__PURE__ */ jsx(StatusBadge, { tone: describePublishState(latest.state).tone, children: describePublishState(latest.state).label }),
|
|
78
113
|
/* @__PURE__ */ jsx("span", { title: fullTime(latest.submittedAt), children: timeAgo(latest.submittedAt) })
|
|
79
114
|
] }) : /* @__PURE__ */ jsx("span", { children: "Not published yet." }),
|
|
115
|
+
/* @__PURE__ */ jsx(NameScopeBadge, { name, naming }),
|
|
80
116
|
/* @__PURE__ */ jsx(
|
|
81
117
|
Link,
|
|
82
118
|
{
|
|
@@ -320,6 +356,7 @@ function PublishesView({ name }) {
|
|
|
320
356
|
}
|
|
321
357
|
export {
|
|
322
358
|
LatestPublishLine,
|
|
359
|
+
NameScopeBadge,
|
|
323
360
|
PublishChip,
|
|
324
361
|
PublishesView,
|
|
325
362
|
uniqueFindings
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CatalogSnapshot } from '@ekanos/integration-schema';
|
|
2
|
+
/**
|
|
3
|
+
* Which of the developer's Sources the harness reads: its catalog (global
|
|
4
|
+
* packages plus the ones attached to that Source) and its publish status.
|
|
5
|
+
* Shown only when there is a choice to make; it never changes where
|
|
6
|
+
* `ekanos publish` sends a package.
|
|
7
|
+
*/
|
|
8
|
+
export declare function SourceSwitcher({ snapshot }: {
|
|
9
|
+
snapshot: CatalogSnapshot;
|
|
10
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
import {
|
|
5
|
+
Select,
|
|
6
|
+
SelectContent,
|
|
7
|
+
SelectItem,
|
|
8
|
+
SelectTrigger,
|
|
9
|
+
SelectValue
|
|
10
|
+
} from "@ekanos/ui/select";
|
|
11
|
+
import { useSelectSource } from "../lib/host-data.js";
|
|
12
|
+
function SourceSwitcher({ snapshot }) {
|
|
13
|
+
const labelId = useId();
|
|
14
|
+
const select = useSelectSource();
|
|
15
|
+
const seats = snapshot.seats ?? [];
|
|
16
|
+
const current = snapshot.scope === "source" ? snapshot.source?.slug : null;
|
|
17
|
+
if (seats.length === 0) return null;
|
|
18
|
+
if (seats.length === 1 && current === seats[0]?.slug) return null;
|
|
19
|
+
const switching = select.isPending || select.isSuccess && select.variables !== current;
|
|
20
|
+
return /* @__PURE__ */ jsxs(
|
|
21
|
+
"div",
|
|
22
|
+
{
|
|
23
|
+
className: "flex flex-wrap items-center gap-x-2 gap-y-1 text-sm",
|
|
24
|
+
"data-test": "source-switcher",
|
|
25
|
+
children: [
|
|
26
|
+
/* @__PURE__ */ jsx("span", { id: labelId, className: "text-muted-foreground", children: "Source" }),
|
|
27
|
+
/* @__PURE__ */ jsxs(
|
|
28
|
+
Select,
|
|
29
|
+
{
|
|
30
|
+
value: (switching ? select.variables : current) ?? null,
|
|
31
|
+
onValueChange: (value) => {
|
|
32
|
+
if (typeof value === "string" && value !== current) {
|
|
33
|
+
select.mutate(value);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
disabled: select.isPending,
|
|
37
|
+
children: [
|
|
38
|
+
/* @__PURE__ */ jsx(
|
|
39
|
+
SelectTrigger,
|
|
40
|
+
{
|
|
41
|
+
size: "sm",
|
|
42
|
+
className: "min-w-40",
|
|
43
|
+
"aria-labelledby": labelId,
|
|
44
|
+
"data-test": "source-switcher-trigger",
|
|
45
|
+
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Pick a Source" })
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
/* @__PURE__ */ jsx(SelectContent, { children: seats.map((seat) => /* @__PURE__ */ jsx(
|
|
49
|
+
SelectItem,
|
|
50
|
+
{
|
|
51
|
+
value: seat.slug,
|
|
52
|
+
"data-test": `source-switcher-${seat.slug}`,
|
|
53
|
+
children: seat.name ?? seat.slug
|
|
54
|
+
},
|
|
55
|
+
seat.slug
|
|
56
|
+
)) })
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
),
|
|
60
|
+
switching ? /* @__PURE__ */ jsx(
|
|
61
|
+
"span",
|
|
62
|
+
{
|
|
63
|
+
className: "text-muted-foreground text-xs",
|
|
64
|
+
"data-test": "source-switching",
|
|
65
|
+
children: "Reading its catalog\u2026"
|
|
66
|
+
}
|
|
67
|
+
) : null,
|
|
68
|
+
select.isError ? /* @__PURE__ */ jsx(
|
|
69
|
+
"span",
|
|
70
|
+
{
|
|
71
|
+
className: "text-destructive text-xs",
|
|
72
|
+
"data-test": "source-switch-error",
|
|
73
|
+
children: select.error.message
|
|
74
|
+
}
|
|
75
|
+
) : null
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
SourceSwitcher
|
|
82
|
+
};
|
|
@@ -140,7 +140,8 @@ function createHttpConsoleClient(fetcher = (input, init) => globalThis.fetch(inp
|
|
|
140
140
|
integrations: wire.integrations.map(integrationView),
|
|
141
141
|
notices: wire.notices,
|
|
142
142
|
errors: wire.errors,
|
|
143
|
-
...experience?.checks ? { checks: experience.checks } : {}
|
|
143
|
+
...experience?.checks ? { checks: experience.checks } : {},
|
|
144
|
+
...wire.naming ? { naming: wire.naming } : {}
|
|
144
145
|
};
|
|
145
146
|
},
|
|
146
147
|
getContract: async (integration) => contractView(
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* so the UI builds and is tested against fakes; once `src/api.ts` publishes
|
|
7
7
|
* the real types, this file is the one place to re-point.
|
|
8
8
|
*/
|
|
9
|
-
import type { ActivationCredentialStatus, HarnessConnectAs, HarnessRunAs, IntegrationConnectionFacts, IntegrationRuntime, OAuthConnectionStatus } from '../../api-types.js';
|
|
10
|
-
export type { ActivationCredentialStatus, HarnessConnectAs, HarnessRunAs, OAuthConnectionStatus, };
|
|
9
|
+
import type { ActivationCredentialStatus, HarnessConnectAs, HarnessRunAs, IntegrationConnectionFacts, IntegrationRuntime, OAuthConnectionStatus, PackageNaming } from '../../api-types.js';
|
|
10
|
+
export type { ActivationCredentialStatus, PackageNaming, HarnessConnectAs, HarnessRunAs, OAuthConnectionStatus, };
|
|
11
11
|
export type JsonSchema = {
|
|
12
12
|
[key: string]: unknown;
|
|
13
13
|
};
|
|
@@ -123,6 +123,8 @@ export interface ConsoleProject {
|
|
|
123
123
|
};
|
|
124
124
|
/** The repo's integration also registers widgets/tile/activation surfaces. */
|
|
125
125
|
legacySurfaces?: boolean;
|
|
126
|
+
/** How the project's own package is named when it publishes. */
|
|
127
|
+
naming?: PackageNaming;
|
|
126
128
|
}
|
|
127
129
|
export interface RunRecord {
|
|
128
130
|
id: string;
|
|
@@ -11,6 +11,11 @@ export declare function usePublishSnapshot(): import("@tanstack/react-query").Us
|
|
|
11
11
|
}, Error>;
|
|
12
12
|
/** Ask `ekanos dev` for a fresh read; the polled files pick it up a moment later. */
|
|
13
13
|
export declare function useRefreshHostData(): import("@tanstack/react-query").UseMutationResult<void, Error, void, unknown>;
|
|
14
|
+
/**
|
|
15
|
+
* Point the harness at another of the developer's Sources: `ekanos dev`
|
|
16
|
+
* re-reads the catalog and publish status for it a moment later.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useSelectSource(): import("@tanstack/react-query").UseMutationResult<void, Error, string, unknown>;
|
|
14
19
|
export type PublishTone = 'clear' | 'success' | 'warning' | 'destructive' | 'info' | 'neutral';
|
|
15
20
|
export declare function describePublishState(state: string): {
|
|
16
21
|
label: string;
|
|
@@ -50,6 +50,29 @@ function useRefreshHostData() {
|
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
+
function useSelectSource() {
|
|
54
|
+
const queryClient = useQueryClient();
|
|
55
|
+
return useMutation({
|
|
56
|
+
mutationFn: async (source) => {
|
|
57
|
+
const response = await fetch(`${HOST_API}/source`, {
|
|
58
|
+
method: "POST",
|
|
59
|
+
headers: { "content-type": "application/json" },
|
|
60
|
+
body: JSON.stringify({ source })
|
|
61
|
+
});
|
|
62
|
+
if (!response.ok) {
|
|
63
|
+
const body = await response.json().catch(() => null);
|
|
64
|
+
throw new Error(body?.error ?? `Switching answered ${response.status}`);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
onSuccess: () => {
|
|
68
|
+
for (const delay of [1500, 4e3]) {
|
|
69
|
+
setTimeout(() => {
|
|
70
|
+
void queryClient.invalidateQueries({ queryKey: ["host"] });
|
|
71
|
+
}, delay);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
53
76
|
const STATE_WORDS = {
|
|
54
77
|
submitted: {
|
|
55
78
|
label: "Waiting for checks",
|
|
@@ -155,5 +178,6 @@ export {
|
|
|
155
178
|
sortVersions,
|
|
156
179
|
useCatalogSnapshot,
|
|
157
180
|
usePublishSnapshot,
|
|
158
|
-
useRefreshHostData
|
|
181
|
+
useRefreshHostData,
|
|
182
|
+
useSelectSource
|
|
159
183
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { PublishedPackage } from '@ekanos/integration-schema';
|
|
2
|
+
import type { PackageNaming } from './console-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Whether a local package is a global package (`news`) or named under a
|
|
5
|
+
* namespace (`acme/news`), in words. The host's answer for a published package
|
|
6
|
+
* wins over what the files declare, because the host may keep an older name
|
|
7
|
+
* (a package admitted under its bare slug stays global). An older host that
|
|
8
|
+
* sends no `namespace` leaves the declaration in charge.
|
|
9
|
+
*/
|
|
10
|
+
export interface NameScope {
|
|
11
|
+
scope: 'global' | 'namespaced';
|
|
12
|
+
/** Null when namespaced under a namespace nothing local names. */
|
|
13
|
+
namespace: string | null;
|
|
14
|
+
/** What an experience writes to name it: `acme/news`, or `news`. */
|
|
15
|
+
displayName: string;
|
|
16
|
+
/** Short chip text. */
|
|
17
|
+
label: string;
|
|
18
|
+
/** One or two sentences: what decided it, and what it means. */
|
|
19
|
+
detail: string;
|
|
20
|
+
/** The host said so (published), rather than the files declaring it. */
|
|
21
|
+
confirmed: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function describeNameScope({ name, published, declared, }: {
|
|
24
|
+
/** The package's bare slug (a namespaced form is accepted and stripped). */
|
|
25
|
+
name: string;
|
|
26
|
+
published?: PublishedPackage | null;
|
|
27
|
+
declared?: PackageNaming | null;
|
|
28
|
+
}): NameScope | null;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const VISIBILITY_NOTE = "Which Sources can see it is set separately, by Ekanos.";
|
|
2
|
+
function describeNameScope({
|
|
3
|
+
name,
|
|
4
|
+
published,
|
|
5
|
+
declared
|
|
6
|
+
}) {
|
|
7
|
+
const slug = name.slice(name.lastIndexOf("/") + 1);
|
|
8
|
+
if (published && published.namespace !== void 0) {
|
|
9
|
+
const namespace2 = published.namespace;
|
|
10
|
+
if (namespace2 === null) {
|
|
11
|
+
return {
|
|
12
|
+
scope: "global",
|
|
13
|
+
namespace: null,
|
|
14
|
+
displayName: slug,
|
|
15
|
+
label: "Global",
|
|
16
|
+
detail: `Published under the global name ${slug}, with no namespace. ${VISIBILITY_NOTE}`,
|
|
17
|
+
confirmed: true
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const displayName2 = `${namespace2}/${slug}`;
|
|
21
|
+
return {
|
|
22
|
+
scope: "namespaced",
|
|
23
|
+
namespace: namespace2,
|
|
24
|
+
displayName: displayName2,
|
|
25
|
+
label: `Namespaced \xB7 ${namespace2}`,
|
|
26
|
+
detail: `Published as ${displayName2}, under your Source's namespace. Experiences name it ${displayName2}. ${VISIBILITY_NOTE}`,
|
|
27
|
+
confirmed: true
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (!declared) return null;
|
|
31
|
+
if (declared.availability === "global") {
|
|
32
|
+
return {
|
|
33
|
+
scope: "global",
|
|
34
|
+
namespace: null,
|
|
35
|
+
displayName: slug,
|
|
36
|
+
label: "Global",
|
|
37
|
+
detail: `ekanos.json sets availability.mode "global", so it publishes under the global name ${slug}. That needs an approved name first: ekanos names claim ${slug}. ${VISIBILITY_NOTE}`,
|
|
38
|
+
confirmed: false
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const namespace = declared.namespace;
|
|
42
|
+
const displayName = namespace ? `${namespace}/${slug}` : slug;
|
|
43
|
+
return {
|
|
44
|
+
scope: "namespaced",
|
|
45
|
+
namespace,
|
|
46
|
+
displayName,
|
|
47
|
+
label: namespace ? `Namespaced \xB7 ${namespace}` : "Namespaced",
|
|
48
|
+
detail: `${namespace ? `Publishes as ${displayName}, under your Source's namespace.` : "Publishes under your Source's namespace."} That is the default; availability.mode "global" in ekanos.json publishes under a global name instead. ${VISIBILITY_NOTE}`,
|
|
49
|
+
confirmed: false
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
describeNameScope
|
|
54
|
+
};
|
|
@@ -19,6 +19,7 @@ import { RunLogCopyButton } from "../components/run-log-copy.js";
|
|
|
19
19
|
import { FOCUS_RING } from "../components/scrollable-nav.js";
|
|
20
20
|
import { SegmentedControl } from "../components/segmented-control.js";
|
|
21
21
|
import { ShellHeader } from "../components/shell-header.js";
|
|
22
|
+
import { SourceSwitcher } from "../components/source-switcher.js";
|
|
22
23
|
import {
|
|
23
24
|
catalogHref,
|
|
24
25
|
catalogPackageName,
|
|
@@ -93,10 +94,10 @@ function productReach(product) {
|
|
|
93
94
|
function scopeLine(snapshot) {
|
|
94
95
|
if (!snapshot) return null;
|
|
95
96
|
if (snapshot.scope === "source") {
|
|
96
|
-
return `Everything ${snapshot.source?.name ?? snapshot.source?.slug ?? "your Source"}
|
|
97
|
+
return `Everything global on Ekanos, plus what is attached to ${snapshot.source?.name ?? snapshot.source?.slug ?? "your Source"}, including what it has not turned on yet.`;
|
|
97
98
|
}
|
|
98
99
|
if (snapshot.scope === "public") {
|
|
99
|
-
return "Everything
|
|
100
|
+
return snapshot.seats?.length ? "Everything global on Ekanos. Pick one of your Sources to add what is attached to it." : "Everything global on Ekanos. Log in with a Source to see what is attached to it too.";
|
|
100
101
|
}
|
|
101
102
|
return null;
|
|
102
103
|
}
|
|
@@ -135,6 +136,7 @@ function CatalogPage() {
|
|
|
135
136
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
136
137
|
/* @__PURE__ */ jsx("h2", { className: "font-heading text-xl font-normal", children: "Integrations and experiences to build on" }),
|
|
137
138
|
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm", children: scopeLine(snapshot) }),
|
|
139
|
+
/* @__PURE__ */ jsx(SourceSwitcher, { snapshot }),
|
|
138
140
|
/* @__PURE__ */ jsx(HostFreshness, { fetchedAt: snapshot.fetchedAt, host: snapshot.host })
|
|
139
141
|
] }),
|
|
140
142
|
snapshot.unavailable ? /* @__PURE__ */ jsx(Alert, { variant: "warning", "data-test": "catalog-unavailable", children: /* @__PURE__ */ jsx(AlertDescription, { children: snapshot.unavailable.message }) }) : null,
|
|
@@ -148,7 +148,8 @@ function ExperienceSummaryPage() {
|
|
|
148
148
|
LatestPublishLine,
|
|
149
149
|
{
|
|
150
150
|
name: project.data.name,
|
|
151
|
-
href: `${links.experience}/publishes
|
|
151
|
+
href: `${links.experience}/publishes`,
|
|
152
|
+
naming: project.data.naming
|
|
152
153
|
}
|
|
153
154
|
),
|
|
154
155
|
/* @__PURE__ */ jsxs("section", { className: "flex flex-col gap-3", children: [
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
import { OverviewSkeleton } from "../components/integration-tab-skeletons.js";
|
|
19
19
|
import { LatestPublishLine } from "../components/publish-status.js";
|
|
20
20
|
import { CONNECTION_KIND_LABEL } from "../lib/connection-facts.js";
|
|
21
|
-
import { useConnection, useRuns } from "../lib/console-hooks.js";
|
|
21
|
+
import { useConnection, useProject, useRuns } from "../lib/console-hooks.js";
|
|
22
22
|
import {
|
|
23
23
|
hasHealthCheck,
|
|
24
24
|
healthKey,
|
|
@@ -169,6 +169,7 @@ function Overview({
|
|
|
169
169
|
const slug = integration.integration;
|
|
170
170
|
const connection = useConnection(slug);
|
|
171
171
|
const runs = useRuns();
|
|
172
|
+
const project = useProject();
|
|
172
173
|
const health = useQuery({
|
|
173
174
|
queryKey: healthKey(slug),
|
|
174
175
|
queryFn: () => null,
|
|
@@ -199,7 +200,14 @@ function Overview({
|
|
|
199
200
|
slug
|
|
200
201
|
});
|
|
201
202
|
return /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col gap-6", "data-test": "overview", children: [
|
|
202
|
-
base ? /* @__PURE__ */ jsx(
|
|
203
|
+
base ? /* @__PURE__ */ jsx(
|
|
204
|
+
LatestPublishLine,
|
|
205
|
+
{
|
|
206
|
+
name: slug,
|
|
207
|
+
href: `${base}/publishes`,
|
|
208
|
+
...integration.own ? { naming: project.data?.naming } : {}
|
|
209
|
+
}
|
|
210
|
+
) : null,
|
|
203
211
|
next ? /* @__PURE__ */ jsx(NextAction, { next, base }) : connection.isError ? /* @__PURE__ */ jsxs("p", { className: "text-destructive text-sm", role: "alert", children: [
|
|
204
212
|
"Could not read the connection: ",
|
|
205
213
|
connection.error.message
|
|
@@ -11,7 +11,7 @@ import { cn } from "@ekanos/ui/utils";
|
|
|
11
11
|
import { useQueryClient } from "@tanstack/react-query";
|
|
12
12
|
import { ConnectControls } from "../components/connect-controls.js";
|
|
13
13
|
import { DocsLink } from "../components/docs-link.js";
|
|
14
|
-
import { PublishChip } from "../components/publish-status.js";
|
|
14
|
+
import { NameScopeBadge, PublishChip } from "../components/publish-status.js";
|
|
15
15
|
import {
|
|
16
16
|
CONNECTION_TYPE,
|
|
17
17
|
ConnectionStatusChip,
|
|
@@ -246,6 +246,7 @@ function IntegrationRow({
|
|
|
246
246
|
row.version
|
|
247
247
|
] }),
|
|
248
248
|
/* @__PURE__ */ jsx(PublishChip, { name: row.name }),
|
|
249
|
+
/* @__PURE__ */ jsx(NameScopeBadge, { name: row.name, naming: row.naming }),
|
|
249
250
|
row.contractVersion ? /* @__PURE__ */ jsxs(
|
|
250
251
|
"span",
|
|
251
252
|
{
|
|
@@ -376,7 +377,8 @@ function ExperienceRow({ row }) {
|
|
|
376
377
|
"v",
|
|
377
378
|
row.version
|
|
378
379
|
] }),
|
|
379
|
-
/* @__PURE__ */ jsx(PublishChip, { name: row.name })
|
|
380
|
+
/* @__PURE__ */ jsx(PublishChip, { name: row.name }),
|
|
381
|
+
/* @__PURE__ */ jsx(NameScopeBadge, { name: row.name, naming: row.naming })
|
|
380
382
|
] }),
|
|
381
383
|
row.error ? /* @__PURE__ */ jsx("p", { className: "text-destructive text-xs", children: row.error }) : null,
|
|
382
384
|
row.integrations.length > 0 ? /* @__PURE__ */ jsxs(
|
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
createFileFixtureSource,
|
|
43
43
|
runOperation
|
|
44
44
|
} from "./operation-runner.js";
|
|
45
|
+
import { readProjectNaming } from "./package-naming.js";
|
|
45
46
|
import { resolveProjectRoot } from "./project-root.js";
|
|
46
47
|
import { createRunLog } from "./run-log.js";
|
|
47
48
|
import { readSessionCatalog } from "./session-catalog.js";
|
|
@@ -340,7 +341,7 @@ function createEkanosApiRouter(partial = {}) {
|
|
|
340
341
|
const method = request.method.toUpperCase();
|
|
341
342
|
const [head, ...rest] = segments;
|
|
342
343
|
if (head === "host") {
|
|
343
|
-
const hosted = handleHostRoute(root.root, method, rest);
|
|
344
|
+
const hosted = await handleHostRoute(root.root, method, rest, request);
|
|
344
345
|
if (hosted) return hosted;
|
|
345
346
|
}
|
|
346
347
|
try {
|
|
@@ -348,8 +349,10 @@ function createEkanosApiRouter(partial = {}) {
|
|
|
348
349
|
if (method !== "GET")
|
|
349
350
|
return apiError(405, "method_not_allowed", "GET only.");
|
|
350
351
|
const state = await getResolution();
|
|
352
|
+
const naming = readProjectNaming(projectRoot());
|
|
351
353
|
const body = {
|
|
352
354
|
kind: state.kind,
|
|
355
|
+
...naming ? { naming } : {},
|
|
353
356
|
integrations: await Promise.all(
|
|
354
357
|
state.integrations.map(
|
|
355
358
|
async (integration) => toIntegrationView(integration, await runtimeOf(integration))
|
|
@@ -11,8 +11,19 @@ export declare function readPublishSnapshot(root: string): PublishStatusSnapshot
|
|
|
11
11
|
/** Ask the running `ekanos dev` for a fresh read of both snapshots. */
|
|
12
12
|
export declare function requestHostRefresh(root: string): void;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* Pick the Source the harness reads, among the seats `ekanos dev` last
|
|
15
|
+
* listed, and ask for a fresh read. The CLI checks the pick against the seats
|
|
16
|
+
* again and the host checks the seat itself; this only keeps a typo out.
|
|
17
17
|
*/
|
|
18
|
-
export declare function
|
|
18
|
+
export declare function selectSource(root: string, source: string): {
|
|
19
|
+
ok: true;
|
|
20
|
+
} | {
|
|
21
|
+
ok: false;
|
|
22
|
+
error: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* `GET host/catalog`, `GET host/publish-status`, `POST host/refresh`,
|
|
26
|
+
* `POST host/source` (`{ source }`), served from `root` (the project, or the
|
|
27
|
+
* repo root). Null for anything else, so the caller answers its own 404.
|
|
28
|
+
*/
|
|
29
|
+
export declare function handleHostRoute(root: string, method: string, rest: readonly string[], request?: Request): Promise<Response | null>;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CatalogSnapshotSchema,
|
|
3
|
-
PublishStatusSnapshotSchema
|
|
3
|
+
PublishStatusSnapshotSchema,
|
|
4
|
+
SourceSelectionSchema
|
|
4
5
|
} from "@ekanos/integration-schema";
|
|
5
6
|
import * as fs from "node:fs";
|
|
6
7
|
import * as path from "node:path";
|
|
7
8
|
const CATALOG_FILE = path.join(".ekanos", "catalog.json");
|
|
8
9
|
const PUBLISH_FILE = path.join(".ekanos", "publish-status.json");
|
|
9
10
|
const REFRESH_REQUEST = path.join(".ekanos", "refresh-request");
|
|
11
|
+
const SOURCE_SELECTION = path.join(".ekanos", "source-selection.json");
|
|
10
12
|
function readJson(root, file) {
|
|
11
13
|
try {
|
|
12
14
|
return JSON.parse(fs.readFileSync(path.join(root, file), "utf8"));
|
|
@@ -30,6 +32,20 @@ function requestHostRefresh(root) {
|
|
|
30
32
|
fs.writeFileSync(file, `${(/* @__PURE__ */ new Date()).toISOString()}
|
|
31
33
|
`);
|
|
32
34
|
}
|
|
35
|
+
function selectSource(root, source) {
|
|
36
|
+
const seats = readCatalogSnapshot(root)?.seats ?? [];
|
|
37
|
+
if (!seats.some((seat) => seat.slug === source)) {
|
|
38
|
+
return { ok: false, error: `You hold no seat on "${source}".` };
|
|
39
|
+
}
|
|
40
|
+
const file = path.join(root, SOURCE_SELECTION);
|
|
41
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
42
|
+
const temp = `${file}.tmp`;
|
|
43
|
+
fs.writeFileSync(temp, `${JSON.stringify({ source })}
|
|
44
|
+
`, { mode: 384 });
|
|
45
|
+
fs.renameSync(temp, file);
|
|
46
|
+
requestHostRefresh(root);
|
|
47
|
+
return { ok: true };
|
|
48
|
+
}
|
|
33
49
|
function json(body, status = 200) {
|
|
34
50
|
return new Response(JSON.stringify(body), {
|
|
35
51
|
status,
|
|
@@ -39,7 +55,7 @@ function json(body, status = 200) {
|
|
|
39
55
|
}
|
|
40
56
|
});
|
|
41
57
|
}
|
|
42
|
-
function handleHostRoute(root, method, rest) {
|
|
58
|
+
async function handleHostRoute(root, method, rest, request) {
|
|
43
59
|
const [name] = rest;
|
|
44
60
|
if (rest.length !== 1) return null;
|
|
45
61
|
if (name === "catalog") {
|
|
@@ -57,11 +73,28 @@ function handleHostRoute(root, method, rest) {
|
|
|
57
73
|
requestHostRefresh(root);
|
|
58
74
|
return json({ requested: true }, 202);
|
|
59
75
|
}
|
|
76
|
+
if (name === "source") {
|
|
77
|
+
if (method !== "POST") return json({ error: "POST only." }, 405);
|
|
78
|
+
let body = null;
|
|
79
|
+
try {
|
|
80
|
+
body = await request?.json();
|
|
81
|
+
} catch {
|
|
82
|
+
body = null;
|
|
83
|
+
}
|
|
84
|
+
const parsed = SourceSelectionSchema.safeParse(body);
|
|
85
|
+
if (!parsed.success) {
|
|
86
|
+
return json({ error: 'Send { "source": "<slug>" }.' }, 400);
|
|
87
|
+
}
|
|
88
|
+
const picked = selectSource(root, parsed.data.source);
|
|
89
|
+
if (!picked.ok) return json({ error: picked.error }, 400);
|
|
90
|
+
return json({ requested: true, source: parsed.data.source }, 202);
|
|
91
|
+
}
|
|
60
92
|
return null;
|
|
61
93
|
}
|
|
62
94
|
export {
|
|
63
95
|
handleHostRoute,
|
|
64
96
|
readCatalogSnapshot,
|
|
65
97
|
readPublishSnapshot,
|
|
66
|
-
requestHostRefresh
|
|
98
|
+
requestHostRefresh,
|
|
99
|
+
selectSource
|
|
67
100
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Availability } from '@ekanos/integration-schema/repo';
|
|
2
|
+
import type { PackageNaming } from '../../api-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* How a package publishes, from its `ekanos.json` and the repo around it. The
|
|
5
|
+
* namespace falls back to the package's own `source` (the Source slug a new
|
|
6
|
+
* Source's namespace defaults from), the same inference discovery makes for a
|
|
7
|
+
* repo.
|
|
8
|
+
*/
|
|
9
|
+
export declare function namingOf(pkg: {
|
|
10
|
+
ekanosJson: Record<string, unknown>;
|
|
11
|
+
availability?: Availability;
|
|
12
|
+
}, repoNamespace: string | null): PackageNaming;
|
|
13
|
+
/** {@link namingOf} for the project at `projectRoot`; null when it has no readable `ekanos.json`. */
|
|
14
|
+
export declare function readProjectNaming(projectRoot: string): PackageNaming | null;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { isValidNamespace } from "@ekanos/integration-schema";
|
|
2
|
+
import {
|
|
3
|
+
AvailabilitySchema
|
|
4
|
+
} from "@ekanos/integration-schema/repo";
|
|
5
|
+
import * as fs from "node:fs";
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
import { repoOf } from "./integration-resolver.js";
|
|
8
|
+
function namingOf(pkg, repoNamespace) {
|
|
9
|
+
const source = pkg.ekanosJson.source;
|
|
10
|
+
return {
|
|
11
|
+
availability: pkg.availability?.mode === "global" ? "global" : "restricted",
|
|
12
|
+
namespace: repoNamespace ?? (typeof source === "string" && isValidNamespace(source) ? source : null)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function readProjectNaming(projectRoot) {
|
|
16
|
+
let ekanosJson;
|
|
17
|
+
try {
|
|
18
|
+
const parsed = JSON.parse(
|
|
19
|
+
fs.readFileSync(path.join(projectRoot, "ekanos.json"), "utf8")
|
|
20
|
+
);
|
|
21
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
22
|
+
ekanosJson = parsed;
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (error.code === "ENOENT") return null;
|
|
25
|
+
console.error(
|
|
26
|
+
`[harness:naming] ${projectRoot}/ekanos.json could not be read`,
|
|
27
|
+
error
|
|
28
|
+
);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const availability = AvailabilitySchema.safeParse(ekanosJson.availability);
|
|
32
|
+
return namingOf(
|
|
33
|
+
{
|
|
34
|
+
ekanosJson,
|
|
35
|
+
...availability.success ? { availability: availability.data } : {}
|
|
36
|
+
},
|
|
37
|
+
repoOf(projectRoot)?.namespace ?? null
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
namingOf,
|
|
42
|
+
readProjectNaming
|
|
43
|
+
};
|
|
@@ -9,6 +9,7 @@ import { handleHostRoute } from "./host-snapshots.js";
|
|
|
9
9
|
import { getLiveStore } from "./live-context.js";
|
|
10
10
|
import { isLoopbackHost, loopbackRefusal } from "./loopback-guard.js";
|
|
11
11
|
import { hasStoredOauthConnection } from "./oauth-persistence.js";
|
|
12
|
+
import { namingOf } from "./package-naming.js";
|
|
12
13
|
import { readSessionCatalog } from "./session-catalog.js";
|
|
13
14
|
function json(body, init = {}) {
|
|
14
15
|
return new Response(JSON.stringify(body), {
|
|
@@ -264,13 +265,17 @@ function createRepoApiRouter(partial) {
|
|
|
264
265
|
for (const pkg of integrationPackages) {
|
|
265
266
|
const { row, connection } = await integrationRow(request, pkg);
|
|
266
267
|
connections.set(pkg.name, connection);
|
|
267
|
-
integrations.push(row);
|
|
268
|
+
integrations.push({ ...row, naming: namingOf(pkg, repo.namespace) });
|
|
268
269
|
}
|
|
269
270
|
const experiences = [];
|
|
270
271
|
for (const pkg of experiencePackages) {
|
|
271
|
-
|
|
272
|
-
|
|
272
|
+
const row = await experienceRow(
|
|
273
|
+
request,
|
|
274
|
+
pkg,
|
|
275
|
+
connections,
|
|
276
|
+
repoPackageName
|
|
273
277
|
);
|
|
278
|
+
experiences.push({ ...row, naming: namingOf(pkg, repo.namespace) });
|
|
274
279
|
}
|
|
275
280
|
for (const experience of experiences) {
|
|
276
281
|
for (const used of experience.integrations) {
|
|
@@ -325,10 +330,11 @@ function createRepoApiRouter(partial) {
|
|
|
325
330
|
const method = request.method.toUpperCase();
|
|
326
331
|
const [head, second, third, fourth] = segments;
|
|
327
332
|
if (head === "host") {
|
|
328
|
-
const hosted = handleHostRoute(
|
|
333
|
+
const hosted = await handleHostRoute(
|
|
329
334
|
partial.repoRoot,
|
|
330
335
|
method,
|
|
331
|
-
segments.slice(1)
|
|
336
|
+
segments.slice(1),
|
|
337
|
+
request
|
|
332
338
|
);
|
|
333
339
|
if (hosted) return hosted;
|
|
334
340
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ekanos/harness",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Ekanos integration dev harness — every surface of an integration rendered in real Ekanos chrome, from fixtures, with no Supabase or auth; and, in live mode, a real localhost OAuth loop over your own dev-app credentials.",
|
|
6
6
|
"homepage": "https://sdk.ekanos.dev/harness/overview",
|
|
@@ -72,13 +72,13 @@
|
|
|
72
72
|
"access": "public"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@ekanos/integration-schema": "0.
|
|
75
|
+
"@ekanos/integration-schema": "0.32.0",
|
|
76
76
|
"next-themes": "0.4.6",
|
|
77
77
|
"tw-animate-css": "1.4.0"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@ekanos/sdk": "0.
|
|
81
|
-
"@ekanos/ui": "0.
|
|
80
|
+
"@ekanos/sdk": "0.32.0",
|
|
81
|
+
"@ekanos/ui": "0.32.0",
|
|
82
82
|
"@kit/tsconfig": "0.1.0",
|
|
83
83
|
"@tailwindcss/postcss": "4.3.5",
|
|
84
84
|
"@tanstack/react-query": "5.107.1",
|
|
@@ -98,8 +98,8 @@
|
|
|
98
98
|
"zod": "4.6.7"
|
|
99
99
|
},
|
|
100
100
|
"peerDependencies": {
|
|
101
|
-
"@ekanos/sdk": "^0.
|
|
102
|
-
"@ekanos/ui": "^0.
|
|
101
|
+
"@ekanos/sdk": "^0.32.0",
|
|
102
|
+
"@ekanos/ui": "^0.32.0",
|
|
103
103
|
"@tanstack/react-query": "^5.101.4",
|
|
104
104
|
"next": "^16.0.0",
|
|
105
105
|
"next-intl": "^4.14.7",
|