zentao-api 0.6.2 → 0.6.4
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/browser/zentao-api.global.js +25 -2
- package/dist/modules/generated.d.ts +552 -70
- package/dist/modules/generated.js +723 -129
- package/dist/modules/override.js +35 -0
- package/dist/modules/registry.d.ts +579 -130
- package/dist/modules/resolve.d.ts +3 -3
- package/dist/modules/resolve.js +4 -4
- package/dist/request/index.js +2 -2
- package/dist/types/module.d.ts +3 -1
- package/dist/types/options.d.ts +1 -0
- package/dist/utils/doc-helper/html.d.ts +3 -0
- package/dist/utils/doc-helper/html.js +442 -0
- package/dist/utils/doc-helper/index.d.ts +3 -0
- package/dist/utils/doc-helper/index.js +2 -0
- package/dist/utils/doc-helper/inline.d.ts +3 -0
- package/dist/utils/doc-helper/inline.js +168 -0
- package/dist/utils/doc-helper/markdown.d.ts +3 -0
- package/dist/utils/doc-helper/markdown.js +402 -0
- package/dist/utils/doc-helper/shared.d.ts +37 -0
- package/dist/utils/doc-helper/shared.js +305 -0
- package/dist/utils/doc-helper/types.d.ts +86 -0
- package/dist/utils/doc-helper/types.js +1 -0
- package/dist/version.js +2 -2
- package/package.json +1 -1
package/dist/modules/override.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { extendModuleAction } from './define.js';
|
|
2
|
+
import { extractResult } from './resolve.js';
|
|
3
|
+
import { snapshotToMarkdown } from '../utils/doc-helper/markdown.js';
|
|
4
|
+
import { isRecord } from '../utils/index.js';
|
|
2
5
|
/**
|
|
3
6
|
* 内置覆盖 / 扩展定义。
|
|
4
7
|
*
|
|
@@ -204,4 +207,36 @@ export function applyBuiltinOverrides() {
|
|
|
204
207
|
}
|
|
205
208
|
return action;
|
|
206
209
|
});
|
|
210
|
+
// 获取文档详情时支持将文档原始 JSON 内容转换为 Markdown
|
|
211
|
+
extendModuleAction('doc', 'get', (action) => {
|
|
212
|
+
const oldGetter = action.resultGetter;
|
|
213
|
+
action.resultGetter = (data, params, options = {}) => {
|
|
214
|
+
const result = oldGetter
|
|
215
|
+
? extractResult({ ...action, resultGetter: oldGetter }, data, params, options)
|
|
216
|
+
: (data.doc ?? data);
|
|
217
|
+
if (!isRecord(result))
|
|
218
|
+
return result;
|
|
219
|
+
const pick = options.pick;
|
|
220
|
+
const pickAll = !pick?.length;
|
|
221
|
+
const wantsContent = pickAll || pick.includes('content');
|
|
222
|
+
const wantsRawContent = pickAll || pick.includes('rawContent');
|
|
223
|
+
if (!wantsContent && !wantsRawContent)
|
|
224
|
+
return result;
|
|
225
|
+
const originalContent = result.content;
|
|
226
|
+
try {
|
|
227
|
+
if (wantsRawContent && (result.rawContent === undefined || result.rawContent === '')) {
|
|
228
|
+
result.rawContent = originalContent;
|
|
229
|
+
}
|
|
230
|
+
if (wantsContent && result.contentType === 'doc') {
|
|
231
|
+
const markdown = snapshotToMarkdown(originalContent);
|
|
232
|
+
result.content = markdown;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
// HTML、纯文本和无法识别的快照保持服务端原始字段不变。
|
|
237
|
+
}
|
|
238
|
+
return result;
|
|
239
|
+
};
|
|
240
|
+
return action;
|
|
241
|
+
});
|
|
207
242
|
}
|