@ynhcj/xiaoyi-channel 0.0.164-next → 0.0.165-next
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +20 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -87,11 +87,28 @@ function preview(value) {
|
|
|
87
87
|
return s.length > 200 ? s.slice(0, 200) + "…" : s;
|
|
88
88
|
}
|
|
89
89
|
/** 防御性地从 cron add 结果中取 job id。
|
|
90
|
-
* 覆盖:裸 job 对象、JSON 字符串、exec 输出文本、
|
|
90
|
+
* 覆盖:裸 job 对象、JSON 字符串、exec 输出文本、
|
|
91
|
+
* {content:[{text}]} / {stdout} / data/result/job 嵌套。 */
|
|
91
92
|
function readJobIdFromResult(result) {
|
|
92
93
|
if (!result)
|
|
93
94
|
return undefined;
|
|
94
|
-
//
|
|
95
|
+
// {content: [{type:"text", text: "..."}]} — exec 工具的输出信封
|
|
96
|
+
if (result && typeof result === "object") {
|
|
97
|
+
const contentArr = result.content;
|
|
98
|
+
if (Array.isArray(contentArr)) {
|
|
99
|
+
for (const item of contentArr) {
|
|
100
|
+
if (item && typeof item === "object") {
|
|
101
|
+
const text = item.text;
|
|
102
|
+
if (typeof text === "string" && text.trim()) {
|
|
103
|
+
const fromContent = readJobIdFromResult(text);
|
|
104
|
+
if (fromContent)
|
|
105
|
+
return fromContent;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// {stdout} — 备选 exec 输出信封
|
|
95
112
|
if (result && typeof result === "object") {
|
|
96
113
|
const stdout = result.stdout;
|
|
97
114
|
if (typeof stdout === "string" && stdout.trim()) {
|
|
@@ -106,7 +123,7 @@ function readJobIdFromResult(result) {
|
|
|
106
123
|
obj = JSON.parse(result);
|
|
107
124
|
}
|
|
108
125
|
catch {
|
|
109
|
-
//
|
|
126
|
+
// 纯文本:可能含 stderr 前缀行 + JSON。用正则抓 "id":"..."。
|
|
110
127
|
const m = result.match(/"id"\s*:\s*"([^"]+)"/);
|
|
111
128
|
if (m)
|
|
112
129
|
return m[1];
|