@stencila/schema
Version:
Extensions to schema.org to support semantic, composable, parameterize-able and executable documents
47 lines (46 loc) • 1.87 kB
TypeScript
declare let CONTEXT: Record<string, string | {
'@id': string;
}>;
/**
* Get the URL of Stencila Schema's JSON-LD `@context` or
* for a specific `stencila:` term e.g. `CodeChunk`, `outputs`.
*
* The `@context`'s URL needs to have a trailing slash because
* it gets prefixed to all keys during JSON-LD expansion.
* e.g. the term `CodeChunk` gets expanded to `https://schema.stenci.la/v0/jsonld/CodeChunk`
* (which in gets redirected to `https://unpkg.com/@stencila/schema@0.32.1/dist/CodeChunk.jsonld`)
*
* @param term The Stencila term (type or property) to generate the
* URL for. Defaults to empty string i.e. the context.
*/
export declare function jsonLdUrl(term?: string): string;
/**
* Get Stencila Schema's JSON-LD `@context` as an object.
*/
export declare function jsonLdContext(): typeof CONTEXT;
/**
* Get the URL for a term in the Stencila Schema's JSON-LD `@context`
* from it's name.
*
* This uses the JSON-LD `@context` in `stencila.jsonld` (which
* provides a mapping between vocabularies) to translate
* type names used in the Stencila Schema
* to those used in other schemas (e.g. Schema.org, Bioschemas).
* The [compact IRIs](https://www.w3.org/TR/json-ld11/#compact-iris)
* in the `@context` e.g. `schema:Person` are expanded to a URL
* e.g. `https://schema.org/Person` suitable for the `itemtype` attribute.
*
* @param term A term in the JSON-LD `@context`. May, or may not be in
* the `stencila` namespace
*/
export declare function jsonLdTermUrl(term: string): string | undefined;
/**
* Get the name of a term in the Stencila Schema's JSON-LD `@context`
* from a URL.
*
* This is the inverse of `jsonLdTermUrl`.
*
* @param url A url to resolve into a term
*/
export declare function jsonLdTermName(url: string): string | undefined;
export {};