返回 CodeWhale
types.ts
根目录 / web / lib / merch / types.ts
1 import type { MerchProductId } from "./catalog";
2 export type Address = { name: string; line1: string; line2: string; city: string; region: string; postalCode: string; phone: string };
3 export type QuoteInput = { productId: MerchProductId; size: string; color: "White"; quantity: number; country: string; address: Address; contributor?: { github: string; contribution: string; language: string; phraseIndex: number } };
4 export type ProductRoute = { approved: boolean; designCode: string; contributorDesigns?: Record<string, string[]>; skuBySize: Record<string, string>; productionCostUsd: number };
5 export type CountryRoute = { regionCode: string; shippingLevelCode: string; currency: "cny" | "usd"; usdExchangeRate: number; feeRate: number; flatFeeUsd: number; taxReviewed: boolean; taxNote: string; supplierPricesUsdReviewed: boolean; addressPolicyReviewed: boolean; allowedPostalPrefixes: string[]; blockedPostalPrefixes?: string[] };
6 export type MerchConfig = { mode: "test" | "live"; checkoutEnabled: boolean; supplierSubmissionEnabled?: boolean; siteOrigin: string; countries: Record<string, CountryRoute>; products: Partial<Record<MerchProductId, Record<string, ProductRoute>>> };
7 export type Quote = { quoteId: string; mode: "test" | "live"; routeApproval: string; expiresAt: number; currency: "cny" | "usd"; merchandise: number; shipping: number; processing: number; total: number; shippingName: string; taxNote: string; input: QuoteInput; skuCode: string; designCode: string; shippingLevelCode: string; vendorProductionUsd: number; vendorShippingUsd: number };
8 export interface D1Statement { bind(...values: unknown[]): D1Statement; first<T>(): Promise<T | null>; all<T>(): Promise<{ results: T[] }>; run(): Promise<{ meta: { changes: number } }>; }
9 export interface MerchDatabase { prepare(sql: string): D1Statement; batch(statements: D1Statement[]): Promise<unknown[]>; }
10 export interface MerchEnv { MERCH_DB?: MerchDatabase; MERCH_RATE_LIMITER?: { limit(value: { key: string }): Promise<{ success: boolean }> }; MERCH_CONFIG_JSON?: string; MERCH_STRIPE_KEY?: string; MERCH_STRIPE_WEBHOOK_SECRET?: string; MERCH_PAYMENT_CONFIGURATION?: string; YOYCOL_ACCESS_KEY?: string; YOYCOL_SECRET_KEY?: string; }
11
11 lines TYPESCRIPT