@tracken/cli 0.0.0-stage → 0.2.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/CHANGELOG.md +404 -0
- package/LICENSE +21 -0
- package/README.md +310 -2
- package/dist/bin/tracken.d.ts +2 -0
- package/dist/bin/tracken.js +5 -0
- package/dist/cli/args.d.ts +17 -0
- package/dist/cli/args.js +114 -0
- package/dist/cli/commands/api.d.ts +2 -0
- package/dist/cli/commands/api.js +73 -0
- package/dist/cli/commands/auth.d.ts +8 -0
- package/dist/cli/commands/auth.js +141 -0
- package/dist/cli/commands/mcp.d.ts +19 -0
- package/dist/cli/commands/mcp.js +89 -0
- package/dist/cli/commands/org.d.ts +24 -0
- package/dist/cli/commands/org.js +123 -0
- package/dist/cli/context.d.ts +54 -0
- package/dist/cli/context.js +135 -0
- package/dist/cli/execute.d.ts +16 -0
- package/dist/cli/execute.js +112 -0
- package/dist/cli/help.d.ts +8 -0
- package/dist/cli/help.js +153 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +114 -0
- package/dist/cli/operation-args.d.ts +25 -0
- package/dist/cli/operation-args.js +245 -0
- package/dist/core/auth/oauth.d.ts +39 -0
- package/dist/core/auth/oauth.js +102 -0
- package/dist/core/auth/scopes.d.ts +19 -0
- package/dist/core/auth/scopes.js +49 -0
- package/dist/core/auth/secret-store.d.ts +60 -0
- package/dist/core/auth/secret-store.js +141 -0
- package/dist/core/auth/session.d.ts +75 -0
- package/dist/core/auth/session.js +200 -0
- package/dist/core/catalog.d.ts +12 -0
- package/dist/core/catalog.js +33 -0
- package/dist/core/client.d.ts +22 -0
- package/dist/core/client.js +45 -0
- package/dist/core/config.d.ts +27 -0
- package/dist/core/config.js +109 -0
- package/dist/core/environments.d.ts +21 -0
- package/dist/core/environments.js +53 -0
- package/dist/core/errors.d.ts +96 -0
- package/dist/core/errors.js +248 -0
- package/dist/core/index.d.ts +21 -0
- package/dist/core/index.js +22 -0
- package/dist/core/jobs.d.ts +15 -0
- package/dist/core/jobs.js +19 -0
- package/dist/core/operations.d.ts +108 -0
- package/dist/core/operations.js +7 -0
- package/dist/core/output/format.d.ts +19 -0
- package/dist/core/output/format.js +62 -0
- package/dist/core/output/render.d.ts +53 -0
- package/dist/core/output/render.js +229 -0
- package/dist/core/pagination.d.ts +2 -0
- package/dist/core/pagination.js +3 -0
- package/dist/core/request.d.ts +29 -0
- package/dist/core/request.js +109 -0
- package/dist/core/version.d.ts +10 -0
- package/dist/core/version.js +13 -0
- package/dist/generated/mcp-tools.d.ts +2 -0
- package/dist/generated/mcp-tools.js +5937 -0
- package/dist/generated/operations.d.ts +4 -0
- package/dist/generated/operations.js +17701 -0
- package/dist/mcp/errors.d.ts +34 -0
- package/dist/mcp/errors.js +100 -0
- package/dist/mcp/live.d.ts +3 -0
- package/dist/mcp/live.js +5 -0
- package/dist/mcp/prompts.d.ts +23 -0
- package/dist/mcp/prompts.js +101 -0
- package/dist/mcp/resources.d.ts +25 -0
- package/dist/mcp/resources.js +125 -0
- package/dist/mcp/server.d.ts +20 -0
- package/dist/mcp/server.js +59 -0
- package/dist/mcp/session.d.ts +60 -0
- package/dist/mcp/session.js +105 -0
- package/dist/mcp/tools.d.ts +17 -0
- package/dist/mcp/tools.js +181 -0
- package/dist/mcp/types.d.ts +25 -0
- package/dist/mcp/types.js +2 -0
- package/node_modules/@tracken/sdk/LICENSE +21 -0
- package/node_modules/@tracken/sdk/README.md +76 -0
- package/node_modules/@tracken/sdk/SOURCE.json +10 -0
- package/node_modules/@tracken/sdk/dist/client.d.ts +94 -0
- package/node_modules/@tracken/sdk/dist/client.js +258 -0
- package/node_modules/@tracken/sdk/dist/credentials.d.ts +60 -0
- package/node_modules/@tracken/sdk/dist/credentials.js +122 -0
- package/node_modules/@tracken/sdk/dist/decimal.d.ts +20 -0
- package/node_modules/@tracken/sdk/dist/decimal.js +67 -0
- package/node_modules/@tracken/sdk/dist/environments.d.ts +14 -0
- package/node_modules/@tracken/sdk/dist/environments.js +16 -0
- package/node_modules/@tracken/sdk/dist/errors.d.ts +150 -0
- package/node_modules/@tracken/sdk/dist/errors.js +190 -0
- package/node_modules/@tracken/sdk/dist/generated/operations.d.ts +1955 -0
- package/node_modules/@tracken/sdk/dist/generated/operations.js +2746 -0
- package/node_modules/@tracken/sdk/dist/generated/schema.d.ts +17988 -0
- package/node_modules/@tracken/sdk/dist/generated/schema.js +5 -0
- package/node_modules/@tracken/sdk/dist/index.d.ts +27 -0
- package/node_modules/@tracken/sdk/dist/index.js +24 -0
- package/node_modules/@tracken/sdk/dist/jobs.d.ts +23 -0
- package/node_modules/@tracken/sdk/dist/jobs.js +80 -0
- package/node_modules/@tracken/sdk/dist/operations.d.ts +23 -0
- package/node_modules/@tracken/sdk/dist/operations.js +2 -0
- package/node_modules/@tracken/sdk/dist/pagination.d.ts +19 -0
- package/node_modules/@tracken/sdk/dist/pagination.js +49 -0
- package/node_modules/@tracken/sdk/dist/request.d.ts +27 -0
- package/node_modules/@tracken/sdk/dist/request.js +10 -0
- package/node_modules/@tracken/sdk/dist/runtime.d.ts +22 -0
- package/node_modules/@tracken/sdk/dist/runtime.js +33 -0
- package/node_modules/@tracken/sdk/dist/tracken.d.ts +74 -0
- package/node_modules/@tracken/sdk/dist/tracken.js +203 -0
- package/node_modules/@tracken/sdk/dist/types.d.ts +130 -0
- package/node_modules/@tracken/sdk/dist/types.js +1 -0
- package/node_modules/@tracken/sdk/dist/version.d.ts +2 -0
- package/node_modules/@tracken/sdk/dist/version.js +2 -0
- package/node_modules/@tracken/sdk/package.json +42 -0
- package/node_modules/openapi-fetch/CHANGELOG.md +565 -0
- package/node_modules/openapi-fetch/CONTRIBUTING.md +102 -0
- package/node_modules/openapi-fetch/LICENSE +21 -0
- package/node_modules/openapi-fetch/README.md +122 -0
- package/node_modules/openapi-fetch/dist/index.cjs +547 -0
- package/node_modules/openapi-fetch/dist/index.cjs.map +1 -0
- package/node_modules/openapi-fetch/dist/index.d.cts +337 -0
- package/node_modules/openapi-fetch/dist/index.d.mts +335 -0
- package/node_modules/openapi-fetch/dist/index.d.ts +337 -0
- package/node_modules/openapi-fetch/dist/index.mjs +531 -0
- package/node_modules/openapi-fetch/dist/index.mjs.map +1 -0
- package/node_modules/openapi-fetch/package.json +77 -0
- package/node_modules/openapi-fetch/src/index.d.ts +345 -0
- package/node_modules/openapi-fetch/src/index.js +689 -0
- package/node_modules/openapi-typescript-helpers/CHANGELOG.md +98 -0
- package/node_modules/openapi-typescript-helpers/LICENSE +21 -0
- package/node_modules/openapi-typescript-helpers/README.md +5 -0
- package/node_modules/openapi-typescript-helpers/dist/index.cjs +3 -0
- package/node_modules/openapi-typescript-helpers/dist/index.cjs.map +1 -0
- package/node_modules/openapi-typescript-helpers/dist/index.d.cts +167 -0
- package/node_modules/openapi-typescript-helpers/dist/index.d.mts +167 -0
- package/node_modules/openapi-typescript-helpers/dist/index.d.ts +167 -0
- package/node_modules/openapi-typescript-helpers/dist/index.mjs +2 -0
- package/node_modules/openapi-typescript-helpers/dist/index.mjs.map +1 -0
- package/node_modules/openapi-typescript-helpers/package.json +39 -0
- package/openapi/SOURCE.json +10 -0
- package/openapi/openapi.yaml +30514 -0
- package/package.json +63 -4
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/** `tracken login`, `tracken logout`, `tracken whoami`. */
|
|
2
|
+
import { pollDeviceToken, requestDeviceAuthorization, revokeToken } from "../../core/auth/oauth.js";
|
|
3
|
+
import { apiScopesOf, describeSessionClass, IDENTITY_SCOPES, READ_SCOPE, sessionClass, validateScopes, writeScopes } from "../../core/auth/scopes.js";
|
|
4
|
+
import { machineCredentialFromEnv, sessionFromTokens } from "../../core/auth/session.js";
|
|
5
|
+
import { CliError, UsageError } from "../../core/errors.js";
|
|
6
|
+
import { formatDateTime } from "../../core/output/format.js";
|
|
7
|
+
import { chooseOrganizationAfterLogin, fetchPrincipal } from "./org.js";
|
|
8
|
+
function requestedScopes(context) {
|
|
9
|
+
const named = [...context.args.values("scope"), ...context.args.positionals.slice(1)].flatMap((entry) => entry.split(/[\s,]+/)).filter(Boolean);
|
|
10
|
+
if (named.length > 0) {
|
|
11
|
+
if (context.args.switch("write"))
|
|
12
|
+
throw new UsageError("Give --write or --scope, not both.");
|
|
13
|
+
return validateScopes(named);
|
|
14
|
+
}
|
|
15
|
+
if (context.args.positionals.length > 1)
|
|
16
|
+
throw new UsageError(`tracken login takes no arguments; scopes go after --scope.`);
|
|
17
|
+
return context.args.switch("write") ? writeScopes() : [READ_SCOPE];
|
|
18
|
+
}
|
|
19
|
+
export async function login(context) {
|
|
20
|
+
const unknown = context.args.others(["env", "org", "write", "scope", "help", "debug", "output"]);
|
|
21
|
+
if (unknown.length)
|
|
22
|
+
throw new UsageError(`Unknown flag --${unknown[0]} for tracken login.`);
|
|
23
|
+
const { environment, io } = context;
|
|
24
|
+
if (machineCredentialFromEnv(io.env)) {
|
|
25
|
+
context.warn("Note: TRACKEN_CLIENT_ID is set, so API calls use that machine credential, not this sign-in.");
|
|
26
|
+
}
|
|
27
|
+
const apiScopes = requestedScopes(context);
|
|
28
|
+
const scope = [...IDENTITY_SCOPES, ...apiScopes].join(" ");
|
|
29
|
+
const authorization = await requestDeviceAuthorization(environment, scope, io.fetch);
|
|
30
|
+
const where = environment.name === "prod" ? "Tracken" : `Tracken (${environment.name})`;
|
|
31
|
+
context.warn([
|
|
32
|
+
`To sign in to ${where}, open this page in a browser:`,
|
|
33
|
+
"",
|
|
34
|
+
` ${authorization.verification_uri_complete ?? authorization.verification_uri}`,
|
|
35
|
+
"",
|
|
36
|
+
`and confirm the code ${authorization.user_code}${authorization.verification_uri_complete ? "" : ` at ${authorization.verification_uri}`}.`,
|
|
37
|
+
`Asking for: ${apiScopes.join(" ")} (${describeSessionClass(sessionClass(apiScopes))}).`,
|
|
38
|
+
`Waiting for confirmation (the code is valid ${Math.round(authorization.expires_in / 60)} minutes)…`,
|
|
39
|
+
].join("\n"));
|
|
40
|
+
const tokens = await pollDeviceToken(environment, authorization, {
|
|
41
|
+
fetch: io.fetch,
|
|
42
|
+
clock: io.clock,
|
|
43
|
+
onSlowDown: (interval) => context.args.switch("debug") && context.warn(` Tracken ID asked to poll every ${interval} s.`),
|
|
44
|
+
});
|
|
45
|
+
const manager = await context.sessions();
|
|
46
|
+
const previous = await manager.load();
|
|
47
|
+
const session = sessionFromTokens(environment, tokens, io.clock.now(), undefined, scope);
|
|
48
|
+
await manager.save(session);
|
|
49
|
+
// The new session replaces the old one; its refresh token is revoked so no chain outlives the swap.
|
|
50
|
+
if (previous?.refresh_token && previous.refresh_token !== session.refresh_token) {
|
|
51
|
+
await revokeToken(environment, previous.refresh_token, "refresh_token", io.fetch).catch(() => undefined);
|
|
52
|
+
}
|
|
53
|
+
const granted = apiScopesOf(session.scope);
|
|
54
|
+
const who = session.email ?? session.name ?? session.subject ?? "you";
|
|
55
|
+
context.warn(`Signed in to ${environment.name} as ${who} with ${granted.join(" ") || "no API scope"} (${describeSessionClass(sessionClass(granted))}).`);
|
|
56
|
+
if (manager.store.kind === "file")
|
|
57
|
+
context.warn(`The session is kept in ${manager.store.location}.`);
|
|
58
|
+
await chooseOrganizationAfterLogin(context);
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
61
|
+
export async function logout(context) {
|
|
62
|
+
const { environment, io } = context;
|
|
63
|
+
const manager = await context.sessions();
|
|
64
|
+
const session = await manager.load();
|
|
65
|
+
if (!session) {
|
|
66
|
+
context.warn(`Not signed in to ${environment.name}.`);
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
if (session.refresh_token) {
|
|
70
|
+
try {
|
|
71
|
+
await revokeToken(environment, session.refresh_token, "refresh_token", io.fetch);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
context.warn(`Warning: Tracken ID did not confirm the revocation (${error.message}); the session is forgotten here regardless.`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
await manager.clear();
|
|
78
|
+
await context.config.setOrganization(environment.name, undefined);
|
|
79
|
+
context.warn(`Signed out of ${environment.name}.`);
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
/** What the API says about the credentials (`whoami --verify`), in whoami's two-column form. */
|
|
83
|
+
function principalLines(principal, sentOrganization, timeZone) {
|
|
84
|
+
const lines = ["", "The API says:", `Type: ${principal.type}`];
|
|
85
|
+
const credential = principal.credential;
|
|
86
|
+
if (credential) {
|
|
87
|
+
const terms = [
|
|
88
|
+
credential.authentication ? `by ${credential.authentication === "public_key" ? "signed assertion" : "secret"}` : "",
|
|
89
|
+
credential.expires_at ? `expires ${formatDateTime(credential.expires_at, timeZone)}` : "no expiry",
|
|
90
|
+
credential.idle_days ? `disabled after ${credential.idle_days} days unused` : "",
|
|
91
|
+
].filter(Boolean);
|
|
92
|
+
lines.push(`Credential: ${credential.client_id}${credential.name ? ` "${credential.name}"` : ""} (${terms.join("; ")})`);
|
|
93
|
+
}
|
|
94
|
+
if (principal.user)
|
|
95
|
+
lines.push(`Person: ${principal.user.email}${principal.user.role ? ` (${principal.user.role} here)` : ""}`);
|
|
96
|
+
const named = principal.organization_id ? principal.organizations.find((organization) => organization.id === principal.organization_id)?.name : undefined;
|
|
97
|
+
lines.push(`Organization: ${principal.organization_id
|
|
98
|
+
? `${principal.organization_id}${named ? ` (${named})` : ""}`
|
|
99
|
+
: sentOrganization
|
|
100
|
+
? `${sentOrganization} cannot be opened by this person; run \`tracken org list\``
|
|
101
|
+
: "none sent"}`);
|
|
102
|
+
lines.push(`Scopes: ${principal.scopes.length ? principal.scopes.join(" ") : "none named (not narrowed)"}`);
|
|
103
|
+
if (principal.type === "user")
|
|
104
|
+
lines.push(`Can open: ${principal.organizations.length} organization${principal.organizations.length === 1 ? "" : "s"}`);
|
|
105
|
+
return lines;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Which environment, credential, scopes and organization the next command uses: local facts, with
|
|
109
|
+
* no API call, unless `--verify` asks the API (getCurrentUser) to confirm them.
|
|
110
|
+
*/
|
|
111
|
+
export async function whoami(context) {
|
|
112
|
+
const { environment, io } = context;
|
|
113
|
+
const lines = [`Environment: ${environment.name} (${environment.apiBaseUrl})`];
|
|
114
|
+
const machine = machineCredentialFromEnv(io.env);
|
|
115
|
+
if (machine) {
|
|
116
|
+
lines.push(`Credential: machine ${machine.clientId} (TRACKEN_CLIENT_ID)`, `Scopes: ${machine.scope ?? "all the credential holds"}`);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
const session = await (await context.sessions()).load();
|
|
120
|
+
if (!session) {
|
|
121
|
+
lines.push(`Credential: none; run \`tracken login${environment.name === "prod" ? "" : ` --env ${environment.name}`}\``);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
const granted = apiScopesOf(session.scope);
|
|
125
|
+
lines.push(`Signed in as: ${session.email ?? session.name ?? session.subject ?? "unknown"}`, `Scopes: ${granted.join(" ")} (${describeSessionClass(sessionClass(granted))})`, `Token until: ${formatDateTime(new Date(session.expires_at).toISOString(), io.timeZone)} (refreshed automatically)`);
|
|
126
|
+
}
|
|
127
|
+
const organization = await context.organizationId();
|
|
128
|
+
const chosen = await context.config.organization(environment.name);
|
|
129
|
+
lines.push(`Organization: ${organization ? `${organization}${chosen?.id === organization && chosen.name ? ` (${chosen.name})` : ""}` : "none; run `tracken org list`"}`);
|
|
130
|
+
}
|
|
131
|
+
if (context.args.switch("verify")) {
|
|
132
|
+
const sent = machine ? undefined : await context.organizationId();
|
|
133
|
+
const { principal } = await fetchPrincipal(context, machine ? undefined : (sent ?? null));
|
|
134
|
+
if (!principal)
|
|
135
|
+
throw new CliError("The API's getCurrentUser answer is not a principal; see `tracken users get-me -o json`.");
|
|
136
|
+
lines.push(...principalLines(principal, sent, io.timeZone));
|
|
137
|
+
}
|
|
138
|
+
io.stdout.write(`${lines.join("\n")}\n`);
|
|
139
|
+
return 0;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Context } from "../context.js";
|
|
2
|
+
export declare const CONFIG_CLIENTS: readonly ["claude", "cursor", "vscode"];
|
|
3
|
+
export type ConfigClient = (typeof CONFIG_CLIENTS)[number];
|
|
4
|
+
export interface Launcher {
|
|
5
|
+
command: string;
|
|
6
|
+
args: string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* How a client should start this CLI: the running Node and script by absolute path when it runs
|
|
10
|
+
* from its built JavaScript (desktop apps do not see the shell's PATH), else `tracken` on PATH.
|
|
11
|
+
*/
|
|
12
|
+
export declare function currentLauncher(execPath?: string, script?: string | undefined): Launcher;
|
|
13
|
+
/**
|
|
14
|
+
* The client's configuration. Claude Code (`.mcp.json`), Claude Desktop (`claude_desktop_config.json`)
|
|
15
|
+
* and Cursor (`.cursor/mcp.json`) read `mcpServers`; VS Code (`.vscode/mcp.json`) reads `servers`
|
|
16
|
+
* with an explicit `type`. No credential is ever written into it: the server reads the session.
|
|
17
|
+
*/
|
|
18
|
+
export declare function clientConfig(client: ConfigClient, launcher: Launcher, serverArgs: string[]): Record<string, unknown>;
|
|
19
|
+
export declare function mcp(context: Context): Promise<number>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `tracken mcp`: the local MCP server on stdio, acting with the CLI's session (or the machine
|
|
3
|
+
* credential in the environment). `--print-config claude|cursor|vscode` prints what to paste into
|
|
4
|
+
* a client instead. While serving, stdout carries only the protocol; notes go to stderr.
|
|
5
|
+
*/
|
|
6
|
+
import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
|
|
7
|
+
import { UsageError } from "../../core/errors.js";
|
|
8
|
+
import { McpSession } from "../../mcp/session.js";
|
|
9
|
+
import { createMcpServer } from "../../mcp/server.js";
|
|
10
|
+
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
11
|
+
export const CONFIG_CLIENTS = ["claude", "cursor", "vscode"];
|
|
12
|
+
/**
|
|
13
|
+
* How a client should start this CLI: the running Node and script by absolute path when it runs
|
|
14
|
+
* from its built JavaScript (desktop apps do not see the shell's PATH), else `tracken` on PATH.
|
|
15
|
+
*/
|
|
16
|
+
export function currentLauncher(execPath = process.execPath, script = process.argv[1]) {
|
|
17
|
+
return script && /\.[cm]?js$/.test(script) ? { command: execPath, args: [script] } : { command: "tracken", args: [] };
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The client's configuration. Claude Code (`.mcp.json`), Claude Desktop (`claude_desktop_config.json`)
|
|
21
|
+
* and Cursor (`.cursor/mcp.json`) read `mcpServers`; VS Code (`.vscode/mcp.json`) reads `servers`
|
|
22
|
+
* with an explicit `type`. No credential is ever written into it: the server reads the session.
|
|
23
|
+
*/
|
|
24
|
+
export function clientConfig(client, launcher, serverArgs) {
|
|
25
|
+
const entry = { command: launcher.command, args: [...launcher.args, "mcp", ...serverArgs] };
|
|
26
|
+
if (client === "vscode")
|
|
27
|
+
return { servers: { tracken: { type: "stdio", ...entry } } };
|
|
28
|
+
return { mcpServers: { tracken: entry } };
|
|
29
|
+
}
|
|
30
|
+
const WHERE = {
|
|
31
|
+
claude: "Claude Code: save as .mcp.json in the project (or run `claude mcp add tracken -- <command> <args…>`). Claude Desktop: merge into claude_desktop_config.json (Settings → Developer → Edit Config).",
|
|
32
|
+
cursor: "Cursor: merge into .cursor/mcp.json in the project, or ~/.cursor/mcp.json for every project.",
|
|
33
|
+
vscode: "VS Code: merge into .vscode/mcp.json in the workspace (or run `MCP: Open User Configuration`).",
|
|
34
|
+
};
|
|
35
|
+
function organizationOverride(context) {
|
|
36
|
+
const value = context.args.value("org") ?? context.io.env.TRACKEN_ORG_ID ?? context.io.env.TRACKEN_ORG;
|
|
37
|
+
if (!value)
|
|
38
|
+
return undefined;
|
|
39
|
+
if (!UUID.test(value))
|
|
40
|
+
throw new UsageError(`--org must be an organization id (a UUID), not "${value}".`);
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
export async function mcp(context) {
|
|
44
|
+
const unknown = context.args.others(["env", "org", "print-config", "debug", "help"]);
|
|
45
|
+
if (unknown.length)
|
|
46
|
+
throw new UsageError(`Unknown flag --${unknown[0]} for tracken mcp.`);
|
|
47
|
+
if (context.args.positionals.length > 1)
|
|
48
|
+
throw new UsageError("tracken mcp takes no arguments.");
|
|
49
|
+
const organizationId = organizationOverride(context);
|
|
50
|
+
const printConfig = context.args.value("print-config");
|
|
51
|
+
if (printConfig !== undefined) {
|
|
52
|
+
if (!CONFIG_CLIENTS.includes(printConfig))
|
|
53
|
+
throw new UsageError(`--print-config takes one of ${CONFIG_CLIENTS.join(", ")}.`);
|
|
54
|
+
const serverArgs = [];
|
|
55
|
+
if (context.args.has("env") || context.io.env.TRACKEN_ENV)
|
|
56
|
+
serverArgs.push("--env", context.environment.name);
|
|
57
|
+
if (context.args.has("org") && organizationId)
|
|
58
|
+
serverArgs.push("--org", organizationId);
|
|
59
|
+
const config = clientConfig(printConfig, currentLauncher(), serverArgs);
|
|
60
|
+
context.io.stdout.write(`${JSON.stringify(config, null, 2)}\n`);
|
|
61
|
+
context.warn(WHERE[printConfig]);
|
|
62
|
+
return 0;
|
|
63
|
+
}
|
|
64
|
+
const session = new McpSession({
|
|
65
|
+
environment: context.environment,
|
|
66
|
+
env: context.io.env,
|
|
67
|
+
config: context.config,
|
|
68
|
+
openStore: () => context.store(),
|
|
69
|
+
fetch: context.io.fetch,
|
|
70
|
+
clock: context.io.clock,
|
|
71
|
+
organizationId,
|
|
72
|
+
language: context.language(),
|
|
73
|
+
debug: context.args.switch("debug") ? (line) => context.warn(line) : undefined,
|
|
74
|
+
});
|
|
75
|
+
const server = createMcpServer({ session });
|
|
76
|
+
const transport = new StdioServerTransport();
|
|
77
|
+
const closed = new Promise((resolve) => {
|
|
78
|
+
const previous = server.server.onclose;
|
|
79
|
+
server.server.onclose = () => {
|
|
80
|
+
previous?.();
|
|
81
|
+
resolve();
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
await server.connect(transport);
|
|
85
|
+
context.warn(`Tracken MCP server (${context.environment.name}) ready on stdio.`);
|
|
86
|
+
await closed;
|
|
87
|
+
return 0;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=mcp.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { components } from "@tracken/sdk";
|
|
2
|
+
import type { Context } from "../context.js";
|
|
3
|
+
export interface OrganizationEntry {
|
|
4
|
+
id: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
role?: string;
|
|
7
|
+
}
|
|
8
|
+
/** getCurrentUser's answer (`GET /users/me`). */
|
|
9
|
+
export type Principal = components["schemas"]["Principal"];
|
|
10
|
+
/** The Principal inside an answer; `undefined` when the API answered something else. */
|
|
11
|
+
export declare function principalOf(body: unknown): Principal | undefined;
|
|
12
|
+
/** The organizations in `getCurrentUser`'s answer: every one the person can open, with their role there. */
|
|
13
|
+
export declare function organizationsOf(body: unknown): OrganizationEntry[];
|
|
14
|
+
/**
|
|
15
|
+
* Who the API says the credentials are. `organization` is sent as X-Organization-ID: the answer's
|
|
16
|
+
* `organization_id` then names it only if the person can open it; `null` sends none.
|
|
17
|
+
*/
|
|
18
|
+
export declare function fetchPrincipal(context: Context, organization: string | null | undefined): Promise<{
|
|
19
|
+
body: unknown;
|
|
20
|
+
principal: Principal | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
/** After sign-in: keep a choice that is still valid, take the only organization, or say how to choose. */
|
|
23
|
+
export declare function chooseOrganizationAfterLogin(context: Context): Promise<void>;
|
|
24
|
+
export declare function org(context: Context): Promise<number>;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/** `tracken org list|use|current`: the organization a person's commands act in. */
|
|
2
|
+
import { operationById } from "../../core/catalog.js";
|
|
3
|
+
import { UsageError } from "../../core/errors.js";
|
|
4
|
+
import { renderTable } from "../../core/output/render.js";
|
|
5
|
+
import { buildRequest } from "../../core/request.js";
|
|
6
|
+
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
7
|
+
/** The Principal inside an answer; `undefined` when the API answered something else. */
|
|
8
|
+
export function principalOf(body) {
|
|
9
|
+
const data = body?.data;
|
|
10
|
+
return typeof data === "object" && data !== null && typeof data.type === "string" ? data : undefined;
|
|
11
|
+
}
|
|
12
|
+
/** The organizations in `getCurrentUser`'s answer: every one the person can open, with their role there. */
|
|
13
|
+
export function organizationsOf(body) {
|
|
14
|
+
const listed = body?.data?.organizations;
|
|
15
|
+
if (!Array.isArray(listed))
|
|
16
|
+
return [];
|
|
17
|
+
return listed
|
|
18
|
+
.filter((entry) => typeof entry === "object" && entry !== null && typeof entry.id === "string")
|
|
19
|
+
.map((entry) => {
|
|
20
|
+
const organization = { id: entry.id };
|
|
21
|
+
if (typeof entry.name === "string")
|
|
22
|
+
organization.name = entry.name;
|
|
23
|
+
if (typeof entry.role === "string")
|
|
24
|
+
organization.role = entry.role;
|
|
25
|
+
return organization;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Who the API says the credentials are. `organization` is sent as X-Organization-ID: the answer's
|
|
30
|
+
* `organization_id` then names it only if the person can open it; `null` sends none.
|
|
31
|
+
*/
|
|
32
|
+
export async function fetchPrincipal(context, organization) {
|
|
33
|
+
const client = await context.client();
|
|
34
|
+
const request = { ...buildRequest(operationById("getCurrentUser")), ...(organization === undefined ? {} : { organization }) };
|
|
35
|
+
const response = await client.send(request);
|
|
36
|
+
return { body: response.body, principal: principalOf(response.body) };
|
|
37
|
+
}
|
|
38
|
+
async function fetchOrganizations(context) {
|
|
39
|
+
if ((await context.credentials()).kind === "machine")
|
|
40
|
+
throw new UsageError("A machine credential belongs to one organization; there is nothing to choose.");
|
|
41
|
+
const { body } = await fetchPrincipal(context, null);
|
|
42
|
+
return { body, organizations: organizationsOf(body) };
|
|
43
|
+
}
|
|
44
|
+
/** After sign-in: keep a choice that is still valid, take the only organization, or say how to choose. */
|
|
45
|
+
export async function chooseOrganizationAfterLogin(context) {
|
|
46
|
+
const { environment } = context;
|
|
47
|
+
const env = environment.name === "prod" ? "" : ` --env ${environment.name}`;
|
|
48
|
+
let organizations;
|
|
49
|
+
try {
|
|
50
|
+
organizations = (await fetchOrganizations(context)).organizations;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
context.warn(`Could not list your organizations (${error.message.split("\n")[0]}); choose one later with \`tracken org use <id>${env}\`.`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const chosen = await context.config.organization(environment.name);
|
|
57
|
+
if (chosen && organizations.some((organization) => organization.id === chosen.id)) {
|
|
58
|
+
context.warn(`Acting in ${chosen.name ?? chosen.id}.`);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (organizations.length === 1) {
|
|
62
|
+
const only = organizations[0];
|
|
63
|
+
await context.config.setOrganization(environment.name, only.name ? { id: only.id, name: only.name } : { id: only.id });
|
|
64
|
+
context.warn(`Acting in ${only.name ?? only.id}.`);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
await context.config.setOrganization(environment.name, undefined);
|
|
68
|
+
context.warn(organizations.length === 0 ? "You belong to no organization yet." : `You belong to ${organizations.length} organizations; choose one with \`tracken org list${env}\` and \`tracken org use <id>${env}\`.`);
|
|
69
|
+
}
|
|
70
|
+
export async function org(context) {
|
|
71
|
+
const [, sub, id, ...extra] = context.args.positionals;
|
|
72
|
+
const { environment } = context;
|
|
73
|
+
if (extra.length)
|
|
74
|
+
throw new UsageError("tracken org takes at most one id.");
|
|
75
|
+
if (sub === "list" || sub === undefined) {
|
|
76
|
+
const { body, organizations } = await fetchOrganizations(context);
|
|
77
|
+
const mode = context.outputMode();
|
|
78
|
+
if (mode === "json") {
|
|
79
|
+
context.io.stdout.write(`${JSON.stringify(body, null, 2)}\n`);
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
if (mode === "ndjson") {
|
|
83
|
+
for (const organization of organizations)
|
|
84
|
+
context.io.stdout.write(`${JSON.stringify(organization)}\n`);
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
const current = (await context.config.organization(environment.name))?.id;
|
|
88
|
+
const rows = organizations.map((organization) => [organization.id === current ? "*" : "", organization.id, organization.name ?? "", organization.role ?? ""]);
|
|
89
|
+
context.io.stdout.write(mode === "csv"
|
|
90
|
+
? `current,id,name,role\n${rows.map((row) => row.map((cell) => (/[",\n]/.test(cell) ? `"${cell.replace(/"/g, '""')}"` : cell)).join(",")).join("\n")}\n`
|
|
91
|
+
: `${rows.length ? renderTable(["", "id", "name", "role"], rows) : "(none)"}\n`);
|
|
92
|
+
return 0;
|
|
93
|
+
}
|
|
94
|
+
if (sub === "current") {
|
|
95
|
+
const chosen = await context.config.organization(environment.name);
|
|
96
|
+
context.io.stdout.write(chosen ? `${chosen.id}${chosen.name ? ` ${chosen.name}` : ""}\n` : "");
|
|
97
|
+
if (!chosen)
|
|
98
|
+
context.warn("No organization chosen; run `tracken org list`.");
|
|
99
|
+
return chosen ? 0 : 1;
|
|
100
|
+
}
|
|
101
|
+
if (sub === "use") {
|
|
102
|
+
if (!id || !UUID.test(id))
|
|
103
|
+
throw new UsageError("tracken org use <id>: the organization's id, a UUID (see `tracken org list`).");
|
|
104
|
+
let name;
|
|
105
|
+
if (context.args.has("verify") ? context.args.switch("verify") : true) {
|
|
106
|
+
if ((await context.credentials()).kind === "machine")
|
|
107
|
+
throw new UsageError("A machine credential belongs to one organization; there is nothing to choose.");
|
|
108
|
+
// getCurrentUser names the organization only when the person can open it, and needs no
|
|
109
|
+
// scope, so a session narrowed to (say) contacts:read can choose its organization too.
|
|
110
|
+
const { principal } = await fetchPrincipal(context, id);
|
|
111
|
+
if (principal?.organization_id !== id) {
|
|
112
|
+
const env = environment.name === "prod" ? "" : ` --env ${environment.name}`;
|
|
113
|
+
throw new UsageError(`You cannot open the organization ${id} on ${environment.name}; \`tracken org list${env}\` shows the ones you can.`);
|
|
114
|
+
}
|
|
115
|
+
name = principal.organizations.find((organization) => organization.id === id)?.name;
|
|
116
|
+
}
|
|
117
|
+
await context.config.setOrganization(environment.name, name ? { id, name } : { id });
|
|
118
|
+
context.warn(`Acting in ${name ?? id} on ${environment.name}.`);
|
|
119
|
+
return 0;
|
|
120
|
+
}
|
|
121
|
+
throw new UsageError(`Unknown command tracken org ${sub}; use list, use <id> or current.`);
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=org.js.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type Clock, type Fetch } from "../core/auth/oauth.js";
|
|
2
|
+
import { type SecretStore } from "../core/auth/secret-store.js";
|
|
3
|
+
import { SessionManager, type Credentials } from "../core/auth/session.js";
|
|
4
|
+
import { TrackenClient } from "../core/client.js";
|
|
5
|
+
import { ConfigStore } from "../core/config.js";
|
|
6
|
+
import { type Environment } from "../core/environments.js";
|
|
7
|
+
import { type ErrorContext } from "../core/errors.js";
|
|
8
|
+
import { type OutputMode } from "../core/output/render.js";
|
|
9
|
+
import type { ParsedArgs } from "./args.js";
|
|
10
|
+
export interface Writable {
|
|
11
|
+
write(text: string | Uint8Array): unknown;
|
|
12
|
+
isTTY?: boolean | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface Io {
|
|
15
|
+
env: NodeJS.ProcessEnv;
|
|
16
|
+
stdout: Writable;
|
|
17
|
+
stderr: Writable;
|
|
18
|
+
readStdin(): Promise<Buffer>;
|
|
19
|
+
readFile(path: string): Promise<Buffer>;
|
|
20
|
+
writeFile(path: string, data: string | Uint8Array): Promise<void>;
|
|
21
|
+
fetch: Fetch;
|
|
22
|
+
clock: Clock;
|
|
23
|
+
/** Opens the secret store; tests pass a memory store or a fake keychain. */
|
|
24
|
+
openStore?: (directory: string, warn: (message: string) => void) => Promise<SecretStore>;
|
|
25
|
+
/** The time zone table output shows instants in; the machine's by default. */
|
|
26
|
+
timeZone?: string | undefined;
|
|
27
|
+
}
|
|
28
|
+
export declare function processIo(): Io;
|
|
29
|
+
export declare class Context {
|
|
30
|
+
readonly io: Io;
|
|
31
|
+
readonly args: ParsedArgs;
|
|
32
|
+
readonly environment: Environment;
|
|
33
|
+
readonly config: ConfigStore;
|
|
34
|
+
private storePromise;
|
|
35
|
+
private credentialsPromise;
|
|
36
|
+
/** The credentials once resolved, for error advice that must not resolve them itself. */
|
|
37
|
+
private resolved;
|
|
38
|
+
constructor(io: Io, args: ParsedArgs);
|
|
39
|
+
get directory(): string;
|
|
40
|
+
warn(message: string): void;
|
|
41
|
+
/** stdout is a terminal: default to table output and keep binary data off it. */
|
|
42
|
+
get interactive(): boolean;
|
|
43
|
+
outputMode(): OutputMode;
|
|
44
|
+
columns(): string[] | undefined;
|
|
45
|
+
store(): Promise<SecretStore>;
|
|
46
|
+
sessions(): Promise<SessionManager>;
|
|
47
|
+
credentials(): Promise<Credentials>;
|
|
48
|
+
/** `--org`, else `TRACKEN_ORG`, else the organization chosen with `tracken org use`. */
|
|
49
|
+
organizationId(): Promise<string | undefined>;
|
|
50
|
+
/** What an error message may say about where the command ran. */
|
|
51
|
+
errorContext(): ErrorContext;
|
|
52
|
+
language(): string | undefined;
|
|
53
|
+
client(): Promise<TrackenClient>;
|
|
54
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a command runs with: the process's streams and environment (injected, so tests run the whole
|
|
3
|
+
* CLI in-process against loopback fakes), the chosen environment and organization, and lazily the
|
|
4
|
+
* secret store, session and API client.
|
|
5
|
+
*/
|
|
6
|
+
import { readFile } from "node:fs/promises";
|
|
7
|
+
import { systemClock } from "../core/auth/oauth.js";
|
|
8
|
+
import { openSecretStore } from "../core/auth/secret-store.js";
|
|
9
|
+
import { apiScopesOf } from "../core/auth/scopes.js";
|
|
10
|
+
import { resolveCredentials, SessionManager, UserCredentials } from "../core/auth/session.js";
|
|
11
|
+
import { TrackenClient } from "../core/client.js";
|
|
12
|
+
import { ConfigStore, configDir } from "../core/config.js";
|
|
13
|
+
import { resolveEnvironment } from "../core/environments.js";
|
|
14
|
+
import { UsageError } from "../core/errors.js";
|
|
15
|
+
import { OUTPUT_MODES } from "../core/output/render.js";
|
|
16
|
+
export function processIo() {
|
|
17
|
+
return {
|
|
18
|
+
env: process.env,
|
|
19
|
+
stdout: process.stdout,
|
|
20
|
+
stderr: process.stderr,
|
|
21
|
+
readStdin: async () => {
|
|
22
|
+
const chunks = [];
|
|
23
|
+
for await (const chunk of process.stdin)
|
|
24
|
+
chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
25
|
+
return Buffer.concat(chunks);
|
|
26
|
+
},
|
|
27
|
+
readFile: (path) => readFile(path),
|
|
28
|
+
writeFile: async (path, data) => {
|
|
29
|
+
const { writeFile } = await import("node:fs/promises");
|
|
30
|
+
await writeFile(path, data);
|
|
31
|
+
},
|
|
32
|
+
fetch: (input, init) => fetch(input, init),
|
|
33
|
+
clock: systemClock,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
37
|
+
export class Context {
|
|
38
|
+
io;
|
|
39
|
+
args;
|
|
40
|
+
environment;
|
|
41
|
+
config;
|
|
42
|
+
storePromise;
|
|
43
|
+
credentialsPromise;
|
|
44
|
+
/** The credentials once resolved, for error advice that must not resolve them itself. */
|
|
45
|
+
resolved;
|
|
46
|
+
constructor(io, args) {
|
|
47
|
+
this.io = io;
|
|
48
|
+
this.args = args;
|
|
49
|
+
this.environment = resolveEnvironment(args.value("env"), io.env);
|
|
50
|
+
this.config = new ConfigStore(configDir(io.env));
|
|
51
|
+
}
|
|
52
|
+
get directory() {
|
|
53
|
+
return this.config.directory;
|
|
54
|
+
}
|
|
55
|
+
warn(message) {
|
|
56
|
+
this.io.stderr.write(`${message}\n`);
|
|
57
|
+
}
|
|
58
|
+
/** stdout is a terminal: default to table output and keep binary data off it. */
|
|
59
|
+
get interactive() {
|
|
60
|
+
return this.io.stdout.isTTY === true;
|
|
61
|
+
}
|
|
62
|
+
outputMode() {
|
|
63
|
+
if (this.args.switch("ndjson")) {
|
|
64
|
+
const named = this.args.value("output");
|
|
65
|
+
if (named !== undefined && named !== "ndjson")
|
|
66
|
+
throw new UsageError(`Give --ndjson or --output ${named}, not both.`);
|
|
67
|
+
return "ndjson";
|
|
68
|
+
}
|
|
69
|
+
const chosen = this.args.value("output") ?? this.io.env.TRACKEN_OUTPUT;
|
|
70
|
+
if (chosen === undefined || chosen === "")
|
|
71
|
+
return this.interactive ? "table" : "json";
|
|
72
|
+
if (!OUTPUT_MODES.includes(chosen))
|
|
73
|
+
throw new UsageError(`--output must be one of ${OUTPUT_MODES.join(", ")}.`);
|
|
74
|
+
return chosen;
|
|
75
|
+
}
|
|
76
|
+
columns() {
|
|
77
|
+
const value = this.args.value("columns");
|
|
78
|
+
return value ? value.split(",").map((column) => column.trim()).filter(Boolean) : undefined;
|
|
79
|
+
}
|
|
80
|
+
store() {
|
|
81
|
+
this.storePromise ??= this.io.openStore
|
|
82
|
+
? this.io.openStore(this.directory, (message) => this.warn(message))
|
|
83
|
+
: openSecretStore({ directory: this.directory, env: this.io.env, warn: (message) => this.warn(message) });
|
|
84
|
+
return this.storePromise;
|
|
85
|
+
}
|
|
86
|
+
async sessions() {
|
|
87
|
+
return new SessionManager(this.environment, await this.store(), this.directory, this.io.fetch, this.io.clock);
|
|
88
|
+
}
|
|
89
|
+
credentials() {
|
|
90
|
+
this.credentialsPromise ??= this.sessions()
|
|
91
|
+
.then((manager) => resolveCredentials({ environment: this.environment, env: this.io.env, manager, fetch: this.io.fetch, clock: this.io.clock }))
|
|
92
|
+
.then((credentials) => (this.resolved = credentials));
|
|
93
|
+
return this.credentialsPromise;
|
|
94
|
+
}
|
|
95
|
+
/** `--org`, else `TRACKEN_ORG`, else the organization chosen with `tracken org use`. */
|
|
96
|
+
async organizationId() {
|
|
97
|
+
const explicit = this.args.value("org") ?? this.io.env.TRACKEN_ORG;
|
|
98
|
+
if (explicit) {
|
|
99
|
+
if (!UUID.test(explicit))
|
|
100
|
+
throw new UsageError(`--org must be an organization id (a UUID), not "${explicit}".`);
|
|
101
|
+
return explicit;
|
|
102
|
+
}
|
|
103
|
+
return (await this.config.organization(this.environment.name))?.id;
|
|
104
|
+
}
|
|
105
|
+
/** What an error message may say about where the command ran. */
|
|
106
|
+
errorContext() {
|
|
107
|
+
const credentials = this.resolved;
|
|
108
|
+
return {
|
|
109
|
+
environment: this.environment.name,
|
|
110
|
+
credentials: credentials?.kind,
|
|
111
|
+
grantedScopes: credentials instanceof UserCredentials ? apiScopesOf(credentials.current.scope) : undefined,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
language() {
|
|
115
|
+
const locale = this.io.env.TRACKEN_LANG ?? this.io.env.LC_ALL ?? this.io.env.LANG ?? "";
|
|
116
|
+
return locale.toLowerCase().startsWith("et") ? "et" : locale ? "en" : undefined;
|
|
117
|
+
}
|
|
118
|
+
async client() {
|
|
119
|
+
const credentials = await this.credentials();
|
|
120
|
+
if (credentials.kind === "machine" && this.args.has("org")) {
|
|
121
|
+
this.warn("Note: a machine credential belongs to one organization; --org is ignored.");
|
|
122
|
+
}
|
|
123
|
+
return new TrackenClient({
|
|
124
|
+
baseUrl: this.environment.apiBaseUrl,
|
|
125
|
+
credentials,
|
|
126
|
+
organizationId: credentials.kind === "user" ? await this.organizationId() : undefined,
|
|
127
|
+
environmentName: this.environment.name,
|
|
128
|
+
fetch: this.io.fetch,
|
|
129
|
+
clock: this.io.clock,
|
|
130
|
+
language: this.language(),
|
|
131
|
+
debug: this.args.switch("debug") ? (line) => this.warn(line) : undefined,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sends a built request and prints its answer: `--all` pages through a list, `--wait` follows a
|
|
3
|
+
* 202 job, a dry run says whether the API confirmed it, binary renditions go to `--out` or a pipe.
|
|
4
|
+
*/
|
|
5
|
+
import type { TrackenClient } from "../core/client.js";
|
|
6
|
+
import type { DisplayHints } from "../core/operations.js";
|
|
7
|
+
import type { ApiRequest } from "../core/request.js";
|
|
8
|
+
import type { Context } from "./context.js";
|
|
9
|
+
export interface ExecuteOptions {
|
|
10
|
+
hints?: DisplayHints | undefined;
|
|
11
|
+
/** The request asked for `dry_run=true`. */
|
|
12
|
+
dryRun: boolean;
|
|
13
|
+
/** `--all` applies: the operation is paginated (or, for `tracken api`, may be). */
|
|
14
|
+
pageable: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function execute(context: Context, client: TrackenClient, request: ApiRequest, options: ExecuteOptions): Promise<void>;
|