Tipos compartidos entre módulos GenPM: contenido, sitemap, búsqueda, recursos de admin, pagos y eventos
Instalar
genpm add @core/contractsQué obtienes
- Código en src/lib/contracts/, 10 archivos. (13,3 kB)
- Reglas de IA en src/lib/contracts/AGENTS.md, más archivos de reglas para tu IDE.
README
Este paquete no tiene README.
Esto es exactamente lo que lee tu IA cuando trabaja en src/lib/contracts. No se añade nada más a su contexto.
@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.
El árbol exacto que se inyectará, tras aplicar .genpmignore. Anclado a
// Fuente de URLs para sitemap.xml: la implementan content, blog, catalog…; la consume @core/seo.
export type SitemapUrl = {
/** Ruta absoluta del sitio (`/blog/hola`) o URL completa. */
loc: string;
lastmod?: Date;
/** Versiones en otros idiomas: locale BCP 47 → ruta o URL (genera `hreflang`). */
alternates?: Record<string, string>;
changefreq?: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
/** 0.0–1.0 */
priority?: number;
};
export type SitemapSource = {
/** Nombre único de la fuente (`pages`, `blog`, `products`); da nombre a su trozo del índice. */
name: string;
urls(): AsyncIterable<SitemapUrl>;
};
export const defineSitemapSource = (source: SitemapSource): SitemapSource => source;
Este paquete no declara servidores MCP.
| Versión | Commit | Publicado | Escaneo |
|---|---|---|---|
| 1.0.0 | 7266529 | hace 5 horas | escaneo superado |
- genpm
- ninguno
- npm
- zod ^4.0.0
- propuesta
- GenPM propone el comando npm y solo lo ejecuta si dices que sí.
- Usado por (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
- escaneo
- escaneo superado · 0 hallazgos
- commit
- v1.0.0 → 7266529e19beb49b518121150977d7b712cb7e5f · verificado tras la descarga
- scripts
- Ninguno. GenPM nunca ejecuta código del paquete.
- licencia
- MIT
- Calidad
- 100/100
- Licencia reconocidacumplido
- AGENTS.md explica su propósitocumplido
- AGENTS.md tiene pasos de integracióncumplido
- AGENTS.md lista convenciones o prohibicionescumplido
- Incluye testscumplido
- Escaneo de seguridad superadocumplido
- Publicado en los últimos 6 mesescumplido
- Publicador verificadocumplido
- Resumen y palabras clavecumplido
- reporte
- ¿Ves algo raro?