Skip to content

Category Schemas

PIM Protocol includes category schemas that define structured attributes for different types of products. These schemas are aligned with Schema.org vocabulary.

How schemas work

A CategorySchema defines, for a given category:

  • a schemaOrgType (e.g. Car, Product, Book)
  • a list of attributes (AttributeField[]) — the structured fields for that category
  • conditionOptions and descriptive traits
  • a buildSchemaOrg() mapping to JSON-LD

A Ref stores its category-specific values in its attributes field (a free-form Record<string, unknown>); the matching CategorySchema describes which attributes that category expects. Look up a schema with getCategorySchema(category, subcategory), which resolves the "Category|Subcategory" key and falls back to a default schema when there's no exact match.

typescript
import { getCategorySchema, getAttributeKeys, buildSchemaOrgLD } from '@pelagora/pim-protocol';

const schema = getCategorySchema('Vehicles', 'Cars'); // schemaOrgType: 'Car'
const keys = getAttributeKeys('Vehicles', 'Cars');     // ['year','make','model','trim','mileage', ...]

Built-in categories

Schemas are keyed by Category|Subcategory. Top-level categories include:

CategoryExample subcategories
ElectronicsPhones & Tablets, Computers & Laptops, Audio & Headphones, Cameras, Gaming
MusicGuitars, Bass, Drums & Percussion, Keyboards & Pianos, Amplifiers, Effects & Pedals
Home & GardenFurniture, Kitchen & Dining, Tools & Hardware, Appliances, Outdoor & Garden, Lighting
Clothing & AccessoriesMens, Womens, Kids, Shoes, Bags & Wallets, Activewear, Vintage
Jewelry & WatchesFine Jewelry, Fashion Jewelry, Watches, Loose Stones & Beads
SportsCycling, Fitness & Gym, Water Sports, Winter Sports, Team Sports, Outdoor & Camping
Books & MediaBooks, Vinyl & Records, CDs & DVDs, Video Games, Magazines, Textbooks, Comics
VehiclesCars, Motorcycles, Bicycles, Trucks & Vans, Boats, Parts & Accessories, Trailers, EVs
Real EstateApartment, and more

Each subcategory maps to a schemaOrgType (e.g. Vehicles|CarsCar, Vehicles|BoatsVehicle). Categories without an exact match resolve to a general default schema.

Schema.org mapping

buildSchemaOrgLD() exports a Ref (plus its category attributes) to Schema.org JSON-LD for interoperability. The @context is an object that maps the default vocabulary to Schema.org and adds a reffo: namespace for Reffo-specific fields (e.g. condition is emitted as reffo:condition):

json
{
  "@context": {
    "@vocab": "https://schema.org/",
    "reffo": "https://reffo.ai/ns/"
  },
  "@type": "Product",
  "name": "Vintage Guitar",
  "description": "1965 Fender Stratocaster",
  "reffo:condition": "used",
  "offers": {
    "@type": "Offer",
    "price": 2500,
    "priceCurrency": "USD"
  }
}

Adding custom categories

See the Adding Categories guide for how to extend the schema system.

Released under the MIT License.