IF Commons GitHub

integrations/pure/export

The first exporters (commons 0019-mizan-integrations FR-010): an ontology's class schemas and code lists written in forms other tools read, as text, deterministically, so that a generated file can be checked for staleness. A JSON Schema for the values of a class, SHACL shapes for its individuals, a SKOS concept scheme and a SQL table for a code list.

A class schema's fields give the shape: a one field is required, an optional one is not, a many one is an array; a plain string, boolean or integer keeps its type, a string that is one of a list of words is an enumeration, a string in a language is an object with its value and language, and a reference is an IRI (the kernel keeps the classes a reference may name for the compiler only, so a shape cannot state them).

import { exportSqlCodeList } from "./export.ts";
exportSqlCodeList("basis", [{ code: "Adopts", label: "adopts" }]); // { kind: "ok", ... } the CREATE TABLE and INSERT

Source: commons/mizan/src/integrations/pure/export.ts

6 of 18 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

integrations.AnySchematypeno test imports it
type AnySchema = { readonly class: Named; readonly curie: string; readonly fields: Fields };

A class schema as an exporter reads it: the class and its fields, whatever their types.

integrations.CodeMembertypeno test imports it
type CodeMember = { readonly code: string; readonly label: string; readonly definition?: string };

One member of a code list as the exporters read it.

integrations.exportJsonSchemafunctionno test imports it
function exportJsonSchema(schema: AnySchema, id?: string | undefined): string

A JSON Schema (2020-12) for the values of a class's individuals, as text: its fields by name, the one fields required, nothing else allowed.

integrations.exportJsonSchemaDefsfunctionno test imports it
function exportJsonSchemaDefs(schemas: readonly AnySchema[], id: string, comment: string): string

A JSON Schema document whose $defs are the schemas of several classes, by their local names: one file for an ontology's classes.

integrations.exportShaclfunctionno test imports it
function exportShacl(schemas: readonly AnySchema[], shapes: { readonly prefix: string; readonly iri: string; }): string

SHACL node shapes for class schemas, as Turtle: each class a shape that targets it, each field a named property shape with its path, cardinality and datatype or node kind.

integrations.exportSkosfunctionno test imports it
function exportSkos(list: { readonly schemeIri: string; readonly label: string; readonly conceptBase: string; readonly members: readonly CodeMember[]; }): string

A SKOS concept scheme for a code list, as Turtle: the scheme, and each member a concept with its notation, label and definition.

integrations.exportSqlCodeListfunctionno test imports it
function exportSqlCodeList(table: string, members: readonly CodeMember[]): Result<string, readonly IntegrationFinding[]>

A SQL table for a code list, as a CREATE TABLE and one INSERT per member in order, or the finding that its name is not one a table may have.

integrations.exportSssomfunctionno test imports it
function exportSssom(set: { readonly setId: string; readonly license: string; readonly comment?: string | undefined; readonly curies: Readonly<Record<string, string>>; readonly mappings: readonly Mapping[]; }): Result<string, readonly IntegrationFinding[]>

The mappings of an ontology as an SSSOM TSV (Simple Standard for Sequential Mappings): the metadata as commented YAML, then one row per mapping, each justified as manual curation, or the finding of an IRI that no prefix of the map shortens.

integrations.Mappingtypeno test imports it
type Mapping = {
  readonly subject: string;
  readonly relation: "exactMatch" | "closeMatch" | "narrowMatch" | "broadMatch" | "subClassOf" | "subPropertyOf";
  readonly object: string;
};

One mapping of a term of ours to a term of a standard, as SSSOM publishes it.

AnySchematype
type AnySchema = { readonly class: Named; readonly curie: string; readonly fields: Fields };

A class schema as an exporter reads it: the class and its fields, whatever their types.

Imported by 18 tests of the run (18 passed, 0 failed): the library's results

CodeMembertypeno test imports it
type CodeMember = { readonly code: string; readonly label: string; readonly definition?: string };

One member of a code list as the exporters read it.

exportJsonSchemafunction
function exportJsonSchema(schema: AnySchema, id?: string | undefined): string

A JSON Schema (2020-12) for the values of a class's individuals, as text: its fields by name, the one fields required, nothing else allowed.

Imported by 18 tests of the run (18 passed, 0 failed): the library's results

exportJsonSchemaDefsfunctionno test imports it
function exportJsonSchemaDefs(schemas: readonly AnySchema[], id: string, comment: string): string

A JSON Schema document whose $defs are the schemas of several classes, by their local names: one file for an ontology's classes.

exportShaclfunction
function exportShacl(schemas: readonly AnySchema[], shapes: { readonly prefix: string; readonly iri: string; }): string

SHACL node shapes for class schemas, as Turtle: each class a shape that targets it, each field a named property shape with its path, cardinality and datatype or node kind.

Imported by 18 tests of the run (18 passed, 0 failed): the library's results

exportSkosfunction
function exportSkos(list: { readonly schemeIri: string; readonly label: string; readonly conceptBase: string; readonly members: readonly CodeMember[]; }): string

A SKOS concept scheme for a code list, as Turtle: the scheme, and each member a concept with its notation, label and definition.

Imported by 18 tests of the run (18 passed, 0 failed): the library's results

exportSqlCodeListfunction
function exportSqlCodeList(table: string, members: readonly CodeMember[]): Result<string, readonly IntegrationFinding[]>

A SQL table for a code list, as a CREATE TABLE and one INSERT per member in order, or the finding that its name is not one a table may have.

Imported by 18 tests of the run (18 passed, 0 failed): the library's results

exportSssomfunction
function exportSssom(set: { readonly setId: string; readonly license: string; readonly comment?: string | undefined; readonly curies: Readonly<Record<string, string>>; readonly mappings: readonly Mapping[]; }): Result<string, readonly IntegrationFinding[]>

The mappings of an ontology as an SSSOM TSV (Simple Standard for Sequential Mappings): the metadata as commented YAML, then one row per mapping, each justified as manual curation, or the finding of an IRI that no prefix of the map shortens.

Imported by 18 tests of the run (18 passed, 0 failed): the library's results

Mappingtypeno test imports it
type Mapping = {
  readonly subject: string;
  readonly relation: "exactMatch" | "closeMatch" | "narrowMatch" | "broadMatch" | "subClassOf" | "subPropertyOf";
  readonly object: string;
};

One mapping of a term of ours to a term of a standard, as SSSOM publishes it.

Titles, headings, exports, tables, columns and requirements. Esc closes.