siluzan-cso-cli 1.0.0-beta.37 → 1.0.0-beta.39
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 -1
- package/dist/index.js +57 -52
- package/dist/skill/_meta.json +2 -2
- package/dist/skill/references/web-pages.md +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ siluzan-cso init -d /path/to/skills # 写入自定义目录
|
|
|
20
20
|
siluzan-cso init --force # 强制覆盖已存在文件
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
> **注意**:当前为测试版(1.0.0-beta.
|
|
23
|
+
> **注意**:当前为测试版(1.0.0-beta.39),供内部测试使用。正式发布后安装命令将改为 `npm install -g siluzan-cso-cli`。
|
|
24
24
|
|
|
25
25
|
| 助手 | 建议 `--ai` |
|
|
26
26
|
|------|-------------|
|
package/dist/index.js
CHANGED
|
@@ -2554,7 +2554,7 @@ function parseMeResponse(text) {
|
|
|
2554
2554
|
try {
|
|
2555
2555
|
const json = JSON.parse(text);
|
|
2556
2556
|
const data = json?.data && typeof json.data === "object" ? json.data : json;
|
|
2557
|
-
const id = pickStr(data, "id") ?? pickStr(data, "userId") ?? pickStr(data, "accountId");
|
|
2557
|
+
const id = pickStr(data, "entityId") ?? pickStr(data, "id") ?? pickStr(data, "userId") ?? pickStr(data, "accountId");
|
|
2558
2558
|
const email = pickStr(data, "email");
|
|
2559
2559
|
const username = pickStr(data, "userName") ?? pickStr(data, "username") ?? pickStr(data, "name") ?? pickStr(data, "phone");
|
|
2560
2560
|
if (!id && !email && !username) return null;
|
|
@@ -2588,6 +2588,27 @@ async function fetchAndSetUser(mainOrigin, config) {
|
|
|
2588
2588
|
if (parsed.username) user.username = parsed.username;
|
|
2589
2589
|
Sentry.setUser(user);
|
|
2590
2590
|
}
|
|
2591
|
+
async function fetchSiluzanCurrentUser(apiBase, config) {
|
|
2592
|
+
const mainOrigin = deriveMainApiOriginFromRequestUrl(apiBase) ?? (apiBase.includes("-ci") ? "https://api-ci.siluzan.com" : "https://api.siluzan.com");
|
|
2593
|
+
const meUrl = `${mainOrigin.replace(/\/$/, "")}/query/account/me`;
|
|
2594
|
+
const authHeaders = config.apiKey ? { "x-api-key": config.apiKey } : { Authorization: `Bearer ${config.authToken}` };
|
|
2595
|
+
try {
|
|
2596
|
+
const res = await rawRequest(meUrl, {
|
|
2597
|
+
method: "GET",
|
|
2598
|
+
headers: {
|
|
2599
|
+
"Content-Type": "application/json",
|
|
2600
|
+
"Accept-Language": "zh-CN",
|
|
2601
|
+
...authHeaders
|
|
2602
|
+
}
|
|
2603
|
+
});
|
|
2604
|
+
if (res.status < 200 || res.status >= 300) return null;
|
|
2605
|
+
const parsed = parseMeResponse(res.text);
|
|
2606
|
+
if (!parsed) return null;
|
|
2607
|
+
return { entityId: parsed.id, email: parsed.email, username: parsed.username };
|
|
2608
|
+
} catch {
|
|
2609
|
+
return null;
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2591
2612
|
function scheduleUserContext(mainOrigin, config) {
|
|
2592
2613
|
const key = cacheKeyForUser(mainOrigin, config);
|
|
2593
2614
|
if (userContextDone.has(key)) return;
|
|
@@ -3258,63 +3279,42 @@ async function runListAccounts(options) {
|
|
|
3258
3279
|
const pageInfo = `\u7B2C ${pageNo} \u9875 / \u5171 ${totalPages} \u9875\uFF0C\u603B\u8BA1 ${total} \u6761`;
|
|
3259
3280
|
const tableOpts2 = options.unicode ? { plain: false } : void 0;
|
|
3260
3281
|
const groups = groupByPlatform(list);
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
\u8D26\u53F7\
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
`);
|
|
3278
|
-
const rows = accounts.map((a) => {
|
|
3279
|
-
const ov = a.mediaAccountOverviewDataDto;
|
|
3280
|
-
return {
|
|
3281
|
-
mediaCustomerName: a.mediaCustomerName,
|
|
3282
|
-
state: formatState(a.mediaAccountState, a.invalidOAuthToken),
|
|
3283
|
-
fansCount: formatCount(ov?.fansCount),
|
|
3284
|
-
videoCount: formatCount(ov?.videoCount),
|
|
3285
|
-
playCount: formatCount(ov?.playCount),
|
|
3286
|
-
commentCount: formatCount(ov?.commentCount),
|
|
3287
|
-
diggCount: formatCount(ov?.diggCount)
|
|
3288
|
-
};
|
|
3289
|
-
});
|
|
3290
|
-
printCliTable(rows, overviewColumns, tableOpts2);
|
|
3291
|
-
}
|
|
3292
|
-
} else {
|
|
3282
|
+
console.log(`
|
|
3283
|
+
\u8D26\u53F7\u5217\u8868\uFF08${pageInfo}\uFF09`);
|
|
3284
|
+
const columns = [
|
|
3285
|
+
{ key: "mediaCustomerName", header: "\u8D26\u53F7\u540D\u79F0" },
|
|
3286
|
+
{ key: "mediaCustomerId", header: "\u8D26\u53F7ID" },
|
|
3287
|
+
{ key: "state", header: "\u72B6\u6001" },
|
|
3288
|
+
{ key: "fansCount", header: "\u7C89\u4E1D\u6570" },
|
|
3289
|
+
{ key: "videoCount", header: "\u4F5C\u54C1\u6570" },
|
|
3290
|
+
{ key: "playCount", header: "\u64AD\u653E\u6570" },
|
|
3291
|
+
{ key: "commentCount", header: "\u8BC4\u8BBA\u6570" },
|
|
3292
|
+
{ key: "diggCount", header: "\u83B7\u8D5E\u6570" },
|
|
3293
|
+
{ key: "lastAuthTime", header: "\u4E0A\u6B21\u6388\u6743" },
|
|
3294
|
+
{ key: "tokenExpiry", header: "Token\u5230\u671F" },
|
|
3295
|
+
{ key: "owners", header: "\u8D1F\u8D23\u4EBA" }
|
|
3296
|
+
];
|
|
3297
|
+
for (const [platform, accounts] of groups) {
|
|
3293
3298
|
console.log(`
|
|
3294
|
-
\u5A92\u4F53\u8D26\u53F7\u5217\u8868\uFF08${pageInfo}\uFF09`);
|
|
3295
|
-
const columns = [
|
|
3296
|
-
{ key: "mediaCustomerName", header: "\u8D26\u53F7\u540D\u79F0" },
|
|
3297
|
-
{ key: "mediaCustomerId", header: "\u8D26\u53F7ID" },
|
|
3298
|
-
{ key: "state", header: "\u72B6\u6001" },
|
|
3299
|
-
{ key: "lastAuthTime", header: "\u4E0A\u6B21\u6388\u6743" },
|
|
3300
|
-
{ key: "tokenExpiry", header: "Token\u5230\u671F" },
|
|
3301
|
-
{ key: "owners", header: "\u8D1F\u8D23\u4EBA" }
|
|
3302
|
-
];
|
|
3303
|
-
for (const [platform, accounts] of groups) {
|
|
3304
|
-
console.log(`
|
|
3305
3299
|
\u25AA ${platform}\uFF08${accounts.length} \u4E2A\u8D26\u53F7\uFF09
|
|
3306
3300
|
`);
|
|
3307
|
-
|
|
3301
|
+
const rows = accounts.map((a) => {
|
|
3302
|
+
const ov = a.mediaAccountOverviewDataDto;
|
|
3303
|
+
return {
|
|
3308
3304
|
mediaCustomerName: a.mediaCustomerName,
|
|
3309
3305
|
mediaCustomerId: a.mediaCustomerId,
|
|
3310
3306
|
state: formatState(a.mediaAccountState, a.invalidOAuthToken),
|
|
3307
|
+
fansCount: formatCount(ov?.fansCount),
|
|
3308
|
+
videoCount: formatCount(ov?.videoCount),
|
|
3309
|
+
playCount: formatCount(ov?.playCount),
|
|
3310
|
+
commentCount: formatCount(ov?.commentCount),
|
|
3311
|
+
diggCount: formatCount(ov?.diggCount),
|
|
3311
3312
|
lastAuthTime: formatDate(a.lastAuthorizationTime),
|
|
3312
|
-
// expiresOn 比 tokenTime 更准确,优先使用
|
|
3313
3313
|
tokenExpiry: formatDate(a.expiresOn ?? a.tokenTime),
|
|
3314
3314
|
owners: formatOwners(a.ownerInfo)
|
|
3315
|
-
}
|
|
3316
|
-
|
|
3317
|
-
|
|
3315
|
+
};
|
|
3316
|
+
});
|
|
3317
|
+
printCliTable(rows, columns, tableOpts2);
|
|
3318
3318
|
}
|
|
3319
3319
|
if (total > pageNo * pageSize) {
|
|
3320
3320
|
console.log(`
|
|
@@ -4073,8 +4073,14 @@ async function runPublish(options) {
|
|
|
4073
4073
|
}
|
|
4074
4074
|
const config = loadConfig(options.token);
|
|
4075
4075
|
const jwtClaims = decodeJwtClaims(config.authToken);
|
|
4076
|
-
|
|
4076
|
+
let currentUserId = isUUID(jwtClaims?.sub) ? jwtClaims.sub : null;
|
|
4077
4077
|
const currentDid = isUUID(jwtClaims?.did) ? jwtClaims.did : null;
|
|
4078
|
+
if (!currentUserId) {
|
|
4079
|
+
const meUser = await fetchSiluzanCurrentUser(config.apiBaseUrl, config);
|
|
4080
|
+
if (meUser?.entityId && isUUID(meUser.entityId)) {
|
|
4081
|
+
currentUserId = meUser.entityId;
|
|
4082
|
+
}
|
|
4083
|
+
}
|
|
4078
4084
|
const now = nowUtc();
|
|
4079
4085
|
const uniqueActionId = guid();
|
|
4080
4086
|
const taskName = input.taskName ?? defaultTaskName();
|
|
@@ -6164,7 +6170,7 @@ program.command("init").description("\u5C06 Skill \u6587\u4EF6\u5199\u5165\u6307
|
|
|
6164
6170
|
program.command("authorize").description("\u53D1\u8D77\u5A92\u4F53\u5E73\u53F0 OAuth \u6388\u6743\uFF08YouTube/TikTokBusinessAccount/Instagram/Facebook/LinkedIn/Twitter \u7B49\uFF09\uFF0C\u5728\u6D4F\u89C8\u5668\u4E2D\u5B8C\u6210\u6388\u6743\u540E\u8DF3\u56DE\u4E1D\u8DEF\u8D5E\u8D26\u53F7\u7BA1\u7406\u9875").requiredOption("--media-type <type>", "\u5A92\u4F53\u5E73\u53F0\u7C7B\u578B\uFF0C\u5982 YouTube / TikTokBusinessAccount / Instagram / Facebook / LinkedIn / Twitter").option("-t, --token <token>", "Token\uFF08\u53EF\u9009\uFF1B\u4F18\u5148\u4E8E ~/.siluzan/config.json\uFF09").option("--verbose", "\u663E\u793A\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F", false).action(async (opts) => {
|
|
6165
6171
|
await runAuthorize(opts);
|
|
6166
6172
|
});
|
|
6167
|
-
program.command("list-accounts").description("\u5217\u51FA\u5A92\u4F53\u8D26\u53F7\u5217\u8868\uFF0C\u9ED8\u8BA4\u5C55\u793A\u7C89\u4E1D\u6570/\u4F5C\u54C1\u6570/\u64AD\u653E\u6570\u7B49\u6570\u636E\u603B\u89C8\uFF1B\u652F\u6301\u5206\u9875\u3001\u5E73\u53F0/\u540D\u79F0/\u72B6\u6001/\u8D1F\u8D23\u4EBA\u8FC7\u6EE4").option("--name <name>", "\u6309\u8D26\u53F7\u540D\u79F0\u6A21\u7CCA\u641C\u7D22").option("--media-type <type>", "\u6309\u5E73\u53F0\u7C7B\u578B\u8FC7\u6EE4\uFF08\u5982 \u6296\u97F3\u3001YouTube\u3001TikTok \u7B49\uFF09").option("--state <state>", "\u6309\u72B6\u6001\u8FC7\u6EE4\uFF1Aall\uFF08\u5168\u90E8\uFF09| normal\uFF08\u6B63\u5E38\uFF09| abnormal\uFF08\u5F02\u5E38/\u8FC7\u671F\uFF09\uFF0C\u9ED8\u8BA4 all", "all").option("--owner <owner>", "\u6309\u8D1F\u8D23\u4EBA\u8FC7\u6EE4\uFF08\u4F20\u5165\u7528\u6237 ID\uFF0C\u53EF\u4ECE --json \u8FD4\u56DE\u7684 ownerInfo[].id \u5B57\u6BB5\u83B7\u53D6\uFF09").option("--page <n>", "\u9875\u7801\uFF08\u9ED8\u8BA4 1\uFF09", "1").option("--page-size <n>", "\u6BCF\u9875\u6761\u6570\uFF08\u9ED8\u8BA4 20\uFF09", "20").option("--
|
|
6173
|
+
program.command("list-accounts").description("\u5217\u51FA\u5A92\u4F53\u8D26\u53F7\u5217\u8868\uFF0C\u9ED8\u8BA4\u5C55\u793A\u7C89\u4E1D\u6570/\u4F5C\u54C1\u6570/\u64AD\u653E\u6570\u7B49\u6570\u636E\u603B\u89C8\uFF1B\u652F\u6301\u5206\u9875\u3001\u5E73\u53F0/\u540D\u79F0/\u72B6\u6001/\u8D1F\u8D23\u4EBA\u8FC7\u6EE4").option("--name <name>", "\u6309\u8D26\u53F7\u540D\u79F0\u6A21\u7CCA\u641C\u7D22").option("--media-type <type>", "\u6309\u5E73\u53F0\u7C7B\u578B\u8FC7\u6EE4\uFF08\u5982 \u6296\u97F3\u3001YouTube\u3001TikTok \u7B49\uFF09").option("--state <state>", "\u6309\u72B6\u6001\u8FC7\u6EE4\uFF1Aall\uFF08\u5168\u90E8\uFF09| normal\uFF08\u6B63\u5E38\uFF09| abnormal\uFF08\u5F02\u5E38/\u8FC7\u671F\uFF09\uFF0C\u9ED8\u8BA4 all", "all").option("--owner <owner>", "\u6309\u8D1F\u8D23\u4EBA\u8FC7\u6EE4\uFF08\u4F20\u5165\u7528\u6237 ID\uFF0C\u53EF\u4ECE --json \u8FD4\u56DE\u7684 ownerInfo[].id \u5B57\u6BB5\u83B7\u53D6\uFF09").option("--page <n>", "\u9875\u7801\uFF08\u9ED8\u8BA4 1\uFF09", "1").option("--page-size <n>", "\u6BCF\u9875\u6761\u6570\uFF08\u9ED8\u8BA4 20\uFF09", "20").option("--json", "\u4EE5 JSON \u8F93\u51FA\u8D26\u53F7\u5217\u8868\uFF08\u542B\u603B\u89C8\u6570\u636E\uFF0C\u7528\u4E8E\u811A\u672C\u6216\u914D\u7F6E\u6587\u4EF6\uFF09", false).option("--unicode", "\u4F7F\u7528 Unicode \u7EBF\u6846\u8868\u683C\uFF08\u9ED8\u8BA4 ASCII +-|\uFF09", false).option("--verbose", "\u663E\u793A\u5B8C\u6574\u4EE4\u724C\u6807\u8BC6\uFF08\u9ED8\u8BA4\u8131\u654F\uFF09", false).action(async (opts) => {
|
|
6168
6174
|
const state = opts.state;
|
|
6169
6175
|
await runListAccounts({
|
|
6170
6176
|
token: opts.token,
|
|
@@ -6174,7 +6180,6 @@ program.command("list-accounts").description("\u5217\u51FA\u5A92\u4F53\u8D26\u53
|
|
|
6174
6180
|
owner: opts.owner,
|
|
6175
6181
|
page: opts.page ? parseInt(opts.page, 10) : void 0,
|
|
6176
6182
|
pageSize: opts.pageSize ? parseInt(opts.pageSize, 10) : void 0,
|
|
6177
|
-
overview: opts.overview,
|
|
6178
6183
|
json: opts.json,
|
|
6179
6184
|
unicode: opts.unicode,
|
|
6180
6185
|
verbose: opts.verbose
|
package/dist/skill/_meta.json
CHANGED
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
|
|
23
23
|
| 页面 | 完整链接 | 功能说明 |
|
|
24
24
|
|------|----------|----------|
|
|
25
|
-
| 发布作品 | `https://www-ci.siluzan.com/v3/foreign_trade/cso/postVideo` |
|
|
25
|
+
| 发布作品 | `https://www-ci.siluzan.com/v3/foreign_trade/cso/postVideo?contentType=1` | 矩阵发布视频、图文、草稿管理、话题组 contentType=1 是视频,contentType=2是图文 |
|
|
26
|
+
|
|
26
27
|
| 发布日历 | `https://www-ci.siluzan.com/v3/foreign_trade/cso/publishCalendar` | 日历视图规划发布任务、创建/编辑发布任务 |
|
|
27
28
|
| 营销日历 | `https://www-ci.siluzan.com/v3/foreign_trade/cso/marketingCalendar` | 营销节点日历、跳转创建发布任务 |
|
|
28
29
|
|
package/package.json
CHANGED