KO
베타 번역

@core / contracts

1.0.0 ▾
인증됨MIT
GitHub

GenPM 모듈 공용 타입: 콘텐츠, 사이트맵, 검색, 관리 리소스, 결제, 추적 이벤트

코드파일 10개컨텍스트약 532토큰검사 통과

.genpmignore 적용 후 주입될 정확한 트리입니다. 고정 대상:

src/lib/contracts/events.ts읽기 전용 · 7266529
// Eventos de negocio que se miden (píxeles, tests A/B). Mismo `eventId` en navegador y servidor = deduplicación.
import { z } from 'zod';
import { MoneySchema } from './money.ts';

const Item = z.strictObject({
  id: z.string().min(1).max(128),
  name: z.string().min(1).max(256),
  price: MoneySchema,
  quantity: z.number().int().positive(),
  variant: z.string().max(128).optional(),
  category: z.string().max(128).optional(),
});

const base = { eventId: z.string().min(8).max(64) };

export const CommerceEventSchema = z.discriminatedUnion('type', [
  z.strictObject({ ...base, type: z.literal('view_item'), items: z.array(Item).min(1), value: MoneySchema }),
  z.strictObject({ ...base, type: z.literal('add_to_cart'), items: z.array(Item).min(1), value: MoneySchema }),
  z.strictObject({ ...base, type: z.literal('begin_checkout'), items: z.array(Item).min(1), value: MoneySchema }),
  z.strictObject({
    ...base,
    type: z.literal('purchase'),
    orderId: z.string().min(1).max(128),
    items: z.array(Item).min(1),
    value: MoneySchema,
  }),
]);

export const LeadEventSchema = z.strictObject({
  ...base,
  type: z.literal('lead'),
  formKey: z.string().max(64).optional(),
  value: MoneySchema.optional(),
});

export const TrackedEventSchema = z.union([CommerceEventSchema, LeadEventSchema]);

export type CommerceItem = z.infer<typeof Item>;
export type CommerceEvent = z.infer<typeof CommerceEventSchema>;
export type LeadEvent = z.infer<typeof LeadEventSchema>;
export type TrackedEvent = z.infer<typeof TrackedEventSchema>;

@core/contracts 신고

패키지를 신고하려면 GitHub로 로그인하세요.