Shared types for GenPM modules: content, sitemap, search, admin resources, payments and tracked events
Install
genpm add @core/contractsWhat you get
- Source in src/lib/contracts/, 10 files. (13.3 kB)
- AI rules in src/lib/contracts/AGENTS.md, plus IDE rule files.
README
This package has no README.
This is exactly what your AI reads when it works in src/lib/contracts. Nothing else is added to its context.
@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.
The exact tree that will be injected, after .genpmignore. Pinned to
// Fuente de documentos para el buscador del sitio: la implementan content, blog, catalog…; la consume @core/search.
export type SearchDocument = {
/** Único dentro de `type`. */
id: string;
/** Tipo de resultado: `page`, `post`, `product`. */
type: string;
url: string;
title: string;
/** Texto plano (sin HTML ni Markdown). */
body: string;
locale?: string;
updatedAt?: Date;
};
export type SearchChange = { op: 'upsert'; doc: SearchDocument } | { op: 'delete'; type: string; id: string };
export type SearchSource = {
type: string;
/** Todos los documentos publicados (reindexado completo). */
documents(): AsyncIterable<SearchDocument>;
/** Avisos incrementales (publicar, despublicar). Devuelve la función para darse de baja. */
subscribe?(listener: (change: SearchChange) => void | Promise<void>): () => void;
};
export const defineSearchSource = (source: SearchSource): SearchSource => source;
This package declares no MCP servers.
| Version | Commit | Published | Scan |
|---|---|---|---|
| 1.0.0 | 7266529 | 3 hours ago | scan passed |
- genpm
- none
- npm
- zod ^4.0.0
- proposed
- GenPM proposes the npm command and runs it only if you say yes.
- Used by (16)
- @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/rbac ^1.0.0@core/shipping ^1.0.0
- scan
- scan passed · 0 findings
- commit
- v1.0.0 → 7266529e19beb49b518121150977d7b712cb7e5f · verified after fetch
- scripts
- None. GenPM never runs package code.
- license
- MIT
- Quality
- 100/100
- Recognized licensepassed
- AGENTS.md explains its purposepassed
- AGENTS.md has integration stepspassed
- AGENTS.md lists conventions or don'tspassed
- Includes testspassed
- Security scan passedpassed
- Released in the last 6 monthspassed
- Verified publisherpassed
- Summary and keywordspassed
- report
- See something wrong?