@nurix/apollo 0.5.3 → 0.5.5
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/commands/search.js +3 -3
- package/dist/index.js +27 -2
- package/dist/lib/apollo_client.js +4 -11
- package/package.json +5 -2
package/dist/commands/search.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// the Apollo Directory. `apollo search <kw>` searches the apps users built (the
|
|
3
3
|
// headline); `apollo search services <kw>` searches the services registry. Both
|
|
4
4
|
// support --json (raw results for agents), --category/--type, and --limit.
|
|
5
|
-
import {
|
|
5
|
+
import { resolveApolloUrl, searchApps, searchCatalogue, } from "../lib/apollo_client.js";
|
|
6
6
|
// `apollo search <keywords...>` — apps (the headline).
|
|
7
7
|
export async function runSearch(keywords, options, globals) {
|
|
8
8
|
const query = keywords.join(" ").trim();
|
|
@@ -11,8 +11,8 @@ export async function runSearch(keywords, options, globals) {
|
|
|
11
11
|
process.exitCode = 1;
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
|
-
const
|
|
15
|
-
const results = await searchApps(
|
|
14
|
+
const baseUrl = resolveApolloUrl(globals);
|
|
15
|
+
const results = await searchApps(baseUrl, query, { category: options.category, limit: options.limit });
|
|
16
16
|
if (options.json) {
|
|
17
17
|
console.log(JSON.stringify(results, null, 2));
|
|
18
18
|
return;
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,6 @@ program
|
|
|
24
24
|
.description("Bootstrap NuStack services into your repo via the Apollo discovery plane.")
|
|
25
25
|
.version(version)
|
|
26
26
|
.option("--apollo-url <url>", "Apollo base URL (defaults to $APOLLO_URL, then the hosted instance)")
|
|
27
|
-
.option("--admin-url <url>", "Apollo base URL for app search (defaults to $APOLLO_ADMIN_URL, then the hosted Apollo instance)")
|
|
28
27
|
// Bare `apollo`: bootstrap — check sign-in, login if needed, then init.
|
|
29
28
|
.action(async () => runBootstrap(program.opts()));
|
|
30
29
|
program.addHelpText("after", "\nRun `apollo` with no command to bootstrap: it checks your sign-in, runs login if needed, then init.");
|
|
@@ -103,4 +102,30 @@ search
|
|
|
103
102
|
.option("--type <type>", "filter services by type")
|
|
104
103
|
.option("--limit <n>", "max results (default 20)", toLimit)
|
|
105
104
|
.action(async (keywords, options) => runSearchServices(keywords, options, program.opts()));
|
|
106
|
-
|
|
105
|
+
// Translate an unexpected throw (mostly network failures from the read-only
|
|
106
|
+
// commands that call the client directly) into a single clean stderr line —
|
|
107
|
+
// never a raw Node stack trace. Interactive commands frame their own errors.
|
|
108
|
+
function describeError(error) {
|
|
109
|
+
const cause = error?.cause;
|
|
110
|
+
const code = cause?.code;
|
|
111
|
+
if (code === "ENOTFOUND" || code === "EAI_AGAIN") {
|
|
112
|
+
return "couldn't resolve the Apollo host — check your connection or pass --apollo-url.";
|
|
113
|
+
}
|
|
114
|
+
if (code === "ECONNREFUSED") {
|
|
115
|
+
return "the Apollo host refused the connection — is it up? Override with --apollo-url.";
|
|
116
|
+
}
|
|
117
|
+
if (error instanceof Error && (error.name === "TimeoutError" || error.name === "AbortError")) {
|
|
118
|
+
return "the request to Apollo timed out — check your connection or try again.";
|
|
119
|
+
}
|
|
120
|
+
if (error instanceof Error && error.message === "fetch failed") {
|
|
121
|
+
return "couldn't reach Apollo — check your connection or pass --apollo-url.";
|
|
122
|
+
}
|
|
123
|
+
return error instanceof Error ? error.message : String(error);
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
await program.parseAsync(process.argv);
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
console.error(`apollo: ${describeError(error)}`);
|
|
130
|
+
process.exitCode = 1;
|
|
131
|
+
}
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
// packages/cli/src/lib/apollo_client.ts - HTTP client for the Apollo discovery
|
|
2
2
|
// plane: catalogue fetch + credential exchange + key validation.
|
|
3
|
-
const DEFAULT_APOLLO_URL = "https://apollo.
|
|
4
|
-
// App search now lives on the merged Apollo worker (same origin as everything
|
|
5
|
-
// else); there is no separate admin host.
|
|
6
|
-
const DEFAULT_ADMIN_URL = "https://apollo.nurix-ai.co";
|
|
3
|
+
const DEFAULT_APOLLO_URL = "https://apollo.nustack.tech";
|
|
7
4
|
const REQUEST_TIMEOUT_MS = 10_000;
|
|
8
5
|
// Resolve the Apollo base URL: --apollo-url flag > APOLLO_URL env > hosted default.
|
|
9
6
|
export function resolveApolloUrl(options) {
|
|
10
7
|
return (options.apolloUrl ?? process.env.APOLLO_URL ?? DEFAULT_APOLLO_URL).replace(/\/+$/, "");
|
|
11
8
|
}
|
|
12
|
-
// Resolve the admin base URL (app search): --admin-url > APOLLO_ADMIN_URL > hosted admin.
|
|
13
|
-
export function resolveAdminUrl(options) {
|
|
14
|
-
return (options.adminUrl ?? process.env.APOLLO_ADMIN_URL ?? DEFAULT_ADMIN_URL).replace(/\/+$/, "");
|
|
15
|
-
}
|
|
16
9
|
// Fetch the public discovery catalogue.
|
|
17
10
|
export async function fetchCatalogue(baseUrl) {
|
|
18
11
|
const response = await fetch(`${baseUrl}/api/catalog.json`, {
|
|
@@ -66,9 +59,9 @@ export async function fetchBrokeredCredential(baseUrl, appKey, service) {
|
|
|
66
59
|
return { url: payload.url ?? null, key: payload.key, meta: payload.meta ?? null };
|
|
67
60
|
}
|
|
68
61
|
// Search published marketplace apps by keyword — the Apollo Directory headline.
|
|
69
|
-
// Extends
|
|
70
|
-
export async function searchApps(
|
|
71
|
-
const url = new URL(`${
|
|
62
|
+
// Extends the apollo Worker's public GET /api/v2/apps with ?q= (the `{ data }` envelope).
|
|
63
|
+
export async function searchApps(baseUrl, query, opts = {}) {
|
|
64
|
+
const url = new URL(`${baseUrl}/api/v2/apps`);
|
|
72
65
|
url.searchParams.set("q", query);
|
|
73
66
|
if (opts.category)
|
|
74
67
|
url.searchParams.set("category", opts.category);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nurix/apollo",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "The apollo CLI — bootstrap NuStack services into a repo via the Apollo discovery plane.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
"build": "tsc && node scripts/copy_schema.mjs",
|
|
24
24
|
"dev": "tsc --watch",
|
|
25
25
|
"typecheck": "tsc --noEmit",
|
|
26
|
+
"test": "vitest run",
|
|
27
|
+
"test:watch": "vitest",
|
|
26
28
|
"prepublishOnly": "npm run build"
|
|
27
29
|
},
|
|
28
30
|
"dependencies": {
|
|
@@ -33,7 +35,8 @@
|
|
|
33
35
|
},
|
|
34
36
|
"devDependencies": {
|
|
35
37
|
"@types/node": "^22.10.0",
|
|
36
|
-
"typescript": "catalog:"
|
|
38
|
+
"typescript": "catalog:",
|
|
39
|
+
"vitest": "latest"
|
|
37
40
|
},
|
|
38
41
|
"publishConfig": {
|
|
39
42
|
"access": "restricted"
|