Files
imen_pishghaman/packages/shared/dist/catalog.js
T

66 lines
2.1 KiB
JavaScript

import { z } from "zod";
import { idSchema, req, slugSchema, text } from "./common.js";
const shortList = z.array(z.string().trim().min(1).max(120)).max(20).default([]);
export const productAttributeSchema = z.object({
name: req(80),
value: req(300),
});
export const productGroupInputSchema = z.object({
/** present when editing an existing group */
id: idSchema.optional(),
slug: slugSchema,
name: req(120),
desc: text(1000),
});
export const categoryInputSchema = z.object({
slug: slugSchema,
code: req(20),
name: req(120),
nameEn: text(120),
shortDesc: text(500),
fullDesc: text(3000),
icon: text(40),
coverImageId: idSchema.nullable().default(null),
isPublished: z.boolean().default(true),
seoTitle: text(120),
seoDescription: text(300),
groups: z.array(productGroupInputSchema).max(30).default([]),
});
export const productInputSchema = z.object({
categoryId: idSchema,
groupId: idSchema.nullable().default(null),
code: req(30),
slug: slugSchema,
name: req(160),
nameEn: text(160),
desc: text(2000),
specs: shortList,
variants: shortList,
details: text(8000),
brand: text(80),
origin: text(80),
sizes: shortList,
standards: shortList,
features: z.array(z.string().trim().min(1).max(300)).max(30).default([]),
applications: shortList,
attributes: z.array(productAttributeSchema).max(40).default([]),
packaging: text(200),
minOrder: text(120),
seoTitle: text(120),
seoDescription: text(300),
imageId: idSchema.nullable().default(null),
galleryIds: z.array(idSchema).max(12).default([]),
isPublished: z.boolean().default(true),
});
export const reorderSchema = z.object({
ids: z.array(idSchema).min(1).max(1000),
});
export const productListQuerySchema = z.object({
categoryId: idSchema.optional(),
groupId: idSchema.optional(),
q: z.string().trim().max(100).optional(),
status: z.enum(["published", "draft"]).optional(),
page: z.coerce.number().int().min(1).default(1),
pageSize: z.coerce.number().int().min(1).max(200).default(50),
});
//# sourceMappingURL=catalog.js.map