1
0
forked from boos/BoosAPI

feat: enhance response serialization for compact mode

- Added support for preserving native response.compaction payloads when compact serialization is requested in `serializeResponsesFinalPayload`.
- Implemented serialization of compact mode as `response.compaction` instead of an ordinary response object.
- Introduced a new type `ResponsesFinalSerializationMode` to manage serialization modes.
- Refactored `serializeResponsesFinalPayload` to handle different serialization modes and usage payloads.
- Added tests to ensure correct behavior for compact serialization and preservation of upstream payloads.
- Updated favicon assets and documentation configuration for VitePress.
This commit is contained in:
cita
2026-03-10 01:28:34 +08:00
parent 74d2e559ec
commit cd031b732f
20 changed files with 1387 additions and 90 deletions
+42
View File
@@ -1,14 +1,56 @@
import { existsSync, globSync } from 'node:fs';
import { resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { defineConfig } from 'vitepress';
import { withMermaid } from 'vitepress-plugin-mermaid';
const repoRoot = fileURLToPath(new URL('../..', import.meta.url));
const resolveDependencyEntry = (hoistedRelativePath: string, pnpmPattern: string) => {
const hoistedEntry = resolve(repoRoot, hoistedRelativePath);
if (existsSync(hoistedEntry)) return hoistedEntry;
const [pnpmEntry] = globSync(resolve(repoRoot, pnpmPattern));
return pnpmEntry;
};
const dayjsEsmEntry = resolveDependencyEntry(
'node_modules/dayjs/esm/index.js',
'node_modules/.pnpm/dayjs@*/node_modules/dayjs/esm/index.js',
);
const sanitizeUrlSourceEntry = resolveDependencyEntry(
'node_modules/@braintree/sanitize-url/src/index.ts',
'node_modules/.pnpm/@braintree+sanitize-url@*/node_modules/@braintree/sanitize-url/src/index.ts',
);
if (!dayjsEsmEntry) {
throw new Error('Unable to resolve the dayjs ESM entry required by vitepress-plugin-mermaid.');
}
if (!sanitizeUrlSourceEntry) {
throw new Error('Unable to resolve the sanitize-url source entry required by vitepress-plugin-mermaid.');
}
export default withMermaid(
defineConfig({
lang: 'zh-CN',
title: 'Metapi 文档',
description: 'Metapi 使用文档、FAQ 与维护协作指南',
head: [
['link', { rel: 'icon', type: 'image/png', sizes: '32x32', href: '/favicon.png' }],
['link', { rel: 'icon', type: 'image/png', sizes: '64x64', href: '/favicon-64.png' }],
['link', { rel: 'shortcut icon', href: '/favicon.ico' }],
],
cleanUrls: true,
lastUpdated: true,
ignoreDeadLinks: true,
vite: {
resolve: {
alias: [
{ find: /^dayjs$/, replacement: dayjsEsmEntry },
{ find: /^@braintree\/sanitize-url$/, replacement: sanitizeUrlSourceEntry },
],
},
},
themeConfig: {
siteTitle: 'Metapi Docs',
logo: '/logos/logo-icon-512.png',