@lingjingai/lj-awb-cli 0.4.5 → 0.4.8
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 +1 -5
- package/install.mjs +11 -3
- package/package.json +4 -3
- package/packages/awb-cli/package.json +2 -2
- package/packages/awb-core/package.json +1 -2
- package/packages/awb-core/src/api.js +13 -3
- package/packages/awb-core/src/commands.js +31 -460
- package/packages/awb-core/src/common.js +12 -0
- package/packages/awb-core/src/output.js +14 -286
- package/packages/awb-core/src/services.js +123 -5
- package/packages/awb-core/src/standalone.js +20 -184
- package/skills/lj-awb/SKILL.md +6 -7
- package/skills/lj-awb/VERSION +1 -1
- package/skills/lj-awb/compat.json +3 -3
- package/skills/lj-awb/modules/account.md +5 -3
- package/skills/lj-awb/modules/credits.md +19 -2
- package/skills/lj-awb/modules/driver.md +1 -10
- package/skills/lj-awb/modules/image.md +1 -1
- package/skills/lj-awb/modules/project.md +2 -2
- package/skills/lj-awb/modules/task.md +1 -1
- package/skills/lj-awb/modules/video.md +1 -1
- package/skills/lj-awb/modules/workflows.md +0 -75
- package/skills/lj-awb/references/error-codes.md +18 -1
- package/skills/lj-awb/references/output-fields.md +5 -10
- package/packages/awb-core/src/artifact.js +0 -936
- package/skills/lj-awb/modules/artifact/asset.md +0 -64
- package/skills/lj-awb/modules/artifact/clip.md +0 -65
- package/skills/lj-awb/modules/artifact/script.md +0 -37
- package/skills/lj-awb/modules/artifact/video.md +0 -65
- package/skills/lj-awb/modules/artifact.md +0 -65
|
@@ -435,136 +435,6 @@ function normalizeList(data = {}, keys) {
|
|
|
435
435
|
});
|
|
436
436
|
}
|
|
437
437
|
|
|
438
|
-
function normalizeArtifactList(commandName, data) {
|
|
439
|
-
if (Array.isArray(data)) {
|
|
440
|
-
return compactRecord({ count: data.length, items: cleanNested(data) });
|
|
441
|
-
}
|
|
442
|
-
if (!isPlainObject(data)) return cleanNested(data);
|
|
443
|
-
const arrayKey = Object.keys(data).find((key) => Array.isArray(data[key]));
|
|
444
|
-
if (arrayKey) {
|
|
445
|
-
return compactRecord({
|
|
446
|
-
count: data.count ?? data[arrayKey].length,
|
|
447
|
-
[arrayKey]: cleanNested(data[arrayKey]),
|
|
448
|
-
...Object.fromEntries(
|
|
449
|
-
Object.entries(data)
|
|
450
|
-
.filter(([key]) => key !== arrayKey && key !== 'raw')
|
|
451
|
-
.map(([key, value]) => [key, cleanNested(value)]),
|
|
452
|
-
),
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
return cleanNested(data);
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
function normalizeArtifactRecord(data) {
|
|
459
|
-
if (!isPlainObject(data)) return cleanNested(data);
|
|
460
|
-
const out = compactRecord({
|
|
461
|
-
id: data.id,
|
|
462
|
-
projectId: data.projectId,
|
|
463
|
-
rowKind: data.rowKind,
|
|
464
|
-
entityKey: data.entityKey,
|
|
465
|
-
parentKey: data.parentKey,
|
|
466
|
-
sortOrder: data.sortOrder,
|
|
467
|
-
actorKey: data.actorKey,
|
|
468
|
-
propKey: data.propKey,
|
|
469
|
-
locationKey: data.locationKey,
|
|
470
|
-
stateKey: data.stateKey,
|
|
471
|
-
episodeId: data.episodeId,
|
|
472
|
-
sceneId: data.sceneId,
|
|
473
|
-
clipId: data.clipId,
|
|
474
|
-
videoEpisodeId: data.videoEpisodeId,
|
|
475
|
-
status: data.status,
|
|
476
|
-
title: data.title,
|
|
477
|
-
name: data.name,
|
|
478
|
-
displayName: data.displayName,
|
|
479
|
-
description: data.description,
|
|
480
|
-
});
|
|
481
|
-
for (const [key, value] of Object.entries(data)) {
|
|
482
|
-
if (key in out) continue;
|
|
483
|
-
if (Array.isArray(value)) out[`${key}Count`] = value.length;
|
|
484
|
-
else if (!isPlainObject(value)) out[key] = value;
|
|
485
|
-
}
|
|
486
|
-
return cleanNested(out);
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
function normalizeArtifactFull(data) {
|
|
490
|
-
if (!isPlainObject(data)) return cleanNested(data);
|
|
491
|
-
const out = compactRecord({
|
|
492
|
-
projectId: data.projectId,
|
|
493
|
-
id: data.id,
|
|
494
|
-
title: data.title,
|
|
495
|
-
status: data.status,
|
|
496
|
-
});
|
|
497
|
-
for (const [key, value] of Object.entries(data)) {
|
|
498
|
-
if (Array.isArray(value)) out[`${key}Count`] = value.length;
|
|
499
|
-
else if (isPlainObject(value)) {
|
|
500
|
-
const innerKey = Object.keys(value).find((k) => Array.isArray(value[k]));
|
|
501
|
-
if (innerKey) out[`${key}.${innerKey}Count`] = value[innerKey].length;
|
|
502
|
-
} else if (!(key in out)) out[key] = value;
|
|
503
|
-
}
|
|
504
|
-
return out;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
function normalizeArtifactImport(data = {}) {
|
|
508
|
-
if (!isPlainObject(data)) return cleanNested(data);
|
|
509
|
-
return compactRecord({
|
|
510
|
-
imported: data.imported,
|
|
511
|
-
dryRun: data.dryRun,
|
|
512
|
-
action: data.action,
|
|
513
|
-
projectId: data.projectId,
|
|
514
|
-
sourceFile: data.sourceFile,
|
|
515
|
-
inputDir: data.inputDir,
|
|
516
|
-
inputFile: data.inputFile,
|
|
517
|
-
rowCount: data.rowCount,
|
|
518
|
-
actorCount: data.actorCount,
|
|
519
|
-
propCount: data.propCount,
|
|
520
|
-
locationCount: data.locationCount,
|
|
521
|
-
episodeCount: data.episodeCount,
|
|
522
|
-
sceneCount: data.sceneCount,
|
|
523
|
-
clipCount: data.clipCount,
|
|
524
|
-
batchCount: Array.isArray(data.batch) ? data.batch.length : undefined,
|
|
525
|
-
rowsByKind: data.rowsByKind,
|
|
526
|
-
files: isPlainObject(data.files)
|
|
527
|
-
? compactRecord({
|
|
528
|
-
actors: data.files.actorsFile,
|
|
529
|
-
props: data.files.propsFile,
|
|
530
|
-
locations: data.files.locationsFile,
|
|
531
|
-
})
|
|
532
|
-
: undefined,
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
function normalizeArtifactWrite(data) {
|
|
537
|
-
if (!isPlainObject(data)) return cleanNested(data);
|
|
538
|
-
return normalizeArtifactRecord(data);
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
function normalizeArtifactDelete(data) {
|
|
542
|
-
if (!isPlainObject(data)) return cleanNested(data);
|
|
543
|
-
return compactRecord({
|
|
544
|
-
deleted: data.deleted ?? true,
|
|
545
|
-
action: data.action,
|
|
546
|
-
projectId: data.projectId,
|
|
547
|
-
key: data.key,
|
|
548
|
-
stateKey: data.stateKey,
|
|
549
|
-
episodeId: data.episodeId,
|
|
550
|
-
sceneId: data.sceneId,
|
|
551
|
-
clipId: data.clipId,
|
|
552
|
-
videoEpisodeId: data.videoEpisodeId,
|
|
553
|
-
rowKind: data.rowKind,
|
|
554
|
-
entityKey: data.entityKey,
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
function normalizeArtifactStatus(data) {
|
|
559
|
-
if (!isPlainObject(data)) return cleanNested(data);
|
|
560
|
-
return compactRecord({
|
|
561
|
-
updated: data.updated ?? true,
|
|
562
|
-
videoEpisodeId: data.videoEpisodeId ?? data.id,
|
|
563
|
-
status: data.status,
|
|
564
|
-
messageCount: Array.isArray(data.messages) ? data.messages.length : undefined,
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
|
|
568
438
|
export function normalizeOutputData(commandName, data) {
|
|
569
439
|
if (!isPlainObject(data)) return cleanNested(data);
|
|
570
440
|
switch (commandName) {
|
|
@@ -595,7 +465,7 @@ export function normalizeOutputData(commandName, data) {
|
|
|
595
465
|
case 'credits balance':
|
|
596
466
|
return normalizeCredits(data);
|
|
597
467
|
case 'project current':
|
|
598
|
-
case 'project
|
|
468
|
+
case 'project switch':
|
|
599
469
|
case 'project create':
|
|
600
470
|
case 'project update':
|
|
601
471
|
case 'project ensure':
|
|
@@ -645,88 +515,6 @@ export function normalizeOutputData(commandName, data) {
|
|
|
645
515
|
default:
|
|
646
516
|
break;
|
|
647
517
|
}
|
|
648
|
-
if (commandName?.startsWith('artifact ')) {
|
|
649
|
-
return normalizeArtifactByCommand(commandName, data);
|
|
650
|
-
}
|
|
651
|
-
return cleanNested(data);
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
const ARTIFACT_LIST_COMMANDS = new Set([
|
|
655
|
-
'artifact script rows',
|
|
656
|
-
'artifact script children',
|
|
657
|
-
'artifact asset actors',
|
|
658
|
-
'artifact asset props',
|
|
659
|
-
'artifact asset locations',
|
|
660
|
-
'artifact video episodes',
|
|
661
|
-
'artifact video scenes',
|
|
662
|
-
'artifact video clips',
|
|
663
|
-
'artifact clip episodes',
|
|
664
|
-
]);
|
|
665
|
-
|
|
666
|
-
const ARTIFACT_RECORD_COMMANDS = new Set([
|
|
667
|
-
'artifact script document',
|
|
668
|
-
'artifact script row',
|
|
669
|
-
'artifact asset actor',
|
|
670
|
-
'artifact asset prop',
|
|
671
|
-
'artifact asset location',
|
|
672
|
-
'artifact video episode',
|
|
673
|
-
'artifact video scene',
|
|
674
|
-
'artifact video clip',
|
|
675
|
-
'artifact clip episode',
|
|
676
|
-
'artifact clip episode-by-id',
|
|
677
|
-
]);
|
|
678
|
-
|
|
679
|
-
const ARTIFACT_FULL_COMMANDS = new Set([
|
|
680
|
-
'artifact script get',
|
|
681
|
-
'artifact asset get',
|
|
682
|
-
'artifact video get',
|
|
683
|
-
'artifact clip get',
|
|
684
|
-
]);
|
|
685
|
-
|
|
686
|
-
const ARTIFACT_IMPORT_COMMANDS = new Set([
|
|
687
|
-
'artifact script import',
|
|
688
|
-
'artifact asset import',
|
|
689
|
-
'artifact video import-storyboard',
|
|
690
|
-
'artifact clip upsert-batch',
|
|
691
|
-
]);
|
|
692
|
-
|
|
693
|
-
const ARTIFACT_WRITE_COMMANDS = new Set([
|
|
694
|
-
'artifact script upsert-row',
|
|
695
|
-
'artifact asset upsert-actor',
|
|
696
|
-
'artifact asset upsert-prop',
|
|
697
|
-
'artifact asset upsert-location',
|
|
698
|
-
'artifact asset upsert-actor-state',
|
|
699
|
-
'artifact asset upsert-prop-state',
|
|
700
|
-
'artifact asset upsert-location-state',
|
|
701
|
-
'artifact video upsert-episode',
|
|
702
|
-
'artifact video upsert-scene',
|
|
703
|
-
'artifact video upsert-clip',
|
|
704
|
-
'artifact video update-clip-urls',
|
|
705
|
-
'artifact clip upsert-episode',
|
|
706
|
-
]);
|
|
707
|
-
|
|
708
|
-
const ARTIFACT_DELETE_COMMANDS = new Set([
|
|
709
|
-
'artifact script delete-row',
|
|
710
|
-
'artifact asset delete-actor',
|
|
711
|
-
'artifact asset delete-prop',
|
|
712
|
-
'artifact asset delete-location',
|
|
713
|
-
'artifact asset delete-actor-state',
|
|
714
|
-
'artifact asset delete-prop-state',
|
|
715
|
-
'artifact asset delete-location-state',
|
|
716
|
-
'artifact video delete-episode',
|
|
717
|
-
'artifact video delete-scene',
|
|
718
|
-
'artifact video delete-clip',
|
|
719
|
-
'artifact clip delete-episode',
|
|
720
|
-
]);
|
|
721
|
-
|
|
722
|
-
function normalizeArtifactByCommand(commandName, data) {
|
|
723
|
-
if (ARTIFACT_LIST_COMMANDS.has(commandName)) return normalizeArtifactList(commandName, data);
|
|
724
|
-
if (ARTIFACT_RECORD_COMMANDS.has(commandName)) return normalizeArtifactRecord(data);
|
|
725
|
-
if (ARTIFACT_FULL_COMMANDS.has(commandName)) return normalizeArtifactFull(data);
|
|
726
|
-
if (ARTIFACT_IMPORT_COMMANDS.has(commandName)) return normalizeArtifactImport(data);
|
|
727
|
-
if (ARTIFACT_WRITE_COMMANDS.has(commandName)) return normalizeArtifactWrite(data);
|
|
728
|
-
if (ARTIFACT_DELETE_COMMANDS.has(commandName)) return normalizeArtifactDelete(data);
|
|
729
|
-
if (commandName === 'artifact clip update-status') return normalizeArtifactStatus(data);
|
|
730
518
|
return cleanNested(data);
|
|
731
519
|
}
|
|
732
520
|
|
|
@@ -1393,13 +1181,15 @@ const OUTPUT_KIND_BY_COMMAND = {
|
|
|
1393
1181
|
'account switch-team': 'generic',
|
|
1394
1182
|
'project list': 'project_list',
|
|
1395
1183
|
'project current': 'project_summary',
|
|
1396
|
-
'project
|
|
1184
|
+
'project switch': 'generic',
|
|
1397
1185
|
'project users': 'project_user_list',
|
|
1398
1186
|
'project create': 'generic',
|
|
1399
1187
|
'project update': 'generic',
|
|
1400
1188
|
'project ensure': 'generic',
|
|
1401
1189
|
'credits balance': 'credits_balance',
|
|
1402
1190
|
'credits usage': 'credits_usage',
|
|
1191
|
+
'credits buy': 'purchase_guide',
|
|
1192
|
+
'credits redeem': 'redeem_result',
|
|
1403
1193
|
'model image-models': 'model_list',
|
|
1404
1194
|
'model video-models': 'model_list',
|
|
1405
1195
|
'model asset-review-models': 'asset_review_model_list',
|
|
@@ -1430,57 +1220,6 @@ const OUTPUT_KIND_BY_COMMAND = {
|
|
|
1430
1220
|
'create asset-group': 'asset_group_write_result',
|
|
1431
1221
|
'create asset-group-update': 'asset_group_write_result',
|
|
1432
1222
|
'create asset': 'asset_register_result',
|
|
1433
|
-
'artifact script get': 'artifact_full',
|
|
1434
|
-
'artifact script document': 'artifact_record',
|
|
1435
|
-
'artifact script rows': 'artifact_list',
|
|
1436
|
-
'artifact script row': 'artifact_record',
|
|
1437
|
-
'artifact script children': 'artifact_list',
|
|
1438
|
-
'artifact script upsert-row': 'artifact_write_result',
|
|
1439
|
-
'artifact script delete-row': 'artifact_delete_result',
|
|
1440
|
-
'artifact script import': 'artifact_import_result',
|
|
1441
|
-
'artifact asset get': 'artifact_full',
|
|
1442
|
-
'artifact asset actors': 'artifact_list',
|
|
1443
|
-
'artifact asset actor': 'artifact_record',
|
|
1444
|
-
'artifact asset props': 'artifact_list',
|
|
1445
|
-
'artifact asset prop': 'artifact_record',
|
|
1446
|
-
'artifact asset locations': 'artifact_list',
|
|
1447
|
-
'artifact asset location': 'artifact_record',
|
|
1448
|
-
'artifact asset upsert-actor': 'artifact_write_result',
|
|
1449
|
-
'artifact asset upsert-prop': 'artifact_write_result',
|
|
1450
|
-
'artifact asset upsert-location': 'artifact_write_result',
|
|
1451
|
-
'artifact asset upsert-actor-state': 'artifact_write_result',
|
|
1452
|
-
'artifact asset upsert-prop-state': 'artifact_write_result',
|
|
1453
|
-
'artifact asset upsert-location-state': 'artifact_write_result',
|
|
1454
|
-
'artifact asset delete-actor': 'artifact_delete_result',
|
|
1455
|
-
'artifact asset delete-prop': 'artifact_delete_result',
|
|
1456
|
-
'artifact asset delete-location': 'artifact_delete_result',
|
|
1457
|
-
'artifact asset delete-actor-state': 'artifact_delete_result',
|
|
1458
|
-
'artifact asset delete-prop-state': 'artifact_delete_result',
|
|
1459
|
-
'artifact asset delete-location-state': 'artifact_delete_result',
|
|
1460
|
-
'artifact asset import': 'artifact_import_result',
|
|
1461
|
-
'artifact video get': 'artifact_full',
|
|
1462
|
-
'artifact video episodes': 'artifact_list',
|
|
1463
|
-
'artifact video episode': 'artifact_record',
|
|
1464
|
-
'artifact video scenes': 'artifact_list',
|
|
1465
|
-
'artifact video scene': 'artifact_record',
|
|
1466
|
-
'artifact video clips': 'artifact_list',
|
|
1467
|
-
'artifact video clip': 'artifact_record',
|
|
1468
|
-
'artifact video upsert-episode': 'artifact_write_result',
|
|
1469
|
-
'artifact video upsert-scene': 'artifact_write_result',
|
|
1470
|
-
'artifact video upsert-clip': 'artifact_write_result',
|
|
1471
|
-
'artifact video update-clip-urls': 'artifact_write_result',
|
|
1472
|
-
'artifact video delete-episode': 'artifact_delete_result',
|
|
1473
|
-
'artifact video delete-scene': 'artifact_delete_result',
|
|
1474
|
-
'artifact video delete-clip': 'artifact_delete_result',
|
|
1475
|
-
'artifact video import-storyboard': 'artifact_import_result',
|
|
1476
|
-
'artifact clip get': 'artifact_full',
|
|
1477
|
-
'artifact clip episodes': 'artifact_list',
|
|
1478
|
-
'artifact clip episode': 'artifact_record',
|
|
1479
|
-
'artifact clip episode-by-id': 'artifact_record',
|
|
1480
|
-
'artifact clip upsert-episode': 'artifact_write_result',
|
|
1481
|
-
'artifact clip upsert-batch': 'artifact_import_result',
|
|
1482
|
-
'artifact clip update-status': 'artifact_status_update',
|
|
1483
|
-
'artifact clip delete-episode': 'artifact_delete_result',
|
|
1484
1223
|
'create subject-list': 'subject_list',
|
|
1485
1224
|
'create subject': 'subject_publish_result',
|
|
1486
1225
|
'create subject-wait': 'subject_status',
|
|
@@ -1493,13 +1232,6 @@ const OUTPUT_KIND_BY_COMMAND = {
|
|
|
1493
1232
|
|
|
1494
1233
|
const KIND_TITLES = {
|
|
1495
1234
|
account_summary: '账号概览',
|
|
1496
|
-
artifact_delete_result: '最终产物删除结果',
|
|
1497
|
-
artifact_full: '最终产物详情',
|
|
1498
|
-
artifact_import_result: '最终产物导入结果',
|
|
1499
|
-
artifact_list: '最终产物列表',
|
|
1500
|
-
artifact_record: '最终产物记录',
|
|
1501
|
-
artifact_status_update: '剪辑状态更新结果',
|
|
1502
|
-
artifact_write_result: '最终产物写入结果',
|
|
1503
1235
|
asset_group_detail: '素材组详情',
|
|
1504
1236
|
asset_group_list: '素材组列表',
|
|
1505
1237
|
asset_group_write_result: '素材组写入结果',
|
|
@@ -1525,6 +1257,8 @@ const KIND_TITLES = {
|
|
|
1525
1257
|
project_list: '项目组列表',
|
|
1526
1258
|
project_summary: '项目组摘要',
|
|
1527
1259
|
project_user_list: '项目组成员',
|
|
1260
|
+
purchase_guide: '购买引导',
|
|
1261
|
+
redeem_result: '兑换结果',
|
|
1528
1262
|
subject_list: '主体列表',
|
|
1529
1263
|
subject_publish_result: '主体创建结果',
|
|
1530
1264
|
subject_status: '主体状态',
|
|
@@ -1548,7 +1282,7 @@ const COMMAND_TITLES = {
|
|
|
1548
1282
|
'auth clear': '清空认证结果',
|
|
1549
1283
|
'auth logout': '退出登录结果',
|
|
1550
1284
|
'account switch-team': '团队切换结果',
|
|
1551
|
-
'project
|
|
1285
|
+
'project switch': '项目组切换结果',
|
|
1552
1286
|
'project create': '项目组创建结果',
|
|
1553
1287
|
'project update': '项目组更新结果',
|
|
1554
1288
|
'project ensure': '项目组确保结果',
|
|
@@ -1598,6 +1332,9 @@ const FIELD_LABELS = {
|
|
|
1598
1332
|
cleared: '已清空',
|
|
1599
1333
|
loggedOut: '已退出登录',
|
|
1600
1334
|
authPath: '认证文件',
|
|
1335
|
+
purchaseUrl: '购买链接',
|
|
1336
|
+
redeemed: '已兑换',
|
|
1337
|
+
redemptionCode: '兑换码',
|
|
1601
1338
|
clipCount: 'Clip 数',
|
|
1602
1339
|
clipId: 'Clip ID',
|
|
1603
1340
|
command: '命令',
|
|
@@ -1750,12 +1487,6 @@ const FIELD_LABELS = {
|
|
|
1750
1487
|
|
|
1751
1488
|
const DETAIL_FIELDS_BY_KIND = {
|
|
1752
1489
|
account_summary: ['userId', 'userName', 'groupId', 'groupName', 'currentProjectGroupNo', 'currentProjectGroupName', 'billingPointBalance', 'projectBudgetBalance', 'projectBudgetMax'],
|
|
1753
|
-
artifact_delete_result: ['deleted', 'action', 'projectId', 'rowKind', 'entityKey', 'key', 'stateKey', 'episodeId', 'sceneId', 'clipId', 'videoEpisodeId'],
|
|
1754
|
-
artifact_full: ['projectId', 'id', 'title', 'status', 'rowCount', 'actorCount', 'propCount', 'locationCount', 'episodeCount', 'sceneCount', 'clipCount'],
|
|
1755
|
-
artifact_import_result: ['imported', 'dryRun', 'action', 'projectId', 'sourceFile', 'inputDir', 'inputFile', 'rowCount', 'actorCount', 'propCount', 'locationCount', 'episodeCount', 'sceneCount', 'clipCount', 'batchCount'],
|
|
1756
|
-
artifact_record: ['id', 'projectId', 'rowKind', 'entityKey', 'parentKey', 'actorKey', 'propKey', 'locationKey', 'stateKey', 'episodeId', 'sceneId', 'clipId', 'videoEpisodeId', 'status', 'title', 'name', 'displayName', 'description'],
|
|
1757
|
-
artifact_status_update: ['updated', 'videoEpisodeId', 'status', 'messageCount'],
|
|
1758
|
-
artifact_write_result: ['id', 'projectId', 'rowKind', 'entityKey', 'parentKey', 'actorKey', 'propKey', 'locationKey', 'stateKey', 'episodeId', 'sceneId', 'clipId', 'videoEpisodeId', 'status', 'title', 'name', 'displayName'],
|
|
1759
1490
|
asset_group_detail: ['groupId', 'platform', 'name', 'projectName', 'description', 'status', 'assetCount'],
|
|
1760
1491
|
asset_group_write_result: ['created', 'updated', 'groupId', 'platform', 'name', 'projectName', 'assetPath'],
|
|
1761
1492
|
asset_register_result: ['created', 'updated', 'registered', 'assetId', 'groupId', 'platform', 'assetType', 'name', 'projectName', 'assetPath', 'validationLegal', 'conversionRequired', 'converted', 'conversionReason', 'conversionTargetFormat', 'conversionTargetWidth', 'conversionTargetHeight', 'conversionTargetPixels', 'conversionTargetFps', 'conversionTargetDuration', 'uploadBackendPath', 'uploadUrl'],
|
|
@@ -1771,6 +1502,8 @@ const DETAIL_FIELDS_BY_KIND = {
|
|
|
1771
1502
|
generic: ['cleared', 'selected', 'created', 'updated', 'reused', 'dryRun', 'action', 'projectGroupNo', 'projectGroupName', 'groupId', 'groupName', 'projectGroupName', 'point', 'memberCount', 'note'],
|
|
1772
1503
|
local_task_records: ['count', 'taskCount', 'successTaskCount', 'resultCount', 'pointTotal'],
|
|
1773
1504
|
project_summary: ['selected', 'created', 'updated', 'reused', 'projectGroupNo', 'projectGroupName', 'isSelected', 'projectBudgetBalance', 'projectBudgetMax', 'memberCount'],
|
|
1505
|
+
purchase_guide: ['purchaseUrl'],
|
|
1506
|
+
redeem_result: ['redeemed', 'redemptionCode', 'billingPointBalance', 'currentProjectGroupNo', 'currentProjectGroupName', 'projectBudgetBalance', 'projectBudgetMax'],
|
|
1774
1507
|
subject_publish_result: ['created', 'name', 'elementId', 'subjectId', 'externalId', 'modelCode', 'status', 'taskStatus', 'errorMessage', 'nextRefSubject'],
|
|
1775
1508
|
subject_status: ['name', 'elementId', 'subjectId', 'externalId', 'modelCode', 'status', 'taskStatus', 'errorMessage', 'isTerminal', 'nextRefSubject'],
|
|
1776
1509
|
subject_voice_create_result: ['created', 'name', 'voiceRecordId', 'reqTaskId', 'voiceId', 'externalId', 'status', 'taskStatus', 'errorMessage', 'nextVoiceArg'],
|
|
@@ -1787,10 +1520,11 @@ const DRY_RUN_FIELDS_BY_COMMAND = {
|
|
|
1787
1520
|
'auth login': ['dryRun', 'saved', 'verified', 'accessKey'],
|
|
1788
1521
|
'auth clear': ['dryRun', 'action', 'cleared'],
|
|
1789
1522
|
'account switch-team': ['dryRun', 'action', 'groupId', 'selected'],
|
|
1790
|
-
'project
|
|
1523
|
+
'project switch': ['dryRun', 'action', 'projectGroupNo', 'selected'],
|
|
1791
1524
|
'project create': ['dryRun', 'action', 'projectGroupName', 'point', 'memberCount', 'note'],
|
|
1792
1525
|
'project update': ['dryRun', 'action', 'projectGroupNo', 'projectGroupName', 'point', 'memberCount'],
|
|
1793
1526
|
'project ensure': ['dryRun', 'action', 'projectGroupName', 'point', 'memberCount', 'note'],
|
|
1527
|
+
'credits redeem': ['dryRun', 'action', 'redemptionCode'],
|
|
1794
1528
|
'upload files': ['dryRun', 'fileCount', 'localFileCount', 'resourceConversionCount'],
|
|
1795
1529
|
'create image': ['dryRun', 'action', 'modelGroupCode', 'projectGroupNo', 'prompt', 'ratio', 'quality', 'generateNum', 'resourceCount', 'localFileCount', 'assetCount'],
|
|
1796
1530
|
'create video': ['dryRun', 'action', 'modelGroupCode', 'projectGroupNo', 'prompt', 'duration', 'ratio', 'quality', 'needAudio', 'resourceCount', 'localFileCount', 'assetCount'],
|
|
@@ -1805,15 +1539,9 @@ const DRY_RUN_FIELDS_BY_COMMAND = {
|
|
|
1805
1539
|
'create subject': ['dryRun', 'action', 'name', 'modelCode', 'elementFrontalImage', 'assetCount', 'localFileCount', 'nextRefSubject'],
|
|
1806
1540
|
'create subject-voice': ['dryRun', 'action', 'name', 'voiceName', 'voiceUrl', 'remoteUrl', 'remoteUpload', 'localFileCount', 'nextVoiceArg'],
|
|
1807
1541
|
'create subject-batch': ['dryRun', 'count', 'modelCode'],
|
|
1808
|
-
'artifact script import': ['dryRun', 'action', 'projectId', 'sourceFile', 'inputFile', 'rowCount', 'actorCount', 'episodeCount', 'sceneCount', 'clipCount'],
|
|
1809
|
-
'artifact asset import': ['dryRun', 'action', 'projectId', 'inputDir', 'actorCount', 'propCount', 'locationCount'],
|
|
1810
|
-
'artifact video import-storyboard': ['dryRun', 'action', 'projectId', 'inputFile', 'episodeId', 'sceneCount', 'clipCount'],
|
|
1811
|
-
'artifact clip upsert-batch': ['dryRun', 'action', 'projectId', 'episodeCount'],
|
|
1812
|
-
'artifact clip update-status': ['dryRun', 'action', 'projectId', 'videoEpisodeId', 'status', 'messageCount'],
|
|
1813
1542
|
};
|
|
1814
1543
|
|
|
1815
1544
|
const LIST_KEY_BY_KIND = {
|
|
1816
|
-
artifact_list: 'items',
|
|
1817
1545
|
asset_group_list: 'groups',
|
|
1818
1546
|
asset_match_list: 'matches',
|
|
1819
1547
|
asset_review_model_list: 'models',
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
nowIso,
|
|
29
29
|
parseJsonArg,
|
|
30
30
|
parseListArg,
|
|
31
|
+
resolvePurchaseUrl,
|
|
31
32
|
safeFileName,
|
|
32
33
|
saveState,
|
|
33
34
|
sleep,
|
|
@@ -471,6 +472,91 @@ export async function accountInfo() {
|
|
|
471
472
|
};
|
|
472
473
|
}
|
|
473
474
|
|
|
475
|
+
const REDEEM_CODE_WAIT_SECONDS_DEFAULT = 600;
|
|
476
|
+
|
|
477
|
+
// 去掉用户粘贴时可能带上的空格 / 制表符 / 换行,避免污染兑换码。
|
|
478
|
+
function sanitizeRedeemCode(value) {
|
|
479
|
+
return String(value ?? '').replace(/\s+/g, '');
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
export async function creditsBuy() {
|
|
483
|
+
const { purchaseUrl } = resolvePurchaseUrl();
|
|
484
|
+
return {
|
|
485
|
+
action: 'credits buy',
|
|
486
|
+
purchaseUrl,
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
async function promptRedeemCode(waitSeconds) {
|
|
491
|
+
if (process.stdin.isTTY !== true || process.stderr.isTTY !== true) {
|
|
492
|
+
throw argumentError(
|
|
493
|
+
'未提供兑换码',
|
|
494
|
+
'非交互终端不会等待输入,请通过 --code 传入兑换码,例如 lj-awb credits redeem --code <code>。',
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
const controller = new AbortController();
|
|
498
|
+
const timer = setTimeout(() => controller.abort(), Math.max(1, waitSeconds) * 1000);
|
|
499
|
+
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
500
|
+
try {
|
|
501
|
+
const answer = await rl.question('请输入兑换码后回车确认:', { signal: controller.signal });
|
|
502
|
+
return sanitizeRedeemCode(answer);
|
|
503
|
+
} catch (error) {
|
|
504
|
+
if (controller.signal.aborted) {
|
|
505
|
+
throw new LingjingAwbCliError('等待输入兑换码超时', {
|
|
506
|
+
type: 'redeem_timeout',
|
|
507
|
+
exitCode: 20,
|
|
508
|
+
hint: '重新运行 lj-awb credits redeem 并在限定时间内输入兑换码,或直接用 --code 传入。',
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
throw error;
|
|
512
|
+
} finally {
|
|
513
|
+
clearTimeout(timer);
|
|
514
|
+
rl.close();
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
export async function creditsRedeem(kwargs = {}) {
|
|
519
|
+
const waitSeconds = Math.max(0, toInt(kwargs.waitSeconds, REDEEM_CODE_WAIT_SECONDS_DEFAULT));
|
|
520
|
+
let code = sanitizeRedeemCode(kwargs.code);
|
|
521
|
+
if (!code) {
|
|
522
|
+
code = await promptRedeemCode(waitSeconds);
|
|
523
|
+
}
|
|
524
|
+
if (!code) {
|
|
525
|
+
throw argumentError('兑换码不能为空', '请提供有效兑换码,或通过 --code <code> 传入。');
|
|
526
|
+
}
|
|
527
|
+
if (toBool(kwargs.dryRun)) {
|
|
528
|
+
return { dryRun: true, action: 'credits redeem', redemptionCode: code };
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
try {
|
|
532
|
+
await awbApi.redeemCode(code);
|
|
533
|
+
} catch (error) {
|
|
534
|
+
// apiFetch 在平台返回 code != 200 时抛 api_error,并带上平台 msg;统一转成更友好的兑换失败提示。
|
|
535
|
+
if (error instanceof LingjingAwbCliError && (error.type === 'api_error' || error.type === 'http_error')) {
|
|
536
|
+
throw new LingjingAwbCliError(error.message || '兑换失败', {
|
|
537
|
+
type: 'redeem_failed',
|
|
538
|
+
exitCode: 1,
|
|
539
|
+
hint: '兑换处理失败,请确认兑换码是否正确或已被使用;若持续失败请联系平台处理。',
|
|
540
|
+
details: error.details,
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
throw error;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// 兑换成功后顺带拉取账号概览,展示最新积分余额(等同于 lj-awb account info)。
|
|
547
|
+
const account = await accountInfo().catch(() => null);
|
|
548
|
+
return {
|
|
549
|
+
redeemed: true,
|
|
550
|
+
action: 'credits redeem',
|
|
551
|
+
redemptionCode: code,
|
|
552
|
+
billingPointBalance: account?.billingPointBalance ?? null,
|
|
553
|
+
currentProjectGroupNo: account?.currentProjectGroupNo ?? null,
|
|
554
|
+
currentProjectGroupName: account?.currentProjectGroupName ?? null,
|
|
555
|
+
projectBudgetBalance: account?.projectBudgetBalance ?? null,
|
|
556
|
+
projectBudgetMax: account?.projectBudgetMax ?? null,
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
|
|
474
560
|
async function pathExists(filePath) {
|
|
475
561
|
if (!filePath) return false;
|
|
476
562
|
try {
|
|
@@ -618,9 +704,41 @@ export async function selectTeam(kwargs = {}) {
|
|
|
618
704
|
action: 'account switch-team',
|
|
619
705
|
groupId,
|
|
620
706
|
});
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
707
|
+
// userId 取当前登录用户(与 account info 同源:fetchUserInfo)
|
|
708
|
+
const userId = normalizeUserInfo(await awbApi.fetchUserInfo()).userId;
|
|
709
|
+
if (!userId) {
|
|
710
|
+
throw new LingjingAwbCliError('无法获取当前用户 userId,切换团队失败', {
|
|
711
|
+
type: 'api_error',
|
|
712
|
+
exitCode: 1,
|
|
713
|
+
hint: '请先确认已登录(lj-awb auth status),再重试。',
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
// 用 userId + 目标 groupId 换取该团队的 accessKey
|
|
717
|
+
const accessKey = trimSecret(await awbApi.fetchGroupAccessKey({ userId, groupId }));
|
|
718
|
+
if (!accessKey) {
|
|
719
|
+
throw new LingjingAwbCliError('切换团队失败:未返回该团队的 accessKey', {
|
|
720
|
+
type: 'api_error',
|
|
721
|
+
exitCode: 1,
|
|
722
|
+
hint: '请确认该 groupId 属于当前用户可访问的团队;若持续失败请联系平台。',
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
// 刷新本地认证文件(等同登录写入),并用新 key 校验,拿到切换后的用户 / 团队上下文
|
|
726
|
+
const saved = await saveVerifiedAccessKey(accessKey, { loginMethod: 'switch-team' });
|
|
727
|
+
const switchedGroupId = saved.user?.groupId ?? groupId;
|
|
728
|
+
await saveState({
|
|
729
|
+
currentGroupId: switchedGroupId,
|
|
730
|
+
currentGroupName: saved.user?.groupName ?? null,
|
|
731
|
+
currentUserId: saved.user?.userId ?? userId,
|
|
732
|
+
}).catch(() => {});
|
|
733
|
+
return {
|
|
734
|
+
selected: true,
|
|
735
|
+
action: 'account switch-team',
|
|
736
|
+
groupId: switchedGroupId,
|
|
737
|
+
groupName: saved.user?.groupName ?? null,
|
|
738
|
+
userId: saved.user?.userId ?? userId,
|
|
739
|
+
userName: saved.user?.userName ?? null,
|
|
740
|
+
accessKey: saved.accessKey,
|
|
741
|
+
};
|
|
624
742
|
}
|
|
625
743
|
|
|
626
744
|
export async function selectProjectGroupCommand(kwargs = {}) {
|
|
@@ -628,13 +746,13 @@ export async function selectProjectGroupCommand(kwargs = {}) {
|
|
|
628
746
|
if (toBool(kwargs.dryRun)) {
|
|
629
747
|
return {
|
|
630
748
|
dryRun: true,
|
|
631
|
-
action: 'project
|
|
749
|
+
action: 'project switch',
|
|
632
750
|
selected: false,
|
|
633
751
|
request: { projectGroupNo },
|
|
634
752
|
};
|
|
635
753
|
}
|
|
636
754
|
ensureConfirmed(kwargs, '切换项目组会改变后续生成任务归属,需要确认', {
|
|
637
|
-
action: 'project
|
|
755
|
+
action: 'project switch',
|
|
638
756
|
projectGroupNo,
|
|
639
757
|
});
|
|
640
758
|
await awbApi.selectProjectGroup(projectGroupNo);
|