KO
베타 번역

@core / cart

1.1.0 ▾
인증됨MIT
GitHub

장바구니: 서명된 게스트 쿠키, 로그인 시 병합, 서버 측 가격, 확장 가능한 합계 계산

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

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

src/lib/cart/schema.ts읽기 전용 · 787ea88
// Tablas de @core/cart. Las recoge drizzle-kit vía src/lib/db/drizzle.config.ts.
import { index, integer, jsonb, pgTable, primaryKey, text, timestamp } from 'drizzle-orm/pg-core';
import { users } from '../auth/index.ts';
import { productVariants } from '../catalog/index.ts';
import { primaryId, timestamps } from '../db/index.ts';

export const carts = pgTable(
  'carts',
  {
    id: primaryId('crt'),
    userId: text('user_id').references(() => users.id, { onDelete: 'cascade' }),
    currency: text('currency').notNull(),
    /** Códigos introducidos por el cliente (los valida @core/discounts al calcular). */
    discountCodes: jsonb('discount_codes').$type<string[]>().notNull().default([]),
    /** Datos que eligen otros pasos (tarifa de envío, país…). */
    meta: jsonb('meta').$type<Record<string, string>>().notNull().default({}),
    expiresAt: timestamp('expires_at', { withTimezone: true, mode: 'date' }).notNull(),
    ...timestamps,
  },
  (t) => [index('carts_user_idx').on(t.userId), index('carts_expires_idx').on(t.expiresAt)],
);

export const cartLines = pgTable(
  'cart_lines',
  {
    cartId: text('cart_id')
      .notNull()
      .references(() => carts.id, { onDelete: 'cascade' }),
    variantId: text('variant_id')
      .notNull()
      .references(() => productVariants.id, { onDelete: 'cascade' }),
    quantity: integer('quantity').notNull(),
    ...timestamps,
  },
  (t) => [primaryKey({ columns: [t.cartId, t.variantId] })],
);

export type Cart = typeof carts.$inferSelect;

@core/cart 신고

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