IF Commons GitHub

integrations/pure/import-vocabulary

The first importer (commons 0019-mizan-integrations FR-005 to FR-009): a slice of an outside vocabulary, read from Turtle, N-Triples, JSON-LD or RDF/XML, written as a generated TypeScript module of a typed vocabulary, whose terms have the basis adopts (0018-standards-first FR-003).

The import takes only the terms of the slice, never the whole standard. It refuses a source whose SHA-256 differs from its record, and a standard that has no license or may not be copied. Each term's class comes from its rdf:type (owl:Class, rdfs:Class, owl:ObjectProperty, owl:DatatypeProperty, rdf:Property); what the typed form cannot hold (a blank-node value, a collection) is a finding, and so is a term of the slice that the source does not have. The output is deterministic: the same source and slice give the same text, so a generated file can be checked for staleness.

import { importVocabulary } from "./import-vocabulary.ts";
// importVocabulary({ standard, sourceText, format: "turtle", namespace: { prefix: "ex", iri: "https://example.org/" }, slice: ["Thing"], rdfImport: "@intellectual-frontiers/rdf" })

Source: commons/mizan/src/integrations/pure/import-vocabulary.ts

1 of 12 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.GENERATORconstno test imports it
const GENERATOR: "commons/mizan/src/integrations/pure/import-vocabulary.ts"

The generator's name, as the provenance and the header of a generated module give it.

integrations.importVocabularyfunctionno test imports it
function importVocabulary(i: ImportInput): Promise<Result<ImportOutput, readonly IntegrationFinding[]>>

A slice of an outside vocabulary as a generated typed-vocabulary module, or what stops it.

integrations.ImportInputtypeno test imports it
type ImportInput = { readonly standard: StandardRecord; /** The source, as the pinned bytes read as UTF-8 text. */ … (735 characters)
type ImportInput = {
  readonly standard: StandardRecord;
  /** The source, as the pinned bytes read as UTF-8 text. */
  readonly sourceText: string;
  readonly format: "turtle" | "n-triples" | "json-ld" | "rdf-xml";
  /** The namespace the slice's terms are in: its prefix and IRI. */
  readonly namespace: { readonly prefix: string; readonly iri: string };
  /** The local names of the terms to take, never the whole standard. */
  readonly slice: readonly string[];
  /** The specifier of the module that exports `namespace` and `vocabulary` (the kernel's `rdf.ts`, or a package path to it). */
  readonly rdfImport: string;
  /** The name the vocabulary is exported as (the prefix by default). */
  readonly exportName?: string;
};

What an import needs.

integrations.ImportOutputtypeno test imports it
type ImportOutput = {
  readonly module: string;
  readonly record: ImportRecordData;
  readonly terms: readonly { readonly iri: string; readonly kind: TermKind | "control" | "code-list" | "field-names" }[];
  readonly findings: readonly IntegrationFinding[];
};

What an import gives: the generated module's text, its provenance, and the terms it states.

integrations.ImportRecordDatatypeno test imports it
type ImportRecordData = {
  readonly standard: string;
  readonly name: string;
  readonly issuer: string;
  readonly version: string;
  readonly location: string;
  readonly license: string;
  readonly sha256: string;
  readonly generator: string;
  readonly slice: readonly string[];
};

The provenance of one import (0019-mizan-integrations FR-009): what was imported, from where, by which generator, with which hash, and which terms. It carries no date, so that the output is deterministic.

integrations.TermKindtypeno test imports it
type TermKind = (typeof KINDS)[number][1];

The kind of a term in a typed vocabulary.

GENERATORconstno test imports it
const GENERATOR: "commons/mizan/src/integrations/pure/import-vocabulary.ts"

The generator's name, as the provenance and the header of a generated module give it.

importVocabularyfunction
function importVocabulary(i: ImportInput): Promise<Result<ImportOutput, readonly IntegrationFinding[]>>

A slice of an outside vocabulary as a generated typed-vocabulary module, or what stops it.

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

ImportInputtypeno test imports it
type ImportInput = { readonly standard: StandardRecord; /** The source, as the pinned bytes read as UTF-8 text. */ … (735 characters)
type ImportInput = {
  readonly standard: StandardRecord;
  /** The source, as the pinned bytes read as UTF-8 text. */
  readonly sourceText: string;
  readonly format: "turtle" | "n-triples" | "json-ld" | "rdf-xml";
  /** The namespace the slice's terms are in: its prefix and IRI. */
  readonly namespace: { readonly prefix: string; readonly iri: string };
  /** The local names of the terms to take, never the whole standard. */
  readonly slice: readonly string[];
  /** The specifier of the module that exports `namespace` and `vocabulary` (the kernel's `rdf.ts`, or a package path to it). */
  readonly rdfImport: string;
  /** The name the vocabulary is exported as (the prefix by default). */
  readonly exportName?: string;
};

What an import needs.

ImportOutputtypeno test imports it
type ImportOutput = {
  readonly module: string;
  readonly record: ImportRecordData;
  readonly terms: readonly { readonly iri: string; readonly kind: TermKind | "control" | "code-list" | "field-names" }[];
  readonly findings: readonly IntegrationFinding[];
};

What an import gives: the generated module's text, its provenance, and the terms it states.

ImportRecordDatatypeno test imports it
type ImportRecordData = {
  readonly standard: string;
  readonly name: string;
  readonly issuer: string;
  readonly version: string;
  readonly location: string;
  readonly license: string;
  readonly sha256: string;
  readonly generator: string;
  readonly slice: readonly string[];
};

The provenance of one import (0019-mizan-integrations FR-009): what was imported, from where, by which generator, with which hash, and which terms. It carries no date, so that the output is deterministic.

TermKindtypeno test imports it
type TermKind = (typeof KINDS)[number][1];

The kind of a term in a typed vocabulary.

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