@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,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who the CLI acts as. A person signed in with `tracken login` (a session in the secret store,
|
|
3
|
+
* refreshed as it nears expiry and after a 401), or a machine credential from
|
|
4
|
+
* `TRACKEN_CLIENT_ID`/`TRACKEN_CLIENT_SECRET` (a client-credentials token kept in memory only).
|
|
5
|
+
*/
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { ClientCredentials, EXPIRY_SKEW_MS, TrackenAuthError, tokenExpiry } from "@tracken/sdk";
|
|
8
|
+
import { withFileLock } from "../config.js";
|
|
9
|
+
import { AuthError, OAuthError, UsageError } from "../errors.js";
|
|
10
|
+
import { userAgent } from "../version.js";
|
|
11
|
+
import { jwtClaims, refreshTokens } from "./oauth.js";
|
|
12
|
+
export function sessionFromTokens(environment, tokens, now, previous, requestedScope) {
|
|
13
|
+
const claims = { ...jwtClaims(tokens.id_token ?? ""), ...jwtClaims(tokens.access_token) };
|
|
14
|
+
const text = (value) => (typeof value === "string" && value ? value : undefined);
|
|
15
|
+
const session = {
|
|
16
|
+
version: 1,
|
|
17
|
+
environment: environment.name,
|
|
18
|
+
issuer: environment.issuer,
|
|
19
|
+
client_id: environment.cliClientId,
|
|
20
|
+
access_token: tokens.access_token,
|
|
21
|
+
expires_at: tokenExpiry(tokens, now),
|
|
22
|
+
scope: tokens.scope ?? previous?.scope ?? requestedScope ?? "",
|
|
23
|
+
obtained_at: previous?.obtained_at ?? now,
|
|
24
|
+
};
|
|
25
|
+
// Refresh tokens rotate: keep the new one; a response without one keeps the chain's last.
|
|
26
|
+
const refresh = tokens.refresh_token ?? previous?.refresh_token;
|
|
27
|
+
if (refresh)
|
|
28
|
+
session.refresh_token = refresh;
|
|
29
|
+
const subject = text(claims.sub) ?? previous?.subject;
|
|
30
|
+
if (subject)
|
|
31
|
+
session.subject = subject;
|
|
32
|
+
const email = text(claims.email) ?? previous?.email;
|
|
33
|
+
if (email)
|
|
34
|
+
session.email = email;
|
|
35
|
+
const name = text(claims.name) ?? previous?.name;
|
|
36
|
+
if (name)
|
|
37
|
+
session.name = name;
|
|
38
|
+
return session;
|
|
39
|
+
}
|
|
40
|
+
const loginCommand = (environment) => `tracken login${environment === "prod" ? "" : ` --env ${environment}`}`;
|
|
41
|
+
/** Loads, saves and refreshes the person's session for one environment. */
|
|
42
|
+
export class SessionManager {
|
|
43
|
+
environment;
|
|
44
|
+
store;
|
|
45
|
+
directory;
|
|
46
|
+
fetchFn;
|
|
47
|
+
clock;
|
|
48
|
+
key;
|
|
49
|
+
lockPath;
|
|
50
|
+
constructor(environment, store, directory, fetchFn, clock) {
|
|
51
|
+
this.environment = environment;
|
|
52
|
+
this.store = store;
|
|
53
|
+
this.directory = directory;
|
|
54
|
+
this.fetchFn = fetchFn;
|
|
55
|
+
this.clock = clock;
|
|
56
|
+
this.key = `session:${environment.name}`;
|
|
57
|
+
this.lockPath = join(directory, `refresh-${environment.name}.lock`);
|
|
58
|
+
}
|
|
59
|
+
async load() {
|
|
60
|
+
const raw = await this.store.get(this.key);
|
|
61
|
+
if (!raw)
|
|
62
|
+
return undefined;
|
|
63
|
+
try {
|
|
64
|
+
const session = JSON.parse(raw);
|
|
65
|
+
return session.version === 1 && typeof session.access_token === "string" ? session : undefined;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async save(session) {
|
|
72
|
+
await this.store.set(this.key, JSON.stringify(session));
|
|
73
|
+
}
|
|
74
|
+
async clear() {
|
|
75
|
+
await this.store.delete(this.key);
|
|
76
|
+
}
|
|
77
|
+
expiringSoon(session) {
|
|
78
|
+
return this.clock.now() >= session.expires_at - EXPIRY_SKEW_MS;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Refreshes under the lock, after re-reading the store: when another process already rotated the
|
|
82
|
+
* tokens, their result is used and the spent refresh token is never presented again (Tracken ID
|
|
83
|
+
* revokes the whole chain on reuse).
|
|
84
|
+
*/
|
|
85
|
+
async refresh(stale) {
|
|
86
|
+
return withFileLock(this.lockPath, this.directory, async () => {
|
|
87
|
+
const latest = await this.load();
|
|
88
|
+
if (!latest)
|
|
89
|
+
throw new AuthError(`Signed out of ${this.environment.name}; run \`${loginCommand(this.environment.name)}\`.`);
|
|
90
|
+
if (latest.access_token !== stale && !this.expiringSoon(latest))
|
|
91
|
+
return latest;
|
|
92
|
+
if (!latest.refresh_token) {
|
|
93
|
+
await this.clear();
|
|
94
|
+
throw new AuthError(`The ${this.environment.name} session has expired; run \`${loginCommand(this.environment.name)}\`.`);
|
|
95
|
+
}
|
|
96
|
+
let tokens;
|
|
97
|
+
try {
|
|
98
|
+
tokens = await refreshTokens(this.environment, latest.refresh_token, this.fetchFn);
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
// invalid_grant covers every way a CLI session ends at Tracken ID: the idle or absolute limit,
|
|
102
|
+
// a sign-out of the browser session that approved it, a revoked or reused refresh token.
|
|
103
|
+
if (error instanceof OAuthError && (error.error === "invalid_grant" || error.error === "invalid_client")) {
|
|
104
|
+
await this.clear();
|
|
105
|
+
throw new AuthError(`The ${this.environment.name} session has ended (time limit, a sign-out, or a revoked token); run \`${loginCommand(this.environment.name)}\`.`);
|
|
106
|
+
}
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
const next = sessionFromTokens(this.environment, tokens, this.clock.now(), latest);
|
|
110
|
+
// Persist the rotated refresh token before anything uses the new access token.
|
|
111
|
+
await this.save(next);
|
|
112
|
+
return next;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
export class UserCredentials {
|
|
117
|
+
manager;
|
|
118
|
+
session;
|
|
119
|
+
kind = "user";
|
|
120
|
+
constructor(manager, session) {
|
|
121
|
+
this.manager = manager;
|
|
122
|
+
this.session = session;
|
|
123
|
+
}
|
|
124
|
+
get current() {
|
|
125
|
+
return this.session;
|
|
126
|
+
}
|
|
127
|
+
async accessToken() {
|
|
128
|
+
if (this.manager.expiringSoon(this.session))
|
|
129
|
+
this.session = await this.manager.refresh(this.session.access_token);
|
|
130
|
+
return this.session.access_token;
|
|
131
|
+
}
|
|
132
|
+
async renew(rejected) {
|
|
133
|
+
this.session = await this.manager.refresh(rejected);
|
|
134
|
+
if (this.session.access_token === rejected)
|
|
135
|
+
throw new AuthError("Tracken ID gave back the token the API refused; run `tracken login`.");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/** A machine credential: the SDK's client-credentials exchange, worded for the CLI when Tracken ID refuses it. */
|
|
139
|
+
export class MachineCredentials {
|
|
140
|
+
credential;
|
|
141
|
+
kind = "machine";
|
|
142
|
+
exchange;
|
|
143
|
+
constructor(environment, credential, fetchFn, clock) {
|
|
144
|
+
this.credential = credential;
|
|
145
|
+
this.exchange = new ClientCredentials({
|
|
146
|
+
issuer: environment.issuer,
|
|
147
|
+
audience: environment.integrationAudience,
|
|
148
|
+
clientId: credential.clientId,
|
|
149
|
+
clientSecret: credential.clientSecret,
|
|
150
|
+
scope: credential.scope,
|
|
151
|
+
fetch: fetchFn,
|
|
152
|
+
clock,
|
|
153
|
+
userAgent: userAgent(),
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
async worded(step) {
|
|
157
|
+
try {
|
|
158
|
+
return await step();
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
if (error instanceof TrackenAuthError) {
|
|
162
|
+
throw new AuthError(`Tracken ID refused the API credential ${this.credential.clientId} (${error.error}): disabled, expired or rotated? Check it under Settings → API access.`);
|
|
163
|
+
}
|
|
164
|
+
throw error;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
accessToken() {
|
|
168
|
+
return this.worded(() => this.exchange.accessToken());
|
|
169
|
+
}
|
|
170
|
+
/** A fresh token, once per refusal; never a person's session in its place. */
|
|
171
|
+
renew(rejected) {
|
|
172
|
+
return this.worded(() => this.exchange.renew(rejected));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/** `TRACKEN_CLIENT_ID` + `TRACKEN_CLIENT_SECRET` (and optional `TRACKEN_SCOPE`), when set. */
|
|
176
|
+
export function machineCredentialFromEnv(env) {
|
|
177
|
+
const clientId = env.TRACKEN_CLIENT_ID?.trim();
|
|
178
|
+
const clientSecret = env.TRACKEN_CLIENT_SECRET;
|
|
179
|
+
if (!clientId && !clientSecret)
|
|
180
|
+
return undefined;
|
|
181
|
+
if (!clientId || !clientSecret)
|
|
182
|
+
throw new UsageError("Machine mode needs both TRACKEN_CLIENT_ID and TRACKEN_CLIENT_SECRET.");
|
|
183
|
+
const scope = env.TRACKEN_SCOPE?.trim();
|
|
184
|
+
return scope ? { clientId, clientSecret, scope } : { clientId, clientSecret };
|
|
185
|
+
}
|
|
186
|
+
/** The machine credential when the environment names one, else the stored session. */
|
|
187
|
+
export async function resolveCredentials(options) {
|
|
188
|
+
const machine = machineCredentialFromEnv(options.env);
|
|
189
|
+
if (machine)
|
|
190
|
+
return new MachineCredentials(options.environment, machine, options.fetch, options.clock);
|
|
191
|
+
const session = await options.manager.load();
|
|
192
|
+
const name = options.environment.name;
|
|
193
|
+
if (!session)
|
|
194
|
+
throw new AuthError(`Not signed in to ${name}; run \`tracken login${name === "prod" ? "" : ` --env ${name}`}\`.`);
|
|
195
|
+
if (session.issuer !== options.environment.issuer) {
|
|
196
|
+
throw new AuthError(`The ${name} session was issued by ${session.issuer}, not ${options.environment.issuer}; run \`tracken login --env ${name}\`.`);
|
|
197
|
+
}
|
|
198
|
+
return new UserCredentials(options.manager, session);
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HttpMethod, OperationSpec } from "./operations.js";
|
|
2
|
+
export declare function findOperation(resource: string, verb: string): OperationSpec | undefined;
|
|
3
|
+
export declare function operationById(operationId: string): OperationSpec | undefined;
|
|
4
|
+
export declare function operationsOf(resource: string): OperationSpec[];
|
|
5
|
+
/** Resources in document order, with the tag each belongs to and whether any of its operations is live. */
|
|
6
|
+
export declare function resources(): Array<{
|
|
7
|
+
resource: string;
|
|
8
|
+
tag: string;
|
|
9
|
+
live: boolean;
|
|
10
|
+
}>;
|
|
11
|
+
/** The operation a raw `tracken api` call addresses (`GET /sales-invoices/<uuid>` → getSalesInvoice). */
|
|
12
|
+
export declare function matchOperation(method: HttpMethod, path: string): OperationSpec | undefined;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Lookups over the generated operations: by command, by operation id, by method and concrete path. */
|
|
2
|
+
import { OPERATIONS } from "../generated/operations.js";
|
|
3
|
+
const byCommand = new Map(OPERATIONS.map((operation) => [`${operation.resource} ${operation.verb}`, operation]));
|
|
4
|
+
const byId = new Map(OPERATIONS.map((operation) => [operation.operationId, operation]));
|
|
5
|
+
export function findOperation(resource, verb) {
|
|
6
|
+
return byCommand.get(`${resource} ${verb}`);
|
|
7
|
+
}
|
|
8
|
+
export function operationById(operationId) {
|
|
9
|
+
return byId.get(operationId);
|
|
10
|
+
}
|
|
11
|
+
export function operationsOf(resource) {
|
|
12
|
+
return OPERATIONS.filter((operation) => operation.resource === resource);
|
|
13
|
+
}
|
|
14
|
+
/** Resources in document order, with the tag each belongs to and whether any of its operations is live. */
|
|
15
|
+
export function resources() {
|
|
16
|
+
const seen = new Map();
|
|
17
|
+
for (const operation of OPERATIONS) {
|
|
18
|
+
const entry = seen.get(operation.resource) ?? { tag: operation.tag, live: false };
|
|
19
|
+
entry.live ||= operation.availability === "live";
|
|
20
|
+
seen.set(operation.resource, entry);
|
|
21
|
+
}
|
|
22
|
+
return [...seen].map(([resource, entry]) => ({ resource, ...entry }));
|
|
23
|
+
}
|
|
24
|
+
const templates = OPERATIONS.map((operation) => ({
|
|
25
|
+
operation,
|
|
26
|
+
pattern: new RegExp(`^${operation.path.replace(/[.*+?^$()|[\]\\]/g, "\\$&").replace(/\{[^}]+\}/g, "[^/:]+")}$`),
|
|
27
|
+
}));
|
|
28
|
+
/** The operation a raw `tracken api` call addresses (`GET /sales-invoices/<uuid>` → getSalesInvoice). */
|
|
29
|
+
export function matchOperation(method, path) {
|
|
30
|
+
const bare = path.split("?")[0];
|
|
31
|
+
return templates.find(({ operation, pattern }) => operation.method === method && pattern.test(bare))?.operation;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=catalog.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI's API client is the SDK's transport (`@tracken/sdk`'s `TrackenClient`: the token, the
|
|
3
|
+
* organization header, the automatic Idempotency-Key, retries, the one renewal after a 401 and the
|
|
4
|
+
* 303 download), named as the CLI in `User-Agent` and `Tracken-Agent`, pointing at `tracken org`
|
|
5
|
+
* when a person's command needs an organization and none is chosen, and saying what to do when the
|
|
6
|
+
* API's 401 stands after the renewal.
|
|
7
|
+
*/
|
|
8
|
+
import { TrackenClient as SdkClient, type ApiResponse, type ClientOptions as SdkClientOptions } from "@tracken/sdk";
|
|
9
|
+
import type { Clock } from "./auth/oauth.js";
|
|
10
|
+
import type { ApiRequest } from "./request.js";
|
|
11
|
+
export { ORGANIZATION_HEADER, type ApiResponse } from "@tracken/sdk";
|
|
12
|
+
export interface ClientOptions extends Omit<SdkClientOptions, "clock" | "userAgent" | "missingOrganizationMessage" | "isRenewalRefusal"> {
|
|
13
|
+
clock: Clock;
|
|
14
|
+
/** Shown in errors when an operation needs an organization and none is chosen. */
|
|
15
|
+
environmentName?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare class TrackenClient extends SdkClient {
|
|
18
|
+
private readonly envFlag;
|
|
19
|
+
constructor({ environmentName, agent, ...options }: ClientOptions);
|
|
20
|
+
/** The SDK's `send`; a 401 that stands after the renewal carries what to do as its `hint`. */
|
|
21
|
+
send(request: ApiRequest): Promise<ApiResponse>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI's API client is the SDK's transport (`@tracken/sdk`'s `TrackenClient`: the token, the
|
|
3
|
+
* organization header, the automatic Idempotency-Key, retries, the one renewal after a 401 and the
|
|
4
|
+
* 303 download), named as the CLI in `User-Agent` and `Tracken-Agent`, pointing at `tracken org`
|
|
5
|
+
* when a person's command needs an organization and none is chosen, and saying what to do when the
|
|
6
|
+
* API's 401 stands after the renewal.
|
|
7
|
+
*/
|
|
8
|
+
import { TrackenAuthError, TrackenClient as SdkClient, TrackenUnauthenticatedError } from "@tracken/sdk";
|
|
9
|
+
import { AuthError, MACHINE_CREDENTIAL_REFUSED, OAuthError } from "./errors.js";
|
|
10
|
+
import { CLI_AGENT, userAgent } from "./version.js";
|
|
11
|
+
export { ORGANIZATION_HEADER } from "@tracken/sdk";
|
|
12
|
+
/** Tracken ID refused the session or the credential, as the CLI's credentials report it. */
|
|
13
|
+
const isRenewalRefusal = (error) => error instanceof AuthError || error instanceof OAuthError || error instanceof TrackenAuthError;
|
|
14
|
+
export class TrackenClient extends SdkClient {
|
|
15
|
+
envFlag;
|
|
16
|
+
constructor({ environmentName, agent, ...options }) {
|
|
17
|
+
const env = environmentName && environmentName !== "prod" ? ` --env ${environmentName}` : "";
|
|
18
|
+
super({
|
|
19
|
+
...options,
|
|
20
|
+
agent: agent ?? CLI_AGENT,
|
|
21
|
+
userAgent: userAgent(),
|
|
22
|
+
missingOrganizationMessage: `No organization chosen: run \`tracken org list${env}\`, then \`tracken org use <id>${env}\` (or pass --org <id>).`,
|
|
23
|
+
isRenewalRefusal,
|
|
24
|
+
});
|
|
25
|
+
this.envFlag = env;
|
|
26
|
+
}
|
|
27
|
+
/** The SDK's `send`; a 401 that stands after the renewal carries what to do as its `hint`. */
|
|
28
|
+
async send(request) {
|
|
29
|
+
try {
|
|
30
|
+
return await super.send(request);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
if (error instanceof TrackenUnauthenticatedError && error.hint === undefined) {
|
|
34
|
+
if (this.credentials.kind === "machine")
|
|
35
|
+
error.hint = MACHINE_CREDENTIAL_REFUSED;
|
|
36
|
+
else if (error.renewalError instanceof Error)
|
|
37
|
+
error.hint = error.renewalError.message;
|
|
38
|
+
else
|
|
39
|
+
error.hint = `The API refused the renewed token as well; run \`tracken login${this.envFlag}\`.`;
|
|
40
|
+
}
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { EnvironmentName } from "./environments.js";
|
|
2
|
+
export declare function configDir(env: NodeJS.ProcessEnv): string;
|
|
3
|
+
export interface OrganizationChoice {
|
|
4
|
+
id: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ConfigFile {
|
|
8
|
+
organizations?: Partial<Record<EnvironmentName, OrganizationChoice>>;
|
|
9
|
+
}
|
|
10
|
+
/** Reads a JSON file; a missing file is `undefined`, a corrupt one an error naming it. */
|
|
11
|
+
export declare function readJson<T>(path: string): Promise<T | undefined>;
|
|
12
|
+
/** Writes a file readable by its owner only, atomically, so a crash never leaves half a file. */
|
|
13
|
+
export declare function writePrivateFile(path: string, contents: string, directory: string): Promise<void>;
|
|
14
|
+
export declare class ConfigStore {
|
|
15
|
+
readonly directory: string;
|
|
16
|
+
readonly path: string;
|
|
17
|
+
constructor(directory: string);
|
|
18
|
+
read(): Promise<ConfigFile>;
|
|
19
|
+
organization(environment: EnvironmentName): Promise<OrganizationChoice | undefined>;
|
|
20
|
+
setOrganization(environment: EnvironmentName, choice: OrganizationChoice | undefined): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Runs `task` holding an exclusive lock file. Refresh tokens rotate and Tracken ID revokes the whole
|
|
24
|
+
* chain when a spent one is presented again, so two processes (the CLI and the MCP server) must
|
|
25
|
+
* never refresh the same session at once. A lock older than 30 s belongs to a crashed process.
|
|
26
|
+
*/
|
|
27
|
+
export declare function withFileLock<T>(path: string, directory: string, task: () => Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI's own files: `config.json` (the organization chosen per environment; nothing secret) and,
|
|
3
|
+
* only when no OS keychain exists, `credentials.json`. Both live in one private directory:
|
|
4
|
+
* `TRACKEN_CONFIG_DIR`, else `$XDG_CONFIG_HOME/tracken`, else `~/.config/tracken`
|
|
5
|
+
* (`%APPDATA%\tracken` on Windows).
|
|
6
|
+
*/
|
|
7
|
+
import { mkdir, open, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
8
|
+
import { homedir } from "node:os";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
import { randomUUID } from "node:crypto";
|
|
11
|
+
export function configDir(env) {
|
|
12
|
+
if (env.TRACKEN_CONFIG_DIR)
|
|
13
|
+
return env.TRACKEN_CONFIG_DIR;
|
|
14
|
+
if (process.platform === "win32" && env.APPDATA)
|
|
15
|
+
return join(env.APPDATA, "tracken");
|
|
16
|
+
return join(env.XDG_CONFIG_HOME || join(homedir(), ".config"), "tracken");
|
|
17
|
+
}
|
|
18
|
+
/** Reads a JSON file; a missing file is `undefined`, a corrupt one an error naming it. */
|
|
19
|
+
export async function readJson(path) {
|
|
20
|
+
let text;
|
|
21
|
+
try {
|
|
22
|
+
text = await readFile(path, "utf8");
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if (error.code === "ENOENT")
|
|
26
|
+
return undefined;
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
return JSON.parse(text);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
throw new Error(`${path} is not valid JSON; fix or delete it.`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Writes a file readable by its owner only, atomically, so a crash never leaves half a file. */
|
|
37
|
+
export async function writePrivateFile(path, contents, directory) {
|
|
38
|
+
await mkdir(directory, { recursive: true, mode: 0o700 });
|
|
39
|
+
const temporary = `${path}.${randomUUID()}.tmp`;
|
|
40
|
+
await writeFile(temporary, contents, { mode: 0o600 });
|
|
41
|
+
try {
|
|
42
|
+
await rename(temporary, path);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
await rm(temporary, { force: true });
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export class ConfigStore {
|
|
50
|
+
directory;
|
|
51
|
+
path;
|
|
52
|
+
constructor(directory) {
|
|
53
|
+
this.directory = directory;
|
|
54
|
+
this.path = join(directory, "config.json");
|
|
55
|
+
}
|
|
56
|
+
async read() {
|
|
57
|
+
return (await readJson(this.path)) ?? {};
|
|
58
|
+
}
|
|
59
|
+
async organization(environment) {
|
|
60
|
+
return (await this.read()).organizations?.[environment];
|
|
61
|
+
}
|
|
62
|
+
async setOrganization(environment, choice) {
|
|
63
|
+
const config = await this.read();
|
|
64
|
+
const organizations = { ...config.organizations };
|
|
65
|
+
if (choice)
|
|
66
|
+
organizations[environment] = choice;
|
|
67
|
+
else
|
|
68
|
+
delete organizations[environment];
|
|
69
|
+
await writePrivateFile(this.path, `${JSON.stringify({ ...config, organizations }, null, 2)}\n`, this.directory);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const LOCK_STALE_MS = 30_000;
|
|
73
|
+
const LOCK_WAIT_MS = 15_000;
|
|
74
|
+
const LOCK_POLL_MS = 50;
|
|
75
|
+
/**
|
|
76
|
+
* Runs `task` holding an exclusive lock file. Refresh tokens rotate and Tracken ID revokes the whole
|
|
77
|
+
* chain when a spent one is presented again, so two processes (the CLI and the MCP server) must
|
|
78
|
+
* never refresh the same session at once. A lock older than 30 s belongs to a crashed process.
|
|
79
|
+
*/
|
|
80
|
+
export async function withFileLock(path, directory, task) {
|
|
81
|
+
await mkdir(directory, { recursive: true, mode: 0o700 });
|
|
82
|
+
const deadline = Date.now() + LOCK_WAIT_MS;
|
|
83
|
+
for (;;) {
|
|
84
|
+
try {
|
|
85
|
+
const handle = await open(path, "wx", 0o600);
|
|
86
|
+
await handle.close();
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (error.code !== "EEXIST")
|
|
91
|
+
throw error;
|
|
92
|
+
const age = await stat(path).then((info) => Date.now() - info.mtimeMs, () => 0);
|
|
93
|
+
if (age > LOCK_STALE_MS) {
|
|
94
|
+
await rm(path, { force: true });
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (Date.now() > deadline)
|
|
98
|
+
throw new Error(`Timed out waiting for ${path}; delete it if no other tracken process is running.`);
|
|
99
|
+
await new Promise((resolve) => setTimeout(resolve, LOCK_POLL_MS));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
return await task();
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
await rm(path, { force: true });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const ENVIRONMENT_NAMES: readonly ["prod", "dev", "local"];
|
|
2
|
+
export type EnvironmentName = (typeof ENVIRONMENT_NAMES)[number];
|
|
3
|
+
export interface Environment {
|
|
4
|
+
name: EnvironmentName;
|
|
5
|
+
/** Tracken ID: device authorization, token and revocation endpoints. */
|
|
6
|
+
issuer: string;
|
|
7
|
+
/** The public API base, including the major version. */
|
|
8
|
+
apiBaseUrl: string;
|
|
9
|
+
/** The resource a person's token is issued for (Accounts' person API). */
|
|
10
|
+
personAudience: string;
|
|
11
|
+
/** The resource a machine credential's token is issued for. */
|
|
12
|
+
integrationAudience: string;
|
|
13
|
+
/** The native client Tracken ID registers for the CLI in this environment (D-57). */
|
|
14
|
+
cliClientId: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function isEnvironmentName(value: string): value is EnvironmentName;
|
|
17
|
+
/**
|
|
18
|
+
* The environment named by `--env`, else `TRACKEN_ENV`, else production. `TRACKEN_ISSUER` and
|
|
19
|
+
* `TRACKEN_API_URL` point one at another host (a tunnel, a local port).
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveEnvironment(name: string | undefined, env: NodeJS.ProcessEnv): Environment;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where each environment's Tracken ID and Accounts API live. Values follow tracken-id's registry
|
|
3
|
+
* (`packages/registry/src/environments/*.ts`: issuer, `tracken-cli-<env>` clients, the person and
|
|
4
|
+
* integration resources) and accounting_software's `accounting-infra/cdk.json` (`api_domain`,
|
|
5
|
+
* `oidc_audience`) and the public document's `servers`.
|
|
6
|
+
*/
|
|
7
|
+
import { ENVIRONMENTS } from "@tracken/sdk";
|
|
8
|
+
import { UsageError } from "./errors.js";
|
|
9
|
+
export const ENVIRONMENT_NAMES = ["prod", "dev", "local"];
|
|
10
|
+
const DEFAULTS = {
|
|
11
|
+
prod: {
|
|
12
|
+
...ENVIRONMENTS.prod,
|
|
13
|
+
personAudience: "https://accounts-api.tracken.ee",
|
|
14
|
+
cliClientId: "tracken-cli-prod",
|
|
15
|
+
},
|
|
16
|
+
dev: {
|
|
17
|
+
...ENVIRONMENTS.dev,
|
|
18
|
+
personAudience: "https://accounts-api.dev.tracken.ee",
|
|
19
|
+
cliClientId: "tracken-cli-dev",
|
|
20
|
+
},
|
|
21
|
+
// Accounts' local stack (`uv run uvicorn local_server:app`) verifies DEV Tracken ID tokens: there is
|
|
22
|
+
// no local identity provider (accounting-api/local_runner/config.py OIDC_ISSUER/OIDC_AUDIENCE,
|
|
23
|
+
// accounting-api/CLAUDE.md "Sign-in is Tracken ID, and locally it is the DEV issuer"). So a local
|
|
24
|
+
// session is a dev sign-in, kept under its own key, sent to the API on this machine.
|
|
25
|
+
local: {
|
|
26
|
+
...ENVIRONMENTS.dev,
|
|
27
|
+
apiBaseUrl: "http://localhost:8000/v1",
|
|
28
|
+
personAudience: "https://accounts-api.dev.tracken.ee",
|
|
29
|
+
cliClientId: "tracken-cli-dev",
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
export function isEnvironmentName(value) {
|
|
33
|
+
return ENVIRONMENT_NAMES.includes(value);
|
|
34
|
+
}
|
|
35
|
+
const trimSlash = (url) => url.replace(/\/+$/, "");
|
|
36
|
+
/**
|
|
37
|
+
* The environment named by `--env`, else `TRACKEN_ENV`, else production. `TRACKEN_ISSUER` and
|
|
38
|
+
* `TRACKEN_API_URL` point one at another host (a tunnel, a local port).
|
|
39
|
+
*/
|
|
40
|
+
export function resolveEnvironment(name, env) {
|
|
41
|
+
const chosen = name ?? env.TRACKEN_ENV ?? "prod";
|
|
42
|
+
if (!isEnvironmentName(chosen)) {
|
|
43
|
+
throw new UsageError(`Unknown environment "${chosen}"; use one of ${ENVIRONMENT_NAMES.join(", ")}.`);
|
|
44
|
+
}
|
|
45
|
+
const base = DEFAULTS[chosen];
|
|
46
|
+
return {
|
|
47
|
+
name: chosen,
|
|
48
|
+
...base,
|
|
49
|
+
issuer: trimSlash(env.TRACKEN_ISSUER || base.issuer),
|
|
50
|
+
apiBaseUrl: trimSlash(env.TRACKEN_API_URL || base.apiBaseUrl),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=environments.js.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Errors and the exit codes scripts can branch on. Each API failure class has its own code, so a
|
|
3
|
+
* script can tell "sign in again" from "you may not" from "it changed under you" without parsing text.
|
|
4
|
+
*/
|
|
5
|
+
import { TrackenApiError, TrackenError } from "@tracken/sdk";
|
|
6
|
+
export declare const EXIT: {
|
|
7
|
+
readonly ok: 0;
|
|
8
|
+
/** Anything not listed below. */
|
|
9
|
+
readonly failure: 1;
|
|
10
|
+
/** The command line itself is wrong (unknown command or flag, bad value). */
|
|
11
|
+
readonly usage: 2;
|
|
12
|
+
/** The API or Tracken ID could not be reached. */
|
|
13
|
+
readonly network: 3;
|
|
14
|
+
/** 401, or no session: sign in again. */
|
|
15
|
+
readonly unauthenticated: 4;
|
|
16
|
+
/** 403: a scope or the role does not allow it. */
|
|
17
|
+
readonly forbidden: 5;
|
|
18
|
+
readonly notFound: 6;
|
|
19
|
+
/** 409: the record's state does not allow it, or it already exists. */
|
|
20
|
+
readonly conflict: 7;
|
|
21
|
+
/** 412: `If-Match` did not match; the record changed since it was read. */
|
|
22
|
+
readonly preconditionFailed: 8;
|
|
23
|
+
/** 400 and 422: the request was refused as invalid; `details` point at the fields. */
|
|
24
|
+
readonly invalid: 9;
|
|
25
|
+
/** 429 after the CLI's own retries. */
|
|
26
|
+
readonly rateLimited: 10;
|
|
27
|
+
/** 5xx after the CLI's own retries. */
|
|
28
|
+
readonly server: 11;
|
|
29
|
+
/** `--wait`: the job finished as failed. */
|
|
30
|
+
readonly jobFailed: 12;
|
|
31
|
+
/** 402: the organization's subscription is not active; export the data or ask an owner to reopen it. */
|
|
32
|
+
readonly paymentRequired: 13;
|
|
33
|
+
};
|
|
34
|
+
export type ExitCode = (typeof EXIT)[keyof typeof EXIT];
|
|
35
|
+
/**
|
|
36
|
+
* The SDK's errors are the CLI's: an API failure, a request refused before it was sent, an
|
|
37
|
+
* unreachable host and a failed job come from `@tracken/sdk` and map to exit codes in `exitCodeOf`.
|
|
38
|
+
*/
|
|
39
|
+
export { TrackenApiError as ApiError, TrackenError, TrackenJobFailedError as JobFailedError, TrackenNetworkError as NetworkError, TrackenUsageError as UsageError, type ErrorDetail, } from "@tracken/sdk";
|
|
40
|
+
/** A failure of the CLI itself, with the exit code it ends the process with. */
|
|
41
|
+
export declare class CliError extends TrackenError {
|
|
42
|
+
readonly exitCode: ExitCode;
|
|
43
|
+
constructor(message: string, exitCode?: ExitCode);
|
|
44
|
+
}
|
|
45
|
+
export declare class AuthError extends CliError {
|
|
46
|
+
constructor(message: string);
|
|
47
|
+
}
|
|
48
|
+
/** An OAuth error answer from Tracken ID (RFC 6749 §5.2, RFC 8628 §3.5). */
|
|
49
|
+
export declare class OAuthError extends CliError {
|
|
50
|
+
readonly error: string;
|
|
51
|
+
readonly description: string | undefined;
|
|
52
|
+
readonly status: number;
|
|
53
|
+
constructor(error: string, description: string | undefined, status: number);
|
|
54
|
+
}
|
|
55
|
+
export declare function exitCodeForStatus(status: number): ExitCode;
|
|
56
|
+
/** The exit code a failure ends the CLI with. */
|
|
57
|
+
export declare function exitCodeOf(error: unknown): ExitCode;
|
|
58
|
+
/** What the command knows about where it ran and as whom, for advice beside an error. */
|
|
59
|
+
export interface ErrorContext {
|
|
60
|
+
/** `prod`, `dev` or `local`. */
|
|
61
|
+
environment?: string | undefined;
|
|
62
|
+
/** A person's session or an API credential, when the command got that far. */
|
|
63
|
+
credentials?: "user" | "machine" | undefined;
|
|
64
|
+
/** The API scopes the person's session holds (to keep them in a `tracken login --scope` hint). */
|
|
65
|
+
grantedScopes?: readonly string[] | undefined;
|
|
66
|
+
/** What to do once the cause is fixed, when not "run the same command again" (the MCP server's tool call). */
|
|
67
|
+
retry?: string | undefined;
|
|
68
|
+
}
|
|
69
|
+
/** What a 401 after the renewal means for an API credential. */
|
|
70
|
+
export declare const MACHINE_CREDENTIAL_REFUSED = "The API credential was refused (disabled, expired or rotated?): check it under Settings \u2192 API access, or set TRACKEN_CLIENT_ID and TRACKEN_CLIENT_SECRET to a current one.";
|
|
71
|
+
/**
|
|
72
|
+
* The one scope to add from those a 403 says would each admit the call: the only specific one when
|
|
73
|
+
* there is one (`contacts:read` over the `read` shorthand), else `read` when it is among them (any
|
|
74
|
+
* read scope admits a deletions feed), else the first.
|
|
75
|
+
*/
|
|
76
|
+
export declare function scopeToAdd(admitting: readonly string[]): string | undefined;
|
|
77
|
+
export declare const TRIAL_LIMIT_REACHED = "TRIAL_LIMIT_REACHED";
|
|
78
|
+
/** A `TRIAL_LIMIT_REACHED` in words: which allowance is used, and the day it resets (absent for one only a plan lifts). */
|
|
79
|
+
export interface TrialLimitFacts {
|
|
80
|
+
/** "The trial's daily allowance of customer e-mails (50) is used". */
|
|
81
|
+
readonly used: string;
|
|
82
|
+
/** `context.resets_on` as `16.11.2026`. */
|
|
83
|
+
readonly resetsOn: string | undefined;
|
|
84
|
+
}
|
|
85
|
+
export declare function trialLimitFacts(error: TrackenApiError): TrialLimitFacts;
|
|
86
|
+
/**
|
|
87
|
+
* What a subscription refusal means, in one sentence: what happened and who can change it. `retry` is
|
|
88
|
+
* what to do once they have ("run the same command again"; the MCP server says "call <tool> again").
|
|
89
|
+
* None of them is worth retrying unchanged, and nothing retries them automatically. Undefined for
|
|
90
|
+
* every other error.
|
|
91
|
+
*/
|
|
92
|
+
export declare function subscriptionAdvice(error: TrackenApiError, retry?: string): string | undefined;
|
|
93
|
+
/** The API's refusal of an operation it does not serve publicly (yet), or not to this kind of principal. */
|
|
94
|
+
export declare const OPERATION_NOT_PUBLIC = "OPERATION_NOT_PUBLIC";
|
|
95
|
+
/** The human rendering of any error, for stderr. */
|
|
96
|
+
export declare function renderError(error: unknown, context?: ErrorContext): string;
|