@intellectual-frontiers/libraries 0.0.0-stage → 0.1.1

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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +8 -2
  3. package/dist/affected.d.ts +28 -0
  4. package/dist/affected.js +250 -0
  5. package/dist/changes.d.ts +27 -0
  6. package/dist/changes.js +470 -0
  7. package/dist/check.d.ts +15 -0
  8. package/dist/check.js +198 -0
  9. package/dist/generate-ontology.d.ts +37 -0
  10. package/dist/generate-ontology.js +293 -0
  11. package/dist/generate-workflows.d.ts +12 -0
  12. package/dist/generate-workflows.js +102 -0
  13. package/dist/imports/nist-sp-800-53.import.d.ts +33 -0
  14. package/dist/imports/nist-sp-800-53.import.js +34 -0
  15. package/dist/imports/schema-org.import.d.ts +33 -0
  16. package/dist/imports/schema-org.import.js +31 -0
  17. package/dist/install-bun.d.ts +1 -0
  18. package/dist/install-bun.js +58 -0
  19. package/dist/libraries.d.ts +79 -0
  20. package/dist/libraries.js +386 -0
  21. package/dist/mod.d.ts +16 -0
  22. package/dist/mod.js +16 -0
  23. package/dist/newer.d.ts +27 -0
  24. package/dist/newer.js +147 -0
  25. package/dist/oscal-register.d.ts +65 -0
  26. package/dist/oscal-register.js +344 -0
  27. package/dist/pack-library.d.ts +47 -0
  28. package/dist/pack-library.js +498 -0
  29. package/dist/pins.d.ts +15 -0
  30. package/dist/pins.js +29 -0
  31. package/dist/publish-ontology.d.ts +160 -0
  32. package/dist/publish-ontology.js +227 -0
  33. package/dist/versions.d.ts +26 -0
  34. package/dist/versions.js +556 -0
  35. package/dist/workflows/definitions.d.ts +65 -0
  36. package/dist/workflows/definitions.js +619 -0
  37. package/dist/workflows/mod.d.ts +10 -0
  38. package/dist/workflows/mod.js +10 -0
  39. package/dist/workflows/model.d.ts +143 -0
  40. package/dist/workflows/model.js +81 -0
  41. package/dist/workflows/render.d.ts +9 -0
  42. package/dist/workflows/render.js +179 -0
  43. package/package.json +129 -4
  44. package/src/affected.ts +265 -0
  45. package/src/changes.ts +546 -0
  46. package/src/check.ts +223 -0
  47. package/src/generate-ontology.ts +350 -0
  48. package/src/generate-workflows.ts +103 -0
  49. package/src/imports/nist-sp-800-53.import.ts +36 -0
  50. package/src/imports/schema-org.import.ts +31 -0
  51. package/src/install-bun.ts +53 -0
  52. package/src/libraries.ts +385 -0
  53. package/src/mod.ts +16 -0
  54. package/src/newer.ts +154 -0
  55. package/src/oscal-register.ts +443 -0
  56. package/src/pack-library.ts +522 -0
  57. package/src/pins.ts +30 -0
  58. package/src/publish-ontology.ts +354 -0
  59. package/src/versions.ts +594 -0
  60. package/src/workflows/definitions.ts +855 -0
  61. package/src/workflows/mod.ts +30 -0
  62. package/src/workflows/model.ts +187 -0
  63. package/src/workflows/render.ts +176 -0
