feat: 接通后台渲染异常上报与响应契约校验
This commit is contained in:
1 parent
330d67adc1
commit
adcaa12970
22 files changed
+845
-33
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { Component, type ErrorInfo, type ReactNode } from "react";
|
||||
import { Button, Result, Space, Typography } from "antd";
|
||||
import { createApiClient } from "../lib/api.js";
|
||||
|
||||
interface AdminErrorBoundaryProps {
|
||||
children: ReactNode;
|
||||
@@ -24,13 +25,28 @@ export class AdminErrorBoundary extends Component<
|
||||
AdminErrorBoundaryState
|
||||
> {
|
||||
override state: AdminErrorBoundaryState = { error: null, errorId: null };
|
||||
private reportedErrorId: string | null = null;
|
||||
|
||||
static getDerivedStateFromError(error: Error): AdminErrorBoundaryState {
|
||||
return { error, errorId: createErrorId() };
|
||||
}
|
||||
|
||||
override componentDidCatch(error: Error, info: ErrorInfo) {
|
||||
console.error("[admin] 页面渲染异常", this.state.errorId, error, info.componentStack);
|
||||
const errorId = this.state.errorId ?? createErrorId();
|
||||
console.error("[admin] 页面渲染异常", errorId, error, info.componentStack);
|
||||
if (this.reportedErrorId === errorId) return;
|
||||
this.reportedErrorId = errorId;
|
||||
// 上报失败不能影响错误页本身:只记录到控制台,不抛出、不改状态。
|
||||
void createApiClient()
|
||||
.reportAdminClientError({
|
||||
errorId,
|
||||
message: error.message.slice(0, 2000) || error.name,
|
||||
route: `${window.location.pathname}${window.location.search}`.slice(0, 500),
|
||||
...(info.componentStack ? { componentStack: info.componentStack.slice(0, 20000) } : {}),
|
||||
})
|
||||
.catch((reportError: unknown) => {
|
||||
console.warn("[admin] 渲染异常上报失败", errorId, reportError);
|
||||
});
|
||||
}
|
||||
|
||||
private reset = () => {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { IsOptional, IsString, Matches, MaxLength, MinLength } from "class-validator";
|
||||
|
||||
/** 后台渲染异常上报:只接受白名单字段,避免把任意浏览器数据写进日志。 */
|
||||
export class CreateClientErrorDto {
|
||||
@IsString()
|
||||
@Matches(/^[A-Za-z0-9._-]{4,128}$/, { message: "errorId 格式不正确" })
|
||||
errorId!: string;
|
||||
|
||||
@IsString()
|
||||
@MinLength(1, { message: "message 不能为空" })
|
||||
@MaxLength(2000, { message: "message 过长" })
|
||||
message!: string;
|
||||
|
||||
@IsString()
|
||||
@Matches(/^\//, { message: "route 必须以 / 开头" })
|
||||
@MaxLength(500, { message: "route 过长" })
|
||||
route!: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(20000, { message: "componentStack 过长" })
|
||||
componentStack?: string;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import { AdminBrand } from "../../admin-auth.decorators.js";
|
||||
import { Body, Controller, Post, Req } from "@nestjs/common";
|
||||
import type { FastifyRequest } from "fastify";
|
||||
import { AdminAccessService } from "../../admin-access.service.js";
|
||||
import { CreateClientErrorDto } from "../../client-error.dto.js";
|
||||
import { AdminClientErrorService } from "./admin-client-error.service.js";
|
||||
|
||||
@AdminBrand()
|
||||
@Controller("admin/client-errors")
|
||||
export class AdminClientErrorController {
|
||||
constructor(
|
||||
private readonly access: AdminAccessService,
|
||||
private readonly errors: AdminClientErrorService,
|
||||
) {}
|
||||
|
||||
@Post()
|
||||
async create(
|
||||
@Req() request: FastifyRequest,
|
||||
@Body() body: CreateClientErrorDto,
|
||||
): Promise<{ received: true; duplicate: boolean }> {
|
||||
const identity = await this.access.requireBrand(request);
|
||||
return this.errors.record({
|
||||
subject: identity.subject,
|
||||
brandId: identity.brandId,
|
||||
errorId: body.errorId,
|
||||
message: body.message,
|
||||
route: body.route,
|
||||
componentStack: body.componentStack,
|
||||
requestId:
|
||||
(request as FastifyRequest & { requestId?: string }).requestId ??
|
||||
request.headers["x-request-id"]?.toString() ??
|
||||
null,
|
||||
userAgent: request.headers["user-agent"]?.toString().slice(0, 300) ?? null,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
import { HttpException, Injectable } from "@nestjs/common";
|
||||
|
||||
const RATE_WINDOW_MS = 60_000;
|
||||
const RATE_LIMIT = 10;
|
||||
const DEDUPE_TTL_MS = 10 * 60_000;
|
||||
const DEDUPE_CAPACITY = 500;
|
||||
const LOG_STACK_LIMIT = 4000;
|
||||
|
||||
export interface ClientErrorReport {
|
||||
subject: string;
|
||||
brandId: string;
|
||||
errorId: string;
|
||||
message: string;
|
||||
route: string;
|
||||
componentStack?: string | undefined;
|
||||
requestId: string | null;
|
||||
userAgent: string | null;
|
||||
}
|
||||
|
||||
export interface ClientErrorReceipt {
|
||||
received: true;
|
||||
duplicate: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台渲染异常去重与限流。
|
||||
* 当前生产为单实例 PM2,因此使用进程内窗口;扩成多实例前需要换成共享存储。
|
||||
*/
|
||||
@Injectable()
|
||||
export class AdminClientErrorService {
|
||||
private readonly recentErrorIds = new Map<string, number>();
|
||||
private readonly windows = new Map<string, number[]>();
|
||||
|
||||
record(report: ClientErrorReport): ClientErrorReceipt {
|
||||
const now = Date.now();
|
||||
this.prune(now);
|
||||
|
||||
const dedupeKey = `${report.subject}:${report.errorId}`;
|
||||
if (this.recentErrorIds.has(dedupeKey)) {
|
||||
return { received: true, duplicate: true };
|
||||
}
|
||||
|
||||
this.assertWithinRate(report.subject, now);
|
||||
this.recentErrorIds.set(dedupeKey, now);
|
||||
this.trimDedupe();
|
||||
|
||||
console.error("admin client error", {
|
||||
errorId: report.errorId,
|
||||
message: report.message,
|
||||
route: report.route,
|
||||
subject: report.subject,
|
||||
brandId: report.brandId,
|
||||
requestId: report.requestId,
|
||||
userAgent: report.userAgent,
|
||||
componentStack: report.componentStack?.slice(0, LOG_STACK_LIMIT) ?? null,
|
||||
});
|
||||
|
||||
return { received: true, duplicate: false };
|
||||
}
|
||||
|
||||
private assertWithinRate(subject: string, now: number): void {
|
||||
const recent = (this.windows.get(subject) ?? []).filter(
|
||||
(timestamp) => now - timestamp < RATE_WINDOW_MS,
|
||||
);
|
||||
if (recent.length >= RATE_LIMIT) {
|
||||
this.windows.set(subject, recent);
|
||||
throw new HttpException("客户端错误上报过于频繁,请稍后再试", 429);
|
||||
}
|
||||
recent.push(now);
|
||||
this.windows.set(subject, recent);
|
||||
}
|
||||
|
||||
private prune(now: number): void {
|
||||
for (const [key, timestamp] of this.recentErrorIds) {
|
||||
if (now - timestamp >= DEDUPE_TTL_MS) this.recentErrorIds.delete(key);
|
||||
}
|
||||
for (const [subject, timestamps] of this.windows) {
|
||||
const recent = timestamps.filter((timestamp) => now - timestamp < RATE_WINDOW_MS);
|
||||
if (recent.length === 0) this.windows.delete(subject);
|
||||
else this.windows.set(subject, recent);
|
||||
}
|
||||
}
|
||||
|
||||
private trimDedupe(): void {
|
||||
while (this.recentErrorIds.size > DEDUPE_CAPACITY) {
|
||||
const oldest = this.recentErrorIds.keys().next();
|
||||
if (oldest.done) return;
|
||||
this.recentErrorIds.delete(oldest.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@ import { Module } from "@nestjs/common";
|
||||
import { BookingModule } from "../booking.module.js";
|
||||
import { InfrastructureModule } from "../infrastructure.module.js";
|
||||
import { AdminBookingController } from "./admin-booking.controller.js";
|
||||
import { AdminClientErrorController } from "./admin-client-error.controller.js";
|
||||
import { AdminClientErrorService } from "./admin-client-error.service.js";
|
||||
import { AdminBrandConfigService } from "./admin-brand-config.service.js";
|
||||
import { AdminConfigController } from "./admin-config.controller.js";
|
||||
import { AdminLocalUploadController } from "./admin-local-upload.controller.js";
|
||||
@@ -32,6 +34,7 @@ import { AdminTemplatePreviewAssetsService } from "./admin-template-preview-asse
|
||||
AdminBookingController,
|
||||
AdminTemplatePackageController,
|
||||
TemplateOperationMetricsController,
|
||||
AdminClientErrorController,
|
||||
],
|
||||
providers: [
|
||||
AdminBrandConfigService,
|
||||
@@ -44,6 +47,7 @@ import { AdminTemplatePreviewAssetsService } from "./admin-template-preview-asse
|
||||
AdminTemplatePreviewService,
|
||||
AdminTemplatePreviewAssetsService,
|
||||
TemplateOperationMetricsService,
|
||||
AdminClientErrorService,
|
||||
],
|
||||
})
|
||||
export class AdminModule {}
|
||||
@@ -0,0 +1,55 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import { HttpException } from "@nestjs/common";
|
||||
import { AdminClientErrorService } from "../src/modules/admin/admin-client-error.service.js";
|
||||
|
||||
function report(errorId: string, subject = "admin:user-1") {
|
||||
return {
|
||||
subject,
|
||||
brandId: "brand-1",
|
||||
errorId,
|
||||
message: "boom",
|
||||
route: "/admin/trust",
|
||||
requestId: "req-1",
|
||||
userAgent: "test-agent",
|
||||
};
|
||||
}
|
||||
|
||||
test("首次上报记录,相同 errorId 在窗口内按管理员去重", () => {
|
||||
const service = new AdminClientErrorService();
|
||||
assert.deepEqual(service.record(report("admin-error-1")), {
|
||||
received: true,
|
||||
duplicate: false,
|
||||
});
|
||||
assert.deepEqual(service.record(report("admin-error-1")), {
|
||||
received: true,
|
||||
duplicate: true,
|
||||
});
|
||||
// 不同管理员使用相同 errorId 时互不影响
|
||||
assert.deepEqual(service.record(report("admin-error-1", "admin:user-2")), {
|
||||
received: true,
|
||||
duplicate: false,
|
||||
});
|
||||
});
|
||||
|
||||
test("同一管理员 60 秒内最多接受 10 条不同错误", () => {
|
||||
const service = new AdminClientErrorService();
|
||||
for (let index = 0; index < 10; index += 1) {
|
||||
assert.deepEqual(service.record(report(`admin-rate-${index}`)), {
|
||||
received: true,
|
||||
duplicate: false,
|
||||
});
|
||||
}
|
||||
try {
|
||||
service.record(report("admin-rate-overflow"));
|
||||
assert.fail("应当触发限流");
|
||||
} catch (error) {
|
||||
assert.ok(error instanceof HttpException);
|
||||
assert.equal(error.getStatus(), 429);
|
||||
}
|
||||
// 另一个管理员不受影响
|
||||
assert.deepEqual(service.record(report("admin-rate-other", "admin:user-2")), {
|
||||
received: true,
|
||||
duplicate: false,
|
||||
});
|
||||
});
|
||||
@@ -1892,6 +1892,42 @@ async function request(url, options = {}) {
|
||||
});
|
||||
}
|
||||
|
||||
test("admin client error reports are authenticated, validated, and deduplicated", async () => {
|
||||
await assertProtectedRouteBoundary("/admin/client-errors", {
|
||||
method: "POST",
|
||||
payload: { errorId: "admin-boundary-check", message: "boom", route: "/admin/publication" },
|
||||
});
|
||||
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
assert.equal(login.statusCode, 201);
|
||||
const headers = { authorization: `Bearer ${sessionToken(login)}` };
|
||||
const errorId = `admin-it-${Date.now().toString(36)}`;
|
||||
const payload = {
|
||||
errorId,
|
||||
message: "Cannot read properties of null (reading 'type')",
|
||||
route: "/admin/trust?tab=1",
|
||||
componentStack: "at TrustContentPage",
|
||||
};
|
||||
|
||||
const first = await request("/admin/client-errors", { method: "POST", headers, payload });
|
||||
assert.equal(first.statusCode, 201);
|
||||
assert.deepEqual(JSON.parse(first.body), { received: true, duplicate: false });
|
||||
|
||||
const duplicate = await request("/admin/client-errors", { method: "POST", headers, payload });
|
||||
assert.equal(duplicate.statusCode, 201);
|
||||
assert.deepEqual(JSON.parse(duplicate.body), { received: true, duplicate: true });
|
||||
|
||||
const invalid = await request("/admin/client-errors", {
|
||||
method: "POST",
|
||||
headers,
|
||||
payload: { errorId: "bad", message: "", route: "no-slash" },
|
||||
});
|
||||
assert.equal(invalid.statusCode, 400);
|
||||
});
|
||||
|
||||
async function assertProtectedRouteBoundary(url, options = {}) {
|
||||
const { method = "GET", payload, forbiddenRole = "customer", headers = {} } = options;
|
||||
const requestOptions = payload === undefined ? { method, headers } : { method, headers, payload };
|
||||
|
||||
@@ -657,6 +657,13 @@ export const ROUTE_COVERAGE: RouteCoverage[] = [
|
||||
authorizationTest: null,
|
||||
successTest: "wechat login creates a customer session for the requested brand",
|
||||
},
|
||||
{
|
||||
method: "POST",
|
||||
path: "/admin/client-errors",
|
||||
auth: "brand",
|
||||
authorizationTest: "admin client error reports are authenticated, validated, and deduplicated",
|
||||
successTest: "admin client error reports are authenticated, validated, and deduplicated",
|
||||
},
|
||||
{
|
||||
method: "PUT",
|
||||
path: "/admin/uploads/local",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { test, expect, type Page, type Route } from "@playwright/test";
|
||||
|
||||
const adminOrigin = process.env.ADMIN_URL || "http://localhost:3005";
|
||||
@@ -19,12 +20,27 @@ interface MockOptions {
|
||||
memberships?: unknown;
|
||||
/** 品牌名称的异常返回 */
|
||||
brandName?: unknown;
|
||||
/** 始终返回的异常信任内容,用于验证契约错误态 */
|
||||
trustContent?: unknown;
|
||||
/** 只在首次请求时返回的异常信任内容,重新加载后恢复 */
|
||||
trustContentOnce?: unknown;
|
||||
/** 只在首次请求时返回的异常工作区数据,用于触发渲染异常 */
|
||||
workspaceOnce?: unknown;
|
||||
/** 上报接口返回的状态码 */
|
||||
clientErrorStatus?: number;
|
||||
}
|
||||
|
||||
type ClientErrorReport = {
|
||||
errorId?: string;
|
||||
message?: string;
|
||||
route?: string;
|
||||
componentStack?: string;
|
||||
};
|
||||
|
||||
async function mockAdminApi(page: Page, options: MockOptions = {}) {
|
||||
let servedTrustContent = false;
|
||||
let servedWorkspace = false;
|
||||
const clientErrors: ClientErrorReport[] = [];
|
||||
|
||||
await page.route("**/api/**", async (route: Route) => {
|
||||
const request = route.request();
|
||||
@@ -70,13 +86,35 @@ async function mockAdminApi(page: Page, options: MockOptions = {}) {
|
||||
});
|
||||
}
|
||||
if (path === "/admin/config/trust-content" && method === "GET") {
|
||||
if (options.trustContent !== undefined) {
|
||||
return route.fulfill({ json: options.trustContent });
|
||||
}
|
||||
if (!servedTrustContent && options.trustContentOnce !== undefined) {
|
||||
servedTrustContent = true;
|
||||
return route.fulfill({ json: options.trustContentOnce });
|
||||
}
|
||||
return route.fulfill({ json: [] });
|
||||
}
|
||||
if (path === "/admin/client-errors" && method === "POST") {
|
||||
clientErrors.push(JSON.parse(request.postData() ?? "{}") as ClientErrorReport);
|
||||
return route.fulfill({
|
||||
status: options.clientErrorStatus ?? 201,
|
||||
...(options.clientErrorStatus && options.clientErrorStatus >= 400
|
||||
? {
|
||||
json: {
|
||||
data: null,
|
||||
error: { code: "HTTP_500", message: "上报失败" },
|
||||
requestId: "req-client-error",
|
||||
},
|
||||
}
|
||||
: { json: { received: true, duplicate: false } }),
|
||||
});
|
||||
}
|
||||
if (path === "/admin/workspace") {
|
||||
if (!servedWorkspace && options.workspaceOnce !== undefined) {
|
||||
servedWorkspace = true;
|
||||
return route.fulfill({ json: options.workspaceOnce });
|
||||
}
|
||||
return route.fulfill({
|
||||
json: {
|
||||
brand: { id: "brand-current", name: "独立工坊" },
|
||||
@@ -92,6 +130,8 @@ async function mockAdminApi(page: Page, options: MockOptions = {}) {
|
||||
}
|
||||
return route.fulfill({ json: [] });
|
||||
});
|
||||
|
||||
return { clientErrors };
|
||||
}
|
||||
|
||||
test("品牌成员与品牌名称异常时后台外壳仍可正常使用", async ({ page }) => {
|
||||
@@ -109,14 +149,27 @@ test("品牌成员与品牌名称异常时后台外壳仍可正常使用", async
|
||||
await expect(page.getByRole("button", { name: "退出登录" })).toBeVisible();
|
||||
});
|
||||
|
||||
test("内容区渲染出错时保留导航,重新加载后恢复", async ({ page }) => {
|
||||
test("内容区渲染出错时上报错误编号并保留导航,重新加载后恢复", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1440, height: 1000 });
|
||||
await mockAdminApi(page, { trustContentOnce: [null] });
|
||||
const { clientErrors } = await mockAdminApi(page, {
|
||||
workspaceOnce: {
|
||||
brand: { id: "brand-current", name: "独立工坊" },
|
||||
installations: [],
|
||||
templateContent: { displayName: "独立创作者画册", trustContentTypes: [null] },
|
||||
offerings: [],
|
||||
forms: [],
|
||||
},
|
||||
});
|
||||
|
||||
await page.goto(`${adminOrigin}/admin/trust`);
|
||||
|
||||
await expect(page.getByText("页面渲染出错")).toBeVisible();
|
||||
await expect(page.getByText(/错误编号:admin-/)).toBeVisible();
|
||||
await expect.poll(() => clientErrors.length).toBe(1);
|
||||
const report = clientErrors[0];
|
||||
assert.match(report?.errorId ?? "", /^admin-/);
|
||||
assert.equal(report?.route, "/admin/trust");
|
||||
assert.ok(report?.message);
|
||||
|
||||
// 外壳导航仍然可用,不会因为单个页面崩溃而整站白屏
|
||||
await expect(page.getByRole("button", { name: "退出登录" })).toBeVisible();
|
||||
@@ -130,3 +183,38 @@ test("内容区渲染出错时保留导航,重新加载后恢复", async ({ pa
|
||||
await expect(page.getByRole("heading", { name: "信任内容" })).toBeVisible();
|
||||
await expect(page.getByText("页面渲染出错")).toBeHidden();
|
||||
});
|
||||
|
||||
test("响应契约不符时展示可读错误,不进入渲染错误边界", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1440, height: 1000 });
|
||||
const { clientErrors } = await mockAdminApi(page, { trustContent: [null] });
|
||||
|
||||
await page.goto(`${adminOrigin}/admin/trust`);
|
||||
|
||||
await expect(page.getByRole("alert")).toContainText("接口返回数据结构不符合契约");
|
||||
await expect(page.getByRole("alert")).toContainText("/admin/config/trust-content");
|
||||
await expect(page.getByText("页面渲染出错")).toBeHidden();
|
||||
assert.equal(clientErrors.length, 0);
|
||||
});
|
||||
|
||||
test("错误上报失败时错误页仍然可用", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1440, height: 1000 });
|
||||
const { clientErrors } = await mockAdminApi(page, {
|
||||
clientErrorStatus: 500,
|
||||
workspaceOnce: {
|
||||
brand: { id: "brand-current", name: "独立工坊" },
|
||||
installations: [],
|
||||
templateContent: { displayName: "独立创作者画册", trustContentTypes: [null] },
|
||||
offerings: [],
|
||||
forms: [],
|
||||
},
|
||||
});
|
||||
|
||||
await page.goto(`${adminOrigin}/admin/trust`);
|
||||
|
||||
await expect(page.getByText("页面渲染出错")).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "重新加载页面" })).toBeVisible();
|
||||
await expect.poll(() => clientErrors.length).toBe(1);
|
||||
// 上报失败不会让错误页递归崩溃,也不会产生未捕获异常
|
||||
await page.waitForTimeout(300);
|
||||
await expect(page.getByText("页面渲染出错")).toBeVisible();
|
||||
});
|
||||
@@ -15,6 +15,7 @@
|
||||
"clean": "rimraf dist"
|
||||
},
|
||||
"dependencies": {
|
||||
"@personal-brand/types": "workspace:*"
|
||||
"@personal-brand/types": "workspace:*",
|
||||
"zod": "^3.25.0"
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { ZodType } from "zod";
|
||||
import type { ApiErrorBody } from "../types/common.js";
|
||||
|
||||
export interface FetchResponse {
|
||||
@@ -17,15 +18,20 @@ export interface ApiClientOptions {
|
||||
token?: string;
|
||||
}
|
||||
|
||||
export type RequestFn = <T>(
|
||||
path: string,
|
||||
options?: { method?: string; body?: unknown; rawBody?: unknown },
|
||||
) => Promise<T>;
|
||||
export interface RequestOptions {
|
||||
method?: string;
|
||||
body?: unknown;
|
||||
rawBody?: unknown;
|
||||
/** 响应体的运行时契约;不匹配时抛出 ApiClientContractError,而不是把脏数据交给页面。 */
|
||||
expect?: ZodType<unknown>;
|
||||
}
|
||||
|
||||
export type RequestFn = <T>(path: string, options?: RequestOptions) => Promise<T>;
|
||||
|
||||
export async function request<T>(
|
||||
state: { baseUrl: string; fetcher: FetchLike; token?: string | undefined },
|
||||
path: string,
|
||||
options: { method?: string; body?: unknown; rawBody?: unknown } = {},
|
||||
options: RequestOptions = {},
|
||||
): Promise<T> {
|
||||
const headers: Record<string, string> = { accept: "application/json" };
|
||||
if (options.rawBody === undefined && options.body !== undefined)
|
||||
@@ -48,9 +54,37 @@ export async function request<T>(
|
||||
)(`${state.baseUrl}${path}`, init);
|
||||
const body = await response.json();
|
||||
if (!response.ok) throw new ApiClientError(response.status, body as ApiErrorBody);
|
||||
if (options.expect) assertResponseContract(options.expect, body, path);
|
||||
return body as T;
|
||||
}
|
||||
|
||||
/** 接口返回结构不符合客户端契约:携带请求路径与首个校验问题,方便定位。 */
|
||||
export class ApiClientContractError extends Error {
|
||||
constructor(
|
||||
readonly path: string,
|
||||
readonly issues: string[],
|
||||
) {
|
||||
super(`接口返回数据结构不符合契约:${path}${issues.length > 0 ? `(${issues[0]})` : ""}`);
|
||||
this.name = "ApiClientContractError";
|
||||
}
|
||||
}
|
||||
|
||||
export function assertResponseContract(
|
||||
schema: ZodType<unknown>,
|
||||
value: unknown,
|
||||
path: string,
|
||||
): void {
|
||||
const result = schema.safeParse(value);
|
||||
if (result.success) return;
|
||||
throw new ApiClientContractError(
|
||||
path,
|
||||
result.error.issues.map((issue) => {
|
||||
const location = issue.path.length > 0 ? issue.path.join(".") + ":" : "";
|
||||
return location + issue.message;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export class ApiClientError extends Error {
|
||||
constructor(
|
||||
readonly status: number,
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
export { ApiClientError } from "./client/request.js";
|
||||
export type { ApiClientOptions, FetchLike, FetchResponse, RequestFn } from "./client/request.js";
|
||||
export {
|
||||
ApiClientContractError,
|
||||
ApiClientError,
|
||||
assertResponseContract,
|
||||
} from "./client/request.js";
|
||||
export type {
|
||||
ApiClientOptions,
|
||||
FetchLike,
|
||||
FetchResponse,
|
||||
RequestFn,
|
||||
RequestOptions,
|
||||
} from "./client/request.js";
|
||||
export type {
|
||||
AdminBooking,
|
||||
Booking,
|
||||
@@ -66,7 +76,11 @@ export const apiClientName = "personal-brand-api-client";
|
||||
|
||||
import { bookingMethods } from "./resources/booking.js";
|
||||
import { brandMethods } from "./resources/brand.js";
|
||||
import { request as createRequest, type ApiClientOptions } from "./client/request.js";
|
||||
import {
|
||||
request as createRequest,
|
||||
type ApiClientOptions,
|
||||
type RequestFn,
|
||||
} from "./client/request.js";
|
||||
import { inquiryMethods } from "./resources/inquiry.js";
|
||||
import { mediaMethods } from "./resources/media.js";
|
||||
import { offeringMethods } from "./resources/offering.js";
|
||||
@@ -103,10 +117,7 @@ export class ApiClient
|
||||
TrustMethods
|
||||
{
|
||||
private readonly state: ClientState;
|
||||
private readonly requestFn: <T>(
|
||||
path: string,
|
||||
options?: { method?: string; body?: unknown; rawBody?: unknown },
|
||||
) => Promise<T>;
|
||||
private readonly requestFn: RequestFn;
|
||||
private resources!: {
|
||||
booking: BookingMethods;
|
||||
brand: BrandMethods;
|
||||
@@ -172,6 +183,8 @@ export class ApiClient
|
||||
this.resources.session.logoutAdmin(...arguments_);
|
||||
logoutCustomer = (...arguments_: Parameters<SessionMethods["logoutCustomer"]>) =>
|
||||
this.resources.session.logoutCustomer(...arguments_);
|
||||
reportAdminClientError = (...arguments_: Parameters<SessionMethods["reportAdminClientError"]>) =>
|
||||
this.resources.session.reportAdminClientError(...arguments_);
|
||||
listCustomerBookings = (...arguments_: Parameters<BookingMethods["listCustomerBookings"]>) =>
|
||||
this.resources.booking.listCustomerBookings(...arguments_);
|
||||
createCustomerBooking = (...arguments_: Parameters<BookingMethods["createCustomerBooking"]>) =>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { BookingStatus } from "@personal-brand/types";
|
||||
import type { RequestFn } from "../client/request.js";
|
||||
import { adminBookingListSchema, adminBookingTagListSchema } from "../schemas/admin-collections.js";
|
||||
import type {
|
||||
AdminBooking,
|
||||
Booking,
|
||||
@@ -38,7 +39,9 @@ export function bookingMethods({ request }: { request: RequestFn }): BookingMeth
|
||||
if (filters.unreadOnly !== undefined) params.push(`unreadOnly=${filters.unreadOnly}`);
|
||||
if (filters.tagId) params.push(`tagId=${encodeURIComponent(filters.tagId)}`);
|
||||
const query = params.join("&");
|
||||
return request(`/admin/bookings${query ? `?${query}` : ""}`);
|
||||
return request(`/admin/bookings${query ? `?${query}` : ""}`, {
|
||||
expect: adminBookingListSchema,
|
||||
});
|
||||
},
|
||||
getAdminBooking: (id) => request(`/admin/bookings/${encodeURIComponent(id)}`),
|
||||
getAdminUnreadCount: () => request("/admin/bookings/unread-count"),
|
||||
@@ -49,7 +52,7 @@ export function bookingMethods({ request }: { request: RequestFn }): BookingMeth
|
||||
}),
|
||||
markAdminBookingRead: (id) =>
|
||||
request(`/admin/bookings/${encodeURIComponent(id)}/read`, { method: "POST" }),
|
||||
listAdminTags: () => request("/admin/bookings/tags"),
|
||||
listAdminTags: () => request("/admin/bookings/tags", { expect: adminBookingTagListSchema }),
|
||||
createAdminTag: (name) => request("/admin/bookings/tags", { method: "POST", body: { name } }),
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,10 @@
|
||||
import type { RequestFn } from "../client/request.js";
|
||||
import {
|
||||
adminBrandMemberListSchema,
|
||||
adminBrandMembershipListSchema,
|
||||
adminMiniAppReleaseListSchema,
|
||||
adminReleaseListSchema,
|
||||
} from "../schemas/admin-collections.js";
|
||||
import type {
|
||||
AdminBrandMember,
|
||||
AdminBrandMembership,
|
||||
@@ -80,12 +86,13 @@ export interface BrandMethods {
|
||||
export function brandMethods({ request }: { request: RequestFn }): BrandMethods {
|
||||
return {
|
||||
getAdminBrand: () => request("/admin/config/brand"),
|
||||
listAdminBrands: () => request("/admin/brands"),
|
||||
listAdminBrands: () => request("/admin/brands", { expect: adminBrandMembershipListSchema }),
|
||||
getAdminBrandCreationOptions: () => request("/admin/brands/creation-options"),
|
||||
createAdminBrand: (body) => request("/admin/brands", { method: "POST", body }),
|
||||
switchAdminBrand: (brandId) =>
|
||||
request(`/admin/brands/${encodeURIComponent(brandId)}/switch`, { method: "POST" }),
|
||||
listAdminMembers: () => request("/admin/brands/members"),
|
||||
listAdminMembers: () =>
|
||||
request("/admin/brands/members", { expect: adminBrandMemberListSchema }),
|
||||
createAdminMember: (body) => request("/admin/brands/members", { method: "POST", body }),
|
||||
updateAdminMember: (id, body) =>
|
||||
request(`/admin/brands/members/${encodeURIComponent(id)}`, {
|
||||
@@ -95,7 +102,7 @@ export function brandMethods({ request }: { request: RequestFn }): BrandMethods
|
||||
updateAdminBrand: (body) => request("/admin/config/brand", { method: "PATCH", body }),
|
||||
updateAdminBrandPresentation: (body) =>
|
||||
request("/admin/config/presentation", { method: "PATCH", body }),
|
||||
listAdminReleases: () => request("/admin/releases"),
|
||||
listAdminReleases: () => request("/admin/releases", { expect: adminReleaseListSchema }),
|
||||
getAdminReleaseReadiness: () => request("/admin/releases/readiness"),
|
||||
publishAdminRelease: (note) =>
|
||||
request("/admin/releases/publish", {
|
||||
@@ -108,7 +115,8 @@ export function brandMethods({ request }: { request: RequestFn }): BrandMethods
|
||||
body: note === undefined ? {} : { note },
|
||||
}),
|
||||
revokeAdminRelease: () => request("/admin/releases/revoke", { method: "POST" }),
|
||||
listAdminMiniAppReleases: () => request("/admin/miniapp-releases"),
|
||||
listAdminMiniAppReleases: () =>
|
||||
request("/admin/miniapp-releases", { expect: adminMiniAppReleaseListSchema }),
|
||||
getLatestAdminMiniAppRelease: () => request("/admin/miniapp-releases/latest"),
|
||||
createAdminMiniAppRelease: (releaseId) =>
|
||||
request("/admin/miniapp-releases", {
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import type { RequestFn } from "../client/request.js";
|
||||
import {
|
||||
adminInquiryFormListSchema,
|
||||
adminInquirySubmissionListSchema,
|
||||
} from "../schemas/admin-collections.js";
|
||||
import type { BrandFieldDefinition } from "../types/field.js";
|
||||
import type { InquiryForm, InquirySubmission } from "../types/inquiry.js";
|
||||
|
||||
@@ -42,8 +46,10 @@ export function inquiryMethods({ request }: { request: RequestFn }): InquiryMeth
|
||||
createAdminField: (body) => request("/admin/workspace/fields", { method: "POST", body }),
|
||||
deleteAdminField: (id) =>
|
||||
request(`/admin/workspace/fields/${encodeURIComponent(id)}`, { method: "DELETE" }),
|
||||
listAdminInquiryForms: () => request("/admin/workspace/forms"),
|
||||
listAdminInquirySubmissions: () => request("/admin/workspace/submissions"),
|
||||
listAdminInquiryForms: () =>
|
||||
request("/admin/workspace/forms", { expect: adminInquiryFormListSchema }),
|
||||
listAdminInquirySubmissions: () =>
|
||||
request("/admin/workspace/submissions", { expect: adminInquirySubmissionListSchema }),
|
||||
updateAdminInquirySubmission: (id, body) =>
|
||||
request(`/admin/workspace/submissions/${encodeURIComponent(id)}`, {
|
||||
method: "PATCH",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { RequestFn } from "../client/request.js";
|
||||
import { adminOfferingListSchema } from "../schemas/admin-collections.js";
|
||||
import type { Offering } from "../types/offering.js";
|
||||
|
||||
export interface OfferingMethods {
|
||||
@@ -17,7 +18,8 @@ export function offeringMethods({ request }: { request: RequestFn }): OfferingMe
|
||||
return {
|
||||
getPublicOffering: (id) => request(`/public/offerings/${encodeURIComponent(id)}`),
|
||||
listPublicOfferings: () => request("/public/offerings"),
|
||||
listAdminOfferings: () => request("/admin/workspace/offerings"),
|
||||
listAdminOfferings: () =>
|
||||
request("/admin/workspace/offerings", { expect: adminOfferingListSchema }),
|
||||
createAdminOffering: (body) => request("/admin/workspace/offerings", { method: "POST", body }),
|
||||
updateAdminOffering: (id, body) =>
|
||||
request(`/admin/workspace/offerings/${encodeURIComponent(id)}`, {
|
||||
|
||||
@@ -16,6 +16,12 @@ export interface SessionMethods {
|
||||
changeAdminPassword(currentPassword: string, newPassword: string): Promise<{ changed: true }>;
|
||||
logoutAdmin(): Promise<{ loggedOut: true }>;
|
||||
logoutCustomer(): Promise<{ loggedOut: true }>;
|
||||
reportAdminClientError(input: {
|
||||
errorId: string;
|
||||
message: string;
|
||||
route: string;
|
||||
componentStack?: string;
|
||||
}): Promise<{ received: true; duplicate: boolean }>;
|
||||
}
|
||||
|
||||
export function sessionMethods({ request }: { request: RequestFn }): SessionMethods {
|
||||
@@ -30,5 +36,7 @@ export function sessionMethods({ request }: { request: RequestFn }): SessionMeth
|
||||
}),
|
||||
logoutAdmin: () => request("/admin/session/logout", { method: "POST", body: {} }),
|
||||
logoutCustomer: () => request("/customer/session/logout", { method: "POST", body: {} }),
|
||||
reportAdminClientError: (input) =>
|
||||
request("/admin/client-errors", { method: "POST", body: input }),
|
||||
};
|
||||
}
|
||||
@@ -1,5 +1,11 @@
|
||||
import type { BrandTemplateKey, RuntimeWorkspace } from "@personal-brand/types";
|
||||
import type { RequestFn } from "../client/request.js";
|
||||
import {
|
||||
adminCapabilityListSchema,
|
||||
adminTemplateOperationFailuresSchema,
|
||||
adminTemplatePackageAuditListSchema,
|
||||
adminTemplatePackageListSchema,
|
||||
} from "../schemas/admin-collections.js";
|
||||
import type { BrandPageSchemeOptions, BrandProfile } from "../types/brand.js";
|
||||
import type { CapabilityWithMetadata } from "../types/capability.js";
|
||||
import type { BrandFieldDefinition } from "../types/field.js";
|
||||
@@ -319,7 +325,9 @@ export function templateMethods({ request }: { request: RequestFn }): TemplateMe
|
||||
? null
|
||||
: `pageSize=${encodeURIComponent(String(params.pageSize))}`,
|
||||
].filter((item): item is string => item !== null);
|
||||
return request(`/admin/templates${query.length ? `?${query.join("&")}` : ""}`);
|
||||
return request(`/admin/templates${query.length ? `?${query.join("&")}` : ""}`, {
|
||||
expect: adminTemplatePackageListSchema,
|
||||
});
|
||||
},
|
||||
importAdminTemplatePackage: (body) =>
|
||||
request("/admin/templates/import", { method: "POST", rawBody: body }),
|
||||
@@ -328,7 +336,9 @@ export function templateMethods({ request }: { request: RequestFn }): TemplateMe
|
||||
retireAdminTemplatePackage: (id) =>
|
||||
request(`/admin/templates/${encodeURIComponent(id)}/retire`, { method: "POST" }),
|
||||
listAdminTemplatePackageAudit: (id) =>
|
||||
request(`/admin/templates/${encodeURIComponent(id)}/audit`),
|
||||
request(`/admin/templates/${encodeURIComponent(id)}/audit`, {
|
||||
expect: adminTemplatePackageAuditListSchema,
|
||||
}),
|
||||
previewAdminTemplatePackage: (id, industry, session) =>
|
||||
request(
|
||||
`/admin/templates/${encodeURIComponent(id)}/preview?industry=${encodeURIComponent(industry)}${session ? `&session=${encodeURIComponent(session)}` : ""}`,
|
||||
@@ -383,7 +393,8 @@ export function templateMethods({ request }: { request: RequestFn }): TemplateMe
|
||||
}),
|
||||
selectAdminTemplateVersion: (input) =>
|
||||
request("/admin/workspace/template/select-version", { method: "POST", body: input }),
|
||||
listAdminCapabilities: () => request("/admin/workspace/capabilities"),
|
||||
listAdminCapabilities: () =>
|
||||
request("/admin/workspace/capabilities", { expect: adminCapabilityListSchema }),
|
||||
updateAdminCapability: (key, body) =>
|
||||
request(`/admin/workspace/capabilities/${encodeURIComponent(key)}`, {
|
||||
method: "PATCH",
|
||||
@@ -409,6 +420,7 @@ export function templateMethods({ request }: { request: RequestFn }): TemplateMe
|
||||
getAdminTemplateOperationFailures: (params = {}) =>
|
||||
request(
|
||||
`/admin/template-operations/failures${params.days === undefined ? "" : `?days=${encodeURIComponent(String(params.days))}`}`,
|
||||
{ expect: adminTemplateOperationFailuresSchema },
|
||||
),
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { RequestFn } from "../client/request.js";
|
||||
import { adminTrustContentListSchema } from "../schemas/admin-collections.js";
|
||||
import type { TrustContent, TrustContentInput } from "../types/trust.js";
|
||||
|
||||
export interface TrustMethods {
|
||||
@@ -10,7 +11,8 @@ export interface TrustMethods {
|
||||
|
||||
export function trustMethods({ request }: { request: RequestFn }): TrustMethods {
|
||||
return {
|
||||
listAdminTrustContent: () => request("/admin/config/trust-content"),
|
||||
listAdminTrustContent: () =>
|
||||
request("/admin/config/trust-content", { expect: adminTrustContentListSchema }),
|
||||
createAdminTrustContent: (body) =>
|
||||
request("/admin/config/trust-content", { method: "POST", body }),
|
||||
updateAdminTrustContent: (id, body) =>
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
import { z } from "zod";
|
||||
|
||||
/**
|
||||
* Admin 列表接口的运行时契约。
|
||||
*
|
||||
* 这些 schema 只用于校验,不参与数据转换:请求层在通过校验后返回原始响应体,
|
||||
* 因此新增字段不会被裁剪。缺少关键字段或字段类型错误时抛出 ApiClientContractError,
|
||||
* 由页面已有的错误态展示,而不是让 React 在渲染阶段崩溃。
|
||||
*/
|
||||
|
||||
const record = z.record(z.string(), z.unknown());
|
||||
const nullableText = z.string().nullish();
|
||||
|
||||
export const adminBrandMembershipListSchema = z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
role: z.string(),
|
||||
brand: z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
slug: z.string(),
|
||||
templateKey: z.string(),
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
||||
export const adminBrandMemberListSchema = z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
role: z.string(),
|
||||
isEnabled: z.boolean(),
|
||||
adminUser: z.object({
|
||||
id: z.string(),
|
||||
username: z.string(),
|
||||
displayName: z.string(),
|
||||
isEnabled: z.boolean(),
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
||||
export const adminReleaseListSchema = z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
version: z.number(),
|
||||
status: z.string(),
|
||||
actorId: z.string(),
|
||||
createdAt: z.string(),
|
||||
note: nullableText,
|
||||
revokedAt: nullableText,
|
||||
}),
|
||||
);
|
||||
|
||||
export const adminMiniAppReleaseListSchema = z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
version: z.number(),
|
||||
status: z.enum([
|
||||
"built",
|
||||
"uploaded",
|
||||
"under_review",
|
||||
"rejected",
|
||||
"approved",
|
||||
"published",
|
||||
"failed",
|
||||
]),
|
||||
createdAt: z.string(),
|
||||
updatedAt: z.string(),
|
||||
}),
|
||||
);
|
||||
|
||||
export const adminTrustContentListSchema = z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
type: z.string(),
|
||||
title: z.string(),
|
||||
content: z.string(),
|
||||
sortOrder: z.number(),
|
||||
isPublished: z.boolean(),
|
||||
summary: nullableText,
|
||||
coverUrl: nullableText,
|
||||
config: record.nullish(),
|
||||
}),
|
||||
);
|
||||
|
||||
export const adminOfferingListSchema = z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
kind: z.enum(["service", "product", "package", "subscription"]),
|
||||
name: z.string(),
|
||||
isEnabled: z.boolean(),
|
||||
sortOrder: z.number(),
|
||||
}),
|
||||
);
|
||||
|
||||
export const adminInquiryFormListSchema = z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
version: z.number(),
|
||||
isEnabled: z.boolean(),
|
||||
fieldsSnapshot: z.array(z.unknown()),
|
||||
purpose: z.enum(["inquiry", "booking", "quote-request"]),
|
||||
targetType: z.enum(["brand", "offering"]),
|
||||
submissionAction: z.enum(["create-inquiry", "create-booking", "create-quote"]),
|
||||
}),
|
||||
);
|
||||
|
||||
export const adminInquirySubmissionListSchema = z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
inquiryFormId: z.string(),
|
||||
formVersion: z.number(),
|
||||
fieldsSnapshot: z.array(z.unknown()),
|
||||
values: record,
|
||||
activeFields: record,
|
||||
createdAt: z.string(),
|
||||
status: z.enum(["new", "reviewing", "replied", "qualified", "converted", "closed"]),
|
||||
}),
|
||||
);
|
||||
|
||||
export const adminBookingListSchema = z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
bookingNo: z.string(),
|
||||
status: z.enum(["received", "contacting", "confirmed", "completed", "cancelled"]),
|
||||
estimatedAmount: z.number().nullable(),
|
||||
createdAt: z.string(),
|
||||
customerName: z.string(),
|
||||
}),
|
||||
);
|
||||
|
||||
export const adminBookingTagListSchema = z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
isPreset: z.boolean(),
|
||||
isEnabled: z.boolean(),
|
||||
}),
|
||||
);
|
||||
|
||||
export const adminCapabilityListSchema = z.array(
|
||||
z.object({
|
||||
id: z.string().nullable(),
|
||||
capabilityKey: z.string(),
|
||||
capabilityVersion: z.string(),
|
||||
status: z.enum(["enabled", "disabled", "degraded"]),
|
||||
updatedAt: z.string().nullable(),
|
||||
}),
|
||||
);
|
||||
|
||||
const templatePackageVersionSchema = z.object({
|
||||
id: z.string(),
|
||||
templatePackageId: z.string(),
|
||||
packageKey: z.string(),
|
||||
version: z.string(),
|
||||
displayName: z.string(),
|
||||
status: z.enum(["imported", "published", "retired", "disabled"]),
|
||||
contentChecksum: z.string(),
|
||||
archiveChecksum: z.string(),
|
||||
importedAt: z.string(),
|
||||
updatedAt: z.string(),
|
||||
validationReport: record,
|
||||
importedBy: z.object({
|
||||
id: z.string(),
|
||||
username: z.string(),
|
||||
displayName: z.string(),
|
||||
}),
|
||||
});
|
||||
|
||||
export const adminTemplatePackageListSchema = z.object({
|
||||
items: z.array(templatePackageVersionSchema),
|
||||
page: z.number(),
|
||||
pageSize: z.number(),
|
||||
total: z.number(),
|
||||
});
|
||||
|
||||
export const adminTemplatePackageAuditListSchema = z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
action: z.string(),
|
||||
fromStatus: z.enum(["imported", "published", "retired", "disabled"]).nullish(),
|
||||
toStatus: z.enum(["imported", "published", "retired", "disabled"]).nullish(),
|
||||
requestId: nullableText,
|
||||
createdAt: z.string(),
|
||||
actor: z.object({
|
||||
id: z.string(),
|
||||
username: z.string(),
|
||||
displayName: z.string(),
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
||||
export const adminTemplateOperationFailuresSchema = z.object({
|
||||
since: z.string(),
|
||||
until: z.string(),
|
||||
days: z.number(),
|
||||
backfilled: z.boolean(),
|
||||
failures: z.array(z.object({ action: z.string(), count: z.number() })),
|
||||
});
|
||||
@@ -1,6 +1,14 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import { ApiClient, ApiClientError, type FetchResponse } from "../src/index.js";
|
||||
import {
|
||||
ApiClient,
|
||||
ApiClientContractError,
|
||||
ApiClientError,
|
||||
assertResponseContract,
|
||||
type FetchResponse,
|
||||
} from "../src/index.js";
|
||||
import { adminTrustContentListSchema } from "../src/schemas/admin-collections.js";
|
||||
import { z } from "zod";
|
||||
|
||||
function response(body: unknown, status = 200): FetchResponse {
|
||||
return { status, ok: status >= 200 && status < 300, json: async () => body };
|
||||
@@ -14,7 +22,7 @@ test("客户端发送认证头、查询参数和 JSON 请求体", async () => {
|
||||
token: "token-1",
|
||||
fetcher: async (url, init) => {
|
||||
calls.push({ url, init });
|
||||
return response({ count: 2 });
|
||||
return response(url.includes("/admin/bookings?") ? [] : { count: 2 });
|
||||
},
|
||||
});
|
||||
await client.listAdminBookings({ status: "received", unreadOnly: true, tagId: "tag/1" });
|
||||
@@ -303,3 +311,112 @@ test("模板运营失败指标客户端发送查询窗口", async () => {
|
||||
{ url: "http://api.test/admin/template-operations/failures?days=14", method: "GET" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("响应契约通过时保留原始数据,包含 schema 未声明的字段", async () => {
|
||||
const body = [
|
||||
{
|
||||
id: "trust-1",
|
||||
type: "credential",
|
||||
title: "从业十年",
|
||||
content: "长期服务本地客户",
|
||||
sortOrder: 0,
|
||||
isPublished: true,
|
||||
summary: null,
|
||||
coverUrl: null,
|
||||
config: { sections: [] },
|
||||
futureField: "保留",
|
||||
},
|
||||
];
|
||||
const client = new ApiClient({
|
||||
baseUrl: "http://api.test",
|
||||
fetcher: async () => response(body),
|
||||
});
|
||||
const result = await client.listAdminTrustContent();
|
||||
assert.deepEqual(result, body);
|
||||
});
|
||||
|
||||
test("响应契约不匹配时抛出带接口路径的 ApiClientContractError", async () => {
|
||||
const client = new ApiClient({
|
||||
baseUrl: "http://api.test",
|
||||
fetcher: async () => response([null]),
|
||||
});
|
||||
await assert.rejects(
|
||||
() => client.listAdminTrustContent(),
|
||||
(error: unknown) => {
|
||||
assert.ok(error instanceof ApiClientContractError);
|
||||
assert.equal(error.path, "/admin/config/trust-content");
|
||||
assert.match(error.message, /\/admin\/config\/trust-content/);
|
||||
assert.ok(error.issues.length > 0);
|
||||
return true;
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test("契约校验只接受对象数组且拒绝缺少关键字段的记录", () => {
|
||||
assert.throws(
|
||||
() =>
|
||||
assertResponseContract(
|
||||
z.array(z.object({ id: z.string() })),
|
||||
[{ id: "ok" }, { id: 1 }],
|
||||
"/admin/example",
|
||||
),
|
||||
(error: unknown) => {
|
||||
assert.ok(error instanceof ApiClientContractError);
|
||||
assert.match(error.issues[0] ?? "", /^1\.id:/);
|
||||
return true;
|
||||
},
|
||||
);
|
||||
assert.doesNotThrow(() =>
|
||||
assertResponseContract(adminTrustContentListSchema, [], "/admin/config/trust-content"),
|
||||
);
|
||||
});
|
||||
|
||||
test("错误响应仍抛 ApiClientError,而不是契约错误", async () => {
|
||||
const client = new ApiClient({
|
||||
baseUrl: "http://api.test",
|
||||
fetcher: async () =>
|
||||
response(
|
||||
{ data: null, error: { code: "HTTP_500", message: "服务异常" }, requestId: "req-2" },
|
||||
500,
|
||||
),
|
||||
});
|
||||
await assert.rejects(
|
||||
() => client.listAdminTrustContent(),
|
||||
(error: unknown) => {
|
||||
assert.ok(error instanceof ApiClientError);
|
||||
assert.equal(error instanceof ApiClientContractError, false);
|
||||
return true;
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test("后台渲染异常上报提交白名单字段", async () => {
|
||||
const calls: Array<{ url: string; method?: string; body?: string }> = [];
|
||||
const client = new ApiClient({
|
||||
baseUrl: "http://api.test",
|
||||
token: "brand-token",
|
||||
fetcher: async (url, init) => {
|
||||
calls.push({ url, method: init?.method, body: init?.body });
|
||||
return response({ received: true, duplicate: false });
|
||||
},
|
||||
});
|
||||
const receipt = await client.reportAdminClientError({
|
||||
errorId: "admin-abc-123",
|
||||
message: "boom",
|
||||
route: "/admin/trust?tab=1",
|
||||
componentStack: "at TrustContentPage",
|
||||
});
|
||||
assert.deepEqual(receipt, { received: true, duplicate: false });
|
||||
assert.deepEqual(calls, [
|
||||
{
|
||||
url: "http://api.test/admin/client-errors",
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
errorId: "admin-abc-123",
|
||||
message: "boom",
|
||||
route: "/admin/trust?tab=1",
|
||||
componentStack: "at TrustContentPage",
|
||||
}),
|
||||
},
|
||||
]);
|
||||
});
|
||||
Generated
+53
-2
@@ -269,6 +269,9 @@ importers:
|
||||
'@personal-brand/types':
|
||||
specifier: workspace:*
|
||||
version: link:../types
|
||||
zod:
|
||||
specifier: ^3.25.0
|
||||
version: 3.25.76
|
||||
|
||||
packages/capability-booking: {}
|
||||
|
||||
@@ -2390,6 +2393,7 @@ packages:
|
||||
engines: {node: ^22.20 || ^24.12 || >=25}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@napi-rs/triples@1.2.0':
|
||||
resolution: {integrity: sha512-HAPjR3bnCsdXBsATpDIP5WCrw0JcACwhhrwIAQhiR46n+jm+a2F8kBsfseAuWtSyQ+H3Yebt2k43B5dy+04yMA==}
|
||||
@@ -2488,36 +2492,42 @@ packages:
|
||||
engines: {node: '>= 10.0.0'}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@parcel/watcher-linux-arm-musl@2.6.0':
|
||||
resolution: {integrity: sha512-9c6AUHgHoG+IY88MRIHupztQiQnrbqHYQjkM2btA+Bf/wQnQMuiD0Wfk1EVv3TlNT3x41uU71rn6E4xh/+zvkw==}
|
||||
engines: {node: '>= 10.0.0'}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@parcel/watcher-linux-arm64-glibc@2.6.0':
|
||||
resolution: {integrity: sha512-yHRqS2owEXe6Hic9z6Mh1ECsCd+ODVOGvZDyciqRd21+v+o+DnXMOrw50DSpIG2sb8GPEaPPmfeCAWKPJdq46g==}
|
||||
engines: {node: '>= 10.0.0'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@parcel/watcher-linux-arm64-musl@2.6.0':
|
||||
resolution: {integrity: sha512-WhB2e/V7rqdHHWZusBSPuy5Ei8S6lSz6FE5TKKQz5h3a0O+C+mhY7vxU9b/stqvMb8beLnPY82ZrFTLKs+SrKA==}
|
||||
engines: {node: '>= 10.0.0'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@parcel/watcher-linux-x64-glibc@2.6.0':
|
||||
resolution: {integrity: sha512-ulGE6x6Oz6iAwg75T8YQSoguBWasniIbX+QWpaYPcCnDOpdWX3k+4xbEYPZVLxOuoJI+svJJPD3sEj8G7lrQ3A==}
|
||||
engines: {node: '>= 10.0.0'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@parcel/watcher-linux-x64-musl@2.6.0':
|
||||
resolution: {integrity: sha512-tkBYKt7YQrjIJWYDnto2YgO8MRkjlMTSNoRHzsXinBqbLdeOM3L32wPZJvIZxqaLMfSlS/4sUjH/6STVP/XDLw==}
|
||||
engines: {node: '>= 10.0.0'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@parcel/watcher-win32-arm64@2.6.0':
|
||||
resolution: {integrity: sha512-gIZAP23jaHjGWasY/TY6yL7NHFClf0Ga7FN+iINvk+KN94rhm94lYZhFsbYFNcA04/onvGD9kKmiJLJB2HbNwQ==}
|
||||
@@ -2928,36 +2938,42 @@ packages:
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rolldown/binding-linux-arm64-musl@1.2.9':
|
||||
resolution: {integrity: sha512-11vWvo8YDwLzukt27J3aYDWU+gg2P7J+ZOmiJ0hkF5BXZDW7pVya7r40MXDy6ya0i9KamoENSVKIugvJNgFXIA==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rolldown/binding-linux-ppc64-gnu@1.2.9':
|
||||
resolution: {integrity: sha512-a1tijMkdwsIARtc0F39ApURROkf3NwqinI6TOiSSWCTR7dT96dffNvMUtDHnq64wKNTIZOIlzKrFvvFUznJiyw==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rolldown/binding-linux-s390x-gnu@1.2.9':
|
||||
resolution: {integrity: sha512-x6SQNdAvv4c3hWqTMaWuawzMX9myaCs/yEmlGsxJzkdClnHW7FbrjQuSiRDhuSYzEYoEMhsaJy9qHG/XNemJPQ==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rolldown/binding-linux-x64-gnu@1.2.9':
|
||||
resolution: {integrity: sha512-9s0AZ8BFK5/n7B/TBoa2yJE3gI3KURrbXcPBlsAsvjU4VeJKgE90y1YtNxyEUIcHPQkg6/yfF3qihUrcM/Kf0Q==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rolldown/binding-linux-x64-musl@1.2.9':
|
||||
resolution: {integrity: sha512-P7VWAmV+WdJluH7ovnRGoiv2i8To7GAZ+kGzfGup635cyL7SyYl3lSUaA3Gp5THf0n/Co5EyEqb2zbqq+nMOHQ==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rolldown/binding-openharmony-arm64@1.2.9':
|
||||
resolution: {integrity: sha512-1qixtsE4BK8h+yS3BfmZ09UhA7O/N4IACva6YBr7EBvCJraByTuRcgOTaiA62Tm0vey3UcKXLOaoGHtYmNGEVg==}
|
||||
@@ -3057,66 +3073,79 @@ packages:
|
||||
resolution: {integrity: sha512-b50NS9TbAEK/b16vBoKrkeNwy+HvGBXmtBbzX4wcodWOh9dQZvRTN9rUyElIXa36QnwXhU9PAVVkZpqRzSi2Tg==}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-arm-musleabihf@4.64.9':
|
||||
resolution: {integrity: sha512-SdqcudB/FzjLESsRMgXhV+FXGtf6usxXwlMoRW7D/XS3f9CZ4T4wycRBu2h9bVl2AOaPpunoA8ftAM/MF4altQ==}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-linux-arm64-gnu@4.64.9':
|
||||
resolution: {integrity: sha512-dg19FFRoovN+KZ+gMHBAq4Do8PgQmBcxpuhux57OuiR0QLavfn8uPBY8CP+UO50bO+xf0tK0GlqI/jld++5E6g==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-arm64-musl@4.64.9':
|
||||
resolution: {integrity: sha512-+jyv5ofGmpAvtrzLjSr/e4syskeikEp5L82bUzB76auwOgK1VNVwZV/F2g1Pes9bhTznbejOefAqPglHSKYmTA==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-linux-loong64-gnu@4.64.9':
|
||||
resolution: {integrity: sha512-MKFXxqmkzCbtNvx/vjiJdss44eRtVabhCtDWcCFD9NHGwP+YkqnM/slnEsv/3fsoq9ukTtudraAjGhptrUPCVg==}
|
||||
cpu: [loong64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-loong64-musl@4.64.9':
|
||||
resolution: {integrity: sha512-lhARcOT6n7Ni9hpQRq8LZjbuoW+G/GXaW4Jfhx2MbmjnCj9XxLMRTceJIMpiMLQVWm+qxe7oq1sYvlIGOAW34Q==}
|
||||
cpu: [loong64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-linux-ppc64-gnu@4.64.9':
|
||||
resolution: {integrity: sha512-oORQzGxZ1oHghJwLdwc8Ni0SY9otILAeXsWdiImTF4F5HkWJUwh5s/269PF5tYILNC1z/3RwFsrgcHPguBcb0g==}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-ppc64-musl@4.64.9':
|
||||
resolution: {integrity: sha512-J2JQHQt7oR1uutd2OSwbV2Qpb2LI5gggPolbkUwDe7vn/0dnduZ0w6EIbGnZUAw7uIKaMgfVylcH6V+Aov8kRA==}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-linux-riscv64-gnu@4.64.9':
|
||||
resolution: {integrity: sha512-bWaKLrfzeQ9mOzJJxXbPgw2RH6VAaTJrb/60Tqf7YSMxubG8780Hzm7Us+D6qVW8QRGJYl4VUvVXxnRB0o9zvQ==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-riscv64-musl@4.64.9':
|
||||
resolution: {integrity: sha512-TFJyaCB9NsvSyvVGQgTSRD9XgxsAq99ivDDkt9KAySlrNW5Obsd1kQpvoCvBCOLq+JlJTjmtroLH0wp8M8mEsA==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-linux-s390x-gnu@4.64.9':
|
||||
resolution: {integrity: sha512-DvmOM5xz/wDnUJFVjqP32ahalxn7BDuvO25bpuFOrb50AIFCCcFPN4lWWUDD1c8Ddv9sMO9SXyqtOet8G8u9cQ==}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-x64-gnu@4.64.9':
|
||||
resolution: {integrity: sha512-aFzokHK3yE00mzAvKm/PY76OsOOTjvoTGE82Vp89iBDyD2wUBlV4ZsR2tWkRECTEFk6TC4Yc3zaEWjPqq1vstQ==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-x64-musl@4.64.9':
|
||||
resolution: {integrity: sha512-t/yMdeaaQUuNNpmT7taBmH2VvHzgT4YA/IaKVE3qVr4PYQemn/kmJkL4uG4UvTLcWXQd0MSoOa/3URYSWGmUEg==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-openbsd-x64@4.64.9':
|
||||
resolution: {integrity: sha512-4dnxKQ8GHARyjqAU87q5UWhywZTpIbR2VWhtACdC37GD1SGszmvb3TaBFVA4n+fnDHSKMut4ZJ63hVFwgnxVtg==}
|
||||
@@ -3238,48 +3267,56 @@ packages:
|
||||
engines: {node: '>=10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@swc/core-linux-arm64-gnu@1.4.14':
|
||||
resolution: {integrity: sha512-3Lqlhlmy8MVRS9xTShMaPAp0oyUt0KFhDs4ixJsjdxKecE0NJSV/MInuDmrkij1C8/RQ2wySRlV9np5jK86oWw==}
|
||||
engines: {node: '>=10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@swc/core-linux-arm64-musl@1.3.96':
|
||||
resolution: {integrity: sha512-i5/UTUwmJLri7zhtF6SAo/4QDQJDH2fhYJaBIUhrICmIkRO/ltURmpejqxsM/ye9Jqv5zG7VszMC0v/GYn/7BQ==}
|
||||
engines: {node: '>=10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@swc/core-linux-arm64-musl@1.4.14':
|
||||
resolution: {integrity: sha512-n0YoCa64TUcJrbcXIHIHDWQjdUPdaXeMHNEu7yyBtOpm01oMGTKP3frsUXIABLBmAVWtKvqit4/W1KVKn5gJzg==}
|
||||
engines: {node: '>=10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@swc/core-linux-x64-gnu@1.3.96':
|
||||
resolution: {integrity: sha512-USdaZu8lTIkm4Yf9cogct/j5eqtdZqTgcTib4I+NloUW0E/hySou3eSyp3V2UAA1qyuC72ld1otXuyKBna0YKQ==}
|
||||
engines: {node: '>=10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@swc/core-linux-x64-gnu@1.4.14':
|
||||
resolution: {integrity: sha512-CGmlwLWbfG1dB4jZBJnp2IWlK5xBMNLjN7AR5kKA3sEpionoccEnChOEvfux1UdVJQjLRKuHNV9yGyqGBTpxfQ==}
|
||||
engines: {node: '>=10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@swc/core-linux-x64-musl@1.3.96':
|
||||
resolution: {integrity: sha512-QYErutd+G2SNaCinUVobfL7jWWjGTI0QEoQ6hqTp7PxCJS/dmKmj3C5ZkvxRYcq7XcZt7ovrYCTwPTHzt6lZBg==}
|
||||
engines: {node: '>=10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@swc/core-linux-x64-musl@1.4.14':
|
||||
resolution: {integrity: sha512-xq4npk8YKYmNwmr8fbvF2KP3kUVdZYfXZMQnW425gP3/sn+yFQO8Nd0bGH40vOVQn41kEesSe0Z5O/JDor2TgQ==}
|
||||
engines: {node: '>=10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@swc/core-win32-arm64-msvc@1.3.96':
|
||||
resolution: {integrity: sha512-hjGvvAduA3Un2cZ9iNP4xvTXOO4jL3G9iakhFsgVhpkU73SGmK7+LN8ZVBEu4oq2SUcHO6caWvnZ881cxGuSpg==}
|
||||
@@ -3388,12 +3425,14 @@ packages:
|
||||
engines: {node: '>= 18'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@tarojs/binding-linux-x64-gnu@4.3.0':
|
||||
resolution: {integrity: sha512-PQlXyN9yicwxbE4v6hSo61qlmb1oUgZ17fIvIu8XniaV+GYRFj8zenDAW/gfPtHfQiYXn9oHP4clbYLuMWNG0A==}
|
||||
engines: {node: '>= 18'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@tarojs/binding-win32-x64-msvc@4.3.0':
|
||||
resolution: {integrity: sha512-CPDZu5YHp8qbcCqwLJHx4XOVzrQHSsFASiQ3Lyn+etu87pPIdgZLlR7DvOoPg6iWZOnR0qAFomnWpRncrsJeuA==}
|
||||
@@ -3471,24 +3510,28 @@ packages:
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@tarojs/parse-css-to-stylesheet-linux-arm64-musl@0.0.69':
|
||||
resolution: {integrity: sha512-bYODGCEx1Ni4EMNuZU95IUPqVZAXsY9gIc5CPSfKQ2j167Vbeo/gskQk/uNVjmnYJ69PplgJ9npylINgLIPIrA==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@tarojs/parse-css-to-stylesheet-linux-x64-gnu@0.0.69':
|
||||
resolution: {integrity: sha512-89f03s+txGJ1c8Zc6Ib4qTAP4YhfFbVFq29XExqbC7eGvpQl5DeOtwonO5DBwMc7lA+LG4b1Q4CMXE3qodn2eA==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@tarojs/parse-css-to-stylesheet-linux-x64-musl@0.0.69':
|
||||
resolution: {integrity: sha512-vyewIf1KysXYNIJdkzc9JSPguTG9zD65Belk3H186mLR18KtsvrqNqlWnP8kKfduF4ixh6qt0F2PkKbeI9PZvg==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@tarojs/parse-css-to-stylesheet-win32-x64-msvc@0.0.69':
|
||||
resolution: {integrity: sha512-CHKlVjAiSAZTFNV8GkfXV88Jy9yyFSvKBAO3++l2KSQUBUWmPX775FbH+god2BOLf5SfAXRPd0HVAEK9qNeHXQ==}
|
||||
@@ -3528,24 +3571,28 @@ packages:
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@tarojs/plugin-doctor-linux-arm64-musl@0.0.13':
|
||||
resolution: {integrity: sha512-V1HnFITOLgHVyQ+OCa1oPFKOtGFRtP91vlbUGfOwMA4GeOVw9g28W/hfTyucTCkfZWlrssLehgW6L2AGAMXh2w==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@tarojs/plugin-doctor-linux-x64-gnu@0.0.13':
|
||||
resolution: {integrity: sha512-oetfzBW60uenPBBF4/NE6Mf0Iwkw1YGqIIBiN++aVQynbWrmMzWBsW8kleZ5vN1npxI9aud9EfRU1uM37DrG2A==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@tarojs/plugin-doctor-linux-x64-musl@0.0.13':
|
||||
resolution: {integrity: sha512-OdIF/kFwwM0kQPDnpkanhvfWRaAI6EtDmpM9rQA/Lu2QcJq86w5d7X/WSN0U2xF1nialAUrfl79NyIaEzp4Fcw==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@tarojs/plugin-doctor-win32-ia32-msvc@0.0.13':
|
||||
resolution: {integrity: sha512-nIbG2SliRhRwACLa1kNMskcfjsihp+3tZQMAxl+LoYUq6JRaWgP3vH2nHkDyZHTCheBTDtAaupqXWrYF3w+U6g==}
|
||||
@@ -5544,11 +5591,11 @@ packages:
|
||||
|
||||
glob@7.1.2:
|
||||
resolution: {integrity: sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==}
|
||||
deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
|
||||
deprecated: Glob versions prior to v9 are no longer supported
|
||||
|
||||
glob@7.2.3:
|
||||
resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==}
|
||||
deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
|
||||
deprecated: Glob versions prior to v9 are no longer supported
|
||||
|
||||
global-modules@2.0.0:
|
||||
resolution: {integrity: sha512-NGbfmJBp9x8IxyJSd1P+otYK8vonoJactOogrVfFRIAEY1ukil8RSKDz2Yo7wh1oihl51l/r6W4epkeKJHqL8A==}
|
||||
@@ -6150,24 +6197,28 @@ packages:
|
||||
engines: {node: '>= 12.0.0'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
lightningcss-linux-arm64-musl@1.33.0:
|
||||
resolution: {integrity: sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==}
|
||||
engines: {node: '>= 12.0.0'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
lightningcss-linux-x64-gnu@1.33.0:
|
||||
resolution: {integrity: sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==}
|
||||
engines: {node: '>= 12.0.0'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
lightningcss-linux-x64-musl@1.33.0:
|
||||
resolution: {integrity: sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==}
|
||||
engines: {node: '>= 12.0.0'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
lightningcss-win32-arm64-msvc@1.33.0:
|
||||
resolution: {integrity: sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==}
|
||||
|
||||
Reference in new issue
Block a user