gangtise-openapi-cli 0.10.5 → 0.10.6
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/dist/src/cli.js +25 -17
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/dist/src/cli.js
CHANGED
|
@@ -193,19 +193,25 @@ async function saveDownloadResult(result, fallbackName, output) {
|
|
|
193
193
|
}
|
|
194
194
|
const POLL_MAX_ATTEMPTS = 12;
|
|
195
195
|
const POLL_DELAY_MS = 15_000;
|
|
196
|
+
function isAsyncPending(error) {
|
|
197
|
+
return error instanceof ApiError && error.code === "410110";
|
|
198
|
+
}
|
|
196
199
|
async function pollAsyncContent(client, getContentEndpoint, dataId, format, output) {
|
|
197
200
|
for (let attempt = 1; attempt <= POLL_MAX_ATTEMPTS; attempt++) {
|
|
198
201
|
try {
|
|
199
202
|
const result = await client.call(getContentEndpoint, { dataId });
|
|
200
|
-
if (result?.content) {
|
|
203
|
+
if (result?.content != null) {
|
|
201
204
|
await printData(result, format, output);
|
|
202
205
|
return true;
|
|
203
206
|
}
|
|
204
207
|
}
|
|
205
208
|
catch (error) {
|
|
206
|
-
if (
|
|
207
|
-
|
|
209
|
+
if (error instanceof ApiError && error.code === "410111") {
|
|
210
|
+
process.stderr.write("Content generation failed (terminal). Do not retry.\n");
|
|
211
|
+
return false;
|
|
208
212
|
}
|
|
213
|
+
if (!isAsyncPending(error))
|
|
214
|
+
throw error;
|
|
209
215
|
}
|
|
210
216
|
if (attempt < POLL_MAX_ATTEMPTS) {
|
|
211
217
|
process.stderr.write(`Attempt ${attempt}/${POLL_MAX_ATTEMPTS}: content not ready, retrying in 15s...\n`);
|
|
@@ -214,22 +220,24 @@ async function pollAsyncContent(client, getContentEndpoint, dataId, format, outp
|
|
|
214
220
|
}
|
|
215
221
|
return false;
|
|
216
222
|
}
|
|
217
|
-
function checkAsyncContent(client, getContentEndpoint, dataId, format, output) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
223
|
+
async function checkAsyncContent(client, getContentEndpoint, dataId, format, output) {
|
|
224
|
+
try {
|
|
225
|
+
const result = await client.call(getContentEndpoint, { dataId });
|
|
226
|
+
if (result?.content != null) {
|
|
227
|
+
await printData(result, format, output);
|
|
228
|
+
return;
|
|
225
229
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
if (error instanceof ApiError && error.code === "410111") {
|
|
233
|
+
process.stderr.write("Content generation failed (terminal). Do not retry.\n");
|
|
234
|
+
process.exitCode = 1;
|
|
235
|
+
return;
|
|
230
236
|
}
|
|
231
|
-
|
|
232
|
-
|
|
237
|
+
if (!isAsyncPending(error))
|
|
238
|
+
throw error;
|
|
239
|
+
}
|
|
240
|
+
process.stdout.write(`${JSON.stringify({ dataId, status: "pending", hint: "Content not ready yet, retry in ~2 minutes" })}\n`);
|
|
233
241
|
}
|
|
234
242
|
function addTimeFilters(command) {
|
|
235
243
|
return command
|
package/dist/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Auto-generated — DO NOT EDIT
|
|
2
|
-
export const CLI_VERSION = "0.10.
|
|
2
|
+
export const CLI_VERSION = "0.10.6";
|