@intellectual-frontiers/libraries 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +8 -2
- package/dist/affected.d.ts +28 -0
- package/dist/affected.js +250 -0
- package/dist/changes.d.ts +27 -0
- package/dist/changes.js +470 -0
- package/dist/check.d.ts +15 -0
- package/dist/check.js +198 -0
- package/dist/generate-ontology.d.ts +37 -0
- package/dist/generate-ontology.js +293 -0
- package/dist/generate-workflows.d.ts +12 -0
- package/dist/generate-workflows.js +102 -0
- package/dist/imports/nist-sp-800-53.import.d.ts +33 -0
- package/dist/imports/nist-sp-800-53.import.js +34 -0
- package/dist/imports/schema-org.import.d.ts +33 -0
- package/dist/imports/schema-org.import.js +31 -0
- package/dist/install-bun.d.ts +1 -0
- package/dist/install-bun.js +58 -0
- package/dist/libraries.d.ts +79 -0
- package/dist/libraries.js +386 -0
- package/dist/mod.d.ts +16 -0
- package/dist/mod.js +16 -0
- package/dist/newer.d.ts +27 -0
- package/dist/newer.js +147 -0
- package/dist/oscal-register.d.ts +65 -0
- package/dist/oscal-register.js +344 -0
- package/dist/pack-library.d.ts +47 -0
- package/dist/pack-library.js +498 -0
- package/dist/pins.d.ts +15 -0
- package/dist/pins.js +29 -0
- package/dist/publish-ontology.d.ts +160 -0
- package/dist/publish-ontology.js +227 -0
- package/dist/versions.d.ts +26 -0
- package/dist/versions.js +556 -0
- package/dist/workflows/definitions.d.ts +65 -0
- package/dist/workflows/definitions.js +614 -0
- package/dist/workflows/mod.d.ts +10 -0
- package/dist/workflows/mod.js +10 -0
- package/dist/workflows/model.d.ts +143 -0
- package/dist/workflows/model.js +81 -0
- package/dist/workflows/render.d.ts +9 -0
- package/dist/workflows/render.js +179 -0
- package/package.json +129 -4
- package/src/affected.ts +265 -0
- package/src/changes.ts +546 -0
- package/src/check.ts +223 -0
- package/src/generate-ontology.ts +350 -0
- package/src/generate-workflows.ts +103 -0
- package/src/imports/nist-sp-800-53.import.ts +36 -0
- package/src/imports/schema-org.import.ts +31 -0
- package/src/install-bun.ts +53 -0
- package/src/libraries.ts +385 -0
- package/src/mod.ts +16 -0
- package/src/newer.ts +154 -0
- package/src/oscal-register.ts +443 -0
- package/src/pack-library.ts +522 -0
- package/src/pins.ts +30 -0
- package/src/publish-ontology.ts +354 -0
- package/src/versions.ts +594 -0
- package/src/workflows/definitions.ts +847 -0
- package/src/workflows/mod.ts +30 -0
- package/src/workflows/model.ts +187 -0
- package/src/workflows/render.ts +176 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Publish a typed ontology (commons 0019-mizan-integrations FR-010 to FR-019): one function that makes every file an ontology of Intellectual Frontiers is published as, from
|
|
3
|
+
* the typed values it is written in, so that Mizan's own ontology and each ontology a specification of commons defines (IFCCM, IFQS, IFR) are published the same way.
|
|
4
|
+
*
|
|
5
|
+
* An ontology is described once, as an {@link OntologyPublication}; {@link publishedFiles} returns its files by path from commons' folder: canonical Turtle, RDF/XML, OWL 2
|
|
6
|
+
* functional syntax, SHACL shapes, a JSON Schema, SKOS concept schemes and SQL tables for its code lists, SSSOM mappings to the standards it maps to, and an HTML view. Nothing
|
|
7
|
+
* here reads or writes a file: `generate-ontology.ts` does.
|
|
8
|
+
*
|
|
9
|
+
* Spec: 0001-libraries FR-008
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import { nTriples, type OntologyFile, owl, triplesOf, turtle } from "@intellectual-frontiers/rdf";
|
|
14
|
+
import {
|
|
15
|
+
type AnySchema,
|
|
16
|
+
type CodeMember,
|
|
17
|
+
exportJsonSchemaDefs,
|
|
18
|
+
exportShacl,
|
|
19
|
+
exportSkos,
|
|
20
|
+
exportSqlCodeList,
|
|
21
|
+
exportSssom,
|
|
22
|
+
type Mapping,
|
|
23
|
+
} from "@intellectual-frontiers/mizan/integrations/pure/export";
|
|
24
|
+
import { exportHtmlView, type ViewBasis, type ViewTerm } from "@intellectual-frontiers/mizan/integrations/pure/export-html";
|
|
25
|
+
import { exportOwl, type OwlText } from "@intellectual-frontiers/mizan/integrations/pure/export-owl";
|
|
26
|
+
import { describeFinding } from "@intellectual-frontiers/mizan/integrations/pure/types";
|
|
27
|
+
import { exportRdfXml } from "@intellectual-frontiers/mizan/integrations/pure/export-rdfxml";
|
|
28
|
+
|
|
29
|
+
type Lang = { readonly value: string; readonly language: string };
|
|
30
|
+
|
|
31
|
+
/** A class or a property as the exporters read it: its IRI and the annotations it carries. */
|
|
32
|
+
type EntityLike = {
|
|
33
|
+
readonly iri: string;
|
|
34
|
+
readonly values: {
|
|
35
|
+
readonly label?: Lang | undefined;
|
|
36
|
+
readonly comment?: Lang | undefined;
|
|
37
|
+
readonly definition?: Lang | undefined;
|
|
38
|
+
readonly subClassOf?: readonly { readonly iri: string }[] | undefined;
|
|
39
|
+
readonly domain?: { readonly iri: string } | undefined;
|
|
40
|
+
readonly range?: { readonly iri: string } | undefined;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** A property: an entity with the class it is an individual of (`owl:ObjectProperty` or `owl:DatatypeProperty`). */
|
|
45
|
+
type PropertyLike = EntityLike & { readonly class: { readonly iri: string } };
|
|
46
|
+
|
|
47
|
+
/** The record of what a term rests on, as the exporters read it. */
|
|
48
|
+
type TermLike = {
|
|
49
|
+
readonly values: {
|
|
50
|
+
readonly termIri: string;
|
|
51
|
+
readonly basis: { readonly iri: string };
|
|
52
|
+
readonly standardTerm?: string | undefined;
|
|
53
|
+
readonly mappingRelation?: Mapping["relation"] | undefined;
|
|
54
|
+
readonly justification?: string | undefined;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** The members of a code list as the exporters read them: its keys, with each individual's label and definition. */
|
|
59
|
+
export function membersOf(
|
|
60
|
+
list: Readonly<
|
|
61
|
+
Record<
|
|
62
|
+
string,
|
|
63
|
+
{ readonly values: { readonly label: { readonly value: string }; readonly definition?: { readonly value: string } | undefined } }
|
|
64
|
+
>
|
|
65
|
+
>,
|
|
66
|
+
): readonly CodeMember[] {
|
|
67
|
+
return Object.entries(list).map(([code, i]) => ({
|
|
68
|
+
code,
|
|
69
|
+
label: i.values.label.value,
|
|
70
|
+
...(i.values.definition === undefined ? {} : { definition: i.values.definition.value }),
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** A code list as `membersOf` reads it. */
|
|
75
|
+
export type CodeListLike = Parameters<typeof membersOf>[0];
|
|
76
|
+
|
|
77
|
+
/** The code lists of an ontology, each by the name of its class, as the publication reads them: its SKOS scheme and its SQL table are named after it. */
|
|
78
|
+
export function listsOf(prefix: string, lists: readonly (readonly [string, CodeListLike])[]): readonly CodeListPublication[] {
|
|
79
|
+
return lists.map(([name, list]) => ({
|
|
80
|
+
name,
|
|
81
|
+
table: `${prefix}_${name.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase()}`,
|
|
82
|
+
members: membersOf(list),
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** One code list of an ontology, with the name its SKOS scheme and its SQL table go by. */
|
|
87
|
+
export type CodeListPublication = { readonly name: string; readonly table: string; readonly members: readonly CodeMember[] };
|
|
88
|
+
|
|
89
|
+
/** Everything an ontology is published from. */
|
|
90
|
+
export type OntologyPublication = {
|
|
91
|
+
/** The name its files go by: `generated/<name>.auto.ttl`, `generated/<name>-shapes.auto.ttl`, and so on. */
|
|
92
|
+
readonly name: string;
|
|
93
|
+
/** The ontology's namespace IRI (ending in `#`) and the prefix it goes by. */
|
|
94
|
+
readonly ns: { readonly prefix: string; readonly iri: string };
|
|
95
|
+
/** The namespace of its individuals, which an SSSOM file declares as a prefix too. */
|
|
96
|
+
readonly idNs: { readonly prefix: string; readonly iri: string };
|
|
97
|
+
/** The prefixes a CURIE is made with in the HTML view, longest namespace first is not required: the first that matches wins. */
|
|
98
|
+
readonly curies: readonly (readonly [string, string])[];
|
|
99
|
+
/** The ontology's files of typed individuals. */
|
|
100
|
+
readonly files: readonly OntologyFile[];
|
|
101
|
+
/** The ontology's own header individual (`owl:Ontology`): its label, description, version information and version IRI. */
|
|
102
|
+
readonly ontology: {
|
|
103
|
+
readonly values: {
|
|
104
|
+
readonly label?: Lang | undefined;
|
|
105
|
+
readonly description?: Lang | undefined;
|
|
106
|
+
readonly versionInfo?: string | undefined;
|
|
107
|
+
readonly versionIri?: { readonly iri: string } | undefined;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
readonly classes: readonly EntityLike[];
|
|
111
|
+
readonly properties: readonly PropertyLike[];
|
|
112
|
+
/** The audit records of the terms (Mizan's own and, for Mizan, the packaging ontology's), which give the HTML view its bases and SSSOM its mappings. */
|
|
113
|
+
readonly terms: readonly TermLike[];
|
|
114
|
+
/** The shapes and schemas: the class schemas of the data the ontology holds. */
|
|
115
|
+
readonly schemas: readonly AnySchema[];
|
|
116
|
+
readonly lists: readonly CodeListPublication[];
|
|
117
|
+
/** Where it is generated from, for the header comment: `commons/ontology/<name>/*.ts`. */
|
|
118
|
+
readonly source: string;
|
|
119
|
+
/** The command that writes the files again. */
|
|
120
|
+
readonly run: string;
|
|
121
|
+
/** The IRI of the SHACL shapes and of the JSON Schema, the SSSOM set and the prefix the shapes use. */
|
|
122
|
+
readonly shapes: { readonly prefix: string; readonly iri: string };
|
|
123
|
+
readonly schemasIri: string;
|
|
124
|
+
readonly sssomSetId: string;
|
|
125
|
+
/** Prefix to namespace pairs the SSSOM file declares besides the ontology's own. */
|
|
126
|
+
readonly sssomCuries: Readonly<Record<string, string>>;
|
|
127
|
+
/** The title of the HTML view. */
|
|
128
|
+
readonly viewTitle: string;
|
|
129
|
+
/** The license of the files: an IRI. */
|
|
130
|
+
readonly license: string;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/** The default license of what Intellectual Frontiers publishes as ontologies: CC0. */
|
|
134
|
+
export const CC0 = "https://creativecommons.org/publicdomain/zero/1.0/";
|
|
135
|
+
|
|
136
|
+
/** The path of a generated file of an ontology, from commons' folder: `generated/<name><suffix>`. */
|
|
137
|
+
export function pathOf(name: string, suffix: string): string {
|
|
138
|
+
return `generated/${name}${suffix}`;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** The files of an ontology, with their title, media type and what they conform to: its DCAT distributions (0019-mizan-integrations FR-018). */
|
|
142
|
+
export function distributionsOf(
|
|
143
|
+
name: string,
|
|
144
|
+
title: string,
|
|
145
|
+
): readonly { readonly file: string; readonly title: string; readonly mediaType: string; readonly conformsTo?: string }[] {
|
|
146
|
+
return [
|
|
147
|
+
{ file: pathOf(name, ".auto.ttl"), title: `${title} ontology, Turtle`, mediaType: "text/turtle" },
|
|
148
|
+
{ file: pathOf(name, ".auto.rdf"), title: `${title} ontology, RDF/XML`, mediaType: "application/rdf+xml" },
|
|
149
|
+
{ file: pathOf(name, ".auto.ofn"), title: `${title} ontology, OWL 2 functional syntax`, mediaType: "text/owl-functional" },
|
|
150
|
+
{
|
|
151
|
+
file: pathOf(name, "-shapes.auto.ttl"),
|
|
152
|
+
title: `${title} SHACL shapes`,
|
|
153
|
+
mediaType: "text/turtle",
|
|
154
|
+
conformsTo: "https://www.w3.org/TR/shacl/",
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
file: pathOf(name, "-schemas.auto.json"),
|
|
158
|
+
title: `${title} JSON Schema`,
|
|
159
|
+
mediaType: "application/schema+json",
|
|
160
|
+
conformsTo: "https://json-schema.org/draft/2020-12/schema",
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
file: pathOf(name, "-code-lists.auto.skos.ttl"),
|
|
164
|
+
title: `${title} code lists, SKOS`,
|
|
165
|
+
mediaType: "text/turtle",
|
|
166
|
+
conformsTo: "https://www.w3.org/TR/skos-reference/",
|
|
167
|
+
},
|
|
168
|
+
{ file: pathOf(name, "-code-lists.auto.sql"), title: `${title} code lists, SQL`, mediaType: "application/sql" },
|
|
169
|
+
{
|
|
170
|
+
file: pathOf(name, "-mappings.auto.sssom.tsv"),
|
|
171
|
+
title: `${title} mappings to standards, SSSOM`,
|
|
172
|
+
mediaType: "text/tab-separated-values",
|
|
173
|
+
conformsTo: "https://mapping-commons.github.io/sssom/spec/",
|
|
174
|
+
},
|
|
175
|
+
{ file: pathOf(name, "-ontology.auto.html"), title: `${title} ontology, HTML view`, mediaType: "text/html" },
|
|
176
|
+
];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** An IRI as a CURIE where a prefix of the publication shortens it. */
|
|
180
|
+
function compactWith(p: OntologyPublication, iri: string): string {
|
|
181
|
+
for (const [prefix, ns] of p.curies) if (iri.startsWith(ns)) return `${prefix}:${iri.slice(ns.length)}`;
|
|
182
|
+
return iri;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** The SHA-256 of the ontology's canonical N-Triples (0012-ontology FR-012): it changes with a fact, never with the layout of a module. */
|
|
186
|
+
export async function digestOf(of: readonly OntologyFile[]): Promise<string> {
|
|
187
|
+
const bytes = new TextEncoder().encode(nTriples(triplesOf(of.flatMap((f) => f.individuals))));
|
|
188
|
+
return [...new Uint8Array(await crypto.subtle.digest("SHA-256", bytes))].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** The ontology as canonical Turtle: every file's individuals, with every file's prefixes. */
|
|
192
|
+
export function turtleOf(of: readonly OntologyFile[], run: string, digest: string, source: string): string {
|
|
193
|
+
const prefixes = new Map(of.flatMap((f) => f.prefixes).map((p) => [p.prefix, p]));
|
|
194
|
+
return turtle({
|
|
195
|
+
comments: [`AUTO-GENERATED by ${run} from ${source}. Do not edit: change the ontology.`, `source_sha256=${digest}`],
|
|
196
|
+
prefixes: [...prefixes.values()],
|
|
197
|
+
triples: triplesOf(of.flatMap((f) => f.individuals)),
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** The text of an exporter's result, or a thrown sentence naming what the ontology states that the form cannot hold. */
|
|
202
|
+
export class ExportRefused extends Error {
|
|
203
|
+
/** The refusal, told as a sentence. */
|
|
204
|
+
constructor(message: string) {
|
|
205
|
+
super(message);
|
|
206
|
+
this.name = "ExportRefused";
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** The value of an exporter's result, or a refusal naming what the ontology states that the form cannot hold. */
|
|
211
|
+
export function textOf(
|
|
212
|
+
r: { readonly kind: "ok"; readonly value: string } | { readonly kind: "err"; readonly error: readonly string[] },
|
|
213
|
+
what: string,
|
|
214
|
+
name: string,
|
|
215
|
+
): string {
|
|
216
|
+
if (r.kind === "ok") return r.value;
|
|
217
|
+
throw new ExportRefused(`the ${name} ontology cannot be written as ${what}: ${r.error.join("; ")}`);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** Stops with a sentence naming what an exporter could not hold: a file that would be empty is never written. */
|
|
221
|
+
function refuse(name: string, what: string, findings: readonly string[]): never {
|
|
222
|
+
throw new ExportRefused(`the ${name} ontology cannot be written as ${what}: ${findings.join("; ")}`);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const owlText = (x: Lang): OwlText => ({ value: x.value, language: x.language });
|
|
226
|
+
|
|
227
|
+
/** The ontology's classes and properties as the OWL writer reads them (0019-mizan-integrations FR-017). */
|
|
228
|
+
function owlOf(p: OntologyPublication, comments: readonly string[]): Parameters<typeof exportOwl>[0] {
|
|
229
|
+
const o = p.ontology.values;
|
|
230
|
+
const entity = (e: EntityLike["values"]) => ({
|
|
231
|
+
...(e.label === undefined ? {} : { label: owlText(e.label) }),
|
|
232
|
+
...(e.comment === undefined ? {} : { comment: owlText(e.comment) }),
|
|
233
|
+
...(e.definition === undefined ? {} : { definition: owlText(e.definition) }),
|
|
234
|
+
});
|
|
235
|
+
return {
|
|
236
|
+
iri: p.ns.iri.replace(/#$/, ""),
|
|
237
|
+
...(o.versionIri === undefined ? {} : { versionIri: o.versionIri.iri }),
|
|
238
|
+
...(o.label === undefined ? {} : { label: owlText(o.label) }),
|
|
239
|
+
...(o.description === undefined ? {} : { description: owlText(o.description) }),
|
|
240
|
+
...(o.versionInfo === undefined ? {} : { versionInfo: o.versionInfo }),
|
|
241
|
+
title: o.label?.value ?? p.name,
|
|
242
|
+
license: p.license,
|
|
243
|
+
prefixes: p.files.flatMap((f) => f.prefixes).map((x) => ({ prefix: x.prefix, iri: x.iri })),
|
|
244
|
+
classes: p.classes.map((c) => ({ iri: c.iri, ...entity(c.values), subClassOf: (c.values.subClassOf ?? []).map((s) => s.iri) })),
|
|
245
|
+
properties: p.properties.map((x) => ({
|
|
246
|
+
iri: x.iri,
|
|
247
|
+
kind: x.class.iri === owl.ObjectProperty.iri ? ("object" as const) : ("datatype" as const),
|
|
248
|
+
...entity(x.values),
|
|
249
|
+
...(x.values.domain === undefined ? {} : { domain: x.values.domain.iri }),
|
|
250
|
+
...(x.values.range === undefined ? {} : { range: x.values.range.iri }),
|
|
251
|
+
})),
|
|
252
|
+
comments,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** The ontology as the HTML view reads it: its classes, properties, code lists and the basis of every term. */
|
|
257
|
+
function viewOf(p: OntologyPublication): Parameters<typeof exportHtmlView>[0] {
|
|
258
|
+
const text = (x: Lang | undefined): { definition?: string } => (x === undefined ? {} : { definition: x.value });
|
|
259
|
+
const classView: ViewTerm[] = p.classes.map((c) => ({
|
|
260
|
+
curie: compactWith(p, c.iri),
|
|
261
|
+
label: c.values.label?.value ?? "",
|
|
262
|
+
...text(c.values.definition),
|
|
263
|
+
}));
|
|
264
|
+
const propertyView: ViewTerm[] = p.properties.map((x) => ({
|
|
265
|
+
curie: compactWith(p, x.iri),
|
|
266
|
+
label: compactWith(p, x.iri).replace(new RegExp(`^${p.ns.prefix}:`), ""),
|
|
267
|
+
...(x.values.domain === undefined ? {} : { domain: compactWith(p, x.values.domain.iri) }),
|
|
268
|
+
...(x.values.range === undefined ? {} : { range: compactWith(p, x.values.range.iri) }),
|
|
269
|
+
...text(x.values.definition),
|
|
270
|
+
}));
|
|
271
|
+
const basisView: ViewBasis[] = p.terms.map((t) => ({
|
|
272
|
+
curie: compactWith(p, t.values.termIri),
|
|
273
|
+
basis: t.values.basis.iri.slice(t.values.basis.iri.lastIndexOf("#") + 1).toLowerCase(),
|
|
274
|
+
...(t.values.standardTerm === undefined ? {} : { standardTerm: compactWith(p, t.values.standardTerm) }),
|
|
275
|
+
...(t.values.mappingRelation === undefined ? {} : { relation: t.values.mappingRelation }),
|
|
276
|
+
...(t.values.justification === undefined ? {} : { justification: t.values.justification }),
|
|
277
|
+
}));
|
|
278
|
+
return {
|
|
279
|
+
title: p.viewTitle,
|
|
280
|
+
iri: p.ns.iri.replace(/#$/, ""),
|
|
281
|
+
...(p.ontology.values.versionIri === undefined ? {} : { versionIri: p.ontology.values.versionIri.iri }),
|
|
282
|
+
classes: classView,
|
|
283
|
+
properties: propertyView,
|
|
284
|
+
codeLists: p.lists.map((l) => ({ name: l.name, members: l.members })),
|
|
285
|
+
terms: basisView,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/** Every file of an ontology (but its DCAT catalog entry, which `generate-ontology.ts` writes for them all), by its path from commons' folder. */
|
|
290
|
+
export async function publishedFiles(p: OntologyPublication): Promise<ReadonlyMap<string, string>> {
|
|
291
|
+
const digest = await digestOf(p.files);
|
|
292
|
+
const note = `AUTO-GENERATED by ${p.run} from ${p.source} (commons 0019-mizan-integrations FR-010). Do not edit: change the ontology. source_sha256=${digest}`;
|
|
293
|
+
const skos = p.lists
|
|
294
|
+
.map((l, i) => {
|
|
295
|
+
const text = exportSkos({ schemeIri: `${p.ns.iri}${l.name}Scheme`, label: l.name, conceptBase: p.ns.iri, members: l.members });
|
|
296
|
+
return i === 0 ? text : text.split("\n").slice(2).join("\n");
|
|
297
|
+
})
|
|
298
|
+
.join("\n");
|
|
299
|
+
const sql = p.lists
|
|
300
|
+
.map((l) => {
|
|
301
|
+
const r = exportSqlCodeList(l.table, l.members);
|
|
302
|
+
return r.kind === "ok" ? r.value : "";
|
|
303
|
+
})
|
|
304
|
+
.join("\n");
|
|
305
|
+
const mappings: Mapping[] = p.terms.flatMap((t) =>
|
|
306
|
+
t.values.standardTerm === undefined || t.values.mappingRelation === undefined
|
|
307
|
+
? []
|
|
308
|
+
: [{ subject: t.values.termIri, relation: t.values.mappingRelation, object: t.values.standardTerm }],
|
|
309
|
+
);
|
|
310
|
+
const sssom = exportSssom({
|
|
311
|
+
setId: p.sssomSetId,
|
|
312
|
+
license: p.license,
|
|
313
|
+
comment: note,
|
|
314
|
+
curies: { [p.ns.prefix]: p.ns.iri, [p.idNs.prefix]: p.idNs.iri, ...p.sssomCuries },
|
|
315
|
+
mappings,
|
|
316
|
+
});
|
|
317
|
+
return new Map([
|
|
318
|
+
[pathOf(p.name, ".auto.ttl"), turtleOf(p.files, p.run, digest, p.source)],
|
|
319
|
+
[
|
|
320
|
+
pathOf(p.name, "-ontology.auto.html"),
|
|
321
|
+
exportHtmlView(
|
|
322
|
+
viewOf(p),
|
|
323
|
+
`AUTO-GENERATED by ${p.run} from ${p.source} (commons 0019-mizan-integrations FR-010). Do not edit. source_sha256=${digest}`,
|
|
324
|
+
),
|
|
325
|
+
],
|
|
326
|
+
[
|
|
327
|
+
pathOf(p.name, "-mappings.auto.sssom.tsv"),
|
|
328
|
+
sssom.kind === "ok"
|
|
329
|
+
? sssom.value
|
|
330
|
+
: refuse(
|
|
331
|
+
p.name,
|
|
332
|
+
"SSSOM",
|
|
333
|
+
sssom.error.map((f) => describeFinding(f)),
|
|
334
|
+
),
|
|
335
|
+
],
|
|
336
|
+
[pathOf(p.name, "-shapes.auto.ttl"), `# ${note}\n\n${exportShacl(p.schemas, p.shapes)}`],
|
|
337
|
+
[pathOf(p.name, "-schemas.auto.json"), exportJsonSchemaDefs(p.schemas, p.schemasIri, note)],
|
|
338
|
+
[pathOf(p.name, "-code-lists.auto.skos.ttl"), `# ${note}\n\n${skos}`],
|
|
339
|
+
[pathOf(p.name, "-code-lists.auto.sql"), `-- ${note}\n\n${sql}`],
|
|
340
|
+
[
|
|
341
|
+
pathOf(p.name, ".auto.rdf"),
|
|
342
|
+
textOf(
|
|
343
|
+
exportRdfXml({
|
|
344
|
+
comments: [note],
|
|
345
|
+
prefixes: [...new Map(p.files.flatMap((f) => f.prefixes).map((x) => [x.prefix, x])).values()],
|
|
346
|
+
triples: triplesOf(p.files.flatMap((f) => f.individuals)),
|
|
347
|
+
}),
|
|
348
|
+
"RDF/XML",
|
|
349
|
+
p.name,
|
|
350
|
+
),
|
|
351
|
+
],
|
|
352
|
+
[pathOf(p.name, ".auto.ofn"), textOf(exportOwl(owlOf(p, [note])), "OWL", p.name)],
|
|
353
|
+
]);
|
|
354
|
+
}
|