@@ -0,0 +1,160 @@
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 { type OntologyFile } from "@intellectual-frontiers/rdf";
14
+ import { type AnySchema, type CodeMember, type Mapping } from "@intellectual-frontiers/mizan/integrations/pure/export";
15
+ type Lang = {
16
+ readonly value: string;
17
+ readonly language: string;
18
+ };
19
+ /** A class or a property as the exporters read it: its IRI and the annotations it carries. */
20
+ type EntityLike = {
21
+ readonly iri: string;
22
+ readonly values: {
23
+ readonly label?: Lang | undefined;
24
+ readonly comment?: Lang | undefined;
25
+ readonly definition?: Lang | undefined;
26
+ readonly subClassOf?: readonly {
27
+ readonly iri: string;
28
+ }[] | undefined;
29
+ readonly domain?: {
30
+ readonly iri: string;
31
+ } | undefined;
32
+ readonly range?: {
33
+ readonly iri: string;
34
+ } | undefined;
35
+ };
36
+ };
37
+ /** A property: an entity with the class it is an individual of (`owl:ObjectProperty` or `owl:DatatypeProperty`). */
38
+ type PropertyLike = EntityLike & {
39
+ readonly class: {
40
+ readonly iri: string;
41
+ };
42
+ };
43
+ /** The record of what a term rests on, as the exporters read it. */
44
+ type TermLike = {
45
+ readonly values: {
46
+ readonly termIri: string;
47
+ readonly basis: {
48
+ readonly iri: string;
49
+ };
50
+ readonly standardTerm?: string | undefined;
51
+ readonly mappingRelation?: Mapping["relation"] | undefined;
52
+ readonly justification?: string | undefined;
53
+ };
54
+ };
55
+ /** The members of a code list as the exporters read them: its keys, with each individual's label and definition. */
56
+ export declare function membersOf(list: Readonly<Record<string, {
57
+ readonly values: {
58
+ readonly label: {
59
+ readonly value: string;
60
+ };
61
+ readonly definition?: {
62
+ readonly value: string;
63
+ } | undefined;
64
+ };
65
+ }>>): readonly CodeMember[];
66
+ /** A code list as `membersOf` reads it. */
67
+ export type CodeListLike = Parameters<typeof membersOf>[0];
68
+ /** 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. */
69
+ export declare function listsOf(prefix: string, lists: readonly (readonly [string, CodeListLike])[]): readonly CodeListPublication[];
70
+ /** One code list of an ontology, with the name its SKOS scheme and its SQL table go by. */
71
+ export type CodeListPublication = {
72
+ readonly name: string;
73
+ readonly table: string;
74
+ readonly members: readonly CodeMember[];
75
+ };
76
+ /** Everything an ontology is published from. */
77
+ export type OntologyPublication = {
78
+ /** The name its files go by: `generated/<name>.auto.ttl`, `generated/<name>-shapes.auto.ttl`, and so on. */
79
+ readonly name: string;
80
+ /** The ontology's namespace IRI (ending in `#`) and the prefix it goes by. */
81
+ readonly ns: {
82
+ readonly prefix: string;
83
+ readonly iri: string;
84
+ };
85
+ /** The namespace of its individuals, which an SSSOM file declares as a prefix too. */
86
+ readonly idNs: {
87
+ readonly prefix: string;
88
+ readonly iri: string;
89
+ };
90
+ /** The prefixes a CURIE is made with in the HTML view, longest namespace first is not required: the first that matches wins. */
91
+ readonly curies: readonly (readonly [string, string])[];
92
+ /** The ontology's files of typed individuals. */
93
+ readonly files: readonly OntologyFile[];
94
+ /** The ontology's own header individual (`owl:Ontology`): its label, description, version information and version IRI. */
95
+ readonly ontology: {
96
+ readonly values: {
97
+ readonly label?: Lang | undefined;
98
+ readonly description?: Lang | undefined;
99
+ readonly versionInfo?: string | undefined;
100
+ readonly versionIri?: {
101
+ readonly iri: string;
102
+ } | undefined;
103
+ };
104
+ };
105
+ readonly classes: readonly EntityLike[];
106
+ readonly properties: readonly PropertyLike[];
107
+ /** 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. */
108
+ readonly terms: readonly TermLike[];
109
+ /** The shapes and schemas: the class schemas of the data the ontology holds. */
110
+ readonly schemas: readonly AnySchema[];
111
+ readonly lists: readonly CodeListPublication[];
112
+ /** Where it is generated from, for the header comment: `commons/ontology/<name>/*.ts`. */
113
+ readonly source: string;
114
+ /** The command that writes the files again. */
115
+ readonly run: string;
116
+ /** The IRI of the SHACL shapes and of the JSON Schema, the SSSOM set and the prefix the shapes use. */
117
+ readonly shapes: {
118
+ readonly prefix: string;
119
+ readonly iri: string;
120
+ };
121
+ readonly schemasIri: string;
122
+ readonly sssomSetId: string;
123
+ /** Prefix to namespace pairs the SSSOM file declares besides the ontology's own. */
124
+ readonly sssomCuries: Readonly<Record<string, string>>;
125
+ /** The title of the HTML view. */
126
+ readonly viewTitle: string;
127
+ /** The license of the files: an IRI. */
128
+ readonly license: string;
129
+ };
130
+ /** The default license of what Intellectual Frontiers publishes as ontologies: CC0. */
131
+ export declare const CC0 = "https://creativecommons.org/publicdomain/zero/1.0/";
132
+ /** The path of a generated file of an ontology, from commons' folder: `generated/<name><suffix>`. */
133
+ export declare function pathOf(name: string, suffix: string): string;
134
+ /** The files of an ontology, with their title, media type and what they conform to: its DCAT distributions (0019-mizan-integrations FR-018). */
135
+ export declare function distributionsOf(name: string, title: string): readonly {
136
+ readonly file: string;
137
+ readonly title: string;
138
+ readonly mediaType: string;
139
+ readonly conformsTo?: string;
140
+ }[];
141
+ /** 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. */
142
+ export declare function digestOf(of: readonly OntologyFile[]): Promise<string>;
143
+ /** The ontology as canonical Turtle: every file's individuals, with every file's prefixes. */
144
+ export declare function turtleOf(of: readonly OntologyFile[], run: string, digest: string, source: string): string;
145
+ /** The text of an exporter's result, or a thrown sentence naming what the ontology states that the form cannot hold. */
146
+ export declare class ExportRefused extends Error {
147
+ /** The refusal, told as a sentence. */
148
+ constructor(message: string);
149
+ }
150
+ /** The value of an exporter's result, or a refusal naming what the ontology states that the form cannot hold. */
151
+ export declare function textOf(r: {
152
+ readonly kind: "ok";
153
+ readonly value: string;
154
+ } | {
155
+ readonly kind: "err";
156
+ readonly error: readonly string[];
157
+ }, what: string, name: string): string;
158
+ /** Every file of an ontology (but its DCAT catalog entry, which `generate-ontology.ts` writes for them all), by its path from commons' folder. */
159
+ export declare function publishedFiles(p: OntologyPublication): Promise<ReadonlyMap<string, string>>;
160
+ export {};
@@ -0,0 +1,227 @@
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, owl, triplesOf, turtle } from "@intellectual-frontiers/rdf";
14
+ import { exportJsonSchemaDefs, exportShacl, exportSkos, exportSqlCodeList, exportSssom, } from "@intellectual-frontiers/mizan/integrations/pure/export";
15
+ import { exportHtmlView } from "@intellectual-frontiers/mizan/integrations/pure/export-html";
16
+ import { exportOwl } from "@intellectual-frontiers/mizan/integrations/pure/export-owl";
17
+ import { describeFinding } from "@intellectual-frontiers/mizan/integrations/pure/types";
18
+ import { exportRdfXml } from "@intellectual-frontiers/mizan/integrations/pure/export-rdfxml";
19
+ /** The members of a code list as the exporters read them: its keys, with each individual's label and definition. */
20
+ export function membersOf(list) {
21
+ return Object.entries(list).map(([code, i]) => ({
22
+ code,
23
+ label: i.values.label.value,
24
+ ...(i.values.definition === undefined ? {} : { definition: i.values.definition.value }),
25
+ }));
26
+ }
27
+ /** 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. */
28
+ export function listsOf(prefix, lists) {
29
+ return lists.map(([name, list]) => ({
30
+ name,
31
+ table: `${prefix}_${name.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase()}`,
32
+ members: membersOf(list),
33
+ }));
34
+ }
35
+ /** The default license of what Intellectual Frontiers publishes as ontologies: CC0. */
36
+ export const CC0 = "https://creativecommons.org/publicdomain/zero/1.0/";
37
+ /** The path of a generated file of an ontology, from commons' folder: `generated/<name><suffix>`. */
38
+ export function pathOf(name, suffix) {
39
+ return `generated/${name}${suffix}`;
40
+ }
41
+ /** The files of an ontology, with their title, media type and what they conform to: its DCAT distributions (0019-mizan-integrations FR-018). */
42
+ export function distributionsOf(name, title) {
43
+ return [
44
+ { file: pathOf(name, ".auto.ttl"), title: `${title} ontology, Turtle`, mediaType: "text/turtle" },
45
+ { file: pathOf(name, ".auto.rdf"), title: `${title} ontology, RDF/XML`, mediaType: "application/rdf+xml" },
46
+ { file: pathOf(name, ".auto.ofn"), title: `${title} ontology, OWL 2 functional syntax`, mediaType: "text/owl-functional" },
47
+ {
48
+ file: pathOf(name, "-shapes.auto.ttl"),
49
+ title: `${title} SHACL shapes`,
50
+ mediaType: "text/turtle",
51
+ conformsTo: "https://www.w3.org/TR/shacl/",
52
+ },
53
+ {
54
+ file: pathOf(name, "-schemas.auto.json"),
55
+ title: `${title} JSON Schema`,
56
+ mediaType: "application/schema+json",
57
+ conformsTo: "https://json-schema.org/draft/2020-12/schema",
58
+ },
59
+ {
60
+ file: pathOf(name, "-code-lists.auto.skos.ttl"),
61
+ title: `${title} code lists, SKOS`,
62
+ mediaType: "text/turtle",
63
+ conformsTo: "https://www.w3.org/TR/skos-reference/",
64
+ },
65
+ { file: pathOf(name, "-code-lists.auto.sql"), title: `${title} code lists, SQL`, mediaType: "application/sql" },
66
+ {
67
+ file: pathOf(name, "-mappings.auto.sssom.tsv"),
68
+ title: `${title} mappings to standards, SSSOM`,
69
+ mediaType: "text/tab-separated-values",
70
+ conformsTo: "https://mapping-commons.github.io/sssom/spec/",
71
+ },
72
+ { file: pathOf(name, "-ontology.auto.html"), title: `${title} ontology, HTML view`, mediaType: "text/html" },
73
+ ];
74
+ }
75
+ /** An IRI as a CURIE where a prefix of the publication shortens it. */
76
+ function compactWith(p, iri) {
77
+ for (const [prefix, ns] of p.curies)
78
+ if (iri.startsWith(ns))
79
+ return `${prefix}:${iri.slice(ns.length)}`;
80
+ return iri;
81
+ }
82
+ /** 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. */
83
+ export async function digestOf(of) {
84
+ const bytes = new TextEncoder().encode(nTriples(triplesOf(of.flatMap((f) => f.individuals))));
85
+ return [...new Uint8Array(await crypto.subtle.digest("SHA-256", bytes))].map((b) => b.toString(16).padStart(2, "0")).join("");
86
+ }
87
+ /** The ontology as canonical Turtle: every file's individuals, with every file's prefixes. */
88
+ export function turtleOf(of, run, digest, source) {
89
+ const prefixes = new Map(of.flatMap((f) => f.prefixes).map((p) => [p.prefix, p]));
90
+ return turtle({
91
+ comments: [`AUTO-GENERATED by ${run} from ${source}. Do not edit: change the ontology.`, `source_sha256=${digest}`],
92
+ prefixes: [...prefixes.values()],
93
+ triples: triplesOf(of.flatMap((f) => f.individuals)),
94
+ });
95
+ }
96
+ /** The text of an exporter's result, or a thrown sentence naming what the ontology states that the form cannot hold. */
97
+ export class ExportRefused extends Error {
98
+ /** The refusal, told as a sentence. */
99
+ constructor(message) {
100
+ super(message);
101
+ this.name = "ExportRefused";
102
+ }
103
+ }
104
+ /** The value of an exporter's result, or a refusal naming what the ontology states that the form cannot hold. */
105
+ export function textOf(r, what, name) {
106
+ if (r.kind === "ok")
107
+ return r.value;
108
+ throw new ExportRefused(`the ${name} ontology cannot be written as ${what}: ${r.error.join("; ")}`);
109
+ }
110
+ /** Stops with a sentence naming what an exporter could not hold: a file that would be empty is never written. */
111
+ function refuse(name, what, findings) {
112
+ throw new ExportRefused(`the ${name} ontology cannot be written as ${what}: ${findings.join("; ")}`);
113
+ }
114
+ const owlText = (x) => ({ value: x.value, language: x.language });
115
+ /** The ontology's classes and properties as the OWL writer reads them (0019-mizan-integrations FR-017). */
116
+ function owlOf(p, comments) {
117
+ const o = p.ontology.values;
118
+ const entity = (e) => ({
119
+ ...(e.label === undefined ? {} : { label: owlText(e.label) }),
120
+ ...(e.comment === undefined ? {} : { comment: owlText(e.comment) }),
121
+ ...(e.definition === undefined ? {} : { definition: owlText(e.definition) }),
122
+ });
123
+ return {
124
+ iri: p.ns.iri.replace(/#$/, ""),
125
+ ...(o.versionIri === undefined ? {} : { versionIri: o.versionIri.iri }),
126
+ ...(o.label === undefined ? {} : { label: owlText(o.label) }),
127
+ ...(o.description === undefined ? {} : { description: owlText(o.description) }),
128
+ ...(o.versionInfo === undefined ? {} : { versionInfo: o.versionInfo }),
129
+ title: o.label?.value ?? p.name,
130
+ license: p.license,
131
+ prefixes: p.files.flatMap((f) => f.prefixes).map((x) => ({ prefix: x.prefix, iri: x.iri })),
132
+ classes: p.classes.map((c) => ({ iri: c.iri, ...entity(c.values), subClassOf: (c.values.subClassOf ?? []).map((s) => s.iri) })),
133
+ properties: p.properties.map((x) => ({
134
+ iri: x.iri,
135
+ kind: x.class.iri === owl.ObjectProperty.iri ? "object" : "datatype",
136
+ ...entity(x.values),
137
+ ...(x.values.domain === undefined ? {} : { domain: x.values.domain.iri }),
138
+ ...(x.values.range === undefined ? {} : { range: x.values.range.iri }),
139
+ })),
140
+ comments,
141
+ };
142
+ }
143
+ /** The ontology as the HTML view reads it: its classes, properties, code lists and the basis of every term. */
144
+ function viewOf(p) {
145
+ const text = (x) => (x === undefined ? {} : { definition: x.value });
146
+ const classView = p.classes.map((c) => ({
147
+ curie: compactWith(p, c.iri),
148
+ label: c.values.label?.value ?? "",
149
+ ...text(c.values.definition),
150
+ }));
151
+ const propertyView = p.properties.map((x) => ({
152
+ curie: compactWith(p, x.iri),
153
+ label: compactWith(p, x.iri).replace(new RegExp(`^${p.ns.prefix}:`), ""),
154
+ ...(x.values.domain === undefined ? {} : { domain: compactWith(p, x.values.domain.iri) }),
155
+ ...(x.values.range === undefined ? {} : { range: compactWith(p, x.values.range.iri) }),
156
+ ...text(x.values.definition),
157
+ }));
158
+ const basisView = p.terms.map((t) => ({
159
+ curie: compactWith(p, t.values.termIri),
160
+ basis: t.values.basis.iri.slice(t.values.basis.iri.lastIndexOf("#") + 1).toLowerCase(),
161
+ ...(t.values.standardTerm === undefined ? {} : { standardTerm: compactWith(p, t.values.standardTerm) }),
162
+ ...(t.values.mappingRelation === undefined ? {} : { relation: t.values.mappingRelation }),
163
+ ...(t.values.justification === undefined ? {} : { justification: t.values.justification }),
164
+ }));
165
+ return {
166
+ title: p.viewTitle,
167
+ iri: p.ns.iri.replace(/#$/, ""),
168
+ ...(p.ontology.values.versionIri === undefined ? {} : { versionIri: p.ontology.values.versionIri.iri }),
169
+ classes: classView,
170
+ properties: propertyView,
171
+ codeLists: p.lists.map((l) => ({ name: l.name, members: l.members })),
172
+ terms: basisView,
173
+ };
174
+ }
175
+ /** Every file of an ontology (but its DCAT catalog entry, which `generate-ontology.ts` writes for them all), by its path from commons' folder. */
176
+ export async function publishedFiles(p) {
177
+ const digest = await digestOf(p.files);
178
+ 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}`;
179
+ const skos = p.lists
180
+ .map((l, i) => {
181
+ const text = exportSkos({ schemeIri: `${p.ns.iri}${l.name}Scheme`, label: l.name, conceptBase: p.ns.iri, members: l.members });
182
+ return i === 0 ? text : text.split("\n").slice(2).join("\n");
183
+ })
184
+ .join("\n");
185
+ const sql = p.lists
186
+ .map((l) => {
187
+ const r = exportSqlCodeList(l.table, l.members);
188
+ return r.kind === "ok" ? r.value : "";
189
+ })
190
+ .join("\n");
191
+ const mappings = p.terms.flatMap((t) => t.values.standardTerm === undefined || t.values.mappingRelation === undefined
192
+ ? []
193
+ : [{ subject: t.values.termIri, relation: t.values.mappingRelation, object: t.values.standardTerm }]);
194
+ const sssom = exportSssom({
195
+ setId: p.sssomSetId,
196
+ license: p.license,
197
+ comment: note,
198
+ curies: { [p.ns.prefix]: p.ns.iri, [p.idNs.prefix]: p.idNs.iri, ...p.sssomCuries },
199
+ mappings,
200
+ });
201
+ return new Map([
202
+ [pathOf(p.name, ".auto.ttl"), turtleOf(p.files, p.run, digest, p.source)],
203
+ [
204
+ pathOf(p.name, "-ontology.auto.html"),
205
+ exportHtmlView(viewOf(p), `AUTO-GENERATED by ${p.run} from ${p.source} (commons 0019-mizan-integrations FR-010). Do not edit. source_sha256=${digest}`),
206
+ ],
207
+ [
208
+ pathOf(p.name, "-mappings.auto.sssom.tsv"),
209
+ sssom.kind === "ok"
210
+ ? sssom.value
211
+ : refuse(p.name, "SSSOM", sssom.error.map((f) => describeFinding(f))),
212
+ ],
213
+ [pathOf(p.name, "-shapes.auto.ttl"), `# ${note}\n\n${exportShacl(p.schemas, p.shapes)}`],
214
+ [pathOf(p.name, "-schemas.auto.json"), exportJsonSchemaDefs(p.schemas, p.schemasIri, note)],
215
+ [pathOf(p.name, "-code-lists.auto.skos.ttl"), `# ${note}\n\n${skos}`],
216
+ [pathOf(p.name, "-code-lists.auto.sql"), `-- ${note}\n\n${sql}`],
217
+ [
218
+ pathOf(p.name, ".auto.rdf"),
219
+ textOf(exportRdfXml({
220
+ comments: [note],
221
+ prefixes: [...new Map(p.files.flatMap((f) => f.prefixes).map((x) => [x.prefix, x])).values()],
222
+ triples: triplesOf(p.files.flatMap((f) => f.individuals)),
223
+ }), "RDF/XML", p.name),
224
+ ],
225
+ [pathOf(p.name, ".auto.ofn"), textOf(exportOwl(owlOf(p, [note])), "OWL", p.name)],
226
+ ]);
227
+ }
@@ -0,0 +1,26 @@
1
+ import { type VersionsFinding } from "@intellectual-frontiers/mizan/versions/rules";
2
+ /** What the command is given besides its arguments: where it writes and the clock (the one place the tool reads it, for the day a snapshot or an approval is made). */
3
+ export type Deps = {
4
+ readonly out?: (text: string) => void;
5
+ readonly err?: (text: string) => void;
6
+ readonly now?: () => Date;
7
+ };
8
+ /** The commands, in the order the help lists them. */
9
+ export declare const COMMANDS: readonly ["check", "bump", "tag", "notes", "cite", "ledger"];
10
+ /** What `checkVersions` found, or why it could not run (`not_run`, FR-031): the findings, the number of works judged and what they were judged against. */
11
+ export type VersionsCheck = {
12
+ readonly kind: "judged";
13
+ readonly findings: readonly VersionsFinding[];
14
+ readonly works: number;
15
+ readonly from: string;
16
+ } | {
17
+ readonly kind: "not_run";
18
+ readonly reason: string;
19
+ };
20
+ /**
21
+ * The version check as data (0026-works-versioning FR-022, FR-040): every work of the repository at `repo` judged against the merge base with `rev` (`origin/main` where not given). It reads only
22
+ * Git, so it runs offline: no host, no network, a base that is any revision the repository holds (a branch, a tag or a commit). A consumer calls this, or `run(["check", "--base", rev, "--repo", repo])`.
23
+ */
24
+ export declare function checkVersions(repo: string, rev?: string): Promise<VersionsCheck>;
25
+ /** Run the command: the exit status (0, 1 findings, 2 usage, 3 the environment cannot do it). */
26
+ export declare function run(argv: readonly string[], deps?: Deps): Promise<number>;