UNPKG

@croct/plug

Version:

A fully-featured devkit for building natively personalized applications.

43 lines (40 loc) 1.17 kB
import { JsonObject } from '@croct/json'; type EntityMap = { post: ArticleEntity; article: ArticleEntity; product: ProductEntity; service: ProductEntity; }; type ProductEntity = { id?: string; sku?: string; name?: string; category?: string; brand?: string; variant?: string; displayPrice?: number; originalPrice?: number; url?: string; imageUrl?: string; }; type ArticleEntity = { id?: string; url?: string; title?: string; tags?: string[]; categories?: string[]; authors?: string[]; publishTime?: number; updateTime?: number; }; type EntityType = keyof EntityMap; type Entity<T extends EntityType = EntityType> = { [K in T]: { type: K; } & EntityMap[K]; }[T]; declare function parseEntity(content: string): Entity | null; declare function extractEntity(data: JsonObject): Entity | null; declare function extractArticle(data: JsonObject): ArticleEntity; declare function extractProduct(data: JsonObject): ProductEntity; export { type ArticleEntity, type Entity, type EntityType, type ProductEntity, extractArticle, extractEntity, extractProduct, parseEntity };