UNPKG

@hz-9/a5-crud-zod

Version:

Zod validation and CRUD utilities for the @hz-9/a5-* series of repositories.

37 lines 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CommonResDto = exports.CommonResDtoSchema = exports.ResDtoSchemaWrap = void 0; const nestjs_zod_1 = require("nestjs-zod"); const zod_1 = require("zod"); /** * @public * * 响应 DTO Schema 包装函数 * * 用于包装任意 Schema 成为标准响应格式 */ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type const ResDtoSchemaWrap = (schema) => zod_1.z.object({ code: zod_1.z.string().describe('"OK" or error code'), message: zod_1.z.string().describe('message'), traceId: zod_1.z.string().describe('Trace ID'), timestamp: zod_1.z.number().describe('Timestamp'), data: schema.describe('Data'), }); exports.ResDtoSchemaWrap = ResDtoSchemaWrap; /** * @public * * 通用响应 DTO Schema */ // eslint-disable-next-line @rushstack/typedef-var exports.CommonResDtoSchema = (0, exports.ResDtoSchemaWrap)(zod_1.z.any()); /** * @public * * 通用响应 DTO 类 */ class CommonResDto extends (0, nestjs_zod_1.createZodDto)(exports.CommonResDtoSchema) { } exports.CommonResDto = CommonResDto; //# sourceMappingURL=common.res.dto.js.map