UNPKG

pg-rdf-to-json

Version:

Transforms RDF files from rdf-files.tar.bz2 provided by Project Gutenberg into JS/JSON objects.

119 lines 3.47 kB
import { type JTDSchemaType } from 'ajv/dist/jtd.js'; export type Formatter = (key: string, val: any, path: string, original: UnformattedRDFFile) => any; export type BookType = 'Collection' | 'Dataset' | 'Event' | 'Image' | 'InteractiveResource' | 'MovingImage' | 'PhysicalObject' | 'Service' | 'Software' | 'Sound' | 'StillImage' | 'Text'; export type NoneOneOrMany<T> = T | T[] | undefined; export interface Node<T = string> { '#text': T; } export interface RDFDescription<T = string> { 'description': { 'value': Node<T>; }; } export interface RDFResource { 'resource': string; } export interface PGAgent { 'agent': { 'about': string; 'name': Node; 'birthdate': Node<number> | undefined; 'deathdate': Node<number> | undefined; 'alias': Node | Node[]; 'webpage': RDFResource | RDFResource[]; }; } export interface PGFile { 'file': { 'about': string; 'isFormatOf': RDFResource; 'extent': NoneOneOrMany<Node<number>>; 'modified': NoneOneOrMany<Node>; 'format': NoneOneOrMany<RDFDescription<string>>; }; } export interface UnformattedRDFFile { 'rdf': { 'ebook': { 'about': string; 'publisher': Node; 'issued': Node; 'title': NoneOneOrMany<Node<string | number>>; 'alternative': NoneOneOrMany<Node<string | number>>; 'creator': NoneOneOrMany<PGAgent | RDFResource>; 'editor': NoneOneOrMany<PGAgent | RDFResource>; 'rights': Node; 'downloads': number; 'marc508': Node | number | undefined; 'marc520': Node | undefined; 'language': RDFDescription | RDFDescription[]; 'type': RDFDescription<BookType>; 'subject': NoneOneOrMany<RDFDescription>; 'bookshelf': NoneOneOrMany<RDFDescription>; 'files': NoneOneOrMany<PGFile>; }; }; } export interface Agent { about: number; name: string; codes: string[]; birthdate?: number; deathdate?: number; alias?: string[]; webpage?: string[]; } export interface Resource<T = string> { resource: T; } export interface TaggedResource extends Resource { kind: 'resource'; code?: string; } export interface File { about: string; isFormatOf: Resource<number>; extent: number[]; format: string[]; modified: Date[]; } export interface Book { about: number; title: string; alternative?: string[]; description?: string[]; publisher: string; license: string; issued: string; rights: string; downloads: number; /** @see {@link https://www.loc.gov/marc/bibliographic/bdsummary.html} */ marc: Record<string, any>; tableOfContents?: string; language: string[]; subject: string[]; bookshelf: string[]; type: string; /** * Relator terms and their associated codes designate the relationship * between an agent and a bibliographic resource. * * https://id.loc.gov/vocabulary/relators.html */ relators: Agent[]; files: File[]; } export interface FormattedRDFFile { 'rdf': { 'ebook': Book; }; } export declare const bookSchema: JTDSchemaType<Book, { file: File; agent: Agent; }>; export declare const formattedRDFFileSchema: JTDSchemaType<FormattedRDFFile, { file: File; agent: Agent; }>; //# sourceMappingURL=types.d.ts.map