1.0.0 → 1.0.1
3 Dateien geändert · +59 −1 · 4e8e68d…1019e5f
Um diese Änderungen zu übernehmen und deine Anpassungen zu behalten, führe in deinem Projekt aus: genpm diff @core/shipping --to 1.0.1
src/lib/shipping/.genpmignore geändert +2 −0
@@ -2,3 +2,5 @@ *.test.ts *.test.tsx __fixtures__/ +# Documentación del repositorio (GitHub), no forma parte del módulo inyectado. +README.md
src/lib/shipping/README.md hinzugefügt +56 −0
@@ -0,0 +1,56 @@ +# @core/shipping + +[](https://genpm.net/p/@core/shipping)  + +> Shipping zones and rates (flat, weight, order value, free over X) with delivery estimates and tracking URLs + +A [GenPM](https://genpm.net) module: **source code + AI rules + MCP config**, injected into your project instead of hidden in `node_modules`. The code lands in `src/lib/shipping`, pinned to a verified commit, and you own it. + +## Install + +```bash +genpm add @core/shipping +``` + +No genpm yet? `curl -fsSL https://genpm.net/install.sh | sh` (macOS/Linux), `irm https://genpm.net/install.ps1 | iex` (Windows), or one-off with `npx @genpm-net/cli add @core/shipping`. + +Or let your AI agent do it: run `genpm mcp setup` once, then ask *"add @core/shipping with genpm"* in Claude Code, Cursor, VS Code, Windsurf, Codex or Gemini CLI. It shows you a dry-run plan before writing anything. + +## What it does + +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`. + +## Setup + +After `genpm add`, follow these steps (your AI agent finds the same steps in `src/lib/shipping/AGENTS.md` and can do them for you): + +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. + +## What's inside + +Paths are relative to `src/lib/shipping`. + +- `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. + +## At a glance + +- **GenPM dependencies** (installed with it): [@core/db](https://genpm.net/p/@core/db), [@core/cart](https://genpm.net/p/@core/cart), [@core/money](https://genpm.net/p/@core/money), [@core/contracts](https://genpm.net/p/@core/contracts) +- **npm dependencies** (proposed, never installed without asking): `zod` +- **AI rules**: [`AGENTS.md`](AGENTS.md), loaded by your agent only when it works in `src/lib/shipping` + +## Security + +GenPM installs a 40-character commit SHA (never a branch), verifies an Ed25519-signed manifest, never runs install scripts and scans AI rules for prompt injection. Details: [genpm.net/docs/security](https://genpm.net/docs/security). + +## License + +MIT — see [LICENSE](LICENSE). Browse the full catalog at [genpm.net](https://genpm.net).
src/lib/shipping/genpm.json geändert +1 −1
@@ -1,7 +1,7 @@ { "$": 1, "n": "@core/shipping", - "v": "1.0.0", + "v": "1.0.1", "s": { "en": "Shipping zones and rates (flat, weight, order value, free over X) with delivery estimates and tracking URLs", "es": "Zonas y tarifas de envío (fija, por peso, por importe, gratis desde X) con plazos estimados y URLs de seguimiento",