Reseñas de producto sobre @core/comments: compra verificada, fotos, importadas etiquetadas, valoraciones y solicitud por email
Instalar
genpm add @core/reviewsQué obtienes
- Código en src/lib/reviews/, 5 archivos. (14 kB)
- Reglas de IA en src/lib/reviews/AGENTS.md, más archivos de reglas para tu IDE.
- Variables añadidas a .env.example: REVIEW_REQUEST_DELAY_DAYS.
- Resuelve @core/auth, @core/catalog, @core/comments, @core/db, @core/email, @core/jobs, @core/orders por ti.
README
Este paquete no tiene README.
Esto es exactamente lo que lee tu IA cuando trabaja en src/lib/reviews. No se añade nada más a su contexto.
@core/reviews — rules for AI agents
Purpose
Product reviews built on @core/comments (no duplicate comment system): a review is a comment on product/<id> with a
1–5 rating, plus review_meta (verified purchase, photos from @core/media, source) and review_stats per product.
"Verified" means the signed-in author has a paid and shipped order with that product (by user id or their account's
verified email); guest reviews are never verified, so the response never reveals whether an email bought. Imported reviews are always labeled with
their source and never verified. Asks customers for a review N days after delivery.
Map
index.ts— public API:postReview,listReviews,productRating,moderateReview,importReviews,verifiedOrder.reviews.ts— logic, stats and thereviews.requestjob (scheduled from the orderdeliveredevent on import).
Integration
- Requires @core/comments (moderation, anti-spam) and @core/orders. Env: optional
REVIEW_REQUEST_DELAY_DAYS(default 7,-1disables),SITE_URL,EMAIL_FROM. - Migrations as in
src/lib/db/AGENTS.md; import this module at startup. - Product page:
productRating(id)for stars and JSON-LD (jsonLd.product({ rating })from @core/seo),listReviews(id, { page, rating, sort })for the list; show a "Verified purchase" badge and, for imported ones, "Imported from <source>". - Review form →
postReview({ productId, rating, body, user | guest, photos }, { headers, fields })with @core/antispam fields. - Moderate in the comments admin (filter
entityType=product) and callmoderateReviewso stats update. - Verify: a buyer's review shows as verified after approval and the product rating changes.
Conventions
- Explain on the page how reviews are checked (EU Omnibus Directive): verified = confirmed order.
- Show all approved reviews, including negative ones; sort options must not hide them by default.
Don't
- Don't write, generate or buy fake reviews, and don't mark imported reviews as verified.
- Don't put
aggregateRatingin JSON-LD when there are no approved reviews. - Don't offer rewards conditioned on a positive review.
# @core/reviews — rules for AI agents
## Purpose
Product reviews built on @core/comments (no duplicate comment system): a review is a comment on `product/<id>` with a
1–5 rating, plus `review_meta` (verified purchase, photos from @core/media, source) and `review_stats` per product.
"Verified" means the signed-in author has a paid and shipped order with that product (by user id or their account's
verified email); guest reviews are never verified, so the response never reveals whether an email bought. Imported reviews are always labeled with
their source and never verified. Asks customers for a review N days after delivery.
## Map
- `index.ts` — public API: `postReview`, `listReviews`, `productRating`, `moderateReview`, `importReviews`, `verifiedOrder`.
- `reviews.ts` — logic, stats and the `reviews.request` job (scheduled from the order `delivered` event on import).
## Integration
1. Requires @core/comments (moderation, anti-spam) and @core/orders. Env: optional `REVIEW_REQUEST_DELAY_DAYS` (default 7, `-1` disables), `SITE_URL`, `EMAIL_FROM`.
2. Migrations as in `src/lib/db/AGENTS.md`; import this module at startup.
3. Product page: `productRating(id)` for stars and JSON-LD (`jsonLd.product({ rating })` from @core/seo), `listReviews(id, { page, rating, sort })`
for the list; show a "Verified purchase" badge and, for imported ones, "Imported from <source>".
4. Review form → `postReview({ productId, rating, body, user | guest, photos }, { headers, fields })` with @core/antispam fields.
5. Moderate in the comments admin (filter `entityType=product`) and call `moderateReview` so stats update.
6. Verify: a buyer's review shows as verified after approval and the product rating changes.
## Conventions
- Explain on the page how reviews are checked (EU Omnibus Directive): verified = confirmed order.
- Show all approved reviews, including negative ones; sort options must not hide them by default.
## Don't
- Don't write, generate or buy fake reviews, and don't mark imported reviews as verified.
- Don't put `aggregateRating` in JSON-LD when there are no approved reviews.
- Don't offer rewards conditioned on a positive review.
El árbol exacto que se inyectará, tras aplicar .genpmignore. Anclado a
// Tablas de @core/reviews. Las reseñas son comentarios (@core/comments) con valoración; aquí solo sus datos extra.
import { boolean, integer, jsonb, pgTable, text } from 'drizzle-orm/pg-core';
import { comments } from '../comments/index.ts';
import { timestamps } from '../db/index.ts';
export const reviewMeta = pgTable('review_meta', {
commentId: text('comment_id')
.primaryKey()
.references(() => comments.id, { onDelete: 'cascade' }),
productId: text('product_id').notNull(),
/** Compra comprobada: el autor tiene un pedido pagado y enviado con este producto. */
verified: boolean('verified').notNull().default(false),
orderId: text('order_id'),
/** `site` o el origen de una reseña importada (`aliexpress`, `trustpilot`…), que se muestra siempre. */
source: text('source').notNull().default('site'),
photos: jsonb('photos').$type<string[]>().notNull().default([]),
...timestamps,
});
/** Agregado por producto (se recalcula al publicar o moderar). `average` × 100. */
export const reviewStats = pgTable('review_stats', {
productId: text('product_id').primaryKey(),
count: integer('count').notNull().default(0),
average: integer('average').notNull().default(0),
histogram: jsonb('histogram').$type<[number, number, number, number, number]>().notNull().default([0, 0, 0, 0, 0]),
...timestamps,
});
Este paquete no declara servidores MCP.
| Versión | Commit | Publicado | Escaneo |
|---|---|---|---|
| 1.0.1 | 9c40b7a | hace 4 horas | escaneo superado |
- genpm
- @core/auth ^1.1.0@core/catalog ^1.0.0@core/comments ^1.0.0@core/db ^1.0.0@core/email ^1.0.1@core/jobs ^1.0.0@core/orders ^1.0.0
- npm
- zod ^4.0.0
- propuesta
- GenPM propone el comando npm y solo lo ejecuta si dices que sí.
- Usado por (1)
- @core/kit-store ^1.0.0
- escaneo
- escaneo superado · 0 hallazgos
- commit
- v1.0.1 → 9c40b7a86c884d5c4711aee662c9b7d674cdbab4 · 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?