@topolo/cli 0.1.12 → 0.1.14
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/index.js +27 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { platform as platform2 } from "os";
|
|
|
9
9
|
import { createInterface } from "readline/promises";
|
|
10
10
|
import { stdin as input } from "process";
|
|
11
11
|
|
|
12
|
-
//
|
|
12
|
+
// ../packages/topolo-sdk/dist/index.js
|
|
13
13
|
function applyAuthHeaders(headers, credential) {
|
|
14
14
|
if (credential.kind === "api_key") {
|
|
15
15
|
headers.set("X-Api-Key", credential.apiKey);
|
|
@@ -1620,6 +1620,9 @@ import { mkdir, readFile, writeFile, chmod } from "fs/promises";
|
|
|
1620
1620
|
import { existsSync } from "fs";
|
|
1621
1621
|
import { homedir, platform } from "os";
|
|
1622
1622
|
import { dirname, join } from "path";
|
|
1623
|
+
var BUILTIN_SERVICE_URL_OVERRIDES = {
|
|
1624
|
+
one: "https://one.topolo.app"
|
|
1625
|
+
};
|
|
1623
1626
|
function configPath() {
|
|
1624
1627
|
const override = process.env.TOPOLO_CONFIG_PATH;
|
|
1625
1628
|
if (override) return override;
|
|
@@ -1690,7 +1693,10 @@ function resolveAgentName(configAgentName) {
|
|
|
1690
1693
|
return process.env.TOPOLO_AGENT_NAME ?? configAgentName;
|
|
1691
1694
|
}
|
|
1692
1695
|
function resolveServiceUrls(configUrls) {
|
|
1693
|
-
const merged = {
|
|
1696
|
+
const merged = {
|
|
1697
|
+
...BUILTIN_SERVICE_URL_OVERRIDES,
|
|
1698
|
+
...configUrls ?? {}
|
|
1699
|
+
};
|
|
1694
1700
|
for (const [k, v] of Object.entries(process.env)) {
|
|
1695
1701
|
if (k.startsWith("TOPOLO_SERVICE_URL_") && v) {
|
|
1696
1702
|
merged[k.slice("TOPOLO_SERVICE_URL_".length).toLowerCase()] = v;
|
|
@@ -1942,7 +1948,7 @@ function sleep(ms) {
|
|
|
1942
1948
|
}
|
|
1943
1949
|
|
|
1944
1950
|
// src/version.ts
|
|
1945
|
-
var CLI_VERSION = "0.1.
|
|
1951
|
+
var CLI_VERSION = "0.1.14";
|
|
1946
1952
|
|
|
1947
1953
|
// src/client.ts
|
|
1948
1954
|
async function buildClient(options) {
|
|
@@ -5074,7 +5080,9 @@ function resolvePlatformSurfaceModel(value) {
|
|
|
5074
5080
|
);
|
|
5075
5081
|
}
|
|
5076
5082
|
function isPlatformAdminIdentity(identity) {
|
|
5077
|
-
|
|
5083
|
+
const role = String(identity?.user?.role || "").trim().toLowerCase();
|
|
5084
|
+
const orgSlug = String(identity?.organization?.slug || "").trim().toLowerCase();
|
|
5085
|
+
return orgSlug === "admin" && (role === "platform_super_admin" || role === "platform_admin");
|
|
5078
5086
|
}
|
|
5079
5087
|
async function requirePlatformAdminSession() {
|
|
5080
5088
|
const client = await buildClient();
|
|
@@ -5093,25 +5101,29 @@ async function requirePlatformAdminSession() {
|
|
|
5093
5101
|
|
|
5094
5102
|
// src/commands/services.ts
|
|
5095
5103
|
function registerServicesCommand(program2) {
|
|
5096
|
-
program2.command("services").description("List every Topolo service the SDK can route to").option("--json", "Output JSON", true).option("--no-json", "Output human-readable table").action((opts) => {
|
|
5104
|
+
program2.command("services").description("List every Topolo service the SDK can route to").option("--json", "Output JSON", true).option("--no-json", "Output human-readable table").action(async (opts) => {
|
|
5097
5105
|
const mode = resolveOutputMode(opts.json);
|
|
5098
5106
|
try {
|
|
5099
|
-
const
|
|
5100
|
-
|
|
5101
|
-
const effectiveUrl = resolveServiceUrl(id);
|
|
5102
|
-
return {
|
|
5103
|
-
id,
|
|
5104
|
-
defaultUrl,
|
|
5105
|
-
effectiveUrl,
|
|
5106
|
-
overridden: defaultUrl !== effectiveUrl
|
|
5107
|
-
};
|
|
5108
|
-
});
|
|
5107
|
+
const config = await readConfig();
|
|
5108
|
+
const rows = buildRows(resolveServiceUrls(config.serviceUrls));
|
|
5109
5109
|
emit({ services: rows }, mode, () => formatRows2(rows));
|
|
5110
5110
|
} catch (err) {
|
|
5111
5111
|
fail(err, mode);
|
|
5112
5112
|
}
|
|
5113
5113
|
});
|
|
5114
5114
|
}
|
|
5115
|
+
function buildRows(overrides) {
|
|
5116
|
+
return Object.keys(DEFAULT_SERVICE_URLS).sort().map((id) => {
|
|
5117
|
+
const defaultUrl = DEFAULT_SERVICE_URLS[id];
|
|
5118
|
+
const effectiveUrl = resolveServiceUrl(id, overrides);
|
|
5119
|
+
return {
|
|
5120
|
+
id,
|
|
5121
|
+
defaultUrl,
|
|
5122
|
+
effectiveUrl,
|
|
5123
|
+
overridden: defaultUrl !== effectiveUrl
|
|
5124
|
+
};
|
|
5125
|
+
});
|
|
5126
|
+
}
|
|
5115
5127
|
function formatRows2(rows) {
|
|
5116
5128
|
const idWidth = Math.max(3, ...rows.map((r) => r.id.length));
|
|
5117
5129
|
const urlWidth = Math.max(7, ...rows.map((r) => r.effectiveUrl.length));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topolo/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"description": "Command-line interface for Topolo developers, operators, and agents, with internal first-party scaffolding available under the topolo platform namespace.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|