Skip to content

Instantly share code, notes, and snippets.

@kristojorg
Last active August 19, 2020 17:43
Show Gist options
  • Save kristojorg/e90777c8717a89d5a962deb165fd77a2 to your computer and use it in GitHub Desktop.
Save kristojorg/e90777c8717a89d5a962deb165fd77a2 to your computer and use it in GitHub Desktop.
Data Types for the OPDS 2.0 Spec
export interface Collection {
type: "application/opds+json"; // must comply with this spec
links: Link[];
}
// a feed is a collection since it has metadata, links and sub collections.
export interface Feed extends Collection {
// sub collections of with roles "navigation", "publication", "group"
navigation?: NavigationEntry[];
publications?: PublicationEntry[];
groups?: GroupEntry[];
}
export interface NavigationEntry {}
export interface PublicationEntry {}
export interface GroupEntry {}
export interface LibraryRegistryFeed extends Feed {
metadata: { adobe_vendor_id: string; title: string };
links: Link[];
catalogs: Catalog[];
}
export interface Catalog extends Feed {
// this is just a feed with an authentication document, thus marking it the
// top level for this library
// the authentication document is nested within links.
// with rel = ?something
}
export type Publication = ReadiumWebPub | OPDSPublication;
export interface ReadiumWebPub {}
export interface OPDSPublication {}
/**
* Links
*/
export const CatalogLinkTemplateRelation =
"http://librarysimplified.org/rel/registry/library";
export const CatalogRootRelation = "http://opds-spec.org/catalog";
export type LinkRelation =
| typeof CatalogLinkTemplateRelation
| typeof CatalogRootRelation
| "self"
| "search"
| "registry";
export type MediaType =
| "application/opds+json"
| "application/opensearchdescription+xml"
| "application/opds+json;profile=https://librarysimplified.org/rel/profile/directory";
export interface Link {
href: string;
type: MediaType;
rel: LinkRelation;
templated?: boolean;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment