GenPM 模块共享类型:内容、站点地图、搜索、后台资源、支付和追踪事件
代码10 个文件上下文约 532 个 token扫描通过
安装
$
genpm add @core/contracts你将获得
- 源代码位于 src/lib/contracts/,共 10 个文件。 (13.3 kB)
- AI 规则位于 src/lib/contracts/AGENTS.md,另附 IDE 规则文件。
README
此包没有 README。
约 532 个 token→ src/lib/contracts/AGENTS.md→ .cursor/rules/genpm-core-contracts.mdc
这正是你的 AI 在 src/lib/contracts 中工作时读取的内容。不会向其上下文添加其他任何内容。
@core/contracts — rules for AI agents
Purpose
Types and small zod schemas shared by GenPM catalog modules, so a module can consume "anything that provides content /
sitemap URLs / search documents / admin resources / payments" without importing the concrete module. No logic, no
tables, no runtime dependency besides zod.
Map
index.ts— public API. Import from here only.content.ts—ContentSource,ContentEntry(implemented by @core/content and CMS adapters).sitemap.ts—SitemapSource(consumed by @core/seo).search.ts—SearchSource,SearchDocument(consumed by @core/search).admin.ts—AdminResource,AdminField(consumed by @core/admin).payment.ts—PaymentProvider(implemented by @core/checkout, used by @core/orders).events.ts—CommerceEvent,LeadEventand their zod schemas (consumed by @core/pixels).money.ts—Money(integer minor units + ISO 4217 code).
Integration
- Usually installed as a dependency of another module; nothing to wire.
- To expose your own data to the admin, sitemap or search, implement the type and register it in the project file
the consuming module documents (
src/genpm/admin.ts,src/genpm/seo.ts,src/genpm/search.ts):import { defineSitemapSource } from './lib/contracts/index.ts'; export const projects = defineSitemapSource({ name: 'projects', async *urls() { yield { loc: '/projects' }; } }); - Validate untrusted tracking payloads with
TrackedEventSchema.parse(body)before forwarding them.
Conventions
- Money is always
{ amount: integer minor units, currency: 'EUR' }; never floats. - Sources are async iterables: stream rows in pages, don't load whole tables into memory.
AdminResource.inputvalidates create/update input; permissions are<resource>:<action>(posts:update).
Don't
- Don't add implementations or helpers with behaviour here; put them in the module that owns the concept.
- Don't change an existing type incompatibly: every catalog module depends on it (major version of the whole train).
- Don't import other modules from this folder.
# @core/contracts — rules for AI agents
## Purpose
Types and small zod schemas shared by GenPM catalog modules, so a module can consume "anything that provides content /
sitemap URLs / search documents / admin resources / payments" without importing the concrete module. No logic, no
tables, no runtime dependency besides `zod`.
## Map
- `index.ts` — public API. Import from here only.
- `content.ts` — `ContentSource`, `ContentEntry` (implemented by @core/content and CMS adapters).
- `sitemap.ts` — `SitemapSource` (consumed by @core/seo).
- `search.ts` — `SearchSource`, `SearchDocument` (consumed by @core/search).
- `admin.ts` — `AdminResource`, `AdminField` (consumed by @core/admin).
- `payment.ts` — `PaymentProvider` (implemented by @core/checkout, used by @core/orders).
- `events.ts` — `CommerceEvent`, `LeadEvent` and their zod schemas (consumed by @core/pixels).
- `money.ts` — `Money` (integer minor units + ISO 4217 code).
## Integration
1. Usually installed as a dependency of another module; nothing to wire.
2. To expose your own data to the admin, sitemap or search, implement the type and register it in the project file
the consuming module documents (`src/genpm/admin.ts`, `src/genpm/seo.ts`, `src/genpm/search.ts`):
```ts
import { defineSitemapSource } from './lib/contracts/index.ts';
export const projects = defineSitemapSource({ name: 'projects', async *urls() { yield { loc: '/projects' }; } });
```
3. Validate untrusted tracking payloads with `TrackedEventSchema.parse(body)` before forwarding them.
## Conventions
- Money is always `{ amount: integer minor units, currency: 'EUR' }`; never floats.
- Sources are async iterables: stream rows in pages, don't load whole tables into memory.
- `AdminResource.input` validates create/update input; permissions are `<resource>:<action>` (`posts:update`).
## Don't
- Don't add implementations or helpers with behaviour here; put them in the module that owns the concept.
- Don't change an existing type incompatibly: every catalog module depends on it (major version of the whole train).
- Don't import other modules from this folder.
应用 .genpmignore 后将被注入的确切目录树。固定于
// Pasarela de pago vista desde los pedidos: la implementa @core/checkout (Stripe); la consume @core/orders para
// reembolsos sin depender de Stripe.
import type { Money } from './money.ts';
export type PaymentStatus = 'pending' | 'succeeded' | 'failed' | 'refunded' | 'partially_refunded';
export type PaymentProvider = {
/** `stripe`, `paypal`… Se guarda en el pedido junto a la referencia. */
name: string;
getPayment(paymentRef: string): Promise<{ status: PaymentStatus; amount: Money } | null>;
/** Reembolsa `amount` (≤ lo cobrado). Debe ser idempotente por `idempotencyKey`. */
refund(
paymentRef: string,
amount: Money,
opts: { idempotencyKey: string; reason?: string },
): Promise<{ refundRef: string }>;
};
此包未声明 MCP 服务器。
| 版本 | 提交 | 发布时间 | 扫描 |
|---|---|---|---|
| 1.0.0 | 7266529 | 5小时前 | 扫描通过 |
- genpm
- 无
- npm
- zod ^4.0.0
- 建议
- GenPM 会给出 npm 命令建议,只有你同意时才会运行。
- 被以下包使用(22)
- @core/admin ^1.0.0@core/blocks ^1.0.0@core/blog ^1.0.0@core/cart ^1.0.0@core/catalog ^1.0.0@core/comments ^1.0.0@core/content ^1.0.0@core/experiments ^1.0.0@core/forms ^1.0.0@core/invoices ^1.0.0@core/media ^1.0.0@core/money ^1.0.0@core/newsletter ^1.0.0@core/orders ^1.0.0@core/pixels ^1.0.0@core/pricing ^1.0.0@core/rbac ^1.0.0@core/search ^1.0.0@core/seo ^1.0.0@core/shipping ^1.0.0
- 扫描
- 扫描通过 · 0 个问题
- 提交
- v1.0.0 → 7266529e19beb49b518121150977d7b712cb7e5f · 获取后已校验
- 脚本
- 无。GenPM 从不运行包中的代码。
- 许可证
- MIT
- 质量
- 100/100
- 可识别的许可证已满足
- AGENTS.md 说明了用途已满足
- AGENTS.md 包含集成步骤已满足
- AGENTS.md 列出约定或禁止事项已满足
- 包含测试已满足
- 通过安全扫描已满足
- 最近 6 个月内发布已满足
- 已验证的发布者已满足
- 摘要和关键词已满足
- 举报
- 发现问题了吗?