toolcraft-openapi 0.0.23 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -3
- package/dist/auth/bearer-token-auth.js +12 -3
- package/dist/auth/types.d.ts +1 -1
- package/dist/bin/generate.d.ts +5 -4
- package/dist/bin/generate.js +57 -23
- package/dist/generate.js +6 -2
- package/dist/http.js +29 -17
- package/dist/interpreter.js +12 -3
- package/dist/mock/fetch.js +22 -5
- package/dist/network-error.js +5 -3
- package/dist/redaction.d.ts +3 -0
- package/dist/redaction.js +38 -0
- package/node_modules/@poe-code/design-system/dist/acp/components.js +3 -1
- package/node_modules/@poe-code/design-system/dist/components/browser.d.ts +1 -1
- package/node_modules/@poe-code/design-system/dist/components/browser.js +6 -1
- package/node_modules/@poe-code/design-system/dist/components/color.js +9 -8
- package/node_modules/@poe-code/design-system/dist/components/command-errors.js +3 -2
- package/node_modules/@poe-code/design-system/dist/components/detail-card.d.ts +22 -0
- package/node_modules/@poe-code/design-system/dist/components/detail-card.js +69 -0
- package/node_modules/@poe-code/design-system/dist/components/help-formatter.js +88 -11
- package/node_modules/@poe-code/design-system/dist/components/index.d.ts +1 -1
- package/node_modules/@poe-code/design-system/dist/components/index.js +1 -1
- package/node_modules/@poe-code/design-system/dist/components/table.d.ts +2 -0
- package/node_modules/@poe-code/design-system/dist/components/table.js +82 -5
- package/node_modules/@poe-code/design-system/dist/components/template.d.ts +4 -0
- package/node_modules/@poe-code/design-system/dist/components/template.js +198 -32
- package/node_modules/@poe-code/design-system/dist/components/text.js +29 -5
- package/node_modules/@poe-code/design-system/dist/dashboard/ansi.d.ts +2 -2
- package/node_modules/@poe-code/design-system/dist/dashboard/ansi.js +77 -32
- package/node_modules/@poe-code/design-system/dist/dashboard/buffer.js +28 -5
- package/node_modules/@poe-code/design-system/dist/dashboard/components/output-pane.js +45 -28
- package/node_modules/@poe-code/design-system/dist/dashboard/terminal-width.d.ts +4 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/terminal-width.js +71 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/types.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/explorer/events.d.ts +6 -0
- package/node_modules/@poe-code/design-system/dist/explorer/reducer.js +32 -10
- package/node_modules/@poe-code/design-system/dist/explorer/render/detail.js +3 -0
- package/node_modules/@poe-code/design-system/dist/explorer/runtime.js +57 -6
- package/node_modules/@poe-code/design-system/dist/explorer/state.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/explorer/state.js +12 -15
- package/node_modules/@poe-code/design-system/dist/index.d.ts +3 -1
- package/node_modules/@poe-code/design-system/dist/index.js +2 -1
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/intro.js +2 -1
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/log.js +8 -5
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/note.js +1 -1
- package/node_modules/@poe-code/design-system/dist/static/menu.js +8 -2
- package/node_modules/@poe-code/design-system/dist/static/spinner.js +10 -4
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser/frontmatter.js +9 -2
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/renderer.js +19 -2
- package/node_modules/@poe-code/design-system/package.json +2 -1
- package/node_modules/auth-store/dist/create-secret-store.js +4 -1
- package/node_modules/auth-store/dist/encrypted-file-store.d.ts +8 -0
- package/node_modules/auth-store/dist/encrypted-file-store.js +104 -8
- package/node_modules/auth-store/dist/index.d.ts +1 -1
- package/node_modules/auth-store/dist/keychain-store.d.ts +4 -1
- package/node_modules/auth-store/dist/keychain-store.js +18 -16
- package/node_modules/auth-store/dist/provider-store.d.ts +5 -1
- package/node_modules/auth-store/dist/provider-store.js +55 -7
- package/node_modules/auth-store/dist/types.d.ts +3 -1
- package/node_modules/auth-store/package.json +2 -1
- package/package.json +3 -3
- package/dist/lock.d.ts +0 -14
- package/dist/lock.js +0 -152
package/dist/lock.js
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { UserError } from "toolcraft";
|
|
3
|
-
import { renderSourceSnippet } from "toolcraft/source-snippet";
|
|
4
|
-
export function parseOpenApiLock(contents, lockPath) {
|
|
5
|
-
let parsed;
|
|
6
|
-
try {
|
|
7
|
-
parsed = JSON.parse(contents);
|
|
8
|
-
}
|
|
9
|
-
catch (error) {
|
|
10
|
-
throw new UserError(formatJsonParseError(lockPath, contents, error), { cause: error });
|
|
11
|
-
}
|
|
12
|
-
if (typeof parsed !== "object" ||
|
|
13
|
-
parsed === null ||
|
|
14
|
-
parsed.version !== 1 ||
|
|
15
|
-
typeof parsed.specSha !== "string" ||
|
|
16
|
-
parsed.specSha.length === 0) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
specSha: parsed.specSha
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export function stringifyOpenApiLock(lock) {
|
|
24
|
-
const document = {
|
|
25
|
-
version: 1,
|
|
26
|
-
specSha: lock.specSha
|
|
27
|
-
};
|
|
28
|
-
return `${JSON.stringify(document, null, 2)}\n`;
|
|
29
|
-
}
|
|
30
|
-
export async function readOpenApiLock(fs, lockPath) {
|
|
31
|
-
try {
|
|
32
|
-
return parseOpenApiLock(await fs.readFile(lockPath, "utf8"), lockPath);
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
if (isNotFoundError(error)) {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
throw error;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
export async function writeOpenApiLock(fs, lockPath, lock) {
|
|
42
|
-
await fs.mkdir(path.dirname(lockPath), { recursive: true });
|
|
43
|
-
try {
|
|
44
|
-
await fs.writeFile(lockPath, stringifyOpenApiLock(lock), "utf8");
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
const code = getErrorCode(error);
|
|
48
|
-
throw new UserError(`Failed to write lock file "${lockPath}"${code === undefined ? "" : ` (${code})`}: ${getErrorMessage(error)}`, { cause: error });
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function isNotFoundError(error) {
|
|
52
|
-
return (typeof error === "object" &&
|
|
53
|
-
error !== null &&
|
|
54
|
-
"code" in error &&
|
|
55
|
-
error.code === "ENOENT");
|
|
56
|
-
}
|
|
57
|
-
function getErrorMessage(error) {
|
|
58
|
-
return error instanceof Error ? error.message : String(error);
|
|
59
|
-
}
|
|
60
|
-
function formatJsonParseError(lockPath, source, error) {
|
|
61
|
-
const location = getJsonParseErrorLocation(error, source);
|
|
62
|
-
const message = getErrorMessage(error);
|
|
63
|
-
if (location === null) {
|
|
64
|
-
return `Lock file "${lockPath}" is not valid JSON: ${message}.`;
|
|
65
|
-
}
|
|
66
|
-
return (`Lock file "${lockPath}" is not valid JSON: ${message} ` +
|
|
67
|
-
`at line ${location.line} column ${location.column}.\n` +
|
|
68
|
-
renderSourceSnippet({
|
|
69
|
-
source,
|
|
70
|
-
line: location.line,
|
|
71
|
-
column: location.column,
|
|
72
|
-
filePath: lockPath
|
|
73
|
-
}));
|
|
74
|
-
}
|
|
75
|
-
function getJsonParseErrorLocation(error, source) {
|
|
76
|
-
const causeLocation = getJsonParseCauseLocation(error);
|
|
77
|
-
if (causeLocation !== null) {
|
|
78
|
-
return causeLocation;
|
|
79
|
-
}
|
|
80
|
-
const directPosition = getNumericProperty(error, "position");
|
|
81
|
-
if (directPosition !== null) {
|
|
82
|
-
return getSourceOffsetLocation(source, directPosition);
|
|
83
|
-
}
|
|
84
|
-
const messagePosition = getJsonParseMessagePosition(getErrorMessage(error));
|
|
85
|
-
if (messagePosition !== null) {
|
|
86
|
-
return getSourceOffsetLocation(source, messagePosition);
|
|
87
|
-
}
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
function getJsonParseCauseLocation(error) {
|
|
91
|
-
if (typeof error !== "object" || error === null || !("cause" in error)) {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
const cause = error.cause;
|
|
95
|
-
const line = getNumericProperty(cause, "line");
|
|
96
|
-
const column = getNumericProperty(cause, "column") ?? getNumericProperty(cause, "col");
|
|
97
|
-
if (line === null || column === null) {
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
return { line, column };
|
|
101
|
-
}
|
|
102
|
-
function getNumericProperty(value, key) {
|
|
103
|
-
if (typeof value !== "object" || value === null || !(key in value)) {
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
const propertyValue = value[key];
|
|
107
|
-
return typeof propertyValue === "number" && Number.isFinite(propertyValue)
|
|
108
|
-
? propertyValue
|
|
109
|
-
: null;
|
|
110
|
-
}
|
|
111
|
-
function getJsonParseMessagePosition(message) {
|
|
112
|
-
const marker = " at position ";
|
|
113
|
-
const markerIndex = message.indexOf(marker);
|
|
114
|
-
if (markerIndex === -1) {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
const startIndex = markerIndex + marker.length;
|
|
118
|
-
let endIndex = startIndex;
|
|
119
|
-
while (endIndex < message.length && isAsciiDigit(message[endIndex] ?? "")) {
|
|
120
|
-
endIndex += 1;
|
|
121
|
-
}
|
|
122
|
-
if (endIndex === startIndex) {
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
return Number.parseInt(message.slice(startIndex, endIndex), 10);
|
|
126
|
-
}
|
|
127
|
-
function getSourceOffsetLocation(source, offset) {
|
|
128
|
-
let line = 1;
|
|
129
|
-
let column = 1;
|
|
130
|
-
const boundedOffset = Math.max(0, Math.floor(offset));
|
|
131
|
-
for (let index = 0; index < boundedOffset && index < source.length; index += 1) {
|
|
132
|
-
if (source[index] === "\n") {
|
|
133
|
-
line += 1;
|
|
134
|
-
column = 1;
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
column += 1;
|
|
138
|
-
}
|
|
139
|
-
return { line, column };
|
|
140
|
-
}
|
|
141
|
-
function isAsciiDigit(value) {
|
|
142
|
-
return value >= "0" && value <= "9";
|
|
143
|
-
}
|
|
144
|
-
function getErrorCode(error) {
|
|
145
|
-
if (typeof error === "object" &&
|
|
146
|
-
error !== null &&
|
|
147
|
-
"code" in error &&
|
|
148
|
-
typeof error.code === "string") {
|
|
149
|
-
return error.code;
|
|
150
|
-
}
|
|
151
|
-
return undefined;
|
|
152
|
-
}
|