@ora-ai/cli 0.25.0 → 0.26.0
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 +39 -1
- package/README.md +569 -462
- package/dist/command-tree.d.ts +30 -0
- package/dist/command-tree.d.ts.map +1 -0
- package/dist/command-tree.js +144 -0
- package/dist/command-tree.js.map +1 -0
- package/dist/core/error-envelope.d.ts +13 -4
- package/dist/core/error-envelope.d.ts.map +1 -1
- package/dist/core/error-envelope.js +19 -4
- package/dist/core/error-envelope.js.map +1 -1
- package/dist/core/error-stories.d.ts +36 -0
- package/dist/core/error-stories.d.ts.map +1 -0
- package/dist/core/error-stories.js +155 -0
- package/dist/core/error-stories.js.map +1 -0
- package/dist/core/http.d.ts +14 -3
- package/dist/core/http.d.ts.map +1 -1
- package/dist/core/http.js +24 -6
- package/dist/core/http.js.map +1 -1
- package/dist/core/limit-story.d.ts +2 -0
- package/dist/core/limit-story.d.ts.map +1 -1
- package/dist/core/limit-story.js +9 -4
- package/dist/core/limit-story.js.map +1 -1
- package/dist/core/operation-command.d.ts +10 -0
- package/dist/core/operation-command.d.ts.map +1 -0
- package/dist/core/operation-command.js +15 -0
- package/dist/core/operation-command.js.map +1 -0
- package/dist/core/operation-meta.d.ts +62 -0
- package/dist/core/operation-meta.d.ts.map +1 -0
- package/dist/core/operation-meta.js +15 -0
- package/dist/core/operation-meta.js.map +1 -0
- package/dist/core/output.d.ts +7 -5
- package/dist/core/output.d.ts.map +1 -1
- package/dist/core/output.js +21 -80
- package/dist/core/output.js.map +1 -1
- package/dist/core/problem.d.ts +34 -0
- package/dist/core/problem.d.ts.map +1 -0
- package/dist/core/problem.js +44 -0
- package/dist/core/problem.js.map +1 -0
- package/dist/core/retry-after.d.ts +4 -3
- package/dist/core/retry-after.d.ts.map +1 -1
- package/dist/core/retry-after.js +4 -3
- package/dist/core/retry-after.js.map +1 -1
- package/dist/core/run-operation.d.ts +9 -4
- package/dist/core/run-operation.d.ts.map +1 -1
- package/dist/core/run-operation.js +17 -4
- package/dist/core/run-operation.js.map +1 -1
- package/dist/generated/operations.d.ts +37 -1
- package/dist/generated/operations.d.ts.map +1 -1
- package/dist/generated/operations.js +27540 -191
- package/dist/generated/operations.js.map +1 -1
- package/dist/generated/types.d.ts +1932 -116
- package/dist/generated/types.d.ts.map +1 -1
- package/dist/generated/types.js +1 -1
- package/dist/interactive/derive-prompts.d.ts +13 -5
- package/dist/interactive/derive-prompts.d.ts.map +1 -1
- package/dist/interactive/derive-prompts.js +25 -1
- package/dist/interactive/derive-prompts.js.map +1 -1
- package/dist/interactive/session.d.ts +2 -2
- package/dist/interactive/session.d.ts.map +1 -1
- package/dist/interactive/session.js +31 -2
- package/dist/interactive/session.js.map +1 -1
- package/dist/mcp/defined-tools/defined-call.d.ts +18 -0
- package/dist/mcp/defined-tools/defined-call.d.ts.map +1 -0
- package/dist/mcp/defined-tools/defined-call.js +114 -0
- package/dist/mcp/defined-tools/defined-call.js.map +1 -0
- package/dist/mcp/defined-tools/defined-tool.d.ts +22 -0
- package/dist/mcp/defined-tools/defined-tool.d.ts.map +1 -0
- package/dist/mcp/defined-tools/defined-tool.js +35 -0
- package/dist/mcp/defined-tools/defined-tool.js.map +1 -0
- package/dist/mcp/defined-tools/json-conform.d.ts +28 -0
- package/dist/mcp/defined-tools/json-conform.d.ts.map +1 -0
- package/dist/mcp/defined-tools/json-conform.js +144 -0
- package/dist/mcp/defined-tools/json-conform.js.map +1 -0
- package/dist/mcp/defined-tools/problem-mapping.d.ts +39 -0
- package/dist/mcp/defined-tools/problem-mapping.d.ts.map +1 -0
- package/dist/mcp/defined-tools/problem-mapping.js +179 -0
- package/dist/mcp/defined-tools/problem-mapping.js.map +1 -0
- package/dist/mcp/defined-tools/request-split.d.ts +19 -0
- package/dist/mcp/defined-tools/request-split.d.ts.map +1 -0
- package/dist/mcp/defined-tools/request-split.js +25 -0
- package/dist/mcp/defined-tools/request-split.js.map +1 -0
- package/dist/mcp/defined-tools/tool-problem.d.ts +40 -0
- package/dist/mcp/defined-tools/tool-problem.d.ts.map +1 -0
- package/dist/mcp/defined-tools/tool-problem.js +42 -0
- package/dist/mcp/defined-tools/tool-problem.js.map +1 -0
- package/dist/mcp/defined-tools/tool-results.d.ts +12 -0
- package/dist/mcp/defined-tools/tool-results.d.ts.map +1 -0
- package/dist/mcp/defined-tools/tool-results.js +21 -0
- package/dist/mcp/defined-tools/tool-results.js.map +1 -0
- package/dist/mcp/local-tools/credential-minting.d.ts +24 -0
- package/dist/mcp/local-tools/credential-minting.d.ts.map +1 -0
- package/dist/mcp/local-tools/credential-minting.js +49 -0
- package/dist/mcp/local-tools/credential-minting.js.map +1 -0
- package/dist/mcp/local-tools/env-file.d.ts +30 -0
- package/dist/mcp/local-tools/env-file.d.ts.map +1 -0
- package/dist/mcp/local-tools/env-file.js +71 -0
- package/dist/mcp/local-tools/env-file.js.map +1 -0
- package/dist/mcp/local-tools/local-tools.d.ts +16 -0
- package/dist/mcp/local-tools/local-tools.d.ts.map +1 -0
- package/dist/mcp/local-tools/local-tools.js +16 -0
- package/dist/mcp/local-tools/local-tools.js.map +1 -0
- package/dist/mcp/local-tools/save-transmitter-credential.d.ts +21 -0
- package/dist/mcp/local-tools/save-transmitter-credential.d.ts.map +1 -0
- package/dist/mcp/local-tools/save-transmitter-credential.js +119 -0
- package/dist/mcp/local-tools/save-transmitter-credential.js.map +1 -0
- package/dist/mcp/mcp-call.d.ts +2 -2
- package/dist/mcp/mcp-call.d.ts.map +1 -1
- package/dist/mcp/mcp-call.js +8 -2
- package/dist/mcp/mcp-call.js.map +1 -1
- package/dist/mcp/mcp-command.d.ts +6 -2
- package/dist/mcp/mcp-command.d.ts.map +1 -1
- package/dist/mcp/mcp-command.js +36 -12
- package/dist/mcp/mcp-command.js.map +1 -1
- package/dist/mcp/mcp-install.d.ts +2 -0
- package/dist/mcp/mcp-install.d.ts.map +1 -1
- package/dist/mcp/mcp-install.js +7 -1
- package/dist/mcp/mcp-install.js.map +1 -1
- package/dist/mcp/mcp-protocol.d.ts +2 -0
- package/dist/mcp/mcp-protocol.d.ts.map +1 -1
- package/dist/mcp/mcp-protocol.js.map +1 -1
- package/dist/mcp/mcp-tools.d.ts +28 -25
- package/dist/mcp/mcp-tools.d.ts.map +1 -1
- package/dist/mcp/mcp-tools.js +39 -16
- package/dist/mcp/mcp-tools.js.map +1 -1
- package/dist/mcp/tool-binding.d.ts +35 -0
- package/dist/mcp/tool-binding.d.ts.map +1 -0
- package/dist/mcp/tool-binding.js +7 -0
- package/dist/mcp/tool-binding.js.map +1 -0
- package/dist/mcp/tool-bindings.d.ts +20 -0
- package/dist/mcp/tool-bindings.d.ts.map +1 -0
- package/dist/mcp/tool-bindings.js +31 -0
- package/dist/mcp/tool-bindings.js.map +1 -0
- package/dist/mcp/tool-filter.d.ts +26 -0
- package/dist/mcp/tool-filter.d.ts.map +1 -0
- package/dist/mcp/tool-filter.js +23 -0
- package/dist/mcp/tool-filter.js.map +1 -0
- package/dist/program.d.ts +9 -9
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +12 -83
- package/dist/program.js.map +1 -1
- package/dist/watch.d.ts +3 -3
- package/dist/watch.d.ts.map +1 -1
- package/dist/watch.js +10 -2
- package/dist/watch.js.map +1 -1
- package/package.json +6 -7
package/dist/core/http.js
CHANGED
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Non-ok responses map to ApiError carrying the platform envelope
|
|
11
11
|
* {error, code, details?} so output.ts can tell the 402/403 stories — read
|
|
12
|
-
* through core/error-envelope.ts, which also accepts
|
|
13
|
-
* nested spellings some services answer with.
|
|
12
|
+
* through core/error-envelope.ts, which also accepts RFC 9457 problems and
|
|
13
|
+
* the code-first and nested spellings some services answer with.
|
|
14
14
|
*/
|
|
15
15
|
import { readErrorEnvelope } from "./error-envelope.js";
|
|
16
|
+
import { retryAfterSeconds } from "./retry-after.js";
|
|
16
17
|
export class ApiError extends Error {
|
|
17
18
|
status;
|
|
18
19
|
code;
|
|
@@ -29,6 +30,12 @@ export class ApiError extends Error {
|
|
|
29
30
|
this.name = "ApiError";
|
|
30
31
|
}
|
|
31
32
|
}
|
|
33
|
+
/** The headers the client sets itself, whatever a caller passes: the credential, and what it asks for and sends. */
|
|
34
|
+
const CLIENT_HEADERS = new Set(["authorization", "accept", "content-type"]);
|
|
35
|
+
/** A caller's headers minus the client's own, compared case-insensitively as HTTP does. */
|
|
36
|
+
function callerHeaders(headers) {
|
|
37
|
+
return Object.fromEntries(Object.entries(headers ?? {}).filter(([name]) => !CLIENT_HEADERS.has(name.toLowerCase())));
|
|
38
|
+
}
|
|
32
39
|
export class HttpClient {
|
|
33
40
|
apiUrl;
|
|
34
41
|
auth;
|
|
@@ -58,8 +65,15 @@ export class HttpClient {
|
|
|
58
65
|
url(opts) {
|
|
59
66
|
const u = new URL(`${this.apiUrl}${opts.path}`);
|
|
60
67
|
for (const [key, value] of Object.entries(opts.query ?? {})) {
|
|
61
|
-
if (value
|
|
68
|
+
if (value === undefined)
|
|
69
|
+
continue;
|
|
70
|
+
if (!Array.isArray(value)) {
|
|
62
71
|
u.searchParams.set(key, String(value));
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
u.searchParams.delete(key);
|
|
75
|
+
for (const item of value)
|
|
76
|
+
u.searchParams.append(key, String(item));
|
|
63
77
|
}
|
|
64
78
|
return u.toString();
|
|
65
79
|
}
|
|
@@ -67,6 +81,7 @@ export class HttpClient {
|
|
|
67
81
|
const attempt = async (token) => this.fetchFn(this.url(opts), {
|
|
68
82
|
method: opts.method.toUpperCase(),
|
|
69
83
|
headers: {
|
|
84
|
+
...callerHeaders(opts.headers),
|
|
70
85
|
authorization: `Bearer ${token}`,
|
|
71
86
|
accept,
|
|
72
87
|
...(opts.body !== undefined ? { "content-type": "application/json" } : {}),
|
|
@@ -79,6 +94,7 @@ export class HttpClient {
|
|
|
79
94
|
if (res.status === 401) {
|
|
80
95
|
res = await attempt(await this.auth.forceRefresh(token));
|
|
81
96
|
}
|
|
97
|
+
opts.onResponse?.({ status: res.status, headers: res.headers });
|
|
82
98
|
if (!res.ok)
|
|
83
99
|
throw await toApiError(res);
|
|
84
100
|
return res;
|
|
@@ -92,11 +108,13 @@ async function toApiError(res) {
|
|
|
92
108
|
// `slug` (slug_taken) — not only the envelope's `details`. The envelope
|
|
93
109
|
// reader folds EVERY extra field in, so the renderer can show the actual
|
|
94
110
|
// field paths instead of a bare error code (audit F8: a 422 you can't
|
|
95
|
-
// self-diagnose costs a paid probe run to bisect), whichever of the
|
|
111
|
+
// self-diagnose costs a paid probe run to bisect), whichever of the four
|
|
96
112
|
// body spellings carried them (core/error-envelope.ts).
|
|
97
113
|
const { code, message, details } = readErrorEnvelope(raw);
|
|
98
|
-
|
|
99
|
-
|
|
114
|
+
// In seconds, whatever answered: a problem, a service's envelope, or the ingress's plain-text 429, which carries
|
|
115
|
+
// nothing but its status and this header.
|
|
116
|
+
const retryAfter = retryAfterSeconds(res.headers.get("retry-after"));
|
|
117
|
+
const merged = { ...details, ...(retryAfter !== undefined ? { retryAfter } : {}) };
|
|
100
118
|
return new ApiError(message ?? `HTTP ${res.status}`, res.status, code ?? "HTTP_ERROR", Object.keys(merged).length > 0 ? merged : undefined, raw);
|
|
101
119
|
}
|
|
102
120
|
//# sourceMappingURL=http.js.map
|
package/dist/core/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/core/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/core/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;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GAAa;IACrC,MAAM,GAAG,GAAY,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACxD,yEAAyE;IACzE,2DAA2D;IAC3D,2EAA2E;IAC3E,wEAAwE;IACxE,yEAAyE;IACzE,sEAAsE;IACtE,yEAAyE;IACzE,wDAAwD;IACxD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAC1D,iHAAiH;IACjH,0CAA0C;IAC1C,MAAM,UAAU,GAAG,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;IACrE,MAAM,MAAM,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACnF,OAAO,IAAI,QAAQ,CACjB,OAAO,IAAI,QAAQ,GAAG,CAAC,MAAM,EAAE,EAC/B,GAAG,CAAC,MAAM,EACV,IAAI,IAAI,YAAY,EACpB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EACnD,GAAG,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -3,6 +3,8 @@ export interface LimitDetails {
|
|
|
3
3
|
dimension?: unknown;
|
|
4
4
|
limit?: unknown;
|
|
5
5
|
used?: unknown;
|
|
6
|
+
/** The page the refusal says the plan is raised on (the Front API's 402 may name one). */
|
|
7
|
+
upgradeUrl?: unknown;
|
|
6
8
|
}
|
|
7
9
|
export declare function limitStory(fallback: string, details?: LimitDetails): {
|
|
8
10
|
headline: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limit-story.d.ts","sourceRoot":"","sources":["../../src/core/limit-story.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"limit-story.d.ts","sourceRoot":"","sources":["../../src/core/limit-story.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,0FAA0F;IAC1F,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAOD,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAW9G"}
|
package/dist/core/limit-story.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
const SERVER_PREFIX = "Usage limit exceeded for ";
|
|
2
2
|
const MONTHLY = new Set(["agent_runs", "domain_scans"]);
|
|
3
3
|
const BILLING = "Upgrade in Studio → Settings → Plan & billing.";
|
|
4
|
+
/** Where to raise the limit: the page the refusal names, else where billing is in Studio. */
|
|
5
|
+
function billingLine(upgradeUrl) {
|
|
6
|
+
return typeof upgradeUrl === "string" && upgradeUrl !== "" ? `Upgrade at ${upgradeUrl}` : BILLING;
|
|
7
|
+
}
|
|
4
8
|
export function limitStory(fallback, details = {}) {
|
|
5
|
-
const { message, dimension, limit, used } = details;
|
|
9
|
+
const { message, dimension, limit, used, upgradeUrl } = details;
|
|
10
|
+
const billing = billingLine(upgradeUrl);
|
|
6
11
|
const label = typeof message === "string" && message.startsWith(SERVER_PREFIX) ? message.slice(SERVER_PREFIX.length) : null;
|
|
7
12
|
if (label && limit === 0)
|
|
8
|
-
return { headline: `No ${label} are available on your plan right now.`, lines: [
|
|
13
|
+
return { headline: `No ${label} are available on your plan right now.`, lines: [billing] };
|
|
9
14
|
if (label && typeof limit === "number" && typeof used === "number" && used >= limit) {
|
|
10
15
|
const resets = typeof dimension === "string" && MONTHLY.has(dimension) ? ["ora usage shows when they reset."] : [];
|
|
11
|
-
return { headline: `You've used all ${limit.toLocaleString("en-US")} ${label} on your plan.`, lines: [...resets,
|
|
16
|
+
return { headline: `You've used all ${limit.toLocaleString("en-US")} ${label} on your plan.`, lines: [...resets, billing] };
|
|
12
17
|
}
|
|
13
18
|
const count = typeof used === "number" && typeof limit === "number" ? [`Used ${used} of ${limit}.`] : [];
|
|
14
|
-
return { headline: typeof message === "string" ? message : fallback, lines: [...count,
|
|
19
|
+
return { headline: typeof message === "string" ? message : fallback, lines: [...count, billing] };
|
|
15
20
|
}
|
|
16
21
|
//# sourceMappingURL=limit-story.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limit-story.js","sourceRoot":"","sources":["../../src/core/limit-story.ts"],"names":[],"mappings":"AAAA,MAAM,aAAa,GAAG,2BAA2B,CAAC;AAClD,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC;AACxD,MAAM,OAAO,GAAG,gDAAgD,CAAC;
|
|
1
|
+
{"version":3,"file":"limit-story.js","sourceRoot":"","sources":["../../src/core/limit-story.ts"],"names":[],"mappings":"AAAA,MAAM,aAAa,GAAG,2BAA2B,CAAC;AAClD,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC;AACxD,MAAM,OAAO,GAAG,gDAAgD,CAAC;AAWjE,6FAA6F;AAC7F,SAAS,WAAW,CAAC,UAAmB;IACtC,OAAO,OAAO,UAAU,KAAK,QAAQ,IAAI,UAA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C,CAAC,EAAE,CAAC;IACzG,OAAO,EAAE,QAAQ,EAAE,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC;AACpG,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The command line that runs an operation, as a person types it (`ora study get <id>`): what an MCP tool says it
|
|
3
|
+
* mirrors (mcp/mcp-tools.ts) and what an API's next step names (error-stories.ts). Built from the manifest, so every
|
|
4
|
+
* door names an operation the same way.
|
|
5
|
+
*/
|
|
6
|
+
import type { CommandOperation } from "./operation-meta.js";
|
|
7
|
+
export declare function commandLineOf(meta: Pick<CommandOperation, "commandPath" | "pathParams">): string;
|
|
8
|
+
/** The command line for an operation id; undefined when the manifest has no such operation. */
|
|
9
|
+
export declare function commandLineForOperation(operationId: string, operations?: readonly Pick<CommandOperation, "id" | "commandPath" | "pathParams">[]): string | undefined;
|
|
10
|
+
//# sourceMappingURL=operation-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-command.d.ts","sourceRoot":"","sources":["../../src/core/operation-command.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,gBAAgB,EAAE,aAAa,GAAG,YAAY,CAAC,GAAG,MAAM,CAEhG;AAED,+FAA+F;AAC/F,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,EACnB,UAAU,GAAE,SAAS,IAAI,CAAC,gBAAgB,EAAE,IAAI,GAAG,aAAa,GAAG,YAAY,CAAC,EAAe,GAC9F,MAAM,GAAG,SAAS,CAGpB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The command line that runs an operation, as a person types it (`ora study get <id>`): what an MCP tool says it
|
|
3
|
+
* mirrors (mcp/mcp-tools.ts) and what an API's next step names (error-stories.ts). Built from the manifest, so every
|
|
4
|
+
* door names an operation the same way.
|
|
5
|
+
*/
|
|
6
|
+
import { OPERATIONS, SPEC } from "../generated/operations.js";
|
|
7
|
+
export function commandLineOf(meta) {
|
|
8
|
+
return [SPEC.bin, ...meta.commandPath, ...meta.pathParams.map((param) => `<${param.name}>`)].join(" ");
|
|
9
|
+
}
|
|
10
|
+
/** The command line for an operation id; undefined when the manifest has no such operation. */
|
|
11
|
+
export function commandLineForOperation(operationId, operations = OPERATIONS) {
|
|
12
|
+
const meta = operations.find((m) => m.id === operationId);
|
|
13
|
+
return meta ? commandLineOf(meta) : undefined;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=operation-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-command.js","sourceRoot":"","sources":["../../src/core/operation-command.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAG9D,MAAM,UAAU,aAAa,CAAC,IAA0D;IACtF,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzG,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,uBAAuB,CACrC,WAAmB,EACnB,aAAqF,UAAU;IAE/F,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,WAAW,CAAC,CAAC;IAC1D,OAAO,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An operation as the CLI's runtime reads it from the generated manifest (generated/operations.ts).
|
|
3
|
+
*
|
|
4
|
+
* The members the generator learned with the Front API's conventions are optional here, and their absence means
|
|
5
|
+
* none: `headerParams` (the request headers the command takes as flags — scripts/lib/header-params.mjs),
|
|
6
|
+
* `stability` (a `beta` operation says so in help), a query parameter's `valueName` (the shape of its value —
|
|
7
|
+
* scripts/lib/query-params.mjs) and `mcpTool` (the MCP tool the document defines for it —
|
|
8
|
+
* scripts/lib/mcp-tool.mjs). So the runtime reads a manifest emitted before the generator learned them exactly as
|
|
9
|
+
* one emitted after, and every manifest operation is a CommandOperation.
|
|
10
|
+
*/
|
|
11
|
+
import type { OperationMeta, QueryParamMeta } from "../generated/operations.js";
|
|
12
|
+
/** A request header a command sends, taken as a flag (`--if-match <version>` sends `If-Match`). */
|
|
13
|
+
export interface HeaderParamMeta {
|
|
14
|
+
/** The header's own name, as sent: `If-Match`. */
|
|
15
|
+
name: string;
|
|
16
|
+
/** The flag, without dashes: `if-match`. */
|
|
17
|
+
flag: string;
|
|
18
|
+
/** Where commander keeps the flag's value: `ifMatch`. */
|
|
19
|
+
optionKey: string;
|
|
20
|
+
required: boolean;
|
|
21
|
+
description?: string;
|
|
22
|
+
}
|
|
23
|
+
/** A query parameter, with the name of its value's shape when its format gives one (`YYYY-MM-DD`). */
|
|
24
|
+
export type QueryParam = QueryParamMeta & {
|
|
25
|
+
valueName?: string;
|
|
26
|
+
};
|
|
27
|
+
/** Where each key of a tool's flat input goes in the request: path, query and body keys, and the If-Match key. */
|
|
28
|
+
export interface McpRequestMapMeta {
|
|
29
|
+
params?: string[];
|
|
30
|
+
query?: string[];
|
|
31
|
+
body?: string[];
|
|
32
|
+
ifMatch?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* An operation's MCP tool exactly as the document defines it (`x-ora-mcp-tool`, written by the API's own contract):
|
|
36
|
+
* what `tools/list` advertises, plus the request map a call is split by. `ora mcp serve` serves it VERBATIM, so it
|
|
37
|
+
* is the very tool ora's remote MCP server serves apps.
|
|
38
|
+
*/
|
|
39
|
+
export interface McpToolMeta {
|
|
40
|
+
name: string;
|
|
41
|
+
title: string;
|
|
42
|
+
description: string;
|
|
43
|
+
inputSchema: Record<string, unknown>;
|
|
44
|
+
outputSchema: Record<string, unknown>;
|
|
45
|
+
annotations: {
|
|
46
|
+
readOnlyHint: boolean;
|
|
47
|
+
destructiveHint: boolean;
|
|
48
|
+
idempotentHint: boolean;
|
|
49
|
+
openWorldHint: boolean;
|
|
50
|
+
};
|
|
51
|
+
request: McpRequestMapMeta;
|
|
52
|
+
}
|
|
53
|
+
export type CommandOperation = Omit<OperationMeta, "queryParams" | "headerParams" | "stability" | "mcpTool"> & {
|
|
54
|
+
queryParams: QueryParam[];
|
|
55
|
+
headerParams?: HeaderParamMeta[];
|
|
56
|
+
stability?: string | null;
|
|
57
|
+
/** The tool the document defines; `false`: the operation is never a tool; absent: it is served as its command. */
|
|
58
|
+
mcpTool?: McpToolMeta | false;
|
|
59
|
+
};
|
|
60
|
+
/** The header flags an operation takes: none when the manifest names none. */
|
|
61
|
+
export declare function headerParamsOf(meta: Pick<CommandOperation, "headerParams">): readonly HeaderParamMeta[];
|
|
62
|
+
//# sourceMappingURL=operation-meta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-meta.d.ts","sourceRoot":"","sources":["../../src/core/operation-meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEhF,mGAAmG;AACnG,MAAM,WAAW,eAAe;IAC9B,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IAC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,gBAAgB,EAAE,cAAc,CAAC,GAAG,SAAS,eAAe,EAAE,CAEvG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An operation as the CLI's runtime reads it from the generated manifest (generated/operations.ts).
|
|
3
|
+
*
|
|
4
|
+
* The members the generator learned with the Front API's conventions are optional here, and their absence means
|
|
5
|
+
* none: `headerParams` (the request headers the command takes as flags — scripts/lib/header-params.mjs),
|
|
6
|
+
* `stability` (a `beta` operation says so in help), a query parameter's `valueName` (the shape of its value —
|
|
7
|
+
* scripts/lib/query-params.mjs) and `mcpTool` (the MCP tool the document defines for it —
|
|
8
|
+
* scripts/lib/mcp-tool.mjs). So the runtime reads a manifest emitted before the generator learned them exactly as
|
|
9
|
+
* one emitted after, and every manifest operation is a CommandOperation.
|
|
10
|
+
*/
|
|
11
|
+
/** The header flags an operation takes: none when the manifest names none. */
|
|
12
|
+
export function headerParamsOf(meta) {
|
|
13
|
+
return meta.headerParams ?? [];
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=operation-meta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-meta.js","sourceRoot":"","sources":["../../src/core/operation-meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAkDH,8EAA8E;AAC9E,MAAM,UAAU,cAAc,CAAC,IAA4C;IACzE,OAAO,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC;AACjC,CAAC"}
|
package/dist/core/output.d.ts
CHANGED
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
* (render/registry.ts), populated by the side-effect import below (Task 6's
|
|
5
5
|
* trajectory/insight/journey/run-list renderers — render/index.ts), falling
|
|
6
6
|
* back to the same plain rendering when none of them claims the payload.
|
|
7
|
-
* renderError is where the CLI earns its keep: the 402 paywall
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* renderError is where the CLI earns its keep: the 402 paywall, the 403 scope
|
|
8
|
+
* story and an API's RFC 9457 problems are precomputed guidance, not bare codes
|
|
9
|
+
* (error-stories.ts — a registry, first match wins) — a refusal worded for the
|
|
10
|
+
* credential that was refused (an api key is told to mint one, a browser
|
|
11
|
+
* sign-in to sign in again: credentials/refusal-words.ts). The words come bound
|
|
12
|
+
* to the caller that met the error (run-operation.ts callerOf); there is no
|
|
13
|
+
* default kind.
|
|
12
14
|
*/
|
|
13
15
|
import "../render/index.js";
|
|
14
16
|
import type { OutputMode } from "../render/mode.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/core/output.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/core/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAKpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAMhE,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GAAG,MAAM,CAO9E;AAwCD,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;;;OAIG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,GAAE,kBAAuB,GAAG,MAAM,CAK9E"}
|
package/dist/core/output.js
CHANGED
|
@@ -4,21 +4,24 @@
|
|
|
4
4
|
* (render/registry.ts), populated by the side-effect import below (Task 6's
|
|
5
5
|
* trajectory/insight/journey/run-list renderers — render/index.ts), falling
|
|
6
6
|
* back to the same plain rendering when none of them claims the payload.
|
|
7
|
-
* renderError is where the CLI earns its keep: the 402 paywall
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* renderError is where the CLI earns its keep: the 402 paywall, the 403 scope
|
|
8
|
+
* story and an API's RFC 9457 problems are precomputed guidance, not bare codes
|
|
9
|
+
* (error-stories.ts — a registry, first match wins) — a refusal worded for the
|
|
10
|
+
* credential that was refused (an api key is told to mint one, a browser
|
|
11
|
+
* sign-in to sign in again: credentials/refusal-words.ts). The words come bound
|
|
12
|
+
* to the caller that met the error (run-operation.ts callerOf); there is no
|
|
13
|
+
* default kind.
|
|
12
14
|
*/
|
|
13
15
|
import chalk from "chalk";
|
|
14
|
-
import { limitStory } from "./limit-story.js";
|
|
15
16
|
import "../render/index.js"; // side-effect: registers the four rich renderers (Task 6)
|
|
16
17
|
import { renderRich } from "../render/registry.js";
|
|
17
18
|
import { sanitizeDeep, sanitizeTerminalText } from "../render/sanitize.js";
|
|
18
19
|
import { MAX_COLUMNS, cell, columnWidths, padLine, rowCountLabel } from "../render/table.js";
|
|
19
20
|
import { AuthError } from "./auth.js";
|
|
21
|
+
import { tellApiError, tellAuthError } from "./error-stories.js";
|
|
20
22
|
import { ApiError } from "./http.js";
|
|
21
23
|
import { SignInError } from "./oauth/sign-in-error.js";
|
|
24
|
+
import { commandLineForOperation } from "./operation-command.js";
|
|
22
25
|
export function renderResult(data, opts) {
|
|
23
26
|
if (opts.mode === "json")
|
|
24
27
|
return JSON.stringify(data, null, 2);
|
|
@@ -69,92 +72,30 @@ export function renderError(err, ctx = {}) {
|
|
|
69
72
|
if (ctx.mode === "json")
|
|
70
73
|
return renderErrorJson(err);
|
|
71
74
|
if (err instanceof ApiError)
|
|
72
|
-
return
|
|
73
|
-
if (err instanceof AuthError)
|
|
74
|
-
return ctx.words
|
|
75
|
-
? refusalStory(ctx.words.signedOut(err.code, err.message))
|
|
76
|
-
: chalk.red(`Authentication failed (${err.code}): ${err.message}`);
|
|
77
|
-
}
|
|
75
|
+
return tellApiError(err, { scope: ctx.scope, words: ctx.words, commandFor: commandLineForOperation });
|
|
76
|
+
if (err instanceof AuthError)
|
|
77
|
+
return tellAuthError(err, ctx.words);
|
|
78
78
|
return chalk.red(err instanceof Error ? err.message : String(err));
|
|
79
79
|
}
|
|
80
80
|
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
81
81
|
/**
|
|
82
82
|
* --json's error line (stderr, one line): the API's own error body as it was sent, so a script reads
|
|
83
83
|
* exactly the fields a client generated from the public doc reads — `code`, `details`, an Autopilot
|
|
84
|
-
* refusal's `details.issues[].refusal.wave` / `.blockedBy
|
|
85
|
-
* refused key exchange, a sign-in that did not complete, a missing
|
|
86
|
-
* non-JSON 502) gets the same house shape, `{error, code}
|
|
84
|
+
* refusal's `details.issues[].refusal.wave` / `.blockedBy`, a problem's `retryable` / `outcome`. A failure
|
|
85
|
+
* the API did not answer in JSON (a refused key exchange, a sign-in that did not complete, a missing
|
|
86
|
+
* credential, an unreadable --file, a non-JSON 502) gets the same house shape, `{error, code}` — plus, for
|
|
87
|
+
* an HTTP answer, its `status` and what the CLI read from it (`details.retryAfter`, in seconds: the
|
|
88
|
+
* ingress's plain-text 429 says nothing else). Plain and rich modes never come here.
|
|
87
89
|
*/
|
|
88
90
|
function renderErrorJson(err) {
|
|
89
91
|
if (err instanceof ApiError && isRecord(err.body) && Object.keys(err.body).length > 0)
|
|
90
92
|
return JSON.stringify(err.body);
|
|
91
|
-
if (err instanceof ApiError
|
|
93
|
+
if (err instanceof ApiError) {
|
|
94
|
+
return JSON.stringify({ error: err.message, code: err.code, status: err.status, ...(err.details ? { details: err.details } : {}) });
|
|
95
|
+
}
|
|
96
|
+
if (err instanceof AuthError || err instanceof SignInError) {
|
|
92
97
|
return JSON.stringify({ error: err.message, code: err.code });
|
|
93
98
|
}
|
|
94
99
|
return JSON.stringify({ error: err instanceof Error ? err.message : String(err), code: "CLI_ERROR" });
|
|
95
100
|
}
|
|
96
|
-
/** The scopes a 403 names (`details.missing`), else the command's own; none when neither says. */
|
|
97
|
-
function missingScopes(err, commandScope) {
|
|
98
|
-
const named = err.details?.missing;
|
|
99
|
-
if (Array.isArray(named) && named.length > 0)
|
|
100
|
-
return named.map(String);
|
|
101
|
-
return commandScope ? [commandScope] : [];
|
|
102
|
-
}
|
|
103
|
-
/** A credential's refusal (its own words, uncoloured): the first line is the headline, the rest say what to do. */
|
|
104
|
-
function refusalStory(lines) {
|
|
105
|
-
return [chalk.red(lines[0] ?? ""), ...lines.slice(1)].join("\n");
|
|
106
|
-
}
|
|
107
|
-
/** A refusal of the credential itself, in its own words; null for any other answer. */
|
|
108
|
-
function credentialRefusal(err, words, commandScope) {
|
|
109
|
-
if (err.status === 403 && err.code === "INSUFFICIENT_SCOPE")
|
|
110
|
-
return words.missingScope(missingScopes(err, commandScope));
|
|
111
|
-
if (err.status === 401)
|
|
112
|
-
return words.signedOut(err.code, err.message);
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
function renderApiError(err, ctx) {
|
|
116
|
-
if (err.status === 402) {
|
|
117
|
-
const story = limitStory(`Limit exceeded: ${err.message}`, err.details);
|
|
118
|
-
return [chalk.red(story.headline), ...story.lines].join("\n");
|
|
119
|
-
}
|
|
120
|
-
const refusal = ctx.words ? credentialRefusal(err, ctx.words, ctx.scope) : null;
|
|
121
|
-
if (refusal)
|
|
122
|
-
return refusalStory(refusal);
|
|
123
|
-
if (err.status === 429) {
|
|
124
|
-
const retryAfter = err.details?.retryAfter;
|
|
125
|
-
if (typeof retryAfter === "string") {
|
|
126
|
-
return chalk.red(`Rate limited: ${err.message}. Retry after ${retryAfter}s.`);
|
|
127
|
-
}
|
|
128
|
-
return chalk.red(`Rate limited: ${err.message}. Retry in a moment.`);
|
|
129
|
-
}
|
|
130
|
-
return [
|
|
131
|
-
chalk.red(`API error ${err.status} (${err.code}): ${err.message}`),
|
|
132
|
-
...renderErrorDetails(err.details, err.message),
|
|
133
|
-
].join("\n");
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* The diagnostics a service attached to its error, rendered as readable
|
|
137
|
-
* lines. `issues` ({path, message}[] — the addon/zod validation shape) gets
|
|
138
|
-
* one line per field; everything else prints as `key: value`. This is what
|
|
139
|
-
* turns a bare `422 addon_validation_failed` into a self-diagnosing message.
|
|
140
|
-
* An issue whose line IS the headline (a one-issue refusal whose message is
|
|
141
|
-
* its issues joined, as Autopilot's are) is not printed a second time.
|
|
142
|
-
*/
|
|
143
|
-
function renderErrorDetails(details, headline) {
|
|
144
|
-
if (!details)
|
|
145
|
-
return [];
|
|
146
|
-
const lines = [];
|
|
147
|
-
for (const [key, value] of Object.entries(details)) {
|
|
148
|
-
if (key === "issues" && Array.isArray(value)) {
|
|
149
|
-
for (const issue of value) {
|
|
150
|
-
const line = `${issue.path || "(body)"}: ${issue.message ?? JSON.stringify(issue)}`;
|
|
151
|
-
if (line !== headline)
|
|
152
|
-
lines.push(chalk.dim(` - ${line}`));
|
|
153
|
-
}
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
lines.push(chalk.dim(` ${key}: ${typeof value === "string" ? value : JSON.stringify(value)}`));
|
|
157
|
-
}
|
|
158
|
-
return lines;
|
|
159
|
-
}
|
|
160
101
|
//# sourceMappingURL=output.js.map
|
package/dist/core/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/core/output.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/core/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,oBAAoB,CAAC,CAAC,0DAA0D;AAGvF,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OA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,CAAC;IACvH,IAAI,GAAG,YAAY,QAAQ,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACtI,CAAC;IACD,IAAI,GAAG,YAAY,SAAS,IAAI,GAAG,YAAY,WAAW,EAAE,CAAC;QAC3D,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;AACxG,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFC 9457 problem details, as the Front API answers every error (`application/problem+json`): the reading side.
|
|
3
|
+
* A problem carries, beyond `type`/`title`/`status`/`detail`, the retry facts a client acts on — `retryable`,
|
|
4
|
+
* `retryAfter`, `outcome` (`not_applied` | `applied` | `unknown`) and `reuseIdempotencyKey` — plus `code`,
|
|
5
|
+
* `requestId`, field `errors` and `nextSteps`. Unknown fields are kept and ignored (additive evolution).
|
|
6
|
+
*/
|
|
7
|
+
export type ProblemOutcome = "not_applied" | "applied" | "unknown";
|
|
8
|
+
export interface ProblemNextStep {
|
|
9
|
+
id?: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
/** The operation that takes the step (`front.connection.update`). */
|
|
12
|
+
operation?: string;
|
|
13
|
+
/** True for a step already taken: listed for context, never a next step. */
|
|
14
|
+
done: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface ProblemFacts {
|
|
17
|
+
code?: string;
|
|
18
|
+
detail?: string;
|
|
19
|
+
title?: string;
|
|
20
|
+
requestId?: string;
|
|
21
|
+
errors: Array<{
|
|
22
|
+
path: string;
|
|
23
|
+
message: string;
|
|
24
|
+
}>;
|
|
25
|
+
nextSteps: ProblemNextStep[];
|
|
26
|
+
retryable: boolean;
|
|
27
|
+
retryAfter?: number;
|
|
28
|
+
outcome?: ProblemOutcome;
|
|
29
|
+
reuseIdempotencyKey: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** A body is a problem when it carries the three members RFC 9457 makes the frame: type, title, status. */
|
|
32
|
+
export declare function isProblem(body: unknown): body is Record<string, unknown>;
|
|
33
|
+
export declare function problemFacts(body: Record<string, unknown>): ProblemFacts;
|
|
34
|
+
//# sourceMappingURL=problem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"problem.d.ts","sourceRoot":"","sources":["../../src/core/problem.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG,SAAS,GAAG,SAAS,CAAC;AAEnE,MAAM,WAAW,eAAe;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,mBAAmB,EAAE,OAAO,CAAC;CAC9B;AAKD,2GAA2G;AAC3G,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAExE;AAQD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY,CA4BxE"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFC 9457 problem details, as the Front API answers every error (`application/problem+json`): the reading side.
|
|
3
|
+
* A problem carries, beyond `type`/`title`/`status`/`detail`, the retry facts a client acts on — `retryable`,
|
|
4
|
+
* `retryAfter`, `outcome` (`not_applied` | `applied` | `unknown`) and `reuseIdempotencyKey` — plus `code`,
|
|
5
|
+
* `requestId`, field `errors` and `nextSteps`. Unknown fields are kept and ignored (additive evolution).
|
|
6
|
+
*/
|
|
7
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8
|
+
/** A body is a problem when it carries the three members RFC 9457 makes the frame: type, title, status. */
|
|
9
|
+
export function isProblem(body) {
|
|
10
|
+
return isRecord(body) && typeof body.type === "string" && typeof body.title === "string" && typeof body.status === "number";
|
|
11
|
+
}
|
|
12
|
+
const OUTCOMES = new Set(["not_applied", "applied", "unknown"]);
|
|
13
|
+
const isOutcome = (value) => typeof value === "string" && OUTCOMES.has(value);
|
|
14
|
+
const text = (value) => (typeof value === "string" ? value : undefined);
|
|
15
|
+
export function problemFacts(body) {
|
|
16
|
+
const errors = Array.isArray(body.errors)
|
|
17
|
+
? body.errors.filter(isRecord).map((e) => ({ path: String(e.path ?? ""), message: String(e.message ?? "") }))
|
|
18
|
+
: [];
|
|
19
|
+
const nextSteps = Array.isArray(body.nextSteps)
|
|
20
|
+
? body.nextSteps.filter(isRecord).map((s) => ({
|
|
21
|
+
...(typeof s.id === "string" ? { id: s.id } : {}),
|
|
22
|
+
...(typeof s.title === "string" ? { title: s.title } : {}),
|
|
23
|
+
...(typeof s.operation === "string" ? { operation: s.operation } : {}),
|
|
24
|
+
done: s.done === true,
|
|
25
|
+
}))
|
|
26
|
+
: [];
|
|
27
|
+
const code = text(body.code);
|
|
28
|
+
const detail = text(body.detail);
|
|
29
|
+
const title = text(body.title);
|
|
30
|
+
const requestId = text(body.requestId);
|
|
31
|
+
return {
|
|
32
|
+
...(code !== undefined ? { code } : {}),
|
|
33
|
+
...(detail !== undefined ? { detail } : {}),
|
|
34
|
+
...(title !== undefined ? { title } : {}),
|
|
35
|
+
...(requestId !== undefined ? { requestId } : {}),
|
|
36
|
+
errors,
|
|
37
|
+
nextSteps,
|
|
38
|
+
retryable: body.retryable === true,
|
|
39
|
+
...(typeof body.retryAfter === "number" ? { retryAfter: body.retryAfter } : {}),
|
|
40
|
+
...(isOutcome(body.outcome) ? { outcome: body.outcome } : {}),
|
|
41
|
+
reuseIdempotencyKey: body.reuseIdempotencyKey === true,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=problem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"problem.js","sourceRoot":"","sources":["../../src/core/problem.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA0BH,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CACpE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAEvE,2GAA2G;AAC3G,MAAM,UAAU,SAAS,CAAC,IAAa;IACrC,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,OAAO,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,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/E,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7D,mBAAmB,EAAE,IAAI,CAAC,mBAAmB,KAAK,IAAI;KACvD,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A `Retry-After` header (RFC 9110 §10.2.3) as whole seconds to wait: delta-seconds as sent (the ingress's per-IP
|
|
3
|
-
* limiter
|
|
4
|
-
* unreadable — undefined.
|
|
5
|
-
*
|
|
3
|
+
* limiter and the Front API's 429 both send those), an HTTP-date as the seconds until it (never negative), and
|
|
4
|
+
* anything else — absent or unreadable — undefined. One reader for every door that can be told to wait: the API
|
|
5
|
+
* client (core/http.ts, as ApiError's `details.retryAfter`) and the sign-in server's (core/oauth/oauth-error.ts), so
|
|
6
|
+
* a browser sign-in told to wait polls no sooner than it was asked to.
|
|
6
7
|
*/
|
|
7
8
|
export declare function retryAfterSeconds(header: string | null | undefined, now?: number): number | undefined;
|
|
8
9
|
//# sourceMappingURL=retry-after.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry-after.d.ts","sourceRoot":"","sources":["../../src/core/retry-after.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"retry-after.d.ts","sourceRoot":"","sources":["../../src/core/retry-after.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,GAAG,GAAE,MAAmB,GAAG,MAAM,GAAG,SAAS,CAOjH"}
|
package/dist/core/retry-after.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A `Retry-After` header (RFC 9110 §10.2.3) as whole seconds to wait: delta-seconds as sent (the ingress's per-IP
|
|
3
|
-
* limiter
|
|
4
|
-
* unreadable — undefined.
|
|
5
|
-
*
|
|
3
|
+
* limiter and the Front API's 429 both send those), an HTTP-date as the seconds until it (never negative), and
|
|
4
|
+
* anything else — absent or unreadable — undefined. One reader for every door that can be told to wait: the API
|
|
5
|
+
* client (core/http.ts, as ApiError's `details.retryAfter`) and the sign-in server's (core/oauth/oauth-error.ts), so
|
|
6
|
+
* a browser sign-in told to wait polls no sooner than it was asked to.
|
|
6
7
|
*/
|
|
7
8
|
export function retryAfterSeconds(header, now = Date.now()) {
|
|
8
9
|
const value = header?.trim();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry-after.js","sourceRoot":"","sources":["../../src/core/retry-after.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"retry-after.js","sourceRoot":"","sources":["../../src/core/retry-after.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAiC,EAAE,MAAc,IAAI,CAAC,GAAG,EAAE;IAC3F,MAAM,KAAK,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC;IAC7B,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC5C,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACrF,CAAC"}
|