@reffo/protocol
v0.2.1
Published
Schema.org + Reffo extension types, category schemas, and utility functions for the Reffo protocol
Maintainers
Readme
@reffo/protocol
Shared protocol definitions for the Reffo peer-to-peer marketplace. Contains Schema.org-aligned types, category schemas, and utility functions used by Reffo Beacon, Reffo Webapp, and other implementations.
Install
npm install @reffo/protocolUsage
import {
type Ref,
type Offer,
getCategorySchema,
buildSchemaOrgLD,
blurLocation,
haversineDistanceMiles,
} from '@reffo/protocol';What's Included
Types (types.ts)
Core data model types aligned with Schema.org:
- Ref — A product/item listing (Schema.org
Product) - Offer — A price offering on a ref (Schema.org
Offer) - Negotiation — Buyer/seller negotiation state
- BeaconSettings / BeaconInfo — Beacon node configuration and status
- RefMedia — Photo/video attachments
- DHT Payloads —
PeerMessage,QueryPayload,AnnouncePayload,ProposalPayload,ProposalResponsePayload
Utility functions:
blurLocation(lat, lng)— Reduce precision to ~0.7 mi / zip-code levelhaversineDistanceMiles(lat1, lng1, lat2, lng2)— Great-circle distance
Schemas (schemas.ts)
Category-specific attribute definitions with Schema.org JSON-LD generation:
- 8 category schemas: Car, Boat, Housing, Phone, Furniture, Art, Dining Service, Default
getCategorySchema(category, subcategory)— Look up schema by categorybuildSchemaOrgLD(category, subcategory, attrs, baseFields)— Generate Schema.org JSON-LDCATEGORY_SCHEMAS— The full registry mapAttributeField/CategorySchema— Schema definition interfaces
Build
npm install
npm run build # Outputs ESM + CJS to dist/
npm run lint # Type-check onlyLicense
CC0-1.0 — See LICENSE
