@ontology-kit/okb 0.0.0-stage → 0.1.0-bootstrap.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 +9 -0
- package/README.md +26 -2
- package/bin/okb.js +8 -0
- package/dist/checks.d.ts +33 -0
- package/dist/checks.js +966 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +718 -0
- package/dist/clidocs.d.ts +6 -0
- package/dist/clidocs.js +90 -0
- package/dist/clock.d.ts +2 -0
- package/dist/clock.js +16 -0
- package/dist/commands.d.ts +28 -0
- package/dist/commands.js +622 -0
- package/dist/export.d.ts +54 -0
- package/dist/export.js +290 -0
- package/dist/families.d.ts +20 -0
- package/dist/families.js +51 -0
- package/dist/help.d.ts +2 -0
- package/dist/help.js +57 -0
- package/dist/markdown.d.ts +60 -0
- package/dist/markdown.js +310 -0
- package/dist/metakb.d.ts +164 -0
- package/dist/metakb.js +130 -0
- package/dist/naming.d.ts +20 -0
- package/dist/naming.js +140 -0
- package/dist/ops/admin.d.ts +16 -0
- package/dist/ops/admin.js +119 -0
- package/dist/ops/classes.d.ts +21 -0
- package/dist/ops/classes.js +105 -0
- package/dist/ops/common.d.ts +6 -0
- package/dist/ops/common.js +4 -0
- package/dist/ops/instances.d.ts +8 -0
- package/dist/ops/instances.js +70 -0
- package/dist/ops/links.d.ts +9 -0
- package/dist/ops/links.js +85 -0
- package/dist/ops/naming.d.ts +4 -0
- package/dist/ops/naming.js +70 -0
- package/dist/ops/scope.d.ts +29 -0
- package/dist/ops/scope.js +124 -0
- package/dist/ops/slots.d.ts +31 -0
- package/dist/ops/slots.js +186 -0
- package/dist/ops/values.d.ts +20 -0
- package/dist/ops/values.js +151 -0
- package/dist/ops.d.ts +14 -0
- package/dist/ops.js +14 -0
- package/dist/provenance.d.ts +53 -0
- package/dist/provenance.js +296 -0
- package/dist/quotes.d.ts +14 -0
- package/dist/quotes.js +104 -0
- package/dist/render.d.ts +30 -0
- package/dist/render.js +413 -0
- package/dist/review.d.ts +10 -0
- package/dist/review.js +145 -0
- package/dist/site.d.ts +6 -0
- package/dist/site.js +6 -0
- package/dist/skills.d.ts +52 -0
- package/dist/skills.js +120 -0
- package/dist/status.d.ts +18 -0
- package/dist/status.js +59 -0
- package/dist/types.d.ts +12 -0
- package/dist/types.js +5 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +7 -0
- package/meta-kb/data/edges.json +3172 -0
- package/meta-kb/data/manifest.json +19 -0
- package/meta-kb/data/nodes.json +3546 -0
- package/package.json +71 -3
- package/skills/build-domain-kb-from-docs/SKILL.md +87 -0
- package/skills/ontology-coach/SKILL.md +100 -0
- package/skills/ontology-review/SKILL.md +66 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** Naming conventions, and the checks every new class or slot name goes through. */
|
|
2
|
+
import * as naming from "../naming.js";
|
|
3
|
+
import { OkbError } from "@ontology-kit/format";
|
|
4
|
+
export function setConventions(ont, o) {
|
|
5
|
+
const conv = { ...naming.DEFAULT_CONVENTIONS, ...(ont.conventions ?? {}) };
|
|
6
|
+
if (o.classCase) {
|
|
7
|
+
if (!naming.CLASS_STYLES.includes(o.classCase))
|
|
8
|
+
throw new OkbError(`Class case must be one of: ${naming.CLASS_STYLES.join(", ")}.`);
|
|
9
|
+
conv.classCase = o.classCase;
|
|
10
|
+
}
|
|
11
|
+
if (o.slotCase) {
|
|
12
|
+
if (!naming.SLOT_STYLES.includes(o.slotCase))
|
|
13
|
+
throw new OkbError(`Slot case must be one of: ${naming.SLOT_STYLES.join(", ")}.`);
|
|
14
|
+
conv.slotCase = o.slotCase;
|
|
15
|
+
}
|
|
16
|
+
if (o.instanceCase !== undefined)
|
|
17
|
+
conv.instanceCase = o.instanceCase || null;
|
|
18
|
+
if (o.classNumber) {
|
|
19
|
+
if (!["singular", "plural"].includes(o.classNumber))
|
|
20
|
+
throw new OkbError("--number must be singular or plural.");
|
|
21
|
+
conv.classNumber = o.classNumber;
|
|
22
|
+
}
|
|
23
|
+
if (o.slotAffix) {
|
|
24
|
+
if (!["none", "has-prefix", "of-suffix"].includes(o.slotAffix))
|
|
25
|
+
throw new OkbError("--slot-affix must be none, has-prefix or of-suffix.");
|
|
26
|
+
conv.slotAffix = o.slotAffix;
|
|
27
|
+
}
|
|
28
|
+
conv.source = "chosen";
|
|
29
|
+
ont.meta.conventions = conv;
|
|
30
|
+
const notes = [];
|
|
31
|
+
const bad = [...ont.ofType("Class"), ...ont.ofType("Slot")].filter((n) => n.name && naming.conventionalName(n.name, n.type, conv) !== n.name);
|
|
32
|
+
if (bad.length)
|
|
33
|
+
notes.push(`${bad.length} existing name(s) don't fit this convention yet: ${bad.map((b) => b.name).join(", ")}. Use okb rename.`);
|
|
34
|
+
return notes;
|
|
35
|
+
}
|
|
36
|
+
function ensureConventions(ont, notes) {
|
|
37
|
+
if (!ont.conventions) {
|
|
38
|
+
ont.meta.conventions = { ...naming.DEFAULT_CONVENTIONS, source: "default" };
|
|
39
|
+
notes.push("No naming convention was set, so okb is using its defaults: classes PascalCase and singular, slots camelCase. Confirm them with `okb convention` (or pick your own).");
|
|
40
|
+
}
|
|
41
|
+
return ont.conventions;
|
|
42
|
+
}
|
|
43
|
+
export function checkName(ont, name, kind, force, notes, exclude) {
|
|
44
|
+
const wasSet = Boolean(ont.conventions);
|
|
45
|
+
const conv = ensureConventions(ont, notes);
|
|
46
|
+
const whose = wasSet ? "your naming convention" : "the default naming convention (pick your own with `okb convention`)";
|
|
47
|
+
if (kind === "Class" ? !naming.matches(name, conv.classCase) : naming.applySlotAffix(name, conv) !== name) {
|
|
48
|
+
const want = naming.conventionalName(name, kind, conv);
|
|
49
|
+
const style = kind === "Class" ? conv.classCase : conv.slotCase + (conv.slotAffix !== "none" ? ", " + conv.slotAffix : "");
|
|
50
|
+
const msg = `'${name}' doesn't follow ${whose}: ${style}. Suggested: '${want}'.`;
|
|
51
|
+
if (!force)
|
|
52
|
+
throw new OkbError(`${msg} Re-run with the suggested name, or add --force to keep yours.`);
|
|
53
|
+
notes.push(msg + " Kept as-is because of --force.");
|
|
54
|
+
}
|
|
55
|
+
if (kind === "Class" && naming.isPlural(naming.headWord(name)) !== (conv.classNumber === "plural")) {
|
|
56
|
+
notes.push(`Note: '${name}' looks ${conv.classNumber === "plural" ? "singular" : "plural"}, but class names here are ${conv.classNumber}. If it's a proper name that just ends in 's' (like Sauternes), that's fine: record it with okb decision add ... --waives naming-singular-plural-consistent.`);
|
|
57
|
+
}
|
|
58
|
+
const clash = ont.ofType(kind).find((n) => n.id !== exclude && naming.key(n.name ?? "") === naming.key(name));
|
|
59
|
+
if (clash)
|
|
60
|
+
throw new OkbError(`There is already a ${kind.toLowerCase()} called '${clash.name}' (${clash.id}).`);
|
|
61
|
+
if (kind === "Class") {
|
|
62
|
+
const syn = ont.ofType("Class").find((cl) => cl.id !== exclude && (cl.synonyms ?? []).some((s) => naming.key(s) === naming.key(name)));
|
|
63
|
+
if (syn)
|
|
64
|
+
throw new OkbError(`'${name}' is already listed as a synonym of '${syn.name}'. Synonyms aren't separate classes (Ontology 101 §4.1).`);
|
|
65
|
+
const sg = naming.key(naming.withHead(name, naming.singularize));
|
|
66
|
+
const pair = ont.ofType("Class").find((cl) => cl.id !== exclude && naming.key(naming.withHead(cl.name, naming.singularize)) === sg);
|
|
67
|
+
if (pair)
|
|
68
|
+
notes.push(`Careful: '${name}' and '${pair.name}' look like the singular and plural of the same concept.`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Ontology, type Disposition } from "@ontology-kit/format";
|
|
2
|
+
import { type Notes } from "./common.js";
|
|
3
|
+
export declare function setScope(ont: Ontology, o: {
|
|
4
|
+
name?: string;
|
|
5
|
+
domain?: string;
|
|
6
|
+
purpose?: string;
|
|
7
|
+
users?: string[];
|
|
8
|
+
maintainers?: string[];
|
|
9
|
+
outOfScope?: string[];
|
|
10
|
+
kind?: string;
|
|
11
|
+
}): Notes;
|
|
12
|
+
export declare function addCQ(ont: Ontology, text: string): Notes;
|
|
13
|
+
export declare function linkCQ(ont: Ontology, cqRef: string, refs: string[], unlink?: boolean): Notes;
|
|
14
|
+
/**
|
|
15
|
+
* Once a question is answered, suggest its family (rule scope-cq-families): the same
|
|
16
|
+
* question about similar things, and more about the same subject. One line, and
|
|
17
|
+
* only after something is built, so nobody has to list every question up front.
|
|
18
|
+
*/
|
|
19
|
+
export declare function familyTip(ont: Ontology, cqId: string): string;
|
|
20
|
+
export declare function addTerms(ont: Ontology, terms: string[], note?: string): Notes;
|
|
21
|
+
export declare function setTerm(ont: Ontology, ref: string, as: string, nodeRef?: string, note?: string): Notes;
|
|
22
|
+
export declare function addReuse(ont: Ontology, o: {
|
|
23
|
+
name: string;
|
|
24
|
+
url?: string;
|
|
25
|
+
decision: string;
|
|
26
|
+
notes?: string;
|
|
27
|
+
}): Notes;
|
|
28
|
+
export declare function reuseNone(ont: Ontology, why: string): Notes;
|
|
29
|
+
export declare function linkTermIfAny(ont: Ontology, name: string, nodeId: string, as: Disposition): void;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/** Step 1 to 3: scope, competency questions, reuse, and the brainstormed term list. */
|
|
2
|
+
import * as naming from "../naming.js";
|
|
3
|
+
import { questionFamilies } from "../families.js";
|
|
4
|
+
import { OkbError, DISPOSITIONS } from "@ontology-kit/format";
|
|
5
|
+
import { isOneOf } from "../types.js";
|
|
6
|
+
import { splitList as list } from "./common.js";
|
|
7
|
+
import { addDecision } from "./admin.js";
|
|
8
|
+
export function setScope(ont, o) {
|
|
9
|
+
const m = ont.meta;
|
|
10
|
+
if (o.name) {
|
|
11
|
+
m.name = o.name;
|
|
12
|
+
ont.manifest.name = o.name;
|
|
13
|
+
}
|
|
14
|
+
if (o.domain !== undefined)
|
|
15
|
+
m.domain = o.domain;
|
|
16
|
+
if (o.purpose !== undefined)
|
|
17
|
+
m.purpose = o.purpose;
|
|
18
|
+
if (o.users?.length)
|
|
19
|
+
m.users = list(o.users);
|
|
20
|
+
if (o.maintainers?.length)
|
|
21
|
+
m.maintainers = list(o.maintainers);
|
|
22
|
+
if (o.outOfScope?.length)
|
|
23
|
+
m.outOfScope = [...new Set([...(m.outOfScope ?? []), ...o.outOfScope])];
|
|
24
|
+
if (o.kind) {
|
|
25
|
+
if (!isOneOf(["application", "terminological"], o.kind))
|
|
26
|
+
throw new OkbError("--kind must be 'application' or 'terminological'.");
|
|
27
|
+
m.kind = o.kind;
|
|
28
|
+
}
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
export function addCQ(ont, text) {
|
|
32
|
+
const id = ont.newId("CompetencyQuestion");
|
|
33
|
+
ont.addNode({ type: "CompetencyQuestion", id, text, status: "draft" });
|
|
34
|
+
const notes = [`Added ${id}.`];
|
|
35
|
+
if (!text.trim().endsWith("?"))
|
|
36
|
+
notes.push("Tip: phrase competency questions as actual questions.");
|
|
37
|
+
return notes;
|
|
38
|
+
}
|
|
39
|
+
export function linkCQ(ont, cqRef, refs, unlink = false) {
|
|
40
|
+
const q = ont.find(cqRef, "CompetencyQuestion");
|
|
41
|
+
const notes = [];
|
|
42
|
+
for (const r of refs) {
|
|
43
|
+
const n = ont.find(r, ["Class", "Slot", "Instance"]);
|
|
44
|
+
if (unlink)
|
|
45
|
+
ont.removeEdges((e) => e.from === q.id && e.type === "NEEDS" && e.to === n.id);
|
|
46
|
+
else
|
|
47
|
+
ont.addEdge(q.id, "NEEDS", n.id);
|
|
48
|
+
notes.push(`${unlink ? "Unlinked" : "Linked"} ${q.id} ${unlink ? "from" : "→"} ${n.name} (${n.type}).`);
|
|
49
|
+
}
|
|
50
|
+
if (!unlink)
|
|
51
|
+
notes.push(familyTip(ont, q.id));
|
|
52
|
+
return notes;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Once a question is answered, suggest its family (rule scope-cq-families): the same
|
|
56
|
+
* question about similar things, and more about the same subject. One line, and
|
|
57
|
+
* only after something is built, so nobody has to list every question up front.
|
|
58
|
+
*/
|
|
59
|
+
export function familyTip(ont, cqId) {
|
|
60
|
+
// Two subjects at most keeps it to one readable line; okb review lists them all.
|
|
61
|
+
const parts = questionFamilies(ont, cqId).slice(0, 2).map((f) => {
|
|
62
|
+
const same = f.sameQuestionAbout.length ? `the same question about ${f.sameQuestionAbout.join(", ")}` : "";
|
|
63
|
+
const more = f.moreAbout.length ? `more about ${f.subject} (${f.moreAbout.join(", ")})` : "";
|
|
64
|
+
return [same, more].filter(Boolean).join(", or ");
|
|
65
|
+
});
|
|
66
|
+
const ideas = parts.length ? ` Would you also ask ${parts.join("; ")}?` : "";
|
|
67
|
+
return `Tip: ${cqId} is one example of a family of questions.${ideas} Add the ones you want (okb cq add "..."), note the rest as out of scope (okb scope --out-of-scope "..."), or keep it narrow.`;
|
|
68
|
+
}
|
|
69
|
+
export function addTerms(ont, terms, note) {
|
|
70
|
+
const notes = [];
|
|
71
|
+
for (const t of terms.map((x) => x.trim()).filter(Boolean)) {
|
|
72
|
+
if (ont.ofType("Term").some((n) => naming.key(n.text) === naming.key(t))) {
|
|
73
|
+
notes.push(`'${t}' is already on the list.`);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
ont.addNode({ type: "Term", id: ont.newId("Term", t), text: t, disposition: "undecided", ...(note ? { note } : {}) });
|
|
77
|
+
}
|
|
78
|
+
notes.push(`${ont.ofType("Term").length} term(s) on the list.`);
|
|
79
|
+
return notes;
|
|
80
|
+
}
|
|
81
|
+
export function setTerm(ont, ref, as, nodeRef, note) {
|
|
82
|
+
const t = ont.find(ref, "Term");
|
|
83
|
+
if (!isOneOf(DISPOSITIONS, as))
|
|
84
|
+
throw new OkbError(`--as must be one of: ${DISPOSITIONS.join(", ")}.`);
|
|
85
|
+
t.disposition = as;
|
|
86
|
+
if (note)
|
|
87
|
+
t.note = note;
|
|
88
|
+
ont.removeEdges((e) => e.from === t.id && e.type === "BECAME");
|
|
89
|
+
const notes = [`'${t.text}' → ${as}.`];
|
|
90
|
+
const typeFor = { class: ["Class"], slot: ["Slot"], instance: ["Instance"], value: ["Slot"], synonym: ["Class"] };
|
|
91
|
+
if (nodeRef) {
|
|
92
|
+
const n = ont.find(nodeRef, typeFor[as] ?? ["Class", "Slot", "Instance"]);
|
|
93
|
+
ont.addEdge(t.id, "BECAME", n.id);
|
|
94
|
+
notes.push(`Linked to ${n.type} '${n.name}'.`);
|
|
95
|
+
}
|
|
96
|
+
else if (typeFor[as]) {
|
|
97
|
+
const guess = ont.find(t.text, typeFor[as], false);
|
|
98
|
+
if (guess) {
|
|
99
|
+
ont.addEdge(t.id, "BECAME", guess.id);
|
|
100
|
+
notes.push(`Linked to ${guess.type} '${guess.name}'.`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return notes;
|
|
104
|
+
}
|
|
105
|
+
export function addReuse(ont, o) {
|
|
106
|
+
const decisions = ["reuse", "adapt", "reference", "rejected"];
|
|
107
|
+
if (!isOneOf(decisions, o.decision))
|
|
108
|
+
throw new OkbError(`--decision must be one of: ${decisions.join(", ")}.`);
|
|
109
|
+
ont.addNode({ type: "ReusedOntology", id: ont.newId("ReusedOntology", o.name), name: o.name, url: o.url, decision: o.decision, notes: o.notes });
|
|
110
|
+
ont.meta.reuseReviewed = true;
|
|
111
|
+
return [`Recorded '${o.name}' (${o.decision}).`];
|
|
112
|
+
}
|
|
113
|
+
export function reuseNone(ont, why) {
|
|
114
|
+
ont.meta.reuseReviewed = true;
|
|
115
|
+
addDecision(ont, { title: "No existing ontology reused", decision: "Build from scratch.", rationale: why, about: ["ontology"] });
|
|
116
|
+
return ["Recorded that no existing ontology was reused, with your reason as a design decision."];
|
|
117
|
+
}
|
|
118
|
+
export function linkTermIfAny(ont, name, nodeId, as) {
|
|
119
|
+
const t = ont.ofType("Term").find((x) => naming.key(naming.withHead(x.text, naming.singularize)) === naming.key(naming.withHead(name, naming.singularize)));
|
|
120
|
+
if (t && (!t.disposition || t.disposition === "undecided")) {
|
|
121
|
+
t.disposition = as;
|
|
122
|
+
ont.addEdge(t.id, "BECAME", nodeId);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Ontology, type LiteralType } from "@ontology-kit/format";
|
|
2
|
+
import { type Notes } from "./common.js";
|
|
3
|
+
export interface SlotOpts {
|
|
4
|
+
on?: string[];
|
|
5
|
+
off?: string[];
|
|
6
|
+
type?: string;
|
|
7
|
+
values?: string[];
|
|
8
|
+
range?: string[];
|
|
9
|
+
addRange?: string[];
|
|
10
|
+
removeRange?: string[];
|
|
11
|
+
card?: string;
|
|
12
|
+
min?: number;
|
|
13
|
+
max?: number;
|
|
14
|
+
default?: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
force?: boolean;
|
|
17
|
+
/** Apply the slot to every Rule (or stop doing so). */
|
|
18
|
+
onRules?: boolean;
|
|
19
|
+
offRules?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare function addSlot(ont: Ontology, name: string, o: SlotOpts): Notes;
|
|
22
|
+
export declare function updateSlot(ont: Ontology, ref: string, o: SlotOpts, creating?: boolean): Notes;
|
|
23
|
+
export declare function inverse(ont: Ontology, a: string, b: string): Notes;
|
|
24
|
+
export declare const EDGE_VALUE_TYPES: LiteralType[];
|
|
25
|
+
export declare function declareEdgeProperty(ont: Ontology, relRef: string, name: string, o: {
|
|
26
|
+
type?: string;
|
|
27
|
+
values?: string[];
|
|
28
|
+
required?: boolean;
|
|
29
|
+
description?: string;
|
|
30
|
+
remove?: boolean;
|
|
31
|
+
}): Notes;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/** Slots (properties and relationships), their facets, inverses and edge-property declarations. */
|
|
2
|
+
import * as naming from "../naming.js";
|
|
3
|
+
import { OkbError, isRelationship, CARDINALITIES, VALUE_TYPES } from "@ontology-kit/format";
|
|
4
|
+
import { isOneOf } from "../types.js";
|
|
5
|
+
import { splitList as list } from "./common.js";
|
|
6
|
+
import { checkName } from "./naming.js";
|
|
7
|
+
import { linkTermIfAny } from "./scope.js";
|
|
8
|
+
import { coerce } from "./values.js";
|
|
9
|
+
export function addSlot(ont, name, o) {
|
|
10
|
+
const notes = [];
|
|
11
|
+
checkName(ont, name, "Slot", o.force, notes);
|
|
12
|
+
if (!o.type)
|
|
13
|
+
throw new OkbError(`Say what kind of value ${name} holds with --type (${VALUE_TYPES.join(", ")}). Not sure? okb explain "value type".`);
|
|
14
|
+
const id = ont.newId("Slot", name);
|
|
15
|
+
ont.addNode({ type: "Slot", id, name });
|
|
16
|
+
try {
|
|
17
|
+
notes.push(...updateSlot(ont, id, o, true));
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
ont.removeNode(id);
|
|
21
|
+
throw e;
|
|
22
|
+
}
|
|
23
|
+
const added = ont.require(id, "Slot");
|
|
24
|
+
notes.unshift(added.valueType === "Instance"
|
|
25
|
+
? `Added relationship ${name}: (${o.on?.join("|") || "?"})-[:${added.relType}]->(${ont.range(id).map((r) => ont.label(r)).join("|") || "?"}).`
|
|
26
|
+
: `Added property ${name}${o.on?.length ? ` on ${o.on.join(", ")}` : ""} (${added.valueType}).`);
|
|
27
|
+
if (!o.on?.length && !added.appliesToRules)
|
|
28
|
+
notes.push(`Attach it to a class: okb slot set ${name} --on <Class> (or to every rule: --on-rules)`);
|
|
29
|
+
if (!o.card)
|
|
30
|
+
notes.push(`Decide how many values it holds: --card single or --card multiple (Step 6).`);
|
|
31
|
+
if (!o.description)
|
|
32
|
+
notes.push(`Add a one-line description: okb slot set ${name} --desc "..."`);
|
|
33
|
+
linkTermIfAny(ont, name, id, "slot");
|
|
34
|
+
return notes;
|
|
35
|
+
}
|
|
36
|
+
export function updateSlot(ont, ref, o, creating = false) {
|
|
37
|
+
const s = ont.find(ref, "Slot");
|
|
38
|
+
const notes = [];
|
|
39
|
+
if (o.type) {
|
|
40
|
+
const wanted = o.type.toLowerCase();
|
|
41
|
+
const t = VALUE_TYPES.find((v) => v.toLowerCase() === wanted);
|
|
42
|
+
if (!t)
|
|
43
|
+
throw new OkbError(`--type must be one of ${VALUE_TYPES.join(", ")}.`);
|
|
44
|
+
const wasRel = s.valueType === "Instance";
|
|
45
|
+
s.valueType = t;
|
|
46
|
+
if (t !== "Enumerated")
|
|
47
|
+
delete s.allowedValues;
|
|
48
|
+
if (t !== "Instance") {
|
|
49
|
+
ont.removeEdges((e) => e.from === s.id && e.type === "RANGE");
|
|
50
|
+
if (wasRel) {
|
|
51
|
+
const dropped = ont.rel.becomeProperty(s);
|
|
52
|
+
if (dropped.links)
|
|
53
|
+
notes.push(`Removed ${dropped.links} ${dropped.type} link(s): ${s.name} no longer links to other things.`);
|
|
54
|
+
}
|
|
55
|
+
delete s.relType;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
if (s.appliesToRules)
|
|
59
|
+
throw new OkbError(`${s.name} applies to rules, and a rule's qualifiers must be properties. Run okb slot set ${s.name} --off-rules first.`);
|
|
60
|
+
ont.rel.becomeRelationship(s);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (o.values?.length) {
|
|
64
|
+
if (s.valueType !== "Enumerated")
|
|
65
|
+
throw new OkbError("--values only applies to Enumerated slots (use --type Enumerated).");
|
|
66
|
+
s.allowedValues = list(o.values);
|
|
67
|
+
}
|
|
68
|
+
const setRange = (refs, replace) => {
|
|
69
|
+
if (s.valueType !== "Instance")
|
|
70
|
+
throw new OkbError("A range only applies to Instance slots (use --type Instance).");
|
|
71
|
+
if (replace)
|
|
72
|
+
ont.removeEdges((e) => e.from === s.id && e.type === "RANGE");
|
|
73
|
+
for (const r of refs)
|
|
74
|
+
ont.addEdge(s.id, "RANGE", ont.find(r, "Class").id);
|
|
75
|
+
};
|
|
76
|
+
if (o.range?.length)
|
|
77
|
+
setRange(o.range, true);
|
|
78
|
+
if (o.addRange?.length)
|
|
79
|
+
setRange(o.addRange, false);
|
|
80
|
+
for (const r of o.removeRange ?? []) {
|
|
81
|
+
const rc = ont.find(r, "Class");
|
|
82
|
+
ont.removeEdges((e) => e.from === s.id && e.type === "RANGE" && e.to === rc.id);
|
|
83
|
+
}
|
|
84
|
+
if (o.card) {
|
|
85
|
+
if (!isOneOf(CARDINALITIES, o.card))
|
|
86
|
+
throw new OkbError("--card must be single or multiple.");
|
|
87
|
+
s.cardinality = o.card;
|
|
88
|
+
}
|
|
89
|
+
if (o.min !== undefined)
|
|
90
|
+
s.minCardinality = o.min;
|
|
91
|
+
if (o.max !== undefined)
|
|
92
|
+
s.maxCardinality = o.max;
|
|
93
|
+
if (o.description !== undefined)
|
|
94
|
+
s.description = o.description;
|
|
95
|
+
for (const c of o.on ?? []) {
|
|
96
|
+
const cl = ont.find(c, "Class");
|
|
97
|
+
const inherited = ont.domain(s.id).find((d) => ont.ancestors(cl.id).has(d));
|
|
98
|
+
if (inherited)
|
|
99
|
+
notes.push(`Note: ${cl.name} already inherits ${s.name} from ${ont.label(inherited)}; attaching it again is redundant.`);
|
|
100
|
+
ont.addEdge(cl.id, "HAS_SLOT", s.id);
|
|
101
|
+
for (const k of ont.domain(s.id).filter((d) => ont.ancestors(d).has(cl.id))) {
|
|
102
|
+
ont.removeEdges((e) => e.from === k && e.type === "HAS_SLOT" && e.to === s.id);
|
|
103
|
+
notes.push(`Removed ${s.name} from ${ont.label(k)}; it now inherits it from ${cl.name}.`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
for (const c of o.off ?? []) {
|
|
107
|
+
const cl = ont.find(c, "Class");
|
|
108
|
+
ont.removeEdges((e) => e.from === cl.id && e.type === "HAS_SLOT" && e.to === s.id);
|
|
109
|
+
}
|
|
110
|
+
if (o.onRules && o.offRules)
|
|
111
|
+
throw new OkbError("Pick one of --on-rules and --off-rules.");
|
|
112
|
+
if (o.onRules) {
|
|
113
|
+
if (s.valueType === "Instance")
|
|
114
|
+
throw new OkbError(`${s.name} is a relationship. A rule's qualifiers must be properties; link rules with okb rule refines.`);
|
|
115
|
+
s.appliesToRules = true;
|
|
116
|
+
}
|
|
117
|
+
if (o.offRules)
|
|
118
|
+
delete s.appliesToRules;
|
|
119
|
+
if (o.default !== undefined) {
|
|
120
|
+
if (o.default === "")
|
|
121
|
+
delete s.default;
|
|
122
|
+
else
|
|
123
|
+
s.default = coerce(ont, s, o.default);
|
|
124
|
+
}
|
|
125
|
+
const mn = s.minCardinality;
|
|
126
|
+
const mx = s.cardinality === "single" ? Math.min(s.maxCardinality ?? 1, 1) : s.maxCardinality;
|
|
127
|
+
if (typeof mn === "number" && typeof mx === "number" && mn > mx) {
|
|
128
|
+
throw new OkbError(`${s.name}: minimum ${mn} is more than maximum ${mx}${s.cardinality === "single" ? " (single cardinality means at most 1)" : ""}. Nothing could ever satisfy that.`);
|
|
129
|
+
}
|
|
130
|
+
if (s.valueType === "Enumerated" && !s.allowedValues?.length)
|
|
131
|
+
notes.push(`List the allowed values: okb slot set ${s.name} --values a,b,c`);
|
|
132
|
+
if (s.valueType === "Instance" && ont.range(s.id).length === 0)
|
|
133
|
+
notes.push(`Say which class its values come from: okb slot set ${s.name} --range <Class>`);
|
|
134
|
+
if (!creating && !notes.length)
|
|
135
|
+
notes.push(`Updated ${s.name}.`);
|
|
136
|
+
return notes;
|
|
137
|
+
}
|
|
138
|
+
export function inverse(ont, a, b) {
|
|
139
|
+
const sa = ont.find(a, "Slot");
|
|
140
|
+
const sb = ont.find(b, "Slot");
|
|
141
|
+
if (!isRelationship(sa) || !isRelationship(sb))
|
|
142
|
+
throw new OkbError("Only relationships (Instance slots) can be inverses.");
|
|
143
|
+
if (sa.id === sb.id)
|
|
144
|
+
throw new OkbError("A relationship can't be its own inverse here; for symmetric relationships just use one.");
|
|
145
|
+
for (const x of [sa, sb]) {
|
|
146
|
+
if (ont.inverses(x.id).length)
|
|
147
|
+
throw new OkbError(`${x.name} already has an inverse (${ont.inverses(x.id).map((i) => ont.label(i)).join(", ")}).`);
|
|
148
|
+
}
|
|
149
|
+
const moved = ont.rel.declareInverse(sa, sb);
|
|
150
|
+
return [
|
|
151
|
+
`${sa.name} and ${sb.name} are now inverses: one relationship read from both ends.`,
|
|
152
|
+
`Stored as (${ont.domain(sa.id).map((d) => ont.label(d)).join("|") || "?"})-[:${sa.relType}]->(${ont.range(sa.id).map((d) => ont.label(d)).join("|") || "?"}); ${sb.name} follows ${sa.relType} backwards, so nothing is stored twice.${moved ? ` Moved ${moved} existing ${sb.relType} edge(s) onto ${sa.relType}.` : ""}`,
|
|
153
|
+
];
|
|
154
|
+
}
|
|
155
|
+
// A relationship's edges can carry properties that qualify that one link (a
|
|
156
|
+
// condition, a weight, a date) plus a reserved `rule` reference to the Rule node
|
|
157
|
+
// that justifies it. Declaring them gives them facets, just like slots.
|
|
158
|
+
export const EDGE_VALUE_TYPES = ["String", "Integer", "Float", "Number", "Boolean", "Enumerated"];
|
|
159
|
+
const RESERVED_EDGE_KEYS = new Set(["from", "to", "type", "rule"]);
|
|
160
|
+
export function declareEdgeProperty(ont, relRef, name, o) {
|
|
161
|
+
const rel = ont.require(ont.rel.primary(ont.find(relRef, "Slot").id), "Slot");
|
|
162
|
+
if (rel.valueType !== "Instance")
|
|
163
|
+
throw new OkbError(`${rel.name} is a property, not a relationship; only relationships have edge properties.`);
|
|
164
|
+
const decls = (rel.edgeProperties ??= []);
|
|
165
|
+
if (o.remove) {
|
|
166
|
+
rel.edgeProperties = decls.filter((d) => d.name !== name);
|
|
167
|
+
return [`Removed edge property ${name} from ${rel.name}. Existing values stay on the edges until you remove them.`];
|
|
168
|
+
}
|
|
169
|
+
if (RESERVED_EDGE_KEYS.has(name))
|
|
170
|
+
throw new OkbError(`'${name}' is reserved on edges.${name === "rule" ? " Every relationship edge can already point at a Rule with --rule." : ""}`);
|
|
171
|
+
const conv = ont.conventions ?? naming.DEFAULT_CONVENTIONS;
|
|
172
|
+
if (!naming.matches(name, conv.slotCase))
|
|
173
|
+
throw new OkbError(`Edge property names follow the slot convention (${conv.slotCase}). Try '${naming.convert(name, conv.slotCase)}'.`);
|
|
174
|
+
const t = EDGE_VALUE_TYPES.find((v) => v.toLowerCase() === (o.type ?? "String").toLowerCase());
|
|
175
|
+
if (!t)
|
|
176
|
+
throw new OkbError(`--type must be one of ${EDGE_VALUE_TYPES.join(", ")} (edges can't link to other things; use --rule to reference a Rule).`);
|
|
177
|
+
if (t === "Enumerated" && !o.values?.length)
|
|
178
|
+
throw new OkbError("Enumerated edge properties need --values a,b,c.");
|
|
179
|
+
const decl = { name, valueType: t, ...(t === "Enumerated" ? { allowedValues: list(o.values) } : {}), ...(o.required ? { required: true } : {}), ...(o.description ? { description: o.description } : {}) };
|
|
180
|
+
const i = decls.findIndex((d) => d.name === name);
|
|
181
|
+
if (i >= 0)
|
|
182
|
+
decls[i] = decl;
|
|
183
|
+
else
|
|
184
|
+
decls.push(decl);
|
|
185
|
+
return [`${rel.name} edges can now carry ${name} (${t}${decl.required ? ", required" : ""}): (…)-[:${rel.relType} {${name}: …}]->(…)`];
|
|
186
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Ontology, type Literal, type SlotNode } from "@ontology-kit/format";
|
|
2
|
+
import { type Notes } from "./common.js";
|
|
3
|
+
export declare function parseAssignments(args: string[]): {
|
|
4
|
+
slot: string;
|
|
5
|
+
op: "=" | "+=" | "-=";
|
|
6
|
+
raw: string;
|
|
7
|
+
}[];
|
|
8
|
+
export declare function findSlotFor(ont: Ontology, ownerId: string, ref: string): SlotNode;
|
|
9
|
+
/** Parse a command-line value for a slot. A relationship's value is the id of the node it names. */
|
|
10
|
+
export declare function coerce(ont: Ontology, slot: SlotNode, raw: string, allowClass?: boolean): Literal;
|
|
11
|
+
/** Set values on an Instance (literal values / relationship edges) or a Class (fixed values). */
|
|
12
|
+
export declare function assign(ont: Ontology, ownerId: string, assignments: string[], mode?: "value" | "fixed"): Notes;
|
|
13
|
+
export declare function classDefault(ont: Ontology, ref: string, assignments: string[]): Notes;
|
|
14
|
+
export declare function restrict(ont: Ontology, ref: string, slotRef: string, o: {
|
|
15
|
+
values?: string[];
|
|
16
|
+
min?: number;
|
|
17
|
+
max?: number;
|
|
18
|
+
range?: string[];
|
|
19
|
+
clear?: boolean;
|
|
20
|
+
}): Notes;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/** Parsing and storing values: instance values, class fixed values, defaults and restrictions. */
|
|
2
|
+
import * as naming from "../naming.js";
|
|
3
|
+
import { OkbError, literalValues, nameOrText } from "@ontology-kit/format";
|
|
4
|
+
import { an, splitList as list } from "./common.js";
|
|
5
|
+
export function parseAssignments(args) {
|
|
6
|
+
return args.map((a) => {
|
|
7
|
+
const m = a.match(/^([^=+\-][^=]*?)\s*(\+=|-=|=)(.*)$/s);
|
|
8
|
+
if (!m)
|
|
9
|
+
throw new OkbError(`Expected slot=value (or slot+=value / slot-=value), got '${a}'.`);
|
|
10
|
+
return { slot: m[1].trim(), op: m[2], raw: m[3].trim() };
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export function findSlotFor(ont, ownerId, ref) {
|
|
14
|
+
const s = ont.find(ref, "Slot");
|
|
15
|
+
if (!ont.applicableSlots(ownerId).includes(s.id)) {
|
|
16
|
+
const forRule = ont.get(ownerId)?.type === "Rule";
|
|
17
|
+
const where = [...ont.domain(s.id).map((d) => ont.label(d)), ...(s.appliesToRules ? ["Rules"] : [])].join(", ") || "nothing";
|
|
18
|
+
const hint = forRule ? ` Make it apply to rules: okb slot set ${s.name} --on-rules.` : "";
|
|
19
|
+
throw new OkbError(`'${s.name}' isn't a slot of ${ont.label(ownerId)} (attached to: ${where}).${hint}`);
|
|
20
|
+
}
|
|
21
|
+
return s;
|
|
22
|
+
}
|
|
23
|
+
/** Parse a command-line value for a slot. A relationship's value is the id of the node it names. */
|
|
24
|
+
export function coerce(ont, slot, raw, allowClass = false) {
|
|
25
|
+
switch (slot.valueType) {
|
|
26
|
+
case "Integer": {
|
|
27
|
+
if (!/^-?\d+$/.test(raw))
|
|
28
|
+
throw new OkbError(`${slot.name} needs a whole number; got '${raw}'.`);
|
|
29
|
+
return Number(raw);
|
|
30
|
+
}
|
|
31
|
+
case "Float":
|
|
32
|
+
case "Number": {
|
|
33
|
+
const n = Number(raw);
|
|
34
|
+
if (raw === "" || Number.isNaN(n))
|
|
35
|
+
throw new OkbError(`${slot.name} needs a number; got '${raw}'.`);
|
|
36
|
+
return n;
|
|
37
|
+
}
|
|
38
|
+
case "Boolean": {
|
|
39
|
+
const v = raw.toLowerCase();
|
|
40
|
+
if (["true", "yes", "y", "1"].includes(v))
|
|
41
|
+
return true;
|
|
42
|
+
if (["false", "no", "n", "0"].includes(v))
|
|
43
|
+
return false;
|
|
44
|
+
throw new OkbError(`${slot.name} needs true or false; got '${raw}'.`);
|
|
45
|
+
}
|
|
46
|
+
case "Enumerated": {
|
|
47
|
+
const hit = (slot.allowedValues ?? []).find((v) => naming.key(v) === naming.key(raw));
|
|
48
|
+
if (!hit)
|
|
49
|
+
throw new OkbError(`${slot.name} must be one of ${(slot.allowedValues ?? []).join(", ")}; got '${raw}'.`);
|
|
50
|
+
return hit;
|
|
51
|
+
}
|
|
52
|
+
case "Instance":
|
|
53
|
+
return ont.find(raw, allowClass ? ["Instance", "Class"] : ["Instance"]).id;
|
|
54
|
+
default:
|
|
55
|
+
return raw;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function splitValues(slot, raw) {
|
|
59
|
+
return slot.cardinality === "multiple" && slot.valueType !== "String" ? list(raw) : [raw];
|
|
60
|
+
}
|
|
61
|
+
/** Set values on an Instance (literal values / relationship edges) or a Class (fixed values). */
|
|
62
|
+
export function assign(ont, ownerId, assignments, mode = "value") {
|
|
63
|
+
const owner = ont.require(ownerId);
|
|
64
|
+
if (owner.type !== "Instance" && owner.type !== "Class" && owner.type !== "Rule")
|
|
65
|
+
throw new OkbError(`Only instances, classes and rules have values; ${ont.label(ownerId)} is ${an(owner.type)}.`);
|
|
66
|
+
const notes = [];
|
|
67
|
+
const firstFixed = mode === "fixed" && !ont.ofType("Class").some((c) => Object.keys(c.fixedValues ?? {}).length || ont.rel.slotsWithValues(c.id).length);
|
|
68
|
+
for (const a of parseAssignments(assignments)) {
|
|
69
|
+
const slot = findSlotFor(ont, ownerId, a.slot);
|
|
70
|
+
if (owner.type === "Rule" && slot.valueType === "Instance")
|
|
71
|
+
throw new OkbError(`${slot.name} is a relationship, and a rule's qualifiers must be properties. Link rules with okb rule refines.`);
|
|
72
|
+
const vals = a.raw === "" ? [] : splitValues(slot, a.raw).map((r) => coerce(ont, slot, r, owner.type === "Class"));
|
|
73
|
+
if (slot.valueType === "Instance") {
|
|
74
|
+
const current = ont.rel.values(ownerId, slot.id);
|
|
75
|
+
const next = a.op === "=" ? vals : a.op === "+=" ? [...new Set([...current, ...vals])] : current.filter((x) => !vals.includes(x));
|
|
76
|
+
const f = ont.effectiveFacets(slot.id, ont.classContext(ownerId));
|
|
77
|
+
for (const v of next) {
|
|
78
|
+
if (!current.includes(v) && f.range.length) {
|
|
79
|
+
const t = ont.require(v);
|
|
80
|
+
const ok = t.type === "Instance"
|
|
81
|
+
? f.range.some((r) => ont.instanceClasses(v).has(r))
|
|
82
|
+
: owner.type === "Class" && f.range.some((r) => ont.isSub(v, r));
|
|
83
|
+
if (!ok)
|
|
84
|
+
throw new OkbError(`${owner.name}.${slot.name} must point at ${f.range.map((r) => an(ont.label(r))).join(" or ")}; ${nameOrText(t)} is ${an(t.type === "Instance" ? ont.targets(v, "INSTANCE_OF").map((c) => ont.label(c)).join("/") || "instance with no class" : "class outside that range")}.`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
for (const gone of current.filter((x) => !next.includes(x)))
|
|
88
|
+
ont.rel.unlink(ownerId, slot.id, gone);
|
|
89
|
+
for (const v of next)
|
|
90
|
+
ont.rel.link(ownerId, slot.id, v);
|
|
91
|
+
const spec = ont.rel.spec(slot.id);
|
|
92
|
+
const shown = next.map((x) => ont.label(x)).join(", ") || "(nothing)";
|
|
93
|
+
notes.push(`${owner.name}.${slot.name} ${mode === "fixed" ? "fixed to" : "="} ${shown}`);
|
|
94
|
+
if (spec.reverse && next.length) {
|
|
95
|
+
notes.push(` (stored once as ${next.map((x) => `(${ont.label(x)})-[:${spec.type}]->(${owner.name})`).join(", ")}; ${slot.name} reads it backwards)`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
const stored = literalValues(owner);
|
|
100
|
+
const cur = stored[slot.id];
|
|
101
|
+
const curList = cur === undefined ? [] : Array.isArray(cur) ? cur : [cur];
|
|
102
|
+
const next = a.op === "=" ? vals : a.op === "+=" ? [...curList, ...vals] : curList.filter((x) => !vals.includes(x));
|
|
103
|
+
if (slot.cardinality !== "multiple" && next.length > 1)
|
|
104
|
+
throw new OkbError(`${slot.name} holds a single value; got ${next.length}.`);
|
|
105
|
+
if (next.length === 0)
|
|
106
|
+
delete stored[slot.id];
|
|
107
|
+
else
|
|
108
|
+
stored[slot.id] = slot.cardinality === "multiple" ? next : next[0];
|
|
109
|
+
notes.push(`${owner.name}.${slot.name} ${mode === "fixed" ? "fixed to" : "="} ${next.map((v) => JSON.stringify(v)).join(", ") || "(nothing)"}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (firstFixed)
|
|
113
|
+
notes.push("Fixed values apply to every subclass and instance and can't be changed below. For an overridable starting value use `okb class default`.");
|
|
114
|
+
return notes;
|
|
115
|
+
}
|
|
116
|
+
export function classDefault(ont, ref, assignments) {
|
|
117
|
+
const cl = ont.find(ref, "Class");
|
|
118
|
+
const notes = [];
|
|
119
|
+
for (const a of parseAssignments(assignments)) {
|
|
120
|
+
const slot = findSlotFor(ont, cl.id, a.slot);
|
|
121
|
+
cl.defaults ??= {};
|
|
122
|
+
if (a.raw === "")
|
|
123
|
+
delete cl.defaults[slot.id];
|
|
124
|
+
else
|
|
125
|
+
cl.defaults[slot.id] = coerce(ont, slot, a.raw);
|
|
126
|
+
notes.push(`New ${cl.name} instances will start with ${slot.name} = ${JSON.stringify(cl.defaults[slot.id] ?? null)} (can be changed per instance).`);
|
|
127
|
+
}
|
|
128
|
+
return notes;
|
|
129
|
+
}
|
|
130
|
+
export function restrict(ont, ref, slotRef, o) {
|
|
131
|
+
const cl = ont.find(ref, "Class");
|
|
132
|
+
const slot = findSlotFor(ont, cl.id, slotRef);
|
|
133
|
+
cl.facetOverrides ??= {};
|
|
134
|
+
if (o.clear) {
|
|
135
|
+
delete cl.facetOverrides[slot.id];
|
|
136
|
+
return [`Removed ${cl.name}'s restrictions on ${slot.name}.`];
|
|
137
|
+
}
|
|
138
|
+
const ov = (cl.facetOverrides[slot.id] ??= {});
|
|
139
|
+
if (o.values?.length)
|
|
140
|
+
ov.allowedValues = list(o.values).map((v) => coerce(ont, slot, v));
|
|
141
|
+
if (o.min !== undefined)
|
|
142
|
+
ov.minCardinality = o.min;
|
|
143
|
+
if (o.max !== undefined)
|
|
144
|
+
ov.maxCardinality = o.max;
|
|
145
|
+
if (o.range?.length)
|
|
146
|
+
ov.range = o.range.map((r) => ont.find(r, "Class").id);
|
|
147
|
+
const notes = [`${cl.name} now restricts ${slot.name}: ${JSON.stringify(ov)}.`];
|
|
148
|
+
if (o.max === 0)
|
|
149
|
+
notes.push(`Maximum 0 means ${cl.name} never has a ${slot.name} (Ontology 101 §3, Step 6).`);
|
|
150
|
+
return notes;
|
|
151
|
+
}
|
package/dist/ops.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every change to an ontology goes through these functions (the CLI is a thin
|
|
3
|
+
* wrapper). Each returns human-readable notes about what happened, including
|
|
4
|
+
* gentle warnings, so beginners learn as they go. Grouped by reason to change:
|
|
5
|
+
*/
|
|
6
|
+
export * from "./ops/common.js";
|
|
7
|
+
export * from "./ops/naming.js";
|
|
8
|
+
export * from "./ops/scope.js";
|
|
9
|
+
export * from "./ops/classes.js";
|
|
10
|
+
export * from "./ops/slots.js";
|
|
11
|
+
export * from "./ops/values.js";
|
|
12
|
+
export * from "./ops/links.js";
|
|
13
|
+
export * from "./ops/instances.js";
|
|
14
|
+
export * from "./ops/admin.js";
|
package/dist/ops.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every change to an ontology goes through these functions (the CLI is a thin
|
|
3
|
+
* wrapper). Each returns human-readable notes about what happened, including
|
|
4
|
+
* gentle warnings, so beginners learn as they go. Grouped by reason to change:
|
|
5
|
+
*/
|
|
6
|
+
export * from "./ops/common.js";
|
|
7
|
+
export * from "./ops/naming.js"; // naming conventions and name checks
|
|
8
|
+
export * from "./ops/scope.js"; // steps 1-3: scope, questions, reuse, terms
|
|
9
|
+
export * from "./ops/classes.js"; // the class hierarchy
|
|
10
|
+
export * from "./ops/slots.js"; // slots, facets, inverses, edge-property declarations
|
|
11
|
+
export * from "./ops/values.js"; // values, fixed values, defaults, restrictions
|
|
12
|
+
export * from "./ops/links.js"; // single relationship values with edge properties
|
|
13
|
+
export * from "./ops/instances.js"; // instances and their classes
|
|
14
|
+
export * from "./ops/admin.js"; // design decisions, rename, remove
|