配送区域与运费(固定、按重量、按金额、满额包邮),含预计送达时间和物流跟踪链接
代码6 个文件上下文约 445 个 token扫描通过
安装
$
genpm add @core/shipping你将获得
- 源代码位于 src/lib/shipping/,共 6 个文件。 (15 kB)
- AI 规则位于 src/lib/shipping/AGENTS.md,另附 IDE 规则文件。
- 自动为你解析 @core/cart, @core/contracts, @core/db, @core/money。
README
此包没有 README。
约 445 个 token→ src/lib/shipping/AGENTS.md→ .cursor/rules/genpm-core-shipping.mdc
这正是你的 AI 在 src/lib/shipping 中工作时读取的内容。不会向其上下文添加其他任何内容。
@core/shipping — rules for AI agents
Purpose
Shipping zones (ISO country lists, * = rest of world) and rates per zone: flat price, weight and order-value
ranges, free shipping over an amount (after discounts) and delivery estimates in days. Registers the shipping
step (order 200) of the @core/cart totals pipeline and builds tracking URLs for common carriers.
No label purchase or live carrier quotes. Tables: shipping_zones, shipping_rates.
Map
index.ts— public API:upsertZone,upsertRate,ratesFor,zoneFor,trackingUrl,CARRIERS,shippingAdminResources.shipping.ts— rules and the totals step.admin.ts— admin resources.schema.ts— tables.
Integration
- Migrations as in
src/lib/db/AGENTS.md. Import this module at startup (it registers the totals step). - Create zones and rates in the admin (
...shippingAdminResources()insrc/genpm/admin.ts, permissionsshipping:read|update). - At checkout, store the country and the chosen rate on the cart:
setCartMeta(cart.id, { country: 'ES', shippingRateId }); list options withratesFor(totals, country)and showminDays–maxDaysbefore payment. - Tracking:
trackingUrl(carrier, number)when marking an order shipped (@core/orders). - Verify: a cart with country
ESgets the cheapest Spanish rate; one over the free threshold pays 0.
Conventions
- Prices in minor units of
STORE_CURRENCY; weights in grams from catalog variants. - Digital-only carts never get shipping.
- Show
no_shippingissues clearly and block checkout for those countries.
Don't
- Don't hide delivery times or shipping costs until after payment (EU consumer law requires them upfront).
- Don't trust a rate id or amount sent by the browser; the totals step recomputes it.
# @core/shipping — rules for AI agents
## Purpose
Shipping zones (ISO country lists, `*` = rest of world) and rates per zone: flat price, weight and order-value
ranges, free shipping over an amount (after discounts) and delivery estimates in days. Registers the `shipping`
step (order 200) of the @core/cart totals pipeline and builds tracking URLs for common carriers.
No label purchase or live carrier quotes. Tables: `shipping_zones`, `shipping_rates`.
## Map
- `index.ts` — public API: `upsertZone`, `upsertRate`, `ratesFor`, `zoneFor`, `trackingUrl`, `CARRIERS`, `shippingAdminResources`.
- `shipping.ts` — rules and the totals step. `admin.ts` — admin resources. `schema.ts` — tables.
## Integration
1. Migrations as in `src/lib/db/AGENTS.md`. Import this module at startup (it registers the totals step).
2. Create zones and rates in the admin (`...shippingAdminResources()` in `src/genpm/admin.ts`, permissions `shipping:read|update`).
3. At checkout, store the country and the chosen rate on the cart: `setCartMeta(cart.id, { country: 'ES', shippingRateId })`;
list options with `ratesFor(totals, country)` and show `minDays–maxDays` before payment.
4. Tracking: `trackingUrl(carrier, number)` when marking an order shipped (@core/orders).
5. Verify: a cart with country `ES` gets the cheapest Spanish rate; one over the free threshold pays 0.
## Conventions
- Prices in minor units of `STORE_CURRENCY`; weights in grams from catalog variants.
- Digital-only carts never get shipping.
- Show `no_shipping` issues clearly and block checkout for those countries.
## Don't
- Don't hide delivery times or shipping costs until after payment (EU consumer law requires them upfront).
- Don't trust a rate id or amount sent by the browser; the totals step recomputes it.
应用 .genpmignore 后将被注入的确切目录树。固定于
// Tablas de @core/shipping. Las recoge drizzle-kit vía src/lib/db/drizzle.config.ts.
import { boolean, index, integer, jsonb, pgTable, text } from 'drizzle-orm/pg-core';
import { primaryId, timestamps } from '../db/index.ts';
export const shippingZones = pgTable('shipping_zones', {
id: primaryId('shz'),
name: text('name').notNull(),
/** Códigos ISO 3166-1 alpha-2; `*` = resto del mundo. */
countries: jsonb('countries').$type<string[]>().notNull(),
position: integer('position').notNull().default(0),
...timestamps,
});
export const shippingRates = pgTable(
'shipping_rates',
{
id: primaryId('shr'),
zoneId: text('zone_id')
.notNull()
.references(() => shippingZones.id, { onDelete: 'cascade' }),
name: text('name').notNull(),
/** Precio en unidades menores de la moneda de la tienda. */
amount: integer('amount').notNull(),
/** Gratis si el subtotal (tras descuentos) llega a este importe. */
freeOver: integer('free_over'),
/** Rango de aplicación por peso del carrito (gramos) y por subtotal. */
minWeightGrams: integer('min_weight_grams'),
maxWeightGrams: integer('max_weight_grams'),
minSubtotal: integer('min_subtotal'),
maxSubtotal: integer('max_subtotal'),
/** Plazo de entrega estimado (días laborables), visible antes de pagar. */
minDays: integer('min_days'),
maxDays: integer('max_days'),
active: boolean('active').notNull().default(true),
position: integer('position').notNull().default(0),
...timestamps,
},
(t) => [index('shipping_rates_zone_idx').on(t.zoneId)],
);
export type ShippingZone = typeof shippingZones.$inferSelect;
export type ShippingRate = typeof shippingRates.$inferSelect;
此包未声明 MCP 服务器。
| 版本 | 提交 | 发布时间 | 扫描 |
|---|---|---|---|
| 1.0.0 | 4e8e68d | 3小时前 | 扫描通过 |
- npm
- zod ^4.0.0
- 建议
- GenPM 会给出 npm 命令建议,只有你同意时才会运行。
- 扫描
- 扫描通过 · 0 个问题
- 提交
- v1.0.0 → 4e8e68d047c764a7a689d286d2e4119529ae11ee · 获取后已校验
- 脚本
- 无。GenPM 从不运行包中的代码。
- 许可证
- MIT
- 质量
- 100/100
- 可识别的许可证已满足
- AGENTS.md 说明了用途已满足
- AGENTS.md 包含集成步骤已满足
- AGENTS.md 列出约定或禁止事项已满足
- 包含测试已满足
- 通过安全扫描已满足
- 最近 6 个月内发布已满足
- 已验证的发布者已满足
- 摘要和关键词已满足
- 举报
- 发现问题了吗?