@ekanos/harness 0.29.0 → 0.31.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/host-freshness.d.ts +12 -0
- package/dist/internal/components/host-freshness.js +61 -0
- package/dist/internal/components/publish-status.d.ts +39 -0
- package/dist/internal/components/publish-status.js +363 -0
- package/dist/internal/components/shell-header.js +16 -0
- package/dist/internal/components/surface-nav.js +12 -0
- package/dist/internal/lib/console-client.js +2 -1
- package/dist/internal/lib/console-types.d.ts +4 -2
- package/dist/internal/lib/docs-links.d.ts +2 -0
- package/dist/internal/lib/docs-links.js +6 -1
- package/dist/internal/lib/host-data.d.ts +44 -0
- package/dist/internal/lib/host-data.js +159 -0
- 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.d.ts +15 -0
- package/dist/internal/routes/catalog-pages.js +425 -0
- package/dist/internal/routes/experience-summary-page.js +9 -0
- package/dist/internal/routes/integrations-overview-page.js +11 -1
- package/dist/internal/routes/publishes-pages.d.ts +4 -0
- package/dist/internal/routes/publishes-pages.js +19 -0
- package/dist/internal/routes/repo-home-page.js +7 -2
- package/dist/internal/server/ekanos-api-router.js +8 -0
- package/dist/internal/server/host-snapshots.d.ts +18 -0
- package/dist/internal/server/host-snapshots.js +67 -0
- 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 +17 -3
- package/dist/internal/server/session-catalog.d.ts +12 -0
- package/dist/routes.d.ts +7 -0
- package/dist/routes.js +14 -0
- package/package.json +7 -7
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { CatalogProduct, CatalogSnapshot, PublishStatusSnapshot, PublishedPackage, PublishedVersion } from '@ekanos/integration-schema';
|
|
2
|
+
export declare const HOST_KEYS: {
|
|
3
|
+
catalog: readonly ['host', 'catalog'];
|
|
4
|
+
publish: readonly ['host', 'publish-status'];
|
|
5
|
+
};
|
|
6
|
+
export declare function useCatalogSnapshot(): import("@tanstack/react-query").UseQueryResult<{
|
|
7
|
+
snapshot: CatalogSnapshot | null;
|
|
8
|
+
}, Error>;
|
|
9
|
+
export declare function usePublishSnapshot(): import("@tanstack/react-query").UseQueryResult<{
|
|
10
|
+
snapshot: PublishStatusSnapshot | null;
|
|
11
|
+
}, Error>;
|
|
12
|
+
/** Ask `ekanos dev` for a fresh read; the polled files pick it up a moment later. */
|
|
13
|
+
export declare function useRefreshHostData(): import("@tanstack/react-query").UseMutationResult<void, Error, void, unknown>;
|
|
14
|
+
export type PublishTone = 'clear' | 'success' | 'warning' | 'destructive' | 'info' | 'neutral';
|
|
15
|
+
export declare function describePublishState(state: string): {
|
|
16
|
+
label: string;
|
|
17
|
+
tone: PublishTone;
|
|
18
|
+
detail: string;
|
|
19
|
+
};
|
|
20
|
+
/** Newest first, by submission time, then version string. */
|
|
21
|
+
export declare function sortVersions(versions: readonly PublishedVersion[]): PublishedVersion[];
|
|
22
|
+
/**
|
|
23
|
+
* The published package for a local one. A namespaced package (`acme/news`)
|
|
24
|
+
* is published under its slug, so either form matches.
|
|
25
|
+
*/
|
|
26
|
+
export declare function findPublishedPackage(snapshot: PublishStatusSnapshot | null | undefined, name: string): PublishedPackage | null;
|
|
27
|
+
export type CatalogKindFilter = 'all' | 'integration' | 'experience';
|
|
28
|
+
export type CatalogAvailabilityFilter = 'all' | 'enabled' | 'available' | 'mine';
|
|
29
|
+
/**
|
|
30
|
+
* The products to show: integrations and experiences only (a Feature is part
|
|
31
|
+
* of the platform, not something to build on), matching every word of the
|
|
32
|
+
* query, ranked with name matches first.
|
|
33
|
+
*/
|
|
34
|
+
export declare function filterCatalog(products: readonly CatalogProduct[], filters: {
|
|
35
|
+
query: string;
|
|
36
|
+
kind: CatalogKindFilter;
|
|
37
|
+
availability: CatalogAvailabilityFilter;
|
|
38
|
+
}): CatalogProduct[];
|
|
39
|
+
/**
|
|
40
|
+
* The name a person reads and types for a catalog entry: a Source's own
|
|
41
|
+
* package is listed by its token (`acme__news`) and named `acme/news`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function catalogPackageName(slug: string): string;
|
|
44
|
+
export declare function catalogHref(slug: string): string;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { CONSOLE_API_BASE } from "./console-client.js";
|
|
4
|
+
const HOST_API = `${CONSOLE_API_BASE}/host`;
|
|
5
|
+
const POLL_MS = 5e3;
|
|
6
|
+
async function getJson(url) {
|
|
7
|
+
const response = await fetch(url, {
|
|
8
|
+
headers: { accept: "application/json" }
|
|
9
|
+
});
|
|
10
|
+
if (!response.ok) {
|
|
11
|
+
throw new Error(`${url} answered ${response.status}`);
|
|
12
|
+
}
|
|
13
|
+
return await response.json();
|
|
14
|
+
}
|
|
15
|
+
const HOST_KEYS = {
|
|
16
|
+
catalog: ["host", "catalog"],
|
|
17
|
+
publish: ["host", "publish-status"]
|
|
18
|
+
};
|
|
19
|
+
function useCatalogSnapshot() {
|
|
20
|
+
return useQuery({
|
|
21
|
+
queryKey: HOST_KEYS.catalog,
|
|
22
|
+
queryFn: () => getJson(`${HOST_API}/catalog`),
|
|
23
|
+
refetchInterval: POLL_MS
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function usePublishSnapshot() {
|
|
27
|
+
return useQuery({
|
|
28
|
+
queryKey: HOST_KEYS.publish,
|
|
29
|
+
queryFn: () => getJson(
|
|
30
|
+
`${HOST_API}/publish-status`
|
|
31
|
+
),
|
|
32
|
+
refetchInterval: POLL_MS
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function useRefreshHostData() {
|
|
36
|
+
const queryClient = useQueryClient();
|
|
37
|
+
return useMutation({
|
|
38
|
+
mutationFn: async () => {
|
|
39
|
+
const response = await fetch(`${HOST_API}/refresh`, { method: "POST" });
|
|
40
|
+
if (!response.ok) {
|
|
41
|
+
throw new Error(`Refresh answered ${response.status}`);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
onSuccess: () => {
|
|
45
|
+
for (const delay of [1500, 4e3]) {
|
|
46
|
+
setTimeout(() => {
|
|
47
|
+
void queryClient.invalidateQueries({ queryKey: ["host"] });
|
|
48
|
+
}, delay);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const STATE_WORDS = {
|
|
54
|
+
submitted: {
|
|
55
|
+
label: "Waiting for checks",
|
|
56
|
+
tone: "info",
|
|
57
|
+
detail: "Submitted. The checks have not run on it yet."
|
|
58
|
+
},
|
|
59
|
+
gated: {
|
|
60
|
+
label: "Passed checks",
|
|
61
|
+
tone: "info",
|
|
62
|
+
detail: "Passed the checks and is being admitted to dev."
|
|
63
|
+
},
|
|
64
|
+
dev: {
|
|
65
|
+
label: "Live on dev",
|
|
66
|
+
tone: "clear",
|
|
67
|
+
detail: "Live on dev, where Sources can turn it on."
|
|
68
|
+
},
|
|
69
|
+
prod: {
|
|
70
|
+
label: "Live in production",
|
|
71
|
+
tone: "clear",
|
|
72
|
+
detail: "Live in production."
|
|
73
|
+
},
|
|
74
|
+
rejected: {
|
|
75
|
+
label: "Failed checks",
|
|
76
|
+
tone: "destructive",
|
|
77
|
+
detail: "Failed the checks. Fix the errors below and publish a new version."
|
|
78
|
+
},
|
|
79
|
+
revoked: {
|
|
80
|
+
label: "Revoked",
|
|
81
|
+
tone: "destructive",
|
|
82
|
+
detail: "Withdrawn after it went live. The findings say why."
|
|
83
|
+
},
|
|
84
|
+
superseded: {
|
|
85
|
+
label: "Replaced",
|
|
86
|
+
tone: "neutral",
|
|
87
|
+
detail: "A newer version replaced it on dev."
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
function describePublishState(state) {
|
|
91
|
+
return STATE_WORDS[state] ?? {
|
|
92
|
+
label: state,
|
|
93
|
+
tone: "neutral",
|
|
94
|
+
detail: `The host reports "${state}".`
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function sortVersions(versions) {
|
|
98
|
+
return [...versions].sort((a, b) => {
|
|
99
|
+
const at = a.submittedAt ?? "";
|
|
100
|
+
const bt = b.submittedAt ?? "";
|
|
101
|
+
if (at !== bt) return bt.localeCompare(at);
|
|
102
|
+
return b.version.localeCompare(a.version, void 0, { numeric: true });
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function findPublishedPackage(snapshot, name) {
|
|
106
|
+
if (!snapshot) return null;
|
|
107
|
+
const slug = name.includes("/") ? name.slice(name.lastIndexOf("/") + 1) : name;
|
|
108
|
+
return snapshot.packages.find(
|
|
109
|
+
(pkg) => pkg.slug === slug || pkg.displayName === name || (pkg.namespace ? `${pkg.namespace}/${pkg.slug}` === name : false)
|
|
110
|
+
) ?? null;
|
|
111
|
+
}
|
|
112
|
+
function haystack(product) {
|
|
113
|
+
return [
|
|
114
|
+
product.slug,
|
|
115
|
+
product.name,
|
|
116
|
+
product.summary ?? "",
|
|
117
|
+
product.description ?? "",
|
|
118
|
+
...product.tools.flatMap((tool) => [tool.name, tool.description]),
|
|
119
|
+
...product.agentEvents.flatMap((event) => [event.label, event.description]),
|
|
120
|
+
...product.experience?.integrations.map((entry) => entry.name) ?? []
|
|
121
|
+
].join(" ").toLowerCase();
|
|
122
|
+
}
|
|
123
|
+
function filterCatalog(products, filters) {
|
|
124
|
+
const words = filters.query.toLowerCase().split(/\s+/).filter(Boolean);
|
|
125
|
+
const matches = products.filter((product) => {
|
|
126
|
+
if (product.kind === "feature") return false;
|
|
127
|
+
if (filters.kind !== "all" && product.kind !== filters.kind) return false;
|
|
128
|
+
if (filters.availability === "mine" && !product.owned) return false;
|
|
129
|
+
if ((filters.availability === "enabled" || filters.availability === "available") && product.availability !== filters.availability) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
if (words.length === 0) return true;
|
|
133
|
+
const text = haystack(product);
|
|
134
|
+
return words.every((word) => text.includes(word));
|
|
135
|
+
});
|
|
136
|
+
if (words.length === 0) return matches;
|
|
137
|
+
const nameHit = (product) => words.some(
|
|
138
|
+
(word) => `${product.name} ${product.slug}`.toLowerCase().includes(word)
|
|
139
|
+
) ? 0 : 1;
|
|
140
|
+
return [...matches].sort((a, b) => nameHit(a) - nameHit(b));
|
|
141
|
+
}
|
|
142
|
+
function catalogPackageName(slug) {
|
|
143
|
+
return slug.replace("__", "/");
|
|
144
|
+
}
|
|
145
|
+
function catalogHref(slug) {
|
|
146
|
+
return `/catalog/${encodeURIComponent(slug)}`;
|
|
147
|
+
}
|
|
148
|
+
export {
|
|
149
|
+
HOST_KEYS,
|
|
150
|
+
catalogHref,
|
|
151
|
+
catalogPackageName,
|
|
152
|
+
describePublishState,
|
|
153
|
+
filterCatalog,
|
|
154
|
+
findPublishedPackage,
|
|
155
|
+
sortVersions,
|
|
156
|
+
useCatalogSnapshot,
|
|
157
|
+
usePublishSnapshot,
|
|
158
|
+
useRefreshHostData
|
|
159
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { CatalogProduct } from '@ekanos/integration-schema';
|
|
3
|
+
/**
|
|
4
|
+
* The Catalog: the integrations and experiences a developer can build on,
|
|
5
|
+
* read from the host by `ekanos dev`. With a Source it is everything that
|
|
6
|
+
* Source can use, including what it has not turned on yet; without one it is
|
|
7
|
+
* everything global on the host.
|
|
8
|
+
*/
|
|
9
|
+
export declare function CatalogLayout({ children }: {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
12
|
+
/** One line on what a product offers to build on. */
|
|
13
|
+
export declare function productReach(product: CatalogProduct): string;
|
|
14
|
+
export declare function CatalogPage(): import("react").JSX.Element;
|
|
15
|
+
export declare function CatalogProductPage(): import("react").JSX.Element;
|