sim 2.0.0-preview.11.1 → 2.0.0-preview.14.1
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 +2 -2
- package/dist/index.js +42 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Non-secret settings live in `~/.sim/config`:
|
|
|
20
20
|
|
|
21
21
|
```ini
|
|
22
22
|
[default]
|
|
23
|
-
endpoint = https://sim.ai
|
|
23
|
+
endpoint = https://www.sim.ai
|
|
24
24
|
workspace = ws_abc123
|
|
25
25
|
output = table
|
|
26
26
|
|
|
@@ -58,7 +58,7 @@ Each setting resolves independently, first match wins:
|
|
|
58
58
|
| 1 | Command-line flag (`--endpoint`, `--workspace`, `--output`) |
|
|
59
59
|
| 2 | Environment (`SIM_ENDPOINT`, `SIM_API_KEY`, `SIM_WORKSPACE`, `SIM_OUTPUT`) |
|
|
60
60
|
| 3 | `~/.sim/config` / `~/.sim/credentials` for the selected profile |
|
|
61
|
-
| 4 | Built-in default (`https://sim.ai`, `table`) |
|
|
61
|
+
| 4 | Built-in default (`https://www.sim.ai`, `table`) |
|
|
62
62
|
|
|
63
63
|
Formats are listed under [Output formats](#output-formats).
|
|
64
64
|
|
package/dist/index.js
CHANGED
|
@@ -2403,7 +2403,7 @@ function removeSection(doc, name) {
|
|
|
2403
2403
|
|
|
2404
2404
|
// src/config/profile.ts
|
|
2405
2405
|
var DEFAULT_PROFILE = "default";
|
|
2406
|
-
var DEFAULT_ENDPOINT = "https://sim.ai";
|
|
2406
|
+
var DEFAULT_ENDPOINT = "https://www.sim.ai";
|
|
2407
2407
|
var OUTPUT_FORMATS = ["table", "json", "yaml", "text"];
|
|
2408
2408
|
|
|
2409
2409
|
class ProfileConfigError extends Error {
|
|
@@ -2527,6 +2527,18 @@ function resolveProfile(overrides = {}) {
|
|
|
2527
2527
|
}
|
|
2528
2528
|
};
|
|
2529
2529
|
}
|
|
2530
|
+
// src/version.ts
|
|
2531
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
2532
|
+
function readPackageVersion() {
|
|
2533
|
+
const metadata = JSON.parse(readFileSync2(new URL("../package.json", import.meta.url), "utf8"));
|
|
2534
|
+
if (typeof metadata !== "object" || metadata === null || !("version" in metadata) || typeof metadata.version !== "string") {
|
|
2535
|
+
throw new Error("CLI package metadata is missing a valid version");
|
|
2536
|
+
}
|
|
2537
|
+
return metadata.version;
|
|
2538
|
+
}
|
|
2539
|
+
var CLI_VERSION = readPackageVersion();
|
|
2540
|
+
var USER_AGENT = `sim-cli/${CLI_VERSION} node/${process.versions.node} (${process.platform}; ${process.arch})`;
|
|
2541
|
+
|
|
2530
2542
|
// src/http/client.ts
|
|
2531
2543
|
class SimApiError extends Error {
|
|
2532
2544
|
status;
|
|
@@ -2551,7 +2563,10 @@ function buildUrl(endpoint, path, query) {
|
|
|
2551
2563
|
}
|
|
2552
2564
|
var REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);
|
|
2553
2565
|
var MARKUP_PREFIX = /^\s*<(?:!doctype|html|\?xml)/i;
|
|
2554
|
-
var
|
|
2566
|
+
var KEY_SCOPE_REFUSALS = new Set([
|
|
2567
|
+
"WORKSPACE_KEY_OPERATION_NOT_PERMITTED",
|
|
2568
|
+
"PRINCIPAL_KIND_NOT_PERMITTED"
|
|
2569
|
+
]);
|
|
2555
2570
|
function toNonJsonError(url, status, contentType, raw) {
|
|
2556
2571
|
const type = contentType?.split(";")[0]?.trim().toLowerCase();
|
|
2557
2572
|
const isMarkup = type === "text/html" || type === "application/xhtml+xml" || MARKUP_PREFIX.test(raw);
|
|
@@ -2583,13 +2598,14 @@ function toApiError(url, status, contentType, raw) {
|
|
|
2583
2598
|
function truncate(value, max) {
|
|
2584
2599
|
return value.length <= max ? value : `${value.slice(0, max)}…`;
|
|
2585
2600
|
}
|
|
2586
|
-
function
|
|
2587
|
-
if (error.code ===
|
|
2601
|
+
function namesKeyScopeRefusal(error) {
|
|
2602
|
+
if (typeof error.code === "string" && KEY_SCOPE_REFUSALS.has(error.code))
|
|
2588
2603
|
return true;
|
|
2589
2604
|
const details = error.details;
|
|
2590
2605
|
if (!details || typeof details !== "object")
|
|
2591
2606
|
return false;
|
|
2592
|
-
|
|
2607
|
+
const code = details.code;
|
|
2608
|
+
return typeof code === "string" && KEY_SCOPE_REFUSALS.has(code);
|
|
2593
2609
|
}
|
|
2594
2610
|
function isStrictPrefix(path, other) {
|
|
2595
2611
|
if (path.length >= other.length)
|
|
@@ -2697,6 +2713,7 @@ class SimClient {
|
|
|
2697
2713
|
headers: {
|
|
2698
2714
|
...apiKey ? { "x-api-key": apiKey } : {},
|
|
2699
2715
|
accept: "application/json",
|
|
2716
|
+
"user-agent": USER_AGENT,
|
|
2700
2717
|
...hasBody ? { "content-type": "application/json" } : {},
|
|
2701
2718
|
...options.headers
|
|
2702
2719
|
},
|
|
@@ -2718,7 +2735,7 @@ class SimClient {
|
|
|
2718
2735
|
if (response.status === 401) {
|
|
2719
2736
|
error.message = `${error.message} — run: sim login --profile ${this.profile.name}`;
|
|
2720
2737
|
}
|
|
2721
|
-
if (
|
|
2738
|
+
if (namesKeyScopeRefusal(error)) {
|
|
2722
2739
|
error.message = `${error.message} — this operation needs a personal API key: sim login --profile ${this.profile.name}`;
|
|
2723
2740
|
}
|
|
2724
2741
|
throw error;
|
|
@@ -6093,9 +6110,6 @@ function printRecord(format, fields, raw) {
|
|
|
6093
6110
|
}
|
|
6094
6111
|
}
|
|
6095
6112
|
|
|
6096
|
-
// src/program.ts
|
|
6097
|
-
import { readFileSync as readFileSync3 } from "node:fs";
|
|
6098
|
-
|
|
6099
6113
|
// ../../node_modules/commander/esm.mjs
|
|
6100
6114
|
var import__ = __toESM(require_commander(), 1);
|
|
6101
6115
|
var {
|
|
@@ -6182,7 +6196,11 @@ async function pollForKey(endpoint, auth, signal) {
|
|
|
6182
6196
|
try {
|
|
6183
6197
|
response = await fetch(new URL(POLL_PATH, endpoint), {
|
|
6184
6198
|
method: "POST",
|
|
6185
|
-
headers: {
|
|
6199
|
+
headers: {
|
|
6200
|
+
"content-type": "application/json",
|
|
6201
|
+
accept: "application/json",
|
|
6202
|
+
"user-agent": USER_AGENT
|
|
6203
|
+
},
|
|
6186
6204
|
body: JSON.stringify({ request: auth.request, verifier: auth.pollSecret }),
|
|
6187
6205
|
signal,
|
|
6188
6206
|
redirect: "manual"
|
|
@@ -9589,7 +9607,7 @@ function configureCommand() {
|
|
|
9589
9607
|
}
|
|
9590
9608
|
|
|
9591
9609
|
// src/runtime/request.ts
|
|
9592
|
-
import { existsSync as existsSync2, readFileSync as
|
|
9610
|
+
import { existsSync as existsSync2, readFileSync as readFileSync3, readSync } from "node:fs";
|
|
9593
9611
|
|
|
9594
9612
|
// src/contract/commands.ts
|
|
9595
9613
|
var TABLE_NAME_HELP = "Identifier: letters, numbers, and underscores; cannot start with a number";
|
|
@@ -9962,6 +9980,17 @@ var CLI_CONTRACT = {
|
|
|
9962
9980
|
{ header: "updated", path: "updatedAt", format: "timestamp" }
|
|
9963
9981
|
]
|
|
9964
9982
|
},
|
|
9983
|
+
listCredentialProviders: {
|
|
9984
|
+
columns: [
|
|
9985
|
+
{ header: "type" },
|
|
9986
|
+
{ header: "service", path: "serviceId" },
|
|
9987
|
+
{ header: "provider", path: "providerId" },
|
|
9988
|
+
{ header: "name" },
|
|
9989
|
+
{ header: "family", path: "providerFamily" },
|
|
9990
|
+
{ header: "available", format: "bool" },
|
|
9991
|
+
{ header: "description" }
|
|
9992
|
+
]
|
|
9993
|
+
},
|
|
9965
9994
|
listSecrets: {
|
|
9966
9995
|
columns: [
|
|
9967
9996
|
{ header: "name" },
|
|
@@ -10454,7 +10483,7 @@ function readArgumentSource(raw, flagName) {
|
|
|
10454
10483
|
}
|
|
10455
10484
|
}
|
|
10456
10485
|
try {
|
|
10457
|
-
return { text:
|
|
10486
|
+
return { text: readFileSync3(path, "utf8"), from: ` (read from ${path})` };
|
|
10458
10487
|
} catch (error) {
|
|
10459
10488
|
throw new SimApiError(`--${flagName} cannot read ${path}: ${error.message}`, 0);
|
|
10460
10489
|
}
|
|
@@ -12170,18 +12199,11 @@ Examples:
|
|
|
12170
12199
|
$ sim workflows import --workflow @wf.json
|
|
12171
12200
|
$ sim whoami --profile dev
|
|
12172
12201
|
`;
|
|
12173
|
-
function readPackageVersion() {
|
|
12174
|
-
const metadata = JSON.parse(readFileSync3(new URL("../package.json", import.meta.url), "utf8"));
|
|
12175
|
-
if (typeof metadata !== "object" || metadata === null || !("version" in metadata) || typeof metadata.version !== "string") {
|
|
12176
|
-
throw new Error("CLI package metadata is missing a valid version");
|
|
12177
|
-
}
|
|
12178
|
-
return metadata.version;
|
|
12179
|
-
}
|
|
12180
12202
|
function buildProgram(options = {}) {
|
|
12181
12203
|
const program2 = new Command;
|
|
12182
12204
|
program2.name("sim").description(PROGRAM_DESCRIPTION);
|
|
12183
12205
|
if (options.version !== false)
|
|
12184
|
-
program2.version(
|
|
12206
|
+
program2.version(CLI_VERSION);
|
|
12185
12207
|
program2.option("-P, --profile <name>", "Profile to use (env: SIM_PROFILE)").option("--endpoint <url>", "Sim deployment to talk to (env: SIM_ENDPOINT)").option("-w, --workspace <id>", "Workspace to target (env: SIM_WORKSPACE)").addOption(new Option("--output <format>", "Output format for this command").choices([...OUTPUT_FORMATS]));
|
|
12186
12208
|
program2.addCommand(loginCommand());
|
|
12187
12209
|
program2.addCommand(logoutCommand());
|