bukesiyi-cli 0.4.0 → 0.5.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/README.md +51 -8
- package/dist/main.js +2060 -162
- package/package.json +3 -3
package/dist/main.js
CHANGED
|
@@ -95,6 +95,7 @@ var CliError = class _CliError extends Error {
|
|
|
95
95
|
hints;
|
|
96
96
|
recovery;
|
|
97
97
|
failures;
|
|
98
|
+
webRecovery;
|
|
98
99
|
constructor(init) {
|
|
99
100
|
super(redactKeys(init.message));
|
|
100
101
|
this.name = "CliError";
|
|
@@ -107,6 +108,7 @@ var CliError = class _CliError extends Error {
|
|
|
107
108
|
this.hints = init.hints ?? [];
|
|
108
109
|
if (init.recovery !== void 0) this.recovery = init.recovery;
|
|
109
110
|
if (init.failures !== void 0) this.failures = init.failures;
|
|
111
|
+
if (init.webRecovery !== void 0) this.webRecovery = init.webRecovery;
|
|
110
112
|
}
|
|
111
113
|
withHint(hint) {
|
|
112
114
|
return new _CliError({
|
|
@@ -119,7 +121,8 @@ var CliError = class _CliError extends Error {
|
|
|
119
121
|
httpStatus: this.httpStatus,
|
|
120
122
|
hints: [...this.hints, hint],
|
|
121
123
|
recovery: this.recovery,
|
|
122
|
-
failures: this.failures
|
|
124
|
+
failures: this.failures,
|
|
125
|
+
webRecovery: this.webRecovery
|
|
123
126
|
});
|
|
124
127
|
}
|
|
125
128
|
withRecovery(recovery) {
|
|
@@ -133,9 +136,13 @@ var CliError = class _CliError extends Error {
|
|
|
133
136
|
httpStatus: this.httpStatus,
|
|
134
137
|
hints: this.hints,
|
|
135
138
|
recovery,
|
|
136
|
-
failures: this.failures
|
|
139
|
+
failures: this.failures,
|
|
140
|
+
webRecovery: this.webRecovery
|
|
137
141
|
});
|
|
138
142
|
}
|
|
143
|
+
withWebRecovery(webRecovery) {
|
|
144
|
+
return new _CliError({ ...this, message: this.message, webRecovery });
|
|
145
|
+
}
|
|
139
146
|
};
|
|
140
147
|
function usageError(message2) {
|
|
141
148
|
return new CliError({ code: "CLI_USAGE", exitCode: EXIT.USAGE, message: `${message2}\u3002\u8FD0\u884C buke --help \u770B\u7528\u6CD5` });
|
|
@@ -265,10 +272,10 @@ function toBuffer(chunk) {
|
|
|
265
272
|
return Buffer.from(chunk);
|
|
266
273
|
}
|
|
267
274
|
function readToEnd(stdin, timeoutMs, signal) {
|
|
268
|
-
return new Promise((
|
|
275
|
+
return new Promise((resolve3, reject) => {
|
|
269
276
|
const state = stdin;
|
|
270
277
|
if (state.readableEnded === true || state.destroyed === true) {
|
|
271
|
-
|
|
278
|
+
resolve3("");
|
|
272
279
|
return;
|
|
273
280
|
}
|
|
274
281
|
const chunks = [];
|
|
@@ -296,7 +303,7 @@ function readToEnd(stdin, timeoutMs, signal) {
|
|
|
296
303
|
}
|
|
297
304
|
chunks.push(piece);
|
|
298
305
|
};
|
|
299
|
-
const onEnd = () => settle(() =>
|
|
306
|
+
const onEnd = () => settle(() => resolve3(Buffer.concat(chunks).toString("utf8").trim()));
|
|
300
307
|
const onError = (error) => settle(() => reject(missingKey(`\u6CA1\u6709\u8BFB\u5230\u5BC6\u94A5\uFF1A\u6807\u51C6\u8F93\u5165\u51FA\u9519\uFF08${briefReason(error)}\uFF09`)));
|
|
301
308
|
const timer = setTimeout(() => {
|
|
302
309
|
settle(
|
|
@@ -316,7 +323,7 @@ function readToEnd(stdin, timeoutMs, signal) {
|
|
|
316
323
|
});
|
|
317
324
|
}
|
|
318
325
|
function readHiddenLine(stdin, signal) {
|
|
319
|
-
return new Promise((
|
|
326
|
+
return new Promise((resolve3, reject) => {
|
|
320
327
|
let typed = "";
|
|
321
328
|
let escape = "none";
|
|
322
329
|
let settled = false;
|
|
@@ -347,7 +354,7 @@ function readHiddenLine(stdin, signal) {
|
|
|
347
354
|
continue;
|
|
348
355
|
}
|
|
349
356
|
if (char === "\r" || char === "\n") {
|
|
350
|
-
settle(() =>
|
|
357
|
+
settle(() => resolve3(typed));
|
|
351
358
|
return;
|
|
352
359
|
}
|
|
353
360
|
if (char === CTRL_C) {
|
|
@@ -355,7 +362,7 @@ function readHiddenLine(stdin, signal) {
|
|
|
355
362
|
return;
|
|
356
363
|
}
|
|
357
364
|
if (char === CTRL_D) {
|
|
358
|
-
settle(() => typed === "" ? reject(missingKey(NO_KEY_READ)) :
|
|
365
|
+
settle(() => typed === "" ? reject(missingKey(NO_KEY_READ)) : resolve3(typed));
|
|
359
366
|
return;
|
|
360
367
|
}
|
|
361
368
|
if (char === DELETE || char === BACKSPACE) {
|
|
@@ -375,7 +382,7 @@ function readHiddenLine(stdin, signal) {
|
|
|
375
382
|
}
|
|
376
383
|
if (escape === "started") escape = "carried";
|
|
377
384
|
};
|
|
378
|
-
const onEnd = () => settle(() =>
|
|
385
|
+
const onEnd = () => settle(() => resolve3(typed));
|
|
379
386
|
const onError = (error) => settle(() => reject(missingKey(`\u6CA1\u6709\u8BFB\u5230\u5BC6\u94A5\uFF1A\u6807\u51C6\u8F93\u5165\u51FA\u9519\uFF08${briefReason(error)}\uFF09`)));
|
|
380
387
|
const onAbort = () => settle(() => reject(interruptedError(CANCELLED)));
|
|
381
388
|
stdin.on("data", onData);
|
|
@@ -420,7 +427,7 @@ async function readNewKey(io) {
|
|
|
420
427
|
|
|
421
428
|
// package.json
|
|
422
429
|
var name = "bukesiyi-cli";
|
|
423
|
-
var version = "0.
|
|
430
|
+
var version = "0.5.0";
|
|
424
431
|
|
|
425
432
|
// src/version.ts
|
|
426
433
|
var PACKAGE_NAME = name;
|
|
@@ -440,9 +447,25 @@ function taskRecovery(taskType, taskId, status4, baseUrl, failureCode) {
|
|
|
440
447
|
...customOrigin ? { baseUrl } : {},
|
|
441
448
|
...failureCode === void 0 || failureCode === "" ? {} : { failureCode },
|
|
442
449
|
nextAction: "query",
|
|
443
|
-
statusCommand: `buke ${taskType} status ${shellArgument(taskId)}` + (customOrigin ? ` --base-url ${shellArgument(baseUrl)}` : "")
|
|
450
|
+
statusCommand: `buke ${taskType} ${taskType === "products" ? "show" : "status"} ${shellArgument(taskId)}` + (customOrigin ? ` --base-url ${shellArgument(baseUrl)}` : "")
|
|
444
451
|
};
|
|
445
452
|
}
|
|
453
|
+
async function retainMutationOnError(taskType, taskId, idempotencyKey, baseUrl, operation, extra = {}) {
|
|
454
|
+
try {
|
|
455
|
+
return await operation();
|
|
456
|
+
} catch (error) {
|
|
457
|
+
const failure = toCliError(error);
|
|
458
|
+
const rejected = failure.httpStatus !== void 0 && failure.httpStatus >= 400 && failure.httpStatus < 500 && failure.httpStatus !== 408;
|
|
459
|
+
throw failure.withRecovery({
|
|
460
|
+
...taskRecovery(taskType, taskId, void 0, baseUrl),
|
|
461
|
+
acceptance: "unknown",
|
|
462
|
+
idempotencyKey,
|
|
463
|
+
operationOutcome: rejected ? "rejected" : "unknown",
|
|
464
|
+
...extra,
|
|
465
|
+
...failure.recovery
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
}
|
|
446
469
|
function dramaConfirmationRecovery(orderId, status4, baseUrl, idempotencyKey, operationOutcome) {
|
|
447
470
|
return {
|
|
448
471
|
...taskRecovery("drama", orderId, status4, baseUrl),
|
|
@@ -762,11 +785,11 @@ async function requestJson(baseUrl, apiKey, plan, deps) {
|
|
|
762
785
|
async function getJson(baseUrl, apiKey, path, deps) {
|
|
763
786
|
return requestJson(baseUrl, apiKey, { method: "GET", path }, deps);
|
|
764
787
|
}
|
|
765
|
-
async function postJson(baseUrl, apiKey, path, body, idempotencyKey, deps) {
|
|
788
|
+
async function postJson(baseUrl, apiKey, path, body, idempotencyKey, deps, options = {}) {
|
|
766
789
|
return requestJson(
|
|
767
790
|
baseUrl,
|
|
768
791
|
apiKey,
|
|
769
|
-
{ method: "POST", path, body: JSON.stringify(body), contentType: "application/json", idempotencyKey },
|
|
792
|
+
{ method: "POST", path, body: JSON.stringify(body), contentType: "application/json", idempotencyKey, ...options },
|
|
770
793
|
deps
|
|
771
794
|
);
|
|
772
795
|
}
|
|
@@ -845,6 +868,28 @@ function assetMimeMatchesBytes(mime, bytes) {
|
|
|
845
868
|
if (mime === "audio/wav" || mime === "audio/x-wav") return bytes.length > 44 && bytes.toString("ascii", 0, 4) === "RIFF" && bytes.toString("ascii", 8, 12) === "WAVE";
|
|
846
869
|
if (mime === "video/webm" || mime === "audio/webm") return bytes.length >= 8 && bytes.subarray(0, 4).toString("hex") === "1a45dfa3" && bytes.subarray(4, 4096).includes(Buffer.from("webm"));
|
|
847
870
|
if (mime === "audio/mpeg") return bytes.length >= 3 && (bytes.toString("ascii", 0, 3) === "ID3" || bytes[0] === 255 && (bytes[1] & 224) === 224);
|
|
871
|
+
if (mime === "audio/aac") {
|
|
872
|
+
if (bytes.length < 7 || bytes[0] !== 255 || (bytes[1] & 246) !== 240 || (bytes[2] >> 2 & 15) > 12) return false;
|
|
873
|
+
const headerBytes = bytes[1] & 1 ? 7 : 9;
|
|
874
|
+
const frameBytes = (bytes[3] & 3) << 11 | bytes[4] << 3 | bytes[5] >> 5;
|
|
875
|
+
return frameBytes > headerBytes && frameBytes <= bytes.length;
|
|
876
|
+
}
|
|
877
|
+
if (mime === "audio/ogg") {
|
|
878
|
+
if (bytes.length < 28 || bytes.toString("ascii", 0, 4) !== "OggS" || bytes[4] !== 0) return false;
|
|
879
|
+
const segments = bytes[26], headerBytes = 27 + segments;
|
|
880
|
+
if (segments === 0 || headerBytes > bytes.length) return false;
|
|
881
|
+
const payloadBytes = bytes.subarray(27, headerBytes).reduce((sum, length) => sum + length, 0);
|
|
882
|
+
return payloadBytes > 0 && headerBytes + payloadBytes <= bytes.length;
|
|
883
|
+
}
|
|
884
|
+
if (mime === "text/vtt") return !bytes.includes(0) && /^\uFEFF?WEBVTT(?:[ \t][^\r\n]*)?(?:\r?\n|$)/u.test(bytes.toString("utf8", 0, Math.min(bytes.length, 4096)));
|
|
885
|
+
if (mime === "application/x-subrip") {
|
|
886
|
+
if (bytes.includes(0)) return false;
|
|
887
|
+
const cue = /^\uFEFF?\s*\d+\r?\n(\d{2,}):([0-5]\d):([0-5]\d),(\d{3})[ \t]+-->[ \t]+(\d{2,}):([0-5]\d):([0-5]\d),(\d{3})(?:[ \t][^\r\n]*)?\r?\n/u.exec(bytes.toString("utf8", 0, Math.min(bytes.length, 4096)));
|
|
888
|
+
if (!cue) return false;
|
|
889
|
+
const start = ((Number(cue[1]) * 60 + Number(cue[2])) * 60 + Number(cue[3])) * 1e3 + Number(cue[4]);
|
|
890
|
+
const end = ((Number(cue[5]) * 60 + Number(cue[6])) * 60 + Number(cue[7])) * 1e3 + Number(cue[8]);
|
|
891
|
+
return Number.isSafeInteger(start) && Number.isSafeInteger(end) && end > start;
|
|
892
|
+
}
|
|
848
893
|
if (mime === "application/pdf") {
|
|
849
894
|
let offset = bytes.length >= 3 && bytes.subarray(0, 3).toString("hex") === "efbbbf" ? 3 : 0;
|
|
850
895
|
const limit = Math.min(bytes.length, 1024);
|
|
@@ -1066,7 +1111,7 @@ function parseDramaOrder(body) {
|
|
|
1066
1111
|
const money = parseDramaMoney(order2.money);
|
|
1067
1112
|
if (money === null) problems.push("money");
|
|
1068
1113
|
const actionsValue = Array.isArray(order2.nextActions) ? order2.nextActions : null;
|
|
1069
|
-
const actions = actionsValue === null ? [] : actionsValue.filter((
|
|
1114
|
+
const actions = actionsValue === null ? [] : actionsValue.filter((action2) => typeof action2 === "string");
|
|
1070
1115
|
if (actionsValue === null || actions.length !== actionsValue.length) problems.push("nextActions");
|
|
1071
1116
|
const gapsValue = order2.gaps === void 0 ? void 0 : Array.isArray(order2.gaps) ? order2.gaps : null;
|
|
1072
1117
|
if (order2.gaps !== void 0 && gapsValue === null) problems.push("gaps");
|
|
@@ -1160,7 +1205,11 @@ function parseRun(body) {
|
|
|
1160
1205
|
problems.push("message");
|
|
1161
1206
|
return { role: "", text: "" };
|
|
1162
1207
|
}
|
|
1163
|
-
return {
|
|
1208
|
+
return {
|
|
1209
|
+
role: typeof message2.role === "string" ? message2.role : "",
|
|
1210
|
+
text: message2.text,
|
|
1211
|
+
...typeof message2.earlierAttemptOf === "string" && message2.earlierAttemptOf ? { earlierAttemptOf: message2.earlierAttemptOf } : {}
|
|
1212
|
+
};
|
|
1164
1213
|
});
|
|
1165
1214
|
const failureValue = isRecord2(run2.failure) ? run2.failure : null;
|
|
1166
1215
|
const failure = failureValue ? {
|
|
@@ -1181,8 +1230,8 @@ function parseRun(body) {
|
|
|
1181
1230
|
productionConfirmed: run2.productionConfirmed === true,
|
|
1182
1231
|
...currentProductionCredits !== void 0 ? { currentProductionCredits } : {},
|
|
1183
1232
|
product: product ? { id: text(product.id), name: text(product.name) } : { id: "", name: "" },
|
|
1184
|
-
nextActions: actions === null ? [] : actions.map((
|
|
1185
|
-
const parsed2 = parseRunAction(
|
|
1233
|
+
nextActions: actions === null ? [] : actions.map((action2) => {
|
|
1234
|
+
const parsed2 = parseRunAction(action2);
|
|
1186
1235
|
if (parsed2 === null) problems.push("action");
|
|
1187
1236
|
return parsed2 ?? { type: "" };
|
|
1188
1237
|
}),
|
|
@@ -1221,45 +1270,51 @@ async function getBalance(baseUrl, apiKey, deps) {
|
|
|
1221
1270
|
return { view: balance2, raw: reply.body };
|
|
1222
1271
|
}
|
|
1223
1272
|
async function createProduct(baseUrl, apiKey, name2, category, idempotencyKey, deps, fields3 = {}) {
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1273
|
+
return retainSubmissionOnError("products", idempotencyKey, baseUrl, async () => {
|
|
1274
|
+
const reply = await postJson(
|
|
1275
|
+
baseUrl,
|
|
1276
|
+
apiKey,
|
|
1277
|
+
"/api/open/v1/products",
|
|
1278
|
+
{ ...fields3, name: name2, ...category === void 0 ? {} : { category } },
|
|
1279
|
+
idempotencyKey,
|
|
1280
|
+
deps
|
|
1281
|
+
);
|
|
1282
|
+
const product = parseProduct(reply.body);
|
|
1283
|
+
if (!product || !isRecord2(reply.body)) throw unreadableResponse(reply.status);
|
|
1284
|
+
return { view: product, raw: reply.body, replayed: reply.status === 200 };
|
|
1285
|
+
});
|
|
1235
1286
|
}
|
|
1236
1287
|
async function putProductImage(baseUrl, apiKey, productId, angle, bytes, contentType, idempotencyKey, deps) {
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1288
|
+
return retainMutationOnError("products", productId, idempotencyKey, baseUrl, async () => {
|
|
1289
|
+
const reply = await putRaw(
|
|
1290
|
+
baseUrl,
|
|
1291
|
+
apiKey,
|
|
1292
|
+
`/api/open/v1/products/${encodeURIComponent(productId)}/images?angle=${angle}`,
|
|
1293
|
+
bytes,
|
|
1294
|
+
contentType,
|
|
1295
|
+
idempotencyKey,
|
|
1296
|
+
deps
|
|
1297
|
+
);
|
|
1298
|
+
const product = parseProduct(reply.body);
|
|
1299
|
+
if (!product || !isRecord2(reply.body)) throw unreadableResponse(reply.status);
|
|
1300
|
+
return { view: product, raw: reply.body, replayed: reply.status === 200 };
|
|
1301
|
+
});
|
|
1249
1302
|
}
|
|
1250
1303
|
async function confirmProductLock(baseUrl, apiKey, productId, lock, idempotencyKey, deps) {
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1304
|
+
return retainMutationOnError("products", productId, idempotencyKey, baseUrl, async () => {
|
|
1305
|
+
const reply = await postJson(
|
|
1306
|
+
baseUrl,
|
|
1307
|
+
apiKey,
|
|
1308
|
+
`/api/open/v1/products/${encodeURIComponent(productId)}/lock/confirm`,
|
|
1309
|
+
{ productLock: lock },
|
|
1310
|
+
idempotencyKey,
|
|
1311
|
+
deps
|
|
1312
|
+
);
|
|
1313
|
+
const productLock = parseProductLock(reply.body);
|
|
1314
|
+
const product = parseProduct(reply.body);
|
|
1315
|
+
if (!productLock || !product || !isRecord2(reply.body)) throw unreadableResponse(reply.status);
|
|
1316
|
+
return { view: { productLock, product }, raw: reply.body };
|
|
1317
|
+
});
|
|
1263
1318
|
}
|
|
1264
1319
|
async function getTemplateShortCatalog(baseUrl, apiKey, deps) {
|
|
1265
1320
|
const reply = await getJson(baseUrl, apiKey, "/api/open/v1/template-shorts", deps);
|
|
@@ -1269,9 +1324,9 @@ async function getTemplateShortCatalog(baseUrl, apiKey, deps) {
|
|
|
1269
1324
|
}
|
|
1270
1325
|
async function uploadTemplateShortAsset(baseUrl, apiKey, bytes, contentType, idempotencyKey, deps) {
|
|
1271
1326
|
const reply = await postRaw(baseUrl, apiKey, "/api/open/v1/template-shorts/uploads", bytes, contentType, idempotencyKey, deps);
|
|
1272
|
-
const
|
|
1273
|
-
if (!
|
|
1274
|
-
return { view:
|
|
1327
|
+
const upload3 = parseUpload(reply.body);
|
|
1328
|
+
if (!upload3 || !isRecord2(reply.body)) throw unreadableResponse(reply.status);
|
|
1329
|
+
return { view: upload3, raw: reply.body };
|
|
1275
1330
|
}
|
|
1276
1331
|
async function quoteTemplateShort(baseUrl, apiKey, templateId, props, idempotencyKey, deps) {
|
|
1277
1332
|
const reply = await postJson(
|
|
@@ -1329,13 +1384,13 @@ async function runReplyOf(reply) {
|
|
|
1329
1384
|
return { view: run2, raw: reply.body };
|
|
1330
1385
|
}
|
|
1331
1386
|
async function createVideoRun(baseUrl, apiKey, body, idempotencyKey, deps) {
|
|
1332
|
-
return runReplyOf(await postJson(baseUrl, apiKey, "/api/open/v1/videos", body, idempotencyKey, deps));
|
|
1387
|
+
return retainSubmissionOnError("videos", idempotencyKey, baseUrl, async () => runReplyOf(await postJson(baseUrl, apiKey, "/api/open/v1/videos", body, idempotencyKey, deps)));
|
|
1333
1388
|
}
|
|
1334
1389
|
async function getVideoRun(baseUrl, apiKey, runId, deps) {
|
|
1335
1390
|
return runReplyOf(await getJson(baseUrl, apiKey, `/api/open/v1/videos/${encodeURIComponent(runId)}`, deps));
|
|
1336
1391
|
}
|
|
1337
1392
|
async function confirmVideoProduction(baseUrl, apiKey, runId, expectedVersion, confirmation, idempotencyKey, deps) {
|
|
1338
|
-
return runReplyOf(
|
|
1393
|
+
return retainMutationOnError("videos", runId, idempotencyKey, baseUrl, async () => runReplyOf(
|
|
1339
1394
|
await postJson(
|
|
1340
1395
|
baseUrl,
|
|
1341
1396
|
apiKey,
|
|
@@ -1344,16 +1399,18 @@ async function confirmVideoProduction(baseUrl, apiKey, runId, expectedVersion, c
|
|
|
1344
1399
|
idempotencyKey,
|
|
1345
1400
|
deps
|
|
1346
1401
|
)
|
|
1347
|
-
);
|
|
1402
|
+
), { operation: "confirm", videoConfirmation: { expectedVersion, confirmation } });
|
|
1348
1403
|
}
|
|
1349
1404
|
async function downloadVideo(baseUrl, apiKey, runId, deps) {
|
|
1350
1405
|
return downloadFile(baseUrl, apiKey, `/api/open/v1/videos/${encodeURIComponent(runId)}/download`, deps);
|
|
1351
1406
|
}
|
|
1352
1407
|
async function createDramaOrder(baseUrl, apiKey, body, idempotencyKey, deps) {
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1408
|
+
return retainSubmissionOnError("drama", idempotencyKey, baseUrl, async () => {
|
|
1409
|
+
const reply = await postJson(baseUrl, apiKey, "/api/open/v1/drama/orders", body, idempotencyKey, deps);
|
|
1410
|
+
const view = parseDramaOrder(reply.body);
|
|
1411
|
+
if (!view || !isRecord2(reply.body)) throw unreadableResponse(reply.status);
|
|
1412
|
+
return { view, raw: reply.body, replayed: reply.status === 200 };
|
|
1413
|
+
});
|
|
1357
1414
|
}
|
|
1358
1415
|
async function getDramaOrder(baseUrl, apiKey, orderId, deps) {
|
|
1359
1416
|
const reply = await getJson(baseUrl, apiKey, `/api/open/v1/drama/orders/${encodeURIComponent(orderId)}`, deps);
|
|
@@ -1407,7 +1464,7 @@ var ORDER_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["succeeded", "failed", "c
|
|
|
1407
1464
|
var RUN_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["succeeded", "failed", "canceled"]);
|
|
1408
1465
|
var RUN_WAITING_FOR_USER_STATUSES = /* @__PURE__ */ new Set(["needs_input", "awaiting_reply", "awaiting_confirmation"]);
|
|
1409
1466
|
var DRAMA_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["delivered", "failed", "canceled", "partial"]);
|
|
1410
|
-
var DRAMA_WAITING_FOR_USER_STATUSES = /* @__PURE__ */ new Set(["needs_attention"]);
|
|
1467
|
+
var DRAMA_WAITING_FOR_USER_STATUSES = /* @__PURE__ */ new Set(["needs_attention", "quotable"]);
|
|
1411
1468
|
async function awaitTemplateShortOrder(baseUrl, apiKey, start, deps, wait2) {
|
|
1412
1469
|
let current = start;
|
|
1413
1470
|
if (ORDER_TERMINAL_STATUSES.has(current.view.status)) return { value: current, timedOut: false };
|
|
@@ -1565,6 +1622,9 @@ function locate(io) {
|
|
|
1565
1622
|
}
|
|
1566
1623
|
return { dir: join(home, ".config", "buke"), ours: true };
|
|
1567
1624
|
}
|
|
1625
|
+
function credentialsDir(io) {
|
|
1626
|
+
return locate(io).dir;
|
|
1627
|
+
}
|
|
1568
1628
|
function credentialsPath(io) {
|
|
1569
1629
|
return join(locate(io).dir, FILE_NAME);
|
|
1570
1630
|
}
|
|
@@ -1855,11 +1915,20 @@ async function readPropsArgument(io, ref, what) {
|
|
|
1855
1915
|
return parsed;
|
|
1856
1916
|
}
|
|
1857
1917
|
async function readStdinAll(io, maxBytes, what) {
|
|
1918
|
+
if (io.signal?.aborted) throw interruptedError();
|
|
1858
1919
|
const stdin = io.stdin;
|
|
1859
1920
|
if (stdin.readableEnded === true) return "";
|
|
1860
1921
|
const chunks = [];
|
|
1861
1922
|
let size = 0;
|
|
1862
|
-
await new Promise((
|
|
1923
|
+
await new Promise((resolve3, reject) => {
|
|
1924
|
+
const onAbort = () => {
|
|
1925
|
+
cleanup();
|
|
1926
|
+
reject(interruptedError());
|
|
1927
|
+
};
|
|
1928
|
+
const timer = setTimeout(() => {
|
|
1929
|
+
cleanup();
|
|
1930
|
+
reject(new CliError({ code: "CLI_STDIN_TIMEOUT", exitCode: EXIT.USAGE, message: `${what}\u6807\u51C6\u8F93\u5165\u7B49\u5F85\u8D85\u65F6\uFF0C\u8BF7\u63D0\u4F9B\u5B8C\u6574 JSON \u5E76\u5173\u95ED\u8F93\u5165\u6D41` }));
|
|
1931
|
+
}, io.stdinTimeoutMs ?? DEFAULT_STDIN_TIMEOUT_MS);
|
|
1863
1932
|
const toBuffer2 = (chunk) => typeof chunk === "string" ? Buffer.from(chunk, "utf8") : Buffer.from(chunk);
|
|
1864
1933
|
const onData = (chunk) => {
|
|
1865
1934
|
const piece = toBuffer2(chunk);
|
|
@@ -1873,25 +1942,49 @@ async function readStdinAll(io, maxBytes, what) {
|
|
|
1873
1942
|
};
|
|
1874
1943
|
const onEnd = () => {
|
|
1875
1944
|
cleanup();
|
|
1876
|
-
|
|
1945
|
+
resolve3();
|
|
1877
1946
|
};
|
|
1878
1947
|
const onError = (error) => {
|
|
1879
1948
|
cleanup();
|
|
1880
1949
|
reject(new CliError({ code: "CLI_USAGE", exitCode: EXIT.USAGE, message: `\u6807\u51C6\u8F93\u5165\u8BFB\u4E0D\u4E86\uFF1A${briefReason(error)}` }));
|
|
1881
1950
|
};
|
|
1951
|
+
const onClose = () => onError(new Error("\u6807\u51C6\u8F93\u5165\u63D0\u524D\u5173\u95ED"));
|
|
1882
1952
|
const cleanup = () => {
|
|
1953
|
+
clearTimeout(timer);
|
|
1954
|
+
io.signal?.removeEventListener("abort", onAbort);
|
|
1883
1955
|
stdin.removeListener("data", onData);
|
|
1884
1956
|
stdin.removeListener("end", onEnd);
|
|
1885
1957
|
stdin.removeListener("error", onError);
|
|
1958
|
+
stdin.removeListener("close", onClose);
|
|
1886
1959
|
stdin.pause();
|
|
1887
1960
|
};
|
|
1888
1961
|
stdin.on("data", onData);
|
|
1889
1962
|
stdin.on("end", onEnd);
|
|
1890
1963
|
stdin.on("error", onError);
|
|
1964
|
+
stdin.on("close", onClose);
|
|
1965
|
+
io.signal?.addEventListener("abort", onAbort, { once: true });
|
|
1891
1966
|
stdin.resume();
|
|
1892
1967
|
});
|
|
1893
1968
|
return Buffer.concat(chunks).toString("utf8");
|
|
1894
1969
|
}
|
|
1970
|
+
async function sleepFor(io, ms) {
|
|
1971
|
+
if (io.signal?.aborted) throw interruptedError();
|
|
1972
|
+
let timer;
|
|
1973
|
+
let stop = () => void 0;
|
|
1974
|
+
const interrupted = new Promise((_resolve, reject) => {
|
|
1975
|
+
stop = () => reject(interruptedError());
|
|
1976
|
+
io.signal?.addEventListener("abort", stop, { once: true });
|
|
1977
|
+
});
|
|
1978
|
+
const sleeping = io.sleep ? io.sleep(ms) : new Promise((resolve3) => {
|
|
1979
|
+
timer = setTimeout(resolve3, ms);
|
|
1980
|
+
});
|
|
1981
|
+
try {
|
|
1982
|
+
await Promise.race([sleeping, interrupted]);
|
|
1983
|
+
} finally {
|
|
1984
|
+
clearTimeout(timer);
|
|
1985
|
+
io.signal?.removeEventListener("abort", stop);
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1895
1988
|
async function readImageFile(path) {
|
|
1896
1989
|
let bytes;
|
|
1897
1990
|
try {
|
|
@@ -1917,9 +2010,9 @@ function sniffImageContentType(bytes) {
|
|
|
1917
2010
|
return void 0;
|
|
1918
2011
|
}
|
|
1919
2012
|
async function readUploadFile(path) {
|
|
1920
|
-
const { stat:
|
|
2013
|
+
const { stat: stat3 } = await import("node:fs/promises");
|
|
1921
2014
|
try {
|
|
1922
|
-
const info = await
|
|
2015
|
+
const info = await stat3(path);
|
|
1923
2016
|
if (!info.isFile() || info.size === 0 || info.size > MAX_IMAGE_BYTES) throw usageError("\u4E0A\u4F20\u6587\u4EF6\u5FC5\u987B\u4E3A 1 \u5B57\u8282\u81F3 64 MiB \u7684\u666E\u901A\u6587\u4EF6");
|
|
1924
2017
|
const bytes = await readFile(path);
|
|
1925
2018
|
if (bytes.byteLength === 0 || bytes.byteLength > MAX_IMAGE_BYTES) throw usageError("\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8D85\u51FA\u5141\u8BB8\u8303\u56F4");
|
|
@@ -1937,6 +2030,7 @@ import { createHash as createHash2 } from "node:crypto";
|
|
|
1937
2030
|
import { writeFile } from "node:fs/promises";
|
|
1938
2031
|
var SUBCOMMANDS = "catalog\u3001upload\u3001quote\u3001order\u3001status\u3001download \u548C cancel";
|
|
1939
2032
|
async function shorts(context) {
|
|
2033
|
+
timeoutSecondsOf(context.values, DEFAULT_WAIT_TIMEOUT_MS / 1e3);
|
|
1940
2034
|
const { args } = context;
|
|
1941
2035
|
const [subcommand] = args;
|
|
1942
2036
|
if (subcommand === void 0) {
|
|
@@ -1968,7 +2062,7 @@ function waitControls(io, values, note) {
|
|
|
1968
2062
|
return {
|
|
1969
2063
|
timeoutMs: timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3,
|
|
1970
2064
|
now: io.now ?? (() => /* @__PURE__ */ new Date()),
|
|
1971
|
-
sleep:
|
|
2065
|
+
sleep: (ms) => sleepFor(io, ms),
|
|
1972
2066
|
note
|
|
1973
2067
|
};
|
|
1974
2068
|
}
|
|
@@ -2139,8 +2233,8 @@ var graphicCommand = {
|
|
|
2139
2233
|
"message <\u9879\u76EEID> --text <\u8981\u6C42> [--attachment-ids <ID,ID>] [--edit-image <\u56FE\u7247ID>] [--source-image <\u56FE\u7247ID>] [--choice <\u9009\u9879ID>] [--wait]",
|
|
2140
2234
|
"retry <\u9879\u76EEID> <\u6D88\u606FID> [--wait]\uFF1A\u91CD\u8BD5\u539F\u514D\u8D39\u6587\u6848\u56DE\u5408\u3002\u6D88\u606F\u4E0D\u4F1A\u81EA\u52A8\u6388\u6743\u51FA\u56FE\u3002",
|
|
2141
2235
|
"quote <\u9879\u76EEID> [--image-indexes <1,2>]\uFF1A\u8BFB\u53D6\u6240\u9009\u65B9\u6848\u62A5\u4EF7\u3002",
|
|
2142
|
-
"generate <\u9879\u76EEID> [--image-indexes <1,2>]
|
|
2143
|
-
"\u5C40\u90E8\u4FEE\u6539\uFF1Aquote/generate <\u9879\u76EEID> --edit-image <\u56FE\u7247ID> --text <\u4FEE\u6539\u8981\u6C42> [--mask <\u9009\u533AID>]\u3002generate \u4ECD\u987B --yes\u3002",
|
|
2236
|
+
"generate <\u9879\u76EEID> [--image-indexes <1,2>] --quote-hash <\u5DF2\u67E5\u770B\u7684\u62A5\u4EF7\u54C8\u5E0C> --yes [--wait]\uFF1A\u62A5\u4EF7\u672A\u53D8\u65F6\u751F\u6210\uFF1B\u4E0D\u5E26 --yes \u4EC5\u9884\u89C8\u3002",
|
|
2237
|
+
"\u5C40\u90E8\u4FEE\u6539\uFF1Aquote/generate <\u9879\u76EEID> --edit-image <\u56FE\u7247ID> --text <\u4FEE\u6539\u8981\u6C42> [--mask <\u9009\u533AID>]\u3002generate \u4ECD\u987B --quote-hash \u548C --yes\u3002",
|
|
2144
2238
|
"model <\u9879\u76EEID> --model <\u6A21\u578B> | quality <\u9879\u76EEID> --quality <\u6863\u4F4D> | bind-product <\u9879\u76EEID> --product <\u4EA7\u54C1ID>",
|
|
2145
2239
|
"upload <\u9879\u76EEID> --file <\u56FE\u7247\u6216\u6587\u6863> | attachments <\u9879\u76EEID> [--attachment-ids <ID,ID>] [--limit <\u6570\u91CF>] [--offset <\u504F\u79FB>]",
|
|
2146
2240
|
"mask <\u9879\u76EEID> <\u56FE\u7247ID> --file <PNG\u9009\u533A> | save-edit <\u9879\u76EEID> <\u56FE\u7247ID> --file <\u7F16\u8F91\u540E\u56FE\u7247>",
|
|
@@ -2188,13 +2282,13 @@ function lines(run2) {
|
|
|
2188
2282
|
async function wait(context, baseUrl, apiKey, initial) {
|
|
2189
2283
|
if (context.values.wait !== true) return initial;
|
|
2190
2284
|
const now = context.io.now ?? (() => /* @__PURE__ */ new Date());
|
|
2191
|
-
const sleep = context.io.sleep ?? ((ms) => new Promise((resolve2) => setTimeout(resolve2, ms)));
|
|
2192
2285
|
const until = now().getTime() + timeoutSecondsOf(context.values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3;
|
|
2193
2286
|
let run2 = initial;
|
|
2194
2287
|
return retainTaskOnError(() => taskRecovery("graphic", run2.id, run2.status, baseUrl), async () => {
|
|
2195
2288
|
while (["preparing", "generating"].includes(run2.status)) {
|
|
2196
2289
|
if (now().getTime() >= until) throw new CliError({ code: "CLI_WAIT_TIMEOUT", exitCode: EXIT.WAIT_TIMEOUT, message: `\u7B49\u5F85\u5DF2\u8FBE\u5230\u65F6\u9650\uFF0C\u9879\u76EE\u5F53\u524D\u72B6\u6001\u4E3A ${singleLine(run2.status)}\uFF1B\u53EF\u67E5\u8BE2\u539F\u9879\u76EE\u7EE7\u7EED\u7B49\u5F85\u3002` });
|
|
2197
|
-
await
|
|
2290
|
+
await sleepFor(context.io, Math.min(1500, Math.max(until - now().getTime(), 1)));
|
|
2291
|
+
if (now().getTime() >= until) continue;
|
|
2198
2292
|
run2 = await getGraphicRun(baseUrl, apiKey, run2.id, context.io);
|
|
2199
2293
|
}
|
|
2200
2294
|
if (["failed", "canceled"].includes(run2.status)) throw new CliError({ code: "CLI_TASK_FAILED", exitCode: EXIT.TASK_FAILED, message: `\u56FE\u6587\u4EFB\u52A1\u72B6\u6001\u4E3A ${run2.status}\uFF1B\u5DF2\u5B8C\u6210\u7684\u56FE\u7247\u4FDD\u7559\u5728\u539F\u9879\u76EE\u4E2D\u3002` });
|
|
@@ -2213,11 +2307,20 @@ async function uploadFile(path) {
|
|
|
2213
2307
|
}
|
|
2214
2308
|
async function graphic(context) {
|
|
2215
2309
|
const { args, values, io, out } = context;
|
|
2310
|
+
timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3);
|
|
2216
2311
|
const command = required2(args[0], "\u56FE\u6587\u5B50\u547D\u4EE4\uFF1B\u8FD0\u884C buke graphic --help \u67E5\u770B\u8BF4\u660E");
|
|
2217
2312
|
const known = ["create", "list", "templates", "status", "message", "retry", "plan", "quote", "generate", "model", "quality", "bind-product", "attachments", "upload", "versions", "download", "save-edit", "mask", "cancel"];
|
|
2218
2313
|
if (!known.includes(command)) throw usageError(`\u672A\u77E5\u56FE\u6587\u5B50\u547D\u4EE4\uFF1A${command}`);
|
|
2219
2314
|
const id = ["create", "list", "templates"].includes(command) ? void 0 : required2(args[1], "\u56FE\u6587\u9879\u76EE ID");
|
|
2315
|
+
if (["quote", "generate"].includes(command)) {
|
|
2316
|
+
for (const option of ["expected-version", "expected-credits"]) {
|
|
2317
|
+
if (values[option] !== void 0) throw usageError(`graphic ${command} \u4E0D\u652F\u6301 --${option}\uFF1B\u8BF7\u4F7F\u7528\u5DF2\u67E5\u770B\u7684 --quote-hash \u7ED1\u5B9A\u62A5\u4EF7`);
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2220
2320
|
const selected = ["quote", "generate"].includes(command) ? selection(context) : {};
|
|
2321
|
+
const expectedQuoteHash = textOption(values, "quote-hash")?.toLowerCase();
|
|
2322
|
+
if (["quote", "generate"].includes(command) && values["quote-hash"] !== void 0 && (expectedQuoteHash === void 0 || !/^[a-f0-9]{64}$/u.test(expectedQuoteHash))) throw usageError("--quote-hash \u5FC5\u987B\u662F\u5DF2\u67E5\u770B\u7684 64 \u4F4D\u5341\u516D\u8FDB\u5236\u62A5\u4EF7\u54C8\u5E0C");
|
|
2323
|
+
if (command === "generate" && values.yes === true && expectedQuoteHash === void 0) throw usageError("\u786E\u8BA4\u751F\u6210\u5FC5\u987B\u63D0\u4F9B\u5DF2\u67E5\u770B\u7684 --quote-hash\uFF1B\u5148\u4E0D\u5E26 --yes \u67E5\u770B\u62A5\u4EF7");
|
|
2221
2324
|
const key = idempotencyKeyOf(values);
|
|
2222
2325
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2223
2326
|
const path = id ? graphicPath(id) : "/api/open/v1/graphic/runs";
|
|
@@ -2266,21 +2369,24 @@ async function graphic(context) {
|
|
|
2266
2369
|
if (["quote", "generate"].includes(command)) {
|
|
2267
2370
|
let current;
|
|
2268
2371
|
let submitted = false;
|
|
2372
|
+
let accepted = false;
|
|
2269
2373
|
try {
|
|
2270
2374
|
current = await getGraphicRun(baseUrl, apiKey, id, io);
|
|
2271
2375
|
const quote3 = await getGraphicQuote(baseUrl, apiKey, id, selected, key, io);
|
|
2272
|
-
if (
|
|
2376
|
+
if (expectedQuoteHash !== void 0 && expectedQuoteHash !== quote3.quoteHash) throw new CliError({ code: "OPEN_API_QUOTE_CHANGED", exitCode: EXIT.QUOTE_CHANGED, message: "\u62A5\u4EF7\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u67E5\u770B\u5F53\u524D\u62A5\u4EF7\u540E\u786E\u8BA4" });
|
|
2273
2377
|
if (command === "quote" || values.yes !== true) {
|
|
2274
2378
|
out.result([
|
|
2275
2379
|
`\u56FE\u6587\u9879\u76EE\uFF1A${id}`,
|
|
2276
2380
|
`\u672C\u6B21\u751F\u6210\uFF1A${quote3.imageCount} \u5F20\uFF0C\u9884\u4F30 ${quote3.totalCredits} \u5E03`,
|
|
2277
2381
|
`\u62A5\u4EF7\u54C8\u5E0C\uFF1A${quote3.quoteHash}`,
|
|
2278
|
-
|
|
2382
|
+
`\u672C\u6B21\u672A\u63D0\u4EA4\u751F\u6210\uFF1B\u4FDD\u7559\u539F\u56FE\u7247\u9009\u62E9\u6216\u4FEE\u6539\u8981\u6C42\uFF0C\u786E\u8BA4\u8D39\u7528\u540E\u4F7F\u7528 --quote-hash ${quote3.quoteHash} --yes\u3002`
|
|
2279
2383
|
], { quote: quote3, submitted: false });
|
|
2280
2384
|
return;
|
|
2281
2385
|
}
|
|
2282
2386
|
submitted = true;
|
|
2283
2387
|
const initial = graphicRun((await postJson(baseUrl, apiKey, `${path}/generate`, { ...selected, quoteHash: quote3.quoteHash, confirmed: true }, key, io)).body);
|
|
2388
|
+
current = initial;
|
|
2389
|
+
accepted = true;
|
|
2284
2390
|
const run2 = await wait(context, baseUrl, apiKey, initial);
|
|
2285
2391
|
out.result([...lines(run2), `\u5E42\u7B49\u952E\uFF1A${key}`], { run: run2, idempotencyKey: key });
|
|
2286
2392
|
return;
|
|
@@ -2292,8 +2398,8 @@ async function graphic(context) {
|
|
|
2292
2398
|
acceptance: current ? "confirmed" : "unknown",
|
|
2293
2399
|
idempotencyKey: key,
|
|
2294
2400
|
operation: "confirm",
|
|
2295
|
-
|
|
2296
|
-
|
|
2401
|
+
...failure.recovery,
|
|
2402
|
+
operationOutcome: accepted ? "accepted" : !submitted ? "not_submitted" : rejected ? "rejected" : "unknown"
|
|
2297
2403
|
});
|
|
2298
2404
|
}
|
|
2299
2405
|
}
|
|
@@ -2339,6 +2445,1398 @@ async function graphic(context) {
|
|
|
2339
2445
|
});
|
|
2340
2446
|
}
|
|
2341
2447
|
|
|
2448
|
+
// src/commands/web.ts
|
|
2449
|
+
import { createHash as createHash5, randomUUID as randomUUID2 } from "node:crypto";
|
|
2450
|
+
import { lstat as lstat4, readFile as readFile3 } from "node:fs/promises";
|
|
2451
|
+
import { basename as basename3 } from "node:path";
|
|
2452
|
+
|
|
2453
|
+
// src/web-operations.ts
|
|
2454
|
+
var WEB_OPERATIONS = [
|
|
2455
|
+
{ "id": "account.clearAgentMemory", "method": "DELETE", "path": "/api/me/agent-memory", "source": "web-src/src/lib/api.ts:2373", "group": "account", "description": "\u8D26\u53F7\uFF1A\u5220\u9664\u5F53\u524D\u8D26\u53F7 / \u5BFC\u6F14\u8BB0\u5FC6", "body": "json" },
|
|
2456
|
+
{ "id": "account.deleteAgentMemory", "method": "DELETE", "path": "/api/me/agent-memory/:id", "source": "web-src/src/lib/api.ts:2372", "group": "account", "description": "\u8D26\u53F7\uFF1A\u5220\u9664\u5F53\u524D\u8D26\u53F7 / \u5BFC\u6F14\u8BB0\u5FC6", "body": "json" },
|
|
2457
|
+
{ "id": "account.emailSettings", "method": "GET", "path": "/api/me/email", "source": "web-src/src/lib/api.ts:1551", "group": "account", "description": "\u8D26\u53F7\uFF1A\u67E5\u8BE2\u5F53\u524D\u8D26\u53F7 / \u90AE\u7BB1" },
|
|
2458
|
+
{ "id": "account.getAgentSettings", "method": "GET", "path": "/api/me/agent-settings", "source": "web-src/src/lib/api.ts:2367", "group": "account", "description": "\u8D26\u53F7\uFF1A\u67E5\u8BE2\u5F53\u524D\u8D26\u53F7 / \u5BFC\u6F14\u8BBE\u7F6E" },
|
|
2459
|
+
{ "id": "account.listAgentMemory", "method": "GET", "path": "/api/me/agent-memory", "source": "web-src/src/lib/api.ts:2370", "group": "account", "description": "\u8D26\u53F7\uFF1A\u67E5\u8BE2\u5F53\u524D\u8D26\u53F7 / \u5BFC\u6F14\u8BB0\u5FC6" },
|
|
2460
|
+
{ "id": "account.me", "method": "GET", "path": "/api/me", "source": "web-src/src/lib/api.ts:1699", "group": "account", "description": "\u8D26\u53F7\uFF1A\u67E5\u8BE2\u5F53\u524D\u8D26\u53F7" },
|
|
2461
|
+
{ "id": "account.requestEmailVerification", "method": "POST", "path": "/api/me/email/verification", "source": "web-src/src/lib/api.ts:1554", "group": "account", "description": "\u8D26\u53F7\uFF1A\u63D0\u4EA4\u90AE\u7BB1 / \u9A8C\u8BC1", "body": "json" },
|
|
2462
|
+
{ "id": "account.updateAgentSettings", "method": "PATCH", "path": "/api/me/agent-settings", "source": "web-src/src/lib/api.ts:2369", "group": "account", "description": "\u8D26\u53F7\uFF1A\u66F4\u65B0\u5F53\u524D\u8D26\u53F7 / \u5BFC\u6F14\u8BBE\u7F6E", "body": "json" },
|
|
2463
|
+
{ "id": "account.updateEmailPreferences", "method": "PATCH", "path": "/api/me/email/preferences", "source": "web-src/src/lib/api.ts:1557", "group": "account", "description": "\u8D26\u53F7\uFF1A\u66F4\u65B0\u90AE\u7BB1 / \u504F\u597D", "body": "json" },
|
|
2464
|
+
{ "id": "actors.actors", "method": "GET", "path": "/api/actors", "source": "web-src/src/lib/api.ts:2037", "group": "actors", "description": "\u4EBA\u7269\uFF1A\u67E5\u8BE2\u4EBA\u7269" },
|
|
2465
|
+
{ "id": "agent.agentAgreement", "method": "GET", "path": "/api/agent/agreement", "source": "web-src/src/lib/api.ts:1709", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u67E5\u8BE2\u63A8\u8350\u8BA1\u5212 / \u5408\u4F5C\u534F\u8BAE" },
|
|
2466
|
+
{ "id": "agent.agentApply", "method": "POST", "path": "/api/agent/apply", "source": "web-src/src/lib/api.ts:1714", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u63D0\u4EA4\u63A8\u8350\u8BA1\u5212 / \u5E94\u7528", "body": "json" },
|
|
2467
|
+
{ "id": "agent.agentEntries", "method": "GET", "path": "/api/agent/entries", "source": "web-src/src/lib/api.ts:1716", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u67E5\u8BE2\u63A8\u8350\u8BA1\u5212 / \u8BB0\u5F55" },
|
|
2468
|
+
{ "id": "agent.agentInvitees", "method": "GET", "path": "/api/agent/invitees", "source": "web-src/src/lib/api.ts:1715", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u67E5\u8BE2\u63A8\u8350\u8BA1\u5212 / \u9080\u8BF7\u8BB0\u5F55" },
|
|
2469
|
+
{ "id": "agent.agentMe", "method": "GET", "path": "/api/agent/me", "source": "web-src/src/lib/api.ts:1708", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u67E5\u8BE2\u63A8\u8350\u8BA1\u5212 / \u5F53\u524D\u8D26\u53F7" },
|
|
2470
|
+
{ "id": "agent.agentProgramBrief", "method": "GET", "path": "/api/agent/program-brief", "source": "web-src/src/lib/api.ts:1712", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u67E5\u8BE2\u63A8\u8350\u8BA1\u5212 / \u5408\u4F5C\u8BA1\u5212" },
|
|
2471
|
+
{ "id": "agent.agentWithdrawals", "method": "GET", "path": "/api/agent/withdrawals", "source": "web-src/src/lib/api.ts:1717", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u67E5\u8BE2\u63A8\u8350\u8BA1\u5212 / \u63D0\u73B0\u8BB0\u5F55" },
|
|
2472
|
+
{ "id": "agent.requestWithdrawal", "method": "POST", "path": "/api/agent/withdrawals", "source": "web-src/src/lib/api.ts:1719", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u63D0\u4EA4\u63A8\u8350\u8BA1\u5212 / \u63D0\u73B0\u8BB0\u5F55", "body": "json" },
|
|
2473
|
+
{ "id": "agent.saveAgentPayoutProfile", "method": "PUT", "path": "/api/agent/payout-profile", "source": "web-src/src/lib/api.ts:1721", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u8BBE\u7F6E\u63A8\u8350\u8BA1\u5212 / \u6536\u6B3E\u4FE1\u606F", "body": "json" },
|
|
2474
|
+
{ "id": "announcements.announcementArchive", "method": "GET", "path": "/api/announcements/archive", "source": "web-src/src/lib/api.ts:1536", "group": "announcements", "description": "\u516C\u544A\uFF1A\u67E5\u8BE2\u516C\u544A / \u5F52\u6863" },
|
|
2475
|
+
{ "id": "announcements.announcementReceipt", "method": "POST", "path": "/api/announcements/:id/receipt", "source": "web-src/src/lib/api.ts:1534", "group": "announcements", "description": "\u516C\u544A\uFF1A\u63D0\u4EA4\u516C\u544A / \u9605\u8BFB\u56DE\u6267", "body": "json" },
|
|
2476
|
+
{ "id": "announcements.liveAnnouncements", "method": "GET", "path": "/api/announcements/live", "source": "web-src/src/lib/api.ts:1531", "group": "announcements", "description": "\u516C\u544A\uFF1A\u67E5\u8BE2\u516C\u544A / \u5B9E\u65F6\u8FDB\u5EA6" },
|
|
2477
|
+
{ "id": "apiKeys.create", "method": "POST", "path": "/api/api-keys", "sensitiveOutput": true, "source": "web-src/src/lib/api-keys.ts:58", "group": "apiKeys", "description": "API\u5BC6\u94A5\uFF1A\u63D0\u4EA4API\u5BC6\u94A5", "body": "json", "exampleBody": { "name": "\u81EA\u52A8\u5316\u811A\u672C", "expiresInDays": 90 } },
|
|
2478
|
+
{ "id": "apiKeys.list", "method": "GET", "path": "/api/api-keys", "source": "web-src/src/lib/api-keys.ts:51", "group": "apiKeys", "description": "API\u5BC6\u94A5\uFF1A\u67E5\u8BE2API\u5BC6\u94A5" },
|
|
2479
|
+
{ "id": "apiKeys.revoke", "method": "POST", "path": "/api/api-keys/:id/revoke", "source": "web-src/src/lib/api-keys.ts:64", "group": "apiKeys", "description": "API\u5BC6\u94A5\uFF1A\u63D0\u4EA4API\u5BC6\u94A5 / \u64A4\u9500", "body": "json" },
|
|
2480
|
+
{ "id": "assets.registry", "method": "GET", "path": "/api/assets/registry", "source": "web-src/src/lib/api.ts:2043", "group": "assets", "description": "\u7D20\u6750\uFF1A\u67E5\u8BE2\u7D20\u6750 / \u7D20\u6750\u5E93" },
|
|
2481
|
+
{ "id": "auth.alipayStatus", "method": "GET", "path": "/api/auth/alipay/status", "source": "web-src/src/lib/api.ts:1690", "group": "auth", "description": "\u767B\u5F55\uFF1A\u67E5\u8BE2\u652F\u4ED8\u5B9D\u767B\u5F55 / \u72B6\u6001", "public": true },
|
|
2482
|
+
{ "id": "auth.changePassword", "method": "POST", "path": "/api/auth/password", "source": "web-src/src/lib/api.ts:1702", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u8BA4\u8BC1 / \u5BC6\u7801", "body": "json" },
|
|
2483
|
+
{ "id": "auth.completeAlipayLogin", "method": "POST", "path": "/api/auth/alipay/complete", "source": "web-src/src/lib/api.ts:1692", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u652F\u4ED8\u5B9D\u767B\u5F55 / \u5B8C\u6210\u767B\u5F55", "body": "json", "public": true, "sessionResponse": true },
|
|
2484
|
+
{ "id": "auth.emailAuthStatus", "method": "GET", "path": "/api/auth/email/status", "source": "web-src/src/lib/api.ts:1684", "group": "auth", "description": "\u767B\u5F55\uFF1A\u67E5\u8BE2\u90AE\u7BB1 / \u72B6\u6001", "public": true },
|
|
2485
|
+
{ "id": "auth.login", "method": "POST", "path": "/api/auth/login", "source": "web-src/src/lib/api.ts:1674", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u8BA4\u8BC1 / \u767B\u5F55", "body": "json", "public": true, "sessionResponse": true },
|
|
2486
|
+
{ "id": "auth.logout", "method": "POST", "path": "/api/auth/logout", "source": "web-src/src/lib/api.ts:1697", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u8BA4\u8BC1 / \u9000\u51FA\u767B\u5F55", "body": "json" },
|
|
2487
|
+
{ "id": "auth.register", "method": "POST", "path": "/api/auth/register", "source": "web-src/src/lib/api.ts:1677", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u8BA4\u8BC1 / \u6CE8\u518C", "body": "json", "public": true, "sessionResponse": true },
|
|
2488
|
+
{ "id": "auth.registerWithEmail", "method": "POST", "path": "/api/auth/register/email", "source": "web-src/src/lib/api.ts:1688", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u6CE8\u518C / \u90AE\u7BB1", "body": "json", "public": true, "sessionResponse": true },
|
|
2489
|
+
{ "id": "auth.registerWithSms", "method": "POST", "path": "/api/auth/register/sms", "source": "web-src/src/lib/api.ts:1682", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u6CE8\u518C / \u77ED\u4FE1", "body": "json", "public": true, "sessionResponse": true },
|
|
2490
|
+
{ "id": "auth.sendRegistrationEmail", "method": "POST", "path": "/api/auth/email/register-code", "source": "web-src/src/lib/api.ts:1686", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u90AE\u7BB1 / \u6CE8\u518C\u9A8C\u8BC1\u7801", "body": "json", "public": true },
|
|
2491
|
+
{ "id": "auth.sendRegistrationSms", "method": "POST", "path": "/api/auth/sms/register-code", "source": "web-src/src/lib/api.ts:1679", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u77ED\u4FE1 / \u6CE8\u518C\u9A8C\u8BC1\u7801", "body": "json", "public": true },
|
|
2492
|
+
{ "id": "budget.budget", "method": "GET", "path": "/api/budget", "source": "web-src/src/lib/api.ts:3270", "group": "budget", "description": "\u8D26\u672C\uFF1A\u67E5\u8BE2\u8D26\u6237\u989D\u5EA6" },
|
|
2493
|
+
{ "id": "budget.budgetEntries", "method": "GET", "path": "/api/budget/entries", "source": "web-src/src/lib/api.ts:3272", "group": "budget", "description": "\u8D26\u672C\uFF1A\u67E5\u8BE2\u8D26\u6237\u989D\u5EA6 / \u8BB0\u5F55" },
|
|
2494
|
+
{ "id": "budget.budgetTransactions", "method": "GET", "path": "/api/budget/transactions", "source": "web-src/src/lib/api.ts:3277", "group": "budget", "description": "\u8D26\u672C\uFF1A\u67E5\u8BE2\u8D26\u6237\u989D\u5EA6 / \u8D26\u5355" },
|
|
2495
|
+
{ "id": "budget.projectCosts", "method": "GET", "path": "/api/budget/by-project", "source": "web-src/src/lib/api.ts:3550", "group": "budget", "description": "\u8D26\u672C\uFF1A\u67E5\u8BE2\u8D26\u6237\u989D\u5EA6 / \u6309\u9879\u76EE\u6C47\u603B" },
|
|
2496
|
+
{ "id": "commercialAds.recommendCommercialAds", "method": "POST", "path": "/api/commercial-ads/recommend", "source": "web-src/src/lib/api.ts:2824", "group": "commercialAds", "description": "\u5E7F\u544A\u63A8\u8350\uFF1A\u63D0\u4EA4\u5E7F\u544A / \u63A8\u8350", "body": "json" },
|
|
2497
|
+
{ "id": "delivery.accept", "method": "POST", "path": "/api/delivery/shared/:token/accepted", "source": "web-src/src/lib/delivery-api.ts:348", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u63D0\u4EA4\u5206\u4EAB\u4EA4\u4ED8 / \u4EA4\u4ED8\u9A8C\u6536", "body": "json", "public": true },
|
|
2498
|
+
{ "id": "delivery.accept.accepted", "method": "POST", "path": "/api/delivery/packages/:id/accepted", "source": "web-src/src/lib/delivery-api.ts:348", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u63D0\u4EA4\u4EA4\u4ED8\u5305 / \u4EA4\u4ED8\u9A8C\u6536", "body": "json" },
|
|
2499
|
+
{ "id": "delivery.comment", "method": "POST", "path": "/api/delivery/shared/:token/comments", "source": "web-src/src/lib/delivery-api.ts:346", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u63D0\u4EA4\u5206\u4EAB\u4EA4\u4ED8 / \u8BC4\u8BBA", "body": "json", "public": true },
|
|
2500
|
+
{ "id": "delivery.comments", "method": "GET", "path": "/api/delivery/packages/:id/comments", "source": "web-src/src/lib/delivery-api.ts:338", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8\u5305 / \u8BC4\u8BBA" },
|
|
2501
|
+
{ "id": "delivery.create", "method": "POST", "path": "/api/delivery/packages", "source": "web-src/src/lib/delivery-api.ts:335", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u63D0\u4EA4\u4EA4\u4ED8 / \u4EA4\u4ED8\u5305", "body": "json", "idempotencyBodyKey": "requestKey", "replaySafe": true, "exampleBody": { "sources": [{ "kind": "episode", "sourceId": "\u9879\u76EE\u7F16\u53F7", "selectedFileIds": ["\u4ECEdelivery.source\u54CD\u5E94\u7684files\u4E2D\u9009\u53D6\u6587\u4EF6id"], "expectedFingerprint": "\u4ECEdelivery.source\u8BFB\u53D6" }], "scope": "full", "title": "\u4EA4\u4ED8\u8D44\u6599" } },
|
|
2502
|
+
{ "id": "delivery.createShare", "method": "POST", "path": "/api/delivery/packages/:id/shares", "sensitiveOutput": true, "source": "web-src/src/lib/delivery-api.ts:340", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u63D0\u4EA4\u4EA4\u4ED8\u5305 / \u5206\u4EAB\u8BB0\u5F55", "body": "json", "exampleBody": { "allowPreview": true, "allowDownload": true, "allowComment": true, "expiresInDays": 7 } },
|
|
2503
|
+
{ "id": "delivery.download", "method": "GET", "path": "/api/delivery/packages/:id/download", "source": "apps/api/src/http/routes/delivery.ts:194", "group": "delivery", "description": "\u4E0B\u8F7D\u5B8C\u6574\u4EA4\u4ED8\u5305" },
|
|
2504
|
+
{ "id": "delivery.downloadFile", "method": "POST", "path": "/api/delivery/packages/:id/download-ticket", "sensitiveOutput": true, "source": "web-src/src/lib/delivery-api.ts:358", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u63D0\u4EA4\u4EA4\u4ED8\u5305 / \u4E0B\u8F7D\u51ED\u8BC1", "body": "json" },
|
|
2505
|
+
{ "id": "delivery.downloadShared", "method": "GET", "path": "/api/delivery/shared/:token/download", "source": "apps/api/src/http/routes/delivery.ts:267", "group": "delivery", "description": "\u4E0B\u8F7D\u5206\u4EAB\u4EA4\u4ED8\u5305", "public": true },
|
|
2506
|
+
{ "id": "delivery.file", "method": "GET", "path": "/api/delivery/shared/:token/files/:fileId", "source": "web-src/src/lib/delivery-api.ts:352", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u5206\u4EAB\u4EA4\u4ED8 / \u6587\u4EF6", "public": true },
|
|
2507
|
+
{ "id": "delivery.file.files", "method": "GET", "path": "/api/delivery/packages/:id/files/:fileId", "source": "web-src/src/lib/delivery-api.ts:352", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8\u5305 / \u6587\u4EF6" },
|
|
2508
|
+
{ "id": "delivery.list", "method": "GET", "path": "/api/delivery/packages", "source": "web-src/src/lib/delivery-api.ts:318", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8 / \u4EA4\u4ED8\u5305" },
|
|
2509
|
+
{ "id": "delivery.options", "method": "GET", "path": "/api/delivery/source-options", "source": "web-src/src/lib/delivery-api.ts:309", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8 / \u6765\u6E90\u9009\u9879" },
|
|
2510
|
+
{ "id": "delivery.package", "method": "GET", "path": "/api/delivery/packages/:id", "source": "web-src/src/lib/delivery-api.ts:336", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8 / \u4EA4\u4ED8\u5305" },
|
|
2511
|
+
{ "id": "delivery.revokeShare", "method": "DELETE", "path": "/api/delivery/shares/:id", "source": "web-src/src/lib/delivery-api.ts:342", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u5220\u9664\u4EA4\u4ED8 / \u5206\u4EAB\u8BB0\u5F55", "body": "json" },
|
|
2512
|
+
{ "id": "delivery.shared", "method": "GET", "path": "/api/delivery/shared/:token", "source": "web-src/src/lib/delivery-api.ts:344", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8 / \u5206\u4EAB\u4EA4\u4ED8", "public": true },
|
|
2513
|
+
{ "id": "delivery.shares", "method": "GET", "path": "/api/delivery/packages/:id/shares", "source": "web-src/src/lib/delivery-api.ts:337", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8\u5305 / \u5206\u4EAB\u8BB0\u5F55" },
|
|
2514
|
+
{ "id": "delivery.source", "method": "GET", "path": "/api/delivery/sources/:kind/:sourceId", "source": "web-src/src/lib/delivery-api.ts:313", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8 / \u6765\u6E90" },
|
|
2515
|
+
{ "id": "drama.acceptAdvice", "method": "POST", "path": "/api/projects/:id/customer-quality/actions", "source": "apps/api/src/http/routes/projects.ts:4149", "group": "drama", "description": "\u7EE7\u7EED\u4F7F\u7528\u5F53\u524D\u6587\u7A3F", "body": "json" },
|
|
2516
|
+
{ "id": "drama.adoptStorySpeech", "method": "POST", "path": "/api/projects/:projectId/director/speech/tracks/:trackId/adopt", "source": "web-src/src/lib/api.ts:2582", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u97F3\u8F68 / \u91C7\u7528", "body": "json" },
|
|
2517
|
+
{ "id": "drama.approveStorySpeech", "method": "POST", "path": "/api/projects/:projectId/director/speech/tracks/:trackId/approve", "source": "web-src/src/lib/api.ts:2578", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u97F3\u8F68 / \u786E\u8BA4", "body": "json" },
|
|
2518
|
+
{ "id": "drama.approveTopicScript", "method": "POST", "path": "/api/projects/:id/topic/script/approve", "source": "web-src/src/lib/api.ts:2571", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u7A3F\u4EF6 / \u786E\u8BA4", "body": "json" },
|
|
2519
|
+
{ "id": "drama.assetGate", "method": "GET", "path": "/api/projects/:id/asset-gate", "source": "web-src/src/lib/api.ts:3436", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u7D20\u6750\u68C0\u67E5" },
|
|
2520
|
+
{ "id": "drama.bindStoryAssets", "method": "POST", "path": "/api/projects/:id/story-bindings", "source": "web-src/src/lib/api.ts:3213", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u4EBA\u7269\u573A\u666F\u7ED1\u5B9A", "body": "json" },
|
|
2521
|
+
{ "id": "drama.cancelProjectGeneration", "method": "POST", "path": "/api/projects/:id/cancel-generation", "source": "web-src/src/lib/api.ts:3503", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u505C\u6B62\u5236\u4F5C", "body": "json" },
|
|
2522
|
+
{ "id": "drama.cancelStoryDirectorAutoStart", "method": "POST", "path": "/api/projects/:projectId/director/auto-start/cancel", "source": "web-src/src/lib/api.ts:2682", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u81EA\u52A8\u5F00\u62CD / \u53D6\u6D88", "body": "json" },
|
|
2523
|
+
{ "id": "drama.capability", "method": "GET", "path": "/api/projects/:projectId/outputs/:outputId/subtitles/capability", "source": "web-src/src/lib/subtitle-version-api.ts:35", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5B57\u5E55 / \u80FD\u529B" },
|
|
2524
|
+
{ "id": "drama.casting", "method": "POST", "path": "/api/projects/:id/casting", "source": "web-src/src/lib/api.ts:3198", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u9009\u89D2", "body": "json" },
|
|
2525
|
+
{ "id": "drama.clearShotVersionSelection", "method": "DELETE", "path": "/api/projects/:id/shots/:shotId/version-selection", "source": "web-src/src/lib/api.ts:3545", "group": "drama", "description": "\u77ED\u5267\uFF1A\u5220\u9664\u955C\u5934 / \u955C\u5934\u9009\u7248", "body": "json" },
|
|
2526
|
+
{ "id": "drama.compareScreenplayVersions", "method": "GET", "path": "/api/projects/:id/screenplay/versions/compare", "source": "web-src/src/lib/api.ts:3235", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u7248\u672C / \u5BF9\u6BD4" },
|
|
2527
|
+
{ "id": "drama.confirmProductionRedo", "method": "POST", "path": "/api/projects/:id/production/redo", "source": "web-src/src/lib/api.ts:3493", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5236\u4F5C\u8FDB\u5EA6 / \u91CD\u65B0\u5236\u4F5C", "body": "json" },
|
|
2528
|
+
{ "id": "drama.confirmStitch", "method": "POST", "path": "/api/projects/:id/production/postprocess/stitch-confirm", "source": "web-src/src/lib/api.ts:3474", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u540E\u671F\u5236\u4F5C / \u786E\u8BA4\u62FC\u63A5", "body": "json" },
|
|
2529
|
+
{ "id": "drama.confirmStoryDirector", "method": "POST", "path": "/api/projects/:projectId/director/confirm", "source": "web-src/src/lib/api.ts:2676", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5BFC\u6F14 / \u786E\u8BA4", "body": "json" },
|
|
2530
|
+
{ "id": "drama.confirmStorySpeech", "method": "POST", "path": "/api/projects/:projectId/director/speech/quotes/:quoteId/confirm", "source": "web-src/src/lib/api.ts:2576", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u62A5\u4EF7 / \u786E\u8BA4", "body": "json" },
|
|
2531
|
+
{ "id": "drama.confirmStorySpeechLegacySource", "method": "POST", "path": "/api/projects/:projectId/director/speech/legacy-source/confirm", "source": "web-src/src/lib/api.ts:2586", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5386\u53F2\u6765\u6E90 / \u786E\u8BA4", "body": "json" },
|
|
2532
|
+
{ "id": "drama.create", "method": "POST", "path": "/api/projects", "source": "web-src/src/lib/api.ts:3132", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE", "body": "json", "exampleBody": { "productId": "\u5546\u54C1\u7F16\u53F7", "genreId": "family", "productionProfile": { "durationKey": "30s" }, "brief": { "description": "\u56F4\u7ED5\u8FD9\u4EF6\u5546\u54C1\u521B\u4F5C\u751F\u6D3B\u77ED\u5267" } } },
|
|
2533
|
+
{ "id": "drama.createProductionSignoff", "method": "POST", "path": "/api/projects/:id/production-signoff", "source": "web-src/src/lib/api.ts:3345", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u5F00\u62CD\u786E\u8BA4", "body": "json" },
|
|
2534
|
+
{ "id": "drama.createTopicProject", "method": "POST", "path": "/api/projects/topic", "source": "web-src/src/lib/api.ts:2568", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u9009\u9898", "body": "json" },
|
|
2535
|
+
{ "id": "drama.customerQuality", "method": "GET", "path": "/api/projects/:id/customer-quality", "source": "web-src/src/lib/api.ts:3306", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u521B\u4F5C\u5EFA\u8BAE" },
|
|
2536
|
+
{ "id": "drama.deleteProject", "method": "DELETE", "path": "/api/projects/:id", "source": "web-src/src/lib/api.ts:3123", "group": "drama", "description": "\u77ED\u5267\uFF1A\u5220\u9664\u9879\u76EE", "body": "json" },
|
|
2537
|
+
{ "id": "drama.downloadEdit", "method": "GET", "path": "/api/projects/:projectId/director/edits/:editId/download", "source": "apps/api/src/http/routes/story-director.ts:52", "group": "drama", "description": "\u4E0B\u8F7D\u77ED\u5267\u526A\u8F91\u7248" },
|
|
2538
|
+
{ "id": "drama.downloadEditSubtitles", "method": "GET", "path": "/api/projects/:projectId/director/edits/:editId/subtitles", "source": "apps/api/src/http/routes/story-director.ts:62", "group": "drama", "description": "\u4E0B\u8F7D\u77ED\u5267\u526A\u8F91\u5B57\u5E55" },
|
|
2539
|
+
{ "id": "drama.downloadFinal", "method": "GET", "path": "/api/exports/:projectId/download", "source": "apps/api/src/http/routes/exports.ts:26", "group": "drama", "description": "\u4E0B\u8F7D\u77ED\u5267\u5B8C\u6574\u6210\u7247" },
|
|
2540
|
+
{ "id": "drama.downloadHistory", "method": "GET", "path": "/api/projects/:projectId/director/history-sources/:sourceEpisodeOutputId/download", "source": "apps/api/src/http/routes/story-director.ts:98", "group": "drama", "description": "\u4E0B\u8F7D\u5386\u53F2\u6210\u7247" },
|
|
2541
|
+
{ "id": "drama.downloadSubtitleFile", "method": "GET", "path": "/api/exports/:projectId/subtitles.srt", "source": "web-src/src/lib/subtitle-download.ts:9", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u4EA4\u4ED8\u4FE1\u606F / \u5B57\u5E55\u6587\u4EF6" },
|
|
2542
|
+
{ "id": "drama.downloadSubtitleVersion", "method": "GET", "path": "/api/projects/:projectId/outputs/:outputId/subtitles/render/:taskId/video", "source": "apps/api/src/http/routes/film-subtitles.ts:40", "group": "drama", "description": "\u4E0B\u8F7D\u5B57\u5E55\u6210\u7247" },
|
|
2543
|
+
{ "id": "drama.draft", "method": "POST", "path": "/api/projects/:projectId/outputs/:outputId/subtitles/draft", "source": "web-src/src/lib/subtitle-version-api.ts:39", "group": "drama", "description": '\u77ED\u5267\uFF1A\u51C6\u5907\u5B57\u5E55\u8349\u7A3F\uFF1B\u8FD4\u56DE canRetry \u65F6\u53EF\u7528 --query JSON \u6587\u4EF6\u4F20 {"retry":1} \u91CD\u8BD5\u51C6\u5907', "body": "json" },
|
|
2544
|
+
{ "id": "drama.exports", "method": "GET", "path": "/api/exports/:projectId", "source": "web-src/src/lib/api.ts:3553", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u4EA4\u4ED8\u4FE1\u606F" },
|
|
2545
|
+
{ "id": "drama.generate", "method": "POST", "path": "/api/projects/:id/generate", "source": "web-src/src/lib/api.ts:3445", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u5236\u4F5C", "body": "json", "businessHeaders": { "prefer": { "default": "respond-async", "values": ["respond-async"] } } },
|
|
2546
|
+
{ "id": "drama.generateStoryboard", "method": "POST", "path": "/api/projects/:id/storyboard", "source": "web-src/src/lib/api.ts:3225", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u6545\u4E8B\u677F", "body": "json" },
|
|
2547
|
+
{ "id": "drama.getProject", "method": "GET", "path": "/api/projects/:id", "source": "web-src/src/lib/api.ts:3122", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE" },
|
|
2548
|
+
{ "id": "drama.getStoryDirector", "method": "GET", "path": "/api/projects/:projectId/director", "source": "web-src/src/lib/api.ts:2608", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u5BFC\u6F14" },
|
|
2549
|
+
{ "id": "drama.getStoryDirectorDoc", "method": "GET", "path": "/api/projects/:projectId/director/doc", "source": "web-src/src/lib/api.ts:2663", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5BFC\u6F14 / \u6587\u7A3F" },
|
|
2550
|
+
{ "id": "drama.getStoryDirectorSpecQuotes", "method": "GET", "path": "/api/projects/:projectId/director/spec-quotes", "source": "web-src/src/lib/api.ts:2704", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5BFC\u6F14 / \u89C4\u683C\u62A5\u4EF7" },
|
|
2551
|
+
{ "id": "drama.getStoryHistoricalSources", "method": "GET", "path": "/api/projects/:projectId/director/history-sources", "source": "web-src/src/lib/api.ts:2584", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5BFC\u6F14 / \u5386\u53F2\u6210\u7247" },
|
|
2552
|
+
{ "id": "drama.getStorySpeech", "method": "GET", "path": "/api/projects/:projectId/director/speech", "source": "web-src/src/lib/api.ts:2572", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5BFC\u6F14 / \u914D\u97F3" },
|
|
2553
|
+
{ "id": "drama.getStorySpeechAdoptions", "method": "GET", "path": "/api/projects/:projectId/director/speech/adoptions", "source": "web-src/src/lib/api.ts:2589", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u914D\u97F3 / \u91C7\u7528\u8BB0\u5F55" },
|
|
2554
|
+
{ "id": "drama.getStorySpeechAudio", "method": "GET", "path": "/api/projects/:projectId/director/speech/tracks/:trackId/audio", "source": "web-src/src/lib/api.ts:2591", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u97F3\u8F68 / \u97F3\u9891" },
|
|
2555
|
+
{ "id": "drama.getStorySpeechTaskAudio", "method": "GET", "path": "/api/projects/:projectId/director/speech/tasks/:taskId/audio", "source": "web-src/src/lib/api.ts:2593", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u4EFB\u52A1 / \u97F3\u9891" },
|
|
2556
|
+
{ "id": "drama.getStoryVideoEditSources", "method": "GET", "path": "/api/projects/:projectId/director/edit-sources", "source": "web-src/src/lib/api.ts:2583", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5BFC\u6F14 / \u526A\u8F91\u7D20\u6750" },
|
|
2557
|
+
{ "id": "drama.getTopicProject", "method": "GET", "path": "/api/projects/:id/topic", "source": "web-src/src/lib/api.ts:2569", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u9009\u9898" },
|
|
2558
|
+
{ "id": "drama.importStorySpeechRecordings", "method": "POST", "path": "/api/projects/:projectId/director/speech/import", "source": "web-src/src/lib/api.ts:2598", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u914D\u97F3 / \u5BFC\u5165", "body": "json" },
|
|
2559
|
+
{ "id": "drama.inspectStoryDirectorAttachments", "method": "GET", "path": "/api/projects/:projectId/director/attachments", "source": "web-src/src/lib/api.ts:2649", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5BFC\u6F14 / \u9644\u4EF6" },
|
|
2560
|
+
{ "id": "drama.jobs", "method": "GET", "path": "/api/projects/:id/jobs", "source": "web-src/src/lib/api.ts:3455", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u4EFB\u52A1" },
|
|
2561
|
+
{ "id": "drama.ledger", "method": "GET", "path": "/api/projects/:id/ledger", "source": "web-src/src/lib/api.ts:3551", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u8D26\u672C" },
|
|
2562
|
+
{ "id": "drama.list", "method": "GET", "path": "/api/projects", "source": "web-src/src/lib/api.ts:2882", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE" },
|
|
2563
|
+
{ "id": "drama.playEdit", "method": "GET", "path": "/api/projects/:projectId/director/edits/:editId/video", "source": "apps/api/src/http/routes/story-director.ts:52", "group": "drama", "description": "\u8BFB\u53D6\u77ED\u5267\u526A\u8F91\u7248" },
|
|
2564
|
+
{ "id": "drama.playHistory", "method": "GET", "path": "/api/projects/:projectId/director/history-sources/:sourceEpisodeOutputId/video", "source": "apps/api/src/http/routes/story-director.ts:98", "group": "drama", "description": "\u8BFB\u53D6\u5386\u53F2\u6210\u7247" },
|
|
2565
|
+
{ "id": "drama.postStoryDirectorMessage", "method": "POST", "path": "/api/projects/:projectId/director/messages", "source": "web-src/src/lib/api.ts:2610", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5BFC\u6F14 / \u5BF9\u8BDD", "body": "json", "exampleBody": { "text": "\u4FDD\u7559\u73B0\u6709\u60C5\u8282\uFF0C\u53EA\u8C03\u6574\u5F00\u573A\u5BF9\u767D" } },
|
|
2566
|
+
{ "id": "drama.production", "method": "GET", "path": "/api/projects/:id/production", "source": "web-src/src/lib/api.ts:3457", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u5236\u4F5C\u8FDB\u5EA6" },
|
|
2567
|
+
{ "id": "drama.productionRedoQuote", "method": "POST", "path": "/api/projects/:id/production/redo/quote", "source": "web-src/src/lib/api.ts:3490", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u91CD\u65B0\u5236\u4F5C / \u62A5\u4EF7", "body": "json" },
|
|
2568
|
+
{ "id": "drama.productionSignoff", "method": "GET", "path": "/api/projects/:id/production-signoff", "source": "web-src/src/lib/api.ts:3298", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u5F00\u62CD\u786E\u8BA4" },
|
|
2569
|
+
{ "id": "drama.quote", "method": "POST", "path": "/api/projects/:id/quote", "source": "web-src/src/lib/api.ts:3295", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u62A5\u4EF7", "body": "json" },
|
|
2570
|
+
{ "id": "drama.quoteShotRetry", "method": "GET", "path": "/api/projects/:id/shots/:shotId/retry-quote", "source": "web-src/src/lib/api.ts:3521", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u955C\u5934 / \u91CD\u62CD\u62A5\u4EF7" },
|
|
2571
|
+
{ "id": "drama.quoteStorySpeech", "method": "POST", "path": "/api/projects/:projectId/director/speech/quotes", "source": "web-src/src/lib/api.ts:2574", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u914D\u97F3 / \u62A5\u4EF7", "body": "json" },
|
|
2572
|
+
{ "id": "drama.refineScreenplayScene", "method": "POST", "path": "/api/projects/:id/screenplay/scenes/:sceneNo/refine", "source": "web-src/src/lib/api.ts:3255", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u573A\u666F / \u5C40\u90E8\u4FEE\u6539", "body": "json" },
|
|
2573
|
+
{ "id": "drama.render", "method": "POST", "path": "/api/projects/:projectId/outputs/:outputId/subtitles/render", "source": "web-src/src/lib/subtitle-version-api.ts:41", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5B57\u5E55 / \u5236\u4F5C\u5305\u88C5", "body": "json" },
|
|
2574
|
+
{ "id": "drama.restoreScreenplayVersion", "method": "POST", "path": "/api/projects/:id/screenplay/versions/:docId/restore", "source": "web-src/src/lib/api.ts:3243", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u7248\u672C / \u6062\u590D", "body": "json", "exampleBody": { "expectedCurrentDocumentId": "\u5F53\u524D\u6587\u7A3F\u7F16\u53F7", "productionEpoch": 0 } },
|
|
2575
|
+
{ "id": "drama.resumeProductionPostprocess", "method": "POST", "path": "/api/projects/:id/production/postprocess/resume", "source": "web-src/src/lib/api.ts:3460", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u540E\u671F\u5236\u4F5C / \u7EE7\u7EED", "body": "json" },
|
|
2576
|
+
{ "id": "drama.retryShotGeneration", "method": "POST", "path": "/api/projects/:id/shots/:shotId/retry-generation", "source": "web-src/src/lib/api.ts:3513", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u955C\u5934 / \u91CD\u65B0\u751F\u6210", "body": "json" },
|
|
2577
|
+
{ "id": "drama.revokeStorySpeech", "method": "POST", "path": "/api/projects/:projectId/director/speech/tracks/:trackId/revoke", "source": "web-src/src/lib/api.ts:2580", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u97F3\u8F68 / \u64A4\u9500", "body": "json" },
|
|
2578
|
+
{ "id": "drama.save", "method": "PUT", "path": "/api/projects/:projectId/outputs/:outputId/subtitles/draft/:draftId", "source": "web-src/src/lib/subtitle-version-api.ts:39", "group": "drama", "description": "\u77ED\u5267\uFF1A\u8BBE\u7F6E\u5B57\u5E55 / \u8349\u7A3F", "body": "json" },
|
|
2579
|
+
{ "id": "drama.saveStoryDirectorAttachmentFile", "method": "GET", "path": "/api/projects/:projectId/director/attachments/:attachmentId/file", "source": "web-src/src/lib/api.ts:2655", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9644\u4EF6 / \u6587\u4EF6" },
|
|
2580
|
+
{ "id": "drama.screenplay", "method": "POST", "path": "/api/projects/:id/screenplay", "source": "web-src/src/lib/api.ts:3227", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u5267\u672C", "body": "json" },
|
|
2581
|
+
{ "id": "drama.screenplayVersion", "method": "GET", "path": "/api/projects/:id/screenplay/versions/:docId", "source": "web-src/src/lib/api.ts:3232", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5267\u672C / \u7248\u672C" },
|
|
2582
|
+
{ "id": "drama.screenplayVersions", "method": "GET", "path": "/api/projects/:id/screenplay/versions", "source": "web-src/src/lib/api.ts:3230", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5267\u672C / \u7248\u672C" },
|
|
2583
|
+
{ "id": "drama.selectScriptAsset", "method": "POST", "path": "/api/projects/:id/script-asset", "source": "web-src/src/lib/api.ts:3262", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u6545\u4E8B\u8DEF\u7EBF", "body": "json" },
|
|
2584
|
+
{ "id": "drama.selectShotVersion", "method": "PUT", "path": "/api/projects/:id/shots/:shotId/version-selection", "source": "web-src/src/lib/api.ts:3534", "group": "drama", "description": "\u77ED\u5267\uFF1A\u8BBE\u7F6E\u955C\u5934 / \u955C\u5934\u9009\u7248", "body": "json" },
|
|
2585
|
+
{ "id": "drama.setStoryDirectorProductionChoice", "method": "POST", "path": "/api/projects/:projectId/director/production-choice", "source": "web-src/src/lib/api.ts:2698", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5BFC\u6F14 / \u5236\u4F5C\u89C4\u683C", "body": "json" },
|
|
2586
|
+
{ "id": "drama.shotPlan", "method": "POST", "path": "/api/projects/:id/shot-plan", "source": "web-src/src/lib/api.ts:3219", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u5206\u955C\u65B9\u6848", "body": "json" },
|
|
2587
|
+
{ "id": "drama.stitchDecision", "method": "POST", "path": "/api/projects/:id/production/postprocess/stitch-decision", "source": "web-src/src/lib/api.ts:3467", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u540E\u671F\u5236\u4F5C / \u62FC\u63A5\u65B9\u6848", "body": "json" },
|
|
2588
|
+
{ "id": "drama.stopStoryDirector", "method": "POST", "path": "/api/projects/:projectId/director/stop", "source": "web-src/src/lib/api.ts:2601", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5BFC\u6F14 / \u505C\u6B62\u56DE\u590D", "body": "json" },
|
|
2589
|
+
{ "id": "drama.storyboard", "method": "GET", "path": "/api/projects/:id/storyboard", "source": "web-src/src/lib/api.ts:3223", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u6545\u4E8B\u677F" },
|
|
2590
|
+
{ "id": "drama.streamStoryDirectorMessage", "method": "POST", "path": "/api/projects/:projectId/director/messages/stream", "source": "web-src/src/lib/api.ts:2623", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5BF9\u8BDD / \u5B9E\u65F6\u5BF9\u8BDD", "body": "json" },
|
|
2591
|
+
{ "id": "drama.switchProjectToLiveAction", "method": "PATCH", "path": "/api/projects/:id/production-profile", "source": "web-src/src/lib/api.ts:3139", "group": "drama", "description": "\u77ED\u5267\uFF1A\u66F4\u65B0\u9879\u76EE / \u5236\u4F5C\u89C4\u683C", "body": "json" },
|
|
2592
|
+
{ "id": "drama.task", "method": "GET", "path": "/api/projects/:projectId/outputs/:outputId/subtitles/render/:taskId", "source": "web-src/src/lib/subtitle-version-api.ts:43", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5B57\u5E55 / \u5236\u4F5C\u5305\u88C5" },
|
|
2593
|
+
{ "id": "drama.updatePlacementIntensity", "method": "PATCH", "path": "/api/projects/:id/placement-intensity", "source": "web-src/src/lib/api.ts:3152", "group": "drama", "description": "\u77ED\u5267\uFF1A\u66F4\u65B0\u9879\u76EE / \u690D\u5165\u7A0B\u5EA6", "body": "json" },
|
|
2594
|
+
{ "id": "drama.updateTopicScript", "method": "POST", "path": "/api/projects/:id/topic/script", "source": "web-src/src/lib/api.ts:2570", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9009\u9898 / \u7A3F\u4EF6", "body": "json" },
|
|
2595
|
+
{ "id": "drama.uploadStoryDirectorAttachment", "method": "PUT", "path": "/api/projects/:projectId/director/attachments", "source": "web-src/src/lib/api.ts:2640", "group": "drama", "description": "\u77ED\u5267\uFF1A\u8BBE\u7F6E\u5BFC\u6F14 / \u9644\u4EF6", "body": "binary", "uploadPolicy": "chatAttachment", "businessHeaders": { "x-attachment-delivery": { "default": "explicit", "values": ["explicit", "legacy"] }, "x-attachment-name": { "fromFilename": true } } },
|
|
2596
|
+
{ "id": "drama.uploadStorySpeechRecording", "method": "PUT", "path": "/api/projects/:projectId/director/speech/recordings/:lineId", "source": "web-src/src/lib/api.ts:2595", "group": "drama", "description": "\u77ED\u5267\uFF1A\u8BBE\u7F6E\u914D\u97F3 / \u5F55\u97F3", "body": "binary", "uploadPolicy": "storySpeech", "businessHeaders": { "x-script-fingerprint": { "required": true } } },
|
|
2597
|
+
{ "id": "email.unsubscribeEmail", "method": "POST", "path": "/api/email/unsubscribe", "source": "web-src/src/lib/api.ts:1561", "group": "email", "description": "\u90AE\u7BB1\uFF1A\u63D0\u4EA4\u90AE\u7BB1 / \u53D6\u6D88\u8BA2\u9605", "body": "json", "public": true },
|
|
2598
|
+
{ "id": "email.verifyEmail", "method": "POST", "path": "/api/email/verify", "source": "web-src/src/lib/api.ts:1559", "group": "email", "description": "\u90AE\u7BB1\uFF1A\u63D0\u4EA4\u90AE\u7BB1 / \u9A8C\u8BC1", "body": "json", "public": true },
|
|
2599
|
+
{ "id": "episodes.approveEpisodeOutline", "method": "POST", "path": "/api/episodes/:id/outline/:docId/approve", "source": "web-src/src/lib/api.ts:3193", "group": "episodes", "description": "\u5206\u96C6\uFF1A\u63D0\u4EA4\u5927\u7EB2 / \u786E\u8BA4", "body": "json" },
|
|
2600
|
+
{ "id": "episodes.generateOutline", "method": "POST", "path": "/api/episodes/:id/outline", "source": "apps/api/src/http/routes/script-engine.ts:143", "group": "episodes", "description": "\u51C6\u5907\u5206\u96C6\u5927\u7EB2", "body": "json" },
|
|
2601
|
+
{ "id": "episodes.getEpisodeOutline", "method": "GET", "path": "/api/episodes/:id/outline", "source": "web-src/src/lib/api.ts:3188", "group": "episodes", "description": "\u5206\u96C6\uFF1A\u67E5\u8BE2\u5206\u96C6 / \u5927\u7EB2" },
|
|
2602
|
+
{ "id": "feedback.commentOnFeedback", "method": "POST", "path": "/api/feedback/tickets/:ticketNo/comments", "source": "web-src/src/lib/api.ts:1621", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u63D0\u4EA4\u53CD\u9988\u5355 / \u8BC4\u8BBA", "body": "json" },
|
|
2603
|
+
{ "id": "feedback.feedbackHonors", "method": "GET", "path": "/api/feedback/honors", "source": "web-src/src/lib/api.ts:1624", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u67E5\u8BE2\u53CD\u9988 / \u8363\u8A89" },
|
|
2604
|
+
{ "id": "feedback.feedbackMe", "method": "GET", "path": "/api/feedback/me", "source": "web-src/src/lib/api.ts:1604", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u67E5\u8BE2\u53CD\u9988 / \u5F53\u524D\u8D26\u53F7" },
|
|
2605
|
+
{ "id": "feedback.feedbackPeriods", "method": "GET", "path": "/api/feedback/periods", "source": "web-src/src/lib/api.ts:1626", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u67E5\u8BE2\u53CD\u9988 / \u5468\u671F" },
|
|
2606
|
+
{ "id": "feedback.feedbackRules", "method": "GET", "path": "/api/feedback/rules", "source": "web-src/src/lib/api.ts:1600", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u67E5\u8BE2\u53CD\u9988 / \u89C4\u5219" },
|
|
2607
|
+
{ "id": "feedback.feedbackTicket", "method": "GET", "path": "/api/feedback/tickets/:ticketNo", "source": "web-src/src/lib/api.ts:1618", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u67E5\u8BE2\u53CD\u9988 / \u53CD\u9988\u5355" },
|
|
2608
|
+
{ "id": "feedback.myFeedback", "method": "GET", "path": "/api/feedback/tickets", "source": "web-src/src/lib/api.ts:1602", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u67E5\u8BE2\u53CD\u9988 / \u53CD\u9988\u5355" },
|
|
2609
|
+
{ "id": "feedback.submitFeedback", "method": "POST", "path": "/api/feedback/tickets", "source": "web-src/src/lib/api.ts:1615", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u63D0\u4EA4\u53CD\u9988 / \u53CD\u9988\u5355", "body": "json" },
|
|
2610
|
+
{ "id": "feedback.uploadFeedbackAttachment", "method": "POST", "path": "/api/feedback/attachments", "source": "web-src/src/lib/api.ts:1608", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u63D0\u4EA4\u53CD\u9988 / \u9644\u4EF6", "body": "binary", "uploadPolicy": "image" },
|
|
2611
|
+
{ "id": "genres.genres", "method": "GET", "path": "/api/genres", "source": "web-src/src/lib/api.ts:2036", "group": "genres", "description": "\u9898\u6750\uFF1A\u67E5\u8BE2\u9898\u6750" },
|
|
2612
|
+
{ "id": "graphic.attachGraphicRunFile", "method": "PUT", "path": "/api/graphic/runs/:runId/attachments", "source": "web-src/src/lib/api.ts:1441", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u8BBE\u7F6E\u4F5C\u54C1 / \u9644\u4EF6", "body": "binary", "uploadPolicy": "graphicAttachment", "businessHeaders": { "x-attachment-delivery": { "default": "explicit", "values": ["explicit", "legacy"] }, "x-attachment-name": { "fromFilename": true } } },
|
|
2613
|
+
{ "id": "graphic.bindGraphicRunProduct", "method": "PATCH", "path": "/api/graphic/runs/:runId/product", "source": "web-src/src/lib/api.ts:1346", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u66F4\u65B0\u4F5C\u54C1 / \u5546\u54C1", "body": "json" },
|
|
2614
|
+
{ "id": "graphic.cancelGraphicGenerationOrder", "method": "POST", "path": "/api/graphic/runs/:runId/generation-orders/:orderId/cancel", "source": "web-src/src/lib/api.ts:1502", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u5236\u4F5C\u5355 / \u53D6\u6D88", "body": "json" },
|
|
2615
|
+
{ "id": "graphic.changeGraphicRunModel", "method": "PATCH", "path": "/api/graphic/runs/:runId/model", "source": "web-src/src/lib/api.ts:1352", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u66F4\u65B0\u4F5C\u54C1 / \u6A21\u578B", "body": "json" },
|
|
2616
|
+
{ "id": "graphic.changeGraphicRunQuality", "method": "PATCH", "path": "/api/graphic/runs/:runId/quality", "source": "web-src/src/lib/api.ts:1357", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u66F4\u65B0\u4F5C\u54C1 / \u753B\u8D28", "body": "json" },
|
|
2617
|
+
{ "id": "graphic.create", "method": "POST", "path": "/api/graphic/runs", "source": "web-src/src/lib/api.ts:1329", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u56FE\u6587 / \u4F5C\u54C1", "body": "json", "exampleBody": { "title": "\u5546\u54C1\u5BA3\u4F20\u56FE" } },
|
|
2618
|
+
{ "id": "graphic.generateGraphicImages", "method": "POST", "path": "/api/graphic/runs/:runId/images", "source": "web-src/src/lib/api.ts:1486", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u56FE\u7247", "body": "json", "businessHeaders": { "prefer": { "default": "respond-async", "values": ["respond-async"] } } },
|
|
2619
|
+
{ "id": "graphic.graphicEditMaskBlob", "method": "GET", "path": "/api/graphic/runs/:runId/images/:imageId/masks/:maskId", "source": "web-src/src/lib/api.ts:1413", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u56FE\u7247 / \u8499\u7248" },
|
|
2620
|
+
{ "id": "graphic.graphicImageBlob", "method": "GET", "path": "/api/graphic/runs/:runId/images/:imageId/download", "source": "web-src/src/lib/api.ts:1380", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u56FE\u7247 / \u4E0B\u8F7D" },
|
|
2621
|
+
{ "id": "graphic.graphicImagePreview", "method": "GET", "path": "/api/graphic/runs/:runId/preview", "source": "web-src/src/lib/api.ts:1370", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u9884\u89C8" },
|
|
2622
|
+
{ "id": "graphic.graphicRun", "method": "GET", "path": "/api/graphic/runs/:runId", "source": "web-src/src/lib/api.ts:1368", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u56FE\u6587 / \u4F5C\u54C1" },
|
|
2623
|
+
{ "id": "graphic.graphicTemplates", "method": "GET", "path": "/api/graphic/templates", "source": "web-src/src/lib/api.ts:1366", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u56FE\u6587 / \u6A21\u677F" },
|
|
2624
|
+
{ "id": "graphic.inspectGraphicRunAttachments", "method": "GET", "path": "/api/graphic/runs/:runId/attachments", "source": "web-src/src/lib/api.ts:1453", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u9644\u4EF6" },
|
|
2625
|
+
{ "id": "graphic.list", "method": "GET", "path": "/api/graphic/runs", "source": "web-src/src/lib/api.ts:1362", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u56FE\u6587 / \u4F5C\u54C1" },
|
|
2626
|
+
{ "id": "graphic.quoteGraphicImages", "method": "POST", "path": "/api/graphic/runs/:runId/quote", "source": "web-src/src/lib/api.ts:1477", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u62A5\u4EF7", "body": "json" },
|
|
2627
|
+
{ "id": "graphic.releaseGraphicOpening", "method": "POST", "path": "/api/graphic/runs/:runId/opening/attachments", "source": "web-src/src/lib/api.ts:1339", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u5F00\u573A / \u9644\u4EF6", "body": "json" },
|
|
2628
|
+
{ "id": "graphic.retryGraphicTurn", "method": "POST", "path": "/api/graphic/runs/:runId/messages/:messageId/retry", "source": "web-src/src/lib/api.ts:1470", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u5BF9\u8BDD / \u91CD\u8BD5", "body": "json" },
|
|
2629
|
+
{ "id": "graphic.saveGraphicEditMask", "method": "POST", "path": "/api/graphic/runs/:runId/images/:imageId/masks", "source": "web-src/src/lib/api.ts:1409", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u56FE\u7247 / \u8499\u7248", "body": "multipart", "uploadPolicy": "mask", "uploadField": "mask" },
|
|
2630
|
+
{ "id": "graphic.saveGraphicImageEdit", "method": "POST", "path": "/api/graphic/runs/:runId/images/:imageId/edits", "source": "web-src/src/lib/api.ts:1402", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u56FE\u7247 / \u7F16\u8F91\u7248\u672C", "body": "multipart", "uploadPolicy": "image", "uploadField": "image" },
|
|
2631
|
+
{ "id": "graphic.saveGraphicRunAttachmentFile", "method": "GET", "path": "/api/graphic/runs/:runId/attachments/:attachmentId/file", "source": "web-src/src/lib/api.ts:1460", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u9644\u4EF6 / \u6587\u4EF6" },
|
|
2632
|
+
{ "id": "graphic.sendGraphicMessage", "method": "POST", "path": "/api/graphic/runs/:runId/messages", "source": "web-src/src/lib/api.ts:1430", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u5BF9\u8BDD", "body": "json", "exampleBody": { "text": "\u4FDD\u7559\u5546\u54C1\u5916\u89C2\uFF0C\u628A\u80CC\u666F\u6539\u6210\u7C73\u767D\u8272" }, "businessHeaders": { "prefer": { "default": "respond-async", "values": ["respond-async"] } } },
|
|
2633
|
+
{ "id": "graphic.stopGraphicRun", "method": "POST", "path": "/api/graphic/runs/:runId/stop", "source": "web-src/src/lib/api.ts:2605", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u505C\u6B62\u56DE\u590D", "body": "json" },
|
|
2634
|
+
{ "id": "graphic.streamGraphicLive", "method": "GET", "path": "/api/graphic/runs/:runId/live", "source": "web-src/src/lib/api.ts:2532", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u5B9E\u65F6\u8FDB\u5EA6" },
|
|
2635
|
+
{ "id": "health.health", "method": "GET", "path": "/api/health", "source": "web-src/src/lib/api.ts:1294", "group": "health", "description": "\u670D\u52A1\u72B6\u6001\uFF1A\u67E5\u8BE2\u670D\u52A1\u72B6\u6001", "public": true },
|
|
2636
|
+
{ "id": "imageModels.imageModelCapabilities", "method": "GET", "path": "/api/image-models/capabilities", "source": "web-src/src/lib/api.ts:2767", "group": "imageModels", "description": "\u56FE\u7247\u6A21\u578B\uFF1A\u67E5\u8BE2\u56FE\u7247\u6A21\u578B / \u80FD\u529B" },
|
|
2637
|
+
{ "id": "imageModels.imageModelReadiness", "method": "GET", "path": "/api/image-models/readiness", "source": "web-src/src/lib/api.ts:2766", "group": "imageModels", "description": "\u56FE\u7247\u6A21\u578B\uFF1A\u67E5\u8BE2\u56FE\u7247\u6A21\u578B / \u5C31\u7EEA\u72B6\u6001" },
|
|
2638
|
+
{ "id": "library.archiveLibraryProject", "method": "POST", "path": "/api/project-library/:kind/:sourceId/archive", "source": "web-src/src/lib/api.ts:2914", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u63D0\u4EA4\u4F5C\u54C1\u5E93 / \u5F52\u6863", "body": "json" },
|
|
2639
|
+
{ "id": "library.downloadTicket", "method": "POST", "path": "/api/project-library/batch-actions/:batchId/download-ticket", "sensitiveOutput": true, "source": "apps/api/src/http/routes/project-library.ts:284", "group": "library", "description": "\u51C6\u5907\u4F5C\u54C1\u5E93\u5408\u96C6\u4E0B\u8F7D", "body": "json" },
|
|
2640
|
+
{ "id": "library.downloadZip", "method": "GET", "path": "/api/project-library/batch-actions/:batchId/download.zip", "source": "apps/api/src/http/routes/project-library.ts:272", "group": "library", "description": "\u4E0B\u8F7D\u4F5C\u54C1\u5E93\u5408\u96C6" },
|
|
2641
|
+
{ "id": "library.executeProjectLibraryBatch", "method": "POST", "path": "/api/project-library/batch-actions/:preflightId/execute", "source": "web-src/src/lib/api.ts:2937", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u63D0\u4EA4\u4F5C\u54C1\u6279\u91CF\u7BA1\u7406 / \u6267\u884C", "body": "json" },
|
|
2642
|
+
{ "id": "library.preflightProjectLibraryBatch", "method": "POST", "path": "/api/project-library/batch-actions/preflight", "source": "web-src/src/lib/api.ts:2924", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u63D0\u4EA4\u4F5C\u54C1\u6279\u91CF\u7BA1\u7406 / \u9884\u68C0", "body": "json" },
|
|
2643
|
+
{ "id": "library.projectLibrary", "method": "GET", "path": "/api/project-library", "source": "web-src/src/lib/api.ts:2891", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u67E5\u8BE2\u4F5C\u54C1\u5E93" },
|
|
2644
|
+
{ "id": "library.projectLibraryBatch", "method": "GET", "path": "/api/project-library/batch-actions/:batchId", "source": "web-src/src/lib/api.ts:2949", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u67E5\u8BE2\u4F5C\u54C1\u5E93 / \u4F5C\u54C1\u6279\u91CF\u7BA1\u7406" },
|
|
2645
|
+
{ "id": "library.projectLibraryByProduct", "method": "GET", "path": "/api/project-library/by-product", "source": "web-src/src/lib/api.ts:2902", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u67E5\u8BE2\u4F5C\u54C1\u5E93 / \u6309\u5546\u54C1\u6C47\u603B" },
|
|
2646
|
+
{ "id": "library.projectLibrarySummary", "method": "GET", "path": "/api/project-library/summary", "source": "web-src/src/lib/api.ts:2896", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u67E5\u8BE2\u4F5C\u54C1\u5E93 / \u6982\u51B5" },
|
|
2647
|
+
{ "id": "library.renameLibraryProject", "method": "PATCH", "path": "/api/project-library/:kind/:sourceId/name", "source": "web-src/src/lib/api.ts:2905", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u66F4\u65B0\u4F5C\u54C1\u5E93 / \u540D\u79F0", "body": "json" },
|
|
2648
|
+
{ "id": "library.unarchiveLibraryProject", "method": "POST", "path": "/api/project-library/:kind/:sourceId/unarchive", "source": "web-src/src/lib/api.ts:2919", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u63D0\u4EA4\u4F5C\u54C1\u5E93 / \u6062\u590D\u5F52\u6863", "body": "json" },
|
|
2649
|
+
{ "id": "membership.brands", "method": "GET", "path": "/api/membership/brands", "source": "web-src/src/lib/membership.ts:345", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458 / \u54C1\u724C" },
|
|
2650
|
+
{ "id": "membership.catalog", "method": "GET", "path": "/api/membership/catalog", "source": "web-src/src/lib/membership.ts:334", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458 / \u76EE\u5F55" },
|
|
2651
|
+
{ "id": "membership.claimDailyAutomatically", "method": "POST", "path": "/api/membership/daily-claim", "source": "web-src/src/lib/membership.ts:339", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u4F1A\u5458 / \u9886\u53D6\u6BCF\u65E5\u6743\u76CA", "body": "json" },
|
|
2652
|
+
{ "id": "membership.daily", "method": "GET", "path": "/api/membership/daily", "source": "web-src/src/lib/membership.ts:338", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458 / \u6BCF\u65E5\u6743\u76CA" },
|
|
2653
|
+
{ "id": "membership.deleteBrand", "method": "DELETE", "path": "/api/membership/brands/:brandId", "source": "web-src/src/lib/membership.ts:348", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u5220\u9664\u4F1A\u5458 / \u54C1\u724C", "body": "json" },
|
|
2654
|
+
{ "id": "membership.downloadPack", "method": "GET", "path": "/api/membership/renders/:taskId/output", "source": "apps/api/src/http/routes/membership.ts:165", "group": "membership", "description": "\u4E0B\u8F7D\u5305\u88C5\u6210\u7247" },
|
|
2655
|
+
{ "id": "membership.orders.create", "method": "POST", "path": "/api/membership/orders", "source": "web-src/src/lib/membership.ts:337", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u4F1A\u5458 / \u8BA2\u5355", "body": "json", "idempotencyBodyKey": "idempotencyKey", "replaySafe": true, "exampleBody": { "planVersion": "\u4ECEmembership.catalog\u8BFB\u53D6\u5F53\u524D\u7248\u672C", "intent": "purchase" } },
|
|
2656
|
+
{ "id": "membership.payments.checkout", "method": "POST", "path": "/api/payments/orders/:id/checkout", "source": "web-src/src/lib/api.ts:3286", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u8BA2\u5355 / \u4F1A\u5458\u4ED8\u6B3E", "body": "json", "membershipPaymentOnly": true },
|
|
2657
|
+
{ "id": "membership.payments.show", "method": "GET", "path": "/api/payments/orders/:id", "source": "apps/api/src/http/routes/payments.ts:87", "group": "membership", "description": "\u8BFB\u53D6\u5E76\u9A8C\u8BC1\u672C\u4EBA\u7684\u4F1A\u5458\u4ED8\u6B3E\u5355", "membershipPaymentOnly": true },
|
|
2658
|
+
{ "id": "membership.payments.status", "method": "GET", "path": "/api/payments/orders/:id/status", "source": "web-src/src/lib/api.ts:3292", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u8BA2\u5355 / \u72B6\u6001", "membershipPaymentOnly": true },
|
|
2659
|
+
{ "id": "membership.refund", "method": "POST", "path": "/api/membership/orders/:orderId/refund", "source": "web-src/src/lib/membership.ts:342", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u8BA2\u5355 / \u9000\u6B3E", "body": "json", "idempotencyBodyKey": "idempotencyKey", "replaySafe": true, "exampleBody": {} },
|
|
2660
|
+
{ "id": "membership.refundDetails", "method": "GET", "path": "/api/membership/refunds/:groupId", "source": "web-src/src/lib/membership.ts:343", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458 / \u9000\u6B3E\u8BB0\u5F55" },
|
|
2661
|
+
{ "id": "membership.refundQuote", "method": "POST", "path": "/api/membership/orders/:orderId/refund-quote", "source": "web-src/src/lib/membership.ts:341", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u8BA2\u5355 / \u9000\u6B3E\u8BD5\u7B97", "body": "json" },
|
|
2662
|
+
{ "id": "membership.refundStatus", "method": "POST", "path": "/api/membership/refunds/:groupId/status", "source": "web-src/src/lib/membership.ts:344", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u9000\u6B3E\u8BB0\u5F55 / \u72B6\u6001", "body": "json" },
|
|
2663
|
+
{ "id": "membership.render", "method": "POST", "path": "/api/membership/render", "source": "web-src/src/lib/membership.ts:353", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u4F1A\u5458 / \u5236\u4F5C\u5305\u88C5", "body": "json" },
|
|
2664
|
+
{ "id": "membership.renderAssets", "method": "GET", "path": "/api/membership/render-assets", "source": "web-src/src/lib/membership.ts:351", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458 / \u5305\u88C5\u7D20\u6750" },
|
|
2665
|
+
{ "id": "membership.renderPreview", "method": "POST", "path": "/api/membership/render-preview", "source": "web-src/src/lib/membership.ts:350", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u4F1A\u5458 / \u5305\u88C5\u9884\u89C8", "body": "json" },
|
|
2666
|
+
{ "id": "membership.renderQuote", "method": "POST", "path": "/api/membership/render-quote", "source": "web-src/src/lib/membership.ts:352", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u4F1A\u5458 / \u5305\u88C5\u62A5\u4EF7", "body": "json" },
|
|
2667
|
+
{ "id": "membership.renders.list", "method": "GET", "path": "/api/membership/renders", "source": "web-src/src/components/domain/story-film-packs.tsx:30", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458 / \u5305\u88C5\u6210\u7247" },
|
|
2668
|
+
{ "id": "membership.renderSources", "method": "GET", "path": "/api/membership/render-sources", "source": "web-src/src/lib/membership.ts:349", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458 / \u5305\u88C5\u7247\u6E90" },
|
|
2669
|
+
{ "id": "membership.saveBrand", "method": "POST", "path": "/api/membership/brands", "source": "web-src/src/lib/membership.ts:347", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u4F1A\u5458 / \u54C1\u724C", "body": "json" },
|
|
2670
|
+
{ "id": "membership.summary", "method": "GET", "path": "/api/membership", "source": "web-src/src/lib/membership.ts:335", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458" },
|
|
2671
|
+
{ "id": "notifications.markAllNotificationsRead", "method": "POST", "path": "/api/notifications/read-all", "source": "web-src/src/lib/api.ts:1526", "group": "notifications", "description": "\u901A\u77E5\uFF1A\u63D0\u4EA4\u901A\u77E5 / \u5168\u90E8\u6807\u4E3A\u5DF2\u8BFB", "body": "json" },
|
|
2672
|
+
{ "id": "notifications.markNotificationsRead", "method": "POST", "path": "/api/notifications/read", "source": "web-src/src/lib/api.ts:1524", "group": "notifications", "description": "\u901A\u77E5\uFF1A\u63D0\u4EA4\u901A\u77E5 / \u6807\u8BB0\u5DF2\u8BFB", "body": "json" },
|
|
2673
|
+
{ "id": "notifications.notifications", "method": "GET", "path": "/api/notifications", "source": "web-src/src/lib/api.ts:1520", "group": "notifications", "description": "\u901A\u77E5\uFF1A\u67E5\u8BE2\u901A\u77E5" },
|
|
2674
|
+
{ "id": "notifications.notificationSummary", "method": "GET", "path": "/api/notifications/summary", "source": "web-src/src/lib/api.ts:1512", "group": "notifications", "description": "\u901A\u77E5\uFF1A\u67E5\u8BE2\u901A\u77E5 / \u6982\u51B5" },
|
|
2675
|
+
{ "id": "notifications.pushKey", "method": "GET", "path": "/api/notifications/push/key", "source": "web-src/src/lib/api.ts:1583", "group": "notifications", "description": "\u901A\u77E5\uFF1A\u67E5\u8BE2\u63A8\u9001 / \u63A8\u9001\u516C\u94A5" },
|
|
2676
|
+
{ "id": "notifications.subscribePush", "method": "POST", "path": "/api/notifications/push/subscribe", "source": "web-src/src/lib/api.ts:1586", "group": "notifications", "description": "\u901A\u77E5\uFF1A\u63D0\u4EA4\u63A8\u9001 / \u8BA2\u9605\u63A8\u9001", "body": "json" },
|
|
2677
|
+
{ "id": "notifications.unsubscribePush", "method": "POST", "path": "/api/notifications/push/unsubscribe", "source": "web-src/src/lib/api.ts:1589", "group": "notifications", "description": "\u901A\u77E5\uFF1A\u63D0\u4EA4\u63A8\u9001 / \u53D6\u6D88\u8BA2\u9605", "body": "json" },
|
|
2678
|
+
{ "id": "products.archiveProduct", "method": "POST", "path": "/api/products/:id/archive", "source": "web-src/src/lib/api.ts:2063", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1 / \u5F52\u6863", "body": "json" },
|
|
2679
|
+
{ "id": "products.confirmProductLock", "method": "POST", "path": "/api/products/:id/lock/confirm", "source": "web-src/src/lib/api.ts:2879", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1\u5916\u89C2 / \u786E\u8BA4", "body": "json" },
|
|
2680
|
+
{ "id": "products.create", "method": "POST", "path": "/api/products", "source": "web-src/src/lib/api.ts:2079", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1", "body": "json" },
|
|
2681
|
+
{ "id": "products.createSeries", "method": "POST", "path": "/api/products/:id/series", "source": "web-src/src/lib/api.ts:3173", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1 / \u7CFB\u5217", "body": "json" },
|
|
2682
|
+
{ "id": "products.deleteProductImage", "method": "DELETE", "path": "/api/products/:id/images", "source": "web-src/src/lib/api.ts:2105", "group": "products", "description": "\u5546\u54C1\uFF1A\u5220\u9664\u5546\u54C1 / \u56FE\u7247", "body": "json" },
|
|
2683
|
+
{ "id": "products.get", "method": "GET", "path": "/api/products/:id", "source": "web-src/src/lib/api.ts:2048", "group": "products", "description": "\u5546\u54C1\uFF1A\u67E5\u8BE2\u5546\u54C1" },
|
|
2684
|
+
{ "id": "products.list", "method": "GET", "path": "/api/products", "source": "web-src/src/lib/api.ts:2047", "group": "products", "description": "\u5546\u54C1\uFF1A\u67E5\u8BE2\u5546\u54C1" },
|
|
2685
|
+
{ "id": "products.mergeProducts", "method": "POST", "path": "/api/products/:id/merge", "source": "web-src/src/lib/api.ts:2059", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1 / \u5408\u5E76", "body": "json" },
|
|
2686
|
+
{ "id": "products.productUsage", "method": "GET", "path": "/api/products/usage", "source": "web-src/src/lib/api.ts:2050", "group": "products", "description": "\u5546\u54C1\uFF1A\u67E5\u8BE2\u5546\u54C1 / \u4F7F\u7528\u60C5\u51B5" },
|
|
2687
|
+
{ "id": "products.recognizeProductLock", "method": "POST", "path": "/api/products/:id/recognize-lock", "source": "web-src/src/lib/api.ts:2109", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1 / \u8BC6\u522B\u5546\u54C1\u5916\u89C2", "body": "json" },
|
|
2688
|
+
{ "id": "products.renameProduct", "method": "PATCH", "path": "/api/products/:id", "source": "web-src/src/lib/api.ts:2052", "group": "products", "description": "\u5546\u54C1\uFF1A\u66F4\u65B0\u5546\u54C1", "body": "json" },
|
|
2689
|
+
{ "id": "products.unarchiveProduct", "method": "POST", "path": "/api/products/:id/unarchive", "source": "web-src/src/lib/api.ts:2065", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1 / \u6062\u590D\u5F52\u6863", "body": "json" },
|
|
2690
|
+
{ "id": "products.unmergeProduct", "method": "POST", "path": "/api/products/:id/unmerge", "source": "web-src/src/lib/api.ts:2061", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1 / \u64A4\u9500\u5408\u5E76", "body": "json" },
|
|
2691
|
+
{ "id": "products.uploadProductImage", "method": "PUT", "path": "/api/products/:id/images", "source": "web-src/src/lib/api.ts:2094", "group": "products", "description": "\u5546\u54C1\uFF1A\u8BBE\u7F6E\u5546\u54C1 / \u56FE\u7247", "body": "binary", "uploadPolicy": "image" },
|
|
2692
|
+
{ "id": "public.checkReferralCode", "method": "POST", "path": "/api/public/referral-codes/check", "source": "web-src/src/lib/api.ts:1707", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u63D0\u4EA4\u63A8\u8350\u7801 / \u6838\u9A8C", "body": "json", "public": true },
|
|
2693
|
+
{ "id": "public.publicAnnouncements", "method": "GET", "path": "/api/public/announcements", "source": "web-src/src/lib/api.ts:1529", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u67E5\u8BE2\u516C\u5F00\u4FE1\u606F / \u516C\u544A", "public": true },
|
|
2694
|
+
{ "id": "public.publicAssetProof", "method": "GET", "path": "/api/public/assets/summary", "source": "web-src/src/lib/api.ts:1506", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u67E5\u8BE2\u7D20\u6750 / \u6982\u51B5", "public": true },
|
|
2695
|
+
{ "id": "public.publicPricing", "method": "GET", "path": "/api/public/pricing", "source": "web-src/src/lib/api.ts:1291", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u67E5\u8BE2\u516C\u5F00\u4FE1\u606F / \u4EF7\u683C", "public": true },
|
|
2696
|
+
{ "id": "public.publicRankings", "method": "GET", "path": "/api/public/rankings", "source": "web-src/src/lib/api.ts:1292", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u67E5\u8BE2\u516C\u5F00\u4FE1\u606F / \u699C\u5355", "public": true },
|
|
2697
|
+
{ "id": "public.publicShowcase", "method": "GET", "path": "/api/public/showcase", "source": "web-src/src/lib/api.ts:1306", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u67E5\u8BE2\u516C\u5F00\u4FE1\u606F / \u5C55\u793A\u4F5C\u54C1", "public": true },
|
|
2698
|
+
{ "id": "public.recordReferralVisit", "method": "POST", "path": "/api/public/referral-codes/visit", "source": "web-src/src/lib/api.ts:1727", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u63D0\u4EA4\u63A8\u8350\u7801 / \u8BBF\u95EE\u8BB0\u5F55", "body": "json", "public": true },
|
|
2699
|
+
{ "id": "public.submitTrialRequest", "method": "POST", "path": "/api/public/trial-requests", "source": "web-src/src/lib/api.ts:1509", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u63D0\u4EA4\u516C\u5F00\u4FE1\u606F / \u8BD5\u7528\u7533\u8BF7", "body": "json", "public": true },
|
|
2700
|
+
{ "id": "series.approveSeriesOutline", "method": "POST", "path": "/api/series/:id/outline/:docId/approve", "source": "web-src/src/lib/api.ts:3184", "group": "series", "description": "\u7CFB\u5217\uFF1A\u63D0\u4EA4\u5927\u7EB2 / \u786E\u8BA4", "body": "json" },
|
|
2701
|
+
{ "id": "series.createEpisode", "method": "POST", "path": "/api/series/:id/episodes", "source": "web-src/src/lib/api.ts:3175", "group": "series", "description": "\u7CFB\u5217\uFF1A\u63D0\u4EA4\u7CFB\u5217 / \u5206\u96C6", "body": "json" },
|
|
2702
|
+
{ "id": "series.generateOutline", "method": "POST", "path": "/api/series/:id/outline", "source": "apps/api/src/http/routes/script-engine.ts:99", "group": "series", "description": "\u51C6\u5907\u7CFB\u5217\u5927\u7EB2", "body": "json" },
|
|
2703
|
+
{ "id": "series.getSeries", "method": "GET", "path": "/api/series/:id", "source": "web-src/src/lib/api.ts:3171", "group": "series", "description": "\u7CFB\u5217\uFF1A\u67E5\u8BE2\u7CFB\u5217" },
|
|
2704
|
+
{ "id": "series.getSeriesOutline", "method": "GET", "path": "/api/series/:id/outline", "source": "web-src/src/lib/api.ts:3179", "group": "series", "description": "\u7CFB\u5217\uFF1A\u67E5\u8BE2\u7CFB\u5217 / \u5927\u7EB2" },
|
|
2705
|
+
{ "id": "series.listSeries", "method": "GET", "path": "/api/series", "source": "web-src/src/lib/api.ts:3170", "group": "series", "description": "\u7CFB\u5217\uFF1A\u67E5\u8BE2\u7CFB\u5217" },
|
|
2706
|
+
{ "id": "templates.createTemplateShortOrder", "method": "POST", "path": "/api/template-shorts/orders", "source": "web-src/src/lib/api.ts:3565", "group": "templates", "description": "\u6A21\u677F\u77ED\u7247\uFF1A\u63D0\u4EA4\u6A21\u677F\u77ED\u7247 / \u8BA2\u5355", "body": "json" },
|
|
2707
|
+
{ "id": "templates.quoteTemplateShortOrder", "method": "POST", "path": "/api/template-shorts/quote", "source": "web-src/src/lib/api.ts:3561", "group": "templates", "description": "\u6A21\u677F\u77ED\u7247\uFF1A\u63D0\u4EA4\u6A21\u677F\u77ED\u7247 / \u62A5\u4EF7", "body": "json" },
|
|
2708
|
+
{ "id": "templates.templateShortOrder", "method": "GET", "path": "/api/template-shorts/orders/:id", "source": "web-src/src/lib/api.ts:3569", "group": "templates", "description": "\u6A21\u677F\u77ED\u7247\uFF1A\u67E5\u8BE2\u6A21\u677F\u77ED\u7247 / \u8BA2\u5355" },
|
|
2709
|
+
{ "id": "templates.templateShortOrderDownload", "method": "GET", "path": "/api/template-shorts/orders/:id/download", "source": "web-src/src/lib/api.ts:3576", "group": "templates", "description": "\u6A21\u677F\u77ED\u7247\uFF1A\u67E5\u8BE2\u8BA2\u5355 / \u4E0B\u8F7D" },
|
|
2710
|
+
{ "id": "templates.templateShortsCatalog", "method": "GET", "path": "/api/template-shorts/catalog", "source": "web-src/src/lib/api.ts:3557", "group": "templates", "description": "\u6A21\u677F\u77ED\u7247\uFF1A\u67E5\u8BE2\u6A21\u677F\u77ED\u7247 / \u76EE\u5F55" },
|
|
2711
|
+
{ "id": "templates.uploadTemplateShortAsset", "method": "POST", "path": "/api/template-shorts/uploads", "source": "web-src/src/lib/api.ts:3585", "group": "templates", "description": "\u6A21\u677F\u77ED\u7247\uFF1A\u63D0\u4EA4\u6A21\u677F\u77ED\u7247 / \u4E0A\u4F20", "body": "binary", "uploadPolicy": "image" },
|
|
2712
|
+
{ "id": "upscale.createUpscaleOrder", "method": "POST", "path": "/api/upscale/orders", "source": "web-src/src/lib/api.ts:2962", "group": "upscale", "description": "\u8D85\u6E05\u753B\u8D28\uFF1A\u63D0\u4EA4\u8D85\u6E05\u753B\u8D28 / \u8BA2\u5355", "body": "json" },
|
|
2713
|
+
{ "id": "upscale.download", "method": "GET", "path": "/api/upscale/orders/:id/video", "source": "apps/api/src/http/routes/upscale.ts:28", "group": "upscale", "description": "\u4E0B\u8F7D\u8D85\u6E05\u6210\u7247" },
|
|
2714
|
+
{ "id": "upscale.listUpscaleOrders", "method": "GET", "path": "/api/upscale/orders", "source": "web-src/src/lib/api.ts:2965", "group": "upscale", "description": "\u8D85\u6E05\u753B\u8D28\uFF1A\u67E5\u8BE2\u8D85\u6E05\u753B\u8D28 / \u8BA2\u5355" },
|
|
2715
|
+
{ "id": "upscale.quoteUpscale", "method": "POST", "path": "/api/upscale/quote", "source": "web-src/src/lib/api.ts:2960", "group": "upscale", "description": "\u8D85\u6E05\u753B\u8D28\uFF1A\u63D0\u4EA4\u8D85\u6E05\u753B\u8D28 / \u62A5\u4EF7", "body": "json" },
|
|
2716
|
+
{ "id": "upscale.upscaleCapability", "method": "GET", "path": "/api/upscale/capability", "source": "web-src/src/lib/api.ts:2958", "group": "upscale", "description": "\u8D85\u6E05\u753B\u8D28\uFF1A\u67E5\u8BE2\u8D85\u6E05\u753B\u8D28 / \u80FD\u529B" },
|
|
2717
|
+
{ "id": "videoModels.videoModelReadiness", "method": "GET", "path": "/api/video-models/readiness", "source": "web-src/src/lib/api.ts:2765", "group": "videoModels", "description": "\u89C6\u9891\u6A21\u578B\uFF1A\u67E5\u8BE2\u89C6\u9891\u6A21\u578B / \u5C31\u7EEA\u72B6\u6001" },
|
|
2718
|
+
{ "id": "videos.acceptShowcaseLearning", "method": "POST", "path": "/api/showcase-videos/:id/accept-learning", "source": "web-src/src/lib/api.ts:2872", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891 / \u91C7\u7528\u5B66\u4E60\u7ED3\u679C", "body": "json" },
|
|
2719
|
+
{ "id": "videos.adoptCommercialAdAssetGapUploaded", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/gaps/:gapId/adopt-uploaded", "source": "web-src/src/lib/api.ts:2325", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u7D20\u6750\u7F3A\u53E3 / \u91C7\u7528\u4E0A\u4F20\u7D20\u6750", "body": "json" },
|
|
2720
|
+
{ "id": "videos.applyCommercialAdMusic", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/music/:taskId/apply", "source": "web-src/src/lib/api.ts:2191", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u914D\u4E50 / \u5E94\u7528", "body": "json" },
|
|
2721
|
+
{ "id": "videos.attachCommercialAdRootImage", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/attachments", "source": "web-src/src/lib/api.ts:2422", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u8BBE\u7F6E\u4F5C\u54C1 / \u9644\u4EF6", "body": "binary", "uploadPolicy": "chatAttachment", "businessHeaders": { "x-attachment-delivery": { "default": "explicit", "values": ["explicit", "legacy"] }, "x-attachment-name": { "fromFilename": true } } },
|
|
2722
|
+
{ "id": "videos.cancelCommercialAdRunWaitingBudget", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/cancel-waiting-budget", "source": "web-src/src/lib/api.ts:2340", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u505C\u6B62\u7B49\u5F85\u4F59\u989D", "body": "json" },
|
|
2723
|
+
{ "id": "videos.commercialAdAreaMaskBlob", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/area/:quoteId/mask", "source": "web-src/src/lib/api.ts:2211", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5C40\u90E8\u4FEE\u6539 / \u8499\u7248" },
|
|
2724
|
+
{ "id": "videos.commercialAdAreaPreviewBlob", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/area/:jobId/preview", "source": "web-src/src/lib/api.ts:2213", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5C40\u90E8\u4FEE\u6539 / \u9884\u89C8" },
|
|
2725
|
+
{ "id": "videos.commercialAdImageBlob", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/images/:assetId/download", "source": "web-src/src/lib/api.ts:2216", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u56FE\u7247 / \u4E0B\u8F7D" },
|
|
2726
|
+
{ "id": "videos.commercialAdImageBlob.download", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/storyboards/:imageKey/download", "source": "web-src/src/lib/api.ts:2216", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u6545\u4E8B\u677F / \u4E0B\u8F7D" },
|
|
2727
|
+
{ "id": "videos.commercialAdImageBlob.download_2", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/:editId/download", "source": "web-src/src/lib/api.ts:2216", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u56FE\u7247\u7F16\u8F91 / \u4E0B\u8F7D" },
|
|
2728
|
+
{ "id": "videos.commercialAdInspirations", "method": "GET", "path": "/api/showcase-videos/inspirations", "source": "web-src/src/lib/api.ts:2763", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u7075\u611F" },
|
|
2729
|
+
{ "id": "videos.commercialAdMethods", "method": "GET", "path": "/api/showcase-videos/methods", "source": "web-src/src/lib/api.ts:2760", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u5236\u4F5C\u65B9\u5F0F" },
|
|
2730
|
+
{ "id": "videos.commercialAdPlayCards", "method": "GET", "path": "/api/showcase-videos/play-cards", "source": "web-src/src/lib/api.ts:2762", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u73A9\u6CD5" },
|
|
2731
|
+
{ "id": "videos.compareCommercialAdRunFileVersions", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/files/:path/versions/compare", "source": "web-src/src/lib/api.ts:2247", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u7248\u672C / \u5BF9\u6BD4" },
|
|
2732
|
+
{ "id": "videos.confirmCommercialAdAreaEdit", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/area/confirm", "source": "web-src/src/lib/api.ts:2209", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5C40\u90E8\u4FEE\u6539 / \u786E\u8BA4", "body": "json" },
|
|
2733
|
+
{ "id": "videos.confirmCommercialAdDirectorImage", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/confirm-image", "source": "web-src/src/lib/api.ts:2388", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u786E\u8BA4\u51FA\u56FE", "body": "json" },
|
|
2734
|
+
{ "id": "videos.confirmCommercialAdRootProduction", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/confirm-production", "source": "web-src/src/lib/api.ts:2379", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u786E\u8BA4\u5236\u4F5C", "body": "json" },
|
|
2735
|
+
{ "id": "videos.confirmCommercialAdRootProductLock", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/product-lock-confirm", "source": "web-src/src/lib/api.ts:2354", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u786E\u8BA4\u5546\u54C1\u5916\u89C2", "body": "json" },
|
|
2736
|
+
{ "id": "videos.confirmShowcaseVideo", "method": "POST", "path": "/api/showcase-videos/:id/confirm", "source": "web-src/src/lib/api.ts:2866", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891 / \u786E\u8BA4", "body": "json" },
|
|
2737
|
+
{ "id": "videos.continueCommercialAdVoiceSelection", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/voice-selection/continue", "source": "web-src/src/lib/api.ts:2171", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u97F3\u8272\u9009\u62E9 / \u7EE7\u7EED", "body": "json" },
|
|
2738
|
+
{ "id": "videos.createCommercialAdMediaPass", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/media-pass", "source": "web-src/src/lib/api.ts:2194", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u64AD\u653E\u51ED\u8BC1", "body": "json" },
|
|
2739
|
+
{ "id": "videos.createCommercialAdPresetVoiceSample", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/voice-candidates/preset", "source": "web-src/src/lib/api.ts:2167", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u97F3\u8272\u5019\u9009 / \u9884\u8BBE", "body": "json" },
|
|
2740
|
+
{ "id": "videos.createMotionReference", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/motion-references", "source": "apps/api/src/http/routes/showcase.ts:749", "group": "videos", "description": "\u622A\u53D6\u52A8\u4F5C\u53C2\u8003", "body": "json" },
|
|
2741
|
+
{ "id": "videos.createShowcaseVideo", "method": "POST", "path": "/api/showcase-videos", "source": "web-src/src/lib/api.ts:2135", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891", "body": "json" },
|
|
2742
|
+
{ "id": "videos.decideCommercialAdPublicReferenceCandidate", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/public-reference-candidates/:assetId/decision", "source": "web-src/src/lib/api.ts:2158", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u8BBE\u7F6E\u516C\u5F00\u53C2\u8003 / \u9009\u7528\u610F\u89C1", "body": "json" },
|
|
2743
|
+
{ "id": "videos.deleteCommercialAdAsset", "method": "DELETE", "path": "/api/showcase-videos/assets/:id", "source": "web-src/src/lib/api.ts:2564", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u5220\u9664\u5546\u54C1\u89C6\u9891 / \u7D20\u6750", "body": "json" },
|
|
2744
|
+
{ "id": "videos.downloadAppend", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/append-tasks/:taskId/clip", "source": "apps/api/src/http/routes/showcase.ts:548", "group": "videos", "description": "\u4E0B\u8F7D\u65B0\u589E\u7247\u6BB5" },
|
|
2745
|
+
{ "id": "videos.downloadEdit", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/edits/:editId/download", "source": "apps/api/src/http/routes/showcase.ts:524", "group": "videos", "description": "\u4E0B\u8F7D\u5546\u54C1\u89C6\u9891\u526A\u8F91\u7248" },
|
|
2746
|
+
{ "id": "videos.downloadEditSubtitles", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/edits/:editId/subtitles", "source": "apps/api/src/http/routes/showcase.ts:527", "group": "videos", "description": "\u4E0B\u8F7D\u5546\u54C1\u89C6\u9891\u526A\u8F91\u5B57\u5E55" },
|
|
2747
|
+
{ "id": "videos.downloadFinal", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/video/download", "source": "apps/api/src/http/routes/showcase.ts:829", "group": "videos", "description": "\u4E0B\u8F7D\u5546\u54C1\u89C6\u9891\u6210\u7247" },
|
|
2748
|
+
{ "id": "videos.downloadMusic", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/music/:taskId/tracks/:index/download", "source": "apps/api/src/http/routes/showcase.ts:817", "group": "videos", "description": "\u4E0B\u8F7D\u914D\u4E50\u97F3\u8F68" },
|
|
2749
|
+
{ "id": "videos.downloadNarration", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/edits/:editId/narration/download", "source": "apps/api/src/http/routes/showcase.ts:538", "group": "videos", "description": "\u4E0B\u8F7D\u65C1\u767D\u97F3\u8F68" },
|
|
2750
|
+
{ "id": "videos.downloadProduction", "method": "GET", "path": "/api/showcase-videos/:id/video/download", "source": "apps/api/src/http/routes/showcase.ts:1460", "group": "videos", "description": "\u4E0B\u8F7D\u6307\u5B9A\u5236\u4F5C\u6210\u7247" },
|
|
2751
|
+
{ "id": "videos.generateCommercialAdAsset", "method": "POST", "path": "/api/showcase-videos/assets/generate", "source": "web-src/src/lib/api.ts:2542", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u7D20\u6750 / \u5236\u4F5C", "body": "json" },
|
|
2752
|
+
{ "id": "videos.getCommercialAdAreaQuote", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/area/:quoteId", "source": "web-src/src/lib/api.ts:2207", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u56FE\u7247\u7F16\u8F91 / \u5C40\u90E8\u4FEE\u6539" },
|
|
2753
|
+
{ "id": "videos.getCommercialAdMusicTrackAudio", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/music/:taskId/tracks/:index/audio", "source": "web-src/src/lib/api.ts:2196", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u97F3\u8F68 / \u97F3\u9891" },
|
|
2754
|
+
{ "id": "videos.getCommercialAdPlatformVoiceAudio", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/platform-voices/:voiceId/audio", "source": "web-src/src/lib/api.ts:2179", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5E73\u53F0\u97F3\u8272 / \u97F3\u9891" },
|
|
2755
|
+
{ "id": "videos.getCommercialAdPlatformVoices", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/platform-voices", "source": "web-src/src/lib/api.ts:2177", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u5E73\u53F0\u97F3\u8272" },
|
|
2756
|
+
{ "id": "videos.getCommercialAdPresetVoiceSampleAudio", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/voice-presets/:voiceId/sample", "source": "web-src/src/lib/api.ts:2182", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u97F3\u8272\u9884\u8BBE / \u8BD5\u542C" },
|
|
2757
|
+
{ "id": "videos.getCommercialAdProductionPreview", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/production-preview", "source": "web-src/src/lib/api.ts:2146", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u5236\u4F5C\u9884\u89C8" },
|
|
2758
|
+
{ "id": "videos.getCommercialAdPublicReferenceCandidates", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/public-reference-candidates", "source": "web-src/src/lib/api.ts:2156", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u516C\u5F00\u53C2\u8003" },
|
|
2759
|
+
{ "id": "videos.getCommercialAdRun", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId", "source": "web-src/src/lib/api.ts:2143", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u4F5C\u54C1" },
|
|
2760
|
+
{ "id": "videos.getCommercialAdRunFile", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/files/:path", "source": "web-src/src/lib/api.ts:2224", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u6587\u4EF6" },
|
|
2761
|
+
{ "id": "videos.getCommercialAdRunFileVersion", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/files/:path/versions/:versionId", "source": "web-src/src/lib/api.ts:2235", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u6587\u4EF6 / \u7248\u672C" },
|
|
2762
|
+
{ "id": "videos.getCommercialAdSubtitles", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/subtitles", "source": "web-src/src/lib/api.ts:2149", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u5B57\u5E55" },
|
|
2763
|
+
{ "id": "videos.getCommercialAdVoiceAudio", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/voice-candidates/:candidateId/audio", "source": "web-src/src/lib/api.ts:2173", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u97F3\u8272\u5019\u9009 / \u97F3\u9891" },
|
|
2764
|
+
{ "id": "videos.getCommercialAdVoiceCandidates", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/voice-candidates", "source": "web-src/src/lib/api.ts:2154", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u97F3\u8272\u5019\u9009" },
|
|
2765
|
+
{ "id": "videos.getCommercialAdVoiceLibraryAudio", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/voice-library/:candidateId/audio", "source": "web-src/src/lib/api.ts:2175", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u58F0\u97F3\u5E93 / \u97F3\u9891" },
|
|
2766
|
+
{ "id": "videos.getCommercialAdVoiceoverPreviewAudio", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/voiceover/previews/:previewId/audio", "source": "web-src/src/lib/api.ts:2185", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u9884\u89C8 / \u97F3\u9891" },
|
|
2767
|
+
{ "id": "videos.getShowcaseVideo", "method": "GET", "path": "/api/showcase-videos/:id", "source": "web-src/src/lib/api.ts:2709", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891" },
|
|
2768
|
+
{ "id": "videos.inspectCommercialAdRootAttachments", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/attachments", "source": "web-src/src/lib/api.ts:2434", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u9644\u4EF6" },
|
|
2769
|
+
{ "id": "videos.listCommercialAdAssetGapOptions", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/asset-gaps/:gapId/options", "source": "web-src/src/lib/api.ts:2299", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u7D20\u6750\u7F3A\u53E3 / \u9009\u9879" },
|
|
2770
|
+
{ "id": "videos.listCommercialAdAssets", "method": "GET", "path": "/api/showcase-videos/assets", "source": "web-src/src/lib/api.ts:2549", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u7D20\u6750" },
|
|
2771
|
+
{ "id": "videos.listCommercialAdImageEdits", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/image-edits", "source": "web-src/src/lib/api.ts:2201", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u56FE\u7247\u7F16\u8F91" },
|
|
2772
|
+
{ "id": "videos.listCommercialAdMusic", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/music", "source": "web-src/src/lib/api.ts:2188", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u914D\u4E50" },
|
|
2773
|
+
{ "id": "videos.listCommercialAdRunFileVersions", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/files/:path/versions", "source": "web-src/src/lib/api.ts:2230", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u6587\u4EF6 / \u7248\u672C" },
|
|
2774
|
+
{ "id": "videos.listCommercialAdRuns", "method": "GET", "path": "/api/showcase-videos/runs/actionable", "source": "web-src/src/lib/api.ts:2758", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u5F85\u5904\u7406\u4F5C\u54C1" },
|
|
2775
|
+
{ "id": "videos.listCommercialAdRuns.runs", "method": "GET", "path": "/api/showcase-videos/runs", "source": "web-src/src/lib/api.ts:2758", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u4F5C\u54C1" },
|
|
2776
|
+
{ "id": "videos.listShowcaseVideos", "method": "GET", "path": "/api/showcase-videos", "source": "web-src/src/lib/api.ts:2745", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891" },
|
|
2777
|
+
{ "id": "videos.motionReferences", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/motion-references", "source": "web-src/src/components/domain/commercial-ad-motion-references.tsx:78", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u52A8\u4F5C\u53C2\u8003" },
|
|
2778
|
+
{ "id": "videos.planShowcaseDuration", "method": "POST", "path": "/api/showcase-videos/plan-duration", "source": "web-src/src/lib/api.ts:2801", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891 / \u89C4\u5212\u65F6\u957F", "body": "json" },
|
|
2779
|
+
{ "id": "videos.playEdit", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/edits/:editId/video", "source": "apps/api/src/http/routes/showcase.ts:523", "group": "videos", "description": "\u8BFB\u53D6\u5546\u54C1\u89C6\u9891\u526A\u8F91\u7248" },
|
|
2780
|
+
{ "id": "videos.playMotionReference", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/motion-references/:candidateId/video", "source": "apps/api/src/http/routes/showcase.ts:759", "group": "videos", "description": "\u8BFB\u53D6\u52A8\u4F5C\u53C2\u8003\u7247\u6BB5" },
|
|
2781
|
+
{ "id": "videos.playSegment", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/production-segments/:index/video", "source": "apps/api/src/http/routes/showcase.ts:559", "group": "videos", "description": "\u8BFB\u53D6\u9010\u6BB5\u89C6\u9891" },
|
|
2782
|
+
{ "id": "videos.pollShowcaseAiPrompt", "method": "POST", "path": "/api/showcase-videos/ai-prompt", "source": "web-src/src/lib/api.ts:1190", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891 / \u521B\u4F5C\u65B9\u6848", "body": "json" },
|
|
2783
|
+
{ "id": "videos.pollShowcaseAiPrompt.ai_prompt", "method": "GET", "path": "/api/showcase-videos/ai-prompt/:receiptId", "source": "web-src/src/lib/api.ts:1202", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u521B\u4F5C\u65B9\u6848" },
|
|
2784
|
+
{ "id": "videos.postCommercialAdRootMessage", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/messages", "source": "web-src/src/lib/api.ts:2463", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u5BF9\u8BDD", "body": "json", "exampleBody": { "text": "\u5148\u6574\u7406\u6545\u4E8B\u811A\u672C\u548C\u5206\u955C\uFF0C\u62A5\u4EF7\u540E\u7B49\u6211\u786E\u8BA4" } },
|
|
2785
|
+
{ "id": "videos.quoteCommercialAdAreaEdit", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/area/quote", "source": "web-src/src/lib/api.ts:2204", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5C40\u90E8\u4FEE\u6539 / \u62A5\u4EF7", "body": "multipart", "uploadPolicy": "mask", "uploadField": "mask" },
|
|
2786
|
+
{ "id": "videos.quoteShowcaseVideo", "method": "GET", "path": "/api/showcase-videos/quote", "source": "web-src/src/lib/api.ts:2769", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u62A5\u4EF7" },
|
|
2787
|
+
{ "id": "videos.redoShowcaseStoryboard", "method": "POST", "path": "/api/showcase-videos/:id/storyboard", "source": "web-src/src/lib/api.ts:2857", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891 / \u6545\u4E8B\u677F", "body": "json" },
|
|
2788
|
+
{ "id": "videos.renameCommercialAdAsset", "method": "PATCH", "path": "/api/showcase-videos/assets/:id", "source": "web-src/src/lib/api.ts:2554", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u66F4\u65B0\u5546\u54C1\u89C6\u9891 / \u7D20\u6750", "body": "json" },
|
|
2789
|
+
{ "id": "videos.resolveCommercialAdAssetGap", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/asset-gaps/:gapId/resolve", "source": "web-src/src/lib/api.ts:2272", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u7D20\u6750\u7F3A\u53E3 / \u5904\u7406\u7F3A\u53E3", "body": "json" },
|
|
2790
|
+
{ "id": "videos.resolveCommercialAdAssetGaps", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/asset-gaps/resolve-batch", "source": "web-src/src/lib/api.ts:2281", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u7D20\u6750\u7F3A\u53E3 / \u5904\u7406\u591A\u4E2A\u7D20\u6750\u7F3A\u53E3", "body": "json" },
|
|
2791
|
+
{ "id": "videos.restoreCommercialAdRunFileVersion", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/files/:path/versions/:versionId/restore", "source": "web-src/src/lib/api.ts:2258", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u7248\u672C / \u6062\u590D", "body": "json" },
|
|
2792
|
+
{ "id": "videos.resumeCommercialAdRootAfterProductImage", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/product-image-resume", "source": "web-src/src/lib/api.ts:2345", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u5546\u54C1\u56FE\u7247\u5C31\u7EEA\u540E\u7EE7\u7EED", "body": "json" },
|
|
2793
|
+
{ "id": "videos.retryCommercialAdFilmJoin", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/append-tasks/:taskId/retry-join", "source": "web-src/src/lib/api.ts:2198", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u8FFD\u52A0\u7247\u6BB5 / \u91CD\u65B0\u5408\u6210", "body": "json" },
|
|
2794
|
+
{ "id": "videos.retryCommercialAdRootFailedStep", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/retry-failed-step", "source": "web-src/src/lib/api.ts:2334", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u91CD\u8BD5\u5931\u8D25\u6B65\u9AA4", "body": "json" },
|
|
2795
|
+
{ "id": "videos.retryShowcaseVideo", "method": "POST", "path": "/api/showcase-videos/:id/retry", "source": "web-src/src/lib/api.ts:2851", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891 / \u91CD\u8BD5", "body": "json" },
|
|
2796
|
+
{ "id": "videos.saveCommercialAdImageEdit", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/:sourceKind/:sourceId", "source": "web-src/src/lib/api.ts:2219", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u8BBE\u7F6E\u4F5C\u54C1 / \u56FE\u7247\u7F16\u8F91", "body": "binary", "uploadPolicy": "image" },
|
|
2797
|
+
{ "id": "videos.saveCommercialAdRootAttachmentFile", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/attachments/:attachmentId/file", "source": "web-src/src/lib/api.ts:2451", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u9644\u4EF6 / \u6587\u4EF6" },
|
|
2798
|
+
{ "id": "videos.selectCommercialAdVoiceCandidate", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/voice-selection", "source": "web-src/src/lib/api.ts:2169", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u8BBE\u7F6E\u4F5C\u54C1 / \u97F3\u8272\u9009\u62E9", "body": "json" },
|
|
2799
|
+
{ "id": "videos.selectMotionReference", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/motion-references/:candidateId/select", "source": "apps/api/src/http/routes/showcase.ts:754", "group": "videos", "description": "\u9009\u62E9\u52A8\u4F5C\u53C2\u8003", "body": "json" },
|
|
2800
|
+
{ "id": "videos.setCommercialAdSubtitles", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/subtitles", "source": "web-src/src/lib/api.ts:2151", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u8BBE\u7F6E\u4F5C\u54C1 / \u5B57\u5E55", "body": "json" },
|
|
2801
|
+
{ "id": "videos.startCommercialAdRun", "method": "POST", "path": "/api/showcase-videos/runs", "source": "web-src/src/lib/api.ts:2141", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891 / \u4F5C\u54C1", "body": "json" },
|
|
2802
|
+
{ "id": "videos.streamCommercialAdRootLive", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/live", "source": "web-src/src/lib/api.ts:2518", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u5B9E\u65F6\u8FDB\u5EA6" },
|
|
2803
|
+
{ "id": "videos.streamCommercialAdRootMessage", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/messages/stream", "source": "web-src/src/lib/api.ts:2497", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5BF9\u8BDD / \u5B9E\u65F6\u5BF9\u8BDD", "body": "json" },
|
|
2804
|
+
{ "id": "videos.updateCommercialAdRootSettings", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/settings", "source": "web-src/src/lib/api.ts:2363", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u8BBE\u7F6E", "body": "json" },
|
|
2805
|
+
{ "id": "videos.uploadCommercialAdAssetGap", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/gaps/:gapId/upload", "source": "web-src/src/lib/api.ts:2400", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u8BBE\u7F6E\u7D20\u6750\u7F3A\u53E3 / \u4E0A\u4F20", "body": "binary", "uploadPolicy": "image" },
|
|
2806
|
+
{ "id": "videos.voiceCandidates.importSource", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/voice-candidates", "source": "web-src/src/lib/api.ts:2161", "group": "videos", "description": "\u4ECE\u5DF2\u6709\u6765\u6E90\u5BFC\u5165\u5546\u54C1\u89C6\u9891\u97F3\u8272\u53C2\u8003", "body": "json" },
|
|
2807
|
+
{ "id": "videos.voiceCandidates.upload", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/voice-candidates", "source": "web-src/src/lib/api.ts:2161", "group": "videos", "description": "\u4E0A\u4F20\u5546\u54C1\u89C6\u9891\u97F3\u8272\u53C2\u8003", "body": "multipart", "uploadPolicy": "voiceSource", "uploadField": "file" }
|
|
2808
|
+
];
|
|
2809
|
+
|
|
2810
|
+
// src/web-operation-contract.ts
|
|
2811
|
+
import { extname } from "node:path";
|
|
2812
|
+
var BUSINESS_HEADERS = /* @__PURE__ */ new Set(["prefer", "x-script-fingerprint", "x-attachment-delivery", "x-attachment-name"]);
|
|
2813
|
+
function buildBusinessHeaders(operation, supplied = {}, filename) {
|
|
2814
|
+
const rules = operation.businessHeaders ?? {};
|
|
2815
|
+
const result = {};
|
|
2816
|
+
for (const [name2, rule] of Object.entries(rules)) {
|
|
2817
|
+
if (!BUSINESS_HEADERS.has(name2)) throw usageError(`\u64CD\u4F5C ${operation.id} \u7684\u4E1A\u52A1\u5934\u914D\u7F6E\u65E0\u6548`);
|
|
2818
|
+
if (rule.default !== void 0) result[name2] = rule.default;
|
|
2819
|
+
if (rule.fromFilename && filename) {
|
|
2820
|
+
try {
|
|
2821
|
+
result[name2] = encodeURIComponent(filename);
|
|
2822
|
+
} catch {
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2827
|
+
for (const [raw, value] of Object.entries(supplied)) {
|
|
2828
|
+
const name2 = raw.toLowerCase();
|
|
2829
|
+
if (!BUSINESS_HEADERS.has(name2) || !Object.hasOwn(rules, name2)) throw usageError(`\u64CD\u4F5C ${operation.id} \u4E0D\u63A5\u53D7\u8BF7\u6C42\u5934 ${raw}`);
|
|
2830
|
+
if (seen.has(name2)) throw usageError(`\u8BF7\u6C42\u5934 ${raw} \u91CD\u590D`);
|
|
2831
|
+
seen.add(name2);
|
|
2832
|
+
if (typeof value !== "string" || !value.trim() || value.length > 4096 || /[^\x20-\x7e]/u.test(value)) throw usageError(`\u8BF7\u6C42\u5934 ${raw} \u5FC5\u987B\u662F\u6709\u6548\u7684 ASCII \u5B57\u7B26\u4E32\uFF1B\u6587\u4EF6\u540D\u8BF7\u5148 URL \u7F16\u7801`);
|
|
2833
|
+
result[name2] = value;
|
|
2834
|
+
}
|
|
2835
|
+
for (const [name2, rule] of Object.entries(rules)) {
|
|
2836
|
+
const value = result[name2];
|
|
2837
|
+
if (rule.required && !value) throw usageError(`\u64CD\u4F5C ${operation.id} \u9700\u8981\u901A\u8FC7 --headers \u63D0\u4F9B ${name2}`);
|
|
2838
|
+
if (value && rule.values && !rule.values.includes(value)) throw usageError(`\u8BF7\u6C42\u5934 ${name2} \u53EA\u652F\u6301 ${rule.values.join("\u3001")}`);
|
|
2839
|
+
}
|
|
2840
|
+
return result;
|
|
2841
|
+
}
|
|
2842
|
+
var MIB = 1024 * 1024;
|
|
2843
|
+
var IMAGE = ["image/png", "image/jpeg", "image/webp"];
|
|
2844
|
+
var DOCUMENT = ["application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "text/plain", "text/markdown"];
|
|
2845
|
+
var VIDEO = ["video/mp4", "video/quicktime", "video/webm"];
|
|
2846
|
+
var CHAT_AUDIO = ["audio/mpeg", "audio/wav"];
|
|
2847
|
+
var SPEECH = ["audio/wav", "audio/mpeg", "audio/mp4", "audio/webm", "audio/ogg"];
|
|
2848
|
+
var MIME_BY_EXTENSION = {
|
|
2849
|
+
".png": "image/png",
|
|
2850
|
+
".jpg": "image/jpeg",
|
|
2851
|
+
".jpeg": "image/jpeg",
|
|
2852
|
+
".webp": "image/webp",
|
|
2853
|
+
".mp4": "video/mp4",
|
|
2854
|
+
".m4v": "video/mp4",
|
|
2855
|
+
".mov": "video/quicktime",
|
|
2856
|
+
".webm": "video/webm",
|
|
2857
|
+
".mp3": "audio/mpeg",
|
|
2858
|
+
".wav": "audio/wav",
|
|
2859
|
+
".m4a": "audio/mp4",
|
|
2860
|
+
".ogg": "audio/ogg",
|
|
2861
|
+
".oga": "audio/ogg",
|
|
2862
|
+
".aac": "audio/aac",
|
|
2863
|
+
".flac": "audio/flac",
|
|
2864
|
+
".opus": "audio/ogg",
|
|
2865
|
+
".pdf": "application/pdf",
|
|
2866
|
+
".docx": DOCUMENT[1],
|
|
2867
|
+
".txt": "text/plain",
|
|
2868
|
+
".md": "text/markdown",
|
|
2869
|
+
".markdown": "text/markdown"
|
|
2870
|
+
};
|
|
2871
|
+
function webUploadPolicy(operation, filename) {
|
|
2872
|
+
const extension = extname(filename).toLowerCase();
|
|
2873
|
+
const policy = operation.uploadPolicy;
|
|
2874
|
+
const mime = policy === "storySpeech" && extension === ".webm" ? "audio/webm" : MIME_BY_EXTENSION[extension];
|
|
2875
|
+
const unsupported = () => usageError(`\u64CD\u4F5C ${operation.id} \u4E0D\u652F\u6301\u6B64\u6587\u4EF6\u7C7B\u578B\uFF1A${extension || "\u65E0\u6269\u5C55\u540D"}`);
|
|
2876
|
+
if (!mime || !policy) throw unsupported();
|
|
2877
|
+
if (policy === "storySpeech") {
|
|
2878
|
+
if (!SPEECH.includes(mime)) throw unsupported();
|
|
2879
|
+
return { mime, maxBytes: 20 * MIB };
|
|
2880
|
+
}
|
|
2881
|
+
if (policy === "voiceSource") {
|
|
2882
|
+
if (!mime.startsWith("audio/") && !VIDEO.includes(mime)) throw unsupported();
|
|
2883
|
+
return { mime, maxBytes: 64 * MIB };
|
|
2884
|
+
}
|
|
2885
|
+
if (policy === "mask") {
|
|
2886
|
+
if (mime !== "image/png") throw unsupported();
|
|
2887
|
+
return { mime, maxBytes: 4 * MIB };
|
|
2888
|
+
}
|
|
2889
|
+
if (IMAGE.includes(mime)) return { mime, maxBytes: 15 * MIB };
|
|
2890
|
+
if (policy === "image") throw unsupported();
|
|
2891
|
+
if (DOCUMENT.includes(mime)) return { mime, maxBytes: 30 * MIB };
|
|
2892
|
+
if (policy === "chatAttachment" && (VIDEO.includes(mime) || CHAT_AUDIO.includes(mime))) return { mime, maxBytes: 90 * MIB };
|
|
2893
|
+
throw unsupported();
|
|
2894
|
+
}
|
|
2895
|
+
|
|
2896
|
+
// src/web-client.ts
|
|
2897
|
+
import { createHash as createHash3, randomBytes as randomBytes2 } from "node:crypto";
|
|
2898
|
+
import { constants as constants2 } from "node:fs";
|
|
2899
|
+
import { link, lstat as lstat2, open as open2, stat as stat2, unlink as unlink2 } from "node:fs/promises";
|
|
2900
|
+
import { basename as basename2, dirname as dirname2, extname as extname2, join as join3, resolve as resolve2 } from "node:path";
|
|
2901
|
+
var MAX_JSON_BYTES = 16 * 1024 * 1024;
|
|
2902
|
+
var MAX_DOWNLOAD_BYTES2 = 1024 * 1024 * 1024;
|
|
2903
|
+
var secretFields = /* @__PURE__ */ new Set(["token", "sessiontoken", "accesstoken", "refreshtoken", "password", "currentpassword", "newpassword", "secret", "clientsecret", "authorization", "cookie", "privatekey", "rawkey"]);
|
|
2904
|
+
function redactWebValue(value, secrets = []) {
|
|
2905
|
+
if (typeof value === "string") return secrets.reduce((text, secret) => secret ? text.split(secret).join("[redacted]") : text, redactKeys(value));
|
|
2906
|
+
if (Array.isArray(value)) return value.map((item) => redactWebValue(item, secrets));
|
|
2907
|
+
if (!value || typeof value !== "object") return value;
|
|
2908
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
2909
|
+
key,
|
|
2910
|
+
secretFields.has(key.toLowerCase().replace(/[_-]/gu, "")) || key === "apiKey" && typeof item === "string" ? "[redacted]" : redactWebValue(item, secrets)
|
|
2911
|
+
]));
|
|
2912
|
+
}
|
|
2913
|
+
function webSecrets(value) {
|
|
2914
|
+
if (!value || typeof value !== "object") return [];
|
|
2915
|
+
return Object.entries(value).flatMap(([key, item]) => secretFields.has(key.toLowerCase().replace(/[_-]/gu, "")) || key === "apiKey" ? typeof item === "string" ? [item] : webSecrets(item) : webSecrets(item));
|
|
2916
|
+
}
|
|
2917
|
+
function badResponse(status4) {
|
|
2918
|
+
return new CliError({ code: "CLI_BAD_RESPONSE", exitCode: EXIT.SERVER, message: "\u7F51\u9875\u63A5\u53E3\u54CD\u5E94\u683C\u5F0F\u65E0\u6548\uFF0C\u672A\u4FDD\u5B58\u4E3A\u4EA4\u4ED8\u6587\u4EF6", httpStatus: status4 });
|
|
2919
|
+
}
|
|
2920
|
+
async function checkWebOutput(path) {
|
|
2921
|
+
const target = resolve2(path);
|
|
2922
|
+
try {
|
|
2923
|
+
const info = await lstat2(target);
|
|
2924
|
+
if (info) throw usageError("\u8F93\u51FA\u8DEF\u5F84\u5DF2\u7ECF\u5B58\u5728\uFF1B\u8BF7\u9009\u62E9\u65B0\u6587\u4EF6\uFF0C\u672C\u6B21\u4E0D\u4F1A\u8986\u76D6\u539F\u6587\u4EF6");
|
|
2925
|
+
} catch (error) {
|
|
2926
|
+
if (error?.code !== "ENOENT") throw error;
|
|
2927
|
+
}
|
|
2928
|
+
try {
|
|
2929
|
+
if (!(await stat2(dirname2(target))).isDirectory()) throw new Error();
|
|
2930
|
+
} catch {
|
|
2931
|
+
throw usageError("\u8F93\u51FA\u76EE\u5F55\u4E0D\u5B58\u5728\u6216\u4E0D\u53EF\u8BBF\u95EE\uFF0C\u8BF7\u5148\u521B\u5EFA\u76EE\u5F55");
|
|
2932
|
+
}
|
|
2933
|
+
return target;
|
|
2934
|
+
}
|
|
2935
|
+
async function atomicWebOutput(path, signal, feed) {
|
|
2936
|
+
const target = await checkWebOutput(path);
|
|
2937
|
+
const temp = join3(dirname2(target), `.${basename2(target)}.${process.pid}.${randomBytes2(8).toString("hex")}.tmp`);
|
|
2938
|
+
const handle = await open2(temp, constants2.O_CREAT | constants2.O_EXCL | constants2.O_WRONLY | (constants2.O_NOFOLLOW ?? 0), 384);
|
|
2939
|
+
let bytes = 0;
|
|
2940
|
+
const hash = createHash3("sha256");
|
|
2941
|
+
try {
|
|
2942
|
+
await feed(async (chunk) => {
|
|
2943
|
+
if (signal.aborted) throw signal.reason;
|
|
2944
|
+
bytes += chunk.byteLength;
|
|
2945
|
+
if (bytes > MAX_DOWNLOAD_BYTES2) throw usageError("\u4E0B\u8F7D\u6587\u4EF6\u8D85\u8FC7 1 GiB \u4E0A\u9650");
|
|
2946
|
+
hash.update(chunk);
|
|
2947
|
+
await handle.writeFile(chunk);
|
|
2948
|
+
});
|
|
2949
|
+
await handle.sync();
|
|
2950
|
+
await handle.close();
|
|
2951
|
+
if (signal.aborted) throw signal.reason;
|
|
2952
|
+
await link(temp, target);
|
|
2953
|
+
return { path: target, bytes, sha256: hash.digest("hex") };
|
|
2954
|
+
} catch (error) {
|
|
2955
|
+
if (error instanceof CliError) throw error;
|
|
2956
|
+
throw new CliError({ code: "CLI_WEB_OUTPUT_FAILED", exitCode: EXIT.SERVER, message: "\u8F93\u51FA\u6587\u4EF6\u4FDD\u5B58\u5931\u8D25\uFF1B\u539F\u6587\u4EF6\u672A\u8986\u76D6\uFF0C\u8BF7\u68C0\u67E5\u76EE\u5F55\u6743\u9650\u4E0E\u78C1\u76D8\u7A7A\u95F4" });
|
|
2957
|
+
} finally {
|
|
2958
|
+
await handle.close().catch(() => void 0);
|
|
2959
|
+
await unlink2(temp).catch(() => void 0);
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
async function saveWebDocument(path, data, signal) {
|
|
2963
|
+
return atomicWebOutput(path, signal ?? new AbortController().signal, (write) => write(Buffer.from(`${JSON.stringify(data, null, 2)}
|
|
2964
|
+
`)));
|
|
2965
|
+
}
|
|
2966
|
+
async function consume(response, signal, max, onChunk) {
|
|
2967
|
+
if (!response.body) return 0;
|
|
2968
|
+
const reader = response.body.getReader();
|
|
2969
|
+
let total = 0;
|
|
2970
|
+
const cancel3 = () => {
|
|
2971
|
+
void reader.cancel().catch(() => void 0);
|
|
2972
|
+
};
|
|
2973
|
+
signal.addEventListener("abort", cancel3, { once: true });
|
|
2974
|
+
try {
|
|
2975
|
+
for (; ; ) {
|
|
2976
|
+
if (signal.aborted) throw signal.reason;
|
|
2977
|
+
const { value, done } = await reader.read();
|
|
2978
|
+
if (signal.aborted) throw signal.reason;
|
|
2979
|
+
if (done) break;
|
|
2980
|
+
total += value.byteLength;
|
|
2981
|
+
if (total > max) throw badResponse(response.status);
|
|
2982
|
+
if (await onChunk(value) === false) break;
|
|
2983
|
+
}
|
|
2984
|
+
return total;
|
|
2985
|
+
} finally {
|
|
2986
|
+
signal.removeEventListener("abort", cancel3);
|
|
2987
|
+
void reader.cancel().catch(() => void 0);
|
|
2988
|
+
}
|
|
2989
|
+
}
|
|
2990
|
+
async function jsonBody(response, signal) {
|
|
2991
|
+
const chunks = [];
|
|
2992
|
+
await consume(response, signal, MAX_JSON_BYTES, (chunk) => {
|
|
2993
|
+
chunks.push(chunk);
|
|
2994
|
+
});
|
|
2995
|
+
if (chunks.length === 0 && response.status === 204) return null;
|
|
2996
|
+
try {
|
|
2997
|
+
return JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
2998
|
+
} catch {
|
|
2999
|
+
throw badResponse(response.status);
|
|
3000
|
+
}
|
|
3001
|
+
}
|
|
3002
|
+
function serverFailure(status4, body, secrets) {
|
|
3003
|
+
secrets = [...secrets, ...webSecrets(body)];
|
|
3004
|
+
const data = body && typeof body === "object" ? body : {};
|
|
3005
|
+
const nested = data.error && typeof data.error === "object" ? data.error : data;
|
|
3006
|
+
const message2 = typeof nested.message === "string" ? nested.message : typeof data.error === "string" ? data.error : `\u7F51\u9875\u8BF7\u6C42\u5931\u8D25\uFF08HTTP ${status4}\uFF09`;
|
|
3007
|
+
return new CliError({
|
|
3008
|
+
code: typeof nested.code === "string" ? String(redactWebValue(nested.code, secrets)) : "CLI_WEB_REQUEST_FAILED",
|
|
3009
|
+
exitCode: exitCodeForHttpStatus(status4),
|
|
3010
|
+
httpStatus: status4,
|
|
3011
|
+
message: String(redactWebValue(message2, secrets)),
|
|
3012
|
+
retryable: status4 === 408 || status4 === 429 || status4 >= 500,
|
|
3013
|
+
...typeof nested.traceId === "string" ? { traceId: String(redactWebValue(nested.traceId, secrets)) } : {},
|
|
3014
|
+
...typeof nested.retryAfterSeconds === "number" ? { retryAfterSeconds: nested.retryAfterSeconds } : {}
|
|
3015
|
+
});
|
|
3016
|
+
}
|
|
3017
|
+
function taskIdOf(value) {
|
|
3018
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
3019
|
+
const data = value;
|
|
3020
|
+
for (const key of ["taskId", "rootRunId", "runId", "projectId"]) if (typeof data[key] === "string" && data[key]) return data[key];
|
|
3021
|
+
for (const key of ["run", "task", "project", "data"]) {
|
|
3022
|
+
const nested = data[key];
|
|
3023
|
+
const found = taskIdOf(nested);
|
|
3024
|
+
if (found) return found;
|
|
3025
|
+
if (key !== "data" && nested && typeof nested === "object" && !Array.isArray(nested) && typeof nested.id === "string") return nested.id;
|
|
3026
|
+
}
|
|
3027
|
+
return void 0;
|
|
3028
|
+
}
|
|
3029
|
+
function mediaPrefixValid(mime, prefix) {
|
|
3030
|
+
const start = prefix.toString("utf8").replace(/^\uFEFF/u, "").trimStart();
|
|
3031
|
+
if (mime === "text/html" || /^<(?:!doctype\s+html|html|head|body)(?:\s|>)/iu.test(start)) return false;
|
|
3032
|
+
if (mime === "video/mp4" || mime === "audio/mp4") return prefix.length >= 12 && prefix.toString("ascii", 4, 8) === "ftyp";
|
|
3033
|
+
if (mime === "video/quicktime") return prefix.length >= 12 && ["ftyp", "wide", "free", "mdat", "moov"].includes(prefix.toString("ascii", 4, 8));
|
|
3034
|
+
if (mime === "image/png") return prefix.subarray(0, 8).toString("hex") === "89504e470d0a1a0a";
|
|
3035
|
+
if (mime === "image/jpeg") return prefix.subarray(0, 3).toString("hex") === "ffd8ff";
|
|
3036
|
+
if (mime === "image/webp") return prefix.toString("ascii", 0, 4) === "RIFF" && prefix.toString("ascii", 8, 12) === "WEBP";
|
|
3037
|
+
if (mime === "image/gif") return /^GIF8[79]a/u.test(prefix.toString("ascii", 0, 6));
|
|
3038
|
+
if (mime === "application/pdf") return start.startsWith("%PDF-");
|
|
3039
|
+
if (["application/zip", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"].includes(mime)) return ["504b0304", "504b0506", "504b0708"].includes(prefix.subarray(0, 4).toString("hex"));
|
|
3040
|
+
if (["audio/wav", "audio/x-wav"].includes(mime)) return prefix.length >= 44 && prefix.toString("ascii", 0, 4) === "RIFF" && prefix.toString("ascii", 8, 12) === "WAVE";
|
|
3041
|
+
if (mime === "audio/mpeg") return prefix.length >= 3 && (prefix.toString("ascii", 0, 3) === "ID3" || prefix[0] === 255 && (prefix[1] & 224) === 224);
|
|
3042
|
+
if (mime === "audio/ogg") return prefix.toString("ascii", 0, 4) === "OggS";
|
|
3043
|
+
if (mime === "audio/flac") return prefix.toString("ascii", 0, 4) === "fLaC";
|
|
3044
|
+
if (mime === "video/webm" || mime === "audio/webm") return prefix.subarray(0, 4).toString("hex") === "1a45dfa3" && prefix.includes(Buffer.from("webm"));
|
|
3045
|
+
if (mime === "text/vtt") return !prefix.includes(0) && /^\uFEFF?WEBVTT(?:[ \t][^\r\n]*)?(?:\r?\n|$)/u.test(prefix.toString("utf8"));
|
|
3046
|
+
if (mime === "application/x-subrip") {
|
|
3047
|
+
if (prefix.includes(0)) return false;
|
|
3048
|
+
const cue = /^\uFEFF?\s*\d+\r?\n(\d{2,}):([0-5]\d):([0-5]\d),(\d{3})[ \t]+-->[ \t]+(\d{2,}):([0-5]\d):([0-5]\d),(\d{3})(?:[ \t][^\r\n]*)?\r?\n/u.exec(prefix.toString("utf8"));
|
|
3049
|
+
if (!cue) return false;
|
|
3050
|
+
const start2 = ((Number(cue[1]) * 60 + Number(cue[2])) * 60 + Number(cue[3])) * 1e3 + Number(cue[4]);
|
|
3051
|
+
const end = ((Number(cue[5]) * 60 + Number(cue[6])) * 60 + Number(cue[7])) * 1e3 + Number(cue[8]);
|
|
3052
|
+
return Number.isSafeInteger(start2) && Number.isSafeInteger(end) && end > start2;
|
|
3053
|
+
}
|
|
3054
|
+
if (["text/plain", "text/markdown", "text/csv"].includes(mime)) return !prefix.includes(0);
|
|
3055
|
+
return true;
|
|
3056
|
+
}
|
|
3057
|
+
async function requestWeb(io, request) {
|
|
3058
|
+
const baseUrl = normalizeBaseUrl(request.baseUrl);
|
|
3059
|
+
assertReachedDirectly(baseUrl, io.env);
|
|
3060
|
+
if (!request.path.startsWith("/api/") || request.path.includes("#") || request.path.includes("\\") || new URL(request.path, baseUrl).origin !== baseUrl || new URL(request.path, baseUrl).pathname !== request.path.split("?")[0]) throw usageError("\u7F51\u9875\u64CD\u4F5C\u8DEF\u5F84\u65E0\u6548");
|
|
3061
|
+
if (request.token?.startsWith("bk_")) throw usageError("API \u5BC6\u94A5\u4E0D\u80FD\u7528\u4E8E\u7F51\u9875\u63A5\u53E3");
|
|
3062
|
+
if (io.signal?.aborted) throw interruptedError();
|
|
3063
|
+
const controller = new AbortController();
|
|
3064
|
+
const secrets = [...request.secrets ?? [], ...request.token ? [request.token] : []];
|
|
3065
|
+
const headers = new Headers({ Accept: "application/json, text/event-stream, */*", "User-Agent": "bukesiyi-cli/web" });
|
|
3066
|
+
if (request.token) headers.set("Authorization", `Bearer ${request.token}`);
|
|
3067
|
+
if (request.workspaceId) headers.set("x-bukesiyi-workspace-id", request.workspaceId);
|
|
3068
|
+
if (request.contentType) headers.set("Content-Type", request.contentType);
|
|
3069
|
+
if (request.idempotencyKey) headers.set("Idempotency-Key", request.idempotencyKey);
|
|
3070
|
+
for (const [name2, value] of Object.entries(request.businessHeaders ?? {})) {
|
|
3071
|
+
if (!["prefer", "x-script-fingerprint", "x-attachment-delivery", "x-attachment-name"].includes(name2.toLowerCase()) || typeof value !== "string" || !value || /[^\x20-\x7e]/u.test(value) || value.length > 4096) throw usageError("\u7F51\u9875\u4E1A\u52A1\u8BF7\u6C42\u5934\u4E0D\u5728\u5141\u8BB8\u8303\u56F4\uFF0C\u64CD\u4F5C\u672A\u63D0\u4EA4");
|
|
3072
|
+
headers.set(name2, value);
|
|
3073
|
+
}
|
|
3074
|
+
const timeoutMs = request.timeoutMs ?? io.requestTimeoutMs ?? 12e4;
|
|
3075
|
+
let timer;
|
|
3076
|
+
let responseReceived = false;
|
|
3077
|
+
let interrupt2 = () => void 0;
|
|
3078
|
+
const stopped = new Promise((_resolve, reject) => {
|
|
3079
|
+
interrupt2 = () => {
|
|
3080
|
+
const error = interruptedError();
|
|
3081
|
+
controller.abort(error);
|
|
3082
|
+
reject(error);
|
|
3083
|
+
};
|
|
3084
|
+
io.signal?.addEventListener("abort", interrupt2, { once: true });
|
|
3085
|
+
timer = setTimeout(() => {
|
|
3086
|
+
const error = new CliError({ code: "CLI_TIMEOUT", exitCode: EXIT.SERVER, retryable: true, message: `\u7F51\u9875\u8BF7\u6C42\u7B49\u5F85\u8D85\u65F6\uFF08${timeoutMs / 1e3} \u79D2\uFF09\uFF1B\u8BF7\u67E5\u8BE2\u539F\u64CD\u4F5C\u7ED3\u679C` });
|
|
3087
|
+
controller.abort(error);
|
|
3088
|
+
reject(error);
|
|
3089
|
+
}, timeoutMs);
|
|
3090
|
+
});
|
|
3091
|
+
const work = (async () => {
|
|
3092
|
+
const response = await io.fetch(`${baseUrl}${request.path}`, {
|
|
3093
|
+
method: request.method,
|
|
3094
|
+
headers,
|
|
3095
|
+
...request.body === void 0 ? {} : { body: request.body },
|
|
3096
|
+
redirect: "manual",
|
|
3097
|
+
signal: controller.signal
|
|
3098
|
+
});
|
|
3099
|
+
responseReceived = true;
|
|
3100
|
+
if (response.status >= 300 && response.status < 400) {
|
|
3101
|
+
await response.body?.cancel().catch(() => void 0);
|
|
3102
|
+
throw new CliError({ code: "CLI_REDIRECT_BLOCKED", exitCode: EXIT.SERVER, httpStatus: response.status, message: "\u7F51\u9875\u63A5\u53E3\u8FD4\u56DE\u91CD\u5B9A\u5411\uFF0C\u672A\u5411\u8DF3\u8F6C\u5730\u5740\u53D1\u9001\u4F1A\u8BDD\u51ED\u636E" });
|
|
3103
|
+
}
|
|
3104
|
+
if (response.status >= 400) {
|
|
3105
|
+
let body;
|
|
3106
|
+
try {
|
|
3107
|
+
body = await jsonBody(response, controller.signal);
|
|
3108
|
+
} catch (error) {
|
|
3109
|
+
if (controller.signal.aborted) throw error;
|
|
3110
|
+
}
|
|
3111
|
+
throw serverFailure(response.status, body, secrets);
|
|
3112
|
+
}
|
|
3113
|
+
const mime = response.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase() ?? "";
|
|
3114
|
+
if (mime === "text/event-stream") {
|
|
3115
|
+
const decoder = new TextDecoder();
|
|
3116
|
+
let buffer = "", eventCount = 0, completed = false;
|
|
3117
|
+
const events = [];
|
|
3118
|
+
const emit = (block) => {
|
|
3119
|
+
const lines2 = block.split("\n");
|
|
3120
|
+
const data = lines2.filter((line) => line.startsWith("data:")).map((line) => line.slice(5).replace(/^ /u, "")).join("\n");
|
|
3121
|
+
if (data === "[DONE]") {
|
|
3122
|
+
completed = true;
|
|
3123
|
+
return;
|
|
3124
|
+
}
|
|
3125
|
+
if (!data) return;
|
|
3126
|
+
let value;
|
|
3127
|
+
try {
|
|
3128
|
+
value = JSON.parse(data);
|
|
3129
|
+
} catch {
|
|
3130
|
+
value = { text: data };
|
|
3131
|
+
}
|
|
3132
|
+
secrets.push(...webSecrets(value));
|
|
3133
|
+
const taskId = taskIdOf(value);
|
|
3134
|
+
if (taskId) request.onTaskId?.(String(redactWebValue(taskId, secrets)));
|
|
3135
|
+
const safe2 = redactWebValue(value, secrets);
|
|
3136
|
+
const eventName = lines2.find((line) => line.startsWith("event:"))?.slice(6).trim();
|
|
3137
|
+
const payload = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
3138
|
+
if (eventName === "error" || payload.type === "error") {
|
|
3139
|
+
const status4 = [payload.httpStatus, payload.status].find((item) => typeof item === "number" && Number.isInteger(item) && item >= 400 && item <= 599);
|
|
3140
|
+
throw serverFailure(typeof status4 === "number" ? status4 : 500, value, secrets);
|
|
3141
|
+
}
|
|
3142
|
+
events.push(eventName ? { event: eventName, data: safe2 } : safe2);
|
|
3143
|
+
if (events.length > 100) events.shift();
|
|
3144
|
+
eventCount++;
|
|
3145
|
+
request.onEvent?.(events.at(-1));
|
|
3146
|
+
if (eventName === "done" || payload.type === "done") completed = true;
|
|
3147
|
+
};
|
|
3148
|
+
await consume(response, controller.signal, MAX_JSON_BYTES, (chunk) => {
|
|
3149
|
+
buffer = (buffer + decoder.decode(chunk, { stream: true })).replace(/\r\n/gu, "\n");
|
|
3150
|
+
if (buffer.length > 1024 * 1024) throw badResponse(response.status);
|
|
3151
|
+
let boundary;
|
|
3152
|
+
while (!completed && (boundary = buffer.indexOf("\n\n")) >= 0) {
|
|
3153
|
+
emit(buffer.slice(0, boundary));
|
|
3154
|
+
buffer = buffer.slice(boundary + 2);
|
|
3155
|
+
}
|
|
3156
|
+
if (completed) return false;
|
|
3157
|
+
});
|
|
3158
|
+
buffer += decoder.decode();
|
|
3159
|
+
if (!completed && buffer.trim()) emit(buffer);
|
|
3160
|
+
if (!completed) throw new CliError({
|
|
3161
|
+
code: "CLI_STREAM_INCOMPLETE",
|
|
3162
|
+
exitCode: EXIT.SERVER,
|
|
3163
|
+
retryable: true,
|
|
3164
|
+
message: "\u7F51\u9875\u4E8B\u4EF6\u6D41\u5728\u5B8C\u6210\u6807\u8BB0\u524D\u7ED3\u675F\uFF1B\u64CD\u4F5C\u7ED3\u679C\u5C1A\u672A\u786E\u8BA4\uFF0C\u8BF7\u4F7F\u7528\u539F\u5E42\u7B49\u952E\u67E5\u8BE2\u539F\u64CD\u4F5C"
|
|
3165
|
+
});
|
|
3166
|
+
const result = { status: response.status, events, eventCount };
|
|
3167
|
+
if (request.outPath) return { ...result, download: await atomicWebOutput(request.outPath, controller.signal, (write) => write(Buffer.from(`${JSON.stringify(result, null, 2)}
|
|
3168
|
+
`))) };
|
|
3169
|
+
return result;
|
|
3170
|
+
}
|
|
3171
|
+
if (mime.includes("json") || response.status === 204) {
|
|
3172
|
+
const data = await jsonBody(response, controller.signal);
|
|
3173
|
+
secrets.push(...webSecrets(data));
|
|
3174
|
+
if (request.method === "POST" && (request.path === "/api/auth/login" || request.sessionResponse === true) && data && typeof data === "object" && !Array.isArray(data)) {
|
|
3175
|
+
const token = data.token;
|
|
3176
|
+
if (typeof token === "string") secrets.push(token);
|
|
3177
|
+
request.onLogin?.(data);
|
|
3178
|
+
}
|
|
3179
|
+
const taskId = taskIdOf(data);
|
|
3180
|
+
if (taskId) request.onTaskId?.(String(redactWebValue(taskId, secrets)));
|
|
3181
|
+
const safe2 = request.secretOutput ? { saved: true } : redactWebValue(data, secrets);
|
|
3182
|
+
if (data && typeof data === "object" && data.error && data.ok === false) throw serverFailure(400, data, secrets);
|
|
3183
|
+
if (request.outPath) {
|
|
3184
|
+
if (response.status !== 200 && response.status !== 201) throw new CliError({ code: "CLI_DOWNLOAD_NOT_READY", exitCode: EXIT.RETRY_LATER, httpStatus: response.status, message: "\u64CD\u4F5C\u5C1A\u672A\u5B8C\u6210\uFF0C\u672A\u628A\u51C6\u5907\u54CD\u5E94\u4FDD\u5B58\u4E3A\u6587\u4EF6" });
|
|
3185
|
+
if (request.expectedFile) throw badResponse(response.status);
|
|
3186
|
+
const download5 = await atomicWebOutput(request.outPath, controller.signal, (write) => write(Buffer.from(`${JSON.stringify(request.secretOutput ? data : safe2, null, 2)}
|
|
3187
|
+
`)));
|
|
3188
|
+
return { status: response.status, data: safe2, download: download5 };
|
|
3189
|
+
}
|
|
3190
|
+
return { status: response.status, data: safe2 };
|
|
3191
|
+
}
|
|
3192
|
+
if (!request.outPath) {
|
|
3193
|
+
await response.body?.cancel().catch(() => void 0);
|
|
3194
|
+
throw usageError("\u8BE5\u64CD\u4F5C\u8FD4\u56DE\u6587\u4EF6\uFF0C\u8BF7\u4F7F\u7528 --out <\u65B0\u6587\u4EF6\u8DEF\u5F84>");
|
|
3195
|
+
}
|
|
3196
|
+
if (response.status !== 200) {
|
|
3197
|
+
await response.body?.cancel().catch(() => void 0);
|
|
3198
|
+
throw new CliError({ code: "CLI_DOWNLOAD_NOT_READY", exitCode: EXIT.RETRY_LATER, httpStatus: response.status, message: "\u4E0B\u8F7D\u5C1A\u672A\u5B8C\u6210\uFF0C\u672A\u4FDD\u5B58\u6587\u4EF6" });
|
|
3199
|
+
}
|
|
3200
|
+
const expectedSize = response.headers.get("content-length"), expectedHash = response.headers.get("x-content-sha256");
|
|
3201
|
+
const byExtension = { ".mp4": "video/mp4", ".mov": "video/quicktime", ".webm": "video/webm", ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp", ".zip": "application/zip", ".pdf": "application/pdf", ".wav": "audio/wav", ".mp3": "audio/mpeg", ".vtt": "text/vtt", ".srt": "application/x-subrip" };
|
|
3202
|
+
const expectedMime = byExtension[extname2(request.outPath).toLowerCase()];
|
|
3203
|
+
if (expectedMime && mime && mime !== "application/octet-stream" && mime !== expectedMime && !(expectedMime === "audio/wav" && mime === "audio/x-wav")) {
|
|
3204
|
+
await response.body?.cancel().catch(() => void 0);
|
|
3205
|
+
throw badResponse(response.status);
|
|
3206
|
+
}
|
|
3207
|
+
const validationMime = !mime || mime === "application/octet-stream" ? expectedMime ?? mime : mime;
|
|
3208
|
+
const download4 = await atomicWebOutput(request.outPath, controller.signal, async (write) => {
|
|
3209
|
+
let prefix = Buffer.alloc(0);
|
|
3210
|
+
const hash = createHash3("sha256");
|
|
3211
|
+
const size = await consume(response, controller.signal, MAX_DOWNLOAD_BYTES2, async (chunk) => {
|
|
3212
|
+
if (prefix.length < 1024) prefix = Buffer.concat([prefix, Buffer.from(chunk).subarray(0, 1024 - prefix.length)]);
|
|
3213
|
+
hash.update(chunk);
|
|
3214
|
+
await write(chunk);
|
|
3215
|
+
});
|
|
3216
|
+
if (size === 0 || !mediaPrefixValid(validationMime, prefix) || expectedSize !== null && (!/^\d+$/u.test(expectedSize) || Number(expectedSize) !== size) || expectedHash !== null && (!/^[a-f0-9]{64}$/iu.test(expectedHash) || hash.digest("hex") !== expectedHash.toLowerCase())) throw badResponse(response.status);
|
|
3217
|
+
});
|
|
3218
|
+
return { status: response.status, download: download4 };
|
|
3219
|
+
})();
|
|
3220
|
+
work.catch(() => void 0);
|
|
3221
|
+
try {
|
|
3222
|
+
return await Promise.race([work, stopped]);
|
|
3223
|
+
} catch (error) {
|
|
3224
|
+
if (controller.signal.aborted && responseReceived) {
|
|
3225
|
+
let cleanupTimer;
|
|
3226
|
+
await Promise.race([work.catch(() => void 0), new Promise((resolve3) => {
|
|
3227
|
+
cleanupTimer = setTimeout(resolve3, 1e3);
|
|
3228
|
+
})]);
|
|
3229
|
+
clearTimeout(cleanupTimer);
|
|
3230
|
+
}
|
|
3231
|
+
if (error instanceof CliError) throw error;
|
|
3232
|
+
if (io.signal?.aborted) throw interruptedError();
|
|
3233
|
+
throw new CliError({ code: "CLI_NETWORK", exitCode: EXIT.SERVER, retryable: true, message: "\u7F51\u9875\u8BF7\u6C42\u8FDE\u63A5\u5931\u8D25\uFF0C\u8BF7\u67E5\u8BE2\u539F\u64CD\u4F5C\u7ED3\u679C\u540E\u518D\u51B3\u5B9A\u662F\u5426\u91CD\u8BD5" });
|
|
3234
|
+
} finally {
|
|
3235
|
+
clearTimeout(timer);
|
|
3236
|
+
io.signal?.removeEventListener("abort", interrupt2);
|
|
3237
|
+
}
|
|
3238
|
+
}
|
|
3239
|
+
|
|
3240
|
+
// src/web-session.ts
|
|
3241
|
+
import { createHash as createHash4, createHmac, randomBytes as randomBytes3 } from "node:crypto";
|
|
3242
|
+
import { constants as constants3 } from "node:fs";
|
|
3243
|
+
import { chmod as chmod2, lstat as lstat3, mkdir as mkdir3, open as open3, readdir as readdir2, rename as rename2, unlink as unlink3 } from "node:fs/promises";
|
|
3244
|
+
import { dirname as dirname3, join as join4, parse } from "node:path";
|
|
3245
|
+
import { StringDecoder } from "node:string_decoder";
|
|
3246
|
+
var noFollow = constants3.O_NOFOLLOW ?? 0;
|
|
3247
|
+
var nonBlock = constants3.O_NONBLOCK ?? 0;
|
|
3248
|
+
var stateNames = /* @__PURE__ */ new Set(["session.json", "last-web-request.json"]);
|
|
3249
|
+
var missing = (error) => error?.code === "ENOENT";
|
|
3250
|
+
function stateError(message2) {
|
|
3251
|
+
return new CliError({ code: "CLI_WEB_SESSION", exitCode: EXIT.SERVER, message: message2 });
|
|
3252
|
+
}
|
|
3253
|
+
function validateSessionToken(value) {
|
|
3254
|
+
if (typeof value !== "string" || value.startsWith("bk_") || !/^[A-Za-z0-9._~-]{20,512}$/u.test(value)) {
|
|
3255
|
+
throw usageError("\u7F51\u9875\u4F1A\u8BDD\u65E0\u6548\uFF1B\u8BF7\u8FD0\u884C buke web login\uFF0CAPI \u5BC6\u94A5\u4E0D\u80FD\u4F5C\u4E3A\u7F51\u9875\u767B\u5F55\u51ED\u636E");
|
|
3256
|
+
}
|
|
3257
|
+
return value;
|
|
3258
|
+
}
|
|
3259
|
+
function webStatePath(io, name2 = "session.json") {
|
|
3260
|
+
if (!stateNames.has(name2) && !/^web-(?:request|fingerprint)-[a-f0-9]{64}\.json$/u.test(name2) && !/^web-lock-[a-f0-9]{64}-\d+-[a-f0-9]{32}\.json$/u.test(name2)) throw stateError("\u4E0D\u652F\u6301\u7684\u7F51\u9875\u72B6\u6001\u6587\u4EF6");
|
|
3261
|
+
return join4(credentialsDir(io), name2);
|
|
3262
|
+
}
|
|
3263
|
+
async function guardAncestors(path) {
|
|
3264
|
+
let current = path;
|
|
3265
|
+
for (; ; ) {
|
|
3266
|
+
try {
|
|
3267
|
+
const info = await lstat3(current);
|
|
3268
|
+
if (info.isSymbolicLink() || !info.isDirectory()) throw stateError("\u7F51\u9875\u51ED\u636E\u76EE\u5F55\u4E0D\u80FD\u7ECF\u8FC7\u7B26\u53F7\u94FE\u63A5\u6216\u975E\u76EE\u5F55\u6587\u4EF6");
|
|
3269
|
+
} catch (error) {
|
|
3270
|
+
if (!missing(error)) throw error;
|
|
3271
|
+
}
|
|
3272
|
+
if (current === parse(current).root) break;
|
|
3273
|
+
current = dirname3(current);
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
async function guardStateFile(path, io, transientTicket = false) {
|
|
3277
|
+
try {
|
|
3278
|
+
const info = await lstat3(path);
|
|
3279
|
+
if (transientTicket && info.isFile() && info.nlink === 0) return await guardStateFile(path, io, true);
|
|
3280
|
+
if (info.isSymbolicLink() || !info.isFile() || info.nlink !== 1) throw stateError("\u7F51\u9875\u72B6\u6001\u6587\u4EF6\u5FC5\u987B\u662F\u666E\u901A\u6587\u4EF6\uFF0C\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5\u6216\u786C\u94FE\u63A5");
|
|
3281
|
+
if (io.platform !== "win32" && (info.mode & 63) !== 0) throw stateError("\u7F51\u9875\u72B6\u6001\u6587\u4EF6\u6743\u9650\u8FC7\u5BBD\uFF0C\u8BF7\u5148\u8BBE\u7F6E\u4E3A 0600");
|
|
3282
|
+
} catch (error) {
|
|
3283
|
+
if (!missing(error)) throw error;
|
|
3284
|
+
}
|
|
3285
|
+
}
|
|
3286
|
+
async function readWebState(io, name2) {
|
|
3287
|
+
const path = webStatePath(io, name2);
|
|
3288
|
+
try {
|
|
3289
|
+
await guardAncestors(dirname3(path));
|
|
3290
|
+
await guardStateFile(path, io, name2.startsWith("web-lock-"));
|
|
3291
|
+
const handle = await open3(path, constants3.O_RDONLY | noFollow | nonBlock);
|
|
3292
|
+
try {
|
|
3293
|
+
const info = await handle.stat();
|
|
3294
|
+
if (info.nlink === 0 && name2.startsWith("web-lock-")) return await readWebState(io, name2);
|
|
3295
|
+
if (!info.isFile() || info.nlink !== 1 || info.size > 64 * 1024 || io.platform !== "win32" && (info.mode & 63) !== 0) throw stateError("\u7F51\u9875\u72B6\u6001\u6587\u4EF6\u65E0\u6548");
|
|
3296
|
+
const value = JSON.parse(await handle.readFile("utf8"));
|
|
3297
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw stateError("\u7F51\u9875\u72B6\u6001\u6587\u4EF6\u683C\u5F0F\u65E0\u6548");
|
|
3298
|
+
return value;
|
|
3299
|
+
} finally {
|
|
3300
|
+
await handle.close();
|
|
3301
|
+
}
|
|
3302
|
+
} catch (error) {
|
|
3303
|
+
if (missing(error)) return null;
|
|
3304
|
+
if (error instanceof CliError) throw error;
|
|
3305
|
+
throw stateError("\u65E0\u6CD5\u8BFB\u53D6\u7F51\u9875\u72B6\u6001\u6587\u4EF6\uFF0C\u8BF7\u68C0\u67E5\u76EE\u5F55\u4E0E\u6587\u4EF6\u6743\u9650");
|
|
3306
|
+
}
|
|
3307
|
+
}
|
|
3308
|
+
async function writeWebState(io, name2, value) {
|
|
3309
|
+
const path = webStatePath(io, name2), dir = dirname3(path);
|
|
3310
|
+
const temp = join4(dir, `.${name2}.${process.pid}.${randomBytes3(8).toString("hex")}.tmp`);
|
|
3311
|
+
let created = false;
|
|
3312
|
+
try {
|
|
3313
|
+
await guardAncestors(dir);
|
|
3314
|
+
await mkdir3(dir, { recursive: true, mode: 448 });
|
|
3315
|
+
await guardAncestors(dir);
|
|
3316
|
+
if (io.platform !== "win32" && ((await lstat3(dir)).mode & 63) !== 0) throw stateError("\u7F51\u9875\u51ED\u636E\u76EE\u5F55\u6743\u9650\u8FC7\u5BBD\uFF0C\u8BF7\u5148\u8BBE\u7F6E\u4E3A 0700");
|
|
3317
|
+
await guardStateFile(path, io);
|
|
3318
|
+
const handle = await open3(temp, constants3.O_CREAT | constants3.O_EXCL | constants3.O_WRONLY | noFollow, 384);
|
|
3319
|
+
created = true;
|
|
3320
|
+
try {
|
|
3321
|
+
await handle.writeFile(`${JSON.stringify(value, null, 2)}
|
|
3322
|
+
`);
|
|
3323
|
+
await handle.sync();
|
|
3324
|
+
} finally {
|
|
3325
|
+
await handle.close();
|
|
3326
|
+
}
|
|
3327
|
+
await guardStateFile(path, io);
|
|
3328
|
+
await rename2(temp, path);
|
|
3329
|
+
created = false;
|
|
3330
|
+
await chmod2(path, 384);
|
|
3331
|
+
return path;
|
|
3332
|
+
} catch (error) {
|
|
3333
|
+
if (created) await unlink3(temp).catch(() => void 0);
|
|
3334
|
+
if (error instanceof CliError) throw error;
|
|
3335
|
+
throw stateError("\u7F51\u9875\u72B6\u6001\u672A\u80FD\u4FDD\u5B58\uFF0C\u539F\u6587\u4EF6\u4FDD\u6301\u4E0D\u53D8\uFF1B\u8BF7\u68C0\u67E5\u76EE\u5F55\u6743\u9650\u4E0E\u78C1\u76D8\u7A7A\u95F4");
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
async function deleteWebSession(io, expected) {
|
|
3339
|
+
const current = await readWebState(io, "session.json");
|
|
3340
|
+
if (current?.token !== expected.token || current?.baseUrl !== expected.baseUrl) return;
|
|
3341
|
+
await unlink3(webStatePath(io)).catch((error) => {
|
|
3342
|
+
if (!missing(error)) throw stateError("\u670D\u52A1\u7AEF\u5DF2\u9000\u51FA\uFF0C\u4F46\u672C\u5730\u4F1A\u8BDD\u6587\u4EF6\u5220\u9664\u5931\u8D25");
|
|
3343
|
+
});
|
|
3344
|
+
}
|
|
3345
|
+
async function lockWebRequest(io, hash) {
|
|
3346
|
+
if (!/^[a-f0-9]{64}$/u.test(hash)) throw stateError("\u7F51\u9875\u8BF7\u6C42\u9501\u6807\u8BC6\u65E0\u6548");
|
|
3347
|
+
const nonce = randomBytes3(16).toString("hex"), prefix = `web-lock-${hash}-`;
|
|
3348
|
+
const name2 = `${prefix}${process.pid}-${nonce}.json`;
|
|
3349
|
+
const mine = { version: 1, pid: process.pid, nonce, choosing: true, ticket: 0 };
|
|
3350
|
+
const release2 = async () => {
|
|
3351
|
+
const current = await readWebState(io, name2);
|
|
3352
|
+
if (current?.nonce === nonce && current.pid === process.pid) await unlink3(webStatePath(io, name2)).catch((error) => {
|
|
3353
|
+
if (!missing(error)) throw error;
|
|
3354
|
+
});
|
|
3355
|
+
};
|
|
3356
|
+
const participants = async () => {
|
|
3357
|
+
await guardAncestors(credentialsDir(io));
|
|
3358
|
+
const names = (await readdir2(credentialsDir(io))).filter((candidate) => candidate.startsWith(prefix) && /^web-lock-[a-f0-9]{64}-\d+-[a-f0-9]{32}\.json$/u.test(candidate));
|
|
3359
|
+
const records = [];
|
|
3360
|
+
for (const candidate of names) {
|
|
3361
|
+
const value = await readWebState(io, candidate);
|
|
3362
|
+
if (!value) continue;
|
|
3363
|
+
if (value.version !== 1 || !Number.isSafeInteger(value.pid) || Number(value.pid) <= 0 || typeof value.nonce !== "string" || candidate !== `${prefix}${value.pid}-${value.nonce}.json` || typeof value.choosing !== "boolean" || !Number.isSafeInteger(value.ticket) || Number(value.ticket) < 0) throw stateError("\u7F51\u9875\u8BF7\u6C42\u9501\u7968\u636E\u65E0\u6548\uFF0C\u64CD\u4F5C\u672A\u63D0\u4EA4");
|
|
3364
|
+
let alive = true;
|
|
3365
|
+
try {
|
|
3366
|
+
process.kill(Number(value.pid), 0);
|
|
3367
|
+
} catch (error) {
|
|
3368
|
+
if (error.code === "ESRCH") alive = false;
|
|
3369
|
+
}
|
|
3370
|
+
if (!alive) {
|
|
3371
|
+
await unlink3(webStatePath(io, candidate)).catch((error) => {
|
|
3372
|
+
if (!missing(error)) throw error;
|
|
3373
|
+
});
|
|
3374
|
+
} else records.push({ name: candidate, ticket: Number(value.ticket), choosing: value.choosing });
|
|
3375
|
+
}
|
|
3376
|
+
return records;
|
|
3377
|
+
};
|
|
3378
|
+
await writeWebState(io, name2, mine);
|
|
3379
|
+
try {
|
|
3380
|
+
const others = await participants();
|
|
3381
|
+
mine.ticket = Math.max(0, ...others.map((value) => value.ticket)) + 1;
|
|
3382
|
+
if (!Number.isSafeInteger(mine.ticket)) throw stateError("\u7F51\u9875\u8BF7\u6C42\u9501\u7968\u53F7\u8D85\u51FA\u8303\u56F4");
|
|
3383
|
+
mine.choosing = false;
|
|
3384
|
+
await writeWebState(io, name2, mine);
|
|
3385
|
+
const deadline = Date.now() + 12e4;
|
|
3386
|
+
for (; ; ) {
|
|
3387
|
+
if (io.signal?.aborted) throw interruptedError();
|
|
3388
|
+
const blocked = (await participants()).some((other) => other.name !== name2 && (other.choosing || other.ticket < mine.ticket || other.ticket === mine.ticket && other.name < name2));
|
|
3389
|
+
if (!blocked) return release2;
|
|
3390
|
+
if (Date.now() >= deadline) throw new CliError({
|
|
3391
|
+
code: "CLI_WEB_REQUEST_BUSY",
|
|
3392
|
+
exitCode: EXIT.RETRY_LATER,
|
|
3393
|
+
message: "\u76F8\u540C\u7F51\u9875\u8BF7\u6C42\u6B63\u5728\u7531\u53E6\u4E00\u4E2A CLI \u8FDB\u7A0B\u5904\u7406\uFF0C\u672C\u6B21\u672A\u63D0\u4EA4\uFF1B\u8BF7\u67E5\u8BE2\u539F\u64CD\u4F5C\u7ED3\u679C"
|
|
3394
|
+
});
|
|
3395
|
+
await new Promise((resolve3) => setTimeout(resolve3, 25));
|
|
3396
|
+
}
|
|
3397
|
+
} catch (error) {
|
|
3398
|
+
await release2().catch(() => void 0);
|
|
3399
|
+
throw error;
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
async function fingerprintWebRequest(io, scope, value) {
|
|
3403
|
+
const scopeHash = createHash4("sha256").update(JSON.stringify(scope)).digest("hex");
|
|
3404
|
+
const name2 = `web-fingerprint-${scopeHash}.json`;
|
|
3405
|
+
const release2 = await lockWebRequest(io, createHash4("sha256").update(`fingerprint:${scopeHash}`).digest("hex"));
|
|
3406
|
+
try {
|
|
3407
|
+
let stored = await readWebState(io, name2);
|
|
3408
|
+
if (!stored) {
|
|
3409
|
+
stored = { version: 1, key: randomBytes3(32).toString("hex") };
|
|
3410
|
+
await writeWebState(io, name2, stored);
|
|
3411
|
+
}
|
|
3412
|
+
if (stored.version !== 1 || typeof stored.key !== "string" || !/^[a-f0-9]{64}$/u.test(stored.key)) throw stateError("\u7F51\u9875\u8BF7\u6C42\u6458\u8981\u5BC6\u94A5\u65E0\u6548\uFF0C\u64CD\u4F5C\u672A\u63D0\u4EA4");
|
|
3413
|
+
return createHmac("sha256", Buffer.from(stored.key, "hex")).update(JSON.stringify(value)).digest("hex");
|
|
3414
|
+
} finally {
|
|
3415
|
+
await release2();
|
|
3416
|
+
}
|
|
3417
|
+
}
|
|
3418
|
+
async function resolveWebSession(context) {
|
|
3419
|
+
const explicit = explicitBaseUrl(context.baseUrl, context.io.env);
|
|
3420
|
+
const supplied = context.io.env.BUKE_SESSION_TOKEN?.trim();
|
|
3421
|
+
if (supplied) {
|
|
3422
|
+
const token2 = validateSessionToken(supplied);
|
|
3423
|
+
context.out.protect(token2);
|
|
3424
|
+
return { version: 1, token: token2, baseUrl: explicit ?? DEFAULT_BASE_URL, savedAt: "", source: "env" };
|
|
3425
|
+
}
|
|
3426
|
+
const stored = await readWebState(context.io, "session.json");
|
|
3427
|
+
if (!stored) throw new CliError({
|
|
3428
|
+
code: "CLI_WEB_NOT_LOGGED_IN",
|
|
3429
|
+
exitCode: EXIT.AUTH,
|
|
3430
|
+
message: "\u5C1A\u672A\u767B\u5F55\u7F51\u9875\u4F1A\u8BDD\uFF0C\u8BF7\u8FD0\u884C buke web login\uFF1Bbuke login \u4FDD\u5B58\u7684 API \u5BC6\u94A5\u4E0D\u80FD\u7528\u4E8E\u7F51\u9875\u63A5\u53E3"
|
|
3431
|
+
});
|
|
3432
|
+
if (stored.version !== 1 || typeof stored.baseUrl !== "string" || typeof stored.savedAt !== "string") throw stateError("\u7F51\u9875\u4F1A\u8BDD\u6587\u4EF6\u683C\u5F0F\u65E0\u6548\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55");
|
|
3433
|
+
const token = validateSessionToken(stored.token), baseUrl = normalizeBaseUrl(stored.baseUrl);
|
|
3434
|
+
context.out.protect(token);
|
|
3435
|
+
if (explicit && explicit !== baseUrl) throw usageError("\u7F51\u9875\u4F1A\u8BDD\u4E0E\u670D\u52A1\u5730\u5740\u4E0D\u5339\u914D\uFF1B\u5207\u6362\u670D\u52A1\u8BF7\u91CD\u65B0\u8FD0\u884C buke web login");
|
|
3436
|
+
return {
|
|
3437
|
+
version: 1,
|
|
3438
|
+
token,
|
|
3439
|
+
baseUrl,
|
|
3440
|
+
savedAt: stored.savedAt,
|
|
3441
|
+
source: "file",
|
|
3442
|
+
...typeof stored.expiresAt === "string" ? { expiresAt: stored.expiresAt } : {}
|
|
3443
|
+
};
|
|
3444
|
+
}
|
|
3445
|
+
async function readWebPassword(io) {
|
|
3446
|
+
if (io.signal?.aborted) throw interruptedError();
|
|
3447
|
+
const fromEnv = io.env.BUKE_PASSWORD;
|
|
3448
|
+
if (fromEnv !== void 0) {
|
|
3449
|
+
if (!fromEnv || fromEnv.length > 8192 || /[\r\n\0]/u.test(fromEnv)) throw usageError("BUKE_PASSWORD \u4E0D\u80FD\u4E3A\u7A7A\u6216\u542B\u6362\u884C");
|
|
3450
|
+
return fromEnv;
|
|
3451
|
+
}
|
|
3452
|
+
const stream = io.stdin;
|
|
3453
|
+
const tty = stream.isTTY === true;
|
|
3454
|
+
if (tty && typeof stream.setRawMode !== "function") throw usageError("\u5F53\u524D\u7EC8\u7AEF\u4E0D\u80FD\u9690\u85CF\u5BC6\u7801\u8F93\u5165\uFF0C\u8BF7\u4F7F\u7528 BUKE_PASSWORD \u6216\u7BA1\u9053");
|
|
3455
|
+
if (tty) io.stderr.write("\u7F51\u9875\u767B\u5F55\u5BC6\u7801\uFF08\u8F93\u5165\u4E0D\u663E\u793A\uFF09\uFF1A");
|
|
3456
|
+
const password = await new Promise((resolve3, reject) => {
|
|
3457
|
+
let value = "", done = false;
|
|
3458
|
+
const decoder = new StringDecoder("utf8");
|
|
3459
|
+
const finish = (error) => {
|
|
3460
|
+
if (done) return;
|
|
3461
|
+
done = true;
|
|
3462
|
+
clearTimeout(timer);
|
|
3463
|
+
for (const [name2, handler] of [["data", onData], ["end", onEnd], ["close", onEnd], ["error", onError]]) stream.removeListener(name2, handler);
|
|
3464
|
+
io.signal?.removeEventListener("abort", onAbort);
|
|
3465
|
+
if (tty) {
|
|
3466
|
+
stream.setRawMode(false);
|
|
3467
|
+
io.stderr.write("\n");
|
|
3468
|
+
}
|
|
3469
|
+
stream.pause();
|
|
3470
|
+
if (error) reject(error);
|
|
3471
|
+
else resolve3(value.replace(/\r?\n$/u, ""));
|
|
3472
|
+
};
|
|
3473
|
+
const onAbort = () => finish(interruptedError());
|
|
3474
|
+
const onEnd = () => {
|
|
3475
|
+
value += decoder.end();
|
|
3476
|
+
finish();
|
|
3477
|
+
};
|
|
3478
|
+
const onError = () => finish(usageError("\u65E0\u6CD5\u8BFB\u53D6\u5BC6\u7801\u8F93\u5165"));
|
|
3479
|
+
const onData = (chunk) => {
|
|
3480
|
+
const text = typeof chunk === "string" ? chunk : decoder.write(Buffer.from(chunk));
|
|
3481
|
+
if (tty) {
|
|
3482
|
+
for (const character of text) {
|
|
3483
|
+
if (character === "") {
|
|
3484
|
+
onAbort();
|
|
3485
|
+
return;
|
|
3486
|
+
}
|
|
3487
|
+
if (character === "\r" || character === "\n" || character === "") {
|
|
3488
|
+
finish();
|
|
3489
|
+
return;
|
|
3490
|
+
}
|
|
3491
|
+
if (character === "\b" || character === "\x7F") value = [...value].slice(0, -1).join("");
|
|
3492
|
+
else if (!/[\p{Cc}]/u.test(character)) value += character;
|
|
3493
|
+
}
|
|
3494
|
+
} else value += text;
|
|
3495
|
+
if (Buffer.byteLength(value) > 8192) finish(usageError("\u5BC6\u7801\u8F93\u5165\u8FC7\u957F"));
|
|
3496
|
+
};
|
|
3497
|
+
const timer = setTimeout(() => finish(usageError("\u7B49\u5F85\u5BC6\u7801\u8F93\u5165\u8D85\u65F6")), io.stdinTimeoutMs ?? 3e4);
|
|
3498
|
+
stream.on("data", onData);
|
|
3499
|
+
stream.on("end", onEnd);
|
|
3500
|
+
stream.on("close", onEnd);
|
|
3501
|
+
stream.on("error", onError);
|
|
3502
|
+
io.signal?.addEventListener("abort", onAbort, { once: true });
|
|
3503
|
+
if (tty) stream.setRawMode(true);
|
|
3504
|
+
stream.resume();
|
|
3505
|
+
});
|
|
3506
|
+
if (!password || /[\r\n\0]/u.test(password)) throw usageError("\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A\u6216\u5305\u542B\u6362\u884C");
|
|
3507
|
+
return password;
|
|
3508
|
+
}
|
|
3509
|
+
|
|
3510
|
+
// src/commands/web.ts
|
|
3511
|
+
var webCommand = {
|
|
3512
|
+
run: web,
|
|
3513
|
+
acceptsBaseUrl: true,
|
|
3514
|
+
options: ["username", "group", "params", "query", "data", "headers", "file", "files", "yes", "out", "timeout", "workspace", "idempotency-key"],
|
|
3515
|
+
positionals: ["\u5B50\u547D\u4EE4", "\u64CD\u4F5C\u7F16\u53F7"],
|
|
3516
|
+
help: [
|
|
3517
|
+
"\u7528\u6CD5\uFF1A",
|
|
3518
|
+
" buke web login --username <\u8D26\u53F7>\uFF1A\u5BC6\u7801\u901A\u8FC7 BUKE_PASSWORD\u3001\u7BA1\u9053\u6216\u9690\u85CF\u7EC8\u7AEF\u8F93\u5165\u63D0\u4F9B\u3002",
|
|
3519
|
+
" buke web whoami [--workspace <\u5DE5\u4F5C\u533AID>] | logout",
|
|
3520
|
+
" buke web operations [--group <\u5206\u7EC4>]\uFF1A\u67E5\u770B\u56FA\u5B9A\u64CD\u4F5C\u76EE\u5F55\u3002",
|
|
3521
|
+
" buke web call <\u64CD\u4F5C\u7F16\u53F7> [--params <JSON\u6587\u4EF6|->] [--query <JSON\u6587\u4EF6>] [--data <JSON\u6587\u4EF6>]",
|
|
3522
|
+
" [--file <\u6587\u4EF6> | --files <\u5B57\u6BB5\u540D\u5230\u6587\u4EF6\u8DEF\u5F84\u7684JSON\u6587\u4EF6>] [--yes] [--out <\u65B0\u6587\u4EF6>]",
|
|
3523
|
+
" [--headers <\u4E1A\u52A1\u8BF7\u6C42\u5934JSON\u6587\u4EF6>] [--workspace <\u5DE5\u4F5C\u533AID>] [--idempotency-key <\u539F\u952E>] [--timeout <\u79D2>] [--json]",
|
|
3524
|
+
"\u6240\u6709\u5199\u64CD\u4F5C\u5FC5\u987B\u6DFB\u52A0 --yes\uFF1B\u8FD9\u53EA\u4EE3\u8868\u63D0\u4EA4\u672C\u6B21\u64CD\u4F5C\uFF0C\u8D39\u7528\u8303\u56F4\u4ECD\u7531\u7F51\u9875\u539F\u63A5\u53E3\u7684\u62A5\u4EF7\u4E0E\u786E\u8BA4\u7EA6\u675F\u3002",
|
|
3525
|
+
"\u53EA\u5141\u8BB8\u76EE\u5F55\u5185\u7684\u8DEF\u5F84\uFF0C\u5145\u503C\u53CA\u540E\u53F0\u7BA1\u7406\u4E0D\u5728\u76EE\u5F55\u4E2D\u3002\u4F1A\u8BDD\u4E0E API \u5BC6\u94A5\u5206\u522B\u4FDD\u5B58\uFF0C\u4E0D\u80FD\u6DF7\u7528\u3002",
|
|
3526
|
+
"\u9ED8\u8BA4\u8BF7\u6C42\u65F6\u9650 120 \u79D2\uFF1B\u6D41\u5F0F\u4E8B\u4EF6\u53EF\u4E2D\u65AD\u3002\u6587\u4EF6\u4EE5 0600 \u539F\u5B50\u4FDD\u5B58\uFF0C\u5DF2\u6709\u6587\u4EF6\u4E0D\u8986\u76D6\u3002",
|
|
3527
|
+
"API \u5BC6\u94A5\u7B7E\u53D1\u5FC5\u987B\u63D0\u4F9B --out\uFF0C\u660E\u6587\u53EA\u5199\u6587\u4EF6\uFF0C\u4E0D\u663E\u793A\u5728\u7EC8\u7AEF\u3002\u672A\u77E5\u7ED3\u679C\u4FDD\u7559\u539F\u952E\uFF0C\u4E0D\u81EA\u52A8\u91CD\u53D1\u3002"
|
|
3528
|
+
].join("\n")
|
|
3529
|
+
};
|
|
3530
|
+
function object(value) {
|
|
3531
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw usageError("\u8BF7\u6C42\u53C2\u6570\u5FC5\u987B\u662F JSON \u5BF9\u8C61");
|
|
3532
|
+
return value;
|
|
3533
|
+
}
|
|
3534
|
+
function issuedSession(context, baseUrl, data) {
|
|
3535
|
+
const user = data.user && typeof data.user === "object" && !Array.isArray(data.user) ? data.user : {};
|
|
3536
|
+
if (data.ok !== true || typeof data.expiresAt !== "string" || !Number.isFinite(Date.parse(data.expiresAt)) || typeof user.id !== "string" || !user.id || typeof user.username !== "string" || !user.username || typeof user.workspaceId !== "string" || !user.workspaceId || !Array.isArray(user.workspaces) || !user.workspaces.some((item) => item && typeof item === "object" && item.id === user.workspaceId)) {
|
|
3537
|
+
throw new CliError({ code: "CLI_BAD_RESPONSE", exitCode: EXIT.SERVER, message: "\u8BA4\u8BC1\u54CD\u5E94\u7F3A\u5C11\u5B8C\u6574\u4F1A\u8BDD\u6216\u7528\u6237\u8EAB\u4EFD\uFF0C\u539F\u4F1A\u8BDD\u4FDD\u6301\u4E0D\u53D8" });
|
|
3538
|
+
}
|
|
3539
|
+
const token = validateSessionToken(data.token);
|
|
3540
|
+
context.out.protect(token);
|
|
3541
|
+
return { version: 1, baseUrl, token, savedAt: (context.io.now?.() ?? /* @__PURE__ */ new Date()).toISOString(), expiresAt: data.expiresAt };
|
|
3542
|
+
}
|
|
3543
|
+
async function optionData(context, name2) {
|
|
3544
|
+
const file = textOption(context.values, name2);
|
|
3545
|
+
return file ? readPropsArgument(context.io, file, `--${name2}`) : {};
|
|
3546
|
+
}
|
|
3547
|
+
function workspaceOf(context) {
|
|
3548
|
+
const workspace = textOption(context.values, "workspace") ?? context.io.env.BUKE_WORKSPACE_ID?.trim();
|
|
3549
|
+
if (workspace && !/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/u.test(workspace)) throw usageError("\u5DE5\u4F5C\u533A\u7F16\u53F7\u683C\u5F0F\u65E0\u6548");
|
|
3550
|
+
return workspace || void 0;
|
|
3551
|
+
}
|
|
3552
|
+
function operationPath(operation, params, query) {
|
|
3553
|
+
const used = /* @__PURE__ */ new Set(), resolved = {};
|
|
3554
|
+
const path = operation.path.replace(/:([A-Za-z][A-Za-z0-9_]*)/gu, (_match, name2) => {
|
|
3555
|
+
const value = params[name2];
|
|
3556
|
+
const text = String(value);
|
|
3557
|
+
const invalidPath = name2 === "path" ? text.split("/").some((segment2) => !segment2 || segment2 === "." || segment2 === "..") : text.includes("/") || [".", ".."].includes(text);
|
|
3558
|
+
if (typeof value !== "string" && typeof value !== "number" || !text || /[\\%\p{Cc}]/u.test(text) || invalidPath) throw usageError(`\u8BF7\u5728 --params \u4E2D\u63D0\u4F9B\u6709\u6548\u8DEF\u5F84\u53C2\u6570 ${name2}`);
|
|
3559
|
+
used.add(name2);
|
|
3560
|
+
resolved[name2] = String(value);
|
|
3561
|
+
return encodeURIComponent(String(value));
|
|
3562
|
+
});
|
|
3563
|
+
if (Object.keys(params).some((name2) => !used.has(name2))) throw usageError("--params \u5305\u542B\u8BE5\u64CD\u4F5C\u4E0D\u4F7F\u7528\u7684\u53C2\u6570");
|
|
3564
|
+
const search = new URLSearchParams();
|
|
3565
|
+
for (const [name2, raw] of Object.entries(query)) {
|
|
3566
|
+
if (!name2 || /[\p{Cc}]/u.test(name2)) throw usageError("\u67E5\u8BE2\u53C2\u6570\u540D\u79F0\u65E0\u6548");
|
|
3567
|
+
for (const value of Array.isArray(raw) ? raw : [raw]) {
|
|
3568
|
+
if (value === null || value === void 0) continue;
|
|
3569
|
+
if (!["string", "number", "boolean"].includes(typeof value)) throw usageError("\u67E5\u8BE2\u53C2\u6570\u53EA\u652F\u6301\u5B57\u7B26\u4E32\u3001\u6570\u5B57\u3001\u5E03\u5C14\u503C\u53CA\u5176\u6570\u7EC4");
|
|
3570
|
+
search.append(name2, String(value));
|
|
3571
|
+
}
|
|
3572
|
+
}
|
|
3573
|
+
return { path: `${path}${search.size ? `?${search}` : ""}`, params: resolved };
|
|
3574
|
+
}
|
|
3575
|
+
function fileOperation(operation) {
|
|
3576
|
+
if (operation.method !== "GET") return false;
|
|
3577
|
+
return /\/(?:download(?:\.zip)?|video|audio|clip|subtitles\.srt)$/u.test(operation.path) || /\/edits\/:[^/]+\/subtitles$/u.test(operation.path) || /\/attachments\/:[^/]+\/file$/u.test(operation.path) || /^\/api\/delivery\/(?:packages|shared)\/:[^/]+\/files\/:[^/]+$/u.test(operation.path) || /^\/api\/membership\/renders\/:[^/]+\/output$/u.test(operation.path) || operation.path === "/api/graphic/runs/:runId/preview" || /^\/api\/showcase-videos\/runs\/:[^/]+\/image-edits\/area\/:[^/]+\/preview$/u.test(operation.path);
|
|
3578
|
+
}
|
|
3579
|
+
async function upload2(path, operation) {
|
|
3580
|
+
try {
|
|
3581
|
+
const policy = webUploadPolicy(operation, basename3(path));
|
|
3582
|
+
const info = await lstat4(path);
|
|
3583
|
+
if (!info.isFile() || info.size <= 0 || info.size > policy.maxBytes) throw usageError(`\u4E0A\u4F20\u5FC5\u987B\u662F 1 \u5B57\u8282\u81F3 ${policy.maxBytes / 1024 / 1024} MiB \u7684\u666E\u901A\u6587\u4EF6`);
|
|
3584
|
+
const bytes = await readFile3(path);
|
|
3585
|
+
if (!bytes.length || bytes.length > policy.maxBytes) throw usageError("\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8D85\u51FA\u8BE5\u64CD\u4F5C\u5141\u8BB8\u8303\u56F4");
|
|
3586
|
+
return { bytes, mime: policy.mime, name: basename3(path), sha256: createHash5("sha256").update(bytes).digest("hex") };
|
|
3587
|
+
} catch (error) {
|
|
3588
|
+
if (error instanceof CliError) throw error;
|
|
3589
|
+
throw usageError("\u4E0A\u4F20\u6587\u4EF6\u4E0D\u5B58\u5728\u6216\u65E0\u6CD5\u8BFB\u53D6");
|
|
3590
|
+
}
|
|
3591
|
+
}
|
|
3592
|
+
async function requestBody(context, operation, data) {
|
|
3593
|
+
const file = textOption(context.values, "file"), filesFile = textOption(context.values, "files");
|
|
3594
|
+
if (file && filesFile) throw usageError("--file \u4E0E --files \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528");
|
|
3595
|
+
if (operation.method === "GET") {
|
|
3596
|
+
if (file || filesFile || textOption(context.values, "data")) throw usageError("\u67E5\u8BE2\u64CD\u4F5C\u4E0D\u63A5\u53D7\u6B63\u6587\u6216\u4E0A\u4F20\u6587\u4EF6");
|
|
3597
|
+
return { identity: null };
|
|
3598
|
+
}
|
|
3599
|
+
if (operation.body === "binary") {
|
|
3600
|
+
if (!file || filesFile || textOption(context.values, "data")) throw usageError("\u8BE5\u64CD\u4F5C\u9700\u8981 --file \u539F\u6587\u4EF6\uFF0C\u4E0D\u80FD\u540C\u65F6\u63D0\u4EA4 JSON \u6B63\u6587");
|
|
3601
|
+
const source = await upload2(file, operation);
|
|
3602
|
+
return { body: new Uint8Array(source.bytes), contentType: source.mime, filename: source.name, identity: { sha256: source.sha256, bytes: source.bytes.length } };
|
|
3603
|
+
}
|
|
3604
|
+
if (operation.body === "multipart") {
|
|
3605
|
+
const field = operation.uploadField;
|
|
3606
|
+
if (!field) throw usageError("\u8BE5\u64CD\u4F5C\u7F3A\u5C11\u4E0A\u4F20\u5B57\u6BB5\u5408\u540C");
|
|
3607
|
+
const mapping = file ? { [field]: file } : await optionData(context, "files");
|
|
3608
|
+
if (Object.keys(mapping).length !== 1 || !(field in mapping) || Array.isArray(mapping[field]) && mapping[field].length !== 1) throw usageError(`\u8BE5\u64CD\u4F5C\u9700\u8981\u4E14\u53EA\u63A5\u53D7\u4E00\u4E2A ${field} \u6587\u4EF6\uFF0C\u8BF7\u4F7F\u7528 --file \u6216\u5BF9\u5E94 --files \u5B57\u6BB5`);
|
|
3609
|
+
const form = new FormData(), identities = [];
|
|
3610
|
+
for (const [name2, value] of Object.entries(data)) form.append(name2, typeof value === "string" ? value : JSON.stringify(value));
|
|
3611
|
+
let total = 0;
|
|
3612
|
+
for (const [field2, paths] of Object.entries(mapping)) {
|
|
3613
|
+
if (!field2 || /[\p{Cc}]/u.test(field2)) throw usageError("\u4E0A\u4F20\u5B57\u6BB5\u540D\u79F0\u65E0\u6548");
|
|
3614
|
+
for (const path of Array.isArray(paths) ? paths : [paths]) {
|
|
3615
|
+
if (typeof path !== "string") throw usageError("--files \u7684\u503C\u5FC5\u987B\u662F\u6587\u4EF6\u8DEF\u5F84\u6216\u6587\u4EF6\u8DEF\u5F84\u6570\u7EC4");
|
|
3616
|
+
const source = await upload2(path, operation);
|
|
3617
|
+
total += source.bytes.length;
|
|
3618
|
+
if (total > 256 * 1024 * 1024) throw usageError("\u672C\u6B21\u9644\u4EF6\u603B\u91CF\u4E0D\u80FD\u8D85\u8FC7 256 MiB");
|
|
3619
|
+
form.append(field2, new Blob([new Uint8Array(source.bytes)], { type: source.mime }), source.name);
|
|
3620
|
+
identities.push({ field: field2, name: source.name, sha256: source.sha256, bytes: source.bytes.length });
|
|
3621
|
+
}
|
|
3622
|
+
}
|
|
3623
|
+
return { body: form, identity: { data, files: identities } };
|
|
3624
|
+
}
|
|
3625
|
+
if (file || filesFile) throw usageError("\u8BE5\u64CD\u4F5C\u63A5\u53D7 JSON \u6B63\u6587\uFF0C\u4E0D\u63A5\u53D7\u6587\u4EF6\u4E0A\u4F20");
|
|
3626
|
+
return { body: JSON.stringify(data), contentType: "application/json", identity: data };
|
|
3627
|
+
}
|
|
3628
|
+
async function webIdentity(context, session, workspace, timeoutMs) {
|
|
3629
|
+
const result = await requestWeb(context.io, { baseUrl: session.baseUrl, token: session.token, method: "GET", path: "/api/me", workspaceId: workspace, timeoutMs });
|
|
3630
|
+
const user = object(object(result.data).user);
|
|
3631
|
+
if (typeof user.id !== "string" || !user.id || typeof user.workspaceId !== "string" || !user.workspaceId || workspace && (user.workspaceId !== workspace || !Array.isArray(user.workspaces) || !user.workspaces.some((item) => item && typeof item === "object" && item.id === workspace))) {
|
|
3632
|
+
throw new CliError({ code: "CLI_WEB_WORKSPACE_FORBIDDEN", exitCode: EXIT.AUTH, message: "\u670D\u52A1\u7AEF\u672A\u786E\u8BA4\u8BE5\u5DE5\u4F5C\u533A\u7684\u6210\u5458\u6743\u9650\uFF0C\u672C\u6B21\u64CD\u4F5C\u672A\u63D0\u4EA4" });
|
|
3633
|
+
}
|
|
3634
|
+
return { result, userId: user.id, workspaceId: user.workspaceId };
|
|
3635
|
+
}
|
|
3636
|
+
async function web(context) {
|
|
3637
|
+
const invocationStartedAt = performance.timeOrigin + performance.now();
|
|
3638
|
+
const { io, out, args, values } = context;
|
|
3639
|
+
const timeoutSeconds = timeoutSecondsOf(values, 120);
|
|
3640
|
+
if (timeoutSeconds > 2147483) throw usageError("--timeout \u8D85\u51FA\u652F\u6301\u8303\u56F4");
|
|
3641
|
+
const timeoutMs = timeoutSeconds * 1e3;
|
|
3642
|
+
const action2 = args[0];
|
|
3643
|
+
if (!["login", "whoami", "logout", "operations", "call"].includes(action2 ?? "")) throw usageError("web \u652F\u6301 login\u3001whoami\u3001logout\u3001operations\u3001call");
|
|
3644
|
+
if (action2 !== "call" && args[1] !== void 0) throw usageError("\u8BE5\u7F51\u9875\u5B50\u547D\u4EE4\u4E0D\u63A5\u53D7\u64CD\u4F5C\u7F16\u53F7");
|
|
3645
|
+
if (["params", "query", "data", "files", "headers"].filter((name2) => values[name2] === "-").length > 1) throw usageError("\u4E00\u6B21\u547D\u4EE4\u53EA\u80FD\u6709\u4E00\u4E2A JSON \u53C2\u6570\u4ECE\u6807\u51C6\u8F93\u5165\u8BFB\u53D6");
|
|
3646
|
+
if (action2 === "operations") {
|
|
3647
|
+
const group = textOption(values, "group");
|
|
3648
|
+
const operations = WEB_OPERATIONS.filter((operation2) => !group || operation2.group === group);
|
|
3649
|
+
out.result(operations.map((operation2) => `${operation2.id} ${operation2.method} ${operation2.path} ${operation2.description}`), { operations });
|
|
3650
|
+
return;
|
|
3651
|
+
}
|
|
3652
|
+
if (action2 === "login") {
|
|
3653
|
+
const username = textOption(values, "username");
|
|
3654
|
+
if (!username) throw usageError("\u8BF7\u63D0\u4F9B --username <\u8D26\u53F7>");
|
|
3655
|
+
const baseUrl = explicitBaseUrl(context.baseUrl, io.env) ?? DEFAULT_BASE_URL;
|
|
3656
|
+
const password = await readWebPassword(io);
|
|
3657
|
+
out.protect(password);
|
|
3658
|
+
let session;
|
|
3659
|
+
const result = await requestWeb(io, {
|
|
3660
|
+
baseUrl,
|
|
3661
|
+
path: "/api/auth/login",
|
|
3662
|
+
method: "POST",
|
|
3663
|
+
timeoutMs,
|
|
3664
|
+
body: JSON.stringify({ username, password }),
|
|
3665
|
+
contentType: "application/json",
|
|
3666
|
+
secrets: [password],
|
|
3667
|
+
onLogin: (data2) => {
|
|
3668
|
+
if (data2.ok !== true) return;
|
|
3669
|
+
session = issuedSession(context, baseUrl, data2);
|
|
3670
|
+
}
|
|
3671
|
+
});
|
|
3672
|
+
if (!session) throw new CliError({ code: "CLI_BAD_RESPONSE", exitCode: EXIT.SERVER, message: "\u767B\u5F55\u54CD\u5E94\u6CA1\u6709\u6709\u6548\u4F1A\u8BDD\uFF0C\u672A\u4FDD\u5B58\u51ED\u636E" });
|
|
3673
|
+
const path = await writeWebState(io, "session.json", session);
|
|
3674
|
+
out.result(["\u7F51\u9875\u767B\u5F55\u6210\u529F", `\u670D\u52A1\u5730\u5740\uFF1A${baseUrl}`, `\u4F1A\u8BDD\u6587\u4EF6\uFF1A${path}`], { ...object(result.data), baseUrl, sessionPath: path });
|
|
3675
|
+
return;
|
|
3676
|
+
}
|
|
3677
|
+
if (action2 === "whoami" || action2 === "logout") {
|
|
3678
|
+
const session = await resolveWebSession(context), workspace2 = workspaceOf(context);
|
|
3679
|
+
if (action2 === "whoami") {
|
|
3680
|
+
const { result } = await webIdentity(context, session, workspace2, timeoutMs);
|
|
3681
|
+
out.result([JSON.stringify(result.data, null, 2)], { ...object(result.data), baseUrl: session.baseUrl, source: session.source });
|
|
3682
|
+
} else {
|
|
3683
|
+
try {
|
|
3684
|
+
await requestWeb(io, { baseUrl: session.baseUrl, token: session.token, path: "/api/auth/logout", method: "POST", timeoutMs });
|
|
3685
|
+
} catch (error) {
|
|
3686
|
+
throw toCliError(error).withHint("\u9000\u51FA\u7ED3\u679C\u672A\u77E5\u6216\u88AB\u62D2\u7EDD\uFF0C\u672C\u5730\u4F1A\u8BDD\u4FDD\u7559\uFF1B\u8BF7\u786E\u8BA4\u670D\u52A1\u5730\u5740\u540E\u91CD\u8BD5\u9000\u51FA\u3002");
|
|
3687
|
+
}
|
|
3688
|
+
await deleteWebSession(io, session);
|
|
3689
|
+
out.result(["\u7F51\u9875\u4F1A\u8BDD\u5DF2\u9000\u51FA"], { loggedOut: true, source: session.source });
|
|
3690
|
+
}
|
|
3691
|
+
return;
|
|
3692
|
+
}
|
|
3693
|
+
const operation = WEB_OPERATIONS.find((item) => item.id === args[1]);
|
|
3694
|
+
if (!operation) throw usageError("\u64CD\u4F5C\u4E0D\u5728\u7F51\u9875\u547D\u4EE4\u76EE\u5F55\u4E2D\uFF0C\u8BF7\u5148\u8FD0\u884C buke web operations");
|
|
3695
|
+
const mutating = operation.method !== "GET";
|
|
3696
|
+
if (mutating && values.yes !== true) throw usageError("\u7F51\u9875\u5199\u64CD\u4F5C\u5FC5\u987B\u6DFB\u52A0 --yes\uFF1B\u8BF7\u5148\u6838\u5BF9\u672C\u6B21\u64CD\u4F5C\u8303\u56F4\u4E0E\u8D39\u7528");
|
|
3697
|
+
const suppliedKey = textOption(values, "idempotency-key");
|
|
3698
|
+
const issueApiKey = operation.method === "POST" && operation.path === "/api/api-keys";
|
|
3699
|
+
const secretOutput = issueApiKey || operation.sensitiveOutput === true;
|
|
3700
|
+
const output = textOption(values, "out");
|
|
3701
|
+
if (secretOutput && !output) throw usageError("\u8BE5\u64CD\u4F5C\u7B7E\u53D1\u5BC6\u94A5\u6216\u79C1\u6709\u94FE\u63A5\uFF0C\u5FC5\u987B\u4F7F\u7528 --out <\u65B0\u6587\u4EF6>\uFF1B\u660E\u6587\u4E0D\u4F1A\u8F93\u51FA\u5230\u7EC8\u7AEF");
|
|
3702
|
+
if (output) await checkWebOutput(output);
|
|
3703
|
+
const params = await optionData(context, "params"), query = await optionData(context, "query"), data = await optionData(context, "data");
|
|
3704
|
+
const bodyKey = operation.idempotencyBodyKey ? data[operation.idempotencyBodyKey] : void 0;
|
|
3705
|
+
if (bodyKey !== void 0 && typeof bodyKey !== "string") throw usageError("\u6B63\u6587\u4E2D\u7684\u5E42\u7B49\u952E\u5FC5\u987B\u662F\u5B57\u7B26\u4E32");
|
|
3706
|
+
if (suppliedKey && bodyKey !== void 0 && suppliedKey !== bodyKey) throw usageError("--idempotency-key \u4E0E\u6B63\u6587\u5E42\u7B49\u952E\u4E0D\u4E00\u81F4\uFF0C\u64CD\u4F5C\u672A\u63D0\u4EA4");
|
|
3707
|
+
const key = mutating ? suppliedKey ?? (typeof bodyKey === "string" ? bodyKey : void 0) ?? randomUUID2() : void 0;
|
|
3708
|
+
if (key && (!/^[A-Za-z0-9_.:-]{1,200}$/u.test(key) || key.startsWith("bk_"))) throw usageError("\u5E42\u7B49\u952E\u683C\u5F0F\u65E0\u6548");
|
|
3709
|
+
if (operation.idempotencyBodyKey && key) data[operation.idempotencyBodyKey] = key;
|
|
3710
|
+
const target = operationPath(operation, params, query);
|
|
3711
|
+
const body = await requestBody(context, operation, data);
|
|
3712
|
+
const businessHeaders = buildBusinessHeaders(operation, await optionData(context, "headers"), body.filename);
|
|
3713
|
+
const requestedWorkspace = workspaceOf(context);
|
|
3714
|
+
let caller;
|
|
3715
|
+
if (operation.public) {
|
|
3716
|
+
if (requestedWorkspace) throw usageError("\u516C\u5F00\u64CD\u4F5C\u4E0D\u63A5\u53D7\u5DE5\u4F5C\u533A\u53C2\u6570");
|
|
3717
|
+
caller = { baseUrl: explicitBaseUrl(context.baseUrl, io.env) ?? DEFAULT_BASE_URL, userId: "public" };
|
|
3718
|
+
} else {
|
|
3719
|
+
const session = await resolveWebSession(context);
|
|
3720
|
+
const identity = await webIdentity(context, session, requestedWorkspace, timeoutMs);
|
|
3721
|
+
caller = { baseUrl: session.baseUrl, token: session.token, userId: identity.userId, workspaceId: identity.workspaceId };
|
|
3722
|
+
}
|
|
3723
|
+
const workspace = caller.workspaceId;
|
|
3724
|
+
const secrets = [...webSecrets(data), ...webSecrets(query), ...webSecrets(params)];
|
|
3725
|
+
for (const secret of secrets) out.protect(secret);
|
|
3726
|
+
if (operation.membershipPaymentOnly) {
|
|
3727
|
+
const id = target.params.id;
|
|
3728
|
+
if (!id) throw usageError("\u4F1A\u5458\u652F\u4ED8\u64CD\u4F5C\u7F3A\u5C11\u8BA2\u5355\u7F16\u53F7");
|
|
3729
|
+
const checked = await requestWeb(io, {
|
|
3730
|
+
baseUrl: caller.baseUrl,
|
|
3731
|
+
token: caller.token,
|
|
3732
|
+
workspaceId: workspace,
|
|
3733
|
+
method: "GET",
|
|
3734
|
+
path: `/api/payments/orders/${encodeURIComponent(id)}`,
|
|
3735
|
+
timeoutMs
|
|
3736
|
+
});
|
|
3737
|
+
const order2 = object(object(checked.data).order);
|
|
3738
|
+
if (order2.id !== id || order2.orderType !== "membership") throw usageError("\u8BE5\u8BA2\u5355\u4E0D\u662F\u4F1A\u5458\u8BA2\u5355\uFF1BCLI \u4E0D\u652F\u6301\u5145\u503C\u53CA\u5176\u652F\u4ED8\u64CD\u4F5C");
|
|
3739
|
+
if (operation.method === "GET" && operation.path === "/api/payments/orders/:id") {
|
|
3740
|
+
const download4 = output ? await saveWebDocument(output, checked.data, io.signal) : void 0;
|
|
3741
|
+
out.result([JSON.stringify(checked.data, null, 2)], { ...checked, ...download4 ? { download: download4 } : {}, operationId: operation.id });
|
|
3742
|
+
return;
|
|
3743
|
+
}
|
|
3744
|
+
}
|
|
3745
|
+
const identityBody = operation.idempotencyBodyKey && body.identity && typeof body.identity === "object" && !Array.isArray(body.identity) ? { ...body.identity, [operation.idempotencyBodyKey]: void 0 } : body.identity;
|
|
3746
|
+
const requestHash = mutating ? await fingerprintWebRequest(
|
|
3747
|
+
io,
|
|
3748
|
+
{ baseUrl: caller.baseUrl, userId: caller.userId },
|
|
3749
|
+
[caller.baseUrl, caller.userId, workspace ?? null, operation.id, target.path, identityBody, businessHeaders]
|
|
3750
|
+
) : void 0;
|
|
3751
|
+
const recordName = `web-request-${requestHash}.json`;
|
|
3752
|
+
let recovery = {
|
|
3753
|
+
operationId: operation.id,
|
|
3754
|
+
baseUrl: caller.baseUrl,
|
|
3755
|
+
userId: caller.userId,
|
|
3756
|
+
...workspace ? { workspaceId: workspace } : {},
|
|
3757
|
+
...key ? { idempotencyKey: key } : {},
|
|
3758
|
+
requestHash,
|
|
3759
|
+
params: redactWebValue(target.params, secrets),
|
|
3760
|
+
operationOutcome: "not_submitted",
|
|
3761
|
+
...mutating ? { requestRecord: webStatePath(io, recordName) } : {}
|
|
3762
|
+
};
|
|
3763
|
+
let finishedAtMs;
|
|
3764
|
+
const persist = async () => {
|
|
3765
|
+
await writeWebState(io, recordName, { version: 1, ...recovery, finishedAtMs });
|
|
3766
|
+
await writeWebState(io, "last-web-request.json", { version: 1, ...recovery, finishedAtMs });
|
|
3767
|
+
};
|
|
3768
|
+
const release2 = mutating ? await lockWebRequest(io, requestHash) : void 0;
|
|
3769
|
+
try {
|
|
3770
|
+
if (mutating) {
|
|
3771
|
+
const previous = await readWebState(io, recordName);
|
|
3772
|
+
const explicitlyChosen = suppliedKey ?? bodyKey;
|
|
3773
|
+
const concurrentCompletion = previous && typeof previous.finishedAtMs === "number" && previous.finishedAtMs >= invocationStartedAt;
|
|
3774
|
+
const sameAttempt = explicitlyChosen === void 0 || explicitlyChosen === previous?.idempotencyKey;
|
|
3775
|
+
if (previous && (concurrentCompletion && sameAttempt || ["unknown", "accepted"].includes(String(previous.operationOutcome)) && (explicitlyChosen === void 0 || explicitlyChosen === previous.idempotencyKey && operation.replaySafe !== true))) {
|
|
3776
|
+
throw usageError(operation.replaySafe === true ? "\u76F8\u540C\u8BF7\u6C42\u5DF2\u6709\u63D0\u4EA4\u8BB0\u5F55\uFF0C\u8BF7\u5148\u67E5\u8BE2\u539F\u64CD\u4F5C\uFF1B\u6062\u590D\u65F6\u4F7F\u7528\u539F\u5E42\u7B49\u952E\u548C\u539F\u53C2\u6570\u6587\u4EF6" : "\u76F8\u540C\u8BF7\u6C42\u5DF2\u6709\u63D0\u4EA4\u8BB0\u5F55\u4E14\u8BE5\u64CD\u4F5C\u4E0D\u652F\u6301\u5B89\u5168\u91CD\u653E\uFF1B\u8BF7\u5148\u67E5\u8BE2\u539F\u8D44\u6E90\u3002\u786E\u9700\u65B0\u5C1D\u8BD5\u65F6\u63D0\u4F9B\u65B0\u5E42\u7B49\u952E\u5E76\u6DFB\u52A0 --yes").withWebRecovery({
|
|
3777
|
+
...recovery,
|
|
3778
|
+
idempotencyKey: String(previous.idempotencyKey),
|
|
3779
|
+
operationOutcome: previous.operationOutcome,
|
|
3780
|
+
...typeof previous.taskId === "string" ? { taskId: previous.taskId } : {}
|
|
3781
|
+
});
|
|
3782
|
+
}
|
|
3783
|
+
recovery.operationOutcome = "unknown";
|
|
3784
|
+
await persist();
|
|
3785
|
+
}
|
|
3786
|
+
try {
|
|
3787
|
+
let authenticated;
|
|
3788
|
+
const result = await requestWeb(io, {
|
|
3789
|
+
baseUrl: caller.baseUrl,
|
|
3790
|
+
token: caller.token,
|
|
3791
|
+
workspaceId: workspace,
|
|
3792
|
+
path: target.path,
|
|
3793
|
+
method: operation.method,
|
|
3794
|
+
body: body.body,
|
|
3795
|
+
contentType: body.contentType,
|
|
3796
|
+
businessHeaders,
|
|
3797
|
+
idempotencyKey: key,
|
|
3798
|
+
timeoutMs,
|
|
3799
|
+
outPath: output,
|
|
3800
|
+
secretOutput,
|
|
3801
|
+
secrets,
|
|
3802
|
+
expectedFile: !secretOutput && (fileOperation(operation) || /\.(?:mp4|mov|webm|png|jpe?g|webp|mp3|wav|pdf|zip|vtt|srt)$/iu.test(output ?? "")),
|
|
3803
|
+
sessionResponse: operation.sessionResponse,
|
|
3804
|
+
onLogin: (response) => {
|
|
3805
|
+
authenticated = issuedSession(context, caller.baseUrl, response);
|
|
3806
|
+
},
|
|
3807
|
+
onTaskId: (taskId) => {
|
|
3808
|
+
recovery = { ...recovery, taskId, operationOutcome: "accepted" };
|
|
3809
|
+
},
|
|
3810
|
+
onEvent: (event) => {
|
|
3811
|
+
if (!out.json) out.notice(singleLine(JSON.stringify(event)));
|
|
3812
|
+
}
|
|
3813
|
+
});
|
|
3814
|
+
if (authenticated) await writeWebState(io, "session.json", authenticated);
|
|
3815
|
+
recovery.operationOutcome = result.status === 202 || recovery.operationOutcome === "accepted" ? "accepted" : "completed";
|
|
3816
|
+
finishedAtMs = performance.timeOrigin + performance.now();
|
|
3817
|
+
if (mutating) await persist().catch(() => out.notice("\u64CD\u4F5C\u5DF2\u5B8C\u6210\uFF0C\u4F46\u672C\u5730\u6062\u590D\u8BB0\u5F55\u66F4\u65B0\u5931\u8D25\uFF1B\u8BF7\u4FDD\u5B58\u672C\u6B21\u7ED3\u679C\u4E0E\u5E42\u7B49\u952E\u3002"));
|
|
3818
|
+
const document = {
|
|
3819
|
+
...result,
|
|
3820
|
+
...key ? { idempotencyKey: key } : {},
|
|
3821
|
+
operationId: operation.id,
|
|
3822
|
+
...recovery.taskId ? { taskId: recovery.taskId } : {}
|
|
3823
|
+
};
|
|
3824
|
+
out.result([JSON.stringify(redactWebValue(document, caller.token ? [caller.token] : []), null, 2)], document);
|
|
3825
|
+
} catch (error) {
|
|
3826
|
+
const failure = toCliError(error);
|
|
3827
|
+
if (recovery.operationOutcome !== "accepted") recovery.operationOutcome = failure.httpStatus !== void 0 && failure.httpStatus >= 400 && failure.httpStatus < 500 && failure.httpStatus !== 408 ? "rejected" : "unknown";
|
|
3828
|
+
finishedAtMs = performance.timeOrigin + performance.now();
|
|
3829
|
+
if (mutating) await persist().catch(() => void 0);
|
|
3830
|
+
throw failure.withWebRecovery(recovery);
|
|
3831
|
+
}
|
|
3832
|
+
} finally {
|
|
3833
|
+
await release2?.();
|
|
3834
|
+
}
|
|
3835
|
+
}
|
|
3836
|
+
|
|
3837
|
+
// src/commands/studio-actions.ts
|
|
3838
|
+
import { basename as basename4 } from "node:path";
|
|
3839
|
+
|
|
2342
3840
|
// src/client-creative.ts
|
|
2343
3841
|
function creativePath(resource, id, suffix = "") {
|
|
2344
3842
|
const prefix = resource === "drama" ? "drama/orders" : resource;
|
|
@@ -2384,13 +3882,13 @@ function idOf(context) {
|
|
|
2384
3882
|
return id.trim();
|
|
2385
3883
|
}
|
|
2386
3884
|
async function dramaCreative(context) {
|
|
2387
|
-
const [
|
|
3885
|
+
const [action2] = context.args;
|
|
2388
3886
|
const id = idOf(context);
|
|
2389
3887
|
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
2390
3888
|
const { io, out, values } = context;
|
|
2391
|
-
if (["context", "director", "document", "versions"].includes(
|
|
2392
|
-
let suffix2 =
|
|
2393
|
-
if (
|
|
3889
|
+
if (["context", "director", "document", "versions"].includes(action2)) {
|
|
3890
|
+
let suffix2 = action2;
|
|
3891
|
+
if (action2 === "document") {
|
|
2394
3892
|
const query = new URLSearchParams({ kind: textOption(values, "kind") ?? "screenplay_snapshot" });
|
|
2395
3893
|
const episode = textOption(values, "episode-number");
|
|
2396
3894
|
if (episode) query.set("episodeNumber", episode);
|
|
@@ -2401,7 +3899,7 @@ async function dramaCreative(context) {
|
|
|
2401
3899
|
return;
|
|
2402
3900
|
}
|
|
2403
3901
|
const body = await creativeData(context);
|
|
2404
|
-
if (
|
|
3902
|
+
if (action2 === "director-confirm") {
|
|
2405
3903
|
const confirmationId = textOption(values, "confirmation-id") ?? body.confirmationId;
|
|
2406
3904
|
const suppliedKind = textOption(values, "kind") ?? body.kind;
|
|
2407
3905
|
if (typeof confirmationId !== "string" || !confirmationId) throw usageError("\u8BF7\u4F7F\u7528 drama director \u4E2D\u5F53\u524D\u786E\u8BA4\u5361\u7684 --confirmation-id");
|
|
@@ -2431,7 +3929,7 @@ async function dramaCreative(context) {
|
|
|
2431
3929
|
throw failure.withRecovery({ ...dramaConfirmationRecovery(id, void 0, baseUrl, key2, "unknown"), ...failure.recovery, confirmation: { kind, confirmationId } });
|
|
2432
3930
|
}
|
|
2433
3931
|
}
|
|
2434
|
-
if (
|
|
3932
|
+
if (action2 === "redo") {
|
|
2435
3933
|
if (values.yes !== true) throw usageError("\u8865\u505A\u4F1A\u6309\u65B0\u62A5\u4EF7\u6536\u53D6\u8D39\u7528\uFF0C\u8BF7\u5148\u6267\u884C redo-quote\uFF0C\u6838\u5BF9\u62A5\u4EF7\u540E\u6DFB\u52A0 --yes");
|
|
2436
3934
|
const quote3 = body.quote && typeof body.quote === "object" ? creativeObject(body.quote) : body;
|
|
2437
3935
|
const required3 = ["redoQuoteId", "redoPlanHash", "redoQuoteHash"];
|
|
@@ -2444,22 +3942,22 @@ async function dramaCreative(context) {
|
|
|
2444
3942
|
const epoch = textOption(values, "expected-epoch");
|
|
2445
3943
|
if (epoch !== void 0) body.expectedProductionEpoch = Number(epoch);
|
|
2446
3944
|
if (!Number.isInteger(body.expectedProductionEpoch) || Number(body.expectedProductionEpoch) < 0) throw usageError("\u8BF7\u5148\u8FD0\u884C drama context\uFF0C\u63D0\u4F9B --expected-epoch \u6216\u5728 --data \u4E2D\u586B\u5199 expectedProductionEpoch");
|
|
2447
|
-
let suffix =
|
|
2448
|
-
if (
|
|
3945
|
+
let suffix = action2;
|
|
3946
|
+
if (action2 === "message") {
|
|
2449
3947
|
const text = textOption(values, "text");
|
|
2450
3948
|
if (text !== void 0) body.text = text;
|
|
2451
3949
|
if (typeof body.text !== "string" || !body.text.trim()) throw usageError("\u8BF7\u63D0\u4F9B --text \u6216 --data.text");
|
|
2452
3950
|
suffix = "messages";
|
|
2453
|
-
} else if (
|
|
3951
|
+
} else if (action2 === "spec") {
|
|
2454
3952
|
const model = textOption(values, "model"), resolution = textOption(values, "resolution");
|
|
2455
3953
|
if (model !== void 0) body.videoModel = model;
|
|
2456
3954
|
if (resolution !== void 0) body.resolution = resolution;
|
|
2457
|
-
} else if (
|
|
3955
|
+
} else if (action2 === "select-version") {
|
|
2458
3956
|
body.shotId = textOption(values, "shot") ?? body.shotId;
|
|
2459
3957
|
const selected = textOption(values, "output-id");
|
|
2460
3958
|
if (selected !== void 0) body.renderOutputId = selected === "default" ? null : selected;
|
|
2461
3959
|
suffix = "selection";
|
|
2462
|
-
} else if (
|
|
3960
|
+
} else if (action2 === "redo-quote") {
|
|
2463
3961
|
const shot = textOption(values, "shot");
|
|
2464
3962
|
if (shot !== void 0) body.shotIds = shot.split(",").map((value) => value.trim());
|
|
2465
3963
|
suffix = "redo/quote";
|
|
@@ -2476,23 +3974,325 @@ async function creativeDownload(context, resource, id, suffix) {
|
|
|
2476
3974
|
context.out.result([`\u5DF2\u4E0B\u8F7D\uFF1A${singleLine(saved.path)}`, `\u5927\u5C0F\uFF1A${saved.bytes} \u5B57\u8282`, `\u6821\u9A8C\uFF1Asha256 ${saved.sha256}`], { download: { ...saved, filename } });
|
|
2477
3975
|
}
|
|
2478
3976
|
|
|
3977
|
+
// src/commands/studio-actions.ts
|
|
3978
|
+
var video = "/api/open/v1/videos/:id";
|
|
3979
|
+
var drama = "/api/open/v1/drama/orders/:id";
|
|
3980
|
+
var pagination = { limit: "limit", offset: "offset", cursor: "cursor" };
|
|
3981
|
+
var action = (resource, command, path, method, description, extra = {}) => ({ resource, command, path, method, description, needsYes: method !== "GET", ...extra });
|
|
3982
|
+
var v = (command, suffix, method, description, extra = {}) => action("videos", command, `${video}/${suffix}`, method, description, extra);
|
|
3983
|
+
var STUDIO_ACTIONS = [
|
|
3984
|
+
action("videos", "list", "/api/open/v1/videos", "GET", "\u5217\u51FA\u5546\u54C1\u89C6\u9891", { query: { limit: "limit", cursor: "cursor", actionable: "actionable" } }),
|
|
3985
|
+
...["methods", "play-cards", "inspirations"].map((kind) => action("videos", kind, `/api/open/v1/video-catalog/${kind}`, "GET", "\u67E5\u8BE2\u521B\u4F5C\u76EE\u5F55")),
|
|
3986
|
+
v("settings", "settings", "POST", "\u4FEE\u6539\u5F53\u524D\u89C4\u683C", { body: ["expectedVersion", "patch"] }),
|
|
3987
|
+
v("retry", "retry-failed-step", "POST", "\u6062\u590D\u672A\u5B8C\u6210\u6B65\u9AA4\u6216\u786E\u8BA4\u5173\u952E\u5E27\u91CD\u505A", { body: ["expectedVersion"] }),
|
|
3988
|
+
v("product-image-resume", "product-image-resume", "POST", "\u8865\u5145\u4EA7\u54C1\u56FE\u540E\u6062\u590D", { body: ["expectedVersion"] }),
|
|
3989
|
+
v("product-lock-confirm", "product-lock-confirm", "POST", "\u786E\u8BA4\u672C\u5355\u5546\u54C1\u5916\u89C2", { body: ["expectedVersion"] }),
|
|
3990
|
+
v("asset-options", "asset-gaps/:gapId/options", "GET", "\u67E5\u8BE2\u7D20\u6750\u804C\u8D23\u7684\u5019\u9009", { query: { ...pagination, q: "q", source: "source", "asset-id": "assetId" } }),
|
|
3991
|
+
v("asset-resolve", "asset-gaps/:gapId/resolve", "POST", "\u6309\u5F53\u524D\u804C\u8D23\u9009\u7D20\u6750\u6216\u786E\u8BA4\u751F\u6210", { body: ["action", "expectedVersion"] }),
|
|
3992
|
+
v("asset-resolve-batch", "asset-gaps/resolve-batch", "POST", "\u6279\u91CF\u91C7\u7528\u73B0\u6709\u804C\u8D23\u7D20\u6750", { body: ["expectedVersion", "items"] }),
|
|
3993
|
+
v("asset-upload", "asset-gaps/:gapId/upload", "PUT", "\u4E0A\u4F20\u672C\u5355\u804C\u8D23\u7D20\u6750", { fileType: "image", query: { "expected-version": "expectedVersion" } }),
|
|
3994
|
+
v("asset-adopt", "asset-gaps/:gapId/adopt-uploaded", "POST", "\u91C7\u7528\u672C\u5355\u5DF2\u4E0A\u4F20\u7D20\u6750", { body: ["expectedVersion", "kind", "id"] }),
|
|
3995
|
+
v("file", "files/:path", "GET", "\u8BFB\u53D6\u5F53\u524D\u6587\u7A3F"),
|
|
3996
|
+
v("file-versions", "files/:path/versions", "GET", "\u5217\u51FA\u6587\u7A3F\u5386\u53F2", { query: { limit: "limit", cursor: "cursor" } }),
|
|
3997
|
+
v("file-version", "files/:path/versions/:versionId", "GET", "\u8BFB\u53D6\u4E00\u7248\u6587\u7A3F"),
|
|
3998
|
+
v("file-compare", "files/:path/versions/compare", "GET", "\u6BD4\u8F83\u4E24\u7248\u6587\u7A3F", { query: { "base-version": "baseVersionId", "target-version": "targetVersionId", cursor: "cursor" } }),
|
|
3999
|
+
v("file-restore", "files/:path/versions/:versionId/restore", "POST", "\u6062\u590D\u6307\u5B9A\u6587\u7A3F\u7248\u672C", { body: ["expectedCurrentVersionId"] }),
|
|
4000
|
+
v("confirm-image", "confirm-image", "POST", "\u6309\u5F53\u524D\u56FE\u5361\u660E\u786E\u786E\u8BA4\u751F\u6210", { body: ["expectedVersion", "confirmation"], confirmation: true }),
|
|
4001
|
+
v("subtitles", "subtitles", "GET", "\u67E5\u8BE2\u6574\u7247\u5B57\u5E55\u5F00\u5173"),
|
|
4002
|
+
v("subtitles-set", "subtitles", "PUT", "\u8BBE\u7F6E\u6574\u7247\u5B57\u5E55\u5F00\u5173", { body: ["enabled"] }),
|
|
4003
|
+
v("production-preview", "production-preview", "GET", "\u67E5\u770B\u5F53\u524D\u5F00\u62CD\u5361\u7684\u9010\u6BB5\u9884\u89C8"),
|
|
4004
|
+
v("public-references", "public-reference-candidates", "GET", "\u67E5\u770B\u516C\u5F00\u53C2\u8003\u5019\u9009"),
|
|
4005
|
+
v("public-reference-decide", "public-reference-candidates/:assetId/decision", "PUT", "\u786E\u8BA4\u6216\u62D2\u7EDD\u516C\u5F00\u53C2\u8003", { body: ["decision", "expectedVersion"] }),
|
|
4006
|
+
v("voices", "voice-candidates", "GET", "\u67E5\u770B\u89D2\u8272\u58F0\u97F3\u5019\u9009"),
|
|
4007
|
+
v("platform-voices", "platform-voices", "GET", "\u67E5\u770B\u5E73\u53F0\u58F0\u97F3"),
|
|
4008
|
+
v("voice-import", "voice-candidates", "POST", "\u5BFC\u5165\u5DF2\u6709\u58F0\u97F3\u6765\u6E90", { fileType: "voice" }),
|
|
4009
|
+
v("voice-preset", "voice-candidates/preset", "POST", "\u91C7\u7528\u5E73\u53F0\u6837\u97F3\u6216\u7533\u8BF7\u8BD5\u542C", { body: ["voiceId"] }),
|
|
4010
|
+
v("voice-select", "voice-selection", "PUT", "\u9009\u62E9\u6216\u53D6\u6D88\u89D2\u8272\u58F0\u97F3", { body: ["roleKey", "candidateId", "expectedVersion"] }),
|
|
4011
|
+
v("voice-continue", "voice-selection/continue", "POST", "\u6309\u5DF2\u9009\u58F0\u97F3\u7EE7\u7EED", { body: ["expectedVersion"] }),
|
|
4012
|
+
v("motion-references", "motion-references", "GET", "\u67E5\u770B\u52A8\u4F5C\u53C2\u8003"),
|
|
4013
|
+
v("motion-prepare", "motion-references", "POST", "\u88C1\u526A\u5DF2\u4E0A\u4F20\u7684\u52A8\u4F5C\u53C2\u8003", { body: ["attachmentId", "startSeconds", "endSeconds"] }),
|
|
4014
|
+
v("motion-select", "motion-references/:candidateId/select", "POST", "\u5C06\u52A8\u4F5C\u53C2\u8003\u7ED1\u5B9A\u5F53\u524D\u955C\u5934", { body: ["shotIds"] }),
|
|
4015
|
+
v("image-edits", "image-edits", "GET", "\u5217\u51FA\u56FE\u7247\u7F16\u8F91\u548C\u5C40\u90E8\u4FEE\u6539\u4EFB\u52A1"),
|
|
4016
|
+
v("image-edit-save", "image-edits/:sourceKind/:sourceId", "PUT", "\u4FDD\u5B58\u672C\u5730\u7F16\u8F91\u540E\u7684\u56FE\u7247", { fileType: "image" }),
|
|
4017
|
+
v("area-quote", "image-edits/area/quote", "POST", "\u4E3A\u8499\u7248\u9009\u533A\u4FEE\u6539\u62A5\u4EF7", { fileType: "mask", body: ["sourceKind", "sourceId", "prompt"] }),
|
|
4018
|
+
v("area-status", "image-edits/area/:quoteId", "GET", "\u67E5\u8BE2\u9009\u533A\u62A5\u4EF7\u53CA\u5236\u4F5C\u72B6\u6001"),
|
|
4019
|
+
v("area-confirm", "image-edits/area/confirm", "POST", "\u786E\u8BA4\u5F53\u524D\u9009\u533A\u62A5\u4EF7", { body: ["quoteId"], confirmation: true }),
|
|
4020
|
+
v("append-retry-join", "append-tasks/:taskId/retry-join", "POST", "\u6062\u590D\u5DF2\u6709\u63D2\u7247\u7684\u514D\u8D39\u62FC\u63A5"),
|
|
4021
|
+
v("stop", "stop", "POST", "\u8BF7\u6C42\u505C\u6B62\u5C1A\u672A\u6267\u884C\u7684\u540E\u7EED\u6B65\u9AA4"),
|
|
4022
|
+
v("events", "live", "GET", "\u8BA2\u9605\u6709\u754C\u5B9E\u65F6\u8FDB\u5EA6", { events: true }),
|
|
4023
|
+
v("message-stream", "messages/stream", "POST", "\u53D1\u9001\u6D88\u606F\u5E76\u8BA2\u9605\u56DE\u5408\u4E8B\u4EF6", { events: true, body: ["text"] }),
|
|
4024
|
+
...[
|
|
4025
|
+
["storyboard-download", "storyboards/:imageKey/download", "image", "\u4E0B\u8F7D\u5173\u952E\u5E27"],
|
|
4026
|
+
["image-download", "images/:assetId/download", "image", "\u4E0B\u8F7D\u4EBA\u7269\u6216\u573A\u666F\u56FE\u7247"],
|
|
4027
|
+
["image-edit-download", "image-edits/:editId/download", "image", "\u4E0B\u8F7D\u56FE\u7247\u7F16\u8F91\u7248"],
|
|
4028
|
+
["area-mask", "image-edits/area/:quoteId/mask", "image", "\u4E0B\u8F7D\u9009\u533A\u8499\u7248"],
|
|
4029
|
+
["area-preview", "image-edits/area/:jobId/preview", "image", "\u4E0B\u8F7D\u5C40\u90E8\u4FEE\u6539\u9884\u89C8"],
|
|
4030
|
+
["edit-subtitles", "edits/:editId/subtitles", "vtt", "\u4E0B\u8F7D\u526A\u8F91\u7248\u5B57\u5E55"],
|
|
4031
|
+
["platform-voice-download", "platform-voices/:voiceId/audio", "audio", "\u4E0B\u8F7D\u5E73\u53F0\u58F0\u97F3\u8BD5\u542C"],
|
|
4032
|
+
["voice-sample-download", "voice-presets/:voiceId/sample", "audio", "\u4E0B\u8F7D\u5E73\u53F0\u6837\u97F3"],
|
|
4033
|
+
["voice-library-download", "voice-library/:candidateId/audio", "audio", "\u4E0B\u8F7D\u58F0\u97F3\u5E93\u7D20\u6750"],
|
|
4034
|
+
["voice-download", "voice-candidates/:candidateId/audio", "audio", "\u4E0B\u8F7D\u5019\u9009\u58F0\u97F3"],
|
|
4035
|
+
["voice-preview-download", "voiceover/previews/:previewId/audio", "audio", "\u4E0B\u8F7D\u914D\u97F3\u8BD5\u542C"],
|
|
4036
|
+
["motion-download", "motion-references/:candidateId/video", "video", "\u4E0B\u8F7D\u52A8\u4F5C\u53C2\u8003\u7247\u6BB5"],
|
|
4037
|
+
["segment-download", "production-segments/:index/download", "video", "\u4E0B\u8F7D\u5DF2\u5B8C\u6210\u5236\u4F5C\u7247\u6BB5"]
|
|
4038
|
+
].map(([command, path, download4, description]) => v(command, path, "GET", description, { download: download4 })),
|
|
4039
|
+
action("graphic", "stop", "/api/open/v1/graphic/runs/:id/stop", "POST", "\u505C\u6B62\u5F53\u524D\u56FE\u6587\u5BFC\u6F14\u56DE\u5408"),
|
|
4040
|
+
action("drama", "stop", `${drama}/director/stop`, "POST", "\u505C\u6B62\u5F53\u524D\u77ED\u5267\u5BFC\u6F14\u56DE\u5408"),
|
|
4041
|
+
action("drama", "script-versions", `${drama}/screenplay/versions`, "GET", "\u5217\u51FA\u5267\u672C\u6587\u7A3F\u7248\u672C", { query: { limit: "limit" } }),
|
|
4042
|
+
action("drama", "script-version", `${drama}/screenplay/versions/:documentId`, "GET", "\u67E5\u770B\u4E00\u7248\u5267\u672C\u6587\u7A3F"),
|
|
4043
|
+
action("drama", "script-compare", `${drama}/screenplay/versions/compare`, "GET", "\u6BD4\u8F83\u4E24\u7248\u5267\u672C\u6587\u7A3F", { query: { "base-version": "baseDocumentId", "target-version": "targetDocumentId", "max-changes": "maxChanges" } }),
|
|
4044
|
+
action("drama", "script-restore", `${drama}/screenplay/versions/:documentId/restore`, "POST", "\u6062\u590D\u6307\u5B9A\u5267\u672C\u6587\u7A3F", { body: ["expectedCurrentDocumentId", "expectedProductionEpoch"] }),
|
|
4045
|
+
action("drama", "edit-sources", `${drama}/edit-sources`, "GET", "\u67E5\u8BE2\u53EF\u526A\u8F91\u7684\u539F\u7247", { query: { "source-output-id": "sourceEpisodeOutputId" } }),
|
|
4046
|
+
action("drama", "speech-adoptions", `${drama}/speech/adoptions`, "GET", "\u67E5\u8BE2\u5DF2\u91C7\u7528\u7684\u914D\u97F3"),
|
|
4047
|
+
action("drama", "edit-subtitles", `${drama}/edits/:editId/subtitles`, "GET", "\u4E0B\u8F7D\u77ED\u5267\u526A\u8F91\u7248\u5B57\u5E55", { download: "vtt" }),
|
|
4048
|
+
action("series", "outline", "/api/open/v1/series/:id/outline", "GET", "\u67E5\u770B\u5267\u96C6\u5927\u7EB2"),
|
|
4049
|
+
action("series", "outline-approve", "/api/open/v1/series/:id/outline/:documentId/approve", "POST", "\u786E\u8BA4\u5927\u7EB2\u5E76\u7EE7\u7EED\u51C6\u5907", { body: ["expectedProductionEpoch"] })
|
|
4050
|
+
];
|
|
4051
|
+
var pathOptions = {
|
|
4052
|
+
gapId: "gap-id",
|
|
4053
|
+
path: "path",
|
|
4054
|
+
versionId: "version-id",
|
|
4055
|
+
candidateId: "candidate-id",
|
|
4056
|
+
taskId: "task-id",
|
|
4057
|
+
documentId: "document-id",
|
|
4058
|
+
assetId: "asset-id",
|
|
4059
|
+
sourceKind: "source-kind",
|
|
4060
|
+
sourceId: "source-id",
|
|
4061
|
+
quoteId: "quote-id",
|
|
4062
|
+
editId: "edit-id",
|
|
4063
|
+
imageKey: "image-key",
|
|
4064
|
+
jobId: "job-id",
|
|
4065
|
+
voiceId: "voice-id",
|
|
4066
|
+
previewId: "preview-id",
|
|
4067
|
+
index: "index"
|
|
4068
|
+
};
|
|
4069
|
+
var STUDIO_ACTION_OPTIONS = [.../* @__PURE__ */ new Set([
|
|
4070
|
+
"yes",
|
|
4071
|
+
"data",
|
|
4072
|
+
"file",
|
|
4073
|
+
"mime",
|
|
4074
|
+
"out",
|
|
4075
|
+
"idempotency-key",
|
|
4076
|
+
"timeout",
|
|
4077
|
+
"text",
|
|
4078
|
+
"expected-version",
|
|
4079
|
+
"expected-epoch",
|
|
4080
|
+
"expected-current-version",
|
|
4081
|
+
"expected-current-document",
|
|
4082
|
+
"expected-credits",
|
|
4083
|
+
"enabled",
|
|
4084
|
+
...Object.values(pathOptions),
|
|
4085
|
+
...STUDIO_ACTIONS.flatMap((item) => Object.keys(item.query ?? {}))
|
|
4086
|
+
])];
|
|
4087
|
+
function STUDIO_ACTION_HELP(resource) {
|
|
4088
|
+
return [
|
|
4089
|
+
"",
|
|
4090
|
+
"\u5DE5\u4F5C\u53F0\u6269\u5C55\u547D\u4EE4\uFF1A",
|
|
4091
|
+
...STUDIO_ACTIONS.filter((item) => item.resource === resource).map((item) => ` buke ${resource} ${item.command}${item.path.includes(":id") ? " <id>" : ""} ${[...item.path.matchAll(/:([A-Za-z]+)/gu)].filter((match) => match[1] !== "id").map((match) => `--${pathOptions[match[1]] ?? match[1]} <\u503C>`).join(" ")}${item.needsYes ? " --yes" : ""} ${item.description}`),
|
|
4092
|
+
" --data <JSON\u6587\u4EF6> \u8BF7\u6C42\u6B63\u6587\uFF1B--file <\u6587\u4EF6> \u4E0A\u4F20\uFF1B--out <\u8DEF\u5F84> \u4E0B\u8F7D\uFF1B--timeout <\u79D2> \u6709\u754C\u7B49\u5F85",
|
|
4093
|
+
" \u5199\u5165\u9700 --yes\uFF1B\u6536\u8D39\u786E\u8BA4\u5FC5\u987B\u63D0\u4F9B\u5DF2\u67E5\u770B\u7684\u62A5\u4EF7\u8EAB\u4EFD\uFF0CCLI \u4E0D\u81EA\u52A8\u63A5\u53D7\u65B0\u62A5\u4EF7\u3002"
|
|
4094
|
+
].join("\n");
|
|
4095
|
+
}
|
|
4096
|
+
function segment(value, label) {
|
|
4097
|
+
if (!value?.trim() || value === "." || value === ".." || new RegExp("\\p{Cc}", "u").test(value) || value.length > 512) throw usageError(`\u8BF7\u63D0\u4F9B\u6709\u6548\u7684 ${label}`);
|
|
4098
|
+
return encodeURIComponent(value);
|
|
4099
|
+
}
|
|
4100
|
+
function numberOption(context, name2) {
|
|
4101
|
+
const value = textOption(context.values, name2);
|
|
4102
|
+
if (value === void 0) return void 0;
|
|
4103
|
+
const number = Number(value);
|
|
4104
|
+
if (!Number.isSafeInteger(number) || number < 0) throw usageError(`--${name2} \u5FC5\u987B\u4E3A\u975E\u8D1F\u6574\u6570`);
|
|
4105
|
+
return number;
|
|
4106
|
+
}
|
|
4107
|
+
function requestPath(spec, context) {
|
|
4108
|
+
const path = spec.path.replace(/:([A-Za-z]+)/gu, (_match, name2) => segment(name2 === "id" ? context.args[1] : textOption(context.values, pathOptions[name2] ?? name2), name2 === "id" ? "\u9879\u76EE\u7F16\u53F7" : `--${pathOptions[name2] ?? name2}`));
|
|
4109
|
+
const query = new URLSearchParams();
|
|
4110
|
+
for (const [option, field] of Object.entries(spec.query ?? {})) {
|
|
4111
|
+
const value = textOption(context.values, option);
|
|
4112
|
+
if (value !== void 0) query.set(field, value);
|
|
4113
|
+
}
|
|
4114
|
+
if ((spec.command === "file-compare" || spec.command === "script-compare") && (!textOption(context.values, "base-version") || !textOption(context.values, "target-version"))) throw usageError("\u6BD4\u8F83\u7248\u672C\u9700\u8981 --base-version \u548C --target-version");
|
|
4115
|
+
if (spec.command === "asset-upload" && textOption(context.values, "expected-version") === void 0) throw usageError("\u4E0A\u4F20\u804C\u8D23\u7D20\u6750\u9700\u8981 --expected-version");
|
|
4116
|
+
return path + (query.size ? `?${query}` : "");
|
|
4117
|
+
}
|
|
4118
|
+
async function requestBody2(spec, context) {
|
|
4119
|
+
const body = await creativeData(context);
|
|
4120
|
+
for (const field of ["ownerId", "workspaceId", "allowPaidConfirmation"]) if (field in body) throw usageError(`--data \u4E0D\u80FD\u63D0\u4F9B ${field}\uFF1B\u5F52\u5C5E\u53CA\u6388\u6743\u7531\u5BC6\u94A5\u51B3\u5B9A`);
|
|
4121
|
+
for (const [option, field] of [["expected-version", "expectedVersion"], ["expected-epoch", "expectedProductionEpoch"], ["expected-credits", "expectedCredits"]]) {
|
|
4122
|
+
const value = numberOption(context, option);
|
|
4123
|
+
if (value !== void 0) body[field] = value;
|
|
4124
|
+
}
|
|
4125
|
+
for (const [option, field] of [["text", "text"], ["quote-id", "quoteId"], ["expected-current-version", "expectedCurrentVersionId"], ["expected-current-document", "expectedCurrentDocumentId"]]) {
|
|
4126
|
+
const value = textOption(context.values, option);
|
|
4127
|
+
if (value !== void 0) body[field] = value;
|
|
4128
|
+
}
|
|
4129
|
+
if (spec.command === "subtitles-set") {
|
|
4130
|
+
const enabled2 = textOption(context.values, "enabled");
|
|
4131
|
+
if (enabled2 !== void 0) {
|
|
4132
|
+
if (enabled2 !== "true" && enabled2 !== "false") throw usageError("--enabled \u53EA\u80FD\u662F true \u6216 false");
|
|
4133
|
+
body.enabled = enabled2 === "true";
|
|
4134
|
+
}
|
|
4135
|
+
}
|
|
4136
|
+
for (const field of spec.body ?? []) if (!(field in body)) throw usageError(`\u8BF7\u5728 --data \u4E2D\u63D0\u4F9B ${field}`);
|
|
4137
|
+
if (spec.confirmation || spec.command === "retry" && body.storyboardTaskId || spec.command === "asset-resolve" && body.action === "generate_personal") body.confirmed = true;
|
|
4138
|
+
if (spec.command === "retry" && body.storyboardTaskId || spec.command === "asset-resolve" && body.action === "generate_personal") {
|
|
4139
|
+
if (!Number.isSafeInteger(body.expectedCredits) || Number(body.expectedCredits) <= 0) throw usageError("\u6536\u8D39\u64CD\u4F5C\u5FC5\u987B\u63D0\u4F9B\u5F53\u524D\u5361\u4E0A\u7684 expectedCredits");
|
|
4140
|
+
}
|
|
4141
|
+
return body;
|
|
4142
|
+
}
|
|
4143
|
+
var mimeTypes = {
|
|
4144
|
+
image: ["image/png", "image/jpeg", "image/webp"],
|
|
4145
|
+
video: ["video/mp4", "video/quicktime"],
|
|
4146
|
+
audio: ["audio/wav", "audio/x-wav", "audio/mpeg", "audio/mp4", "audio/aac", "audio/ogg"],
|
|
4147
|
+
vtt: ["text/vtt", "application/x-subrip"]
|
|
4148
|
+
};
|
|
4149
|
+
async function tryStudioAction(resource, context) {
|
|
4150
|
+
const spec = STUDIO_ACTIONS.find((item) => item.resource === resource && item.command === context.args[0]);
|
|
4151
|
+
if (!spec) return false;
|
|
4152
|
+
if (spec.needsYes && context.values.yes !== true) throw usageError("\u8BF7\u5148\u6838\u5BF9\u64CD\u4F5C\u8303\u56F4\u548C\u8D39\u7528\uFF0C\u6DFB\u52A0 --yes \u540E\u63D0\u4EA4");
|
|
4153
|
+
const path = requestPath(spec, context);
|
|
4154
|
+
const body = spec.method !== "GET" ? await requestBody2(spec, context) : {};
|
|
4155
|
+
const filePath = textOption(context.values, "file");
|
|
4156
|
+
if (spec.fileType && spec.fileType !== "voice" && !filePath) throw usageError("\u8BF7\u63D0\u4F9B --file <\u672C\u5730\u6587\u4EF6>");
|
|
4157
|
+
const upload3 = spec.fileType && filePath ? await readUploadFile(filePath) : void 0;
|
|
4158
|
+
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
4159
|
+
const id = context.args[1] ?? "", key = spec.method === "GET" ? void 0 : idempotencyKeyOf(context.values);
|
|
4160
|
+
const perform = async () => {
|
|
4161
|
+
if (spec.events) return studioEvents(baseUrl, apiKey, path, spec.method, body, key, context);
|
|
4162
|
+
if (spec.download) {
|
|
4163
|
+
const file = await downloadAssetFile(baseUrl, apiKey, path, context.io, { allowedMimeTypes: mimeTypes[spec.download] });
|
|
4164
|
+
const filename = file.filename ?? `${resource}-${spec.command}-${id || "output"}.${spec.download === "vtt" ? "vtt" : spec.download === "audio" ? "wav" : spec.download === "video" ? "mp4" : "png"}`;
|
|
4165
|
+
const download4 = await saveDownload(textOption(context.values, "out") ?? filename, file.bytes);
|
|
4166
|
+
return { download: { ...download4, filename } };
|
|
4167
|
+
}
|
|
4168
|
+
let response;
|
|
4169
|
+
if (spec.method === "GET") response = await getJson(baseUrl, apiKey, path, context.io);
|
|
4170
|
+
else if (upload3) {
|
|
4171
|
+
let bytes = upload3.bytes, contentType = textOption(context.values, "mime") ?? upload3.contentType;
|
|
4172
|
+
if (spec.fileType === "mask" || spec.fileType === "voice") {
|
|
4173
|
+
const form = new FormData();
|
|
4174
|
+
form.set(spec.fileType === "mask" ? "mask" : "file", new Blob([new Uint8Array(upload3.bytes)], { type: contentType ?? "application/octet-stream" }), basename4(filePath));
|
|
4175
|
+
for (const [name2, value] of Object.entries(body)) if (value !== void 0 && value !== null) form.set(name2, typeof value === "object" ? JSON.stringify(value) : String(value));
|
|
4176
|
+
const prepared = new Request("https://multipart.invalid", { method: "POST", body: form });
|
|
4177
|
+
bytes = new Uint8Array(await prepared.arrayBuffer());
|
|
4178
|
+
contentType = prepared.headers.get("content-type");
|
|
4179
|
+
}
|
|
4180
|
+
response = await (spec.method === "PUT" ? putRaw : postRaw)(baseUrl, apiKey, path, bytes, contentType, key, context.io);
|
|
4181
|
+
} else if (spec.method === "PUT") response = await putRaw(baseUrl, apiKey, path, Buffer.from(JSON.stringify(body)), "application/json", key, context.io);
|
|
4182
|
+
else response = await postJson(baseUrl, apiKey, path, body, key, context.io, { timeoutMs: timeoutSecondsOf(context.values, 120) * 1e3 });
|
|
4183
|
+
if (!response.body || typeof response.body !== "object" || Array.isArray(response.body)) throw new CliError({ code: "CLI_BAD_RESPONSE", message: "\u670D\u52A1\u7AEF\u6CA1\u6709\u8FD4\u56DE\u6709\u6548\u5BF9\u8C61", exitCode: EXIT.SERVER });
|
|
4184
|
+
return response.body;
|
|
4185
|
+
};
|
|
4186
|
+
const result = key ? await retainMutationOnError(resource, id, key, baseUrl, perform) : await perform();
|
|
4187
|
+
const output = { ...result, ...key ? { idempotencyKey: key } : {} };
|
|
4188
|
+
context.out.result([JSON.stringify(result, null, 2), ...key ? [`\u5E42\u7B49\u952E\uFF1A${key}`] : []], output);
|
|
4189
|
+
return true;
|
|
4190
|
+
}
|
|
4191
|
+
async function studioEvents(baseUrl, apiKey, path, method, body, key, context) {
|
|
4192
|
+
const origin = normalizeBaseUrl(baseUrl);
|
|
4193
|
+
assertKeyFormat(apiKey);
|
|
4194
|
+
assertReachedDirectly(origin, context.io.env);
|
|
4195
|
+
const timeout = timeoutSecondsOf(context.values, 30);
|
|
4196
|
+
if (timeout > 600) throw usageError("\u5B9E\u65F6\u4E8B\u4EF6\u5355\u6B21\u6700\u591A\u7B49\u5F85 600 \u79D2");
|
|
4197
|
+
const controller = new AbortController(), events = [];
|
|
4198
|
+
let timedOut = false, completed = false, accepted = false, reader;
|
|
4199
|
+
const recovery = () => ({
|
|
4200
|
+
...taskRecovery("videos", context.args[1] ?? "", void 0, baseUrl),
|
|
4201
|
+
...key ? { idempotencyKey: key, operationOutcome: accepted ? "accepted" : "unknown" } : {}
|
|
4202
|
+
});
|
|
4203
|
+
const stop = () => controller.abort();
|
|
4204
|
+
if (context.io.signal?.aborted) throw interruptedError();
|
|
4205
|
+
context.io.signal?.addEventListener("abort", stop, { once: true });
|
|
4206
|
+
const timer = setTimeout(() => {
|
|
4207
|
+
timedOut = true;
|
|
4208
|
+
controller.abort();
|
|
4209
|
+
}, timeout * 1e3);
|
|
4210
|
+
try {
|
|
4211
|
+
const response = await context.io.fetch(`${origin}${path}`, {
|
|
4212
|
+
method,
|
|
4213
|
+
redirect: "manual",
|
|
4214
|
+
signal: controller.signal,
|
|
4215
|
+
headers: { Authorization: `Bearer ${apiKey}`, Accept: "text/event-stream", ...key ? { "Idempotency-Key": key, "Content-Type": "application/json" } : {} },
|
|
4216
|
+
...method === "GET" ? {} : { body: JSON.stringify(body) }
|
|
4217
|
+
});
|
|
4218
|
+
if (response.status >= 300 && response.status < 400) throw new CliError({ code: "CLI_REDIRECT", message: "\u670D\u52A1\u7AEF\u8DF3\u8F6C\u5DF2\u62D2\u7EDD\uFF0C\u5BC6\u94A5\u6CA1\u6709\u8F6C\u53D1", exitCode: EXIT.SERVER });
|
|
4219
|
+
if (!response.ok) throw new CliError({
|
|
4220
|
+
code: "CLI_EVENT_HTTP_ERROR",
|
|
4221
|
+
message: `\u5B9E\u65F6\u4E8B\u4EF6\u8BF7\u6C42\u8FD4\u56DE HTTP ${response.status}\uFF0C\u8BF7\u67E5\u8BE2\u539F\u4EFB\u52A1`,
|
|
4222
|
+
httpStatus: response.status,
|
|
4223
|
+
exitCode: exitCodeForHttpStatus(response.status),
|
|
4224
|
+
retryable: response.status === 429 || response.status >= 500
|
|
4225
|
+
});
|
|
4226
|
+
if (response.headers.get("content-type")?.split(";")[0] !== "text/event-stream" || !response.body) throw new CliError({ code: "CLI_BAD_RESPONSE", message: "\u670D\u52A1\u7AEF\u672A\u8FD4\u56DE\u4E8B\u4EF6\u6D41", exitCode: EXIT.SERVER });
|
|
4227
|
+
accepted = true;
|
|
4228
|
+
reader = response.body.getReader();
|
|
4229
|
+
const decoder = new TextDecoder();
|
|
4230
|
+
let pending = "", size = 0;
|
|
4231
|
+
stream: for (; ; ) {
|
|
4232
|
+
const next = await reader.read();
|
|
4233
|
+
if (next.done) break;
|
|
4234
|
+
size += next.value.byteLength;
|
|
4235
|
+
if (size > 4 * 1024 * 1024 || events.length >= 1e3) throw new CliError({ code: "CLI_EVENT_LIMIT", message: "\u672C\u6B21\u4E8B\u4EF6\u5DF2\u8FBE\u5230\u8BFB\u53D6\u4E0A\u9650\uFF0C\u8BF7\u67E5\u8BE2\u5F53\u524D\u4EFB\u52A1\u6216\u91CD\u65B0\u8FDE\u63A5", exitCode: EXIT.RETRY_LATER });
|
|
4236
|
+
pending = (pending + decoder.decode(next.value, { stream: true })).replace(/\r\n/gu, "\n");
|
|
4237
|
+
for (let at = pending.indexOf("\n\n"); at >= 0; at = pending.indexOf("\n\n")) {
|
|
4238
|
+
const block = pending.slice(0, at);
|
|
4239
|
+
pending = pending.slice(at + 2);
|
|
4240
|
+
const data = block.split("\n").filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trimStart()).join("\n");
|
|
4241
|
+
const eventName = block.split("\n").find((line) => line.startsWith("event:"))?.slice(6).trim();
|
|
4242
|
+
if (data === "[DONE]") {
|
|
4243
|
+
completed = true;
|
|
4244
|
+
break stream;
|
|
4245
|
+
}
|
|
4246
|
+
if (!data) continue;
|
|
4247
|
+
let event;
|
|
4248
|
+
try {
|
|
4249
|
+
event = JSON.parse(data);
|
|
4250
|
+
} catch {
|
|
4251
|
+
event = { text: singleLine(data) };
|
|
4252
|
+
}
|
|
4253
|
+
if (events.length >= 1e3) throw new CliError({ code: "CLI_EVENT_LIMIT", message: "\u672C\u6B21\u4E8B\u4EF6\u5DF2\u8FBE\u5230\u8BFB\u53D6\u4E0A\u9650\uFF0C\u8BF7\u67E5\u8BE2\u5F53\u524D\u4EFB\u52A1", exitCode: EXIT.RETRY_LATER });
|
|
4254
|
+
events.push(event);
|
|
4255
|
+
const payload = event && typeof event === "object" && !Array.isArray(event) ? event : {};
|
|
4256
|
+
if (payload.type === "error" || eventName === "error") throw new CliError({
|
|
4257
|
+
code: "CLI_EVENT_ERROR",
|
|
4258
|
+
message: singleLine(typeof payload.message === "string" ? payload.message : "\u5BFC\u6F14\u56DE\u5408\u8FD4\u56DE\u9519\u8BEF\uFF0C\u8BF7\u67E5\u8BE2\u539F\u4EFB\u52A1"),
|
|
4259
|
+
exitCode: EXIT.SERVER
|
|
4260
|
+
});
|
|
4261
|
+
if (payload.type === "done" || eventName === "done") {
|
|
4262
|
+
completed = true;
|
|
4263
|
+
break stream;
|
|
4264
|
+
}
|
|
4265
|
+
}
|
|
4266
|
+
}
|
|
4267
|
+
if (!completed) throw new CliError({ code: "CLI_EVENT_INCOMPLETE", message: "\u5B9E\u65F6\u8FDE\u63A5\u5DF2\u7ED3\u675F\uFF0C\u4F46\u672A\u6536\u5230\u5B8C\u6210\u56DE\u6267\uFF0C\u8BF7\u67E5\u8BE2\u539F\u4EFB\u52A1", exitCode: EXIT.RETRY_LATER });
|
|
4268
|
+
} catch (error) {
|
|
4269
|
+
const failure = context.io.signal?.aborted ? interruptedError() : timedOut ? new CliError({ code: "CLI_TIMEOUT", message: "\u5B9E\u65F6\u7B49\u5F85\u5DF2\u8D85\u65F6\uFF0C\u8BF7\u67E5\u8BE2\u539F\u4EFB\u52A1\uFF1B\u6CA1\u6709\u91CD\u65B0\u63D0\u4EA4\u6D88\u606F", exitCode: EXIT.SERVER }) : toCliError(error);
|
|
4270
|
+
if (!timedOut || key || context.io.signal?.aborted) throw accepted ? failure.withRecovery(recovery()) : failure;
|
|
4271
|
+
} finally {
|
|
4272
|
+
clearTimeout(timer);
|
|
4273
|
+
context.io.signal?.removeEventListener("abort", stop);
|
|
4274
|
+
await reader?.cancel().catch(() => void 0);
|
|
4275
|
+
}
|
|
4276
|
+
return { events, timedOut, completed, taskId: context.args[1], recovery: recovery() };
|
|
4277
|
+
}
|
|
4278
|
+
|
|
2479
4279
|
// src/commands/series.ts
|
|
2480
4280
|
async function series(context) {
|
|
2481
|
-
const [
|
|
4281
|
+
const [action2, id] = context.args;
|
|
2482
4282
|
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
2483
|
-
if (
|
|
2484
|
-
if (
|
|
4283
|
+
if (action2 === "list" || action2 === "show") {
|
|
4284
|
+
if (action2 === "show" && !id) throw usageError("\u8BF7\u63D0\u4F9B\u5267\u96C6\u7F16\u53F7");
|
|
2485
4285
|
const query = new URLSearchParams();
|
|
2486
4286
|
for (const name2 of ["limit", "offset"]) {
|
|
2487
4287
|
const value = textOption(context.values, name2);
|
|
2488
4288
|
if (value) query.set(name2, value);
|
|
2489
4289
|
}
|
|
2490
|
-
const result2 = await getCreative(baseUrl, apiKey, "series",
|
|
4290
|
+
const result2 = await getCreative(baseUrl, apiKey, "series", action2 === "show" ? id : void 0, action2 === "list" && query.size ? `?${query}` : "", context.io);
|
|
2491
4291
|
context.out.result([JSON.stringify(result2, null, 2)], result2);
|
|
2492
4292
|
return;
|
|
2493
4293
|
}
|
|
2494
|
-
if (
|
|
2495
|
-
if (
|
|
4294
|
+
if (action2 !== "create" && action2 !== "episode-create") throw usageError("series \u652F\u6301 list\u3001show\u3001create\u3001episode-create");
|
|
4295
|
+
if (action2 === "episode-create" && !id) throw usageError("\u8BF7\u63D0\u4F9B\u5267\u96C6\u7F16\u53F7");
|
|
2496
4296
|
const body = await creativeData(context);
|
|
2497
4297
|
for (const [option, field] of [["product", "productId"], ["project", "projectId"], ["title", "title"], ["main-line", "mainLine"], ["logline", "logline"], ["previous-episode", "previousEpisodeId"]]) {
|
|
2498
4298
|
const value = textOption(context.values, option);
|
|
@@ -2502,12 +4302,12 @@ async function series(context) {
|
|
|
2502
4302
|
if (epoch !== void 0) body.expectedProductionEpoch = Number(epoch);
|
|
2503
4303
|
if (!Number.isInteger(body.expectedProductionEpoch) || Number(body.expectedProductionEpoch) < 0) throw usageError("\u8BF7\u4ECE drama context \u6216 series show \u67E5\u8BE2\u7248\u672C\uFF0C\u5E76\u63D0\u4F9B --expected-epoch");
|
|
2504
4304
|
const key = idempotencyKeyOf(context.values);
|
|
2505
|
-
const result = await postCreative(baseUrl, apiKey, "series",
|
|
4305
|
+
const result = await postCreative(baseUrl, apiKey, "series", action2 === "episode-create" ? id : void 0, action2 === "episode-create" ? "episodes" : "", body, key, context.io);
|
|
2506
4306
|
context.out.result([JSON.stringify(result, null, 2), `\u5E42\u7B49\u952E\uFF1A${key}`], { ...result, idempotencyKey: key });
|
|
2507
4307
|
}
|
|
2508
4308
|
|
|
2509
4309
|
// src/commands/assets.ts
|
|
2510
|
-
import { basename as
|
|
4310
|
+
import { basename as basename5 } from "node:path";
|
|
2511
4311
|
|
|
2512
4312
|
// src/client-catalog.ts
|
|
2513
4313
|
var fields = ["id", "name", "category", "sku", "archivedAt", "mergedIntoProductId", "createdAt", "updatedAt", "kind", "source", "status", "statusLabel", "projectId", "seriesId", "durationSeconds", "aspectRatio", "model", "renamable", "archivable", "mime", "bytes", "sha256", "license", "manageable", "archived", "url"];
|
|
@@ -2589,26 +4389,26 @@ async function catalogUpload(baseUrl, key, path, bytes, mime, idempotencyKey, de
|
|
|
2589
4389
|
|
|
2590
4390
|
// src/commands/assets.ts
|
|
2591
4391
|
async function assets(context) {
|
|
2592
|
-
const [
|
|
2593
|
-
if (!["list", "search", "show", "upload", "rename", "archive", "restore"].includes(
|
|
2594
|
-
const listing =
|
|
2595
|
-
if (!listing && !rawId) throw usageError(
|
|
4392
|
+
const [action2, rawId] = context.args;
|
|
4393
|
+
if (!["list", "search", "show", "upload", "rename", "archive", "restore"].includes(action2 ?? "")) throw usageError("assets \u652F\u6301 list\u3001search\u3001show\u3001upload\u3001rename\u3001archive\u3001restore");
|
|
4394
|
+
const listing = action2 === "list" || action2 === "search";
|
|
4395
|
+
if (!listing && !rawId) throw usageError(action2 === "upload" ? "\u8BF7\u63D0\u4F9B\u4E0A\u4F20\u6587\u4EF6\u8DEF\u5F84" : "\u8BF7\u63D0\u4F9B\u7D20\u6750\u7F16\u53F7");
|
|
2596
4396
|
const name2 = textOption(context.values, "name");
|
|
2597
|
-
if (
|
|
4397
|
+
if (action2 === "rename" && !name2) throw usageError("\u8BF7\u63D0\u4F9B --name <\u540D\u79F0>");
|
|
2598
4398
|
const source = textOption(context.values, "source") ?? "personal";
|
|
2599
|
-
if (["rename", "archive", "restore"].includes(
|
|
2600
|
-
let
|
|
4399
|
+
if (["rename", "archive", "restore"].includes(action2) && source !== "personal") throw usageError("\u53EA\u6709\u4E2A\u4EBA\u751F\u6210\u7D20\u6750\u652F\u6301\u6539\u540D\u3001\u5F52\u6863\u53CA\u6062\u590D\uFF1B\u5E73\u53F0\u7D20\u6750\u53EA\u8BFB\uFF0C\u4E0A\u4F20\u7D20\u6750\u4FDD\u7559\u6388\u6743\u8BB0\u5F55");
|
|
4400
|
+
let upload3;
|
|
2601
4401
|
let query = "";
|
|
2602
|
-
if (
|
|
4402
|
+
if (action2 === "upload") {
|
|
2603
4403
|
const authorization = textOption(context.values, "authorization"), license = textOption(context.values, "license");
|
|
2604
4404
|
if (!authorization || !["own", "licensed", "public_domain"].includes(authorization) || !license) throw usageError("\u4E0A\u4F20\u9700\u63D0\u4F9B --authorization <own|licensed|public_domain> \u4E0E --license <\u6388\u6743\u8BF4\u660E>");
|
|
2605
|
-
|
|
2606
|
-
query = `?${new URLSearchParams({ name: name2 ??
|
|
4405
|
+
upload3 = await readUploadFile(rawId);
|
|
4406
|
+
query = `?${new URLSearchParams({ name: name2 ?? basename5(rawId), authorization, license })}`;
|
|
2607
4407
|
}
|
|
2608
4408
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2609
|
-
const key = listing ||
|
|
4409
|
+
const key = listing || action2 === "show" ? void 0 : idempotencyKeyOf(context.values);
|
|
2610
4410
|
const path = listing ? `/api/open/v1/assets${catalogQuery(context.values, ["q", "kind", "source", "limit", "offset"])}` : `/api/open/v1/assets/${encodeURIComponent(rawId)}`;
|
|
2611
|
-
const result =
|
|
4411
|
+
const result = upload3 ? await catalogUpload(baseUrl, apiKey, `/api/open/v1/assets/uploads${query}`, upload3.bytes, upload3.contentType, key, context.io) : key ? await catalogWrite(baseUrl, apiKey, `${path}${action2 === "rename" ? "" : `/${action2}`}`, action2 === "rename" ? "PATCH" : "POST", action2 === "rename" ? { name: name2 } : {}, key, context.io) : await catalogGet(baseUrl, apiKey, listing ? path : `${path}?${new URLSearchParams({ source })}`, context.io);
|
|
2612
4412
|
const items = Array.isArray(result.assets) ? result.assets : [result.asset];
|
|
2613
4413
|
context.out.result(items.filter(Boolean).map((item) => {
|
|
2614
4414
|
const r = item;
|
|
@@ -2618,17 +4418,17 @@ async function assets(context) {
|
|
|
2618
4418
|
|
|
2619
4419
|
// src/commands/library.ts
|
|
2620
4420
|
async function library(context) {
|
|
2621
|
-
const [
|
|
2622
|
-
if (!["list", "search", "show", "rename", "archive", "restore"].includes(
|
|
2623
|
-
const listing =
|
|
4421
|
+
const [action2, rawId] = context.args;
|
|
4422
|
+
if (!["list", "search", "show", "rename", "archive", "restore"].includes(action2 ?? "")) throw usageError("library \u652F\u6301 list\u3001search\u3001show\u3001rename\u3001archive\u3001restore");
|
|
4423
|
+
const listing = action2 === "list" || action2 === "search";
|
|
2624
4424
|
const kind = textOption(context.values, "kind");
|
|
2625
4425
|
if (!listing && (!rawId || !kind)) throw usageError("\u8BF7\u63D0\u4F9B\u4F5C\u54C1\u7F16\u53F7\u53CA --kind <commercial_ad|episode|graphic>");
|
|
2626
4426
|
const path = listing ? `/api/open/v1/library${catalogQuery(context.values, ["q", "kind", "state", "product", "archived", "limit", "cursor"])}` : `/api/open/v1/library/${encodeURIComponent(kind)}/${encodeURIComponent(rawId)}`;
|
|
2627
4427
|
const name2 = textOption(context.values, "name");
|
|
2628
|
-
if (
|
|
4428
|
+
if (action2 === "rename" && !name2) throw usageError("\u8BF7\u63D0\u4F9B --name <\u540D\u79F0>");
|
|
2629
4429
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2630
|
-
const key = listing ||
|
|
2631
|
-
const result = key ? await catalogWrite(baseUrl, apiKey, `${path}${
|
|
4430
|
+
const key = listing || action2 === "show" ? void 0 : idempotencyKeyOf(context.values);
|
|
4431
|
+
const result = key ? await catalogWrite(baseUrl, apiKey, `${path}${action2 === "rename" ? "" : `/${action2}`}`, action2 === "rename" ? "PATCH" : "POST", action2 === "rename" ? { name: name2 } : {}, key, context.io) : await catalogGet(baseUrl, apiKey, path, context.io);
|
|
2632
4432
|
const items = Array.isArray(result.items) ? result.items : [result.item];
|
|
2633
4433
|
context.out.result(items.filter(Boolean).map((item) => {
|
|
2634
4434
|
const r = item;
|
|
@@ -2656,12 +4456,12 @@ async function balance(context) {
|
|
|
2656
4456
|
}
|
|
2657
4457
|
|
|
2658
4458
|
// src/commands/creative-attachments.ts
|
|
2659
|
-
import { basename as
|
|
4459
|
+
import { basename as basename6 } from "node:path";
|
|
2660
4460
|
async function creativeAttachments(context, resource) {
|
|
2661
|
-
const [
|
|
4461
|
+
const [action2, id] = context.args;
|
|
2662
4462
|
if (!id) throw usageError("\u8BF7\u63D0\u4F9B\u9879\u76EE\u7F16\u53F7");
|
|
2663
4463
|
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
2664
|
-
if (
|
|
4464
|
+
if (action2 === "attachments") {
|
|
2665
4465
|
const ids = textOption(context.values, "attachment-ids")?.split(",").map((value) => value.trim());
|
|
2666
4466
|
const params = new URLSearchParams();
|
|
2667
4467
|
const offset = textOption(context.values, "offset");
|
|
@@ -2671,14 +4471,14 @@ async function creativeAttachments(context, resource) {
|
|
|
2671
4471
|
context.out.result([JSON.stringify(result, null, 2)], result);
|
|
2672
4472
|
return;
|
|
2673
4473
|
}
|
|
2674
|
-
if (
|
|
4474
|
+
if (action2 === "upload") {
|
|
2675
4475
|
const path = textOption(context.values, "file");
|
|
2676
4476
|
if (!path) throw usageError("\u8BF7\u63D0\u4F9B --file <\u9644\u4EF6\u8DEF\u5F84>");
|
|
2677
|
-
const
|
|
4477
|
+
const upload3 = await readUploadFile(path);
|
|
2678
4478
|
const key = idempotencyKeyOf(context.values);
|
|
2679
|
-
const suffix = `attachments?${new URLSearchParams({ name:
|
|
4479
|
+
const suffix = `attachments?${new URLSearchParams({ name: basename6(path) })}`;
|
|
2680
4480
|
try {
|
|
2681
|
-
const result = creativeObject((await putRaw(baseUrl, apiKey, creativePath(resource, id, suffix),
|
|
4481
|
+
const result = creativeObject((await putRaw(baseUrl, apiKey, creativePath(resource, id, suffix), upload3.bytes, upload3.contentType, key, context.io)).body);
|
|
2682
4482
|
context.out.result([JSON.stringify(result, null, 2), `\u5E42\u7B49\u952E\uFF1A${key}`], { ...result, idempotencyKey: key });
|
|
2683
4483
|
return;
|
|
2684
4484
|
} catch (error) {
|
|
@@ -2708,7 +4508,8 @@ async function creativeAttachments(context, resource) {
|
|
|
2708
4508
|
// src/commands/drama.ts
|
|
2709
4509
|
var SUBCOMMANDS2 = "create\u3001status\u3001quote\u3001confirm\u3001cancel\u3001download\u3001context\u3001director\u3001document\u3001message\u3001director-confirm\u3001bindings\u3001spec\u3001shot-plan\u3001versions\u3001select-version\u3001redo-quote\u3001redo";
|
|
2710
4510
|
var DURATION_KEYS = ["30s", "60s", "90s"];
|
|
2711
|
-
async function
|
|
4511
|
+
async function drama2(context) {
|
|
4512
|
+
timeoutSecondsOf(context.values, DEFAULT_WAIT_TIMEOUT_MS / 1e3);
|
|
2712
4513
|
const { args } = context;
|
|
2713
4514
|
const [subcommand] = args;
|
|
2714
4515
|
if (subcommand === void 0) {
|
|
@@ -2734,7 +4535,7 @@ function waitControls2(io, values, note) {
|
|
|
2734
4535
|
return {
|
|
2735
4536
|
timeoutMs: timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3,
|
|
2736
4537
|
now: io.now ?? (() => /* @__PURE__ */ new Date()),
|
|
2737
|
-
sleep:
|
|
4538
|
+
sleep: (ms) => sleepFor(io, ms),
|
|
2738
4539
|
note
|
|
2739
4540
|
};
|
|
2740
4541
|
}
|
|
@@ -2847,12 +4648,15 @@ function quoteLines(orderId, quote3) {
|
|
|
2847
4648
|
}
|
|
2848
4649
|
async function create(context) {
|
|
2849
4650
|
const { io, out, values } = context;
|
|
2850
|
-
const
|
|
2851
|
-
|
|
4651
|
+
const dataRef = textOption(values, "data");
|
|
4652
|
+
const data = dataRef ? await readPropsArgument(io, dataRef, "\u77ED\u5267\u53C2\u6570\uFF08--data\uFF09") : {};
|
|
4653
|
+
for (const field of ["ownerId", "workspaceId", "allowPaidConfirmation"]) if (field in data) throw usageError(`--data \u4E0D\u80FD\u63D0\u4F9B ${field}`);
|
|
4654
|
+
const productId = textOption(values, "product") ?? (typeof data.productId === "string" ? data.productId : void 0);
|
|
4655
|
+
if (!productId?.trim()) {
|
|
2852
4656
|
throw usageError("\u8981\u7ED9 --product <\u4EA7\u54C1id>\uFF08buke products create \u56DE\u7684\u90A3\u4E2A\uFF09");
|
|
2853
4657
|
}
|
|
2854
4658
|
const genreId = textOption(values, "genre");
|
|
2855
|
-
const durationKey = textOption(values, "duration");
|
|
4659
|
+
const durationKey = textOption(values, "duration") ?? (typeof data.durationKey === "string" ? data.durationKey : void 0);
|
|
2856
4660
|
if (durationKey !== void 0 && !DURATION_KEYS.includes(durationKey)) {
|
|
2857
4661
|
throw usageError(`--duration \u53EA\u80FD\u662F ${DURATION_KEYS.join("\u3001")}\uFF0C\u5199\u7684\u662F ${durationKey}`);
|
|
2858
4662
|
}
|
|
@@ -2866,6 +4670,7 @@ async function create(context) {
|
|
|
2866
4670
|
baseUrl,
|
|
2867
4671
|
apiKey,
|
|
2868
4672
|
{
|
|
4673
|
+
...data,
|
|
2869
4674
|
productId,
|
|
2870
4675
|
...genreId === void 0 ? {} : { genreId },
|
|
2871
4676
|
...durationKey === void 0 ? {} : { durationKey },
|
|
@@ -2996,6 +4801,7 @@ function errorDocument(error) {
|
|
|
2996
4801
|
if (error.httpStatus !== void 0) document.error.httpStatus = error.httpStatus;
|
|
2997
4802
|
if (error.recovery !== void 0) document.recovery = error.recovery;
|
|
2998
4803
|
if (error.failures !== void 0) document.failures = error.failures;
|
|
4804
|
+
if (error.webRecovery !== void 0) document.webRecovery = error.webRecovery;
|
|
2999
4805
|
return document;
|
|
3000
4806
|
}
|
|
3001
4807
|
function errorLines(error) {
|
|
@@ -3007,16 +4813,23 @@ function errorLines(error) {
|
|
|
3007
4813
|
`\u9519\u8BEF\uFF1A${singleLine(error.message)}`,
|
|
3008
4814
|
`\uFF08${details.join("\uFF1B")}\uFF09`,
|
|
3009
4815
|
...error.hints,
|
|
4816
|
+
...error.webRecovery ? [
|
|
4817
|
+
`\u7F51\u9875\u64CD\u4F5C\uFF1A${singleLine(error.webRecovery.operationId)}\uFF1B\u7ED3\u679C\uFF1A${error.webRecovery.operationOutcome}`,
|
|
4818
|
+
...error.webRecovery.taskId ? [`\u539F\u4EFB\u52A1\uFF1A${singleLine(error.webRecovery.taskId)}`] : [],
|
|
4819
|
+
...error.webRecovery.idempotencyKey ? [`\u539F\u5E42\u7B49\u952E\uFF1A${singleLine(error.webRecovery.idempotencyKey)}\uFF1B\u8BF7\u5148\u67E5\u8BE2\u539F\u64CD\u4F5C\uFF0C\u4E0D\u8981\u6362\u952E\u91CD\u590D\u63D0\u4EA4\u3002`] : [],
|
|
4820
|
+
...error.webRecovery.requestRecord ? [`\u6062\u590D\u8BB0\u5F55\uFF1A${singleLine(error.webRecovery.requestRecord)}`] : []
|
|
4821
|
+
] : [],
|
|
3010
4822
|
...recovery === void 0 ? [] : [
|
|
3011
4823
|
recovery.operation === "confirm" ? `${recovery.acceptance === "confirmed" ? "\u539F\u8BA2\u5355" : "\u76EE\u6807\u8BA2\u5355"}\uFF1A${singleLine(recovery.taskId ?? "")}` : recovery.acceptance === "confirmed" ? `\u5DF2\u53D7\u7406\u4EFB\u52A1\uFF1A${singleLine(recovery.taskId ?? "")}` : "\u63D0\u4EA4\u7ED3\u679C\u5C1A\u672A\u786E\u8BA4\uFF0C\u8BF7\u5148\u5728 Studio \u6838\u5BF9\u539F\u8BF7\u6C42\uFF1B\u4E0D\u8981\u91CD\u65B0\u4E0B\u5355",
|
|
3012
4824
|
...recovery.operation !== "confirm" ? [] : [
|
|
3013
|
-
recovery.operationOutcome === "not_submitted" ? "\u672C\u6B21\u786E\u8BA4\u5C1A\u672A\u63D0\u4EA4\uFF1B\u8BF7\u5148\u67E5\u8BE2\u8BA2\u5355\u72B6\u6001\u5E76\u5904\u7406\u9519\u8BEF\u3002" : recovery.operationOutcome === "rejected" ? "\u672C\u6B21\u786E\u8BA4\u5DF2\u88AB\u62D2\u7EDD\uFF0C\u672A\u53D7\u7406\uFF1B\u8BF7\u5904\u7406\u9519\u8BEF\u540E\u67E5\u8BE2\u539F\u8BA2\u5355\u3002" : "\u672C\u6B21\u786E\u8BA4\u7ED3\u679C\u672A\u77E5\uFF1B\u8BF7\u5148\u67E5\u8BE2\u539F\u8BA2\u5355\uFF0C\u4E0D\u8981\u91CD\u590D\u63D0\u4EA4\u786E\u8BA4\u3002"
|
|
4825
|
+
recovery.operationOutcome === "not_submitted" ? "\u672C\u6B21\u786E\u8BA4\u5C1A\u672A\u63D0\u4EA4\uFF1B\u8BF7\u5148\u67E5\u8BE2\u8BA2\u5355\u72B6\u6001\u5E76\u5904\u7406\u9519\u8BEF\u3002" : recovery.operationOutcome === "rejected" ? "\u672C\u6B21\u786E\u8BA4\u5DF2\u88AB\u62D2\u7EDD\uFF0C\u672A\u53D7\u7406\uFF1B\u8BF7\u5904\u7406\u9519\u8BEF\u540E\u67E5\u8BE2\u539F\u8BA2\u5355\u3002" : recovery.operationOutcome === "accepted" ? "\u672C\u6B21\u786E\u8BA4\u5DF2\u53D7\u7406\uFF1B\u540E\u7EED\u7B49\u5F85\u6216\u67E5\u8BE2\u672A\u5B8C\u6210\uFF0C\u8BF7\u7EE7\u7EED\u67E5\u8BE2\u539F\u4EFB\u52A1\uFF0C\u4E0D\u8981\u91CD\u65B0\u63D0\u4EA4\u751F\u6210\u3002" : "\u672C\u6B21\u786E\u8BA4\u7ED3\u679C\u672A\u77E5\uFF1B\u8BF7\u5148\u67E5\u8BE2\u539F\u8BA2\u5355\uFF0C\u4E0D\u8981\u91CD\u590D\u63D0\u4EA4\u786E\u8BA4\u3002"
|
|
3014
4826
|
],
|
|
3015
4827
|
...recovery.baseUrl === void 0 ? [] : [`\u670D\u52A1\u5730\u5740\uFF1A${singleLine(recovery.baseUrl)}`],
|
|
3016
4828
|
...recovery.status === void 0 ? [] : [`\u6700\u540E\u72B6\u6001\uFF1A${singleLine(recovery.status)}`],
|
|
3017
4829
|
...recovery.failureCode === void 0 ? [] : [`\u4EFB\u52A1\u5931\u8D25\u7801\uFF1A${singleLine(recovery.failureCode)}`],
|
|
3018
4830
|
...recovery.idempotencyKey === void 0 ? [] : [`\u5E42\u7B49\u952E\uFF1A${singleLine(recovery.idempotencyKey)}`],
|
|
3019
4831
|
...recovery.confirmation === void 0 ? [] : [`\u539F\u786E\u8BA4\u7C7B\u578B\uFF1A${singleLine(recovery.confirmation.kind)}`, `\u539F\u786E\u8BA4\u7F16\u53F7\uFF1A${singleLine(recovery.confirmation.confirmationId)}`],
|
|
4832
|
+
...recovery.videoConfirmation === void 0 ? [] : [`\u539F\u786E\u8BA4\u8BF7\u6C42\uFF08\u4FDD\u5B58\u4E3A JSON\uFF0C\u7528 --data \u4E0E\u539F --idempotency-key \u6062\u590D\uFF09\uFF1A${JSON.stringify(recovery.videoConfirmation)}`],
|
|
3020
4833
|
...recovery.statusCommand === void 0 ? [] : [`${recovery.operation === "confirm" ? "\u67E5\u8BE2\u8BA2\u5355\u72B6\u6001" : "\u53EA\u67E5\u8BE2\u539F\u4EFB\u52A1"}\uFF1A${singleLine(recovery.statusCommand)}`]
|
|
3021
4834
|
]
|
|
3022
4835
|
];
|
|
@@ -3257,15 +5070,15 @@ async function confirmLock(context, values, rawId) {
|
|
|
3257
5070
|
);
|
|
3258
5071
|
}
|
|
3259
5072
|
async function manageProducts(context) {
|
|
3260
|
-
const [
|
|
3261
|
-
const listing =
|
|
5073
|
+
const [action2, id] = context.args;
|
|
5074
|
+
const listing = action2 === "list" || action2 === "search";
|
|
3262
5075
|
if (!listing && !id) throw usageError("\u8BF7\u63D0\u4F9B\u4EA7\u54C1\u7F16\u53F7");
|
|
3263
5076
|
const name2 = textOption(context.values, "name");
|
|
3264
|
-
if (
|
|
5077
|
+
if (action2 === "update" && !name2) throw usageError("\u8BF7\u63D0\u4F9B --name <\u540D\u79F0>\uFF1B\u56FE\u7247\u548C\u5916\u89C2\u9501\u4F7F\u7528 set-images\u3001confirm-lock");
|
|
3265
5078
|
const path = listing ? `/api/open/v1/products${catalogQuery(context.values, ["q", "archived", "limit", "offset"])}` : `/api/open/v1/products/${encodeURIComponent(id)}`;
|
|
3266
5079
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
3267
|
-
const key = listing ||
|
|
3268
|
-
const result = key ? await catalogWrite(baseUrl, apiKey, `${path}${
|
|
5080
|
+
const key = listing || action2 === "show" ? void 0 : idempotencyKeyOf(context.values);
|
|
5081
|
+
const result = key ? await catalogWrite(baseUrl, apiKey, `${path}${action2 === "update" ? "" : `/${action2}`}`, action2 === "update" ? "PATCH" : "POST", action2 === "update" ? { name: name2 } : {}, key, context.io) : await catalogGet(baseUrl, apiKey, path, context.io);
|
|
3269
5082
|
const items = Array.isArray(result.products) ? result.products : [result.product];
|
|
3270
5083
|
context.out.result(items.filter(Boolean).map((item) => {
|
|
3271
5084
|
const r = item;
|
|
@@ -3274,7 +5087,7 @@ async function manageProducts(context) {
|
|
|
3274
5087
|
}
|
|
3275
5088
|
|
|
3276
5089
|
// src/commands/video-music.ts
|
|
3277
|
-
function
|
|
5090
|
+
function object2(value) {
|
|
3278
5091
|
if (!value || typeof value !== "object" || Array.isArray(value)) throw new CliError({ code: "CLI_BAD_RESPONSE", exitCode: EXIT.SERVER, message: "\u670D\u52A1\u7AEF\u672A\u8FD4\u56DE\u6709\u6548\u7684\u914D\u4E50\u7ED3\u679C" });
|
|
3279
5092
|
return value;
|
|
3280
5093
|
}
|
|
@@ -3286,24 +5099,32 @@ function safe(value) {
|
|
|
3286
5099
|
return Object.fromEntries(Object.entries(value).filter(([key]) => fields2.has(key)).map(([key, item]) => [key, safe(item)]));
|
|
3287
5100
|
}
|
|
3288
5101
|
function task(value) {
|
|
3289
|
-
const result =
|
|
5102
|
+
const result = object2(safe(value));
|
|
3290
5103
|
if (typeof result.id !== "string" || !["pending", "running", "succeeded", "failed"].includes(String(result.status))) throw new CliError({ code: "CLI_BAD_RESPONSE", exitCode: EXIT.SERVER, message: "\u670D\u52A1\u7AEF\u672A\u8FD4\u56DE\u6709\u6548\u7684\u914D\u4E50\u4EFB\u52A1\u7F16\u53F7\u6216\u72B6\u6001" });
|
|
3291
5104
|
return result;
|
|
3292
5105
|
}
|
|
3293
5106
|
async function videoMusic(context) {
|
|
3294
5107
|
const { args, values, out, io } = context;
|
|
5108
|
+
const timeoutSeconds = timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3);
|
|
3295
5109
|
const command = args[0];
|
|
3296
5110
|
const id = args[1]?.trim();
|
|
3297
5111
|
if (!id) throw usageError("\u8BF7\u63D0\u4F9B\u5546\u54C1\u89C6\u9891\u4EFB\u52A1 ID");
|
|
5112
|
+
for (const option of ["expected-version", "expected-credits"]) {
|
|
5113
|
+
if (values[option] !== void 0) throw usageError(`videos ${command} \u4E0D\u652F\u6301 --${option}\uFF1B\u914D\u4E50\u751F\u6210\u8BF7\u4F7F\u7528\u5DF2\u67E5\u770B\u7684 --quote-hash \u7ED1\u5B9A\u62A5\u4EF7`);
|
|
5114
|
+
}
|
|
5115
|
+
const expectedQuoteHash = textOption(values, "quote-hash")?.toLowerCase();
|
|
5116
|
+
if (["music-quote", "music-compose"].includes(command) && values["quote-hash"] !== void 0 && (expectedQuoteHash === void 0 || !/^[a-f0-9]{64}$/u.test(expectedQuoteHash))) throw usageError("--quote-hash \u5FC5\u987B\u662F\u5DF2\u67E5\u770B\u7684 64 \u4F4D\u5341\u516D\u8FDB\u5236\u62A5\u4EF7\u54C8\u5E0C");
|
|
5117
|
+
if (command === "music-compose" && values.yes === true && expectedQuoteHash === void 0) throw usageError("\u786E\u8BA4\u914D\u4E50\u751F\u6210\u5FC5\u987B\u63D0\u4F9B\u5DF2\u67E5\u770B\u7684 --quote-hash\uFF1B\u5148\u4E0D\u5E26 --yes \u67E5\u770B\u62A5\u4EF7");
|
|
3298
5118
|
const request = ["music-quote", "music-compose", "music-apply"].includes(command) ? await readPropsArgument(io, textOption(values, "props"), "\u914D\u4E50\u8BF7\u6C42") : {};
|
|
3299
5119
|
const key = idempotencyKeyOf(values);
|
|
3300
5120
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
3301
5121
|
const path = `/api/open/v1/videos/${encodeURIComponent(id)}/music`;
|
|
3302
5122
|
let submitted = false;
|
|
5123
|
+
let accepted = false;
|
|
3303
5124
|
let latestTask;
|
|
3304
5125
|
try {
|
|
3305
5126
|
if (command === "music-list") {
|
|
3306
|
-
const data =
|
|
5127
|
+
const data = object2(safe((await getJson(baseUrl, apiKey, path, io)).body));
|
|
3307
5128
|
const tasks = Array.isArray(data.tasks) ? data.tasks.map(task) : [];
|
|
3308
5129
|
out.result(tasks.map((item) => `${singleLine(item.id)} ${singleLine(item.status)} ${singleLine(String(item.title ?? ""))}`), { ...data, tasks });
|
|
3309
5130
|
return;
|
|
@@ -3311,28 +5132,33 @@ async function videoMusic(context) {
|
|
|
3311
5132
|
if (command === "music-apply") {
|
|
3312
5133
|
const taskId = textOption(values, "music-task-id");
|
|
3313
5134
|
if (!taskId) throw usageError("\u8BF7\u63D0\u4F9B --music-task-id <\u914D\u4E50\u4EFB\u52A1ID>");
|
|
3314
|
-
const
|
|
5135
|
+
const timeoutMs = values.timeout === void 0 ? 3e5 : timeoutSeconds * 1e3;
|
|
5136
|
+
const data = object2(safe((await postJson(baseUrl, apiKey, `${path}/${encodeURIComponent(taskId)}/apply`, request, key, io, { timeoutMs })).body));
|
|
3315
5137
|
out.result(["\u914D\u4E50\u5DF2\u5408\u6210\uFF1B\u539F\u6210\u7247\u4FDD\u7559\uFF0C\u672C\u6B21\u5408\u6210\u4E0D\u6536\u53D6\u751F\u6210\u8D39\u7528\u3002", `\u914D\u4E50\u4EFB\u52A1\uFF1A${singleLine(taskId)}`, `\u5E42\u7B49\u952E\uFF1A${key}`], { ...data, idempotencyKey: key });
|
|
3316
5138
|
return;
|
|
3317
5139
|
}
|
|
3318
|
-
const quote3 =
|
|
5140
|
+
const quote3 = object2(object2(safe((await postJson(baseUrl, apiKey, `${path}/quote`, request, key, io)).body)).quote);
|
|
3319
5141
|
if (typeof quote3.quoteHash !== "string" || !/^[a-f0-9]{64}$/u.test(quote3.quoteHash) || typeof quote3.credits !== "number" || !Number.isFinite(quote3.credits) || quote3.credits <= 0) throw new CliError({ code: "CLI_BAD_RESPONSE", exitCode: EXIT.SERVER, message: "\u914D\u4E50\u62A5\u4EF7\u54CD\u5E94\u65E0\u6548\uFF0C\u672C\u6B21\u672A\u63D0\u4EA4\u751F\u6210" });
|
|
3320
|
-
|
|
3321
|
-
if (expected && expected !== quote3.quoteHash) throw new CliError({ code: "OPEN_API_QUOTE_CHANGED", exitCode: EXIT.QUOTE_CHANGED, message: "\u914D\u4E50\u62A5\u4EF7\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u67E5\u770B\u5E76\u786E\u8BA4" });
|
|
5142
|
+
if (expectedQuoteHash !== void 0 && expectedQuoteHash !== quote3.quoteHash) throw new CliError({ code: "OPEN_API_QUOTE_CHANGED", exitCode: EXIT.QUOTE_CHANGED, message: "\u914D\u4E50\u62A5\u4EF7\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u67E5\u770B\u5E76\u786E\u8BA4" });
|
|
3322
5143
|
if (command === "music-quote" || values.yes !== true) {
|
|
3323
|
-
out.result([
|
|
5144
|
+
out.result([
|
|
5145
|
+
`\u914D\u4E50\u62A5\u4EF7\uFF1A${quote3.credits} \u5E03`,
|
|
5146
|
+
`\u62A5\u4EF7\u54C8\u5E0C\uFF1A${quote3.quoteHash}`,
|
|
5147
|
+
`\u786E\u8BA4\u540E\u4F7F\u7528 buke videos music-compose ${id} --props <\u539F\u914D\u4E50\u8BF7\u6C42\u6587\u4EF6> --quote-hash ${quote3.quoteHash} --yes \u63D0\u4EA4\u751F\u6210\u3002`
|
|
5148
|
+
], { quote: quote3, submitted: false });
|
|
3324
5149
|
return;
|
|
3325
5150
|
}
|
|
3326
5151
|
submitted = true;
|
|
3327
|
-
latestTask = task(
|
|
5152
|
+
latestTask = task(object2((await postJson(baseUrl, apiKey, path, { ...request, confirmed: true, quoteHash: quote3.quoteHash }, key, io)).body).task);
|
|
5153
|
+
accepted = true;
|
|
3328
5154
|
if (values.wait === true) {
|
|
3329
5155
|
const now = io.now ?? (() => /* @__PURE__ */ new Date());
|
|
3330
|
-
const
|
|
3331
|
-
const until = now().getTime() + timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3;
|
|
5156
|
+
const until = now().getTime() + timeoutSeconds * 1e3;
|
|
3332
5157
|
while (["pending", "running"].includes(latestTask.status)) {
|
|
3333
5158
|
if (now().getTime() >= until) throw new CliError({ code: "CLI_WAIT_TIMEOUT", exitCode: EXIT.WAIT_TIMEOUT, message: "\u914D\u4E50\u7B49\u5F85\u5DF2\u8FBE\u5230\u65F6\u9650\uFF0C\u8BF7\u67E5\u8BE2\u539F\u914D\u4E50\u4EFB\u52A1\uFF0C\u4E0D\u8981\u91CD\u65B0\u63D0\u4EA4\u751F\u6210" });
|
|
3334
|
-
await
|
|
3335
|
-
|
|
5159
|
+
await sleepFor(io, Math.min(1500, Math.max(until - now().getTime(), 1)));
|
|
5160
|
+
if (now().getTime() >= until) continue;
|
|
5161
|
+
const data = object2((await getJson(baseUrl, apiKey, path, io)).body);
|
|
3336
5162
|
const found = Array.isArray(data.tasks) ? data.tasks.find((item) => item && typeof item === "object" && item.id === latestTask.id) : null;
|
|
3337
5163
|
latestTask = task(found);
|
|
3338
5164
|
}
|
|
@@ -3354,7 +5180,7 @@ async function videoMusic(context) {
|
|
|
3354
5180
|
acceptance: latestTask ? "confirmed" : "unknown",
|
|
3355
5181
|
idempotencyKey: key,
|
|
3356
5182
|
operation: "confirm",
|
|
3357
|
-
operationOutcome: !submitted ? "not_submitted" : rejected ? "rejected" : "unknown",
|
|
5183
|
+
operationOutcome: accepted ? "accepted" : !submitted ? "not_submitted" : rejected ? "rejected" : "unknown",
|
|
3358
5184
|
statusCommand: taskRecovery("videos", id, latestTask?.status, baseUrl).statusCommand.replace(" videos status ", " videos music-list ")
|
|
3359
5185
|
});
|
|
3360
5186
|
}
|
|
@@ -3363,6 +5189,7 @@ async function videoMusic(context) {
|
|
|
3363
5189
|
// src/commands/videos.ts
|
|
3364
5190
|
var SUBCOMMANDS3 = "create\u3001status\u3001message\u3001confirm\u3001versions\u3001cancel\u3001download\u3001music-quote\u3001music-compose\u3001music-list\u3001music-apply";
|
|
3365
5191
|
async function videos(context) {
|
|
5192
|
+
timeoutSecondsOf(context.values, DEFAULT_WAIT_TIMEOUT_MS / 1e3);
|
|
3366
5193
|
const { args } = context;
|
|
3367
5194
|
const [subcommand] = args;
|
|
3368
5195
|
if (subcommand === void 0) {
|
|
@@ -3388,7 +5215,7 @@ function waitControls3(io, values) {
|
|
|
3388
5215
|
return {
|
|
3389
5216
|
timeoutMs: timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3,
|
|
3390
5217
|
now: io.now ?? (() => /* @__PURE__ */ new Date()),
|
|
3391
|
-
sleep:
|
|
5218
|
+
sleep: (ms) => sleepFor(io, ms)
|
|
3392
5219
|
};
|
|
3393
5220
|
}
|
|
3394
5221
|
function settleRun(outcome, baseUrl) {
|
|
@@ -3479,6 +5306,9 @@ async function create3(context) {
|
|
|
3479
5306
|
{ run: raw.run, idempotencyKey }
|
|
3480
5307
|
);
|
|
3481
5308
|
}
|
|
5309
|
+
function latestDirectorLine(messages) {
|
|
5310
|
+
return [...messages].reverse().find((message2) => message2.role === "assistant" && !message2.earlierAttemptOf && message2.text.trim() !== "");
|
|
5311
|
+
}
|
|
3482
5312
|
async function status3(context, rawId) {
|
|
3483
5313
|
const { io, out, values } = context;
|
|
3484
5314
|
const runId = runIdOf(rawId);
|
|
@@ -3487,7 +5317,7 @@ async function status3(context, rawId) {
|
|
|
3487
5317
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
3488
5318
|
const current = await getVideoRun(baseUrl, apiKey, runId, io);
|
|
3489
5319
|
const final = shouldWait ? settleRun(await awaitVideoRun(baseUrl, apiKey, current, io, controls), baseUrl) : current;
|
|
3490
|
-
const lastDirectorLine =
|
|
5320
|
+
const lastDirectorLine = latestDirectorLine(final.view.messages);
|
|
3491
5321
|
out.result(
|
|
3492
5322
|
[
|
|
3493
5323
|
...runLines(final.view),
|
|
@@ -3508,8 +5338,8 @@ async function message(context, rawId) {
|
|
|
3508
5338
|
}
|
|
3509
5339
|
const idempotencyKey = idempotencyKeyOf(values);
|
|
3510
5340
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
3511
|
-
const { view, raw } = await runReplyOf(await postJson(baseUrl, apiKey, `/api/open/v1/videos/${encodeURIComponent(runId)}/messages`, { ...data, text }, idempotencyKey, io));
|
|
3512
|
-
const lastDirectorLine =
|
|
5341
|
+
const { view, raw } = await retainMutationOnError("videos", runId, idempotencyKey, baseUrl, async () => runReplyOf(await postJson(baseUrl, apiKey, `/api/open/v1/videos/${encodeURIComponent(runId)}/messages`, { ...data, text }, idempotencyKey, io)));
|
|
5342
|
+
const lastDirectorLine = latestDirectorLine(view.messages);
|
|
3513
5343
|
out.result(
|
|
3514
5344
|
[
|
|
3515
5345
|
...runLines(view),
|
|
@@ -3523,10 +5353,39 @@ async function message(context, rawId) {
|
|
|
3523
5353
|
async function confirm2(context, rawId) {
|
|
3524
5354
|
const { io, out, values } = context;
|
|
3525
5355
|
const runId = runIdOf(rawId);
|
|
5356
|
+
const data = await creativeData(context);
|
|
5357
|
+
const originalKey = textOption(values, "idempotency-key");
|
|
5358
|
+
if (textOption(values, "data")) {
|
|
5359
|
+
if (!originalKey) throw usageError("\u6062\u590D\u539F\u786E\u8BA4\u5FC5\u987B\u63D0\u4F9B\u539F --idempotency-key");
|
|
5360
|
+
if (!Number.isInteger(data.expectedVersion) || Number(data.expectedVersion) < 0 || !data.confirmation || typeof data.confirmation !== "object" || Array.isArray(data.confirmation)) {
|
|
5361
|
+
throw usageError("--data \u5FC5\u987B\u5305\u542B\u539F\u786E\u8BA4\u7684 expectedVersion \u4E0E confirmation");
|
|
5362
|
+
}
|
|
5363
|
+
if (values.yes !== true) throw usageError("\u6062\u590D\u539F\u786E\u8BA4\u8BF7\u6838\u5BF9\u539F\u8BF7\u6C42\uFF0C\u5E76\u6DFB\u52A0 --yes");
|
|
5364
|
+
const { apiKey: apiKey2, baseUrl: baseUrl2 } = await resolveApiKey(context);
|
|
5365
|
+
const outcome2 = await confirmVideoProduction(baseUrl2, apiKey2, runId, Number(data.expectedVersion), data.confirmation, originalKey, io);
|
|
5366
|
+
out.result(
|
|
5367
|
+
[...runLines(outcome2.view), "\u5DF2\u91CD\u653E\u539F\u786E\u8BA4\u8BF7\u6C42", ...waitingLines(outcome2.view), `\u5E42\u7B49\u952E\uFF1A${originalKey}`],
|
|
5368
|
+
{ run: outcome2.raw.run, replayedConfirmation: true, idempotencyKey: originalKey }
|
|
5369
|
+
);
|
|
5370
|
+
return;
|
|
5371
|
+
}
|
|
5372
|
+
const expectedVersionRaw = textOption(values, "expected-version");
|
|
5373
|
+
const expectedCreditsRaw = textOption(values, "expected-credits");
|
|
5374
|
+
const expectedVersion = expectedVersionRaw === void 0 ? void 0 : Number(expectedVersionRaw);
|
|
5375
|
+
const expectedCredits = expectedCreditsRaw === void 0 ? void 0 : Number(expectedCreditsRaw);
|
|
5376
|
+
if (values["expected-version"] !== void 0 && (expectedVersion === void 0 || !Number.isSafeInteger(expectedVersion) || expectedVersion < 0)) {
|
|
5377
|
+
throw usageError("--expected-version \u5FC5\u987B\u662F\u4E4B\u524D\u67E5\u770B\u7684\u975E\u8D1F\u6574\u6570\u7248\u672C\u53F7");
|
|
5378
|
+
}
|
|
5379
|
+
if (values["expected-credits"] !== void 0 && (expectedCredits === void 0 || !Number.isFinite(expectedCredits) || expectedCredits < 0)) {
|
|
5380
|
+
throw usageError("--expected-credits \u5FC5\u987B\u662F\u4E4B\u524D\u67E5\u770B\u7684\u975E\u8D1F\u6709\u9650\u91D1\u989D");
|
|
5381
|
+
}
|
|
5382
|
+
if (values.yes === true && (expectedVersion === void 0 || expectedCredits === void 0)) {
|
|
5383
|
+
throw usageError("\u786E\u8BA4\u652F\u51FA\u5FC5\u987B\u63D0\u4F9B\u4E4B\u524D\u67E5\u770B\u7684 --expected-version \u548C --expected-credits\uFF1B\u5148\u4E0D\u5E26 --yes \u67E5\u770B\u5F53\u524D\u786E\u8BA4\u5361");
|
|
5384
|
+
}
|
|
3526
5385
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
3527
5386
|
const fetched = await getVideoRun(baseUrl, apiKey, runId, io);
|
|
3528
5387
|
const run2 = fetched.view;
|
|
3529
|
-
const card = run2.nextActions.find((
|
|
5388
|
+
const card = run2.nextActions.find((action2) => action2.type === "confirm_production");
|
|
3530
5389
|
if (card === void 0) {
|
|
3531
5390
|
throw new CliError({
|
|
3532
5391
|
code: "CLI_USAGE",
|
|
@@ -3534,25 +5393,48 @@ async function confirm2(context, rawId) {
|
|
|
3534
5393
|
message: `\u73B0\u5728\u6CA1\u6709\u7B49\u7740\u786E\u8BA4\u7684\u5361\uFF08\u5F53\u524D\u72B6\u6001\uFF1A${run2.status}\uFF09\u3002\u5BFC\u6F14\u505C\u4E0B\u6765\u8981\u786E\u8BA4\u65F6\u518D\u8FD0\u884C\u8FD9\u6761\u547D\u4EE4`
|
|
3535
5394
|
});
|
|
3536
5395
|
}
|
|
3537
|
-
if (card.confirmation
|
|
5396
|
+
if (!card.confirmation || typeof card.confirmation !== "object" || Array.isArray(card.confirmation)) {
|
|
3538
5397
|
throw new CliError({
|
|
3539
5398
|
code: "CLI_USAGE",
|
|
3540
5399
|
exitCode: EXIT.USAGE,
|
|
3541
5400
|
message: "\u670D\u52A1\u7AEF\u6302\u51FA\u7684\u8FD9\u5F20\u5361\u4E0D\u5E26\u786E\u8BA4\u8EAB\u4EFD\uFF0C\u786E\u8BA4\u4E0D\u4E86\uFF1B\u7A0D\u540E\u91CD\u65B0\u8FD0\u884C buke videos status \u770B\u6700\u65B0\u72B6\u6001"
|
|
3542
5401
|
});
|
|
3543
5402
|
}
|
|
3544
|
-
const credits = card.credits
|
|
5403
|
+
const credits = card.credits;
|
|
5404
|
+
if (!Number.isSafeInteger(run2.version) || run2.version < 0 || typeof credits !== "number" || !Number.isFinite(credits) || credits < 0 || "credits" in card.confirmation && card.confirmation.credits !== credits) {
|
|
5405
|
+
throw new CliError({
|
|
5406
|
+
code: "CLI_BAD_RESPONSE",
|
|
5407
|
+
exitCode: EXIT.SERVER,
|
|
5408
|
+
message: "\u786E\u8BA4\u5361\u7248\u672C\u6216\u91D1\u989D\u65E0\u6548\uFF0C\u6216\u786E\u8BA4\u8EAB\u4EFD\u5185\u7684\u91D1\u989D\u4E0D\u4E00\u81F4\uFF1B\u672C\u6B21\u672A\u63D0\u4EA4\uFF0C\u8BF7\u91CD\u65B0\u67E5\u8BE2\u5F53\u524D\u786E\u8BA4\u5361"
|
|
5409
|
+
});
|
|
5410
|
+
}
|
|
5411
|
+
if (expectedVersion !== void 0 && expectedVersion !== run2.version || expectedCredits !== void 0 && expectedCredits !== credits) {
|
|
5412
|
+
throw new CliError({
|
|
5413
|
+
code: "OPEN_API_QUOTE_CHANGED",
|
|
5414
|
+
exitCode: EXIT.QUOTE_CHANGED,
|
|
5415
|
+
message: "\u786E\u8BA4\u5361\u7248\u672C\u6216\u91D1\u989D\u5DF2\u53D8\u5316\uFF0C\u672C\u6B21\u672A\u63D0\u4EA4\uFF1B\u8BF7\u91CD\u65B0\u67E5\u770B\u540E\u660E\u786E\u786E\u8BA4"
|
|
5416
|
+
});
|
|
5417
|
+
}
|
|
3545
5418
|
const kind = card.confirmKind === void 0 ? "\u786E\u8BA4" : `\u786E\u8BA4\uFF08${card.confirmKind}\uFF09`;
|
|
3546
5419
|
if (values.yes !== true) {
|
|
3547
5420
|
throw new CliError({
|
|
3548
5421
|
code: "CLI_USAGE",
|
|
3549
5422
|
exitCode: EXIT.USAGE,
|
|
3550
5423
|
message: `\u8FD9\u5F20\u5361\u8981\u82B1 ${credits} \u5E03\u3002\u52A0 --yes \u786E\u8BA4\u8FD9\u7B14\u5E03\u652F\u51FA`,
|
|
3551
|
-
hints: [
|
|
5424
|
+
hints: [
|
|
5425
|
+
`${kind}\uFF1A${singleLine(run2.label)}`,
|
|
5426
|
+
`\u770B\u8FC7\u518D\u786E\u8BA4\uFF1Abuke videos confirm ${run2.rootRunId} --expected-version ${run2.version} --expected-credits ${credits} --yes`
|
|
5427
|
+
]
|
|
3552
5428
|
});
|
|
3553
5429
|
}
|
|
3554
5430
|
const idempotencyKey = idempotencyKeyOf(values);
|
|
3555
|
-
|
|
5431
|
+
let outcome;
|
|
5432
|
+
try {
|
|
5433
|
+
outcome = await confirmVideoProduction(baseUrl, apiKey, runId, run2.version, card.confirmation, idempotencyKey, io);
|
|
5434
|
+
} catch (error) {
|
|
5435
|
+
const failure = toCliError(error);
|
|
5436
|
+
throw failure.withRecovery({ ...taskRecovery("videos", runId, run2.status, baseUrl), ...failure.recovery, acceptance: "confirmed" });
|
|
5437
|
+
}
|
|
3556
5438
|
out.result(
|
|
3557
5439
|
[...runLines(outcome.view), `\u5DF2\u786E\u8BA4\uFF1A\u8FD9\u7B14\u6700\u591A ${credits} \u5E03`, ...waitingLines(outcome.view), `\u5E42\u7B49\u952E\uFF1A${idempotencyKey}`],
|
|
3558
5440
|
{ run: outcome.raw.run, confirmed: { credits, confirmKind: card.confirmKind ?? null }, idempotencyKey }
|
|
@@ -3636,6 +5518,7 @@ var KEY_HOWTO = [
|
|
|
3636
5518
|
" 3. \u5728\u7EC8\u7AEF\u91CC\u76F4\u63A5\u8FD0\u884C buke login\uFF0C\u6309\u63D0\u793A\u7C98\u8D34\uFF08\u8F93\u5165\u4E0D\u4F1A\u663E\u793A\uFF09"
|
|
3637
5519
|
];
|
|
3638
5520
|
var COMMANDS = {
|
|
5521
|
+
web: webCommand,
|
|
3639
5522
|
graphic: graphicCommand,
|
|
3640
5523
|
login: {
|
|
3641
5524
|
run: login,
|
|
@@ -3781,7 +5664,7 @@ var COMMANDS = {
|
|
|
3781
5664
|
" buke shorts download <\u8BA2\u5355id> [--out <\u8DEF\u5F84>]",
|
|
3782
5665
|
" buke shorts cancel <\u8BA2\u5355id>",
|
|
3783
5666
|
"",
|
|
3784
|
-
"\
|
|
5667
|
+
"\u6A21\u677F\u77ED\u7247\uFF08\u6A21\u677F\u76F4\u51FA\u7684\u7AD6\u5C4F\u5546\u54C1\u77ED\u7247\uFF09\uFF1A",
|
|
3785
5668
|
" catalog \u5217\u51FA\u5168\u90E8\u6A21\u677F\uFF08id\u3001\u65F6\u957F\u3001\u8981\u54EA\u4E9B\u7D20\u6750\uFF09",
|
|
3786
5669
|
" upload \u6258\u7BA1\u4E00\u5F20\u7D20\u6750\u56FE\uFF0C\u6362\u56DE\u53EF\u4EE5\u76F4\u63A5\u586B\u8FDB\u6A21\u677F\u56FE\u7247\u69FD\u7684\u5730\u5740",
|
|
3787
5670
|
" quote \u53EA\u8BFB\u62A5\u4EF7\uFF1B\u6536\u8D39\u7684\u6A21\u677F\u4E0B\u5355\u524D\u5FC5\u987B\u5148\u62FF quoteHash",
|
|
@@ -3861,10 +5744,12 @@ var COMMANDS = {
|
|
|
3861
5744
|
" buke videos versions <\u89C6\u9891id>",
|
|
3862
5745
|
" buke videos music-list <\u89C6\u9891id>",
|
|
3863
5746
|
" buke videos music-quote <\u89C6\u9891id> --props <JSON\u6587\u4EF6|->",
|
|
3864
|
-
" buke videos music-compose <\u89C6\u9891id> --props <JSON\u6587\u4EF6|-> --
|
|
5747
|
+
" buke videos music-compose <\u89C6\u9891id> --props <JSON\u6587\u4EF6|-> --quote-hash <\u5DF2\u67E5\u770B\u62A5\u4EF7\u6807\u8BC6> --yes",
|
|
3865
5748
|
" buke videos music-apply <\u89C6\u9891id> --music-task-id <\u4EFB\u52A1id> --props <JSON\u6587\u4EF6|->",
|
|
3866
5749
|
" buke videos cancel <\u89C6\u9891id>",
|
|
3867
|
-
" buke videos confirm <\u89C6\u9891id>
|
|
5750
|
+
" buke videos confirm <\u89C6\u9891id> \u67E5\u770B\u5F53\u524D\u786E\u8BA4\u5361",
|
|
5751
|
+
" buke videos confirm <\u89C6\u9891id> --expected-version <\u5DF2\u67E5\u770B\u7248\u672C> --expected-credits <\u5DF2\u67E5\u770B\u91D1\u989D> --yes",
|
|
5752
|
+
" buke videos confirm <\u89C6\u9891id> --data <\u539F\u786E\u8BA4JSON> --idempotency-key <\u539F\u952E> --yes \u91CD\u653E\u539F\u786E\u8BA4",
|
|
3868
5753
|
" buke videos download <\u89C6\u9891id> [--production-id <\u5236\u4F5C\u7248\u672C>] [--edit-id <\u526A\u8F91\u7248\u672C>] [--out <\u8DEF\u5F84>]",
|
|
3869
5754
|
" buke videos download <\u89C6\u9891id> --music-task-id <\u4EFB\u52A1id> --track-index <0|1> [--out <\u8DEF\u5F84>]",
|
|
3870
5755
|
" buke videos download <\u89C6\u9891id> [--append-task-id <\u63D2\u6BB5\u4EFB\u52A1>] [--narration-edit-id <\u914D\u97F3\u7248\u672C>] [--out <\u8DEF\u5F84>]",
|
|
@@ -3874,7 +5759,7 @@ var COMMANDS = {
|
|
|
3874
5759
|
" create \u521B\u5EFA\u4EFB\u52A1\uFF1B\u987B\u5148\u5EFA\u7ACB\u4EA7\u54C1\u3002\u53D7\u7406\u540E\u901A\u8FC7 status \u67E5\u8BE2\u8FDB\u5EA6",
|
|
3875
5760
|
" status \u67E5\u8BE2\u8FDB\u5EA6\uFF1B--wait \u7B49\u5F85\u7EC8\u6001\u6216\u9700\u8981\u7528\u6237\u5904\u7406\u7684\u72B6\u6001",
|
|
3876
5761
|
" message \u63D0\u4EA4\u5236\u4F5C\u8981\u6C42\u3001\u95EE\u9898\u56DE\u590D\u3001\u9644\u4EF6\u6216\u7ED3\u6784\u5316\u9009\u9879",
|
|
3877
|
-
" confirm \
|
|
5762
|
+
" confirm \u5BF9\u7167\u5DF2\u67E5\u770B\u7684\u7248\u672C\u548C\u91D1\u989D\uFF0C\u63D0\u4EA4\u540C\u4E00\u786E\u8BA4\u5361\uFF1B\u53D8\u5316\u65F6\u4E0D\u63D0\u4EA4",
|
|
3878
5763
|
" download \u4E0B\u8F7D\u6210\u7247\uFF08mp4\uFF09",
|
|
3879
5764
|
"",
|
|
3880
5765
|
"\u9009\u9879\uFF1A",
|
|
@@ -3896,7 +5781,7 @@ var COMMANDS = {
|
|
|
3896
5781
|
].join("\n")
|
|
3897
5782
|
},
|
|
3898
5783
|
drama: {
|
|
3899
|
-
run:
|
|
5784
|
+
run: drama2,
|
|
3900
5785
|
acceptsBaseUrl: true,
|
|
3901
5786
|
options: ["file", "offset", "attachment-id", "text", "data", "expected-epoch", "kind", "episode-number", "confirmation-id", "shot", "output-id", "edit-id", "source-output-id", "attachment-ids", "product", "genre", "duration", "brief", "model", "resolution", "quote-hash", "yes", "wait", "timeout", "out", "idempotency-key"],
|
|
3902
5787
|
positionals: ["\u5B50\u547D\u4EE4", "\u8BA2\u5355id"],
|
|
@@ -3947,6 +5832,18 @@ var COMMANDS = {
|
|
|
3947
5832
|
].join("\n")
|
|
3948
5833
|
}
|
|
3949
5834
|
};
|
|
5835
|
+
for (const resource of ["videos", "drama", "graphic", "series"]) {
|
|
5836
|
+
const command = COMMANDS[resource];
|
|
5837
|
+
const runOriginal = command.run;
|
|
5838
|
+
COMMANDS[resource] = {
|
|
5839
|
+
...command,
|
|
5840
|
+
options: [.../* @__PURE__ */ new Set([...command.options, ...STUDIO_ACTION_OPTIONS])],
|
|
5841
|
+
help: command.help + STUDIO_ACTION_HELP(resource),
|
|
5842
|
+
run: async (context) => {
|
|
5843
|
+
if (!await tryStudioAction(resource, context)) await runOriginal(context);
|
|
5844
|
+
}
|
|
5845
|
+
};
|
|
5846
|
+
}
|
|
3950
5847
|
var GENERAL_HELP = [
|
|
3951
5848
|
"buke\uFF1A\u300A\u4E0D\u53EF\u601D\u8BAE\u300B\u7684\u547D\u4EE4\u884C\u5DE5\u5177",
|
|
3952
5849
|
"",
|
|
@@ -3956,13 +5853,14 @@ var GENERAL_HELP = [
|
|
|
3956
5853
|
" buke logout [--json] \u9000\u51FA\u767B\u5F55\uFF0C\u5220\u9664\u672C\u673A\u4FDD\u5B58\u7684\u5BC6\u94A5",
|
|
3957
5854
|
" buke balance [--json] \u67E5\u8BE2\u8D26\u6237\u4F59\u989D",
|
|
3958
5855
|
" buke products <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u4EA7\u54C1\u5EFA\u6863\u4E0E\u7BA1\u7406\uFF1Alist\u3001show\u3001create\u3001update\u3001archive\u3001restore",
|
|
3959
|
-
" buke shorts <\u5B50\u547D\u4EE4> [\u53C2\u6570] \
|
|
5856
|
+
" buke shorts <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u6A21\u677F\u77ED\u7247\uFF1Acatalog\u3001upload\u3001quote\u3001order\u3001status\u3001download\u3001cancel",
|
|
3960
5857
|
" buke videos <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u5546\u54C1\u89C6\u9891\uFF1A\u521B\u4F5C\u3001\u786E\u8BA4\u3001\u7248\u672C\u3001\u914D\u4E50\u548C\u4E0B\u8F7D",
|
|
3961
5858
|
" buke drama <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u77ED\u5267\uFF1A\u5267\u672C\u3001\u5206\u955C\u3001\u4EBA\u666F\u7ED1\u5B9A\u3001\u62A5\u4EF7\u3001\u91CD\u62CD\u548C\u4EA4\u4ED8",
|
|
3962
5859
|
" buke library <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u4F5C\u54C1\u67E5\u8BE2\u3001\u641C\u7D22\u3001\u91CD\u547D\u540D\u3001\u5F52\u6863\u53CA\u6062\u590D",
|
|
3963
5860
|
" buke assets <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u5E73\u53F0\u4E0E\u4E2A\u4EBA\u7D20\u6750\u67E5\u8BE2\u3001\u4E0A\u4F20\u53CA\u7BA1\u7406",
|
|
3964
5861
|
" buke graphic <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u56FE\u6587\u65B9\u6848\u3001\u62A5\u4EF7\u3001\u751F\u6210\u3001\u7F16\u8F91\u53CA\u4E0B\u8F7D",
|
|
3965
5862
|
" buke series <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u591A\u96C6\u77ED\u5267\u67E5\u8BE2\u3001\u521B\u5EFA\u53CA\u7EED\u96C6",
|
|
5863
|
+
" buke web <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u7F51\u9875\u4F1A\u8BDD\uFF1A\u767B\u5F55\u3001\u64CD\u4F5C\u76EE\u5F55\u4E0E\u7F51\u9875\u529F\u80FD\u8C03\u7528\uFF08\u5145\u503C\u9664\u5916\uFF09",
|
|
3966
5864
|
" buke --help | -h \u663E\u793A\u8FD9\u4EFD\u8BF4\u660E\uFF1Bbuke <\u547D\u4EE4> --help \u770B\u5355\u6761\u547D\u4EE4",
|
|
3967
5865
|
" buke --version | -v \u663E\u793A\u7248\u672C\u53F7",
|
|
3968
5866
|
"",
|
|
@@ -4033,7 +5931,7 @@ var BOOLEAN_OPTIONS = /* @__PURE__ */ new Set(["help", "version", "json", "wait"
|
|
|
4033
5931
|
for (const command of Object.values(COMMANDS)) for (const option of command.options) {
|
|
4034
5932
|
if (!BOOLEAN_OPTIONS.has(option)) STRING_OPTIONS.add(option);
|
|
4035
5933
|
}
|
|
4036
|
-
function
|
|
5934
|
+
function parse2(argv) {
|
|
4037
5935
|
try {
|
|
4038
5936
|
const options = {};
|
|
4039
5937
|
for (const name2 of STRING_OPTIONS) options[name2] = { type: "string" };
|
|
@@ -4076,7 +5974,7 @@ async function dispatch(argv, io, out) {
|
|
|
4076
5974
|
message: "\u5BC6\u94A5\u4E0D\u8981\u5199\u5728\u547D\u4EE4\u884C\u91CC\uFF08\u4F1A\u7559\u5728 shell \u5386\u53F2\u548C\u8FDB\u7A0B\u5217\u8868\u91CC\uFF09\u3002\u8BF7\u7528\u73AF\u5883\u53D8\u91CF BUKE_API_KEY\uFF0C\u6216\u8005\u901A\u8FC7\u7BA1\u9053\u4F20\u7ED9 buke login\u3002\u521A\u624D\u8FD9\u628A\u5982\u679C\u662F\u771F\u7684\uFF0C\u5EFA\u8BAE\u540A\u9500\u540E\u91CD\u65B0\u521B\u5EFA\u3002"
|
|
4077
5975
|
});
|
|
4078
5976
|
}
|
|
4079
|
-
const parsed =
|
|
5977
|
+
const parsed = parse2(argv);
|
|
4080
5978
|
const command = parsed.command !== void 0 && Object.hasOwn(COMMANDS, parsed.command) ? COMMANDS[parsed.command] : void 0;
|
|
4081
5979
|
if (parsed.command !== void 0 && !command) throw usageError(`\u4E0D\u8BA4\u8BC6\u7684\u547D\u4EE4 ${echo(parsed.command)}`);
|
|
4082
5980
|
const args = parsed.positionals.slice(1);
|